mirror of
https://github.com/recp/cglm.git
synced 2026-02-17 03:39:05 +00:00
add tests for clamp
This commit is contained in:
@@ -104,7 +104,8 @@ test_tests_SOURCES=\
|
|||||||
test/src/test_common.c \
|
test/src/test_common.c \
|
||||||
test/src/test_main.c \
|
test/src/test_main.c \
|
||||||
test/src/test_mat4.c \
|
test/src/test_mat4.c \
|
||||||
test/src/test_cam.c
|
test/src/test_cam.c \
|
||||||
|
test/src/test_clamp.c
|
||||||
|
|
||||||
all-local:
|
all-local:
|
||||||
sh ./post-build.sh
|
sh ./post-build.sh
|
||||||
|
|||||||
30
test/src/test_clamp.c
Normal file
30
test/src/test_clamp.c
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
/*
|
||||||
|
* 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"
|
||||||
|
|
||||||
|
void
|
||||||
|
test_clamp(void **state) {
|
||||||
|
vec3 v3 = {15.07, 0.4, 17.3};
|
||||||
|
vec4 v4 = {5.07, 2.3, 1.3, 1.4};
|
||||||
|
|
||||||
|
assert_true(glm_clamp(1.6f, 0.0f, 1.0f) == 1.0f);
|
||||||
|
assert_true(glm_clamp(-1.6f, 0.0f, 1.0f) == 0.0f);
|
||||||
|
assert_true(glm_clamp(0.6f, 0.0f, 1.0f) == 0.6f);
|
||||||
|
|
||||||
|
glm_vec_clamp(v3, 0.0, 1.0);
|
||||||
|
glm_vec4_clamp(v4, 1.5, 3.0);
|
||||||
|
|
||||||
|
assert_true(v3[0] == 1.0f);
|
||||||
|
assert_true(v3[1] == 0.4f);
|
||||||
|
assert_true(v3[2] == 1.0f);
|
||||||
|
|
||||||
|
assert_true(v4[0] == 3.0f);
|
||||||
|
assert_true(v4[1] == 2.3f);
|
||||||
|
assert_true(v4[2] == 1.5f);
|
||||||
|
assert_true(v4[3] == 1.5f);
|
||||||
|
}
|
||||||
@@ -14,7 +14,10 @@ main(int argc, const char * argv[]) {
|
|||||||
|
|
||||||
/* camera */
|
/* camera */
|
||||||
cmocka_unit_test(test_camera_lookat),
|
cmocka_unit_test(test_camera_lookat),
|
||||||
cmocka_unit_test(test_camera_decomp)
|
cmocka_unit_test(test_camera_decomp),
|
||||||
|
|
||||||
|
/* vector */
|
||||||
|
cmocka_unit_test(test_clamp)
|
||||||
};
|
};
|
||||||
|
|
||||||
return cmocka_run_group_tests(tests, NULL, NULL);
|
return cmocka_run_group_tests(tests, NULL, NULL);
|
||||||
|
|||||||
@@ -16,4 +16,7 @@ test_camera_lookat(void **state);
|
|||||||
void
|
void
|
||||||
test_camera_decomp(void **state);
|
test_camera_decomp(void **state);
|
||||||
|
|
||||||
|
void
|
||||||
|
test_clamp(void **state);
|
||||||
|
|
||||||
#endif /* test_tests_h */
|
#endif /* test_tests_h */
|
||||||
|
|||||||
Reference in New Issue
Block a user