Skip to content

Commit 87d7c00

Browse files
committed
[libcxx] [test] Fix path.modifiers/make_preferred for windows
Use p.string() instead of p.native() for comparing with the expected value. Explicitly list the expected values for both posix and windos, even if the operation is an identity operation on posix. Differential Revision: https://reviews.llvm.org/D89532
1 parent b30e429 commit 87d7c00

File tree

1 file changed

+16
-8
lines changed

1 file changed

+16
-8
lines changed

libcxx/test/std/input.output/filesystems/class.path/path.member/path.modifiers/make_preferred.pass.cpp

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,28 +26,36 @@
2626

2727
struct MakePreferredTestcase {
2828
const char* value;
29+
const char* expected_posix;
30+
const char* expected_windows;
2931
};
3032

3133
const MakePreferredTestcase TestCases[] =
3234
{
33-
{""}
34-
, {"hello_world"}
35-
, {"/"}
36-
, {"/foo/bar/baz/"}
37-
, {"\\"}
38-
, {"\\foo\\bar\\baz\\"}
39-
, {"\\foo\\/bar\\/baz\\"}
35+
{"", "", ""}
36+
, {"hello_world", "hello_world", "hello_world"}
37+
, {"/", "/", "\\"}
38+
, {"/foo/bar/baz/", "/foo/bar/baz/", "\\foo\\bar\\baz\\"}
39+
, {"\\", "\\", "\\"}
40+
, {"\\foo\\bar\\baz\\", "\\foo\\bar\\baz\\", "\\foo\\bar\\baz\\"}
41+
, {"\\foo\\/bar\\/baz\\", "\\foo\\/bar\\/baz\\", "\\foo\\\\bar\\\\baz\\"}
4042
};
4143

4244
int main(int, char**)
4345
{
4446
// This operation is an identity operation on linux.
47+
// On windows, compare with preferred_win, if set.
4548
using namespace fs;
4649
for (auto const & TC : TestCases) {
4750
path p(TC.value);
4851
assert(p == TC.value);
4952
path& Ref = (p.make_preferred());
50-
assert(p.native() == TC.value);
53+
#ifdef _WIN32
54+
std::string s(TC.expected_windows);
55+
#else
56+
std::string s(TC.expected_posix);
57+
#endif
58+
assert(p.string() == s);
5159
assert(&Ref == &p);
5260
}
5361

0 commit comments

Comments
 (0)