From b004a76a473b6e3406c0645ff394f407f57309e8 Mon Sep 17 00:00:00 2001 From: Albert Cheng Date: Wed, 30 Jun 1999 13:08:14 -0500 Subject: [svn-r1394] Changes made by Patrick to the h5dumptst.c in testfiles. --- tools/h5dumptst.c | 300 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 300 insertions(+) diff --git a/tools/h5dumptst.c b/tools/h5dumptst.c index 2ffcb3e..e97677a 100644 --- a/tools/h5dumptst.c +++ b/tools/h5dumptst.c @@ -19,8 +19,40 @@ #define FILE12 "tmany.h5" #define FILE13 "tstr.h5" #define FILE14 "tstr2.h5" +#define FILE15 "enum.h5" +#define FILE16 "objref.h5" +#define FILE17 "datareg.h5" #define LENSTR 50 #define LENSTR2 11 + +#define SPACE2_RANK 2 +#define SPACE2_DIM1 10 +#define SPACE2_DIM2 10 + +#define SPACE1_RANK 1 +#define SPACE1_DIM1 4 + + +/* Element selection information */ +#define POINT1_NPOINTS 10 + + +typedef enum{ + RED, + GREEN, + BLUE, + WHITE, + BLACK, +} enumtype; + +/* Compound datatype */ +typedef struct s1_t { + unsigned int a; + unsigned int b; + float c; +} s1_t; + + static void test_group(void) { hid_t fid, group; @@ -1227,6 +1259,270 @@ hsize_t sdim, maxdim; } + +void test_enum(){ +/*some code is taken from enum.c in the test dir */ + hid_t file, type, space, dset; + int val; + signed char val8; + enumtype data[] = {RED, GREEN, BLUE, GREEN, WHITE, + WHITE, BLACK, GREEN, BLUE, RED, + RED, BLUE, GREEN, BLACK, WHITE, + RED, WHITE, GREEN, GREEN, BLUE}; + hsize_t size[1] = {NELMTS(data)}; + + file = H5Fcreate(FILE15,H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + + + type = H5Tcreate(H5T_ENUM, sizeof(enumtype)); + H5Tenum_insert(type, "RED", (val = 0, &val)); + H5Tenum_insert(type, "GREEN", (val = 1, &val)); + H5Tenum_insert(type, "BLUE", (val = 2, &val)); + H5Tenum_insert(type, "WHITE", (val = 3, &val)); + H5Tenum_insert(type, "BLACK", (val = 4, &val)); + H5Tcommit(file, "enum normal", type); + + space = H5Screate_simple(1,size,NULL); + dset = H5Dcreate(file,"table",type, space, H5P_DEFAULT); + H5Dwrite(dset,type,space,space,H5P_DEFAULT,data); + + H5Dclose(dset); + H5Sclose(space); + H5Fclose(file); +} + + + +void test_objref(){ +/*some code is taken from enum.c in the test dir */ + hid_t fid1; /* HDF5 File IDs */ + hid_t dataset, /* Dataset ID */ + dset2; /* Dereferenced dataset ID */ + hid_t group; /* Group ID */ + hid_t sid1; /* Dataspace ID */ + hid_t tid1; /* Datatype ID */ + hsize_t dims1[] = {SPACE1_DIM1}; + hobj_ref_t *wbuf, /* buffer to write to disk */ + *rbuf, /* buffer read from disk */ + *tbuf; /* temp. buffer read from disk */ + uint32_t *tu32; /* Temporary pointer to uint32 data */ + intn i; /* counting variables */ + const char *write_comment="Foo!"; /* Comments for group */ + char read_comment[10]; + herr_t ret; /* Generic return value */ + + + /* Allocate write & read buffers */ + wbuf=malloc(sizeof(hobj_ref_t)*SPACE1_DIM1); + rbuf=malloc(sizeof(hobj_ref_t)*SPACE1_DIM1); + tbuf=malloc(sizeof(hobj_ref_t)*SPACE1_DIM1); + + /* Create file */ + fid1 = H5Fcreate(FILE16, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + + /* Create dataspace for datasets */ + sid1 = H5Screate_simple(SPACE1_RANK, dims1, NULL); + + /* Create a group */ + group=H5Gcreate(fid1,"Group1",-1); + + /* Set group's comment */ + ret=H5Gset_comment(group,".",write_comment); + + /* Create a dataset (inside Group1) */ + dataset=H5Dcreate(group,"Dataset1",H5T_STD_U32LE,sid1,H5P_DEFAULT); + + for(tu32=(uint32_t *)wbuf,i=0; i