From d32f15feb14a19e2f1fc0c125795ef87e8cdfc6a Mon Sep 17 00:00:00 2001 From: reanon <793584285@qq.com> Date: Tue, 29 Nov 2022 01:17:07 +0800 Subject: [PATCH] fix(testcase): modify testcase --- .../go/chapter_stack_and_queue/stack_test.go | 24 ++++++++----------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/codes/go/chapter_stack_and_queue/stack_test.go b/codes/go/chapter_stack_and_queue/stack_test.go index b3cd3da49..b546d553f 100644 --- a/codes/go/chapter_stack_and_queue/stack_test.go +++ b/codes/go/chapter_stack_and_queue/stack_test.go @@ -6,9 +6,9 @@ package chapter_stack_and_queue import "testing" -func TestStack(t *testing.T) { +func TestArrayStack(t *testing.T) { // 初始化栈 - stack := NewLinkedListStack() + stack := NewArrayStack() // 元素入栈 stack.Push(1) @@ -35,9 +35,9 @@ func TestStack(t *testing.T) { t.Log("栈是否为空 = ", isEmpty) } -func TestArrayStack(t *testing.T) { +func TestLinkedListStack(t *testing.T) { // 初始化栈 - stack := NewArrayStack() + stack := NewLinkedListStack() // 元素入栈 stack.Push(1) @@ -64,13 +64,9 @@ func TestArrayStack(t *testing.T) { t.Log("栈是否为空 = ", isEmpty) } -func TestLinkedListStack(t *testing.T) { - -} - -// BenchmarkStack 65.02 ns/op in Mac M1 Pro -func BenchmarkStack(b *testing.B) { - stack := NewLinkedListStack() +// BenchmarkArrayStack 8 ns/op in Mac M1 Pro +func BenchmarkArrayStack(b *testing.B) { + stack := NewArrayStack() // use b.N for looping for i := 0; i < b.N; i++ { stack.Push(777) @@ -80,9 +76,9 @@ func BenchmarkStack(b *testing.B) { } } -// BenchmarkArrayStack 8 ns/op in Mac M1 Pro -func BenchmarkArrayStack(b *testing.B) { - stack := NewArrayStack() +// BenchmarkLinkedListStack 65.02 ns/op in Mac M1 Pro +func BenchmarkLinkedListStack(b *testing.B) { + stack := NewLinkedListStack() // use b.N for looping for i := 0; i < b.N; i++ { stack.Push(777)