diff options
author | Marshall Clow <mclow.lists@gmail.com> | 2019-08-20 21:31:51 +0000 |
---|---|---|
committer | Marshall Clow <mclow.lists@gmail.com> | 2019-08-20 21:31:51 +0000 |
commit | 7fa6865392692e1446376e52f9c2b264d58b2294 (patch) | |
tree | 0b00bcc90d9aec9925ad09d271d8c069adfeab88 /libcxx/test/std/algorithms | |
parent | d5035727ad2cd8a3ab501250c78a68e8cb52dd5c (diff) | |
download | bcm5719-llvm-7fa6865392692e1446376e52f9c2b264d58b2294.tar.gz bcm5719-llvm-7fa6865392692e1446376e52f9c2b264d58b2294.zip |
Fix a couple of unguarded operator, calls in algorithm. Fixes PR#43063. Updated all the heap tests to check this.
llvm-svn: 369448
Diffstat (limited to 'libcxx/test/std/algorithms')
12 files changed, 93 insertions, 0 deletions
diff --git a/libcxx/test/std/algorithms/alg.sorting/alg.heap.operations/is.heap/is_heap.pass.cpp b/libcxx/test/std/algorithms/alg.sorting/alg.heap.operations/is.heap/is_heap.pass.cpp index 14b1d1754f2..8ccff2ebb53 100644 --- a/libcxx/test/std/algorithms/alg.sorting/alg.heap.operations/is.heap/is_heap.pass.cpp +++ b/libcxx/test/std/algorithms/alg.sorting/alg.heap.operations/is.heap/is_heap.pass.cpp @@ -17,6 +17,7 @@ #include <cassert> #include "test_macros.h" +#include "test_iterators.h" #if TEST_STD_VER > 17 TEST_CONSTEXPR bool test_constexpr() { @@ -29,9 +30,13 @@ TEST_CONSTEXPR bool test_constexpr() { void test() { + typedef random_access_iterator<int *> RI; int i1[] = {0, 0}; assert(std::is_heap(i1, i1)); assert(std::is_heap(i1, i1+1) == (std::is_heap_until(i1, i1+1) == i1+1)); + assert(std::is_heap(RI(i1), RI(i1))); + assert(std::is_heap(RI(i1), RI(i1+1)) == (std::is_heap_until(RI(i1), RI(i1+1)) == RI(i1+1))); + int i2[] = {0, 1}; int i3[] = {1, 0}; assert(std::is_heap(i1, i1+2) == (std::is_heap_until(i1, i1+2) == i1+2)); diff --git a/libcxx/test/std/algorithms/alg.sorting/alg.heap.operations/is.heap/is_heap_comp.pass.cpp b/libcxx/test/std/algorithms/alg.sorting/alg.heap.operations/is.heap/is_heap_comp.pass.cpp index 9e344588239..b07a3c8f24f 100644 --- a/libcxx/test/std/algorithms/alg.sorting/alg.heap.operations/is.heap/is_heap_comp.pass.cpp +++ b/libcxx/test/std/algorithms/alg.sorting/alg.heap.operations/is.heap/is_heap_comp.pass.cpp @@ -18,6 +18,7 @@ #include <cassert> #include "test_macros.h" +#include "test_iterators.h" #if TEST_STD_VER > 17 TEST_CONSTEXPR bool test_constexpr() { @@ -30,9 +31,13 @@ TEST_CONSTEXPR bool test_constexpr() { void test() { + typedef random_access_iterator<int *> RI; int i1[] = {0, 0}; assert(std::is_heap(i1, i1, std::greater<int>())); assert(std::is_heap(i1, i1+1, std::greater<int>()) == (std::is_heap_until(i1, i1+1, std::greater<int>()) == i1+1)); + assert(std::is_heap(RI(i1), RI(i1), std::greater<int>())); + assert(std::is_heap(RI(i1), RI(i1+1), std::greater<int>()) == (std::is_heap_until(RI(i1), RI(i1+1), std::greater<int>()) == RI(i1+1))); + int i2[] = {0, 1}; int i3[] = {1, 0}; assert(std::is_heap(i1, i1+2, std::greater<int>()) == (std::is_heap_until(i1, i1+2, std::greater<int>()) == i1+2)); diff --git a/libcxx/test/std/algorithms/alg.sorting/alg.heap.operations/is.heap/is_heap_until.pass.cpp b/libcxx/test/std/algorithms/alg.sorting/alg.heap.operations/is.heap/is_heap_until.pass.cpp index b9bb3e1f5bf..9708db7ce5f 100644 --- a/libcxx/test/std/algorithms/alg.sorting/alg.heap.operations/is.heap/is_heap_until.pass.cpp +++ b/libcxx/test/std/algorithms/alg.sorting/alg.heap.operations/is.heap/is_heap_until.pass.cpp @@ -17,6 +17,7 @@ #include <cassert> #include "test_macros.h" +#include "test_iterators.h" #if TEST_STD_VER > 17 TEST_CONSTEXPR bool test_constexpr() { @@ -29,9 +30,13 @@ TEST_CONSTEXPR bool test_constexpr() { void test() { + typedef random_access_iterator<int *> RI; int i1[] = {0, 0}; assert(std::is_heap_until(i1, i1) == i1); assert(std::is_heap_until(i1, i1+1) == i1+1); + assert(std::is_heap_until(RI(i1), RI(i1)) == RI(i1)); + assert(std::is_heap_until(RI(i1), RI(i1+1)) == RI(i1+1)); + int i2[] = {0, 1}; int i3[] = {1, 0}; assert(std::is_heap_until(i1, i1+2) == i1+2); diff --git a/libcxx/test/std/algorithms/alg.sorting/alg.heap.operations/is.heap/is_heap_until_comp.pass.cpp b/libcxx/test/std/algorithms/alg.sorting/alg.heap.operations/is.heap/is_heap_until_comp.pass.cpp index 6002f662e1a..1cec5440f00 100644 --- a/libcxx/test/std/algorithms/alg.sorting/alg.heap.operations/is.heap/is_heap_until_comp.pass.cpp +++ b/libcxx/test/std/algorithms/alg.sorting/alg.heap.operations/is.heap/is_heap_until_comp.pass.cpp @@ -18,6 +18,7 @@ #include <cassert> #include "test_macros.h" +#include "test_iterators.h" #if TEST_STD_VER > 17 TEST_CONSTEXPR bool test_constexpr() { @@ -30,9 +31,13 @@ TEST_CONSTEXPR bool test_constexpr() { void test() { + typedef random_access_iterator<int *> RI; int i1[] = {0, 0}; assert(std::is_heap_until(i1, i1, std::greater<int>()) == i1); assert(std::is_heap_until(i1, i1+1, std::greater<int>()) == i1+1); + assert(std::is_heap_until(RI(i1), RI(i1), std::greater<int>()) == RI(i1)); + assert(std::is_heap_until(RI(i1), RI(i1+1), std::greater<int>()) == RI(i1+1)); + int i2[] = {0, 1}; int i3[] = {1, 0}; assert(std::is_heap_until(i1, i1+2, std::greater<int>()) == i1+2); diff --git a/libcxx/test/std/algorithms/alg.sorting/alg.heap.operations/make.heap/make_heap.pass.cpp b/libcxx/test/std/algorithms/alg.sorting/alg.heap.operations/make.heap/make_heap.pass.cpp index 76244a9f0b3..80422998c47 100644 --- a/libcxx/test/std/algorithms/alg.sorting/alg.heap.operations/make.heap/make_heap.pass.cpp +++ b/libcxx/test/std/algorithms/alg.sorting/alg.heap.operations/make.heap/make_heap.pass.cpp @@ -18,6 +18,7 @@ #include <cassert> #include "test_macros.h" +#include "test_iterators.h" std::mt19937 randomness; @@ -29,6 +30,12 @@ void test(int N) std::shuffle(ia, ia+N, randomness); std::make_heap(ia, ia+N); assert(std::is_heap(ia, ia+N)); + + typedef random_access_iterator<int *> RI; + std::shuffle(RI(ia), RI(ia+N), randomness); + std::make_heap(RI(ia), RI(ia+N)); + assert(std::is_heap(RI(ia), RI(ia+N))); + delete [] ia; } diff --git a/libcxx/test/std/algorithms/alg.sorting/alg.heap.operations/make.heap/make_heap_comp.pass.cpp b/libcxx/test/std/algorithms/alg.sorting/alg.heap.operations/make.heap/make_heap_comp.pass.cpp index 0650f745479..23c501cd774 100644 --- a/libcxx/test/std/algorithms/alg.sorting/alg.heap.operations/make.heap/make_heap_comp.pass.cpp +++ b/libcxx/test/std/algorithms/alg.sorting/alg.heap.operations/make.heap/make_heap_comp.pass.cpp @@ -21,6 +21,7 @@ #include "test_macros.h" #include "counting_predicates.hpp" +#include "test_iterators.h" struct indirect_less { @@ -40,6 +41,11 @@ void test(int N) std::shuffle(ia, ia+N, randomness); std::make_heap(ia, ia+N, std::greater<int>()); assert(std::is_heap(ia, ia+N, std::greater<int>())); + + std::shuffle(ia, ia+N, randomness); + std::make_heap(random_access_iterator<int *>(ia), + random_access_iterator<int *>(ia+N), std::greater<int>()); + assert(std::is_heap(ia, ia+N, std::greater<int>())); } // Ascending diff --git a/libcxx/test/std/algorithms/alg.sorting/alg.heap.operations/pop.heap/pop_heap.pass.cpp b/libcxx/test/std/algorithms/alg.sorting/alg.heap.operations/pop.heap/pop_heap.pass.cpp index fa0e1120b30..1282232e477 100644 --- a/libcxx/test/std/algorithms/alg.sorting/alg.heap.operations/pop.heap/pop_heap.pass.cpp +++ b/libcxx/test/std/algorithms/alg.sorting/alg.heap.operations/pop.heap/pop_heap.pass.cpp @@ -18,6 +18,7 @@ #include <cassert> #include "test_macros.h" +#include "test_iterators.h" std::mt19937 randomness; @@ -34,6 +35,18 @@ void test(int N) assert(std::is_heap(ia, ia+i-1)); } std::pop_heap(ia, ia); + + + typedef random_access_iterator<int *> RI; + std::shuffle(RI(ia), RI(ia+N), randomness); + std::make_heap(RI(ia), RI(ia+N)); + for (int i = N; i > 0; --i) + { + std::pop_heap(RI(ia), RI(ia+i)); + assert(std::is_heap(RI(ia), RI(ia+i-1))); + } + std::pop_heap(RI(ia), RI(ia)); + delete [] ia; } diff --git a/libcxx/test/std/algorithms/alg.sorting/alg.heap.operations/pop.heap/pop_heap_comp.pass.cpp b/libcxx/test/std/algorithms/alg.sorting/alg.heap.operations/pop.heap/pop_heap_comp.pass.cpp index 63bd1520f46..dc4658ff0c1 100644 --- a/libcxx/test/std/algorithms/alg.sorting/alg.heap.operations/pop.heap/pop_heap_comp.pass.cpp +++ b/libcxx/test/std/algorithms/alg.sorting/alg.heap.operations/pop.heap/pop_heap_comp.pass.cpp @@ -20,6 +20,7 @@ #include <memory> #include "test_macros.h" +#include "test_iterators.h" struct indirect_less { @@ -44,6 +45,17 @@ void test(int N) assert(std::is_heap(ia, ia+i-1, std::greater<int>())); } std::pop_heap(ia, ia, std::greater<int>()); + + typedef random_access_iterator<int *> RI; + std::shuffle(RI(ia), RI(ia+N), randomness); + std::make_heap(RI(ia), RI(ia+N), std::greater<int>()); + for (int i = N; i > 0; --i) + { + std::pop_heap(RI(ia), RI(ia+i), std::greater<int>()); + assert(std::is_heap(RI(ia), RI(ia+i-1), std::greater<int>())); + } + std::pop_heap(RI(ia), RI(ia), std::greater<int>()); + delete [] ia; } diff --git a/libcxx/test/std/algorithms/alg.sorting/alg.heap.operations/push.heap/push_heap.pass.cpp b/libcxx/test/std/algorithms/alg.sorting/alg.heap.operations/push.heap/push_heap.pass.cpp index 208bf6e80f5..52f279bac6e 100644 --- a/libcxx/test/std/algorithms/alg.sorting/alg.heap.operations/push.heap/push_heap.pass.cpp +++ b/libcxx/test/std/algorithms/alg.sorting/alg.heap.operations/push.heap/push_heap.pass.cpp @@ -19,6 +19,7 @@ #include <cassert> #include "test_macros.h" +#include "test_iterators.h" std::mt19937 randomness; @@ -33,6 +34,15 @@ void test(int N) std::push_heap(ia, ia+i); assert(std::is_heap(ia, ia+i)); } + + typedef random_access_iterator<int *> RI; + std::shuffle(RI(ia), RI(ia+N), randomness); + for (int i = 0; i <= N; ++i) + { + std::push_heap(RI(ia), RI(ia+i)); + assert(std::is_heap(RI(ia), RI(ia+i))); + } + delete [] ia; } diff --git a/libcxx/test/std/algorithms/alg.sorting/alg.heap.operations/push.heap/push_heap_comp.pass.cpp b/libcxx/test/std/algorithms/alg.sorting/alg.heap.operations/push.heap/push_heap_comp.pass.cpp index 4a47f65bfc3..3681d87c5b5 100644 --- a/libcxx/test/std/algorithms/alg.sorting/alg.heap.operations/push.heap/push_heap_comp.pass.cpp +++ b/libcxx/test/std/algorithms/alg.sorting/alg.heap.operations/push.heap/push_heap_comp.pass.cpp @@ -21,6 +21,7 @@ #include <memory> #include "test_macros.h" +#include "test_iterators.h" struct indirect_less { @@ -42,6 +43,15 @@ void test(int N) std::push_heap(ia, ia+i, std::greater<int>()); assert(std::is_heap(ia, ia+i, std::greater<int>())); } + + typedef random_access_iterator<int *> RI; + std::shuffle(RI(ia), RI(ia+N), randomness); + for (int i = 0; i <= N; ++i) + { + std::push_heap(RI(ia), RI(ia+i), std::greater<int>()); + assert(std::is_heap(RI(ia), RI(ia+i), std::greater<int>())); + } + delete [] ia; } diff --git a/libcxx/test/std/algorithms/alg.sorting/alg.heap.operations/sort.heap/sort_heap.pass.cpp b/libcxx/test/std/algorithms/alg.sorting/alg.heap.operations/sort.heap/sort_heap.pass.cpp index 7d48b87aea5..30ef3456065 100644 --- a/libcxx/test/std/algorithms/alg.sorting/alg.heap.operations/sort.heap/sort_heap.pass.cpp +++ b/libcxx/test/std/algorithms/alg.sorting/alg.heap.operations/sort.heap/sort_heap.pass.cpp @@ -18,6 +18,7 @@ #include <cassert> #include "test_macros.h" +#include "test_iterators.h" std::mt19937 randomness; @@ -30,6 +31,13 @@ void test(int N) std::make_heap(ia, ia+N); std::sort_heap(ia, ia+N); assert(std::is_sorted(ia, ia+N)); + + typedef random_access_iterator<int *> RI; + std::shuffle(RI(ia), RI(ia+N), randomness); + std::make_heap(RI(ia), RI(ia+N)); + std::sort_heap(RI(ia), RI(ia+N)); + assert(std::is_sorted(RI(ia), RI(ia+N))); + delete [] ia; } diff --git a/libcxx/test/std/algorithms/alg.sorting/alg.heap.operations/sort.heap/sort_heap_comp.pass.cpp b/libcxx/test/std/algorithms/alg.sorting/alg.heap.operations/sort.heap/sort_heap_comp.pass.cpp index 151373b7181..df791f2de4a 100644 --- a/libcxx/test/std/algorithms/alg.sorting/alg.heap.operations/sort.heap/sort_heap_comp.pass.cpp +++ b/libcxx/test/std/algorithms/alg.sorting/alg.heap.operations/sort.heap/sort_heap_comp.pass.cpp @@ -20,6 +20,7 @@ #include <memory> #include "test_macros.h" +#include "test_iterators.h" struct indirect_less { @@ -39,6 +40,12 @@ void test(int N) std::make_heap(ia, ia+N, std::greater<int>()); std::sort_heap(ia, ia+N, std::greater<int>()); assert(std::is_sorted(ia, ia+N, std::greater<int>())); + + typedef random_access_iterator<int *> RI; + std::shuffle(RI(ia), RI(ia+N), randomness); + std::make_heap(RI(ia), RI(ia+N), std::greater<int>()); + std::sort_heap(RI(ia), RI(ia+N), std::greater<int>()); + assert(std::is_sorted(RI(ia), RI(ia+N), std::greater<int>())); delete [] ia; } |