Skip to content

Add tests pinning grid layout and directional movement - #68

Merged
dmccoystephenson merged 1 commit into
masterfrom
feature/grid-layout-movement-tests
Oct 30, 2026
Merged

dmccoystephenson merged 1 commit into
masterfrom
feature/grid-layout-movement-tests

Conversation

@dmccoystephenson

Copy link
Copy Markdown
Member

Summary

Stage B (unit-test expansion) cycle for the README's "Grid Layout and Movement" contract. The existing directional-move tests place the entity at a random location and accept either outcome, so the off-grid false path and the y-down direction mapping were never asserted deterministically. The location id format and generation order were also untested.

Four characterization tests were added to src/tests.cpp and registered in main():

  • Test 53: Grid(3, 3) generates locations row by row (y outer, x inner), with ids of the form <gridId>-<x>-<y>.
  • Test 54: Grid::setId and Grid::setSize only overwrite the stored values. The location count and ids stay as generated.
  • Test 55: moves off the top/left edge from (0,0) and off the bottom/right edge from (2,2) return false and leave the entity in place.
  • Test 56: from (1,1), up → 0-1-0, right → 0-2-0, down → 0-2-1, left → 0-1-1, each returning true.

No production code is changed. No tracking issue exists: the gap was found during triage, when the open-issue backlog was empty.

Test plan

  • make compiles cleanly with the new tests.
  • CI "Library tests (make + CMake)" job green. bash run_tests.sh cannot be run in this session, so CI is the anchor.

This PR description was drafted during a Gardener session (https://github.com/Stephenson-Software/gardener).

🤖 Generated with Claude Code


drafted by Claude on behalf of Daniel Stephenson

Cover the location id format and row-by-row generation order, setId/setSize
leaving existing locations alone, off-grid moves returning false from both
corners, and each direction following y-down coordinates.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@dmccoystephenson

Copy link
Copy Markdown
Member Author

Self-review rubric (anchor: CI "Library tests (make + CMake)" job, run 41014552214, where the log shows Tests 1–56 each followed by --- Success):

  • Scope: PASS. Only src/tests.cpp is modified (+71 lines). There are no production, formatting or comment changes.
  • Tests-new: PASS. No new public methods were added. Four new tests cover previously unasserted behaviour of Grid generation, setId/setSize and the four directional moves.
  • Tests-fix: N/A. No bug fix is included. These are characterization tests of current behaviour.
  • Sibling structure: PASS. Each test follows the existing void test<Behavior>() + "Test N - ..." / " --- Success" pattern, numbered 53–56 after Test 52.
  • Sibling renames: N/A. Nothing was renamed.
  • Docs: PASS. The ## Classes table in README.md still lists exactly the four classes. The new tests assert what the "Grid Layout and Movement" section already documents (id format <gridId>-<x>-<y>, row-by-row order, setId/setSize not regenerating, y-down moves, false off-grid).
  • Issue resolution: N/A. No Closes reference is made. The gap was found during triage with an empty backlog.
  • Local test suite: PASS (via CI). The local bash run_tests.sh is not runnable in this session. make compiled cleanly locally, and CI ran and passed all 56 tests.
  • Header/definition parity: N/A. No headers were changed.
  • Include guards: N/A. No new headers were added.
  • Test registration: PASS. All four functions are called from main() (CI output confirms Tests 53–56 executed).

Findings:

  • src/tests.cpp Test 55 uses moveEntityToNewLocation as setup to reach (2,2). A regression in that method would surface here as well as in Tests 15/16. This is acceptable, since that method has its own coverage, and is noted for traceability.
  • src/tests.cpp Test 54 partially overlaps Test 30 (getSize() == 6 after setSize). The overlap is kept because Test 54 asserts the stronger property (locations unchanged).

No blocking findings.

This comment was drafted during a Gardener session (https://github.com/Stephenson-Software/gardener).


drafted by Claude on behalf of Daniel Stephenson

@dmccoystephenson
dmccoystephenson merged commit 46ad336 into master Oct 30, 2026
3 checks passed
@dmccoystephenson
dmccoystephenson deleted the feature/grid-layout-movement-tests branch October 30, 2026 06:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant