diff --git a/src/unity.c b/src/unity.c index 87c7aec..398da66 100644 --- a/src/unity.c +++ b/src/unity.c @@ -571,26 +571,26 @@ void UnityConcludeTest(void) /*-----------------------------------------------*/ static void UnityAddMsgIfSpecified(const char* msg) { - if (msg) - { - UnityPrint(UnityStrSpacer); - #ifdef UNITY_PRINT_TEST_CONTEXT - UNITY_PRINT_TEST_CONTEXT(); + UnityPrint(UnityStrSpacer); + UNITY_PRINT_TEST_CONTEXT(); #endif #ifndef UNITY_EXCLUDE_DETAILS - if (Unity.CurrentDetail1) + if (Unity.CurrentDetail1) + { + UnityPrint(UnityStrSpacer); + UnityPrint(UnityStrDetail1Name); + UnityPrint(Unity.CurrentDetail1); + if (Unity.CurrentDetail2) { - UnityPrint(UnityStrDetail1Name); - UnityPrint(Unity.CurrentDetail1); - if (Unity.CurrentDetail2) - { - UnityPrint(UnityStrDetail2Name); - UnityPrint(Unity.CurrentDetail2); - } - UnityPrint(UnityStrSpacer); + UnityPrint(UnityStrDetail2Name); + UnityPrint(Unity.CurrentDetail2); } -#endif + } +#endif + if (msg) + { + UnityPrint(UnityStrSpacer); UnityPrint(msg); } } @@ -819,12 +819,22 @@ void UnityAssertEqualIntArray(UNITY_INTERNAL_PTR expected, case 1: expect_val = *(UNITY_PTR_ATTRIBUTE const UNITY_INT8*)expected; actual_val = *(UNITY_PTR_ATTRIBUTE const UNITY_INT8*)actual; + if (style & (UNITY_DISPLAY_RANGE_UINT | UNITY_DISPLAY_RANGE_HEX)) + { + expect_val &= 0x000000FF; + actual_val &= 0x000000FF; + } increment = sizeof(UNITY_INT8); break; case 2: expect_val = *(UNITY_PTR_ATTRIBUTE const UNITY_INT16*)expected; actual_val = *(UNITY_PTR_ATTRIBUTE const UNITY_INT16*)actual; + if (style & (UNITY_DISPLAY_RANGE_UINT | UNITY_DISPLAY_RANGE_HEX)) + { + expect_val &= 0x0000FFFF; + actual_val &= 0x0000FFFF; + } increment = sizeof(UNITY_INT16); break; @@ -839,7 +849,14 @@ void UnityAssertEqualIntArray(UNITY_INTERNAL_PTR expected, default: /* default is length 4 bytes */ case 4: expect_val = *(UNITY_PTR_ATTRIBUTE const UNITY_INT32*)expected; - actual_val = *(UNITY_PTR_ATTRIBUTE const UNITY_INT32*)actual; + actual_val = *(UNITY_PTR_ATTRIBUTE const UNITY_INT32*)actual; +#ifdef UNITY_SUPPORT_64 + if (style & (UNITY_DISPLAY_RANGE_UINT | UNITY_DISPLAY_RANGE_HEX)) + { + expect_val &= 0x00000000FFFFFFFF; + actual_val &= 0x00000000FFFFFFFF; + } +#endif increment = sizeof(UNITY_INT32); length = 4; break; diff --git a/test/rakefile_helper.rb b/test/rakefile_helper.rb index 8678944..4487a28 100644 --- a/test/rakefile_helper.rb +++ b/test/rakefile_helper.rb @@ -173,7 +173,7 @@ module RakefileHelpers def execute(command_string, ok_to_fail = false) report command_string if $verbose output = `#{command_string}`.chomp - report(output) if $verbose && !output.nil? && !output.empty? + report(output) if ($verbose && !output.nil? && !output.empty?) || (!$?.nil? && !$?.exitstatus.zero? && !ok_to_fail) raise "Command failed. (Returned #{$?.exitstatus})" if !$?.nil? && !$?.exitstatus.zero? && !ok_to_fail output end diff --git a/test/tests/test_unity_arrays.c b/test/tests/test_unity_arrays.c index ff90a6c..8d5bb47 100644 --- a/test/tests/test_unity_arrays.c +++ b/test/tests/test_unity_arrays.c @@ -1133,6 +1133,18 @@ void testHEX64ArrayWithinDelta(void) #endif } +void testHEX64ArrayWithinDeltaShouldNotHaveSignIssues(void) +{ +#ifndef UNITY_SUPPORT_64 + TEST_IGNORE(); +#else + UNITY_UINT64 expected[] = {0x7FFFFFFFFFFFFFFF, 0x8000000000000000}; + UNITY_UINT64 actualBigDelta[] = {0x8000000000000000, 0x7FFFFFFFFFFFFFFF}; + + TEST_ASSERT_HEX64_ARRAY_WITHIN(1, expected, actualBigDelta, 2); +#endif +} + void testHEX64ArrayWithinDeltaAndMessage(void) { #ifndef UNITY_SUPPORT_64 @@ -1287,6 +1299,14 @@ void testHEX32ArrayWithinDelta(void) TEST_ASSERT_HEX32_ARRAY_WITHIN(110, expected, actualBigDelta, 3); } +void testHEX32ArrayWithinDeltaShouldNotHaveSignIssues(void) +{ + UNITY_UINT32 expected[] = {0x7FFFFFFF, 0x80000000}; + UNITY_UINT32 actualBigDelta[] = {0x80000000, 0x7FFFFFFF}; + + TEST_ASSERT_HEX32_ARRAY_WITHIN(1, expected, actualBigDelta, 2); +} + void testHEX32ArrayWithinDeltaAndMessage(void) { UNITY_UINT expected[] = {0xABCD1234, 0xABCD1122, 0xABCD1277}; @@ -1398,6 +1418,14 @@ void testHEX16ArrayWithinDelta(void) TEST_ASSERT_HEX16_ARRAY_WITHIN(110, expected, actualBigDelta, 3); } +void testHEX16ArrayWithinDeltaShouldNotHaveSignIssues(void) +{ + UNITY_UINT16 expected[] = {0x7FFF, 0x8000}; + UNITY_UINT16 actualBigDelta[] = {0x8000, 0x7FFF}; + + TEST_ASSERT_HEX16_ARRAY_WITHIN(1, expected, actualBigDelta, 2); +} + void testHEX16ArrayWithinDeltaAndMessage(void) { UNITY_UINT16 expected[] = {0x1234, 0x1122, 0x1277}; @@ -1528,6 +1556,14 @@ void testHEX8ArrayNotWithinDelta(void) VERIFY_FAILS_END } +void testHEX8ArrayWithinDeltaShouldNotHaveSignIssues(void) +{ + UNITY_UINT8 expected[] = {0x7F, 0x80}; + UNITY_UINT8 actualBigDelta[] = {0x80, 0x7F}; + + TEST_ASSERT_HEX8_ARRAY_WITHIN(1, expected, actualBigDelta, 2); +} + void testHEX8ArrayNotWithinDeltaAndMessage(void) { UNITY_UINT8 expected[] = {0x34, 0x22, 0x77}; diff --git a/test/tests/test_unity_integers.c b/test/tests/test_unity_integers.c index 7bdfa14..d615e5f 100644 --- a/test/tests/test_unity_integers.c +++ b/test/tests/test_unity_integers.c @@ -800,6 +800,11 @@ void testHEX32sWithinDelta(void) TEST_ASSERT_HEX32_WITHIN(5, 5000, 5005); } +void testHEX32sWithinDeltaShouldIgnoreSign(void) +{ + TEST_ASSERT_HEX32_WITHIN(1, 0x7FFFFFFF, 0x80000000); +} + void testHEX32sWithinDeltaAndCustomMessage(void) { TEST_ASSERT_HEX32_WITHIN_MESSAGE(1, 5000, 5001, "Custom Message."); @@ -842,6 +847,11 @@ void testHEX16sWithinDelta(void) TEST_ASSERT_HEX16_WITHIN(5, 5000, 5005); } +void testHEX16sWithinDeltaShouldIgnoreSign(void) +{ + TEST_ASSERT_HEX16_WITHIN(1, 0x7FFF, 0x8000); +} + void testHEX16sWithinDeltaAndCustomMessage(void) { TEST_ASSERT_HEX16_WITHIN_MESSAGE(1, 5000, 5001, "Custom Message."); @@ -880,6 +890,11 @@ void testHEX8sWithinDelta(void) TEST_ASSERT_HEX8_WITHIN(5, 1, 4); } +void testHEX8sWithinDeltaShouldIgnoreSign(void) +{ + TEST_ASSERT_HEX8_WITHIN(1, 0x7F, 0x80); +} + void testHEX8sWithinDeltaAndCustomMessage(void) { TEST_ASSERT_HEX8_WITHIN_MESSAGE(1, 254, 255, "Custom Message."); diff --git a/test/tests/test_unity_integers_64.c b/test/tests/test_unity_integers_64.c index e12566e..867d1e7 100644 --- a/test/tests/test_unity_integers_64.c +++ b/test/tests/test_unity_integers_64.c @@ -652,6 +652,15 @@ void testHEX64sWithinDelta(void) #endif } +void testHEX32sWithinDeltaShouldIgnoreSign(void) +{ +#ifndef UNITY_SUPPORT_64 + TEST_IGNORE(); +#else + TEST_ASSERT_HEX64_WITHIN(1, 0x7FFFFFFFFFFFFFFF,0x8000000000000000); +#endif +} + void testHEX64sNotWithinDelta(void) { #ifndef UNITY_SUPPORT_64