Files
lkm/stream/ringbuffer_test.go
DESKTOP-COJOJSE\lenovo 33ec8159f1 完善Source和Sink
2023-11-18 17:57:05 +08:00

30 lines
451 B
Go

package stream
import (
"fmt"
"testing"
)
func TestRingBuffer(t *testing.T) {
buffer := NewRingBuffer(10)
full := buffer.IsFull()
empty := buffer.IsEmpty()
head := buffer.Head()
tail := buffer.Tail()
pop := buffer.Pop()
println(full)
println(empty)
println(head)
println(tail)
println(pop)
for i := 0; i < 100; i++ {
buffer.Push(i)
}
for !buffer.IsEmpty() {
i := buffer.Pop()
println(fmt.Sprintf("element:%d", i.(int)))
}
}