fix existing tests build

This commit is contained in:
Recep Aslantas
2023-04-21 22:15:04 +03:00
parent 17b3911e7c
commit c1ff76d3b1
13 changed files with 154 additions and 146 deletions

View File

@@ -243,11 +243,6 @@ test_tests_SOURCES=\
test/runner.c \ test/runner.c \
test/src/test_common.c \ test/src/test_common.c \
test/src/tests.c \ test/src/tests.c \
test/src/test_cam.c \
test/src/test_cam_lh_zo.c \
test/src/test_cam_rh_zo.c \
test/src/test_cam_lh_no.c \
test/src/test_cam_rh_no.c \
test/src/test_clamp.c \ test/src/test_clamp.c \
test/src/test_euler.c \ test/src/test_euler.c \
test/src/test_bezier.c \ test/src/test_bezier.c \

View File

@@ -108,11 +108,6 @@ if get_option('build_tests') == true
test_src = files( test_src = files(
'test/runner.c', 'test/runner.c',
'test/src/test_bezier.c', 'test/src/test_bezier.c',
'test/src/test_cam.c',
'test/src/test_cam_lh_no.c',
'test/src/test_cam_lh_zo.c',
'test/src/test_cam_rh_no.c',
'test/src/test_cam_rh_zo.c',
'test/src/test_clamp.c', 'test/src/test_clamp.c',
'test/src/test_common.c', 'test/src/test_common.c',
'test/src/test_euler.c', 'test/src/test_euler.c',

View File

@@ -5,11 +5,6 @@ set(TESTFILES
runner.c runner.c
src/test_euler.c src/test_euler.c
src/test_bezier.c src/test_bezier.c
src/test_cam.c
src/test_cam_lh_zo.c
src/test_cam_rh_zo.c
src/test_cam_lh_no.c
src/test_cam_rh_no.c
src/test_struct.c src/test_struct.c
src/test_clamp.c src/test_clamp.c
src/test_common.c src/test_common.c

View File

@@ -1,55 +0,0 @@
/*
* Copyright (c), Recep Aslantas.
*
* MIT License (MIT), http://opensource.org/licenses/MIT
* Full license can be found in the LICENSE file
*/
#include "test_common.h"
TEST_IMPL(camera_lookat) {
mat4 view1, view2;
vec3 center,
eye = {0.024f, 14.6f, 67.04f},
dir = {0.0f, 0.0f, -1.0f},
up = {0.0f, 1.0f, 0.0f};
glm_vec3_add(eye, dir, center);
glm_lookat(eye, center, up, view1);
glm_look(eye, dir, up, view2);
ASSERTIFY(test_assert_mat4_eq(view1, view2))
TEST_SUCCESS
}
TEST_IMPL(camera_decomp) {
mat4 proj, proj2;
vec4 sizes;
float aspect, fovy, nearZ, farZ;
aspect = 0.782f;
fovy = glm_rad(49.984f);
nearZ = 0.1f;
farZ = 100.0f;
glm_perspective(fovy, aspect, nearZ, farZ, proj);
ASSERT(fabsf(aspect - glm_persp_aspect(proj)) < GLM_FLT_EPSILON)
ASSERT(fabsf(fovy - glm_persp_fovy(proj)) < GLM_FLT_EPSILON)
ASSERT(fabsf(49.984f - glm_deg(glm_persp_fovy(proj))) < GLM_FLT_EPSILON)
glm_persp_sizes(proj, fovy, sizes);
glm_frustum(-sizes[0] * 0.5f,
sizes[0] * 0.5f,
-sizes[1] * 0.5f,
sizes[1] * 0.5f,
nearZ,
farZ,
proj2);
ASSERTIFY(test_assert_mat4_eq(proj, proj2))
TEST_SUCCESS
}

View File

@@ -66,3 +66,50 @@ TEST_IMPL(GLM_PREFIX, frustum) {
TEST_SUCCESS TEST_SUCCESS
} }
TEST_IMPL(GLM_PREFIX, camera_lookat) {
mat4 view1, view2;
vec3 center,
eye = {0.024f, 14.6f, 67.04f},
dir = {0.0f, 0.0f, -1.0f},
up = {0.0f, 1.0f, 0.0f};
glm_vec3_add(eye, dir, center);
glm_lookat(eye, center, up, view1);
glm_look(eye, dir, up, view2);
ASSERTIFY(test_assert_mat4_eq(view1, view2))
TEST_SUCCESS
}
TEST_IMPL(GLM_PREFIX, camera_decomp) {
mat4 proj, proj2;
vec4 sizes;
float aspect, fovy, nearZ, farZ;
aspect = 0.782f;
fovy = glm_rad(49.984f);
nearZ = 0.1f;
farZ = 100.0f;
glm_perspective(fovy, aspect, nearZ, farZ, proj);
ASSERT(fabsf(aspect - glm_persp_aspect(proj)) < GLM_FLT_EPSILON)
ASSERT(fabsf(fovy - glm_persp_fovy(proj)) < GLM_FLT_EPSILON)
ASSERT(fabsf(49.984f - glm_deg(glm_persp_fovy(proj))) < GLM_FLT_EPSILON)
glm_persp_sizes(proj, fovy, sizes);
glm_frustum(-sizes[0] * 0.5f,
sizes[0] * 0.5f,
-sizes[1] * 0.5f,
sizes[1] * 0.5f,
nearZ,
farZ,
proj2);
ASSERTIFY(test_assert_mat4_eq(proj, proj2))
TEST_SUCCESS
}

View File

@@ -6,15 +6,17 @@
*/ */
#include "test_common.h" #include "test_common.h"
#include "../../include/cglm/clipspace/persp_lh_no.h"
#include "../../include/cglm/call/clipspace/persp_lh_no.h"
TEST_IMPL(perspective_lh_no) { TEST_IMPL(GLM_PREFIX, perspective_lh_no) {
mat4 dst; mat4 dst;
const float fovy = glm_rad(45.0f); const float fovy = glm_rad(45.0f);
const float aspect = 640/480.0f; const float aspect = 640/480.0f;
const float zNearVal = 0.1f; const float zNearVal = 0.1f;
const float zFarVal = 100.0f; const float zFarVal = 100.0f;
glm_perspective_lh_no(fovy, aspect, zNearVal, zFarVal, dst); GLM(perspective_lh_no)(fovy, aspect, zNearVal, zFarVal, dst);
/* Sanity mk. I: longhand version */ /* Sanity mk. I: longhand version */
ASSERT(test_eq(dst[0][0], 1.0f / (tanf(fovy / 2) * aspect))) ASSERT(test_eq(dst[0][0], 1.0f / (tanf(fovy / 2) * aspect)))

View File

@@ -6,15 +6,17 @@
*/ */
#include "test_common.h" #include "test_common.h"
#include "../../include/cglm/clipspace/persp_lh_zo.h"
#include "../../include/cglm/call/clipspace/persp_lh_zo.h"
TEST_IMPL(perspective_lh_zo) { TEST_IMPL(GLM_PREFIX, perspective_lh_zo) {
mat4 dst; mat4 dst;
const float fovy = glm_rad(45.0f); const float fovy = glm_rad(45.0f);
const float aspect = 640/480.0f; const float aspect = 640/480.0f;
const float zNearVal = 0.1f; const float zNearVal = 0.1f;
const float zFarVal = 100.0f; const float zFarVal = 100.0f;
glm_perspective_lh_zo(fovy, aspect, zNearVal, zFarVal, dst); GLM(perspective_lh_zo)(fovy, aspect, zNearVal, zFarVal, dst);
/* Sanity mk. I: longhand version */ /* Sanity mk. I: longhand version */
ASSERT(test_eq(dst[0][0], 1.0f / (tanf(fovy / 2) * aspect))) ASSERT(test_eq(dst[0][0], 1.0f / (tanf(fovy / 2) * aspect)))

View File

@@ -6,15 +6,17 @@
*/ */
#include "test_common.h" #include "test_common.h"
#include "../../include/cglm/clipspace/persp_rh_no.h"
#include "../../include/cglm/call/clipspace/persp_rh_no.h"
TEST_IMPL(perspective_rh_no) { TEST_IMPL(GLM_PREFIX, perspective_rh_no) {
mat4 dst; mat4 dst;
const float fovy = glm_rad(45.0f); const float fovy = glm_rad(45.0f);
const float aspect = 640/480.0f; const float aspect = 640/480.0f;
const float zNearVal = 0.1f; const float zNearVal = 0.1f;
const float zFarVal = 100.0f; const float zFarVal = 100.0f;
glm_perspective_rh_no(fovy, aspect, zNearVal, zFarVal, dst); GLM(perspective_rh_no)(fovy, aspect, zNearVal, zFarVal, dst);
/* Sanity mk. I: longhand version */ /* Sanity mk. I: longhand version */
ASSERT(test_eq(dst[0][0], 1.0f / (tanf(fovy / 2) * aspect))) ASSERT(test_eq(dst[0][0], 1.0f / (tanf(fovy / 2) * aspect)))

View File

@@ -6,15 +6,17 @@
*/ */
#include "test_common.h" #include "test_common.h"
#include "../../include/cglm/clipspace/persp_rh_zo.h"
#include "../../include/cglm/call/clipspace/persp_rh_zo.h"
TEST_IMPL(perspective_rh_zo) { TEST_IMPL(GLM_PREFIX, perspective_rh_zo) {
mat4 dst; mat4 dst;
const float fovy = glm_rad(45.0f); const float fovy = glm_rad(45.0f);
const float aspect = 640/480.0f; const float aspect = 640/480.0f;
const float zNearVal = 0.1f; const float zNearVal = 0.1f;
const float zFarVal = 100.0f; const float zFarVal = 100.0f;
glm_perspective_rh_zo(fovy, aspect, zNearVal, zFarVal, dst); GLM(perspective_rh_zo)(fovy, aspect, zNearVal, zFarVal, dst);
/* Sanity mk. I: longhand version */ /* Sanity mk. I: longhand version */
ASSERT(test_eq(dst[0][0], 1 / (tanf(fovy / 2) * aspect))) ASSERT(test_eq(dst[0][0], 1 / (tanf(fovy / 2) * aspect)))

View File

@@ -10,6 +10,10 @@
#include "../include/common.h" #include "../include/common.h"
#if !defined(_WIN32) && !defined(_MSC_VER)
# pragma GCC diagnostic ignored "-Wstrict-prototypes"
#endif
void void
test_rand_mat4(mat4 dest); test_rand_mat4(mat4 dest);

View File

@@ -28,7 +28,11 @@
#include "test_affine2d.h" #include "test_affine2d.h"
#include "test_affine_mat.h" #include "test_affine_mat.h"
#include "test_ray.h" #include "test_ray.h"
#include "test_camera.h" #include "test_cam.h"
#include "test_cam_lh_no.h"
#include "test_cam_lh_zo.h"
#include "test_cam_rh_no.h"
#include "test_cam_rh_zo.h"
#undef GLM #undef GLM
#undef GLM_PREFIX #undef GLM_PREFIX
@@ -55,7 +59,11 @@
#include "test_affine2d.h" #include "test_affine2d.h"
#include "test_affine_mat.h" #include "test_affine_mat.h"
#include "test_ray.h" #include "test_ray.h"
#include "test_camera.h" #include "test_cam.h"
#include "test_cam_lh_no.h"
#include "test_cam_lh_zo.h"
#include "test_cam_rh_no.h"
#include "test_cam_rh_zo.h"
#undef GLM #undef GLM
#undef GLM_PREFIX #undef GLM_PREFIX

View File

@@ -223,12 +223,19 @@ TEST_DECLARE(glmc_mat2_swap_row)
TEST_DECLARE(glmc_mat2_rmc) TEST_DECLARE(glmc_mat2_rmc)
/* camera (incl [LR]H cross [NZ]O) */ /* camera (incl [LR]H cross [NZ]O) */
TEST_DECLARE(perspective_lh_zo) TEST_DECLARE(glm_perspective_lh_zo)
TEST_DECLARE(perspective_rh_zo) TEST_DECLARE(glm_perspective_rh_zo)
TEST_DECLARE(perspective_lh_no) TEST_DECLARE(glm_perspective_lh_no)
TEST_DECLARE(perspective_rh_no) TEST_DECLARE(glm_perspective_rh_no)
TEST_DECLARE(camera_lookat) TEST_DECLARE(glm_camera_lookat)
TEST_DECLARE(camera_decomp) TEST_DECLARE(glm_camera_decomp)
TEST_DECLARE(glmc_perspective_lh_zo)
TEST_DECLARE(glmc_perspective_rh_zo)
TEST_DECLARE(glmc_perspective_lh_no)
TEST_DECLARE(glmc_perspective_rh_no)
TEST_DECLARE(glmc_camera_lookat)
TEST_DECLARE(glmc_camera_decomp)
TEST_DECLARE(glm_frustum) TEST_DECLARE(glm_frustum)
@@ -1057,12 +1064,19 @@ TEST_LIST {
TEST_ENTRY(glmc_mat2_rmc) TEST_ENTRY(glmc_mat2_rmc)
/* camera (incl [LR]H cross [NZ]O) */ /* camera (incl [LR]H cross [NZ]O) */
TEST_ENTRY(perspective_lh_zo) TEST_ENTRY(glm_perspective_lh_zo)
TEST_ENTRY(perspective_rh_zo) TEST_ENTRY(glm_perspective_rh_zo)
TEST_ENTRY(perspective_lh_no) TEST_ENTRY(glm_perspective_lh_no)
TEST_ENTRY(perspective_rh_no) TEST_ENTRY(glm_perspective_rh_no)
TEST_ENTRY(camera_lookat) TEST_ENTRY(glm_camera_lookat)
TEST_ENTRY(camera_decomp) TEST_ENTRY(glm_camera_decomp)
TEST_ENTRY(glmc_perspective_lh_zo)
TEST_ENTRY(glmc_perspective_rh_zo)
TEST_ENTRY(glmc_perspective_lh_no)
TEST_ENTRY(glmc_perspective_rh_no)
TEST_ENTRY(glmc_camera_lookat)
TEST_ENTRY(glmc_camera_decomp)
TEST_ENTRY(glm_frustum) TEST_ENTRY(glm_frustum)

View File

@@ -17,9 +17,6 @@
<ClCompile Include="..\test\src\test_bezier.c"> <ClCompile Include="..\test\src\test_bezier.c">
<Filter>src</Filter> <Filter>src</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\test\src\test_cam.c">
<Filter>src</Filter>
</ClCompile>
<ClCompile Include="..\test\src\test_clamp.c"> <ClCompile Include="..\test\src\test_clamp.c">
<Filter>src</Filter> <Filter>src</Filter>
</ClCompile> </ClCompile>
@@ -35,18 +32,6 @@
<ClCompile Include="..\test\src\tests.c"> <ClCompile Include="..\test\src\tests.c">
<Filter>src</Filter> <Filter>src</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\test\src\test_cam_lh_no.c">
<Filter>src</Filter>
</ClCompile>
<ClCompile Include="..\test\src\test_cam_lh_zo.c">
<Filter>src</Filter>
</ClCompile>
<ClCompile Include="..\test\src\test_cam_rh_no.c">
<Filter>src</Filter>
</ClCompile>
<ClCompile Include="..\test\src\test_cam_rh_zo.c">
<Filter>src</Filter>
</ClCompile>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClInclude Include="..\test\tests.h"> <ClInclude Include="..\test\tests.h">
@@ -58,46 +43,28 @@
<ClInclude Include="..\test\include\common.h"> <ClInclude Include="..\test\include\common.h">
<Filter>include</Filter> <Filter>include</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="..\test\src\test_mat3.h">
<Filter>src</Filter>
</ClInclude>
<ClInclude Include="..\test\src\test_mat4.h">
<Filter>src</Filter>
</ClInclude>
<ClInclude Include="..\test\src\test_project.h">
<Filter>src</Filter>
</ClInclude>
<ClInclude Include="..\test\src\test_quat.h">
<Filter>src</Filter>
</ClInclude>
<ClInclude Include="..\test\src\test_vec3.h">
<Filter>src</Filter>
</ClInclude>
<ClInclude Include="..\test\src\test_vec4.h">
<Filter>src</Filter>
</ClInclude>
<ClInclude Include="..\test\src\test_affine.h"> <ClInclude Include="..\test\src\test_affine.h">
<Filter>src</Filter> <Filter>src</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="..\test\src\test_affine_mat.h"> <ClInclude Include="..\test\src\test_affine_mat.h">
<Filter>src</Filter> <Filter>src</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="..\test\src\test_mat2.h">
<Filter>src</Filter>
</ClInclude>
<ClInclude Include="..\test\src\test_plane.h">
<Filter>src</Filter>
</ClInclude>
<ClInclude Include="..\test\src\test_vec2.h">
<Filter>src</Filter>
</ClInclude>
<ClInclude Include="..\test\src\test_ray.h">
<Filter>src</Filter>
</ClInclude>
<ClInclude Include="..\test\src\test_affine2d.h"> <ClInclude Include="..\test\src\test_affine2d.h">
<Filter>src</Filter> <Filter>src</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="..\test\src\test_camera.h"> <ClInclude Include="..\test\src\test_cam.h">
<Filter>src</Filter>
</ClInclude>
<ClInclude Include="..\test\src\test_cam_lh_no.h">
<Filter>src</Filter>
</ClInclude>
<ClInclude Include="..\test\src\test_cam_lh_zo.h">
<Filter>src</Filter>
</ClInclude>
<ClInclude Include="..\test\src\test_cam_rh_no.h">
<Filter>src</Filter>
</ClInclude>
<ClInclude Include="..\test\src\test_cam_rh_zo.h">
<Filter>src</Filter> <Filter>src</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="..\test\src\test_ivec2.h"> <ClInclude Include="..\test\src\test_ivec2.h">
@@ -109,5 +76,35 @@
<ClInclude Include="..\test\src\test_ivec4.h"> <ClInclude Include="..\test\src\test_ivec4.h">
<Filter>src</Filter> <Filter>src</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="..\test\src\test_mat2.h">
<Filter>src</Filter>
</ClInclude>
<ClInclude Include="..\test\src\test_mat3.h">
<Filter>src</Filter>
</ClInclude>
<ClInclude Include="..\test\src\test_mat4.h">
<Filter>src</Filter>
</ClInclude>
<ClInclude Include="..\test\src\test_plane.h">
<Filter>src</Filter>
</ClInclude>
<ClInclude Include="..\test\src\test_project.h">
<Filter>src</Filter>
</ClInclude>
<ClInclude Include="..\test\src\test_quat.h">
<Filter>src</Filter>
</ClInclude>
<ClInclude Include="..\test\src\test_ray.h">
<Filter>src</Filter>
</ClInclude>
<ClInclude Include="..\test\src\test_vec2.h">
<Filter>src</Filter>
</ClInclude>
<ClInclude Include="..\test\src\test_vec3.h">
<Filter>src</Filter>
</ClInclude>
<ClInclude Include="..\test\src\test_vec4.h">
<Filter>src</Filter>
</ClInclude>
</ItemGroup> </ItemGroup>
</Project> </Project>