FRDM K64F Metronome

Committer:
ram54288
Date:
Sun May 14 18:35:07 2017 +0000
Revision:
0:a2cb7295a1f7
Initial commit

Who changed what in which revision?

UserRevisionLine numberNew contents of line
ram54288 0:a2cb7295a1f7 1 /* =========================================================================
ram54288 0:a2cb7295a1f7 2 Unity Project - A Test Framework for C
ram54288 0:a2cb7295a1f7 3 Copyright (c) 2007-14 Mike Karlesky, Mark VanderVoord, Greg Williams
ram54288 0:a2cb7295a1f7 4 [Released under MIT License. Please refer to license.txt for details]
ram54288 0:a2cb7295a1f7 5 ============================================================================ */
ram54288 0:a2cb7295a1f7 6
ram54288 0:a2cb7295a1f7 7 #include "unity.h"
ram54288 0:a2cb7295a1f7 8 #include <stddef.h>
ram54288 0:a2cb7295a1f7 9
ram54288 0:a2cb7295a1f7 10 /* If omitted from header, declare overrideable prototypes here so they're ready for use */
ram54288 0:a2cb7295a1f7 11 #ifdef UNITY_OMIT_OUTPUT_CHAR_HEADER_DECLARATION
ram54288 0:a2cb7295a1f7 12 void UNITY_OUTPUT_CHAR(int);
ram54288 0:a2cb7295a1f7 13 #endif
ram54288 0:a2cb7295a1f7 14
ram54288 0:a2cb7295a1f7 15 /* Helpful macros for us to use here */
ram54288 0:a2cb7295a1f7 16 #define UNITY_FAIL_AND_BAIL { Unity.CurrentTestFailed = 1; longjmp(Unity.AbortFrame, 1); }
ram54288 0:a2cb7295a1f7 17 #define UNITY_IGNORE_AND_BAIL { Unity.CurrentTestIgnored = 1; longjmp(Unity.AbortFrame, 1); }
ram54288 0:a2cb7295a1f7 18
ram54288 0:a2cb7295a1f7 19 /* return prematurely if we are already in failure or ignore state */
ram54288 0:a2cb7295a1f7 20 #define UNITY_SKIP_EXECUTION { if ((Unity.CurrentTestFailed != 0) || (Unity.CurrentTestIgnored != 0)) {return;} }
ram54288 0:a2cb7295a1f7 21
ram54288 0:a2cb7295a1f7 22 struct _Unity Unity;
ram54288 0:a2cb7295a1f7 23
ram54288 0:a2cb7295a1f7 24 static const char UnityStrOk[] = "OK";
ram54288 0:a2cb7295a1f7 25 static const char UnityStrPass[] = "PASS";
ram54288 0:a2cb7295a1f7 26 static const char UnityStrFail[] = "FAIL";
ram54288 0:a2cb7295a1f7 27 static const char UnityStrIgnore[] = "IGNORE";
ram54288 0:a2cb7295a1f7 28 static const char UnityStrNull[] = "NULL";
ram54288 0:a2cb7295a1f7 29 static const char UnityStrSpacer[] = ". ";
ram54288 0:a2cb7295a1f7 30 static const char UnityStrExpected[] = " Expected ";
ram54288 0:a2cb7295a1f7 31 static const char UnityStrWas[] = " Was ";
ram54288 0:a2cb7295a1f7 32 static const char UnityStrElement[] = " Element ";
ram54288 0:a2cb7295a1f7 33 static const char UnityStrByte[] = " Byte ";
ram54288 0:a2cb7295a1f7 34 static const char UnityStrMemory[] = " Memory Mismatch.";
ram54288 0:a2cb7295a1f7 35 static const char UnityStrDelta[] = " Values Not Within Delta ";
ram54288 0:a2cb7295a1f7 36 static const char UnityStrPointless[] = " You Asked Me To Compare Nothing, Which Was Pointless.";
ram54288 0:a2cb7295a1f7 37 static const char UnityStrNullPointerForExpected[] = " Expected pointer to be NULL";
ram54288 0:a2cb7295a1f7 38 static const char UnityStrNullPointerForActual[] = " Actual pointer was NULL";
ram54288 0:a2cb7295a1f7 39 static const char UnityStrNot[] = "Not ";
ram54288 0:a2cb7295a1f7 40 static const char UnityStrInf[] = "Infinity";
ram54288 0:a2cb7295a1f7 41 static const char UnityStrNegInf[] = "Negative Infinity";
ram54288 0:a2cb7295a1f7 42 static const char UnityStrNaN[] = "NaN";
ram54288 0:a2cb7295a1f7 43 static const char UnityStrDet[] = "Determinate";
ram54288 0:a2cb7295a1f7 44 static const char UnityStrInvalidFloatTrait[] = "Invalid Float Trait";
ram54288 0:a2cb7295a1f7 45 const char UnityStrErrFloat[] = "Unity Floating Point Disabled";
ram54288 0:a2cb7295a1f7 46 const char UnityStrErrDouble[] = "Unity Double Precision Disabled";
ram54288 0:a2cb7295a1f7 47 const char UnityStrErr64[] = "Unity 64-bit Support Disabled";
ram54288 0:a2cb7295a1f7 48 static const char UnityStrBreaker[] = "-----------------------";
ram54288 0:a2cb7295a1f7 49 static const char UnityStrResultsTests[] = " Tests ";
ram54288 0:a2cb7295a1f7 50 static const char UnityStrResultsFailures[] = " Failures ";
ram54288 0:a2cb7295a1f7 51 static const char UnityStrResultsIgnored[] = " Ignored ";
ram54288 0:a2cb7295a1f7 52 static const char UnityStrDetail1Name[] = UNITY_DETAIL1_NAME " ";
ram54288 0:a2cb7295a1f7 53 static const char UnityStrDetail2Name[] = " " UNITY_DETAIL2_NAME " ";
ram54288 0:a2cb7295a1f7 54
ram54288 0:a2cb7295a1f7 55 #ifdef UNITY_FLOAT_NEEDS_ZERO
ram54288 0:a2cb7295a1f7 56 /* Dividing by these constants produces +/- infinity.
ram54288 0:a2cb7295a1f7 57 * The rationale is given in UnityAssertFloatIsInf's body. */
ram54288 0:a2cb7295a1f7 58 static const _UF f_zero = 0.0f;
ram54288 0:a2cb7295a1f7 59 #endif
ram54288 0:a2cb7295a1f7 60
ram54288 0:a2cb7295a1f7 61 /* compiler-generic print formatting masks */
ram54288 0:a2cb7295a1f7 62 static const _U_UINT UnitySizeMask[] =
ram54288 0:a2cb7295a1f7 63 {
ram54288 0:a2cb7295a1f7 64 255u, /* 0xFF */
ram54288 0:a2cb7295a1f7 65 65535u, /* 0xFFFF */
ram54288 0:a2cb7295a1f7 66 65535u,
ram54288 0:a2cb7295a1f7 67 4294967295u, /* 0xFFFFFFFF */
ram54288 0:a2cb7295a1f7 68 4294967295u,
ram54288 0:a2cb7295a1f7 69 4294967295u,
ram54288 0:a2cb7295a1f7 70 4294967295u
ram54288 0:a2cb7295a1f7 71 #ifdef UNITY_SUPPORT_64
ram54288 0:a2cb7295a1f7 72 ,0xFFFFFFFFFFFFFFFF
ram54288 0:a2cb7295a1f7 73 #endif
ram54288 0:a2cb7295a1f7 74 };
ram54288 0:a2cb7295a1f7 75
ram54288 0:a2cb7295a1f7 76 /*-----------------------------------------------
ram54288 0:a2cb7295a1f7 77 * Pretty Printers & Test Result Output Handlers
ram54288 0:a2cb7295a1f7 78 *-----------------------------------------------*/
ram54288 0:a2cb7295a1f7 79
ram54288 0:a2cb7295a1f7 80 void UnityPrint(const char* string)
ram54288 0:a2cb7295a1f7 81 {
ram54288 0:a2cb7295a1f7 82 const char* pch = string;
ram54288 0:a2cb7295a1f7 83
ram54288 0:a2cb7295a1f7 84 if (pch != NULL)
ram54288 0:a2cb7295a1f7 85 {
ram54288 0:a2cb7295a1f7 86 while (*pch)
ram54288 0:a2cb7295a1f7 87 {
ram54288 0:a2cb7295a1f7 88 /* printable characters plus CR & LF are printed */
ram54288 0:a2cb7295a1f7 89 if ((*pch <= 126) && (*pch >= 32))
ram54288 0:a2cb7295a1f7 90 {
ram54288 0:a2cb7295a1f7 91 UNITY_OUTPUT_CHAR(*pch);
ram54288 0:a2cb7295a1f7 92 }
ram54288 0:a2cb7295a1f7 93 /* write escaped carriage returns */
ram54288 0:a2cb7295a1f7 94 else if (*pch == 13)
ram54288 0:a2cb7295a1f7 95 {
ram54288 0:a2cb7295a1f7 96 UNITY_OUTPUT_CHAR('\\');
ram54288 0:a2cb7295a1f7 97 UNITY_OUTPUT_CHAR('r');
ram54288 0:a2cb7295a1f7 98 }
ram54288 0:a2cb7295a1f7 99 /* write escaped line feeds */
ram54288 0:a2cb7295a1f7 100 else if (*pch == 10)
ram54288 0:a2cb7295a1f7 101 {
ram54288 0:a2cb7295a1f7 102 UNITY_OUTPUT_CHAR('\\');
ram54288 0:a2cb7295a1f7 103 UNITY_OUTPUT_CHAR('n');
ram54288 0:a2cb7295a1f7 104 }
ram54288 0:a2cb7295a1f7 105 /* unprintable characters are shown as codes */
ram54288 0:a2cb7295a1f7 106 else
ram54288 0:a2cb7295a1f7 107 {
ram54288 0:a2cb7295a1f7 108 UNITY_OUTPUT_CHAR('\\');
ram54288 0:a2cb7295a1f7 109 UnityPrintNumberHex((_U_UINT)*pch, 2);
ram54288 0:a2cb7295a1f7 110 }
ram54288 0:a2cb7295a1f7 111 pch++;
ram54288 0:a2cb7295a1f7 112 }
ram54288 0:a2cb7295a1f7 113 }
ram54288 0:a2cb7295a1f7 114 }
ram54288 0:a2cb7295a1f7 115
ram54288 0:a2cb7295a1f7 116 void UnityPrintLen(const char* string, const _UU32 length);
ram54288 0:a2cb7295a1f7 117 void UnityPrintLen(const char* string, const _UU32 length)
ram54288 0:a2cb7295a1f7 118 {
ram54288 0:a2cb7295a1f7 119 const char* pch = string;
ram54288 0:a2cb7295a1f7 120
ram54288 0:a2cb7295a1f7 121 if (pch != NULL)
ram54288 0:a2cb7295a1f7 122 {
ram54288 0:a2cb7295a1f7 123 while (*pch && (_UU32)(pch - string) < length)
ram54288 0:a2cb7295a1f7 124 {
ram54288 0:a2cb7295a1f7 125 /* printable characters plus CR & LF are printed */
ram54288 0:a2cb7295a1f7 126 if ((*pch <= 126) && (*pch >= 32))
ram54288 0:a2cb7295a1f7 127 {
ram54288 0:a2cb7295a1f7 128 UNITY_OUTPUT_CHAR(*pch);
ram54288 0:a2cb7295a1f7 129 }
ram54288 0:a2cb7295a1f7 130 /* write escaped carriage returns */
ram54288 0:a2cb7295a1f7 131 else if (*pch == 13)
ram54288 0:a2cb7295a1f7 132 {
ram54288 0:a2cb7295a1f7 133 UNITY_OUTPUT_CHAR('\\');
ram54288 0:a2cb7295a1f7 134 UNITY_OUTPUT_CHAR('r');
ram54288 0:a2cb7295a1f7 135 }
ram54288 0:a2cb7295a1f7 136 /* write escaped line feeds */
ram54288 0:a2cb7295a1f7 137 else if (*pch == 10)
ram54288 0:a2cb7295a1f7 138 {
ram54288 0:a2cb7295a1f7 139 UNITY_OUTPUT_CHAR('\\');
ram54288 0:a2cb7295a1f7 140 UNITY_OUTPUT_CHAR('n');
ram54288 0:a2cb7295a1f7 141 }
ram54288 0:a2cb7295a1f7 142 /* unprintable characters are shown as codes */
ram54288 0:a2cb7295a1f7 143 else
ram54288 0:a2cb7295a1f7 144 {
ram54288 0:a2cb7295a1f7 145 UNITY_OUTPUT_CHAR('\\');
ram54288 0:a2cb7295a1f7 146 UnityPrintNumberHex((_U_UINT)*pch, 2);
ram54288 0:a2cb7295a1f7 147 }
ram54288 0:a2cb7295a1f7 148 pch++;
ram54288 0:a2cb7295a1f7 149 }
ram54288 0:a2cb7295a1f7 150 }
ram54288 0:a2cb7295a1f7 151 }
ram54288 0:a2cb7295a1f7 152
ram54288 0:a2cb7295a1f7 153 /*-----------------------------------------------*/
ram54288 0:a2cb7295a1f7 154 void UnityPrintNumberByStyle(const _U_SINT number, const UNITY_DISPLAY_STYLE_T style)
ram54288 0:a2cb7295a1f7 155 {
ram54288 0:a2cb7295a1f7 156 if ((style & UNITY_DISPLAY_RANGE_INT) == UNITY_DISPLAY_RANGE_INT)
ram54288 0:a2cb7295a1f7 157 {
ram54288 0:a2cb7295a1f7 158 UnityPrintNumber(number);
ram54288 0:a2cb7295a1f7 159 }
ram54288 0:a2cb7295a1f7 160 else if ((style & UNITY_DISPLAY_RANGE_UINT) == UNITY_DISPLAY_RANGE_UINT)
ram54288 0:a2cb7295a1f7 161 {
ram54288 0:a2cb7295a1f7 162 UnityPrintNumberUnsigned( (_U_UINT)number & UnitySizeMask[((_U_UINT)style & (_U_UINT)0x0F) - 1] );
ram54288 0:a2cb7295a1f7 163 }
ram54288 0:a2cb7295a1f7 164 else
ram54288 0:a2cb7295a1f7 165 {
ram54288 0:a2cb7295a1f7 166 UnityPrintNumberHex((_U_UINT)number, (char)((style & 0x000F) << 1));
ram54288 0:a2cb7295a1f7 167 }
ram54288 0:a2cb7295a1f7 168 }
ram54288 0:a2cb7295a1f7 169
ram54288 0:a2cb7295a1f7 170 /*-----------------------------------------------*/
ram54288 0:a2cb7295a1f7 171 void UnityPrintNumber(const _U_SINT number_to_print)
ram54288 0:a2cb7295a1f7 172 {
ram54288 0:a2cb7295a1f7 173 _U_UINT number = (_U_UINT)number_to_print;
ram54288 0:a2cb7295a1f7 174
ram54288 0:a2cb7295a1f7 175 if (number_to_print < 0)
ram54288 0:a2cb7295a1f7 176 {
ram54288 0:a2cb7295a1f7 177 /* A negative number, including MIN negative */
ram54288 0:a2cb7295a1f7 178 UNITY_OUTPUT_CHAR('-');
ram54288 0:a2cb7295a1f7 179 number = (_U_UINT)(-number_to_print);
ram54288 0:a2cb7295a1f7 180 }
ram54288 0:a2cb7295a1f7 181 UnityPrintNumberUnsigned(number);
ram54288 0:a2cb7295a1f7 182 }
ram54288 0:a2cb7295a1f7 183
ram54288 0:a2cb7295a1f7 184 /*-----------------------------------------------
ram54288 0:a2cb7295a1f7 185 * basically do an itoa using as little ram as possible */
ram54288 0:a2cb7295a1f7 186 void UnityPrintNumberUnsigned(const _U_UINT number)
ram54288 0:a2cb7295a1f7 187 {
ram54288 0:a2cb7295a1f7 188 _U_UINT divisor = 1;
ram54288 0:a2cb7295a1f7 189
ram54288 0:a2cb7295a1f7 190 /* figure out initial divisor */
ram54288 0:a2cb7295a1f7 191 while (number / divisor > 9)
ram54288 0:a2cb7295a1f7 192 {
ram54288 0:a2cb7295a1f7 193 divisor *= 10;
ram54288 0:a2cb7295a1f7 194 }
ram54288 0:a2cb7295a1f7 195
ram54288 0:a2cb7295a1f7 196 /* now mod and print, then divide divisor */
ram54288 0:a2cb7295a1f7 197 do
ram54288 0:a2cb7295a1f7 198 {
ram54288 0:a2cb7295a1f7 199 UNITY_OUTPUT_CHAR((char)('0' + (number / divisor % 10)));
ram54288 0:a2cb7295a1f7 200 divisor /= 10;
ram54288 0:a2cb7295a1f7 201 }
ram54288 0:a2cb7295a1f7 202 while (divisor > 0);
ram54288 0:a2cb7295a1f7 203 }
ram54288 0:a2cb7295a1f7 204
ram54288 0:a2cb7295a1f7 205 /*-----------------------------------------------*/
ram54288 0:a2cb7295a1f7 206 void UnityPrintNumberHex(const _U_UINT number, const char nibbles_to_print)
ram54288 0:a2cb7295a1f7 207 {
ram54288 0:a2cb7295a1f7 208 _U_UINT nibble;
ram54288 0:a2cb7295a1f7 209 char nibbles = nibbles_to_print;
ram54288 0:a2cb7295a1f7 210 UNITY_OUTPUT_CHAR('0');
ram54288 0:a2cb7295a1f7 211 UNITY_OUTPUT_CHAR('x');
ram54288 0:a2cb7295a1f7 212
ram54288 0:a2cb7295a1f7 213 while (nibbles > 0)
ram54288 0:a2cb7295a1f7 214 {
ram54288 0:a2cb7295a1f7 215 nibble = (number >> (--nibbles << 2)) & 0x0000000F;
ram54288 0:a2cb7295a1f7 216 if (nibble <= 9)
ram54288 0:a2cb7295a1f7 217 {
ram54288 0:a2cb7295a1f7 218 UNITY_OUTPUT_CHAR((char)('0' + nibble));
ram54288 0:a2cb7295a1f7 219 }
ram54288 0:a2cb7295a1f7 220 else
ram54288 0:a2cb7295a1f7 221 {
ram54288 0:a2cb7295a1f7 222 UNITY_OUTPUT_CHAR((char)('A' - 10 + nibble));
ram54288 0:a2cb7295a1f7 223 }
ram54288 0:a2cb7295a1f7 224 }
ram54288 0:a2cb7295a1f7 225 }
ram54288 0:a2cb7295a1f7 226
ram54288 0:a2cb7295a1f7 227 /*-----------------------------------------------*/
ram54288 0:a2cb7295a1f7 228 void UnityPrintMask(const _U_UINT mask, const _U_UINT number)
ram54288 0:a2cb7295a1f7 229 {
ram54288 0:a2cb7295a1f7 230 _U_UINT current_bit = (_U_UINT)1 << (UNITY_INT_WIDTH - 1);
ram54288 0:a2cb7295a1f7 231 _US32 i;
ram54288 0:a2cb7295a1f7 232
ram54288 0:a2cb7295a1f7 233 for (i = 0; i < UNITY_INT_WIDTH; i++)
ram54288 0:a2cb7295a1f7 234 {
ram54288 0:a2cb7295a1f7 235 if (current_bit & mask)
ram54288 0:a2cb7295a1f7 236 {
ram54288 0:a2cb7295a1f7 237 if (current_bit & number)
ram54288 0:a2cb7295a1f7 238 {
ram54288 0:a2cb7295a1f7 239 UNITY_OUTPUT_CHAR('1');
ram54288 0:a2cb7295a1f7 240 }
ram54288 0:a2cb7295a1f7 241 else
ram54288 0:a2cb7295a1f7 242 {
ram54288 0:a2cb7295a1f7 243 UNITY_OUTPUT_CHAR('0');
ram54288 0:a2cb7295a1f7 244 }
ram54288 0:a2cb7295a1f7 245 }
ram54288 0:a2cb7295a1f7 246 else
ram54288 0:a2cb7295a1f7 247 {
ram54288 0:a2cb7295a1f7 248 UNITY_OUTPUT_CHAR('X');
ram54288 0:a2cb7295a1f7 249 }
ram54288 0:a2cb7295a1f7 250 current_bit = current_bit >> 1;
ram54288 0:a2cb7295a1f7 251 }
ram54288 0:a2cb7295a1f7 252 }
ram54288 0:a2cb7295a1f7 253
ram54288 0:a2cb7295a1f7 254 /*-----------------------------------------------*/
ram54288 0:a2cb7295a1f7 255 #ifdef UNITY_FLOAT_VERBOSE
ram54288 0:a2cb7295a1f7 256 #include <stdio.h>
ram54288 0:a2cb7295a1f7 257
ram54288 0:a2cb7295a1f7 258 #ifndef UNITY_VERBOSE_NUMBER_MAX_LENGTH
ram54288 0:a2cb7295a1f7 259 # ifdef UNITY_DOUBLE_VERBOSE
ram54288 0:a2cb7295a1f7 260 # define UNITY_VERBOSE_NUMBER_MAX_LENGTH 317
ram54288 0:a2cb7295a1f7 261 # else
ram54288 0:a2cb7295a1f7 262 # define UNITY_VERBOSE_NUMBER_MAX_LENGTH 47
ram54288 0:a2cb7295a1f7 263 # endif
ram54288 0:a2cb7295a1f7 264 #endif
ram54288 0:a2cb7295a1f7 265
ram54288 0:a2cb7295a1f7 266 void UnityPrintFloat(_UF number)
ram54288 0:a2cb7295a1f7 267 {
ram54288 0:a2cb7295a1f7 268 char TempBuffer[UNITY_VERBOSE_NUMBER_MAX_LENGTH + 1];
ram54288 0:a2cb7295a1f7 269 snprintf(TempBuffer, sizeof(TempBuffer), "%.6f", number);
ram54288 0:a2cb7295a1f7 270 UnityPrint(TempBuffer);
ram54288 0:a2cb7295a1f7 271 }
ram54288 0:a2cb7295a1f7 272 #endif
ram54288 0:a2cb7295a1f7 273
ram54288 0:a2cb7295a1f7 274 /*-----------------------------------------------*/
ram54288 0:a2cb7295a1f7 275
ram54288 0:a2cb7295a1f7 276 void UnityPrintFail(void);
ram54288 0:a2cb7295a1f7 277 void UnityPrintFail(void)
ram54288 0:a2cb7295a1f7 278 {
ram54288 0:a2cb7295a1f7 279 UnityPrint(UnityStrFail);
ram54288 0:a2cb7295a1f7 280 }
ram54288 0:a2cb7295a1f7 281
ram54288 0:a2cb7295a1f7 282 void UnityPrintOk(void);
ram54288 0:a2cb7295a1f7 283 void UnityPrintOk(void)
ram54288 0:a2cb7295a1f7 284 {
ram54288 0:a2cb7295a1f7 285 UnityPrint(UnityStrOk);
ram54288 0:a2cb7295a1f7 286 }
ram54288 0:a2cb7295a1f7 287
ram54288 0:a2cb7295a1f7 288 /*-----------------------------------------------*/
ram54288 0:a2cb7295a1f7 289 static void UnityTestResultsBegin(const char* file, const UNITY_LINE_TYPE line);
ram54288 0:a2cb7295a1f7 290 static void UnityTestResultsBegin(const char* file, const UNITY_LINE_TYPE line)
ram54288 0:a2cb7295a1f7 291 {
ram54288 0:a2cb7295a1f7 292 #ifndef UNITY_FIXTURES
ram54288 0:a2cb7295a1f7 293 UnityPrint(file);
ram54288 0:a2cb7295a1f7 294 UNITY_OUTPUT_CHAR(':');
ram54288 0:a2cb7295a1f7 295 UnityPrintNumber((_U_SINT)line);
ram54288 0:a2cb7295a1f7 296 UNITY_OUTPUT_CHAR(':');
ram54288 0:a2cb7295a1f7 297 UnityPrint(Unity.CurrentTestName);
ram54288 0:a2cb7295a1f7 298 UNITY_OUTPUT_CHAR(':');
ram54288 0:a2cb7295a1f7 299 #else
ram54288 0:a2cb7295a1f7 300 UNITY_UNUSED(file);
ram54288 0:a2cb7295a1f7 301 UNITY_UNUSED(line);
ram54288 0:a2cb7295a1f7 302 #endif
ram54288 0:a2cb7295a1f7 303 }
ram54288 0:a2cb7295a1f7 304
ram54288 0:a2cb7295a1f7 305 /* SA_PATCH: Make failures more noticable. */
ram54288 0:a2cb7295a1f7 306 static void UnityPrintVisibleFailure(void);
ram54288 0:a2cb7295a1f7 307 static void UnityPrintVisibleFailure(void)
ram54288 0:a2cb7295a1f7 308 {
ram54288 0:a2cb7295a1f7 309 UNITY_OUTPUT_CHAR('\n');
ram54288 0:a2cb7295a1f7 310 UnityPrint("===!!!===> ");
ram54288 0:a2cb7295a1f7 311 /* SA_PATCH: Output results using easy to parse tags. */
ram54288 0:a2cb7295a1f7 312 UnityPrint(UNITY_RESULTS_TAGS_RESULT_START);
ram54288 0:a2cb7295a1f7 313 UnityPrint(UnityStrFail);
ram54288 0:a2cb7295a1f7 314 /* SA_PATCH: Output results using easy to parse tags. */
ram54288 0:a2cb7295a1f7 315 UnityPrint(UNITY_RESULTS_TAGS_RESULT_END);
ram54288 0:a2cb7295a1f7 316 UnityPrint(" <===!!!===");
ram54288 0:a2cb7295a1f7 317 }
ram54288 0:a2cb7295a1f7 318 /*-----------------------------------------------*/
ram54288 0:a2cb7295a1f7 319 static void UnityTestResultsFailBegin(const UNITY_LINE_TYPE line);
ram54288 0:a2cb7295a1f7 320 static void UnityTestResultsFailBegin(const UNITY_LINE_TYPE line)
ram54288 0:a2cb7295a1f7 321 {
ram54288 0:a2cb7295a1f7 322 #ifndef UNITY_FIXTURES
ram54288 0:a2cb7295a1f7 323 UnityTestResultsBegin(Unity.TestFile, line);
ram54288 0:a2cb7295a1f7 324 #else
ram54288 0:a2cb7295a1f7 325 UNITY_UNUSED(line);
ram54288 0:a2cb7295a1f7 326 #endif
ram54288 0:a2cb7295a1f7 327 /* SA_PATCH: Make failures more noticable. */
ram54288 0:a2cb7295a1f7 328 UnityPrintVisibleFailure();
ram54288 0:a2cb7295a1f7 329 //UnityPrint(UnityStrFail);
ram54288 0:a2cb7295a1f7 330 UNITY_OUTPUT_CHAR(':');
ram54288 0:a2cb7295a1f7 331 }
ram54288 0:a2cb7295a1f7 332
ram54288 0:a2cb7295a1f7 333 /*-----------------------------------------------*/
ram54288 0:a2cb7295a1f7 334 void UnityConcludeTest(void)
ram54288 0:a2cb7295a1f7 335 {
ram54288 0:a2cb7295a1f7 336 if (Unity.CurrentTestIgnored)
ram54288 0:a2cb7295a1f7 337 {
ram54288 0:a2cb7295a1f7 338 Unity.TestIgnores++;
ram54288 0:a2cb7295a1f7 339 }
ram54288 0:a2cb7295a1f7 340 else if (!Unity.CurrentTestFailed)
ram54288 0:a2cb7295a1f7 341 {
ram54288 0:a2cb7295a1f7 342 UnityTestResultsBegin(Unity.TestFile, Unity.CurrentTestLineNumber);
ram54288 0:a2cb7295a1f7 343 UnityPrint(UnityStrPass);
ram54288 0:a2cb7295a1f7 344 }
ram54288 0:a2cb7295a1f7 345 else
ram54288 0:a2cb7295a1f7 346 {
ram54288 0:a2cb7295a1f7 347 Unity.TestFailures++;
ram54288 0:a2cb7295a1f7 348 }
ram54288 0:a2cb7295a1f7 349
ram54288 0:a2cb7295a1f7 350 Unity.CurrentTestFailed = 0;
ram54288 0:a2cb7295a1f7 351 Unity.CurrentTestIgnored = 0;
ram54288 0:a2cb7295a1f7 352 UNITY_PRINT_EOL();
ram54288 0:a2cb7295a1f7 353 UNITY_FLUSH_CALL();
ram54288 0:a2cb7295a1f7 354 }
ram54288 0:a2cb7295a1f7 355
ram54288 0:a2cb7295a1f7 356 /*-----------------------------------------------*/
ram54288 0:a2cb7295a1f7 357 static void UnityAddMsgIfSpecified(const char* msg);
ram54288 0:a2cb7295a1f7 358 static void UnityAddMsgIfSpecified(const char* msg)
ram54288 0:a2cb7295a1f7 359 {
ram54288 0:a2cb7295a1f7 360 if (msg)
ram54288 0:a2cb7295a1f7 361 {
ram54288 0:a2cb7295a1f7 362 UnityPrint(UnityStrSpacer);
ram54288 0:a2cb7295a1f7 363 #ifndef UNITY_EXCLUDE_DETAILS
ram54288 0:a2cb7295a1f7 364 if (Unity.CurrentDetail1)
ram54288 0:a2cb7295a1f7 365 {
ram54288 0:a2cb7295a1f7 366 UnityPrint(UnityStrDetail1Name);
ram54288 0:a2cb7295a1f7 367 UnityPrint(Unity.CurrentDetail1);
ram54288 0:a2cb7295a1f7 368 if (Unity.CurrentDetail2)
ram54288 0:a2cb7295a1f7 369 {
ram54288 0:a2cb7295a1f7 370 UnityPrint(UnityStrDetail2Name);
ram54288 0:a2cb7295a1f7 371 UnityPrint(Unity.CurrentDetail2);
ram54288 0:a2cb7295a1f7 372 }
ram54288 0:a2cb7295a1f7 373 UnityPrint(UnityStrSpacer);
ram54288 0:a2cb7295a1f7 374 }
ram54288 0:a2cb7295a1f7 375 #endif
ram54288 0:a2cb7295a1f7 376 UnityPrint(msg);
ram54288 0:a2cb7295a1f7 377 }
ram54288 0:a2cb7295a1f7 378 }
ram54288 0:a2cb7295a1f7 379
ram54288 0:a2cb7295a1f7 380 /*-----------------------------------------------*/
ram54288 0:a2cb7295a1f7 381 static void UnityPrintExpectedAndActualStrings(const char* expected, const char* actual);
ram54288 0:a2cb7295a1f7 382 static void UnityPrintExpectedAndActualStrings(const char* expected, const char* actual)
ram54288 0:a2cb7295a1f7 383 {
ram54288 0:a2cb7295a1f7 384 UnityPrint(UnityStrExpected);
ram54288 0:a2cb7295a1f7 385 if (expected != NULL)
ram54288 0:a2cb7295a1f7 386 {
ram54288 0:a2cb7295a1f7 387 UNITY_OUTPUT_CHAR('\'');
ram54288 0:a2cb7295a1f7 388 UnityPrint(expected);
ram54288 0:a2cb7295a1f7 389 UNITY_OUTPUT_CHAR('\'');
ram54288 0:a2cb7295a1f7 390 }
ram54288 0:a2cb7295a1f7 391 else
ram54288 0:a2cb7295a1f7 392 {
ram54288 0:a2cb7295a1f7 393 UnityPrint(UnityStrNull);
ram54288 0:a2cb7295a1f7 394 }
ram54288 0:a2cb7295a1f7 395 UnityPrint(UnityStrWas);
ram54288 0:a2cb7295a1f7 396 if (actual != NULL)
ram54288 0:a2cb7295a1f7 397 {
ram54288 0:a2cb7295a1f7 398 UNITY_OUTPUT_CHAR('\'');
ram54288 0:a2cb7295a1f7 399 UnityPrint(actual);
ram54288 0:a2cb7295a1f7 400 UNITY_OUTPUT_CHAR('\'');
ram54288 0:a2cb7295a1f7 401 }
ram54288 0:a2cb7295a1f7 402 else
ram54288 0:a2cb7295a1f7 403 {
ram54288 0:a2cb7295a1f7 404 UnityPrint(UnityStrNull);
ram54288 0:a2cb7295a1f7 405 }
ram54288 0:a2cb7295a1f7 406 }
ram54288 0:a2cb7295a1f7 407
ram54288 0:a2cb7295a1f7 408 /*-----------------------------------------------*/
ram54288 0:a2cb7295a1f7 409 static void UnityPrintExpectedAndActualStringsLen(const char* expected, const char* actual, const _UU32 length)
ram54288 0:a2cb7295a1f7 410 {
ram54288 0:a2cb7295a1f7 411 UnityPrint(UnityStrExpected);
ram54288 0:a2cb7295a1f7 412 if (expected != NULL)
ram54288 0:a2cb7295a1f7 413 {
ram54288 0:a2cb7295a1f7 414 UNITY_OUTPUT_CHAR('\'');
ram54288 0:a2cb7295a1f7 415 UnityPrintLen(expected, length);
ram54288 0:a2cb7295a1f7 416 UNITY_OUTPUT_CHAR('\'');
ram54288 0:a2cb7295a1f7 417 }
ram54288 0:a2cb7295a1f7 418 else
ram54288 0:a2cb7295a1f7 419 {
ram54288 0:a2cb7295a1f7 420 UnityPrint(UnityStrNull);
ram54288 0:a2cb7295a1f7 421 }
ram54288 0:a2cb7295a1f7 422 UnityPrint(UnityStrWas);
ram54288 0:a2cb7295a1f7 423 if (actual != NULL)
ram54288 0:a2cb7295a1f7 424 {
ram54288 0:a2cb7295a1f7 425 UNITY_OUTPUT_CHAR('\'');
ram54288 0:a2cb7295a1f7 426 UnityPrintLen(actual, length);
ram54288 0:a2cb7295a1f7 427 UNITY_OUTPUT_CHAR('\'');
ram54288 0:a2cb7295a1f7 428 }
ram54288 0:a2cb7295a1f7 429 else
ram54288 0:a2cb7295a1f7 430 {
ram54288 0:a2cb7295a1f7 431 UnityPrint(UnityStrNull);
ram54288 0:a2cb7295a1f7 432 }
ram54288 0:a2cb7295a1f7 433 }
ram54288 0:a2cb7295a1f7 434
ram54288 0:a2cb7295a1f7 435
ram54288 0:a2cb7295a1f7 436
ram54288 0:a2cb7295a1f7 437 /*-----------------------------------------------
ram54288 0:a2cb7295a1f7 438 * Assertion & Control Helpers
ram54288 0:a2cb7295a1f7 439 *-----------------------------------------------*/
ram54288 0:a2cb7295a1f7 440
ram54288 0:a2cb7295a1f7 441 static int UnityCheckArraysForNull(UNITY_INTERNAL_PTR expected, UNITY_INTERNAL_PTR actual, const UNITY_LINE_TYPE lineNumber, const char* msg)
ram54288 0:a2cb7295a1f7 442 {
ram54288 0:a2cb7295a1f7 443 /* return true if they are both NULL */
ram54288 0:a2cb7295a1f7 444 if ((expected == NULL) && (actual == NULL))
ram54288 0:a2cb7295a1f7 445 return 1;
ram54288 0:a2cb7295a1f7 446
ram54288 0:a2cb7295a1f7 447 /* throw error if just expected is NULL */
ram54288 0:a2cb7295a1f7 448 if (expected == NULL)
ram54288 0:a2cb7295a1f7 449 {
ram54288 0:a2cb7295a1f7 450 UnityTestResultsFailBegin(lineNumber);
ram54288 0:a2cb7295a1f7 451 UnityPrint(UnityStrNullPointerForExpected);
ram54288 0:a2cb7295a1f7 452 UnityAddMsgIfSpecified(msg);
ram54288 0:a2cb7295a1f7 453 UNITY_FAIL_AND_BAIL;
ram54288 0:a2cb7295a1f7 454 }
ram54288 0:a2cb7295a1f7 455
ram54288 0:a2cb7295a1f7 456 /* throw error if just actual is NULL */
ram54288 0:a2cb7295a1f7 457 if (actual == NULL)
ram54288 0:a2cb7295a1f7 458 {
ram54288 0:a2cb7295a1f7 459 UnityTestResultsFailBegin(lineNumber);
ram54288 0:a2cb7295a1f7 460 UnityPrint(UnityStrNullPointerForActual);
ram54288 0:a2cb7295a1f7 461 UnityAddMsgIfSpecified(msg);
ram54288 0:a2cb7295a1f7 462 UNITY_FAIL_AND_BAIL;
ram54288 0:a2cb7295a1f7 463 }
ram54288 0:a2cb7295a1f7 464
ram54288 0:a2cb7295a1f7 465 /* return false if neither is NULL */
ram54288 0:a2cb7295a1f7 466 return 0;
ram54288 0:a2cb7295a1f7 467 }
ram54288 0:a2cb7295a1f7 468
ram54288 0:a2cb7295a1f7 469 /*-----------------------------------------------
ram54288 0:a2cb7295a1f7 470 * Assertion Functions
ram54288 0:a2cb7295a1f7 471 *-----------------------------------------------*/
ram54288 0:a2cb7295a1f7 472
ram54288 0:a2cb7295a1f7 473 void UnityAssertBits(const _U_SINT mask,
ram54288 0:a2cb7295a1f7 474 const _U_SINT expected,
ram54288 0:a2cb7295a1f7 475 const _U_SINT actual,
ram54288 0:a2cb7295a1f7 476 const char* msg,
ram54288 0:a2cb7295a1f7 477 const UNITY_LINE_TYPE lineNumber)
ram54288 0:a2cb7295a1f7 478 {
ram54288 0:a2cb7295a1f7 479 UNITY_SKIP_EXECUTION;
ram54288 0:a2cb7295a1f7 480
ram54288 0:a2cb7295a1f7 481 if ((mask & expected) != (mask & actual))
ram54288 0:a2cb7295a1f7 482 {
ram54288 0:a2cb7295a1f7 483 UnityTestResultsFailBegin(lineNumber);
ram54288 0:a2cb7295a1f7 484 UnityPrint(UnityStrExpected);
ram54288 0:a2cb7295a1f7 485 UnityPrintMask((_U_UINT)mask, (_U_UINT)expected);
ram54288 0:a2cb7295a1f7 486 UnityPrint(UnityStrWas);
ram54288 0:a2cb7295a1f7 487 UnityPrintMask((_U_UINT)mask, (_U_UINT)actual);
ram54288 0:a2cb7295a1f7 488 UnityAddMsgIfSpecified(msg);
ram54288 0:a2cb7295a1f7 489 UNITY_FAIL_AND_BAIL;
ram54288 0:a2cb7295a1f7 490 }
ram54288 0:a2cb7295a1f7 491 }
ram54288 0:a2cb7295a1f7 492
ram54288 0:a2cb7295a1f7 493 /*-----------------------------------------------*/
ram54288 0:a2cb7295a1f7 494 void UnityAssertEqualNumber(const _U_SINT expected,
ram54288 0:a2cb7295a1f7 495 const _U_SINT actual,
ram54288 0:a2cb7295a1f7 496 const char* msg,
ram54288 0:a2cb7295a1f7 497 const UNITY_LINE_TYPE lineNumber,
ram54288 0:a2cb7295a1f7 498 const UNITY_DISPLAY_STYLE_T style)
ram54288 0:a2cb7295a1f7 499 {
ram54288 0:a2cb7295a1f7 500 UNITY_SKIP_EXECUTION;
ram54288 0:a2cb7295a1f7 501
ram54288 0:a2cb7295a1f7 502 if (expected != actual)
ram54288 0:a2cb7295a1f7 503 {
ram54288 0:a2cb7295a1f7 504 UnityTestResultsFailBegin(lineNumber);
ram54288 0:a2cb7295a1f7 505 UnityPrint(UnityStrExpected);
ram54288 0:a2cb7295a1f7 506 UnityPrintNumberByStyle(expected, style);
ram54288 0:a2cb7295a1f7 507 UnityPrint(UnityStrWas);
ram54288 0:a2cb7295a1f7 508 UnityPrintNumberByStyle(actual, style);
ram54288 0:a2cb7295a1f7 509 UnityAddMsgIfSpecified(msg);
ram54288 0:a2cb7295a1f7 510 UNITY_FAIL_AND_BAIL;
ram54288 0:a2cb7295a1f7 511 }
ram54288 0:a2cb7295a1f7 512 }
ram54288 0:a2cb7295a1f7 513
ram54288 0:a2cb7295a1f7 514 #define UnityPrintPointlessAndBail() \
ram54288 0:a2cb7295a1f7 515 { \
ram54288 0:a2cb7295a1f7 516 UnityTestResultsFailBegin(lineNumber); \
ram54288 0:a2cb7295a1f7 517 UnityPrint(UnityStrPointless); \
ram54288 0:a2cb7295a1f7 518 UnityAddMsgIfSpecified(msg); \
ram54288 0:a2cb7295a1f7 519 UNITY_FAIL_AND_BAIL; }
ram54288 0:a2cb7295a1f7 520
ram54288 0:a2cb7295a1f7 521 /*-----------------------------------------------*/
ram54288 0:a2cb7295a1f7 522 void UnityAssertEqualIntArray(UNITY_INTERNAL_PTR expected,
ram54288 0:a2cb7295a1f7 523 UNITY_INTERNAL_PTR actual,
ram54288 0:a2cb7295a1f7 524 const _UU32 num_elements,
ram54288 0:a2cb7295a1f7 525 const char* msg,
ram54288 0:a2cb7295a1f7 526 const UNITY_LINE_TYPE lineNumber,
ram54288 0:a2cb7295a1f7 527 const UNITY_DISPLAY_STYLE_T style)
ram54288 0:a2cb7295a1f7 528 {
ram54288 0:a2cb7295a1f7 529 _UU32 elements = num_elements;
ram54288 0:a2cb7295a1f7 530 UNITY_INTERNAL_PTR ptr_exp = (UNITY_INTERNAL_PTR)expected;
ram54288 0:a2cb7295a1f7 531 UNITY_INTERNAL_PTR ptr_act = (UNITY_INTERNAL_PTR)actual;
ram54288 0:a2cb7295a1f7 532
ram54288 0:a2cb7295a1f7 533 UNITY_SKIP_EXECUTION;
ram54288 0:a2cb7295a1f7 534
ram54288 0:a2cb7295a1f7 535 if (elements == 0)
ram54288 0:a2cb7295a1f7 536 {
ram54288 0:a2cb7295a1f7 537 UnityPrintPointlessAndBail();
ram54288 0:a2cb7295a1f7 538 }
ram54288 0:a2cb7295a1f7 539
ram54288 0:a2cb7295a1f7 540 if (UnityCheckArraysForNull((UNITY_INTERNAL_PTR)expected, (UNITY_INTERNAL_PTR)actual, lineNumber, msg) == 1)
ram54288 0:a2cb7295a1f7 541 return;
ram54288 0:a2cb7295a1f7 542
ram54288 0:a2cb7295a1f7 543 /* If style is UNITY_DISPLAY_STYLE_INT, we'll fall into the default case rather than the INT16 or INT32 (etc) case
ram54288 0:a2cb7295a1f7 544 * as UNITY_DISPLAY_STYLE_INT includes a flag for UNITY_DISPLAY_RANGE_AUTO, which the width-specific
ram54288 0:a2cb7295a1f7 545 * variants do not. Therefore remove this flag. */
ram54288 0:a2cb7295a1f7 546 switch(style & (UNITY_DISPLAY_STYLE_T)(~UNITY_DISPLAY_RANGE_AUTO))
ram54288 0:a2cb7295a1f7 547 {
ram54288 0:a2cb7295a1f7 548 case UNITY_DISPLAY_STYLE_HEX8:
ram54288 0:a2cb7295a1f7 549 case UNITY_DISPLAY_STYLE_INT8:
ram54288 0:a2cb7295a1f7 550 case UNITY_DISPLAY_STYLE_UINT8:
ram54288 0:a2cb7295a1f7 551 while (elements--)
ram54288 0:a2cb7295a1f7 552 {
ram54288 0:a2cb7295a1f7 553 if (*(UNITY_PTR_ATTRIBUTE const _US8*)ptr_exp != *(UNITY_PTR_ATTRIBUTE const _US8*)ptr_act)
ram54288 0:a2cb7295a1f7 554 {
ram54288 0:a2cb7295a1f7 555 UnityTestResultsFailBegin(lineNumber);
ram54288 0:a2cb7295a1f7 556 UnityPrint(UnityStrElement);
ram54288 0:a2cb7295a1f7 557 UnityPrintNumberUnsigned(num_elements - elements - 1);
ram54288 0:a2cb7295a1f7 558 UnityPrint(UnityStrExpected);
ram54288 0:a2cb7295a1f7 559 UnityPrintNumberByStyle(*(UNITY_PTR_ATTRIBUTE const _US8*)ptr_exp, style);
ram54288 0:a2cb7295a1f7 560 UnityPrint(UnityStrWas);
ram54288 0:a2cb7295a1f7 561 UnityPrintNumberByStyle(*(UNITY_PTR_ATTRIBUTE const _US8*)ptr_act, style);
ram54288 0:a2cb7295a1f7 562 UnityAddMsgIfSpecified(msg);
ram54288 0:a2cb7295a1f7 563 UNITY_FAIL_AND_BAIL;
ram54288 0:a2cb7295a1f7 564 }
ram54288 0:a2cb7295a1f7 565 ptr_exp = (UNITY_INTERNAL_PTR)((_UP)ptr_exp + 1);
ram54288 0:a2cb7295a1f7 566 ptr_act = (UNITY_INTERNAL_PTR)((_UP)ptr_act + 1);
ram54288 0:a2cb7295a1f7 567 }
ram54288 0:a2cb7295a1f7 568 break;
ram54288 0:a2cb7295a1f7 569 case UNITY_DISPLAY_STYLE_HEX16:
ram54288 0:a2cb7295a1f7 570 case UNITY_DISPLAY_STYLE_INT16:
ram54288 0:a2cb7295a1f7 571 case UNITY_DISPLAY_STYLE_UINT16:
ram54288 0:a2cb7295a1f7 572 while (elements--)
ram54288 0:a2cb7295a1f7 573 {
ram54288 0:a2cb7295a1f7 574 if (*(UNITY_PTR_ATTRIBUTE const _US16*)ptr_exp != *(UNITY_PTR_ATTRIBUTE const _US16*)ptr_act)
ram54288 0:a2cb7295a1f7 575 {
ram54288 0:a2cb7295a1f7 576 UnityTestResultsFailBegin(lineNumber);
ram54288 0:a2cb7295a1f7 577 UnityPrint(UnityStrElement);
ram54288 0:a2cb7295a1f7 578 UnityPrintNumberUnsigned(num_elements - elements - 1);
ram54288 0:a2cb7295a1f7 579 UnityPrint(UnityStrExpected);
ram54288 0:a2cb7295a1f7 580 UnityPrintNumberByStyle(*(UNITY_PTR_ATTRIBUTE const _US16*)ptr_exp, style);
ram54288 0:a2cb7295a1f7 581 UnityPrint(UnityStrWas);
ram54288 0:a2cb7295a1f7 582 UnityPrintNumberByStyle(*(UNITY_PTR_ATTRIBUTE const _US16*)ptr_act, style);
ram54288 0:a2cb7295a1f7 583 UnityAddMsgIfSpecified(msg);
ram54288 0:a2cb7295a1f7 584 UNITY_FAIL_AND_BAIL;
ram54288 0:a2cb7295a1f7 585 }
ram54288 0:a2cb7295a1f7 586 ptr_exp = (UNITY_INTERNAL_PTR)((_UP)ptr_exp + 2);
ram54288 0:a2cb7295a1f7 587 ptr_act = (UNITY_INTERNAL_PTR)((_UP)ptr_act + 2);
ram54288 0:a2cb7295a1f7 588 }
ram54288 0:a2cb7295a1f7 589 break;
ram54288 0:a2cb7295a1f7 590 #ifdef UNITY_SUPPORT_64
ram54288 0:a2cb7295a1f7 591 case UNITY_DISPLAY_STYLE_HEX64:
ram54288 0:a2cb7295a1f7 592 case UNITY_DISPLAY_STYLE_INT64:
ram54288 0:a2cb7295a1f7 593 case UNITY_DISPLAY_STYLE_UINT64:
ram54288 0:a2cb7295a1f7 594 while (elements--)
ram54288 0:a2cb7295a1f7 595 {
ram54288 0:a2cb7295a1f7 596 if (*(UNITY_PTR_ATTRIBUTE const _US64*)ptr_exp != *(UNITY_PTR_ATTRIBUTE const _US64*)ptr_act)
ram54288 0:a2cb7295a1f7 597 {
ram54288 0:a2cb7295a1f7 598 UnityTestResultsFailBegin(lineNumber);
ram54288 0:a2cb7295a1f7 599 UnityPrint(UnityStrElement);
ram54288 0:a2cb7295a1f7 600 UnityPrintNumberUnsigned(num_elements - elements - 1);
ram54288 0:a2cb7295a1f7 601 UnityPrint(UnityStrExpected);
ram54288 0:a2cb7295a1f7 602 UnityPrintNumberByStyle(*(UNITY_PTR_ATTRIBUTE const _US64*)ptr_exp, style);
ram54288 0:a2cb7295a1f7 603 UnityPrint(UnityStrWas);
ram54288 0:a2cb7295a1f7 604 UnityPrintNumberByStyle(*(UNITY_PTR_ATTRIBUTE const _US64*)ptr_act, style);
ram54288 0:a2cb7295a1f7 605 UnityAddMsgIfSpecified(msg);
ram54288 0:a2cb7295a1f7 606 UNITY_FAIL_AND_BAIL;
ram54288 0:a2cb7295a1f7 607 }
ram54288 0:a2cb7295a1f7 608 ptr_exp = (UNITY_INTERNAL_PTR)((_UP)ptr_exp + 8);
ram54288 0:a2cb7295a1f7 609 ptr_act = (UNITY_INTERNAL_PTR)((_UP)ptr_act + 8);
ram54288 0:a2cb7295a1f7 610 }
ram54288 0:a2cb7295a1f7 611 break;
ram54288 0:a2cb7295a1f7 612 #endif
ram54288 0:a2cb7295a1f7 613 default:
ram54288 0:a2cb7295a1f7 614 while (elements--)
ram54288 0:a2cb7295a1f7 615 {
ram54288 0:a2cb7295a1f7 616 if (*(UNITY_PTR_ATTRIBUTE const _US32*)ptr_exp != *(UNITY_PTR_ATTRIBUTE const _US32*)ptr_act)
ram54288 0:a2cb7295a1f7 617 {
ram54288 0:a2cb7295a1f7 618 UnityTestResultsFailBegin(lineNumber);
ram54288 0:a2cb7295a1f7 619 UnityPrint(UnityStrElement);
ram54288 0:a2cb7295a1f7 620 UnityPrintNumberUnsigned(num_elements - elements - 1);
ram54288 0:a2cb7295a1f7 621 UnityPrint(UnityStrExpected);
ram54288 0:a2cb7295a1f7 622 UnityPrintNumberByStyle(*(UNITY_PTR_ATTRIBUTE const _US32*)ptr_exp, style);
ram54288 0:a2cb7295a1f7 623 UnityPrint(UnityStrWas);
ram54288 0:a2cb7295a1f7 624 UnityPrintNumberByStyle(*(UNITY_PTR_ATTRIBUTE const _US32*)ptr_act, style);
ram54288 0:a2cb7295a1f7 625 UnityAddMsgIfSpecified(msg);
ram54288 0:a2cb7295a1f7 626 UNITY_FAIL_AND_BAIL;
ram54288 0:a2cb7295a1f7 627 }
ram54288 0:a2cb7295a1f7 628 ptr_exp = (UNITY_INTERNAL_PTR)((_UP)ptr_exp + 4);
ram54288 0:a2cb7295a1f7 629 ptr_act = (UNITY_INTERNAL_PTR)((_UP)ptr_act + 4);
ram54288 0:a2cb7295a1f7 630 }
ram54288 0:a2cb7295a1f7 631 break;
ram54288 0:a2cb7295a1f7 632 }
ram54288 0:a2cb7295a1f7 633 }
ram54288 0:a2cb7295a1f7 634
ram54288 0:a2cb7295a1f7 635 /*-----------------------------------------------*/
ram54288 0:a2cb7295a1f7 636 #ifndef UNITY_EXCLUDE_FLOAT
ram54288 0:a2cb7295a1f7 637 void UnityAssertEqualFloatArray(UNITY_PTR_ATTRIBUTE const _UF* expected,
ram54288 0:a2cb7295a1f7 638 UNITY_PTR_ATTRIBUTE const _UF* actual,
ram54288 0:a2cb7295a1f7 639 const _UU32 num_elements,
ram54288 0:a2cb7295a1f7 640 const char* msg,
ram54288 0:a2cb7295a1f7 641 const UNITY_LINE_TYPE lineNumber)
ram54288 0:a2cb7295a1f7 642 {
ram54288 0:a2cb7295a1f7 643 _UU32 elements = num_elements;
ram54288 0:a2cb7295a1f7 644 UNITY_PTR_ATTRIBUTE const _UF* ptr_expected = expected;
ram54288 0:a2cb7295a1f7 645 UNITY_PTR_ATTRIBUTE const _UF* ptr_actual = actual;
ram54288 0:a2cb7295a1f7 646 _UF diff, tol;
ram54288 0:a2cb7295a1f7 647
ram54288 0:a2cb7295a1f7 648 UNITY_SKIP_EXECUTION;
ram54288 0:a2cb7295a1f7 649
ram54288 0:a2cb7295a1f7 650 if (elements == 0)
ram54288 0:a2cb7295a1f7 651 {
ram54288 0:a2cb7295a1f7 652 UnityPrintPointlessAndBail();
ram54288 0:a2cb7295a1f7 653 }
ram54288 0:a2cb7295a1f7 654
ram54288 0:a2cb7295a1f7 655 if (UnityCheckArraysForNull((UNITY_INTERNAL_PTR)expected, (UNITY_INTERNAL_PTR)actual, lineNumber, msg) == 1)
ram54288 0:a2cb7295a1f7 656 return;
ram54288 0:a2cb7295a1f7 657
ram54288 0:a2cb7295a1f7 658 while (elements--)
ram54288 0:a2cb7295a1f7 659 {
ram54288 0:a2cb7295a1f7 660 diff = *ptr_expected - *ptr_actual;
ram54288 0:a2cb7295a1f7 661 if (diff < 0.0f)
ram54288 0:a2cb7295a1f7 662 diff = 0.0f - diff;
ram54288 0:a2cb7295a1f7 663 tol = UNITY_FLOAT_PRECISION * *ptr_expected;
ram54288 0:a2cb7295a1f7 664 if (tol < 0.0f)
ram54288 0:a2cb7295a1f7 665 tol = 0.0f - tol;
ram54288 0:a2cb7295a1f7 666
ram54288 0:a2cb7295a1f7 667 /* This first part of this condition will catch any NaN or Infinite values */
ram54288 0:a2cb7295a1f7 668 if (isnan(diff) || isinf(diff) || (diff > tol))
ram54288 0:a2cb7295a1f7 669 {
ram54288 0:a2cb7295a1f7 670 UnityTestResultsFailBegin(lineNumber);
ram54288 0:a2cb7295a1f7 671 UnityPrint(UnityStrElement);
ram54288 0:a2cb7295a1f7 672 UnityPrintNumberUnsigned(num_elements - elements - 1);
ram54288 0:a2cb7295a1f7 673 #ifdef UNITY_FLOAT_VERBOSE
ram54288 0:a2cb7295a1f7 674 UnityPrint(UnityStrExpected);
ram54288 0:a2cb7295a1f7 675 UnityPrintFloat(*ptr_expected);
ram54288 0:a2cb7295a1f7 676 UnityPrint(UnityStrWas);
ram54288 0:a2cb7295a1f7 677 UnityPrintFloat(*ptr_actual);
ram54288 0:a2cb7295a1f7 678 #else
ram54288 0:a2cb7295a1f7 679 UnityPrint(UnityStrDelta);
ram54288 0:a2cb7295a1f7 680 #endif
ram54288 0:a2cb7295a1f7 681 UnityAddMsgIfSpecified(msg);
ram54288 0:a2cb7295a1f7 682 UNITY_FAIL_AND_BAIL;
ram54288 0:a2cb7295a1f7 683 }
ram54288 0:a2cb7295a1f7 684 ptr_expected++;
ram54288 0:a2cb7295a1f7 685 ptr_actual++;
ram54288 0:a2cb7295a1f7 686 }
ram54288 0:a2cb7295a1f7 687 }
ram54288 0:a2cb7295a1f7 688
ram54288 0:a2cb7295a1f7 689 /*-----------------------------------------------*/
ram54288 0:a2cb7295a1f7 690 void UnityAssertFloatsWithin(const _UF delta,
ram54288 0:a2cb7295a1f7 691 const _UF expected,
ram54288 0:a2cb7295a1f7 692 const _UF actual,
ram54288 0:a2cb7295a1f7 693 const char* msg,
ram54288 0:a2cb7295a1f7 694 const UNITY_LINE_TYPE lineNumber)
ram54288 0:a2cb7295a1f7 695 {
ram54288 0:a2cb7295a1f7 696 _UF diff = actual - expected;
ram54288 0:a2cb7295a1f7 697 _UF pos_delta = delta;
ram54288 0:a2cb7295a1f7 698
ram54288 0:a2cb7295a1f7 699 UNITY_SKIP_EXECUTION;
ram54288 0:a2cb7295a1f7 700
ram54288 0:a2cb7295a1f7 701 if (diff < 0.0f)
ram54288 0:a2cb7295a1f7 702 {
ram54288 0:a2cb7295a1f7 703 diff = 0.0f - diff;
ram54288 0:a2cb7295a1f7 704 }
ram54288 0:a2cb7295a1f7 705 if (pos_delta < 0.0f)
ram54288 0:a2cb7295a1f7 706 {
ram54288 0:a2cb7295a1f7 707 pos_delta = 0.0f - pos_delta;
ram54288 0:a2cb7295a1f7 708 }
ram54288 0:a2cb7295a1f7 709
ram54288 0:a2cb7295a1f7 710 /* This first part of this condition will catch any NaN or Infinite values */
ram54288 0:a2cb7295a1f7 711 if (isnan(diff) || isinf(diff) || (pos_delta < diff))
ram54288 0:a2cb7295a1f7 712 {
ram54288 0:a2cb7295a1f7 713 UnityTestResultsFailBegin(lineNumber);
ram54288 0:a2cb7295a1f7 714 #ifdef UNITY_FLOAT_VERBOSE
ram54288 0:a2cb7295a1f7 715 UnityPrint(UnityStrExpected);
ram54288 0:a2cb7295a1f7 716 UnityPrintFloat(expected);
ram54288 0:a2cb7295a1f7 717 UnityPrint(UnityStrWas);
ram54288 0:a2cb7295a1f7 718 UnityPrintFloat(actual);
ram54288 0:a2cb7295a1f7 719 #else
ram54288 0:a2cb7295a1f7 720 UnityPrint(UnityStrDelta);
ram54288 0:a2cb7295a1f7 721 #endif
ram54288 0:a2cb7295a1f7 722 UnityAddMsgIfSpecified(msg);
ram54288 0:a2cb7295a1f7 723 UNITY_FAIL_AND_BAIL;
ram54288 0:a2cb7295a1f7 724 }
ram54288 0:a2cb7295a1f7 725 }
ram54288 0:a2cb7295a1f7 726
ram54288 0:a2cb7295a1f7 727 /*-----------------------------------------------*/
ram54288 0:a2cb7295a1f7 728 void UnityAssertFloatSpecial(const _UF actual,
ram54288 0:a2cb7295a1f7 729 const char* msg,
ram54288 0:a2cb7295a1f7 730 const UNITY_LINE_TYPE lineNumber,
ram54288 0:a2cb7295a1f7 731 const UNITY_FLOAT_TRAIT_T style)
ram54288 0:a2cb7295a1f7 732 {
ram54288 0:a2cb7295a1f7 733 const char* trait_names[] = { UnityStrInf, UnityStrNegInf, UnityStrNaN, UnityStrDet };
ram54288 0:a2cb7295a1f7 734 _U_SINT should_be_trait = ((_U_SINT)style & 1);
ram54288 0:a2cb7295a1f7 735 _U_SINT is_trait = !should_be_trait;
ram54288 0:a2cb7295a1f7 736 _U_SINT trait_index = (_U_SINT)(style >> 1);
ram54288 0:a2cb7295a1f7 737
ram54288 0:a2cb7295a1f7 738 UNITY_SKIP_EXECUTION;
ram54288 0:a2cb7295a1f7 739
ram54288 0:a2cb7295a1f7 740 switch(style)
ram54288 0:a2cb7295a1f7 741 {
ram54288 0:a2cb7295a1f7 742 /* To determine Inf / Neg Inf, we compare to an Inf / Neg Inf value we create on the fly
ram54288 0:a2cb7295a1f7 743 * We are using a variable to hold the zero value because some compilers complain about dividing by zero otherwise */
ram54288 0:a2cb7295a1f7 744 case UNITY_FLOAT_IS_INF:
ram54288 0:a2cb7295a1f7 745 case UNITY_FLOAT_IS_NOT_INF:
ram54288 0:a2cb7295a1f7 746 is_trait = isinf(actual) & ispos(actual);
ram54288 0:a2cb7295a1f7 747 break;
ram54288 0:a2cb7295a1f7 748 case UNITY_FLOAT_IS_NEG_INF:
ram54288 0:a2cb7295a1f7 749 case UNITY_FLOAT_IS_NOT_NEG_INF:
ram54288 0:a2cb7295a1f7 750 is_trait = isinf(actual) & isneg(actual);
ram54288 0:a2cb7295a1f7 751 break;
ram54288 0:a2cb7295a1f7 752
ram54288 0:a2cb7295a1f7 753 /* NaN is the only floating point value that does NOT equal itself. Therefore if Actual == Actual, then it is NOT NaN. */
ram54288 0:a2cb7295a1f7 754 case UNITY_FLOAT_IS_NAN:
ram54288 0:a2cb7295a1f7 755 case UNITY_FLOAT_IS_NOT_NAN:
ram54288 0:a2cb7295a1f7 756 is_trait = isnan(actual);
ram54288 0:a2cb7295a1f7 757 break;
ram54288 0:a2cb7295a1f7 758
ram54288 0:a2cb7295a1f7 759 /* A determinate number is non infinite and not NaN. (therefore the opposite of the two above) */
ram54288 0:a2cb7295a1f7 760 case UNITY_FLOAT_IS_DET:
ram54288 0:a2cb7295a1f7 761 case UNITY_FLOAT_IS_NOT_DET:
ram54288 0:a2cb7295a1f7 762 if (isinf(actual) | isnan(actual))
ram54288 0:a2cb7295a1f7 763 is_trait = 0;
ram54288 0:a2cb7295a1f7 764 else
ram54288 0:a2cb7295a1f7 765 is_trait = 1;
ram54288 0:a2cb7295a1f7 766 break;
ram54288 0:a2cb7295a1f7 767
ram54288 0:a2cb7295a1f7 768 default:
ram54288 0:a2cb7295a1f7 769 trait_index = 0;
ram54288 0:a2cb7295a1f7 770 trait_names[0] = UnityStrInvalidFloatTrait;
ram54288 0:a2cb7295a1f7 771 break;
ram54288 0:a2cb7295a1f7 772 }
ram54288 0:a2cb7295a1f7 773
ram54288 0:a2cb7295a1f7 774 if (is_trait != should_be_trait)
ram54288 0:a2cb7295a1f7 775 {
ram54288 0:a2cb7295a1f7 776 UnityTestResultsFailBegin(lineNumber);
ram54288 0:a2cb7295a1f7 777 UnityPrint(UnityStrExpected);
ram54288 0:a2cb7295a1f7 778 if (!should_be_trait)
ram54288 0:a2cb7295a1f7 779 UnityPrint(UnityStrNot);
ram54288 0:a2cb7295a1f7 780 UnityPrint(trait_names[trait_index]);
ram54288 0:a2cb7295a1f7 781 UnityPrint(UnityStrWas);
ram54288 0:a2cb7295a1f7 782 #ifdef UNITY_FLOAT_VERBOSE
ram54288 0:a2cb7295a1f7 783 UnityPrintFloat(actual);
ram54288 0:a2cb7295a1f7 784 #else
ram54288 0:a2cb7295a1f7 785 if (should_be_trait)
ram54288 0:a2cb7295a1f7 786 UnityPrint(UnityStrNot);
ram54288 0:a2cb7295a1f7 787 UnityPrint(trait_names[trait_index]);
ram54288 0:a2cb7295a1f7 788 #endif
ram54288 0:a2cb7295a1f7 789 UnityAddMsgIfSpecified(msg);
ram54288 0:a2cb7295a1f7 790 UNITY_FAIL_AND_BAIL;
ram54288 0:a2cb7295a1f7 791 }
ram54288 0:a2cb7295a1f7 792 }
ram54288 0:a2cb7295a1f7 793
ram54288 0:a2cb7295a1f7 794 #endif /* not UNITY_EXCLUDE_FLOAT */
ram54288 0:a2cb7295a1f7 795
ram54288 0:a2cb7295a1f7 796 /*-----------------------------------------------*/
ram54288 0:a2cb7295a1f7 797 #ifndef UNITY_EXCLUDE_DOUBLE
ram54288 0:a2cb7295a1f7 798 void UnityAssertEqualDoubleArray(UNITY_PTR_ATTRIBUTE const _UD* expected,
ram54288 0:a2cb7295a1f7 799 UNITY_PTR_ATTRIBUTE const _UD* actual,
ram54288 0:a2cb7295a1f7 800 const _UU32 num_elements,
ram54288 0:a2cb7295a1f7 801 const char* msg,
ram54288 0:a2cb7295a1f7 802 const UNITY_LINE_TYPE lineNumber)
ram54288 0:a2cb7295a1f7 803 {
ram54288 0:a2cb7295a1f7 804 _UU32 elements = num_elements;
ram54288 0:a2cb7295a1f7 805 UNITY_PTR_ATTRIBUTE const _UD* ptr_expected = expected;
ram54288 0:a2cb7295a1f7 806 UNITY_PTR_ATTRIBUTE const _UD* ptr_actual = actual;
ram54288 0:a2cb7295a1f7 807 _UD diff, tol;
ram54288 0:a2cb7295a1f7 808
ram54288 0:a2cb7295a1f7 809 UNITY_SKIP_EXECUTION;
ram54288 0:a2cb7295a1f7 810
ram54288 0:a2cb7295a1f7 811 if (elements == 0)
ram54288 0:a2cb7295a1f7 812 {
ram54288 0:a2cb7295a1f7 813 UnityPrintPointlessAndBail();
ram54288 0:a2cb7295a1f7 814 }
ram54288 0:a2cb7295a1f7 815
ram54288 0:a2cb7295a1f7 816 if (UnityCheckArraysForNull((UNITY_INTERNAL_PTR)expected, (UNITY_INTERNAL_PTR)actual, lineNumber, msg) == 1)
ram54288 0:a2cb7295a1f7 817 return;
ram54288 0:a2cb7295a1f7 818
ram54288 0:a2cb7295a1f7 819 while (elements--)
ram54288 0:a2cb7295a1f7 820 {
ram54288 0:a2cb7295a1f7 821 diff = *ptr_expected - *ptr_actual;
ram54288 0:a2cb7295a1f7 822 if (diff < 0.0)
ram54288 0:a2cb7295a1f7 823 diff = 0.0 - diff;
ram54288 0:a2cb7295a1f7 824 tol = UNITY_DOUBLE_PRECISION * *ptr_expected;
ram54288 0:a2cb7295a1f7 825 if (tol < 0.0)
ram54288 0:a2cb7295a1f7 826 tol = 0.0 - tol;
ram54288 0:a2cb7295a1f7 827
ram54288 0:a2cb7295a1f7 828 /* This first part of this condition will catch any NaN or Infinite values */
ram54288 0:a2cb7295a1f7 829 if (isnan(diff) || isinf(diff) || (diff > tol))
ram54288 0:a2cb7295a1f7 830 {
ram54288 0:a2cb7295a1f7 831 UnityTestResultsFailBegin(lineNumber);
ram54288 0:a2cb7295a1f7 832 UnityPrint(UnityStrElement);
ram54288 0:a2cb7295a1f7 833 UnityPrintNumberUnsigned(num_elements - elements - 1);
ram54288 0:a2cb7295a1f7 834 #ifdef UNITY_DOUBLE_VERBOSE
ram54288 0:a2cb7295a1f7 835 UnityPrint(UnityStrExpected);
ram54288 0:a2cb7295a1f7 836 UnityPrintFloat((float)(*ptr_expected));
ram54288 0:a2cb7295a1f7 837 UnityPrint(UnityStrWas);
ram54288 0:a2cb7295a1f7 838 UnityPrintFloat((float)(*ptr_actual));
ram54288 0:a2cb7295a1f7 839 #else
ram54288 0:a2cb7295a1f7 840 UnityPrint(UnityStrDelta);
ram54288 0:a2cb7295a1f7 841 #endif
ram54288 0:a2cb7295a1f7 842 UnityAddMsgIfSpecified(msg);
ram54288 0:a2cb7295a1f7 843 UNITY_FAIL_AND_BAIL;
ram54288 0:a2cb7295a1f7 844 }
ram54288 0:a2cb7295a1f7 845 ptr_expected++;
ram54288 0:a2cb7295a1f7 846 ptr_actual++;
ram54288 0:a2cb7295a1f7 847 }
ram54288 0:a2cb7295a1f7 848 }
ram54288 0:a2cb7295a1f7 849
ram54288 0:a2cb7295a1f7 850 /*-----------------------------------------------*/
ram54288 0:a2cb7295a1f7 851 void UnityAssertDoublesWithin(const _UD delta,
ram54288 0:a2cb7295a1f7 852 const _UD expected,
ram54288 0:a2cb7295a1f7 853 const _UD actual,
ram54288 0:a2cb7295a1f7 854 const char* msg,
ram54288 0:a2cb7295a1f7 855 const UNITY_LINE_TYPE lineNumber)
ram54288 0:a2cb7295a1f7 856 {
ram54288 0:a2cb7295a1f7 857 _UD diff = actual - expected;
ram54288 0:a2cb7295a1f7 858 _UD pos_delta = delta;
ram54288 0:a2cb7295a1f7 859
ram54288 0:a2cb7295a1f7 860 UNITY_SKIP_EXECUTION;
ram54288 0:a2cb7295a1f7 861
ram54288 0:a2cb7295a1f7 862 if (diff < 0.0)
ram54288 0:a2cb7295a1f7 863 {
ram54288 0:a2cb7295a1f7 864 diff = 0.0 - diff;
ram54288 0:a2cb7295a1f7 865 }
ram54288 0:a2cb7295a1f7 866 if (pos_delta < 0.0)
ram54288 0:a2cb7295a1f7 867 {
ram54288 0:a2cb7295a1f7 868 pos_delta = 0.0 - pos_delta;
ram54288 0:a2cb7295a1f7 869 }
ram54288 0:a2cb7295a1f7 870
ram54288 0:a2cb7295a1f7 871 /* This first part of this condition will catch any NaN or Infinite values */
ram54288 0:a2cb7295a1f7 872 if (isnan(diff) || isinf(diff) || (pos_delta < diff))
ram54288 0:a2cb7295a1f7 873 {
ram54288 0:a2cb7295a1f7 874 UnityTestResultsFailBegin(lineNumber);
ram54288 0:a2cb7295a1f7 875 #ifdef UNITY_DOUBLE_VERBOSE
ram54288 0:a2cb7295a1f7 876 UnityPrint(UnityStrExpected);
ram54288 0:a2cb7295a1f7 877 UnityPrintFloat((float)expected);
ram54288 0:a2cb7295a1f7 878 UnityPrint(UnityStrWas);
ram54288 0:a2cb7295a1f7 879 UnityPrintFloat((float)actual);
ram54288 0:a2cb7295a1f7 880 #else
ram54288 0:a2cb7295a1f7 881 UnityPrint(UnityStrDelta);
ram54288 0:a2cb7295a1f7 882 #endif
ram54288 0:a2cb7295a1f7 883 UnityAddMsgIfSpecified(msg);
ram54288 0:a2cb7295a1f7 884 UNITY_FAIL_AND_BAIL;
ram54288 0:a2cb7295a1f7 885 }
ram54288 0:a2cb7295a1f7 886 }
ram54288 0:a2cb7295a1f7 887
ram54288 0:a2cb7295a1f7 888 /*-----------------------------------------------*/
ram54288 0:a2cb7295a1f7 889
ram54288 0:a2cb7295a1f7 890 void UnityAssertDoubleSpecial(const _UD actual,
ram54288 0:a2cb7295a1f7 891 const char* msg,
ram54288 0:a2cb7295a1f7 892 const UNITY_LINE_TYPE lineNumber,
ram54288 0:a2cb7295a1f7 893 const UNITY_FLOAT_TRAIT_T style)
ram54288 0:a2cb7295a1f7 894 {
ram54288 0:a2cb7295a1f7 895 const char* trait_names[] = { UnityStrInf, UnityStrNegInf, UnityStrNaN, UnityStrDet };
ram54288 0:a2cb7295a1f7 896 _U_SINT should_be_trait = ((_U_SINT)style & 1);
ram54288 0:a2cb7295a1f7 897 _U_SINT is_trait = !should_be_trait;
ram54288 0:a2cb7295a1f7 898 _U_SINT trait_index = (_U_SINT)(style >> 1);
ram54288 0:a2cb7295a1f7 899
ram54288 0:a2cb7295a1f7 900 UNITY_SKIP_EXECUTION;
ram54288 0:a2cb7295a1f7 901
ram54288 0:a2cb7295a1f7 902 switch(style)
ram54288 0:a2cb7295a1f7 903 {
ram54288 0:a2cb7295a1f7 904 /* To determine Inf / Neg Inf, we compare to an Inf / Neg Inf value we create on the fly
ram54288 0:a2cb7295a1f7 905 * We are using a variable to hold the zero value because some compilers complain about dividing by zero otherwise */
ram54288 0:a2cb7295a1f7 906 case UNITY_FLOAT_IS_INF:
ram54288 0:a2cb7295a1f7 907 case UNITY_FLOAT_IS_NOT_INF:
ram54288 0:a2cb7295a1f7 908 is_trait = isinf(actual) & ispos(actual);
ram54288 0:a2cb7295a1f7 909 break;
ram54288 0:a2cb7295a1f7 910 case UNITY_FLOAT_IS_NEG_INF:
ram54288 0:a2cb7295a1f7 911 case UNITY_FLOAT_IS_NOT_NEG_INF:
ram54288 0:a2cb7295a1f7 912 is_trait = isinf(actual) & isneg(actual);
ram54288 0:a2cb7295a1f7 913 break;
ram54288 0:a2cb7295a1f7 914
ram54288 0:a2cb7295a1f7 915 /* NaN is the only floating point value that does NOT equal itself. Therefore if Actual == Actual, then it is NOT NaN. */
ram54288 0:a2cb7295a1f7 916 case UNITY_FLOAT_IS_NAN:
ram54288 0:a2cb7295a1f7 917 case UNITY_FLOAT_IS_NOT_NAN:
ram54288 0:a2cb7295a1f7 918 is_trait = isnan(actual);
ram54288 0:a2cb7295a1f7 919 break;
ram54288 0:a2cb7295a1f7 920
ram54288 0:a2cb7295a1f7 921 /* A determinate number is non infinite and not NaN. (therefore the opposite of the two above) */
ram54288 0:a2cb7295a1f7 922 case UNITY_FLOAT_IS_DET:
ram54288 0:a2cb7295a1f7 923 case UNITY_FLOAT_IS_NOT_DET:
ram54288 0:a2cb7295a1f7 924 if (isinf(actual) | isnan(actual))
ram54288 0:a2cb7295a1f7 925 is_trait = 0;
ram54288 0:a2cb7295a1f7 926 else
ram54288 0:a2cb7295a1f7 927 is_trait = 1;
ram54288 0:a2cb7295a1f7 928 break;
ram54288 0:a2cb7295a1f7 929
ram54288 0:a2cb7295a1f7 930 default:
ram54288 0:a2cb7295a1f7 931 trait_index = 0;
ram54288 0:a2cb7295a1f7 932 trait_names[0] = UnityStrInvalidFloatTrait;
ram54288 0:a2cb7295a1f7 933 break;
ram54288 0:a2cb7295a1f7 934 }
ram54288 0:a2cb7295a1f7 935
ram54288 0:a2cb7295a1f7 936 if (is_trait != should_be_trait)
ram54288 0:a2cb7295a1f7 937 {
ram54288 0:a2cb7295a1f7 938 UnityTestResultsFailBegin(lineNumber);
ram54288 0:a2cb7295a1f7 939 UnityPrint(UnityStrExpected);
ram54288 0:a2cb7295a1f7 940 if (!should_be_trait)
ram54288 0:a2cb7295a1f7 941 UnityPrint(UnityStrNot);
ram54288 0:a2cb7295a1f7 942 UnityPrint(trait_names[trait_index]);
ram54288 0:a2cb7295a1f7 943 UnityPrint(UnityStrWas);
ram54288 0:a2cb7295a1f7 944 #ifdef UNITY_DOUBLE_VERBOSE
ram54288 0:a2cb7295a1f7 945 UnityPrintFloat(actual);
ram54288 0:a2cb7295a1f7 946 #else
ram54288 0:a2cb7295a1f7 947 if (should_be_trait)
ram54288 0:a2cb7295a1f7 948 UnityPrint(UnityStrNot);
ram54288 0:a2cb7295a1f7 949 UnityPrint(trait_names[trait_index]);
ram54288 0:a2cb7295a1f7 950 #endif
ram54288 0:a2cb7295a1f7 951 UnityAddMsgIfSpecified(msg);
ram54288 0:a2cb7295a1f7 952 UNITY_FAIL_AND_BAIL;
ram54288 0:a2cb7295a1f7 953 }
ram54288 0:a2cb7295a1f7 954 }
ram54288 0:a2cb7295a1f7 955
ram54288 0:a2cb7295a1f7 956
ram54288 0:a2cb7295a1f7 957 #endif /* not UNITY_EXCLUDE_DOUBLE */
ram54288 0:a2cb7295a1f7 958
ram54288 0:a2cb7295a1f7 959 /*-----------------------------------------------*/
ram54288 0:a2cb7295a1f7 960 void UnityAssertNumbersWithin( const _U_UINT delta,
ram54288 0:a2cb7295a1f7 961 const _U_SINT expected,
ram54288 0:a2cb7295a1f7 962 const _U_SINT actual,
ram54288 0:a2cb7295a1f7 963 const char* msg,
ram54288 0:a2cb7295a1f7 964 const UNITY_LINE_TYPE lineNumber,
ram54288 0:a2cb7295a1f7 965 const UNITY_DISPLAY_STYLE_T style)
ram54288 0:a2cb7295a1f7 966 {
ram54288 0:a2cb7295a1f7 967 UNITY_SKIP_EXECUTION;
ram54288 0:a2cb7295a1f7 968
ram54288 0:a2cb7295a1f7 969 if ((style & UNITY_DISPLAY_RANGE_INT) == UNITY_DISPLAY_RANGE_INT)
ram54288 0:a2cb7295a1f7 970 {
ram54288 0:a2cb7295a1f7 971 if (actual > expected)
ram54288 0:a2cb7295a1f7 972 Unity.CurrentTestFailed = ((_U_UINT)(actual - expected) > delta);
ram54288 0:a2cb7295a1f7 973 else
ram54288 0:a2cb7295a1f7 974 Unity.CurrentTestFailed = ((_U_UINT)(expected - actual) > delta);
ram54288 0:a2cb7295a1f7 975 }
ram54288 0:a2cb7295a1f7 976 else
ram54288 0:a2cb7295a1f7 977 {
ram54288 0:a2cb7295a1f7 978 if ((_U_UINT)actual > (_U_UINT)expected)
ram54288 0:a2cb7295a1f7 979 Unity.CurrentTestFailed = ((_U_UINT)(actual - expected) > delta);
ram54288 0:a2cb7295a1f7 980 else
ram54288 0:a2cb7295a1f7 981 Unity.CurrentTestFailed = ((_U_UINT)(expected - actual) > delta);
ram54288 0:a2cb7295a1f7 982 }
ram54288 0:a2cb7295a1f7 983
ram54288 0:a2cb7295a1f7 984 if (Unity.CurrentTestFailed)
ram54288 0:a2cb7295a1f7 985 {
ram54288 0:a2cb7295a1f7 986 UnityTestResultsFailBegin(lineNumber);
ram54288 0:a2cb7295a1f7 987 UnityPrint(UnityStrDelta);
ram54288 0:a2cb7295a1f7 988 UnityPrintNumberByStyle((_U_SINT)delta, style);
ram54288 0:a2cb7295a1f7 989 UnityPrint(UnityStrExpected);
ram54288 0:a2cb7295a1f7 990 UnityPrintNumberByStyle(expected, style);
ram54288 0:a2cb7295a1f7 991 UnityPrint(UnityStrWas);
ram54288 0:a2cb7295a1f7 992 UnityPrintNumberByStyle(actual, style);
ram54288 0:a2cb7295a1f7 993 UnityAddMsgIfSpecified(msg);
ram54288 0:a2cb7295a1f7 994 UNITY_FAIL_AND_BAIL;
ram54288 0:a2cb7295a1f7 995 }
ram54288 0:a2cb7295a1f7 996 }
ram54288 0:a2cb7295a1f7 997
ram54288 0:a2cb7295a1f7 998 /*-----------------------------------------------*/
ram54288 0:a2cb7295a1f7 999 void UnityAssertEqualString(const char* expected,
ram54288 0:a2cb7295a1f7 1000 const char* actual,
ram54288 0:a2cb7295a1f7 1001 const char* msg,
ram54288 0:a2cb7295a1f7 1002 const UNITY_LINE_TYPE lineNumber)
ram54288 0:a2cb7295a1f7 1003 {
ram54288 0:a2cb7295a1f7 1004 _UU32 i;
ram54288 0:a2cb7295a1f7 1005
ram54288 0:a2cb7295a1f7 1006 UNITY_SKIP_EXECUTION;
ram54288 0:a2cb7295a1f7 1007
ram54288 0:a2cb7295a1f7 1008 /* if both pointers not null compare the strings */
ram54288 0:a2cb7295a1f7 1009 if (expected && actual)
ram54288 0:a2cb7295a1f7 1010 {
ram54288 0:a2cb7295a1f7 1011 for (i = 0; expected[i] || actual[i]; i++)
ram54288 0:a2cb7295a1f7 1012 {
ram54288 0:a2cb7295a1f7 1013 if (expected[i] != actual[i])
ram54288 0:a2cb7295a1f7 1014 {
ram54288 0:a2cb7295a1f7 1015 Unity.CurrentTestFailed = 1;
ram54288 0:a2cb7295a1f7 1016 break;
ram54288 0:a2cb7295a1f7 1017 }
ram54288 0:a2cb7295a1f7 1018 }
ram54288 0:a2cb7295a1f7 1019 }
ram54288 0:a2cb7295a1f7 1020 else
ram54288 0:a2cb7295a1f7 1021 { /* handle case of one pointers being null (if both null, test should pass) */
ram54288 0:a2cb7295a1f7 1022 if (expected != actual)
ram54288 0:a2cb7295a1f7 1023 {
ram54288 0:a2cb7295a1f7 1024 Unity.CurrentTestFailed = 1;
ram54288 0:a2cb7295a1f7 1025 }
ram54288 0:a2cb7295a1f7 1026 }
ram54288 0:a2cb7295a1f7 1027
ram54288 0:a2cb7295a1f7 1028 if (Unity.CurrentTestFailed)
ram54288 0:a2cb7295a1f7 1029 {
ram54288 0:a2cb7295a1f7 1030 UnityTestResultsFailBegin(lineNumber);
ram54288 0:a2cb7295a1f7 1031 UnityPrintExpectedAndActualStrings(expected, actual);
ram54288 0:a2cb7295a1f7 1032 UnityAddMsgIfSpecified(msg);
ram54288 0:a2cb7295a1f7 1033 UNITY_FAIL_AND_BAIL;
ram54288 0:a2cb7295a1f7 1034 }
ram54288 0:a2cb7295a1f7 1035 }
ram54288 0:a2cb7295a1f7 1036
ram54288 0:a2cb7295a1f7 1037 /*-----------------------------------------------*/
ram54288 0:a2cb7295a1f7 1038 void UnityAssertEqualStringLen(const char* expected,
ram54288 0:a2cb7295a1f7 1039 const char* actual,
ram54288 0:a2cb7295a1f7 1040 const _UU32 length,
ram54288 0:a2cb7295a1f7 1041 const char* msg,
ram54288 0:a2cb7295a1f7 1042 const UNITY_LINE_TYPE lineNumber)
ram54288 0:a2cb7295a1f7 1043 {
ram54288 0:a2cb7295a1f7 1044 _UU32 i;
ram54288 0:a2cb7295a1f7 1045
ram54288 0:a2cb7295a1f7 1046 UNITY_SKIP_EXECUTION;
ram54288 0:a2cb7295a1f7 1047
ram54288 0:a2cb7295a1f7 1048 /* if both pointers not null compare the strings */
ram54288 0:a2cb7295a1f7 1049 if (expected && actual)
ram54288 0:a2cb7295a1f7 1050 {
ram54288 0:a2cb7295a1f7 1051 for (i = 0; (expected[i] || actual[i]) && i < length; i++)
ram54288 0:a2cb7295a1f7 1052 {
ram54288 0:a2cb7295a1f7 1053 if (expected[i] != actual[i])
ram54288 0:a2cb7295a1f7 1054 {
ram54288 0:a2cb7295a1f7 1055 Unity.CurrentTestFailed = 1;
ram54288 0:a2cb7295a1f7 1056 break;
ram54288 0:a2cb7295a1f7 1057 }
ram54288 0:a2cb7295a1f7 1058 }
ram54288 0:a2cb7295a1f7 1059 }
ram54288 0:a2cb7295a1f7 1060 else
ram54288 0:a2cb7295a1f7 1061 { /* handle case of one pointers being null (if both null, test should pass) */
ram54288 0:a2cb7295a1f7 1062 if (expected != actual)
ram54288 0:a2cb7295a1f7 1063 {
ram54288 0:a2cb7295a1f7 1064 Unity.CurrentTestFailed = 1;
ram54288 0:a2cb7295a1f7 1065 }
ram54288 0:a2cb7295a1f7 1066 }
ram54288 0:a2cb7295a1f7 1067
ram54288 0:a2cb7295a1f7 1068 if (Unity.CurrentTestFailed)
ram54288 0:a2cb7295a1f7 1069 {
ram54288 0:a2cb7295a1f7 1070 UnityTestResultsFailBegin(lineNumber);
ram54288 0:a2cb7295a1f7 1071 UnityPrintExpectedAndActualStringsLen(expected, actual, length);
ram54288 0:a2cb7295a1f7 1072 UnityAddMsgIfSpecified(msg);
ram54288 0:a2cb7295a1f7 1073 UNITY_FAIL_AND_BAIL;
ram54288 0:a2cb7295a1f7 1074 }
ram54288 0:a2cb7295a1f7 1075 }
ram54288 0:a2cb7295a1f7 1076
ram54288 0:a2cb7295a1f7 1077
ram54288 0:a2cb7295a1f7 1078 /*-----------------------------------------------*/
ram54288 0:a2cb7295a1f7 1079 void UnityAssertEqualStringArray( const char** expected,
ram54288 0:a2cb7295a1f7 1080 const char** actual,
ram54288 0:a2cb7295a1f7 1081 const _UU32 num_elements,
ram54288 0:a2cb7295a1f7 1082 const char* msg,
ram54288 0:a2cb7295a1f7 1083 const UNITY_LINE_TYPE lineNumber)
ram54288 0:a2cb7295a1f7 1084 {
ram54288 0:a2cb7295a1f7 1085 _UU32 i, j = 0;
ram54288 0:a2cb7295a1f7 1086
ram54288 0:a2cb7295a1f7 1087 UNITY_SKIP_EXECUTION;
ram54288 0:a2cb7295a1f7 1088
ram54288 0:a2cb7295a1f7 1089 /* if no elements, it's an error */
ram54288 0:a2cb7295a1f7 1090 if (num_elements == 0)
ram54288 0:a2cb7295a1f7 1091 {
ram54288 0:a2cb7295a1f7 1092 UnityPrintPointlessAndBail();
ram54288 0:a2cb7295a1f7 1093 }
ram54288 0:a2cb7295a1f7 1094
ram54288 0:a2cb7295a1f7 1095 if (UnityCheckArraysForNull((UNITY_INTERNAL_PTR)expected, (UNITY_INTERNAL_PTR)actual, lineNumber, msg) == 1)
ram54288 0:a2cb7295a1f7 1096 return;
ram54288 0:a2cb7295a1f7 1097
ram54288 0:a2cb7295a1f7 1098 do
ram54288 0:a2cb7295a1f7 1099 {
ram54288 0:a2cb7295a1f7 1100 /* if both pointers not null compare the strings */
ram54288 0:a2cb7295a1f7 1101 if (expected[j] && actual[j])
ram54288 0:a2cb7295a1f7 1102 {
ram54288 0:a2cb7295a1f7 1103 for (i = 0; expected[j][i] || actual[j][i]; i++)
ram54288 0:a2cb7295a1f7 1104 {
ram54288 0:a2cb7295a1f7 1105 if (expected[j][i] != actual[j][i])
ram54288 0:a2cb7295a1f7 1106 {
ram54288 0:a2cb7295a1f7 1107 Unity.CurrentTestFailed = 1;
ram54288 0:a2cb7295a1f7 1108 break;
ram54288 0:a2cb7295a1f7 1109 }
ram54288 0:a2cb7295a1f7 1110 }
ram54288 0:a2cb7295a1f7 1111 }
ram54288 0:a2cb7295a1f7 1112 else
ram54288 0:a2cb7295a1f7 1113 { /* handle case of one pointers being null (if both null, test should pass) */
ram54288 0:a2cb7295a1f7 1114 if (expected[j] != actual[j])
ram54288 0:a2cb7295a1f7 1115 {
ram54288 0:a2cb7295a1f7 1116 Unity.CurrentTestFailed = 1;
ram54288 0:a2cb7295a1f7 1117 }
ram54288 0:a2cb7295a1f7 1118 }
ram54288 0:a2cb7295a1f7 1119
ram54288 0:a2cb7295a1f7 1120 if (Unity.CurrentTestFailed)
ram54288 0:a2cb7295a1f7 1121 {
ram54288 0:a2cb7295a1f7 1122 UnityTestResultsFailBegin(lineNumber);
ram54288 0:a2cb7295a1f7 1123 if (num_elements > 1)
ram54288 0:a2cb7295a1f7 1124 {
ram54288 0:a2cb7295a1f7 1125 UnityPrint(UnityStrElement);
ram54288 0:a2cb7295a1f7 1126 UnityPrintNumberUnsigned(j);
ram54288 0:a2cb7295a1f7 1127 }
ram54288 0:a2cb7295a1f7 1128 UnityPrintExpectedAndActualStrings((const char*)(expected[j]), (const char*)(actual[j]));
ram54288 0:a2cb7295a1f7 1129 UnityAddMsgIfSpecified(msg);
ram54288 0:a2cb7295a1f7 1130 UNITY_FAIL_AND_BAIL;
ram54288 0:a2cb7295a1f7 1131 }
ram54288 0:a2cb7295a1f7 1132 } while (++j < num_elements);
ram54288 0:a2cb7295a1f7 1133 }
ram54288 0:a2cb7295a1f7 1134
ram54288 0:a2cb7295a1f7 1135 /*-----------------------------------------------*/
ram54288 0:a2cb7295a1f7 1136 void UnityAssertEqualMemory( UNITY_INTERNAL_PTR expected,
ram54288 0:a2cb7295a1f7 1137 UNITY_INTERNAL_PTR actual,
ram54288 0:a2cb7295a1f7 1138 const _UU32 length,
ram54288 0:a2cb7295a1f7 1139 const _UU32 num_elements,
ram54288 0:a2cb7295a1f7 1140 const char* msg,
ram54288 0:a2cb7295a1f7 1141 const UNITY_LINE_TYPE lineNumber)
ram54288 0:a2cb7295a1f7 1142 {
ram54288 0:a2cb7295a1f7 1143 UNITY_PTR_ATTRIBUTE const unsigned char* ptr_exp = (UNITY_PTR_ATTRIBUTE const unsigned char*)expected;
ram54288 0:a2cb7295a1f7 1144 UNITY_PTR_ATTRIBUTE const unsigned char* ptr_act = (UNITY_PTR_ATTRIBUTE const unsigned char*)actual;
ram54288 0:a2cb7295a1f7 1145 _UU32 elements = num_elements;
ram54288 0:a2cb7295a1f7 1146 _UU32 bytes;
ram54288 0:a2cb7295a1f7 1147
ram54288 0:a2cb7295a1f7 1148 UNITY_SKIP_EXECUTION;
ram54288 0:a2cb7295a1f7 1149
ram54288 0:a2cb7295a1f7 1150 if ((elements == 0) || (length == 0))
ram54288 0:a2cb7295a1f7 1151 {
ram54288 0:a2cb7295a1f7 1152 UnityPrintPointlessAndBail();
ram54288 0:a2cb7295a1f7 1153 }
ram54288 0:a2cb7295a1f7 1154
ram54288 0:a2cb7295a1f7 1155 if (UnityCheckArraysForNull((UNITY_INTERNAL_PTR)expected, (UNITY_INTERNAL_PTR)actual, lineNumber, msg) == 1)
ram54288 0:a2cb7295a1f7 1156 return;
ram54288 0:a2cb7295a1f7 1157
ram54288 0:a2cb7295a1f7 1158 while (elements--)
ram54288 0:a2cb7295a1f7 1159 {
ram54288 0:a2cb7295a1f7 1160 /* /////////////////////////////////// */
ram54288 0:a2cb7295a1f7 1161 bytes = length;
ram54288 0:a2cb7295a1f7 1162 while (bytes--)
ram54288 0:a2cb7295a1f7 1163 {
ram54288 0:a2cb7295a1f7 1164 if (*ptr_exp != *ptr_act)
ram54288 0:a2cb7295a1f7 1165 {
ram54288 0:a2cb7295a1f7 1166 UnityTestResultsFailBegin(lineNumber);
ram54288 0:a2cb7295a1f7 1167 UnityPrint(UnityStrMemory);
ram54288 0:a2cb7295a1f7 1168 if (num_elements > 1)
ram54288 0:a2cb7295a1f7 1169 {
ram54288 0:a2cb7295a1f7 1170 UnityPrint(UnityStrElement);
ram54288 0:a2cb7295a1f7 1171 UnityPrintNumberUnsigned(num_elements - elements - 1);
ram54288 0:a2cb7295a1f7 1172 }
ram54288 0:a2cb7295a1f7 1173 UnityPrint(UnityStrByte);
ram54288 0:a2cb7295a1f7 1174 UnityPrintNumberUnsigned(length - bytes - 1);
ram54288 0:a2cb7295a1f7 1175 UnityPrint(UnityStrExpected);
ram54288 0:a2cb7295a1f7 1176 UnityPrintNumberByStyle(*ptr_exp, UNITY_DISPLAY_STYLE_HEX8);
ram54288 0:a2cb7295a1f7 1177 UnityPrint(UnityStrWas);
ram54288 0:a2cb7295a1f7 1178 UnityPrintNumberByStyle(*ptr_act, UNITY_DISPLAY_STYLE_HEX8);
ram54288 0:a2cb7295a1f7 1179 UnityAddMsgIfSpecified(msg);
ram54288 0:a2cb7295a1f7 1180 UNITY_FAIL_AND_BAIL;
ram54288 0:a2cb7295a1f7 1181 }
ram54288 0:a2cb7295a1f7 1182 ptr_exp = (UNITY_INTERNAL_PTR)((_UP)ptr_exp + 1);
ram54288 0:a2cb7295a1f7 1183 ptr_act = (UNITY_INTERNAL_PTR)((_UP)ptr_act + 1);
ram54288 0:a2cb7295a1f7 1184 }
ram54288 0:a2cb7295a1f7 1185 /* /////////////////////////////////// */
ram54288 0:a2cb7295a1f7 1186
ram54288 0:a2cb7295a1f7 1187 }
ram54288 0:a2cb7295a1f7 1188 }
ram54288 0:a2cb7295a1f7 1189
ram54288 0:a2cb7295a1f7 1190 /*-----------------------------------------------
ram54288 0:a2cb7295a1f7 1191 * Control Functions
ram54288 0:a2cb7295a1f7 1192 *-----------------------------------------------*/
ram54288 0:a2cb7295a1f7 1193
ram54288 0:a2cb7295a1f7 1194 void UnityFail(const char* msg, const UNITY_LINE_TYPE line)
ram54288 0:a2cb7295a1f7 1195 {
ram54288 0:a2cb7295a1f7 1196 UNITY_SKIP_EXECUTION;
ram54288 0:a2cb7295a1f7 1197
ram54288 0:a2cb7295a1f7 1198 UnityTestResultsBegin(Unity.TestFile, line);
ram54288 0:a2cb7295a1f7 1199 /* SA_PATCH: Make failures more noticable. */
ram54288 0:a2cb7295a1f7 1200 UnityPrintVisibleFailure();
ram54288 0:a2cb7295a1f7 1201 //UnityPrintFail();
ram54288 0:a2cb7295a1f7 1202 if (msg != NULL)
ram54288 0:a2cb7295a1f7 1203 {
ram54288 0:a2cb7295a1f7 1204 UNITY_OUTPUT_CHAR(':');
ram54288 0:a2cb7295a1f7 1205
ram54288 0:a2cb7295a1f7 1206 #ifndef UNITY_EXCLUDE_DETAILS
ram54288 0:a2cb7295a1f7 1207 if (Unity.CurrentDetail1)
ram54288 0:a2cb7295a1f7 1208 {
ram54288 0:a2cb7295a1f7 1209 UnityPrint(UnityStrDetail1Name);
ram54288 0:a2cb7295a1f7 1210 UnityPrint(Unity.CurrentDetail1);
ram54288 0:a2cb7295a1f7 1211 if (Unity.CurrentDetail2)
ram54288 0:a2cb7295a1f7 1212 {
ram54288 0:a2cb7295a1f7 1213 UnityPrint(UnityStrDetail2Name);
ram54288 0:a2cb7295a1f7 1214 UnityPrint(Unity.CurrentDetail2);
ram54288 0:a2cb7295a1f7 1215 }
ram54288 0:a2cb7295a1f7 1216 UnityPrint(UnityStrSpacer);
ram54288 0:a2cb7295a1f7 1217 }
ram54288 0:a2cb7295a1f7 1218 #endif
ram54288 0:a2cb7295a1f7 1219 if (msg[0] != ' ')
ram54288 0:a2cb7295a1f7 1220 {
ram54288 0:a2cb7295a1f7 1221 UNITY_OUTPUT_CHAR(' ');
ram54288 0:a2cb7295a1f7 1222 }
ram54288 0:a2cb7295a1f7 1223 UnityPrint(msg);
ram54288 0:a2cb7295a1f7 1224 }
ram54288 0:a2cb7295a1f7 1225
ram54288 0:a2cb7295a1f7 1226 UNITY_FAIL_AND_BAIL;
ram54288 0:a2cb7295a1f7 1227 }
ram54288 0:a2cb7295a1f7 1228
ram54288 0:a2cb7295a1f7 1229 /*-----------------------------------------------*/
ram54288 0:a2cb7295a1f7 1230 void UnityIgnore(const char* msg, const UNITY_LINE_TYPE line)
ram54288 0:a2cb7295a1f7 1231 {
ram54288 0:a2cb7295a1f7 1232 UNITY_SKIP_EXECUTION;
ram54288 0:a2cb7295a1f7 1233
ram54288 0:a2cb7295a1f7 1234 UnityTestResultsBegin(Unity.TestFile, line);
ram54288 0:a2cb7295a1f7 1235 UnityPrint(UnityStrIgnore);
ram54288 0:a2cb7295a1f7 1236 if (msg != NULL)
ram54288 0:a2cb7295a1f7 1237 {
ram54288 0:a2cb7295a1f7 1238 UNITY_OUTPUT_CHAR(':');
ram54288 0:a2cb7295a1f7 1239 UNITY_OUTPUT_CHAR(' ');
ram54288 0:a2cb7295a1f7 1240 UnityPrint(msg);
ram54288 0:a2cb7295a1f7 1241 }
ram54288 0:a2cb7295a1f7 1242 UNITY_IGNORE_AND_BAIL;
ram54288 0:a2cb7295a1f7 1243 }
ram54288 0:a2cb7295a1f7 1244
ram54288 0:a2cb7295a1f7 1245 /*-----------------------------------------------*/
ram54288 0:a2cb7295a1f7 1246 #if defined(UNITY_WEAK_ATTRIBUTE)
ram54288 0:a2cb7295a1f7 1247 UNITY_WEAK_ATTRIBUTE void setUp(void) { }
ram54288 0:a2cb7295a1f7 1248 UNITY_WEAK_ATTRIBUTE void tearDown(void) { }
ram54288 0:a2cb7295a1f7 1249 #elif defined(UNITY_WEAK_PRAGMA)
ram54288 0:a2cb7295a1f7 1250 # pragma weak setUp
ram54288 0:a2cb7295a1f7 1251 void setUp(void) { }
ram54288 0:a2cb7295a1f7 1252 # pragma weak tearDown
ram54288 0:a2cb7295a1f7 1253 void tearDown(void) { }
ram54288 0:a2cb7295a1f7 1254 #endif
ram54288 0:a2cb7295a1f7 1255 /*-----------------------------------------------*/
ram54288 0:a2cb7295a1f7 1256 void UnityDefaultTestRun(UnityTestFunction Func, const char* FuncName, const int FuncLineNum)
ram54288 0:a2cb7295a1f7 1257 {
ram54288 0:a2cb7295a1f7 1258 Unity.CurrentTestName = FuncName;
ram54288 0:a2cb7295a1f7 1259 Unity.CurrentTestLineNumber = (UNITY_LINE_TYPE)FuncLineNum;
ram54288 0:a2cb7295a1f7 1260 Unity.NumberOfTests++;
ram54288 0:a2cb7295a1f7 1261 UNITY_CLR_DETAILS();
ram54288 0:a2cb7295a1f7 1262 if (TEST_PROTECT())
ram54288 0:a2cb7295a1f7 1263 {
ram54288 0:a2cb7295a1f7 1264 setUp();
ram54288 0:a2cb7295a1f7 1265 Func();
ram54288 0:a2cb7295a1f7 1266 }
ram54288 0:a2cb7295a1f7 1267 if (TEST_PROTECT() && !(Unity.CurrentTestIgnored))
ram54288 0:a2cb7295a1f7 1268 {
ram54288 0:a2cb7295a1f7 1269 tearDown();
ram54288 0:a2cb7295a1f7 1270 }
ram54288 0:a2cb7295a1f7 1271 UnityConcludeTest();
ram54288 0:a2cb7295a1f7 1272 }
ram54288 0:a2cb7295a1f7 1273
ram54288 0:a2cb7295a1f7 1274 /*-----------------------------------------------*/
ram54288 0:a2cb7295a1f7 1275 void UnityBegin(const char* filename)
ram54288 0:a2cb7295a1f7 1276 {
ram54288 0:a2cb7295a1f7 1277 Unity.TestFile = filename;
ram54288 0:a2cb7295a1f7 1278 Unity.CurrentTestName = NULL;
ram54288 0:a2cb7295a1f7 1279 Unity.CurrentTestLineNumber = 0;
ram54288 0:a2cb7295a1f7 1280 Unity.NumberOfTests = 0;
ram54288 0:a2cb7295a1f7 1281 Unity.TestFailures = 0;
ram54288 0:a2cb7295a1f7 1282 Unity.TestIgnores = 0;
ram54288 0:a2cb7295a1f7 1283 Unity.CurrentTestFailed = 0;
ram54288 0:a2cb7295a1f7 1284 Unity.CurrentTestIgnored = 0;
ram54288 0:a2cb7295a1f7 1285
ram54288 0:a2cb7295a1f7 1286 UNITY_CLR_DETAILS();
ram54288 0:a2cb7295a1f7 1287 UNITY_OUTPUT_START();
ram54288 0:a2cb7295a1f7 1288 }
ram54288 0:a2cb7295a1f7 1289
ram54288 0:a2cb7295a1f7 1290 /*-----------------------------------------------*/
ram54288 0:a2cb7295a1f7 1291 int UnityEnd(void)
ram54288 0:a2cb7295a1f7 1292 {
ram54288 0:a2cb7295a1f7 1293 UNITY_PRINT_EOL();
ram54288 0:a2cb7295a1f7 1294 UnityPrint(UnityStrBreaker);
ram54288 0:a2cb7295a1f7 1295 UNITY_PRINT_EOL();
ram54288 0:a2cb7295a1f7 1296 UnityPrintNumber((_U_SINT)(Unity.NumberOfTests));
ram54288 0:a2cb7295a1f7 1297 UnityPrint(UnityStrResultsTests);
ram54288 0:a2cb7295a1f7 1298 UnityPrintNumber((_U_SINT)(Unity.TestFailures));
ram54288 0:a2cb7295a1f7 1299 UnityPrint(UnityStrResultsFailures);
ram54288 0:a2cb7295a1f7 1300 UnityPrintNumber((_U_SINT)(Unity.TestIgnores));
ram54288 0:a2cb7295a1f7 1301 UnityPrint(UnityStrResultsIgnored);
ram54288 0:a2cb7295a1f7 1302 UNITY_PRINT_EOL();
ram54288 0:a2cb7295a1f7 1303 if (Unity.TestFailures == 0U)
ram54288 0:a2cb7295a1f7 1304 {
ram54288 0:a2cb7295a1f7 1305 UnityPrintOk();
ram54288 0:a2cb7295a1f7 1306 }
ram54288 0:a2cb7295a1f7 1307 else
ram54288 0:a2cb7295a1f7 1308 {
ram54288 0:a2cb7295a1f7 1309 UnityPrintFail();
ram54288 0:a2cb7295a1f7 1310 #ifdef UNITY_DIFFERENTIATE_FINAL_FAIL
ram54288 0:a2cb7295a1f7 1311 UNITY_OUTPUT_CHAR('E'); UNITY_OUTPUT_CHAR('D');
ram54288 0:a2cb7295a1f7 1312 #endif
ram54288 0:a2cb7295a1f7 1313 }
ram54288 0:a2cb7295a1f7 1314 UNITY_PRINT_EOL();
ram54288 0:a2cb7295a1f7 1315 UNITY_FLUSH_CALL();
ram54288 0:a2cb7295a1f7 1316 UNITY_OUTPUT_COMPLETE();
ram54288 0:a2cb7295a1f7 1317 return (int)(Unity.TestFailures);
ram54288 0:a2cb7295a1f7 1318 }
ram54288 0:a2cb7295a1f7 1319
ram54288 0:a2cb7295a1f7 1320 /*-----------------------------------------------*/