Skip to content

Commit

Permalink
Improve print in case of failing test
Browse files Browse the repository at this point in the history
Relates #722
  • Loading branch information
RainerKuemmerle committed Oct 21, 2023
1 parent dcf7935 commit 1c339b8
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions unit_test/slam3d/optimization_slam3d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@
#include "g2o/core/optimization_algorithm_levenberg.h"
#include "g2o/solvers/eigen/linear_solver_eigen.h"
#include "g2o/types/slam3d/edge_se3.h"
#include "gtest/gtest.h"
#include "gmock/gmock.h"
#include "unit_test/test_helper/eigen_matcher.h"

using namespace std;
using namespace g2o;
Expand Down Expand Up @@ -91,10 +92,10 @@ TYPED_TEST_P(Slam3DOptimization, Translation) {

g2o::VertexSE3* v2AfterOpti =
dynamic_cast<g2o::VertexSE3*>(this->optimizer.vertex(1));
ASSERT_TRUE(
v2AfterOpti->estimate().translation().isApprox(g2o::Vector3::Zero()));
ASSERT_TRUE(v2AfterOpti->estimate().rotation().diagonal().isApprox(
g2o::Vector3::Ones()));
EXPECT_THAT(print_wrap(v2AfterOpti->estimate().translation()),
EigenMaxDiff(print_wrap(g2o::Vector3::Zero()), 1e-3));
EXPECT_THAT(print_wrap(v2AfterOpti->estimate().rotation().diagonal()),
EigenMaxDiff(print_wrap(g2o::Vector3::Ones()), 1e-3));
}

TYPED_TEST_P(Slam3DOptimization, Rotation) {
Expand Down Expand Up @@ -130,10 +131,10 @@ TYPED_TEST_P(Slam3DOptimization, Rotation) {

g2o::VertexSE3* v2AfterOpti =
dynamic_cast<g2o::VertexSE3*>(this->optimizer.vertex(1));
ASSERT_TRUE(
v2AfterOpti->estimate().translation().isApprox(g2o::Vector3::Zero()));
ASSERT_TRUE(v2AfterOpti->estimate().rotation().diagonal().isApprox(
g2o::Vector3::Ones()));
EXPECT_THAT(print_wrap(v2AfterOpti->estimate().translation()),
EigenMaxDiff(print_wrap(g2o::Vector3::Zero()), 1e-3));
EXPECT_THAT(print_wrap(v2AfterOpti->estimate().rotation().diagonal()),
EigenMaxDiff(print_wrap(g2o::Vector3::Ones()), 1e-3));
}

// registering the test suite and all the types to be tested
Expand Down

0 comments on commit 1c339b8

Please sign in to comment.