cosmopolitan/test/libcxx/errc_test.cc
Justine Tunney 77d3a07ff2
Fix std::filesystem
This change makes a second pass, at fixing the errno issue with libcxx's
filesystem code. Previously, 89.01% of LLVM's test suite was passing and
now 98.59% of their tests pass. Best of all, it's now possible for Clang
to be built as a working APE binary that can to compile the Cosmopolitan
repository. Please note it has only been vetted so far for some objects,
and more work would obviously need to be done in cosmo, to fix warnings.
2024-07-28 17:31:21 -07:00

22 lines
686 B
C++

#include <cerrno>
#include <system_error>
bool test_errc_mapping(int posix_error, std::errc expected_errc) {
std::error_code ec(posix_error, std::generic_category());
return ec.value() == posix_error && //
std::error_condition(expected_errc) == ec;
}
int main() {
if (!test_errc_mapping(EACCES, std::errc::permission_denied))
return 1;
if (!test_errc_mapping(ENOENT, std::errc::no_such_file_or_directory))
return 2;
if (!test_errc_mapping(EEXIST, std::errc::file_exists))
return 3;
if (!test_errc_mapping(EINVAL, std::errc::invalid_argument))
return 4;
if (!test_errc_mapping(ENOSPC, std::errc::no_space_on_device))
return 5;
return 0;
}