aboutsummaryrefslogtreecommitdiff
path: root/weed/stats/duration_counter_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'weed/stats/duration_counter_test.go')
-rw-r--r--weed/stats/duration_counter_test.go19
1 files changed, 19 insertions, 0 deletions
diff --git a/weed/stats/duration_counter_test.go b/weed/stats/duration_counter_test.go
new file mode 100644
index 000000000..aa9d61c87
--- /dev/null
+++ b/weed/stats/duration_counter_test.go
@@ -0,0 +1,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)
+}