]> gcc.gnu.org Git - gcc.git/commitdiff
libstdc++: Fix tests that fail with fully-dynamic-string
authorJonathan Wakely <jwakely@redhat.com>
Tue, 30 Nov 2021 16:07:21 +0000 (16:07 +0000)
committerJonathan Wakely <jwakely@redhat.com>
Thu, 21 Apr 2022 11:13:10 +0000 (12:13 +0100)
Fix some tests that assume that a moved-from string is empty, or that
default constructing a string doesn't allocate.

libstdc++-v3/ChangeLog:

* testsuite/21_strings/basic_string/cons/char/moveable.cc: Allow
moved-from string to be non-empty.
* testsuite/21_strings/basic_string/cons/char/moveable2.cc:
Likewise.
* testsuite/21_strings/basic_string/cons/char/moveable2_c++17.cc:
Likewise.
* testsuite/21_strings/basic_string/cons/wchar_t/moveable.cc:
Likewise.
* testsuite/21_strings/basic_string/cons/wchar_t/moveable2.cc:
Likewise.
* testsuite/21_strings/basic_string/cons/wchar_t/moveable2_c++17.cc:
Likewise.
* testsuite/21_strings/basic_string/modifiers/assign/char/87749.cc:
Construct empty string before setting oom flag.
* testsuite/21_strings/basic_string/modifiers/assign/wchar_t/87749.cc:
Likewise.

(cherry picked from commit be30fc4ce085ef786f104c6a407ccd44e554cd54)

libstdc++-v3/testsuite/21_strings/basic_string/cons/char/moveable.cc
libstdc++-v3/testsuite/21_strings/basic_string/cons/char/moveable2.cc
libstdc++-v3/testsuite/21_strings/basic_string/cons/char/moveable2_c++17.cc
libstdc++-v3/testsuite/21_strings/basic_string/cons/wchar_t/moveable.cc
libstdc++-v3/testsuite/21_strings/basic_string/cons/wchar_t/moveable2.cc
libstdc++-v3/testsuite/21_strings/basic_string/cons/wchar_t/moveable2_c++17.cc
libstdc++-v3/testsuite/21_strings/basic_string/modifiers/assign/char/87749.cc
libstdc++-v3/testsuite/21_strings/basic_string/modifiers/assign/wchar_t/87749.cc

index 5de2a5f93305c6168853d00b59804003e37bf926..3ba39ec432d62f0a0afb346dc64e536684242a1e 100644 (file)
@@ -35,7 +35,9 @@ void test01()
 
   std::string c(std::move(b));
   VERIFY( c.size() == 1 && c[0] == '1' );
-  VERIFY( b.size() == 0 );
+#if ! _GLIBCXX_FULLY_DYNAMIC_STRING
+  VERIFY( b.size() == 0 ); // not guaranteed by the standard
+#endif
 }
 
 int main()
index fe91c5ab53964706d04f210130f768670ace4817..5804ccb6bf883e495de5e1016d9c2926e9fd9e99 100644 (file)
@@ -44,7 +44,9 @@ void test01()
 
   tstring c(std::move(b));
   VERIFY( c.size() == 1 && c[0] == '1' );
-  VERIFY( b.size() == 0 );
+#if ! _GLIBCXX_FULLY_DYNAMIC_STRING
+  VERIFY( b.size() == 0 ); // not guaranteed by the standard
+#endif
 }
 
 int main()
index 1caedcccfce44c92e3519ae09f8a04326029649b..59d1d775134f480607292b483d834899a07688d6 100644 (file)
@@ -42,7 +42,9 @@ void test01()
 
   tstring c(std::move(b));
   VERIFY( c.size() == 1 && c[0] == '1' );
-  VERIFY( b.size() == 0 );
+#if ! _GLIBCXX_FULLY_DYNAMIC_STRING
+  VERIFY( b.size() == 0 ); // not guaranteed by the standard
+#endif
 }
 
 int main()
index d05afb7d466807c185d0932dbd2ce5d178696773..67e25de2916b92064a600767425d3af46aea937e 100644 (file)
@@ -35,7 +35,9 @@ void test01()
 
   std::wstring c(std::move(b));
   VERIFY( c.size() == 1 && c[0] == L'1' );
-  VERIFY( b.size() == 0 );
+#if ! _GLIBCXX_FULLY_DYNAMIC_STRING
+  VERIFY( b.size() == 0 ); // not guaranteed by the standard
+#endif
 }
 
 int main()
index e301984612d2002df3da33636709723636ac97ac..c72eb9bfddbb8895305279f00802c2b10912cd28 100644 (file)
@@ -44,7 +44,9 @@ void test01()
 
   twstring c(std::move(b));
   VERIFY( c.size() == 1 && c[0] == L'1' );
-  VERIFY( b.size() == 0 );
+#if ! _GLIBCXX_FULLY_DYNAMIC_STRING
+  VERIFY( b.size() == 0 ); // not guaranteed by the standard
+#endif
 }
 
 int main()
index d3e4744ff347b060594c15cc29d81671307077a0..6a2bc2714b5240d2baa0b840273b94ec1ac5988a 100644 (file)
@@ -42,7 +42,9 @@ void test01()
 
   tstring c(std::move(b));
   VERIFY( c.size() == 1 && c[0] == L'1' );
-  VERIFY( b.size() == 0 );
+#if ! _GLIBCXX_FULLY_DYNAMIC_STRING
+  VERIFY( b.size() == 0 ); // not guaranteed by the standard
+#endif
 }
 
 int main()
index 87d8c2f406800d802adb7e7e1b05aa87baa9afac..6a3ed55f5572803d64c39038fa00c0c6b08b9ba3 100644 (file)
@@ -71,8 +71,8 @@ int main()
 
   string s = "PR libstdc++/87749 a string that is longer than a short string";
   const auto ptr = s.c_str();
-  oom = true;
   string ss;
+  oom = true;
   ss = std::move(s); // allocators are equal, should not allocate new storage
   VERIFY( ss.c_str() == ptr );
 }
index 4d744f8a411e1d5e89d722fd7a9c0c77cb9a1bd6..536ca6153d325fa6550e96beb26f341e37555e6d 100644 (file)
@@ -72,8 +72,8 @@ int main()
 
   string s = L"PR libstdc++/87749 a string that is longer than a short string";
   const auto ptr = s.c_str();
-  oom = true;
   string ss;
+  oom = true;
   ss = std::move(s); // allocators are equal, should not allocate new storage
   VERIFY( ss.c_str() == ptr );
 }
This page took 0.071454 seconds and 5 git commands to generate.