Skip to content

Pin first-match location lookups and occupied-location copies - #85

Merged
dmccoystephenson merged 1 commit into
masterfrom
feature/pin-duplicate-location-lookups
Nov 16, 2026
Merged

dmccoystephenson merged 1 commit into
masterfrom
feature/pin-duplicate-location-lookups

Conversation

@dmccoystephenson

Copy link
Copy Markdown
Member

Summary

  • Two characterization tests are added to src/tests.cpp and registered in main() (Stage B, unit-test expansion on Grid):
    • Test 88: when locations share an id or coordinates, Grid::getLocation, Grid::getLocationByCoordinates, and Grid::addEntityToLocation use the first match in getLocations() order, while Grid::removeLocation removes every location with the id (and detaches the entity placed there).
    • Test 89: Grid::addLocation on a location that already holds entities copies the Entity* pointers, so the grid counts the entity and reports it present, but no grid id is set; afterwards the original's and the copy's vectors are independent.
  • The "Ownership and Lifetime" section of README.md gains two short paragraphs describing the same behaviour. No production code is changed.

No tracking issue: the open-issue backlog was empty at triage, so this gap was found during a coverage sweep comparing the public methods of Grid against the existing tests.

Test plan

  • make compiles the suite locally with the two new tests.
  • CI job Library tests (make + CMake) runs run_tests.sh and run_tests_asan.sh green (local execution of the test binary is blocked in this sandbox, 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

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

Copy link
Copy Markdown
Member Author

Self-review rubric (anchored on CI run 43819531064)

  • Scope: PASS — only src/tests.cpp (two tests plus two main() registrations) and README.md (two paragraphs in Ownership and Lifetime) are touched; no production code changed.
  • Tests-new: PASS — no new public methods; the two tests characterize existing Grid::getLocation, getLocationByCoordinates, addEntityToLocation, removeLocation, and addLocation behaviour.
  • Tests-fix: N/A — no bug fix; characterization only.
  • Sibling structure: PASS — both tests follow the Test N - ... / --- Success pattern and continue numbering from Test 87.
  • Sibling renames: N/A — nothing renamed.
  • Docs: PASS — the README paragraphs state exactly what the asserts pin (first match for lookups and placement, every match for removal; copied pointers, no grid id set, independent vectors). The Classes table is unchanged and still accurate.
  • Issue resolution: N/A — no tracking issue, as the backlog was empty at triage; stated in the PR body.
  • Local test suite: PASS (via CI) — local execution of the test binary is blocked in this sandbox, but the Library tests job log shows Test 88 and Test 89 printing Success in both the make step and the AddressSanitizer step, with Test 89 as the final registered test. Strata and Web build jobs are also green.
  • Header/definition parity: N/A — no header changes.
  • Include guards: N/A — no new headers.
  • Test registration: PASS — both functions are called at the end of main().

Judgment note: src/tests.cpp Test 89 — the grid outlives nothing it dereferences (entity is declared after grid, so it is destroyed first, and no destructor reads the stored pointer); the ASan step confirms no use-after-scope. Do-not-auto-merge paths: none matched (no Makefile, workflow, or large deletion).

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 05eb744 into master Nov 16, 2026
3 checks passed
@dmccoystephenson
dmccoystephenson deleted the feature/pin-duplicate-location-lookups branch November 16, 2026 06:53
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