xref: /libCEED/tests/t120-vector.c (revision 2eb0be0b68ebb7cb25cc038250732c3239325ad2)
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   CeedSize len;
21   CeedVectorGetLength(x_2, &len);  // Second reference still valid
22   if (len != n) printf("Error copying CeedVector reference\n");
23 
24   CeedVectorDestroy(&x_2);
25   CeedDestroy(&ceed);
26   return 0;
27 }
28