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