-
Notifications
You must be signed in to change notification settings - Fork 6
/
privmsg_test.go
38 lines (36 loc) · 1.02 KB
/
privmsg_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 main
import "testing"
func TestParseCommand(t *testing.T) {
cases := []struct {
name string
me string
in string
text string
ok bool
}{
{"empty", "Bocchi", "", "", false},
{"exact", "Bocchi", "Bocchi", "", true},
{"case", "Bocchi", "bOCCHI", "", true},
{"prespace", "Bocchi", " Bocchi", "", true},
{"postspace", "Bocchi", "Bocchi ", "", true},
{"at", "Bocchi", "@Bocchi", "", true},
{"punct", "Bocchi", "Bocchi...", "", true},
{"prefix", "Bocchi", "Bocchi3", "", false},
{"suffix", "Bocchi", "9Bocchi", "", false},
{"text-after", "Bocchi", "Bocchi the Rock!", "the Rock!", true},
{"text-before", "Bocchi", "Hitori Bocchi", "Hitori", true},
{"middle", "Bocchi", "Hitori Bocchi Tokyo", "", false},
}
for _, c := range cases {
c := c
t.Run(c.name, func(t *testing.T) {
got, ok := parseCommand(c.me, c.in)
if got != c.text {
t.Errorf("wrong command text: want %q, got %q", c.text, got)
}
if ok != c.ok {
t.Errorf("wrong commandness: want %t, got %t", c.ok, ok)
}
})
}
}