aboutsummaryrefslogtreecommitdiff
path: root/internal/validate/grid_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/validate/grid_test.go')
-rw-r--r--internal/validate/grid_test.go61
1 files changed, 56 insertions, 5 deletions
diff --git a/internal/validate/grid_test.go b/internal/validate/grid_test.go
index b3f834a..716cec1 100644
--- a/internal/validate/grid_test.go
+++ b/internal/validate/grid_test.go
@@ -87,9 +87,8 @@ func TestGridTwist(t *testing.T) {
}
func TestGridMultiPlaneViaUpDown(t *testing.T) {
- // Plane A is just room 1. Going up seeds plane B (origin 10), which has an
- // overlap. This proves up/down crosses planes and frames are independent
- // (room 1 and room 10 both sit at (0,0) without conflicting).
+ // 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",
@@ -99,8 +98,60 @@ func TestGridMultiPlaneViaUpDown(t *testing.T) {
14: "name: fourteen\n",
}
issues := runGridCheck(t, rooms, 1)
- if !containsMsg(issues, "plane origin 10") {
- t.Errorf("expected an overlap in plane origin 10, got: %+v", issues)
+ if !containsMsg(issues, "Grid overlap") {
+ t.Errorf("expected a 3D grid overlap, got: %+v", issues)
+ }
+}
+
+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",
+ }
+ if issues := runGridCheck(t, rooms, 1); len(issues) != 0 {
+ t.Errorf("expected no grid issues, got: %+v", issues)
+ }
+}
+
+func TestGrid3DOverlapUpDown(t *testing.T) {
+ // Two rooms land on the same 3D cell via up/down paths.
+ // 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",
+ 2: "name: two\n",
+ 3: "exits:\n up: 4\n west: 1\n",
+ 4: "exits:\n west: 5\n down: 3\n",
+ 5: "name: five\n",
+ }
+ issues := runGridCheck(t, rooms, 1)
+ if !containsMsg(issues, "Grid overlap") {
+ t.Errorf("expected a 3D grid overlap, got: %+v", issues)
+ }
+}
+
+func TestGrid3DTwistUpDown(t *testing.T) {
+ // Room 4 forced to two different coordinates via up/down paths.
+ // path1: 1 up→2(0,0,1) south→3(0,1,1) east→4 places 4 at (1,1,1)
+ // 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",
+ 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",
+ }
+ issues := runGridCheck(t, rooms, 1)
+ if !containsMsg(issues, "Grid twist") {
+ t.Errorf("expected a 3D grid twist, got: %+v", issues)
}
}