diff --git a/tests/unit/test_toolchain.cpp b/tests/unit/test_toolchain.cpp index 07878817e..a66317a41 100644 --- a/tests/unit/test_toolchain.cpp +++ b/tests/unit/test_toolchain.cpp @@ -34,6 +34,7 @@ #include "test_util.h" #include "thread/topology.hpp" +#include "utils/static_assert.hpp" extern "C" { uint32_t otNetifAddress_Size_c(); @@ -51,7 +52,7 @@ void test_packed1() uint16_t mShort; } OT_TOOL_PACKED_END; - CompileTimeAssert(sizeof(packed_t) == 7, "packed_t should be packed to 7 bytes"); + OT_STATIC_ASSERT(sizeof(packed_t) == 7, "packed_t should be packed to 7 bytes"); VerifyOrQuit(sizeof(packed_t) == 7, "Toolchain::OT_TOOL_PACKED failed 1"); } @@ -65,7 +66,7 @@ void test_packed2() uint8_t mByte; } OT_TOOL_PACKED_END; - CompileTimeAssert(sizeof(packed_t) == 4, "packed_t should be packed to 4 bytes"); + OT_STATIC_ASSERT(sizeof(packed_t) == 4, "packed_t should be packed to 4 bytes"); VerifyOrQuit(sizeof(packed_t) == 4, "Toolchain::OT_TOOL_PACKED failed 2"); } @@ -88,7 +89,7 @@ void test_packed_union() } OT_TOOL_PACKED_FIELD; } OT_TOOL_PACKED_END; - CompileTimeAssert(sizeof(packed_t) == 5, "packed_t should be packed to 5 bytes"); + OT_STATIC_ASSERT(sizeof(packed_t) == 5, "packed_t should be packed to 5 bytes"); VerifyOrQuit(sizeof(packed_t) == 5, "Toolchain::OT_TOOL_PACKED failed 3"); } diff --git a/tests/unit/test_util.h b/tests/unit/test_util.h index c54a8c18f..6e155cf5f 100644 --- a/tests/unit/test_util.h +++ b/tests/unit/test_util.h @@ -72,15 +72,6 @@ extern "C" { } \ } while (false) -//#define CompileTimeAssert(COND, MSG) typedef char __C_ASSERT__[(COND)?1:-1] - -// I would use the above definition for CompileTimeAssert, but I am getting the following errors -// when I run 'make -f examples/Makefile-posix distcheck': -// -// error: typedef "__C_ASSERT__" locally defined but not used [-Werror=unused-local-typedefs] -// -#define CompileTimeAssert(COND, MSG) - #ifdef __cplusplus } #endif