forked from OSchip/llvm-project
[libc++][ranges][NFC] Make sure all implemented algorithms are enabled in "robust" tests.
Also fix `std::find_first_of` (which accidentally copied the predicate in the implementation). Differential Revision: https://reviews.llvm.org/D131235
This commit is contained in:
parent
bc062e034f
commit
8ac015caf6
|
@ -24,7 +24,8 @@ template <class _ForwardIterator1, class _ForwardIterator2, class _BinaryPredica
|
|||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _ForwardIterator1 __find_first_of_ce(_ForwardIterator1 __first1,
|
||||
_ForwardIterator1 __last1,
|
||||
_ForwardIterator2 __first2,
|
||||
_ForwardIterator2 __last2, _BinaryPredicate __pred) {
|
||||
_ForwardIterator2 __last2,
|
||||
_BinaryPredicate&& __pred) {
|
||||
for (; __first1 != __last1; ++__first1)
|
||||
for (_ForwardIterator2 __j = __first2; __j != __last2; ++__j)
|
||||
if (__pred(*__first1, *__j))
|
||||
|
|
|
@ -121,9 +121,9 @@ constexpr bool all_the_algorithms()
|
|||
(void)std::ranges::for_each(first, last, UnaryVoid(&copies)); assert(copies == 1); copies = 0;
|
||||
(void)std::ranges::for_each(a, UnaryVoid(&copies)); assert(copies == 1); copies = 0;
|
||||
(void)std::ranges::for_each_n(first, count, UnaryVoid(&copies)); assert(copies == 1); copies = 0;
|
||||
//(void)std::ranges::generate(first, last, NullaryValue(&copies)); assert(copies == 0);
|
||||
//(void)std::ranges::generate(a, NullaryValue(&copies)); assert(copies == 0);
|
||||
//(void)std::ranges::generate_n(first, count, NullaryValue(&copies)); assert(copies == 0);
|
||||
(void)std::ranges::generate(first, last, NullaryValue(&copies)); assert(copies == 0);
|
||||
(void)std::ranges::generate(a, NullaryValue(&copies)); assert(copies == 0);
|
||||
(void)std::ranges::generate_n(first, count, NullaryValue(&copies)); assert(copies == 0);
|
||||
(void)std::ranges::includes(first, last, first2, last2, Less(&copies)); assert(copies == 0);
|
||||
(void)std::ranges::includes(a, b, Less(&copies)); assert(copies == 0);
|
||||
(void)std::ranges::is_heap(first, last, Less(&copies)); assert(copies == 0);
|
||||
|
|
|
@ -120,7 +120,7 @@ TEST_CONSTEXPR_CXX20 bool all_the_algorithms()
|
|||
#endif
|
||||
(void)std::equal_range(first, last, value, Less<T>(&copies)); assert(copies == 0);
|
||||
(void)std::find_end(first, last, first2, mid2, Equal<T>(&copies)); assert(copies == 0);
|
||||
//(void)std::find_first_of(first, last, first2, last2, Equal(&copies)); assert(copies == 0);
|
||||
(void)std::find_first_of(first, last, first2, last2, Equal<T>(&copies)); assert(copies == 0);
|
||||
(void)std::find_if(first, last, UnaryTrue<T>(&copies)); assert(copies == 0);
|
||||
(void)std::find_if_not(first, last, UnaryTrue<T>(&copies)); assert(copies == 0);
|
||||
(void)std::for_each(first, last, UnaryVoid<T>(&copies)); assert(copies == 1); copies = 0;
|
||||
|
|
|
@ -36,8 +36,8 @@ static_assert(std::is_same_v<in_out_result<int, long>, remove_copy_result<int, l
|
|||
static_assert(std::is_same_v<in_out_result<int, long>, remove_copy_if_result<int, long>>);
|
||||
static_assert(std::is_same_v<in_out_result<int, long>, replace_copy_result<int, long>>);
|
||||
static_assert(std::is_same_v<in_out_result<int, long>, replace_copy_if_result<int, long>>);
|
||||
// static_assert(std::is_same_v<in_out_result<int, long>, reverse_copy_result<int, long>>);
|
||||
// static_assert(std::is_same_v<in_out_result<int, long>, rotate_copy_result<int, long>>);
|
||||
static_assert(std::is_same_v<in_out_result<int, long>, reverse_copy_result<int, long>>);
|
||||
static_assert(std::is_same_v<in_out_result<int, long>, rotate_copy_result<int, long>>);
|
||||
static_assert(std::is_same_v<in_out_result<int, long>, set_difference_result<int, long>>);
|
||||
static_assert(std::is_same_v<in_out_result<int, long>, unary_transform_result<int, long>>);
|
||||
static_assert(std::is_same_v<in_out_result<int, long>, uninitialized_copy_result<int, long>>);
|
||||
|
|
|
@ -76,8 +76,10 @@ constexpr bool test_all() {
|
|||
using std::ranges::mismatch_result;
|
||||
using std::ranges::move_result;
|
||||
using std::ranges::move_backward_result;
|
||||
using std::ranges::next_permutation_result;
|
||||
using std::ranges::partial_sort_copy_result;
|
||||
using std::ranges::partition_copy_result;
|
||||
using std::ranges::prev_permutation_result;
|
||||
using std::ranges::remove_copy_result;
|
||||
using std::ranges::remove_copy_if_result;
|
||||
using std::ranges::replace_copy_result;
|
||||
|
@ -199,8 +201,8 @@ constexpr bool test_all() {
|
|||
dangling_1st(std::ranges::push_heap, in);
|
||||
dangling_1st(std::ranges::pop_heap, in);
|
||||
dangling_1st(std::ranges::sort_heap, in);
|
||||
//dangling_1st(std::ranges::prev_permutation, in);
|
||||
//dangling_1st(std::ranges::next_permutation, in);
|
||||
dangling_1st<prev_permutation_result<dangling>>(std::ranges::prev_permutation, in);
|
||||
dangling_1st<next_permutation_result<dangling>>(std::ranges::next_permutation, in);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -69,7 +69,6 @@ constexpr void run_tests() {
|
|||
int count = 1;
|
||||
|
||||
auto unary_pred = [](const Proxy<T&>&) { return true; };
|
||||
//auto binary_pred = [](const Proxy<T>&, const Proxy<T>&) { return return false; };
|
||||
auto binary_func = [](const Proxy<T>&, const Proxy<T>&) -> Proxy<T> { return Proxy<T>(T()); };
|
||||
auto gen = [] { return Proxy<T>(T{42}); };
|
||||
|
||||
|
@ -87,7 +86,7 @@ constexpr void run_tests() {
|
|||
test(std::ranges::partition_point, in, unary_pred);
|
||||
test(std::ranges::lower_bound, in, x);
|
||||
test(std::ranges::upper_bound, in, x);
|
||||
//test(std::ranges::equal_range, in, x);
|
||||
test(std::ranges::equal_range, in, x);
|
||||
test(std::ranges::binary_search, in, x);
|
||||
|
||||
test(std::ranges::min_element, in);
|
||||
|
@ -169,8 +168,8 @@ constexpr void run_tests() {
|
|||
test(std::ranges::push_heap, in);
|
||||
test(std::ranges::pop_heap, in);
|
||||
test(std::ranges::sort_heap, in);
|
||||
//test(std::ranges::prev_permutation, in);
|
||||
//test(std::ranges::next_permutation, in);
|
||||
test(std::ranges::prev_permutation, in);
|
||||
test(std::ranges::next_permutation, in);
|
||||
|
||||
// The algorithms that work on uninitialized memory have constraints that prevent proxy iterators from being used with
|
||||
// them.
|
||||
|
|
|
@ -56,7 +56,6 @@ int a[10];
|
|||
auto odd = [](int x) { return x % 2 != 0; };
|
||||
auto triple = [](int x) { return 3*x; };
|
||||
auto gen = [] { return 42; };
|
||||
//auto plus = [](int x, int y) { return x == y; };
|
||||
std::mt19937 g;
|
||||
|
||||
// [algorithm.syn]
|
||||
|
@ -79,7 +78,7 @@ static_assert(test(std::ranges::fill, a, 42));
|
|||
static_assert(test(std::ranges::fill_n, a, 10, 42));
|
||||
static_assert(test(std::ranges::find, a, 42));
|
||||
static_assert(test(std::ranges::find_end, a, a));
|
||||
//static_assert(test(std::ranges::find_first_of, a, a));
|
||||
static_assert(test(std::ranges::find_first_of, a, a));
|
||||
static_assert(test(std::ranges::find_if, a, odd));
|
||||
static_assert(test(std::ranges::find_if_not, a, odd));
|
||||
static_assert(test(std::ranges::for_each, a, odd));
|
||||
|
@ -107,7 +106,7 @@ static_assert(test(std::ranges::minmax_element, a));
|
|||
static_assert(test(std::ranges::mismatch, a, a));
|
||||
static_assert(test(std::ranges::move, a, a));
|
||||
static_assert(test(std::ranges::move_backward, a, a));
|
||||
//static_assert(test(std::ranges::next_permutation, a));
|
||||
static_assert(test(std::ranges::next_permutation, a));
|
||||
static_assert(test(std::ranges::none_of, a, odd));
|
||||
static_assert(test(std::ranges::nth_element, a, a+5));
|
||||
static_assert(test(std::ranges::partial_sort, a, a+5));
|
||||
|
@ -116,7 +115,7 @@ static_assert(test(std::ranges::partition, a, odd));
|
|||
static_assert(test(std::ranges::partition_copy, a, a, a, odd));
|
||||
static_assert(test(std::ranges::partition_point, a, odd));
|
||||
static_assert(test(std::ranges::pop_heap, a));
|
||||
//static_assert(test(std::ranges::prev_permutation, a));
|
||||
static_assert(test(std::ranges::prev_permutation, a));
|
||||
static_assert(test(std::ranges::push_heap, a));
|
||||
static_assert(test(std::ranges::remove, a, 42));
|
||||
static_assert(test(std::ranges::remove_copy, a, a, 42));
|
||||
|
|
Loading…
Reference in New Issue