优化循环队列test

This commit is contained in:
orgin
2022-06-30 10:38:05 +08:00
parent f61fd5d1be
commit ae0ba1d966
2 changed files with 31 additions and 9 deletions

View File

@@ -12,7 +12,7 @@ func Test_Example(t *testing.T) {
t.Log("is empty :", queue.IsEmpty())
t.Log("is full :", queue.IsFull())
//3.游标使用
//3.游标使用,打印所有数据
cursor := queue.GetCursor()
cursor.First()
for {
@@ -23,7 +23,7 @@ func Test_Example(t *testing.T) {
t.Log("elem:", elem)
}
//4.push数据
//4.push数据,塞满队列
for i := 0; i < 6; i++ {
t.Log("push:", queue.Push(i))
}
@@ -31,7 +31,7 @@ func Test_Example(t *testing.T) {
t.Log("is empty :", queue.IsEmpty())
t.Log("is full :", queue.IsFull())
//5.游标遍历
//5.使用游标遍历所有数据
cursor.First()
for {
elem, ret := cursor.Next()
@@ -41,7 +41,21 @@ func Test_Example(t *testing.T) {
t.Log("elem:", elem)
}
//pop数据所有
//6.删除2个元素
removeNum := queue.RemoveElement(2)
t.Log("Remove Num:", removeNum)
//7.游标遍历
cursor.First()
for {
elem, ret := cursor.Next()
if ret == false {
break
}
t.Log("elem:", elem)
}
//8.pop数据所有
for i := 0; i < 6; i++ {
elem, ret := queue.Pop()
t.Log("pop:", elem, "-", ret, " len:", queue.Len())