mirror of
https://gitee.com/johng/gf.git
synced 2024-12-01 03:38:35 +08:00
add some gqueue tests
This commit is contained in:
parent
a7f15a4e00
commit
677549ec15
@ -7,17 +7,54 @@ import (
|
||||
)
|
||||
|
||||
func TestQueue_Len(t *testing.T) {
|
||||
q1 := gqueue.New()
|
||||
q1.Push(1)
|
||||
q1.Push(5)
|
||||
gtest.Assert(q1.Len(), 2)
|
||||
q1 := gqueue.New(300)
|
||||
for i := 0; i < 200; i++ {
|
||||
q1.Push(i)
|
||||
}
|
||||
gtest.Assert(q1.Len(), 200)
|
||||
}
|
||||
|
||||
func TestQueue_Pop(t *testing.T) {
|
||||
q1 := gqueue.New()
|
||||
|
||||
q1.Push(1)
|
||||
q1.Push(2)
|
||||
i1:=q1.Pop()
|
||||
i1 := q1.Pop()
|
||||
gtest.Assert(i1, 1)
|
||||
q1.Close()
|
||||
i1 = q1.Pop()
|
||||
gtest.Assert(i1, 2)
|
||||
|
||||
maxs := 12
|
||||
q2 := gqueue.New(maxs)
|
||||
for i := 0; i < maxs; i++ {
|
||||
q2.Push(i)
|
||||
}
|
||||
|
||||
i3 := q2.Pop()
|
||||
gtest.Assert(i3, 0)
|
||||
|
||||
}
|
||||
|
||||
func TestQueue_Pop2(t *testing.T) {
|
||||
|
||||
maxs := 14
|
||||
q2 := gqueue.New(maxs)
|
||||
for i := 1; i < maxs; i++ {
|
||||
q2.Push(i)
|
||||
}
|
||||
i3 := q2.Pop()
|
||||
gtest.Assert(i3, 1)
|
||||
|
||||
}
|
||||
|
||||
func TestQueue_Close(t *testing.T) {
|
||||
q1 := gqueue.New()
|
||||
q1.Push(1)
|
||||
q1.Push(2)
|
||||
gtest.Assert(q1.Len(), 2)
|
||||
|
||||
q1.Close()
|
||||
gtest.Assert(q1.Len(), 2)
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user