1
0

counter_test.go 354 B

1234567891011121314151617181920212223
  1. package metric
  2. import (
  3. "testing"
  4. "github.com/stretchr/testify/assert"
  5. )
  6. func TestCounter(t *testing.T) {
  7. assert := assert.New(t)
  8. c := NewCounter()
  9. c.Inc(10)
  10. assert.EqualValues(10, c.Count())
  11. c.Dec(5)
  12. assert.EqualValues(5, c.Count())
  13. cTmp := c.Snapshot()
  14. assert.EqualValues(5, cTmp.Count())
  15. c.Clear()
  16. assert.EqualValues(0, c.Count())
  17. }