summaryrefslogtreecommitdiff
path: root/tests/texceptions.c
diff options
context:
space:
mode:
authorpelissip <pelissip@280ebfd0-de03-0410-8827-d642c229c3f4>2004-11-19 12:39:10 +0000
committerpelissip <pelissip@280ebfd0-de03-0410-8827-d642c229c3f4>2004-11-19 12:39:10 +0000
commit38c77249c6671159c0c7e40a73f1f5a3bc76dc8e (patch)
treefd12f35cf4b230dfcccf5eaf65a216f3ba0cdca7 /tests/texceptions.c
parent68d7536264604dfa93c6540d11fd292e6e14e3ff (diff)
downloadmpfr-38c77249c6671159c0c7e40a73f1f5a3bc76dc8e.tar.gz
Improve coverage tests.
git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@3107 280ebfd0-de03-0410-8827-d642c229c3f4
Diffstat (limited to 'tests/texceptions.c')
-rw-r--r--tests/texceptions.c44
1 files changed, 42 insertions, 2 deletions
diff --git a/tests/texceptions.c b/tests/texceptions.c
index 1ff15158f..138253479 100644
--- a/tests/texceptions.c
+++ b/tests/texceptions.c
@@ -26,6 +26,20 @@ MA 02111-1307, USA. */
#define ERROR(s) do { printf(s); exit(1); } while(0)
+/* Test powerof2 */
+static void
+check_powerof2 (void)
+{
+ mpfr_t x;
+
+ mpfr_init (x);
+ mpfr_set_ui (x, 1, GMP_RNDN);
+ MPFR_ASSERTN (mpfr_powerof2_raw (x));
+ mpfr_set_ui (x, 3, GMP_RNDN);
+ MPFR_ASSERTN (!mpfr_powerof2_raw (x));
+ mpfr_clear (x);
+}
+
/* Test default rounding mode */
static void
check_default_rnd (void)
@@ -34,7 +48,7 @@ check_default_rnd (void)
for(r = 0 ; r < GMP_RND_MAX ; r++)
{
mpfr_set_default_rounding_mode (r);
- t = mpfr_get_default_rounding_mode();
+ t = (mpfr_get_default_rounding_mode) ();
if (r !=t)
ERROR("ERROR in setting / getting default rounding mode (1)\n");
}
@@ -63,12 +77,37 @@ check_emin_emax (void)
ERROR("get_emax FAILED!");
if ((mpfr_set_emax)(MPFR_EMAX_MAX+1) == 0)
ERROR("set_emax failed! (2)");
+
+ if ((mpfr_get_emin_min) () != MPFR_EMIN_MIN)
+ ERROR ("get_emin_min");
+ if ((mpfr_get_emin_max) () != MPFR_EMIN_MAX)
+ ERROR ("get_emin_max");
+ if ((mpfr_get_emax_min) () != MPFR_EMAX_MIN)
+ ERROR ("get_emax_min");
+ if ((mpfr_get_emax_max) () != MPFR_EMAX_MAX)
+ ERROR ("get_emax_max");
+}
+
+static void
+check_set_get_prec (void)
+{
+ mpfr_t x;
+
+ mpfr_init2 (x, 17);
+ if (mpfr_get_prec (x) != 17 || (mpfr_get_prec)(x) != 17)
+ ERROR ("mpfr_get_prec");
+ mpfr_clear (x);
}
static void
mpfr_set_double_range (void)
{
+ mpfr_set_default_prec (54);
+ if (mpfr_get_default_prec () != 54)
+ ERROR ("get_default_prec failed (1)");
mpfr_set_default_prec (53);
+ if ((mpfr_get_default_prec) () != 53)
+ ERROR ("get_default_prec failed (2)");
/* in double precision format, the unbiased exponent is between 0 and
2047, where 0 is used for subnormal numbers, and 2047 for special
@@ -311,7 +350,8 @@ main (int argc, char *argv[])
check_emin_emax();
check_flags();
-
+ check_set_get_prec ();
+ check_powerof2 ();
tests_end_mpfr ();
return 0;
}