Debian Codegraph @

slackutilsx/slackutilsx_test.go

raw symbols SCIP
1 package slackutilsx
2
3 import (
4 "testing"
5 )
6
7 func TestDetectChannelType(t *testing.T) {
8 test := func(channelID string, expected ChannelType) {
9 if computed := DetectChannelType(channelID); computed != expected {
10 t.Errorf("expected channelID %s to have type %s, got: %s", channelID, expected, computed)
11 }
12 }
13
14 test("G11111111", CTypeGroup)
15 test("D11111111", CTypeDM)
16 test("C11111111", CTypeChannel)
17 test("", CTypeUnknown)
18 test("X11111111", CTypeUnknown)
19 }
20
21 func TestEscapeMessage(t *testing.T) {
22 test := func(message string, expected string) {
23 if computed := EscapeMessage(message); computed != expected {
24 t.Errorf("expected message %s to be converted to %s, got: %s", message, expected, computed)
25 }
26 }
27 test("A & B", "A & B")
28 test("A < B", "A &lt; B")
29 test("A > B", "A &gt; B")
30 }
31
32 func BenchmarkEscapeMessage(b *testing.B) {
33 for i := 0; i < b.N; i++ {
34 EscapeMessage("A & B")
35 }
36 }