Integrate CMocka to do unit testing
parent
6005d3f490
commit
ca621bf798
|
@ -97,3 +97,8 @@ target_link_libraries(assets_test
|
||||||
${GAME_LIBS}
|
${GAME_LIBS}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if (UNIT_TESTING)
|
||||||
|
find_package(cmocka 1.1.0 REQUIRED)
|
||||||
|
add_subdirectory(tests)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,9 @@
|
||||||
|
add_executable(AABBTest test_AABB.c)
|
||||||
|
target_compile_features(AABBTest PRIVATE c_std_99)
|
||||||
|
target_link_libraries(AABBTest PRIVATE
|
||||||
|
cmocka
|
||||||
|
lib_scenes
|
||||||
|
)
|
||||||
|
|
||||||
|
enable_testing()
|
||||||
|
add_test(NAME AABBTest COMMAND AABBTest)
|
|
@ -0,0 +1,25 @@
|
||||||
|
#include "AABB.h"
|
||||||
|
|
||||||
|
#include <stdarg.h>
|
||||||
|
#include <stddef.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <setjmp.h>
|
||||||
|
#include <cmocka.h>
|
||||||
|
|
||||||
|
static void test_no_overlap(void **state)
|
||||||
|
{
|
||||||
|
(void) state;
|
||||||
|
Vector2 a = {0, 5};
|
||||||
|
Vector2 b = {6, 9};
|
||||||
|
float overlap = 0;
|
||||||
|
assert_int_equal(find_1D_overlap(a, b, &overlap), 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(void)
|
||||||
|
{
|
||||||
|
const struct CMUnitTest tests[] = {
|
||||||
|
cmocka_unit_test(test_no_overlap),
|
||||||
|
};
|
||||||
|
|
||||||
|
return cmocka_run_group_tests(tests, NULL, NULL);
|
||||||
|
}
|
Loading…
Reference in New Issue