Windows Unit Test Support (#629)

Window Unit Test Support
This commit is contained in:
Nick Banks
2016-09-20 18:11:19 -07:00
committed by Jonathan Hui
parent 4bd62977d4
commit 25cea9414b
19 changed files with 753 additions and 123 deletions
+17 -6
View File
@@ -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