51 lines
893 B
Go
51 lines
893 B
Go
package gohan
|
|
|
|
import (
|
|
"testing"
|
|
)
|
|
|
|
func TestActiveEntities(t *testing.T) {
|
|
w := NewWorld()
|
|
w.cacheTime = 0
|
|
|
|
active := w.CurrentEntities()
|
|
if active != 0 {
|
|
t.Fatalf("expected 0 active entities, got %d", active)
|
|
}
|
|
|
|
active = w.CurrentEntities()
|
|
if active != 0 {
|
|
t.Fatalf("expected 0 active entities, got %d", active)
|
|
}
|
|
|
|
// Create entity.
|
|
e1 := w.NewEntity()
|
|
|
|
active = w.CurrentEntities()
|
|
if active != 1 {
|
|
t.Fatalf("expected 1 active entities, got %d", active)
|
|
}
|
|
|
|
// Create entity.
|
|
e2 := w.NewEntity()
|
|
|
|
active = w.CurrentEntities()
|
|
if active != 2 {
|
|
t.Fatalf("expected 2 active entities, got %d", active)
|
|
}
|
|
|
|
w.RemoveEntity(e1)
|
|
|
|
active = w.CurrentEntities()
|
|
if active != 1 {
|
|
t.Fatalf("expected 1 active entities, got %d", active)
|
|
}
|
|
|
|
w.RemoveEntity(e2)
|
|
|
|
active = w.CurrentEntities()
|
|
if active != 0 {
|
|
t.Fatalf("expected 0 active entities, got %d", active)
|
|
}
|
|
}
|