summaryrefslogtreecommitdiffstats
path: root/libcxx
diff options
context:
space:
mode:
authorMarshall Clow <mclow.lists@gmail.com>2014-06-30 05:04:20 +0000
committerMarshall Clow <mclow.lists@gmail.com>2014-06-30 05:04:20 +0000
commit3484495b3d061038210aa19fc20ed28834dcc1da (patch)
tree74e3a13091e13101048dfe0c116da844ce7b3f45 /libcxx
parent83222d6109ae6657fac01a0002d999ad64255f93 (diff)
downloadbcm5719-llvm-3484495b3d061038210aa19fc20ed28834dcc1da.tar.gz
bcm5719-llvm-3484495b3d061038210aa19fc20ed28834dcc1da.zip
Add checking for the complexity guarantees in the standard
llvm-svn: 212017
Diffstat (limited to 'libcxx')
-rw-r--r--libcxx/test/algorithms/alg.sorting/alg.heap.operations/make.heap/make_heap_comp.pass.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/libcxx/test/algorithms/alg.sorting/alg.heap.operations/make.heap/make_heap_comp.pass.cpp b/libcxx/test/algorithms/alg.sorting/alg.heap.operations/make.heap/make_heap_comp.pass.cpp
index ed76fa2f988..7bbdd09546c 100644
--- a/libcxx/test/algorithms/alg.sorting/alg.heap.operations/make.heap/make_heap_comp.pass.cpp
+++ b/libcxx/test/algorithms/alg.sorting/alg.heap.operations/make.heap/make_heap_comp.pass.cpp
@@ -17,6 +17,9 @@
#include <algorithm>
#include <functional>
#include <cassert>
+
+#include "counting_predicates.hpp"
+
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
#include <memory>
@@ -34,9 +37,20 @@ void test(unsigned N)
int* ia = new int [N];
for (int i = 0; i < N; ++i)
ia[i] = i;
+ {
std::random_shuffle(ia, ia+N);
std::make_heap(ia, ia+N, std::greater<int>());
assert(std::is_heap(ia, ia+N, std::greater<int>()));
+ }
+
+ {
+ binary_counting_predicate<std::greater<int>, int, int> pred ((std::greater<int>()));
+ std::random_shuffle(ia, ia+N);
+ std::make_heap(ia, ia+N, std::ref(pred));
+ assert(pred.count() <= 3*N);
+ assert(std::is_heap(ia, ia+N, pred));
+ }
+
delete [] ia;
}
@@ -48,6 +62,8 @@ int main()
test(3);
test(10);
test(1000);
+ test(10000);
+ test(100000);
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
{
OpenPOWER on IntegriCloud