Skip to content

Commit

Permalink
fix(testcase): modify testcase
Browse files Browse the repository at this point in the history
  • Loading branch information
Reanon committed Nov 29, 2022
1 parent bed8b07 commit d32f15f
Showing 1 changed file with 10 additions and 14 deletions.
24 changes: 10 additions & 14 deletions codes/go/chapter_stack_and_queue/stack_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand Down

0 comments on commit d32f15f

Please sign in to comment.