Skip to content

Keep UnorderedRangeEquals comparator argument order#3113

Open
puneetdixit200 wants to merge 2 commits into
catchorg:develfrom
puneetdixit200:fix-unordered-range-comparator-order
Open

Keep UnorderedRangeEquals comparator argument order#3113
puneetdixit200 wants to merge 2 commits into
catchorg:develfrom
puneetdixit200:fix-unordered-range-comparator-order

Conversation

@puneetdixit200

Copy link
Copy Markdown

Description

  • match unordered ranges with a matched-element bitmap instead of is_permutation counting
  • keep custom predicates called as (actual_element, expected_element) for every comparison
  • add a regression test for different actual/expected element types and refresh approval baselines

GitHub Issues

References #3043

Tests

  • cmake -B /tmp/catch2-basic-build -S . -DCMAKE_BUILD_TYPE=Debug --preset basic-tests
  • cmake --build /tmp/catch2-basic-build --target SelfTest -j 4
  • /tmp/catch2-basic-build/tests/SelfTest "Usage of UnorderedRangeEquals range matcher" --rng-seed 1
  • ctest --test-dir /tmp/catch2-basic-build -R "RunTests|ApprovalTests" --output-on-failure -j 2
  • ctest --test-dir /tmp/catch2-basic-build --output-on-failure -j 4
  • git diff --check

@codecov

codecov Bot commented May 22, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.32%. Comparing base (69e0473) to head (55fb808).

Additional details and impacted files
@@            Coverage Diff             @@
##            devel    #3113      +/-   ##
==========================================
+ Coverage   91.26%   91.32%   +0.05%     
==========================================
  Files         204      204              
  Lines        8905     8925      +20     
==========================================
+ Hits         8127     8150      +23     
+ Misses        778      775       -3     
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@rajpratham1 rajpratham1 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Nice fix. Preserving the comparator argument order for UnorderedRangeEquals makes the matcher behave consistently with user expectations, especially for heterogeneous element types where the parameter order is significant. The regression test clearly demonstrates the issue, and the replacement matching algorithm is straightforward and easy to follow. LGTM.

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