22 #include "gtest/gtest.h" 29 class RigidTransformTest :
public ::testing::Test {
31 T eps() {
return std::numeric_limits<T>::epsilon(); }
33 Rigid2<T> GetRandomRigid2() {
40 Rigid3<T> GetRandomRigid3() {
52 std::mt19937
prng_ = std::mt19937(42);
54 std::uniform_real_distribution<T>(-1., 1.);
57 using ScalarTypes = ::testing::Types<float, double>;
58 TYPED_TEST_CASE(RigidTransformTest, ScalarTypes);
60 TYPED_TEST(RigidTransformTest, Identity2DTest) {
61 const auto pose = this->GetRandomRigid2();
62 EXPECT_THAT(
pose * Rigid2<TypeParam>(), IsNearly(
pose, this->eps()));
63 EXPECT_THAT(Rigid2<TypeParam>() *
pose, IsNearly(
pose, this->eps()));
65 IsNearly(
pose, this->eps()));
67 IsNearly(
pose, this->eps()));
70 TYPED_TEST(RigidTransformTest, Inverse2DTest) {
71 const auto pose = this->GetRandomRigid2();
78 TYPED_TEST(RigidTransformTest, Identity3DTest) {
79 const auto pose = this->GetRandomRigid3();
80 EXPECT_THAT(
pose * Rigid3<TypeParam>(), IsNearly(
pose, this->eps()));
81 EXPECT_THAT(Rigid3<TypeParam>() *
pose, IsNearly(
pose, this->eps()));
83 IsNearly(
pose, this->eps()));
85 IsNearly(
pose, this->eps()));
88 TYPED_TEST(RigidTransformTest, Inverse3DTest) {
89 const auto pose = this->GetRandomRigid3();