]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - test/std/algorithms/alg.sorting/alg.heap.operations/make.heap/make_heap.pass.cpp
Vendor import of libc++ trunk r300422:
[FreeBSD/FreeBSD.git] / test / std / algorithms / alg.sorting / alg.heap.operations / make.heap / make_heap.pass.cpp
1 //===----------------------------------------------------------------------===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is dual licensed under the MIT and the University of Illinois Open
6 // Source Licenses. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9
10 // <algorithm>
11
12 // template<RandomAccessIterator Iter>
13 //   requires ShuffleIterator<Iter> && LessThanComparable<Iter::value_type>
14 //   void
15 //   make_heap(Iter first, Iter last);
16
17 #include <algorithm>
18 #include <random>
19 #include <cassert>
20
21 std::mt19937 randomness;
22
23 void test(int N)
24 {
25     int* ia = new int [N];
26     for (int i = 0; i < N; ++i)
27         ia[i] = i;
28     std::shuffle(ia, ia+N, randomness);
29     std::make_heap(ia, ia+N);
30     assert(std::is_heap(ia, ia+N));
31     delete [] ia;
32 }
33
34 int main()
35 {
36     test(0);
37     test(1);
38     test(2);
39     test(3);
40     test(10);
41     test(1000);
42 }