Trim test names so CATCH2 does not ignore them#1057
Conversation
Signed-off-by: Elazar Gershuni <elazarg@gmail.com>
Signed-off-by: Elazar Gershuni <elazarg@gmail.com>
WalkthroughThis PR includes formatting consolidations in IR handling code and introduces a compile-time test name bounding mechanism with a new Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
📝 Coding Plan
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment Tip You can customize the high-level summary generated by CodeRabbit.Configure the |
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/test/test_verify.hpp`:
- Around line 113-149: Add deterministic unit tests for BoundedTestName that
validate its invariants: (1) passthrough behavior for short names (construct
constexpr BoundedTestName with a name length <= BoundedTestName::MAX_LEN and
assert data contains the full input and is null-terminated); (2) truncation
behavior for long names (construct with length > MAX_LEN and assert resulting
data length is exactly MAX_LEN, contains the prefix of length MAX_LEN-6 followed
by the literal ".." and a 4-hex-digit suffix); and (3) suffix
determinism/variance (construct two different long inputs that differ only
beyond the prefix and assert their 4-hex suffixes differ, and construct the same
long input twice and assert the suffixes are identical). Use the BoundedTestName
constructor and its data member in constexpr contexts where possible and add
focused test cases that fail deterministically when any invariant is violated.
- Around line 134-146: The truncation currently appends a 4-hex suffix (16 bits)
using prefix_len = MAX_LEN - 6 and four assignments from hash; increase the
suffix to 8 hex digits (32 bits) to improve collision resistance by making the
suffix two dots plus eight hex chars (i.e., suffix length 10) so set prefix_len
= MAX_LEN - 10, then write eight hex characters into data[prefix_len + 2]
through data[prefix_len + 9] using the hex[] lookup with appropriate bit-shifts
(e.g., shifts for 28,24,20,16,12,8,4,0) against the hash variable, and keep the
null terminator at data[MAX_LEN]; update any related comments and ensure hash is
wide enough (32-bit) where needed.
- Line 129: Add a direct include of the fixed-width integer header so the use of
uint32_t in test_verify.hpp is not relying on transitive includes: insert
`#include` <cstdint> near the other includes at the top of
src/test/test_verify.hpp so the declaration "uint32_t hash = 2166136261u;" is
valid and portable.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: dd4a628c-f099-4ea0-a0a5-acd2fd64d240
📒 Files selected for processing (4)
scripts/format-codesrc/ir/assertions.cppsrc/ir/unmarshal.cppsrc/test/test_verify.hpp
Summary by CodeRabbit
Style
Tests
Chores