1477729cfSJeremy L Thompson /// @file 2477729cfSJeremy L Thompson /// Test error storage for a CEED object 3477729cfSJeremy L Thompson /// \test Test error storage for a CEED object 4477729cfSJeremy L Thompson #include <ceed.h> 5477729cfSJeremy L Thompson #include <string.h> 6477729cfSJeremy L Thompson 7477729cfSJeremy L Thompson int main(int argc, char **argv) { 8477729cfSJeremy L Thompson Ceed ceed; 9477729cfSJeremy L Thompson 10477729cfSJeremy L Thompson CeedInit(argv[1], &ceed); 11477729cfSJeremy L Thompson 12477729cfSJeremy L Thompson // Check for standard message with default handler 13d1d35e2fSjeremylt const char *err_msg = NULL; 14d1d35e2fSjeremylt CeedGetErrorMessage(ceed, &err_msg); 15*2b730f8bSJeremy L Thompson if (strcmp(err_msg, "No error message stored")) printf("Unexpected error message received: \"%s\"\n", err_msg); 16477729cfSJeremy L Thompson 17477729cfSJeremy L Thompson // Set error handler to store error message 18477729cfSJeremy L Thompson CeedSetErrorHandler(ceed, CeedErrorStore); 19477729cfSJeremy L Thompson 20477729cfSJeremy L Thompson // Generate error 21477729cfSJeremy L Thompson CeedVector vec; 22477729cfSJeremy L Thompson CeedScalar *array; 23477729cfSJeremy L Thompson CeedVectorCreate(ceed, 10, &vec); 24477729cfSJeremy L Thompson CeedVectorGetArray(vec, CEED_MEM_HOST, &array); 25477729cfSJeremy L Thompson CeedVectorGetArray(vec, CEED_MEM_HOST, &array); 26477729cfSJeremy L Thompson 27477729cfSJeremy L Thompson // Check error message 28d1d35e2fSjeremylt CeedGetErrorMessage(ceed, &err_msg); 29*2b730f8bSJeremy L Thompson if (!err_msg || !strcmp(err_msg, "No error message stored\n")) printf("Unexpected error message received: \"%s\"\n", err_msg); 30d1d35e2fSjeremylt CeedResetErrorMessage(ceed, &err_msg); 31477729cfSJeremy L Thompson 32477729cfSJeremy L Thompson // Check error message reset 33d1d35e2fSjeremylt CeedGetErrorMessage(ceed, &err_msg); 34*2b730f8bSJeremy L Thompson if (strcmp(err_msg, "No error message stored")) printf("Unexpected error message received: \"%s\"\n", err_msg); 35477729cfSJeremy L Thompson 36477729cfSJeremy L Thompson // Cleanup 37477729cfSJeremy L Thompson CeedVectorRestoreArray(vec, &array); 38477729cfSJeremy L Thompson CeedVectorDestroy(&vec); 39477729cfSJeremy L Thompson CeedDestroy(&ceed); 40477729cfSJeremy L Thompson return 0; 41477729cfSJeremy L Thompson } 42