xref: /libCEED/tests/t115-vector.c (revision 49a40c8a2d720db341b0b117b89656b473cbebfb)
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   const CeedScalar *b;
14 
15   CeedInit(argv[1], &ceed);
16 
17   CeedVectorCreate(ceed, len, &x);
18   CeedVectorSetValue(x, 0.0);
19 
20   // Write access followed by read access should generate an error
21   CeedVectorGetArray(x, CEED_MEM_HOST, &a);
22   CeedVectorGetArrayRead(x, CEED_MEM_HOST, &b);
23 
24   // LCOV_EXCL_START
25   CeedVectorRestoreArray(x, &a);
26   CeedVectorRestoreArrayRead(x, &b);
27 
28   CeedVectorDestroy(&x);
29   CeedDestroy(&ceed);
30   return 0;
31   // LCOV_EXCL_STOP
32 }
33