restructurized stuff

This commit is contained in:
2026-03-10 15:57:22 +03:00
parent afb2a13dd6
commit 673835618c
8 changed files with 18 additions and 13 deletions

View File

@@ -1,51 +0,0 @@
//
// Created by orange on 08.03.2026.
//
#include <gtest/gtest.h>
#include <lua.hpp>
#include <omath/lua/lua.hpp>
class LuaColor : public ::testing::Test
{
protected:
lua_State* L = nullptr;
void SetUp() override
{
L = luaL_newstate();
luaL_openlibs(L);
omath::lua::register_lib(L);
if (luaL_dofile(L, LUA_SCRIPTS_DIR "/color_tests.lua") != LUA_OK)
FAIL() << lua_tostring(L, -1);
}
void TearDown() override { lua_close(L); }
void check(const char* func_name)
{
lua_getglobal(L, func_name);
if (lua_pcall(L, 0, 0, 0) != LUA_OK)
{
FAIL() << lua_tostring(L, -1);
lua_pop(L, 1);
}
}
};
TEST_F(LuaColor, Constructor_float) { check("Color_Constructor_float"); }
TEST_F(LuaColor, Constructor_default) { check("Color_Constructor_default"); }
TEST_F(LuaColor, Constructor_clamping) { check("Color_Constructor_clamping"); }
TEST_F(LuaColor, from_rgba) { check("Color_from_rgba"); }
TEST_F(LuaColor, from_hsv_components) { check("Color_from_hsv_components"); }
TEST_F(LuaColor, from_hsv_struct) { check("Color_from_hsv_struct"); }
TEST_F(LuaColor, red) { check("Color_red"); }
TEST_F(LuaColor, green) { check("Color_green"); }
TEST_F(LuaColor, blue) { check("Color_blue"); }
TEST_F(LuaColor, to_hsv) { check("Color_to_hsv"); }
TEST_F(LuaColor, set_hue) { check("Color_set_hue"); }
TEST_F(LuaColor, set_saturation) { check("Color_set_saturation"); }
TEST_F(LuaColor, set_value) { check("Color_set_value"); }
TEST_F(LuaColor, blend) { check("Color_blend"); }
TEST_F(LuaColor, blend_clamped_ratio) { check("Color_blend_clamped_ratio"); }
TEST_F(LuaColor, to_string) { check("Color_to_string"); }
TEST_F(LuaColor, Hsv_fields) { check("Hsv_fields"); }

View File

@@ -1,79 +0,0 @@
//
// Created by orange on 07.03.2026.
//
#include <gtest/gtest.h>
#include <lua.hpp>
#include <omath/lua/lua.hpp>
class LuaSourceEngine : public ::testing::Test
{
protected:
lua_State* L = nullptr;
void SetUp() override
{
L = luaL_newstate();
luaL_openlibs(L);
omath::lua::register_lib(L);
if (luaL_dofile(L, LUA_SCRIPTS_DIR "/source_engine_tests.lua") != LUA_OK)
FAIL() << lua_tostring(L, -1);
}
void TearDown() override { lua_close(L); }
void check(const char* func_name)
{
lua_getglobal(L, func_name);
if (lua_pcall(L, 0, 0, 0) != LUA_OK)
{
FAIL() << lua_tostring(L, -1);
lua_pop(L, 1);
}
}
};
// PitchAngle
TEST_F(LuaSourceEngine, PitchAngle_from_degrees) { check("Source_PitchAngle_from_degrees"); }
TEST_F(LuaSourceEngine, PitchAngle_clamping_max) { check("Source_PitchAngle_clamping_max"); }
TEST_F(LuaSourceEngine, PitchAngle_clamping_min) { check("Source_PitchAngle_clamping_min"); }
TEST_F(LuaSourceEngine, PitchAngle_from_radians) { check("Source_PitchAngle_from_radians"); }
TEST_F(LuaSourceEngine, PitchAngle_as_radians) { check("Source_PitchAngle_as_radians"); }
TEST_F(LuaSourceEngine, PitchAngle_sin) { check("Source_PitchAngle_sin"); }
TEST_F(LuaSourceEngine, PitchAngle_cos) { check("Source_PitchAngle_cos"); }
TEST_F(LuaSourceEngine, PitchAngle_tan) { check("Source_PitchAngle_tan"); }
TEST_F(LuaSourceEngine, PitchAngle_addition) { check("Source_PitchAngle_addition"); }
TEST_F(LuaSourceEngine, PitchAngle_addition_clamped) { check("Source_PitchAngle_addition_clamped"); }
TEST_F(LuaSourceEngine, PitchAngle_subtraction) { check("Source_PitchAngle_subtraction"); }
TEST_F(LuaSourceEngine, PitchAngle_unary_minus) { check("Source_PitchAngle_unary_minus"); }
TEST_F(LuaSourceEngine, PitchAngle_equal_to) { check("Source_PitchAngle_equal_to"); }
TEST_F(LuaSourceEngine, PitchAngle_to_string) { check("Source_PitchAngle_to_string"); }
// YawAngle
TEST_F(LuaSourceEngine, YawAngle_from_degrees) { check("Source_YawAngle_from_degrees"); }
TEST_F(LuaSourceEngine, YawAngle_normalization) { check("Source_YawAngle_normalization"); }
// RollAngle
TEST_F(LuaSourceEngine, RollAngle_from_degrees) { check("Source_RollAngle_from_degrees"); }
// FieldOfView
TEST_F(LuaSourceEngine, FieldOfView_from_degrees) { check("Source_FieldOfView_from_degrees"); }
TEST_F(LuaSourceEngine, FieldOfView_clamping) { check("Source_FieldOfView_clamping"); }
// ViewAngles
TEST_F(LuaSourceEngine, ViewAngles_new) { check("Source_ViewAngles_new"); }
TEST_F(LuaSourceEngine, ViewAngles_field_mutation) { check("Source_ViewAngles_field_mutation"); }
// Camera
TEST_F(LuaSourceEngine, Camera_constructor) { check("Source_Camera_constructor"); }
TEST_F(LuaSourceEngine, Camera_get_set_origin) { check("Source_Camera_get_set_origin"); }
TEST_F(LuaSourceEngine, Camera_get_set_near_plane) { check("Source_Camera_get_set_near_plane"); }
TEST_F(LuaSourceEngine, Camera_get_set_far_plane) { check("Source_Camera_get_set_far_plane"); }
TEST_F(LuaSourceEngine, Camera_get_set_fov) { check("Source_Camera_get_set_fov"); }
TEST_F(LuaSourceEngine, Camera_get_set_view_angles) { check("Source_Camera_get_set_view_angles"); }
TEST_F(LuaSourceEngine, Camera_look_at) { check("Source_Camera_look_at"); }
TEST_F(LuaSourceEngine, Camera_get_forward) { check("Source_Camera_get_forward"); }
TEST_F(LuaSourceEngine, Camera_get_right) { check("Source_Camera_get_right"); }
TEST_F(LuaSourceEngine, Camera_get_up) { check("Source_Camera_get_up"); }
TEST_F(LuaSourceEngine, Camera_world_to_screen_success) { check("Source_Camera_world_to_screen_success"); }
TEST_F(LuaSourceEngine, Camera_world_to_screen_error) { check("Source_Camera_world_to_screen_error"); }
TEST_F(LuaSourceEngine, Camera_screen_to_world) { check("Source_Camera_screen_to_world"); }

View File

@@ -1,56 +0,0 @@
//
// Created by orange on 07.03.2026.
//
#include <gtest/gtest.h>
#include <lua.hpp>
#include <omath/lua/lua.hpp>
class LuaVec2 : public ::testing::Test
{
protected:
lua_State* L = nullptr;
void SetUp() override
{
L = luaL_newstate();
luaL_openlibs(L);
omath::lua::register_lib(L);
if (luaL_dofile(L, LUA_SCRIPTS_DIR "/vec2_tests.lua") != LUA_OK)
FAIL() << lua_tostring(L, -1);
}
void TearDown() override { lua_close(L); }
void check(const char* func_name)
{
lua_getglobal(L, func_name);
if (lua_pcall(L, 0, 0, 0) != LUA_OK)
{
FAIL() << lua_tostring(L, -1);
lua_pop(L, 1);
}
}
};
TEST_F(LuaVec2, Constructor_default) { check("Vec2_Constructor_default"); }
TEST_F(LuaVec2, Constructor_xy) { check("Vec2_Constructor_xy"); }
TEST_F(LuaVec2, Field_mutation) { check("Vec2_Field_mutation"); }
TEST_F(LuaVec2, Addition) { check("Vec2_Addition"); }
TEST_F(LuaVec2, Subtraction) { check("Vec2_Subtraction"); }
TEST_F(LuaVec2, UnaryMinus) { check("Vec2_UnaryMinus"); }
TEST_F(LuaVec2, Multiplication_scalar) { check("Vec2_Multiplication_scalar"); }
TEST_F(LuaVec2, Multiplication_scalar_reversed) { check("Vec2_Multiplication_scalar_reversed"); }
TEST_F(LuaVec2, Division_scalar) { check("Vec2_Division_scalar"); }
TEST_F(LuaVec2, EqualTo_true) { check("Vec2_EqualTo_true"); }
TEST_F(LuaVec2, EqualTo_false) { check("Vec2_EqualTo_false"); }
TEST_F(LuaVec2, LessThan) { check("Vec2_LessThan"); }
TEST_F(LuaVec2, LessThanOrEqual) { check("Vec2_LessThanOrEqual"); }
TEST_F(LuaVec2, ToString) { check("Vec2_ToString"); }
TEST_F(LuaVec2, Length) { check("Vec2_Length"); }
TEST_F(LuaVec2, LengthSqr) { check("Vec2_LengthSqr"); }
TEST_F(LuaVec2, Normalized) { check("Vec2_Normalized"); }
TEST_F(LuaVec2, Dot) { check("Vec2_Dot"); }
TEST_F(LuaVec2, DistanceTo) { check("Vec2_DistanceTo"); }
TEST_F(LuaVec2, DistanceToSqr) { check("Vec2_DistanceToSqr"); }
TEST_F(LuaVec2, Sum) { check("Vec2_Sum"); }
TEST_F(LuaVec2, Abs) { check("Vec2_Abs"); }

View File

@@ -1,69 +0,0 @@
//
// Created by orange on 07.03.2026.
//
#include <gtest/gtest.h>
#include <lua.hpp>
#include <omath/lua/lua.hpp>
class LuaVec3 : public ::testing::Test
{
protected:
lua_State* L = nullptr;
void SetUp() override
{
L = luaL_newstate();
luaL_openlibs(L);
omath::lua::register_lib(L);
if (luaL_dofile(L, LUA_SCRIPTS_DIR "/vec3_tests.lua") != LUA_OK)
FAIL() << lua_tostring(L, -1);
}
void TearDown() override { lua_close(L); }
void check(const char* func_name)
{
lua_getglobal(L, func_name);
if (lua_pcall(L, 0, 0, 0) != LUA_OK)
{
FAIL() << lua_tostring(L, -1);
lua_pop(L, 1);
}
}
};
TEST_F(LuaVec3, Constructor_default) { check("Vec3_Constructor_default"); }
TEST_F(LuaVec3, Constructor_xyz) { check("Vec3_Constructor_xyz"); }
TEST_F(LuaVec3, Field_mutation) { check("Vec3_Field_mutation"); }
TEST_F(LuaVec3, Addition) { check("Vec3_Addition"); }
TEST_F(LuaVec3, Subtraction) { check("Vec3_Subtraction"); }
TEST_F(LuaVec3, UnaryMinus) { check("Vec3_UnaryMinus"); }
TEST_F(LuaVec3, Multiplication_scalar) { check("Vec3_Multiplication_scalar"); }
TEST_F(LuaVec3, Multiplication_scalar_reversed) { check("Vec3_Multiplication_scalar_reversed"); }
TEST_F(LuaVec3, Multiplication_vec) { check("Vec3_Multiplication_vec"); }
TEST_F(LuaVec3, Division_scalar) { check("Vec3_Division_scalar"); }
TEST_F(LuaVec3, Division_vec) { check("Vec3_Division_vec"); }
TEST_F(LuaVec3, EqualTo_true) { check("Vec3_EqualTo_true"); }
TEST_F(LuaVec3, EqualTo_false) { check("Vec3_EqualTo_false"); }
TEST_F(LuaVec3, LessThan) { check("Vec3_LessThan"); }
TEST_F(LuaVec3, LessThanOrEqual) { check("Vec3_LessThanOrEqual"); }
TEST_F(LuaVec3, ToString) { check("Vec3_ToString"); }
TEST_F(LuaVec3, Length) { check("Vec3_Length"); }
TEST_F(LuaVec3, Length2d) { check("Vec3_Length2d"); }
TEST_F(LuaVec3, LengthSqr) { check("Vec3_LengthSqr"); }
TEST_F(LuaVec3, Normalized) { check("Vec3_Normalized"); }
TEST_F(LuaVec3, Dot_perpendicular) { check("Vec3_Dot_perpendicular"); }
TEST_F(LuaVec3, Dot_parallel) { check("Vec3_Dot_parallel"); }
TEST_F(LuaVec3, Cross) { check("Vec3_Cross"); }
TEST_F(LuaVec3, DistanceTo) { check("Vec3_DistanceTo"); }
TEST_F(LuaVec3, DistanceToSqr) { check("Vec3_DistanceToSqr"); }
TEST_F(LuaVec3, Sum) { check("Vec3_Sum"); }
TEST_F(LuaVec3, Sum2d) { check("Vec3_Sum2d"); }
TEST_F(LuaVec3, Abs) { check("Vec3_Abs"); }
TEST_F(LuaVec3, PointToSameDirection_true) { check("Vec3_PointToSameDirection_true"); }
TEST_F(LuaVec3, PointToSameDirection_false) { check("Vec3_PointToSameDirection_false"); }
TEST_F(LuaVec3, IsPerpendicular_true) { check("Vec3_IsPerpendicular_true"); }
TEST_F(LuaVec3, IsPerpendicular_false) { check("Vec3_IsPerpendicular_false"); }
TEST_F(LuaVec3, AngleBetween_90deg) { check("Vec3_AngleBetween_90deg"); }
TEST_F(LuaVec3, AngleBetween_zero_vector_error) { check("Vec3_AngleBetween_zero_vector_error"); }
TEST_F(LuaVec3, AsTable) { check("Vec3_AsTable"); }

View File

@@ -1,57 +0,0 @@
//
// Created by orange on 07.03.2026.
//
#include <gtest/gtest.h>
#include <lua.hpp>
#include <omath/lua/lua.hpp>
class LuaVec4 : public ::testing::Test
{
protected:
lua_State* L = nullptr;
void SetUp() override
{
L = luaL_newstate();
luaL_openlibs(L);
omath::lua::register_lib(L);
if (luaL_dofile(L, LUA_SCRIPTS_DIR "/vec4_tests.lua") != LUA_OK)
FAIL() << lua_tostring(L, -1);
}
void TearDown() override { lua_close(L); }
void check(const char* func_name)
{
lua_getglobal(L, func_name);
if (lua_pcall(L, 0, 0, 0) != LUA_OK)
{
FAIL() << lua_tostring(L, -1);
lua_pop(L, 1);
}
}
};
TEST_F(LuaVec4, Constructor_default) { check("Vec4_Constructor_default"); }
TEST_F(LuaVec4, Constructor_xyzw) { check("Vec4_Constructor_xyzw"); }
TEST_F(LuaVec4, Field_mutation) { check("Vec4_Field_mutation"); }
TEST_F(LuaVec4, Addition) { check("Vec4_Addition"); }
TEST_F(LuaVec4, Subtraction) { check("Vec4_Subtraction"); }
TEST_F(LuaVec4, UnaryMinus) { check("Vec4_UnaryMinus"); }
TEST_F(LuaVec4, Multiplication_scalar) { check("Vec4_Multiplication_scalar"); }
TEST_F(LuaVec4, Multiplication_scalar_reversed) { check("Vec4_Multiplication_scalar_reversed"); }
TEST_F(LuaVec4, Multiplication_vec) { check("Vec4_Multiplication_vec"); }
TEST_F(LuaVec4, Division_scalar) { check("Vec4_Division_scalar"); }
TEST_F(LuaVec4, Division_vec) { check("Vec4_Division_vec"); }
TEST_F(LuaVec4, EqualTo_true) { check("Vec4_EqualTo_true"); }
TEST_F(LuaVec4, EqualTo_false) { check("Vec4_EqualTo_false"); }
TEST_F(LuaVec4, LessThan) { check("Vec4_LessThan"); }
TEST_F(LuaVec4, LessThanOrEqual) { check("Vec4_LessThanOrEqual"); }
TEST_F(LuaVec4, ToString) { check("Vec4_ToString"); }
TEST_F(LuaVec4, Length) { check("Vec4_Length"); }
TEST_F(LuaVec4, LengthSqr) { check("Vec4_LengthSqr"); }
TEST_F(LuaVec4, Dot) { check("Vec4_Dot"); }
TEST_F(LuaVec4, Dot_perpendicular) { check("Vec4_Dot_perpendicular"); }
TEST_F(LuaVec4, Sum) { check("Vec4_Sum"); }
TEST_F(LuaVec4, Abs) { check("Vec4_Abs"); }
TEST_F(LuaVec4, Clamp) { check("Vec4_Clamp"); }