[libcxx-commits] [PATCH] D102360: [libcxx] [test] Change the generic_string_alloc test to do a conversion that also does something on windows

Martin Storsjö via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Fri May 14 01:57:50 PDT 2021


This revision was automatically updated to reflect the committed changes.
Closed by commit rGc12c8124e142: [libcxx] [test] Change the generic_string_alloc test to test conversions to all… (authored by mstorsjo).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D102360/new/

https://reviews.llvm.org/D102360

Files:
  libcxx/test/std/input.output/filesystems/class.path/path.member/path.generic.obs/generic_string_alloc.pass.cpp
  libcxx/test/std/input.output/filesystems/class.path/path.member/path.native.obs/string_alloc.pass.cpp


Index: libcxx/test/std/input.output/filesystems/class.path/path.member/path.native.obs/string_alloc.pass.cpp
===================================================================
--- libcxx/test/std/input.output/filesystems/class.path/path.member/path.native.obs/string_alloc.pass.cpp
+++ libcxx/test/std/input.output/filesystems/class.path/path.member/path.native.obs/string_alloc.pass.cpp
@@ -150,6 +150,9 @@
     doShortStringTest<wchar_t>(S);
     doShortStringTest<char16_t>(S);
     doShortStringTest<char32_t>(S);
+#if TEST_STD_VER > 17 && defined(__cpp_lib_char8_t)
+    doShortStringTest<char8_t>(S);
+#endif
   }
   {
     auto const& S = longString;
@@ -157,6 +160,9 @@
     doLongStringTest<wchar_t>(S);
     doLongStringTest<char16_t>(S);
     doLongStringTest<char32_t>(S);
+#if TEST_STD_VER > 17 && defined(__cpp_lib_char8_t)
+    doLongStringTest<char8_t>(S);
+#endif
   }
 
   return 0;
Index: libcxx/test/std/input.output/filesystems/class.path/path.member/path.generic.obs/generic_string_alloc.pass.cpp
===================================================================
--- libcxx/test/std/input.output/filesystems/class.path/path.member/path.generic.obs/generic_string_alloc.pass.cpp
+++ libcxx/test/std/input.output/filesystems/class.path/path.member/path.generic.obs/generic_string_alloc.pass.cpp
@@ -34,26 +34,39 @@
 
 
 // generic_string<C, T, A> forwards to string<C, T, A>. Tests for
-// string<C, T, A>() are in "path.native.op/string_alloc.pass.cpp".
+// string<C, T, A>() are in "path.native.obs/string_alloc.pass.cpp".
 // generic_string is minimally tested here.
-int main(int, char**)
+template <class CharT>
+void doAllocTest()
 {
   using namespace fs;
-  using CharT = wchar_t;
   using Traits = std::char_traits<CharT>;
   using Alloc = malloc_allocator<CharT>;
   using Str = std::basic_string<CharT, Traits, Alloc>;
-  const wchar_t* expect = longString;
+  const CharT* expect = longString;
   const path p((const char*)longString);
   {
-    DisableAllocationGuard g;
+    // On Windows, charset conversions cause allocations outside of the
+    // provided allocator.
+    TEST_NOT_WIN32(DisableAllocationGuard g);
     Alloc a;
     Alloc::disable_default_constructor = true;
-    Str s = p.generic_string<wchar_t, Traits, Alloc>(a);
+    Str s = p.generic_string<CharT, Traits, Alloc>(a);
     assert(s == expect);
     assert(Alloc::alloc_count > 0);
     assert(Alloc::outstanding_alloc() == 1);
+    Alloc::disable_default_constructor = false;
   }
+}
 
+int main(int, char**)
+{
+  doAllocTest<char>();
+  doAllocTest<wchar_t>();
+  doAllocTest<char16_t>();
+  doAllocTest<char32_t>();
+#if TEST_STD_VER > 17 && defined(__cpp_lib_char8_t)
+  doAllocTest<char8_t>();
+#endif
   return 0;
 }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D102360.345374.patch
Type: text/x-patch
Size: 2736 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20210514/ec11a3b0/attachment-0001.bin>


More information about the libcxx-commits mailing list