::testing::AssertionResult assert_same(const char* exp_expr, const char* act_expr, const Eigen::EigenBase<DerivedExp>& exp, const Eigen::EigenBase<DerivedAct>& act) { if (exp.rows() == act.rows() && exp.cols() == act.cols() && exp.derived() == act.derived()) { return ::testing::AssertionSuccess(); } // if eigen did not define the == operator, you could use // exp.derived().cwiseEqual(act.derived()).all(); ::testing::AssertionResult result = ::testing::AssertionFailure() << "Eigen objects are not the same: (" << exp_expr << ", " << act_expr << ")\n" << exp_expr << ":\n" << ::testing::PrintToString(exp) << "\n---and\n" << act_expr << ":\n" << ::testing::PrintToString(act) << "\n---are not equal!\n"; return result; }
inline int size1(const Eigen::EigenBase<Derived> &mat) { return mat.rows(); }