aboutsummaryrefslogtreecommitdiff
path: root/internal/validate/grid_test.go
diff options
context:
space:
mode:
authorhistoria <[not public]>2026-06-29 17:19:40 -0400
committerhistoria <[not public]>2026-06-29 17:19:40 -0400
commitfeb80b7dde200d4121cd9f9c583a08f9869c5588 (patch)
tree3271cae1d74c8f3b84ef3ae84f8f62e563029dff /internal/validate/grid_test.go
parentc6cbf76b33ac20d071d25e74b70f6901476193a6 (diff)
downloadthehouseoficarus-feb80b7dde200d4121cd9f9c583a08f9869c5588.tar.gz
feat: incardinal directions (nw, ne, sw, se). probably janky in ways I haven't yet discovered.
Diffstat (limited to 'internal/validate/grid_test.go')
-rw-r--r--internal/validate/grid_test.go46
1 files changed, 46 insertions, 0 deletions
diff --git a/internal/validate/grid_test.go b/internal/validate/grid_test.go
index 9a8ef02..b3f834a 100644
--- a/internal/validate/grid_test.go
+++ b/internal/validate/grid_test.go
@@ -103,3 +103,49 @@ func TestGridMultiPlaneViaUpDown(t *testing.T) {
t.Errorf("expected an overlap in plane origin 10, got: %+v", issues)
}
}
+
+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",
+ }
+ if issues := runGridCheck(t, rooms, 1); len(issues) != 0 {
+ t.Errorf("expected no grid issues, got: %+v", issues)
+ }
+}
+
+func TestGridDiagonalOverlap(t *testing.T) {
+ // Two different rooms both resolve to (2,1):
+ // 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",
+ 4: "name: four\n",
+ 5: "name: five\n",
+ }
+ issues := runGridCheck(t, rooms, 1)
+ if !containsMsg(issues, "Grid overlap") {
+ t.Errorf("expected a grid overlap via diagonal, got: %+v", issues)
+ }
+}
+
+func TestGridDiagonalTwist(t *testing.T) {
+ // Room 4 forced onto two different cells:
+ // path1: 1→E→2 (2 at 1,0). 2→NE→4 places 4 at (2,-1).
+ // 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",
+ 4: "name: four\n",
+ 5: "exits:\n north: 4\n",
+ }
+ issues := runGridCheck(t, rooms, 1)
+ if !containsMsg(issues, "Grid twist") {
+ t.Errorf("expected a grid twist via diagonal, got: %+v", issues)
+ }
+}