Thumbnail

rani/matterbridge.git

Clone URL: https://git.buni.party/rani/matterbridge.git

Viewing file on branch master

1package bdiscord
2
3import (
4 "testing"
5
6 "github.com/stretchr/testify/assert"
7)
8
9func TestEnumerateUsernames(t *testing.T) {
10 testcases := map[string]struct {
11 match string
12 expectedUsernames []string
13 }{
14 "only space": {
15 match: " \t\n \t",
16 expectedUsernames: nil,
17 },
18 "single word": {
19 match: "veni",
20 expectedUsernames: []string{"veni"},
21 },
22 "single word with preceeding space": {
23 match: " vidi",
24 expectedUsernames: []string{" vidi"},
25 },
26 "single word with suffixed space": {
27 match: "vici ",
28 expectedUsernames: []string{"vici"},
29 },
30 "multi-word with varying whitespace": {
31 match: "just me and\tmy friends \t",
32 expectedUsernames: []string{
33 "just",
34 "just me",
35 "just me and",
36 "just me and\tmy",
37 "just me and\tmy friends",
38 },
39 },
40 }
41
42 for testname, testcase := range testcases {
43 foundUsernames := enumerateUsernames(testcase.match)
44 assert.Equalf(t, testcase.expectedUsernames, foundUsernames, "Should have found the expected usernames for testcase %s", testname)
45 }
46}
47