Add unit tests for expected platform behavior
This commit is contained in:
parent
e5b19fb151
commit
35e479bc28
@ -182,10 +182,11 @@ enable_testing()
|
||||
set(CMAKE_CTEST_COMMAND ctest -V)
|
||||
add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND})
|
||||
|
||||
add_executable(test_internal EXCLUDE_FROM_ALL tests/test_internal.c
|
||||
tests/stream_buffer.c
|
||||
add_executable(test_internal EXCLUDE_FROM_ALL tests/stream_buffer.c
|
||||
tests/test_internal.c
|
||||
src/stream.c
|
||||
src/internal/ascii_parse.c)
|
||||
add_executable(test_platform EXCLUDE_FROM_ALL tests/test_platform.c)
|
||||
add_test(test_internal test_internal)
|
||||
add_dependencies(check test_internal)
|
||||
|
||||
add_test(test_platform test_platform)
|
||||
add_dependencies(check test_internal test_platform)
|
||||
|
50
tests/test_platform.c
Normal file
50
tests/test_platform.c
Normal file
@ -0,0 +1,50 @@
|
||||
#include "utest_lib.h"
|
||||
|
||||
#include "../src/global.h"
|
||||
#include "../src/libstl/stl_triangle.h"
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
const char* test_platform__alignment()
|
||||
{
|
||||
UTEST_ASSERT(offsetof(foug_stl_coords_t, x) == 0);
|
||||
UTEST_ASSERT(offsetof(foug_stl_coords_t, y) == 4);
|
||||
UTEST_ASSERT(offsetof(foug_stl_coords_t, z) == 8);
|
||||
UTEST_ASSERT(sizeof(foug_stl_coords_t) == FOUG_STL_COORDS_RAWSIZE);
|
||||
|
||||
UTEST_ASSERT(offsetof(foug_stl_triangle_t, normal) == 0);
|
||||
UTEST_ASSERT(offsetof(foug_stl_triangle_t, v1) == FOUG_STL_COORDS_RAWSIZE);
|
||||
UTEST_ASSERT(offsetof(foug_stl_triangle_t, v2) == 2*FOUG_STL_COORDS_RAWSIZE);
|
||||
UTEST_ASSERT(offsetof(foug_stl_triangle_t, v3) == 3*FOUG_STL_COORDS_RAWSIZE);
|
||||
UTEST_ASSERT(offsetof(foug_stl_triangle_t, attribute_byte_count) == 4*FOUG_STL_COORDS_RAWSIZE);
|
||||
UTEST_ASSERT(sizeof(foug_stl_triangle_t) >= FOUG_STLB_TRIANGLE_RAWSIZE);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const char* test_platform__global_h()
|
||||
{
|
||||
UTEST_ASSERT(sizeof(int8_t) == 1);
|
||||
UTEST_ASSERT(sizeof(uint8_t) == 1);
|
||||
|
||||
UTEST_ASSERT(sizeof(int16_t) == 2);
|
||||
UTEST_ASSERT(sizeof(uint16_t) == 2);
|
||||
|
||||
UTEST_ASSERT(sizeof(int32_t) == 4);
|
||||
UTEST_ASSERT(sizeof(uint32_t) == 4);
|
||||
|
||||
UTEST_ASSERT(sizeof(foug_real32_t) == 4);
|
||||
UTEST_ASSERT(sizeof(foug_real64_t) == 8);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const char* all_tests()
|
||||
{
|
||||
UTEST_SUITE_START();
|
||||
UTEST_RUN(test_platform__alignment);
|
||||
UTEST_RUN(test_platform__global_h);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
UTEST_MAIN(all_tests)
|
Loading…
Reference in New Issue
Block a user