Expand test coverage for error-handling macros and error pool
All checks were successful
libakerror CI Build / cmake_build (push) Successful in 2m42s
All checks were successful
libakerror CI Build / cmake_build (push) Successful in 2m42s
Add 11 CTest programs and a shared test helper covering gaps left by the original four tests (which only exercised FAIL/CATCH/HANDLE and CLEANUP): - err_capture.h: capturing akerr_log_method + NDEBUG-proof AKERR_CHECK so tests can assert on message/status/stacktrace content, not just exit codes - err_success: clean nested return does not break/handle/leak - err_pool_refcount: 100k raise->catch->handle cycles leak 0 pool slots - err_handle_default / err_handle_group / err_handle_dispatch: handler routing - err_pass / err_ignore / err_swallow: PASS, IGNORE, FINISH(e,false) - err_break_variants: FAIL_*_BREAK and FAIL_*_RETURN - err_errno: system errno name lookup + "Unknown Error" boundary - err_custom_handler: override the unhandled-error hook, assert non-fatally Register tests via a foreach loop in CMakeLists.txt. Ignore build/. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
34
tests/err_ignore.c
Normal file
34
tests/err_ignore.c
Normal file
@@ -0,0 +1,34 @@
|
||||
#include "akerror.h"
|
||||
#include "err_capture.h"
|
||||
|
||||
/*
|
||||
* IGNORE deliberately swallows an error: it records the context in
|
||||
* __akerr_last_ignored, logs it with an "IGNORED ERROR" marker, and lets
|
||||
* execution continue.
|
||||
*/
|
||||
|
||||
akerr_ErrorContext *boom(void)
|
||||
{
|
||||
PREPARE_ERROR(e);
|
||||
FAIL_RETURN(e, AKERR_VALUE, "this error is ignored on purpose");
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
akerr_capture_install();
|
||||
|
||||
int reached_after_ignore = 0;
|
||||
PREPARE_ERROR(e);
|
||||
(void)e;
|
||||
|
||||
IGNORE(boom());
|
||||
reached_after_ignore = 1;
|
||||
|
||||
AKERR_CHECK(__akerr_last_ignored != NULL);
|
||||
AKERR_CHECK(__akerr_last_ignored->status == AKERR_VALUE);
|
||||
AKERR_CHECK(reached_after_ignore == 1);
|
||||
AKERR_CHECK_CONTAINS("IGNORED ERROR");
|
||||
AKERR_CHECK_CONTAINS("this error is ignored on purpose");
|
||||
fprintf(stderr, "err_ignore ok\n");
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user