Add test cases

This commit is contained in:
TsFreddie 2020-09-06 23:57:21 +01:00
parent 6b053936c7
commit e48596dc6c

View file

@ -208,3 +208,29 @@ TEST(Str, StrCopyNum)
str_utf8_truncate(aBuf3, sizeof(aBuf3), foo, 7);
EXPECT_STREQ(aBuf3, "Foobaré");
}
TEST(Str, StrCopyUtf8)
{
const char *foo = "DDNet最好了";
char aBuf[64];
str_utf8_copy(aBuf, foo, 7);
EXPECT_STREQ(aBuf, "DDNet");
str_utf8_copy(aBuf, foo, 8);
EXPECT_STREQ(aBuf, "DDNet");
str_utf8_copy(aBuf, foo, 9);
EXPECT_STREQ(aBuf, "DDNet");
str_utf8_copy(aBuf, foo, 10);
EXPECT_STREQ(aBuf, "DDNet最");
str_utf8_copy(aBuf, foo, 11);
EXPECT_STREQ(aBuf, "DDNet最");
str_utf8_copy(aBuf, foo, 12);
EXPECT_STREQ(aBuf, "DDNet最");
str_utf8_copy(aBuf, foo, 13);
EXPECT_STREQ(aBuf, "DDNet最好");
str_utf8_copy(aBuf, foo, 14);
EXPECT_STREQ(aBuf, "DDNet最好");
str_utf8_copy(aBuf, foo, 15);
EXPECT_STREQ(aBuf, "DDNet最好");
str_utf8_copy(aBuf, foo, 16);
EXPECT_STREQ(aBuf, "DDNet最好了");
}