Skip to content

Commit

Permalink
test: Add test for cyrillic characters (#27)
Browse files Browse the repository at this point in the history
  • Loading branch information
TwiN committed Mar 20, 2022
1 parent f683c84 commit 3376eba
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions goaway_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,10 @@ func TestProfanityDetector_Censor(t *testing.T) {
input: "glass",
expectedCensoredOutput: "glass",
},
{
input: "ы",
expectedCensoredOutput: "ы",
},
}
for _, tt := range tests {
t.Run(tt.input, func(t *testing.T) {
Expand Down Expand Up @@ -222,6 +226,30 @@ func TestBadWordsWithAccentedLetters(t *testing.T) {
}
}

func TestCensorWithVerySpecialCharacters(t *testing.T) {
profanities := []string{"крывавыa"}
words := []string{"крывавыa"}
expectedOutputs := []string{"********"}
tests := []struct {
name string
profanityDetector *ProfanityDetector
}{
{
name: "With Custom Dictionary",
profanityDetector: NewProfanityDetector().WithCustomDictionary(profanities, DefaultFalsePositives, DefaultFalseNegatives),
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
for index, w := range words {
if output := tt.profanityDetector.Censor(w); output != expectedOutputs[index] {
t.Errorf("Expected %s to return %s, got %s", w, expectedOutputs[index], output)
}
}
})
}
}

func TestSentencesWithBadWords(t *testing.T) {
profanities := []string{"fuck", "ass", "poop", "penis", "bitch"}
sentences := []string{"What the fuck is your problem", "Go away, asshole!"}
Expand Down

0 comments on commit 3376eba

Please sign in to comment.