diff options
author | Patrick Lu <ptlu@hawkwind.ncsa.uiuc.edu> | 1999-06-25 19:25:52 (GMT) |
---|---|---|
committer | Patrick Lu <ptlu@hawkwind.ncsa.uiuc.edu> | 1999-06-25 19:25:52 (GMT) |
commit | 78f622071f1199581775479811b5d730d14f0779 (patch) | |
tree | 480cf8ce64be7bb934d784770c0df5a4d9046ba7 | |
parent | b1a4689964444db1bf1febbb9936a298cb2f312f (diff) | |
download | hdf5-78f622071f1199581775479811b5d730d14f0779.zip hdf5-78f622071f1199581775479811b5d730d14f0779.tar.gz hdf5-78f622071f1199581775479811b5d730d14f0779.tar.bz2 |
[svn-r1384]
added a function to create an enum test file
-rw-r--r-- | tools/testfiles/h5dumptst.c | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/tools/testfiles/h5dumptst.c b/tools/testfiles/h5dumptst.c index 2ffcb3e..207fbb4 100644 --- a/tools/testfiles/h5dumptst.c +++ b/tools/testfiles/h5dumptst.c @@ -19,8 +19,18 @@ #define FILE12 "tmany.h5" #define FILE13 "tstr.h5" #define FILE14 "tstr2.h5" +#define FILE15 "enum.h5" #define LENSTR 50 #define LENSTR2 11 + +typedef enum{ + RED, + GREEN, + BLUE, + WHITE, + BLACK, +} enumtype; + static void test_group(void) { hid_t fid, group; @@ -1227,6 +1237,38 @@ hsize_t sdim, maxdim; } + +void test_enum(){ +/*this 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); +} + int main(void){ test_group(); @@ -1246,6 +1288,7 @@ test_many(); test_str(); test_str2(); +test_enum(); return 0; } |