Skip to content

Commit

Permalink
[libc++] Enables constexpr string tests.
Browse files Browse the repository at this point in the history
These tests were disabled during constant evaluation in D90569. At that
time constexpr string was not implemented. It now is.

Reviewed By: #libc, philnik

Differential Revision: https://reviews.llvm.org/D154227
  • Loading branch information
mordante committed Jul 1, 2023
1 parent 8fdbc87 commit 0fa67d4
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 72 deletions.
Expand Up @@ -59,17 +59,7 @@ test_use_move()
}
#endif // TEST_STD_VER > 17

// C++20 can use string in constexpr evaluation, but both libc++ and MSVC
// don't have the support yet. In these cases omit the constexpr test.
// FIXME Remove constexpr string workaround introduced in D90569
#if TEST_STD_VER > 17 && \
(!defined(__cpp_lib_constexpr_string) || __cpp_lib_constexpr_string < 201907L)
void
#else
TEST_CONSTEXPR_CXX20 void
#endif
test_string()
{
TEST_CONSTEXPR_CXX20 void test_string() {
std::string sa[] = {"a", "b", "c"};
assert(std::accumulate(sa, sa + 3, std::string()) == "abc");
assert(std::accumulate(sa, sa + 3, std::string(), std::plus<std::string>()) == "abc");
Expand Down Expand Up @@ -110,13 +100,7 @@ test()
#if TEST_STD_VER > 17
test_use_move();
#endif // TEST_STD_VER > 17
// C++20 can use string in constexpr evaluation, but both libc++ and MSVC
// don't have the support yet. In these cases omit the constexpr test.
// FIXME Remove constexpr string workaround introduced in D90569
#if TEST_STD_VER > 17 && \
(!defined(__cpp_lib_constexpr_string) || __cpp_lib_constexpr_string < 201907L)
if (!std::is_constant_evaluated())
#endif

test_string();

return true;
Expand Down
Expand Up @@ -66,17 +66,7 @@ test_use_move()
}
#endif // TEST_STD_VER > 17

// C++20 can use string in constexpr evaluation, but both libc++ and MSVC
// don't have the support yet. In these cases omit the constexpr test.
// FIXME Remove constexpr string workaround introduced in D90569
#if TEST_STD_VER > 17 && \
(!defined(__cpp_lib_constexpr_string) || __cpp_lib_constexpr_string < 201907L)
void
#else
TEST_CONSTEXPR_CXX20 void
#endif
test_string()
{
TEST_CONSTEXPR_CXX20 void test_string() {
std::string sa[] = {"a", "b", "c"};
std::string sr[] = {"a", "ba", "cb"};
std::string output[3];
Expand Down Expand Up @@ -179,13 +169,7 @@ test()
#if TEST_STD_VER > 17
test_use_move();
#endif // TEST_STD_VER > 17
// C++20 can use string in constexpr evaluation, but both libc++ and MSVC
// don't have the support yet. In these cases omit the constexpr test.
// FIXME Remove constexpr string workaround introduced in D90569
#if TEST_STD_VER > 17 && \
(!defined(__cpp_lib_constexpr_string) || __cpp_lib_constexpr_string < 201907L)
if (!std::is_constant_evaluated())
#endif

test_string();

return true;
Expand Down
Expand Up @@ -73,17 +73,7 @@ test_use_move()
}
#endif // TEST_STD_VER > 17

// C++20 can use string in constexpr evaluation, but both libc++ and MSVC
// don't have the support yet. In these cases omit the constexpr test.
// FIXME Remove constexpr string workaround introduced in D90569
#if TEST_STD_VER > 17 && \
(!defined(__cpp_lib_constexpr_string) || __cpp_lib_constexpr_string < 201907L)
void
#else
TEST_CONSTEXPR_CXX20 void
#endif
test_string()
{
TEST_CONSTEXPR_CXX20 void test_string() {
std::string sa[] = {"a", "b", "c"};
assert(std::accumulate(sa, sa + 3, std::string()) == "abc");
assert(std::accumulate(sa, sa + 3, std::string(), std::plus<std::string>()) == "abc");
Expand Down Expand Up @@ -150,13 +140,7 @@ test()
#if TEST_STD_VER > 17
test_use_move();
#endif // TEST_STD_VER > 17
// C++20 can use string in constexpr evaluation, but both libc++ and MSVC
// don't have the support yet. In these cases omit the constexpr test.
// FIXME Remove constexpr string workaround introduced in D90569
#if TEST_STD_VER > 17 && \
(!defined(__cpp_lib_constexpr_string) || __cpp_lib_constexpr_string < 201907L)
if (!std::is_constant_evaluated())
#endif

test_string();

return true;
Expand Down
Expand Up @@ -65,17 +65,7 @@ test_use_move()
}
#endif // TEST_STD_VER > 17

// C++20 can use string in constexpr evaluation, but both libc++ and MSVC
// don't have the support yet. In these cases omit the constexpr test.
// FIXME Remove constexpr string workaround introduced in D90569
#if TEST_STD_VER > 17 && \
(!defined(__cpp_lib_constexpr_string) || __cpp_lib_constexpr_string < 201907L)
void
#else
TEST_CONSTEXPR_CXX20 void
#endif
test_string()
{
TEST_CONSTEXPR_CXX20 void test_string() {
std::string sa[] = {"a", "b", "c"};
std::string sr[] = {"a", "ba", "cb"};
std::string output[3];
Expand Down Expand Up @@ -133,13 +123,7 @@ test()
#if TEST_STD_VER > 17
test_use_move();
#endif // TEST_STD_VER > 17
// C++20 can use string in constexpr evaluation, but both libc++ and MSVC
// don't have the support yet. In these cases omit the constexpr test.
// FIXME Remove constexpr string workaround introduced in D90569
#if TEST_STD_VER > 17 && \
(!defined(__cpp_lib_constexpr_string) || __cpp_lib_constexpr_string < 201907L)
if (!std::is_constant_evaluated())
#endif

test_string();

return true;
Expand Down

0 comments on commit 0fa67d4

Please sign in to comment.