Skip to content

Commit

Permalink
Refactor the VectorApprox to a single location (#470)
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Carroll <[email protected]>
  • Loading branch information
mjcarroll authored Jan 12, 2023
1 parent f9d7e1b commit 70059ae
Show file tree
Hide file tree
Showing 6 changed files with 240 additions and 320 deletions.
24 changes: 1 addition & 23 deletions dartsim/src/WorldFeatures_TEST.cc
Original file line number Diff line number Diff line change
Expand Up @@ -47,29 +47,7 @@ using namespace gz;

using TestEnginePtr = physics::Engine3dPtr<TestFeatureList>;
using TestWorldPtr = physics::World3dPtr<TestFeatureList>;

// A predicate-formatter for asserting that two vectors are approximately equal.
class AssertVectorApprox
{
public: explicit AssertVectorApprox(double _tol = 1e-6) : tol(_tol)
{
}

public: ::testing::AssertionResult operator()(
const char *_mExpr, const char *_nExpr, Eigen::Vector3d _m,
Eigen::Vector3d _n)
{
if (gz::physics::test::Equal(_m, _n, this->tol))
return ::testing::AssertionSuccess();

return ::testing::AssertionFailure()
<< _mExpr << " and " << _nExpr << " ([" << _m.transpose()
<< "] and [" << _n.transpose() << "]"
<< ") are not equal";
}

private: double tol;
};
using AssertVectorApprox = physics::test::AssertVectorApprox;

//////////////////////////////////////////////////
class WorldFeaturesFixture : public ::testing::Test
Expand Down
Loading

0 comments on commit 70059ae

Please sign in to comment.