diff options
author | Patrick Lu <ptlu@hawkwind.ncsa.uiuc.edu> | 2000-05-31 16:22:38 (GMT) |
---|---|---|
committer | Patrick Lu <ptlu@hawkwind.ncsa.uiuc.edu> | 2000-05-31 16:22:38 (GMT) |
commit | 0264342a3ef88bdd03eae699963ef0dafc5ea71c (patch) | |
tree | 24d83ef05cacd5217d234476b1dbc8c598f703f3 | |
parent | cee9fa8a0ef879797c4673ffb05aae7d74528018 (diff) | |
download | hdf5-0264342a3ef88bdd03eae699963ef0dafc5ea71c.zip hdf5-0264342a3ef88bdd03eae699963ef0dafc5ea71c.tar.gz hdf5-0264342a3ef88bdd03eae699963ef0dafc5ea71c.tar.bz2 |
[svn-r2308] added a funtion to create a bitfields test file. just used the code from the dataset
test file
-rw-r--r-- | tools/h5dumptst.c | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/tools/h5dumptst.c b/tools/h5dumptst.c index 97c5c08..25d9ec2 100644 --- a/tools/h5dumptst.c +++ b/tools/h5dumptst.c @@ -24,6 +24,7 @@ #define FILE17 "tdatareg.h5" #define FILE18 "tnestedcomp.h5" #define FILE19 "topaque.h5" +#define FILE20 "tbitfields.h5" #define LENSTR 50 #define LENSTR2 11 @@ -1723,6 +1724,52 @@ void test_opaque(){ } +void test_bitfields(){ + hid_t file, grp=-1, type=-1, space=-1, dset=-1; + size_t i; + hsize_t nelmts; + unsigned char buf[32]; + + file = H5Fcreate(FILE20, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + + if ((grp=H5Gcreate(file, "typetests", 0))<0) goto error; + + /* bitfield_1 */ + nelmts = sizeof(buf); + if ((type=H5Tcopy(H5T_STD_B8LE))<0 || + (space=H5Screate_simple(1, &nelmts, NULL))<0 || + (dset=H5Dcreate(grp, "bitfield_1", type, space, H5P_DEFAULT))<0) + goto error; + for (i=0; i<sizeof buf; i++) buf[i] = (unsigned char)0xff ^ (unsigned char)i; + if (H5Dwrite(dset, type, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf)<0) + goto error; + if (H5Sclose(space)<0) goto error; + if (H5Tclose(type)<0) goto error; + if (H5Dclose(dset)<0) goto error; + + /* bitfield_2 */ + nelmts = sizeof(buf)/2; + if ((type=H5Tcopy(H5T_STD_B16LE))<0 || + (space=H5Screate_simple(1, &nelmts, NULL))<0 || + (dset=H5Dcreate(grp, "bitfield_2", type, space, H5P_DEFAULT))<0) + goto error; + for (i=0; i<sizeof buf; i++) buf[i] = (unsigned char)0xff ^ (unsigned char)i; + if (H5Dwrite(dset, type, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf)<0) + goto error; + if (H5Sclose(space)<0) goto error; + if (H5Tclose(type)<0) goto error; + if (H5Dclose(dset)<0) goto error; + if (H5Gclose(grp)<0) goto error; + H5Fclose(file); + + error: + H5E_BEGIN_TRY { + H5Gclose(grp); + H5Tclose(type); + H5Sclose(space); + H5Dclose(dset); + } H5E_END_TRY; +} int main(void){ @@ -1751,6 +1798,7 @@ test_datareg(); test_nestcomp(); test_opaque(); +test_bitfields(); return 0; } |