From 92ebcac7b471965a6890d40fc1c5b6ff31c16dad Mon Sep 17 00:00:00 2001 From: vlefevre Date: Sat, 6 Mar 2021 12:01:29 +0000 Subject: Added tests of mpfr_copysign, mpfr_setsign and mpfr_signbit macros. Without MPFR_USE_NO_MACRO, the compilation of these tests in tcopysign.c currently fails because some arguments are not converted to mpfr_srcptr. git-svn-id: https://scm.gforge.inria.fr/anonscm/svn/mpfr/trunk@14456 280ebfd0-de03-0410-8827-d642c229c3f4 --- tests/tcopysign.c | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) (limited to 'tests') diff --git a/tests/tcopysign.c b/tests/tcopysign.c index 354f6ad2d..a96250381 100644 --- a/tests/tcopysign.c +++ b/tests/tcopysign.c @@ -27,16 +27,17 @@ copysign_variant (mpfr_ptr z, mpfr_srcptr x, mpfr_srcptr y, mpfr_rnd_t rnd_mode, int k) { mpfr_srcptr p; + int a = 0, b = 0, c = 0; /* invalid sign, to test that the sign is always correctly set */ MPFR_SIGN (z) = 0; - if (k >= 6) + if (k >= 8) { MPFR_ASSERTN (MPFR_PREC (z) >= MPFR_PREC (x)); mpfr_set (z, x, MPFR_RNDN); p = z; - k -= 6; + k -= 8; } else p = x; @@ -51,17 +52,33 @@ copysign_variant (mpfr_ptr z, mpfr_srcptr x, mpfr_srcptr y, (mpfr_copysign) (z, p, y, rnd_mode); return; case 2: - mpfr_setsign (z, p, mpfr_signbit (y), rnd_mode); + mpfr_copysign ((a++, (void *) z), + (b++, (void *) p), + (c++, (void *) y), rnd_mode); + MPFR_ASSERTN (a == 1); + MPFR_ASSERTN (b == 1); + MPFR_ASSERTN (c == 1); return; case 3: - mpfr_setsign (z, p, (mpfr_signbit) (y), rnd_mode); + mpfr_setsign (z, p, mpfr_signbit (y), rnd_mode); return; case 4: - (mpfr_setsign) (z, p, mpfr_signbit (y), rnd_mode); + mpfr_setsign (z, p, (mpfr_signbit) (y), rnd_mode); return; case 5: + (mpfr_setsign) (z, p, mpfr_signbit (y), rnd_mode); + return; + case 6: (mpfr_setsign) (z, p, (mpfr_signbit) (y), rnd_mode); return; + case 7: + mpfr_setsign ((a++, (void *) z), + (b++, (void *) p), + mpfr_signbit ((c++, (void *) y)), rnd_mode); + MPFR_ASSERTN (a == 1); + MPFR_ASSERTN (b == 1); + MPFR_ASSERTN (c == 1); + return; } } @@ -79,7 +96,7 @@ main (void) for (i = 0; i <= 1; i++) for (j = 0; j <= 1; j++) - for (k = 0; k < 12; k++) + for (k = 0; k < 16; k++) { mpfr_set_nan (x); i ? MPFR_SET_NEG (x) : MPFR_SET_POS (x); -- cgit v1.2.1