diff options
author | Pedro Vicente Nunes <pvn@hdfgroup.org> | 2008-05-05 20:06:22 (GMT) |
---|---|---|
committer | Pedro Vicente Nunes <pvn@hdfgroup.org> | 2008-05-05 20:06:22 (GMT) |
commit | 26d880217ba085053abb0e26be737b6eb35e6c96 (patch) | |
tree | a08dcbd55bfcb18cb46152e1d99527e66f2fc312 /tools/h5dump/h5dumpgentest.c | |
parent | 5bd2405c11837865b6d7c54e30933dbc0b43c938 (diff) | |
download | hdf5-26d880217ba085053abb0e26be737b6eb35e6c96.zip hdf5-26d880217ba085053abb0e26be737b6eb35e6c96.tar.gz hdf5-26d880217ba085053abb0e26be737b6eb35e6c96.tar.bz2 |
[svn-r14934] Add a test for the floating point user defined printf format
Usage is
-m T, --format=T
Where T - is a string containing the floating point format, e.g '%.3f'
The test consists of writing a number with 7 fractional digits (default precision display of %f is 6 digits) and have the 7 digits displayed with
-m %.7f fpformat.h5
Tested: windows, linux, solaris
Note: the output file was generated in linux, it may be possible that platforms other than the ones tested have a different representation of the number
Diffstat (limited to 'tools/h5dump/h5dumpgentest.c')
-rw-r--r-- | tools/h5dump/h5dumpgentest.c | 51 |
1 files changed, 49 insertions, 2 deletions
diff --git a/tools/h5dump/h5dumpgentest.c b/tools/h5dump/h5dumpgentest.c index 4070425..54b22df 100644 --- a/tools/h5dump/h5dumpgentest.c +++ b/tools/h5dump/h5dumpgentest.c @@ -87,6 +87,8 @@ #define FILE57 "thyperslab.h5" #define FILE58 "tordergr.h5" #define FILE59 "torderattr.h5" +#define FILE60 "tfpformat.h5" + /*------------------------------------------------------------------------- @@ -5542,14 +5544,14 @@ error: * Contains: * 1) an integer dataset * 2) a float dataset - * 4) a double dataset + * 3) a double dataset * *------------------------------------------------------------------------- */ static void gent_binary(void) { - hid_t fid, sid, did, tid; + hid_t fid, sid, did; hsize_t dims[1] = {6}; int ibuf[6] = {1,2,3,4,5,6}; float fbuf[6] = {1,2,3,4,5,6}; @@ -6128,6 +6130,50 @@ out: } +/*------------------------------------------------------------------------- + * Function: gent_fpformat + * + * Purpose: Generate a file to be used in the floating point format test + * Contains: + * 2) a float dataset + * 4) a double dataset + * + *------------------------------------------------------------------------- + */ +static void +gent_fpformat(void) +{ + hid_t fid, sid, did; + hsize_t dims[1] = {6}; + double dbuf[6] = {-0.1234567, 0.1234567, 0, 0, 0, 0}; + float fbuf[6] = {-0.1234567f, 0.1234567f, 0, 0, 0, 0}; + + fid = H5Fcreate(FILE60, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + sid = H5Screate_simple(1, dims, NULL); + +/*------------------------------------------------------------------------- + * double + *------------------------------------------------------------------------- + */ + did = H5Dcreate2(fid, "double", H5T_NATIVE_DOUBLE, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + H5Dwrite(did, H5T_NATIVE_DOUBLE, H5S_ALL, H5S_ALL, H5P_DEFAULT, dbuf); + H5Dclose(did); + + +/*------------------------------------------------------------------------- + * float + *------------------------------------------------------------------------- + */ + did = H5Dcreate2(fid, "float", H5T_NATIVE_FLOAT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + H5Dwrite(did, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL, H5P_DEFAULT, fbuf); + H5Dclose(did); + + + /* close */ + H5Sclose(sid); + H5Fclose(fid); +} + /*------------------------------------------------------------------------- * Function: main @@ -6196,6 +6242,7 @@ int main(void) gent_hyperslab(); gent_group_creation_order(); gent_attr_creation_order(); + gent_fpformat(); return 0; |