gitee.com/sy_183/go-common@v1.0.5-0.20231205030221-958cfe129b47/container/queue_test.go (about) 1 package container 2 3 import ( 4 "fmt" 5 "testing" 6 ) 7 8 func TestQueue(t *testing.T) { 9 queue := NewQueue[int](10) 10 queue.Unshift(9) 11 queue.Unshift(8) 12 queue.Push(0) 13 queue.Push(1) 14 queue.Push(2) 15 queue.Shift() 16 fmt.Println(queue.Get(1)) 17 fmt.Println(queue.Tail()) 18 fmt.Println(queue.Head()) 19 fmt.Println(queue.Slice(0, 1)) 20 } 21 22 func BenchmarkQueue(b *testing.B) { 23 l := 200000 24 queue := NewQueue[int](l) 25 for i := 0; i < b.N; i++ { 26 for i := 0; i < l; i++ { 27 queue.Push(i) 28 } 29 for i := 0; i < l; i++ { 30 queue.Shift() 31 } 32 } 33 }