[committed] libstdc++: Fix tests that fail with fully-dynamic-string
Commit Message
Tested powerpc64le-linux (old ABI) and x86_64-linux (new ABI), pushed to
trunk.
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.
---
.../testsuite/21_strings/basic_string/cons/char/moveable.cc | 4 +++-
.../testsuite/21_strings/basic_string/cons/char/moveable2.cc | 4 +++-
.../21_strings/basic_string/cons/char/moveable2_c++17.cc | 4 +++-
.../21_strings/basic_string/cons/wchar_t/moveable.cc | 4 +++-
.../21_strings/basic_string/cons/wchar_t/moveable2.cc | 4 +++-
.../21_strings/basic_string/cons/wchar_t/moveable2_c++17.cc | 4 +++-
.../21_strings/basic_string/modifiers/assign/char/87749.cc | 2 +-
.../21_strings/basic_string/modifiers/assign/wchar_t/87749.cc | 2 +-
8 files changed, 20 insertions(+), 8 deletions(-)
@@ -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()
@@ -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()
@@ -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()
@@ -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()
@@ -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()
@@ -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()
@@ -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 );
}
@@ -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 );
}