🧪 test: 添加pop测试用例
This commit is contained in:
parent
920556ace4
commit
3b96f88503
@ -10,6 +10,7 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
. "github.com/krahets/hello-algo/pkg"
|
. "github.com/krahets/hello-algo/pkg"
|
||||||
|
"gotest.tools/v3/assert"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestQueue(t *testing.T) {
|
func TestQueue(t *testing.T) {
|
||||||
@ -46,6 +47,15 @@ func TestQueue(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestArrayQueue(t *testing.T) {
|
func TestArrayQueue(t *testing.T) {
|
||||||
|
t.Run("pop", func(t *testing.T) {
|
||||||
|
queue := newArrayQueue(2)
|
||||||
|
assert.Equal(t, nil, queue.pop())
|
||||||
|
|
||||||
|
queue.push(1)
|
||||||
|
queue.push(2)
|
||||||
|
assert.Equal(t, 1, queue.pop())
|
||||||
|
})
|
||||||
|
|
||||||
// 初始化队列,使用队列的通用接口
|
// 初始化队列,使用队列的通用接口
|
||||||
capacity := 10
|
capacity := 10
|
||||||
queue := newArrayQueue(capacity)
|
queue := newArrayQueue(capacity)
|
||||||
|
@ -1,3 +1,7 @@
|
|||||||
module github.com/krahets/hello-algo
|
module github.com/krahets/hello-algo
|
||||||
|
|
||||||
go 1.19
|
go 1.19
|
||||||
|
|
||||||
|
require gotest.tools/v3 v3.5.1
|
||||||
|
|
||||||
|
require github.com/google/go-cmp v0.5.9 // indirect
|
||||||
|
4
codes/go/go.sum
Normal file
4
codes/go/go.sum
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
|
||||||
|
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
|
||||||
|
gotest.tools/v3 v3.5.1 h1:EENdUnS3pdur5nybKYIh2Vfgc8IUNBjxDPSjtiJcOzU=
|
||||||
|
gotest.tools/v3 v3.5.1/go.mod h1:isy3WKz7GK6uNw/sbHzfKBLvlvXwUyV06n6brMxxopU=
|
Loading…
Reference in New Issue
Block a user