summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorPatrick Lu <ptlu@hawkwind.ncsa.uiuc.edu>2000-05-31 17:36:38 (GMT)
committerPatrick Lu <ptlu@hawkwind.ncsa.uiuc.edu>2000-05-31 17:36:38 (GMT)
commit8130eaff8febf2b27a52b24f31cc92004aa4f677 (patch)
treea36696f1159d7753429b7a2bbe9ababe9114279c /tools
parent71b68698a82d39f88337efda067d47cce62a7551 (diff)
downloadhdf5-8130eaff8febf2b27a52b24f31cc92004aa4f677.zip
hdf5-8130eaff8febf2b27a52b24f31cc92004aa4f677.tar.gz
hdf5-8130eaff8febf2b27a52b24f31cc92004aa4f677.tar.bz2
[svn-r2313] added a function to create the bitfields test file.
taken from the dset test file
Diffstat (limited to 'tools')
-rw-r--r--tools/h5dumptst.c48
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;
}