🧪 test: 添加pop测试用例

This commit is contained in:
xiaok29 2024-05-14 11:54:16 +08:00
parent 920556ace4
commit 3b96f88503
3 changed files with 18 additions and 0 deletions

View File

@ -10,6 +10,7 @@ import (
"testing"
. "github.com/krahets/hello-algo/pkg"
"gotest.tools/v3/assert"
)
func TestQueue(t *testing.T) {
@ -46,6 +47,15 @@ func TestQueue(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
queue := newArrayQueue(capacity)

View File

@ -1,3 +1,7 @@
module github.com/krahets/hello-algo
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
View 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=