mirror of
https://github.com/gulrak/filesystem.git
synced 2026-07-30 16:26:11 +08:00
Refine weakly_canonical test to validate error codes and handle invalid paths more robustly.
This commit is contained in:
parent
21b931bd97
commit
a6aab92fb2
@ -2868,11 +2868,18 @@ TEST_CASE("fs.op.weakly_canonical - weakly_canonical", "[filesystem][operations]
|
|||||||
CHECK(!ec);
|
CHECK(!ec);
|
||||||
|
|
||||||
const auto invalid = dir / std::string(1024, 'x');
|
const auto invalid = dir / std::string(1024, 'x');
|
||||||
CHECK(fs::weakly_canonical(invalid, ec).empty());
|
std::error_code lookupError;
|
||||||
CHECK(ec);
|
CHECK_FALSE(fs::exists(invalid, lookupError));
|
||||||
#ifdef GHC_WITH_EXCEPTIONS
|
#ifndef GHC_OS_WINDOWS
|
||||||
CHECK_THROWS_AS(fs::weakly_canonical(invalid), fs::filesystem_error);
|
REQUIRE(lookupError);
|
||||||
#endif
|
#endif
|
||||||
|
if (lookupError) {
|
||||||
|
CHECK(fs::weakly_canonical(invalid, ec).empty());
|
||||||
|
CHECK(ec == lookupError);
|
||||||
|
#ifdef GHC_WITH_EXCEPTIONS
|
||||||
|
CHECK_THROWS_AS(fs::weakly_canonical(invalid), fs::filesystem_error);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user