You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
v2ray-core/app/stats/stats_test.go

33 lines
627 B

7 years ago
package stats_test
import (
"context"
7 years ago
"testing"
"v2ray.com/core"
. "v2ray.com/core/app/stats"
"v2ray.com/core/common"
7 years ago
. "v2ray.com/ext/assert"
)
func TestInternface(t *testing.T) {
assert := With(t)
assert((*Manager)(nil), Implements, (*core.StatManager)(nil))
}
func TestStatsCounter(t *testing.T) {
assert := With(t)
raw, err := common.CreateObject(context.Background(), &Config{})
assert(err, IsNil)
m := raw.(core.StatManager)
c, err := m.RegisterCounter("test.counter")
assert(err, IsNil)
assert(c.Add(1), Equals, int64(1))
assert(c.Set(0), Equals, int64(1))
assert(c.Value(), Equals, int64(0))
}