[libcxx-commits] [libcxx] 93a375a - [libc++][test] Enable constexpr string comparison tests

Joe Loser via libcxx-commits libcxx-commits at lists.llvm.org
Wed Jun 1 18:28:36 PDT 2022


Author: Joe Loser
Date: 2022-06-01T19:26:20-06:00
New Revision: 93a375a15c8ad4226453b3ec920070b5be361656

URL: https://github.com/llvm/llvm-project/commit/93a375a15c8ad4226453b3ec920070b5be361656
DIFF: https://github.com/llvm/llvm-project/commit/93a375a15c8ad4226453b3ec920070b5be361656.diff

LOG: [libc++][test] Enable constexpr string comparison tests

Some tests in `string.view.comparison` are not enabled due to previous lack of
support for `constexpr std::string`. Now that it is implemented, we can enable
these tests.

Differential Revision: https://reviews.llvm.org/D126737

Added: 
    

Modified: 
    libcxx/test/std/strings/string.view/string.view.comparison/equal.pass.cpp
    libcxx/test/std/strings/string.view/string.view.comparison/greater.pass.cpp
    libcxx/test/std/strings/string.view/string.view.comparison/greater_equal.pass.cpp
    libcxx/test/std/strings/string.view/string.view.comparison/less.pass.cpp
    libcxx/test/std/strings/string.view/string.view.comparison/less_equal.pass.cpp
    libcxx/test/std/strings/string.view/string.view.comparison/not_equal.pass.cpp

Removed: 
    


################################################################################
diff  --git a/libcxx/test/std/strings/string.view/string.view.comparison/equal.pass.cpp b/libcxx/test/std/strings/string.view/string.view.comparison/equal.pass.cpp
index 4aa27b0b99caa..916e5ed18c77a 100644
--- a/libcxx/test/std/strings/string.view/string.view.comparison/equal.pass.cpp
+++ b/libcxx/test/std/strings/string.view/string.view.comparison/equal.pass.cpp
@@ -52,8 +52,7 @@ TEST_CONSTEXPR_CXX14 bool test()
             assert((ConvertibleTo<SV>(v[i]) == v[j]) == expected);
             assert((v[i] == ConvertibleTo<SV>(v[j])) == expected);
 
-            if (!TEST_IS_CONSTANT_EVALUATED) {
-                // TODO FIXME: once P0980 "Making std::string constexpr" is implemented
+            if (!TEST_IS_CONSTANT_EVALUATED || TEST_STD_VER >= 20) {
                 assert((std::basic_string<CharT, Traits>(v[i]) == v[j]) == expected);
                 assert((v[i] == std::basic_string<CharT, Traits>(v[j])) == expected);
             }
@@ -74,8 +73,7 @@ TEST_CONSTEXPR_CXX14 bool test()
     assert((abc.data() == abc0def) == false);
     assert((abc0def == abc.data()) == false);
 
-    if (!TEST_IS_CONSTANT_EVALUATED) {
-        // TODO FIXME: once P0980 "Making std::string constexpr" is implemented
+    if (!TEST_IS_CONSTANT_EVALUATED || TEST_STD_VER >= 20) {
         assert((std::basic_string<CharT, Traits>(abc) == abc0def) == false);
         assert((abc0def == std::basic_string<CharT, Traits>(abc)) == false);
     }

diff  --git a/libcxx/test/std/strings/string.view/string.view.comparison/greater.pass.cpp b/libcxx/test/std/strings/string.view/string.view.comparison/greater.pass.cpp
index 84753b04e1965..4f56bc991ae9a 100644
--- a/libcxx/test/std/strings/string.view/string.view.comparison/greater.pass.cpp
+++ b/libcxx/test/std/strings/string.view/string.view.comparison/greater.pass.cpp
@@ -52,8 +52,7 @@ TEST_CONSTEXPR_CXX14 bool test()
             assert((ConvertibleTo<SV>(v[i]) > v[j]) == expected);
             assert((v[i] > ConvertibleTo<SV>(v[j])) == expected);
 
-            if (!TEST_IS_CONSTANT_EVALUATED) {
-                // TODO FIXME: once P0980 "Making std::string constexpr" is implemented
+            if (!TEST_IS_CONSTANT_EVALUATED || TEST_STD_VER >= 20) {
                 assert((std::basic_string<CharT, Traits>(v[i]) > v[j]) == expected);
                 assert((v[i] > std::basic_string<CharT, Traits>(v[j])) == expected);
             }
@@ -74,8 +73,7 @@ TEST_CONSTEXPR_CXX14 bool test()
     assert((abc.data() > abc0def) == false);
     assert((abc0def > abc.data()) == true);
 
-    if (!TEST_IS_CONSTANT_EVALUATED) {
-        // TODO FIXME: once P0980 "Making std::string constexpr" is implemented
+    if (!TEST_IS_CONSTANT_EVALUATED || TEST_STD_VER >= 20) {
         assert((std::basic_string<CharT, Traits>(abc) > abc0def) == false);
         assert((abc0def > std::basic_string<CharT, Traits>(abc)) == true);
     }

diff  --git a/libcxx/test/std/strings/string.view/string.view.comparison/greater_equal.pass.cpp b/libcxx/test/std/strings/string.view/string.view.comparison/greater_equal.pass.cpp
index 0ae1b6ff86441..147dc3a504200 100644
--- a/libcxx/test/std/strings/string.view/string.view.comparison/greater_equal.pass.cpp
+++ b/libcxx/test/std/strings/string.view/string.view.comparison/greater_equal.pass.cpp
@@ -52,8 +52,7 @@ TEST_CONSTEXPR_CXX14 bool test()
             assert((ConvertibleTo<SV>(v[i]) >= v[j]) == expected);
             assert((v[i] >= ConvertibleTo<SV>(v[j])) == expected);
 
-            if (!TEST_IS_CONSTANT_EVALUATED) {
-                // TODO FIXME: once P0980 "Making std::string constexpr" is implemented
+            if (!TEST_IS_CONSTANT_EVALUATED || TEST_STD_VER >= 20) {
                 assert((std::basic_string<CharT, Traits>(v[i]) >= v[j]) == expected);
                 assert((v[i] >= std::basic_string<CharT, Traits>(v[j])) == expected);
             }
@@ -74,8 +73,7 @@ TEST_CONSTEXPR_CXX14 bool test()
     assert((abc.data() >= abc0def) == false);
     assert((abc0def >= abc.data()) == true);
 
-    if (!TEST_IS_CONSTANT_EVALUATED) {
-        // TODO FIXME: once P0980 "Making std::string constexpr" is implemented
+    if (!TEST_IS_CONSTANT_EVALUATED || TEST_STD_VER >= 20) {
         assert((std::basic_string<CharT, Traits>(abc) >= abc0def) == false);
         assert((abc0def >= std::basic_string<CharT, Traits>(abc)) == true);
     }

diff  --git a/libcxx/test/std/strings/string.view/string.view.comparison/less.pass.cpp b/libcxx/test/std/strings/string.view/string.view.comparison/less.pass.cpp
index 5c9e052fad7f8..fe56920d203e3 100644
--- a/libcxx/test/std/strings/string.view/string.view.comparison/less.pass.cpp
+++ b/libcxx/test/std/strings/string.view/string.view.comparison/less.pass.cpp
@@ -52,8 +52,7 @@ TEST_CONSTEXPR_CXX14 bool test()
             assert((ConvertibleTo<SV>(v[i]) < v[j]) == expected);
             assert((v[i] < ConvertibleTo<SV>(v[j])) == expected);
 
-            if (!TEST_IS_CONSTANT_EVALUATED) {
-                // TODO FIXME: once P0980 "Making std::string constexpr" is implemented
+            if (!TEST_IS_CONSTANT_EVALUATED || TEST_STD_VER >= 20) {
                 assert((std::basic_string<CharT, Traits>(v[i]) < v[j]) == expected);
                 assert((v[i] < std::basic_string<CharT, Traits>(v[j])) == expected);
             }
@@ -74,8 +73,7 @@ TEST_CONSTEXPR_CXX14 bool test()
     assert((abc.data() < abc0def) == true);
     assert((abc0def < abc.data()) == false);
 
-    if (!TEST_IS_CONSTANT_EVALUATED) {
-        // TODO FIXME: once P0980 "Making std::string constexpr" is implemented
+    if (!TEST_IS_CONSTANT_EVALUATED || TEST_STD_VER >= 20) {
         assert((std::basic_string<CharT, Traits>(abc) < abc0def) == true);
         assert((abc0def < std::basic_string<CharT, Traits>(abc)) == false);
     }

diff  --git a/libcxx/test/std/strings/string.view/string.view.comparison/less_equal.pass.cpp b/libcxx/test/std/strings/string.view/string.view.comparison/less_equal.pass.cpp
index b7e31c6945ba6..e03f4b4a28a00 100644
--- a/libcxx/test/std/strings/string.view/string.view.comparison/less_equal.pass.cpp
+++ b/libcxx/test/std/strings/string.view/string.view.comparison/less_equal.pass.cpp
@@ -52,8 +52,7 @@ TEST_CONSTEXPR_CXX14 bool test()
             assert((ConvertibleTo<SV>(v[i]) <= v[j]) == expected);
             assert((v[i] <= ConvertibleTo<SV>(v[j])) == expected);
 
-            if (!TEST_IS_CONSTANT_EVALUATED) {
-                // TODO FIXME: once P0980 "Making std::string constexpr" is implemented
+            if (!TEST_IS_CONSTANT_EVALUATED || TEST_STD_VER >= 20) {
                 assert((std::basic_string<CharT, Traits>(v[i]) <= v[j]) == expected);
                 assert((v[i] <= std::basic_string<CharT, Traits>(v[j])) == expected);
             }
@@ -74,8 +73,7 @@ TEST_CONSTEXPR_CXX14 bool test()
     assert((abc.data() <= abc0def) == true);
     assert((abc0def <= abc.data()) == false);
 
-    if (!TEST_IS_CONSTANT_EVALUATED) {
-        // TODO FIXME: once P0980 "Making std::string constexpr" is implemented
+    if (!TEST_IS_CONSTANT_EVALUATED || TEST_STD_VER >= 20) {
         assert((std::basic_string<CharT, Traits>(abc) <= abc0def) == true);
         assert((abc0def <= std::basic_string<CharT, Traits>(abc)) == false);
     }

diff  --git a/libcxx/test/std/strings/string.view/string.view.comparison/not_equal.pass.cpp b/libcxx/test/std/strings/string.view/string.view.comparison/not_equal.pass.cpp
index bca79e48bb300..35b1a62d88005 100644
--- a/libcxx/test/std/strings/string.view/string.view.comparison/not_equal.pass.cpp
+++ b/libcxx/test/std/strings/string.view/string.view.comparison/not_equal.pass.cpp
@@ -52,8 +52,7 @@ TEST_CONSTEXPR_CXX14 bool test()
             assert((ConvertibleTo<SV>(v[i]) != v[j]) == expected);
             assert((v[i] != ConvertibleTo<SV>(v[j])) == expected);
 
-            if (!TEST_IS_CONSTANT_EVALUATED) {
-                // TODO FIXME: once P0980 "Making std::string constexpr" is implemented
+            if (!TEST_IS_CONSTANT_EVALUATED || TEST_STD_VER >= 20) {
                 assert((std::basic_string<CharT, Traits>(v[i]) != v[j]) == expected);
                 assert((v[i] != std::basic_string<CharT, Traits>(v[j])) == expected);
             }
@@ -74,8 +73,7 @@ TEST_CONSTEXPR_CXX14 bool test()
     assert((abc.data() != abc0def) == true);
     assert((abc0def != abc.data()) == true);
 
-    if (!TEST_IS_CONSTANT_EVALUATED) {
-        // TODO FIXME: once P0980 "Making std::string constexpr" is implemented
+    if (!TEST_IS_CONSTANT_EVALUATED || TEST_STD_VER >= 20) {
         assert((std::basic_string<CharT, Traits>(abc) != abc0def) == true);
         assert((abc0def != std::basic_string<CharT, Traits>(abc)) == true);
     }


        


More information about the libcxx-commits mailing list