完善Source和Sink

This commit is contained in:
DESKTOP-COJOJSE\lenovo
2023-11-18 17:57:05 +08:00
parent bffd89375e
commit 33ec8159f1
13 changed files with 517 additions and 54 deletions

29
stream/ringbuffer_test.go Normal file
View 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)))
}
}