diff --git a/v2/debounce_test.go b/v2/debounce_test.go index f81ea7b..f37c031 100644 --- a/v2/debounce_test.go +++ b/v2/debounce_test.go @@ -1,12 +1,11 @@ package debounce_test import ( + "slices" "testing" "time" "github.com/floatdrop/debounce/v2" - - "github.com/stretchr/testify/assert" ) // helper to collect output with a timeout @@ -42,8 +41,11 @@ func TestDebounce_LastValueOnly(t *testing.T) { close(in) }() + expected := []int{4} result := collect(out, 1*time.Second) - assert.Equal(t, []int{4}, result) + if !slices.Equal(expected, result) { + t.Errorf("expected result = %v, got %v", expected, result) + } } func TestDebounce_MultipleValuesSpacedOut(t *testing.T) { @@ -60,8 +62,11 @@ func TestDebounce_MultipleValuesSpacedOut(t *testing.T) { close(in) }() + expected := []int{1, 2, 3} result := collect(out, 1*time.Second) - assert.Equal(t, []int{1, 2, 3}, result) + if !slices.Equal(expected, result) { + t.Errorf("expected result = %v, got %v", expected, result) + } } func TestDebounce_WithLimit(t *testing.T) { @@ -80,8 +85,11 @@ func TestDebounce_WithLimit(t *testing.T) { close(in) }() + expected := []int{3, 4} result := collect(out, 1*time.Second) - assert.Equal(t, []int{3, 4}, result) + if !slices.Equal(expected, result) { + t.Errorf("expected result = %v, got %v", expected, result) + } } func TestDebounce_ChannelCloses(t *testing.T) { @@ -93,8 +101,11 @@ func TestDebounce_ChannelCloses(t *testing.T) { close(in) }() + expected := []int{42} result := collect(out, 1*time.Second) - assert.Equal(t, []int{42}, result) + if !slices.Equal(expected, result) { + t.Errorf("expected result = %v, got %v", expected, result) + } } func TestDebounce_EmptyChannelCloses(t *testing.T) { @@ -105,14 +116,19 @@ func TestDebounce_EmptyChannelCloses(t *testing.T) { close(in) }() + expected := []int(nil) result := collect(out, 1*time.Second) - assert.Equal(t, []int(nil), result) + if !slices.Equal(expected, result) { + t.Errorf("expected result = %v, got %v", expected, result) + } } func TestDebounce_ZeroDelay(t *testing.T) { in := make(chan int) out := debounce.Chan(in) - assert.Equal(t, (<-chan int)(in), out) + if (<-chan int)(in) != out { + t.Errorf("expected result = %v, got %v", (<-chan int)(in), out) + } } func BenchmarkDebounce_Insert(b *testing.B) { diff --git a/v2/go.mod b/v2/go.mod index 07b1ace..5ce03b7 100644 --- a/v2/go.mod +++ b/v2/go.mod @@ -1,11 +1,3 @@ module github.com/floatdrop/debounce/v2 go 1.23 - -require github.com/stretchr/testify v1.10.0 - -require ( - github.com/davecgh/go-spew v1.1.1 // indirect - github.com/pmezard/go-difflib v1.0.0 // indirect - gopkg.in/yaml.v3 v3.0.1 // indirect -) diff --git a/v2/go.sum b/v2/go.sum index 713a0b4..e69de29 100644 --- a/v2/go.sum +++ b/v2/go.sum @@ -1,10 +0,0 @@ -github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= -github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= -github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA= -github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= -gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= -gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= -gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=