| 2371 | } |
| 2372 | |
| 2373 | void runTest() override |
| 2374 | { |
| 2375 | Random r = getRandom(); |
| 2376 | |
| 2377 | { |
| 2378 | beginTest ("Basics"); |
| 2379 | |
| 2380 | expect (String().length() == 0); |
| 2381 | expect (String() == String()); |
| 2382 | String s1, s2 ("abcd"); |
| 2383 | expect (s1.isEmpty() && ! s1.isNotEmpty()); |
| 2384 | expect (s2.isNotEmpty() && ! s2.isEmpty()); |
| 2385 | expect (s2.length() == 4); |
| 2386 | s1 = "abcd"; |
| 2387 | expect (s2 == s1 && s1 == s2); |
| 2388 | expect (s1 == "abcd" && s1 == L"abcd"); |
| 2389 | expect (String ("abcd") == String (L"abcd")); |
| 2390 | expect (String ("abcdefg", 4) == L"abcd"); |
| 2391 | expect (String ("abcdefg", 4) == String (L"abcdefg", 4)); |
| 2392 | expect (String::charToString ('x') == "x"); |
| 2393 | expect (String::charToString (0) == String()); |
| 2394 | expect (s2 + "e" == "abcde" && s2 + 'e' == "abcde"); |
| 2395 | expect (s2 + L'e' == "abcde" && s2 + L"e" == "abcde"); |
| 2396 | expect (s1.equalsIgnoreCase ("abcD") && s1 < "abce" && s1 > "abbb"); |
| 2397 | expect (s1.startsWith ("ab") && s1.startsWith ("abcd") && ! s1.startsWith ("abcde")); |
| 2398 | expect (s1.startsWithIgnoreCase ("aB") && s1.endsWithIgnoreCase ("CD")); |
| 2399 | expect (s1.endsWith ("bcd") && ! s1.endsWith ("aabcd")); |
| 2400 | expectEquals (s1.indexOf (String()), 0); |
| 2401 | expectEquals (s1.indexOfIgnoreCase (String()), 0); |
| 2402 | expect (s1.startsWith (String()) && s1.endsWith (String()) && s1.contains (String())); |
| 2403 | expect (s1.contains ("cd") && s1.contains ("ab") && s1.contains ("abcd")); |
| 2404 | expect (s1.containsChar ('a')); |
| 2405 | expect (! s1.containsChar ('x')); |
| 2406 | expect (! s1.containsChar (0)); |
| 2407 | expect (String ("abc foo bar").containsWholeWord ("abc") && String ("abc foo bar").containsWholeWord ("abc")); |
| 2408 | } |
| 2409 | |
| 2410 | { |
| 2411 | beginTest ("Operations"); |
| 2412 | |
| 2413 | String s ("012345678"); |
| 2414 | expect (s.hashCode() != 0); |
| 2415 | expect (s.hashCode64() != 0); |
| 2416 | expect (s.hashCode() != (s + s).hashCode()); |
| 2417 | expect (s.hashCode64() != (s + s).hashCode64()); |
| 2418 | expect (s.compare (String ("012345678")) == 0); |
| 2419 | expect (s.compare (String ("012345679")) < 0); |
| 2420 | expect (s.compare (String ("012345676")) > 0); |
| 2421 | expect (String("a").compareNatural ("A") == 0); |
| 2422 | expect (String("A").compareNatural ("B") < 0); |
| 2423 | expect (String("a").compareNatural ("B") < 0); |
| 2424 | expect (String("10").compareNatural ("2") > 0); |
| 2425 | expect (String("Abc 10").compareNatural ("aBC 2") > 0); |
| 2426 | expect (String("Abc 1").compareNatural ("aBC 2") < 0); |
| 2427 | expect (s.substring (2, 3) == String::charToString (s[2])); |
| 2428 | expect (s.substring (0, 1) == String::charToString (s[0])); |
| 2429 | expect (s.getLastCharacter() == s [s.length() - 1]); |
| 2430 | expect (String::charToString (s.getLastCharacter()) == s.getLastCharacters (1)); |
nothing calls this directly
no test coverage detected