-
Notifications
You must be signed in to change notification settings - Fork 0
/
repl_test.go
42 lines (39 loc) · 805 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
package main
import "testing"
func TestCleanInput(t *testing.T) {
cases := []struct {
input string
expected []string
}{
{
input: " ",
expected: []string{},
},
{
input: " hello ",
expected: []string{"hello"},
},
{
input: " hello world ",
expected: []string{"hello", "world"},
},
{
input: " HellO World ",
expected: []string{"hello", "world"},
},
}
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)
}
}
}
}