@@ -185,7 +185,7 @@ void UnityPrintLen(const char* string, const UNITY_UINT32 length)
185
185
}
186
186
187
187
/*-----------------------------------------------*/
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 )
189
189
{
190
190
if ((style & UNITY_DISPLAY_RANGE_INT ) == UNITY_DISPLAY_RANGE_INT )
191
191
{
@@ -223,12 +223,6 @@ void UnityPrintNumberByStyle(const UNITY_INT number, const UNITY_DISPLAY_STYLE_T
223
223
UnityPrintNumber (number );
224
224
}
225
225
}
226
- else
227
- {
228
- UNITY_OUTPUT_CHAR ('0' );
229
- UNITY_OUTPUT_CHAR ('x' );
230
- UnityPrintNumberHex ((UNITY_UINT )number , (char )((style & 0xF ) * 2 ));
231
- }
232
226
}
233
227
234
228
void 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
237
231
{
238
232
UnityPrintNumberUnsigned (number );
239
233
}
234
+ else
235
+ {
236
+ UNITY_OUTPUT_CHAR ('0' );
237
+ UNITY_OUTPUT_CHAR ('x' );
238
+ UnityPrintNumberHex ((UNITY_UINT )number , (char )((style & 0xF ) * 2 ));
239
+ }
240
240
}
241
241
242
242
/*-----------------------------------------------*/
@@ -725,9 +725,9 @@ void UnityAssertEqualIntNumber(const UNITY_INT expected,
725
725
{
726
726
UnityTestResultsFailBegin (lineNumber );
727
727
UnityPrint (UnityStrExpected );
728
- UnityPrintNumberByStyle (expected , style );
728
+ UnityPrintIntNumberByStyle (expected , style );
729
729
UnityPrint (UnityStrWas );
730
- UnityPrintNumberByStyle (actual , style );
730
+ UnityPrintIntNumberByStyle (actual , style );
731
731
UnityAddMsgIfSpecified (msg );
732
732
UNITY_FAIL_AND_BAIL ;
733
733
}
@@ -753,40 +753,62 @@ void UnityAssertEqualUintNumber(const UNITY_UINT expected,
753
753
}
754
754
}
755
755
/*-----------------------------------------------*/
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 )
762
762
{
763
763
int failed = 0 ;
764
764
RETURN_IF_FAIL_OR_IGNORE ;
765
765
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 ; }
768
767
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 )
775
772
{
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 ;
778
783
}
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 ; }
779
801
780
802
if (failed )
781
803
{
782
804
UnityTestResultsFailBegin (lineNumber );
783
805
UnityPrint (UnityStrExpected );
784
- UnityPrintNumberByStyle (actual , style );
806
+ UnityPrintUintNumberByStyle (actual , style );
785
807
if (compare & UNITY_GREATER_THAN ) { UnityPrint (UnityStrGt ); }
786
808
if (compare & UNITY_SMALLER_THAN ) { UnityPrint (UnityStrLt ); }
787
809
if (compare & UNITY_EQUAL_TO ) { UnityPrint (UnityStrOrEqual ); }
788
810
if (compare == UNITY_NOT_EQUAL ) { UnityPrint (UnityStrNotEqual ); }
789
- UnityPrintNumberByStyle (threshold , style );
811
+ UnityPrintUintNumberByStyle (threshold , style );
790
812
UnityAddMsgIfSpecified (msg );
791
813
UNITY_FAIL_AND_BAIL ;
792
814
}
@@ -900,9 +922,9 @@ void UnityAssertEqualIntArray(UNITY_INTERNAL_PTR expected,
900
922
UnityPrint (UnityStrElement );
901
923
UnityPrintNumberUnsigned (num_elements - elements - 1 );
902
924
UnityPrint (UnityStrExpected );
903
- UnityPrintNumberByStyle (expect_val , style );
925
+ UnityPrintIntNumberByStyle (expect_val , style );
904
926
UnityPrint (UnityStrWas );
905
- UnityPrintNumberByStyle (actual_val , style );
927
+ UnityPrintIntNumberByStyle (actual_val , style );
906
928
UnityAddMsgIfSpecified (msg );
907
929
UNITY_FAIL_AND_BAIL ;
908
930
}
@@ -1400,47 +1422,65 @@ void UnityAssertDoubleSpecial(const UNITY_DOUBLE actual,
1400
1422
#endif /* not UNITY_EXCLUDE_DOUBLE */
1401
1423
1402
1424
/*-----------------------------------------------*/
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 )
1409
1431
{
1410
1432
RETURN_IF_FAIL_OR_IGNORE ;
1411
1433
1412
- if (( style & UNITY_DISPLAY_RANGE_INT ) == UNITY_DISPLAY_RANGE_INT )
1434
+ if (actual > expected )
1413
1435
{
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 );
1422
1437
}
1423
1438
else
1424
1439
{
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 );
1433
1473
}
1434
1474
1435
1475
if (Unity .CurrentTestFailed )
1436
1476
{
1437
1477
UnityTestResultsFailBegin (lineNumber );
1438
1478
UnityPrint (UnityStrDelta );
1439
- UnityPrintNumberByStyle (( UNITY_INT ) delta , style );
1479
+ UnityPrintUintNumberByStyle ( delta , style );
1440
1480
UnityPrint (UnityStrExpected );
1441
- UnityPrintNumberByStyle (expected , style );
1481
+ UnityPrintUintNumberByStyle (expected , style );
1442
1482
UnityPrint (UnityStrWas );
1443
- UnityPrintNumberByStyle (actual , style );
1483
+ UnityPrintUintNumberByStyle (actual , style );
1444
1484
UnityAddMsgIfSpecified (msg );
1445
1485
UNITY_FAIL_AND_BAIL ;
1446
1486
}
@@ -1591,13 +1631,13 @@ void UnityAssertNumbersArrayWithin(const UNITY_UINT delta,
1591
1631
}
1592
1632
UnityTestResultsFailBegin (lineNumber );
1593
1633
UnityPrint (UnityStrDelta );
1594
- UnityPrintNumberByStyle ((UNITY_INT )delta , style );
1634
+ UnityPrintIntNumberByStyle ((UNITY_INT )delta , style );
1595
1635
UnityPrint (UnityStrElement );
1596
1636
UnityPrintNumberUnsigned (num_elements - elements - 1 );
1597
1637
UnityPrint (UnityStrExpected );
1598
- UnityPrintNumberByStyle (expect_val , style );
1638
+ UnityPrintIntNumberByStyle (expect_val , style );
1599
1639
UnityPrint (UnityStrWas );
1600
- UnityPrintNumberByStyle (actual_val , style );
1640
+ UnityPrintIntNumberByStyle (actual_val , style );
1601
1641
UnityAddMsgIfSpecified (msg );
1602
1642
UNITY_FAIL_AND_BAIL ;
1603
1643
}
@@ -1828,9 +1868,9 @@ void UnityAssertEqualMemory(UNITY_INTERNAL_PTR expected,
1828
1868
UnityPrint (UnityStrByte );
1829
1869
UnityPrintNumberUnsigned (length - bytes - 1 );
1830
1870
UnityPrint (UnityStrExpected );
1831
- UnityPrintNumberByStyle (* ptr_exp , UNITY_DISPLAY_STYLE_HEX8 );
1871
+ UnityPrintIntNumberByStyle (* ptr_exp , UNITY_DISPLAY_STYLE_HEX8 );
1832
1872
UnityPrint (UnityStrWas );
1833
- UnityPrintNumberByStyle (* ptr_act , UNITY_DISPLAY_STYLE_HEX8 );
1873
+ UnityPrintIntNumberByStyle (* ptr_act , UNITY_DISPLAY_STYLE_HEX8 );
1834
1874
UnityAddMsgIfSpecified (msg );
1835
1875
UNITY_FAIL_AND_BAIL ;
1836
1876
}
0 commit comments