Add a first test
This commit is contained in:
parent
33bf5eaff2
commit
cd46fcb60d
28
lib/common_test.go
Normal file
28
lib/common_test.go
Normal file
@ -0,0 +1,28 @@
|
||||
package lib
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestHasCommand(t *testing.T) {
|
||||
tables := []struct {
|
||||
s string
|
||||
prefix string
|
||||
cmd string
|
||||
r bool
|
||||
}{
|
||||
{"!command x y", "!", "command", true},
|
||||
{"#command x y", "#", "command", true},
|
||||
{"command x y", "!", "comamnd", false},
|
||||
{"", "", "", false},
|
||||
{"!", "!", "", false},
|
||||
{"! x y", "!", "", false},
|
||||
}
|
||||
|
||||
for _, table := range tables {
|
||||
r := HasCommand(table.s, table.prefix, table.cmd)
|
||||
if r != table.r {
|
||||
t.Errorf("HasCommand(%q, %q, %q), got: %t, want: %t",
|
||||
table.s, table.prefix, table.cmd, r, table.r,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user