Skip to content

Commit

Permalink
Add unit tests for priority_queue::replace_top.
Browse files Browse the repository at this point in the history
  • Loading branch information
Quuxplusone committed Feb 5, 2019
1 parent 2a65cc9 commit 49af5dc
Show file tree
Hide file tree
Showing 3 changed files with 97 additions and 0 deletions.
@@ -0,0 +1,33 @@
//===----------------------------------------------------------------------===//
//
// 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
//
//===----------------------------------------------------------------------===//

// UNSUPPORTED: c++98, c++03

// <queue>

// priority_queue();

// template <class... Args> void reemplace_top(Args&&... args);

#include <queue>
#include <cassert>

#include "../../../../../std/containers/Emplaceable.h"

int main()
{
std::priority_queue<Emplaceable> q;
q.emplace(1, 2.5);
assert(q.top() == Emplaceable(1, 2.5));
q.emplace(3, 4.5);
assert(q.top() == Emplaceable(3, 4.5));
q.reemplace_top(2, 3.5);
assert(q.top() == Emplaceable(2, 3.5));
q.reemplace_top(0, 1.5);
assert(q.top() == Emplaceable(1, 2.5));
}
@@ -0,0 +1,31 @@
//===----------------------------------------------------------------------===//
//
// 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
//
//===----------------------------------------------------------------------===//

// <queue>

// priority_queue();

// void replace_top(const value_type& v);

#include <queue>
#include <cassert>

int main()
{
std::priority_queue<int> q;
q.push(1);
assert(q.top() == 1);
q.push(3);
assert(q.top() == 3);
q.replace_top(2);
assert(q.top() == 2);
q.replace_top(0);
assert(q.top() == 1);

return 0;
}
@@ -0,0 +1,33 @@
//===----------------------------------------------------------------------===//
//
// 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
//
//===----------------------------------------------------------------------===//

// UNSUPPORTED: c++98, c++03

// <queue>

// priority_queue();

// void replace_top(value_type&& v);

#include <queue>
#include <cassert>

#include "MoveOnly.h"

int main()
{
std::priority_queue<MoveOnly> q;
q.push(1);
assert(q.top() == 1);
q.push(3);
assert(q.top() == 3);
q.replace_top(2);
assert(q.top() == 2);
q.replace_top(0);
assert(q.top() == 1);
}

0 comments on commit 49af5dc

Please sign in to comment.