File: read_ui8_test.c

package info (click to toggle)
hdf5-filter-plugin 0.0~git20221111.49e3b65-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 3,848 kB
  • sloc: ansic: 14,374; sh: 11,445; cpp: 1,463; makefile: 100; python: 19; xml: 6
file content (32 lines) | stat: -rw-r--r-- 639 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#include <hdf5.h>
#include <stdlib.h>

#define N 10
static const uint8_t ref_data[]={0,1,2,3,4,5,6,7,8,9};
static const char *fname="ui8_data.h5";


int main()
{
    hid_t fid = H5Fopen(fname,H5F_ACC_RDONLY,H5P_DEFAULT);
    if(fid<0) return 1;

    hid_t dset = H5Dopen(fid,"/data",H5P_DEFAULT);
    if(dset<0) return 1;
    
    uint8_t data[N];
    hid_t mem_type = H5Tcopy(H5T_NATIVE_UINT8);
    if(H5Dread(dset,mem_type,H5S_ALL,H5S_ALL,H5P_DEFAULT,(void*)(data))<0)
        return 1;
    
    size_t index;
    for(index=0;index<N;index++)
    {
        if(ref_data[index]!=data[index])
            return 1;
    }



    return 0;
}