#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_EOF, AKERR_ITERATOR_BREAK and AKERR_NOT_IMPLEMENTED are omitted -- * they are valid codes but akerr_init does not register a display name for them, * so akerr_name_for_status returns an empty string rather than a known name. */ 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" }, { AKERR_BADEXC, "Invalid akerr_ErrorContext" }, }; 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; }