xref: /libCEED/tests/t112-vector.c (revision aa67b84255fd38cedae0f40d1566f643808af2e9)
1 /// @file
2 /// Test CeedVectorGetArray state counter
3 /// \test Test CeedVectorGetArray state counter
4 
5 //TESTARGS(only="cpu") {ceed_resource}
6 #include <ceed.h>
7 
8 int main(int argc, char **argv) {
9   Ceed        ceed;
10   CeedVector  x;
11   CeedInt     len = 10;
12   CeedScalar *a;
13 
14   CeedInit(argv[1], &ceed);
15 
16   CeedVectorCreate(ceed, len, &x);
17   CeedVectorSetValue(x, 0.0);
18 
19   // Write access followed by set value should generate an error
20   CeedVectorGetArray(x, CEED_MEM_HOST, &a);
21   CeedVectorSetValue(x, 1.0);
22 
23   // LCOV_EXCL_START
24   CeedVectorRestoreArray(x, &a);
25 
26   CeedVectorDestroy(&x);
27   CeedDestroy(&ceed);
28   return 0;
29   // LCOV_EXCL_STOP
30 }
31