-
Notifications
You must be signed in to change notification settings - Fork 0
/
noun_test.go
38 lines (30 loc) · 950 Bytes
/
noun_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
package neng
import (
"testing"
"github.com/Zedran/neng/internal/tests"
)
// Tests plural. Fails if incorrect plural form of a noun is returned.
func TestPlural(t *testing.T) {
var cases map[string]string
if err := tests.ReadData("TestPlural.json", &cases); err != nil {
t.Fatalf("Failed loading test data: %v", err)
}
gen, err := DefaultGenerator()
if err != nil {
t.Fatalf("Failed: DefaultGenerator returned an error: %v", err)
}
for input, expected := range cases {
word, err := gen.Find(input, WC_NOUN)
if err != nil {
t.Logf("Test case '%s' does not exist in the word database. Assume it is regular and proceed.", input)
word, err = NewWordFromParams(input, 0, nil)
if err != nil {
t.Errorf("Failed for '%s' - error from NewWordFromParams: %v", input, err)
}
}
output := plural(word)
if output != expected {
t.Errorf("Failed for '%s': expected '%s', got '%s'", input, expected, output)
}
}
}