[tests] Add return-iterator compliance and edge-case regression tests for hpx::partial_sort#7196
Merged
hkaiser merged 3 commits intoTheHPXProject:masterfrom Apr 18, 2026
Conversation
|
Can one of the admins verify this patch? |
Up to standards ✅🟢 Issues
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The existing
partial_sort.cpptest suite verified only that the sorted prefix contained correct values, but never validated the return value ofhpx::partial_sortacross any execution policy. According to the C++ standard (and HPX documentation),partial_sortmust return an iterator pointing tolast-- this was completely untested.Additionally, the following boundary conditions had zero coverage:
first == last)middle == first(zero elements to sort)middle == last(degenerates to full sort)Changes## Summary
The existing
partial_sort.cpptest suite verified only that the sorted prefix contained correct values, but never validated the return value ofhpx::partial_sortacross any execution policy. According to the C++ standard (and HPX documentation),partial_sortmust return an iterator pointing tolast-- this was completely untested.Additionally, the following boundary conditions had zero coverage:
first == last)middle == first(zero elements to sort)middle == last(degenerates to full sort)Changes
libs/core/algorithms/tests/unit/algorithms/partial_sort.cpp(test-only change)result == B.end()assertions to all three existing test functions: sequential, parallel, and async variants.test_partial_sort_edge_cases()function covering all boundary conditions listed above across all policies (seq,par,par_unseq, and no-policy sequential).Testing
All new tests validate both return value correctness and content correctness (where applicable). The code is
clang-formatclean (verified locally with--dry-run --Werror).Why This Matters
Return-iterator compliance is a correctness guarantee of the C++ standard. Callers chaining operations on the returned iterator rely on it pointing to exactly
last. Without this regression test, a future refactor could silently break this contract.-libs/core/algorithms/tests/unit/algorithms/partial_sort.cpp(test-only change)result == B.end()assertions to all three existing test functions: sequential, parallel, and async variants.test_partial_sort_edge_cases()function covering all boundary conditions listed above across all policies (seq,par,par_unseq, and no-policy sequential).Testing
All new tests validate both return value correctness and content correctness (where applicable). The code is
clang-formatclean (verified locally with--dry-run --Werror).Why This Matters
Return-iterator compliance is a correctness guarantee of the C++ standard. Callers chaining operations on the returned iterator rely on it pointing to exactly
last. Without this regression test, a future refactor could silently break this contract.The existingpartial_sort.cpptest suite verified only that the sorted prefix contained correct values, but never validated the return value ofhpx::partial_sortacross any execution policy. According to the C++ standard (and HPX documentation),partial_sortmust return an iterator pointing tolastChecklist
Not all points below apply to all pull requests.