xref: /libCEED/tests/t002-ceed.c (revision 1d0137909cd290d677dbca28a6953e6505c9d054)
1 /// @file
2 /// Test return of a CEED object full resource name
3 /// \test Test return of a CEED object full resource name
4 #include <string.h>
5 #include <ceed.h>
6 
7 int main(int argc, char **argv) {
8   Ceed ceed;
9   const char *backend = argv[1];
10   const char *resource;
11 
12   CeedInit(backend, &ceed);
13 
14   CeedGetResource(ceed, &resource);
15 
16   const size_t resourceLength = strlen(resource);
17   const bool isExactMatch = strcmp(resource, backend) == 0;
18   const bool isMatchWithQueryArguments = (
19       !isExactMatch
20       && memcmp(resource, backend, resourceLength) == 0
21       && backend[resourceLength] == ':'
22                                          );
23 
24   if (!isExactMatch && !isMatchWithQueryArguments) {
25     // LCOV_EXCL_START
26     return CeedError(ceed, 1, "Incorrect full resource name: %s != %s",
27                      resource, backend);
28     // LCOV_EXCL_STOP
29   }
30 
31   CeedDestroy(&ceed);
32   return 0;
33 }
34