diff options
Diffstat (limited to 'libcxx/test/std/algorithms/alg.sorting')
6 files changed, 89 insertions, 0 deletions
diff --git a/libcxx/test/std/algorithms/alg.sorting/alg.min.max/max_element.pass.cpp b/libcxx/test/std/algorithms/alg.sorting/alg.min.max/max_element.pass.cpp index 2788b193200..2197b97d7f2 100644 --- a/libcxx/test/std/algorithms/alg.sorting/alg.min.max/max_element.pass.cpp +++ b/libcxx/test/std/algorithms/alg.sorting/alg.min.max/max_element.pass.cpp @@ -57,10 +57,24 @@ test() test<Iter>(1000); } +#if __cplusplus >= 201402L +constexpr int il[] = { 2, 4, 6, 8, 7, 5, 3, 1 }; +#endif + +void constexpr_test() +{ +#if __cplusplus >= 201402L + constexpr auto p = std::max_element(il,il+8); + static_assert ( *p == 8, "" ); +#endif +} + int main() { test<forward_iterator<const int*> >(); test<bidirectional_iterator<const int*> >(); test<random_access_iterator<const int*> >(); test<const int*>(); + + constexpr_test (); } diff --git a/libcxx/test/std/algorithms/alg.sorting/alg.min.max/max_element_comp.pass.cpp b/libcxx/test/std/algorithms/alg.sorting/alg.min.max/max_element_comp.pass.cpp index 74e9fe6027f..37c181393aa 100644 --- a/libcxx/test/std/algorithms/alg.sorting/alg.min.max/max_element_comp.pass.cpp +++ b/libcxx/test/std/algorithms/alg.sorting/alg.min.max/max_element_comp.pass.cpp @@ -75,6 +75,19 @@ void test_eq() delete [] a; } +#if __cplusplus >= 201402L +constexpr int il[] = { 2, 4, 6, 8, 7, 5, 3, 1 }; +struct less { constexpr bool operator ()( const int &x, const int &y) const { return x < y; }}; +#endif + +void constexpr_test() +{ +#if __cplusplus >= 201402L + constexpr auto p = std::max_element(il, il+8, less()); + static_assert ( *p == 8, "" ); +#endif +} + int main() { test<forward_iterator<const int*> >(); @@ -82,4 +95,6 @@ int main() test<random_access_iterator<const int*> >(); test<const int*>(); test_eq(); + + constexpr_test(); } diff --git a/libcxx/test/std/algorithms/alg.sorting/alg.min.max/min_element.pass.cpp b/libcxx/test/std/algorithms/alg.sorting/alg.min.max/min_element.pass.cpp index fd41f7a9ad7..a9a9d61340f 100644 --- a/libcxx/test/std/algorithms/alg.sorting/alg.min.max/min_element.pass.cpp +++ b/libcxx/test/std/algorithms/alg.sorting/alg.min.max/min_element.pass.cpp @@ -57,10 +57,24 @@ test() test<Iter>(1000); } +#if __cplusplus >= 201402L +constexpr int il[] = { 2, 4, 6, 8, 7, 5, 3, 1 }; +#endif + +void constexpr_test() +{ +#if __cplusplus >= 201402L + constexpr auto p = std::min_element(il, il+8); + static_assert ( *p == 1, "" ); +#endif +} + int main() { test<forward_iterator<const int*> >(); test<bidirectional_iterator<const int*> >(); test<random_access_iterator<const int*> >(); test<const int*>(); + + constexpr_test(); } diff --git a/libcxx/test/std/algorithms/alg.sorting/alg.min.max/min_element_comp.pass.cpp b/libcxx/test/std/algorithms/alg.sorting/alg.min.max/min_element_comp.pass.cpp index 2b5fdb1e0bb..9517f7eac94 100644 --- a/libcxx/test/std/algorithms/alg.sorting/alg.min.max/min_element_comp.pass.cpp +++ b/libcxx/test/std/algorithms/alg.sorting/alg.min.max/min_element_comp.pass.cpp @@ -75,6 +75,19 @@ void test_eq() delete [] a; } +#if __cplusplus >= 201402L +constexpr int il[] = { 2, 4, 6, 8, 7, 5, 3, 1 }; +struct less { constexpr bool operator ()( const int &x, const int &y) const { return x < y; }}; +#endif + +void constexpr_test() +{ +#if __cplusplus >= 201402L + constexpr auto p = std::min_element(il, il+8, less()); + static_assert(*p == 1, ""); +#endif +} + int main() { test<forward_iterator<const int*> >(); @@ -82,4 +95,6 @@ int main() test<random_access_iterator<const int*> >(); test<const int*>(); test_eq(); + + constexpr_test(); } diff --git a/libcxx/test/std/algorithms/alg.sorting/alg.min.max/minmax_element.pass.cpp b/libcxx/test/std/algorithms/alg.sorting/alg.min.max/minmax_element.pass.cpp index 6cdb87dedb4..915b1d176ab 100644 --- a/libcxx/test/std/algorithms/alg.sorting/alg.min.max/minmax_element.pass.cpp +++ b/libcxx/test/std/algorithms/alg.sorting/alg.min.max/minmax_element.pass.cpp @@ -74,10 +74,25 @@ test() } } +#if __cplusplus >= 201402L +constexpr int il[] = { 2, 4, 6, 8, 7, 5, 3, 1 }; +#endif + +void constexpr_test() +{ +#if __cplusplus >= 201402L + constexpr auto p = std::minmax_element(il, il+8); + static_assert ( *(p.first) == 1, "" ); + static_assert ( *(p.second) == 8, "" ); +#endif +} + int main() { test<forward_iterator<const int*> >(); test<bidirectional_iterator<const int*> >(); test<random_access_iterator<const int*> >(); test<const int*>(); + + constexpr_test(); } diff --git a/libcxx/test/std/algorithms/alg.sorting/alg.min.max/minmax_element_comp.pass.cpp b/libcxx/test/std/algorithms/alg.sorting/alg.min.max/minmax_element_comp.pass.cpp index cc0e66e175c..d3a067fda3c 100644 --- a/libcxx/test/std/algorithms/alg.sorting/alg.min.max/minmax_element_comp.pass.cpp +++ b/libcxx/test/std/algorithms/alg.sorting/alg.min.max/minmax_element_comp.pass.cpp @@ -79,10 +79,26 @@ test() } } +#if __cplusplus >= 201402L +constexpr int il[] = { 2, 4, 6, 8, 7, 5, 3, 1 }; +struct less { constexpr bool operator ()( const int &x, const int &y) const { return x < y; }}; +#endif + +void constexpr_test() +{ +#if __cplusplus >= 201402L + constexpr auto p = std::minmax_element(il, il+8, less()); + static_assert ( *(p.first) == 1, "" ); + static_assert ( *(p.second) == 8, "" ); +#endif +} + int main() { test<forward_iterator<const int*> >(); test<bidirectional_iterator<const int*> >(); test<random_access_iterator<const int*> >(); test<const int*>(); + + constexpr_test(); } |