11 #define UNITY_FAIL_AND_BAIL { Unity.CurrentTestFailed = 1; UNITY_OUTPUT_CHAR('\n'); longjmp(Unity.AbortFrame, 1); }
12 #define UNITY_IGNORE_AND_BAIL { Unity.CurrentTestIgnored = 1; UNITY_OUTPUT_CHAR('\n'); longjmp(Unity.AbortFrame, 1); }
13 #define UNITY_SKIP_EXECUTION { if ((Unity.CurrentTestFailed != 0) || (Unity.CurrentTestIgnored != 0)) {return;} }
15 #define UNITY_PRINT_EOL { UNITY_OUTPUT_CHAR('\n'); }
17 struct _Unity Unity = { 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0, { 0 } };
19 const char* UnityStrNull =
"NULL";
20 const char* UnityStrSpacer =
". ";
21 const char* UnityStrExpected =
" Expected ";
22 const char* UnityStrWas =
" Was ";
23 const char* UnityStrTo =
" To ";
24 const char* UnityStrElement =
" Element ";
25 const char* UnityStrByte =
" Byte ";
26 const char* UnityStrMemory =
" Memory Mismatch.";
27 const char* UnityStrDelta =
" Values Not Within Delta ";
28 const char* UnityStrPointless=
" You Asked Me To Compare Nothing, Which Was Pointless.";
29 const char* UnityStrNullPointerForExpected=
" Expected pointer to be NULL";
30 const char* UnityStrNullPointerForActual =
" Actual pointer was NULL";
31 const char* UnityStrInf =
"Infinity";
32 const char* UnityStrNegInf =
"Negative Infinity";
33 const char* UnityStrNaN =
"NaN";
37 static const _UF f_zero = 0.0f;
38 #ifndef UNITY_EXCLUDE_DOUBLE
39 static const _UD d_zero = 0.0;
43 const _U_UINT UnitySizeMask[] =
52 #ifdef UNITY_SUPPORT_64
57 void UnityPrintFail(
void);
58 void UnityPrintOk(
void);
64 void UnityPrint(
const char*
string)
73 if ((*pch <= 126) && (*pch >= 32))
75 UNITY_OUTPUT_CHAR(*pch);
80 UNITY_OUTPUT_CHAR(
'\\');
81 UNITY_OUTPUT_CHAR(
'r');
86 UNITY_OUTPUT_CHAR(
'\\');
87 UNITY_OUTPUT_CHAR(
'n');
92 UNITY_OUTPUT_CHAR(
'\\');
93 UnityPrintNumberHex((_U_SINT)*pch, 2);
101 void UnityPrintNumberByStyle(
const _U_SINT number,
const UNITY_DISPLAY_STYLE_T style)
103 if ((style & UNITY_DISPLAY_RANGE_INT) == UNITY_DISPLAY_RANGE_INT)
105 UnityPrintNumber(number);
107 else if ((style & UNITY_DISPLAY_RANGE_UINT) == UNITY_DISPLAY_RANGE_UINT)
109 UnityPrintNumberUnsigned( (_U_UINT)number & UnitySizeMask[((_U_UINT)style & (_U_UINT)0x0F) - 1] );
113 UnityPrintNumberHex((_U_UINT)number, (style & 0x000F) << 1);
119 void UnityPrintNumber(
const _U_SINT number_to_print)
122 _U_SINT next_divisor;
123 _U_SINT number = number_to_print;
127 UNITY_OUTPUT_CHAR(
'-');
132 while (number / divisor > 9)
134 next_divisor = divisor * 10;
135 if (next_divisor > divisor)
136 divisor = next_divisor;
144 UNITY_OUTPUT_CHAR((
char)(
'0' + (number / divisor % 10)));
152 void UnityPrintNumberUnsigned(
const _U_UINT number)
155 _U_UINT next_divisor;
158 while (number / divisor > 9)
160 next_divisor = divisor * 10;
161 if (next_divisor > divisor)
162 divisor = next_divisor;
170 UNITY_OUTPUT_CHAR((
char)(
'0' + (number / divisor % 10)));
177 void UnityPrintNumberHex(
const _U_UINT number,
const char nibbles_to_print)
180 char nibbles = nibbles_to_print;
181 UNITY_OUTPUT_CHAR(
'0');
182 UNITY_OUTPUT_CHAR(
'x');
186 nibble = (number >> (--nibbles << 2)) & 0x0000000F;
189 UNITY_OUTPUT_CHAR((
char)(
'0' + nibble));
193 UNITY_OUTPUT_CHAR((
char)(
'A' - 10 + nibble));
199 void UnityPrintMask(
const _U_UINT mask,
const _U_UINT number)
201 _U_UINT current_bit = (_U_UINT)1 << (UNITY_INT_WIDTH - 1);
204 for (i = 0; i < UNITY_INT_WIDTH; i++)
206 if (current_bit & mask)
208 if (current_bit & number)
210 UNITY_OUTPUT_CHAR(
'1');
214 UNITY_OUTPUT_CHAR(
'0');
219 UNITY_OUTPUT_CHAR(
'X');
221 current_bit = current_bit >> 1;
226 #ifdef UNITY_FLOAT_VERBOSE
227 void UnityPrintFloat(_UF number)
230 sprintf(TempBuffer,
"%.6f", number);
231 UnityPrint(TempBuffer);
237 void UnityPrintFail(
void)
242 void UnityPrintOk(
void)
248 void UnityTestResultsBegin(
const char* file,
const UNITY_LINE_TYPE
line)
251 UNITY_OUTPUT_CHAR(
':');
252 UnityPrintNumber(
line);
253 UNITY_OUTPUT_CHAR(
':');
254 UnityPrint(Unity.CurrentTestName);
255 UNITY_OUTPUT_CHAR(
':');
259 void UnityTestResultsFailBegin(
const UNITY_LINE_TYPE
line)
261 UnityTestResultsBegin(Unity.TestFile,
line);
266 void UnityConcludeTest(
void)
268 if (Unity.CurrentTestIgnored)
272 else if (!Unity.CurrentTestFailed)
274 UnityTestResultsBegin(Unity.TestFile, Unity.CurrentTestLineNumber);
280 Unity.TestFailures++;
283 Unity.CurrentTestFailed = 0;
284 Unity.CurrentTestIgnored = 0;
288 void UnityAddMsgIfSpecified(
const char* msg)
292 UnityPrint(UnityStrSpacer);
298 void UnityPrintExpectedAndActualStrings(
const char* expected,
const char* actual)
300 UnityPrint(UnityStrExpected);
301 if (expected != NULL)
303 UNITY_OUTPUT_CHAR(
'\'');
304 UnityPrint(expected);
305 UNITY_OUTPUT_CHAR(
'\'');
309 UnityPrint(UnityStrNull);
311 UnityPrint(UnityStrWas);
314 UNITY_OUTPUT_CHAR(
'\'');
316 UNITY_OUTPUT_CHAR(
'\'');
320 UnityPrint(UnityStrNull);
328 int UnityCheckArraysForNull(
const void* expected,
const void* actual,
const UNITY_LINE_TYPE lineNumber,
const char* msg)
331 if ((expected == NULL) && (actual == NULL))
335 if (expected == NULL)
337 UnityTestResultsFailBegin(lineNumber);
338 UnityPrint(UnityStrNullPointerForExpected);
339 UnityAddMsgIfSpecified(msg);
346 UnityTestResultsFailBegin(lineNumber);
347 UnityPrint(UnityStrNullPointerForActual);
348 UnityAddMsgIfSpecified(msg);
360 void UnityAssertBits(
const _U_SINT mask,
361 const _U_SINT expected,
362 const _U_SINT actual,
364 const UNITY_LINE_TYPE lineNumber)
366 UNITY_SKIP_EXECUTION;
368 if ((mask & expected) != (mask & actual))
370 UnityTestResultsFailBegin(lineNumber);
371 UnityPrint(UnityStrExpected);
372 UnityPrintMask(mask, expected);
373 UnityPrint(UnityStrWas);
374 UnityPrintMask(mask, actual);
375 UnityAddMsgIfSpecified(msg);
381 void UnityAssertEqualNumber(
const _U_SINT expected,
382 const _U_SINT actual,
384 const UNITY_LINE_TYPE lineNumber,
385 const UNITY_DISPLAY_STYLE_T style)
387 UNITY_SKIP_EXECUTION;
389 if (expected != actual)
391 UnityTestResultsFailBegin(lineNumber);
392 UnityPrint(UnityStrExpected);
393 UnityPrintNumberByStyle(expected, style);
394 UnityPrint(UnityStrWas);
395 UnityPrintNumberByStyle(actual, style);
396 UnityAddMsgIfSpecified(msg);
402 void UnityAssertEqualIntArray(
const _U_SINT* expected,
403 const _U_SINT* actual,
404 const _UU32 num_elements,
406 const UNITY_LINE_TYPE lineNumber,
407 const UNITY_DISPLAY_STYLE_T style)
409 _UU32 elements = num_elements;
410 const _US8* ptr_exp = (_US8*)expected;
411 const _US8* ptr_act = (_US8*)actual;
413 UNITY_SKIP_EXECUTION;
417 UnityTestResultsFailBegin(lineNumber);
418 UnityPrint(UnityStrPointless);
419 UnityAddMsgIfSpecified(msg);
423 if (UnityCheckArraysForNull((
void*)expected, (
void*)actual, lineNumber, msg) == 1)
428 case UNITY_DISPLAY_STYLE_HEX8:
429 case UNITY_DISPLAY_STYLE_INT8:
430 case UNITY_DISPLAY_STYLE_UINT8:
433 if (*ptr_exp != *ptr_act)
435 UnityTestResultsFailBegin(lineNumber);
436 UnityPrint(UnityStrElement);
437 UnityPrintNumberByStyle((num_elements - elements - 1), UNITY_DISPLAY_STYLE_UINT);
438 UnityPrint(UnityStrExpected);
439 UnityPrintNumberByStyle(*ptr_exp, style);
440 UnityPrint(UnityStrWas);
441 UnityPrintNumberByStyle(*ptr_act, style);
442 UnityAddMsgIfSpecified(msg);
449 case UNITY_DISPLAY_STYLE_HEX16:
450 case UNITY_DISPLAY_STYLE_INT16:
451 case UNITY_DISPLAY_STYLE_UINT16:
454 if (*(_US16*)ptr_exp != *(_US16*)ptr_act)
456 UnityTestResultsFailBegin(lineNumber);
457 UnityPrint(UnityStrElement);
458 UnityPrintNumberByStyle((num_elements - elements - 1), UNITY_DISPLAY_STYLE_UINT);
459 UnityPrint(UnityStrExpected);
460 UnityPrintNumberByStyle(*(_US16*)ptr_exp, style);
461 UnityPrint(UnityStrWas);
462 UnityPrintNumberByStyle(*(_US16*)ptr_act, style);
463 UnityAddMsgIfSpecified(msg);
470 #ifdef UNITY_SUPPORT_64
471 case UNITY_DISPLAY_STYLE_HEX64:
472 case UNITY_DISPLAY_STYLE_INT64:
473 case UNITY_DISPLAY_STYLE_UINT64:
476 if (*(_US64*)ptr_exp != *(_US64*)ptr_act)
478 UnityTestResultsFailBegin(lineNumber);
479 UnityPrint(UnityStrElement);
480 UnityPrintNumberByStyle((num_elements - elements - 1), UNITY_DISPLAY_STYLE_UINT);
481 UnityPrint(UnityStrExpected);
482 UnityPrintNumberByStyle(*(_US64*)ptr_exp, style);
483 UnityPrint(UnityStrWas);
484 UnityPrintNumberByStyle(*(_US64*)ptr_act, style);
485 UnityAddMsgIfSpecified(msg);
496 if (*(_US32*)ptr_exp != *(_US32*)ptr_act)
498 UnityTestResultsFailBegin(lineNumber);
499 UnityPrint(UnityStrElement);
500 UnityPrintNumberByStyle((num_elements - elements - 1), UNITY_DISPLAY_STYLE_UINT);
501 UnityPrint(UnityStrExpected);
502 UnityPrintNumberByStyle(*(_US32*)ptr_exp, style);
503 UnityPrint(UnityStrWas);
504 UnityPrintNumberByStyle(*(_US32*)ptr_act, style);
505 UnityAddMsgIfSpecified(msg);
516 #ifndef UNITY_EXCLUDE_FLOAT
517 void UnityAssertEqualFloatArray(
const _UF* expected,
519 const _UU32 num_elements,
521 const UNITY_LINE_TYPE lineNumber)
523 _UU32 elements = num_elements;
524 const _UF* ptr_expected = expected;
525 const _UF* ptr_actual = actual;
528 UNITY_SKIP_EXECUTION;
532 UnityTestResultsFailBegin(lineNumber);
533 UnityPrint(UnityStrPointless);
534 UnityAddMsgIfSpecified(msg);
538 if (UnityCheckArraysForNull((
void*)expected, (
void*)actual, lineNumber, msg) == 1)
543 diff = *ptr_expected - *ptr_actual;
546 tol = UNITY_FLOAT_PRECISION * *ptr_expected;
551 if ((diff * 0.0f != 0.0f) || (diff > tol))
553 UnityTestResultsFailBegin(lineNumber);
554 UnityPrint(UnityStrElement);
555 UnityPrintNumberByStyle((num_elements - elements - 1), UNITY_DISPLAY_STYLE_UINT);
556 #ifdef UNITY_FLOAT_VERBOSE
557 UnityPrint(UnityStrExpected);
558 UnityPrintFloat(*ptr_expected);
559 UnityPrint(UnityStrWas);
560 UnityPrintFloat(*ptr_actual);
562 UnityPrint(UnityStrDelta);
564 UnityAddMsgIfSpecified(msg);
573 void UnityAssertFloatsWithin(
const _UF delta,
577 const UNITY_LINE_TYPE lineNumber)
579 _UF diff = actual - expected;
580 _UF pos_delta = delta;
582 UNITY_SKIP_EXECUTION;
588 if (pos_delta < 0.0f)
590 pos_delta = 0.0f - pos_delta;
594 if ((diff * 0.0f != 0.0f) || (pos_delta < diff))
596 UnityTestResultsFailBegin(lineNumber);
597 #ifdef UNITY_FLOAT_VERBOSE
598 UnityPrint(UnityStrExpected);
599 UnityPrintFloat(expected);
600 UnityPrint(UnityStrWas);
601 UnityPrintFloat(actual);
603 UnityPrint(UnityStrDelta);
605 UnityAddMsgIfSpecified(msg);
611 void UnityAssertFloatIsInf(
const _UF actual,
613 const UNITY_LINE_TYPE lineNumber)
615 UNITY_SKIP_EXECUTION;
622 if ((1.0f / f_zero) != actual)
624 UnityTestResultsFailBegin(lineNumber);
625 #ifdef UNITY_FLOAT_VERBOSE
626 UnityPrint(UnityStrExpected);
627 UnityPrint(UnityStrInf);
628 UnityPrint(UnityStrWas);
629 UnityPrintFloat(actual);
631 UnityPrint(UnityStrDelta);
633 UnityAddMsgIfSpecified(msg);
639 void UnityAssertFloatIsNegInf(
const _UF actual,
641 const UNITY_LINE_TYPE lineNumber)
643 UNITY_SKIP_EXECUTION;
646 if ((-1.0f / f_zero) != actual)
648 UnityTestResultsFailBegin(lineNumber);
649 #ifdef UNITY_FLOAT_VERBOSE
650 UnityPrint(UnityStrExpected);
651 UnityPrint(UnityStrNegInf);
652 UnityPrint(UnityStrWas);
653 UnityPrintFloat(actual);
655 UnityPrint(UnityStrDelta);
657 UnityAddMsgIfSpecified(msg);
663 void UnityAssertFloatIsNaN(
const _UF actual,
665 const UNITY_LINE_TYPE lineNumber)
667 UNITY_SKIP_EXECUTION;
669 if (actual == actual)
671 UnityTestResultsFailBegin(lineNumber);
672 #ifdef UNITY_FLOAT_VERBOSE
673 UnityPrint(UnityStrExpected);
674 UnityPrint(UnityStrNaN);
675 UnityPrint(UnityStrWas);
676 UnityPrintFloat(actual);
678 UnityPrint(UnityStrDelta);
680 UnityAddMsgIfSpecified(msg);
685 #endif //not UNITY_EXCLUDE_FLOAT
688 #ifndef UNITY_EXCLUDE_DOUBLE
689 void UnityAssertEqualDoubleArray(
const _UD* expected,
691 const _UU32 num_elements,
693 const UNITY_LINE_TYPE lineNumber)
695 _UU32 elements = num_elements;
696 const _UD* ptr_expected = expected;
697 const _UD* ptr_actual = actual;
700 UNITY_SKIP_EXECUTION;
704 UnityTestResultsFailBegin(lineNumber);
705 UnityPrint(UnityStrPointless);
706 UnityAddMsgIfSpecified(msg);
710 if (UnityCheckArraysForNull((
void*)expected, (
void*)actual, lineNumber, msg) == 1)
715 diff = *ptr_expected - *ptr_actual;
718 tol = UNITY_DOUBLE_PRECISION * *ptr_expected;
723 if ((diff * 0.0 != 0.0) || (diff > tol))
725 UnityTestResultsFailBegin(lineNumber);
726 UnityPrint(UnityStrElement);
727 UnityPrintNumberByStyle((num_elements - elements - 1), UNITY_DISPLAY_STYLE_UINT);
728 #ifdef UNITY_DOUBLE_VERBOSE
729 UnityPrint(UnityStrExpected);
730 UnityPrintFloat((
float)(*ptr_expected));
731 UnityPrint(UnityStrWas);
732 UnityPrintFloat((
float)(*ptr_actual));
734 UnityPrint(UnityStrDelta);
736 UnityAddMsgIfSpecified(msg);
745 void UnityAssertDoublesWithin(
const _UD delta,
749 const UNITY_LINE_TYPE lineNumber)
751 _UD diff = actual - expected;
752 _UD pos_delta = delta;
754 UNITY_SKIP_EXECUTION;
762 pos_delta = 0.0 - pos_delta;
766 if ((diff * 0.0 != 0.0) || (pos_delta < diff))
768 UnityTestResultsFailBegin(lineNumber);
769 #ifdef UNITY_DOUBLE_VERBOSE
770 UnityPrint(UnityStrExpected);
771 UnityPrintFloat((
float)expected);
772 UnityPrint(UnityStrWas);
773 UnityPrintFloat((
float)actual);
775 UnityPrint(UnityStrDelta);
777 UnityAddMsgIfSpecified(msg);
783 void UnityAssertDoubleIsInf(
const _UD actual,
785 const UNITY_LINE_TYPE lineNumber)
787 UNITY_SKIP_EXECUTION;
790 if ((1.0 / d_zero) != actual)
792 UnityTestResultsFailBegin(lineNumber);
793 #ifdef UNITY_DOUBLE_VERBOSE
794 UnityPrint(UnityStrExpected);
795 UnityPrint(UnityStrInf);
796 UnityPrint(UnityStrWas);
797 UnityPrintFloat((
float)actual);
799 UnityPrint(UnityStrDelta);
801 UnityAddMsgIfSpecified(msg);
807 void UnityAssertDoubleIsNegInf(
const _UD actual,
809 const UNITY_LINE_TYPE lineNumber)
811 UNITY_SKIP_EXECUTION;
814 if ((-1.0 / d_zero) != actual)
816 UnityTestResultsFailBegin(lineNumber);
817 #ifdef UNITY_DOUBLE_VERBOSE
818 UnityPrint(UnityStrExpected);
819 UnityPrint(UnityStrNegInf);
820 UnityPrint(UnityStrWas);
821 UnityPrintFloat((
float)actual);
823 UnityPrint(UnityStrDelta);
825 UnityAddMsgIfSpecified(msg);
831 void UnityAssertDoubleIsNaN(
const _UD actual,
833 const UNITY_LINE_TYPE lineNumber)
835 UNITY_SKIP_EXECUTION;
837 if (actual == actual)
839 UnityTestResultsFailBegin(lineNumber);
840 #ifdef UNITY_DOUBLE_VERBOSE
841 UnityPrint(UnityStrExpected);
842 UnityPrint(UnityStrNaN);
843 UnityPrint(UnityStrWas);
844 UnityPrintFloat((
float)actual);
846 UnityPrint(UnityStrDelta);
848 UnityAddMsgIfSpecified(msg);
853 #endif // not UNITY_EXCLUDE_DOUBLE
856 void UnityAssertNumbersWithin(
const _U_SINT delta,
857 const _U_SINT expected,
858 const _U_SINT actual,
860 const UNITY_LINE_TYPE lineNumber,
861 const UNITY_DISPLAY_STYLE_T style)
863 UNITY_SKIP_EXECUTION;
865 if ((style & UNITY_DISPLAY_RANGE_INT) == UNITY_DISPLAY_RANGE_INT)
867 if (actual > expected)
868 Unity.CurrentTestFailed = ((actual - expected) > delta);
870 Unity.CurrentTestFailed = ((expected - actual) > delta);
874 if ((_U_UINT)actual > (_U_UINT)expected)
875 Unity.CurrentTestFailed = ((_U_UINT)(actual - expected) > (_U_UINT)delta);
877 Unity.CurrentTestFailed = ((_U_UINT)(expected - actual) > (_U_UINT)delta);
880 if (Unity.CurrentTestFailed)
882 UnityTestResultsFailBegin(lineNumber);
883 UnityPrint(UnityStrDelta);
884 UnityPrintNumberByStyle(delta, style);
885 UnityPrint(UnityStrExpected);
886 UnityPrintNumberByStyle(expected, style);
887 UnityPrint(UnityStrWas);
888 UnityPrintNumberByStyle(actual, style);
889 UnityAddMsgIfSpecified(msg);
895 void UnityAssertEqualString(
const char* expected,
898 const UNITY_LINE_TYPE lineNumber)
902 UNITY_SKIP_EXECUTION;
905 if (expected && actual)
907 for (i = 0; expected[i] || actual[i]; i++)
909 if (expected[i] != actual[i])
911 Unity.CurrentTestFailed = 1;
918 if (expected != actual)
920 Unity.CurrentTestFailed = 1;
924 if (Unity.CurrentTestFailed)
926 UnityTestResultsFailBegin(lineNumber);
927 UnityPrintExpectedAndActualStrings(expected, actual);
928 UnityAddMsgIfSpecified(msg);
934 void UnityAssertEqualStringArray(
const char** expected,
936 const _UU32 num_elements,
938 const UNITY_LINE_TYPE lineNumber)
942 UNITY_SKIP_EXECUTION;
945 if (num_elements == 0)
947 UnityTestResultsFailBegin(lineNumber);
948 UnityPrint(UnityStrPointless);
949 UnityAddMsgIfSpecified(msg);
953 if (UnityCheckArraysForNull((
void*)expected, (
void*)actual, lineNumber, msg) == 1)
959 if (expected[j] && actual[j])
961 for (i = 0; expected[j][i] || actual[j][i]; i++)
963 if (expected[j][i] != actual[j][i])
965 Unity.CurrentTestFailed = 1;
972 if (expected[j] != actual[j])
974 Unity.CurrentTestFailed = 1;
978 if (Unity.CurrentTestFailed)
980 UnityTestResultsFailBegin(lineNumber);
981 if (num_elements > 1)
983 UnityPrint(UnityStrElement);
984 UnityPrintNumberByStyle((num_elements - j - 1), UNITY_DISPLAY_STYLE_UINT);
986 UnityPrintExpectedAndActualStrings((
const char*)(expected[j]), (
const char*)(actual[j]));
987 UnityAddMsgIfSpecified(msg);
990 }
while (++j < num_elements);
994 void UnityAssertEqualMemory(
const void* expected,
997 const _UU32 num_elements,
999 const UNITY_LINE_TYPE lineNumber)
1001 unsigned char* ptr_exp = (
unsigned char*)expected;
1002 unsigned char* ptr_act = (
unsigned char*)actual;
1003 _UU32 elements = num_elements;
1006 UNITY_SKIP_EXECUTION;
1008 if ((elements == 0) || (length == 0))
1010 UnityTestResultsFailBegin(lineNumber);
1011 UnityPrint(UnityStrPointless);
1012 UnityAddMsgIfSpecified(msg);
1013 UNITY_FAIL_AND_BAIL;
1016 if (UnityCheckArraysForNull((
void*)expected, (
void*)actual, lineNumber, msg) == 1)
1025 if (*ptr_exp != *ptr_act)
1027 UnityTestResultsFailBegin(lineNumber);
1028 UnityPrint(UnityStrMemory);
1029 if (num_elements > 1)
1031 UnityPrint(UnityStrElement);
1032 UnityPrintNumberByStyle((num_elements - elements - 1), UNITY_DISPLAY_STYLE_UINT);
1034 UnityPrint(UnityStrByte);
1035 UnityPrintNumberByStyle((length - bytes - 1), UNITY_DISPLAY_STYLE_UINT);
1036 UnityPrint(UnityStrExpected);
1037 UnityPrintNumberByStyle(*ptr_exp, UNITY_DISPLAY_STYLE_HEX8);
1038 UnityPrint(UnityStrWas);
1039 UnityPrintNumberByStyle(*ptr_act, UNITY_DISPLAY_STYLE_HEX8);
1040 UnityAddMsgIfSpecified(msg);
1041 UNITY_FAIL_AND_BAIL;
1055 void UnityFail(
const char* msg,
const UNITY_LINE_TYPE
line)
1057 UNITY_SKIP_EXECUTION;
1059 UnityTestResultsBegin(Unity.TestFile,
line);
1063 UNITY_OUTPUT_CHAR(
':');
1066 UNITY_OUTPUT_CHAR(
' ');
1070 UNITY_FAIL_AND_BAIL;
1074 void UnityIgnore(
const char* msg,
const UNITY_LINE_TYPE
line)
1076 UNITY_SKIP_EXECUTION;
1078 UnityTestResultsBegin(Unity.TestFile,
line);
1079 UnityPrint(
"IGNORE");
1082 UNITY_OUTPUT_CHAR(
':');
1083 UNITY_OUTPUT_CHAR(
' ');
1086 UNITY_IGNORE_AND_BAIL;
1091 void tearDown(
void);
1092 void UnityDefaultTestRun(UnityTestFunction Func,
const char* FuncName,
const int FuncLineNum)
1094 Unity.CurrentTestName = FuncName;
1095 Unity.CurrentTestLineNumber = FuncLineNum;
1096 Unity.NumberOfTests++;
1102 if (TEST_PROTECT() && !(Unity.CurrentTestIgnored))
1106 UnityConcludeTest();
1110 void UnityBegin(
void)
1112 Unity.NumberOfTests = 0;
1113 Unity.TestFailures = 0;
1114 Unity.TestIgnores = 0;
1115 Unity.CurrentTestFailed = 0;
1116 Unity.CurrentTestIgnored = 0;
1117 Unity.StartCNT =
CNT;
1124 void UnityPrintTotalExecutionTime(
void){
1125 int currentCNT =
CNT;
1127 int seconds = (currentCNT - Unity.StartCNT) /
CLKFREQ;
1128 int milliseconds = (currentCNT - Unity.StartCNT - seconds*
CLKFREQ) / (
CLKFREQ/1000);
1130 UnityPrint(
"Test Suite Total Time ");
1131 UnityPrintNumber(seconds);
1133 UnityPrintNumber(milliseconds);
1141 UnityPrint(
"-----------------------");
1143 UnityPrintTotalExecutionTime();
1144 UnityPrintNumber(Unity.NumberOfTests);
1145 UnityPrint(
" Tests ");
1146 UnityPrintNumber(Unity.TestFailures);
1147 UnityPrint(
" Failures ");
1148 UnityPrintNumber(Unity.TestIgnores);
1149 UnityPrint(
" Ignored");
1151 if (Unity.TestFailures == 0U)
1162 UNITY_OUTPUT_CHAR(0xFF);
1163 UNITY_OUTPUT_CHAR(0x00);
1164 UNITY_OUTPUT_CHAR(Unity.TestFailures);
1167 return Unity.TestFailures;