From 2acf382f1fe290c160ea12e467ec1173adf23405 Mon Sep 17 00:00:00 2001 From: Zorchenhimer Date: Sat, 30 Mar 2019 17:19:10 -0400 Subject: [PATCH] Add some tests for emote parsing --- common/emotes_test.go | 44 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 common/emotes_test.go diff --git a/common/emotes_test.go b/common/emotes_test.go new file mode 100644 index 0000000..f531b6f --- /dev/null +++ b/common/emotes_test.go @@ -0,0 +1,44 @@ +package common + +import ( + "os" + "testing" +) + +var data_good = map[string]string{ + "one": ``, + "two": ``, + "three": ``, + + ":one:": ``, + ":two:": ``, + ":three:": ``, + + "[one]": ``, + "[two]": ``, + "[three]": ``, + + ":one: two [three]": ` `, + + "nope one what": `nope what`, + "nope :two: what": `nope what`, + "nope [three] what": `nope what`, +} + +func TestMain(m *testing.M) { + Emotes = map[string]string{ + "one": "one.png", + "two": "two.png", + "three": "three.gif", + } + os.Exit(m.Run()) +} + +func TestEmotes_ParseEmotes(t *testing.T) { + for input, expected := range data_good { + got := ParseEmotes(input) + if got != expected { + t.Errorf("%s failed to parse into %q. Received: %q", input, expected, got) + } + } +}