duration_counter_test.go 256 B

12345678910111213141516171819
  1. package stats
  2. import "testing"
  3. func TestRobinCounter(t *testing.T) {
  4. rrc := NewRoundRobinCounter(60)
  5. rrc.Add(0, 1)
  6. rrc.Add(50, 2)
  7. if rrc.Count() != 2 {
  8. t.Fatal()
  9. }
  10. if rrc.Sum() != 3 {
  11. t.Fatal()
  12. }
  13. /*
  14. index out of range
  15. */
  16. rrc.Add(61, 1)
  17. }