Entity Component System framework for Ebiten
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
893 B

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)
}
}