From a6aab92fb26c569d8fcf417d903601a3b3d4ce6f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Steffen=20Schu=CC=88mann?= Date: Sat, 11 Jul 2026 23:04:57 +0200 Subject: [PATCH] Refine `weakly_canonical` test to validate error codes and handle invalid paths more robustly. --- test/filesystem_test.cpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/test/filesystem_test.cpp b/test/filesystem_test.cpp index bab84ed..263a837 100644 --- a/test/filesystem_test.cpp +++ b/test/filesystem_test.cpp @@ -2868,11 +2868,18 @@ TEST_CASE("fs.op.weakly_canonical - weakly_canonical", "[filesystem][operations] CHECK(!ec); const auto invalid = dir / std::string(1024, 'x'); - CHECK(fs::weakly_canonical(invalid, ec).empty()); - CHECK(ec); -#ifdef GHC_WITH_EXCEPTIONS - CHECK_THROWS_AS(fs::weakly_canonical(invalid), fs::filesystem_error); + std::error_code lookupError; + CHECK_FALSE(fs::exists(invalid, lookupError)); +#ifndef GHC_OS_WINDOWS + REQUIRE(lookupError); #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 + } } }