From ba2286a9a930ea571a2b2e717b982635f04bfdbd Mon Sep 17 00:00:00 2001 From: Andrew Bachmann Date: Wed, 18 May 2005 20:45:02 +0000 Subject: [PATCH] add test for drem, expand testing for and supress table output for copysign, drem git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@12721 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- .../kernel/libroot/posix/math/math_test.cpp | 40 +++++++++++++++---- 1 file changed, 33 insertions(+), 7 deletions(-) diff --git a/src/tests/kernel/libroot/posix/math/math_test.cpp b/src/tests/kernel/libroot/posix/math/math_test.cpp index c6b4d40178..f926a4af42 100644 --- a/src/tests/kernel/libroot/posix/math/math_test.cpp +++ b/src/tests/kernel/libroot/posix/math/math_test.cpp @@ -45,10 +45,12 @@ main(int argc, char **argv) fprintf(stdout, "value\tsin(value)\tbe_sin(value)\n"); for (int i = -9 ; i <= 9 ; i++) { double f = (double)i; - fprintf(stdout, "%0.1f\t%0.10f\t%0.10f\n", f, sin(f), be_sin(f)); + fprintf(stdout, "%0.1f\t%0.10f\t%0.10f", f, sin(f), be_sin(f)); if (sin(f) != be_sin(f)) { + fprintf(stdout, " **"); result = B_ERROR; } + fprintf(stdout, "\n"); } fprintf(stdout, "\n"); @@ -56,27 +58,51 @@ main(int argc, char **argv) // test cos for (int i = -9 ; i <= 9 ; i++) { double f = (double)i; - fprintf(stdout, "%0.1f\t%0.10f\t%0.10f\n", f, cos(f), be_cos(f)); + fprintf(stdout, "%0.1f\t%0.10f\t%0.10f", f, cos(f), be_cos(f)); if (cos(f) != be_cos(f)) { + fprintf(stdout, " **"); result = B_ERROR; } + fprintf(stdout, "\n"); } fprintf(stdout, "\n"); fprintf(stdout, "arg1\targ2\tcopysign()\tbe_copysign()\n"); // test copysign - for (int i = -2 ; i <= 2 ; i++) { - for (int j = -2 ; j <= 2 ; j++) { + for (int i = -9 ; i <= 9 ; i++) { + for (int j = -9 ; j <= 9 ; j++) { double f = (double)i; double g = (double)j; - fprintf(stdout, "%0.1f\t%0.1f\t%0.10f\t%0.10f\n", - f, g, copysign(f, g), be_copysign(f, g)); - if (copysign(f, g) != be_copysign(f, g)) { + double x = copysign(f, g); + double y = be_copysign(f, g); + if ((x != y) && !(isnan(x) && isnan(y))) { + fprintf(stdout, "%0.1f\t%0.1f\t%0.6f\t%0.6f", f, g, x, y); + fprintf(stdout, " **"); + fprintf(stdout, "\n"); result = B_ERROR; } } } fprintf(stdout, "\n"); + fprintf(stdout, "arg1\targ2\tdrem(values)\tbe_drem(values)\n"); + // test drem + for (int i = -21 ; i <= 21 ; i++) { + for (int j = -36 ; j <= 36 ; j++) { + double f = (double)i/3.0; + double g = (double)j/4.0; + double x = drem(f, g); + double y = be_drem(f, g); + if ((x != y) && !(isnan(x) && isnan(y))) { + fprintf(stdout, "%0.2f\t%0.2f\t%0.10f\t%0.10f", f, g, x, y); + fprintf(stdout, " **"); + fprintf(stdout, "\n"); + result = B_ERROR; + } + } + } + fprintf(stdout, "\n"); + + fprintf(stdout, "result = %s\n", (result == B_OK ? "OK" : "ERROR")); return result; }