forked from llvm-mirror/libcxx
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add unit tests for priority_queue::replace_top.
- Loading branch information
1 parent
2a65cc9
commit 49af5dc
Showing
3 changed files
with
97 additions
and
0 deletions.
There are no files selected for viewing
33 changes: 33 additions & 0 deletions
33
...bcxx/containers/container.adaptors/priority.queue/priqueue.members/reemplace_top.pass.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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)); | ||
} |
31 changes: 31 additions & 0 deletions
31
...libcxx/containers/container.adaptors/priority.queue/priqueue.members/replace_top.pass.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} |
33 changes: 33 additions & 0 deletions
33
...containers/container.adaptors/priority.queue/priqueue.members/replace_top_rvalue.pass.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
} |