-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathmargopher_test.go
44 lines (34 loc) · 1.11 KB
/
margopher_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
package margopher
import "testing"
func TestGetRandomWord(t *testing.T) {
if getRandomWord([]string{"1", "2", "3"}) == "" {
t.Error("getRandomWord: it should return a string element from slice.")
}
}
func TestIsTerminalWord(t *testing.T) {
if isTerminalWord("Hey.") == false {
t.Error("isTerminalWord: it should return true for words ending in `.`")
}
if isTerminalWord("Hey,") == false {
t.Error("isTerminalWord: it should return true for words ending in `,`")
}
if isTerminalWord("Hey:") == false {
t.Error("isTerminalWord: it should return true for words ending in `:`")
}
if isTerminalWord("Hey;") == false {
t.Error("isTerminalWord: it should return true for words ending in `;`")
}
if isTerminalWord("Hey?") == false {
t.Error("isTerminalWord: it should return true for words ending in `?`")
}
if isTerminalWord("Hey!") == false {
t.Error("isTerminalWord: it should return true for words ending in `!`")
}
}
func TestParse(t *testing.T) {
m := New()
m.parse("Cats are nice. Cats love pizza, and Cats hates dogs.")
if m.states == nil {
t.Error("ParseText: it should initialize states.")
}
}