mirror of
https://gitee.com/IrisVega/frp.git
synced 2024-11-01 22:31:29 +08:00
24 lines
354 B
Go
24 lines
354 B
Go
package metric
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestCounter(t *testing.T) {
|
|
assert := assert.New(t)
|
|
c := NewCounter()
|
|
c.Inc(10)
|
|
assert.EqualValues(10, c.Count())
|
|
|
|
c.Dec(5)
|
|
assert.EqualValues(5, c.Count())
|
|
|
|
cTmp := c.Snapshot()
|
|
assert.EqualValues(5, cTmp.Count())
|
|
|
|
c.Clear()
|
|
assert.EqualValues(0, c.Count())
|
|
}
|