forked from bxcodec/faker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
lorem_test.go
47 lines (41 loc) · 938 Bytes
/
lorem_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
package faker
import (
"fmt"
"reflect"
"strings"
"testing"
"github.com/bxcodec/faker/v3/support/slice"
)
func TestDataFaker(t *testing.T) {
SetDataFaker(Lorem{})
}
func TestWord(t *testing.T) {
word, err := GetLorem().Word(reflect.Value{})
if err != nil {
t.Error("Expected not error, got err", err)
}
if !slice.Contains(wordList, word.(string)) {
t.Error("Expected word from slice wordList")
}
}
func TestSentence(t *testing.T) {
res, err := GetLorem().Sentence(reflect.Value{})
if err != nil {
t.Error("Expected not error, got err", err)
}
s := res.(string)
if s == "" || !strings.HasSuffix(s, ".") {
t.Error("Expected sentence")
}
}
func TestParagraph(t *testing.T) {
res, err := GetLorem().Paragraph(reflect.Value{})
if err != nil {
t.Error("Expected not error, got err", err)
}
s := res.(string)
fmt.Println(s)
if s == "" || !strings.HasSuffix(s, ".") {
t.Error("Expected paragraph")
}
}