42 lines
529 B
Go
42 lines
529 B
Go
package _8_stack
|
|
|
|
import "testing"
|
|
|
|
func TestArrayStack_Push(t *testing.T) {
|
|
s := NewArrayStack()
|
|
s.Push(1)
|
|
s.Push(2)
|
|
s.Push(3)
|
|
s.Print()
|
|
}
|
|
|
|
func TestArrayStack_Pop(t *testing.T) {
|
|
s := NewArrayStack()
|
|
s.Push(1)
|
|
s.Push(2)
|
|
s.Push(3)
|
|
s.Print()
|
|
|
|
t.Log(s.Pop())
|
|
t.Log(s.Pop())
|
|
t.Log(s.Pop())
|
|
t.Log(s.Pop())
|
|
s.Print()
|
|
}
|
|
|
|
func TestArrayStack_Top(t *testing.T) {
|
|
s := NewArrayStack()
|
|
s.Push(1)
|
|
s.Push(2)
|
|
s.Push(3)
|
|
|
|
t.Log(s.Top())
|
|
s.Pop()
|
|
t.Log(s.Top())
|
|
s.Pop()
|
|
t.Log(s.Top())
|
|
s.Pop()
|
|
t.Log(s.Top())
|
|
s.Pop()
|
|
}
|