Fixed more unit tests
parent
18b71ef110
commit
2d60d2cdfa
|
@ -28,7 +28,7 @@ double f(const LieVector& x) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ************************************************************************* */
|
/* ************************************************************************* */
|
||||||
TEST_UNSAFE(testNumericalDerivative, numericalHessian) {
|
TEST(testNumericalDerivative, numericalHessian) {
|
||||||
LieVector center = ones(2);
|
LieVector center = ones(2);
|
||||||
|
|
||||||
Matrix expected = Matrix_(2,2,
|
Matrix expected = Matrix_(2,2,
|
||||||
|
@ -47,7 +47,7 @@ double f2(const LieVector& x) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ************************************************************************* */
|
/* ************************************************************************* */
|
||||||
TEST_UNSAFE(testNumericalDerivative, numericalHessian2) {
|
TEST(testNumericalDerivative, numericalHessian2) {
|
||||||
LieVector center(2, 0.5, 1.0);
|
LieVector center(2, 0.5, 1.0);
|
||||||
|
|
||||||
Matrix expected = Matrix_(2,2,
|
Matrix expected = Matrix_(2,2,
|
||||||
|
@ -66,7 +66,7 @@ double f3(const LieVector& x1, const LieVector& x2) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ************************************************************************* */
|
/* ************************************************************************* */
|
||||||
TEST_UNSAFE(testNumericalDerivative, numericalHessian211) {
|
TEST(testNumericalDerivative, numericalHessian211) {
|
||||||
LieVector center1(1, 1.0), center2(1, 5.0);
|
LieVector center1(1, 1.0), center2(1, 5.0);
|
||||||
|
|
||||||
Matrix expected11 = Matrix_(1,1,-sin(center1(0))*cos(center2(0)));
|
Matrix expected11 = Matrix_(1,1,-sin(center1(0))*cos(center2(0)));
|
||||||
|
@ -89,7 +89,7 @@ double f4(const LieVector& x, const LieVector& y, const LieVector& z) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ************************************************************************* */
|
/* ************************************************************************* */
|
||||||
TEST_UNSAFE(testNumericalDerivative, numericalHessian311) {
|
TEST(testNumericalDerivative, numericalHessian311) {
|
||||||
LieVector center1(1, 1.0), center2(1, 2.0), center3(1, 3.0);
|
LieVector center1(1, 1.0), center2(1, 2.0), center3(1, 3.0);
|
||||||
double x = center1(0), y = center2(0), z = center3(0);
|
double x = center1(0), y = center2(0), z = center3(0);
|
||||||
Matrix expected11 = Matrix_(1,1,-sin(x)*cos(y)*z*z);
|
Matrix expected11 = Matrix_(1,1,-sin(x)*cos(y)*z*z);
|
||||||
|
|
|
@ -116,7 +116,7 @@ TEST( ReferenceFrameFactor, jacobians_zero ) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ************************************************************************* */
|
/* ************************************************************************* */
|
||||||
TEST_UNSAFE( ReferenceFrameFactor, converge_trans ) {
|
TEST( ReferenceFrameFactor, converge_trans ) {
|
||||||
|
|
||||||
// initial points
|
// initial points
|
||||||
Point2 local1(2.0, 2.0), local2(4.0, 5.0),
|
Point2 local1(2.0, 2.0), local2(4.0, 5.0),
|
||||||
|
|
|
@ -46,7 +46,7 @@ bool check_smoother(const NonlinearFactorGraph& fullgraph, const Values& fullini
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ************************************************************************* */
|
/* ************************************************************************* */
|
||||||
TEST_UNSAFE( BatchFixedLagSmoother, Example )
|
TEST( BatchFixedLagSmoother, Example )
|
||||||
{
|
{
|
||||||
// Test the BatchFixedLagSmoother in a pure linear environment. Thus, full optimization and
|
// Test the BatchFixedLagSmoother in a pure linear environment. Thus, full optimization and
|
||||||
// the BatchFixedLagSmoother should be identical (even with the linearized approximations at
|
// the BatchFixedLagSmoother should be identical (even with the linearized approximations at
|
||||||
|
|
|
@ -598,7 +598,7 @@ TEST( ConcurrentBatchFilter, update_incremental_with_marginalization )
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ************************************************************************* */
|
/* ************************************************************************* */
|
||||||
TEST_UNSAFE( ConcurrentBatchFilter, synchronize )
|
TEST( ConcurrentBatchFilter, synchronize )
|
||||||
{
|
{
|
||||||
// Test the 'synchronize' function of the ConcurrentBatchFilter in a nonlinear environment.
|
// Test the 'synchronize' function of the ConcurrentBatchFilter in a nonlinear environment.
|
||||||
// The filter is operating on a known tree structure, so the factors and summarization can
|
// The filter is operating on a known tree structure, so the factors and summarization can
|
||||||
|
|
|
@ -473,7 +473,7 @@ TEST( ConcurrentBatchSmoother, update_incremental )
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ************************************************************************* */
|
/* ************************************************************************* */
|
||||||
TEST_UNSAFE( ConcurrentBatchSmoother, synchronize )
|
TEST( ConcurrentBatchSmoother, synchronize )
|
||||||
{
|
{
|
||||||
// Test the 'synchronize' function of the ConcurrentBatchSmoother in a nonlinear environment.
|
// Test the 'synchronize' function of the ConcurrentBatchSmoother in a nonlinear environment.
|
||||||
// The smoother is operating on a known tree structure, so the factors and summarization can
|
// The smoother is operating on a known tree structure, so the factors and summarization can
|
||||||
|
|
|
@ -50,7 +50,7 @@ bool check_smoother(const NonlinearFactorGraph& fullgraph, const Values& fullini
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ************************************************************************* */
|
/* ************************************************************************* */
|
||||||
TEST_UNSAFE( IncrementalFixedLagSmoother, Example )
|
TEST( IncrementalFixedLagSmoother, Example )
|
||||||
{
|
{
|
||||||
// Test the IncrementalFixedLagSmoother in a pure linear environment. Thus, full optimization and
|
// Test the IncrementalFixedLagSmoother in a pure linear environment. Thus, full optimization and
|
||||||
// the IncrementalFixedLagSmoother should be identical (even with the linearized approximations at
|
// the IncrementalFixedLagSmoother should be identical (even with the linearized approximations at
|
||||||
|
|
|
@ -30,7 +30,7 @@ using symbol_shorthand::X;
|
||||||
using symbol_shorthand::L;
|
using symbol_shorthand::L;
|
||||||
|
|
||||||
/* ************************************************************************* */
|
/* ************************************************************************* */
|
||||||
TEST_UNSAFE( ExtendedKalmanFilter, linear ) {
|
TEST( ExtendedKalmanFilter, linear ) {
|
||||||
|
|
||||||
// Create the TestKeys for our example
|
// Create the TestKeys for our example
|
||||||
Symbol x0('x',0), x1('x',1), x2('x',2), x3('x',3);
|
Symbol x0('x',0), x1('x',1), x2('x',2), x3('x',3);
|
||||||
|
@ -364,7 +364,7 @@ public:
|
||||||
|
|
||||||
|
|
||||||
/* ************************************************************************* */
|
/* ************************************************************************* */
|
||||||
TEST_UNSAFE( ExtendedKalmanFilter, nonlinear ) {
|
TEST( ExtendedKalmanFilter, nonlinear ) {
|
||||||
|
|
||||||
// Create the set of expected output TestValues (generated using Matlab Kalman Filter)
|
// Create the set of expected output TestValues (generated using Matlab Kalman Filter)
|
||||||
Point2 expected_predict[10];
|
Point2 expected_predict[10];
|
||||||
|
|
|
@ -37,8 +37,6 @@ using namespace example;
|
||||||
using symbol_shorthand::X;
|
using symbol_shorthand::X;
|
||||||
using symbol_shorthand::L;
|
using symbol_shorthand::L;
|
||||||
|
|
||||||
#define TEST TEST_UNSAFE
|
|
||||||
|
|
||||||
/* ************************************************************************* */
|
/* ************************************************************************* */
|
||||||
// Some numbers that should be consistent among all smoother tests
|
// Some numbers that should be consistent among all smoother tests
|
||||||
|
|
||||||
|
|
|
@ -143,7 +143,7 @@ ISAM2 createSlamlikeISAM2(
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ************************************************************************* */
|
/* ************************************************************************* */
|
||||||
TEST_UNSAFE(ISAM2, ImplAddVariables) {
|
TEST(ISAM2, ImplAddVariables) {
|
||||||
|
|
||||||
// Create initial state
|
// Create initial state
|
||||||
Values theta;
|
Values theta;
|
||||||
|
@ -211,7 +211,7 @@ TEST_UNSAFE(ISAM2, ImplAddVariables) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ************************************************************************* */
|
/* ************************************************************************* */
|
||||||
TEST_UNSAFE(ISAM2, ImplRemoveVariables) {
|
TEST(ISAM2, ImplRemoveVariables) {
|
||||||
|
|
||||||
// Create initial state
|
// Create initial state
|
||||||
Values theta;
|
Values theta;
|
||||||
|
@ -610,7 +610,7 @@ TEST(ISAM2, removeFactors)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ************************************************************************* */
|
/* ************************************************************************* */
|
||||||
TEST_UNSAFE(ISAM2, removeVariables)
|
TEST(ISAM2, removeVariables)
|
||||||
{
|
{
|
||||||
// These variables will be reused and accumulate factors and values
|
// These variables will be reused and accumulate factors and values
|
||||||
Values fullinit;
|
Values fullinit;
|
||||||
|
@ -633,7 +633,7 @@ TEST_UNSAFE(ISAM2, removeVariables)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ************************************************************************* */
|
/* ************************************************************************* */
|
||||||
TEST_UNSAFE(ISAM2, swapFactors)
|
TEST(ISAM2, swapFactors)
|
||||||
{
|
{
|
||||||
// This test builds a graph in the same way as the "slamlike" test above, but
|
// This test builds a graph in the same way as the "slamlike" test above, but
|
||||||
// then swaps the 2nd-to-last landmark measurement with a different one
|
// then swaps the 2nd-to-last landmark measurement with a different one
|
||||||
|
@ -888,7 +888,7 @@ namespace {
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ************************************************************************* */
|
/* ************************************************************************* */
|
||||||
TEST_UNSAFE(ISAM2, marginalizeLeaves1)
|
TEST(ISAM2, marginalizeLeaves1)
|
||||||
{
|
{
|
||||||
ISAM2 isam;
|
ISAM2 isam;
|
||||||
|
|
||||||
|
@ -917,7 +917,7 @@ TEST_UNSAFE(ISAM2, marginalizeLeaves1)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ************************************************************************* */
|
/* ************************************************************************* */
|
||||||
TEST_UNSAFE(ISAM2, marginalizeLeaves2)
|
TEST(ISAM2, marginalizeLeaves2)
|
||||||
{
|
{
|
||||||
ISAM2 isam;
|
ISAM2 isam;
|
||||||
|
|
||||||
|
@ -949,7 +949,7 @@ TEST_UNSAFE(ISAM2, marginalizeLeaves2)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ************************************************************************* */
|
/* ************************************************************************* */
|
||||||
TEST_UNSAFE(ISAM2, marginalizeLeaves3)
|
TEST(ISAM2, marginalizeLeaves3)
|
||||||
{
|
{
|
||||||
ISAM2 isam;
|
ISAM2 isam;
|
||||||
|
|
||||||
|
@ -990,7 +990,7 @@ TEST_UNSAFE(ISAM2, marginalizeLeaves3)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ************************************************************************* */
|
/* ************************************************************************* */
|
||||||
TEST_UNSAFE(ISAM2, marginalizeLeaves4)
|
TEST(ISAM2, marginalizeLeaves4)
|
||||||
{
|
{
|
||||||
ISAM2 isam;
|
ISAM2 isam;
|
||||||
|
|
||||||
|
@ -1017,7 +1017,7 @@ TEST_UNSAFE(ISAM2, marginalizeLeaves4)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ************************************************************************* */
|
/* ************************************************************************* */
|
||||||
TEST_UNSAFE(ISAM2, marginalizeLeaves5)
|
TEST(ISAM2, marginalizeLeaves5)
|
||||||
{
|
{
|
||||||
// Create isam2
|
// Create isam2
|
||||||
ISAM2 isam = createSlamlikeISAM2();
|
ISAM2 isam = createSlamlikeISAM2();
|
||||||
|
|
|
@ -273,10 +273,10 @@ TEST(NonlinearFactor, NoiseModelFactor4) {
|
||||||
EXPECT(assert_equal(Vector_(1, 10.0), tf.unwhitenedError(tv)));
|
EXPECT(assert_equal(Vector_(1, 10.0), tf.unwhitenedError(tv)));
|
||||||
DOUBLES_EQUAL(25.0/2.0, tf.error(tv), 1e-9);
|
DOUBLES_EQUAL(25.0/2.0, tf.error(tv), 1e-9);
|
||||||
JacobianFactor jf(*boost::dynamic_pointer_cast<JacobianFactor>(tf.linearize(tv)));
|
JacobianFactor jf(*boost::dynamic_pointer_cast<JacobianFactor>(tf.linearize(tv)));
|
||||||
LONGS_EQUAL((long)jf.keys()[0], 0);
|
LONGS_EQUAL(X(1), (long)jf.keys()[0]);
|
||||||
LONGS_EQUAL((long)jf.keys()[1], 1);
|
LONGS_EQUAL(X(2), (long)jf.keys()[1]);
|
||||||
LONGS_EQUAL((long)jf.keys()[2], 2);
|
LONGS_EQUAL(X(3), (long)jf.keys()[2]);
|
||||||
LONGS_EQUAL((long)jf.keys()[3], 3);
|
LONGS_EQUAL(X(4), (long)jf.keys()[3]);
|
||||||
EXPECT(assert_equal(Matrix_(1,1, 0.5), jf.getA(jf.begin())));
|
EXPECT(assert_equal(Matrix_(1,1, 0.5), jf.getA(jf.begin())));
|
||||||
EXPECT(assert_equal(Matrix_(1,1, 1.0), jf.getA(jf.begin()+1)));
|
EXPECT(assert_equal(Matrix_(1,1, 1.0), jf.getA(jf.begin()+1)));
|
||||||
EXPECT(assert_equal(Matrix_(1,1, 1.5), jf.getA(jf.begin()+2)));
|
EXPECT(assert_equal(Matrix_(1,1, 1.5), jf.getA(jf.begin()+2)));
|
||||||
|
@ -320,11 +320,11 @@ TEST(NonlinearFactor, NoiseModelFactor5) {
|
||||||
EXPECT(assert_equal(Vector_(1, 15.0), tf.unwhitenedError(tv)));
|
EXPECT(assert_equal(Vector_(1, 15.0), tf.unwhitenedError(tv)));
|
||||||
DOUBLES_EQUAL(56.25/2.0, tf.error(tv), 1e-9);
|
DOUBLES_EQUAL(56.25/2.0, tf.error(tv), 1e-9);
|
||||||
JacobianFactor jf(*boost::dynamic_pointer_cast<JacobianFactor>(tf.linearize(tv)));
|
JacobianFactor jf(*boost::dynamic_pointer_cast<JacobianFactor>(tf.linearize(tv)));
|
||||||
LONGS_EQUAL((long)jf.keys()[0], 0);
|
LONGS_EQUAL(X(1), (long)jf.keys()[0]);
|
||||||
LONGS_EQUAL((long)jf.keys()[1], 1);
|
LONGS_EQUAL(X(2), (long)jf.keys()[1]);
|
||||||
LONGS_EQUAL((long)jf.keys()[2], 2);
|
LONGS_EQUAL(X(3), (long)jf.keys()[2]);
|
||||||
LONGS_EQUAL((long)jf.keys()[3], 3);
|
LONGS_EQUAL(X(4), (long)jf.keys()[3]);
|
||||||
LONGS_EQUAL((long)jf.keys()[4], 4);
|
LONGS_EQUAL(X(5), (long)jf.keys()[4]);
|
||||||
EXPECT(assert_equal(Matrix_(1,1, 0.5), jf.getA(jf.begin())));
|
EXPECT(assert_equal(Matrix_(1,1, 0.5), jf.getA(jf.begin())));
|
||||||
EXPECT(assert_equal(Matrix_(1,1, 1.0), jf.getA(jf.begin()+1)));
|
EXPECT(assert_equal(Matrix_(1,1, 1.0), jf.getA(jf.begin()+1)));
|
||||||
EXPECT(assert_equal(Matrix_(1,1, 1.5), jf.getA(jf.begin()+2)));
|
EXPECT(assert_equal(Matrix_(1,1, 1.5), jf.getA(jf.begin()+2)));
|
||||||
|
@ -373,12 +373,12 @@ TEST(NonlinearFactor, NoiseModelFactor6) {
|
||||||
EXPECT(assert_equal(Vector_(1, 21.0), tf.unwhitenedError(tv)));
|
EXPECT(assert_equal(Vector_(1, 21.0), tf.unwhitenedError(tv)));
|
||||||
DOUBLES_EQUAL(110.25/2.0, tf.error(tv), 1e-9);
|
DOUBLES_EQUAL(110.25/2.0, tf.error(tv), 1e-9);
|
||||||
JacobianFactor jf(*boost::dynamic_pointer_cast<JacobianFactor>(tf.linearize(tv)));
|
JacobianFactor jf(*boost::dynamic_pointer_cast<JacobianFactor>(tf.linearize(tv)));
|
||||||
LONGS_EQUAL((long)jf.keys()[0], 0);
|
LONGS_EQUAL(X(1), (long)jf.keys()[0]);
|
||||||
LONGS_EQUAL((long)jf.keys()[1], 1);
|
LONGS_EQUAL(X(2), (long)jf.keys()[1]);
|
||||||
LONGS_EQUAL((long)jf.keys()[2], 2);
|
LONGS_EQUAL(X(3), (long)jf.keys()[2]);
|
||||||
LONGS_EQUAL((long)jf.keys()[3], 3);
|
LONGS_EQUAL(X(4), (long)jf.keys()[3]);
|
||||||
LONGS_EQUAL((long)jf.keys()[4], 4);
|
LONGS_EQUAL(X(5), (long)jf.keys()[4]);
|
||||||
LONGS_EQUAL((long)jf.keys()[5], 5);
|
LONGS_EQUAL(X(6), (long)jf.keys()[5]);
|
||||||
EXPECT(assert_equal(Matrix_(1,1, 0.5), jf.getA(jf.begin())));
|
EXPECT(assert_equal(Matrix_(1,1, 0.5), jf.getA(jf.begin())));
|
||||||
EXPECT(assert_equal(Matrix_(1,1, 1.0), jf.getA(jf.begin()+1)));
|
EXPECT(assert_equal(Matrix_(1,1, 1.0), jf.getA(jf.begin()+1)));
|
||||||
EXPECT(assert_equal(Matrix_(1,1, 1.5), jf.getA(jf.begin()+2)));
|
EXPECT(assert_equal(Matrix_(1,1, 1.5), jf.getA(jf.begin()+2)));
|
||||||
|
|
|
@ -284,7 +284,7 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
/* ************************************************************************* */
|
/* ************************************************************************* */
|
||||||
TEST_UNSAFE( OccupancyGrid, Test1) {
|
TEST( OccupancyGrid, Test1) {
|
||||||
//Build a small grid and test optimization
|
//Build a small grid and test optimization
|
||||||
|
|
||||||
//Build small grid
|
//Build small grid
|
||||||
|
|
|
@ -58,7 +58,7 @@ TEST( wrap, ArgumentList ) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ************************************************************************* */
|
/* ************************************************************************* */
|
||||||
TEST_UNSAFE( wrap, check_exception ) {
|
TEST( wrap, check_exception ) {
|
||||||
THROWS_EXCEPTION(Module("/notarealpath", "geometry",enable_verbose));
|
THROWS_EXCEPTION(Module("/notarealpath", "geometry",enable_verbose));
|
||||||
CHECK_EXCEPTION(Module("/alsonotarealpath", "geometry",enable_verbose), CantOpenFile);
|
CHECK_EXCEPTION(Module("/alsonotarealpath", "geometry",enable_verbose), CantOpenFile);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue