Skip to content

tests(algorithms): ensure cross-policy consistency and add missing edge cases#7175

Open
aneek22112007-tech wants to merge 5 commits intoTheHPXProject:masterfrom
aneek22112007-tech:test/cross-policy-consistency-search-algorithms
Open

tests(algorithms): ensure cross-policy consistency and add missing edge cases#7175
aneek22112007-tech wants to merge 5 commits intoTheHPXProject:masterfrom
aneek22112007-tech:test/cross-policy-consistency-search-algorithms

Conversation

@aneek22112007-tech
Copy link
Copy Markdown
Contributor

While working on the recent find_first_of early-termination fix, I noticed that our test suite doesn't explicitly verify that seq, par, and par_unseq return identical results for the exact same inputs. It also missed a few basic boundary conditions (like the "not found" path for parallel execution).

This PR adds some straightforward regression tests to make sure the standard execution policies never diverge from the sequential behavior. No API or implementation logic was changed.

Changes:

  • find & find_if: Added a cross-policy helper that checks 7 deterministic scenarios (empty range, single element, partition boundaries, complete miss, and multiple matches). Also removed a leftover std::cout debug print in findif_tests.hpp.
  • find_first_of: Added standard-compliance checks for empty needle ranges. Added a cross-policy test that acts as a direct regression guard for the recent inner-loop short-circuiting bug.
  • mismatch: The empty-range test was previously only running under the HPX_HAVE_STDEXEC sender path. Extended this to run for seq, par, and par_unseq.
  • reduce_by_key: Added basic boundary tests for empty inputs, all-identical keys (single group), and all-unique keys.

These additions should give us a bit more confidence when tweaking or optimizing the parallel algorithm implementations in the future.

@StellarBot
Copy link
Copy Markdown

Can one of the admins verify this patch?

@codacy-production
Copy link
Copy Markdown

codacy-production bot commented Apr 12, 2026

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

TIP This summary will be updated as you push new changes. Give us feedback

@hkaiser
Copy link
Copy Markdown
Contributor

hkaiser commented Apr 12, 2026

@aneek22112007-tech Please have a look at the inspect issues reported.

@aneek22112007-tech aneek22112007-tech force-pushed the test/cross-policy-consistency-search-algorithms branch from e1239e0 to d27bc0d Compare April 12, 2026 23:20
@aneek22112007-tech
Copy link
Copy Markdown
Contributor Author

@aneek22112007-tech Please have a look at the inspect issues reported.

@hkaiser Thanks for catching that! The inspect issue was caused by some non-ASCII em-dashes (—) in my code comments. I've stripped them out and forced an update to the branch. The inspect checks should be green now!

@aneek22112007-tech aneek22112007-tech force-pushed the test/cross-policy-consistency-search-algorithms branch from d27bc0d to 8c687ea Compare April 12, 2026 23:44
…ion tests

- hpx::find: add test_find_cross_policy covering 7 deterministic datasets
  (empty range, single element match/no-match, boundary-0, boundary-N,
  no match anywhere, multiple matches) across seq/par/par_unseq

- hpx::find_if: add test_find_if_cross_policy with identical 7-dataset harness;
  remove stale debug std::cout left in test_find_if_async

- hpx::find_first_of: add test_find_first_of_empty_needle verifying the C++
  standard mandate that an empty needle range returns first (exercised per
  policy); add test_find_first_of_cross_policy as a direct regression guard
  for the historical inner-loop non-short-circuit bug

- hpx::mismatch: add test_mismatch_cross_policy extending empty-range coverage
  from the HPX_HAVE_STDEXEC-only sender path to seq/par/par_unseq

- hpx::experimental::reduce_by_key: add three boundary condition tests:
  empty input, single key group (all keys identical), all-unique keys

No API or implementation changes. Pure test additions.
@aneek22112007-tech aneek22112007-tech force-pushed the test/cross-policy-consistency-search-algorithms branch 2 times, most recently from 6aeebc8 to 191eb2a Compare April 13, 2026 12:16
@hkaiser
Copy link
Copy Markdown
Contributor

hkaiser commented Apr 13, 2026

@aneek22112007-tech inspect is still not happy:

/libs/core/algorithms/tests/unit/algorithms/findfirstof.cpp: *I* missing #include (type_traits) for symbol std::is_same_v on line 89

@aneek22112007-tech aneek22112007-tech force-pushed the test/cross-policy-consistency-search-algorithms branch from 191eb2a to 5fdcbcd Compare April 13, 2026 13:10
@aneek22112007-tech aneek22112007-tech force-pushed the test/cross-policy-consistency-search-algorithms branch from 5fdcbcd to 66175f1 Compare April 13, 2026 13:40
@aneek22112007-tech
Copy link
Copy Markdown
Contributor Author

@aneek22112007-tech inspect is still not happy:

/libs/core/algorithms/tests/unit/algorithms/findfirstof.cpp: *I* missing #include (type_traits) for symbol std::is_same_v on line 89

@hkaiser Good catch! I missed the <type_traits> header for std::is_same_v when I pulled out the edge case tests earlier. I've just added the include and forced an update. Hopefully, inspect is happy this time!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants