fix(testcase): modify testcase

pull/45/head
reanon 2 years ago
parent bed8b07b0b
commit d32f15feb1

@ -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)

Loading…
Cancel
Save