-
Notifications
You must be signed in to change notification settings - Fork 1
/
user_test.go
51 lines (36 loc) · 905 Bytes
/
user_test.go
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
43
44
45
46
47
48
49
50
51
package stats
import (
"testing"
"time"
)
func TestUser_BasicTextCounters(t *testing.T) {
t.Parallel()
s := NewStats()
s.AddMessage(Msg, network, channel, hostmask, time.Now(), "a b c d ef")
u := s.Users[1]
if u.WordsPerLine() != 5 {
t.Error("Should have 5 words per line here")
}
if u.LettersPerLine() != 6 {
t.Error("Should have 6 letters per line")
}
}
func TestUser_EmoticonCounter(t *testing.T) {
t.Parallel()
s := NewStats()
s.AddMessage(Msg, network, channel, hostmask, time.Now(), "you wanna come over ;) ;)")
u := s.Users[1]
if tok := u.TopEmoticon(); tok.Token != ";)" || tok.Count != 2 {
t.Error("Should have ;) as top emoticon with 2 uses")
}
}
func TestUser_String(t *testing.T) {
t.Parallel()
u := &User{
Nick: "foo",
MessageIDs: []uint{1, 2, 3},
}
if u.String() != "User: foo, Messages: 3" {
t.Error("Didn't return correct string")
}
}