forked from icrowley/fake
-
Notifications
You must be signed in to change notification settings - Fork 2
/
lorem_ipsum_test.go
54 lines (48 loc) · 1.06 KB
/
lorem_ipsum_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
package fake
import "testing"
var loremIpsumFuncs = map[string]func(int) string{
"CharactersN": CharactersN,
"WordsN": WordsN,
"SentencesN": SentencesN,
"ParagraphsN": ParagraphsN,
}
func TestLoremIpsumN(t *testing.T) {
for _, lang := range GetLangs() {
err := SetLang(lang)
if err != nil {
t.Errorf("Could not set language %s", lang)
}
for name, funct := range loremIpsumFuncs {
name, funct := name, funct // capture range variable
t.Run(name, func(t *testing.T) {
t.Parallel()
if a := funct(2); a == "" {
t.Errorf("%s failed with lang %s", name, lang)
}
})
}
}
}
func TestLoremIpsumUnique(t *testing.T) {
for _, lang := range GetLangs() {
err := SetLang(lang)
if err != nil {
t.Errorf("Could not set language %s", lang)
}
vs := WordsNUnique(251)
if len(vs) != 251 {
t.Errorf("WordsNUnique failed with lang %s", lang)
}
lw := ""
for n, w := range vs {
if w == lw {
t.Errorf("Duplicate words found")
}
if w == "" {
t.Errorf("Word %d is empty", n)
continue
}
lw = w
}
}
}