From 91e8903699224b9ebb91544e60e7c6f35834847c Mon Sep 17 00:00:00 2001 From: Abtin Keshavarzian Date: Wed, 27 Nov 2019 11:23:42 -0800 Subject: [PATCH] [unit-test] use OT_STATIC_ASSERT in unit tests (#4367) This commit removes `CompileTimeAssert` (which was an empty macro). Instead `OT_STATIC_ASSERT` is used in `test_toolchain.cpp`. --- tests/unit/test_toolchain.cpp | 7 ++++--- tests/unit/test_util.h | 9 --------- 2 files changed, 4 insertions(+), 12 deletions(-) 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