algo/go/08_stack/StackBasedOnLinkedList_test.go
2018-10-09 23:54:01 +08:00

42 lines
559 B
Go

package _8_stack
import "testing"
func TestLinkedListStack_Push(t *testing.T) {
s := NewLinkedListStack()
s.Push(1)
s.Push(2)
s.Push(3)
s.Print()
}
func TestLinkedListStack_Pop(t *testing.T) {
s := NewLinkedListStack()
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 TestLinkedListStack_Top(t *testing.T) {
s := NewLinkedListStack()
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()
}