Skip to content

Add test helper functions to reduce Test::new() boilerplate#50

Merged
ptrsauer merged 2 commits intomainfrom
feat/test-helpers
Feb 15, 2026
Merged

Add test helper functions to reduce Test::new() boilerplate#50
ptrsauer merged 2 commits intomainfrom
feat/test-helpers

Conversation

@ptrsauer
Copy link
Owner

Summary

  • New test/helpers.rs module with 4 helper functions: default_test(), case_insensitive_test(), no_backspace_test(), look_ahead_test()
  • Replaced 36 of 37 test Test::new() call sites with self-documenting helpers
  • #[cfg(test)] gated — zero impact on production binary

Design Decisions

  • Separate file (test/helpers.rs): Follows existing pattern of test/mod.rs + test/results.rs
  • 4 variants: Covers all common parameter combinations (default 27, case_insensitive 4, no_backspace 4, look_ahead 2)
  • No production changes: main.rs call sites intentionally left unchanged (minimal blast radius)
  • 1 remaining Test::new(): The single no_backtrack test stays as direct call (not worth a dedicated helper)

Test plan

  • 4 new tests in test/helpers.rs (verify each helper's settings)
  • All 114 tests pass (105 unit + 9 integration)
  • No new warnings (helpers are #[cfg(test)] gated)

Closes #49

🤖 Generated with Claude Code

ptrsauer and others added 2 commits February 15, 2026 22:21
Replace 36 of 37 test call sites with self-documenting helper functions:
- default_test(): standard config (27 call sites)
- case_insensitive_test(): case-insensitive mode (4 call sites)
- no_backspace_test(): backspace disabled (4 call sites)
- look_ahead_test(): look-ahead limiting (2 call sites)

Helpers are #[cfg(test)] gated and live in test/helpers.rs.
One no_backtrack call site remains as Test::new() (single occurrence).

Closes #49

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Add 5th helper no_backtrack_test() for backtracking-disabled tests
- Replace last remaining Test::new() call site in mod.rs
- Improve doc-comments with [`default_test`] cross-references
- Clarify look_ahead_test docs (uses Some(n) internally)
- Add test for no_backtrack_test helper settings

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@ptrsauer ptrsauer merged commit 56d73ed into main Feb 15, 2026
4 of 6 checks passed
@ptrsauer ptrsauer deleted the feat/test-helpers branch February 15, 2026 21:27
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.

Add test helper functions to reduce Test::new() boilerplate

1 participant