-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrepl_test.go
More file actions
52 lines (49 loc) · 1.01 KB
/
repl_test.go
File metadata and controls
52 lines (49 loc) · 1.01 KB
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
package main
import (
"fmt"
"testing"
)
func TestCleanInput(t *testing.T) {
cases := []struct {
input string
expected []string
}{
{
input: "hello world",
expected: []string{"hello", "world"},
},
{
input: "bulbasaur SQUIRTLE Charmander",
expected: []string{"bulbasaur", "squirtle", "charmander"},
},
{
input: "TesT",
expected: []string{"test"},
},
{
input: " map ",
expected: []string{"map"},
},
{
input: "MAP",
expected: []string{"map"},
},
{
input: "test 1 2 3",
expected: []string{"test", "1", "2", "3"},
},
}
for i, c := range cases {
t.Run(fmt.Sprintf("Test case %v", i), func(t *testing.T) {
words := cleanInput(c.input)
if len(words) != len(c.expected) {
t.Errorf("args length of %v does not match the expected length of %v", len(words), len(c.expected))
}
for i, word := range words {
if word != c.expected[i] {
t.Errorf("expected word to be %v but got %v", c.expected[i], word)
}
}
})
}
}