@@ -195,7 +195,7 @@ void UnityPrintLen(const char* string, const UNITY_UINT32 length)
195
195
}
196
196
197
197
/*-----------------------------------------------*/
198
- void UnityPrintNumberByStyle (const UNITY_INT number , const UNITY_DISPLAY_STYLE_T style )
198
+ void UnityPrintIntNumberByStyle (const UNITY_INT number , const UNITY_DISPLAY_STYLE_T style )
199
199
{
200
200
if ((style & UNITY_DISPLAY_RANGE_INT ) == UNITY_DISPLAY_RANGE_INT )
201
201
{
@@ -233,9 +233,13 @@ void UnityPrintNumberByStyle(const UNITY_INT number, const UNITY_DISPLAY_STYLE_T
233
233
UnityPrintNumber (number );
234
234
}
235
235
}
236
- else if ((style & UNITY_DISPLAY_RANGE_UINT ) == UNITY_DISPLAY_RANGE_UINT )
236
+ }
237
+
238
+ void UnityPrintUintNumberByStyle (const UNITY_UINT number , const UNITY_DISPLAY_STYLE_T style )
239
+ {
240
+ if ((style & UNITY_DISPLAY_RANGE_UINT ) == UNITY_DISPLAY_RANGE_UINT )
237
241
{
238
- UnityPrintNumberUnsigned (( UNITY_UINT ) number );
242
+ UnityPrintNumberUnsigned (number );
239
243
}
240
244
else
241
245
{
@@ -742,61 +746,102 @@ void UnityAssertBits(const UNITY_INT mask,
742
746
}
743
747
744
748
/*-----------------------------------------------*/
745
- void UnityAssertEqualNumber (const UNITY_INT expected ,
746
- const UNITY_INT actual ,
747
- const char * msg ,
748
- const UNITY_LINE_TYPE lineNumber ,
749
- const UNITY_DISPLAY_STYLE_T style )
749
+ void UnityAssertEqualIntNumber (const UNITY_INT expected ,
750
+ const UNITY_INT actual ,
751
+ const char * msg ,
752
+ const UNITY_LINE_TYPE lineNumber ,
753
+ const UNITY_DISPLAY_STYLE_T style )
750
754
{
751
755
RETURN_IF_FAIL_OR_IGNORE ;
752
756
753
757
if (expected != actual )
754
758
{
755
759
UnityTestResultsFailBegin (lineNumber );
756
760
UnityPrint (UnityStrExpected );
757
- UnityPrintNumberByStyle (expected , style );
761
+ UnityPrintIntNumberByStyle (expected , style );
758
762
UnityPrint (UnityStrWas );
759
- UnityPrintNumberByStyle (actual , style );
763
+ UnityPrintIntNumberByStyle (actual , style );
760
764
UnityAddMsgIfSpecified (msg );
761
765
UNITY_FAIL_AND_BAIL ;
762
766
}
763
767
}
764
768
769
+ void UnityAssertEqualUintNumber (const UNITY_UINT expected ,
770
+ const UNITY_UINT actual ,
771
+ const char * msg ,
772
+ const UNITY_LINE_TYPE lineNumber ,
773
+ const UNITY_DISPLAY_STYLE_T style )
774
+ {
775
+ RETURN_IF_FAIL_OR_IGNORE ;
776
+
777
+ if (expected != actual )
778
+ {
779
+ UnityTestResultsFailBegin (lineNumber );
780
+ UnityPrint (UnityStrExpected );
781
+ UnityPrintUintNumberByStyle (expected , style );
782
+ UnityPrint (UnityStrWas );
783
+ UnityPrintUintNumberByStyle (actual , style );
784
+ UnityAddMsgIfSpecified (msg );
785
+ UNITY_FAIL_AND_BAIL ;
786
+ }
787
+ }
765
788
/*-----------------------------------------------*/
766
- void UnityAssertGreaterOrLessOrEqualNumber (const UNITY_INT threshold ,
767
- const UNITY_INT actual ,
768
- const UNITY_COMPARISON_T compare ,
769
- const char * msg ,
770
- const UNITY_LINE_TYPE lineNumber ,
771
- const UNITY_DISPLAY_STYLE_T style )
789
+ void UnityAssertIntGreaterOrLessOrEqualNumber (const UNITY_INT threshold ,
790
+ const UNITY_INT actual ,
791
+ const UNITY_COMPARISON_T compare ,
792
+ const char * msg ,
793
+ const UNITY_LINE_TYPE lineNumber ,
794
+ const UNITY_DISPLAY_STYLE_T style )
772
795
{
773
796
int failed = 0 ;
774
797
RETURN_IF_FAIL_OR_IGNORE ;
775
798
776
- if ((threshold == actual ) && (compare & UNITY_EQUAL_TO )) { return ; }
777
- if ((threshold == actual )) { failed = 1 ; }
799
+ if ((threshold == actual ) && !(compare & UNITY_EQUAL_TO )) { failed = 1 ; }
778
800
779
- if ((style & UNITY_DISPLAY_RANGE_INT ) == UNITY_DISPLAY_RANGE_INT )
780
- {
781
- if ((actual > threshold ) && (compare & UNITY_SMALLER_THAN )) { failed = 1 ; }
782
- if ((actual < threshold ) && (compare & UNITY_GREATER_THAN )) { failed = 1 ; }
783
- }
784
- else /* UINT or HEX */
801
+ if ((actual > threshold ) && (compare & UNITY_SMALLER_THAN )) { failed = 1 ; }
802
+ if ((actual < threshold ) && (compare & UNITY_GREATER_THAN )) { failed = 1 ; }
803
+
804
+ if (failed )
785
805
{
786
- if (((UNITY_UINT )actual > (UNITY_UINT )threshold ) && (compare & UNITY_SMALLER_THAN )) { failed = 1 ; }
787
- if (((UNITY_UINT )actual < (UNITY_UINT )threshold ) && (compare & UNITY_GREATER_THAN )) { failed = 1 ; }
806
+ UnityTestResultsFailBegin (lineNumber );
807
+ UnityPrint (UnityStrExpected );
808
+ UnityPrintIntNumberByStyle (actual , style );
809
+ if (compare & UNITY_GREATER_THAN ) { UnityPrint (UnityStrGt ); }
810
+ if (compare & UNITY_SMALLER_THAN ) { UnityPrint (UnityStrLt ); }
811
+ if (compare & UNITY_EQUAL_TO ) { UnityPrint (UnityStrOrEqual ); }
812
+ if (compare == UNITY_NOT_EQUAL ) { UnityPrint (UnityStrNotEqual ); }
813
+ UnityPrintIntNumberByStyle (threshold , style );
814
+ UnityAddMsgIfSpecified (msg );
815
+ UNITY_FAIL_AND_BAIL ;
788
816
}
817
+ }
818
+
819
+ void UnityAssertUintGreaterOrLessOrEqualNumber (const UNITY_UINT threshold ,
820
+ const UNITY_UINT actual ,
821
+ const UNITY_COMPARISON_T compare ,
822
+ const char * msg ,
823
+ const UNITY_LINE_TYPE lineNumber ,
824
+ const UNITY_DISPLAY_STYLE_T style )
825
+ {
826
+ int failed = 0 ;
827
+ RETURN_IF_FAIL_OR_IGNORE ;
828
+
829
+ if ((threshold == actual ) && !(compare & UNITY_EQUAL_TO )) { failed = 1 ; }
830
+
831
+ /* UINT or HEX */
832
+ if ((actual > threshold ) && (compare & UNITY_SMALLER_THAN )) { failed = 1 ; }
833
+ if ((actual < threshold ) && (compare & UNITY_GREATER_THAN )) { failed = 1 ; }
789
834
790
835
if (failed )
791
836
{
792
837
UnityTestResultsFailBegin (lineNumber );
793
838
UnityPrint (UnityStrExpected );
794
- UnityPrintNumberByStyle (actual , style );
839
+ UnityPrintUintNumberByStyle (actual , style );
795
840
if (compare & UNITY_GREATER_THAN ) { UnityPrint (UnityStrGt ); }
796
841
if (compare & UNITY_SMALLER_THAN ) { UnityPrint (UnityStrLt ); }
797
842
if (compare & UNITY_EQUAL_TO ) { UnityPrint (UnityStrOrEqual ); }
798
843
if (compare == UNITY_NOT_EQUAL ) { UnityPrint (UnityStrNotEqual ); }
799
- UnityPrintNumberByStyle (threshold , style );
844
+ UnityPrintUintNumberByStyle (threshold , style );
800
845
UnityAddMsgIfSpecified (msg );
801
846
UNITY_FAIL_AND_BAIL ;
802
847
}
@@ -910,9 +955,9 @@ void UnityAssertEqualIntArray(UNITY_INTERNAL_PTR expected,
910
955
UnityPrint (UnityStrElement );
911
956
UnityPrintNumberUnsigned (num_elements - elements - 1 );
912
957
UnityPrint (UnityStrExpected );
913
- UnityPrintNumberByStyle (expect_val , style );
958
+ UnityPrintIntNumberByStyle (expect_val , style );
914
959
UnityPrint (UnityStrWas );
915
- UnityPrintNumberByStyle (actual_val , style );
960
+ UnityPrintIntNumberByStyle (actual_val , style );
916
961
UnityAddMsgIfSpecified (msg );
917
962
UNITY_FAIL_AND_BAIL ;
918
963
}
@@ -1410,47 +1455,65 @@ void UnityAssertDoubleSpecial(const UNITY_DOUBLE actual,
1410
1455
#endif /* not UNITY_EXCLUDE_DOUBLE */
1411
1456
1412
1457
/*-----------------------------------------------*/
1413
- void UnityAssertNumbersWithin (const UNITY_UINT delta ,
1414
- const UNITY_INT expected ,
1415
- const UNITY_INT actual ,
1416
- const char * msg ,
1417
- const UNITY_LINE_TYPE lineNumber ,
1418
- const UNITY_DISPLAY_STYLE_T style )
1458
+ void UnityAssertIntNumbersWithin (const UNITY_UINT delta ,
1459
+ const UNITY_INT expected ,
1460
+ const UNITY_INT actual ,
1461
+ const char * msg ,
1462
+ const UNITY_LINE_TYPE lineNumber ,
1463
+ const UNITY_DISPLAY_STYLE_T style )
1419
1464
{
1420
1465
RETURN_IF_FAIL_OR_IGNORE ;
1421
1466
1422
- if (( style & UNITY_DISPLAY_RANGE_INT ) == UNITY_DISPLAY_RANGE_INT )
1467
+ if (actual > expected )
1423
1468
{
1424
- if (actual > expected )
1425
- {
1426
- Unity .CurrentTestFailed = (((UNITY_UINT )actual - (UNITY_UINT )expected ) > delta );
1427
- }
1428
- else
1429
- {
1430
- Unity .CurrentTestFailed = (((UNITY_UINT )expected - (UNITY_UINT )actual ) > delta );
1431
- }
1469
+ Unity .CurrentTestFailed = (((UNITY_UINT )actual - (UNITY_UINT )expected ) > delta );
1432
1470
}
1433
1471
else
1434
1472
{
1435
- if ((UNITY_UINT )actual > (UNITY_UINT )expected )
1436
- {
1437
- Unity .CurrentTestFailed = (((UNITY_UINT )actual - (UNITY_UINT )expected ) > delta );
1438
- }
1439
- else
1440
- {
1441
- Unity .CurrentTestFailed = (((UNITY_UINT )expected - (UNITY_UINT )actual ) > delta );
1442
- }
1473
+ Unity .CurrentTestFailed = (((UNITY_UINT )expected - (UNITY_UINT )actual ) > delta );
1474
+ }
1475
+
1476
+ if (Unity .CurrentTestFailed )
1477
+ {
1478
+ UnityTestResultsFailBegin (lineNumber );
1479
+ UnityPrint (UnityStrDelta );
1480
+ UnityPrintIntNumberByStyle ((UNITY_INT )delta , style );
1481
+ UnityPrint (UnityStrExpected );
1482
+ UnityPrintIntNumberByStyle (expected , style );
1483
+ UnityPrint (UnityStrWas );
1484
+ UnityPrintIntNumberByStyle (actual , style );
1485
+ UnityAddMsgIfSpecified (msg );
1486
+ UNITY_FAIL_AND_BAIL ;
1487
+ }
1488
+ }
1489
+
1490
+ void UnityAssertUintNumbersWithin (const UNITY_UINT delta ,
1491
+ const UNITY_UINT expected ,
1492
+ const UNITY_UINT actual ,
1493
+ const char * msg ,
1494
+ const UNITY_LINE_TYPE lineNumber ,
1495
+ const UNITY_DISPLAY_STYLE_T style )
1496
+ {
1497
+ RETURN_IF_FAIL_OR_IGNORE ;
1498
+
1499
+ if (actual > expected )
1500
+ {
1501
+ Unity .CurrentTestFailed = ((actual - expected ) > delta );
1502
+ }
1503
+ else
1504
+ {
1505
+ Unity .CurrentTestFailed = ((expected - actual ) > delta );
1443
1506
}
1444
1507
1445
1508
if (Unity .CurrentTestFailed )
1446
1509
{
1447
1510
UnityTestResultsFailBegin (lineNumber );
1448
1511
UnityPrint (UnityStrDelta );
1449
- UnityPrintNumberByStyle (( UNITY_INT ) delta , style );
1512
+ UnityPrintUintNumberByStyle ( delta , style );
1450
1513
UnityPrint (UnityStrExpected );
1451
- UnityPrintNumberByStyle (expected , style );
1514
+ UnityPrintUintNumberByStyle (expected , style );
1452
1515
UnityPrint (UnityStrWas );
1453
- UnityPrintNumberByStyle (actual , style );
1516
+ UnityPrintUintNumberByStyle (actual , style );
1454
1517
UnityAddMsgIfSpecified (msg );
1455
1518
UNITY_FAIL_AND_BAIL ;
1456
1519
}
@@ -1601,13 +1664,13 @@ void UnityAssertNumbersArrayWithin(const UNITY_UINT delta,
1601
1664
}
1602
1665
UnityTestResultsFailBegin (lineNumber );
1603
1666
UnityPrint (UnityStrDelta );
1604
- UnityPrintNumberByStyle ((UNITY_INT )delta , style );
1667
+ UnityPrintIntNumberByStyle ((UNITY_INT )delta , style );
1605
1668
UnityPrint (UnityStrElement );
1606
1669
UnityPrintNumberUnsigned (num_elements - elements - 1 );
1607
1670
UnityPrint (UnityStrExpected );
1608
- UnityPrintNumberByStyle (expect_val , style );
1671
+ UnityPrintIntNumberByStyle (expect_val , style );
1609
1672
UnityPrint (UnityStrWas );
1610
- UnityPrintNumberByStyle (actual_val , style );
1673
+ UnityPrintIntNumberByStyle (actual_val , style );
1611
1674
UnityAddMsgIfSpecified (msg );
1612
1675
UNITY_FAIL_AND_BAIL ;
1613
1676
}
@@ -1838,9 +1901,9 @@ void UnityAssertEqualMemory(UNITY_INTERNAL_PTR expected,
1838
1901
UnityPrint (UnityStrByte );
1839
1902
UnityPrintNumberUnsigned (length - bytes - 1 );
1840
1903
UnityPrint (UnityStrExpected );
1841
- UnityPrintNumberByStyle (* ptr_exp , UNITY_DISPLAY_STYLE_HEX8 );
1904
+ UnityPrintIntNumberByStyle (* ptr_exp , UNITY_DISPLAY_STYLE_HEX8 );
1842
1905
UnityPrint (UnityStrWas );
1843
- UnityPrintNumberByStyle (* ptr_act , UNITY_DISPLAY_STYLE_HEX8 );
1906
+ UnityPrintIntNumberByStyle (* ptr_act , UNITY_DISPLAY_STYLE_HEX8 );
1844
1907
UnityAddMsgIfSpecified (msg );
1845
1908
UNITY_FAIL_AND_BAIL ;
1846
1909
}
0 commit comments