xref: /libCEED/tests/t120-vector.c (revision 6a6224a1a47cd78a9f5d31ac282da39a8c250ecc)
1 /// @file
2 /// Test creation, copying, and destroying of a vector
3 /// \test Test creation, copying, and destroying of a vector
4 #include <ceed.h>
5 
6 int main(int argc, char **argv) {
7   Ceed ceed;
8   CeedVector x, x_2;
9   CeedInt n;
10 
11   CeedInit(argv[1], &ceed);
12 
13   n = 10;
14   CeedVectorCreate(ceed, n, &x);
15   CeedVectorCreate(ceed, n+1, &x_2);
16 
17   CeedVectorReferenceCopy(x, &x_2); // This destroys the previous x_2
18   CeedVectorDestroy(&x);
19 
20   CeedInt len;
21   CeedVectorGetLength(x_2, &len); // Second reference still valid
22   if (len != n)
23     // LCOV_EXCL_START
24     printf("Error copying CeedVector reference.");
25   // LCOV_EXCL_STOP
26 
27   CeedVectorDestroy(&x_2);
28   CeedDestroy(&ceed);
29   return 0;
30 }
31