xref: /libCEED/tests/t111-vector.c (revision e64bb3f3ed2986a0c10dec3b47522d734c6e367d)
1 /// @file
2 /// Test CeedVectorGetArray state counter
3 /// \test Test CeedVectorGetArray state counter
4 
5 //TESTARGS(name="length 10") {ceed_resource} 10
6 //TESTARGS(name="length 0") {ceed_resource} 0
7 #include <ceed.h>
8 #include <stdlib.h>
9 
10 int main(int argc, char **argv) {
11   Ceed        ceed;
12   CeedVector  x;
13   CeedInt     len = 10;
14   CeedScalar *a, b[len];
15 
16   CeedInit(argv[1], &ceed);
17   len = argc > 2 ? atoi(argv[2]) : len;
18 
19   CeedVectorCreate(ceed, len, &x);
20   CeedVectorSetValue(x, 0.0);
21 
22   // Two write accesses should generate an error
23   CeedVectorGetArray(x, CEED_MEM_HOST, &a);
24   CeedVectorSetArray(x, CEED_MEM_HOST, CEED_COPY_VALUES, b);
25 
26   // LCOV_EXCL_START
27   CeedVectorRestoreArray(x, &a);
28 
29   CeedVectorDestroy(&x);
30   CeedDestroy(&ceed);
31   return 0;
32   // LCOV_EXCL_STOP
33 }
34