blob: 52f279bac6e404d6cbfc9e8eb7353f106e185be8 [file] [log] [blame]
//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
// <algorithm>
// template<RandomAccessIterator Iter>
// requires ShuffleIterator<Iter>
// && LessThanComparable<Iter::value_type>
// void
// push_heap(Iter first, Iter last);
#include <algorithm>
#include <random>
#include <cassert>
#include "test_macros.h"
#include "test_iterators.h"
std::mt19937 randomness;
void test(int N)
{
int* ia = new int [N];
for (int i = 0; i < N; ++i)
ia[i] = i;
std::shuffle(ia, ia+N, randomness);
for (int i = 0; i <= N; ++i)
{
std::push_heap(ia, ia+i);
assert(std::is_heap(ia, ia+i));
}
typedef random_access_iterator<int *> RI;
std::shuffle(RI(ia), RI(ia+N), randomness);
for (int i = 0; i <= N; ++i)
{
std::push_heap(RI(ia), RI(ia+i));
assert(std::is_heap(RI(ia), RI(ia+i)));
}
delete [] ia;
}
int main(int, char**)
{
test(1000);
return 0;
}