bb/lib/common_test.go

29 lines
602 B
Go
Raw Normal View History

2022-09-04 13:50:43 +00:00
package lib
import "testing"
2022-09-05 17:54:56 +00:00
func TestContainsCommand(t *testing.T) {
2022-09-04 13:50:43 +00:00
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 {
2022-09-05 17:54:56 +00:00
r := ContainsCommand(table.s, table.prefix, table.cmd)
2022-09-04 13:50:43 +00:00
if r != table.r {
2022-09-05 17:54:56 +00:00
t.Errorf("ContainsCommand(%q, %q, %q), got: %t, want: %t",
2022-09-04 13:50:43 +00:00
table.s, table.prefix, table.cmd, r, table.r,
)
}
}
}