mirror of
https://github.com/zyedidia/micro.git
synced 2026-02-05 22:50:21 +09:00
40 lines
585 B
Go
40 lines
585 B
Go
package main
|
|
|
|
import "testing"
|
|
|
|
func TestStack(t *testing.T) {
|
|
stack := new(Stack)
|
|
|
|
if stack.Len() != 0 {
|
|
t.Errorf("Len failed")
|
|
}
|
|
stack.Push(5)
|
|
stack.Push("test")
|
|
stack.Push(10)
|
|
if stack.Len() != 3 {
|
|
t.Errorf("Len failed")
|
|
}
|
|
|
|
var popped interface{}
|
|
popped = stack.Pop()
|
|
if popped != 10 {
|
|
t.Errorf("Pop failed")
|
|
}
|
|
|
|
popped = stack.Pop()
|
|
if popped != "test" {
|
|
t.Errorf("Pop failed")
|
|
}
|
|
|
|
stack.Push("test")
|
|
popped = stack.Pop()
|
|
if popped != "test" {
|
|
t.Errorf("Pop failed")
|
|
}
|
|
stack.Pop()
|
|
popped = stack.Pop()
|
|
if popped != nil {
|
|
t.Errorf("Pop failed")
|
|
}
|
|
}
|