|
@@ -8,7 +8,7 @@ using String = Core::ArrayString<128>;
|
|
|
|
|
|
static String build(const char* cs) {
|
|
|
String s;
|
|
|
- CORE_TEST_FALSE(s.append(cs));
|
|
|
+ CORE_TEST_ERROR(s.append(cs));
|
|
|
return s;
|
|
|
}
|
|
|
|
|
@@ -42,16 +42,16 @@ static void testInequality() {
|
|
|
|
|
|
static void testStringAppend() {
|
|
|
String s = build("test");
|
|
|
- CORE_TEST_FALSE(s.append("22"));
|
|
|
- CORE_TEST_FALSE(s.append("333"));
|
|
|
- CORE_TEST_FALSE(s.append("4444"));
|
|
|
+ CORE_TEST_ERROR(s.append("22"));
|
|
|
+ CORE_TEST_ERROR(s.append("333"));
|
|
|
+ CORE_TEST_ERROR(s.append("4444"));
|
|
|
CORE_TEST_EQUAL(build("test223334444"), s);
|
|
|
}
|
|
|
|
|
|
static void testStringAppendOverflow() {
|
|
|
Core::ArrayString<20> s;
|
|
|
- CORE_TEST_FALSE(s.append("te"));
|
|
|
- CORE_TEST_TRUE(s.append("23334444"));
|
|
|
+ CORE_TEST_ERROR(s.append("te"));
|
|
|
+ CORE_TEST_EQUAL(Core::Error::CAPACITY_REACHED, s.append("23334444"));
|
|
|
CORE_TEST_TRUE(build("te23334444") != s);
|
|
|
}
|
|
|
|
|
@@ -66,14 +66,14 @@ static void testCharacters() {
|
|
|
static void testLength() {
|
|
|
String s = build("test");
|
|
|
CORE_TEST_EQUAL(4, s.getLength());
|
|
|
- CORE_TEST_FALSE(s.append("aaa"));
|
|
|
+ CORE_TEST_ERROR(s.append("aaa"));
|
|
|
CORE_TEST_EQUAL(7, s.getLength());
|
|
|
}
|
|
|
|
|
|
static void testChar() {
|
|
|
String s = build("test");
|
|
|
for(char i = 'a'; i < 'd'; i++) {
|
|
|
- CORE_TEST_FALSE(s.append(i));
|
|
|
+ CORE_TEST_ERROR(s.append(i));
|
|
|
}
|
|
|
CORE_TEST_EQUAL(build("testabc"), s);
|
|
|
}
|
|
@@ -81,7 +81,7 @@ static void testChar() {
|
|
|
static void testSignedChar() {
|
|
|
String s = build("test");
|
|
|
for(signed char i = 'b'; i < 'e'; i++) {
|
|
|
- CORE_TEST_FALSE(s.append(i));
|
|
|
+ CORE_TEST_ERROR(s.append(i));
|
|
|
}
|
|
|
CORE_TEST_EQUAL(build("testbcd"), s);
|
|
|
}
|
|
@@ -89,7 +89,7 @@ static void testSignedChar() {
|
|
|
static void testUnsignedChar() {
|
|
|
String s = build("test");
|
|
|
for(unsigned char i = 'c'; i < 'f'; i++) {
|
|
|
- CORE_TEST_FALSE(s.append(i));
|
|
|
+ CORE_TEST_ERROR(s.append(i));
|
|
|
}
|
|
|
CORE_TEST_EQUAL(build("testcde"), s);
|
|
|
}
|
|
@@ -97,7 +97,7 @@ static void testUnsignedChar() {
|
|
|
static void testSignedShort() {
|
|
|
String s = build("test");
|
|
|
for(signed short i = 100; i < 103; i++) {
|
|
|
- CORE_TEST_FALSE(s.append(i));
|
|
|
+ CORE_TEST_ERROR(s.append(i));
|
|
|
}
|
|
|
CORE_TEST_EQUAL(build("test100101102"), s);
|
|
|
}
|
|
@@ -105,7 +105,7 @@ static void testSignedShort() {
|
|
|
static void testUnsignedShort() {
|
|
|
String s = build("test");
|
|
|
for(unsigned short i = 101; i < 104; i++) {
|
|
|
- CORE_TEST_FALSE(s.append(i));
|
|
|
+ CORE_TEST_ERROR(s.append(i));
|
|
|
}
|
|
|
CORE_TEST_EQUAL(build("test101102103"), s);
|
|
|
}
|
|
@@ -113,7 +113,7 @@ static void testUnsignedShort() {
|
|
|
static void testSignedInt() {
|
|
|
String s = build("test");
|
|
|
for(signed int i = 102; i < 105; i++) {
|
|
|
- CORE_TEST_FALSE(s.append(i));
|
|
|
+ CORE_TEST_ERROR(s.append(i));
|
|
|
}
|
|
|
CORE_TEST_EQUAL(build("test102103104"), s);
|
|
|
}
|
|
@@ -121,7 +121,7 @@ static void testSignedInt() {
|
|
|
static void testUnsignedInt() {
|
|
|
String s = build("test");
|
|
|
for(unsigned int i = 103; i < 106; i++) {
|
|
|
- CORE_TEST_FALSE(s.append(i));
|
|
|
+ CORE_TEST_ERROR(s.append(i));
|
|
|
}
|
|
|
CORE_TEST_EQUAL(build("test103104105"), s);
|
|
|
}
|
|
@@ -129,7 +129,7 @@ static void testUnsignedInt() {
|
|
|
static void testSignedLong() {
|
|
|
String s = build("test");
|
|
|
for(signed long i = 104; i < 107; i++) {
|
|
|
- CORE_TEST_FALSE(s.append(i));
|
|
|
+ CORE_TEST_ERROR(s.append(i));
|
|
|
}
|
|
|
CORE_TEST_EQUAL(build("test104105106"), s);
|
|
|
}
|
|
@@ -137,7 +137,7 @@ static void testSignedLong() {
|
|
|
static void testUnsignedLong() {
|
|
|
String s = build("test");
|
|
|
for(unsigned long i = 105; i < 108; i++) {
|
|
|
- CORE_TEST_FALSE(s.append(i));
|
|
|
+ CORE_TEST_ERROR(s.append(i));
|
|
|
}
|
|
|
CORE_TEST_EQUAL(build("test105106107"), s);
|
|
|
}
|
|
@@ -145,7 +145,7 @@ static void testUnsignedLong() {
|
|
|
static void testSignedLongLong() {
|
|
|
String s = build("test");
|
|
|
for(signed long long i = 106; i < 109; i++) {
|
|
|
- CORE_TEST_FALSE(s.append(i));
|
|
|
+ CORE_TEST_ERROR(s.append(i));
|
|
|
}
|
|
|
CORE_TEST_EQUAL(build("test106107108"), s);
|
|
|
}
|
|
@@ -153,7 +153,7 @@ static void testSignedLongLong() {
|
|
|
static void testUnsignedLongLong() {
|
|
|
String s = build("test");
|
|
|
for(unsigned long long i = 107; i < 110; i++) {
|
|
|
- CORE_TEST_FALSE(s.append(i));
|
|
|
+ CORE_TEST_ERROR(s.append(i));
|
|
|
}
|
|
|
CORE_TEST_EQUAL(build("test107108109"), s);
|
|
|
}
|
|
@@ -161,7 +161,7 @@ static void testUnsignedLongLong() {
|
|
|
static void testFloat() {
|
|
|
String s = build("test");
|
|
|
for(float i = 108; i < 111; i++) {
|
|
|
- CORE_TEST_FALSE(s.append(i));
|
|
|
+ CORE_TEST_ERROR(s.append(i));
|
|
|
}
|
|
|
CORE_TEST_EQUAL(build("test108.00109.00110.00"), s);
|
|
|
}
|
|
@@ -169,7 +169,7 @@ static void testFloat() {
|
|
|
static void testDouble() {
|
|
|
String s = build("test");
|
|
|
for(double i = 109; i < 112; i++) {
|
|
|
- CORE_TEST_FALSE(s.append(i));
|
|
|
+ CORE_TEST_ERROR(s.append(i));
|
|
|
}
|
|
|
CORE_TEST_EQUAL(build("test109.00110.00111.00"), s);
|
|
|
}
|
|
@@ -177,26 +177,26 @@ static void testDouble() {
|
|
|
static void testLongDouble() {
|
|
|
String s = build("test");
|
|
|
for(long double i = 110; i < 113; i++) {
|
|
|
- CORE_TEST_FALSE(s.append(i));
|
|
|
+ CORE_TEST_ERROR(s.append(i));
|
|
|
}
|
|
|
CORE_TEST_EQUAL(build("test110.00111.00112.00"), s);
|
|
|
}
|
|
|
|
|
|
static void testBool() {
|
|
|
String s = build("test");
|
|
|
- CORE_TEST_FALSE(s.append(true));
|
|
|
- CORE_TEST_FALSE(s.append(false));
|
|
|
- CORE_TEST_FALSE(s.append(true));
|
|
|
+ CORE_TEST_ERROR(s.append(true));
|
|
|
+ CORE_TEST_ERROR(s.append(false));
|
|
|
+ CORE_TEST_ERROR(s.append(true));
|
|
|
CORE_TEST_EQUAL(build("testtruefalsetrue"), s);
|
|
|
}
|
|
|
|
|
|
static void testIntOverflow() {
|
|
|
Core::ArrayString<20> s;
|
|
|
- CORE_TEST_TRUE(s.append(123456));
|
|
|
+ CORE_TEST_EQUAL(Core::Error::CAPACITY_REACHED, s.append(123456));
|
|
|
|
|
|
String o;
|
|
|
for(int i = 0; i < s.getCapacity(); i++) {
|
|
|
- CORE_TEST_FALSE(o.append(i + 1));
|
|
|
+ CORE_TEST_ERROR(o.append(i + 1));
|
|
|
}
|
|
|
|
|
|
CORE_TEST_TRUE(o == s);
|
|
@@ -204,29 +204,29 @@ static void testIntOverflow() {
|
|
|
|
|
|
static void testUnicode() {
|
|
|
String s;
|
|
|
- CORE_TEST_FALSE(s.appendUnicode('\u0040'));
|
|
|
- CORE_TEST_FALSE(s.appendUnicode(L'\u0400'));
|
|
|
- CORE_TEST_FALSE(s.appendUnicode(L'\u8000'));
|
|
|
- CORE_TEST_FALSE(s.appendUnicode(U'\U00100000'));
|
|
|
+ CORE_TEST_ERROR(s.appendUnicode('\u0040'));
|
|
|
+ CORE_TEST_ERROR(s.appendUnicode(L'\u0400'));
|
|
|
+ CORE_TEST_ERROR(s.appendUnicode(L'\u8000'));
|
|
|
+ CORE_TEST_ERROR(s.appendUnicode(U'\U00100000'));
|
|
|
CORE_TEST_EQUAL(build("\u0040\u0400\u8000\U00100000"), s);
|
|
|
}
|
|
|
|
|
|
static void testClear() {
|
|
|
String s = build("test");
|
|
|
- CORE_TEST_FALSE(s.append(1234));
|
|
|
+ CORE_TEST_ERROR(s.append(1234));
|
|
|
s.clear();
|
|
|
- CORE_TEST_FALSE(s.append("wusi"));
|
|
|
- CORE_TEST_FALSE(s.append("1234"));
|
|
|
+ CORE_TEST_ERROR(s.append("wusi"));
|
|
|
+ CORE_TEST_ERROR(s.append("1234"));
|
|
|
CORE_TEST_EQUAL(build("wusi1234"), s);
|
|
|
}
|
|
|
|
|
|
static void testHashCode() {
|
|
|
String s;
|
|
|
- CORE_TEST_FALSE(s.append("a"));
|
|
|
- CORE_TEST_FALSE(s.append("bc"));
|
|
|
- CORE_TEST_FALSE(s.append(20));
|
|
|
- CORE_TEST_FALSE(s.append(25.5f));
|
|
|
- CORE_TEST_FALSE(s.append(true));
|
|
|
+ CORE_TEST_ERROR(s.append("a"));
|
|
|
+ CORE_TEST_ERROR(s.append("bc"));
|
|
|
+ CORE_TEST_ERROR(s.append(20));
|
|
|
+ CORE_TEST_ERROR(s.append(25.5f));
|
|
|
+ CORE_TEST_ERROR(s.append(true));
|
|
|
CORE_TEST_EQUAL(build("abc2025.50true").hashCode(), s.hashCode());
|
|
|
s.clear();
|
|
|
CORE_TEST_EQUAL(String().hashCode(), s.hashCode());
|
|
@@ -234,17 +234,17 @@ static void testHashCode() {
|
|
|
|
|
|
static void testAddSelf() {
|
|
|
String s;
|
|
|
- CORE_TEST_FALSE(s.append("test1"));
|
|
|
- CORE_TEST_FALSE(s.append(s));
|
|
|
- CORE_TEST_FALSE(s.append(s));
|
|
|
+ CORE_TEST_ERROR(s.append("test1"));
|
|
|
+ CORE_TEST_ERROR(s.append(s));
|
|
|
+ CORE_TEST_ERROR(s.append(s));
|
|
|
CORE_TEST_EQUAL(build("test1test1test1test1"), s);
|
|
|
}
|
|
|
|
|
|
static void testAsHashMapKey() {
|
|
|
Core::HashMap<String, int> map;
|
|
|
- CORE_TEST_NOT_NULL(map.add(build("wusi"), 3));
|
|
|
- CORE_TEST_NOT_NULL(map.add(build("hiThere"), 7));
|
|
|
- CORE_TEST_NOT_NULL(map.add(build("baum123"), 5));
|
|
|
+ CORE_TEST_ERROR(map.add(build("wusi"), 3));
|
|
|
+ CORE_TEST_ERROR(map.add(build("hiThere"), 7));
|
|
|
+ CORE_TEST_ERROR(map.add(build("baum123"), 5));
|
|
|
|
|
|
int* a = map.search(build("wusi"));
|
|
|
int* b = map.search(build("hiThere"));
|
|
@@ -265,19 +265,19 @@ static void testAsHashMapKey() {
|
|
|
|
|
|
static void testStartsWith() {
|
|
|
String s;
|
|
|
- CORE_TEST_FALSE(s.append("0123456789"));
|
|
|
+ CORE_TEST_ERROR(s.append("0123456789"));
|
|
|
|
|
|
String s2;
|
|
|
- CORE_TEST_FALSE(s2.append("123"));
|
|
|
+ CORE_TEST_ERROR(s2.append("123"));
|
|
|
String s3;
|
|
|
- CORE_TEST_FALSE(s3.append("234"));
|
|
|
+ CORE_TEST_ERROR(s3.append("234"));
|
|
|
String s4;
|
|
|
- CORE_TEST_FALSE(s4.append("789"));
|
|
|
+ CORE_TEST_ERROR(s4.append("789"));
|
|
|
String s5;
|
|
|
- CORE_TEST_FALSE(s5.append("124"));
|
|
|
+ CORE_TEST_ERROR(s5.append("124"));
|
|
|
String s6;
|
|
|
String s7;
|
|
|
- CORE_TEST_FALSE(s7.append("7891"));
|
|
|
+ CORE_TEST_ERROR(s7.append("7891"));
|
|
|
|
|
|
CORE_TEST_FALSE(s.startsWidth(s2));
|
|
|
CORE_TEST_TRUE(s.startsWidth(s2, 1));
|
|
@@ -300,19 +300,19 @@ static void testStartsWith() {
|
|
|
|
|
|
static void testSearch() {
|
|
|
String s;
|
|
|
- CORE_TEST_FALSE(s.append("0123456789"));
|
|
|
+ CORE_TEST_ERROR(s.append("0123456789"));
|
|
|
|
|
|
String s2;
|
|
|
- CORE_TEST_FALSE(s2.append("123"));
|
|
|
+ CORE_TEST_ERROR(s2.append("123"));
|
|
|
String s3;
|
|
|
- CORE_TEST_FALSE(s3.append("234"));
|
|
|
+ CORE_TEST_ERROR(s3.append("234"));
|
|
|
String s4;
|
|
|
- CORE_TEST_FALSE(s4.append("789"));
|
|
|
+ CORE_TEST_ERROR(s4.append("789"));
|
|
|
String s5;
|
|
|
- CORE_TEST_FALSE(s5.append("124"));
|
|
|
+ CORE_TEST_ERROR(s5.append("124"));
|
|
|
String s6;
|
|
|
String s7;
|
|
|
- CORE_TEST_FALSE(s7.append("7891"));
|
|
|
+ CORE_TEST_ERROR(s7.append("7891"));
|
|
|
|
|
|
CORE_TEST_EQUAL(1, s.search(s2));
|
|
|
CORE_TEST_EQUAL(2, s.search(s3));
|
|
@@ -331,19 +331,19 @@ static void testSearch() {
|
|
|
|
|
|
static void testContains() {
|
|
|
String s;
|
|
|
- CORE_TEST_FALSE(s.append("0123456789"));
|
|
|
+ CORE_TEST_ERROR(s.append("0123456789"));
|
|
|
|
|
|
String s2;
|
|
|
- CORE_TEST_FALSE(s2.append("123"));
|
|
|
+ CORE_TEST_ERROR(s2.append("123"));
|
|
|
String s3;
|
|
|
- CORE_TEST_FALSE(s3.append("234"));
|
|
|
+ CORE_TEST_ERROR(s3.append("234"));
|
|
|
String s4;
|
|
|
- CORE_TEST_FALSE(s4.append("789"));
|
|
|
+ CORE_TEST_ERROR(s4.append("789"));
|
|
|
String s5;
|
|
|
- CORE_TEST_FALSE(s5.append("124"));
|
|
|
+ CORE_TEST_ERROR(s5.append("124"));
|
|
|
String s6;
|
|
|
String s7;
|
|
|
- CORE_TEST_FALSE(s7.append("7891"));
|
|
|
+ CORE_TEST_ERROR(s7.append("7891"));
|
|
|
|
|
|
CORE_TEST_TRUE(s.contains(s2));
|
|
|
CORE_TEST_TRUE(s.contains(s3));
|
|
@@ -355,7 +355,7 @@ static void testContains() {
|
|
|
|
|
|
static void testSearchChar() {
|
|
|
String s;
|
|
|
- CORE_TEST_FALSE(s.append("01üää3ä"));
|
|
|
+ CORE_TEST_ERROR(s.append("01üää3ä"));
|
|
|
|
|
|
CORE_TEST_EQUAL(0, s.search(U'0'));
|
|
|
CORE_TEST_EQUAL(1, s.search(U'1'));
|
|
@@ -368,7 +368,7 @@ static void testSearchChar() {
|
|
|
|
|
|
static void testContainsChar() {
|
|
|
String s;
|
|
|
- CORE_TEST_FALSE(s.append("01üää3ä"));
|
|
|
+ CORE_TEST_ERROR(s.append("01üää3ä"));
|
|
|
|
|
|
CORE_TEST_TRUE(s.contains(U'0'));
|
|
|
CORE_TEST_TRUE(s.contains(U'1'));
|
|
@@ -379,7 +379,7 @@ static void testContainsChar() {
|
|
|
|
|
|
static void testSubString() {
|
|
|
String s;
|
|
|
- CORE_TEST_FALSE(s.append("01üää3ä"));
|
|
|
+ CORE_TEST_ERROR(s.append("01üää3ä"));
|
|
|
|
|
|
CORE_TEST_STRING("01üää3ä", s.substring(-2));
|
|
|
CORE_TEST_STRING("1üää3ä", s.substring(1));
|
|
@@ -397,26 +397,26 @@ static void testSubString() {
|
|
|
|
|
|
static void testReplace() {
|
|
|
String s;
|
|
|
- CORE_TEST_FALSE(s.append("0äääää1üää3ä"));
|
|
|
+ CORE_TEST_ERROR(s.append("0äääää1üää3ä"));
|
|
|
|
|
|
String search;
|
|
|
- CORE_TEST_FALSE(search.append("ää"));
|
|
|
+ CORE_TEST_ERROR(search.append("ää"));
|
|
|
|
|
|
String replace;
|
|
|
- CORE_TEST_FALSE(replace.append("ABCD"));
|
|
|
+ CORE_TEST_ERROR(replace.append("ABCD"));
|
|
|
|
|
|
- CORE_TEST_FALSE(s.replace(search, replace));
|
|
|
+ CORE_TEST_ERROR(s.replace(search, replace));
|
|
|
|
|
|
CORE_TEST_STRING("0ABCDABCDä1üABCD3ä", s);
|
|
|
|
|
|
String s2;
|
|
|
- CORE_TEST_FALSE(s2.append("0ABCDABCDä1üABCD3ä"));
|
|
|
+ CORE_TEST_ERROR(s2.append("0ABCDABCDä1üABCD3ä"));
|
|
|
CORE_TEST_EQUAL(s2.hashCode(), s.hashCode());
|
|
|
}
|
|
|
|
|
|
static void testReplaceChar() {
|
|
|
String s;
|
|
|
- CORE_TEST_FALSE(s.append("01üää3ä"));
|
|
|
+ CORE_TEST_ERROR(s.append("01üää3ä"));
|
|
|
s.replace(U'0', U'A');
|
|
|
CORE_TEST_STRING("A1üää3ä", s);
|
|
|
s.replace(U'1', U'B');
|
|
@@ -429,7 +429,7 @@ static void testReplaceChar() {
|
|
|
CORE_TEST_STRING("ABCDDED", s);
|
|
|
|
|
|
String s2;
|
|
|
- CORE_TEST_FALSE(s2.append("ABCDDED"));
|
|
|
+ CORE_TEST_ERROR(s2.append("ABCDDED"));
|
|
|
CORE_TEST_EQUAL(s2.hashCode(), s.hashCode());
|
|
|
}
|
|
|
|