[libcxx] [test] Adjust separator form in fs.op.absolute for libc++ on windows

This test was previously tweaked in
321f696920 to match the output of
of MS STL (except that the MS STL fails on the testcase with an
empty path).

libc++ doesn't produce paths with all normalized separators (and the
spec doesn't mandate it to either).

Tweak the test reference to match exactly what libc++ produces. If
testing with a non-libc++ library, do a relaxed comparison that allows
the separators to differ.

Differential Revision: https://reviews.llvm.org/D98215
This commit is contained in:
Martin Storsjö 2021-02-26 14:08:11 +02:00
parent 574663f9d5
commit e23317c9da
2 changed files with 10 additions and 3 deletions

View File

@ -42,15 +42,16 @@ TEST_CASE(basic_test)
} TestCases [] = {
{"", cwd / ""},
{"foo", cwd / "foo"},
{"foo/", cwd / "foo" / ""},
{"/already_absolute", cwd.root_path() / "already_absolute"}
{"foo/", cwd / "foo/"},
{"/already_absolute", cwd.root_name() / "/already_absolute"}
};
for (auto& TC : TestCases) {
std::error_code ec = GetTestEC();
const path ret = absolute(TC.input, ec);
TEST_CHECK(!ec);
TEST_CHECK(ret.is_absolute());
TEST_CHECK(PathEq(ret, TC.expect));
TEST_CHECK(PathEqIgnoreSep(ret, TC.expect));
LIBCPP_ONLY(TEST_CHECK(PathEq(ret, TC.expect)));
}
}

View File

@ -591,6 +591,12 @@ inline bool PathEq(fs::path const& LHS, fs::path const& RHS) {
return LHS.native() == RHS.native();
}
inline bool PathEqIgnoreSep(fs::path LHS, fs::path RHS) {
LHS.make_preferred();
RHS.make_preferred();
return LHS.native() == RHS.native();
}
struct ExceptionChecker {
std::errc expected_err;
fs::path expected_path1;