Adding tests for decompose function

Added scale and rotation decompose test
This commit is contained in:
2023-05-16 20:43:05 +02:00
parent c640ac574b
commit 817d0bdca9
2 changed files with 42 additions and 0 deletions

View File

@ -1,4 +1,5 @@
#include <YoggieEngine.h>
#include <ImGuizmo.h>
#include <gtest/gtest.h>
@ -23,6 +24,42 @@ TEST(TRANSFORM_COMPONENT_TESTS , CAN_EXTRACT_TRANSLATION_FROM_TRANSFORM_MATRIX)
}
TEST(TRANSFORM_COMPONENT_TESTS, CAN_EXTRACT_SCALE_FROM_TRANSFORM_MATRIX) {
auto component = YoggieEngine::TransformComponent{};
component.Scale = glm::vec3(1.0f, 2.0f, 3.0f);
auto tranformationMatrix = component.GetTransform();
auto newComponent = YoggieEngine::TransformComponent{};
newComponent.Decompose(tranformationMatrix);
EXPECT_EQ(newComponent.Scale.x, component.Scale.x);
EXPECT_EQ(newComponent.Scale.y, component.Scale.y);
EXPECT_EQ(newComponent.Scale.z, component.Scale.z);
}
TEST(TRANSFORM_COMPONENT_TESTS, CAN_EXTRACT_ROTATION_FROM_TRANSFORM_MATRIX) {
auto component = YoggieEngine::TransformComponent{};
component.Rotation = glm::vec3(2.0f, 10.0f, 20.0f);
auto transformMatrix = component.GetTransform();
auto newComponent = YoggieEngine::TransformComponent{};
newComponent.Decompose(transformMatrix);
EXPECT_EQ(newComponent.Rotation.x, component.Rotation.x);
EXPECT_EQ(newComponent.Rotation.y, component.Rotation.y);
EXPECT_EQ(newComponent.Rotation.z, component.Rotation.z);
}
int main(int argc, char** argv) {