#include "akerror.h" #include "err_capture.h" #include /* * akerr_init() registers a human-readable name for each library error code. * Verify the names are actually installed (mutation testing showed the * registration calls could be deleted without any test noticing). * * Note: AKERR_NOT_IMPLEMENTED and AKERR_BADEXC are intentionally omitted -- they * exceed AKERR_MAX_ERR_VALUE, so akerr_name_for_status cannot store or return * their names (see tests/MUTATION.md). */ static const struct { int code; const char *name; } expected[] = { { AKERR_NULLPOINTER, "Null Pointer Error" }, { AKERR_OUTOFBOUNDS, "Out Of Bounds Error" }, { AKERR_API, "API Error" }, { AKERR_ATTRIBUTE, "Attribute Error" }, { AKERR_TYPE, "Type Error" }, { AKERR_KEY, "Key Error" }, { AKERR_INDEX, "Index Error" }, { AKERR_FORMAT, "Format Error" }, { AKERR_IO, "Input Output Error" }, { AKERR_VALUE, "Value Error" }, { AKERR_RELATIONSHIP, "Relationship Error" }, { AKERR_CIRCULAR_REFERENCE, "Circular Reference Error" }, }; int main(void) { akerr_init(); for ( unsigned i = 0; i < sizeof(expected) / sizeof(expected[0]); i++ ) { char *nm = akerr_name_for_status(expected[i].code, NULL); AKERR_CHECK(nm != NULL); AKERR_CHECK(strcmp(nm, expected[i].name) == 0); } fprintf(stderr, "err_error_names ok\n"); return 0; }