2018-03-14 01:35:31 +00:00
|
|
|
#include <gtest/gtest.h>
|
|
|
|
|
|
|
|
#include <engine/server/name_ban.h>
|
|
|
|
|
|
|
|
TEST(NameBan, Empty)
|
|
|
|
{
|
2022-05-23 20:55:04 +00:00
|
|
|
std::vector<CNameBan> vBans;
|
|
|
|
EXPECT_FALSE(IsNameBanned("", vBans));
|
|
|
|
EXPECT_FALSE(IsNameBanned("abc", vBans));
|
2018-03-14 01:35:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
TEST(NameBan, Equality)
|
|
|
|
{
|
2022-05-23 20:55:04 +00:00
|
|
|
std::vector<CNameBan> vBans;
|
|
|
|
vBans.emplace_back("abc", 0, 0);
|
|
|
|
EXPECT_TRUE(IsNameBanned("abc", vBans));
|
|
|
|
EXPECT_TRUE(IsNameBanned(" abc", vBans));
|
|
|
|
EXPECT_TRUE(IsNameBanned("abc ", vBans));
|
|
|
|
EXPECT_TRUE(IsNameBanned("abc foo", vBans)); // Maximum name length.
|
|
|
|
EXPECT_TRUE(IsNameBanned("äbc", vBans)); // Confusables
|
|
|
|
EXPECT_FALSE(IsNameBanned("def", vBans));
|
|
|
|
EXPECT_FALSE(IsNameBanned("abcdef", vBans));
|
2018-03-14 01:35:31 +00:00
|
|
|
}
|
2019-03-11 14:00:51 +00:00
|
|
|
|
|
|
|
TEST(NameBan, Substring)
|
|
|
|
{
|
2022-05-23 20:55:04 +00:00
|
|
|
std::vector<CNameBan> vBans;
|
|
|
|
vBans.emplace_back("xyz", 0, 1);
|
|
|
|
EXPECT_TRUE(IsNameBanned("abcxyz", vBans));
|
|
|
|
EXPECT_TRUE(IsNameBanned("abcxyzdef", vBans));
|
|
|
|
EXPECT_FALSE(IsNameBanned("abcdef", vBans));
|
2019-03-12 01:06:54 +00:00
|
|
|
}
|