added unit test for overloaded translation printing

release/4.3a0
Varun Agrawal 2020-02-24 16:30:21 -05:00
parent aa18546d7c
commit 2959acee7f
1 changed files with 26 additions and 0 deletions

View File

@ -993,6 +993,32 @@ TEST(Pose3, Create) {
EXPECT(assert_equal(numericalDerivative22<Pose3,Rot3,Point3>(create, R, P2), actualH2, 1e-9));
}
/* ************************************************************************* */
TEST(Pose3, print) {
std::stringstream redirectStream;
std::streambuf* ssbuf = redirectStream.rdbuf();
std::streambuf* oldbuf = std::cout.rdbuf();
// redirect cout to redirectStream
std::cout.rdbuf(ssbuf);
Pose3 pose(Rot3::identity(), Point3(1, 2, 3));
// output is captured to redirectStream
pose.print();
// Generate the expected output
std::stringstream expected;
Point3 translation(1, 2, 3);
expected << '[' << translation.x() << ", " << translation.y() << ", " << translation.z() << "]\';";
// reset cout to the original stream
std::cout.rdbuf(oldbuf);
// Get substring corresponding to translation part
std::string actual = redirectStream.str().substr(47, 11);
CHECK_EQUAL(expected.str(), actual);
}
/* ************************************************************************* */
int main() {
TestResult tr;