Added "TestableAssertions.h" as a header file to add specializations for operations on Testable objects, like assert_equal for vectors of Testable objects. The separate header file is so that changes don't require recompiling the entire library.

release/4.3a0
Alex Cunningham 2010-08-10 16:58:42 +00:00
parent 1c72d92365
commit 16d283d1e1
2 changed files with 35 additions and 1 deletions

View File

@ -19,7 +19,7 @@ check_PROGRAMS += tests/testSPQRUtil
endif
# Testing
headers += Testable.h numericalDerivative.h
headers += Testable.h TestableAssertions.h numericalDerivative.h
# Lie Groups
headers += Lie.h Lie-inl.h

34
base/TestableAssertions.h Normal file
View File

@ -0,0 +1,34 @@
/**
* @file TestableAssertions.h
* @brief Provides additional testing facilities for common data structures
* @author Alex Cunningham
*/
#pragma once
#include <vector>
#include <boost/foreach.hpp>
#include "Testable.h"
namespace gtsam {
/**
* Version of assert_equals to work with vectors
*/
template<class V>
bool assert_equal(const std::vector<V>& expected, const std::vector<V>& actual, double tol = 1e-9) {
if (expected.size() != actual.size()) {
printf("Sizes not equal:\n");
printf("expected size: %lu\n", expected.size());
printf("actual size: %lu\n", actual.size());
return false;
}
size_t i = 0;
BOOST_FOREACH(const V& a, expected) {
if (!assert_equal(a, expected[i++], tol))
return false;
}
return true;
}
} // \namespace gtsam