xref: /libCEED/tests/t118-vector.c (revision 22070f9510d4ff69aa6119a59aa3c46d57cc1cc7)
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 sync array should generate an error
20   CeedVectorGetArray(x, CEED_MEM_HOST, &a);
21   CeedVectorSyncArray(x, CEED_MEM_HOST);
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