1*477729cfSJeremy L Thompson /// @file 2*477729cfSJeremy L Thompson /// Test error storage for a CEED object 3*477729cfSJeremy L Thompson /// \test Test error storage for a CEED object 4*477729cfSJeremy L Thompson #include <ceed.h> 5*477729cfSJeremy L Thompson #include <string.h> 6*477729cfSJeremy L Thompson 7*477729cfSJeremy L Thompson int main(int argc, char **argv) { 8*477729cfSJeremy L Thompson Ceed ceed; 9*477729cfSJeremy L Thompson 10*477729cfSJeremy L Thompson CeedInit(argv[1], &ceed); 11*477729cfSJeremy L Thompson 12*477729cfSJeremy L Thompson // Check for standard message with default handler 13*477729cfSJeremy L Thompson const char *errmsg = NULL; 14*477729cfSJeremy L Thompson CeedGetErrorMessage(ceed, &errmsg); 15*477729cfSJeremy L Thompson if (strcmp(errmsg, "No error message stored")) 16*477729cfSJeremy L Thompson // LCOV_EXCL_START 17*477729cfSJeremy L Thompson printf("Unexpected error message received: \"%s\"\n", errmsg); 18*477729cfSJeremy L Thompson // LCOV_EXCL_STOP 19*477729cfSJeremy L Thompson 20*477729cfSJeremy L Thompson // Set error handler to store error message 21*477729cfSJeremy L Thompson CeedSetErrorHandler(ceed, CeedErrorStore); 22*477729cfSJeremy L Thompson 23*477729cfSJeremy L Thompson // Generate error 24*477729cfSJeremy L Thompson CeedVector vec; 25*477729cfSJeremy L Thompson CeedScalar *array; 26*477729cfSJeremy L Thompson CeedVectorCreate(ceed, 10, &vec); 27*477729cfSJeremy L Thompson CeedVectorGetArray(vec, CEED_MEM_HOST, &array); 28*477729cfSJeremy L Thompson CeedVectorGetArray(vec, CEED_MEM_HOST, &array); 29*477729cfSJeremy L Thompson 30*477729cfSJeremy L Thompson // Check error message 31*477729cfSJeremy L Thompson CeedGetErrorMessage(ceed, &errmsg); 32*477729cfSJeremy L Thompson if (!errmsg || !strcmp(errmsg, "No error message stored")) 33*477729cfSJeremy L Thompson // LCOV_EXCL_START 34*477729cfSJeremy L Thompson printf("Unexpected error message received: \"%s\"\n", errmsg); 35*477729cfSJeremy L Thompson // LCOV_EXCL_STOP 36*477729cfSJeremy L Thompson CeedResetErrorMessage(ceed, &errmsg); 37*477729cfSJeremy L Thompson 38*477729cfSJeremy L Thompson // Check error message reset 39*477729cfSJeremy L Thompson CeedGetErrorMessage(ceed, &errmsg); 40*477729cfSJeremy L Thompson if (strcmp(errmsg, "No error message stored")) 41*477729cfSJeremy L Thompson // LCOV_EXCL_START 42*477729cfSJeremy L Thompson printf("Unexpected error message received: \"%s\"\n", errmsg); 43*477729cfSJeremy L Thompson // LCOV_EXCL_STOP 44*477729cfSJeremy L Thompson 45*477729cfSJeremy L Thompson // Cleanup 46*477729cfSJeremy L Thompson CeedVectorRestoreArray(vec, &array); 47*477729cfSJeremy L Thompson CeedVectorDestroy(&vec); 48*477729cfSJeremy L Thompson CeedDestroy(&ceed); 49*477729cfSJeremy L Thompson return 0; 50*477729cfSJeremy L Thompson } 51