aboutsummaryrefslogtreecommitdiff
path: root/weed/stats/duration_counter_test.go
blob: aa9d61c87c2ecf9dadfe1f1c12ffac20cbe3fd0d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
package stats

import "testing"

func TestRobinCounter(t *testing.T) {
	rrc := NewRoundRobinCounter(60)
	rrc.Add(0, 1)
	rrc.Add(50, 2)
	if rrc.Count() != 2 {
		t.Fatal()
	}
	if rrc.Sum() != 3 {
		t.Fatal()
	}
	/*
		index out of range
	*/
	rrc.Add(61, 1)
}