-
Notifications
You must be signed in to change notification settings - Fork 0
/
stopwords-iso_test.go
56 lines (48 loc) · 1.53 KB
/
stopwords-iso_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
package stopwordsiso
import (
"testing"
)
func TestNewStopwordsMapping(t *testing.T) {
mapping, err := NewStopwordsMapping()
if err != nil {
t.Errorf("NewStopwordsMapping() error = %v, wantErr %v", err, false)
}
if len(mapping) == 0 {
t.Errorf("NewStopwordsMapping() returned an empty mapping")
}
// Test if the mapping contains expected languages
if _, exists := mapping["en"]; !exists {
t.Errorf("NewStopwordsMapping() should contain 'en' key for English stopwords")
}
// More specific tests can be added here
}
func TestClearStringByLang(t *testing.T) {
mapping, _ := NewStopwordsMapping() // Assuming that NewStopwordsMapping works correctly
tests := []struct {
name string
str string
language ISOCode639_1
want string
}{
{"English", "this is a special", "en", "special"},
{"Non-Existent Language", "this should not change", "xx", "this should not change"},
{"Case Insensitivity", "THIS is A Google", "EN", "Google"},
{"No Stopwords", "uniqueword", "en", "uniqueword"},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := mapping.ClearStringByLang(tt.str, tt.language); got != tt.want {
t.Errorf("StopwordsMapping.ClearStringByLang() got = %v, want %v", got, tt.want)
}
})
}
}
func TestStopwordsMapping_ClearString(t *testing.T) {
mapping, _ := NewStopwordsMapping()
testStr := "А ИЛИ ОН it's ok vadim"
want := "vadim"
got := mapping.ClearString(testStr)
if got != want {
t.Errorf("StopwordsMapping.ClearString() got = %v, want %v", got, want)
}
}