mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-19 18:32:23 +00:00
chore: add test for sample.Sum
This commit is contained in:
parent
cc792610f4
commit
ed9b7a6dd4
1 changed files with 3 additions and 5 deletions
|
|
@ -112,16 +112,11 @@ func TestExpDecaySample(t *testing.T) {
|
||||||
if have, want := len(values), min(tc.updates, tc.reservoirSize); have != want {
|
if have, want := len(values), min(tc.updates, tc.reservoirSize); have != want {
|
||||||
t.Errorf("unexpected values length: have %d want %d", have, want)
|
t.Errorf("unexpected values length: have %d want %d", have, want)
|
||||||
}
|
}
|
||||||
sum := int64(0)
|
|
||||||
for _, v := range values {
|
for _, v := range values {
|
||||||
sum += v
|
|
||||||
if v > int64(tc.updates) || v < 0 {
|
if v > int64(tc.updates) || v < 0 {
|
||||||
t.Errorf("out of range [0, %d]: %v", tc.updates, v)
|
t.Errorf("out of range [0, %d]: %v", tc.updates, v)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if have, want := snap.Sum(), sum; have != want {
|
|
||||||
t.Errorf("unexpected sum: have %d want %d", have, want)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -256,6 +251,9 @@ func benchmarkSample(b *testing.B, s Sample) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func testExpDecaySampleStatistics(t *testing.T, s SampleSnapshot) {
|
func testExpDecaySampleStatistics(t *testing.T, s SampleSnapshot) {
|
||||||
|
if sum := s.Sum(); sum != 496598 {
|
||||||
|
t.Errorf("s.Sum(): 496598 != %v\n", sum)
|
||||||
|
}
|
||||||
if count := s.Count(); count != 10000 {
|
if count := s.Count(); count != 10000 {
|
||||||
t.Errorf("s.Count(): 10000 != %v\n", count)
|
t.Errorf("s.Count(): 10000 != %v\n", count)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue