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
10 years ago
|
package stack
|
||
|
|
||
|
import "testing"
|
||
|
|
||
|
func Test_Stack(t *testing.T) {
|
||
10 years ago
|
stack := New()
|
||
10 years ago
|
|
||
|
stack.Push(5)
|
||
|
stack.Push(6)
|
||
|
stack.Push(7)
|
||
10 years ago
|
|
||
|
if stack.Length() != 3 {
|
||
|
t.Error("[Error] stack length is wrong")
|
||
|
}
|
||
10 years ago
|
|
||
|
stack.Pop()
|
||
|
|
||
10 years ago
|
if stack.Length() != 2 {
|
||
|
t.Error("[Error] stack length is wrong after pop")
|
||
|
}
|
||
|
|
||
|
if stack.Peek() != 6 {
|
||
|
t.Error("[Error] stack Peek is wrong")
|
||
|
}
|
||
10 years ago
|
}
|