From cd46fcb60db2d0198a06c766c78aaa759d125dc2 Mon Sep 17 00:00:00 2001 From: Ryan Cavicchioni Date: Sun, 4 Sep 2022 08:50:43 -0500 Subject: [PATCH] Add a first test --- lib/common_test.go | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 lib/common_test.go diff --git a/lib/common_test.go b/lib/common_test.go new file mode 100644 index 0000000..43371aa --- /dev/null +++ b/lib/common_test.go @@ -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, + ) + } + } +}