You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
26 lines
427 B
Go
26 lines
427 B
Go
package stack
|
|
|
|
import "testing"
|
|
|
|
func Test_Stack(t *testing.T) {
|
|
stack := New()
|
|
|
|
stack.Push(5)
|
|
stack.Push(6)
|
|
stack.Push(7)
|
|
|
|
if stack.Length() != 3 {
|
|
t.Error("[Error] stack length is wrong")
|
|
}
|
|
|
|
stack.Pop()
|
|
|
|
if stack.Length() != 2 {
|
|
t.Error("[Error] stack length is wrong after pop")
|
|
}
|
|
|
|
if stack.Peek() != 6 {
|
|
t.Error("[Error] stack Peek is wrong")
|
|
}
|
|
}
|