[libcxx-commits] [libcxx] [libc++][test] Mark `optional` test functions as `TEST_CONSTEXPR_CXX20` (PR #94172)
Stephan T. Lavavej via libcxx-commits
libcxx-commits at lists.llvm.org
Sun Jun 2 14:20:22 PDT 2024
https://github.com/StephanTLavavej updated https://github.com/llvm/llvm-project/pull/94172
>From 24b1a67c8daac22addb6740de2457e16f3123dd3 Mon Sep 17 00:00:00 2001
From: "Stephan T. Lavavej" <stl at nuwen.net>
Date: Sun, 2 Jun 2024 14:06:52 -0700
Subject: [PATCH 1/2] Mark `test_empty_emplace()` and `check_reset()` as
`TEST_CONSTEXPR_CXX20`.
---
.../optional.object/optional.object.assign/emplace.pass.cpp | 2 +-
.../optional/optional.object/optional.object.mod/reset.pass.cpp | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/libcxx/test/std/utilities/optional/optional.object/optional.object.assign/emplace.pass.cpp b/libcxx/test/std/utilities/optional/optional.object/optional.object.assign/emplace.pass.cpp
index 17a1e94b0ba6e..631052cad94b9 100644
--- a/libcxx/test/std/utilities/optional/optional.object/optional.object.assign/emplace.pass.cpp
+++ b/libcxx/test/std/utilities/optional/optional.object/optional.object.assign/emplace.pass.cpp
@@ -210,7 +210,7 @@ void test_on_test_type() {
}
}
-constexpr bool test_empty_emplace()
+TEST_CONSTEXPR_CXX20 bool test_empty_emplace()
{
optional<const int> opt;
auto &v = opt.emplace(42);
diff --git a/libcxx/test/std/utilities/optional/optional.object/optional.object.mod/reset.pass.cpp b/libcxx/test/std/utilities/optional/optional.object/optional.object.mod/reset.pass.cpp
index 112ee213b42a6..c8c0b01060608 100644
--- a/libcxx/test/std/utilities/optional/optional.object/optional.object.mod/reset.pass.cpp
+++ b/libcxx/test/std/utilities/optional/optional.object/optional.object.mod/reset.pass.cpp
@@ -31,7 +31,7 @@ struct X
bool X::dtor_called = false;
-constexpr bool check_reset()
+TEST_CONSTEXPR_CXX20 bool check_reset()
{
{
optional<int> opt;
>From aa5fe119a2ae4bc44d8de1e00e649a34933e096d Mon Sep 17 00:00:00 2001
From: "Stephan T. Lavavej" <stl at nuwen.net>
Date: Sun, 2 Jun 2024 14:19:50 -0700
Subject: [PATCH 2/2] clang-format.
---
.../optional.object.assign/emplace.pass.cpp | 19 +++++++------
.../optional.object.mod/reset.pass.cpp | 27 +++++++++----------
2 files changed, 22 insertions(+), 24 deletions(-)
diff --git a/libcxx/test/std/utilities/optional/optional.object/optional.object.assign/emplace.pass.cpp b/libcxx/test/std/utilities/optional/optional.object/optional.object.assign/emplace.pass.cpp
index 631052cad94b9..245d8ff3d2146 100644
--- a/libcxx/test/std/utilities/optional/optional.object/optional.object.assign/emplace.pass.cpp
+++ b/libcxx/test/std/utilities/optional/optional.object/optional.object.assign/emplace.pass.cpp
@@ -210,16 +210,15 @@ void test_on_test_type() {
}
}
-TEST_CONSTEXPR_CXX20 bool test_empty_emplace()
-{
- optional<const int> opt;
- auto &v = opt.emplace(42);
- static_assert( std::is_same_v<const int&, decltype(v)>, "" );
- assert(*opt == 42);
- assert( v == 42);
- opt.emplace();
- assert(*opt == 0);
- return true;
+TEST_CONSTEXPR_CXX20 bool test_empty_emplace() {
+ optional<const int> opt;
+ auto& v = opt.emplace(42);
+ static_assert(std::is_same_v<const int&, decltype(v)>, "");
+ assert(*opt == 42);
+ assert(v == 42);
+ opt.emplace();
+ assert(*opt == 0);
+ return true;
}
int main(int, char**)
diff --git a/libcxx/test/std/utilities/optional/optional.object/optional.object.mod/reset.pass.cpp b/libcxx/test/std/utilities/optional/optional.object/optional.object.mod/reset.pass.cpp
index c8c0b01060608..7029b37cbecd7 100644
--- a/libcxx/test/std/utilities/optional/optional.object/optional.object.mod/reset.pass.cpp
+++ b/libcxx/test/std/utilities/optional/optional.object/optional.object.mod/reset.pass.cpp
@@ -31,20 +31,19 @@ struct X
bool X::dtor_called = false;
-TEST_CONSTEXPR_CXX20 bool check_reset()
-{
- {
- optional<int> opt;
- static_assert(noexcept(opt.reset()) == true, "");
- opt.reset();
- assert(static_cast<bool>(opt) == false);
- }
- {
- optional<int> opt(3);
- opt.reset();
- assert(static_cast<bool>(opt) == false);
- }
- return true;
+TEST_CONSTEXPR_CXX20 bool check_reset() {
+ {
+ optional<int> opt;
+ static_assert(noexcept(opt.reset()) == true, "");
+ opt.reset();
+ assert(static_cast<bool>(opt) == false);
+ }
+ {
+ optional<int> opt(3);
+ opt.reset();
+ assert(static_cast<bool>(opt) == false);
+ }
+ return true;
}
int main(int, char**)
More information about the libcxx-commits
mailing list