Files
libakerror/tests/err_handle_default.c
Andrew Kesterson 4ae1decde2
All checks were successful
libakerror CI Build / cmake_build (push) Successful in 2m44s
libakerror CI Build / mutation_test (push) Successful in 7m46s
Expand error status test coverage
- 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
2026-07-29 17:12:52 -04:00

42 lines
952 B
C

#include "akerror.h"
#include "err_capture.h"
/*
* An error whose status has no matching HANDLE block must fall through to
* HANDLE_DEFAULT, and the non-matching HANDLE body must not run.
*/
static int specific_fired = 0;
static int default_fired = 0;
static int default_status = 0;
akerr_ErrorContext *boom(void)
{
PREPARE_ERROR(e);
FAIL_RETURN(e, AKERR_TYPE, "wrong type");
}
int main(void)
{
akerr_capture_install();
PREPARE_ERROR(e);
ATTEMPT {
CATCH(e, boom());
} CLEANUP {
} PROCESS(e) {
} HANDLE(e, AKERR_KEY) {
specific_fired = 1; /* must NOT run: error is AKERR_TYPE */
} HANDLE_DEFAULT(e) {
default_fired = 1;
default_status = e->status;
} FINISH_NORETURN(e);
AKERR_CHECK(specific_fired == 0);
AKERR_CHECK(default_fired == 1);
AKERR_CHECK(default_status == AKERR_TYPE);
AKERR_CHECK(akerr_slots_in_use() == 0);
fprintf(stderr, "err_handle_default ok\n");
return 0;
}