diff options
-rw-r--r-- | tests/tset_z.c | 58 |
1 files changed, 31 insertions, 27 deletions
diff --git a/tests/tset_z.c b/tests/tset_z.c index 4921c0b57..519f7067b 100644 --- a/tests/tset_z.c +++ b/tests/tset_z.c @@ -28,48 +28,52 @@ MA 02111-1307, USA. */ #include "mpfr-test.h" -/* FIXME: 1000000 random runs of check() is excessive. - - FIXME: It'd be better to examine the actual data in an mpfr_t to see that +/* FIXME: It'd be better to examine the actual data in an mpfr_t to see that it's as expected. Comparing mpfr_set_z with mpfr_cmp or against mpfr_get_si is a rather indirect test of a low level routine. */ static void -check(long i, unsigned char rnd) +check (long i, unsigned char rnd) { - mpfr_t f; mpz_t z; + mpfr_t f; + mpz_t z; - mpfr_init2(f, 8*sizeof(long)); mpz_init(z); - mpz_set_ui(z, i); - mpfr_set_z(f, z, rnd); + mpfr_init2 (f, 8 * sizeof(long)); + mpz_init (z); + mpz_set_ui (z, i); + mpfr_set_z (f, z, rnd); if (mpfr_get_si (f, GMP_RNDZ) != i) { - printf("Error in mpfr_set_z for i=%ld rnd_mode=%d\n",i,rnd); - exit(1); + fprintf (stderr, "Error in mpfr_set_z for i=%ld rnd_mode=%d\n", i, rnd); + exit (1); } - mpfr_clear(f); mpz_clear(z); + mpfr_clear (f); + mpz_clear (z); } static void check_large (void) { - mpz_t z; mpfr_t x,y; - - mpz_init(z); mpfr_init2(x, 160); mpfr_init2(y, 160); - mpz_set_str(z, "77031627725494291259359895954016675357279104942148788042", 10); - mpfr_set_z(x, z, GMP_RNDN); - mpfr_set_str_raw(y, "0.1100100100001111110110101010001000100001011010001100001000110100110001001100011001100010100010111000000011011100000111001101000100101001000000100100111000001001E186"); - if (mpfr_cmp(x,y)) + mpz_t z; + mpfr_t x, y; + + mpz_init (z); + mpfr_init2 (x, 160); + mpfr_init2 (y, 160); + mpz_set_str (z, "77031627725494291259359895954016675357279104942148788042", 10); + mpfr_set_z (x, z, GMP_RNDN); + mpfr_set_str_raw (y, "0.1100100100001111110110101010001000100001011010001100001000110100110001001100011001100010100010111000000011011100000111001101000100101001000000100100111000001001E186"); + if (mpfr_cmp (x, y)) { - fprintf(stderr, "Error in mpfr_set_z on large input\n"); - exit(1); + fprintf (stderr, "Error in mpfr_set_z on large input\n"); + exit (1); } - mpz_clear(z); mpfr_clear(x); mpfr_clear(y); + mpz_clear (z); + mpfr_clear (x); + mpfr_clear (y); } -/* tset_z z rnd prec */ - int main (int argc, char *argv[]) { @@ -77,10 +81,10 @@ main (int argc, char *argv[]) tests_start_mpfr (); - check_large(); - check(0, 0); - for (j=0; j<1000000; j++) - check(randlimb () & LONG_MAX, randlimb () % 4); + check_large (); + check (0, 0); + for (j = 0; j < 500000; j++) + check (randlimb () & LONG_MAX, randlimb () % 4); tests_end_mpfr (); return 0; |