diff options
author | ryde <ryde@280ebfd0-de03-0410-8827-d642c229c3f4> | 2003-06-24 23:50:03 +0000 |
---|---|---|
committer | ryde <ryde@280ebfd0-de03-0410-8827-d642c229c3f4> | 2003-06-24 23:50:03 +0000 |
commit | 9299267f4dc820531b9527d81ff7eaf8411c8077 (patch) | |
tree | bd7733f248aa317b4bb157ed0856a9db9b5424db /tests/tget_d.c | |
parent | eee9b7369a0baeb9e80ecba372d13141a2466d4e (diff) | |
download | mpfr-9299267f4dc820531b9527d81ff7eaf8411c8077.tar.gz |
(check_inf_nan): New test.
git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@2366 280ebfd0-de03-0410-8827-d642c229c3f4
Diffstat (limited to 'tests/tget_d.c')
-rw-r--r-- | tests/tget_d.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/tests/tget_d.c b/tests/tget_d.c index a1dc1e0a4..5d40ac12f 100644 --- a/tests/tget_d.c +++ b/tests/tget_d.c @@ -72,6 +72,34 @@ check_denorms () return fail; } +static void +check_inf_nan () +{ + /* only if nans and infs are available */ +#if _GMP_IEEE_FLOATS + mpfr_t x; + double d; + + mpfr_init2 (x, 123); + + mpfr_set_inf (x, 1); + d = mpfr_get_d (x, GMP_RNDZ); + ASSERT_ALWAYS (d > 0); + ASSERT_ALWAYS (DOUBLE_ISINF (d)); + + mpfr_set_inf (x, -1); + d = mpfr_get_d (x, GMP_RNDZ); + ASSERT_ALWAYS (d < 0); + ASSERT_ALWAYS (DOUBLE_ISINF (d)); + + mpfr_set_nan (x); + d = mpfr_get_d (x, GMP_RNDZ); + ASSERT_ALWAYS (DOUBLE_ISNAN (d)); + + mpfr_clear (x); +#endif +} + int main (void) { @@ -81,6 +109,8 @@ main (void) if (check_denorms ()) exit (1); + check_inf_nan (); + tests_end_mpfr (); return 0; } |