diff options
Diffstat (limited to 'tools')
-rwxr-xr-x | tools/h5diff/testh5diff.sh | 2 | ||||
-rw-r--r-- | tools/lib/h5diff_array.c | 41 | ||||
-rw-r--r-- | tools/testfiles/h5diff_16_2.txt | 16 |
3 files changed, 37 insertions, 22 deletions
diff --git a/tools/h5diff/testh5diff.sh b/tools/h5diff/testh5diff.sh index d71ea78..a44a4c1 100755 --- a/tools/h5diff/testh5diff.sh +++ b/tools/h5diff/testh5diff.sh @@ -290,7 +290,7 @@ TOOLTEST h5diff_15.txt $FILE1 $FILE2 -r -d 5 g1/dset3 g1/dset4 TOOLTEST h5diff_16_1.txt $FILE1 $FILE1 -v -p 0.02 g1/dset5 g1/dset6 # 1.6.2 with -p (unsigned long_long) -#TOOLTEST h5diff_16_2.txt $FILE1 $FILE1 -v -p 0.02 g1/dset7 g1/dset8 +TOOLTEST h5diff_16_2.txt $FILE1 $FILE1 -v -p 0.02 g1/dset7 g1/dset8 # 1.6.3 with -p (double) TOOLTEST h5diff_16_3.txt $FILE1 $FILE1 -v -p 0.02 g1/dset9 g1/dset10 diff --git a/tools/lib/h5diff_array.c b/tools/lib/h5diff_array.c index 242cae7..a01aefe 100644 --- a/tools/lib/h5diff_array.c +++ b/tools/lib/h5diff_array.c @@ -60,7 +60,6 @@ static hbool_t equal_float(float value, float expected); static hbool_t equal_double(double value, double expected); - /*------------------------------------------------------------------------- * -p relative error formula * @@ -90,13 +89,13 @@ static int not_comparable; } -#define PER_UNSIGN(A,B) { per=-1; \ +#define PER_UNSIGN(TYPE,A,B) { per=-1; \ not_comparable=0; \ both_zero=0; \ if (A==0 && B==0) \ both_zero=1; \ if (A!=0) \ - per = (double) (B-A) / (double)A ; \ + per = ABS((double)((TYPE)(B-A)) / (double)A) ; \ else \ not_comparable=1; \ } @@ -946,7 +945,7 @@ hsize_t diff_datum(void *_mem1, /* !-d and -p */ else if (!options->d && options->p) { - PER_UNSIGN(temp1_uchar,temp2_uchar); + PER_UNSIGN(signed char,temp1_uchar,temp2_uchar); if (not_comparable && !both_zero) /* not comparable */ { @@ -976,7 +975,7 @@ hsize_t diff_datum(void *_mem1, /* -d and -p */ else if ( options->d && options->p) { - PER_UNSIGN(temp1_uchar,temp2_uchar); + PER_UNSIGN(signed char,temp1_uchar,temp2_uchar); if (not_comparable && !both_zero) /* not comparable */ { @@ -1149,7 +1148,7 @@ hsize_t diff_datum(void *_mem1, /* !-d and -p */ else if (!options->d && options->p) { - PER_UNSIGN(temp1_ushort,temp2_ushort); + PER_UNSIGN(signed short,temp1_ushort,temp2_ushort); if (not_comparable && !both_zero) /* not comparable */ { @@ -1180,7 +1179,7 @@ hsize_t diff_datum(void *_mem1, /* -d and -p */ else if ( options->d && options->p) { - PER_UNSIGN(temp1_ushort,temp2_ushort); + PER_UNSIGN(signed short,temp1_ushort,temp2_ushort); if (not_comparable && !both_zero) /* not comparable */ { @@ -1350,7 +1349,7 @@ hsize_t diff_datum(void *_mem1, /* !-d and -p */ else if (!options->d && options->p) { - PER_UNSIGN(temp1_uint,temp2_uint); + PER_UNSIGN(signed int,temp1_uint,temp2_uint); if (not_comparable && !both_zero) /* not comparable */ { @@ -1380,7 +1379,7 @@ hsize_t diff_datum(void *_mem1, /* -d and -p */ else if ( options->d && options->p) { - PER_UNSIGN(temp1_uint,temp2_uint); + PER_UNSIGN(signed int,temp1_uint,temp2_uint); if (not_comparable && !both_zero) /* not comparable */ { @@ -1552,7 +1551,7 @@ hsize_t diff_datum(void *_mem1, /* !-d and -p */ else if (!options->d && options->p) { - PER_UNSIGN(temp1_ulong,temp2_ulong); + PER_UNSIGN(signed long,temp1_ulong,temp2_ulong); if (not_comparable && !both_zero) /* not comparable */ { @@ -1582,7 +1581,7 @@ hsize_t diff_datum(void *_mem1, /* -d and -p */ else if ( options->d && options->p) { - PER_UNSIGN(temp1_ulong,temp2_ulong); + PER_UNSIGN(signed long,temp1_ulong,temp2_ulong); if (not_comparable && !both_zero) /* not comparable */ { @@ -2459,7 +2458,7 @@ hsize_t character_compare_opt(unsigned char *mem1, /* !-d and -p */ else if (!options->d && options->p) { - PER_UNSIGN(temp1_uchar,temp2_uchar); + PER_UNSIGN(signed char,temp1_uchar,temp2_uchar); if ( per > options->percent ) { if ( print_data(options) ) @@ -2474,7 +2473,7 @@ hsize_t character_compare_opt(unsigned char *mem1, /* -d and -p */ else if ( options->d && options->p) { - PER_UNSIGN(temp1_uchar,temp2_uchar); + PER_UNSIGN(signed char,temp1_uchar,temp2_uchar); if ( per > options->percent && PDIFF(temp1_uchar,temp2_uchar) > options->delta ) { if ( print_data(options) ) @@ -3100,7 +3099,7 @@ hsize_t diff_uchar(unsigned char *mem1, memcpy(&temp1_uchar, mem1, sizeof(unsigned char)); memcpy(&temp2_uchar, mem2, sizeof(unsigned char)); - PER_UNSIGN(temp1_uchar,temp2_uchar); + PER_UNSIGN(signed char,temp1_uchar,temp2_uchar); if (not_comparable && !both_zero) /* not comparable */ { @@ -3145,7 +3144,7 @@ hsize_t diff_uchar(unsigned char *mem1, memcpy(&temp1_uchar, mem1, sizeof(unsigned char)); memcpy(&temp2_uchar, mem2, sizeof(unsigned char)); - PER_UNSIGN(temp1_uchar,temp2_uchar); + PER_UNSIGN(signed char,temp1_uchar,temp2_uchar); if (not_comparable && !both_zero) /* not comparable */ { @@ -3457,7 +3456,7 @@ hsize_t diff_ushort(unsigned char *mem1, memcpy(&temp1_ushort, mem1, sizeof(unsigned short)); memcpy(&temp2_ushort, mem2, sizeof(unsigned short)); - PER_UNSIGN(temp1_ushort,temp2_ushort); + PER_UNSIGN(signed short,temp1_ushort,temp2_ushort); if (not_comparable && !both_zero) /* not comparable */ { @@ -3504,7 +3503,7 @@ hsize_t diff_ushort(unsigned char *mem1, memcpy(&temp1_ushort, mem1, sizeof(unsigned short)); memcpy(&temp2_ushort, mem2, sizeof(unsigned short)); - PER_UNSIGN(temp1_ushort,temp2_ushort); + PER_UNSIGN(signed short,temp1_ushort,temp2_ushort); if (not_comparable && !both_zero) /* not comparable */ { @@ -3819,7 +3818,7 @@ hsize_t diff_uint(unsigned char *mem1, memcpy(&temp1_uint, mem1, sizeof(unsigned int)); memcpy(&temp2_uint, mem2, sizeof(unsigned int)); - PER_UNSIGN(temp1_uint,temp2_uint); + PER_UNSIGN(signed int,temp1_uint,temp2_uint); if (not_comparable && !both_zero) /* not comparable */ { @@ -3865,7 +3864,7 @@ hsize_t diff_uint(unsigned char *mem1, memcpy(&temp1_uint, mem1, sizeof(unsigned int)); memcpy(&temp2_uint, mem2, sizeof(unsigned int)); - PER_UNSIGN(temp1_uint,temp2_uint); + PER_UNSIGN(signed int,temp1_uint,temp2_uint); if (not_comparable && !both_zero) /* not comparable */ { @@ -4189,7 +4188,7 @@ hsize_t diff_ulong(unsigned char *mem1, memcpy(&temp1_ulong, mem1, sizeof(unsigned long)); memcpy(&temp2_ulong, mem2, sizeof(unsigned long)); - PER_UNSIGN(temp1_ulong,temp2_ulong); + PER_UNSIGN(signed long,temp1_ulong,temp2_ulong); if (not_comparable && !both_zero) /* not comparable */ { @@ -4235,7 +4234,7 @@ hsize_t diff_ulong(unsigned char *mem1, memcpy(&temp1_ulong, mem1, sizeof(unsigned long)); memcpy(&temp2_ulong, mem2, sizeof(unsigned long)); - PER_UNSIGN(temp1_ulong,temp2_ulong); + PER_UNSIGN(signed long,temp1_ulong,temp2_ulong); if (not_comparable && !both_zero) /* not comparable */ { diff --git a/tools/testfiles/h5diff_16_2.txt b/tools/testfiles/h5diff_16_2.txt new file mode 100644 index 0000000..02bc972 --- /dev/null +++ b/tools/testfiles/h5diff_16_2.txt @@ -0,0 +1,16 @@ +############################# +Expected output for 'h5diff h5diff_basic1.h5 h5diff_basic1.h5 -v -p 0.02 g1/dset7 g1/dset8' +############################# +dataset: </g1/dset7> and </g1/dset8> +size: [3x2] [3x2] +position dset7 dset8 difference relative +------------------------------------------------------------------------ +[ 0 0 ] 100 120 20 0.200000 +[ 0 1 ] 100 80 20 0.200000 +[ 1 0 ] 100 0 100 1.000000 +[ 1 1 ] 0 100 100 not comparable +[ 2 1 ] 100 50 50 0.500000 +5 differences found +-------------------------------- +Some objects are not comparable +-------------------------------- |