github.com/weedge/lib@v0.0.0-20230424045628-a36dcc1d90e4/timingwheel/bucket_test.go (about) 1 package timingwheel 2 3 import "testing" 4 5 func TestBucket_Flush(t *testing.T) { 6 b := newBucket() 7 8 b.Add(&Timer{}) 9 b.Add(&Timer{}) 10 l1 := b.timers.Len() 11 if l1 != 2 { 12 t.Fatalf("Got (%+v) != Want (%+v)", l1, 2) 13 } 14 15 b.Flush(func(*Timer) {}) 16 l2 := b.timers.Len() 17 if l2 != 0 { 18 t.Fatalf("Got (%+v) != Want (%+v)", l2, 0) 19 } 20 }