forked from ByteArena/box2d
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCommonB2GrowableStack_test.go
50 lines (41 loc) · 1.13 KB
/
CommonB2GrowableStack_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package box2d_test
import (
"testing"
"github.com/hulkholden/box2d"
)
func TestGrowableStack(t *testing.T) {
s := box2d.NewGrowableStack[int](4)
if got := s.GetCount(); got != 0 {
t.Errorf("GetCount() = %d, want 0", got)
}
s.Push(1)
if got, want := s.GetCount(), 1; got != want {
t.Errorf("GetCount() = %d, want %d", got, want)
}
s.Push(2)
if got, want := s.GetCount(), 2; got != want {
t.Errorf("GetCount() = %d, want %d", got, want)
}
s.Push(3)
if got, want := s.GetCount(), 3; got != want {
t.Errorf("GetCount() = %d, want %d", got, want)
}
if got, want := s.Pop(), 3; got != want {
t.Errorf("Pop() = %d, want %d", got, want)
}
if got, want := s.GetCount(), 2; got != want {
t.Errorf("GetCount() = %d, want %d", got, want)
}
if got, want := s.Pop(), 2; got != want {
t.Errorf("Pop() = %d, want %d", got, want)
}
if got, want := s.GetCount(), 1; got != want {
t.Errorf("GetCount() = %d, want %d", got, want)
}
if got, want := s.Pop(), 1; got != want {
t.Errorf("Pop() = %d, want %d", got, want)
}
if got, want := s.GetCount(), 0; got != want {
t.Errorf("GetCount() = %d, want %d", got, want)
}
}