[mlpack-git] master: Always get the boolean value and store it in a temporary, because the Boost unit test macros do weird things and will cause bizarre problems. (9e170a2)

gitdub at big.cc.gt.atl.ga.us gitdub at big.cc.gt.atl.ga.us
Thu Mar 5 22:10:43 EST 2015


Repository : https://github.com/mlpack/mlpack

On branch  : master
Link       : https://github.com/mlpack/mlpack/compare/904762495c039e345beba14c1142fd719b3bd50e...f94823c800ad6f7266995c700b1b630d5ffdcf40

>---------------------------------------------------------------

commit 9e170a210e26fdc529a3b9136bd7a8909bc7cce3
Author: Marcus Edel <marcus.edel at fu-berlin.de>
Date:   Tue Jan 6 11:34:16 2015 +0100

    Always get the boolean value and store it in a temporary, because the Boost unit test macros do weird things and will cause bizarre problems.


>---------------------------------------------------------------

9e170a210e26fdc529a3b9136bd7a8909bc7cce3
 src/mlpack/tests/activation_functions_test.cpp | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/src/mlpack/tests/activation_functions_test.cpp b/src/mlpack/tests/activation_functions_test.cpp
index 60a4fe1..5d2ce2d 100644
--- a/src/mlpack/tests/activation_functions_test.cpp
+++ b/src/mlpack/tests/activation_functions_test.cpp
@@ -29,6 +29,10 @@ using namespace mlpack::ann;
 
 BOOST_AUTO_TEST_SUITE(ActivationFunctionsTest);
 
+// Be careful!  When writing new tests, always get the boolean value and store
+// it in a temporary, because the Boost unit test macros do weird things and
+// will cause bizarre problems.
+
 // Generate dataset for activation function tests.
 const arma::colvec activationData("-2 3.2 4.5 -100.2 1 -1 2 0");
 
@@ -323,7 +327,8 @@ void CheckGradientNumericallyCorrect(const arma::colvec input,
         dW = (pLoss - mLoss) / (2 * perturbation);
         e = std::abs(dW - gradient[l].at(i, j));
 
-        BOOST_REQUIRE_EQUAL(e < threshold, 1);
+        bool b = e < threshold;
+        BOOST_REQUIRE_EQUAL(b, 1);
 
         // Restore original weight.
         layer[l].get().Weights().at(i, j) = weight;



More information about the mlpack-git mailing list