Add generated C file changes to test patch
The C test files generated by autogen are not included in the upstream repository but are in the source tarball.
This commit is contained in:
parent
42e624c5ec
commit
a4822eb066
@ -73,3 +73,88 @@ index c68e3a26e..0d1cd8bb9 100644
|
|||||||
exit (1) ;
|
exit (1) ;
|
||||||
} ;
|
} ;
|
||||||
|
|
||||||
|
diff --git a/tests/utils.c b/tests/utils.c
|
||||||
|
index c239606..b1adf29 100644
|
||||||
|
--- a/tests/utils.c
|
||||||
|
+++ b/tests/utils.c
|
||||||
|
@@ -43,6 +43,7 @@
|
||||||
|
#include <string.h>
|
||||||
|
#include <ctype.h>
|
||||||
|
#include <math.h>
|
||||||
|
+#include <float.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
|
||||||
|
@@ -66,6 +67,28 @@
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
+/*
|
||||||
|
+** Compare for equality, with epsilon
|
||||||
|
+*/
|
||||||
|
+static inline int
|
||||||
|
+equals_short (const short a, const short b)
|
||||||
|
+{ return (a == b);
|
||||||
|
+} /* equals_short */
|
||||||
|
+static inline int
|
||||||
|
+equals_int (const int a, const int b)
|
||||||
|
+{ return (a == b);
|
||||||
|
+} /* equals_int */
|
||||||
|
+static inline int
|
||||||
|
+equals_float (const float a, const float b)
|
||||||
|
+{ return (fabsf(a - b) <= FLT_EPSILON);
|
||||||
|
+} /* equals_float */
|
||||||
|
+static inline int
|
||||||
|
+equals_double (const double a, const double b)
|
||||||
|
+{ return (fabs(a - b) <= DBL_EPSILON);
|
||||||
|
+} /* equals_double */
|
||||||
|
+
|
||||||
|
+
|
||||||
|
+
|
||||||
|
void
|
||||||
|
gen_windowed_sine_float (float *data, int len, double maximum)
|
||||||
|
{ int k ;
|
||||||
|
@@ -958,8 +981,8 @@ compare_short_or_die (const short *expected, const short *actual, unsigned count
|
||||||
|
unsigned k ;
|
||||||
|
|
||||||
|
for (k = 0 ; k < count ; k++)
|
||||||
|
- if (expected [k] != actual [k])
|
||||||
|
- { printf ("\n\nLine %d : Error at index %d, got " "% d" ", should be " "% d" ".\n\n", line_num, k, actual [k], expected [k]) ;
|
||||||
|
+ if (!equals_short(expected [k], actual [k]))
|
||||||
|
+ { printf ("\n\nLine %d : Error at index %d, got " "% d" ", should be " "% d" "(delta=" "% d" " ).\n\n", line_num, k, actual [k], expected [k], actual [k] - expected [k]) ;
|
||||||
|
exit (1) ;
|
||||||
|
} ;
|
||||||
|
|
||||||
|
@@ -971,8 +994,8 @@ compare_int_or_die (const int *expected, const int *actual, unsigned count, int
|
||||||
|
unsigned k ;
|
||||||
|
|
||||||
|
for (k = 0 ; k < count ; k++)
|
||||||
|
- if (expected [k] != actual [k])
|
||||||
|
- { printf ("\n\nLine %d : Error at index %d, got " "% d" ", should be " "% d" ".\n\n", line_num, k, actual [k], expected [k]) ;
|
||||||
|
+ if (!equals_int(expected [k], actual [k]))
|
||||||
|
+ { printf ("\n\nLine %d : Error at index %d, got " "% d" ", should be " "% d" "(delta=" "% d" " ).\n\n", line_num, k, actual [k], expected [k], actual [k] - expected [k]) ;
|
||||||
|
exit (1) ;
|
||||||
|
} ;
|
||||||
|
|
||||||
|
@@ -984,8 +1007,8 @@ compare_float_or_die (const float *expected, const float *actual, unsigned count
|
||||||
|
unsigned k ;
|
||||||
|
|
||||||
|
for (k = 0 ; k < count ; k++)
|
||||||
|
- if (expected [k] != actual [k])
|
||||||
|
- { printf ("\n\nLine %d : Error at index %d, got " "% g" ", should be " "% g" ".\n\n", line_num, k, actual [k], expected [k]) ;
|
||||||
|
+ if (!equals_float(expected [k], actual [k]))
|
||||||
|
+ { printf ("\n\nLine %d : Error at index %d, got " "% g" ", should be " "% g" "(delta=" "% g" " ).\n\n", line_num, k, actual [k], expected [k], actual [k] - expected [k]) ;
|
||||||
|
exit (1) ;
|
||||||
|
} ;
|
||||||
|
|
||||||
|
@@ -997,8 +1020,8 @@ compare_double_or_die (const double *expected, const double *actual, unsigned co
|
||||||
|
unsigned k ;
|
||||||
|
|
||||||
|
for (k = 0 ; k < count ; k++)
|
||||||
|
- if (expected [k] != actual [k])
|
||||||
|
- { printf ("\n\nLine %d : Error at index %d, got " "% g" ", should be " "% g" ".\n\n", line_num, k, actual [k], expected [k]) ;
|
||||||
|
+ if (!equals_double(expected [k], actual [k]))
|
||||||
|
+ { printf ("\n\nLine %d : Error at index %d, got " "% g" ", should be " "% g" "(delta=" "% g" " ).\n\n", line_num, k, actual [k], expected [k], actual [k] - expected [k]) ;
|
||||||
|
exit (1) ;
|
||||||
|
} ;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user