-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathparser_test.go
More file actions
48 lines (44 loc) · 1.45 KB
/
parser_test.go
File metadata and controls
48 lines (44 loc) · 1.45 KB
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
package ethnic
import (
"reflect"
"testing"
)
func TestParseFamilyname(t *testing.T) {
tests := []struct {
name string
familyname string
wantPrefLangs []string
wantSuffLangs []string
}{
{"ov test", "Lomonosov", []string{}, []string{"Russian", "all Eastern Slavic languages"}},
{"son test", "Johnson", []string{}, []string{"English", "French", "German", "Icelandic", "Norwegian", "Swedish"}},
{"de la test", "de la Vega", []string{"French", "Italian", "Portuguese", "Spanish"}, []string{"European", "Kurdish", "except French Frisian"}},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
gotPrefLangs, gotSuffLangs := ParseFamilyname(tt.familyname)
if !reflect.DeepEqual(gotPrefLangs, tt.wantPrefLangs) {
t.Errorf("ParseFamilyname() gotPrefLangs = %v, want %v", gotPrefLangs, tt.wantPrefLangs)
}
if !reflect.DeepEqual(gotSuffLangs, tt.wantSuffLangs) {
t.Errorf("ParseFamilyname() gotSuffLangs = %v, want %v", gotSuffLangs, tt.wantSuffLangs)
}
})
}
}
func TestParseNameSuffixes(t *testing.T) {
tests := []struct {
name string
nameSuffixes string
wantLangs []string
}{
{"base test", "md, III", []string{"American", "British"}},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if gotLangs := ParseNameSuffixes(tt.nameSuffixes); !reflect.DeepEqual(gotLangs, tt.wantLangs) {
t.Errorf("ParseNameSuffixes() = %v, want %v", gotLangs, tt.wantLangs)
}
})
}
}