diff options
author | Pedro Vicente Nunes <pvn@hdfgroup.org> | 2008-05-06 20:08:11 (GMT) |
---|---|---|
committer | Pedro Vicente Nunes <pvn@hdfgroup.org> | 2008-05-06 20:08:11 (GMT) |
commit | eb9ba954a5ed7200cc3d3c165c1ce630576c2a75 (patch) | |
tree | 541e05b8947a7415e06d32c29d643c8952f0fb06 /tools/h5dump/h5dumpgentest.c | |
parent | 41bf2001b12eb45be944d44dd99b56a5a15bfb92 (diff) | |
download | hdf5-eb9ba954a5ed7200cc3d3c165c1ce630576c2a75.zip hdf5-eb9ba954a5ed7200cc3d3c165c1ce630576c2a75.tar.gz hdf5-eb9ba954a5ed7200cc3d3c165c1ce630576c2a75.tar.bz2 |
[svn-r14948] 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 | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/tools/h5dump/h5dumpgentest.c b/tools/h5dump/h5dumpgentest.c index 4070425..270f2ee 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" + /*------------------------------------------------------------------------- @@ -6128,6 +6130,49 @@ out: } +/*------------------------------------------------------------------------- + * Function: gent_fpformat + * + * Purpose: Generate a file to be used in the floating point format test + * Contains: + * 1) a float dataset + * 2) 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 +6241,7 @@ int main(void) gent_hyperslab(); gent_group_creation_order(); gent_attr_creation_order(); + gent_fpformat(); return 0; |