2018-03-14 01:35:31 +00:00
|
|
|
#include <gtest/gtest.h>
|
|
|
|
|
|
|
|
#include <engine/server/name_ban.h>
|
|
|
|
|
|
|
|
TEST(NameBan, Empty)
|
|
|
|
{
|
2019-03-12 01:06:54 +00:00
|
|
|
EXPECT_FALSE(IsNameBanned("", 0, 0));
|
|
|
|
EXPECT_FALSE(IsNameBanned("abc", 0, 0));
|
2018-03-14 01:35:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
TEST(NameBan, Equality)
|
|
|
|
{
|
2019-03-03 18:02:42 +00:00
|
|
|
CNameBan Abc0("abc", 0, 0);
|
2019-03-12 01:06:54 +00:00
|
|
|
EXPECT_TRUE(IsNameBanned("abc", &Abc0, 1));
|
|
|
|
EXPECT_TRUE(IsNameBanned(" abc", &Abc0, 1));
|
|
|
|
EXPECT_TRUE(IsNameBanned("abc ", &Abc0, 1));
|
|
|
|
EXPECT_TRUE(IsNameBanned("abc foo", &Abc0, 1)); // Maximum name length.
|
|
|
|
EXPECT_TRUE(IsNameBanned("äbc", &Abc0, 1)); // Confusables
|
|
|
|
EXPECT_FALSE(IsNameBanned("def", &Abc0, 1));
|
|
|
|
EXPECT_FALSE(IsNameBanned("abcdef", &Abc0, 1));
|
2018-03-14 01:35:31 +00:00
|
|
|
}
|
2019-03-11 14:00:51 +00:00
|
|
|
|
|
|
|
TEST(NameBan, Substring)
|
|
|
|
{
|
|
|
|
CNameBan Xyz("xyz", 0, 1);
|
2019-03-12 01:06:54 +00:00
|
|
|
EXPECT_TRUE(IsNameBanned("abcxyz", &Xyz, 1));
|
|
|
|
EXPECT_TRUE(IsNameBanned("abcxyzdef", &Xyz, 1));
|
|
|
|
EXPECT_FALSE(IsNameBanned("abcdef", &Xyz, 1));
|
|
|
|
}
|