-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathemoticon_counter_test.go
More file actions
42 lines (33 loc) · 934 Bytes
/
emoticon_counter_test.go
File metadata and controls
42 lines (33 loc) · 934 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package stats
import "testing"
func TestEmoticonCounter(t *testing.T) {
t.Parallel()
tc := NewEmoticonCounter()
if len(tc.Top) != 0 {
t.Error("Top Emoticons should be empty.")
}
if len(tc.All) != 0 {
t.Error("All Emoticons should be empty.")
}
m := &Message{Message: "he:Dllo :D world :D :("}
tc.addMessage(m)
if len(tc.Top) != 2 {
t.Error("Top Emoticons should have two unique Emoticons.")
}
if len(tc.All) != 2 {
t.Error("All Emoticons should have two unique Emoticons.")
}
if count, ok := tc.All[":("]; !ok {
t.Error("Should have :( in All emoticons.")
} else if count != 1 {
t.Error("Should get correct count for emoticon.")
}
if count, ok := tc.All[":D"]; !ok {
t.Error("Should have :D in All emoticons.")
} else if count != 2 {
t.Error("Should get correct count for emoticons.")
}
if tok := tc.Top[0]; tok.Token != ":D" || tok.Count != 2 {
t.Error("Top emoticon is incorrect")
}
}