[libcxx-commits] [PATCH] D141253: [libc++][test] Make some string tests MSVC-friendly
Casey Carter via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Mon Jan 9 15:00:26 PST 2023
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG6b90f6745ac7: [libc++][test] Make some string tests MSVC-friendly (authored by CaseyCarter).
Changed prior to commit:
https://reviews.llvm.org/D141253?vs=487285&id=487566#toc
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D141253/new/
https://reviews.llvm.org/D141253
Files:
libcxx/test/std/strings/basic.string/string.cons/dtor.pass.cpp
libcxx/test/std/strings/basic.string/string.ops/string_substr/substr_rvalue.pass.cpp
Index: libcxx/test/std/strings/basic.string/string.ops/string_substr/substr_rvalue.pass.cpp
===================================================================
--- libcxx/test/std/strings/basic.string/string.ops/string_substr/substr_rvalue.pass.cpp
+++ libcxx/test/std/strings/basic.string/string.ops/string_substr/substr_rvalue.pass.cpp
@@ -13,6 +13,7 @@
// constexpr basic_string substr(size_type pos = 0, size_type n = npos) &&;
#include <algorithm>
+#include <stdexcept>
#include <string>
#include "constexpr_char_traits.h"
@@ -26,7 +27,7 @@
} should_throw_exception;
template <class S>
-constexpr void test(S orig, size_t pos, ptrdiff_t n, S expected) {
+constexpr void test(S orig, typename S::size_type pos, typename S::size_type n, const S expected) {
S str = std::move(orig).substr(pos, n);
LIBCPP_ASSERT(orig.__invariants());
LIBCPP_ASSERT(str.__invariants());
@@ -34,7 +35,7 @@
}
template <class S>
-constexpr void test(S orig, size_t pos, ptrdiff_t n, should_throw_exception_t) {
+constexpr void test(S orig, typename S::size_type pos, typename S::size_type n, should_throw_exception_t) {
#ifndef TEST_HAS_NO_EXCEPTIONS
if (!std::is_constant_evaluated()) {
try {
Index: libcxx/test/std/strings/basic.string/string.cons/dtor.pass.cpp
===================================================================
--- libcxx/test/std/strings/basic.string/string.cons/dtor.pass.cpp
+++ libcxx/test/std/strings/basic.string/string.cons/dtor.pass.cpp
@@ -29,9 +29,9 @@
// Test that it's possible to take the address of basic_string's destructors
// by creating globals which will register their destructors with cxa_atexit.
-std::string s;
+std::string unused_string;
#ifndef TEST_HAS_NO_WIDE_CHARACTERS
-std::wstring ws;
+std::wstring unused_wide_string;
#endif
static_assert(std::is_nothrow_destructible<std::string>::value, "");
@@ -45,7 +45,8 @@
{
std::basic_string<char, std::char_traits<char>, test_allocator<char>> str2((test_allocator<char>(&alloc_stats)));
str2 = "long long string so no SSO";
- assert(alloc_stats.alloc_count == 1);
+ assert(alloc_stats.alloc_count > 0);
+ LIBCPP_ASSERT(alloc_stats.alloc_count == 1);
}
assert(alloc_stats.alloc_count == 0);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D141253.487566.patch
Type: text/x-patch
Size: 2238 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20230109/51cf8275/attachment.bin>
More information about the libcxx-commits
mailing list