func TestReset(t *testing.T) { cms := streaming.MakeCMSDirect(100, 100, 2.0, streaming.Plain_update, streaming.Plain_read) k1 := []byte("hello") cms.Update(k1, 1.0) cms.Reset() cnt, _ := cms.Count(k1) if math.Abs(cnt-0.0) > eps { t.Errorf("reset should have made count be 0, instead was %d", cnt) } }
func TestCMSSanity(t *testing.T) { cms := streaming.MakeCMSDirect(100, 100, 2.0, streaming.Plain_update, streaming.Plain_read) k1 := []byte("hello") cnt, _ := cms.Count(k1) if 0 != cnt { t.Error("shouldn't be anything yet") } for i := 0; i < 10; i++ { cms.Update(k1, 1.0) } cnt, _ = cms.Count(k1) if math.Abs(cnt-10.0) > eps { t.Error("should have 10") } }