Strengthened test and now checks problemSize_

release/4.3a0
dellaert 2015-06-21 14:36:23 -07:00
parent c3811a5488
commit 5237c74928
1 changed files with 39 additions and 27 deletions

View File

@ -69,8 +69,7 @@ using symbol_shorthand::L;
C3 x1 : x2 C3 x1 : x2
C4 x7 : x6 C4 x7 : x6
*/ */
TEST( GaussianJunctionTreeB, constructor2 ) TEST( GaussianJunctionTreeB, constructor2 ) {
{
// create a graph // create a graph
NonlinearFactorGraph nlfg; NonlinearFactorGraph nlfg;
Values values; Values values;
@ -80,7 +79,8 @@ TEST( GaussianJunctionTreeB, constructor2 )
// linearize // linearize
GaussianFactorGraph::shared_ptr fg = nlfg.linearize(values); GaussianFactorGraph::shared_ptr fg = nlfg.linearize(values);
Ordering ordering; ordering += X(1),X(3),X(5),X(7),X(2),X(6),X(4); Ordering ordering;
ordering += X(1), X(3), X(5), X(7), X(2), X(6), X(4);
// create an ordering // create an ordering
GaussianEliminationTree etree(*fg, ordering); GaussianEliminationTree etree(*fg, ordering);
@ -89,10 +89,14 @@ TEST( GaussianJunctionTreeB, constructor2 )
GaussianJunctionTree actual(etree); GaussianJunctionTree actual(etree);
GTSAM_PRINT(actual); GTSAM_PRINT(actual);
Ordering o324; o324 += X(3), X(2), X(4); Ordering o324;
Ordering o56; o56 += X(5), X(6); o324 += X(3), X(2), X(4);
Ordering o7; o7 += X(7); Ordering o56;
Ordering o1; o1 += X(1); o56 += X(5), X(6);
Ordering o7;
o7 += X(7);
Ordering o1;
o1 += X(1);
// Can no longer test these: // Can no longer test these:
// Ordering sep1; // Ordering sep1;
@ -102,13 +106,11 @@ TEST( GaussianJunctionTreeB, constructor2 )
GaussianJunctionTree::sharedNode x324 = actual.roots().front(); GaussianJunctionTree::sharedNode x324 = actual.roots().front();
LONGS_EQUAL(2, x324->children.size()); LONGS_EQUAL(2, x324->children.size());
#if defined(__APPLE__) // tie-breaking seems different :-(
GaussianJunctionTree::sharedNode x1 = x324->children[0]; GaussianJunctionTree::sharedNode x1 = x324->children[0];
GaussianJunctionTree::sharedNode x56 = x324->children[1]; GaussianJunctionTree::sharedNode x56 = x324->children[1];
#else if (x1->children.size() > 0)
GaussianJunctionTree::sharedNode x1 = x324->children[1]; x1.swap(x56); // makes it work with different tie-breakers
GaussianJunctionTree::sharedNode x56 = x324->children[0];
#endif
LONGS_EQUAL(0, x1->children.size()); LONGS_EQUAL(0, x1->children.size());
LONGS_EQUAL(1, x56->children.size()); LONGS_EQUAL(1, x56->children.size());
GaussianJunctionTree::sharedNode x7 = x56->children[0]; GaussianJunctionTree::sharedNode x7 = x56->children[0];
@ -116,12 +118,19 @@ TEST( GaussianJunctionTreeB, constructor2 )
EXPECT(assert_equal(o324, x324->orderedFrontalKeys)); EXPECT(assert_equal(o324, x324->orderedFrontalKeys));
EXPECT_LONGS_EQUAL(5, x324->factors.size()); EXPECT_LONGS_EQUAL(5, x324->factors.size());
EXPECT_LONGS_EQUAL(9, x324->problemSize_);
EXPECT(assert_equal(o56, x56->orderedFrontalKeys)); EXPECT(assert_equal(o56, x56->orderedFrontalKeys));
EXPECT_LONGS_EQUAL(4, x56->factors.size()); EXPECT_LONGS_EQUAL(4, x56->factors.size());
EXPECT_LONGS_EQUAL(9, x56->problemSize_);
EXPECT(assert_equal(o7, x7->orderedFrontalKeys)); EXPECT(assert_equal(o7, x7->orderedFrontalKeys));
EXPECT_LONGS_EQUAL(2, x7->factors.size()); EXPECT_LONGS_EQUAL(2, x7->factors.size());
EXPECT_LONGS_EQUAL(4, x7->problemSize_);
EXPECT(assert_equal(o1, x1->orderedFrontalKeys)); EXPECT(assert_equal(o1, x1->orderedFrontalKeys));
EXPECT_LONGS_EQUAL(2, x1->factors.size()); EXPECT_LONGS_EQUAL(2, x1->factors.size());
EXPECT_LONGS_EQUAL(4, x1->problemSize_);
} }
///* ************************************************************************* */ ///* ************************************************************************* */
@ -266,6 +275,9 @@ TEST( GaussianJunctionTreeB, constructor2 )
//} //}
/* ************************************************************************* */ /* ************************************************************************* */
int main() { TestResult tr; return TestRegistry::runAllTests(tr);} int main() {
TestResult tr;
return TestRegistry::runAllTests(tr);
}
/* ************************************************************************* */ /* ************************************************************************* */