|
@@ -437,6 +437,49 @@ static void testCastAppendSelf8() {
|
|
CORE_TEST_STRING("abcabcabcabc", s);
|
|
CORE_TEST_STRING("abcabcabcabc", s);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+static void testCompareWithShorter8() {
|
|
|
|
+ String8 s;
|
|
|
|
+ CORE_TEST_ERROR(s.append("abc"));
|
|
|
|
+ CORE_TEST_FALSE(s == "ab");
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+static void testAppendSignedChar8() {
|
|
|
|
+ const signed char buffer[] = {'a', 'b', 'c', '\0'};
|
|
|
|
+ String8 s;
|
|
|
|
+ CORE_TEST_ERROR(s.append(buffer));
|
|
|
|
+ CORE_TEST_TRUE(s == "abc");
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+static void testAppendUnsignedChar8() {
|
|
|
|
+ const unsigned char buffer[] = {'a', 'b', 'c', '\0'};
|
|
|
|
+ String8 s;
|
|
|
|
+ CORE_TEST_ERROR(s.append(buffer));
|
|
|
|
+ CORE_TEST_TRUE(s == "abc");
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+static void testAppendError8() {
|
|
|
|
+ String8 s;
|
|
|
|
+ CORE_TEST_ERROR(s.append(Core::Error::NONE));
|
|
|
|
+ CORE_TEST_TRUE(s == "NONE");
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+static void testPrint8() {
|
|
|
|
+ String8 s;
|
|
|
|
+ CORE_TEST_ERROR(s.append('\u0040'));
|
|
|
|
+ CORE_TEST_ERROR(s.append(L'\u0400'));
|
|
|
|
+ CORE_TEST_ERROR(s.append(L'\u8000'));
|
|
|
|
+ CORE_TEST_ERROR(s.append(U'\U00100000'));
|
|
|
|
+ CORE_TEST_EQUAL(build("\u0040\u0400\u8000\U00100000"), s);
|
|
|
|
+ CORE_TEST_ERROR(s.print());
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+static void testKeepHash8() {
|
|
|
|
+ String8 s;
|
|
|
|
+ CORE_TEST_ERROR(s.append("a ## test #### #####"));
|
|
|
|
+ CORE_TEST_ERROR(s.format(1, 2, 3, 4, 5, 6, 7, 8, 9));
|
|
|
|
+ CORE_TEST_STRING("a # test ## ##123456789", s);
|
|
|
|
+}
|
|
|
|
+
|
|
static String32 build(const c32* cs) {
|
|
static String32 build(const c32* cs) {
|
|
String32 s;
|
|
String32 s;
|
|
CORE_TEST_ERROR(s.append(cs));
|
|
CORE_TEST_ERROR(s.append(cs));
|
|
@@ -875,6 +918,65 @@ static void testCastAppendSelf32() {
|
|
CORE_TEST_STRING("abcabcabcabc", s);
|
|
CORE_TEST_STRING("abcabcabcabc", s);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+static void testCompareWithShorter32() {
|
|
|
|
+ String32 s;
|
|
|
|
+ CORE_TEST_ERROR(s.append("abc"));
|
|
|
|
+ CORE_TEST_FALSE(s == U"ab");
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+static void testAppendSignedChar32() {
|
|
|
|
+ const signed char buffer[] = {'a', 'b', 'c', '\0'};
|
|
|
|
+ String32 s;
|
|
|
|
+ CORE_TEST_ERROR(s.append(buffer));
|
|
|
|
+ CORE_TEST_TRUE(s == U"abc");
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+static void testAppendUnsignedChar32() {
|
|
|
|
+ const unsigned char buffer[] = {'a', 'b', 'c', '\0'};
|
|
|
|
+ String32 s;
|
|
|
|
+ CORE_TEST_ERROR(s.append(buffer));
|
|
|
|
+ CORE_TEST_TRUE(s == U"abc");
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+static void testAppendError32() {
|
|
|
|
+ String32 s;
|
|
|
|
+ CORE_TEST_ERROR(s.append(Core::Error::NONE));
|
|
|
|
+ CORE_TEST_TRUE(s == U"NONE");
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+static void testPrint32() {
|
|
|
|
+ String32 s;
|
|
|
|
+ CORE_TEST_ERROR(s.append('\u0040'));
|
|
|
|
+ CORE_TEST_ERROR(s.append(L'\u0400'));
|
|
|
|
+ CORE_TEST_ERROR(s.append(L'\u8000'));
|
|
|
|
+ CORE_TEST_ERROR(s.append(U'\U00100000'));
|
|
|
|
+ CORE_TEST_EQUAL(build(U"\u0040\u0400\u8000\U00100000"), s);
|
|
|
|
+ CORE_TEST_ERROR(s.print());
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+static void testVariousUnicode32() {
|
|
|
|
+ const unsigned char buffer[] = {0xC0, 0};
|
|
|
|
+ const unsigned char buffer2[] = {0xE0, 0};
|
|
|
|
+ const unsigned char buffer3[] = {0xE0, 1, 2, 0};
|
|
|
|
+ const unsigned char buffer4[] = {0xF0, 0};
|
|
|
|
+ const unsigned char buffer5[] = {0xF0, 1, 2, 3, 0};
|
|
|
|
+ const unsigned char buffer6[] = {0xFF, 0};
|
|
|
|
+ String32 s;
|
|
|
|
+ CORE_TEST_EQUAL(Core::Error::INVALID_CHAR, s.append(buffer));
|
|
|
|
+ CORE_TEST_EQUAL(Core::Error::INVALID_CHAR, s.append(buffer2));
|
|
|
|
+ CORE_TEST_EQUAL(Core::Error::NONE, s.append(buffer3));
|
|
|
|
+ CORE_TEST_EQUAL(Core::Error::INVALID_CHAR, s.append(buffer4));
|
|
|
|
+ CORE_TEST_EQUAL(Core::Error::NONE, s.append(buffer5));
|
|
|
|
+ CORE_TEST_EQUAL(Core::Error::INVALID_CHAR, s.append(buffer6));
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+static void testKeepHash32() {
|
|
|
|
+ String32 s;
|
|
|
|
+ CORE_TEST_ERROR(s.append("a ## test #### #####"));
|
|
|
|
+ CORE_TEST_ERROR(s.format(1, 2, 3, 4, 5, 6, 7, 8, 9));
|
|
|
|
+ CORE_TEST_STRING("a # test ## ##123456789", s);
|
|
|
|
+}
|
|
|
|
+
|
|
static void testConversion() {
|
|
static void testConversion() {
|
|
const c32* a = U"öüewfde_§$§%$ädsf";
|
|
const c32* a = U"öüewfde_§$§%$ädsf";
|
|
const char* b = "öüewfde_§$§%$ädsf";
|
|
const char* b = "öüewfde_§$§%$ädsf";
|
|
@@ -931,6 +1033,12 @@ void Core::testArrayString() {
|
|
testReplace8();
|
|
testReplace8();
|
|
testReplaceChar8();
|
|
testReplaceChar8();
|
|
testCastAppendSelf8();
|
|
testCastAppendSelf8();
|
|
|
|
+ testCompareWithShorter8();
|
|
|
|
+ testAppendSignedChar8();
|
|
|
|
+ testAppendUnsignedChar8();
|
|
|
|
+ testAppendError8();
|
|
|
|
+ testPrint8();
|
|
|
|
+ testKeepHash8();
|
|
|
|
|
|
testEquality32();
|
|
testEquality32();
|
|
testUnicodeEquality32();
|
|
testUnicodeEquality32();
|
|
@@ -969,6 +1077,13 @@ void Core::testArrayString() {
|
|
testReplace32();
|
|
testReplace32();
|
|
testReplaceChar32();
|
|
testReplaceChar32();
|
|
testCastAppendSelf32();
|
|
testCastAppendSelf32();
|
|
|
|
+ testCompareWithShorter32();
|
|
|
|
+ testAppendSignedChar32();
|
|
|
|
+ testAppendUnsignedChar32();
|
|
|
|
+ testAppendError32();
|
|
|
|
+ testPrint32();
|
|
|
|
+ testVariousUnicode32();
|
|
|
|
+ testKeepHash32();
|
|
|
|
|
|
testConversion();
|
|
testConversion();
|
|
}
|
|
}
|