[PPL-devel] [GIT] ppl/ppl(floating_point): Added a couple of simple tests.

Fabio Bossi bossi at cs.unipr.it
Fri Sep 25 09:48:01 CEST 2009


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

Author: Fabio Bossi <bossi at cs.unipr.it>
Date:   Fri Sep 25 09:47:14 2009 +0200

Added a couple of simple tests.
Makefile fixed.

---

 tests/Floating_Point_Expression/Makefile.am    |   13 ++++---
 tests/Floating_Point_Expression/polyhedron2.cc |   40 +++++++++++++++++++++--
 2 files changed, 43 insertions(+), 10 deletions(-)

diff --git a/tests/Floating_Point_Expression/Makefile.am b/tests/Floating_Point_Expression/Makefile.am
index 6698b36..b165040 100644
--- a/tests/Floating_Point_Expression/Makefile.am
+++ b/tests/Floating_Point_Expression/Makefile.am
@@ -51,12 +51,13 @@ $(top_builddir)/src/libppl.la \
 @extra_libraries@
 
 ORIGINAL_TESTS = \
-polyhedron1
-#bdshape1 \
-#floatingpointexpr1 \
-#linearform1 \
-#octagonalshape1 \
-#octagonalshape2
+bdshape1 \
+floatingpointexpr1 \
+linearform1 \
+octagonalshape1 \
+octagonalshape2 \
+polyhedron1 \
+polyhedron2
 
 DERIVED_TESTS =
 
diff --git a/tests/Floating_Point_Expression/polyhedron2.cc b/tests/Floating_Point_Expression/polyhedron2.cc
index 7ab1b68..3b57c57 100644
--- a/tests/Floating_Point_Expression/polyhedron2.cc
+++ b/tests/Floating_Point_Expression/polyhedron2.cc
@@ -51,15 +51,46 @@ test01() {
 
 bool
 test02() {
-  C_Polyhedron pol(1);
+  C_Polyhedron result(1);
   FP_Interval_Abstract_Store store(1);
   store.set_interval(Variable(0), FP_Interval(1.5));
   FP_Interval interval(57);
   FP_Linear_Form lf1(Variable(0));
   FP_Linear_Form lf2(interval);
-  pol.refine_with_linear_form_inequality(lf1, lf2, store);
-  print_constraints(pol, "RESULT");
-  return true;
+  result.refine_with_linear_form_inequality(lf1, lf2, store);
+  print_constraints(result, "RESULT");
+  C_Polyhedron known_result(1);
+  known_result.refine_with_constraint(Variable(0) <= 57);
+  print_constraints(known_result, "KNOWN RESULT");
+  return result == known_result;
+}
+
+bool
+test03() {
+  Variable A(0);
+  Variable B(1);
+  FP_Interval_Abstract_Store store(2);
+  store.set_interval(A, FP_Interval(1));
+  store.set_interval(B, FP_Interval(2));
+
+  C_Polyhedron result(2);
+  result.refine_with_linear_form_inequality(-FP_Linear_Form(A),
+				 FP_Linear_Form(FP_Interval(0)), store);
+  result.refine_with_linear_form_inequality(FP_Linear_Form(A),
+				 FP_Linear_Form(FP_Interval(2)), store);
+  result.refine_with_linear_form_inequality(-FP_Linear_Form(A),
+				 FP_Linear_Form(FP_Interval(1)), store);
+  result.refine_with_linear_form_inequality(-FP_Linear_Form(B),
+				 FP_Linear_Form(FP_Interval(-1)), store);
+  print_constraints(result, "RESULT");
+
+  C_Polyhedron known_result(2);
+  known_result.add_constraint(A >= 0);
+  known_result.add_constraint(A <= 2);
+  known_result.add_constraint(B >= 1);
+  print_constraints(known_result, "KNOWN RESULT");
+
+  return result == known_result;
 }
 
 } // namespace
@@ -67,4 +98,5 @@ test02() {
 BEGIN_MAIN
   DO_TEST(test01);
   DO_TEST(test02);
+  DO_TEST(test03);
 END_MAIN




More information about the PPL-devel mailing list