37 #include <gtest/gtest.h>
39 #include <Eigen/Geometry>
42 template <
typename _Scalar,
int _Dim,
int _Mode,
int _Options>
43 std::ostream&
operator<<(std::ostream& s,
const Eigen::Transform<_Scalar, _Dim, _Mode, _Options>& t)
45 return s <<
"p=[" <<
t.translation().transpose() <<
"] q=[" << Eigen::Quaterniond(
t.linear()).coeffs().transpose()
50 template <
typename T1,
typename T2>
58 ::testing::AssertionResult
operator()(
const char* expr1,
const char* expr2, T1 val1, T2 val2)
60 if (val1.isApprox(val2,
prec_))
61 return ::testing::AssertionSuccess();
63 std::stringstream msg;
64 msg <<
"Expected equality of these values (up to precision " <<
prec_ <<
"):" << std::fixed
65 << std::setprecision(1 - std::log10(
prec_))
66 <<
"\n " << expr1 <<
"\n Which is: " << val1
67 <<
"\n " << expr2 <<
"\n Which is: " << val2;
68 return ::testing::AssertionFailure() << msg.str();
72 #define EXPECT_EIGEN_EQ(val1, val2) \
73 EXPECT_PRED_FORMAT2((IsApprox<decltype(val1), decltype(val2)>( \
74 Eigen::NumTraits<typename std::decay<decltype(val1)>::type::Scalar>::dummy_precision())), \
76 #define EXPECT_EIGEN_NEAR(val1, val2, prec_) \
77 EXPECT_PRED_FORMAT2((IsApprox<decltype(val1), decltype(val2)>(prec_)), val1, val2)