Debian Codegraph @

BZIP2/test/read_ui8_test.c

raw
1 #include <hdf5.h>
2 #include <stdlib.h>
3
4 #define N 10
5 static const uint8_t ref_data[]={0,1,2,3,4,5,6,7,8,9};
6 static const char *fname="ui8_data.h5";
7
8
9 int main()
10 {
11 hid_t fid = H5Fopen(fname,H5F_ACC_RDONLY,H5P_DEFAULT);
12 if(fid<0) return 1;
13
14 hid_t dset = H5Dopen(fid,"/data",H5P_DEFAULT);
15 if(dset<0) return 1;
16
17 uint8_t data[N];
18 hid_t mem_type = H5Tcopy(H5T_NATIVE_UINT8);
19 if(H5Dread(dset,mem_type,H5S_ALL,H5S_ALL,H5P_DEFAULT,(void*)(data))<0)
20 return 1;
21
22 size_t index;
23 for(index=0;index<N;index++)
24 {
25 if(ref_data[index]!=data[index])
26 return 1;
27 }
28
29
30
31 return 0;
32 }