[Mpfi-commits] r343 - trunk/mpfi/tests

ptheveny at users.gforge.inria.fr ptheveny at users.gforge.inria.fr
Jeu 24 Juin 18:51:00 CEST 2010


Author: ptheveny
Date: 2010-06-24 18:50:59 +0200 (Thu, 24 Jun 2010)
New Revision: 343

Added:
   trunk/mpfi/tests/is_pos.dat
   trunk/mpfi/tests/tis_pos.c
Modified:
   trunk/mpfi/tests/Makefile.am
Log:
Add tests for mpfi_is_pos

Modified: trunk/mpfi/tests/Makefile.am
===================================================================
--- trunk/mpfi/tests/Makefile.am	2010-06-24 16:48:43 UTC (rev 342)
+++ trunk/mpfi/tests/Makefile.am	2010-06-24 16:50:59 UTC (rev 343)
@@ -21,7 +21,7 @@
     tinit_set tintersect tinterv_d tinterv_fr tinterv_q		\
     tinterv_si tinterv_ui tinterv_z tinv tio_str tis_empty	\
     tis_inside tis_inside_d tis_inside_fr tis_inside_q		\
-    tis_inside_si tis_inside_ui tis_inside_z			\
+    tis_inside_si tis_inside_ui tis_inside_z tis_pos		\
     tis_strictly_inside tlog tlog10 tlog1p tlog2 tmag tmid	\
     tmig tmul tmul_2exp tmul_2si tmul_2ui tmul_d tmul_fr	\
     tmul_q tmul_si tmul_ui tmul_z tneg tput_d tput_fr tput_q	\
@@ -38,11 +38,12 @@
     cbrt.dat const_catalan.dat const_euler.dat			\
     const_log2.dat const_pi.dat cos.dat cosh.dat cot.dat	\
     diam.dat diam_abs.dat diam_rel.dat div.dat increase.dat	\
-    inp_str.dat intersect.dat inv.dat log.dat mag.dat		\
-    mid.dat mig.dat mul.dat mul_d.dat neg.dat put_d.dat		\
-    put_fr.dat put_q.dat put_si.dat put_ui.dat put_z.dat	\
-    q_div.dat set_d.dat set_fr.dat set_q.dat set_si.dat		\
-    set_ui.dat set_z.dat sqr.dat sqrt.dat sub.dat union.dat
+    inp_str.dat intersect.dat inv.dat is_pos.dat log.dat	\
+    mag.dat mid.dat mig.dat mul.dat mul_d.dat neg.dat		\
+    put_d.dat put_fr.dat put_q.dat put_si.dat put_ui.dat	\
+    put_z.dat q_div.dat set_d.dat set_fr.dat set_q.dat		\
+    set_si.dat set_ui.dat set_z.dat sqr.dat sqrt.dat sub.dat	\
+    union.dat
 
 TESTS = $(check_PROGRAMS)
 CLEANFILES = io_str.tmp
\ No newline at end of file

Added: trunk/mpfi/tests/is_pos.dat
===================================================================
--- trunk/mpfi/tests/is_pos.dat	                        (rev 0)
+++ trunk/mpfi/tests/is_pos.dat	2010-06-24 16:50:59 UTC (rev 343)
@@ -0,0 +1,43 @@
+# data file for mpfi_is_pos
+#
+# column fields:
+# 1: return value (0: false, +: true)
+# 2: precision of argument
+# 3: left endpoint value of argument
+# 4: right endpoint value of argument
+#
+
+# special values
+0 53  nan -inf
+0 53  nan -8
+0 53 -8    nan
+0 53  nan -0
+0 53 +0    nan
+0 53  nan  5
+0 53  5    nan
+0 53  nan +inf
+0 53  nan  nan
+0 53 -inf -inf
+0 53 -inf -8
+0 53 -inf -0
+0 53 -inf  5
+0 53 -inf +inf
+0 53 -inf  nan
+0 53 -8   -0
+
+0 53 +0   -0   #should it return true?
+
++ 53 +0    5
++ 53 +0   +inf
++ 53  5   +inf
++ 53 +inf +inf
+0 53 +inf  nan
+
+# regular values
+0  8 -34                   -17
+0  8 -8                    -1
+0  8 -34                    17
+0 53 -0x1921fb54442d18p-51  0x1921fb54442d19p-51
++ 53  0x1921fb54442d18p-51  0x1921fb54442d19p-51
++ 53 +8                    +0x7fffffffffffbp+51
++ 53 +0x1fffffffffffffp-53  2

Added: trunk/mpfi/tests/tis_pos.c
===================================================================
--- trunk/mpfi/tests/tis_pos.c	                        (rev 0)
+++ trunk/mpfi/tests/tis_pos.c	2010-06-24 16:50:59 UTC (rev 343)
@@ -0,0 +1,69 @@
+/* tis_pos.c -- Test mpfi_is_pos.
+
+Copyright 2010
+                     Spaces project, Inria Lorraine
+                     and Salsa project, INRIA Rocquencourt,
+                     and Arenaire project, Inria Rhone-Alpes, France
+                     and Lab. ANO, USTL (Univ. of Lille),  France
+
+
+This file is part of the MPFI Library.
+
+The MPFI 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 2.1 of the License, or (at your
+option) any later version.
+
+The MPFI 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 MPFI Library; see the file COPYING.LIB.  If not, write to
+the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
+MA 02110-1301, USA. */
+
+#include "mpfi-tests.h"
+
+extern nextchar;
+
+static void
+print_error (mpfi_srcptr a)
+{
+  printf ("Error: mpfi_is_pos (A) returns %d\nA = ",
+          mpfi_is_pos (a));
+  mpfi_out_str (stdout, 10, 0, a);
+  printf ("\n");
+
+  exit (1);
+}
+
+int
+main (int argc, char **argv)
+{
+  FILE *stream;
+  mpfi_t interval;
+  int expected;
+  int got;
+
+  mpfi_init2 (interval, 1024);
+
+  stream = open_file ("is_pos.dat");
+
+  init_reading (stream);
+
+  while (nextchar != EOF) {
+    read_sign (stream, &expected);
+    read_mpfi (stream, interval);
+
+    got = mpfi_is_pos (interval);
+    if (got != expected || got * expected < 0)
+      print_error (interval);
+  }
+
+  close_file (stream);
+  mpfi_clear (interval);
+
+  return 0;
+}




More information about the Mpfi-commits mailing list