aboutsummaryrefslogtreecommitdiff
path: root/internal/validate
diff options
context:
space:
mode:
Diffstat (limited to 'internal/validate')
-rw-r--r--internal/validate/grid_test.go72
-rw-r--r--internal/validate/local_test.go24
2 files changed, 52 insertions, 44 deletions
diff --git a/internal/validate/grid_test.go b/internal/validate/grid_test.go
index e40c50b..0e1d2dd 100644
--- a/internal/validate/grid_test.go
+++ b/internal/validate/grid_test.go
@@ -42,9 +42,9 @@ func containsMsg(issues []Issue, substr string) bool {
func TestGridCleanLayout(t *testing.T) {
// A consistent 2x2 block: 4 is reached the same way from 2 and from 3.
rooms := map[int]string{
- 1: "exits:\n south: 3\n east: 2\n",
- 2: "exits:\n south: 4\n",
- 3: "exits:\n east: 4\n",
+ 1: "exits:\n south: {room: 3}\n east: {room: 2}\n",
+ 2: "exits:\n south: {room: 4}\n",
+ 3: "exits:\n east: {room: 4}\n",
4: "name: corner\n",
}
if issues := runGridCheck(t, rooms, 1); len(issues) != 0 {
@@ -55,9 +55,9 @@ func TestGridCleanLayout(t *testing.T) {
func TestGridOverlap(t *testing.T) {
// rooms 4 and 5 both resolve to grid (1,1).
rooms := map[int]string{
- 1: "exits:\n south: 3\n east: 2\n",
- 2: "exits:\n south: 5\n",
- 3: "exits:\n east: 4\n",
+ 1: "exits:\n south: {room: 3}\n east: {room: 2}\n",
+ 2: "exits:\n south: {room: 5}\n",
+ 3: "exits:\n east: {room: 4}\n",
4: "name: four\n",
5: "name: five\n",
}
@@ -75,9 +75,9 @@ func TestGridOverlap(t *testing.T) {
func TestGridTwist(t *testing.T) {
// room 3 is forced onto two different cells.
rooms := map[int]string{
- 1: "exits:\n south: 4\n east: 2\n",
- 2: "exits:\n east: 3\n",
- 4: "exits:\n east: 3\n",
+ 1: "exits:\n south: {room: 4}\n east: {room: 2}\n",
+ 2: "exits:\n east: {room: 3}\n",
+ 4: "exits:\n east: {room: 3}\n",
3: "name: three\n",
}
issues := runGridCheck(t, rooms, 1)
@@ -90,10 +90,10 @@ func TestGridMultiPlaneViaUpDown(t *testing.T) {
// Room 1 at (0,0,0) goes up to room 10 at (0,0,1). Rooms 13 and 14 both
// resolve to (1,1,1) — 3D overlap on the upper level.
rooms := map[int]string{
- 1: "exits:\n up: 10\n",
- 10: "exits:\n south: 12\n east: 11\n",
- 11: "exits:\n south: 14\n",
- 12: "exits:\n east: 13\n",
+ 1: "exits:\n up: {room: 10}\n",
+ 10: "exits:\n south: {room: 12}\n east: {room: 11}\n",
+ 11: "exits:\n south: {room: 14}\n",
+ 12: "exits:\n east: {room: 13}\n",
13: "name: thirteen\n",
14: "name: fourteen\n",
}
@@ -107,11 +107,11 @@ func TestGrid3DCleanViaUpDown(t *testing.T) {
// Clean 3D layout: up/down maintain same (x,y) across z-levels.
// 1(0,0,0) up→2(0,0,1) east→3(1,0,1) down→4(1,0,0) south→5(1,1,0)
rooms := map[int]string{
- 1: "exits:\n up: 2\n",
- 2: "exits:\n east: 3\n down: 1\n",
- 3: "exits:\n down: 4\n west: 2\n",
- 4: "exits:\n south: 5\n up: 3\n",
- 5: "name: five\n exits:\n north: 4\n",
+ 1: "exits:\n up: {room: 2}\n",
+ 2: "exits:\n east: {room: 3}\n down: {room: 1}\n",
+ 3: "exits:\n down: {room: 4}\n west: {room: 2}\n",
+ 4: "exits:\n south: {room: 5}\n up: {room: 3}\n",
+ 5: "name: five\n exits:\n north: {room: 4}\n",
}
if issues := runGridCheck(t, rooms, 1); len(issues) != 0 {
t.Errorf("expected no grid issues, got: %+v", issues)
@@ -123,10 +123,10 @@ func TestGrid3DOverlapUpDown(t *testing.T) {
// 1(0,0,0) up→2(0,0,1).
// 1(0,0,0) east→3(1,0,0) up→4(1,0,1) west→5 wants (0,0,1) — already room 2.
rooms := map[int]string{
- 1: "exits:\n up: 2\n east: 3\n",
+ 1: "exits:\n up: {room: 2}\n east: {room: 3}\n",
2: "name: two\n",
- 3: "exits:\n up: 4\n west: 1\n",
- 4: "exits:\n west: 5\n down: 3\n",
+ 3: "exits:\n up: {room: 4}\n west: {room: 1}\n",
+ 4: "exits:\n west: {room: 5}\n down: {room: 3}\n",
5: "name: five\n",
}
issues := runGridCheck(t, rooms, 1)
@@ -141,13 +141,13 @@ func TestGrid3DTwistUpDown(t *testing.T) {
// path2: 1 east→A(1,0,0) up→B(1,0,1) east→C(2,0,1) south→4 wants (2,1,1)
// 4 already at (1,1,1) from path1 → twist.
rooms := map[int]string{
- 1: "exits:\n up: 2\n east: 6\n",
- 2: "exits:\n south: 3\n down: 1\n",
- 3: "exits:\n east: 4\n north: 2\n",
+ 1: "exits:\n up: {room: 2}\n east: {room: 6}\n",
+ 2: "exits:\n south: {room: 3}\n down: {room: 1}\n",
+ 3: "exits:\n east: {room: 4}\n north: {room: 2}\n",
4: "name: four\n",
- 6: "exits:\n up: 7\n west: 1\n",
- 7: "exits:\n east: 8\n down: 6\n",
- 8: "exits:\n south: 4\n west: 7\n",
+ 6: "exits:\n up: {room: 7}\n west: {room: 1}\n",
+ 7: "exits:\n east: {room: 8}\n down: {room: 6}\n",
+ 8: "exits:\n south: {room: 4}\n west: {room: 7}\n",
}
issues := runGridCheck(t, rooms, 1)
if !containsMsg(issues, "Grid twist") {
@@ -158,8 +158,8 @@ func TestGrid3DTwistUpDown(t *testing.T) {
func TestGridDiagonalClean(t *testing.T) {
// Room 1 -> NE -> Room 2 (at 1,-1). Clean diagonal placement.
rooms := map[int]string{
- 1: "exits:\n northeast: 2\n",
- 2: "name: two\n exits:\n southwest: 1\n",
+ 1: "exits:\n northeast: {room: 2}\n",
+ 2: "name: two\n exits:\n southwest: {room: 1}\n",
}
if issues := runGridCheck(t, rooms, 1); len(issues) != 0 {
t.Errorf("expected no grid issues, got: %+v", issues)
@@ -171,9 +171,9 @@ func TestGridDiagonalOverlap(t *testing.T) {
// 1→SE→2→E→4 lands 4 at (2,1).
// 1→E→3→SE→5 lands 5 at (2,1). Room 4 != 5 → overlap.
rooms := map[int]string{
- 1: "exits:\n southeast: 2\n east: 3\n",
- 2: "exits:\n east: 4\n",
- 3: "exits:\n southeast: 5\n",
+ 1: "exits:\n southeast: {room: 2}\n east: {room: 3}\n",
+ 2: "exits:\n east: {room: 4}\n",
+ 3: "exits:\n southeast: {room: 5}\n",
4: "name: four\n",
5: "name: five\n",
}
@@ -189,11 +189,11 @@ func TestGridDiagonalTwist(t *testing.T) {
// path2: 1→N→3 (3 at 0,-1). 3→E→5 (5 at 1,-1). 5→N→4 wants 4 at (1,-2).
// 4 already placed at (2,-1) but wanted at (1,-2) → twist.
rooms := map[int]string{
- 1: "exits:\n east: 2\n north: 3\n",
- 2: "exits:\n northeast: 4\n",
- 3: "exits:\n east: 5\n",
+ 1: "exits:\n east: {room: 2}\n north: {room: 3}\n",
+ 2: "exits:\n northeast: {room: 4}\n",
+ 3: "exits:\n east: {room: 5}\n",
4: "name: four\n",
- 5: "exits:\n north: 4\n",
+ 5: "exits:\n north: {room: 4}\n",
}
issues := runGridCheck(t, rooms, 1)
if !containsMsg(issues, "Grid twist") {
diff --git a/internal/validate/local_test.go b/internal/validate/local_test.go
index 337f3d2..f0bc0a1 100644
--- a/internal/validate/local_test.go
+++ b/internal/validate/local_test.go
@@ -78,9 +78,11 @@ func TestValidateRoomsSameNameCollision(t *testing.T) {
objects:
- id: ghost_object
- name: sign
- description: "one"
+ description:
+ - text: "one"
- name: sign
- description: "two"
+ description:
+ - text: "two"
`)
issues := validateRooms(newSource(dir))
@@ -102,7 +104,8 @@ objects:
- id: copper_rock
- id: anvil
- name: anvil
- description: "a local thing that collides with the file id"
+ description:
+ - text: "a local thing that collides with the file id"
`)
issues := validateRooms(newSource(dir))
@@ -136,11 +139,13 @@ func TestValidateExitReciprocityMismatch(t *testing.T) {
dir := t.TempDir()
writeFile(t, filepath.Join(dir, "rooms", "1.yaml"), `name: Room One
exits:
- down: 2
+ down:
+ room: 2
`)
writeFile(t, filepath.Join(dir, "rooms", "2.yaml"), `name: Room Two
exits:
- south: 1
+ south:
+ room: 1
`)
issues := validateExitReciprocity(newSource(dir))
if !containsMsg(issues, "not the expected opposite direction") {
@@ -152,7 +157,8 @@ func TestValidateExitReciprocityOneWay(t *testing.T) {
dir := t.TempDir()
writeFile(t, filepath.Join(dir, "rooms", "1.yaml"), `name: Room One
exits:
- east: 2
+ east:
+ room: 2
`)
writeFile(t, filepath.Join(dir, "rooms", "2.yaml"), `name: Room Two
`)
@@ -167,9 +173,11 @@ func TestValidateRoomsPartialNameSiblingsOK(t *testing.T) {
writeFile(t, filepath.Join(dir, "rooms", "1.yaml"), `name: Test Room
objects:
- name: rusty sign
- description: "rusty"
+ description:
+ - text: "rusty"
- name: shiny sign
- description: "shiny"
+ description:
+ - text: "shiny"
`)
issues := validateRooms(newSource(dir))
for _, iss := range issues {