-
Notifications
You must be signed in to change notification settings - Fork 0
/
repl_test.go
44 lines (41 loc) · 890 Bytes
/
repl_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 main
import (
"testing"
)
func TestCleanInput(t *testing.T) {
cases := []struct {
input string
expected []string
}{
{
input: " ", // empty strings
expected: []string{},
},
{
input: " this ", // empty strings
expected: []string{"this"},
},
{
input: " this and that ", // empty strings
expected: []string{"this", "and", "that"},
},
{
input: " ThiS AnD ThaT ", // empty strings
expected: []string{"this", "and", "that"},
},
}
for _, c := range cases {
actual := cleanInput(c.input)
if len(actual) != len(c.expected) {
t.Errorf("lengths don't match: '%v' vs '%v'", actual, c.expected)
continue
}
for i := range actual {
word := actual[i]
expectedWord := c.expected[i]
if word != expectedWord {
t.Errorf("cleanInput(%v) == %v, expected %v", c.input, actual, c.expected)
}
}
}
}