mirror of
https://github.com/partic2/libffi
synced 2026-11-11 10:37:19 +00:00
Merge pull request #144 from atrosinenko/testsuite-fp-comparison-fix
Floating point number comparison fix for testsuite
This commit is contained in:
@@ -63,7 +63,7 @@ int main (void)
|
|||||||
|
|
||||||
res = (((cls_ret_double)code))(0.1, 0.2, 0.3, 0.4, 5, 0.6, 0.7, 0.8, 0.9, 10,
|
res = (((cls_ret_double)code))(0.1, 0.2, 0.3, 0.4, 5, 0.6, 0.7, 0.8, 0.9, 10,
|
||||||
1.1, 12, 1.3, 14, 1.5, 16);
|
1.1, 12, 1.3, 14, 1.5, 16);
|
||||||
if (abs(res - expected) < FLT_EPSILON)
|
if (fabs(res - expected) < FLT_EPSILON)
|
||||||
exit(0);
|
exit(0);
|
||||||
else
|
else
|
||||||
abort();
|
abort();
|
||||||
|
|||||||
@@ -8,6 +8,8 @@
|
|||||||
#include "ffitest.h"
|
#include "ffitest.h"
|
||||||
#include "float.h"
|
#include "float.h"
|
||||||
|
|
||||||
|
#include <math.h>
|
||||||
|
|
||||||
typedef union
|
typedef union
|
||||||
{
|
{
|
||||||
double d;
|
double d;
|
||||||
@@ -47,7 +49,7 @@ int main (void)
|
|||||||
|
|
||||||
/* These are not always the same!! Check for a reasonable delta */
|
/* These are not always the same!! Check for a reasonable delta */
|
||||||
|
|
||||||
CHECK(result[0].d - dblit(f) < DBL_EPSILON);
|
CHECK(fabs(result[0].d - dblit(f)) < DBL_EPSILON);
|
||||||
|
|
||||||
/* Check the canary. */
|
/* Check the canary. */
|
||||||
for (i = 0; i < sizeof (double); ++i)
|
for (i = 0; i < sizeof (double); ++i)
|
||||||
|
|||||||
@@ -8,6 +8,8 @@
|
|||||||
#include "ffitest.h"
|
#include "ffitest.h"
|
||||||
#include "float.h"
|
#include "float.h"
|
||||||
|
|
||||||
|
#include <math.h>
|
||||||
|
|
||||||
static long double ldblit(float f)
|
static long double ldblit(float f)
|
||||||
{
|
{
|
||||||
return (long double) (((long double) f)/ (long double) 3.0);
|
return (long double) (((long double) f)/ (long double) 3.0);
|
||||||
@@ -47,7 +49,7 @@ int main (void)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* These are not always the same!! Check for a reasonable delta */
|
/* These are not always the same!! Check for a reasonable delta */
|
||||||
if (ld - ldblit(f) < LDBL_EPSILON)
|
if (fabsl(ld - ldblit(f)) < LDBL_EPSILON)
|
||||||
puts("long double return value tests ok!");
|
puts("long double return value tests ok!");
|
||||||
else
|
else
|
||||||
CHECK(0);
|
CHECK(0);
|
||||||
|
|||||||
@@ -9,6 +9,8 @@
|
|||||||
#include "ffitest.h"
|
#include "ffitest.h"
|
||||||
#include "float.h"
|
#include "float.h"
|
||||||
|
|
||||||
|
#include <math.h>
|
||||||
|
|
||||||
static double floating_1(float a, double b, long double c)
|
static double floating_1(float a, double b, long double c)
|
||||||
{
|
{
|
||||||
return (double) a + b + (double) c;
|
return (double) a + b + (double) c;
|
||||||
@@ -49,7 +51,7 @@ int main (void)
|
|||||||
|
|
||||||
ffi_call(&cif, FFI_FN(floating_1), &rd, values);
|
ffi_call(&cif, FFI_FN(floating_1), &rd, values);
|
||||||
|
|
||||||
CHECK(rd - floating_1(f, d, ld) < DBL_EPSILON);
|
CHECK(fabs(rd - floating_1(f, d, ld)) < DBL_EPSILON);
|
||||||
|
|
||||||
args[0] = &ffi_type_longdouble;
|
args[0] = &ffi_type_longdouble;
|
||||||
values[0] = &ld;
|
values[0] = &ld;
|
||||||
@@ -66,7 +68,7 @@ int main (void)
|
|||||||
|
|
||||||
ffi_call(&cif, FFI_FN(floating_2), &rd, values);
|
ffi_call(&cif, FFI_FN(floating_2), &rd, values);
|
||||||
|
|
||||||
CHECK(rd - floating_2(ld, d, f) < DBL_EPSILON);
|
CHECK(fabs(rd - floating_2(ld, d, f)) < DBL_EPSILON);
|
||||||
|
|
||||||
exit (0);
|
exit (0);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user