From a264e27f7c781bb8153c3ad2bd2fccb656eb61f0 Mon Sep 17 00:00:00 2001 From: John Van Enk Date: Wed, 3 Oct 2012 14:17:07 -0400 Subject: [PATCH] Switch up the testing strategy to handle funny architectural issues. --- test/testunity.c | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/test/testunity.c b/test/testunity.c index 8af6adb..e98ca8f 100755 --- a/test/testunity.c +++ b/test/testunity.c @@ -52,13 +52,32 @@ void tearDown(void) void testUnitySizeInitializationReminder(void) { - char * message = "Unexpected size for _Unity struct. Please check that " - "the initialization of the Unity symbol in unity.c is " - "still correct."; /* This test ensures that sizeof(struct _Unity) doesn't change. If this * test breaks, go look at the initialization of the Unity global variable * in unity.c and make sure we're filling in the proper fields. */ - TEST_ASSERT_EQUAL_MESSAGE(104, sizeof(Unity), message); + char * message = "Unexpected size for _Unity struct. Please check that " + "the initialization of the Unity symbol in unity.c is " + "still correct."; + + /* Define a structure with all the same fields as `struct _Unity`. */ + struct { + const char* TestFile; + const char* CurrentTestName; + UNITY_LINE_TYPE CurrentTestLineNumber; + UNITY_COUNTER_TYPE NumberOfTests; + UNITY_COUNTER_TYPE TestFailures; + UNITY_COUNTER_TYPE TestIgnores; + UNITY_COUNTER_TYPE CurrentTestFailed; + UNITY_COUNTER_TYPE CurrentTestIgnored; + jmp_buf AbortFrame; + } _Expected_Unity; + + /* Compare our fake structure's size to the actual structure's size. They + * should be the same. + * + * This accounts for alignment, padding, and packing issues that might come + * up between different architectures. */ + TEST_ASSERT_EQUAL_MESSAGE(sizeof(_Expected_Unity), sizeof(Unity), message); } void testTrue(void) -- GitLab