1
0
mirror of https://github.com/divan/expvarmon.git synced 2025-05-06 19:29:17 +08:00
expvarmon/stack_test.go

28 lines
479 B
Go
Raw Normal View History

2015-04-25 09:06:45 +03:00
package main
import "testing"
func TestStack(t *testing.T) {
size := 10
2015-05-01 16:49:19 +03:00
s := NewStackWithSize(size)
2015-04-25 09:06:45 +03:00
for i := 0; i < size+5; i++ {
s.Push(i)
l := len(s.Values)
if l < size {
if l != i+1 {
2015-04-25 09:07:33 +03:00
t.Fatalf("len is incorrect. expecting %d, got %d", i, l)
2015-04-25 09:06:45 +03:00
}
} else {
if l != size {
2015-04-25 09:07:33 +03:00
t.Fatalf("len is incorrect. expecting %d, got %d", size, l)
2015-04-25 09:06:45 +03:00
}
}
}
2015-04-30 23:54:54 +03:00
if s.Front() != 14 {
t.Fatalf("Front returns wrong value: expecting %d, got %d", 14, s.Front())
}
2015-04-25 09:06:45 +03:00
}