Cleaned up tests, testing size() as well.
parent
efefe2d31a
commit
3e10adb178
|
|
@ -11,60 +11,66 @@
|
|||
|
||||
/**
|
||||
* @file testVariableIndex.cpp
|
||||
* @brief
|
||||
* @brief Unit tests for VariableIndex class
|
||||
* @author Richard Roberts
|
||||
* @date Sep 26, 2010
|
||||
*/
|
||||
|
||||
#include <gtsam/inference/VariableIndex.h>
|
||||
#include <gtsam/symbolic/SymbolicFactorGraph.h>
|
||||
#include <gtsam/base/TestableAssertions.h>
|
||||
|
||||
#include <CppUnitLite/TestHarness.h>
|
||||
|
||||
#include <boost/assign/std/list.hpp>
|
||||
#include <boost/assign/list_of.hpp>
|
||||
using namespace boost::assign;
|
||||
|
||||
#include <CppUnitLite/TestHarness.h>
|
||||
#include <gtsam/base/TestableAssertions.h>
|
||||
|
||||
#include <gtsam/inference/VariableIndex.h>
|
||||
#include <gtsam/symbolic/SymbolicFactorGraph.h>
|
||||
|
||||
using namespace std;
|
||||
using namespace gtsam;
|
||||
|
||||
/* ************************************************************************* */
|
||||
TEST(VariableIndex, augment) {
|
||||
// 2 small symbolic graphs shared by all tests
|
||||
|
||||
SymbolicFactorGraph fg1, fg2;
|
||||
SymbolicFactorGraph testGraph1() {
|
||||
SymbolicFactorGraph fg1;
|
||||
fg1.push_factor(0, 1);
|
||||
fg1.push_factor(0, 2);
|
||||
fg1.push_factor(5, 9);
|
||||
fg1.push_factor(2, 3);
|
||||
return fg1;
|
||||
}
|
||||
|
||||
SymbolicFactorGraph testGraph2() {
|
||||
SymbolicFactorGraph fg2;
|
||||
fg2.push_factor(1, 3);
|
||||
fg2.push_factor(2, 4);
|
||||
fg2.push_factor(3, 5);
|
||||
fg2.push_factor(5, 6);
|
||||
return fg2;
|
||||
}
|
||||
|
||||
SymbolicFactorGraph fgCombined; fgCombined.push_back(fg1); fgCombined.push_back(fg2);
|
||||
/* ************************************************************************* */
|
||||
TEST(VariableIndex, augment) {
|
||||
auto fg1 = testGraph1(), fg2 = testGraph2();
|
||||
SymbolicFactorGraph fgCombined;
|
||||
fgCombined.push_back(fg1);
|
||||
fgCombined.push_back(fg2);
|
||||
|
||||
VariableIndex expected(fgCombined);
|
||||
VariableIndex actual(fg1);
|
||||
actual.augment(fg2);
|
||||
|
||||
LONGS_EQUAL(16, (long)actual.nEntries());
|
||||
LONGS_EQUAL(8, (long)actual.nFactors());
|
||||
LONGS_EQUAL(8, actual.size());
|
||||
LONGS_EQUAL(16, actual.nEntries());
|
||||
LONGS_EQUAL(8, actual.nFactors());
|
||||
EXPECT(assert_equal(expected, actual));
|
||||
}
|
||||
|
||||
/* ************************************************************************* */
|
||||
TEST(VariableIndex, augment2) {
|
||||
|
||||
SymbolicFactorGraph fg1, fg2;
|
||||
fg1.push_factor(0, 1);
|
||||
fg1.push_factor(0, 2);
|
||||
fg1.push_factor(5, 9);
|
||||
fg1.push_factor(2, 3);
|
||||
fg2.push_factor(1, 3);
|
||||
fg2.push_factor(2, 4);
|
||||
fg2.push_factor(3, 5);
|
||||
fg2.push_factor(5, 6);
|
||||
auto fg1 = testGraph1(), fg2 = testGraph2();
|
||||
|
||||
SymbolicFactorGraph fgCombined;
|
||||
fgCombined.push_back(fg1);
|
||||
|
|
@ -77,23 +83,16 @@ TEST(VariableIndex, augment2) {
|
|||
VariableIndex actual(fg1);
|
||||
actual.augment(fg2, newIndices);
|
||||
|
||||
LONGS_EQUAL(16, (long) actual.nEntries());
|
||||
LONGS_EQUAL(9, (long) actual.nFactors());
|
||||
LONGS_EQUAL(8, actual.size());
|
||||
LONGS_EQUAL(16, actual.nEntries());
|
||||
LONGS_EQUAL(9, actual.nFactors());
|
||||
EXPECT(assert_equal(expected, actual));
|
||||
}
|
||||
|
||||
/* ************************************************************************* */
|
||||
TEST(VariableIndex, remove) {
|
||||
|
||||
SymbolicFactorGraph fg1, fg2;
|
||||
fg1.push_factor(0, 1);
|
||||
fg1.push_factor(0, 2);
|
||||
fg1.push_factor(5, 9);
|
||||
fg1.push_factor(2, 3);
|
||||
fg2.push_factor(1, 3);
|
||||
fg2.push_factor(2, 4);
|
||||
fg2.push_factor(3, 5);
|
||||
fg2.push_factor(5, 6);
|
||||
auto fg1 = testGraph1(), fg2 = testGraph2();
|
||||
|
||||
SymbolicFactorGraph fgCombined; fgCombined.push_back(fg1); fgCombined.push_back(fg2);
|
||||
|
||||
|
|
@ -118,15 +117,7 @@ TEST(VariableIndex, remove) {
|
|||
/* ************************************************************************* */
|
||||
TEST(VariableIndex, deep_copy) {
|
||||
|
||||
SymbolicFactorGraph fg1, fg2;
|
||||
fg1.push_factor(0, 1);
|
||||
fg1.push_factor(0, 2);
|
||||
fg1.push_factor(5, 9);
|
||||
fg1.push_factor(2, 3);
|
||||
fg2.push_factor(1, 3);
|
||||
fg2.push_factor(2, 4);
|
||||
fg2.push_factor(3, 5);
|
||||
fg2.push_factor(5, 6);
|
||||
auto fg1 = testGraph1(), fg2 = testGraph2();
|
||||
|
||||
// Create original graph and VariableIndex
|
||||
SymbolicFactorGraph fgOriginal; fgOriginal.push_back(fg1); fgOriginal.push_back(fg2);
|
||||
|
|
|
|||
Loading…
Reference in New Issue