@@ -185,7 +185,7 @@ void UnityPrintLen(const char* string, const UNITY_UINT32 length)
185185}
186186
187187/*-----------------------------------------------*/
188- void UnityPrintNumberByStyle (const UNITY_INT number , const UNITY_DISPLAY_STYLE_T style )
188+ void UnityPrintIntNumberByStyle (const UNITY_INT number , const UNITY_DISPLAY_STYLE_T style )
189189{
190190 if ((style & UNITY_DISPLAY_RANGE_INT ) == UNITY_DISPLAY_RANGE_INT )
191191 {
@@ -223,12 +223,6 @@ void UnityPrintNumberByStyle(const UNITY_INT number, const UNITY_DISPLAY_STYLE_T
223223 UnityPrintNumber (number );
224224 }
225225 }
226- else
227- {
228- UNITY_OUTPUT_CHAR ('0' );
229- UNITY_OUTPUT_CHAR ('x' );
230- UnityPrintNumberHex ((UNITY_UINT )number , (char )((style & 0xF ) * 2 ));
231- }
232226}
233227
234228void UnityPrintUintNumberByStyle (const UNITY_UINT number , const UNITY_DISPLAY_STYLE_T style )
@@ -237,6 +231,12 @@ void UnityPrintUintNumberByStyle(const UNITY_UINT number, const UNITY_DISPLAY_ST
237231 {
238232 UnityPrintNumberUnsigned (number );
239233 }
234+ else
235+ {
236+ UNITY_OUTPUT_CHAR ('0' );
237+ UNITY_OUTPUT_CHAR ('x' );
238+ UnityPrintNumberHex ((UNITY_UINT )number , (char )((style & 0xF ) * 2 ));
239+ }
240240}
241241
242242/*-----------------------------------------------*/
@@ -725,9 +725,9 @@ void UnityAssertEqualIntNumber(const UNITY_INT expected,
725725 {
726726 UnityTestResultsFailBegin (lineNumber );
727727 UnityPrint (UnityStrExpected );
728- UnityPrintNumberByStyle (expected , style );
728+ UnityPrintIntNumberByStyle (expected , style );
729729 UnityPrint (UnityStrWas );
730- UnityPrintNumberByStyle (actual , style );
730+ UnityPrintIntNumberByStyle (actual , style );
731731 UnityAddMsgIfSpecified (msg );
732732 UNITY_FAIL_AND_BAIL ;
733733 }
@@ -753,40 +753,62 @@ void UnityAssertEqualUintNumber(const UNITY_UINT expected,
753753 }
754754}
755755/*-----------------------------------------------*/
756- void UnityAssertGreaterOrLessOrEqualNumber (const UNITY_INT threshold ,
757- const UNITY_INT actual ,
758- const UNITY_COMPARISON_T compare ,
759- const char * msg ,
760- const UNITY_LINE_TYPE lineNumber ,
761- const UNITY_DISPLAY_STYLE_T style )
756+ void UnityAssertIntGreaterOrLessOrEqualNumber (const UNITY_INT threshold ,
757+ const UNITY_INT actual ,
758+ const UNITY_COMPARISON_T compare ,
759+ const char * msg ,
760+ const UNITY_LINE_TYPE lineNumber ,
761+ const UNITY_DISPLAY_STYLE_T style )
762762{
763763 int failed = 0 ;
764764 RETURN_IF_FAIL_OR_IGNORE ;
765765
766- if ((threshold == actual ) && (compare & UNITY_EQUAL_TO )) { return ; }
767- if ((threshold == actual )) { failed = 1 ; }
766+ if ((threshold == actual ) && !(compare & UNITY_EQUAL_TO )) { failed = 1 ; }
768767
769- if ((style & UNITY_DISPLAY_RANGE_INT ) == UNITY_DISPLAY_RANGE_INT )
770- {
771- if ((actual > threshold ) && (compare & UNITY_SMALLER_THAN )) { failed = 1 ; }
772- if ((actual < threshold ) && (compare & UNITY_GREATER_THAN )) { failed = 1 ; }
773- }
774- else /* UINT or HEX */
768+ if ((actual > threshold ) && (compare & UNITY_SMALLER_THAN )) { failed = 1 ; }
769+ if ((actual < threshold ) && (compare & UNITY_GREATER_THAN )) { failed = 1 ; }
770+
771+ if (failed )
775772 {
776- if (((UNITY_UINT )actual > (UNITY_UINT )threshold ) && (compare & UNITY_SMALLER_THAN )) { failed = 1 ; }
777- if (((UNITY_UINT )actual < (UNITY_UINT )threshold ) && (compare & UNITY_GREATER_THAN )) { failed = 1 ; }
773+ UnityTestResultsFailBegin (lineNumber );
774+ UnityPrint (UnityStrExpected );
775+ UnityPrintIntNumberByStyle (actual , style );
776+ if (compare & UNITY_GREATER_THAN ) { UnityPrint (UnityStrGt ); }
777+ if (compare & UNITY_SMALLER_THAN ) { UnityPrint (UnityStrLt ); }
778+ if (compare & UNITY_EQUAL_TO ) { UnityPrint (UnityStrOrEqual ); }
779+ if (compare == UNITY_NOT_EQUAL ) { UnityPrint (UnityStrNotEqual ); }
780+ UnityPrintIntNumberByStyle (threshold , style );
781+ UnityAddMsgIfSpecified (msg );
782+ UNITY_FAIL_AND_BAIL ;
778783 }
784+ }
785+
786+ void UnityAssertUintGreaterOrLessOrEqualNumber (const UNITY_UINT threshold ,
787+ const UNITY_UINT actual ,
788+ const UNITY_COMPARISON_T compare ,
789+ const char * msg ,
790+ const UNITY_LINE_TYPE lineNumber ,
791+ const UNITY_DISPLAY_STYLE_T style )
792+ {
793+ int failed = 0 ;
794+ RETURN_IF_FAIL_OR_IGNORE ;
795+
796+ if ((threshold == actual ) && !(compare & UNITY_EQUAL_TO )) { failed = 1 ; }
797+
798+ /* UINT or HEX */
799+ if ((actual > threshold ) && (compare & UNITY_SMALLER_THAN )) { failed = 1 ; }
800+ if ((actual < threshold ) && (compare & UNITY_GREATER_THAN )) { failed = 1 ; }
779801
780802 if (failed )
781803 {
782804 UnityTestResultsFailBegin (lineNumber );
783805 UnityPrint (UnityStrExpected );
784- UnityPrintNumberByStyle (actual , style );
806+ UnityPrintUintNumberByStyle (actual , style );
785807 if (compare & UNITY_GREATER_THAN ) { UnityPrint (UnityStrGt ); }
786808 if (compare & UNITY_SMALLER_THAN ) { UnityPrint (UnityStrLt ); }
787809 if (compare & UNITY_EQUAL_TO ) { UnityPrint (UnityStrOrEqual ); }
788810 if (compare == UNITY_NOT_EQUAL ) { UnityPrint (UnityStrNotEqual ); }
789- UnityPrintNumberByStyle (threshold , style );
811+ UnityPrintUintNumberByStyle (threshold , style );
790812 UnityAddMsgIfSpecified (msg );
791813 UNITY_FAIL_AND_BAIL ;
792814 }
@@ -900,9 +922,9 @@ void UnityAssertEqualIntArray(UNITY_INTERNAL_PTR expected,
900922 UnityPrint (UnityStrElement );
901923 UnityPrintNumberUnsigned (num_elements - elements - 1 );
902924 UnityPrint (UnityStrExpected );
903- UnityPrintNumberByStyle (expect_val , style );
925+ UnityPrintIntNumberByStyle (expect_val , style );
904926 UnityPrint (UnityStrWas );
905- UnityPrintNumberByStyle (actual_val , style );
927+ UnityPrintIntNumberByStyle (actual_val , style );
906928 UnityAddMsgIfSpecified (msg );
907929 UNITY_FAIL_AND_BAIL ;
908930 }
@@ -1400,47 +1422,65 @@ void UnityAssertDoubleSpecial(const UNITY_DOUBLE actual,
14001422#endif /* not UNITY_EXCLUDE_DOUBLE */
14011423
14021424/*-----------------------------------------------*/
1403- void UnityAssertNumbersWithin (const UNITY_UINT delta ,
1404- const UNITY_INT expected ,
1405- const UNITY_INT actual ,
1406- const char * msg ,
1407- const UNITY_LINE_TYPE lineNumber ,
1408- const UNITY_DISPLAY_STYLE_T style )
1425+ void UnityAssertIntNumbersWithin (const UNITY_UINT delta ,
1426+ const UNITY_INT expected ,
1427+ const UNITY_INT actual ,
1428+ const char * msg ,
1429+ const UNITY_LINE_TYPE lineNumber ,
1430+ const UNITY_DISPLAY_STYLE_T style )
14091431{
14101432 RETURN_IF_FAIL_OR_IGNORE ;
14111433
1412- if (( style & UNITY_DISPLAY_RANGE_INT ) == UNITY_DISPLAY_RANGE_INT )
1434+ if (actual > expected )
14131435 {
1414- if (actual > expected )
1415- {
1416- Unity .CurrentTestFailed = (((UNITY_UINT )actual - (UNITY_UINT )expected ) > delta );
1417- }
1418- else
1419- {
1420- Unity .CurrentTestFailed = (((UNITY_UINT )expected - (UNITY_UINT )actual ) > delta );
1421- }
1436+ Unity .CurrentTestFailed = (((UNITY_UINT )actual - (UNITY_UINT )expected ) > delta );
14221437 }
14231438 else
14241439 {
1425- if ((UNITY_UINT )actual > (UNITY_UINT )expected )
1426- {
1427- Unity .CurrentTestFailed = (((UNITY_UINT )actual - (UNITY_UINT )expected ) > delta );
1428- }
1429- else
1430- {
1431- Unity .CurrentTestFailed = (((UNITY_UINT )expected - (UNITY_UINT )actual ) > delta );
1432- }
1440+ Unity .CurrentTestFailed = (((UNITY_UINT )expected - (UNITY_UINT )actual ) > delta );
1441+ }
1442+
1443+ if (Unity .CurrentTestFailed )
1444+ {
1445+ UnityTestResultsFailBegin (lineNumber );
1446+ UnityPrint (UnityStrDelta );
1447+ UnityPrintIntNumberByStyle ((UNITY_INT )delta , style );
1448+ UnityPrint (UnityStrExpected );
1449+ UnityPrintIntNumberByStyle (expected , style );
1450+ UnityPrint (UnityStrWas );
1451+ UnityPrintIntNumberByStyle (actual , style );
1452+ UnityAddMsgIfSpecified (msg );
1453+ UNITY_FAIL_AND_BAIL ;
1454+ }
1455+ }
1456+
1457+ void UnityAssertUintNumbersWithin (const UNITY_UINT delta ,
1458+ const UNITY_UINT expected ,
1459+ const UNITY_UINT actual ,
1460+ const char * msg ,
1461+ const UNITY_LINE_TYPE lineNumber ,
1462+ const UNITY_DISPLAY_STYLE_T style )
1463+ {
1464+ RETURN_IF_FAIL_OR_IGNORE ;
1465+
1466+ if (actual > expected )
1467+ {
1468+ Unity .CurrentTestFailed = ((actual - expected ) > delta );
1469+ }
1470+ else
1471+ {
1472+ Unity .CurrentTestFailed = ((expected - actual ) > delta );
14331473 }
14341474
14351475 if (Unity .CurrentTestFailed )
14361476 {
14371477 UnityTestResultsFailBegin (lineNumber );
14381478 UnityPrint (UnityStrDelta );
1439- UnityPrintNumberByStyle (( UNITY_INT ) delta , style );
1479+ UnityPrintUintNumberByStyle ( delta , style );
14401480 UnityPrint (UnityStrExpected );
1441- UnityPrintNumberByStyle (expected , style );
1481+ UnityPrintUintNumberByStyle (expected , style );
14421482 UnityPrint (UnityStrWas );
1443- UnityPrintNumberByStyle (actual , style );
1483+ UnityPrintUintNumberByStyle (actual , style );
14441484 UnityAddMsgIfSpecified (msg );
14451485 UNITY_FAIL_AND_BAIL ;
14461486 }
@@ -1591,13 +1631,13 @@ void UnityAssertNumbersArrayWithin(const UNITY_UINT delta,
15911631 }
15921632 UnityTestResultsFailBegin (lineNumber );
15931633 UnityPrint (UnityStrDelta );
1594- UnityPrintNumberByStyle ((UNITY_INT )delta , style );
1634+ UnityPrintIntNumberByStyle ((UNITY_INT )delta , style );
15951635 UnityPrint (UnityStrElement );
15961636 UnityPrintNumberUnsigned (num_elements - elements - 1 );
15971637 UnityPrint (UnityStrExpected );
1598- UnityPrintNumberByStyle (expect_val , style );
1638+ UnityPrintIntNumberByStyle (expect_val , style );
15991639 UnityPrint (UnityStrWas );
1600- UnityPrintNumberByStyle (actual_val , style );
1640+ UnityPrintIntNumberByStyle (actual_val , style );
16011641 UnityAddMsgIfSpecified (msg );
16021642 UNITY_FAIL_AND_BAIL ;
16031643 }
@@ -1828,9 +1868,9 @@ void UnityAssertEqualMemory(UNITY_INTERNAL_PTR expected,
18281868 UnityPrint (UnityStrByte );
18291869 UnityPrintNumberUnsigned (length - bytes - 1 );
18301870 UnityPrint (UnityStrExpected );
1831- UnityPrintNumberByStyle (* ptr_exp , UNITY_DISPLAY_STYLE_HEX8 );
1871+ UnityPrintIntNumberByStyle (* ptr_exp , UNITY_DISPLAY_STYLE_HEX8 );
18321872 UnityPrint (UnityStrWas );
1833- UnityPrintNumberByStyle (* ptr_act , UNITY_DISPLAY_STYLE_HEX8 );
1873+ UnityPrintIntNumberByStyle (* ptr_act , UNITY_DISPLAY_STYLE_HEX8 );
18341874 UnityAddMsgIfSpecified (msg );
18351875 UNITY_FAIL_AND_BAIL ;
18361876 }
0 commit comments