RxGo
RxGo copied to clipboard
BufferWithTimeOrCount can exceed buffer size
Describe the bug
Calling BufferWithTimeOrCount can result in larger buffers being emitted.
To Reproduce The following test always seems to fail
func TestBufferWithTimeOrCountDoesNotExceedBufferSize(t *testing.T){
observable := rxgo.Just(1,2,3)()
buffers := observable.BufferWithTimeOrCount(rxgo.WithDuration(time.Second), 1)
rxgo.Assert(context.Background(), t, buffers, rxgo.HasItems([]interface{}{1}, []interface{}{2}, []interface{}{3}))
}
The following test will intermittently fail. On my machine, I find a fail occurs on most runs if I run with go test -count 10000
func TestBufferWithTimeOrCountDoesNotExceedBufferSizeOf2(t *testing.T){
observable := rxgo.Just(1,2,3,4,5)()
buffers := observable.BufferWithTimeOrCount(rxgo.WithDuration(time.Second), 2)
rxgo.Assert(context.Background(), t, buffers, rxgo.HasItems([]interface{}{1,2}, []interface{}{3,4}, []interface{}{5}))
}
Expected behavior Buffer sizes should never exceed the count passed
Additional context
Fixed in PR https://github.com/ReactiveX/RxGo/pull/289