33 lines
529 B
Go
33 lines
529 B
Go
|
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)
|
||
|
}
|
||
|
}
|