added more unit tests

This commit is contained in:
2024-11-30 03:37:25 +03:00
parent 6a9a51b39c
commit a33ee638b9
7 changed files with 84 additions and 10 deletions

View File

@@ -15,10 +15,12 @@ add_executable(unit-tests
general/UnitTestColor.cpp
general/UnitTestVector4.cpp
general/UnitTestLineTrace.cpp
general/UnitTestAngles.cpp
engines/UnitTestOpenGL.cpp
engines/UnitTestUnityEngine.cpp
engines/UnitTestSourceEngine.cpp
)
target_link_libraries(unit-tests PRIVATE gtest gtest_main omath glm)

View File

@@ -5,8 +5,8 @@
#include <gtest/gtest.h>
#include <omath/Matrix.hpp>
#include <print>
#include <omath/engines/opengl.hpp>
#include <omath/engines/source.hpp>
#include <omath/engines/OpenGL.hpp>
#include <omath/engines/Source.hpp>
#include <glm/glm.hpp>
#include "glm/ext/matrix_clip_space.hpp"

View File

@@ -0,0 +1,38 @@
//
// Created by Orange on 11/30/2024.
//
#include <gtest/gtest.h>
#include <omath/Angles.hpp>
TEST(UnitTestAngles, RadiansToDeg)
{
constexpr float rad = 67;
EXPECT_NEAR(omath::angles::RadiansToDegrees(rad), 3838.82f, 0.01f);
}
TEST(UnitTestAngles, DegreesToRadians)
{
constexpr float degree = 90;
EXPECT_NEAR(omath::angles::DegreesToRadians(degree), 1.5708f, 0.01f);
}
TEST(UnitTestAngles, HorizontalFovToVerical)
{
constexpr float hFov = 90;
constexpr float aspectRation = 16.0f / 9.0f;
const auto verticalFov = omath::angles::HorizontalFovToVertical(hFov, aspectRation);
EXPECT_NEAR(verticalFov, 58.71f, 0.01f);
}
TEST(UnitTestAngles, VerticalToHorizontal)
{
constexpr float vFov = 58.71;
constexpr float aspectRation = 16.0f / 9.0f;
const auto horizontalFov = omath::angles::VerticalFovToHorizontal(vFov, aspectRation);
EXPECT_NEAR(horizontalFov, 89.99f, 0.01f);
}