about summary refs log tree commit diff
diff options
context:
space:
mode:
authorJoseph Myers <joseph@codesourcery.com>2013-11-29 16:28:47 +0000
committerJoseph Myers <joseph@codesourcery.com>2013-11-29 16:28:47 +0000
commit0712c9d861f4e861313a7f9fad06609bd1afb263 (patch)
treebb4970ef29798e1cb61bf75dcbb4c5eb7b9b3980
parentffb536d0ac914a110c160c48d01097d132e20531 (diff)
downloadglibc-0712c9d861f4e861313a7f9fad06609bd1afb263.tar.gz
glibc-0712c9d861f4e861313a7f9fad06609bd1afb263.tar.xz
glibc-0712c9d861f4e861313a7f9fad06609bd1afb263.zip
Test sqrt in all rounding modes.
-rw-r--r--ChangeLog10
-rw-r--r--math/libm-test.inc88
2 files changed, 98 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index 2f5b2766b0..faf1c8df28 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,15 @@
 2013-11-29  Joseph Myers  <joseph@codesourcery.com>
 
+	* math/libm-test.inc (sqrt_tonearest_test_data): New variable.
+	(sqrt_test_tonearest): New function.
+	(sqrt_towardzero_test_data): New variable.
+	(sqrt_test_towardzero): New function.
+	(sqrt_downward_test_data): New variable.
+	(sqrt_test_downward): New function.
+	(sqrt_upward_test_data): New variable.
+	(sqrt_test_upward): New function.
+	(main): Call the new functions.
+
 	* math/gen-auto-libm-tests.c: New file.
 	* math/auto-libm-test-in: Likewise.
 	* math/auto-libm-test-out: New generated file.
diff --git a/math/libm-test.inc b/math/libm-test.inc
index 017fa63122..7c599c101c 100644
--- a/math/libm-test.inc
+++ b/math/libm-test.inc
@@ -13770,6 +13770,90 @@ sqrt_test (void)
   END;
 }
 
+static const struct test_f_f_data sqrt_tonearest_test_data[] =
+  {
+    TEST_f_f (sqrt, qnan_value, qnan_value, NO_INEXACT_EXCEPTION),
+    TEST_f_f (sqrt, plus_infty, plus_infty, NO_INEXACT_EXCEPTION),
+
+    /* sqrt (x) == qNaN plus invalid exception for x < 0.  */
+    TEST_f_f (sqrt, -1, qnan_value, NO_INEXACT_EXCEPTION|INVALID_EXCEPTION|ERRNO_EDOM),
+    TEST_f_f (sqrt, -max_value, qnan_value, NO_INEXACT_EXCEPTION|INVALID_EXCEPTION|ERRNO_EDOM),
+    TEST_f_f (sqrt, minus_infty, qnan_value, NO_INEXACT_EXCEPTION|INVALID_EXCEPTION|ERRNO_EDOM),
+
+    AUTO_TESTS_f_f (sqrt, tonearest),
+  };
+
+static void
+sqrt_test_tonearest (void)
+{
+  START (sqrt_tonearest);
+  RUN_TEST_LOOP_f_f (sqrt, sqrt_tonearest_test_data, FE_TONEAREST);
+  END;
+}
+
+static const struct test_f_f_data sqrt_towardzero_test_data[] =
+  {
+    TEST_f_f (sqrt, qnan_value, qnan_value, NO_INEXACT_EXCEPTION),
+    TEST_f_f (sqrt, plus_infty, plus_infty, NO_INEXACT_EXCEPTION),
+
+    /* sqrt (x) == qNaN plus invalid exception for x < 0.  */
+    TEST_f_f (sqrt, -1, qnan_value, NO_INEXACT_EXCEPTION|INVALID_EXCEPTION|ERRNO_EDOM),
+    TEST_f_f (sqrt, -max_value, qnan_value, NO_INEXACT_EXCEPTION|INVALID_EXCEPTION|ERRNO_EDOM),
+    TEST_f_f (sqrt, minus_infty, qnan_value, NO_INEXACT_EXCEPTION|INVALID_EXCEPTION|ERRNO_EDOM),
+
+    AUTO_TESTS_f_f (sqrt, towardzero),
+  };
+
+static void
+sqrt_test_towardzero (void)
+{
+  START (sqrt_towardzero);
+  RUN_TEST_LOOP_f_f (sqrt, sqrt_towardzero_test_data, FE_TOWARDZERO);
+  END;
+}
+
+static const struct test_f_f_data sqrt_downward_test_data[] =
+  {
+    TEST_f_f (sqrt, qnan_value, qnan_value, NO_INEXACT_EXCEPTION),
+    TEST_f_f (sqrt, plus_infty, plus_infty, NO_INEXACT_EXCEPTION),
+
+    /* sqrt (x) == qNaN plus invalid exception for x < 0.  */
+    TEST_f_f (sqrt, -1, qnan_value, NO_INEXACT_EXCEPTION|INVALID_EXCEPTION|ERRNO_EDOM),
+    TEST_f_f (sqrt, -max_value, qnan_value, NO_INEXACT_EXCEPTION|INVALID_EXCEPTION|ERRNO_EDOM),
+    TEST_f_f (sqrt, minus_infty, qnan_value, NO_INEXACT_EXCEPTION|INVALID_EXCEPTION|ERRNO_EDOM),
+
+    AUTO_TESTS_f_f (sqrt, downward),
+  };
+
+static void
+sqrt_test_downward (void)
+{
+  START (sqrt_downward);
+  RUN_TEST_LOOP_f_f (sqrt, sqrt_downward_test_data, FE_DOWNWARD);
+  END;
+}
+
+static const struct test_f_f_data sqrt_upward_test_data[] =
+  {
+    TEST_f_f (sqrt, qnan_value, qnan_value, NO_INEXACT_EXCEPTION),
+    TEST_f_f (sqrt, plus_infty, plus_infty, NO_INEXACT_EXCEPTION),
+
+    /* sqrt (x) == qNaN plus invalid exception for x < 0.  */
+    TEST_f_f (sqrt, -1, qnan_value, NO_INEXACT_EXCEPTION|INVALID_EXCEPTION|ERRNO_EDOM),
+    TEST_f_f (sqrt, -max_value, qnan_value, NO_INEXACT_EXCEPTION|INVALID_EXCEPTION|ERRNO_EDOM),
+    TEST_f_f (sqrt, minus_infty, qnan_value, NO_INEXACT_EXCEPTION|INVALID_EXCEPTION|ERRNO_EDOM),
+
+    AUTO_TESTS_f_f (sqrt, upward),
+  };
+
+static void
+sqrt_test_upward (void)
+{
+  START (sqrt_upward);
+  RUN_TEST_LOOP_f_f (sqrt, sqrt_upward_test_data, FE_UPWARD);
+  END;
+}
+
 
 static const struct test_f_f_data tan_test_data[] =
   {
@@ -15089,6 +15173,10 @@ main (int argc, char **argv)
   pow_test_downward ();
   pow_test_upward ();
   sqrt_test ();
+  sqrt_test_tonearest ();
+  sqrt_test_towardzero ();
+  sqrt_test_downward ();
+  sqrt_test_upward ();
 
   /* Error and gamma functions:  */
   erf_test ();