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>
5*49aac155SJeremy L Thompson #include <stdio.h>
6477729cfSJeremy L Thompson #include <string.h>
7477729cfSJeremy L Thompson
main(int argc,char ** argv)8477729cfSJeremy L Thompson int main(int argc, char **argv) {
9477729cfSJeremy L Thompson Ceed ceed;
104fee36f0SJeremy L Thompson CeedVector vec;
114fee36f0SJeremy L Thompson CeedScalar *array;
124fee36f0SJeremy L Thompson const char *err_msg = NULL;
13477729cfSJeremy L Thompson
14477729cfSJeremy L Thompson CeedInit(argv[1], &ceed);
15477729cfSJeremy L Thompson
16477729cfSJeremy L Thompson // Check for standard message with default handler
17d1d35e2fSjeremylt CeedGetErrorMessage(ceed, &err_msg);
182b730f8bSJeremy L Thompson if (strcmp(err_msg, "No error message stored")) printf("Unexpected error message received: \"%s\"\n", err_msg);
19477729cfSJeremy L Thompson
20477729cfSJeremy L Thompson // Set error handler to store error message
21477729cfSJeremy L Thompson CeedSetErrorHandler(ceed, CeedErrorStore);
22477729cfSJeremy L Thompson
23477729cfSJeremy L Thompson // Generate error
24477729cfSJeremy L Thompson CeedVectorCreate(ceed, 10, &vec);
25477729cfSJeremy L Thompson CeedVectorGetArray(vec, CEED_MEM_HOST, &array);
26477729cfSJeremy L Thompson CeedVectorGetArray(vec, CEED_MEM_HOST, &array);
27477729cfSJeremy L Thompson
28477729cfSJeremy L Thompson // Check error message
29d1d35e2fSjeremylt CeedGetErrorMessage(ceed, &err_msg);
302b730f8bSJeremy L Thompson if (!err_msg || !strcmp(err_msg, "No error message stored\n")) printf("Unexpected error message received: \"%s\"\n", err_msg);
31d1d35e2fSjeremylt CeedResetErrorMessage(ceed, &err_msg);
32477729cfSJeremy L Thompson
33477729cfSJeremy L Thompson // Check error message reset
34d1d35e2fSjeremylt CeedGetErrorMessage(ceed, &err_msg);
352b730f8bSJeremy L Thompson if (strcmp(err_msg, "No error message stored")) printf("Unexpected error message received: \"%s\"\n", err_msg);
36477729cfSJeremy L Thompson
37477729cfSJeremy L Thompson // Cleanup
38477729cfSJeremy L Thompson CeedVectorRestoreArray(vec, &array);
39477729cfSJeremy L Thompson CeedVectorDestroy(&vec);
40477729cfSJeremy L Thompson CeedDestroy(&ceed);
41477729cfSJeremy L Thompson return 0;
42477729cfSJeremy L Thompson }
43