Mayank Gupta / Mbed OS pelion-example-frdm

Dependencies:   FXAS21002 FXOS8700Q

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers unity.c Source File

unity.c

00001 /* =========================================================================
00002     Unity Project - A Test Framework for C
00003     Copyright (c) 2007-14 Mike Karlesky, Mark VanderVoord, Greg Williams
00004     [Released under MIT License. Please refer to license.txt for details]
00005 ============================================================================ */
00006 
00007 #include "unity.h"
00008 #include <stddef.h>
00009 
00010 /* If omitted from header, declare overrideable prototypes here so they're ready for use */
00011 #ifdef UNITY_OMIT_OUTPUT_CHAR_HEADER_DECLARATION
00012 void UNITY_OUTPUT_CHAR(int);
00013 #endif
00014 
00015 /* Helpful macros for us to use here */
00016 #define UNITY_FAIL_AND_BAIL   { UNITY_PRINT_EOL(); Unity.CurrentTestFailed  = 1; longjmp(Unity.AbortFrame, 1); }
00017 #define UNITY_IGNORE_AND_BAIL { UNITY_PRINT_EOL(); Unity.CurrentTestIgnored = 1; longjmp(Unity.AbortFrame, 1); }
00018 
00019 /* return prematurely if we are already in failure or ignore state */
00020 #define UNITY_SKIP_EXECUTION  { if ((Unity.CurrentTestFailed != 0) || (Unity.CurrentTestIgnored != 0)) {return;} }
00021 
00022 struct _Unity Unity;
00023 
00024 static const char UnityStrOk[]                     = "OK";
00025 static const char UnityStrPass[]                   = "PASS";
00026 static const char UnityStrFail[]                   = "FAIL";
00027 static const char UnityStrIgnore[]                 = "SKIP"; // Switched "IGNORE" to "SKIP" for direct icetea mapping.
00028 static const char UnityStrNull[]                   = "NULL";
00029 static const char UnityStrSpacer[]                 = ". ";
00030 static const char UnityStrExpected[]               = " Expected ";
00031 static const char UnityStrWas[]                    = " Was ";
00032 static const char UnityStrElement[]                = " Element ";
00033 static const char UnityStrByte[]                   = " Byte ";
00034 static const char UnityStrMemory[]                 = " Memory Mismatch.";
00035 static const char UnityStrDelta[]                  = " Values Not Within Delta ";
00036 static const char UnityStrPointless[]              = " You Asked Me To Compare Nothing, Which Was Pointless.";
00037 static const char UnityStrNullPointerForExpected[] = " Expected pointer to be NULL";
00038 static const char UnityStrNullPointerForActual[]   = " Actual pointer was NULL";
00039 static const char UnityStrNot[]                    = "Not ";
00040 static const char UnityStrInf[]                    = "Infinity";
00041 static const char UnityStrNegInf[]                 = "Negative Infinity";
00042 static const char UnityStrNaN[]                    = "NaN";
00043 static const char UnityStrDet[]                    = "Determinate";
00044 static const char UnityStrInvalidFloatTrait[]      = "Invalid Float Trait";
00045 const char UnityStrErrFloat[]                      = "Unity Floating Point Disabled";
00046 const char UnityStrErrDouble[]                     = "Unity Double Precision Disabled";
00047 const char UnityStrErr64[]                         = "Unity 64-bit Support Disabled";
00048 static const char UnityStrBreaker[]                = "-----------------------";
00049 static const char UnityStrResultsTests[]           = " Tests ";
00050 static const char UnityStrResultsFailures[]        = " Failures ";
00051 static const char UnityStrResultsIgnored[]         = " Ignored ";
00052 static const char UnityStrDetail1Name[]            = UNITY_DETAIL1_NAME " ";
00053 static const char UnityStrDetail2Name[]            = " " UNITY_DETAIL2_NAME " ";
00054 
00055 #ifdef UNITY_FLOAT_NEEDS_ZERO
00056 /* Dividing by these constants produces +/- infinity.
00057  * The rationale is given in UnityAssertFloatIsInf's body. */
00058 static const _UF f_zero = 0.0f;
00059 #endif
00060 
00061 /* compiler-generic print formatting masks */
00062 static const _U_UINT UnitySizeMask[] =
00063 {
00064     255u,         /* 0xFF */
00065     65535u,       /* 0xFFFF */
00066     65535u,
00067     4294967295u,  /* 0xFFFFFFFF */
00068     4294967295u,
00069     4294967295u,
00070     4294967295u
00071 #ifdef UNITY_SUPPORT_64
00072     ,0xFFFFFFFFFFFFFFFF
00073 #endif
00074 };
00075 
00076 /*-----------------------------------------------
00077  * Pretty Printers & Test Result Output Handlers
00078  *-----------------------------------------------*/
00079 
00080 void UnityPrint(const char* string)
00081 {
00082     const char* pch = string;
00083 
00084     if (pch != NULL)
00085     {
00086         while (*pch)
00087         {
00088             /* printable characters plus CR & LF are printed */
00089             if ((*pch <= 126) && (*pch >= 32))
00090             {
00091                 UNITY_OUTPUT_CHAR(*pch);
00092             }
00093             /* write escaped carriage returns */
00094             else if (*pch == 13)
00095             {
00096                 UNITY_OUTPUT_CHAR('\\');
00097                 UNITY_OUTPUT_CHAR('r');
00098             }
00099             /* write escaped line feeds */
00100             else if (*pch == 10)
00101             {
00102                 UNITY_OUTPUT_CHAR('\\');
00103                 UNITY_OUTPUT_CHAR('n');
00104             }
00105             /* unprintable characters are shown as codes */
00106             else
00107             {
00108                 UNITY_OUTPUT_CHAR('\\');
00109                 UnityPrintNumberHex((_U_UINT)*pch, 2);
00110             }
00111             pch++;
00112         }
00113     }
00114 }
00115 
00116 void UnityPrintLen(const char* string, const _UU32 length);
00117 void UnityPrintLen(const char* string, const _UU32 length)
00118 {
00119     const char* pch = string;
00120 
00121     if (pch != NULL)
00122     {
00123         while (*pch && (_UU32)(pch - string) < length)
00124         {
00125             /* printable characters plus CR & LF are printed */
00126             if ((*pch <= 126) && (*pch >= 32))
00127             {
00128                 UNITY_OUTPUT_CHAR(*pch);
00129             }
00130             /* write escaped carriage returns */
00131             else if (*pch == 13)
00132             {
00133                 UNITY_OUTPUT_CHAR('\\');
00134                 UNITY_OUTPUT_CHAR('r');
00135             }
00136             /* write escaped line feeds */
00137             else if (*pch == 10)
00138             {
00139                 UNITY_OUTPUT_CHAR('\\');
00140                 UNITY_OUTPUT_CHAR('n');
00141             }
00142             /* unprintable characters are shown as codes */
00143             else
00144             {
00145                 UNITY_OUTPUT_CHAR('\\');
00146                 UnityPrintNumberHex((_U_UINT)*pch, 2);
00147             }
00148             pch++;
00149         }
00150     }
00151 }
00152 
00153 /*-----------------------------------------------*/
00154 void UnityPrintNumberByStyle(const _U_SINT number, const UNITY_DISPLAY_STYLE_T style)
00155 {
00156     if ((style & UNITY_DISPLAY_RANGE_INT) == UNITY_DISPLAY_RANGE_INT)
00157     {
00158         UnityPrintNumber(number);
00159     }
00160     else if ((style & UNITY_DISPLAY_RANGE_UINT) == UNITY_DISPLAY_RANGE_UINT)
00161     {
00162         UnityPrintNumberUnsigned(  (_U_UINT)number  &  UnitySizeMask[((_U_UINT)style & (_U_UINT)0x0F) - 1]  );
00163     }
00164     else
00165     {
00166         UnityPrintNumberHex((_U_UINT)number, (char)((style & 0x000F) << 1));
00167     }
00168 }
00169 
00170 /*-----------------------------------------------*/
00171 void UnityPrintNumber(const _U_SINT number_to_print)
00172 {
00173     _U_UINT number = (_U_UINT)number_to_print;
00174 
00175     if (number_to_print < 0)
00176     {
00177         /* A negative number, including MIN negative */
00178         UNITY_OUTPUT_CHAR('-');
00179         number = (_U_UINT)(-number_to_print);
00180     }
00181     UnityPrintNumberUnsigned(number);
00182 }
00183 
00184 /*-----------------------------------------------
00185  * basically do an itoa using as little ram as possible */
00186 void UnityPrintNumberUnsigned(const _U_UINT number)
00187 {
00188     _U_UINT divisor = 1;
00189 
00190     /* figure out initial divisor */
00191     while (number / divisor > 9)
00192     {
00193         divisor *= 10;
00194     }
00195 
00196     /* now mod and print, then divide divisor */
00197     do
00198     {
00199         UNITY_OUTPUT_CHAR((char)('0' + (number / divisor % 10)));
00200         divisor /= 10;
00201     }
00202     while (divisor > 0);
00203 }
00204 
00205 /*-----------------------------------------------*/
00206 void UnityPrintNumberHex(const _U_UINT number, const char nibbles_to_print)
00207 {
00208     _U_UINT nibble;
00209     char nibbles = nibbles_to_print;
00210     UNITY_OUTPUT_CHAR('0');
00211     UNITY_OUTPUT_CHAR('x');
00212 
00213     while (nibbles > 0)
00214     {
00215         nibble = (number >> (--nibbles << 2)) & 0x0000000F;
00216         if (nibble <= 9)
00217         {
00218             UNITY_OUTPUT_CHAR((char)('0' + nibble));
00219         }
00220         else
00221         {
00222             UNITY_OUTPUT_CHAR((char)('A' - 10 + nibble));
00223         }
00224     }
00225 }
00226 
00227 /*-----------------------------------------------*/
00228 void UnityPrintMask(const _U_UINT mask, const _U_UINT number)
00229 {
00230     _U_UINT current_bit = (_U_UINT)1 << (UNITY_INT_WIDTH - 1);
00231     _US32 i;
00232 
00233     for (i = 0; i < UNITY_INT_WIDTH; i++)
00234     {
00235         if (current_bit & mask)
00236         {
00237             if (current_bit & number)
00238             {
00239                 UNITY_OUTPUT_CHAR('1');
00240             }
00241             else
00242             {
00243                 UNITY_OUTPUT_CHAR('0');
00244             }
00245         }
00246         else
00247         {
00248             UNITY_OUTPUT_CHAR('X');
00249         }
00250         current_bit = current_bit >> 1;
00251     }
00252 }
00253 
00254 /*-----------------------------------------------*/
00255 #ifdef UNITY_FLOAT_VERBOSE
00256 #include <stdio.h>
00257 
00258 #ifndef UNITY_VERBOSE_NUMBER_MAX_LENGTH
00259 # ifdef UNITY_DOUBLE_VERBOSE
00260 #  define UNITY_VERBOSE_NUMBER_MAX_LENGTH 317
00261 # else
00262 #  define UNITY_VERBOSE_NUMBER_MAX_LENGTH 47
00263 # endif
00264 #endif
00265 
00266 void UnityPrintFloat(_UF number)
00267 {
00268     char TempBuffer[UNITY_VERBOSE_NUMBER_MAX_LENGTH + 1];
00269     snprintf(TempBuffer, sizeof(TempBuffer), "%.6f", number);
00270     UnityPrint(TempBuffer);
00271 }
00272 #endif
00273 
00274 /*-----------------------------------------------*/
00275 
00276 void UnityPrintFail(void);
00277 void UnityPrintFail(void)
00278 {
00279     UnityPrint(UnityStrFail);
00280 }
00281 
00282 void UnityPrintOk(void);
00283 void UnityPrintOk(void)
00284 {
00285     UnityPrint(UnityStrOk);
00286 }
00287 
00288 /*-----------------------------------------------*/
00289 static void UnityTestResultsBegin(const char* file, const UNITY_LINE_TYPE line);
00290 static void UnityTestResultsBegin(const char* file, const UNITY_LINE_TYPE line)
00291 {
00292 #ifndef UNITY_FIXTURES
00293     UnityPrint(file);
00294     UNITY_OUTPUT_CHAR(':');
00295     UnityPrintNumber((_U_SINT)line);
00296     UNITY_OUTPUT_CHAR(':');
00297     UnityPrint(Unity.CurrentTestName);
00298     UNITY_OUTPUT_CHAR(':');
00299 #else
00300     UNITY_UNUSED(file);
00301     UNITY_UNUSED(line);
00302 #endif
00303 }
00304 
00305 /* SA_PATCH: Make failures more noticable. */
00306 static void UnityPrintVisibleFailure(void);
00307 static void UnityPrintVisibleFailure(void)
00308 {
00309     UnityPrint(UNITY_RESULTS_TAGS_RESULT_START);
00310     UnityPrint(UnityStrFail);
00311     UnityPrint(UNITY_RESULTS_TAGS_RESULT_END);
00312 }
00313 /*-----------------------------------------------*/
00314 static void UnityTestResultsFailBegin(const UNITY_LINE_TYPE line);
00315 static void UnityTestResultsFailBegin(const UNITY_LINE_TYPE line)
00316 {
00317 #ifndef UNITY_FIXTURES
00318     UnityTestResultsBegin(Unity.TestFile, line);
00319 #else
00320     UNITY_UNUSED(line);
00321 #endif
00322     /* SA_PATCH: Make failures more noticable. */
00323     UnityPrintVisibleFailure();
00324     //UnityPrint(UnityStrFail);
00325     UNITY_OUTPUT_CHAR(':');
00326 }
00327 
00328 /*-----------------------------------------------*/
00329 void UnityConcludeTest(void)
00330 {
00331     if (Unity.CurrentTestIgnored)
00332     {
00333         Unity.TestIgnores++;
00334     }
00335     else if (!Unity.CurrentTestFailed)
00336     {
00337         UnityTestResultsBegin(Unity.TestFile, Unity.CurrentTestLineNumber);
00338         UnityPrint(UnityStrPass);
00339     }
00340     else
00341     {
00342         Unity.TestFailures++;
00343     }
00344 
00345     Unity.CurrentTestFailed = 0;
00346     Unity.CurrentTestIgnored = 0;
00347     UNITY_PRINT_EOL();
00348     UNITY_FLUSH_CALL();
00349 }
00350 
00351 /*-----------------------------------------------*/
00352 static void UnityAddMsgIfSpecified(const char* msg);
00353 static void UnityAddMsgIfSpecified(const char* msg)
00354 {
00355     if (msg)
00356     {
00357         UnityPrint(UnityStrSpacer);
00358 #ifndef UNITY_EXCLUDE_DETAILS
00359         if (Unity.CurrentDetail1)
00360         {
00361             UnityPrint(UnityStrDetail1Name);
00362             UnityPrint(Unity.CurrentDetail1);
00363             if (Unity.CurrentDetail2)
00364             {
00365                 UnityPrint(UnityStrDetail2Name);
00366                 UnityPrint(Unity.CurrentDetail2);
00367             }
00368             UnityPrint(UnityStrSpacer);
00369         }
00370 #endif
00371         UnityPrint(msg);
00372     }
00373 }
00374 
00375 /*-----------------------------------------------*/
00376 static void UnityPrintExpectedAndActualStrings(const char* expected, const char* actual);
00377 static void UnityPrintExpectedAndActualStrings(const char* expected, const char* actual)
00378 {
00379     UnityPrint(UnityStrExpected);
00380     if (expected != NULL)
00381     {
00382         UNITY_OUTPUT_CHAR('\'');
00383         UnityPrint(expected);
00384         UNITY_OUTPUT_CHAR('\'');
00385     }
00386     else
00387     {
00388       UnityPrint(UnityStrNull);
00389     }
00390     UnityPrint(UnityStrWas);
00391     if (actual != NULL)
00392     {
00393         UNITY_OUTPUT_CHAR('\'');
00394         UnityPrint(actual);
00395         UNITY_OUTPUT_CHAR('\'');
00396     }
00397     else
00398     {
00399       UnityPrint(UnityStrNull);
00400     }
00401 }
00402 
00403 /*-----------------------------------------------*/
00404 static void UnityPrintExpectedAndActualStringsLen(const char* expected, const char* actual, const _UU32 length)
00405 {
00406     UnityPrint(UnityStrExpected);
00407     if (expected != NULL)
00408     {
00409         UNITY_OUTPUT_CHAR('\'');
00410         UnityPrintLen(expected, length);
00411         UNITY_OUTPUT_CHAR('\'');
00412     }
00413     else
00414     {
00415       UnityPrint(UnityStrNull);
00416     }
00417     UnityPrint(UnityStrWas);
00418     if (actual != NULL)
00419     {
00420         UNITY_OUTPUT_CHAR('\'');
00421         UnityPrintLen(actual, length);
00422         UNITY_OUTPUT_CHAR('\'');
00423     }
00424     else
00425     {
00426       UnityPrint(UnityStrNull);
00427     }
00428 }
00429 
00430 
00431 
00432 /*-----------------------------------------------
00433  * Assertion & Control Helpers
00434  *-----------------------------------------------*/
00435 
00436 static int UnityCheckArraysForNull(UNITY_INTERNAL_PTR expected, UNITY_INTERNAL_PTR actual, const UNITY_LINE_TYPE lineNumber, const char* msg)
00437 {
00438     /* return true if they are both NULL */
00439     if ((expected == NULL) && (actual == NULL))
00440         return 1;
00441 
00442     /* throw error if just expected is NULL */
00443     if (expected == NULL)
00444     {
00445         UnityTestResultsFailBegin(lineNumber);
00446         UnityPrint(UnityStrNullPointerForExpected);
00447         UnityAddMsgIfSpecified(msg);
00448         UNITY_FAIL_AND_BAIL;
00449     }
00450 
00451     /* throw error if just actual is NULL */
00452     if (actual == NULL)
00453     {
00454         UnityTestResultsFailBegin(lineNumber);
00455         UnityPrint(UnityStrNullPointerForActual);
00456         UnityAddMsgIfSpecified(msg);
00457         UNITY_FAIL_AND_BAIL;
00458     }
00459 
00460     /* return false if neither is NULL */
00461     return 0;
00462 }
00463 
00464 /*-----------------------------------------------
00465  * Assertion Functions
00466  *-----------------------------------------------*/
00467 
00468 void UnityAssertBits(const _U_SINT mask,
00469                      const _U_SINT expected,
00470                      const _U_SINT actual,
00471                      const char* msg,
00472                      const UNITY_LINE_TYPE lineNumber)
00473 {
00474     UNITY_SKIP_EXECUTION;
00475 
00476     if ((mask & expected) != (mask & actual))
00477     {
00478         UnityTestResultsFailBegin(lineNumber);
00479         UnityPrint(UnityStrExpected);
00480         UnityPrintMask((_U_UINT)mask, (_U_UINT)expected);
00481         UnityPrint(UnityStrWas);
00482         UnityPrintMask((_U_UINT)mask, (_U_UINT)actual);
00483         UnityAddMsgIfSpecified(msg);
00484         UNITY_FAIL_AND_BAIL;
00485     }
00486 }
00487 
00488 /*-----------------------------------------------*/
00489 void UnityAssertEqualNumber(const _U_SINT expected,
00490                             const _U_SINT actual,
00491                             const char* msg,
00492                             const UNITY_LINE_TYPE lineNumber,
00493                             const UNITY_DISPLAY_STYLE_T style)
00494 {
00495     UNITY_SKIP_EXECUTION;
00496 
00497     if (expected != actual)
00498     {
00499         UnityTestResultsFailBegin(lineNumber);
00500         UnityPrint(UnityStrExpected);
00501         UnityPrintNumberByStyle(expected, style);
00502         UnityPrint(UnityStrWas);
00503         UnityPrintNumberByStyle(actual, style);
00504         UnityAddMsgIfSpecified(msg);
00505         UNITY_FAIL_AND_BAIL;
00506     }
00507 }
00508 
00509 #define UnityPrintPointlessAndBail()       \
00510 {                                          \
00511     UnityTestResultsFailBegin(lineNumber); \
00512     UnityPrint(UnityStrPointless);         \
00513     UnityAddMsgIfSpecified(msg);           \
00514     UNITY_FAIL_AND_BAIL; }
00515 
00516 /*-----------------------------------------------*/
00517 void UnityAssertEqualIntArray(UNITY_INTERNAL_PTR expected,
00518                               UNITY_INTERNAL_PTR actual,
00519                               const _UU32 num_elements,
00520                               const char* msg,
00521                               const UNITY_LINE_TYPE lineNumber,
00522                               const UNITY_DISPLAY_STYLE_T style)
00523 {
00524     _UU32 elements = num_elements;
00525     UNITY_INTERNAL_PTR ptr_exp = (UNITY_INTERNAL_PTR)expected;
00526     UNITY_INTERNAL_PTR ptr_act = (UNITY_INTERNAL_PTR)actual;
00527 
00528     UNITY_SKIP_EXECUTION;
00529 
00530     if (elements == 0)
00531     {
00532         UnityPrintPointlessAndBail();
00533     }
00534 
00535     if (UnityCheckArraysForNull((UNITY_INTERNAL_PTR)expected, (UNITY_INTERNAL_PTR)actual, lineNumber, msg) == 1)
00536         return;
00537 
00538     /* If style is UNITY_DISPLAY_STYLE_INT, we'll fall into the default case rather than the INT16 or INT32 (etc) case
00539      * as UNITY_DISPLAY_STYLE_INT includes a flag for UNITY_DISPLAY_RANGE_AUTO, which the width-specific
00540      * variants do not. Therefore remove this flag. */
00541     switch(style & (UNITY_DISPLAY_STYLE_T)(~UNITY_DISPLAY_RANGE_AUTO))
00542     {
00543         case UNITY_DISPLAY_STYLE_HEX8:
00544         case UNITY_DISPLAY_STYLE_INT8:
00545         case UNITY_DISPLAY_STYLE_UINT8:
00546             while (elements--)
00547             {
00548                 if (*(UNITY_PTR_ATTRIBUTE const _US8*)ptr_exp != *(UNITY_PTR_ATTRIBUTE const _US8*)ptr_act)
00549                 {
00550                     UnityTestResultsFailBegin(lineNumber);
00551                     UnityPrint(UnityStrElement);
00552                     UnityPrintNumberUnsigned(num_elements - elements - 1);
00553                     UnityPrint(UnityStrExpected);
00554                     UnityPrintNumberByStyle(*(UNITY_PTR_ATTRIBUTE const _US8*)ptr_exp, style);
00555                     UnityPrint(UnityStrWas);
00556                     UnityPrintNumberByStyle(*(UNITY_PTR_ATTRIBUTE const _US8*)ptr_act, style);
00557                     UnityAddMsgIfSpecified(msg);
00558                     UNITY_FAIL_AND_BAIL;
00559                 }
00560                 ptr_exp = (UNITY_INTERNAL_PTR)((_UP)ptr_exp + 1);
00561                 ptr_act = (UNITY_INTERNAL_PTR)((_UP)ptr_act + 1);
00562             }
00563             break;
00564         case UNITY_DISPLAY_STYLE_HEX16:
00565         case UNITY_DISPLAY_STYLE_INT16:
00566         case UNITY_DISPLAY_STYLE_UINT16:
00567             while (elements--)
00568             {
00569                 if (*(UNITY_PTR_ATTRIBUTE const _US16*)ptr_exp != *(UNITY_PTR_ATTRIBUTE const _US16*)ptr_act)
00570                 {
00571                     UnityTestResultsFailBegin(lineNumber);
00572                     UnityPrint(UnityStrElement);
00573                     UnityPrintNumberUnsigned(num_elements - elements - 1);
00574                     UnityPrint(UnityStrExpected);
00575                     UnityPrintNumberByStyle(*(UNITY_PTR_ATTRIBUTE const _US16*)ptr_exp, style);
00576                     UnityPrint(UnityStrWas);
00577                     UnityPrintNumberByStyle(*(UNITY_PTR_ATTRIBUTE const _US16*)ptr_act, style);
00578                     UnityAddMsgIfSpecified(msg);
00579                     UNITY_FAIL_AND_BAIL;
00580                 }
00581                 ptr_exp = (UNITY_INTERNAL_PTR)((_UP)ptr_exp + 2);
00582                 ptr_act = (UNITY_INTERNAL_PTR)((_UP)ptr_act + 2);
00583             }
00584             break;
00585 #ifdef UNITY_SUPPORT_64
00586         case UNITY_DISPLAY_STYLE_HEX64:
00587         case UNITY_DISPLAY_STYLE_INT64:
00588         case UNITY_DISPLAY_STYLE_UINT64:
00589             while (elements--)
00590             {
00591                 if (*(UNITY_PTR_ATTRIBUTE const _US64*)ptr_exp != *(UNITY_PTR_ATTRIBUTE const _US64*)ptr_act)
00592                 {
00593                     UnityTestResultsFailBegin(lineNumber);
00594                     UnityPrint(UnityStrElement);
00595                     UnityPrintNumberUnsigned(num_elements - elements - 1);
00596                     UnityPrint(UnityStrExpected);
00597                     UnityPrintNumberByStyle(*(UNITY_PTR_ATTRIBUTE const _US64*)ptr_exp, style);
00598                     UnityPrint(UnityStrWas);
00599                     UnityPrintNumberByStyle(*(UNITY_PTR_ATTRIBUTE const _US64*)ptr_act, style);
00600                     UnityAddMsgIfSpecified(msg);
00601                     UNITY_FAIL_AND_BAIL;
00602                 }
00603                 ptr_exp = (UNITY_INTERNAL_PTR)((_UP)ptr_exp + 8);
00604                 ptr_act = (UNITY_INTERNAL_PTR)((_UP)ptr_act + 8);
00605             }
00606             break;
00607 #endif
00608         default:
00609             while (elements--)
00610             {
00611                 if (*(UNITY_PTR_ATTRIBUTE const _US32*)ptr_exp != *(UNITY_PTR_ATTRIBUTE const _US32*)ptr_act)
00612                 {
00613                     UnityTestResultsFailBegin(lineNumber);
00614                     UnityPrint(UnityStrElement);
00615                     UnityPrintNumberUnsigned(num_elements - elements - 1);
00616                     UnityPrint(UnityStrExpected);
00617                     UnityPrintNumberByStyle(*(UNITY_PTR_ATTRIBUTE const _US32*)ptr_exp, style);
00618                     UnityPrint(UnityStrWas);
00619                     UnityPrintNumberByStyle(*(UNITY_PTR_ATTRIBUTE const _US32*)ptr_act, style);
00620                     UnityAddMsgIfSpecified(msg);
00621                     UNITY_FAIL_AND_BAIL;
00622                 }
00623                 ptr_exp = (UNITY_INTERNAL_PTR)((_UP)ptr_exp + 4);
00624                 ptr_act = (UNITY_INTERNAL_PTR)((_UP)ptr_act + 4);
00625             }
00626             break;
00627     }
00628 }
00629 
00630 /*-----------------------------------------------*/
00631 #ifndef UNITY_EXCLUDE_FLOAT
00632 void UnityAssertEqualFloatArray(UNITY_PTR_ATTRIBUTE const _UF* expected,
00633                                 UNITY_PTR_ATTRIBUTE const _UF* actual,
00634                                 const _UU32 num_elements,
00635                                 const char* msg,
00636                                 const UNITY_LINE_TYPE lineNumber)
00637 {
00638     _UU32 elements = num_elements;
00639     UNITY_PTR_ATTRIBUTE const _UF* ptr_expected = expected;
00640     UNITY_PTR_ATTRIBUTE const _UF* ptr_actual = actual;
00641     _UF diff, tol;
00642 
00643     UNITY_SKIP_EXECUTION;
00644 
00645     if (elements == 0)
00646     {
00647         UnityPrintPointlessAndBail();
00648     }
00649 
00650     if (UnityCheckArraysForNull((UNITY_INTERNAL_PTR)expected, (UNITY_INTERNAL_PTR)actual, lineNumber, msg) == 1)
00651         return;
00652 
00653     while (elements--)
00654     {
00655         diff = *ptr_expected - *ptr_actual;
00656         if (diff < 0.0f)
00657             diff = 0.0f - diff;
00658         tol = UNITY_FLOAT_PRECISION * *ptr_expected;
00659         if (tol < 0.0f)
00660             tol = 0.0f - tol;
00661 
00662         /* This first part of this condition will catch any NaN or Infinite values */
00663         if (isnan(diff) || isinf(diff) || (diff > tol))
00664         {
00665             UnityTestResultsFailBegin(lineNumber);
00666             UnityPrint(UnityStrElement);
00667             UnityPrintNumberUnsigned(num_elements - elements - 1);
00668 #ifdef UNITY_FLOAT_VERBOSE
00669             UnityPrint(UnityStrExpected);
00670             UnityPrintFloat(*ptr_expected);
00671             UnityPrint(UnityStrWas);
00672             UnityPrintFloat(*ptr_actual);
00673 #else
00674             UnityPrint(UnityStrDelta);
00675 #endif
00676             UnityAddMsgIfSpecified(msg);
00677             UNITY_FAIL_AND_BAIL;
00678         }
00679         ptr_expected++;
00680         ptr_actual++;
00681     }
00682 }
00683 
00684 /*-----------------------------------------------*/
00685 void UnityAssertFloatsWithin(const _UF delta,
00686                              const _UF expected,
00687                              const _UF actual,
00688                              const char* msg,
00689                              const UNITY_LINE_TYPE lineNumber)
00690 {
00691     _UF diff = actual - expected;
00692     _UF pos_delta = delta;
00693 
00694     UNITY_SKIP_EXECUTION;
00695 
00696     if (diff < 0.0f)
00697     {
00698         diff = 0.0f - diff;
00699     }
00700     if (pos_delta < 0.0f)
00701     {
00702         pos_delta = 0.0f - pos_delta;
00703     }
00704 
00705     /* This first part of this condition will catch any NaN or Infinite values */
00706     if (isnan(diff) || isinf(diff) || (pos_delta < diff))
00707     {
00708         UnityTestResultsFailBegin(lineNumber);
00709 #ifdef UNITY_FLOAT_VERBOSE
00710         UnityPrint(UnityStrExpected);
00711         UnityPrintFloat(expected);
00712         UnityPrint(UnityStrWas);
00713         UnityPrintFloat(actual);
00714 #else
00715         UnityPrint(UnityStrDelta);
00716 #endif
00717         UnityAddMsgIfSpecified(msg);
00718         UNITY_FAIL_AND_BAIL;
00719     }
00720 }
00721 
00722 /*-----------------------------------------------*/
00723 void UnityAssertFloatSpecial(const _UF actual,
00724                              const char* msg,
00725                              const UNITY_LINE_TYPE lineNumber,
00726                              const UNITY_FLOAT_TRAIT_T style)
00727 {
00728     const char* trait_names[] = { UnityStrInf, UnityStrNegInf, UnityStrNaN, UnityStrDet };
00729     _U_SINT should_be_trait   = ((_U_SINT)style & 1);
00730     _U_SINT is_trait          = !should_be_trait;
00731     _U_SINT trait_index       = (_U_SINT)(style >> 1);
00732 
00733     UNITY_SKIP_EXECUTION;
00734 
00735     switch(style)
00736     {
00737         /* To determine Inf / Neg Inf, we compare to an Inf / Neg Inf value we create on the fly
00738          * We are using a variable to hold the zero value because some compilers complain about dividing by zero otherwise */
00739         case UNITY_FLOAT_IS_INF:
00740         case UNITY_FLOAT_IS_NOT_INF:
00741             is_trait = isinf(actual) & ispos(actual);
00742             break;
00743         case UNITY_FLOAT_IS_NEG_INF:
00744         case UNITY_FLOAT_IS_NOT_NEG_INF:
00745             is_trait = isinf(actual) & isneg(actual);
00746             break;
00747 
00748         /* NaN is the only floating point value that does NOT equal itself. Therefore if Actual == Actual, then it is NOT NaN. */
00749         case UNITY_FLOAT_IS_NAN:
00750         case UNITY_FLOAT_IS_NOT_NAN:
00751             is_trait = isnan(actual);
00752             break;
00753 
00754         /* A determinate number is non infinite and not NaN. (therefore the opposite of the two above) */
00755         case UNITY_FLOAT_IS_DET:
00756         case UNITY_FLOAT_IS_NOT_DET:
00757             if (isinf(actual) | isnan(actual))
00758                 is_trait = 0;
00759             else
00760                 is_trait = 1;
00761             break;
00762 
00763         default:
00764             trait_index = 0;
00765             trait_names[0] = UnityStrInvalidFloatTrait;
00766             break;
00767     }
00768 
00769     if (is_trait != should_be_trait)
00770     {
00771         UnityTestResultsFailBegin(lineNumber);
00772         UnityPrint(UnityStrExpected);
00773         if (!should_be_trait)
00774             UnityPrint(UnityStrNot);
00775         UnityPrint(trait_names[trait_index]);
00776         UnityPrint(UnityStrWas);
00777 #ifdef UNITY_FLOAT_VERBOSE
00778         UnityPrintFloat(actual);
00779 #else
00780         if (should_be_trait)
00781             UnityPrint(UnityStrNot);
00782         UnityPrint(trait_names[trait_index]);
00783 #endif
00784         UnityAddMsgIfSpecified(msg);
00785         UNITY_FAIL_AND_BAIL;
00786     }
00787 }
00788 
00789 #endif /* not UNITY_EXCLUDE_FLOAT */
00790 
00791 /*-----------------------------------------------*/
00792 #ifndef UNITY_EXCLUDE_DOUBLE
00793 void UnityAssertEqualDoubleArray(UNITY_PTR_ATTRIBUTE const _UD* expected,
00794                                  UNITY_PTR_ATTRIBUTE const _UD* actual,
00795                                  const _UU32 num_elements,
00796                                  const char* msg,
00797                                  const UNITY_LINE_TYPE lineNumber)
00798 {
00799     _UU32 elements = num_elements;
00800     UNITY_PTR_ATTRIBUTE const _UD* ptr_expected = expected;
00801     UNITY_PTR_ATTRIBUTE const _UD* ptr_actual = actual;
00802     _UD diff, tol;
00803 
00804     UNITY_SKIP_EXECUTION;
00805 
00806     if (elements == 0)
00807     {
00808         UnityPrintPointlessAndBail();
00809     }
00810 
00811     if (UnityCheckArraysForNull((UNITY_INTERNAL_PTR)expected, (UNITY_INTERNAL_PTR)actual, lineNumber, msg) == 1)
00812         return;
00813 
00814     while (elements--)
00815     {
00816         diff = *ptr_expected - *ptr_actual;
00817         if (diff < 0.0)
00818           diff = 0.0 - diff;
00819         tol = UNITY_DOUBLE_PRECISION * *ptr_expected;
00820         if (tol < 0.0)
00821             tol = 0.0 - tol;
00822 
00823         /* This first part of this condition will catch any NaN or Infinite values */
00824         if (isnan(diff) || isinf(diff) || (diff > tol))
00825         {
00826             UnityTestResultsFailBegin(lineNumber);
00827             UnityPrint(UnityStrElement);
00828             UnityPrintNumberUnsigned(num_elements - elements - 1);
00829 #ifdef UNITY_DOUBLE_VERBOSE
00830             UnityPrint(UnityStrExpected);
00831             UnityPrintFloat((float)(*ptr_expected));
00832             UnityPrint(UnityStrWas);
00833             UnityPrintFloat((float)(*ptr_actual));
00834 #else
00835             UnityPrint(UnityStrDelta);
00836 #endif
00837             UnityAddMsgIfSpecified(msg);
00838             UNITY_FAIL_AND_BAIL;
00839         }
00840         ptr_expected++;
00841         ptr_actual++;
00842     }
00843 }
00844 
00845 /*-----------------------------------------------*/
00846 void UnityAssertDoublesWithin(const _UD delta,
00847                               const _UD expected,
00848                               const _UD actual,
00849                               const char* msg,
00850                               const UNITY_LINE_TYPE lineNumber)
00851 {
00852     _UD diff = actual - expected;
00853     _UD pos_delta = delta;
00854 
00855     UNITY_SKIP_EXECUTION;
00856 
00857     if (diff < 0.0)
00858     {
00859         diff = 0.0 - diff;
00860     }
00861     if (pos_delta < 0.0)
00862     {
00863         pos_delta = 0.0 - pos_delta;
00864     }
00865 
00866     /* This first part of this condition will catch any NaN or Infinite values */
00867     if (isnan(diff) || isinf(diff) || (pos_delta < diff))
00868     {
00869         UnityTestResultsFailBegin(lineNumber);
00870 #ifdef UNITY_DOUBLE_VERBOSE
00871         UnityPrint(UnityStrExpected);
00872         UnityPrintFloat((float)expected);
00873         UnityPrint(UnityStrWas);
00874         UnityPrintFloat((float)actual);
00875 #else
00876         UnityPrint(UnityStrDelta);
00877 #endif
00878         UnityAddMsgIfSpecified(msg);
00879         UNITY_FAIL_AND_BAIL;
00880     }
00881 }
00882 
00883 /*-----------------------------------------------*/
00884 
00885 void UnityAssertDoubleSpecial(const _UD actual,
00886                               const char* msg,
00887                               const UNITY_LINE_TYPE lineNumber,
00888                               const UNITY_FLOAT_TRAIT_T style)
00889 {
00890     const char* trait_names[] = { UnityStrInf, UnityStrNegInf, UnityStrNaN, UnityStrDet };
00891     _U_SINT should_be_trait   = ((_U_SINT)style & 1);
00892     _U_SINT is_trait          = !should_be_trait;
00893     _U_SINT trait_index       = (_U_SINT)(style >> 1);
00894 
00895     UNITY_SKIP_EXECUTION;
00896 
00897      switch(style)
00898     {
00899         /* To determine Inf / Neg Inf, we compare to an Inf / Neg Inf value we create on the fly
00900          * We are using a variable to hold the zero value because some compilers complain about dividing by zero otherwise */
00901         case UNITY_FLOAT_IS_INF:
00902         case UNITY_FLOAT_IS_NOT_INF:
00903             is_trait = isinf(actual) & ispos(actual);
00904             break;
00905         case UNITY_FLOAT_IS_NEG_INF:
00906         case UNITY_FLOAT_IS_NOT_NEG_INF:
00907             is_trait = isinf(actual) & isneg(actual);
00908             break;
00909 
00910         /* NaN is the only floating point value that does NOT equal itself. Therefore if Actual == Actual, then it is NOT NaN. */
00911         case UNITY_FLOAT_IS_NAN:
00912         case UNITY_FLOAT_IS_NOT_NAN:
00913             is_trait = isnan(actual);
00914             break;
00915 
00916         /* A determinate number is non infinite and not NaN. (therefore the opposite of the two above) */
00917         case UNITY_FLOAT_IS_DET:
00918         case UNITY_FLOAT_IS_NOT_DET:
00919             if (isinf(actual) | isnan(actual))
00920                 is_trait = 0;
00921             else
00922                 is_trait = 1;
00923             break;
00924 
00925         default:
00926             trait_index = 0;
00927             trait_names[0] = UnityStrInvalidFloatTrait;
00928             break;
00929     }
00930 
00931     if (is_trait != should_be_trait)
00932     {
00933         UnityTestResultsFailBegin(lineNumber);
00934         UnityPrint(UnityStrExpected);
00935         if (!should_be_trait)
00936             UnityPrint(UnityStrNot);
00937         UnityPrint(trait_names[trait_index]);
00938         UnityPrint(UnityStrWas);
00939 #ifdef UNITY_DOUBLE_VERBOSE
00940         UnityPrintFloat(actual);
00941 #else
00942         if (should_be_trait)
00943             UnityPrint(UnityStrNot);
00944         UnityPrint(trait_names[trait_index]);
00945 #endif
00946         UnityAddMsgIfSpecified(msg);
00947         UNITY_FAIL_AND_BAIL;
00948     }
00949 }
00950 
00951 
00952 #endif /* not UNITY_EXCLUDE_DOUBLE */
00953 
00954 /*-----------------------------------------------*/
00955 void UnityAssertNumbersWithin( const _U_UINT delta,
00956                                const _U_SINT expected,
00957                                const _U_SINT actual,
00958                                const char* msg,
00959                                const UNITY_LINE_TYPE lineNumber,
00960                                const UNITY_DISPLAY_STYLE_T style)
00961 {
00962     UNITY_SKIP_EXECUTION;
00963 
00964     if ((style & UNITY_DISPLAY_RANGE_INT) == UNITY_DISPLAY_RANGE_INT)
00965     {
00966         if (actual > expected)
00967             Unity.CurrentTestFailed = ((_U_UINT)(actual - expected) > delta);
00968         else
00969             Unity.CurrentTestFailed = ((_U_UINT)(expected - actual) > delta);
00970     }
00971     else
00972     {
00973         if ((_U_UINT)actual > (_U_UINT)expected)
00974             Unity.CurrentTestFailed = ((_U_UINT)(actual - expected) > delta);
00975         else
00976             Unity.CurrentTestFailed = ((_U_UINT)(expected - actual) > delta);
00977     }
00978 
00979     if (Unity.CurrentTestFailed)
00980     {
00981         UnityTestResultsFailBegin(lineNumber);
00982         UnityPrint(UnityStrDelta);
00983         UnityPrintNumberByStyle((_U_SINT)delta, style);
00984         UnityPrint(UnityStrExpected);
00985         UnityPrintNumberByStyle(expected, style);
00986         UnityPrint(UnityStrWas);
00987         UnityPrintNumberByStyle(actual, style);
00988         UnityAddMsgIfSpecified(msg);
00989         UNITY_FAIL_AND_BAIL;
00990     }
00991 }
00992 
00993 /*-----------------------------------------------*/
00994 void UnityAssertEqualString(const char* expected,
00995                             const char* actual,
00996                             const char* msg,
00997                             const UNITY_LINE_TYPE lineNumber)
00998 {
00999     _UU32 i;
01000 
01001     UNITY_SKIP_EXECUTION;
01002 
01003     /* if both pointers not null compare the strings */
01004     if (expected && actual)
01005     {
01006         for (i = 0; expected[i] || actual[i]; i++)
01007         {
01008             if (expected[i] != actual[i])
01009             {
01010                 Unity.CurrentTestFailed = 1;
01011                 break;
01012             }
01013         }
01014     }
01015     else
01016     { /* handle case of one pointers being null (if both null, test should pass) */
01017         if (expected != actual)
01018         {
01019             Unity.CurrentTestFailed = 1;
01020         }
01021     }
01022 
01023     if (Unity.CurrentTestFailed)
01024     {
01025       UnityTestResultsFailBegin(lineNumber);
01026       UnityPrintExpectedAndActualStrings(expected, actual);
01027       UnityAddMsgIfSpecified(msg);
01028       UNITY_FAIL_AND_BAIL;
01029     }
01030 }
01031 
01032 /*-----------------------------------------------*/
01033 void UnityAssertEqualStringLen(const char* expected,
01034                             const char* actual,
01035                             const _UU32 length,
01036                             const char* msg,
01037                             const UNITY_LINE_TYPE lineNumber)
01038 {
01039     _UU32 i;
01040 
01041     UNITY_SKIP_EXECUTION;
01042 
01043     /* if both pointers not null compare the strings */
01044     if (expected && actual)
01045     {
01046         for (i = 0; (expected[i] || actual[i]) && i < length; i++)
01047         {
01048             if (expected[i] != actual[i])
01049             {
01050                 Unity.CurrentTestFailed = 1;
01051                 break;
01052             }
01053         }
01054     }
01055     else
01056     { /* handle case of one pointers being null (if both null, test should pass) */
01057         if (expected != actual)
01058         {
01059             Unity.CurrentTestFailed = 1;
01060         }
01061     }
01062 
01063     if (Unity.CurrentTestFailed)
01064     {
01065       UnityTestResultsFailBegin(lineNumber);
01066       UnityPrintExpectedAndActualStringsLen(expected, actual, length);
01067       UnityAddMsgIfSpecified(msg);
01068       UNITY_FAIL_AND_BAIL;
01069     }
01070 }
01071 
01072 
01073 /*-----------------------------------------------*/
01074 void UnityAssertEqualStringArray( const char** expected,
01075                                   const char** actual,
01076                                   const _UU32 num_elements,
01077                                   const char* msg,
01078                                   const UNITY_LINE_TYPE lineNumber)
01079 {
01080     _UU32 i, j = 0;
01081 
01082     UNITY_SKIP_EXECUTION;
01083 
01084     /* if no elements, it's an error */
01085     if (num_elements == 0)
01086     {
01087         UnityPrintPointlessAndBail();
01088     }
01089 
01090     if (UnityCheckArraysForNull((UNITY_INTERNAL_PTR)expected, (UNITY_INTERNAL_PTR)actual, lineNumber, msg) == 1)
01091         return;
01092 
01093     do
01094     {
01095         /* if both pointers not null compare the strings */
01096         if (expected[j] && actual[j])
01097         {
01098             for (i = 0; expected[j][i] || actual[j][i]; i++)
01099             {
01100                 if (expected[j][i] != actual[j][i])
01101                 {
01102                     Unity.CurrentTestFailed = 1;
01103                     break;
01104                 }
01105             }
01106         }
01107         else
01108         { /* handle case of one pointers being null (if both null, test should pass) */
01109             if (expected[j] != actual[j])
01110             {
01111                 Unity.CurrentTestFailed = 1;
01112             }
01113         }
01114 
01115         if (Unity.CurrentTestFailed)
01116         {
01117             UnityTestResultsFailBegin(lineNumber);
01118             if (num_elements > 1)
01119             {
01120                 UnityPrint(UnityStrElement);
01121                 UnityPrintNumberUnsigned(j);
01122             }
01123             UnityPrintExpectedAndActualStrings((const char*)(expected[j]), (const char*)(actual[j]));
01124             UnityAddMsgIfSpecified(msg);
01125             UNITY_FAIL_AND_BAIL;
01126         }
01127     } while (++j < num_elements);
01128 }
01129 
01130 /*-----------------------------------------------*/
01131 void UnityAssertEqualMemory( UNITY_INTERNAL_PTR expected,
01132                              UNITY_INTERNAL_PTR actual,
01133                              const _UU32 length,
01134                              const _UU32 num_elements,
01135                              const char* msg,
01136                              const UNITY_LINE_TYPE lineNumber)
01137 {
01138     UNITY_PTR_ATTRIBUTE const unsigned char* ptr_exp = (UNITY_PTR_ATTRIBUTE const unsigned char*)expected;
01139     UNITY_PTR_ATTRIBUTE const unsigned char* ptr_act = (UNITY_PTR_ATTRIBUTE const unsigned char*)actual;
01140     _UU32 elements = num_elements;
01141     _UU32 bytes;
01142 
01143     UNITY_SKIP_EXECUTION;
01144 
01145     if ((elements == 0) || (length == 0))
01146     {
01147         UnityPrintPointlessAndBail();
01148     }
01149 
01150     if (UnityCheckArraysForNull((UNITY_INTERNAL_PTR)expected, (UNITY_INTERNAL_PTR)actual, lineNumber, msg) == 1)
01151         return;
01152 
01153     while (elements--)
01154     {
01155         /* /////////////////////////////////// */
01156         bytes = length;
01157         while (bytes--)
01158         {
01159             if (*ptr_exp != *ptr_act)
01160             {
01161                 UnityTestResultsFailBegin(lineNumber);
01162                 UnityPrint(UnityStrMemory);
01163                 if (num_elements > 1)
01164                 {
01165                     UnityPrint(UnityStrElement);
01166                     UnityPrintNumberUnsigned(num_elements - elements - 1);
01167                 }
01168                 UnityPrint(UnityStrByte);
01169                 UnityPrintNumberUnsigned(length - bytes - 1);
01170                 UnityPrint(UnityStrExpected);
01171                 UnityPrintNumberByStyle(*ptr_exp, UNITY_DISPLAY_STYLE_HEX8);
01172                 UnityPrint(UnityStrWas);
01173                 UnityPrintNumberByStyle(*ptr_act, UNITY_DISPLAY_STYLE_HEX8);
01174                 UnityAddMsgIfSpecified(msg);
01175                 UNITY_FAIL_AND_BAIL;
01176             }
01177             ptr_exp = (UNITY_INTERNAL_PTR)((_UP)ptr_exp + 1);
01178             ptr_act = (UNITY_INTERNAL_PTR)((_UP)ptr_act + 1);
01179         }
01180         /* /////////////////////////////////// */
01181 
01182     }
01183 }
01184 
01185 /*-----------------------------------------------
01186  * Control Functions
01187  *-----------------------------------------------*/
01188 
01189 void UnityFail(const char* msg, const UNITY_LINE_TYPE line)
01190 {
01191    UNITY_SKIP_EXECUTION;
01192 
01193     UnityTestResultsBegin(Unity.TestFile, line);
01194     /* SA_PATCH: Make failures more noticable. */
01195     UnityPrintVisibleFailure();
01196     //UnityPrintFail();
01197     if (msg != NULL)
01198     {
01199         UNITY_OUTPUT_CHAR(':');
01200 
01201 #ifndef UNITY_EXCLUDE_DETAILS
01202         if (Unity.CurrentDetail1)
01203         {
01204             UnityPrint(UnityStrDetail1Name);
01205             UnityPrint(Unity.CurrentDetail1);
01206             if (Unity.CurrentDetail2)
01207             {
01208                 UnityPrint(UnityStrDetail2Name);
01209                 UnityPrint(Unity.CurrentDetail2);
01210             }
01211             UnityPrint(UnityStrSpacer);
01212         }
01213 #endif
01214         if (msg[0] != ' ')
01215         {
01216             UNITY_OUTPUT_CHAR(' ');
01217         }
01218         UnityPrint(msg);
01219     }
01220 
01221     UNITY_FAIL_AND_BAIL;
01222 }
01223 
01224 /*-----------------------------------------------*/
01225 void UnityIgnore(const char* msg, const UNITY_LINE_TYPE line)
01226 {
01227     UNITY_SKIP_EXECUTION;
01228 
01229     UnityTestResultsBegin(Unity.TestFile, line);
01230     // SA_PATCH
01231     UnityPrint(UNITY_RESULTS_TAGS_RESULT_START);
01232     UnityPrint(UnityStrIgnore);
01233     UnityPrint(UNITY_RESULTS_TAGS_RESULT_END);
01234     if (msg != NULL)
01235     {
01236       UNITY_OUTPUT_CHAR(':');
01237       UNITY_OUTPUT_CHAR(' ');
01238       UnityPrint(msg);
01239     }
01240     UNITY_IGNORE_AND_BAIL;
01241 }
01242 
01243 /*-----------------------------------------------*/
01244 #if defined(UNITY_WEAK_ATTRIBUTE)
01245     UNITY_WEAK_ATTRIBUTE void setUp(void) { }
01246     UNITY_WEAK_ATTRIBUTE void tearDown(void) { }
01247 #elif defined(UNITY_WEAK_PRAGMA)
01248 #   pragma weak setUp
01249     void setUp(void) { }
01250 #   pragma weak tearDown
01251     void tearDown(void) { }
01252 #endif
01253 /*-----------------------------------------------*/
01254 void UnityDefaultTestRun(UnityTestFunction Func, const char* FuncName, const int FuncLineNum)
01255 {
01256     Unity.CurrentTestName = FuncName;
01257     Unity.CurrentTestLineNumber = (UNITY_LINE_TYPE)FuncLineNum;
01258     Unity.NumberOfTests++;
01259     UNITY_CLR_DETAILS();
01260     if (TEST_PROTECT())
01261     {
01262         setUp();
01263         Func();
01264     }
01265     if (TEST_PROTECT() && !(Unity.CurrentTestIgnored))
01266     {
01267         tearDown();
01268     }
01269     UnityConcludeTest();
01270 }
01271 
01272 /*-----------------------------------------------*/
01273 void UnityBegin(const char* filename)
01274 {
01275     Unity.TestFile = filename;
01276     Unity.CurrentTestName = NULL;
01277     Unity.CurrentTestLineNumber = 0;
01278     Unity.NumberOfTests = 0;
01279     Unity.TestFailures = 0;
01280     Unity.TestIgnores = 0;
01281     Unity.CurrentTestFailed = 0;
01282     Unity.CurrentTestIgnored = 0;
01283 
01284     UNITY_CLR_DETAILS();
01285     UNITY_OUTPUT_START();
01286 }
01287 
01288 /*-----------------------------------------------*/
01289 int UnityEnd(void)
01290 {
01291     UNITY_PRINT_EOL();
01292     UnityPrint(UnityStrBreaker);
01293     UNITY_PRINT_EOL();
01294     UnityPrintNumber((_U_SINT)(Unity.NumberOfTests));
01295     UnityPrint(UnityStrResultsTests);
01296     UnityPrintNumber((_U_SINT)(Unity.TestFailures));
01297     UnityPrint(UnityStrResultsFailures);
01298     UnityPrintNumber((_U_SINT)(Unity.TestIgnores));
01299     UnityPrint(UnityStrResultsIgnored);
01300     UNITY_PRINT_EOL();
01301     if (Unity.TestFailures == 0U)
01302     {
01303         UnityPrintOk();
01304     }
01305     else
01306     {
01307         UnityPrintFail();
01308 #ifdef UNITY_DIFFERENTIATE_FINAL_FAIL
01309         UNITY_OUTPUT_CHAR('E'); UNITY_OUTPUT_CHAR('D');
01310 #endif
01311     }
01312     UNITY_PRINT_EOL();
01313     UNITY_FLUSH_CALL();
01314     UNITY_OUTPUT_COMPLETE();
01315     return (int)(Unity.TestFailures);
01316 }
01317 
01318 /*-----------------------------------------------*/