- Added explicit status validation across error handling tests. - Added lifecycle and slot-leak checks to older tests. - Improved unhandled-error propagation coverage. - Added repository guidance and a test runner script. - Verified all 23 CTest tests pass. Co-Authored by Codex GPT 5.4
44 lines
871 B
C
44 lines
871 B
C
#include "akerror.h"
|
|
#include <stdlib.h>
|
|
|
|
static void expect_unhandled_nullpointer(akerr_ErrorContext *errctx)
|
|
{
|
|
exit((errctx != NULL && errctx->status == AKERR_NULLPOINTER) ? 1 : 0);
|
|
}
|
|
|
|
akerr_ErrorContext *func2(void)
|
|
{
|
|
PREPARE_ERROR(errctx);
|
|
ATTEMPT {
|
|
FAIL(errctx, AKERR_NULLPOINTER, "This is a failure in func2");
|
|
} CLEANUP {
|
|
} PROCESS(errctx) {
|
|
} FINISH(errctx, true);
|
|
SUCCEED_RETURN(errctx);
|
|
}
|
|
|
|
akerr_ErrorContext *func1(void)
|
|
{
|
|
PREPARE_ERROR(errctx);
|
|
ATTEMPT {
|
|
CATCH(errctx, func2());
|
|
} CLEANUP {
|
|
} PROCESS(errctx) {
|
|
} FINISH(errctx, true);
|
|
SUCCEED_RETURN(errctx);
|
|
}
|
|
|
|
|
|
int main(void)
|
|
{
|
|
akerr_init();
|
|
akerr_handler_unhandled_error = &expect_unhandled_nullpointer;
|
|
|
|
PREPARE_ERROR(errctx);
|
|
ATTEMPT {
|
|
CATCH(errctx, func1());
|
|
} CLEANUP {
|
|
} PROCESS(errctx) {
|
|
} FINISH_NORETURN(errctx);
|
|
}
|