2019-03-30 22:19:10 +01:00
|
|
|
package common
|
|
|
|
|
|
|
|
import (
|
2019-06-19 04:13:53 +02:00
|
|
|
"os"
|
2019-03-30 22:19:10 +01:00
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
|
|
|
var data_good = map[string]string{
|
2021-01-16 21:36:44 +01:00
|
|
|
"one": `<img src="/emotes/one.png" class="emote" title="one" />`,
|
|
|
|
"two": `<img src="/emotes/two.png" class="emote" title="two" />`,
|
|
|
|
"three": `<img src="/emotes/three.gif" class="emote" title="three" />`,
|
2019-03-30 22:19:10 +01:00
|
|
|
|
2021-01-16 21:36:44 +01:00
|
|
|
":one:": `<img src="/emotes/one.png" class="emote" title="one" />`,
|
|
|
|
":two:": `<img src="/emotes/two.png" class="emote" title="two" />`,
|
|
|
|
":three:": `<img src="/emotes/three.gif" class="emote" title="three" />`,
|
2019-03-30 22:19:10 +01:00
|
|
|
|
2021-01-16 21:36:44 +01:00
|
|
|
":one::one:": `<img src="/emotes/one.png" class="emote" title="one" /><img src="/emotes/one.png" class="emote" title="one" />`,
|
|
|
|
":one:one:": `<img src="/emotes/one.png" class="emote" title="one" />one:`,
|
2020-04-19 18:26:27 +02:00
|
|
|
"oneone": "oneone",
|
2021-01-16 21:36:44 +01:00
|
|
|
"one:one:": `one<img src="/emotes/one.png" class="emote" title="one" />`,
|
2020-04-19 18:26:27 +02:00
|
|
|
|
2021-01-16 21:36:44 +01:00
|
|
|
"[one]": `<img src="/emotes/one.png" class="emote" title="one" />`,
|
|
|
|
"[two]": `<img src="/emotes/two.png" class="emote" title="two" />`,
|
|
|
|
"[three]": `<img src="/emotes/three.gif" class="emote" title="three" />`,
|
2019-03-30 22:19:10 +01:00
|
|
|
|
2021-01-16 21:36:44 +01:00
|
|
|
"[one][one]": `<img src="/emotes/one.png" class="emote" title="one" /><img src="/emotes/one.png" class="emote" title="one" />`,
|
|
|
|
"[one]one": `<img src="/emotes/one.png" class="emote" title="one" />one`,
|
2020-04-19 18:26:27 +02:00
|
|
|
|
2021-01-16 21:36:44 +01:00
|
|
|
":one: two [three]": `<img src="/emotes/one.png" class="emote" title="one" /> <img src="/emotes/two.png" class="emote" title="two" /> <img src="/emotes/three.gif" class="emote" title="three" />`,
|
2019-03-30 22:19:10 +01:00
|
|
|
|
2021-01-16 21:36:44 +01:00
|
|
|
"nope one what": `nope <img src="/emotes/one.png" class="emote" title="one" /> what`,
|
|
|
|
"nope :two: what": `nope <img src="/emotes/two.png" class="emote" title="two" /> what`,
|
|
|
|
"nope [three] what": `nope <img src="/emotes/three.gif" class="emote" title="three" /> what`,
|
2019-03-30 22:19:10 +01:00
|
|
|
}
|
|
|
|
|
2020-04-19 18:26:27 +02:00
|
|
|
var data_wrapped = map[string]string{
|
|
|
|
"one": `one`,
|
|
|
|
"two": `two`,
|
|
|
|
"three": `three`,
|
|
|
|
|
|
|
|
":one:": `<img src="/emotes/one.png" height="28px" title="one" />`,
|
|
|
|
":two:": `<img src="/emotes/two.png" height="28px" title="two" />`,
|
|
|
|
":three:": `<img src="/emotes/three.gif" height="28px" title="three" />`,
|
|
|
|
|
|
|
|
":one::one:": `<img src="/emotes/one.png" height="28px" title="one" /><img src="/emotes/one.png" height="28px" title="one" />`,
|
|
|
|
":one:one:": `<img src="/emotes/one.png" height="28px" title="one" />one:`,
|
|
|
|
"oneone": "oneone",
|
|
|
|
"one:one:": `one<img src="/emotes/one.png" height="28px" title="one" />`,
|
|
|
|
|
|
|
|
"[one]": `<img src="/emotes/one.png" height="28px" title="one" />`,
|
|
|
|
"[two]": `<img src="/emotes/two.png" height="28px" title="two" />`,
|
|
|
|
"[three]": `<img src="/emotes/three.gif" height="28px" title="three" />`,
|
|
|
|
|
|
|
|
"[one][one]": `<img src="/emotes/one.png" height="28px" title="one" /><img src="/emotes/one.png" height="28px" title="one" />`,
|
|
|
|
"[one]one": `<img src="/emotes/one.png" height="28px" title="one" />one`,
|
|
|
|
|
|
|
|
":one: two [three]": `<img src="/emotes/one.png" height="28px" title="one" /> two <img src="/emotes/three.gif" height="28px" title="three" />`,
|
|
|
|
|
|
|
|
"nope one what": `nope one what`,
|
|
|
|
"nope :two: what": `nope <img src="/emotes/two.png" height="28px" title="two" /> what`,
|
|
|
|
"nope [three] what": `nope <img src="/emotes/three.gif" height="28px" title="three" /> what`,
|
|
|
|
}
|
|
|
|
|
2019-03-30 22:19:10 +01:00
|
|
|
func TestMain(m *testing.M) {
|
2019-06-19 04:13:53 +02:00
|
|
|
Emotes = map[string]string{
|
|
|
|
"one": "/emotes/one.png",
|
|
|
|
"two": "/emotes/two.png",
|
|
|
|
"three": "/emotes/three.gif",
|
2019-03-30 22:19:10 +01:00
|
|
|
}
|
2019-06-19 04:13:53 +02:00
|
|
|
os.Exit(m.Run())
|
2019-03-30 22:19:10 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
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)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-04-19 18:26:27 +02:00
|
|
|
|
|
|
|
func TestEmotes_ParseEmotes_WrappedOnly(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)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|