| 11506 | } |
| 11507 | |
| 11508 | void runTest() |
| 11509 | { |
| 11510 | { |
| 11511 | beginTest ("Basics"); |
| 11512 | |
| 11513 | expect (String().length() == 0); |
| 11514 | expect (String() == String::empty); |
| 11515 | String s1, s2 ("abcd"); |
| 11516 | expect (s1.isEmpty() && ! s1.isNotEmpty()); |
| 11517 | expect (s2.isNotEmpty() && ! s2.isEmpty()); |
| 11518 | expect (s2.length() == 4); |
| 11519 | s1 = "abcd"; |
| 11520 | expect (s2 == s1 && s1 == s2); |
| 11521 | expect (s1 == "abcd" && s1 == L"abcd"); |
| 11522 | expect (String ("abcd") == String (L"abcd")); |
| 11523 | expect (String ("abcdefg", 4) == L"abcd"); |
| 11524 | expect (String ("abcdefg", 4) == String (L"abcdefg", 4)); |
| 11525 | expect (String::charToString ('x') == "x"); |
| 11526 | expect (String::charToString (0) == String::empty); |
| 11527 | expect (s2 + "e" == "abcde" && s2 + 'e' == "abcde"); |
| 11528 | expect (s2 + L'e' == "abcde" && s2 + L"e" == "abcde"); |
| 11529 | expect (s1.equalsIgnoreCase ("abcD") && s1 < "abce" && s1 > "abbb"); |
| 11530 | expect (s1.startsWith ("ab") && s1.startsWith ("abcd") && ! s1.startsWith ("abcde")); |
| 11531 | expect (s1.startsWithIgnoreCase ("aB") && s1.endsWithIgnoreCase ("CD")); |
| 11532 | expect (s1.endsWith ("bcd") && ! s1.endsWith ("aabcd")); |
| 11533 | expectEquals (s1.indexOf (String::empty), 0); |
| 11534 | expectEquals (s1.indexOfIgnoreCase (String::empty), 0); |
| 11535 | expect (s1.startsWith (String::empty) && s1.endsWith (String::empty) && s1.contains (String::empty)); |
| 11536 | expect (s1.contains ("cd") && s1.contains ("ab") && s1.contains ("abcd")); |
| 11537 | expect (s1.containsChar ('a')); |
| 11538 | expect (! s1.containsChar ('x')); |
| 11539 | expect (! s1.containsChar (0)); |
| 11540 | expect (String ("abc foo bar").containsWholeWord ("abc") && String ("abc foo bar").containsWholeWord ("abc")); |
| 11541 | } |
| 11542 | |
| 11543 | { |
| 11544 | beginTest ("Operations"); |
| 11545 | |
| 11546 | String s ("012345678"); |
| 11547 | expect (s.hashCode() != 0); |
| 11548 | expect (s.hashCode64() != 0); |
| 11549 | expect (s.hashCode() != (s + s).hashCode()); |
| 11550 | expect (s.hashCode64() != (s + s).hashCode64()); |
| 11551 | expect (s.compare (String ("012345678")) == 0); |
| 11552 | expect (s.compare (String ("012345679")) < 0); |
| 11553 | expect (s.compare (String ("012345676")) > 0); |
| 11554 | expect (s.substring (2, 3) == String::charToString (s[2])); |
| 11555 | expect (s.substring (0, 1) == String::charToString (s[0])); |
| 11556 | expect (s.getLastCharacter() == s [s.length() - 1]); |
| 11557 | expect (String::charToString (s.getLastCharacter()) == s.getLastCharacters (1)); |
| 11558 | expect (s.substring (0, 3) == L"012"); |
| 11559 | expect (s.substring (0, 100) == s); |
| 11560 | expect (s.substring (-1, 100) == s); |
| 11561 | expect (s.substring (3) == "345678"); |
| 11562 | expect (s.indexOf (L"45") == 4); |
| 11563 | expect (String ("444445").indexOf ("45") == 4); |
| 11564 | expect (String ("444445").lastIndexOfChar ('4') == 4); |
| 11565 | expect (String ("45454545x").lastIndexOf (L"45") == 6); |
nothing calls this directly
no test coverage detected