-
Notifications
You must be signed in to change notification settings - Fork 29
/
namegen_test.go
76 lines (67 loc) · 2.09 KB
/
namegen_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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
package namegen
import (
"strings"
"testing"
"github.com/go-playground/assert"
)
var genders []string = []string{"male", "female", "both"}
var origins []string = []string{
"anglosaxon", "dutch", "dwarf", "elf", "english", "estonian", "fantasy", "finnish",
"french", "german", "greek", "hindu", "icelandic", "indonesian", "italian", "japanese",
"korean", "mayan", "nepalese", "norwegian", "portuguese", "russian", "spanish", "swedish",
"thai",
}
func Test_NameGeneratorFromType(t *testing.T) {
for _, origin := range origins {
for _, gender := range genders {
result := NameGeneratorFromType(origin, gender)
assert.NotEqual(t, 0, len(result.FemaleFirstNames))
assert.NotEqual(t, 0, len(result.MaleFirstNames))
assert.NotEqual(t, 0, len(result.LastNames))
}
}
}
func Test_NameGenerator_LastName(t *testing.T) {
for _, origin := range origins {
for _, gender := range genders {
generator := NameGeneratorFromType(origin, gender)
result, err := generator.LastName()
assert.Equal(t, nil, err)
assert.NotEqual(t, 0, len(result))
}
}
}
func Test_NameGenerator_FirstName(t *testing.T) {
for _, origin := range origins {
for _, gender := range genders {
generator := NameGeneratorFromType(origin, gender)
result, err := generator.FirstName(gender)
assert.Equal(t, nil, err)
assert.NotEqual(t, 0, len(result))
}
}
}
func Test_NameGenerator_CompleteName(t *testing.T) {
generator := &NameGenerator{
FemaleFirstNames: germanFemaleFirstNames,
MaleFirstNames: germanMaleFirstNames,
}
result, err := generator.CompleteName(genders[0])
assert.NotEqual(t, nil, err)
assert.Equal(t, 0, len(result))
generator = &NameGenerator{
LastNames: germanLastNames,
}
result, err = generator.CompleteName(genders[0])
assert.NotEqual(t, nil, err)
assert.Equal(t, 0, len(result))
for _, origin := range origins {
for _, gender := range genders {
generator := NameGeneratorFromType(origin, gender)
result, err := generator.CompleteName(gender)
assert.Equal(t, nil, err)
assert.NotEqual(t, 0, len(result))
assert.Equal(t, true, strings.Contains(result, " "))
}
}
}