[libcxx-commits] [PATCH] D93026: [libc++] [P1164] Add tests for create_directories. NFC.

Martin Storsjö via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Mon Dec 14 04:32:46 PST 2020

mstorsjo added inline comments.

Comment at: libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.create_directories/create_directories.pass.cpp:107
+    TEST_CHECK(ec);
+    TEST_CHECK(ec == std::errc::file_exists);
+    TEST_CHECK(is_regular_file(file));
curdeius wrote:
> mstorsjo wrote:
> > Btw, the filesystem tests has got a helper function, that would allow writing this as `ErrorIs(ec, std::errc::file_exists)` - but I verified that this form also seems to work.
> > 
> > The thing is, that with MS STL, the returned error codes don't use the standard `std::errc` values and category, but wrap the windows native error codes. The `ErrorIs()` helper explicitly converts them to the generic error category (via `ec.default_error_condition()`) before comparing error values, but it looks like `operator==()` does the same as well, implicitly.
> Ok, I use `ErrorIs` now, even it doesn't change much. But it may be future proof.
> Do you have a scenario where the returned error code would be unintuitive?
Not in libc++ itself, but MS STL produces such error codes (and I have a setup where I run the libc++ tests against MS STL).

  rG LLVM Github Monorepo



More information about the libcxx-commits mailing list