rove/pkg/game/world_test.go

28 lines
528 B
Go
Raw Normal View History

package game
2020-05-30 23:42:01 +01:00
import (
2020-06-02 17:51:54 +01:00
"os"
2020-05-30 23:42:01 +01:00
"testing"
)
func TestNewWorld(t *testing.T) {
// Very basic for now, nothing to verify
2020-06-02 17:51:54 +01:00
world := NewWorld(os.TempDir())
2020-05-30 23:42:01 +01:00
if world == nil {
t.Error("Failed to create world")
}
}
func TestWorld_CreateInstance(t *testing.T) {
2020-06-02 17:51:54 +01:00
world := NewWorld(os.TempDir())
2020-05-30 23:42:01 +01:00
a := world.CreateInstance()
b := world.CreateInstance()
// Basic duplicate check
if a == b {
t.Errorf("Created identical instances")
2020-06-02 17:51:54 +01:00
} else if len(world.Instances) != 2 {
t.Errorf("Incorrect number of instances created")
2020-05-30 23:42:01 +01:00
}
}