world/map_test.go

33 lines
529 B
Go
Raw Normal View History

2021-05-24 09:51:12 +00:00
package world
import "testing"
const (
EntityNone = iota
EntityFloor
EntityWall
EntityCeiling
EntityActor
)
func TestMap(t *testing.T) {
m := NewMap()
e := NewEntity(EntityFloor)
m.Add(e, 0, 0, 0)
c := m.Contents()
found := 0
for position, entity := range c {
if entity.Is(EntityFloor) {
if position != "0,0,0" {
t.Errorf("unexpected position: wanted %s, got %s", "0,0,0", position)
}
found++
}
}
if found != 1 {
t.Errorf("unexpected number of floor tiles: wanted %d, got %d", 1, found)
}
}