summaryrefslogtreecommitdiff
path: root/tests/tmin_prec.c
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 /tests/tmin_prec.c
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
Diffstat (limited to 'tests/tmin_prec.c')
-rw-r--r--tests/tmin_prec.c73
1 files changed, 73 insertions, 0 deletions
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;
+}