Skip to content

test: TransTableL op-stats unit tests (#379 item 3) - #403

Merged
wopdevries merged 1 commit into
developfrom
wopdevries-transtablel-op-stats-tests
Sep 27, 2026
Merged

wopdevries merged 1 commit into
developfrom
wopdevries-transtablel-op-stats-tests

Conversation

@wopdevries

Copy link
Copy Markdown
Collaborator

Adds unit test coverage for TransTableL's op-stats counters (num_adds_, num_overwrites_, num_harvests_), instrumented in #365 but never directly tested — item 3 from #379.

Tests added (library/tests/trans_table/trans_table_l_op_stats_test.cpp):

InsertIncrementsAddsOnly — a single new entry increments adds only.
FullBlockReplacementIncrementsOverwrites — filling a block to BlocksPerEntry (125) capacity and adding one more distinct entry increments both adds and overwrites.
ResetOpStatsClearsCounters — reset_op_stats() zeroes all three counters after activity.

Implementation note: the public API has no way to fill a WinBlock to capacity, so the full-block test seeds WinBlock/WinMatch state directly via a friend class TransTableLOpStatsTest; declaration added to trans_table_l.hpp, rather than reverse-engineering add()'s internal win-rank/aggregation encoding to manufacture 125 organic collisions. Seeded entries use mask_index_ = 0 / top_set1_..4_ = 0, a combination the real encoding never produces once any suit has a nonzero win rank — so the real add() call in the test is guaranteed to take the "not found → new insert" path rather than accidentally matching a seeded entry.

Verification: compiled and ran against the real sources outside Bazel first, then confirmed each test actually catches its corresponding regression by deliberately disabling num_adds_++/num_overwrites_++ and separately reset_op_stats()'s body — each break fails exactly the test(s) it should and no others. Also compiled alongside the other three files sharing this Bazel target (trans_table_base_test.cpp, trans_table_s_test.cpp, trans_table_p_test.cpp) to rule out link-time collisions. bazelisk test //library/tests/trans_table:trans_table passes on the real toolchain.

Refs #379 (item 3 of 4 — items 1/2 covered by #397/#402; item 4, the analyse_later_board reset/report scoping question, is a separate design discussion still in progress).

@zzcgumn zzcgumn left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@wopdevries
wopdevries merged commit 15cce07 into develop Sep 27, 2026
12 checks passed
@wopdevries
wopdevries deleted the wopdevries-transtablel-op-stats-tests branch September 27, 2026 15:25
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.

2 participants