diff --git a/test/libcxx/containers/container.adaptors/priority.queue/priqueue.members/reemplace_top.pass.cpp b/test/libcxx/containers/container.adaptors/priority.queue/priqueue.members/reemplace_top.pass.cpp new file mode 100644 index 000000000..422908f65 --- /dev/null +++ b/test/libcxx/containers/container.adaptors/priority.queue/priqueue.members/reemplace_top.pass.cpp @@ -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 + +// + +// priority_queue(); + +// template void reemplace_top(Args&&... args); + +#include +#include + +#include "../../../../../std/containers/Emplaceable.h" + +int main() +{ + std::priority_queue 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)); +} diff --git a/test/libcxx/containers/container.adaptors/priority.queue/priqueue.members/replace_top.pass.cpp b/test/libcxx/containers/container.adaptors/priority.queue/priqueue.members/replace_top.pass.cpp new file mode 100644 index 000000000..a97a81e9b --- /dev/null +++ b/test/libcxx/containers/container.adaptors/priority.queue/priqueue.members/replace_top.pass.cpp @@ -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 +// +//===----------------------------------------------------------------------===// + +// + +// priority_queue(); + +// void replace_top(const value_type& v); + +#include +#include + +int main() +{ + std::priority_queue 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; +} diff --git a/test/libcxx/containers/container.adaptors/priority.queue/priqueue.members/replace_top_rvalue.pass.cpp b/test/libcxx/containers/container.adaptors/priority.queue/priqueue.members/replace_top_rvalue.pass.cpp new file mode 100644 index 000000000..8d7d5f84e --- /dev/null +++ b/test/libcxx/containers/container.adaptors/priority.queue/priqueue.members/replace_top_rvalue.pass.cpp @@ -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 + +// + +// priority_queue(); + +// void replace_top(value_type&& v); + +#include +#include + +#include "MoveOnly.h" + +int main() +{ + std::priority_queue 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); +}