about summary refs log tree commit diff
path: root/math/libm-test.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>1998-02-26 11:20:59 +0000
committerUlrich Drepper <drepper@redhat.com>1998-02-26 11:20:59 +0000
commitd111572f2f7c595060b9bafcadba98d5391d464c (patch)
tree6ede0af6714c7586d9f52caa90118ef6af4b21e0 /math/libm-test.c
parent14e9dd679a43ef9eb90adc0764152045caab6146 (diff)
downloadglibc-d111572f2f7c595060b9bafcadba98d5391d464c.tar.gz
glibc-d111572f2f7c595060b9bafcadba98d5391d464c.tar.xz
glibc-d111572f2f7c595060b9bafcadba98d5391d464c.zip
Update.
1998-02-26  Ulrich Drepper  <drepper@cygnus.com>

	* nis/ypclnt.c (yp_master): Check result of strdup.
	Patch by Thorsten Kukuk.

1998-02-26  Thorsten Kukuk  <kukuk@vt.uni-paderborn.de>

	* nis/ypclnt.c: Give clnt handle after error checking free, change
	return codes to fix problems with rpc.nisd in YP mode on Ultra's.

1998-02-26 09:00  Ulrich Drepper  <drepper@cygnus.com>

	* misc/fstab.c: Partly rewritten to use dynamically allocated buffer.
	Patch by Joe Keane <jgk@jgk.org>.

	* misc/fstab.h (struct fstab): Change fs_type member to be const.
	* misc/fstab.c: Remove casts in fs_type assignments.

1998-02-26  Andreas Jaeger  <aj@arthur.rhein-neckar.de>

	* sysdeps/i386/fpu/bits/fenv.h: Correct typo.  ISO C 9X defines
	FE_TOWARDZERO and not FE_TOWARDSZERO.  Reported by H.J. Lu.
	* sysdeps/sparc/sparc64/fpu/bits/fenv.h: Likewise.
	* sysdeps/sparc/sparc32/fpu/bits/fenv.h: Likewise.
	* sysdeps/powerpc/bits/fenv.h: Likewise.
	* sysdeps/m68k/fpu/bits/fenv.h: Likewise.
	* sysdeps/generic/bits/fenv.h: Likewise.
	* sysdeps/alpha/fpu/bits/fenv.h: Likewise.
	* sysdeps/i386/fpu/fesetenv.c (fesetenv): Likewise.
	* sysdeps/powerpc/test-arith.c (main): Likewise.

1998-02-25  Ulrich Drepper  <drepper@cygnus.com>

	* sysdeps/i386/fpu/bits/mathinline.h: Also fix i386 versions of
	the comparison macros.

1998-02-21 20:14  H.J. Lu  <hjl@gnu.org>

	* sysdeps/libm-ieee754/s_log2.c (ln2): Added.
	(__log2): Fixed return values.
	* sysdeps/libm-ieee754/s_log2f.c: Likewise.

1998-02-25  Ulrich Drepper  <drepper@cygnus.com>

	* math/math.h (isunordered): Rename local variables to ensure
	correct code.  Reported by HJ Lu.

1998-02-25 10:34  Ulrich Drepper  <drepper@cygnus.com>

	* sysdpes/i386/fpu/bits/mathinline.h (isgreater, isgreaterequal,
	isless, islessequal, islessgreater, isunordered): Fix syntax for
	fucompip instruction.
	(isless, islessequal): Fix logic.

1998-02-21  Andreas Jaeger  <aj@arthur.rhein-neckar.de>

	* math/libm-test.c (sqrt_test): Add test for sqrt(2).
	(comparisons_test): New tests for comparison macros.
Diffstat (limited to 'math/libm-test.c')
-rw-r--r--math/libm-test.c97
1 files changed, 95 insertions, 2 deletions
diff --git a/math/libm-test.c b/math/libm-test.c
index 7093fdcf14..e51bfe3eb6 100644
--- a/math/libm-test.c
+++ b/math/libm-test.c
@@ -46,6 +46,7 @@
    fabs, fdim, floor, fma, fmax, fmin, fmod, fpclassify,
    frexp, gamma, hypot,
    ilogb, isfinite, isinf, isnan, isnormal,
+   isless, islessequal, isgreater, isgreaterequal, islessgreater, isunordered,
    ldexp, lgamma, log, log10, log1p, log2, logb,
    modf, nearbyint, nextafter,
    pow, remainder, remquo, rint, lrint, llrint,
@@ -60,7 +61,7 @@
    conj, cproj, cimag, creal, drem,
    j0, j1, jn, y0, y1, yn,
    significand,
-   nan, comparison macros (isless,isgreater,...).
+   nan
 
    The routines using random variables are still under construction. I don't
    like it the way it's working now and will change it.
@@ -361,7 +362,7 @@ check_equal (MATHTYPE computed, MATHTYPE supplied, MATHTYPE eps, MATHTYPE * diff
   ret_value = (*diff <= eps &&
                (signbit (computed) == signbit (supplied) || eps != 0.0));
 
-  /* Make sure the subtraction/comparsion have no influence on the exceptions. */
+  /* Make sure the subtraction/comparison have no influence on the exceptions. */
   feclearexcept (FE_ALL_EXCEPT);
 
   return ret_value;
@@ -2458,6 +2459,7 @@ sqrt_test (void)
   x = random_value (0, 10000);
   check_ext ("sqrt (x*x) == x", FUNC(sqrt) (x*x), x, x);
   check ("sqrt (4) == 2", FUNC(sqrt) (4), 2);
+  check ("sqrt (2) == 1.14142...", FUNC(sqrt) (2), M_SQRT2l);
   check ("sqrt (0.25) == 0.5", FUNC(sqrt) (0.25), 0.5);
   check ("sqrt (6642.25) == 81.5", FUNC(sqrt) (6642.25), 81.5);
   check_eps ("sqrt (15239.903) == 123.45", FUNC(sqrt) (15239.903), 123.45,
@@ -5530,6 +5532,95 @@ fma_test (void)
 }
 
 
+/*
+  Tests for the comparison macros
+ */
+typedef enum {is_less, is_equal, is_greater, is_unordered} comp_result;
+
+
+static void
+comparison2_test (MATHTYPE x, MATHTYPE y, comp_result comp)
+{
+  char buf[255];
+  int result;
+  int expected;
+
+  expected = (comp == is_greater);
+  sprintf (buf, "isgreater (%" PRINTF_EXPR ", %" PRINTF_EXPR ") == %d", x, y,
+	   expected);
+  result = (isgreater (x, y) == expected);
+  check_bool (buf, result);
+
+  expected = (comp == is_greater || comp == is_equal);
+  sprintf (buf, "isgreaterequal (%" PRINTF_EXPR ", %" PRINTF_EXPR ") == %d", x, y,
+	   expected);
+  result = (isgreaterequal (x, y) == expected);
+  check_bool (buf, result);
+
+  expected = (comp == is_less);
+  sprintf (buf, "isless (%" PRINTF_EXPR ", %" PRINTF_EXPR ") == %d", x, y,
+	   expected);
+  result = (isless (x, y) == expected);
+  check_bool (buf, result);
+
+  expected = (comp == is_less || comp == is_equal);
+  sprintf (buf, "islessequal (%" PRINTF_EXPR ", %" PRINTF_EXPR ") == %d", x, y,
+	   expected);
+  result = (islessequal (x, y) == expected);
+  check_bool (buf, result);
+
+  expected = (comp == is_greater || comp == is_less);
+  sprintf (buf, "islessgreater (%" PRINTF_EXPR ", %" PRINTF_EXPR ") == %d", x, y,
+	   expected);
+  result = (islessgreater (x, y) == expected);
+  check_bool (buf, result);
+
+  expected = (comp == is_unordered);
+  sprintf (buf, "isunordered (%" PRINTF_EXPR ", %" PRINTF_EXPR ") == %d", x, y,
+	   expected);
+  result = (isunordered (x, y) == expected);
+  check_bool (buf, result);
+
+}
+
+
+static void
+comparison1_test (MATHTYPE x, MATHTYPE y, comp_result comp)
+{
+  comp_result comp_swap;
+  switch (comp)
+    {
+    case is_less:
+      comp_swap = is_greater;
+      break;
+    case is_greater:
+      comp_swap = is_less;
+      break;
+    default:
+      comp_swap = comp;
+      break;
+    }
+  comparison2_test (x, y, comp);
+  comparison2_test (y, x, comp_swap);
+}
+
+
+static void
+comparisons_test (void)
+{
+  comparison1_test (1, 2, is_less);
+  comparison1_test (-30, 30, is_less);
+  comparison1_test (42, 42, is_equal);
+  comparison1_test (1, plus_infty, is_less);
+  comparison1_test (35, minus_infty, is_greater);
+  comparison1_test (1, nan_value, is_unordered);
+  comparison1_test (nan_value, nan_value, is_unordered);
+  comparison1_test (plus_infty, nan_value, is_unordered);
+  comparison1_test (minus_infty, nan_value, is_unordered);
+  comparison1_test (plus_infty, minus_infty, is_greater);
+}
+
+
 static void
 inverse_func_pair_test (const char *test_name,
 			mathfunc f1, mathfunc inverse,
@@ -5838,6 +5929,8 @@ main (int argc, char *argv[])
   isnormal_test ();
   signbit_test ();
 
+  comparisons_test ();
+
   /* trigonometric functions */
   acos_test ();
   asin_test ();