#include "akerror.h" #include "err_capture.h" #include /* * akerr_name_for_status must reject out-of-range status codes at BOTH ends. * It already guarded the upper bound, but a negative status indexed * __AKERR_ERROR_NAMES[negative] -- an out-of-bounds read (and an out-of-bounds * write when a name is supplied). Every out-of-range status must return the * "Unknown Error" sentinel instead. */ int main(void) { akerr_init(); /* Below range. */ AKERR_CHECK(strcmp(akerr_name_for_status(-1, NULL), "Unknown Error") == 0); AKERR_CHECK(strcmp(akerr_name_for_status(-9999, NULL), "Unknown Error") == 0); /* Above range (already handled; kept as a guard against regressions). */ AKERR_CHECK(strcmp(akerr_name_for_status(AKERR_MAX_ERR_VALUE + 1, NULL), "Unknown Error") == 0); /* A valid code must still resolve to its real name. */ AKERR_CHECK(strcmp(akerr_name_for_status(AKERR_NULLPOINTER, NULL), "Null Pointer Error") == 0); fprintf(stderr, "err_name_bounds ok\n"); return 0; }