xref: /libCEED/tests/t009-ceed.c (revision 69f5adf13c38b25ccc4fa9a9f050d7775cff5bb5)
1 /// @file
2 /// Test creation, copying, and destruction of a CEED object
3 /// \test Test creation, copying, and destruction of a CEED object
4 #include <ceed.h>
5 
6 int main(int argc, char **argv) {
7   Ceed ceed, ceed_2;
8 
9   CeedInit(argv[1], &ceed);
10   CeedInit("/cpu/self/ref/serial", &ceed_2);
11 
12   CeedReferenceCopy(ceed, &ceed_2); // This destroys the previous ceed_2
13   if (ceed != ceed_2)
14     // LCOV_EXCL_START
15     printf("Error copying Ceed reference.");
16   // LCOV_EXCL_STOP
17 
18   CeedDestroy(&ceed);
19 
20   CeedMemType type;
21   CeedGetPreferredMemType(ceed_2, &type); // Second reference still valid
22 
23   CeedDestroy(&ceed_2); // Both references should be destroyed
24   return 0;
25 }
26