diff options
-rw-r--r-- | tests/tadd1sp.c | 7 | ||||
-rw-r--r-- | tests/tests.c | 22 | ||||
-rw-r--r-- | tests/tset_exp.c | 7 | ||||
-rw-r--r-- | tests/tsubnormal.c | 24 |
4 files changed, 60 insertions, 0 deletions
diff --git a/tests/tadd1sp.c b/tests/tadd1sp.c index cf3beb8d5..5a81699a1 100644 --- a/tests/tadd1sp.c +++ b/tests/tadd1sp.c @@ -32,6 +32,10 @@ static void check_overflow (void) { mpfr_t x, y, z1, z2; + mp_exp_t emin, emax; + + emin = mpfr_get_emin (); + emax = mpfr_get_emax (); set_emin (-1021); set_emax (1024); @@ -48,6 +52,9 @@ check_overflow (void) exit (1); } mpfr_clears (x, y, z1, z2, (void *) 0); + + set_emin (emin); + set_emax (emax); } int main(void) diff --git a/tests/tests.c b/tests/tests.c index c60bb83eb..fc874f45c 100644 --- a/tests/tests.c +++ b/tests/tests.c @@ -85,6 +85,8 @@ set_fpu_prec (void) #endif +static mp_exp_t default_emin, default_emax; + static void tests_rand_start (void); static void tests_rand_end (void); static void tests_limit_start (void); @@ -117,14 +119,34 @@ tests_start_mpfr (void) tests_memory_start (); tests_rand_start (); tests_limit_start (); + + default_emin = mpfr_get_emin (); + default_emax = mpfr_get_emax (); } void tests_end_mpfr (void) { + int err = 0; + + if (mpfr_get_emin () != default_emin) + { + printf ("Default emin value has not been restored!\n"); + err = 1; + } + + if (mpfr_get_emax () != default_emax) + { + printf ("Default emax value has not been restored!\n"); + err = 1; + } + mpfr_free_cache (); tests_rand_end (); tests_memory_end (); + + if (err) + exit (err); } static void diff --git a/tests/tset_exp.c b/tests/tset_exp.c index 28e21457a..4e6a4cd32 100644 --- a/tests/tset_exp.c +++ b/tests/tset_exp.c @@ -30,9 +30,13 @@ main (int argc, char *argv[]) { mpfr_t x; int ret; + mp_exp_t emin, emax; tests_start_mpfr (); + emin = mpfr_get_emin (); + emax = mpfr_get_emax (); + mpfr_init (x); mpfr_set_ui (x, 1, GMP_RNDN); @@ -55,6 +59,9 @@ main (int argc, char *argv[]) mpfr_clear (x); + set_emin (emin); + set_emax (emax); + tests_end_mpfr (); return 0; } diff --git a/tests/tsubnormal.c b/tests/tsubnormal.c index 5e045bfa6..5e63312ea 100644 --- a/tests/tsubnormal.c +++ b/tests/tsubnormal.c @@ -55,6 +55,10 @@ check1 (void) { mpfr_t x; int i, j, k, s, old_inex; + mp_exp_t emin, emax; + + emin = mpfr_get_emin (); + emax = mpfr_get_emax (); mpfr_set_default_prec (9); mpfr_set_emin (-10); @@ -91,6 +95,12 @@ check1 (void) } } mpfr_clear (x); + + MPFR_ASSERTN (mpfr_get_emin () == -10); + MPFR_ASSERTN (mpfr_get_emax () == 10); + + set_emin (emin); + set_emax (emax); } /* bug found by Kevin P. Rauch on 22 Oct 2007 */ @@ -99,6 +109,9 @@ check2 (void) { mpfr_t x, y, z; int tern; + mp_exp_t emin; + + emin = mpfr_get_emin (); mpfr_init2 (x, 32); mpfr_init2 (y, 32); @@ -121,6 +134,10 @@ check2 (void) mpfr_clear (x); mpfr_clear (y); mpfr_clear (z); + + MPFR_ASSERTN (mpfr_get_emin () == -29); + + set_emin (emin); } /* bug found by Kevin P. Rauch on 22 Oct 2007 */ @@ -129,6 +146,9 @@ check3 (void) { mpfr_t x, y, z; int tern; + mp_exp_t emin; + + emin = mpfr_get_emin (); mpfr_init2 (x, 32); mpfr_init2 (y, 32); @@ -170,6 +190,10 @@ check3 (void) mpfr_clear (x); mpfr_clear (y); mpfr_clear (z); + + MPFR_ASSERTN (mpfr_get_emin () == -1); + + set_emin (emin); } int |