Tests: add unit tests for Matrix4D and Rotation
This commit is contained in:
65
tests/src/Base/Rotation.cpp
Normal file
65
tests/src/Base/Rotation.cpp
Normal file
@@ -0,0 +1,65 @@
|
||||
#include "gtest/gtest.h"
|
||||
#include <Base/Matrix.h>
|
||||
#include <Base/Rotation.h>
|
||||
|
||||
|
||||
TEST(Rotation, TestNonUniformScaleLeft)
|
||||
{
|
||||
Base::Rotation rot;
|
||||
rot.setYawPitchRoll(20.0, 0.0, 0.0);
|
||||
|
||||
Base::Matrix4D mat;
|
||||
rot.getValue(mat);
|
||||
|
||||
Base::Matrix4D scale;
|
||||
scale.scale(2.0, 3.0, 4.0);
|
||||
|
||||
Base::Rotation scaled_rot(scale * mat);
|
||||
|
||||
EXPECT_EQ(scaled_rot.isSame(rot, 1.0e-7), true);
|
||||
EXPECT_EQ(rot.isSame(scaled_rot, 1.0e-7), true);
|
||||
}
|
||||
|
||||
TEST(Rotation, TestNonUniformScaleRight)
|
||||
{
|
||||
Base::Rotation rot;
|
||||
rot.setYawPitchRoll(20.0, 0.0, 0.0);
|
||||
|
||||
Base::Matrix4D mat;
|
||||
rot.getValue(mat);
|
||||
|
||||
Base::Matrix4D scale;
|
||||
scale.scale(2.0, 3.0, 4.0);
|
||||
|
||||
Base::Rotation scaled_rot(mat * scale);
|
||||
|
||||
EXPECT_EQ(scaled_rot.isSame(rot, 1.0e-7), true);
|
||||
EXPECT_EQ(rot.isSame(scaled_rot, 1.0e-7), true);
|
||||
}
|
||||
|
||||
TEST(Rotation, TestUniformScaleGT1)
|
||||
{
|
||||
Base::Rotation rot;
|
||||
rot.setYawPitchRoll(20.0, 0.0, 0.0);
|
||||
|
||||
Base::Matrix4D mat;
|
||||
rot.getValue(mat);
|
||||
|
||||
Base::Matrix4D scale;
|
||||
scale.scale(3.0, 3.0, 3.0);
|
||||
|
||||
Base::Rotation scaled_rot(mat * scale);
|
||||
|
||||
EXPECT_EQ(scaled_rot.isSame(rot, 1.0e-7), true);
|
||||
EXPECT_EQ(rot.isSame(scaled_rot, 1.0e-7), true);
|
||||
}
|
||||
|
||||
TEST(Rotation, TestUniformScaleLT1)
|
||||
{
|
||||
Base::Matrix4D mat;
|
||||
mat.scale(0.5);
|
||||
|
||||
Base::Rotation scaled_rot(mat);
|
||||
|
||||
EXPECT_EQ(scaled_rot.isSame(scaled_rot, 1.0e-7), true);
|
||||
}
|
||||
Reference in New Issue
Block a user