-
Notifications
You must be signed in to change notification settings - Fork 0
/
verb_test.go
104 lines (85 loc) · 2.85 KB
/
verb_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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
package neng
import "testing"
/* Tests gerund function. Fails if improper gerund form of a verb is returned. */
func TestGerund(t *testing.T) {
cases, err := loadTestMapStringString("TestGerund.json")
if err != nil {
t.Fatalf("Failed loading test data: %s", err.Error())
}
for input, expected := range cases {
output := gerund(input)
if output != expected {
t.Errorf("Failed for '%s': expected '%s', got '%s'", input, expected, output)
}
}
}
/*
Tests pastParticiple function. Fails if improper Past Participle form of a verb is returned.
Handling of regular verbs is only symbolically checked, as it is the focus of TestPastSimpleRegular.
*/
func TestPastParticiple(t *testing.T) {
cases, err := loadTestMapStringString("TestPastParticiple.json")
if err != nil {
t.Fatalf("Failed loading test data: %s", err.Error())
}
irregular, err := loadIrregularWords("res/verb.irr")
if err != nil {
t.Fatalf("loadIrregularWords failed: %s", err.Error())
}
for input, expected := range cases {
output := pastParticiple(input, irregular)
if output != expected {
t.Errorf("Failed for '%s': expected '%s', got '%s'", input, expected, output)
}
}
}
/* Tests pastRegular function. Fails if incorrect past tense form of a regular verb is returned. */
func TestPastRegular(t *testing.T) {
cases, err := loadTestMapStringString("TestPastRegular.json")
if err != nil {
t.Fatalf("Failed loading test data: %s", err.Error())
}
for input, expected := range cases {
output := pastRegular(input)
if output != expected {
t.Errorf("Failed for '%s': expected '%s', got '%s'", input, expected, output)
}
}
}
/*
Tests pastSimple function. Fails if improper Past Simple form of a verb is returned.
Handling of regular verbs is only symbolically checked, as it is the focus of TestPastSimpleRegular.
*/
func TestPastSimple(t *testing.T) {
cases, err := loadSliceTestCasePlural("TestPastSimple.json")
if err != nil {
t.Fatalf("Failed loading test data: %s", err.Error())
}
irregular, err := loadIrregularWords("res/verb.irr")
if err != nil {
t.Fatalf("loadIrregularWords failed: %s", err.Error())
}
for _, c := range cases {
output := pastSimple(c.Input, irregular, c.Plural)
if output != c.Expected {
t.Errorf("Failed for '%s' (plural = %v): expected '%s', got '%s'", c.Input, c.Plural, c.Expected, output)
}
}
}
/* Tests presentSimple function. Fails if improper Present Simple form of a verb is returned. */
func TestPresentSimple(t *testing.T) {
cases, err := loadSliceTestCasePlural("TestPresentSimple.json")
if err != nil {
t.Fatalf("Failed loading test data: %s", err.Error())
}
for _, c := range cases {
output := presentSimple(c.Input, c.Plural)
if output != c.Expected {
number := "sing."
if c.Plural {
number = "pl."
}
t.Errorf("Failed for '%s': expected '%s' (%s), got '%s'", c.Input, c.Expected, number, output)
}
}
}