Skip to content

Commit

Permalink
sketch test
Browse files Browse the repository at this point in the history
Signed-off-by: Ben Ye <[email protected]>
  • Loading branch information
yeya24 committed Dec 4, 2024
1 parent 447cad7 commit 79f4d87
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions pkg/block/index_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ package block

import (
"context"
"github.com/stretchr/testify/require"
"math"
"os"
"path/filepath"
Expand Down Expand Up @@ -96,3 +97,22 @@ func TestGatherIndexHealthStatsReturnsOutOfOrderChunksErr(t *testing.T) {
testutil.Equals(t, 1, stats.OutOfOrderChunks)
testutil.NotOk(t, stats.OutOfOrderChunksErr())
}

func TestSketch(t *testing.T) {
s := newSketch()
// Empty.
require.Equal(t, int64(0), s.cnt)
require.Equal(t, int64(0), s.Max())
require.Equal(t, int64(0), s.Min())
require.Equal(t, int64(0), s.Avg())
require.Equal(t, int64(0), s.Quantile(0.9))

s.Add(1)
s.Add(2)
s.Add(3)
require.Equal(t, int64(3), s.cnt)
require.Equal(t, int64(3), s.Max())
require.Equal(t, int64(1), s.Min())
require.Equal(t, int64(2), s.Avg())
require.Equal(t, int64(2), s.Quantile(0.9))
}

0 comments on commit 79f4d87

Please sign in to comment.