mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 10:08:18 +00:00
Add string and nameban tests with Unicode characters
This commit is contained in:
parent
c65ffeb4ae
commit
aa85c5b4a8
|
@ -15,6 +15,7 @@ TEST(NameBan, Equality)
|
||||||
ASSERT_TRUE(IsNameBanned(" abc", &Abc0, 1));
|
ASSERT_TRUE(IsNameBanned(" abc", &Abc0, 1));
|
||||||
ASSERT_TRUE(IsNameBanned("abc ", &Abc0, 1));
|
ASSERT_TRUE(IsNameBanned("abc ", &Abc0, 1));
|
||||||
ASSERT_TRUE(IsNameBanned("abc foo", &Abc0, 1)); // Maximum name length.
|
ASSERT_TRUE(IsNameBanned("abc foo", &Abc0, 1)); // Maximum name length.
|
||||||
|
ASSERT_TRUE(IsNameBanned("äbc", &Abc0, 1)); // Confusables
|
||||||
ASSERT_FALSE(IsNameBanned("def", &Abc0, 1));
|
ASSERT_FALSE(IsNameBanned("def", &Abc0, 1));
|
||||||
ASSERT_FALSE(IsNameBanned("abcdef", &Abc0, 1));
|
ASSERT_FALSE(IsNameBanned("abcdef", &Abc0, 1));
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,8 +20,14 @@ TEST(Str, Dist)
|
||||||
|
|
||||||
TEST(Str, Utf8Isspace)
|
TEST(Str, Utf8Isspace)
|
||||||
{
|
{
|
||||||
|
EXPECT_TRUE(str_utf8_isspace(0x200b)); // Zero-width space
|
||||||
EXPECT_TRUE(str_utf8_isspace(' '));
|
EXPECT_TRUE(str_utf8_isspace(' '));
|
||||||
EXPECT_FALSE(str_utf8_isspace('a'));
|
EXPECT_FALSE(str_utf8_isspace('a'));
|
||||||
|
// Control characters.
|
||||||
|
for(char c = 0; c < 0x20; c++)
|
||||||
|
{
|
||||||
|
EXPECT_TRUE(str_utf8_isspace(c));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(Str, Utf8SkipWhitespaces)
|
TEST(Str, Utf8SkipWhitespaces)
|
||||||
|
@ -29,6 +35,7 @@ TEST(Str, Utf8SkipWhitespaces)
|
||||||
EXPECT_STREQ(str_utf8_skip_whitespaces("abc"), "abc");
|
EXPECT_STREQ(str_utf8_skip_whitespaces("abc"), "abc");
|
||||||
EXPECT_STREQ(str_utf8_skip_whitespaces("abc "), "abc ");
|
EXPECT_STREQ(str_utf8_skip_whitespaces("abc "), "abc ");
|
||||||
EXPECT_STREQ(str_utf8_skip_whitespaces(" abc"), "abc");
|
EXPECT_STREQ(str_utf8_skip_whitespaces(" abc"), "abc");
|
||||||
|
EXPECT_STREQ(str_utf8_skip_whitespaces("\xe2\x80\x8b abc"), "abc");
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(Str, Utf8TrimRight)
|
TEST(Str, Utf8TrimRight)
|
||||||
|
@ -36,4 +43,5 @@ TEST(Str, Utf8TrimRight)
|
||||||
char A1[] = "abc"; str_utf8_trim_right(A1); EXPECT_STREQ(A1, "abc");
|
char A1[] = "abc"; str_utf8_trim_right(A1); EXPECT_STREQ(A1, "abc");
|
||||||
char A2[] = " abc"; str_utf8_trim_right(A2); EXPECT_STREQ(A2, " abc");
|
char A2[] = " abc"; str_utf8_trim_right(A2); EXPECT_STREQ(A2, " abc");
|
||||||
char A3[] = "abc "; str_utf8_trim_right(A3); EXPECT_STREQ(A3, "abc");
|
char A3[] = "abc "; str_utf8_trim_right(A3); EXPECT_STREQ(A3, "abc");
|
||||||
|
char A4[] = "abc \xe2\x80\x8b"; str_utf8_trim_right(A4); EXPECT_STREQ(A4, "abc");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue