[libcxx-commits] [libcxx] f153770 - [libcxx] [test] Use string().c_str() to convert a std::filesystem::path to a const char*

Martin Storsjö via libcxx-commits libcxx-commits at lists.llvm.org
Thu Feb 25 14:11:07 PST 2021


Author: Martin Storsjö
Date: 2021-02-26T00:10:47+02:00
New Revision: f15377084c3094ad47eca8738f15d397f558df7b

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

LOG: [libcxx] [test] Use string().c_str() to convert a std::filesystem::path to a const char*

On Windows, path::value_type is wchar_t, so one can't pass the return
value of path::c_str() directly to std::remove().

This matches what was done for tests under std/input.output/filesystems
in 81db3c31aafec72f1cfec2a9da4381ece7f97a29 and
3784bdf2176f38cc30134fab776efb43506c0c54.

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

Added: 
    

Modified: 
    libcxx/test/std/input.output/file.streams/fstreams/filebuf.members/open_path.pass.cpp
    libcxx/test/std/input.output/file.streams/fstreams/fstream.cons/path.pass.cpp
    libcxx/test/std/input.output/file.streams/fstreams/fstream.members/open_path.pass.cpp
    libcxx/test/std/input.output/file.streams/fstreams/ofstream.cons/path.pass.cpp
    libcxx/test/std/input.output/file.streams/fstreams/ofstream.members/open_path.pass.cpp

Removed: 
    


################################################################################
diff  --git a/libcxx/test/std/input.output/file.streams/fstreams/filebuf.members/open_path.pass.cpp b/libcxx/test/std/input.output/file.streams/fstreams/filebuf.members/open_path.pass.cpp
index b51f9598f948..512840d95552 100644
--- a/libcxx/test/std/input.output/file.streams/fstreams/filebuf.members/open_path.pass.cpp
+++ b/libcxx/test/std/input.output/file.streams/fstreams/filebuf.members/open_path.pass.cpp
@@ -46,7 +46,7 @@ int main(int, char**) {
     assert(f.sbumpc() == '2');
     assert(f.sbumpc() == '3');
   }
-  std::remove(p.c_str());
+  std::remove(p.string().c_str());
   {
     std::wfilebuf f;
     assert(f.open(p, std::ios_base::out) != 0);
@@ -61,7 +61,7 @@ int main(int, char**) {
     assert(f.sbumpc() == L'2');
     assert(f.sbumpc() == L'3');
   }
-  remove(p.c_str());
+  remove(p.string().c_str());
 
   return 0;
 }

diff  --git a/libcxx/test/std/input.output/file.streams/fstreams/fstream.cons/path.pass.cpp b/libcxx/test/std/input.output/file.streams/fstreams/fstream.cons/path.pass.cpp
index 8384f503eba9..f38da79cc054 100644
--- a/libcxx/test/std/input.output/file.streams/fstreams/fstream.cons/path.pass.cpp
+++ b/libcxx/test/std/input.output/file.streams/fstreams/fstream.cons/path.pass.cpp
@@ -44,7 +44,7 @@ int main(int, char**) {
     fs >> x;
     assert(x == 3.25);
   }
-  std::remove(p.c_str());
+  std::remove(p.string().c_str());
   {
     std::wfstream fs(p, std::ios_base::in | std::ios_base::out |
                             std::ios_base::trunc);
@@ -54,7 +54,7 @@ int main(int, char**) {
     fs >> x;
     assert(x == 3.25);
   }
-  std::remove(p.c_str());
+  std::remove(p.string().c_str());
 
   return 0;
 }

diff  --git a/libcxx/test/std/input.output/file.streams/fstreams/fstream.members/open_path.pass.cpp b/libcxx/test/std/input.output/file.streams/fstreams/fstream.members/open_path.pass.cpp
index bd5b1f81e0c9..ee3b96b133b7 100644
--- a/libcxx/test/std/input.output/file.streams/fstreams/fstream.members/open_path.pass.cpp
+++ b/libcxx/test/std/input.output/file.streams/fstreams/fstream.members/open_path.pass.cpp
@@ -44,7 +44,7 @@ int main(int, char**) {
     stream >> x;
     assert(x == 3.25);
   }
-  std::remove(p.c_str());
+  std::remove(p.string().c_str());
   {
     std::wfstream stream;
     assert(!stream.is_open());
@@ -57,7 +57,7 @@ int main(int, char**) {
     stream >> x;
     assert(x == 3.25);
   }
-  std::remove(p.c_str());
+  std::remove(p.string().c_str());
 
   return 0;
 }

diff  --git a/libcxx/test/std/input.output/file.streams/fstreams/ofstream.cons/path.pass.cpp b/libcxx/test/std/input.output/file.streams/fstreams/ofstream.cons/path.pass.cpp
index 2406295be402..e5c57e23e408 100644
--- a/libcxx/test/std/input.output/file.streams/fstreams/ofstream.cons/path.pass.cpp
+++ b/libcxx/test/std/input.output/file.streams/fstreams/ofstream.cons/path.pass.cpp
@@ -57,7 +57,7 @@ int main(int, char**) {
     stream >> x;
     assert(x == 3.25);
   }
-  std::remove(p.c_str());
+  std::remove(p.string().c_str());
   {
     std::wofstream stream(p);
     stream << 3.25;
@@ -74,7 +74,7 @@ int main(int, char**) {
     stream >> x;
     assert(x == 3.25);
   }
-  std::remove(p.c_str());
+  std::remove(p.string().c_str());
 
   return 0;
 }

diff  --git a/libcxx/test/std/input.output/file.streams/fstreams/ofstream.members/open_path.pass.cpp b/libcxx/test/std/input.output/file.streams/fstreams/ofstream.members/open_path.pass.cpp
index c656ada41d95..761ae31981a0 100644
--- a/libcxx/test/std/input.output/file.streams/fstreams/ofstream.members/open_path.pass.cpp
+++ b/libcxx/test/std/input.output/file.streams/fstreams/ofstream.members/open_path.pass.cpp
@@ -50,7 +50,7 @@ int main(int, char**) {
     fs >> c;
     assert(c == 'a');
   }
-  std::remove(p.c_str());
+  std::remove(p.string().c_str());
   {
     std::wofstream fs;
     assert(!fs.is_open());
@@ -67,7 +67,7 @@ int main(int, char**) {
     fs >> c;
     assert(c == L'a');
   }
-  std::remove(p.c_str());
+  std::remove(p.string().c_str());
 
   return 0;
 }


        


More information about the libcxx-commits mailing list