diff --git a/test/algorithms/alg.sorting/alg.min.max/max_element_comp.pass.cpp b/test/algorithms/alg.sorting/alg.min.max/max_element_comp.pass.cpp index c99c6936..74e9fe60 100644 --- a/test/algorithms/alg.sorting/alg.min.max/max_element_comp.pass.cpp +++ b/test/algorithms/alg.sorting/alg.min.max/max_element_comp.pass.cpp @@ -58,10 +58,28 @@ test() test(1000); } +template +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()); + test_eq0(a, a+N, std::greater()); + delete [] a; +} + int main() { test >(); test >(); test >(); test(); + test_eq(); } diff --git a/test/algorithms/alg.sorting/alg.min.max/min_element_comp.pass.cpp b/test/algorithms/alg.sorting/alg.min.max/min_element_comp.pass.cpp index 55d7215a..2b5fdb1e 100644 --- a/test/algorithms/alg.sorting/alg.min.max/min_element_comp.pass.cpp +++ b/test/algorithms/alg.sorting/alg.min.max/min_element_comp.pass.cpp @@ -58,10 +58,28 @@ test() test(1000); } +template +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()); + test_eq0(a, a+N, std::greater()); + delete [] a; +} + int main() { test >(); test >(); test >(); test(); + test_eq(); }