You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

55 lines
1.5 KiB
Go

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

package profanity
import "testing"
func TestHeroNameIsProfane_english(t *testing.T) {
if HeroNameIsProfane("Alice") {
t.Fatal("expected clean name")
}
if !HeroNameIsProfane("fuckface") {
t.Fatal("expected English profanity")
}
}
func TestHeroNameIsProfane_russianPlain(t *testing.T) {
for _, n := range []string{"ХУЙ", "хуй", "ХуЙ", "хуйло", "пиздец", "сука"} {
if !HeroNameIsProfane(n) {
t.Fatalf("expected profane: %q", n)
}
}
}
func TestHeroNameIsProfane_khersonNotBlocked(t *testing.T) {
if HeroNameIsProfane("Херсон") {
t.Fatal("did not expect city name to be blocked")
}
}
func TestHeroNameIsProfane_mixedLatinCyrillic(t *testing.T) {
cases := []string{
"xуй", // лат. x + кирил. уй
"хyй", // кирил. х + лат. y + кирил. й
"hуй", // лат. h → х
"xyи", // лат. xy + кирил. и
"cука", // лат. c → с
}
for _, n := range cases {
if !HeroNameIsProfane(n) {
t.Fatalf("expected profane (mixed script): %q", n)
}
}
}
func TestHeroNameIsProfane_digitHomoglyphs(t *testing.T) {
// смешанный ник: кириллица + цифра вместо буквы (3 → з)
if !HeroNameIsProfane("пи3да") {
t.Fatal("expected 3→з to form пизда")
}
}
func TestHeroNameIsProfane_cyrillicHomoglyphEnglish(t *testing.T) {
if !HeroNameIsProfane("fu\u0441k") { // кириллическая «с»
t.Fatal("expected spoof latin profanity to be caught")
}
}