
Module: ppl/ppl Branch: floating_point Commit: 2af7d3f9cb5283ce313f38d9d217d881ea53a3dd URL: http://www.cs.unipr.it/git/gitweb.cgi?p=ppl/ppl.git;a=commit;h=2af7d3f9cb528...
Author: Fabio Bossi bossi@cs.unipr.it Date: Fri Jul 23 13:50:13 2010 +0200
Added a few trivial tests.
---
tests/Concrete_Expression/Makefile.am | 7 +++- tests/Concrete_Expression/float.cc | 44 ++++++++++++++++++++++++++++++ tests/Concrete_Expression/linearform1.cc | 34 +++++++++++++++++++++++ 3 files changed, 83 insertions(+), 2 deletions(-)
diff --git a/tests/Concrete_Expression/Makefile.am b/tests/Concrete_Expression/Makefile.am index c433cad..015f0f8 100644 --- a/tests/Concrete_Expression/Makefile.am +++ b/tests/Concrete_Expression/Makefile.am @@ -51,12 +51,13 @@ $(top_builddir)/src/libppl.la \ @extra_libraries@
ORIGINAL_TESTS = \ -C_Expr +C_Expr \ +float \ +linearform1 #bdshape1 \ #bdshape2 \ #digitalfilters1 \ #floatingpointexpr1 \ -#linearform1 \ #octagonalshape1 \ #octagonalshape2 \ #polyhedron1 \ @@ -138,6 +139,8 @@ bdshape2_SOURCES = bdshape2.cc
digitalfilters1_SOURCES = digitalfilters1.cc
+float_SOURCES = float.cc + floatingpointexpr1_SOURCES = floatingpointexpr1.cc
linearform1_SOURCES = linearform1.cc diff --git a/tests/Concrete_Expression/float.cc b/tests/Concrete_Expression/float.cc new file mode 100644 index 0000000..28f8d78 --- /dev/null +++ b/tests/Concrete_Expression/float.cc @@ -0,0 +1,44 @@ +/* Test function compute_absolute_error. + Copyright (C) 2001-2010 Roberto Bagnara bagnara@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; + +bool +test01() { + std::cout << compute_absolute_error<FP_Interval>(IEEE754_HALF) << + std::endl; + + std::cout << compute_absolute_error<FP_Interval>(IEEE754_HALF) << + std::endl; + + return 1; +} + +} + +BEGIN_MAIN + DO_TEST(test01); +END_MAIN diff --git a/tests/Concrete_Expression/linearform1.cc b/tests/Concrete_Expression/linearform1.cc index 63b828c..5f532dd 100644 --- a/tests/Concrete_Expression/linearform1.cc +++ b/tests/Concrete_Expression/linearform1.cc @@ -21,6 +21,7 @@ For the most up-to-date information see the Parma Polyhedra Library site: http://www.cs.unipr.it/ppl/ . */
#include "ppl_test.hh" +#include <limits>
namespace {
@@ -291,6 +292,37 @@ test08() { return ok1 && ok2 && ok3 && ok4 && ok5 && ok6; }
+bool +test09() { + Variable A(0); + FP_Linear_Form f; + bool ok1 = !f.overflows(); + f += A; + bool ok2 = !f.overflows(); + FP_Interval max(std::numeric_limits<ANALYZER_FP_FORMAT>::max()); + f *= max; + f *= max; + bool ok3 = f.overflows(); + return ok1 && ok2 && ok3; +} + +bool +test10() { + Variable A(0); + FP_Linear_Form f; + FP_Interval_Abstract_Store s(2); + FP_Interval i(2.0); + f += i; + f += A; + s.set_interval(A, i); + FP_Interval result; + f.intervalize(s, result); + FP_Interval known_result = i+i; + nout << "Result: " << result << std::endl; + nout << "Known result: " << known_result << std::endl; + return result == known_result; +} + } // namespace
BEGIN_MAIN @@ -302,4 +334,6 @@ BEGIN_MAIN DO_TEST(test06); DO_TEST(test07); DO_TEST(test08); + DO_TEST(test09); + DO_TEST(test10); END_MAIN