...
1 package gohan
2
3 import (
4 "testing"
5 )
6
7 func TestActiveEntities(t *testing.T) {
8 Reset()
9 w.cacheTime = 0
10
11 active := CurrentEntities()
12 if active != 0 {
13 t.Fatalf("expected 0 active entities, got %d", active)
14 }
15
16 active = CurrentEntities()
17 if active != 0 {
18 t.Fatalf("expected 0 active entities, got %d", active)
19 }
20
21
22 e1 := NewEntity()
23
24 active = CurrentEntities()
25 if active != 1 {
26 t.Fatalf("expected 1 active entities, got %d", active)
27 }
28
29
30 e2 := NewEntity()
31
32 active = CurrentEntities()
33 if active != 2 {
34 t.Fatalf("expected 2 active entities, got %d", active)
35 }
36
37 e1.Remove()
38
39 active = CurrentEntities()
40 if active != 1 {
41 t.Fatalf("expected 1 active entities, got %d", active)
42 }
43
44 e2.Remove()
45
46 active = CurrentEntities()
47 if active != 0 {
48 t.Fatalf("expected 0 active entities, got %d", active)
49 }
50 }
51
View as plain text