|
@@ -3,20 +3,18 @@
|
|
|
#include "core/utils/ArrayString.hpp"
|
|
|
#include "core/utils/Error.hpp"
|
|
|
|
|
|
-template class Core::ArrayString<128, char, Core::CharString>;
|
|
|
-template class Core::ArrayString<128, c32, Core::Char32String>;
|
|
|
+template class Core::ArrayString<128>;
|
|
|
|
|
|
-using String8 = Core::String8<128>;
|
|
|
-using String32 = Core::String32<128>;
|
|
|
+using String = Core::ArrayString<128>;
|
|
|
|
|
|
-static String8 build(const char* cs) {
|
|
|
- String8 s;
|
|
|
- CORE_TEST_ERROR(s.append(cs));
|
|
|
+static String build(const char* cs) {
|
|
|
+ String s;
|
|
|
+ s.append(cs);
|
|
|
return s;
|
|
|
}
|
|
|
|
|
|
-static void testEquality8() {
|
|
|
- String8 s = build("test");
|
|
|
+static void testEquality() {
|
|
|
+ String s = build("test");
|
|
|
CORE_TEST_TRUE(s == "test");
|
|
|
CORE_TEST_TRUE(s == build("test"));
|
|
|
CORE_TEST_TRUE("test" == s);
|
|
@@ -25,9 +23,9 @@ static void testEquality8() {
|
|
|
CORE_TEST_TRUE(s == s);
|
|
|
}
|
|
|
|
|
|
-static void testUnicodeEquality8() {
|
|
|
+static void testUnicodeEquality() {
|
|
|
const char* cs = "\u0040\u0400\u8000\U00100000";
|
|
|
- String8 s = build(cs);
|
|
|
+ String s = build(cs);
|
|
|
CORE_TEST_TRUE(s == cs);
|
|
|
CORE_TEST_TRUE(s == build(cs));
|
|
|
CORE_TEST_TRUE(cs == s);
|
|
@@ -35,8 +33,8 @@ static void testUnicodeEquality8() {
|
|
|
CORE_TEST_TRUE(s == s);
|
|
|
}
|
|
|
|
|
|
-static void testInequality8() {
|
|
|
- String8 s = build("test");
|
|
|
+static void testInequality() {
|
|
|
+ String s = build("test");
|
|
|
CORE_TEST_FALSE(s != "test");
|
|
|
CORE_TEST_FALSE(s != build("test"));
|
|
|
CORE_TEST_FALSE("test" != s);
|
|
@@ -44,209 +42,202 @@ static void testInequality8() {
|
|
|
CORE_TEST_FALSE(s != s);
|
|
|
}
|
|
|
|
|
|
-static void testStringAppend8() {
|
|
|
- String8 s = build("test");
|
|
|
- CORE_TEST_ERROR(s.append("22"));
|
|
|
- CORE_TEST_ERROR(s.append("333"));
|
|
|
- CORE_TEST_ERROR(s.append("4444"));
|
|
|
+static void testStringAppend() {
|
|
|
+ String s = build("test");
|
|
|
+ s.append("22").append("333").append("4444");
|
|
|
CORE_TEST_EQUAL(build("test223334444"), s);
|
|
|
}
|
|
|
|
|
|
-static void testStringAppendOverflow8() {
|
|
|
- Core::String8<6> s;
|
|
|
- CORE_TEST_ERROR(s.append("te"));
|
|
|
- CORE_TEST_EQUAL(Core::ErrorCode::CAPACITY_REACHED, s.append("23334444"));
|
|
|
+static void testStringAppendOverflow() {
|
|
|
+ Core::ArrayString<6> s;
|
|
|
+ s.append("te").append("23334444");
|
|
|
CORE_TEST_TRUE(build("te23334444") != s);
|
|
|
}
|
|
|
|
|
|
-static void testCharacters8() {
|
|
|
- String8 s = build("test");
|
|
|
+static void testCharacters() {
|
|
|
+ String s = build("test");
|
|
|
CORE_TEST_EQUAL('t', s[0]);
|
|
|
CORE_TEST_EQUAL('e', s[1]);
|
|
|
CORE_TEST_EQUAL('s', s[2]);
|
|
|
CORE_TEST_EQUAL('t', s[3]);
|
|
|
}
|
|
|
|
|
|
-static void testLength8() {
|
|
|
- String8 s = build("test");
|
|
|
+static void testLength() {
|
|
|
+ String s = build("test");
|
|
|
CORE_TEST_EQUAL(4, s.getLength());
|
|
|
- CORE_TEST_ERROR(s.append("aaa"));
|
|
|
+ s.append("aaa");
|
|
|
CORE_TEST_EQUAL(7, s.getLength());
|
|
|
}
|
|
|
|
|
|
-static void testChar8() {
|
|
|
- String8 s = build("test");
|
|
|
+static void testChar() {
|
|
|
+ String s = build("test");
|
|
|
for(char i = 'a'; i < 'd'; i++) {
|
|
|
- CORE_TEST_ERROR(s.append(i));
|
|
|
+ s.append(i);
|
|
|
}
|
|
|
CORE_TEST_EQUAL(build("testabc"), s);
|
|
|
}
|
|
|
|
|
|
-static void testSignedChar8() {
|
|
|
- String8 s = build("test");
|
|
|
+static void testSignedChar() {
|
|
|
+ String s = build("test");
|
|
|
for(signed char i = 'b'; i < 'e'; i++) {
|
|
|
- CORE_TEST_ERROR(s.append(i));
|
|
|
+ s.append(i);
|
|
|
}
|
|
|
CORE_TEST_EQUAL(build("testbcd"), s);
|
|
|
}
|
|
|
|
|
|
-static void testUnsignedChar8() {
|
|
|
- String8 s = build("test");
|
|
|
+static void testUnsignedChar() {
|
|
|
+ String s = build("test");
|
|
|
for(unsigned char i = 'c'; i < 'f'; i++) {
|
|
|
- CORE_TEST_ERROR(s.append(i));
|
|
|
+ s.append(i);
|
|
|
}
|
|
|
CORE_TEST_EQUAL(build("testcde"), s);
|
|
|
}
|
|
|
|
|
|
-static void testSignedShort8() {
|
|
|
- String8 s = build("test");
|
|
|
+static void testSignedShort() {
|
|
|
+ String s = build("test");
|
|
|
for(signed short i = 100; i < 103; i++) {
|
|
|
- CORE_TEST_ERROR(s.append(i));
|
|
|
+ s.append(i);
|
|
|
}
|
|
|
CORE_TEST_EQUAL(build("test100101102"), s);
|
|
|
}
|
|
|
|
|
|
-static void testUnsignedShort8() {
|
|
|
- String8 s = build("test");
|
|
|
+static void testUnsignedShort() {
|
|
|
+ String s = build("test");
|
|
|
for(unsigned short i = 101; i < 104; i++) {
|
|
|
- CORE_TEST_ERROR(s.append(i));
|
|
|
+ s.append(i);
|
|
|
}
|
|
|
CORE_TEST_EQUAL(build("test101102103"), s);
|
|
|
}
|
|
|
|
|
|
-static void testSignedInt8() {
|
|
|
- String8 s = build("test");
|
|
|
+static void testSignedInt() {
|
|
|
+ String s = build("test");
|
|
|
for(signed int i = 102; i < 105; i++) {
|
|
|
- CORE_TEST_ERROR(s.append(i));
|
|
|
+ s.append(i);
|
|
|
}
|
|
|
CORE_TEST_EQUAL(build("test102103104"), s);
|
|
|
}
|
|
|
|
|
|
-static void testUnsignedInt8() {
|
|
|
- String8 s = build("test");
|
|
|
+static void testUnsignedInt() {
|
|
|
+ String s = build("test");
|
|
|
for(unsigned int i = 103; i < 106; i++) {
|
|
|
- CORE_TEST_ERROR(s.append(i));
|
|
|
+ s.append(i);
|
|
|
}
|
|
|
CORE_TEST_EQUAL(build("test103104105"), s);
|
|
|
}
|
|
|
|
|
|
-static void testSignedLong8() {
|
|
|
- String8 s = build("test");
|
|
|
+static void testSignedLong() {
|
|
|
+ String s = build("test");
|
|
|
for(signed long i = 104; i < 107; i++) {
|
|
|
- CORE_TEST_ERROR(s.append(i));
|
|
|
+ s.append(i);
|
|
|
}
|
|
|
CORE_TEST_EQUAL(build("test104105106"), s);
|
|
|
}
|
|
|
|
|
|
-static void testUnsignedLong8() {
|
|
|
- String8 s = build("test");
|
|
|
+static void testUnsignedLong() {
|
|
|
+ String s = build("test");
|
|
|
for(unsigned long i = 105; i < 108; i++) {
|
|
|
- CORE_TEST_ERROR(s.append(i));
|
|
|
+ s.append(i);
|
|
|
}
|
|
|
CORE_TEST_EQUAL(build("test105106107"), s);
|
|
|
}
|
|
|
|
|
|
-static void testSignedLongLong8() {
|
|
|
- String8 s = build("test");
|
|
|
+static void testSignedLongLong() {
|
|
|
+ String s = build("test");
|
|
|
for(signed long long i = 106; i < 109; i++) {
|
|
|
- CORE_TEST_ERROR(s.append(i));
|
|
|
+ s.append(i);
|
|
|
}
|
|
|
CORE_TEST_EQUAL(build("test106107108"), s);
|
|
|
}
|
|
|
|
|
|
-static void testUnsignedLongLong8() {
|
|
|
- String8 s = build("test");
|
|
|
+static void testUnsignedLongLong() {
|
|
|
+ String s = build("test");
|
|
|
for(unsigned long long i = 107; i < 110; i++) {
|
|
|
- CORE_TEST_ERROR(s.append(i));
|
|
|
+ s.append(i);
|
|
|
}
|
|
|
CORE_TEST_EQUAL(build("test107108109"), s);
|
|
|
}
|
|
|
|
|
|
-static void testFloat8() {
|
|
|
- String8 s = build("test");
|
|
|
+static void testFloat() {
|
|
|
+ String s = build("test");
|
|
|
for(float i = 108; i < 111; i++) {
|
|
|
- CORE_TEST_ERROR(s.append(i));
|
|
|
+ s.append(i);
|
|
|
}
|
|
|
CORE_TEST_EQUAL(build("test108.00109.00110.00"), s);
|
|
|
}
|
|
|
|
|
|
-static void testDouble8() {
|
|
|
- String8 s = build("test");
|
|
|
+static void testDouble() {
|
|
|
+ String s = build("test");
|
|
|
for(double i = 109; i < 112; i++) {
|
|
|
- CORE_TEST_ERROR(s.append(i));
|
|
|
+ s.append(i);
|
|
|
}
|
|
|
CORE_TEST_EQUAL(build("test109.00110.00111.00"), s);
|
|
|
}
|
|
|
|
|
|
-static void testLongDouble8() {
|
|
|
- String8 s = build("test");
|
|
|
+static void testLongDouble() {
|
|
|
+ String s = build("test");
|
|
|
for(long double i = 110; i < 113; i++) {
|
|
|
- CORE_TEST_ERROR(s.append(i));
|
|
|
+ s.append(i);
|
|
|
}
|
|
|
CORE_TEST_EQUAL(build("test110.00111.00112.00"), s);
|
|
|
}
|
|
|
|
|
|
-static void testBool8() {
|
|
|
- String8 s = build("test");
|
|
|
- CORE_TEST_ERROR(s.append(true));
|
|
|
- CORE_TEST_ERROR(s.append(false));
|
|
|
- CORE_TEST_ERROR(s.append(true));
|
|
|
+static void testBool() {
|
|
|
+ String s = build("test");
|
|
|
+ s.append(true).append(false).append(true);
|
|
|
CORE_TEST_EQUAL(build("testtruefalsetrue"), s);
|
|
|
}
|
|
|
|
|
|
-static void testIntOverflow8() {
|
|
|
- Core::String8<4> s;
|
|
|
- CORE_TEST_EQUAL(Core::ErrorCode::CAPACITY_REACHED, s.append(123456));
|
|
|
+static void testIntOverflow() {
|
|
|
+ Core::ArrayString<4> s;
|
|
|
+ s.append(123456);
|
|
|
|
|
|
- String8 o;
|
|
|
+ String o;
|
|
|
for(size_t i = 0; i < s.getCapacity(); i++) {
|
|
|
- CORE_TEST_ERROR(o.append(i + 1));
|
|
|
+ o.append(i + 1);
|
|
|
}
|
|
|
|
|
|
CORE_TEST_TRUE(o == s);
|
|
|
}
|
|
|
|
|
|
-static void testUnicode8() {
|
|
|
- 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'));
|
|
|
+static void testUnicode() {
|
|
|
+ String s;
|
|
|
+ s.append('\u0040');
|
|
|
+ s.append(L'\u0400');
|
|
|
+ s.append(L'\u8000');
|
|
|
+ s.append(U'\U00100000');
|
|
|
CORE_TEST_EQUAL(build("\u0040\u0400\u8000\U00100000"), s);
|
|
|
}
|
|
|
|
|
|
-static void testClear8() {
|
|
|
- String8 s = build("test");
|
|
|
- CORE_TEST_ERROR(s.append(1234));
|
|
|
+static void testClear() {
|
|
|
+ String s = build("test");
|
|
|
+ s.append(1234);
|
|
|
s.clear();
|
|
|
- CORE_TEST_ERROR(s.append("wusi"));
|
|
|
- CORE_TEST_ERROR(s.append("1234"));
|
|
|
+ s.append("wusi");
|
|
|
+ s.append("1234");
|
|
|
CORE_TEST_EQUAL(build("wusi1234"), s);
|
|
|
}
|
|
|
|
|
|
-static void testAddSelf8() {
|
|
|
- String8 s;
|
|
|
- CORE_TEST_ERROR(s.append("test1"));
|
|
|
- CORE_TEST_ERROR(s.append(s));
|
|
|
- CORE_TEST_ERROR(s.append(s));
|
|
|
+static void testAddSelf() {
|
|
|
+ String s;
|
|
|
+ s.append("test1").append(s).append(s);
|
|
|
CORE_TEST_EQUAL(build("test1test1test1test1"), s);
|
|
|
}
|
|
|
|
|
|
-static void testStartsWith8() {
|
|
|
- String8 s;
|
|
|
- CORE_TEST_ERROR(s.append("0123456789"));
|
|
|
-
|
|
|
- String8 s2;
|
|
|
- CORE_TEST_ERROR(s2.append("123"));
|
|
|
- String8 s3;
|
|
|
- CORE_TEST_ERROR(s3.append("234"));
|
|
|
- String8 s4;
|
|
|
- CORE_TEST_ERROR(s4.append("789"));
|
|
|
- String8 s5;
|
|
|
- CORE_TEST_ERROR(s5.append("124"));
|
|
|
- String8 s6;
|
|
|
- String8 s7;
|
|
|
- CORE_TEST_ERROR(s7.append("7891"));
|
|
|
+static void testStartsWith() {
|
|
|
+ String s;
|
|
|
+ s.append("0123456789");
|
|
|
+
|
|
|
+ String s2;
|
|
|
+ s2.append("123");
|
|
|
+ String s3;
|
|
|
+ s3.append("234");
|
|
|
+ String s4;
|
|
|
+ s4.append("789");
|
|
|
+ String s5;
|
|
|
+ s5.append("124");
|
|
|
+ String s6;
|
|
|
+ String s7;
|
|
|
+ s7.append("7891");
|
|
|
|
|
|
CORE_TEST_FALSE(s.startsWith(s2));
|
|
|
CORE_TEST_TRUE(s.startsWith(s2, 1));
|
|
@@ -267,21 +258,21 @@ static void testStartsWith8() {
|
|
|
CORE_TEST_FALSE(s.startsWith(s7, 7));
|
|
|
}
|
|
|
|
|
|
-static void testSearch8() {
|
|
|
- String8 s;
|
|
|
- CORE_TEST_ERROR(s.append("0123456789"));
|
|
|
-
|
|
|
- String8 s2;
|
|
|
- CORE_TEST_ERROR(s2.append("123"));
|
|
|
- String8 s3;
|
|
|
- CORE_TEST_ERROR(s3.append("234"));
|
|
|
- String8 s4;
|
|
|
- CORE_TEST_ERROR(s4.append("789"));
|
|
|
- String8 s5;
|
|
|
- CORE_TEST_ERROR(s5.append("124"));
|
|
|
- String8 s6;
|
|
|
- String8 s7;
|
|
|
- CORE_TEST_ERROR(s7.append("7891"));
|
|
|
+static void testSearch() {
|
|
|
+ String s;
|
|
|
+ s.append("0123456789");
|
|
|
+
|
|
|
+ String s2;
|
|
|
+ s2.append("123");
|
|
|
+ String s3;
|
|
|
+ s3.append("234");
|
|
|
+ String s4;
|
|
|
+ s4.append("789");
|
|
|
+ String s5;
|
|
|
+ s5.append("124");
|
|
|
+ String s6;
|
|
|
+ String s7;
|
|
|
+ s7.append("7891");
|
|
|
|
|
|
CORE_TEST_EQUAL(1, s.search(s2));
|
|
|
CORE_TEST_EQUAL(2, s.search(s3));
|
|
@@ -298,21 +289,21 @@ static void testSearch8() {
|
|
|
CORE_TEST_EQUAL(SIZE_MAX, s.search(s7, 3));
|
|
|
}
|
|
|
|
|
|
-static void testContains8() {
|
|
|
- String8 s;
|
|
|
- CORE_TEST_ERROR(s.append("0123456789"));
|
|
|
-
|
|
|
- String8 s2;
|
|
|
- CORE_TEST_ERROR(s2.append("123"));
|
|
|
- String8 s3;
|
|
|
- CORE_TEST_ERROR(s3.append("234"));
|
|
|
- String8 s4;
|
|
|
- CORE_TEST_ERROR(s4.append("789"));
|
|
|
- String8 s5;
|
|
|
- CORE_TEST_ERROR(s5.append("124"));
|
|
|
- String8 s6;
|
|
|
- String8 s7;
|
|
|
- CORE_TEST_ERROR(s7.append("7891"));
|
|
|
+static void testContains() {
|
|
|
+ String s;
|
|
|
+ s.append("0123456789");
|
|
|
+
|
|
|
+ String s2;
|
|
|
+ s2.append("123");
|
|
|
+ String s3;
|
|
|
+ s3.append("234");
|
|
|
+ String s4;
|
|
|
+ s4.append("789");
|
|
|
+ String s5;
|
|
|
+ s5.append("124");
|
|
|
+ String s6;
|
|
|
+ String s7;
|
|
|
+ s7.append("7891");
|
|
|
|
|
|
CORE_TEST_TRUE(s.contains(s2));
|
|
|
CORE_TEST_TRUE(s.contains(s3));
|
|
@@ -322,68 +313,68 @@ static void testContains8() {
|
|
|
CORE_TEST_FALSE(s.contains(s7));
|
|
|
}
|
|
|
|
|
|
-static void testSearchChar8() {
|
|
|
- String8 s;
|
|
|
- CORE_TEST_ERROR(s.append("01üää3ä"));
|
|
|
+static void testSearchChar() {
|
|
|
+ String s;
|
|
|
+ s.append("01üää3ä");
|
|
|
|
|
|
CORE_TEST_EQUAL(0, s.search('0'));
|
|
|
CORE_TEST_EQUAL(1, s.search('1'));
|
|
|
CORE_TEST_EQUAL(8, s.search('3'));
|
|
|
}
|
|
|
|
|
|
-static void testContainsChar8() {
|
|
|
- String8 s;
|
|
|
- CORE_TEST_ERROR(s.append("01üää3ä"));
|
|
|
+static void testContainsChar() {
|
|
|
+ String s;
|
|
|
+ s.append("01üää3ä");
|
|
|
CORE_TEST_TRUE(s.contains('0'));
|
|
|
CORE_TEST_TRUE(s.contains('1'));
|
|
|
CORE_TEST_TRUE(s.contains('3'));
|
|
|
CORE_TEST_FALSE(s.contains('a'));
|
|
|
}
|
|
|
|
|
|
-static void testSubString8() {
|
|
|
- String8 s;
|
|
|
- CORE_TEST_ERROR(s.append("01üää3ä"));
|
|
|
+static void testSubString() {
|
|
|
+ String s;
|
|
|
+ s.append("01üää3ä");
|
|
|
|
|
|
- String8 sub;
|
|
|
- CORE_TEST_ERROR(s.substring(sub, 0));
|
|
|
+ String sub;
|
|
|
+ s.substring(sub, 0);
|
|
|
CORE_TEST_STRING("01üää3ä", sub);
|
|
|
- CORE_TEST_ERROR(s.substring(sub, 2));
|
|
|
+ s.substring(sub, 2);
|
|
|
CORE_TEST_STRING("üää3ä", sub);
|
|
|
- CORE_TEST_ERROR(s.substring(sub, 4));
|
|
|
+ s.substring(sub, 4);
|
|
|
CORE_TEST_STRING("ää3ä", sub);
|
|
|
- CORE_TEST_ERROR(s.substring(sub, 6));
|
|
|
+ s.substring(sub, 6);
|
|
|
CORE_TEST_STRING("ä3ä", sub);
|
|
|
|
|
|
- CORE_TEST_ERROR(s.substring(sub, 0, 10));
|
|
|
+ s.substring(sub, 0, 10);
|
|
|
CORE_TEST_STRING("01üää3ä", sub);
|
|
|
- CORE_TEST_ERROR(s.substring(sub, 1, 8));
|
|
|
+ s.substring(sub, 1, 8);
|
|
|
CORE_TEST_STRING("1üää3", sub);
|
|
|
- CORE_TEST_ERROR(s.substring(sub, 2, 7));
|
|
|
+ s.substring(sub, 2, 7);
|
|
|
CORE_TEST_STRING("üää", sub);
|
|
|
- CORE_TEST_ERROR(s.substring(sub, 4, 5));
|
|
|
+ s.substring(sub, 4, 5);
|
|
|
CORE_TEST_STRING("ä", sub);
|
|
|
- CORE_TEST_ERROR(s.substring(sub, 4, 2));
|
|
|
+ s.substring(sub, 4, 2);
|
|
|
CORE_TEST_STRING("", sub);
|
|
|
- CORE_TEST_ERROR(s.substring(sub, 6, 23));
|
|
|
+ s.substring(sub, 6, 23);
|
|
|
CORE_TEST_STRING("ä3ä", sub);
|
|
|
}
|
|
|
|
|
|
-static void testReplace8() {
|
|
|
- String8 s;
|
|
|
- CORE_TEST_ERROR(s.append("0äääää1üää3ä"));
|
|
|
+static void testReplace() {
|
|
|
+ String s;
|
|
|
+ s.append("0äääää1üää3ä");
|
|
|
|
|
|
- String8 search;
|
|
|
- CORE_TEST_ERROR(search.append("ää"));
|
|
|
+ String search;
|
|
|
+ search.append("ää");
|
|
|
|
|
|
- String8 replace;
|
|
|
- CORE_TEST_ERROR(replace.append("ABCD"));
|
|
|
- CORE_TEST_ERROR(s.replace(search, replace));
|
|
|
+ String replace;
|
|
|
+ replace.append("ABCD");
|
|
|
+ s.replace(search, replace);
|
|
|
CORE_TEST_STRING("0ABCDABCDä1üABCD3ä", s);
|
|
|
}
|
|
|
|
|
|
-static void testReplaceChar8() {
|
|
|
- String8 s;
|
|
|
- CORE_TEST_ERROR(s.append("01YXX3X"));
|
|
|
+static void testReplaceChar() {
|
|
|
+ String s;
|
|
|
+ s.append("01YXX3X");
|
|
|
s.replace('0', 'A');
|
|
|
CORE_TEST_STRING("A1YXX3X", s);
|
|
|
s.replace('1', 'B');
|
|
@@ -396,654 +387,132 @@ static void testReplaceChar8() {
|
|
|
CORE_TEST_STRING("ABCDDED", s);
|
|
|
}
|
|
|
|
|
|
-static void testCastAppendSelf8() {
|
|
|
- String8 s;
|
|
|
- CORE_TEST_ERROR(s.append("abc"));
|
|
|
- CORE_TEST_ERROR(s.append(s));
|
|
|
- CORE_TEST_ERROR(s.append(static_cast<const char*>(s)));
|
|
|
+static void testCastAppendSelf() {
|
|
|
+ String s;
|
|
|
+ s.append("abc");
|
|
|
+ s.append(s);
|
|
|
+ s.append(static_cast<const char*>(s));
|
|
|
CORE_TEST_STRING("abcabcabcabc", s);
|
|
|
}
|
|
|
|
|
|
-static void testCompareWithShorter8() {
|
|
|
- String8 s;
|
|
|
- CORE_TEST_ERROR(s.append("abc"));
|
|
|
+static void testCompareWithShorter() {
|
|
|
+ String s;
|
|
|
+ s.append("abc");
|
|
|
CORE_TEST_FALSE(s == "ab");
|
|
|
}
|
|
|
|
|
|
-static void testAppendSignedChar8() {
|
|
|
+static void testAppendSignedChar() {
|
|
|
const signed char buffer[] = {'a', 'b', 'c', '\0'};
|
|
|
- String8 s;
|
|
|
- CORE_TEST_ERROR(s.append(buffer));
|
|
|
+ String s;
|
|
|
+ s.append(buffer);
|
|
|
CORE_TEST_TRUE(s == "abc");
|
|
|
}
|
|
|
|
|
|
-static void testAppendUnsignedChar8() {
|
|
|
+static void testAppendUnsignedChar() {
|
|
|
const unsigned char buffer[] = {'a', 'b', 'c', '\0'};
|
|
|
- String8 s;
|
|
|
- CORE_TEST_ERROR(s.append(buffer));
|
|
|
+ String s;
|
|
|
+ s.append(buffer);
|
|
|
CORE_TEST_TRUE(s == "abc");
|
|
|
}
|
|
|
|
|
|
-static void testAppendError8() {
|
|
|
- String8 s;
|
|
|
- CORE_TEST_ERROR(s.append(Core::ErrorCode::NONE));
|
|
|
+static void testAppendError() {
|
|
|
+ String s;
|
|
|
+ s.append(Core::ErrorCode::NONE);
|
|
|
CORE_TEST_STRING("0", s);
|
|
|
}
|
|
|
|
|
|
-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'));
|
|
|
+static void testPrint() {
|
|
|
+ String s;
|
|
|
+ s.append('\u0040');
|
|
|
+ s.append(L'\u0400');
|
|
|
+ s.append(L'\u8000');
|
|
|
+ s.append(U'\U00100000');
|
|
|
CORE_TEST_EQUAL(build("\u0040\u0400\u8000\U00100000"), s);
|
|
|
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));
|
|
|
+static void testKeepHash() {
|
|
|
+ String s;
|
|
|
+ s.append("a ## test #### #####");
|
|
|
+ s.format(1, 2, 3, 4, 5, 6, 7, 8, 9);
|
|
|
CORE_TEST_STRING("a # test ## ##123456789", s);
|
|
|
}
|
|
|
|
|
|
-static void testFormatWithoutArguments8() {
|
|
|
- String8 s;
|
|
|
- CORE_TEST_ERROR(s.append("wusi"));
|
|
|
- CORE_TEST_ERROR(s.format());
|
|
|
+static void testFormatWithoutArguments() {
|
|
|
+ String s;
|
|
|
+ s.append("wusi");
|
|
|
+ s.format();
|
|
|
CORE_TEST_STRING("wusi", s);
|
|
|
}
|
|
|
|
|
|
-static void testUnicodeString8() {
|
|
|
- String8 s;
|
|
|
- CORE_TEST_ERROR(s.append(U"_üö§äab"));
|
|
|
+static void testUnicodeString() {
|
|
|
+ String s;
|
|
|
+ s.append(U"_üö§äab");
|
|
|
CORE_TEST_STRING("_üö§äab", s);
|
|
|
}
|
|
|
|
|
|
-static void testInvalidUnicodeString8() {
|
|
|
- String8 s;
|
|
|
- CORE_TEST_EQUAL(Core::ErrorCode::INVALID_CHAR,
|
|
|
- s.append(static_cast<c32>(0xFFFFFFFF)));
|
|
|
-}
|
|
|
-
|
|
|
-static String32 build(const c32* cs) {
|
|
|
- String32 s;
|
|
|
- CORE_TEST_ERROR(s.append(cs));
|
|
|
- return s;
|
|
|
-}
|
|
|
-
|
|
|
-static void testEquality32() {
|
|
|
- String32 s = build(U"test");
|
|
|
- CORE_TEST_TRUE(s == U"test");
|
|
|
- CORE_TEST_TRUE(s == build(U"test"));
|
|
|
- CORE_TEST_TRUE(U"test" == s);
|
|
|
- CORE_TEST_TRUE(build(U"test") == s);
|
|
|
- CORE_TEST_FALSE(build(U"tes2") == s);
|
|
|
- CORE_TEST_TRUE(s == s);
|
|
|
-}
|
|
|
-
|
|
|
-static void testUnicodeEquality32() {
|
|
|
- const c32* cs = U"\u0040\u0400\u8000\U00100000";
|
|
|
- String32 s = build(cs);
|
|
|
- CORE_TEST_TRUE(s == cs);
|
|
|
- CORE_TEST_TRUE(s == build(cs));
|
|
|
- CORE_TEST_TRUE(cs == s);
|
|
|
- CORE_TEST_TRUE(build(cs) == s);
|
|
|
- CORE_TEST_TRUE(s == s);
|
|
|
-}
|
|
|
-
|
|
|
-static void testInequality32() {
|
|
|
- String32 s = build(U"test");
|
|
|
- CORE_TEST_FALSE(s != U"test");
|
|
|
- CORE_TEST_FALSE(s != build(U"test"));
|
|
|
- CORE_TEST_FALSE(U"test" != s);
|
|
|
- CORE_TEST_FALSE(build(U"test") != s);
|
|
|
- CORE_TEST_FALSE(s != s);
|
|
|
-}
|
|
|
-
|
|
|
-static void testStringAppend32() {
|
|
|
- String32 s = build(U"test");
|
|
|
- CORE_TEST_ERROR(s.append(U"22"));
|
|
|
- CORE_TEST_ERROR(s.append(U"333"));
|
|
|
- CORE_TEST_ERROR(s.append(U"4444"));
|
|
|
- CORE_TEST_EQUAL(build(U"test223334444"), s);
|
|
|
-}
|
|
|
-
|
|
|
-static void testStringAppendOverflow32() {
|
|
|
- Core::String32<6> s;
|
|
|
- CORE_TEST_ERROR(s.append(U"te"));
|
|
|
- CORE_TEST_EQUAL(Core::ErrorCode::CAPACITY_REACHED, s.append(U"23334444"));
|
|
|
- CORE_TEST_TRUE(build(U"te23334444") != s);
|
|
|
-}
|
|
|
-
|
|
|
-static void testCharacters32() {
|
|
|
- String32 s = build(U"test");
|
|
|
- CORE_TEST_EQUAL('t', s[0]);
|
|
|
- CORE_TEST_EQUAL('e', s[1]);
|
|
|
- CORE_TEST_EQUAL('s', s[2]);
|
|
|
- CORE_TEST_EQUAL('t', s[3]);
|
|
|
-}
|
|
|
-
|
|
|
-static void testLength32() {
|
|
|
- String32 s = build(U"test");
|
|
|
- CORE_TEST_EQUAL(4, s.getLength());
|
|
|
- CORE_TEST_ERROR(s.append(U"aaa"));
|
|
|
- CORE_TEST_EQUAL(7, s.getLength());
|
|
|
-}
|
|
|
-
|
|
|
-static void testChar32() {
|
|
|
- String32 s = build(U"test");
|
|
|
- for(char i = 'a'; i < 'd'; i++) {
|
|
|
- CORE_TEST_ERROR(s.append(i));
|
|
|
- }
|
|
|
- CORE_TEST_EQUAL(build(U"testabc"), s);
|
|
|
-}
|
|
|
-
|
|
|
-static void testSignedChar32() {
|
|
|
- String32 s = build(U"test");
|
|
|
- for(signed char i = 'b'; i < 'e'; i++) {
|
|
|
- CORE_TEST_ERROR(s.append(i));
|
|
|
- }
|
|
|
- CORE_TEST_EQUAL(build(U"testbcd"), s);
|
|
|
-}
|
|
|
-
|
|
|
-static void testUnsignedChar32() {
|
|
|
- String32 s = build(U"test");
|
|
|
- for(unsigned char i = 'c'; i < 'f'; i++) {
|
|
|
- CORE_TEST_ERROR(s.append(i));
|
|
|
- }
|
|
|
- CORE_TEST_EQUAL(build(U"testcde"), s);
|
|
|
-}
|
|
|
-
|
|
|
-static void testSignedShort32() {
|
|
|
- String32 s = build(U"test");
|
|
|
- for(signed short i = 100; i < 103; i++) {
|
|
|
- CORE_TEST_ERROR(s.append(i));
|
|
|
- }
|
|
|
- CORE_TEST_EQUAL(build(U"test100101102"), s);
|
|
|
-}
|
|
|
-
|
|
|
-static void testUnsignedShort32() {
|
|
|
- String32 s = build(U"test");
|
|
|
- for(unsigned short i = 101; i < 104; i++) {
|
|
|
- CORE_TEST_ERROR(s.append(i));
|
|
|
- }
|
|
|
- CORE_TEST_EQUAL(build(U"test101102103"), s);
|
|
|
-}
|
|
|
-
|
|
|
-static void testSignedInt32() {
|
|
|
- String32 s = build(U"test");
|
|
|
- for(signed int i = 102; i < 105; i++) {
|
|
|
- CORE_TEST_ERROR(s.append(i));
|
|
|
- }
|
|
|
- CORE_TEST_EQUAL(build(U"test102103104"), s);
|
|
|
-}
|
|
|
-
|
|
|
-static void testUnsignedInt32() {
|
|
|
- String32 s = build(U"test");
|
|
|
- for(unsigned int i = 103; i < 106; i++) {
|
|
|
- CORE_TEST_ERROR(s.append(i));
|
|
|
- }
|
|
|
- CORE_TEST_EQUAL(build(U"test103104105"), s);
|
|
|
-}
|
|
|
-
|
|
|
-static void testSignedLong32() {
|
|
|
- String32 s = build(U"test");
|
|
|
- for(signed long i = 104; i < 107; i++) {
|
|
|
- CORE_TEST_ERROR(s.append(i));
|
|
|
- }
|
|
|
- CORE_TEST_EQUAL(build(U"test104105106"), s);
|
|
|
-}
|
|
|
-
|
|
|
-static void testUnsignedLong32() {
|
|
|
- String32 s = build(U"test");
|
|
|
- for(unsigned long i = 105; i < 108; i++) {
|
|
|
- CORE_TEST_ERROR(s.append(i));
|
|
|
- }
|
|
|
- CORE_TEST_EQUAL(build(U"test105106107"), s);
|
|
|
-}
|
|
|
-
|
|
|
-static void testSignedLongLong32() {
|
|
|
- String32 s = build(U"test");
|
|
|
- for(signed long long i = 106; i < 109; i++) {
|
|
|
- CORE_TEST_ERROR(s.append(i));
|
|
|
- }
|
|
|
- CORE_TEST_EQUAL(build(U"test106107108"), s);
|
|
|
-}
|
|
|
-
|
|
|
-static void testUnsignedLongLong32() {
|
|
|
- String32 s = build(U"test");
|
|
|
- for(unsigned long long i = 107; i < 110; i++) {
|
|
|
- CORE_TEST_ERROR(s.append(i));
|
|
|
- }
|
|
|
- CORE_TEST_EQUAL(build(U"test107108109"), s);
|
|
|
-}
|
|
|
-
|
|
|
-static void testFloat32() {
|
|
|
- String32 s = build(U"test");
|
|
|
- for(float i = 108; i < 111; i++) {
|
|
|
- CORE_TEST_ERROR(s.append(i));
|
|
|
- }
|
|
|
- CORE_TEST_EQUAL(build(U"test108.00109.00110.00"), s);
|
|
|
-}
|
|
|
-
|
|
|
-static void testDouble32() {
|
|
|
- String32 s = build(U"test");
|
|
|
- for(double i = 109; i < 112; i++) {
|
|
|
- CORE_TEST_ERROR(s.append(i));
|
|
|
- }
|
|
|
- CORE_TEST_EQUAL(build(U"test109.00110.00111.00"), s);
|
|
|
-}
|
|
|
-
|
|
|
-static void testLongDouble32() {
|
|
|
- String32 s = build(U"test");
|
|
|
- for(long double i = 110; i < 113; i++) {
|
|
|
- CORE_TEST_ERROR(s.append(i));
|
|
|
- }
|
|
|
- CORE_TEST_EQUAL(build(U"test110.00111.00112.00"), s);
|
|
|
-}
|
|
|
-
|
|
|
-static void testBool32() {
|
|
|
- String32 s = build(U"test");
|
|
|
- CORE_TEST_ERROR(s.append(true));
|
|
|
- CORE_TEST_ERROR(s.append(false));
|
|
|
- CORE_TEST_ERROR(s.append(true));
|
|
|
- CORE_TEST_EQUAL(build(U"testtruefalsetrue"), s);
|
|
|
-}
|
|
|
-
|
|
|
-static void testIntOverflow32() {
|
|
|
- Core::String32<4> s;
|
|
|
- CORE_TEST_EQUAL(Core::ErrorCode::CAPACITY_REACHED, s.append(123456));
|
|
|
-
|
|
|
- String32 o;
|
|
|
- for(size_t i = 0; i < s.getCapacity(); i++) {
|
|
|
- CORE_TEST_ERROR(o.append(i + 1));
|
|
|
- }
|
|
|
-
|
|
|
- CORE_TEST_TRUE(o == s);
|
|
|
-}
|
|
|
-
|
|
|
-static void testUnicode32() {
|
|
|
- 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);
|
|
|
-}
|
|
|
-
|
|
|
-static void testClear32() {
|
|
|
- String32 s = build(U"test");
|
|
|
- CORE_TEST_ERROR(s.append(1234));
|
|
|
- s.clear();
|
|
|
- CORE_TEST_ERROR(s.append(U"wusi"));
|
|
|
- CORE_TEST_ERROR(s.append(U"1234"));
|
|
|
- CORE_TEST_EQUAL(build(U"wusi1234"), s);
|
|
|
-}
|
|
|
-
|
|
|
-static void testAddSelf32() {
|
|
|
- String32 s;
|
|
|
- CORE_TEST_ERROR(s.append(U"test1"));
|
|
|
- CORE_TEST_ERROR(s.append(s));
|
|
|
- CORE_TEST_ERROR(s.append(s));
|
|
|
- CORE_TEST_EQUAL(build(U"test1test1test1test1"), s);
|
|
|
-}
|
|
|
-
|
|
|
-static void testStartsWith32() {
|
|
|
- String32 s;
|
|
|
- CORE_TEST_ERROR(s.append(U"0123456789"));
|
|
|
-
|
|
|
- String32 s2;
|
|
|
- CORE_TEST_ERROR(s2.append(U"123"));
|
|
|
- String32 s3;
|
|
|
- CORE_TEST_ERROR(s3.append(U"234"));
|
|
|
- String32 s4;
|
|
|
- CORE_TEST_ERROR(s4.append(U"789"));
|
|
|
- String32 s5;
|
|
|
- CORE_TEST_ERROR(s5.append(U"124"));
|
|
|
- String32 s6;
|
|
|
- String32 s7;
|
|
|
- CORE_TEST_ERROR(s7.append(U"7891"));
|
|
|
-
|
|
|
- CORE_TEST_FALSE(s.startsWith(s2));
|
|
|
- CORE_TEST_TRUE(s.startsWith(s2, 1));
|
|
|
-
|
|
|
- CORE_TEST_FALSE(s.startsWith(s3));
|
|
|
- CORE_TEST_TRUE(s.startsWith(s3, 2));
|
|
|
-
|
|
|
- CORE_TEST_FALSE(s.startsWith(s4));
|
|
|
- CORE_TEST_TRUE(s.startsWith(s4, 7));
|
|
|
-
|
|
|
- CORE_TEST_FALSE(s.startsWith(s5));
|
|
|
- CORE_TEST_FALSE(s.startsWith(s5, 3));
|
|
|
-
|
|
|
- CORE_TEST_TRUE(s.startsWith(s6));
|
|
|
- CORE_TEST_TRUE(s.startsWith(s6, 3));
|
|
|
-
|
|
|
- CORE_TEST_FALSE(s.startsWith(s7));
|
|
|
- CORE_TEST_FALSE(s.startsWith(s7, 7));
|
|
|
-}
|
|
|
-
|
|
|
-static void testSearch32() {
|
|
|
- String32 s;
|
|
|
- CORE_TEST_ERROR(s.append(U"0123456789"));
|
|
|
-
|
|
|
- String32 s2;
|
|
|
- CORE_TEST_ERROR(s2.append(U"123"));
|
|
|
- String32 s3;
|
|
|
- CORE_TEST_ERROR(s3.append(U"234"));
|
|
|
- String32 s4;
|
|
|
- CORE_TEST_ERROR(s4.append(U"789"));
|
|
|
- String32 s5;
|
|
|
- CORE_TEST_ERROR(s5.append(U"124"));
|
|
|
- String32 s6;
|
|
|
- String32 s7;
|
|
|
- CORE_TEST_ERROR(s7.append(U"7891"));
|
|
|
-
|
|
|
- CORE_TEST_EQUAL(1, s.search(s2));
|
|
|
- CORE_TEST_EQUAL(2, s.search(s3));
|
|
|
- CORE_TEST_EQUAL(7, s.search(s4));
|
|
|
- CORE_TEST_EQUAL(SIZE_MAX, s.search(s5));
|
|
|
- CORE_TEST_EQUAL(0, s.search(s6));
|
|
|
- CORE_TEST_EQUAL(SIZE_MAX, s.search(s7));
|
|
|
-
|
|
|
- CORE_TEST_EQUAL(SIZE_MAX, s.search(s2, 3));
|
|
|
- CORE_TEST_EQUAL(SIZE_MAX, s.search(s3, 3));
|
|
|
- CORE_TEST_EQUAL(7, s.search(s4, 3));
|
|
|
- CORE_TEST_EQUAL(SIZE_MAX, s.search(s5, 3));
|
|
|
- CORE_TEST_EQUAL(3, s.search(s6, 3));
|
|
|
- CORE_TEST_EQUAL(SIZE_MAX, s.search(s7, 3));
|
|
|
-}
|
|
|
-
|
|
|
-static void testContains32() {
|
|
|
- String32 s;
|
|
|
- CORE_TEST_ERROR(s.append(U"0123456789"));
|
|
|
-
|
|
|
- String32 s2;
|
|
|
- CORE_TEST_ERROR(s2.append(U"123"));
|
|
|
- String32 s3;
|
|
|
- CORE_TEST_ERROR(s3.append(U"234"));
|
|
|
- String32 s4;
|
|
|
- CORE_TEST_ERROR(s4.append(U"789"));
|
|
|
- String32 s5;
|
|
|
- CORE_TEST_ERROR(s5.append(U"124"));
|
|
|
- String32 s6;
|
|
|
- String32 s7;
|
|
|
- CORE_TEST_ERROR(s7.append(U"7891"));
|
|
|
-
|
|
|
- CORE_TEST_TRUE(s.contains(s2));
|
|
|
- CORE_TEST_TRUE(s.contains(s3));
|
|
|
- CORE_TEST_TRUE(s.contains(s4));
|
|
|
- CORE_TEST_FALSE(s.contains(s5));
|
|
|
- CORE_TEST_TRUE(s.contains(s6));
|
|
|
- CORE_TEST_FALSE(s.contains(s7));
|
|
|
-}
|
|
|
-
|
|
|
-static void testSearchChar32() {
|
|
|
- String32 s;
|
|
|
- CORE_TEST_ERROR(s.append(U"01üää3ä"));
|
|
|
-
|
|
|
- CORE_TEST_EQUAL(0, s.search('0'));
|
|
|
- CORE_TEST_EQUAL(1, s.search('1'));
|
|
|
- CORE_TEST_EQUAL(5, s.search('3'));
|
|
|
- CORE_TEST_EQUAL(2, s.search(U'ü'));
|
|
|
- CORE_TEST_EQUAL(3, s.search(U'ä'));
|
|
|
- CORE_TEST_EQUAL(4, s.search(U'ä', 4));
|
|
|
- CORE_TEST_EQUAL(6, s.search(U'ä', 5));
|
|
|
-}
|
|
|
-
|
|
|
-static void testContainsChar32() {
|
|
|
- String32 s;
|
|
|
- CORE_TEST_ERROR(s.append(U"01üää3ä"));
|
|
|
- CORE_TEST_TRUE(s.contains(U'0'));
|
|
|
- CORE_TEST_TRUE(s.contains(U'1'));
|
|
|
- CORE_TEST_TRUE(s.contains(U'3'));
|
|
|
- CORE_TEST_FALSE(s.contains(U'a'));
|
|
|
- CORE_TEST_TRUE(s.contains(U'0'));
|
|
|
- CORE_TEST_TRUE(s.contains(U'1'));
|
|
|
- CORE_TEST_TRUE(s.contains(U'ü'));
|
|
|
- CORE_TEST_TRUE(s.contains(U'ä'));
|
|
|
- CORE_TEST_FALSE(s.contains(U'ö'));
|
|
|
-}
|
|
|
-
|
|
|
-static void testSubString32() {
|
|
|
- String32 s;
|
|
|
- CORE_TEST_ERROR(s.append(U"01üää3ä"));
|
|
|
-
|
|
|
- String32 sub;
|
|
|
- CORE_TEST_ERROR(s.substring(sub, 0));
|
|
|
- CORE_TEST_STRING(U"01üää3ä", sub);
|
|
|
- CORE_TEST_ERROR(s.substring(sub, 1));
|
|
|
- CORE_TEST_STRING(U"1üää3ä", sub);
|
|
|
- CORE_TEST_ERROR(s.substring(sub, 2));
|
|
|
- CORE_TEST_STRING(U"üää3ä", sub);
|
|
|
- CORE_TEST_ERROR(s.substring(sub, 3));
|
|
|
- CORE_TEST_STRING(U"ää3ä", sub);
|
|
|
- CORE_TEST_ERROR(s.substring(sub, 4));
|
|
|
- CORE_TEST_STRING(U"ä3ä", sub);
|
|
|
-
|
|
|
- CORE_TEST_ERROR(s.substring(sub, 0, 6));
|
|
|
- CORE_TEST_STRING(U"01üää3ä", sub);
|
|
|
- CORE_TEST_ERROR(s.substring(sub, 1, 5));
|
|
|
- CORE_TEST_STRING(U"1üää3", sub);
|
|
|
- CORE_TEST_ERROR(s.substring(sub, 2, 4));
|
|
|
- CORE_TEST_STRING(U"üää", sub);
|
|
|
- CORE_TEST_ERROR(s.substring(sub, 3, 3));
|
|
|
- CORE_TEST_STRING(U"ä", sub);
|
|
|
- CORE_TEST_ERROR(s.substring(sub, 4, 2));
|
|
|
- CORE_TEST_STRING(U"", sub);
|
|
|
- CORE_TEST_ERROR(s.substring(sub, 4, 23));
|
|
|
- CORE_TEST_STRING(U"ä3ä", sub);
|
|
|
-}
|
|
|
-
|
|
|
-static void testReplace32() {
|
|
|
- String32 s;
|
|
|
- CORE_TEST_ERROR(s.append(U"0äääää1üää3ä"));
|
|
|
-
|
|
|
- String32 search;
|
|
|
- CORE_TEST_ERROR(search.append(U"ää"));
|
|
|
-
|
|
|
- String32 replace;
|
|
|
- CORE_TEST_ERROR(replace.append(U"ABCD"));
|
|
|
- CORE_TEST_ERROR(s.replace(search, replace));
|
|
|
- CORE_TEST_STRING(U"0ABCDABCDä1üABCD3ä", s);
|
|
|
-}
|
|
|
-
|
|
|
-static void testReplaceChar32() {
|
|
|
- String32 s;
|
|
|
- CORE_TEST_ERROR(s.append(U"01üää3ä"));
|
|
|
- s.replace(U'0', U'A');
|
|
|
- CORE_TEST_STRING(U"A1üää3ä", s);
|
|
|
- s.replace(U'1', U'B');
|
|
|
- CORE_TEST_STRING(U"ABüää3ä", s);
|
|
|
- s.replace(U'ü', U'C');
|
|
|
- CORE_TEST_STRING(U"ABCää3ä", s);
|
|
|
- s.replace(U'ä', U'D');
|
|
|
- CORE_TEST_STRING(U"ABCDD3D", s);
|
|
|
- s.replace(U'3', U'E');
|
|
|
- CORE_TEST_STRING(U"ABCDDED", s);
|
|
|
-}
|
|
|
-
|
|
|
-static void testCastAppendSelf32() {
|
|
|
- String32 s;
|
|
|
- CORE_TEST_ERROR(s.append("abc"));
|
|
|
- CORE_TEST_ERROR(s.append(s));
|
|
|
- CORE_TEST_ERROR(s.append(static_cast<const c32*>(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::ErrorCode::NONE));
|
|
|
- CORE_TEST_STRING(U"0", s);
|
|
|
-}
|
|
|
-
|
|
|
-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);
|
|
|
- s.print();
|
|
|
-}
|
|
|
-
|
|
|
-static void testVariousUnicode32() {
|
|
|
- const unsigned char buffer[] = {0xC0, 0};
|
|
|
- const unsigned char buffer2[] = {0xE0, 0};
|
|
|
- const unsigned char buffer3[] = {0xC3, 0xA4, 0};
|
|
|
- const unsigned char buffer4[] = {0xF0, 0};
|
|
|
- const unsigned char buffer5[] = {0xF0, 0x9F, 0x8F, 0xA3, 0};
|
|
|
- const unsigned char buffer6[] = {0xFF, 0};
|
|
|
- String32 s;
|
|
|
- CORE_TEST_EQUAL(Core::ErrorCode::INVALID_CHAR, s.append(buffer));
|
|
|
- CORE_TEST_EQUAL(Core::ErrorCode::INVALID_CHAR, s.append(buffer2));
|
|
|
- CORE_TEST_EQUAL(Core::ErrorCode::NONE, s.append(buffer3));
|
|
|
- CORE_TEST_EQUAL(Core::ErrorCode::INVALID_CHAR, s.append(buffer4));
|
|
|
- CORE_TEST_EQUAL(Core::ErrorCode::NONE, s.append(buffer5));
|
|
|
- CORE_TEST_EQUAL(Core::ErrorCode::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 testInvalidPrint32() {
|
|
|
- String32 s;
|
|
|
- CORE_TEST_ERROR(s.append(static_cast<c32>(0xFFFFFFFF)));
|
|
|
- s.printLine();
|
|
|
+static void testInvalidUnicodeString() {
|
|
|
+ String s;
|
|
|
+ s.append(static_cast<c32>(0xFFFFFFFF));
|
|
|
+ CORE_TEST_STRING("?", s);
|
|
|
}
|
|
|
|
|
|
static void testConversion() {
|
|
|
const c32* a = U"öüewfde_§$§%$ädsf";
|
|
|
const char* b = "öüewfde_§$§%$ädsf";
|
|
|
|
|
|
- String32 sa;
|
|
|
- CORE_TEST_ERROR(sa.append(a));
|
|
|
- String8 sb;
|
|
|
- CORE_TEST_ERROR(sb.append(b));
|
|
|
+ String s;
|
|
|
+ s.append(a);
|
|
|
+ String s2;
|
|
|
+ s2.append(b);
|
|
|
|
|
|
- String8 sa2;
|
|
|
- CORE_TEST_ERROR(sa2.append(sa));
|
|
|
- String32 sb2;
|
|
|
- CORE_TEST_ERROR(sb2.append(sb));
|
|
|
-
|
|
|
- CORE_TEST_STRING(a, sa2);
|
|
|
- CORE_TEST_STRING(b, sb2);
|
|
|
+ CORE_TEST_STRING(s, s2);
|
|
|
}
|
|
|
|
|
|
void Core::testArrayString() {
|
|
|
- testEquality8();
|
|
|
- testUnicodeEquality8();
|
|
|
- testInequality8();
|
|
|
- testStringAppend8();
|
|
|
- testStringAppendOverflow8();
|
|
|
- testCharacters8();
|
|
|
- testLength8();
|
|
|
- testChar8();
|
|
|
- testSignedChar8();
|
|
|
- testUnsignedChar8();
|
|
|
- testSignedShort8();
|
|
|
- testUnsignedShort8();
|
|
|
- testSignedInt8();
|
|
|
- testUnsignedInt8();
|
|
|
- testSignedLong8();
|
|
|
- testUnsignedLong8();
|
|
|
- testSignedLongLong8();
|
|
|
- testUnsignedLongLong8();
|
|
|
- testFloat8();
|
|
|
- testDouble8();
|
|
|
- testLongDouble8();
|
|
|
- testBool8();
|
|
|
- testIntOverflow8();
|
|
|
- testUnicode8();
|
|
|
- testClear8();
|
|
|
- testAddSelf8();
|
|
|
- testStartsWith8();
|
|
|
- testSearch8();
|
|
|
- testContains8();
|
|
|
- testSearchChar8();
|
|
|
- testContainsChar8();
|
|
|
- testSubString8();
|
|
|
- testReplace8();
|
|
|
- testReplaceChar8();
|
|
|
- testCastAppendSelf8();
|
|
|
- testCompareWithShorter8();
|
|
|
- testAppendSignedChar8();
|
|
|
- testAppendUnsignedChar8();
|
|
|
- testAppendError8();
|
|
|
- testPrint8();
|
|
|
- testKeepHash8();
|
|
|
- testFormatWithoutArguments8();
|
|
|
- testUnicodeString8();
|
|
|
- testInvalidUnicodeString8();
|
|
|
-
|
|
|
- testEquality32();
|
|
|
- testUnicodeEquality32();
|
|
|
- testInequality32();
|
|
|
- testStringAppend32();
|
|
|
- testStringAppendOverflow32();
|
|
|
- testCharacters32();
|
|
|
- testLength32();
|
|
|
- testChar32();
|
|
|
- testSignedChar32();
|
|
|
- testUnsignedChar32();
|
|
|
- testSignedShort32();
|
|
|
- testUnsignedShort32();
|
|
|
- testSignedInt32();
|
|
|
- testUnsignedInt32();
|
|
|
- testSignedLong32();
|
|
|
- testUnsignedLong32();
|
|
|
- testSignedLongLong32();
|
|
|
- testUnsignedLongLong32();
|
|
|
- testFloat32();
|
|
|
- testDouble32();
|
|
|
- testLongDouble32();
|
|
|
- testBool32();
|
|
|
- testIntOverflow32();
|
|
|
- testUnicode32();
|
|
|
- testClear32();
|
|
|
- testAddSelf32();
|
|
|
- testStartsWith32();
|
|
|
- testSearch32();
|
|
|
- testContains32();
|
|
|
- testSearchChar32();
|
|
|
- testContainsChar32();
|
|
|
- testSubString32();
|
|
|
- testReplace32();
|
|
|
- testReplaceChar32();
|
|
|
- testCastAppendSelf32();
|
|
|
- testCompareWithShorter32();
|
|
|
- testAppendSignedChar32();
|
|
|
- testAppendUnsignedChar32();
|
|
|
- testAppendError32();
|
|
|
- testPrint32();
|
|
|
- testVariousUnicode32();
|
|
|
- testKeepHash32();
|
|
|
- testInvalidPrint32();
|
|
|
-
|
|
|
+ testEquality();
|
|
|
+ testUnicodeEquality();
|
|
|
+ testInequality();
|
|
|
+ testStringAppend();
|
|
|
+ testStringAppendOverflow();
|
|
|
+ testCharacters();
|
|
|
+ testLength();
|
|
|
+ testChar();
|
|
|
+ testSignedChar();
|
|
|
+ testUnsignedChar();
|
|
|
+ testSignedShort();
|
|
|
+ testUnsignedShort();
|
|
|
+ testSignedInt();
|
|
|
+ testUnsignedInt();
|
|
|
+ testSignedLong();
|
|
|
+ testUnsignedLong();
|
|
|
+ testSignedLongLong();
|
|
|
+ testUnsignedLongLong();
|
|
|
+ testFloat();
|
|
|
+ testDouble();
|
|
|
+ testLongDouble();
|
|
|
+ testBool();
|
|
|
+ testIntOverflow();
|
|
|
+ testUnicode();
|
|
|
+ testClear();
|
|
|
+ testAddSelf();
|
|
|
+ testStartsWith();
|
|
|
+ testSearch();
|
|
|
+ testContains();
|
|
|
+ testSearchChar();
|
|
|
+ testContainsChar();
|
|
|
+ testSubString();
|
|
|
+ testReplace();
|
|
|
+ testReplaceChar();
|
|
|
+ testCastAppendSelf();
|
|
|
+ testCompareWithShorter();
|
|
|
+ testAppendSignedChar();
|
|
|
+ testAppendUnsignedChar();
|
|
|
+ testAppendError();
|
|
|
+ testPrint();
|
|
|
+ testKeepHash();
|
|
|
+ testFormatWithoutArguments();
|
|
|
+ testUnicodeString();
|
|
|
+ testInvalidUnicodeString();
|
|
|
testConversion();
|
|
|
}
|