added unit tests

This commit is contained in:
2025-04-16 18:35:50 +03:00
parent 3f6ea010dc
commit bed204a663
6 changed files with 43 additions and 11 deletions

View File

@@ -16,7 +16,7 @@ TEST(UnitTestOpenGL, ForwardVector)
std::print("{}\n", angles.pitch.AsDegrees());
const auto forward2 = omath::opengl_engine::ForwardVector(angles);
std::println("{} {} {}", forward2.x, (int)forward2.y, (int)forward2.z);
std::println("OpenGL {} {} {}", std::round(forward2.x), std::round(forward2.y), std::round(forward2.z));
EXPECT_EQ(forward, omath::opengl_engine::kAbsForward);
}

View File

@@ -10,11 +10,6 @@
TEST(UnitTestSourceEngine, ForwardVector)
{
const auto forward = omath::source_engine::ForwardVector({});
omath::source_engine::ViewAngles angles;
//angles.pitch = omath::source_engine::PitchAngle::FromDegrees(-90);
const auto forward2 = omath::source_engine::ForwardVector(angles);
//std::println("{} {} {}", forward2.x, forward2.y, forward2.z);
EXPECT_EQ(forward, omath::source_engine::kAbsForward);
}

View File

@@ -14,6 +14,42 @@ TEST(UnitTestUnityEngine, ForwardVector)
EXPECT_EQ(forward, omath::unity_engine::kAbsForward);
}
TEST(UnitTestUnityEngine, ForwardVectorRotationYaw)
{
omath::unity_engine::ViewAngles angles;
angles.yaw = omath::unity_engine::YawAngle::FromDegrees(90.f);
const auto forward = omath::unity_engine::ForwardVector(angles);
EXPECT_NEAR(forward.x, omath::unity_engine::kAbsRight.x, 0.00001f);
EXPECT_NEAR(forward.y, omath::unity_engine::kAbsRight.y, 0.00001f);
EXPECT_NEAR(forward.z, omath::unity_engine::kAbsRight.z, 0.00001f);
}
TEST(UnitTestUnityEngine, ForwardVectorRotationPitch)
{
omath::unity_engine::ViewAngles angles;
angles.pitch = omath::unity_engine::PitchAngle::FromDegrees(-90.f);
const auto forward = omath::unity_engine::ForwardVector(angles);
EXPECT_NEAR(forward.x, omath::unity_engine::kAbsUp.x, 0.00001f);
EXPECT_NEAR(forward.y, omath::unity_engine::kAbsUp.y, 0.00001f);
EXPECT_NEAR(forward.z, omath::unity_engine::kAbsUp.z, 0.00001f);
}
TEST(UnitTestUnityEngine, ForwardVectorRotationRoll)
{
omath::unity_engine::ViewAngles angles;
angles.roll = omath::unity_engine::RollAngle::FromDegrees(-90.f);
const auto forward = omath::unity_engine::UpVector(angles);
EXPECT_NEAR(forward.x, omath::unity_engine::kAbsRight.x, 0.00001f);
EXPECT_NEAR(forward.y, omath::unity_engine::kAbsRight.y, 0.00001f);
EXPECT_NEAR(forward.z, omath::unity_engine::kAbsRight.z, 0.00001f);
}
TEST(UnitTestUnityEngine, RightVector)
{
const auto right = omath::unity_engine::RightVector({});