This is an archive of the discontinued LLVM Phabricator instance.

[libcxx] [test] Use error_code::default_error_condition to check errors against the expected codes
ClosedPublic

Authored by mstorsjo on Nov 2 2020, 5:52 AM.

Details

Summary

error_code returned from functions might not be of the generic category, but of the system category, which can have different error code values. Use default_error_condition() to remap errors to the generic category where possible, to allow comparing them to the expected values.

Use the ErrorIs() helper instead of a direct comparison against an excpected value.

Diff Detail

Event Timeline

mstorsjo created this revision.Nov 2 2020, 5:52 AM
Herald added a project: Restricted Project. · View Herald TranscriptNov 2 2020, 5:52 AM
Herald added 1 blocking reviewer(s): Restricted Project. · View Herald Transcript
mstorsjo requested review of this revision.Nov 2 2020, 5:52 AM
ldionne accepted this revision.Nov 2 2020, 4:05 PM
ldionne added a subscriber: ldionne.

LGTM with my comments applied.

libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.permissions/permissions.pass.cpp
176

Can you please use static_cast instead of a C-style cast?

libcxx/test/support/filesystem_test_helper.h
565

Same, static_cast.

This revision is now accepted and ready to land.Nov 2 2020, 4:05 PM