From 3b96f8850332a2cbfa827d793f7c815729ad31b8 Mon Sep 17 00:00:00 2001 From: xiaok29 <1526783667@qq.com> Date: Tue, 14 May 2024 11:54:16 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=A7=AA=20test:=20=E6=B7=BB=E5=8A=A0pop?= =?UTF-8?q?=E6=B5=8B=E8=AF=95=E7=94=A8=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- codes/go/chapter_stack_and_queue/queue_test.go | 10 ++++++++++ codes/go/go.mod | 4 ++++ codes/go/go.sum | 4 ++++ 3 files changed, 18 insertions(+) create mode 100644 codes/go/go.sum diff --git a/codes/go/chapter_stack_and_queue/queue_test.go b/codes/go/chapter_stack_and_queue/queue_test.go index cf46cd17b..8c0906bbe 100644 --- a/codes/go/chapter_stack_and_queue/queue_test.go +++ b/codes/go/chapter_stack_and_queue/queue_test.go @@ -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) diff --git a/codes/go/go.mod b/codes/go/go.mod index 34f5dac20..a62c29afd 100644 --- a/codes/go/go.mod +++ b/codes/go/go.mod @@ -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 diff --git a/codes/go/go.sum b/codes/go/go.sum new file mode 100644 index 000000000..7dd4ab56e --- /dev/null +++ b/codes/go/go.sum @@ -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=