Preliminary main mbed library for nexpaq development

Committer:
nexpaq
Date:
Fri Nov 04 20:27:58 2016 +0000
Revision:
0:6c56fb4bc5f0
Moving to library for sharing updates

Who changed what in which revision?

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