array_stack_test

  • 2022-12-14
  • 浏览 (526)

array_stack_test.go 源码

package array_stack

import (
	"fmt"
	"testing"
)

func TestArrayStack(t *testing.T) {
	stack := Default()

	stack.Push(1)
	stack.Push(23)
	stack.Push(3)
	stack.Push("jack")

	peek, _ := stack.Peek()
	fmt.Println(peek)

	fmt.Println(len(stack.data))
	fmt.Println(cap(stack.data))
	fmt.Println(stack.Size())

	stack.PrintData()

	pop, _ := stack.Pop()
	pop, _ = stack.Pop()
	pop, _ = stack.Pop()
	fmt.Println(pop)
	fmt.Println(stack.Size())

	stack.PrintData()

	pop, _ = stack.Pop()
	fmt.Println(pop)
	fmt.Println(stack.Size())
	fmt.Println(stack.Empty())
}

你可能感兴趣的文章

array_stack

0  赞