summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzimmerma <zimmerma@280ebfd0-de03-0410-8827-d642c229c3f4>2009-03-16 12:50:24 +0000
committerzimmerma <zimmerma@280ebfd0-de03-0410-8827-d642c229c3f4>2009-03-16 12:50:24 +0000
commitd16ba2c3d47b950223c1b8323b5b05780a096f0c (patch)
tree2337c0ba07583a98918a88b3c6cb39b1f9f6fe71
parente679628141c2dc65866fee2af06172c810e92a31 (diff)
downloadmpfr-d16ba2c3d47b950223c1b8323b5b05780a096f0c.tar.gz
[tests/tmin_prec.c] new file contributed from Laurent Fousse
[tests/Makefile.am] added tmin_prec git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@6116 280ebfd0-de03-0410-8827-d642c229c3f4
-rw-r--r--tests/Makefile.am2
-rw-r--r--tests/tmin_prec.c73
2 files changed, 74 insertions, 1 deletions
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 9f5849378..2619f478f 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -16,7 +16,7 @@ check_PROGRAMS = tversion tinternals tinits tisqrt tsgn tcheck tisnan \
tget_f tconst_catalan troot tsec tcsc tcot teint tcoth tcsch tsech \
tstckintc tsubnormal tlngamma tlgamma tzeta_ui tget_ld_2exp \
tget_set_d64 tj0 tj1 tjn ty0 ty1 tyn tremquo tfmod tl2b tli2 tprintf \
- tsprintf tfprintf trec_sqrt tpow_all taway
+ tsprintf tfprintf trec_sqrt tpow_all taway tmin_prec
EXTRA_DIST = tgeneric.c tgeneric_ui.c mpf_compat.h inp_str.data tmul.dat
diff --git a/tests/tmin_prec.c b/tests/tmin_prec.c
new file mode 100644
index 000000000..8a95d3722
--- /dev/null
+++ b/tests/tmin_prec.c
@@ -0,0 +1,73 @@
+/* Test file for mpfr_min_prec.
+
+Copyright 2009 Free Software Foundation, Inc.
+Contributed by the Arenaire and Cacao projects, INRIA.
+
+This file is part of the GNU MPFR Library.
+
+The GNU MPFR Library is free software; you can redistribute it and/or modify
+it under the terms of the GNU Lesser General Public License as published by
+the Free Software Foundation; either version 3 of the License, or (at your
+option) any later version.
+
+The GNU MPFR Library is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+License for more details.
+
+You should have received a copy of the GNU Lesser General Public License
+along with the GNU MPFR Library; see the file COPYING.LIB. If not, see
+http://www.gnu.org/licenses/ or write to the Free Software Foundation, Inc.,
+51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. */
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "mpfr-test.h"
+
+int
+main (int argc, char *argv[])
+{
+ mpfr_t x;
+ mpfr_prec_t ret;
+
+ tests_start_mpfr ();
+
+ mpfr_init (x);
+
+ /* Check special values */
+ mpfr_set_nan (x);
+ ret = mpfr_min_prec (x);
+ MPFR_ASSERTN(ret == 0);
+
+ mpfr_set_inf (x, 1);
+ ret = mpfr_min_prec (x);
+ MPFR_ASSERTN(ret == 0);
+
+ mpfr_set_inf (x, -1);
+ ret = mpfr_min_prec (x);
+ MPFR_ASSERTN(ret == 0);
+
+ MPFR_ASSERTN(mpfr_set_ui (x, 0, GMP_RNDN) == 0);
+ ret = mpfr_min_prec (x);
+ MPFR_ASSERTN(ret == 0);
+
+ /* Some constants */
+
+ MPFR_ASSERTN(mpfr_set_ui (x, 1, GMP_RNDN) == 0);
+ ret = mpfr_min_prec (x);
+ MPFR_ASSERTN(ret == 1);
+
+ MPFR_ASSERTN(mpfr_set_ui (x, 17, GMP_RNDN) == 0);
+ ret = mpfr_min_prec (x);
+ MPFR_ASSERTN(ret == 5);
+
+ MPFR_ASSERTN(mpfr_set_ui (x, 42, GMP_RNDN) == 0);
+ ret = mpfr_min_prec (x);
+ MPFR_ASSERTN(ret == 5);
+
+ mpfr_clear (x);
+
+ tests_end_mpfr ();
+ return 0;
+}