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>
45 lines
992 B
C
45 lines
992 B
C
#include "akerror.h"
|
|
#include "err_capture.h"
|
|
|
|
/*
|
|
* The success path: a nested call that returns cleanly (NULL) must not break
|
|
* out of the caller's ATTEMPT block, must not enter any handler, and must not
|
|
* consume a slot from the error pool.
|
|
*/
|
|
|
|
static int default_fired = 0;
|
|
|
|
akerr_ErrorContext *ok_func(void)
|
|
{
|
|
PREPARE_ERROR(e);
|
|
ATTEMPT {
|
|
} CLEANUP {
|
|
} PROCESS(e) {
|
|
} FINISH(e, true);
|
|
SUCCEED_RETURN(e);
|
|
}
|
|
|
|
int main(void)
|
|
{
|
|
akerr_capture_install();
|
|
akerr_init();
|
|
|
|
int reached_after_catch = 0;
|
|
PREPARE_ERROR(e);
|
|
ATTEMPT {
|
|
CATCH(e, ok_func());
|
|
reached_after_catch = 1; /* must run: no break on success */
|
|
} CLEANUP {
|
|
} PROCESS(e) {
|
|
} HANDLE_DEFAULT(e) {
|
|
default_fired = 1; /* must NOT run */
|
|
} FINISH_NORETURN(e);
|
|
|
|
AKERR_CHECK(reached_after_catch == 1);
|
|
AKERR_CHECK(default_fired == 0);
|
|
AKERR_CHECK(e == NULL);
|
|
AKERR_CHECK(akerr_slots_in_use() == 0);
|
|
fprintf(stderr, "err_success ok\n");
|
|
return 0;
|
|
}
|