[PPL-devel] [GIT] ppl/ppl(floating_point): Added a test directory ( and a dummy test file).

Enea Zaffanella zaffanella at cs.unipr.it
Thu Sep 3 15:41:42 CEST 2009


Module: ppl/ppl
Branch: floating_point
Commit: 452881a1cd2c0186c5ce2e222b19c40830ee60a5
URL:    http://www.cs.unipr.it/git/gitweb.cgi?p=ppl/ppl.git;a=commit;h=452881a1cd2c0186c5ce2e222b19c40830ee60a5

Author: Enea Zaffanella <zaffanella at cs.unipr.it>
Date:   Thu Sep  3 15:36:22 2009 +0200

Added a test directory (and a dummy test file).

---

 configure.ac                                       |    1 +
 tests/Floating_Point_Expression/Makefile.am        |   84 ++++++++
 .../floatingpointexpr1.cc                          |  199 ++++++++++++++++++++
 tests/Makefile.am                                  |    1 +
 4 files changed, 285 insertions(+), 0 deletions(-)

diff --git a/configure.ac b/configure.ac
index ba08ec1..09f25ca 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1520,6 +1520,7 @@ AC_CONFIG_FILES(Makefile
                 tests/Makefile
                 tests/BD_Shape/Makefile
                 tests/Box/Makefile
+                tests/Floating_Point_Expression/Makefile
                 tests/Grid/Makefile
                 tests/MIP_Problem/Makefile
                 tests/Octagonal_Shape/Makefile
diff --git a/tests/Floating_Point_Expression/Makefile.am b/tests/Floating_Point_Expression/Makefile.am
new file mode 100644
index 0000000..3fb4233
--- /dev/null
+++ b/tests/Floating_Point_Expression/Makefile.am
@@ -0,0 +1,84 @@
+# Automake source file for the Parma Polyhedra Library.
+# Copyright (C) 2001-2009 Roberto Bagnara <bagnara at cs.unipr.it>
+#
+# This file is part of the Parma Polyhedra Library (PPL).
+#
+# The PPL is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by the
+# Free Software Foundation; either version 3 of the License, or (at your
+# option) any later version.
+#
+# The PPL 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 General Public License
+# for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1307, USA.
+#
+# For the most up-to-date information see the Parma Polyhedra Library
+# site: http://www.cs.unipr.it/ppl/ .
+
+if VALGRIND_TESTS_ENABLED
+
+CHECKER = \
+$(VALGRIND) --tool=memcheck -q --trace-children=yes --leak-check=yes \
+--num-callers=100 --leak-resolution=high \
+--suppressions=$(top_srcdir)/tests/valgrind_suppressions
+
+else !VALGRIND_TESTS_ENABLED
+
+CHECKER =
+
+endif !VALGRIND_TESTS_ENABLED
+
+TESTS_ENVIRONMENT = $(CHECKER)
+
+AM_CPPFLAGS = \
+-I$(top_srcdir)/src \
+-I$(top_builddir)/src \
+-I$(top_srcdir)/utils \
+-I$(top_srcdir)/tests \
+ at extra_includes@ \
+ at debug_flag@
+
+LDADD = \
+$(top_builddir)/utils/libppl_utils.a \
+$(top_builddir)/tests/libppl_tests.a \
+$(top_builddir)/src/libppl.la \
+ at extra_libraries@
+
+TESTS = \
+floatingpointexpr1
+
+XFAIL_TESTS =
+
+BUGS =
+
+#
+# Sources for the tests
+#
+
+floatingpointexpr1_SOURCES = floatingpointexpr1.cc
+
+check_PROGRAMS = \
+$(TESTS) \
+$(WATCHDOG_TESTS) \
+$(BUGS)
+
+EXTRA_DIST =
+
+MOSTLYCLEANFILES =
+
+$(top_builddir)/utils/libppl_utils.a:
+	$(MAKE) $(AM_MAKEFLAGS) -C $(top_builddir)/utils libppl_utils.a
+
+$(top_builddir)/tests/libppl_tests.a:
+	$(MAKE) $(AM_MAKEFLAGS) -C $(top_builddir)/tests libppl_tests.a
+
+$(top_builddir)/src/libppl.la:
+	$(MAKE) $(AM_MAKEFLAGS) -C $(top_builddir)/src libppl.la
+
+$(top_builddir)/Watchdog/src/libpwl.la:
+	$(MAKE) $(AM_MAKEFLAGS) -C $(top_builddir)/Watchdog/src libpwl.la
diff --git a/tests/Floating_Point_Expression/floatingpointexpr1.cc b/tests/Floating_Point_Expression/floatingpointexpr1.cc
new file mode 100644
index 0000000..33395d1
--- /dev/null
+++ b/tests/Floating_Point_Expression/floatingpointexpr1.cc
@@ -0,0 +1,199 @@
+/* Testing Linear_Expression.
+   Copyright (C) 2001-2009 Roberto Bagnara <bagnara at cs.unipr.it>
+
+This file is part of the Parma Polyhedra Library (PPL).
+
+The PPL is free software; you can redistribute it and/or modify it
+under the terms of the GNU General Public License as published by the
+Free Software Foundation; either version 3 of the License, or (at your
+option) any later version.
+
+The PPL 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 General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software Foundation,
+Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1307, USA.
+
+For the most up-to-date information see the Parma Polyhedra Library
+site: http://www.cs.unipr.it/ppl/ . */
+
+#include "ppl_test.hh"
+
+namespace {
+
+using namespace Parma_Polyhedra_Library::IO_Operators;
+
+// Test operator-=(Linear_Form<db_r_oc>& f1, const Linear_Form<db_r_oc>& f2):
+// in this case the dimension of f2 is strictly greater than
+// the dimension of f1.
+bool
+test01() {
+  Variable A(0);
+  Variable B(1);
+
+  Linear_Form<db_r_oc> f1 = A;
+  Linear_Form<db_r_oc> f2 = B;
+  f1 -= f2;
+
+  Linear_Form<db_r_oc> known_result = A - Linear_Form<db_r_oc>(B);
+
+  bool ok = (f1 == known_result);
+
+  nout << "*** known_result ***" << endl
+       << known_result << endl;
+
+  return ok;
+}
+
+bool
+test02() {
+  Variable A(15);
+  Variable B(0);
+
+  Linear_Form<db_r_oc> f1 = A;
+  Linear_Form<db_r_oc> f2 = B;
+
+  Linear_Form<db_r_oc> known_result1 = f1 + f2;
+
+  bool ok1 = (Linear_Form<db_r_oc>(A) + B == known_result1)
+    && (B + Linear_Form<db_r_oc>(A) == known_result1)
+    && (A + Linear_Form<db_r_oc>(B) == known_result1)
+    && (Linear_Form<db_r_oc>(B) + A == known_result1)
+    && (Linear_Form<db_r_oc>(B) + Linear_Form<db_r_oc>(A) == known_result1);
+
+  nout << "*** known_result1 ***" << endl
+       << known_result1 << endl;
+
+  Linear_Form<db_r_oc> known_result2 = f1 + f1;
+
+  bool ok2 = (Linear_Form<db_r_oc>(A) + A == known_result2)
+    && (A + Linear_Form<db_r_oc>(A) == known_result2)
+    && (A + Linear_Form<db_r_oc>(A) == known_result2)
+    && (Linear_Form<db_r_oc>(A) + A == known_result2)
+    && (Linear_Form<db_r_oc>(A) + Linear_Form<db_r_oc>(A) == known_result2);
+
+  nout << "*** known_result2 ***" << endl
+       << known_result2 << endl;
+
+  return ok1 && ok2;
+}
+
+bool
+test03() {
+  Variable A(15);
+  Variable B(10);
+
+  Linear_Form<db_r_oc> f1 = A;
+  Linear_Form<db_r_oc> f2 = B;
+
+  Linear_Form<db_r_oc> known_result1 = f1 - f2;
+
+  bool ok1 = (Linear_Form<db_r_oc>(A) - B == known_result1)
+    && (A - Linear_Form<db_r_oc>(B) == known_result1)
+    && (Linear_Form<db_r_oc>(A) - Linear_Form<db_r_oc>(B) == known_result1);
+
+  nout << "*** known_result1 ***" << endl
+       << known_result1 << endl;
+
+  Linear_Form<db_r_oc> known_result2 = f2 - f1;
+
+  bool ok2 = (Linear_Form<db_r_oc>(B) - A == known_result2)
+    && (B - Linear_Form<db_r_oc>(A) == known_result2)
+    && (Linear_Form<db_r_oc>(B) - Linear_Form<db_r_oc>(A) == known_result2);
+
+  nout << "*** known_result2 ***" << endl
+       << known_result2 << endl;
+
+  Linear_Form<db_r_oc> known_result3 = f1 - f1;
+
+  bool ok3 = (Linear_Form<db_r_oc>(A) - A == known_result3)
+    && (A - Linear_Form<db_r_oc>(A) == known_result3)
+    && (Linear_Form<db_r_oc>(A) - Linear_Form<db_r_oc>(A) == known_result3);
+
+  nout << "*** known_result3 ***" << endl
+       << known_result3 << endl;
+
+  return ok1 && ok2 && ok3;
+}
+
+// Test operator+=(Linear_Form<db_r_oc>& f1, const Linear_Form<db_r_oc>& f2):
+// in this case the dimension of f2 is strictly greater than
+// the dimension of f1.
+bool
+test04() {
+  Variable A(0);
+  Variable B(1);
+
+  Linear_Form<db_r_oc> f1 = A;
+  Linear_Form<db_r_oc> f2 = B;
+  f1 += f2;
+
+  Linear_Form<db_r_oc> known_result = Linear_Form<db_r_oc>(A) + B;
+
+  bool ok = (f1 == known_result);
+
+  nout << "*** known_result ***" << endl
+       << known_result << endl;
+
+  return ok;
+}
+
+// Test operator+=(Linear_Form<db_r_oc>& f, Variable v):
+// in this case the dimension of v is strictly greater than
+// the dimension of f.
+bool
+test05() {
+  Variable A(0);
+  Variable B(1);
+
+  Linear_Form<db_r_oc> f = A;
+  db_r_oc x(2.0);
+  x /= 3.0;
+  f *= x;
+
+  Linear_Form<db_r_oc> known_result = f + B;
+
+  f += B;
+
+  bool ok = (f == known_result);
+
+  nout << "*** known_result ***" << endl
+       << known_result << endl;
+
+  return ok;
+}
+
+bool
+test06() {
+  Variable A(0);
+  Variable B(1);
+  Variable C(16);
+  Variable D(120);
+
+  Linear_Form<db_r_oc> f = A + 2*B + 16*C + 120*D;
+
+  Linear_Form<db_r_oc> known_result = A;
+  known_result += db_r_oc(2) * Linear_Form<db_r_oc>(B);
+  known_result += db_r_oc(16) * Linear_Form<db_r_oc>(C);
+  known_result += db_r_oc(120) * Linear_Form<db_r_oc>(D);
+
+  bool ok = (f == known_result);
+
+  nout << "*** known_result ***" << endl
+       << known_result << endl;
+
+  return ok;
+}
+
+} // namespace
+
+BEGIN_MAIN
+  DO_TEST(test01);
+  DO_TEST(test02);
+  DO_TEST(test03);
+  DO_TEST(test04);
+  DO_TEST(test06);
+END_MAIN
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 40f075a..1124df0 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -22,6 +22,7 @@
 
 SUBDIRS = \
 . \
+Floating_Point_Expression \
 Powerset \
 Partially_Reduced_Product \
 Box \




More information about the PPL-devel mailing list