diff options
author | vlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4> | 2021-03-06 09:27:48 +0000 |
---|---|---|
committer | vlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4> | 2021-03-06 09:27:48 +0000 |
commit | 5d47175159cf0fab533f689edbe50e1d66e0456a (patch) | |
tree | 85f78923d5ef67b6a9f52a0990721971d2dd3ff2 | |
parent | 19c04d5f86f52f8a815f9f0a66995e10f5d51723 (diff) | |
download | mpfr-5d47175159cf0fab533f689edbe50e1d66e0456a.tar.gz |
[tests/tisnan.c] Check that when mpfr_nan_p, mpfr_inf_p, mpfr_number_p,
mpfr_zero_p and mpfr_regular_p is implemented as a macro, it behaves
like a function.
git-svn-id: https://scm.gforge.inria.fr/anonscm/svn/mpfr/trunk@14448 280ebfd0-de03-0410-8827-d642c229c3f4
-rw-r--r-- | tests/tisnan.c | 96 |
1 files changed, 66 insertions, 30 deletions
diff --git a/tests/tisnan.c b/tests/tisnan.c index 72908b1ea..ebad85887 100644 --- a/tests/tisnan.c +++ b/tests/tisnan.c @@ -27,6 +27,12 @@ int main (void) { mpfr_t x; + int i = 0, j = 0; + + /* We need to check that when the function is implemented by a macro, + it behaves correctly. */ +#define ARG (i++, (void *) x) +#define CHECK MPFR_ASSERTN (i == ++j) tests_start_mpfr (); @@ -35,172 +41,202 @@ main (void) /* check +infinity gives non-zero for mpfr_inf_p only */ mpfr_set_ui (x, 1L, MPFR_RNDZ); mpfr_div_ui (x, x, 0L, MPFR_RNDZ); - if (mpfr_nan_p (x) || (mpfr_nan_p) (x) ) + if (mpfr_nan_p (x) || (mpfr_nan_p) (x) || mpfr_nan_p (ARG)) { printf ("Error: mpfr_nan_p(+Inf) gives non-zero\n"); exit (1); } - if (mpfr_inf_p (x) == 0) + CHECK; + if (!mpfr_inf_p (x) || !(mpfr_inf_p) (x) || !mpfr_inf_p (ARG)) { printf ("Error: mpfr_inf_p(+Inf) gives zero\n"); exit (1); } - if (mpfr_number_p (x) || (mpfr_number_p) (x) ) + CHECK; + if (mpfr_number_p (x) || (mpfr_number_p) (x) || mpfr_number_p (ARG)) { printf ("Error: mpfr_number_p(+Inf) gives non-zero\n"); exit (1); } - if (mpfr_zero_p (x) || (mpfr_zero_p) (x) ) + CHECK; + if (mpfr_zero_p (x) || (mpfr_zero_p) (x) || mpfr_zero_p (ARG)) { printf ("Error: mpfr_zero_p(+Inf) gives non-zero\n"); exit (1); } - if (mpfr_regular_p (x) || (mpfr_regular_p) (x) ) + CHECK; + if (mpfr_regular_p (x) || (mpfr_regular_p) (x) || mpfr_regular_p (ARG)) { printf ("Error: mpfr_regular_p(+Inf) gives non-zero\n"); exit (1); } + CHECK; /* same for -Inf */ mpfr_neg (x, x, MPFR_RNDN); - if (mpfr_nan_p (x) || (mpfr_nan_p(x))) + if (mpfr_nan_p (x) || (mpfr_nan_p) (x) || mpfr_nan_p (ARG)) { printf ("Error: mpfr_nan_p(-Inf) gives non-zero\n"); exit (1); } - if (mpfr_inf_p (x) == 0) + CHECK; + if (!mpfr_inf_p (x) || !(mpfr_inf_p) (x) || !mpfr_inf_p (ARG)) { printf ("Error: mpfr_inf_p(-Inf) gives zero\n"); exit (1); } - if (mpfr_number_p (x) || (mpfr_number_p)(x) ) + CHECK; + if (mpfr_number_p (x) || (mpfr_number_p) (x) || mpfr_number_p (ARG)) { printf ("Error: mpfr_number_p(-Inf) gives non-zero\n"); exit (1); } - if (mpfr_zero_p (x) || (mpfr_zero_p)(x) ) + CHECK; + if (mpfr_zero_p (x) || (mpfr_zero_p) (x) || mpfr_zero_p (ARG)) { printf ("Error: mpfr_zero_p(-Inf) gives non-zero\n"); exit (1); } - if (mpfr_regular_p (x) || (mpfr_regular_p) (x) ) + CHECK; + if (mpfr_regular_p (x) || (mpfr_regular_p) (x) || mpfr_regular_p (ARG)) { printf ("Error: mpfr_regular_p(-Inf) gives non-zero\n"); exit (1); } + CHECK; /* same for NaN */ mpfr_sub (x, x, x, MPFR_RNDN); - if (mpfr_nan_p (x) == 0) + if (!mpfr_nan_p (x) || !(mpfr_nan_p) (x) || !mpfr_nan_p (ARG)) { printf ("Error: mpfr_nan_p(NaN) gives zero\n"); exit (1); } - if (mpfr_inf_p (x) || (mpfr_inf_p)(x) ) + CHECK; + if (mpfr_inf_p (x) || (mpfr_inf_p) (x) || mpfr_inf_p (ARG)) { printf ("Error: mpfr_inf_p(NaN) gives non-zero\n"); exit (1); } - if (mpfr_number_p (x) || (mpfr_number_p) (x) ) + CHECK; + if (mpfr_number_p (x) || (mpfr_number_p) (x) || mpfr_number_p (ARG)) { printf ("Error: mpfr_number_p(NaN) gives non-zero\n"); exit (1); } - if (mpfr_zero_p (x) || (mpfr_zero_p)(x) ) + CHECK; + if (mpfr_zero_p (x) || (mpfr_zero_p) (x) || mpfr_zero_p (ARG)) { printf ("Error: mpfr_number_p(NaN) gives non-zero\n"); exit (1); } - if (mpfr_regular_p (x) || (mpfr_regular_p) (x) ) + CHECK; + if (mpfr_regular_p (x) || (mpfr_regular_p) (x) || mpfr_regular_p (ARG)) { printf ("Error: mpfr_regular_p(NaN) gives non-zero\n"); exit (1); } + CHECK; /* same for a regular number */ mpfr_set_ui (x, 1, MPFR_RNDN); - if (mpfr_nan_p (x) || (mpfr_nan_p)(x)) + if (mpfr_nan_p (x) || (mpfr_nan_p) (x) || mpfr_nan_p (ARG)) { printf ("Error: mpfr_nan_p(1) gives non-zero\n"); exit (1); } - if (mpfr_inf_p (x) || (mpfr_inf_p)(x) ) + CHECK; + if (mpfr_inf_p (x) || (mpfr_inf_p) (x) || mpfr_inf_p (ARG)) { printf ("Error: mpfr_inf_p(1) gives non-zero\n"); exit (1); } - if (mpfr_number_p (x) == 0) + CHECK; + if (!mpfr_number_p (x) || !(mpfr_number_p) (x) || !mpfr_number_p (ARG)) { printf ("Error: mpfr_number_p(1) gives zero\n"); exit (1); } - if (mpfr_zero_p (x) || (mpfr_zero_p) (x) ) + CHECK; + if (mpfr_zero_p (x) || (mpfr_zero_p) (x) || mpfr_zero_p (ARG)) { printf ("Error: mpfr_zero_p(1) gives non-zero\n"); exit (1); } - if (mpfr_regular_p (x) == 0 || (mpfr_regular_p) (x) == 0) + CHECK; + if (!mpfr_regular_p (x) || !(mpfr_regular_p) (x) || !mpfr_regular_p (ARG)) { printf ("Error: mpfr_regular_p(1) gives zero\n"); exit (1); } + CHECK; /* Same for +0 */ mpfr_set_ui (x, 0, MPFR_RNDN); - if (mpfr_nan_p (x) || (mpfr_nan_p)(x)) + if (mpfr_nan_p (x) || (mpfr_nan_p) (x) || mpfr_nan_p (ARG)) { printf ("Error: mpfr_nan_p(+0) gives non-zero\n"); exit (1); } - if (mpfr_inf_p (x) || (mpfr_inf_p)(x) ) + CHECK; + if (mpfr_inf_p (x) || (mpfr_inf_p) (x) || mpfr_inf_p (ARG)) { printf ("Error: mpfr_inf_p(+0) gives non-zero\n"); exit (1); } - if (mpfr_number_p (x) == 0) + CHECK; + if (!mpfr_number_p (x) || !(mpfr_number_p) (x) || !mpfr_number_p (ARG)) { printf ("Error: mpfr_number_p(+0) gives zero\n"); exit (1); } - if (mpfr_zero_p (x) == 0 ) + CHECK; + if (!mpfr_zero_p (x) || !(mpfr_zero_p) (x) || !mpfr_zero_p (ARG)) { printf ("Error: mpfr_zero_p(+0) gives zero\n"); exit (1); } - if (mpfr_regular_p (x) || (mpfr_regular_p) (x) ) + CHECK; + if (mpfr_regular_p (x) || (mpfr_regular_p) (x) || mpfr_regular_p (ARG)) { printf ("Error: mpfr_regular_p(+0) gives non-zero\n"); exit (1); } + CHECK; /* Same for -0 */ mpfr_set_ui (x, 0, MPFR_RNDN); mpfr_neg (x, x, MPFR_RNDN); - if (mpfr_nan_p (x) || (mpfr_nan_p)(x)) + if (mpfr_nan_p (x) || (mpfr_nan_p) (x) || mpfr_nan_p (ARG)) { printf ("Error: mpfr_nan_p(-0) gives non-zero\n"); exit (1); } - if (mpfr_inf_p (x) || (mpfr_inf_p)(x) ) + CHECK; + if (mpfr_inf_p (x) || (mpfr_inf_p) (x) || mpfr_inf_p (ARG)) { printf ("Error: mpfr_inf_p(-0) gives non-zero\n"); exit (1); } - if (mpfr_number_p (x) == 0) + CHECK; + if (!mpfr_number_p (x) || !(mpfr_number_p) (x) || !mpfr_number_p (ARG)) { printf ("Error: mpfr_number_p(-0) gives zero\n"); exit (1); } - if (mpfr_zero_p (x) == 0 ) + CHECK; + if (!mpfr_zero_p (x) || !(mpfr_zero_p) (x) || !mpfr_zero_p (ARG)) { printf ("Error: mpfr_zero_p(-0) gives zero\n"); exit (1); } - if (mpfr_regular_p (x) || (mpfr_regular_p) (x) ) + CHECK; + if (mpfr_regular_p (x) || (mpfr_regular_p) (x) || mpfr_regular_p (ARG)) { printf ("Error: mpfr_regular_p(-0) gives non-zero\n"); exit (1); } + CHECK; mpfr_clear (x); |