[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 81db3c31aa and
3784bdf217.

Differential Revision: https://reviews.llvm.org/D97458
This commit is contained in:
Martin Storsjö 2021-02-25 12:53:39 +02:00
parent 3573a90b8a
commit f15377084c
5 changed files with 10 additions and 10 deletions

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}