forked from abh/geodns
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathzone_stats_test.go
52 lines (42 loc) · 864 Bytes
/
zone_stats_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
52
package main
import (
. "github.com/abh/geodns/Godeps/_workspace/src/gopkg.in/check.v1"
)
type ZoneStatsSuite struct {
}
var _ = Suite(&ZoneStatsSuite{})
func (s *ZoneStatsSuite) TestZoneStats(c *C) {
zs := NewZoneLabelStats(4)
c.Assert(zs, NotNil)
c.Log("adding 4 entries")
zs.Add("abc")
zs.Add("foo")
zs.Add("def")
zs.Add("abc")
c.Log("getting counts")
co := zs.Counts()
c.Check(co["abc"], Equals, 2)
c.Check(co["foo"], Equals, 1)
zs.Add("foo")
co = zs.Counts()
c.Check(co["abc"], Equals, 1)
c.Check(co["foo"], Equals, 2)
zs.Close()
zs = NewZoneLabelStats(10)
zs.Add("a")
zs.Add("a")
zs.Add("a")
zs.Add("b")
zs.Add("c")
zs.Add("c")
zs.Add("d")
zs.Add("d")
zs.Add("e")
zs.Add("f")
top := zs.TopCounts(2)
c.Check(top, HasLen, 3)
c.Check(top[0].Label, Equals, "a")
zs.Reset()
c.Check(zs.Counts(), HasLen, 0)
zs.Close()
}