diff --git a/tests/test_internal.c b/tests/test_internal.c index 004dc6f..ee833a3 100644 --- a/tests/test_internal.c +++ b/tests/test_internal.c @@ -19,6 +19,7 @@ #include "../src/gmio_core/internal/byte_codec.h" #include "../src/gmio_core/internal/byte_swap.h" +#include "../src/gmio_core/internal/safe_cast.h" #include "../src/gmio_core/internal/string_parse.h" #include "stream_buffer.h" @@ -56,6 +57,17 @@ const char* test_internal__byte_codec() return NULL; } +const char* test_internal__safe_cast() +{ +#if GMIO_TARGET_ARCH_BIT_SIZE > 32 + const size_t maxUInt32 = 0xFFFFFFFF; + UTEST_ASSERT(gmio_size_to_uint32(maxUInt32 + 1) == 0xFFFFFFFF); + UTEST_ASSERT(gmio_size_to_uint32(0xFFFFFFFF) == 0xFFFFFFFF); + UTEST_ASSERT(gmio_size_to_uint32(100) == 100); +#endif + return NULL; +} + const char* test_internal__string_parse() { const char text[] = @@ -127,6 +139,7 @@ const char* all_tests() UTEST_SUITE_START(); UTEST_RUN(test_internal__byte_swap); UTEST_RUN(test_internal__byte_codec); + UTEST_RUN(test_internal__safe_cast); UTEST_RUN(test_internal__string_parse); return NULL; }