[opengm] 16/40: add tolarance for floating point operation-tests

Ghislain Vaillant ghisvail-guest at moszumanska.debian.org
Sun Feb 14 16:06:02 UTC 2016


This is an automated email from the git hooks/post-receive script.

ghisvail-guest pushed a commit to branch master
in repository opengm.

commit 39931093f11cc07f9e5f036daef740c2a9a0cd3c
Author: joergkappes <kappes at math.uni-heidelberg.de>
Date:   Wed Dec 2 11:45:10 2015 +0100

    add tolarance for floating point operation-tests
---
 src/unittest/test_functions.cxx | 26 +++++++++++++-------------
 1 file changed, 13 insertions(+), 13 deletions(-)

diff --git a/src/unittest/test_functions.cxx b/src/unittest/test_functions.cxx
index eeea979..21c38b9 100644
--- a/src/unittest/test_functions.cxx
+++ b/src/unittest/test_functions.cxx
@@ -1013,19 +1013,19 @@ struct FunctionsTest {
          // bounds
          typename std::vector<ValueType>::const_iterator boundsIter = bounds.begin();
          for(LinearConstraintsIteratorType constraintsIter = lessEqualFunction.linearConstraintsBegin(); constraintsIter != lessEqualFunction.linearConstraintsEnd(); ++constraintsIter) {
-            OPENGM_TEST_EQUAL(constraintsIter->getBound(), *boundsIter);
+            OPENGM_TEST_EQUAL_TOLERANCE(constraintsIter->getBound(), *boundsIter, OPENGM_FLOAT_TOL);
             ++boundsIter;
          }
          OPENGM_TEST(boundsIter == bounds.end());
          boundsIter = bounds.begin();
          for(LinearConstraintsIteratorType constraintsIter = equalFunction.linearConstraintsBegin(); constraintsIter != equalFunction.linearConstraintsEnd(); ++constraintsIter) {
-            OPENGM_TEST_EQUAL(constraintsIter->getBound(), *boundsIter);
+            OPENGM_TEST_EQUAL_TOLERANCE(constraintsIter->getBound(), *boundsIter, OPENGM_FLOAT_TOL);
             ++boundsIter;
          }
          OPENGM_TEST(boundsIter == bounds.end());
          boundsIter = bounds.begin();
          for(LinearConstraintsIteratorType constraintsIter = greaterEqualFunction.linearConstraintsBegin(); constraintsIter != greaterEqualFunction.linearConstraintsEnd(); ++constraintsIter) {
-            OPENGM_TEST_EQUAL(constraintsIter->getBound(), *boundsIter);
+            OPENGM_TEST_EQUAL_TOLERANCE(constraintsIter->getBound(), *boundsIter, OPENGM_FLOAT_TOL);
             ++boundsIter;
          }
          OPENGM_TEST(boundsIter == bounds.end());
@@ -1173,8 +1173,8 @@ struct FunctionsTest {
                OPENGM_TEST(std::distance(violatedConstraintsBegin, violatedConstraintsEnd) > 0);
                for(size_t i = 0; i < numConstraints; i++) {
                   if(expectedValues[i] > bounds[i]) {
-                     OPENGM_TEST_EQUAL(expectedValues[i] - bounds[i], *violatedConstraintsWeightsBegin);
-                     OPENGM_TEST_EQUAL(bounds[i], violatedConstraintsBegin->getBound());
+                     OPENGM_TEST_EQUAL_TOLERANCE(expectedValues[i] - bounds[i], *violatedConstraintsWeightsBegin, OPENGM_FLOAT_TOL);
+                     OPENGM_TEST_EQUAL_TOLERANCE(bounds[i], violatedConstraintsBegin->getBound(), OPENGM_FLOAT_TOL);
                      OPENGM_TEST_EQUAL_SEQUENCE(constraints[i].indicatorVariablesBegin(), constraints[i].indicatorVariablesEnd(), violatedConstraintsBegin->indicatorVariablesBegin());
                      ++violatedConstraintsBegin;
                      ++violatedConstraintsWeightsBegin;
@@ -1200,8 +1200,8 @@ struct FunctionsTest {
                OPENGM_TEST(std::distance(violatedConstraintsBegin, violatedConstraintsEnd) > 0);
                for(size_t i = 0; i < numConstraints; i++) {
                   if(expectedValues[i] != bounds[i]) {
-                     OPENGM_TEST_EQUAL(std::abs(expectedValues[i] - bounds[i]), *violatedConstraintsWeightsBegin);
-                     OPENGM_TEST_EQUAL(bounds[i], violatedConstraintsBegin->getBound());
+                     OPENGM_TEST_EQUAL_TOLERANCE(std::abs(expectedValues[i] - bounds[i]), *violatedConstraintsWeightsBegin, OPENGM_FLOAT_TOL);
+                     OPENGM_TEST_EQUAL_TOLERANCE(bounds[i], violatedConstraintsBegin->getBound(), OPENGM_FLOAT_TOL);
                      OPENGM_TEST_EQUAL_SEQUENCE(constraints[i].indicatorVariablesBegin(), constraints[i].indicatorVariablesEnd(), violatedConstraintsBegin->indicatorVariablesBegin());
                      ++violatedConstraintsBegin;
                      ++violatedConstraintsWeightsBegin;
@@ -1227,8 +1227,8 @@ struct FunctionsTest {
                OPENGM_TEST(std::distance(violatedConstraintsBegin, violatedConstraintsEnd) > 0);
                for(size_t i = 0; i < numConstraints; i++) {
                   if(expectedValues[i] < bounds[i]) {
-                     OPENGM_TEST_EQUAL(bounds[i] - expectedValues[i], *violatedConstraintsWeightsBegin);
-                     OPENGM_TEST_EQUAL(bounds[i], violatedConstraintsBegin->getBound());
+                     OPENGM_TEST_EQUAL_TOLERANCE(bounds[i] - expectedValues[i], *violatedConstraintsWeightsBegin, OPENGM_FLOAT_TOL);
+                     OPENGM_TEST_EQUAL_TOLERANCE(bounds[i], violatedConstraintsBegin->getBound(), OPENGM_FLOAT_TOL);
                      OPENGM_TEST_EQUAL_SEQUENCE(constraints[i].indicatorVariablesBegin(), constraints[i].indicatorVariablesEnd(), violatedConstraintsBegin->indicatorVariablesBegin());
                      ++violatedConstraintsBegin;
                      ++violatedConstraintsWeightsBegin;
@@ -1280,25 +1280,25 @@ struct FunctionsTest {
             for(size_t i = 0; i < numConstraints; i++) {
                if(expectedValues[i] < bounds[i]) {  
                   OPENGM_TEST_EQUAL_TOLERANCE(bounds[i] - expectedValues[i], *violatedConstraintsWeightsEqualFunctionBegin, OPENGM_FLOAT_TOL);
-                  OPENGM_TEST_EQUAL(bounds[i], violatedConstraintsEqualFunctionBegin->getBound());
+                  OPENGM_TEST_EQUAL_TOLERANCE(bounds[i], violatedConstraintsEqualFunctionBegin->getBound(), OPENGM_FLOAT_TOL);
                   OPENGM_TEST_EQUAL_SEQUENCE(constraints[i].indicatorVariablesBegin(), constraints[i].indicatorVariablesEnd(), violatedConstraintsEqualFunctionBegin->indicatorVariablesBegin());
                   ++violatedConstraintsEqualFunctionBegin;
                   ++violatedConstraintsWeightsEqualFunctionBegin;
 
                   OPENGM_TEST_EQUAL_TOLERANCE(bounds[i] - expectedValues[i], *violatedConstraintsWeightsGreaterEqualFunctionBegin, OPENGM_FLOAT_TOL);
-                  OPENGM_TEST_EQUAL(bounds[i], violatedConstraintsGreaterEqualFunctionBegin->getBound());
+                  OPENGM_TEST_EQUAL_TOLERANCE(bounds[i], violatedConstraintsGreaterEqualFunctionBegin->getBound(), OPENGM_FLOAT_TOL);
                   OPENGM_TEST_EQUAL_SEQUENCE(constraints[i].indicatorVariablesBegin(), constraints[i].indicatorVariablesEnd(), violatedConstraintsGreaterEqualFunctionBegin->indicatorVariablesBegin());
                   ++violatedConstraintsGreaterEqualFunctionBegin;
                   ++violatedConstraintsWeightsGreaterEqualFunctionBegin;
                } else if(expectedValues[i] > bounds[i]) {
                   OPENGM_TEST_EQUAL_TOLERANCE(expectedValues[i] - bounds[i], *violatedConstraintsWeightsEqualFunctionBegin, OPENGM_FLOAT_TOL);
-                  OPENGM_TEST_EQUAL(bounds[i], violatedConstraintsEqualFunctionBegin->getBound());
+                  OPENGM_TEST_EQUAL_TOLERANCE(bounds[i], violatedConstraintsEqualFunctionBegin->getBound(), OPENGM_FLOAT_TOL);
                   OPENGM_TEST_EQUAL_SEQUENCE(constraints[i].indicatorVariablesBegin(), constraints[i].indicatorVariablesEnd(), violatedConstraintsEqualFunctionBegin->indicatorVariablesBegin());
                   ++violatedConstraintsEqualFunctionBegin;
                   ++violatedConstraintsWeightsEqualFunctionBegin;
 
                   OPENGM_TEST_EQUAL_TOLERANCE(expectedValues[i] - bounds[i], *violatedConstraintsWeightsLessEqualFunctionBegin, OPENGM_FLOAT_TOL);
-                  OPENGM_TEST_EQUAL(bounds[i], violatedConstraintsLessEqualFunctionBegin->getBound());
+                  OPENGM_TEST_EQUAL_TOLERANCE(bounds[i], violatedConstraintsLessEqualFunctionBegin->getBound(), OPENGM_FLOAT_TOL);
                   OPENGM_TEST_EQUAL_SEQUENCE(constraints[i].indicatorVariablesBegin(), constraints[i].indicatorVariablesEnd(), violatedConstraintsLessEqualFunctionBegin->indicatorVariablesBegin());
                   ++violatedConstraintsLessEqualFunctionBegin;
                   ++violatedConstraintsWeightsLessEqualFunctionBegin;

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/opengm.git



More information about the debian-science-commits mailing list