1
0
mirror of https://github.com/ThrowTheSwitch/Unity.git synced 2026-01-23 00:15:58 +01:00

Rearrange details to always print if given, no matter if another msg added or not.

Print output on failures no matter if verbose or not.
Enforce that HEX comparisons are unsigned comparisons.
This commit is contained in:
Mark VanderVoord
2022-04-19 16:21:04 -04:00
parent b9e9268d92
commit 0df1d442cb
5 changed files with 94 additions and 17 deletions

View File

@@ -571,26 +571,26 @@ void UnityConcludeTest(void)
/*-----------------------------------------------*/
static void UnityAddMsgIfSpecified(const char* msg)
{
#ifdef UNITY_PRINT_TEST_CONTEXT
UnityPrint(UnityStrSpacer);
UNITY_PRINT_TEST_CONTEXT();
#endif
#ifndef UNITY_EXCLUDE_DETAILS
if (Unity.CurrentDetail1)
{
UnityPrint(UnityStrSpacer);
UnityPrint(UnityStrDetail1Name);
UnityPrint(Unity.CurrentDetail1);
if (Unity.CurrentDetail2)
{
UnityPrint(UnityStrDetail2Name);
UnityPrint(Unity.CurrentDetail2);
}
}
#endif
if (msg)
{
UnityPrint(UnityStrSpacer);
#ifdef UNITY_PRINT_TEST_CONTEXT
UNITY_PRINT_TEST_CONTEXT();
#endif
#ifndef UNITY_EXCLUDE_DETAILS
if (Unity.CurrentDetail1)
{
UnityPrint(UnityStrDetail1Name);
UnityPrint(Unity.CurrentDetail1);
if (Unity.CurrentDetail2)
{
UnityPrint(UnityStrDetail2Name);
UnityPrint(Unity.CurrentDetail2);
}
UnityPrint(UnityStrSpacer);
}
#endif
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;
@@ -840,6 +850,13 @@ void UnityAssertEqualIntArray(UNITY_INTERNAL_PTR expected,
case 4:
expect_val = *(UNITY_PTR_ATTRIBUTE const UNITY_INT32*)expected;
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;

View File

@@ -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

View File

@@ -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};

View File

@@ -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.");

View File

@@ -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