Made unit test local vars/functions in anonymous namespace

release/4.3a0
Richard Roberts 2013-04-22 17:44:09 +00:00
parent dd84ffcc8e
commit 124a38f72d
4 changed files with 30 additions and 11 deletions

View File

@ -11,13 +11,17 @@
using namespace gtsam; using namespace gtsam;
using namespace gtsam::symbol_shorthand; using namespace gtsam::symbol_shorthand;
const double tol=1e-5; namespace {
const double h = 0.1;
const double g = 9.81, l = 1.0;
const double deg2rad = M_PI/180.0; const double tol=1e-5;
LieScalar origin, q1(deg2rad*30.0), q2(deg2rad*31.0); const double h = 0.1;
LieScalar v1(deg2rad*1.0/h), v2((v1-h*g/l*sin(q1))); const double g = 9.81, l = 1.0;
const double deg2rad = M_PI/180.0;
LieScalar origin, q1(deg2rad*30.0), q2(deg2rad*31.0);
LieScalar v1(deg2rad*1.0/h), v2((v1-h*g/l*sin(q1)));
}
/* ************************************************************************* */ /* ************************************************************************* */
TEST( testPendulumFactor1, evaluateError) { TEST( testPendulumFactor1, evaluateError) {

View File

@ -5,21 +5,29 @@
#include <CppUnitLite/TestHarness.h> #include <CppUnitLite/TestHarness.h>
#include <gtsam/nonlinear/Symbol.h>
#include <gtsam_unstable/dynamics/VelocityConstraint3.h> #include <gtsam_unstable/dynamics/VelocityConstraint3.h>
/* ************************************************************************* */ /* ************************************************************************* */
using namespace gtsam; using namespace gtsam;
const double tol=1e-5; namespace {
const double dt = 1.0;
LieScalar origin, const double tol=1e-5;
x1(1.0), x2(2.0), v(1.0); const double dt = 1.0;
LieScalar origin,
x1(1.0), x2(2.0), v(1.0);
}
/* ************************************************************************* */ /* ************************************************************************* */
TEST( testVelocityConstraint3, evaluateError) { TEST( testVelocityConstraint3, evaluateError) {
using namespace gtsam::symbol_shorthand;
// hard constraints don't need a noise model // hard constraints don't need a noise model
VelocityConstraint3 constraint(x1, x2, v, dt); VelocityConstraint3 constraint(X(1), X(2), V(1), dt);
// verify error function // verify error function
EXPECT(assert_equal(zero(1), constraint.evaluateError(x1, x2, v), tol)); EXPECT(assert_equal(zero(1), constraint.evaluateError(x1, x2, v), tol));

View File

@ -35,6 +35,7 @@
using namespace std; using namespace std;
using namespace gtsam; using namespace gtsam;
namespace {
// Set up initial pose, odometry difference, loop closure difference, and initialization errors // Set up initial pose, odometry difference, loop closure difference, and initialization errors
const Pose3 poseInitial; const Pose3 poseInitial;
@ -431,6 +432,8 @@ void FindFactorsWithOnly(const CONTAINER& keys, const NonlinearFactorGraph& sour
} }
}
/* ************************************************************************* */ /* ************************************************************************* */
TEST( ConcurrentBatchFilter, update_batch ) TEST( ConcurrentBatchFilter, update_batch )
{ {

View File

@ -34,6 +34,8 @@
using namespace std; using namespace std;
using namespace gtsam; using namespace gtsam;
namespace {
// Set up initial pose, odometry difference, loop closure difference, and initialization errors // Set up initial pose, odometry difference, loop closure difference, and initialization errors
const Pose3 poseInitial; const Pose3 poseInitial;
const Pose3 poseOdometry( Rot3::RzRyRx(Vector_(3, 0.05, 0.10, -0.75)), Point3(1.0, -0.25, 0.10) ); const Pose3 poseOdometry( Rot3::RzRyRx(Vector_(3, 0.05, 0.10, -0.75)), Point3(1.0, -0.25, 0.10) );
@ -395,6 +397,8 @@ void FindFactorsWithOnly(const std::set<Key>& keys, const NonlinearFactorGraph&
} }
}
/* ************************************************************************* */ /* ************************************************************************* */
TEST( ConcurrentBatchSmoother, update_batch ) TEST( ConcurrentBatchSmoother, update_batch )
{ {