|
@@ -377,6 +377,62 @@ static void testContainsChar() {
|
|
|
CORE_TEST_FALSE(s.contains(U'ö'));
|
|
|
}
|
|
|
|
|
|
+static void testSubString() {
|
|
|
+ String s;
|
|
|
+ CORE_TEST_FALSE(s.append("01üää3ä"));
|
|
|
+
|
|
|
+ CORE_TEST_STRING("01üää3ä", s.substring(-2));
|
|
|
+ CORE_TEST_STRING("1üää3ä", s.substring(1));
|
|
|
+ CORE_TEST_STRING("üää3ä", s.substring(2));
|
|
|
+ CORE_TEST_STRING("ää3ä", s.substring(3));
|
|
|
+ CORE_TEST_STRING("ä3ä", s.substring(4));
|
|
|
+
|
|
|
+ CORE_TEST_STRING("01üää3ä", s.substring(0, 6));
|
|
|
+ CORE_TEST_STRING("1üää3", s.substring(1, 5));
|
|
|
+ CORE_TEST_STRING("üää", s.substring(2, 4));
|
|
|
+ CORE_TEST_STRING("ä", s.substring(3, 3));
|
|
|
+ CORE_TEST_STRING("", s.substring(4, 2));
|
|
|
+ CORE_TEST_STRING("ä3ä", s.substring(4, 23));
|
|
|
+}
|
|
|
+
|
|
|
+static void testReplace() {
|
|
|
+ String s;
|
|
|
+ CORE_TEST_FALSE(s.append("0äääää1üää3ä"));
|
|
|
+
|
|
|
+ String search;
|
|
|
+ CORE_TEST_FALSE(search.append("ää"));
|
|
|
+
|
|
|
+ String replace;
|
|
|
+ CORE_TEST_FALSE(replace.append("ABCD"));
|
|
|
+
|
|
|
+ CORE_TEST_FALSE(s.replace(search, replace));
|
|
|
+
|
|
|
+ CORE_TEST_STRING("0ABCDABCDä1üABCD3ä", s);
|
|
|
+
|
|
|
+ String s2;
|
|
|
+ CORE_TEST_FALSE(s2.append("0ABCDABCDä1üABCD3ä"));
|
|
|
+ CORE_TEST_EQUAL(s2.hashCode(), s.hashCode());
|
|
|
+}
|
|
|
+
|
|
|
+static void testReplaceChar() {
|
|
|
+ String s;
|
|
|
+ CORE_TEST_FALSE(s.append("01üää3ä"));
|
|
|
+ s.replace(U'0', U'A');
|
|
|
+ CORE_TEST_STRING("A1üää3ä", s);
|
|
|
+ s.replace(U'1', U'B');
|
|
|
+ CORE_TEST_STRING("ABüää3ä", s);
|
|
|
+ s.replace(U'ü', U'C');
|
|
|
+ CORE_TEST_STRING("ABCää3ä", s);
|
|
|
+ s.replace(U'ä', U'D');
|
|
|
+ CORE_TEST_STRING("ABCDD3D", s);
|
|
|
+ s.replace(U'3', U'E');
|
|
|
+ CORE_TEST_STRING("ABCDDED", s);
|
|
|
+
|
|
|
+ String s2;
|
|
|
+ CORE_TEST_FALSE(s2.append("ABCDDED"));
|
|
|
+ CORE_TEST_EQUAL(s2.hashCode(), s.hashCode());
|
|
|
+}
|
|
|
+
|
|
|
void Core::ArrayStringTests::test() {
|
|
|
testEquality();
|
|
|
testUnicodeEquality();
|
|
@@ -411,4 +467,7 @@ void Core::ArrayStringTests::test() {
|
|
|
testContains();
|
|
|
testSearchChar();
|
|
|
testContainsChar();
|
|
|
+ testSubString();
|
|
|
+ testReplace();
|
|
|
+ testReplaceChar();
|
|
|
}
|