1 /// @file 2 /// Test creation, reference copying, and destroying of a vector 3 /// \test Test creation, reference copying, and destroying of a vector 4 5 //TESTARGS(name="length 10") {ceed_resource} 10 6 //TESTARGS(name="length 0") {ceed_resource} 0 7 #include <ceed.h> 8 #include <stdio.h> 9 #include <stdlib.h> 10 11 int main(int argc, char **argv) { 12 Ceed ceed; 13 CeedVector x, x_2; 14 CeedInt len = 10; 15 16 CeedInit(argv[1], &ceed); 17 len = argc > 2 ? atoi(argv[2]) : len; 18 19 CeedVectorCreate(ceed, len, &x); 20 CeedVectorCreate(ceed, len + 1, &x_2); 21 22 CeedVectorReferenceCopy(x, &x_2); // This destroys the previous x_2 23 CeedVectorDestroy(&x); 24 25 { 26 CeedSize len_2; 27 28 CeedVectorGetLength(x_2, &len_2); // Second reference still valid 29 if (len_2 != len) printf("Error copying CeedVector reference\n"); 30 } 31 32 CeedVectorDestroy(&x_2); 33 CeedDestroy(&ceed); 34 return 0; 35 } 36