42 lines
559 B
Go
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()
|
|
}
|