11package debounce_test
22
33import (
4+ "slices"
45 "testing"
56 "time"
67
78 "github.com/floatdrop/debounce/v2"
8-
9- "github.com/stretchr/testify/assert"
109)
1110
1211// helper to collect output with a timeout
@@ -42,8 +41,11 @@ func TestDebounce_LastValueOnly(t *testing.T) {
4241 close (in )
4342 }()
4443
44+ expected := []int {4 }
4545 result := collect (out , 1 * time .Second )
46- assert .Equal (t , []int {4 }, result )
46+ if ! slices .Equal (expected , result ) {
47+ t .Errorf ("expected result = %v, got %v" , expected , result )
48+ }
4749}
4850
4951func TestDebounce_MultipleValuesSpacedOut (t * testing.T ) {
@@ -60,8 +62,11 @@ func TestDebounce_MultipleValuesSpacedOut(t *testing.T) {
6062 close (in )
6163 }()
6264
65+ expected := []int {1 , 2 , 3 }
6366 result := collect (out , 1 * time .Second )
64- assert .Equal (t , []int {1 , 2 , 3 }, result )
67+ if ! slices .Equal (expected , result ) {
68+ t .Errorf ("expected result = %v, got %v" , expected , result )
69+ }
6570}
6671
6772func TestDebounce_WithLimit (t * testing.T ) {
@@ -80,8 +85,11 @@ func TestDebounce_WithLimit(t *testing.T) {
8085 close (in )
8186 }()
8287
88+ expected := []int {3 , 4 }
8389 result := collect (out , 1 * time .Second )
84- assert .Equal (t , []int {3 , 4 }, result )
90+ if ! slices .Equal (expected , result ) {
91+ t .Errorf ("expected result = %v, got %v" , expected , result )
92+ }
8593}
8694
8795func TestDebounce_ChannelCloses (t * testing.T ) {
@@ -93,8 +101,11 @@ func TestDebounce_ChannelCloses(t *testing.T) {
93101 close (in )
94102 }()
95103
104+ expected := []int {42 }
96105 result := collect (out , 1 * time .Second )
97- assert .Equal (t , []int {42 }, result )
106+ if ! slices .Equal (expected , result ) {
107+ t .Errorf ("expected result = %v, got %v" , expected , result )
108+ }
98109}
99110
100111func TestDebounce_EmptyChannelCloses (t * testing.T ) {
@@ -105,14 +116,19 @@ func TestDebounce_EmptyChannelCloses(t *testing.T) {
105116 close (in )
106117 }()
107118
119+ expected := []int (nil )
108120 result := collect (out , 1 * time .Second )
109- assert .Equal (t , []int (nil ), result )
121+ if ! slices .Equal (expected , result ) {
122+ t .Errorf ("expected result = %v, got %v" , expected , result )
123+ }
110124}
111125
112126func TestDebounce_ZeroDelay (t * testing.T ) {
113127 in := make (chan int )
114128 out := debounce .Chan (in )
115- assert .Equal (t , (<- chan int )(in ), out )
129+ if (<- chan int )(in ) != out {
130+ t .Errorf ("expected result = %v, got %v" , (<- chan int )(in ), out )
131+ }
116132}
117133
118134func BenchmarkDebounce_Insert (b * testing.B ) {
0 commit comments