mirror of
https://github.com/espressif/openthread.git
synced 2026-08-29 21:39:54 +00:00
@@ -34,23 +34,29 @@
|
||||
|
||||
void test_packed1()
|
||||
{
|
||||
typedef OT_TOOL_PACKED_BEGIN struct
|
||||
OT_TOOL_PACKED_BEGIN
|
||||
struct packed_t
|
||||
{
|
||||
uint8_t mByte;
|
||||
uint32_t mWord;
|
||||
uint16_t mShort;
|
||||
} OT_TOOL_PACKED_END packed_t;
|
||||
} OT_TOOL_PACKED_END;
|
||||
|
||||
CompileTimeAssert(sizeof(packed_t) == 7, "packed_t should be packed to 7 bytes");
|
||||
|
||||
VerifyOrQuit(sizeof(packed_t) == 7, "Toolchain::OT_TOOL_PACKED failed 1\n");
|
||||
}
|
||||
|
||||
void test_packed2()
|
||||
{
|
||||
typedef OT_TOOL_PACKED_BEGIN struct
|
||||
OT_TOOL_PACKED_BEGIN
|
||||
struct packed_t
|
||||
{
|
||||
uint8_t mBytes[3];
|
||||
uint8_t mByte;
|
||||
} OT_TOOL_PACKED_END packed_t;
|
||||
} OT_TOOL_PACKED_END;
|
||||
|
||||
CompileTimeAssert(sizeof(packed_t) == 4, "packed_t should be packed to 4 bytes");
|
||||
|
||||
VerifyOrQuit(sizeof(packed_t) == 4, "Toolchain::OT_TOOL_PACKED failed 2\n");
|
||||
}
|
||||
@@ -62,7 +68,8 @@ void test_packed_union()
|
||||
uint16_t mField;
|
||||
} nested_t;
|
||||
|
||||
typedef OT_TOOL_PACKED_BEGIN struct
|
||||
OT_TOOL_PACKED_BEGIN
|
||||
struct packed_t
|
||||
{
|
||||
uint8_t mBytes[3];
|
||||
union
|
||||
@@ -70,7 +77,9 @@ void test_packed_union()
|
||||
nested_t mNestedStruct;
|
||||
uint8_t mByte;
|
||||
} OT_TOOL_PACKED_FIELD;
|
||||
} OT_TOOL_PACKED_END packed_t;
|
||||
} OT_TOOL_PACKED_END;
|
||||
|
||||
CompileTimeAssert(sizeof(packed_t) == 5, "packed_t should be packed to 5 bytes");
|
||||
|
||||
VerifyOrQuit(sizeof(packed_t) == 5, "Toolchain::OT_TOOL_PACKED failed 3\n");
|
||||
}
|
||||
@@ -92,9 +101,11 @@ void TestToolchain(void)
|
||||
test_packed_enum();
|
||||
}
|
||||
|
||||
#ifdef ENABLE_TEST_MAIN
|
||||
int main(void)
|
||||
{
|
||||
TestToolchain();
|
||||
printf("All tests passed\n");
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user