summaryrefslogtreecommitdiffstats
path: root/tools/h5diff/h5diffgentest.c
diff options
context:
space:
mode:
authorPedro Vicente Nunes <pvn@hdfgroup.org>2006-11-27 20:10:53 (GMT)
committerPedro Vicente Nunes <pvn@hdfgroup.org>2006-11-27 20:10:53 (GMT)
commit124ef64faf9e3feecdc0d3d28967a222859f915d (patch)
treed3f37c6d74bbe73ac471dfda3e22bfceb3f6edfe /tools/h5diff/h5diffgentest.c
parent957a5082d12873eb4238a962ce0193adeac5a1dc (diff)
downloadhdf5-124ef64faf9e3feecdc0d3d28967a222859f915d.zip
hdf5-124ef64faf9e3feecdc0d3d28967a222859f915d.tar.gz
hdf5-124ef64faf9e3feecdc0d3d28967a222859f915d.tar.bz2
[svn-r12984]
Added a relative error formula to deal with floating point uncertainty in the comparison of floats and double types. Added new tests for this feature to the file generator program and to the shell script
Diffstat (limited to 'tools/h5diff/h5diffgentest.c')
-rw-r--r--tools/h5diff/h5diffgentest.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/tools/h5diff/h5diffgentest.c b/tools/h5diff/h5diffgentest.c
index ecce3c6..e7cff69 100644
--- a/tools/h5diff/h5diffgentest.c
+++ b/tools/h5diff/h5diffgentest.c
@@ -132,8 +132,8 @@ int test_basic(const char *fname1,
hsize_t dims[2] = { 3,2 };
/* Test */
- double data1[3][2] = {{1,1},{1,1},{1,1}};
- double data2[3][2] = {{1,1.1},{1.01,1.001},{1.0001,1}};
+ double data1[3][2] = {{1,1}, {1,1}, {0,0}};
+ double data2[3][2] = {{0,1.1},{1.01,1.001},{0,1}};
int data5[3][2] = {{100,100},{100,100},{100,100}};
int data6[3][2] = {{101,102},{103,104},{150,200}};
unsigned long_long data7[3][2] = {{100,100},{100,100},{100,100}};
@@ -154,6 +154,12 @@ A B 1-B/A %
100 50 0.5 50
*/
+ /* floating point comparison , epsilon = 0.00001 */
+ float data11[3][2] ={{0.00000f,0.00001f},{0.00001f, 0.00000f},{0.00001f,0.00001f}};
+ float data12[3][2] ={{0.00000f,0.00002f},{0.000009f,0.00001f},{0.00000f,0.00001f}};
+ double data13[3][2] ={{0.000000000,0.000000001},{0.000000001, 0.000000000},{0.000000001,0.000000001}};
+ double data14[3][2] ={{0.000000000,0.000000002},{0.0000000009,0.000000001},{0.000000000,0.000000001}};
+
/*-------------------------------------------------------------------------
* Create two files
*-------------------------------------------------------------------------
@@ -184,6 +190,12 @@ A B 1-B/A %
write_dset(gid1,2,dims,"dset9",H5T_NATIVE_DOUBLE,data9);
write_dset(gid1,2,dims,"dset10",H5T_NATIVE_DOUBLE,data10);
+ /* test floating point comparison */
+ write_dset(gid1,2,dims,"fp1",H5T_NATIVE_FLOAT,data11);
+ write_dset(gid1,2,dims,"fp2",H5T_NATIVE_FLOAT,data12);
+ write_dset(gid1,2,dims,"d1",H5T_NATIVE_DOUBLE,data13);
+ write_dset(gid1,2,dims,"d2",H5T_NATIVE_DOUBLE,data14);
+
/*-------------------------------------------------------------------------
* Close
*-------------------------------------------------------------------------