summaryrefslogtreecommitdiffstats
path: root/libcxx/test/std/algorithms
diff options
context:
space:
mode:
Diffstat (limited to 'libcxx/test/std/algorithms')
-rw-r--r--libcxx/test/std/algorithms/alg.modifying.operations/alg.partitions/is_partitioned.pass.cpp19
-rw-r--r--libcxx/test/std/algorithms/alg.nonmodifying/alg.is_permutation/is_permutation.pass.cpp21
-rw-r--r--libcxx/test/std/algorithms/alg.nonmodifying/alg.is_permutation/is_permutation_pred.pass.cpp21
-rw-r--r--libcxx/test/std/algorithms/alg.sorting/alg.heap.operations/is.heap/is_heap.pass.cpp17
-rw-r--r--libcxx/test/std/algorithms/alg.sorting/alg.heap.operations/is.heap/is_heap_comp.pass.cpp17
-rw-r--r--libcxx/test/std/algorithms/alg.sorting/alg.heap.operations/is.heap/is_heap_until.pass.cpp17
-rw-r--r--libcxx/test/std/algorithms/alg.sorting/alg.heap.operations/is.heap/is_heap_until_comp.pass.cpp17
-rw-r--r--libcxx/test/std/algorithms/alg.sorting/alg.sort/is.sorted/is_sorted.pass.cpp13
-rw-r--r--libcxx/test/std/algorithms/alg.sorting/alg.sort/is.sorted/is_sorted_comp.pass.cpp13
-rw-r--r--libcxx/test/std/algorithms/alg.sorting/alg.sort/is.sorted/is_sorted_until.pass.cpp13
-rw-r--r--libcxx/test/std/algorithms/alg.sorting/alg.sort/is.sorted/is_sorted_until_comp.pass.cpp13
11 files changed, 173 insertions, 8 deletions
diff --git a/libcxx/test/std/algorithms/alg.modifying.operations/alg.partitions/is_partitioned.pass.cpp b/libcxx/test/std/algorithms/alg.modifying.operations/alg.partitions/is_partitioned.pass.cpp
index 8597b08da8c..eb9be71c2b5 100644
--- a/libcxx/test/std/algorithms/alg.modifying.operations/alg.partitions/is_partitioned.pass.cpp
+++ b/libcxx/test/std/algorithms/alg.modifying.operations/alg.partitions/is_partitioned.pass.cpp
@@ -10,7 +10,7 @@
// <algorithm>
// template <class InputIterator, class Predicate>
-// bool
+// constpexr bool // constexpr after C++17
// is_partitioned(InputIterator first, InputIterator last, Predicate pred);
#include <algorithm>
@@ -18,13 +18,24 @@
#include <cstddef>
#include <cassert>
+#include "test_macros.h"
#include "test_iterators.h"
#include "counting_predicates.hpp"
struct is_odd {
- bool operator()(const int &i) const { return i & 1; }
+ TEST_CONSTEXPR bool operator()(const int &i) const { return i & 1; }
};
+#if TEST_STD_VER > 17
+TEST_CONSTEXPR int test_constexpr() {
+ int ia[] = {1, 3, 5, 2, 4, 6};
+ int ib[] = {1, 2, 3, 4, 5, 6};
+ return std::is_partitioned(std::begin(ia), std::end(ia), is_odd())
+ && !std::is_partitioned(std::begin(ib), std::end(ib), is_odd());
+ }
+#endif
+
+
int main() {
{
const int ia[] = {1, 2, 3, 4, 5, 6};
@@ -80,4 +91,8 @@ int main() {
assert(static_cast<std::ptrdiff_t>(pred.count()) <=
std::distance(std::begin(ia), std::end(ia)));
}
+
+#if TEST_STD_VER > 17
+ static_assert(test_constexpr());
+#endif
}
diff --git a/libcxx/test/std/algorithms/alg.nonmodifying/alg.is_permutation/is_permutation.pass.cpp b/libcxx/test/std/algorithms/alg.nonmodifying/alg.is_permutation/is_permutation.pass.cpp
index e3f7c3cd87d..cde76d5ca06 100644
--- a/libcxx/test/std/algorithms/alg.nonmodifying/alg.is_permutation/is_permutation.pass.cpp
+++ b/libcxx/test/std/algorithms/alg.nonmodifying/alg.is_permutation/is_permutation.pass.cpp
@@ -10,7 +10,7 @@
// <algorithm>
// template<class ForwardIterator1, class ForwardIterator2>
-// bool
+// constexpr bool // constexpr after C++17
// is_permutation(ForwardIterator1 first1, ForwardIterator1 last1,
// ForwardIterator2 first2);
@@ -21,6 +21,21 @@
#include "test_macros.h"
+#if TEST_STD_VER > 17
+TEST_CONSTEXPR int test_constexpr() {
+ int ia[] = {0, 0, 0};
+ int ib[] = {1, 1, 0};
+ int ic[] = {1, 0, 1};
+ int id[] = {1};
+ return !std::is_permutation(std::begin(ia), std::end(ia), std::begin(ib))
+ && !std::is_permutation(std::begin(ia), std::end(ia), std::begin(ib), std::end(ib))
+ && std::is_permutation(std::begin(ib), std::end(ib), std::begin(ic))
+ && std::is_permutation(std::begin(ib), std::end(ib), std::begin(ic), std::end(ic))
+ && !std::is_permutation(std::begin(ic), std::end(ic), std::begin(id), std::end(id))
+ ;
+ }
+#endif
+
int main()
{
{
@@ -600,4 +615,8 @@ int main()
forward_iterator<const int*>(ib + sa)) == false);
#endif
}
+
+#if TEST_STD_VER > 17
+ static_assert(test_constexpr());
+#endif
}
diff --git a/libcxx/test/std/algorithms/alg.nonmodifying/alg.is_permutation/is_permutation_pred.pass.cpp b/libcxx/test/std/algorithms/alg.nonmodifying/alg.is_permutation/is_permutation_pred.pass.cpp
index 6e9cdaabd30..13129289629 100644
--- a/libcxx/test/std/algorithms/alg.nonmodifying/alg.is_permutation/is_permutation_pred.pass.cpp
+++ b/libcxx/test/std/algorithms/alg.nonmodifying/alg.is_permutation/is_permutation_pred.pass.cpp
@@ -10,7 +10,7 @@
// <algorithm>
// template<class ForwardIterator1, class ForwardIterator2, class BinaryPredicate>
-// bool
+// constexpr bool // constexpr after C++17
// is_permutation(ForwardIterator1 first1, ForwardIterator1 last1,
// ForwardIterator2 first2, BinaryPredicate pred);
@@ -28,6 +28,21 @@ bool counting_equals ( const T &a, const T &b ) {
return a == b;
}
+#if TEST_STD_VER > 17
+TEST_CONSTEXPR int test_constexpr() {
+ int ia[] = {0, 0, 0};
+ int ib[] = {1, 1, 0};
+ int ic[] = {1, 0, 1};
+ int id[] = {1};
+ std::equal_to<int> c;
+ return !std::is_permutation(std::begin(ia), std::end(ia), std::begin(ib) , c)
+ && !std::is_permutation(std::begin(ia), std::end(ia), std::begin(ib), std::end(ib), c)
+ && std::is_permutation(std::begin(ib), std::end(ib), std::begin(ic) , c)
+ && std::is_permutation(std::begin(ib), std::end(ib), std::begin(ic), std::end(ic), c)
+ && !std::is_permutation(std::begin(ic), std::end(ic), std::begin(id), std::end(id), c)
+ ;
+ }
+#endif
int main()
{
@@ -723,4 +738,8 @@ int main()
std::equal_to<const int>()) == false);
#endif
}
+
+#if TEST_STD_VER > 17
+ static_assert(test_constexpr());
+#endif
}
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 f16b2c3c61a..8df07dad1a5 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
@@ -11,12 +11,23 @@
// template<RandomAccessIterator Iter>
// requires LessThanComparable<Iter::value_type>
-// bool
+// constexpr bool // constexpr after C++17
// is_heap(Iter first, Iter last);
#include <algorithm>
#include <cassert>
+#include "test_macros.h"
+
+#if TEST_STD_VER > 17
+TEST_CONSTEXPR int test_constexpr() {
+ int ia[] = {1, 1, 1, 1, 0, 1, 1};
+ int ib[] = {0, 0, 1, 0, 0, 0, 0};
+ return std::is_heap(std::begin(ia), std::end(ia))
+ && !std::is_heap(std::begin(ib), std::end(ib));
+ }
+#endif
+
void test()
{
int i1[] = {0, 0};
@@ -518,4 +529,8 @@ void test()
int main()
{
test();
+
+#if TEST_STD_VER > 17
+ static_assert(test_constexpr());
+#endif
}
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 af55cc499ed..80b5cd36f20 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
@@ -11,13 +11,24 @@
// template<RandomAccessIterator Iter>
// requires LessThanComparable<Iter::value_type>
-// bool
+// constexpr bool // constexpr after C++17
// is_heap(Iter first, Iter last);
#include <algorithm>
#include <functional>
#include <cassert>
+#include "test_macros.h"
+
+#if TEST_STD_VER > 17
+TEST_CONSTEXPR int test_constexpr() {
+ int ia[] = {0, 0, 1, 1, 1};
+ int ib[] = {1, 0, 4, 1, 0};
+ return std::is_heap(std::begin(ia), std::end(ia), std::greater<int>())
+ && !std::is_heap(std::begin(ib), std::end(ib), std::greater<int>());
+ }
+#endif
+
void test()
{
int i1[] = {0, 0};
@@ -519,4 +530,8 @@ void test()
int main()
{
test();
+
+#if TEST_STD_VER > 17
+ static_assert(test_constexpr());
+#endif
}
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 082c0445182..5616401da79 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
@@ -11,12 +11,23 @@
// template<RandomAccessIterator Iter>
// requires LessThanComparable<Iter::value_type>
-// Iter
+// constexpr bool // constexpr after C++17
// is_heap_until(Iter first, Iter last);
#include <algorithm>
#include <cassert>
+#include "test_macros.h"
+
+#if TEST_STD_VER > 17
+TEST_CONSTEXPR int test_constexpr() {
+ int ia[] = {0, 0, 0, 0, 1, 0};
+ int ib[] = {0, 0, 0, 1, 1, 1};
+ return (std::is_heap_until(std::begin(ia), std::end(ia)) == ia+4)
+ && (std::is_heap_until(std::begin(ib), std::end(ib)) == ib+3);
+ }
+#endif
+
void test()
{
int i1[] = {0, 0};
@@ -518,4 +529,8 @@ void test()
int main()
{
test();
+
+#if TEST_STD_VER > 17
+ static_assert(test_constexpr());
+#endif
}
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 657c177fee5..dba4a0c7ffe 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
@@ -11,13 +11,24 @@
// template<RandomAccessIterator Iter, StrictWeakOrder<auto, Iter::value_type> Compare>
// requires CopyConstructible<Compare>
-// Iter
+// constexpr bool // constexpr after C++17
// is_heap_until(Iter first, Iter last, Compare comp);
#include <algorithm>
#include <functional>
#include <cassert>
+#include "test_macros.h"
+
+#if TEST_STD_VER > 17
+TEST_CONSTEXPR int test_constexpr() {
+ int ia[] = {1, 0, 0, 0};
+ int ib[] = {0, 1, 1, 0};
+ return (std::is_heap_until(std::begin(ia), std::end(ia), std::greater<int>()) == ia+1)
+ && (std::is_heap_until(std::begin(ib), std::end(ib), std::greater<int>()) == ib+3);
+ }
+#endif
+
void test()
{
int i1[] = {0, 0};
@@ -519,4 +530,8 @@ void test()
int main()
{
test();
+
+#if TEST_STD_VER > 17
+ static_assert(test_constexpr());
+#endif
}
diff --git a/libcxx/test/std/algorithms/alg.sorting/alg.sort/is.sorted/is_sorted.pass.cpp b/libcxx/test/std/algorithms/alg.sorting/alg.sort/is.sorted/is_sorted.pass.cpp
index dd6b5c1766a..e50aae8ef18 100644
--- a/libcxx/test/std/algorithms/alg.sorting/alg.sort/is.sorted/is_sorted.pass.cpp
+++ b/libcxx/test/std/algorithms/alg.sorting/alg.sort/is.sorted/is_sorted.pass.cpp
@@ -19,6 +19,15 @@
#include "test_iterators.h"
+#if TEST_STD_VER > 17
+TEST_CONSTEXPR int test_constexpr() {
+ int ia[] = {0, 0, 1, 1};
+ int ib[] = {1, 1, 0, 0};
+ return std::is_sorted(std::begin(ia), std::end(ia))
+ && !std::is_sorted(std::begin(ib), std::end(ib));
+ }
+#endif
+
template <class Iter>
void
test()
@@ -180,4 +189,8 @@ int main()
test<bidirectional_iterator<const int*> >();
test<random_access_iterator<const int*> >();
test<const int*>();
+
+#if TEST_STD_VER > 17
+ static_assert(test_constexpr());
+#endif
}
diff --git a/libcxx/test/std/algorithms/alg.sorting/alg.sort/is.sorted/is_sorted_comp.pass.cpp b/libcxx/test/std/algorithms/alg.sorting/alg.sort/is.sorted/is_sorted_comp.pass.cpp
index d5a34e2f2cb..a1562d7c1ed 100644
--- a/libcxx/test/std/algorithms/alg.sorting/alg.sort/is.sorted/is_sorted_comp.pass.cpp
+++ b/libcxx/test/std/algorithms/alg.sorting/alg.sort/is.sorted/is_sorted_comp.pass.cpp
@@ -20,6 +20,15 @@
#include "test_iterators.h"
+#if TEST_STD_VER > 17
+TEST_CONSTEXPR int test_constexpr() {
+ int ia[] = {1, 1, 0, 0};
+ int ib[] = {0, 0, 1, 1};
+ return std::is_sorted(std::begin(ia), std::end(ia), std::greater<int>())
+ && !std::is_sorted(std::begin(ib), std::end(ib), std::greater<int>());
+ }
+#endif
+
template <class Iter>
void
test()
@@ -181,4 +190,8 @@ int main()
test<bidirectional_iterator<const int*> >();
test<random_access_iterator<const int*> >();
test<const int*>();
+
+#if TEST_STD_VER > 17
+ static_assert(test_constexpr());
+#endif
}
diff --git a/libcxx/test/std/algorithms/alg.sorting/alg.sort/is.sorted/is_sorted_until.pass.cpp b/libcxx/test/std/algorithms/alg.sorting/alg.sort/is.sorted/is_sorted_until.pass.cpp
index bef01027472..5d30532c825 100644
--- a/libcxx/test/std/algorithms/alg.sorting/alg.sort/is.sorted/is_sorted_until.pass.cpp
+++ b/libcxx/test/std/algorithms/alg.sorting/alg.sort/is.sorted/is_sorted_until.pass.cpp
@@ -19,6 +19,15 @@
#include "test_iterators.h"
+#if TEST_STD_VER > 17
+TEST_CONSTEXPR int test_constexpr() {
+ int ia[] = {0, 1, 0};
+ int ib[] = {0, 1, 1};
+ return (std::is_sorted_until(std::begin(ia), std::end(ia)) == ia+2)
+ && (std::is_sorted_until(std::begin(ib), std::end(ib)) == ib+3);
+ }
+#endif
+
template <class Iter>
void
test()
@@ -180,4 +189,8 @@ int main()
test<bidirectional_iterator<const int*> >();
test<random_access_iterator<const int*> >();
test<const int*>();
+
+#if TEST_STD_VER > 17
+ static_assert(test_constexpr());
+#endif
}
diff --git a/libcxx/test/std/algorithms/alg.sorting/alg.sort/is.sorted/is_sorted_until_comp.pass.cpp b/libcxx/test/std/algorithms/alg.sorting/alg.sort/is.sorted/is_sorted_until_comp.pass.cpp
index 68ed29c6f4b..37b5e44da35 100644
--- a/libcxx/test/std/algorithms/alg.sorting/alg.sort/is.sorted/is_sorted_until_comp.pass.cpp
+++ b/libcxx/test/std/algorithms/alg.sorting/alg.sort/is.sorted/is_sorted_until_comp.pass.cpp
@@ -20,6 +20,15 @@
#include "test_iterators.h"
+#if TEST_STD_VER > 17
+TEST_CONSTEXPR int test_constexpr() {
+ int ia[] = {1, 0, 1};
+ int ib[] = {1, 1, 0};
+ return (std::is_sorted_until(std::begin(ia), std::end(ia), std::greater<int>()) == ia+2)
+ && (std::is_sorted_until(std::begin(ib), std::end(ib), std::greater<int>()) == ib+3);
+ }
+#endif
+
template <class Iter>
void
test()
@@ -181,4 +190,8 @@ int main()
test<bidirectional_iterator<const int*> >();
test<random_access_iterator<const int*> >();
test<const int*>();
+
+#if TEST_STD_VER > 17
+ static_assert(test_constexpr());
+#endif
}
OpenPOWER on IntegriCloud