Skip to content

Commit

Permalink
test collect return and Exceeded
Browse files Browse the repository at this point in the history
  • Loading branch information
electron0zero committed Sep 25, 2024
1 parent 073799f commit 312131c
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions pkg/collector/distinct_value_collector_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,16 @@ import (
func TestDistinctValueCollector(t *testing.T) {
d := NewDistinctValue[string](10, func(s string) int { return len(s) })

d.Collect("123")
d.Collect("4567")
d.Collect("890")
var stop bool
stop = d.Collect("123")
require.False(t, stop)
stop = d.Collect("4567")
require.False(t, stop)
stop = d.Collect("890")
require.True(t, stop)

require.True(t, d.Exceeded())
require.Equal(t, stop, d.Exceeded()) // final stop should be same as Exceeded
require.Equal(t, []string{"123", "4567"}, d.Values())

// diff fails when diff is not enabled
Expand Down

0 comments on commit 312131c

Please sign in to comment.