diff --git a/gtsam/inference/tests/testFactorGraph.cpp b/gtsam/inference/tests/testFactorGraph.cpp new file mode 100644 index 000000000..a3a69e72d --- /dev/null +++ b/gtsam/inference/tests/testFactorGraph.cpp @@ -0,0 +1,44 @@ +/* ---------------------------------------------------------------------------- + + * GTSAM Copyright 2010, Georgia Tech Research Corporation, + * Atlanta, Georgia 30332-0415 + * All Rights Reserved + * Authors: Frank Dellaert, et al. (see THANKS for the full author list) + + * See LICENSE for the license information + + * -------------------------------------------------------------------------- */ + +/** + * @file testFactorGraph.cpp + * @author Yao Chen + */ + +#include +#include +#include + +#include +#include + +using namespace std; +using namespace gtsam; + + +TEST(FactorGraph, testEmplaceShared) { + Cal3_S2::shared_ptr K(new Cal3_S2(50.0, 50.0, 0.0, 50.0, 50.0)); + noiseModel::Isotropic::shared_ptr measurementNoise = noiseModel::Isotropic::Sigma(2, 1.0); + Point2 measurement(10.0, 10.0); + + NonlinearFactorGraph graph; + graph.push_back(GenericProjectionFactor(measurement, measurementNoise, Symbol('x', 0), Symbol('l', 0), K)); + graph.emplace_shared >(measurement, measurementNoise, Symbol('x', 0), Symbol('l', 0), K); + + EXPECT_LONGS_EQUAL(2, graph.size()); + EXPECT(graph[0]->equals(*(graph[1]))); +} + + +/* ************************************************************************* */ +int main() { TestResult tr; return TestRegistry::runAllTests(tr); } +/* ************************************************************************* */