mirror of
https://github.com/lkmio/lkm.git
synced 2025-10-05 07:06:57 +08:00
完善Source和Sink
This commit is contained in:
29
stream/ringbuffer_test.go
Normal file
29
stream/ringbuffer_test.go
Normal file
@@ -0,0 +1,29 @@
|
||||
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)))
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user