summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarshall Clow <mclow.lists@gmail.com>2014-04-25 15:50:54 +0000
committerMarshall Clow <mclow.lists@gmail.com>2014-04-25 15:50:54 +0000
commit190cc60a2d3adcacb001a17a0390feb12b026886 (patch)
treebdf2b691ffd6f6c70204e23a496e38f6ad7fafb2
parent35013fa3903277bc4edf3bd3543d92df877148c1 (diff)
downloadbcm5719-llvm-190cc60a2d3adcacb001a17a0390feb12b026886.tar.gz
bcm5719-llvm-190cc60a2d3adcacb001a17a0390feb12b026886.zip
Added some tests for equal elements in min_element and max_element. Bug #19547 was invalid, but we weren't testing that case
llvm-svn: 207232
-rw-r--r--libcxx/test/algorithms/alg.sorting/alg.min.max/max_element_comp.pass.cpp18
-rw-r--r--libcxx/test/algorithms/alg.sorting/alg.min.max/min_element_comp.pass.cpp18
2 files changed, 36 insertions, 0 deletions
diff --git a/libcxx/test/algorithms/alg.sorting/alg.min.max/max_element_comp.pass.cpp b/libcxx/test/algorithms/alg.sorting/alg.min.max/max_element_comp.pass.cpp
index c99c6936ef5..74e9fe6027f 100644
--- a/libcxx/test/algorithms/alg.sorting/alg.min.max/max_element_comp.pass.cpp
+++ b/libcxx/test/algorithms/alg.sorting/alg.min.max/max_element_comp.pass.cpp
@@ -58,10 +58,28 @@ test()
test<Iter>(1000);
}
+template <class Iter, class Pred>
+void test_eq0(Iter first, Iter last, Pred p)
+{
+ assert(first == std::max_element(first, last, p));
+}
+
+void test_eq()
+{
+ const size_t N = 10;
+ int* a = new int[N];
+ for (int i = 0; i < N; ++i)
+ a[i] = 10; // all the same
+ test_eq0(a, a+N, std::less<int>());
+ test_eq0(a, a+N, std::greater<int>());
+ delete [] a;
+}
+
int main()
{
test<forward_iterator<const int*> >();
test<bidirectional_iterator<const int*> >();
test<random_access_iterator<const int*> >();
test<const int*>();
+ test_eq();
}
diff --git a/libcxx/test/algorithms/alg.sorting/alg.min.max/min_element_comp.pass.cpp b/libcxx/test/algorithms/alg.sorting/alg.min.max/min_element_comp.pass.cpp
index 55d7215a40e..2b5fdb1e0bb 100644
--- a/libcxx/test/algorithms/alg.sorting/alg.min.max/min_element_comp.pass.cpp
+++ b/libcxx/test/algorithms/alg.sorting/alg.min.max/min_element_comp.pass.cpp
@@ -58,10 +58,28 @@ test()
test<Iter>(1000);
}
+template <class Iter, class Pred>
+void test_eq0(Iter first, Iter last, Pred p)
+{
+ assert(first == std::min_element(first, last, p));
+}
+
+void test_eq()
+{
+ const size_t N = 10;
+ int* a = new int[N];
+ for (int i = 0; i < N; ++i)
+ a[i] = 10; // all the same
+ test_eq0(a, a+N, std::less<int>());
+ test_eq0(a, a+N, std::greater<int>());
+ delete [] a;
+}
+
int main()
{
test<forward_iterator<const int*> >();
test<bidirectional_iterator<const int*> >();
test<random_access_iterator<const int*> >();
test<const int*>();
+ test_eq();
}
OpenPOWER on IntegriCloud