You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
50 lines
887 B
50 lines
887 B
package gohan |
|
|
|
import ( |
|
"testing" |
|
) |
|
|
|
func TestActiveEntities(t *testing.T) { |
|
w := NewWorld() |
|
w.cacheTime = 0 |
|
|
|
active := w.ActiveEntities() |
|
if active != 0 { |
|
t.Fatalf("expected 0 active entities, got %d", active) |
|
} |
|
|
|
active = w.ActiveEntities() |
|
if active != 0 { |
|
t.Fatalf("expected 0 active entities, got %d", active) |
|
} |
|
|
|
// Create entity. |
|
e1 := w.NewEntity() |
|
|
|
active = w.ActiveEntities() |
|
if active != 1 { |
|
t.Fatalf("expected 1 active entities, got %d", active) |
|
} |
|
|
|
// Create entity. |
|
e2 := w.NewEntity() |
|
|
|
active = w.ActiveEntities() |
|
if active != 2 { |
|
t.Fatalf("expected 2 active entities, got %d", active) |
|
} |
|
|
|
w.RemoveEntity(e1) |
|
|
|
active = w.ActiveEntities() |
|
if active != 1 { |
|
t.Fatalf("expected 1 active entities, got %d", active) |
|
} |
|
|
|
w.RemoveEntity(e2) |
|
|
|
active = w.ActiveEntities() |
|
if active != 0 { |
|
t.Fatalf("expected 0 active entities, got %d", active) |
|
} |
|
}
|
|
|