|
@@ -4,194 +4,216 @@
|
|
|
#include "test/Test.h"
|
|
|
#include "utils/ArrayString.h"
|
|
|
|
|
|
-using String = Core::ArrayString<128>;
|
|
|
-
|
|
|
+template<typename String>
|
|
|
static String build(const char* cs) {
|
|
|
String s;
|
|
|
CORE_TEST_ERROR(s.append(cs));
|
|
|
return s;
|
|
|
}
|
|
|
|
|
|
+template<typename String>
|
|
|
static void testEquality() {
|
|
|
- String s = build("test");
|
|
|
+ String s = build<String>("test");
|
|
|
CORE_TEST_TRUE(s == "test");
|
|
|
- CORE_TEST_TRUE(s == build("test"));
|
|
|
+ CORE_TEST_TRUE(s == build<String>("test"));
|
|
|
CORE_TEST_TRUE("test" == s);
|
|
|
- CORE_TEST_TRUE(build("test") == s);
|
|
|
+ CORE_TEST_TRUE(build<String>("test") == s);
|
|
|
CORE_TEST_TRUE(s == s);
|
|
|
}
|
|
|
|
|
|
+template<typename String>
|
|
|
static void testUnicodeEquality() {
|
|
|
const char* cs = "\u0040\u0400\u8000\U00100000";
|
|
|
- String s = build(cs);
|
|
|
+ String s = build<String>(cs);
|
|
|
CORE_TEST_TRUE(s == cs);
|
|
|
- CORE_TEST_TRUE(s == build(cs));
|
|
|
+ CORE_TEST_TRUE(s == build<String>(cs));
|
|
|
CORE_TEST_TRUE(cs == s);
|
|
|
- CORE_TEST_TRUE(build(cs) == s);
|
|
|
+ CORE_TEST_TRUE(build<String>(cs) == s);
|
|
|
CORE_TEST_TRUE(s == s);
|
|
|
}
|
|
|
|
|
|
+template<typename String>
|
|
|
static void testInequality() {
|
|
|
- String s = build("test");
|
|
|
+ String s = build<String>("test");
|
|
|
CORE_TEST_FALSE(s != "test");
|
|
|
- CORE_TEST_FALSE(s != build("test"));
|
|
|
+ CORE_TEST_FALSE(s != build<String>("test"));
|
|
|
CORE_TEST_FALSE("test" != s);
|
|
|
- CORE_TEST_FALSE(build("test") != s);
|
|
|
+ CORE_TEST_FALSE(build<String>("test") != s);
|
|
|
CORE_TEST_FALSE(s != s);
|
|
|
}
|
|
|
|
|
|
+template<typename String>
|
|
|
static void testStringAppend() {
|
|
|
- String s = build("test");
|
|
|
+ String s = build<String>("test");
|
|
|
CORE_TEST_ERROR(s.append("22"));
|
|
|
CORE_TEST_ERROR(s.append("333"));
|
|
|
CORE_TEST_ERROR(s.append("4444"));
|
|
|
- CORE_TEST_EQUAL(build("test223334444"), s);
|
|
|
+ CORE_TEST_EQUAL(build<String>("test223334444"), s);
|
|
|
}
|
|
|
|
|
|
+template<typename String, typename CharType>
|
|
|
static void testStringAppendOverflow() {
|
|
|
- Core::ArrayString<6> s;
|
|
|
+ Core::ArrayString<6, CharType> s;
|
|
|
CORE_TEST_ERROR(s.append("te"));
|
|
|
CORE_TEST_EQUAL(Core::Error::CAPACITY_REACHED, s.append("23334444"));
|
|
|
- CORE_TEST_TRUE(build("te23334444") != s);
|
|
|
+ CORE_TEST_TRUE(build<String>("te23334444") != s);
|
|
|
}
|
|
|
|
|
|
+template<typename String>
|
|
|
static void testCharacters() {
|
|
|
- String s = build("test");
|
|
|
+ String s = build<String>("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]);
|
|
|
}
|
|
|
|
|
|
+template<typename String>
|
|
|
static void testLength() {
|
|
|
- String s = build("test");
|
|
|
+ String s = build<String>("test");
|
|
|
CORE_TEST_EQUAL(4, s.getLength());
|
|
|
CORE_TEST_ERROR(s.append("aaa"));
|
|
|
CORE_TEST_EQUAL(7, s.getLength());
|
|
|
}
|
|
|
|
|
|
+template<typename String>
|
|
|
static void testChar() {
|
|
|
- String s = build("test");
|
|
|
+ String s = build<String>("test");
|
|
|
for(char i = 'a'; i < 'd'; i++) {
|
|
|
CORE_TEST_ERROR(s.append(i));
|
|
|
}
|
|
|
- CORE_TEST_EQUAL(build("testabc"), s);
|
|
|
+ CORE_TEST_EQUAL(build<String>("testabc"), s);
|
|
|
}
|
|
|
|
|
|
+template<typename String>
|
|
|
static void testSignedChar() {
|
|
|
- String s = build("test");
|
|
|
+ String s = build<String>("test");
|
|
|
for(signed char i = 'b'; i < 'e'; i++) {
|
|
|
CORE_TEST_ERROR(s.append(i));
|
|
|
}
|
|
|
- CORE_TEST_EQUAL(build("testbcd"), s);
|
|
|
+ CORE_TEST_EQUAL(build<String>("testbcd"), s);
|
|
|
}
|
|
|
|
|
|
+template<typename String>
|
|
|
static void testUnsignedChar() {
|
|
|
- String s = build("test");
|
|
|
+ String s = build<String>("test");
|
|
|
for(unsigned char i = 'c'; i < 'f'; i++) {
|
|
|
CORE_TEST_ERROR(s.append(i));
|
|
|
}
|
|
|
- CORE_TEST_EQUAL(build("testcde"), s);
|
|
|
+ CORE_TEST_EQUAL(build<String>("testcde"), s);
|
|
|
}
|
|
|
|
|
|
+template<typename String>
|
|
|
static void testSignedShort() {
|
|
|
- String s = build("test");
|
|
|
+ String s = build<String>("test");
|
|
|
for(signed short i = 100; i < 103; i++) {
|
|
|
CORE_TEST_ERROR(s.append(i));
|
|
|
}
|
|
|
- CORE_TEST_EQUAL(build("test100101102"), s);
|
|
|
+ CORE_TEST_EQUAL(build<String>("test100101102"), s);
|
|
|
}
|
|
|
|
|
|
+template<typename String>
|
|
|
static void testUnsignedShort() {
|
|
|
- String s = build("test");
|
|
|
+ String s = build<String>("test");
|
|
|
for(unsigned short i = 101; i < 104; i++) {
|
|
|
CORE_TEST_ERROR(s.append(i));
|
|
|
}
|
|
|
- CORE_TEST_EQUAL(build("test101102103"), s);
|
|
|
+ CORE_TEST_EQUAL(build<String>("test101102103"), s);
|
|
|
}
|
|
|
|
|
|
+template<typename String>
|
|
|
static void testSignedInt() {
|
|
|
- String s = build("test");
|
|
|
+ String s = build<String>("test");
|
|
|
for(signed int i = 102; i < 105; i++) {
|
|
|
CORE_TEST_ERROR(s.append(i));
|
|
|
}
|
|
|
- CORE_TEST_EQUAL(build("test102103104"), s);
|
|
|
+ CORE_TEST_EQUAL(build<String>("test102103104"), s);
|
|
|
}
|
|
|
|
|
|
+template<typename String>
|
|
|
static void testUnsignedInt() {
|
|
|
- String s = build("test");
|
|
|
+ String s = build<String>("test");
|
|
|
for(unsigned int i = 103; i < 106; i++) {
|
|
|
CORE_TEST_ERROR(s.append(i));
|
|
|
}
|
|
|
- CORE_TEST_EQUAL(build("test103104105"), s);
|
|
|
+ CORE_TEST_EQUAL(build<String>("test103104105"), s);
|
|
|
}
|
|
|
|
|
|
+template<typename String>
|
|
|
static void testSignedLong() {
|
|
|
- String s = build("test");
|
|
|
+ String s = build<String>("test");
|
|
|
for(signed long i = 104; i < 107; i++) {
|
|
|
CORE_TEST_ERROR(s.append(i));
|
|
|
}
|
|
|
- CORE_TEST_EQUAL(build("test104105106"), s);
|
|
|
+ CORE_TEST_EQUAL(build<String>("test104105106"), s);
|
|
|
}
|
|
|
|
|
|
+template<typename String>
|
|
|
static void testUnsignedLong() {
|
|
|
- String s = build("test");
|
|
|
+ String s = build<String>("test");
|
|
|
for(unsigned long i = 105; i < 108; i++) {
|
|
|
CORE_TEST_ERROR(s.append(i));
|
|
|
}
|
|
|
- CORE_TEST_EQUAL(build("test105106107"), s);
|
|
|
+ CORE_TEST_EQUAL(build<String>("test105106107"), s);
|
|
|
}
|
|
|
|
|
|
+template<typename String>
|
|
|
static void testSignedLongLong() {
|
|
|
- String s = build("test");
|
|
|
+ String s = build<String>("test");
|
|
|
for(signed long long i = 106; i < 109; i++) {
|
|
|
CORE_TEST_ERROR(s.append(i));
|
|
|
}
|
|
|
- CORE_TEST_EQUAL(build("test106107108"), s);
|
|
|
+ CORE_TEST_EQUAL(build<String>("test106107108"), s);
|
|
|
}
|
|
|
|
|
|
+template<typename String>
|
|
|
static void testUnsignedLongLong() {
|
|
|
- String s = build("test");
|
|
|
+ String s = build<String>("test");
|
|
|
for(unsigned long long i = 107; i < 110; i++) {
|
|
|
CORE_TEST_ERROR(s.append(i));
|
|
|
}
|
|
|
- CORE_TEST_EQUAL(build("test107108109"), s);
|
|
|
+ CORE_TEST_EQUAL(build<String>("test107108109"), s);
|
|
|
}
|
|
|
|
|
|
+template<typename String>
|
|
|
static void testFloat() {
|
|
|
- String s = build("test");
|
|
|
+ String s = build<String>("test");
|
|
|
for(float i = 108; i < 111; i++) {
|
|
|
CORE_TEST_ERROR(s.append(i));
|
|
|
}
|
|
|
- CORE_TEST_EQUAL(build("test108.00109.00110.00"), s);
|
|
|
+ CORE_TEST_EQUAL(build<String>("test108.00109.00110.00"), s);
|
|
|
}
|
|
|
|
|
|
+template<typename String>
|
|
|
static void testDouble() {
|
|
|
- String s = build("test");
|
|
|
+ String s = build<String>("test");
|
|
|
for(double i = 109; i < 112; i++) {
|
|
|
CORE_TEST_ERROR(s.append(i));
|
|
|
}
|
|
|
- CORE_TEST_EQUAL(build("test109.00110.00111.00"), s);
|
|
|
+ CORE_TEST_EQUAL(build<String>("test109.00110.00111.00"), s);
|
|
|
}
|
|
|
|
|
|
+template<typename String>
|
|
|
static void testLongDouble() {
|
|
|
- String s = build("test");
|
|
|
+ String s = build<String>("test");
|
|
|
for(long double i = 110; i < 113; i++) {
|
|
|
CORE_TEST_ERROR(s.append(i));
|
|
|
}
|
|
|
- CORE_TEST_EQUAL(build("test110.00111.00112.00"), s);
|
|
|
+ CORE_TEST_EQUAL(build<String>("test110.00111.00112.00"), s);
|
|
|
}
|
|
|
|
|
|
+template<typename String>
|
|
|
static void testBool() {
|
|
|
- String s = build("test");
|
|
|
+ String s = build<String>("test");
|
|
|
CORE_TEST_ERROR(s.append(true));
|
|
|
CORE_TEST_ERROR(s.append(false));
|
|
|
CORE_TEST_ERROR(s.append(true));
|
|
|
- CORE_TEST_EQUAL(build("testtruefalsetrue"), s);
|
|
|
+ CORE_TEST_EQUAL(build<String>("testtruefalsetrue"), s);
|
|
|
}
|
|
|
|
|
|
+template<typename String, typename CharType>
|
|
|
static void testIntOverflow() {
|
|
|
- Core::ArrayString<4> s;
|
|
|
+ Core::ArrayString<4, CharType> s;
|
|
|
CORE_TEST_EQUAL(Core::Error::CAPACITY_REACHED, s.append(123456));
|
|
|
|
|
|
String o;
|
|
@@ -202,24 +224,27 @@ static void testIntOverflow() {
|
|
|
CORE_TEST_TRUE(o == s);
|
|
|
}
|
|
|
|
|
|
+template<typename String>
|
|
|
static void testUnicode() {
|
|
|
String s;
|
|
|
- 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);
|
|
|
+ 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<String>("\u0040\u0400\u8000\U00100000"), s);
|
|
|
}
|
|
|
|
|
|
+template<typename String>
|
|
|
static void testClear() {
|
|
|
- String s = build("test");
|
|
|
+ String s = build<String>("test");
|
|
|
CORE_TEST_ERROR(s.append(1234));
|
|
|
s.clear();
|
|
|
CORE_TEST_ERROR(s.append("wusi"));
|
|
|
CORE_TEST_ERROR(s.append("1234"));
|
|
|
- CORE_TEST_EQUAL(build("wusi1234"), s);
|
|
|
+ CORE_TEST_EQUAL(build<String>("wusi1234"), s);
|
|
|
}
|
|
|
|
|
|
+template<typename String>
|
|
|
static void testHashCode() {
|
|
|
String s;
|
|
|
CORE_TEST_ERROR(s.append("a"));
|
|
@@ -227,29 +252,31 @@ static void testHashCode() {
|
|
|
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());
|
|
|
+ CORE_TEST_EQUAL(build<String>("abc2025.50true").hashCode(), s.hashCode());
|
|
|
s.clear();
|
|
|
CORE_TEST_EQUAL(String().hashCode(), s.hashCode());
|
|
|
}
|
|
|
|
|
|
+template<typename String>
|
|
|
static void testAddSelf() {
|
|
|
String 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);
|
|
|
+ CORE_TEST_EQUAL(build<String>("test1test1test1test1"), s);
|
|
|
}
|
|
|
|
|
|
+template<typename String>
|
|
|
static void testAsHashMapKey() {
|
|
|
Core::HashMap<String, int> map;
|
|
|
- CORE_TEST_ERROR(map.add(build("wusi"), 3));
|
|
|
- CORE_TEST_ERROR(map.add(build("hiThere"), 7));
|
|
|
- CORE_TEST_ERROR(map.add(build("baum123"), 5));
|
|
|
+ CORE_TEST_ERROR(map.add(build<String>("wusi"), 3));
|
|
|
+ CORE_TEST_ERROR(map.add(build<String>("hiThere"), 7));
|
|
|
+ CORE_TEST_ERROR(map.add(build<String>("baum123"), 5));
|
|
|
|
|
|
- int* a = map.search(build("wusi"));
|
|
|
- int* b = map.search(build("hiThere"));
|
|
|
- int* c = map.search(build("baum123"));
|
|
|
- int* d = map.search(build("423hifd"));
|
|
|
+ int* a = map.search(build<String>("wusi"));
|
|
|
+ int* b = map.search(build<String>("hiThere"));
|
|
|
+ int* c = map.search(build<String>("baum123"));
|
|
|
+ int* d = map.search(build<String>("423hifd"));
|
|
|
|
|
|
CORE_TEST_NOT_NULL(a);
|
|
|
CORE_TEST_NOT_NULL(b);
|
|
@@ -263,6 +290,7 @@ static void testAsHashMapKey() {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+template<typename String>
|
|
|
static void testStartsWith() {
|
|
|
String s;
|
|
|
CORE_TEST_ERROR(s.append("0123456789"));
|
|
@@ -298,6 +326,7 @@ static void testStartsWith() {
|
|
|
CORE_TEST_FALSE(s.startsWidth(s7, 7));
|
|
|
}
|
|
|
|
|
|
+template<typename String>
|
|
|
static void testSearch() {
|
|
|
String s;
|
|
|
CORE_TEST_ERROR(s.append("0123456789"));
|
|
@@ -329,6 +358,7 @@ static void testSearch() {
|
|
|
CORE_TEST_EQUAL(-1, s.search(s7, 3));
|
|
|
}
|
|
|
|
|
|
+template<typename String>
|
|
|
static void testContains() {
|
|
|
String s;
|
|
|
CORE_TEST_ERROR(s.append("0123456789"));
|
|
@@ -353,48 +383,75 @@ static void testContains() {
|
|
|
CORE_TEST_FALSE(s.contains(s7));
|
|
|
}
|
|
|
|
|
|
+template<typename String, typename CharType>
|
|
|
static void testSearchChar() {
|
|
|
String s;
|
|
|
CORE_TEST_ERROR(s.append("01üää3ä"));
|
|
|
|
|
|
- CORE_TEST_EQUAL(0, s.search(U'0'));
|
|
|
- CORE_TEST_EQUAL(1, s.search(U'1'));
|
|
|
- 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(5, s.search(U'3'));
|
|
|
- CORE_TEST_EQUAL(6, s.search(U'ä', 5));
|
|
|
+ CORE_TEST_EQUAL(0, s.search('0'));
|
|
|
+ CORE_TEST_EQUAL(1, s.search('1'));
|
|
|
+ CORE_TEST_EQUAL((Core::IsSame<CharType, c32> ? 5 : 8), s.search('3'));
|
|
|
+
|
|
|
+ if constexpr(Core::IsSame<CharType, c32>) {
|
|
|
+ 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));
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
+template<typename String, typename CharType>
|
|
|
static void testContainsChar() {
|
|
|
String s;
|
|
|
CORE_TEST_ERROR(s.append("01üää3ä"));
|
|
|
|
|
|
- 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'ö'));
|
|
|
+ if constexpr(Core::IsSame<CharType, c32>) {
|
|
|
+ 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'ö'));
|
|
|
+ } else {
|
|
|
+ CORE_TEST_TRUE(s.contains('0'));
|
|
|
+ CORE_TEST_TRUE(s.contains('1'));
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
+template<typename String, typename CharType>
|
|
|
static void testSubString() {
|
|
|
String s;
|
|
|
CORE_TEST_ERROR(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));
|
|
|
+ if constexpr(Core::IsSame<CharType, c32>) {
|
|
|
+ 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));
|
|
|
+ } else {
|
|
|
+ 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(4));
|
|
|
+ CORE_TEST_STRING("ä3ä", s.substring(6));
|
|
|
+
|
|
|
+ CORE_TEST_STRING("01üää3ä", s.substring(0, 10));
|
|
|
+ CORE_TEST_STRING("1üää3", s.substring(1, 8));
|
|
|
+ CORE_TEST_STRING("üää", s.substring(2, 7));
|
|
|
+ CORE_TEST_STRING("ä", s.substring(4, 5));
|
|
|
+ CORE_TEST_STRING("", s.substring(4, 2));
|
|
|
+ CORE_TEST_STRING("ä3ä", s.substring(6, 23));
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
+template<typename String>
|
|
|
static void testReplace() {
|
|
|
String s;
|
|
|
CORE_TEST_ERROR(s.append("0äääää1üää3ä"));
|
|
@@ -414,60 +471,81 @@ static void testReplace() {
|
|
|
CORE_TEST_EQUAL(s2.hashCode(), s.hashCode());
|
|
|
}
|
|
|
|
|
|
+template<typename String, typename CharType>
|
|
|
static void testReplaceChar() {
|
|
|
String s;
|
|
|
- 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');
|
|
|
- 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);
|
|
|
-
|
|
|
+ if constexpr(Core::IsSame<CharType, c32>) {
|
|
|
+ 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');
|
|
|
+ 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);
|
|
|
+ } else {
|
|
|
+ CORE_TEST_ERROR(s.append("01YXX3X"));
|
|
|
+ s.replace('0', 'A');
|
|
|
+ CORE_TEST_STRING("A1YXX3X", s);
|
|
|
+ s.replace('1', 'B');
|
|
|
+ CORE_TEST_STRING("ABYXX3X", s);
|
|
|
+ s.replace('Y', 'C');
|
|
|
+ CORE_TEST_STRING("ABCXX3X", s);
|
|
|
+ s.replace('X', 'D');
|
|
|
+ CORE_TEST_STRING("ABCDD3D", s);
|
|
|
+ s.replace('3', 'E');
|
|
|
+ CORE_TEST_STRING("ABCDDED", s);
|
|
|
+ }
|
|
|
String s2;
|
|
|
CORE_TEST_ERROR(s2.append("ABCDDED"));
|
|
|
CORE_TEST_EQUAL(s2.hashCode(), s.hashCode());
|
|
|
}
|
|
|
|
|
|
+template<int N, typename CharType>
|
|
|
+static void typedTest() {
|
|
|
+ using String = Core::ArrayString<N, CharType>;
|
|
|
+ testEquality<String>();
|
|
|
+ testUnicodeEquality<String>();
|
|
|
+ testInequality<String>();
|
|
|
+ testStringAppend<String>();
|
|
|
+ testStringAppendOverflow<String, CharType>();
|
|
|
+ testCharacters<String>();
|
|
|
+ testLength<String>();
|
|
|
+ testChar<String>();
|
|
|
+ testSignedChar<String>();
|
|
|
+ testUnsignedChar<String>();
|
|
|
+ testSignedShort<String>();
|
|
|
+ testUnsignedShort<String>();
|
|
|
+ testSignedInt<String>();
|
|
|
+ testUnsignedInt<String>();
|
|
|
+ testSignedLong<String>();
|
|
|
+ testUnsignedLong<String>();
|
|
|
+ testSignedLongLong<String>();
|
|
|
+ testUnsignedLongLong<String>();
|
|
|
+ testFloat<String>();
|
|
|
+ testDouble<String>();
|
|
|
+ testLongDouble<String>();
|
|
|
+ testBool<String>();
|
|
|
+ testIntOverflow<String, CharType>();
|
|
|
+ testUnicode<String>();
|
|
|
+ testClear<String>();
|
|
|
+ testHashCode<String>();
|
|
|
+ testAddSelf<String>();
|
|
|
+ testAsHashMapKey<String>();
|
|
|
+ testStartsWith<String>();
|
|
|
+ testSearch<String>();
|
|
|
+ testContains<String>();
|
|
|
+ testSearchChar<String, CharType>();
|
|
|
+ testContainsChar<String, CharType>();
|
|
|
+ testSubString<String, CharType>();
|
|
|
+ testReplace<String>();
|
|
|
+ testReplaceChar<String, CharType>();
|
|
|
+}
|
|
|
+
|
|
|
void Core::ArrayStringTests::test() {
|
|
|
- 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();
|
|
|
- testHashCode();
|
|
|
- testAddSelf();
|
|
|
- testAsHashMapKey();
|
|
|
- testStartsWith();
|
|
|
- testSearch();
|
|
|
- testContains();
|
|
|
- testSearchChar();
|
|
|
- testContainsChar();
|
|
|
- testSubString();
|
|
|
- testReplace();
|
|
|
- testReplaceChar();
|
|
|
+ typedTest<128, c32>();
|
|
|
+ typedTest<128, char>();
|
|
|
}
|