From c2947ea633ba398efc008eb25de5cacff9fa4264 Mon Sep 17 00:00:00 2001 From: Alex Cunningham Date: Tue, 28 Feb 2012 03:51:24 +0000 Subject: [PATCH] Added variation on boost::optional assert_equal to allow for const refs --- gtsam/base/TestableAssertions.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/gtsam/base/TestableAssertions.h b/gtsam/base/TestableAssertions.h index 46f738f7d..bf96c5d48 100644 --- a/gtsam/base/TestableAssertions.h +++ b/gtsam/base/TestableAssertions.h @@ -70,6 +70,14 @@ bool assert_equal(const V& expected, const boost::optional& actual, double to return assert_equal(expected, *actual, tol); } +template +bool assert_equal(const V& expected, const boost::optional& actual, double tol = 1e-9) { + if (!actual) { + std::cout << "actual is boost::none" << std::endl; + return false; + } + return assert_equal(expected, *actual, tol); +} /** * Version of assert_equals to work with vectors