Add missing string tests

This commit is contained in:
sfan5 2022-12-23 17:13:32 +01:00
parent 29a448de4d
commit 735af8eec6

View File

@ -17,6 +17,8 @@ static void test_basics()
UASSERTEQ(s.c_str()[0], '\0'); UASSERTEQ(s.c_str()[0], '\0');
s = stringc(0.1234567); s = stringc(0.1234567);
UASSERTSTR(s, "0.123457"); UASSERTSTR(s, "0.123457");
s = stringc(0x1p+53);
UASSERTSTR(s, "9007199254740992.000000");
s = stringc(static_cast<int>(-102400)); s = stringc(static_cast<int>(-102400));
UASSERTSTR(s, "-102400"); UASSERTSTR(s, "-102400");
s = stringc(static_cast<unsigned int>(102400)); s = stringc(static_cast<unsigned int>(102400));
@ -27,6 +29,8 @@ static void test_basics()
UASSERTSTR(s, "1024000"); UASSERTSTR(s, "1024000");
s = stringc("YESno", 3); s = stringc("YESno", 3);
UASSERTSTR(s, "YES"); UASSERTSTR(s, "YES");
s = stringc(L"test", 4);
UASSERTSTR(s, "test");
s = stringc("Hello World!"); s = stringc("Hello World!");
UASSERTSTR(s, "Hello World!"); UASSERTSTR(s, "Hello World!");
// operator= // operator=
@ -41,6 +45,11 @@ static void test_basics()
UASSERTSTR(s, "abcdef"); UASSERTSTR(s, "abcdef");
s = static_cast<const char*>(nullptr); s = static_cast<const char*>(nullptr);
UASSERTSTR(s, ""); UASSERTSTR(s, "");
// operator+
s = s + stringc("foo");
UASSERTSTR(s, "foo");
s = s + L"bar";
UASSERTSTR(s, "foobar");
// the rest // the rest
s = "f"; s = "f";
UASSERTEQ(s[0], 'f'); UASSERTEQ(s[0], 'f');
@ -53,6 +62,9 @@ static void test_basics()
UASSERT(sref < stringc("b")); UASSERT(sref < stringc("b"));
UASSERT(stringc("Z") < sref); UASSERT(stringc("Z") < sref);
UASSERT(!(sref < stringc("a"))); UASSERT(!(sref < stringc("a")));
UASSERT(sref.lower_ignore_case("AA"));
UASSERT(sref.lower_ignore_case("B"));
UASSERT(!sref.lower_ignore_case("A"));
s = "dog"; s = "dog";
UASSERT(sref != "cat"); UASSERT(sref != "cat");
UASSERT(sref != stringc("cat")); UASSERT(sref != stringc("cat"));
@ -68,6 +80,7 @@ static void test_methods()
s.clear(); s.clear();
UASSERTEQ(sref.size(), 0); UASSERTEQ(sref.size(), 0);
UASSERT(sref.empty()); UASSERT(sref.empty());
UASSERT(sref[0] == 0);
s = "\tAz#`"; s = "\tAz#`";
s.make_lower(); s.make_lower();
UASSERTSTR(s, "\taz#`"); UASSERTSTR(s, "\taz#`");