[libcxx-commits] [libcxx] [libcxx] Correct and clean-up filesystem operations error_code paths (PR #88341)
Louis Dionne via libcxx-commits
libcxx-commits at lists.llvm.org
Tue Jun 11 18:57:24 PDT 2024
================
@@ -79,6 +79,14 @@ int main(int, char**) {
TEST_REQUIRE(PathEq(output, expect),
TEST_WRITE_CONCATENATED(
"Input: ", TC.input.string(), "\nExpected: ", expect.string(), "\nOutput: ", output.string()));
+
+ // Get coverage over the error_code form of the api.
+ std::error_code ec;
+ const fs::path output_c = fs::weakly_canonical(p, ec);
+
+ TEST_REQUIRE(PathEq(output_c, expect),
+ TEST_WRITE_CONCATENATED(
+ "Input: ", TC.input.string(), "\nExpected: ", expect.string(), "\nOutput: ", output_c.string()));
----------------
ldionne wrote:
Minor style nit, I'd suggest writing it this way instead:
```suggestion
// Get coverage over the error_code form of the api.
{
std::error_code ec;
const fs::path output = fs::weakly_canonical(p, ec);
TEST_REQUIRE(PathEq(output, expect),
TEST_WRITE_CONCATENATED(
"Input: ", TC.input.string(), "\nExpected: ", expect.string(), "\nOutput: ", output.string()));
}
```
Similarly, put the exception-based test right above in its own scope. That way it's more obvious that those are two test cases and you don't need to invent a new name (`output_c`) for one of the test cases.
https://github.com/llvm/llvm-project/pull/88341
More information about the libcxx-commits
mailing list