[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
This commit is contained in:
Martin Storsjö 2020-10-15 13:41:50 +03:00
parent b30e42922a
commit 87d7c00092
1 changed files with 16 additions and 8 deletions

View File

@ -26,28 +26,36 @@
struct MakePreferredTestcase {
const char* value;
const char* expected_posix;
const char* expected_windows;
};
const MakePreferredTestcase TestCases[] =
{
{""}
, {"hello_world"}
, {"/"}
, {"/foo/bar/baz/"}
, {"\\"}
, {"\\foo\\bar\\baz\\"}
, {"\\foo\\/bar\\/baz\\"}
{"", "", ""}
, {"hello_world", "hello_world", "hello_world"}
, {"/", "/", "\\"}
, {"/foo/bar/baz/", "/foo/bar/baz/", "\\foo\\bar\\baz\\"}
, {"\\", "\\", "\\"}
, {"\\foo\\bar\\baz\\", "\\foo\\bar\\baz\\", "\\foo\\bar\\baz\\"}
, {"\\foo\\/bar\\/baz\\", "\\foo\\/bar\\/baz\\", "\\foo\\\\bar\\\\baz\\"}
};
int main(int, char**)
{
// This operation is an identity operation on linux.
// On windows, compare with preferred_win, if set.
using namespace fs;
for (auto const & TC : TestCases) {
path p(TC.value);
assert(p == TC.value);
path& Ref = (p.make_preferred());
assert(p.native() == TC.value);
#ifdef _WIN32
std::string s(TC.expected_windows);
#else
std::string s(TC.expected_posix);
#endif
assert(p.string() == s);
assert(&Ref == &p);
}