From 31dc00cc70ad46e541534256dbe37c38d8edda78 Mon Sep 17 00:00:00 2001 From: pelissip Date: Mon, 19 Jan 2004 16:03:30 +0000 Subject: Add mpfr_get_default_rounding_mode. Add the tests for mpfr_get/set_default_rounding_mode. Fix mpfr_set_default_rounding_mode. git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@2633 280ebfd0-de03-0410-8827-d642c229c3f4 --- tests/texceptions.c | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) (limited to 'tests/texceptions.c') diff --git a/tests/texceptions.c b/tests/texceptions.c index 82e6cd8c1..cf13f5a44 100644 --- a/tests/texceptions.c +++ b/tests/texceptions.c @@ -1,6 +1,6 @@ /* Test file for exceptions. -Copyright 2001, 2002, 2003 Free Software Foundation. +Copyright 2001, 2002, 2003, 2004 Free Software Foundation. This file is part of the MPFR Library. @@ -24,6 +24,35 @@ MA 02111-1307, USA. */ #include "mpfr-test.h" +/* Test default rounding mode */ +static void +check_default_rnd(void) +{ + mp_rnd_t r, t; + for(r = 0 ; r < 4 ; r++) + { + mpfr_set_default_rounding_mode (r); + t = mpfr_get_default_rounding_mode(); + if (r !=t) + { + printf("ERROR in setting / getting default rounding mode (1)\n"); + exit(1); + } + } + mpfr_set_default_rounding_mode(4); + if (mpfr_get_default_rounding_mode() != GMP_RNDD) + { + printf("ERROR in setting / getting default rounding mode (2)\n"); + exit(1); + } + mpfr_set_default_rounding_mode(-1); + if (mpfr_get_default_rounding_mode() != GMP_RNDD) + { + printf("ERROR in setting / getting default rounding mode (3)\n"); + exit(1); + } +} + static void mpfr_set_double_range (void) { @@ -141,6 +170,7 @@ main (int argc, char *argv[]) test_set_underflow (); test_set_overflow (); + check_default_rnd(); mpfr_init (x); mpfr_init (y); -- cgit v1.2.1