ASCII Serial Com
Serial communication library between computers, microcontrollers, FPGAs, etc. Uses only ASCII. Not the most efficient protocol, but meant to be easy to read
Loading...
Searching...
No Matches
unity.c
1/* =========================================================================
2 Unity Project - A Test Framework for C
3 Copyright (c) 2007-19 Mike Karlesky, Mark VanderVoord, Greg Williams
4 [Released under MIT License. Please refer to license.txt for details]
5============================================================================ */
6
7#include "unity.h"
8#include <stddef.h>
9
10#ifdef AVR
11#include <avr/pgmspace.h>
12#else
13#define PROGMEM
14#endif
15
16/* If omitted from header, declare overrideable prototypes here so they're ready
17 * for use */
18#ifdef UNITY_OMIT_OUTPUT_CHAR_HEADER_DECLARATION
19void UNITY_OUTPUT_CHAR(int);
20#endif
21
22/* Helpful macros for us to use here in Assert functions */
23#define UNITY_FAIL_AND_BAIL \
24 { \
25 Unity.CurrentTestFailed = 1; \
26 UNITY_OUTPUT_FLUSH(); \
27 TEST_ABORT(); \
28 }
29#define UNITY_IGNORE_AND_BAIL \
30 { \
31 Unity.CurrentTestIgnored = 1; \
32 UNITY_OUTPUT_FLUSH(); \
33 TEST_ABORT(); \
34 }
35#define RETURN_IF_FAIL_OR_IGNORE \
36 if (Unity.CurrentTestFailed || Unity.CurrentTestIgnored) \
37 TEST_ABORT()
38
39struct UNITY_STORAGE_T Unity;
40
41#ifdef UNITY_OUTPUT_COLOR
42const char PROGMEM UnityStrOk[] = "\033[42mOK\033[00m";
43const char PROGMEM UnityStrPass[] = "\033[42mPASS\033[00m";
44const char PROGMEM UnityStrFail[] = "\033[41mFAIL\033[00m";
45const char PROGMEM UnityStrIgnore[] = "\033[43mIGNORE\033[00m";
46#else
47const char PROGMEM UnityStrOk[] = "OK";
48const char PROGMEM UnityStrPass[] = "PASS";
49const char PROGMEM UnityStrFail[] = "FAIL";
50const char PROGMEM UnityStrIgnore[] = "IGNORE";
51#endif
52static const char PROGMEM UnityStrNull[] = "NULL";
53static const char PROGMEM UnityStrSpacer[] = ". ";
54static const char PROGMEM UnityStrExpected[] = " Expected ";
55static const char PROGMEM UnityStrWas[] = " Was ";
56static const char PROGMEM UnityStrGt[] = " to be greater than ";
57static const char PROGMEM UnityStrLt[] = " to be less than ";
58static const char PROGMEM UnityStrOrEqual[] = "or equal to ";
59static const char PROGMEM UnityStrNotEqual[] = " to be not equal to ";
60static const char PROGMEM UnityStrElement[] = " Element ";
61static const char PROGMEM UnityStrByte[] = " Byte ";
62static const char PROGMEM UnityStrMemory[] = " Memory Mismatch.";
63static const char PROGMEM UnityStrDelta[] = " Values Not Within Delta ";
64static const char PROGMEM UnityStrPointless[] =
65 " You Asked Me To Compare Nothing, Which Was Pointless.";
66static const char PROGMEM UnityStrNullPointerForExpected[] =
67 " Expected pointer to be NULL";
68static const char PROGMEM UnityStrNullPointerForActual[] =
69 " Actual pointer was NULL";
70#ifndef UNITY_EXCLUDE_FLOAT
71static const char PROGMEM UnityStrNot[] = "Not ";
72static const char PROGMEM UnityStrInf[] = "Infinity";
73static const char PROGMEM UnityStrNegInf[] = "Negative Infinity";
74static const char PROGMEM UnityStrNaN[] = "NaN";
75static const char PROGMEM UnityStrDet[] = "Determinate";
76static const char PROGMEM UnityStrInvalidFloatTrait[] = "Invalid Float Trait";
77#endif
78const char PROGMEM UnityStrErrShorthand[] = "Unity Shorthand Support Disabled";
79const char PROGMEM UnityStrErrFloat[] = "Unity Floating Point Disabled";
80const char PROGMEM UnityStrErrDouble[] = "Unity Double Precision Disabled";
81const char PROGMEM UnityStrErr64[] = "Unity 64-bit Support Disabled";
82static const char PROGMEM UnityStrBreaker[] = "-----------------------";
83static const char PROGMEM UnityStrResultsTests[] = " Tests ";
84static const char PROGMEM UnityStrResultsFailures[] = " Failures ";
85static const char PROGMEM UnityStrResultsIgnored[] = " Ignored ";
86static const char PROGMEM UnityStrDetail1Name[] = UNITY_DETAIL1_NAME " ";
87static const char PROGMEM UnityStrDetail2Name[] = " " UNITY_DETAIL2_NAME " ";
88
89/*-----------------------------------------------
90 * Pretty Printers & Test Result Output Handlers
91 *-----------------------------------------------*/
92
93/*-----------------------------------------------*/
94/* Local helper function to print characters. */
95static void UnityPrintChar(const char *pch) {
96 /* printable characters plus CR & LF are printed */
97 if ((*pch <= 126) && (*pch >= 32)) {
98 UNITY_OUTPUT_CHAR(*pch);
99 }
100 /* write escaped carriage returns */
101 else if (*pch == 13) {
102 UNITY_OUTPUT_CHAR('\\');
103 UNITY_OUTPUT_CHAR('r');
104 }
105 /* write escaped line feeds */
106 else if (*pch == 10) {
107 UNITY_OUTPUT_CHAR('\\');
108 UNITY_OUTPUT_CHAR('n');
109 }
110 /* unprintable characters are shown as codes */
111 else {
112 UNITY_OUTPUT_CHAR('\\');
113 UNITY_OUTPUT_CHAR('x');
114 UnityPrintNumberHex((UNITY_UINT)*pch, 2);
115 }
116}
117
118/*-----------------------------------------------*/
119/* Local helper function to print ANSI escape strings e.g. "\033[42m". */
120#ifdef UNITY_OUTPUT_COLOR
121static UNITY_UINT UnityPrintAnsiEscapeString(const char *string) {
122 const char *pch = string;
123 UNITY_UINT count = 0;
124
125 while (*pch && (*pch != 'm')) {
126 UNITY_OUTPUT_CHAR(*pch);
127 pch++;
128 count++;
129 }
130 UNITY_OUTPUT_CHAR('m');
131 count++;
132
133 return count;
134}
135#endif
136
137/*-----------------------------------------------*/
138void UnityPrint(const char *string) {
139 const char *pch = string;
140
141 if (pch != NULL) {
142 while (*pch) {
143#ifdef UNITY_OUTPUT_COLOR
144 /* print ANSI escape code */
145 if ((*pch == 27) && (*(pch + 1) == '[')) {
146 pch += UnityPrintAnsiEscapeString(pch);
147 continue;
148 }
149#endif
150 UnityPrintChar(pch);
151 pch++;
152 }
153 }
154}
155/*-----------------------------------------------*/
156void UnityPrintLen(const char *string, const UNITY_UINT32 length) {
157 const char *pch = string;
158
159 if (pch != NULL) {
160 while (*pch && ((UNITY_UINT32)(pch - string) < length)) {
161 /* printable characters plus CR & LF are printed */
162 if ((*pch <= 126) && (*pch >= 32)) {
163 UNITY_OUTPUT_CHAR(*pch);
164 }
165 /* write escaped carriage returns */
166 else if (*pch == 13) {
167 UNITY_OUTPUT_CHAR('\\');
168 UNITY_OUTPUT_CHAR('r');
169 }
170 /* write escaped line feeds */
171 else if (*pch == 10) {
172 UNITY_OUTPUT_CHAR('\\');
173 UNITY_OUTPUT_CHAR('n');
174 }
175 /* unprintable characters are shown as codes */
176 else {
177 UNITY_OUTPUT_CHAR('\\');
178 UNITY_OUTPUT_CHAR('x');
179 UnityPrintNumberHex((UNITY_UINT)*pch, 2);
180 }
181 pch++;
182 }
183 }
184}
185
186/*-----------------------------------------------*/
187void UnityPrintNumberByStyle(const UNITY_INT number,
188 const UNITY_DISPLAY_STYLE_T style) {
189 if ((style & UNITY_DISPLAY_RANGE_INT) == UNITY_DISPLAY_RANGE_INT) {
190 if (style == UNITY_DISPLAY_STYLE_CHAR) {
191 /* printable characters plus CR & LF are printed */
192 UNITY_OUTPUT_CHAR('\'');
193 if ((number <= 126) && (number >= 32)) {
194 UNITY_OUTPUT_CHAR((int)number);
195 }
196 /* write escaped carriage returns */
197 else if (number == 13) {
198 UNITY_OUTPUT_CHAR('\\');
199 UNITY_OUTPUT_CHAR('r');
200 }
201 /* write escaped line feeds */
202 else if (number == 10) {
203 UNITY_OUTPUT_CHAR('\\');
204 UNITY_OUTPUT_CHAR('n');
205 }
206 /* unprintable characters are shown as codes */
207 else {
208 UNITY_OUTPUT_CHAR('\\');
209 UNITY_OUTPUT_CHAR('x');
210 UnityPrintNumberHex((UNITY_UINT)number, 2);
211 }
212 UNITY_OUTPUT_CHAR('\'');
213 } else {
214 UnityPrintNumber(number);
215 }
216 } else if ((style & UNITY_DISPLAY_RANGE_UINT) == UNITY_DISPLAY_RANGE_UINT) {
217 UnityPrintNumberUnsigned((UNITY_UINT)number);
218 } else {
219 UNITY_OUTPUT_CHAR('0');
220 UNITY_OUTPUT_CHAR('x');
221 UnityPrintNumberHex((UNITY_UINT)number, (char)((style & 0xF) * 2));
222 }
223}
224
225/*-----------------------------------------------*/
226void UnityPrintNumber(const UNITY_INT number_to_print) {
227 UNITY_UINT number = (UNITY_UINT)number_to_print;
228
229 if (number_to_print < 0) {
230 /* A negative number, including MIN negative */
231 UNITY_OUTPUT_CHAR('-');
232 number = (~number) + 1;
233 }
234 UnityPrintNumberUnsigned(number);
235}
236
237/*-----------------------------------------------
238 * basically do an itoa using as little ram as possible */
239void UnityPrintNumberUnsigned(const UNITY_UINT number) {
240 UNITY_UINT divisor = 1;
241
242 /* figure out initial divisor */
243 while (number / divisor > 9) {
244 divisor *= 10;
245 }
246
247 /* now mod and print, then divide divisor */
248 do {
249 UNITY_OUTPUT_CHAR((char)('0' + (number / divisor % 10)));
250 divisor /= 10;
251 } while (divisor > 0);
252}
253
254/*-----------------------------------------------*/
255void UnityPrintNumberHex(const UNITY_UINT number, const char nibbles_to_print) {
256 int nibble;
257 char nibbles = nibbles_to_print;
258
259 if ((unsigned)nibbles > UNITY_MAX_NIBBLES) {
260 nibbles = UNITY_MAX_NIBBLES;
261 }
262
263 while (nibbles > 0) {
264 nibbles--;
265 nibble = (int)(number >> (nibbles * 4)) & 0x0F;
266 if (nibble <= 9) {
267 UNITY_OUTPUT_CHAR((char)('0' + nibble));
268 } else {
269 UNITY_OUTPUT_CHAR((char)('A' - 10 + nibble));
270 }
271 }
272}
273
274/*-----------------------------------------------*/
275void UnityPrintMask(const UNITY_UINT mask, const UNITY_UINT number) {
276 UNITY_UINT current_bit = (UNITY_UINT)1 << (UNITY_INT_WIDTH - 1);
277 UNITY_INT32 i;
278
279 for (i = 0; i < UNITY_INT_WIDTH; i++) {
280 if (current_bit & mask) {
281 if (current_bit & number) {
282 UNITY_OUTPUT_CHAR('1');
283 } else {
284 UNITY_OUTPUT_CHAR('0');
285 }
286 } else {
287 UNITY_OUTPUT_CHAR('X');
288 }
289 current_bit = current_bit >> 1;
290 }
291}
292
293/*-----------------------------------------------*/
294#ifndef UNITY_EXCLUDE_FLOAT_PRINT
295/*
296 * This function prints a floating-point value in a format similar to
297 * printf("%.7g") on a single-precision machine or printf("%.9g") on a
298 * double-precision machine. The 7th digit won't always be totally correct
299 * in single-precision operation (for that level of accuracy, a more
300 * complicated algorithm would be needed).
301 */
302void UnityPrintFloat(const UNITY_DOUBLE input_number) {
303#ifdef UNITY_INCLUDE_DOUBLE
304 static const int sig_digits = 9;
305 static const UNITY_INT32 min_scaled = 100000000;
306 static const UNITY_INT32 max_scaled = 1000000000;
307#else
308 static const int sig_digits = 7;
309 static const UNITY_INT32 min_scaled = 1000000;
310 static const UNITY_INT32 max_scaled = 10000000;
311#endif
312
313 UNITY_DOUBLE number = input_number;
314
315 /* print minus sign (does not handle negative zero) */
316 if (number < 0.0f) {
317 UNITY_OUTPUT_CHAR('-');
318 number = -number;
319 }
320
321 /* handle zero, NaN, and +/- infinity */
322#pragma GCC diagnostic ignored "-Wfloat-equal"
323#pragma GCC diagnostic push
324 if (number == 0.0f) {
325 UnityPrint("0");
326 } else if (isnan(number)) {
327 UnityPrint("nan");
328 } else if (isinf(number)) {
329 UnityPrint("inf");
330 } else {
331 UNITY_INT32 n_int = 0, n;
332 int exponent = 0;
333 int decimals, digits;
334 char buf[16] = {0};
335
336 /*
337 * Scale up or down by powers of 10. To minimize rounding error,
338 * start with a factor/divisor of 10^10, which is the largest
339 * power of 10 that can be represented exactly. Finally, compute
340 * (exactly) the remaining power of 10 and perform one more
341 * multiplication or division.
342 */
343 if (number < 1.0f) {
344 UNITY_DOUBLE factor = 1.0f;
345
346 while (number < (UNITY_DOUBLE)max_scaled / 1e10f) {
347 number *= 1e10f;
348 exponent -= 10;
349 }
350 while (number * factor < (UNITY_DOUBLE)min_scaled) {
351 factor *= 10.0f;
352 exponent--;
353 }
354
355 number *= factor;
356 } else if (number > (UNITY_DOUBLE)max_scaled) {
357 UNITY_DOUBLE divisor = 1.0f;
358
359 while (number > (UNITY_DOUBLE)min_scaled * 1e10f) {
360 number /= 1e10f;
361 exponent += 10;
362 }
363 while (number / divisor > (UNITY_DOUBLE)max_scaled) {
364 divisor *= 10.0f;
365 exponent++;
366 }
367
368 number /= divisor;
369 } else {
370 /*
371 * In this range, we can split off the integer part before
372 * doing any multiplications. This reduces rounding error by
373 * freeing up significant bits in the fractional part.
374 */
375 UNITY_DOUBLE factor = 1.0f;
376 n_int = (UNITY_INT32)number;
377 number -= (UNITY_DOUBLE)n_int;
378
379 while (n_int < min_scaled) {
380 n_int *= 10;
381 factor *= 10.0f;
382 exponent--;
383 }
384
385 number *= factor;
386 }
387
388 /* round to nearest integer */
389 n = ((UNITY_INT32)(number + number) + 1) / 2;
390
391#ifndef UNITY_ROUND_TIES_AWAY_FROM_ZERO
392 /* round to even if exactly between two integers */
393 if ((n & 1) && (((UNITY_DOUBLE)n - number) == 0.5f))
394 n--;
395#endif
396
397 n += n_int;
398
399 if (n >= max_scaled) {
400 n = min_scaled;
401 exponent++;
402 }
403
404 /* determine where to place decimal point */
405 decimals = ((exponent <= 0) && (exponent >= -(sig_digits + 3)))
406 ? (-exponent)
407 : (sig_digits - 1);
408 exponent += decimals;
409
410 /* truncate trailing zeroes after decimal point */
411 while ((decimals > 0) && ((n % 10) == 0)) {
412 n /= 10;
413 decimals--;
414 }
415
416 /* build up buffer in reverse order */
417 digits = 0;
418 while ((n != 0) || (digits < (decimals + 1))) {
419 buf[digits++] = (char)('0' + n % 10);
420 n /= 10;
421 }
422 while (digits > 0) {
423 if (digits == decimals) {
424 UNITY_OUTPUT_CHAR('.');
425 }
426 UNITY_OUTPUT_CHAR(buf[--digits]);
427 }
428
429 /* print exponent if needed */
430 if (exponent != 0) {
431 UNITY_OUTPUT_CHAR('e');
432
433 if (exponent < 0) {
434 UNITY_OUTPUT_CHAR('-');
435 exponent = -exponent;
436 } else {
437 UNITY_OUTPUT_CHAR('+');
438 }
439
440 digits = 0;
441 while ((exponent != 0) || (digits < 2)) {
442 buf[digits++] = (char)('0' + exponent % 10);
443 exponent /= 10;
444 }
445 while (digits > 0) {
446 UNITY_OUTPUT_CHAR(buf[--digits]);
447 }
448 }
449 }
450#pragma GCC diagnostic pop
451}
452#endif /* ! UNITY_EXCLUDE_FLOAT_PRINT */
453
454/*-----------------------------------------------*/
455static void UnityTestResultsBegin(const char *file,
456 const UNITY_LINE_TYPE line) {
457#ifdef UNITY_OUTPUT_FOR_ECLIPSE
458 UNITY_OUTPUT_CHAR('(');
459 UnityPrint(file);
460 UNITY_OUTPUT_CHAR(':');
461 UnityPrintNumber((UNITY_INT)line);
462 UNITY_OUTPUT_CHAR(')');
463 UNITY_OUTPUT_CHAR(' ');
464 UnityPrint(Unity.CurrentTestName);
465 UNITY_OUTPUT_CHAR(':');
466#else
467#ifdef UNITY_OUTPUT_FOR_IAR_WORKBENCH
468 UnityPrint("<SRCREF line=");
469 UnityPrintNumber((UNITY_INT)line);
470 UnityPrint(" file=\"");
471 UnityPrint(file);
472 UNITY_OUTPUT_CHAR('"');
473 UNITY_OUTPUT_CHAR('>');
474 UnityPrint(Unity.CurrentTestName);
475 UnityPrint("</SRCREF> ");
476#else
477#ifdef UNITY_OUTPUT_FOR_QT_CREATOR
478 UnityPrint("file://");
479 UnityPrint(file);
480 UNITY_OUTPUT_CHAR(':');
481 UnityPrintNumber((UNITY_INT)line);
482 UNITY_OUTPUT_CHAR(' ');
483 UnityPrint(Unity.CurrentTestName);
484 UNITY_OUTPUT_CHAR(':');
485#else
486 UnityPrint(file);
487 UNITY_OUTPUT_CHAR(':');
488 UnityPrintNumber((UNITY_INT)line);
489 UNITY_OUTPUT_CHAR(':');
490 UnityPrint(Unity.CurrentTestName);
491 UNITY_OUTPUT_CHAR(':');
492#endif
493#endif
494#endif
495}
496
497/*-----------------------------------------------*/
498static void UnityTestResultsFailBegin(const UNITY_LINE_TYPE line) {
499 UnityTestResultsBegin(Unity.TestFile, line);
500 UnityPrint(UnityStrFail);
501 UNITY_OUTPUT_CHAR(':');
502}
503
504/*-----------------------------------------------*/
505void UnityConcludeTest(void) {
506 if (Unity.CurrentTestIgnored) {
507 Unity.TestIgnores++;
508 } else if (!Unity.CurrentTestFailed) {
509 UnityTestResultsBegin(Unity.TestFile, Unity.CurrentTestLineNumber);
510 UnityPrint(UnityStrPass);
511 } else {
512 Unity.TestFailures++;
513 }
514
515 Unity.CurrentTestFailed = 0;
516 Unity.CurrentTestIgnored = 0;
517 UNITY_PRINT_EXEC_TIME();
518 UNITY_PRINT_EOL();
519 UNITY_FLUSH_CALL();
520}
521
522/*-----------------------------------------------*/
523static void UnityAddMsgIfSpecified(const char *msg) {
524 if (msg) {
525 UnityPrint(UnityStrSpacer);
526
527#ifdef UNITY_PRINT_TEST_CONTEXT
528 UNITY_PRINT_TEST_CONTEXT();
529#endif
530#ifndef UNITY_EXCLUDE_DETAILS
531 if (Unity.CurrentDetail1) {
532 UnityPrint(UnityStrDetail1Name);
533 UnityPrint(Unity.CurrentDetail1);
534 if (Unity.CurrentDetail2) {
535 UnityPrint(UnityStrDetail2Name);
536 UnityPrint(Unity.CurrentDetail2);
537 }
538 UnityPrint(UnityStrSpacer);
539 }
540#endif
541 UnityPrint(msg);
542 }
543}
544
545/*-----------------------------------------------*/
546static void UnityPrintExpectedAndActualStrings(const char *expected,
547 const char *actual) {
548 UnityPrint(UnityStrExpected);
549 if (expected != NULL) {
550 UNITY_OUTPUT_CHAR('\'');
551 UnityPrint(expected);
552 UNITY_OUTPUT_CHAR('\'');
553 } else {
554 UnityPrint(UnityStrNull);
555 }
556 UnityPrint(UnityStrWas);
557 if (actual != NULL) {
558 UNITY_OUTPUT_CHAR('\'');
559 UnityPrint(actual);
560 UNITY_OUTPUT_CHAR('\'');
561 } else {
562 UnityPrint(UnityStrNull);
563 }
564}
565
566/*-----------------------------------------------*/
567static void UnityPrintExpectedAndActualStringsLen(const char *expected,
568 const char *actual,
569 const UNITY_UINT32 length) {
570 UnityPrint(UnityStrExpected);
571 if (expected != NULL) {
572 UNITY_OUTPUT_CHAR('\'');
573 UnityPrintLen(expected, length);
574 UNITY_OUTPUT_CHAR('\'');
575 } else {
576 UnityPrint(UnityStrNull);
577 }
578 UnityPrint(UnityStrWas);
579 if (actual != NULL) {
580 UNITY_OUTPUT_CHAR('\'');
581 UnityPrintLen(actual, length);
582 UNITY_OUTPUT_CHAR('\'');
583 } else {
584 UnityPrint(UnityStrNull);
585 }
586}
587
588/*-----------------------------------------------
589 * Assertion & Control Helpers
590 *-----------------------------------------------*/
591
592/*-----------------------------------------------*/
593static int UnityIsOneArrayNull(UNITY_INTERNAL_PTR expected,
594 UNITY_INTERNAL_PTR actual,
595 const UNITY_LINE_TYPE lineNumber,
596 const char *msg) {
597 /* Both are NULL or same pointer */
598 if (expected == actual) {
599 return 0;
600 }
601
602 /* print and return true if just expected is NULL */
603 if (expected == NULL) {
604 UnityTestResultsFailBegin(lineNumber);
605 UnityPrint(UnityStrNullPointerForExpected);
606 UnityAddMsgIfSpecified(msg);
607 return 1;
608 }
609
610 /* print and return true if just actual is NULL */
611 if (actual == NULL) {
612 UnityTestResultsFailBegin(lineNumber);
613 UnityPrint(UnityStrNullPointerForActual);
614 UnityAddMsgIfSpecified(msg);
615 return 1;
616 }
617
618 return 0; /* return false if neither is NULL */
619}
620
621/*-----------------------------------------------
622 * Assertion Functions
623 *-----------------------------------------------*/
624
625/*-----------------------------------------------*/
626void UnityAssertBits(const UNITY_INT mask, const UNITY_INT expected,
627 const UNITY_INT actual, const char *msg,
628 const UNITY_LINE_TYPE lineNumber) {
629 RETURN_IF_FAIL_OR_IGNORE;
630
631 if ((mask & expected) != (mask & actual)) {
632 UnityTestResultsFailBegin(lineNumber);
633 UnityPrint(UnityStrExpected);
634 UnityPrintMask((UNITY_UINT)mask, (UNITY_UINT)expected);
635 UnityPrint(UnityStrWas);
636 UnityPrintMask((UNITY_UINT)mask, (UNITY_UINT)actual);
637 UnityAddMsgIfSpecified(msg);
638 UNITY_FAIL_AND_BAIL;
639 }
640}
641
642/*-----------------------------------------------*/
643void UnityAssertEqualNumber(const UNITY_INT expected, const UNITY_INT actual,
644 const char *msg, const UNITY_LINE_TYPE lineNumber,
645 const UNITY_DISPLAY_STYLE_T style) {
646 RETURN_IF_FAIL_OR_IGNORE;
647
648 if (expected != actual) {
649 UnityTestResultsFailBegin(lineNumber);
650 UnityPrint(UnityStrExpected);
651 UnityPrintNumberByStyle(expected, style);
652 UnityPrint(UnityStrWas);
653 UnityPrintNumberByStyle(actual, style);
654 UnityAddMsgIfSpecified(msg);
655 UNITY_FAIL_AND_BAIL;
656 }
657}
658
659/*-----------------------------------------------*/
660void UnityAssertGreaterOrLessOrEqualNumber(const UNITY_INT threshold,
661 const UNITY_INT actual,
662 const UNITY_COMPARISON_T compare,
663 const char *msg,
664 const UNITY_LINE_TYPE lineNumber,
665 const UNITY_DISPLAY_STYLE_T style) {
666 int failed = 0;
667 RETURN_IF_FAIL_OR_IGNORE;
668
669 if ((threshold == actual) && (compare & UNITY_EQUAL_TO)) {
670 return;
671 }
672 if ((threshold == actual)) {
673 failed = 1;
674 }
675
676 if ((style & UNITY_DISPLAY_RANGE_INT) == UNITY_DISPLAY_RANGE_INT) {
677 if ((actual > threshold) && (compare & UNITY_SMALLER_THAN)) {
678 failed = 1;
679 }
680 if ((actual < threshold) && (compare & UNITY_GREATER_THAN)) {
681 failed = 1;
682 }
683 } else /* UINT or HEX */
684 {
685 if (((UNITY_UINT)actual > (UNITY_UINT)threshold) &&
686 (compare & UNITY_SMALLER_THAN)) {
687 failed = 1;
688 }
689 if (((UNITY_UINT)actual < (UNITY_UINT)threshold) &&
690 (compare & UNITY_GREATER_THAN)) {
691 failed = 1;
692 }
693 }
694
695 if (failed) {
696 UnityTestResultsFailBegin(lineNumber);
697 UnityPrint(UnityStrExpected);
698 UnityPrintNumberByStyle(actual, style);
699 if (compare & UNITY_GREATER_THAN) {
700 UnityPrint(UnityStrGt);
701 }
702 if (compare & UNITY_SMALLER_THAN) {
703 UnityPrint(UnityStrLt);
704 }
705 if (compare & UNITY_EQUAL_TO) {
706 UnityPrint(UnityStrOrEqual);
707 }
708 if (compare == UNITY_NOT_EQUAL) {
709 UnityPrint(UnityStrNotEqual);
710 }
711 UnityPrintNumberByStyle(threshold, style);
712 UnityAddMsgIfSpecified(msg);
713 UNITY_FAIL_AND_BAIL;
714 }
715}
716
717#define UnityPrintPointlessAndBail() \
718 { \
719 UnityTestResultsFailBegin(lineNumber); \
720 UnityPrint(UnityStrPointless); \
721 UnityAddMsgIfSpecified(msg); \
722 UNITY_FAIL_AND_BAIL; \
723 }
724
725/*-----------------------------------------------*/
726void UnityAssertEqualIntArray(UNITY_INTERNAL_PTR expected,
727 UNITY_INTERNAL_PTR actual,
728 const UNITY_UINT32 num_elements, const char *msg,
729 const UNITY_LINE_TYPE lineNumber,
730 const UNITY_DISPLAY_STYLE_T style,
731 const UNITY_FLAGS_T flags) {
732 UNITY_UINT32 elements = num_elements;
733 unsigned int length = style & 0xF;
734 unsigned int increment = 0;
735
736 RETURN_IF_FAIL_OR_IGNORE;
737
738 if (num_elements == 0) {
739 UnityPrintPointlessAndBail();
740 }
741
742 if (expected == actual) {
743 return; /* Both are NULL or same pointer */
744 }
745
746 if (UnityIsOneArrayNull(expected, actual, lineNumber, msg)) {
747 UNITY_FAIL_AND_BAIL;
748 }
749
750 while ((elements > 0) && (elements--)) {
751 UNITY_INT expect_val;
752 UNITY_INT actual_val;
753
754 switch (length) {
755 case 1:
756 expect_val = *(UNITY_PTR_ATTRIBUTE const UNITY_INT8 *)expected;
757 actual_val = *(UNITY_PTR_ATTRIBUTE const UNITY_INT8 *)actual;
758 increment = sizeof(UNITY_INT8);
759 break;
760
761 case 2:
762 expect_val = *(UNITY_PTR_ATTRIBUTE const UNITY_INT16 *)expected;
763 actual_val = *(UNITY_PTR_ATTRIBUTE const UNITY_INT16 *)actual;
764 increment = sizeof(UNITY_INT16);
765 break;
766
767#ifdef UNITY_SUPPORT_64
768 case 8:
769 expect_val = *(UNITY_PTR_ATTRIBUTE const UNITY_INT64 *)expected;
770 actual_val = *(UNITY_PTR_ATTRIBUTE const UNITY_INT64 *)actual;
771 increment = sizeof(UNITY_INT64);
772 break;
773#endif
774
775 default: /* default is length 4 bytes */
776 case 4:
777 expect_val = *(UNITY_PTR_ATTRIBUTE const UNITY_INT32 *)expected;
778 actual_val = *(UNITY_PTR_ATTRIBUTE const UNITY_INT32 *)actual;
779 increment = sizeof(UNITY_INT32);
780 length = 4;
781 break;
782 }
783
784 if (expect_val != actual_val) {
785 if ((style & UNITY_DISPLAY_RANGE_UINT) &&
786 (length <
787 (UNITY_INT_WIDTH / 8))) { /* For UINT, remove sign extension (padding
788 1's) from signed type casts above */
789 UNITY_INT mask = 1;
790 mask = (mask << 8 * length) - 1;
791 expect_val &= mask;
792 actual_val &= mask;
793 }
794 UnityTestResultsFailBegin(lineNumber);
795 UnityPrint(UnityStrElement);
796 UnityPrintNumberUnsigned(num_elements - elements - 1);
797 UnityPrint(UnityStrExpected);
798 UnityPrintNumberByStyle(expect_val, style);
799 UnityPrint(UnityStrWas);
800 UnityPrintNumberByStyle(actual_val, style);
801 UnityAddMsgIfSpecified(msg);
802 UNITY_FAIL_AND_BAIL;
803 }
804 /* Walk through array by incrementing the pointers */
805 if (flags == UNITY_ARRAY_TO_ARRAY) {
806 expected = (UNITY_INTERNAL_PTR)((const char *)expected + increment);
807 }
808 actual = (UNITY_INTERNAL_PTR)((const char *)actual + increment);
809 }
810}
811
812/*-----------------------------------------------*/
813#ifndef UNITY_EXCLUDE_FLOAT
814/* Wrap this define in a function with variable types as float or double */
815#define UNITY_FLOAT_OR_DOUBLE_WITHIN(delta, expected, actual, diff) \
816 if (isinf(expected) && isinf(actual) && \
817 (((expected) < 0) == ((actual) < 0))) \
818 return 1; \
819 if (UNITY_NAN_CHECK) \
820 return 1; \
821 (diff) = (actual) - (expected); \
822 if ((diff) < 0) \
823 (diff) = -(diff); \
824 if ((delta) < 0) \
825 (delta) = -(delta); \
826 return !(isnan(diff) || isinf(diff) || ((diff) > (delta)))
827/* This first part of this condition will catch any NaN or Infinite values */
828#ifndef UNITY_NAN_NOT_EQUAL_NAN
829#define UNITY_NAN_CHECK isnan(expected) && isnan(actual)
830#else
831#define UNITY_NAN_CHECK 0
832#endif
833
834#ifndef UNITY_EXCLUDE_FLOAT_PRINT
835#define UNITY_PRINT_EXPECTED_AND_ACTUAL_FLOAT(expected, actual) \
836 { \
837 UnityPrint(UnityStrExpected); \
838 UnityPrintFloat(expected); \
839 UnityPrint(UnityStrWas); \
840 UnityPrintFloat(actual); \
841 }
842#else
843#define UNITY_PRINT_EXPECTED_AND_ACTUAL_FLOAT(expected, actual) \
844 UnityPrint(UnityStrDelta)
845#endif /* UNITY_EXCLUDE_FLOAT_PRINT */
846
847/*-----------------------------------------------*/
848static int UnityFloatsWithin(UNITY_FLOAT delta, UNITY_FLOAT expected,
849 UNITY_FLOAT actual) {
850 UNITY_FLOAT diff;
851 UNITY_FLOAT_OR_DOUBLE_WITHIN(delta, expected, actual, diff);
852}
853
854/*-----------------------------------------------*/
855void UnityAssertEqualFloatArray(UNITY_PTR_ATTRIBUTE const UNITY_FLOAT *expected,
856 UNITY_PTR_ATTRIBUTE const UNITY_FLOAT *actual,
857 const UNITY_UINT32 num_elements,
858 const char *msg,
859 const UNITY_LINE_TYPE lineNumber,
860 const UNITY_FLAGS_T flags) {
861 UNITY_UINT32 elements = num_elements;
862 UNITY_PTR_ATTRIBUTE const UNITY_FLOAT *ptr_expected = expected;
863 UNITY_PTR_ATTRIBUTE const UNITY_FLOAT *ptr_actual = actual;
864
865 RETURN_IF_FAIL_OR_IGNORE;
866
867 if (elements == 0) {
868 UnityPrintPointlessAndBail();
869 }
870
871 if (expected == actual) {
872 return; /* Both are NULL or same pointer */
873 }
874
875 if (UnityIsOneArrayNull((UNITY_INTERNAL_PTR)expected,
876 (UNITY_INTERNAL_PTR)actual, lineNumber, msg)) {
877 UNITY_FAIL_AND_BAIL;
878 }
879
880 while (elements--) {
881 if (!UnityFloatsWithin(*ptr_expected * UNITY_FLOAT_PRECISION, *ptr_expected,
882 *ptr_actual)) {
883 UnityTestResultsFailBegin(lineNumber);
884 UnityPrint(UnityStrElement);
885 UnityPrintNumberUnsigned(num_elements - elements - 1);
886 UNITY_PRINT_EXPECTED_AND_ACTUAL_FLOAT((UNITY_DOUBLE)*ptr_expected,
887 (UNITY_DOUBLE)*ptr_actual);
888 UnityAddMsgIfSpecified(msg);
889 UNITY_FAIL_AND_BAIL;
890 }
891 if (flags == UNITY_ARRAY_TO_ARRAY) {
892 ptr_expected++;
893 }
894 ptr_actual++;
895 }
896}
897
898/*-----------------------------------------------*/
899void UnityAssertFloatsWithin(const UNITY_FLOAT delta,
900 const UNITY_FLOAT expected,
901 const UNITY_FLOAT actual, const char *msg,
902 const UNITY_LINE_TYPE lineNumber) {
903 RETURN_IF_FAIL_OR_IGNORE;
904
905 if (!UnityFloatsWithin(delta, expected, actual)) {
906 UnityTestResultsFailBegin(lineNumber);
907 UNITY_PRINT_EXPECTED_AND_ACTUAL_FLOAT((UNITY_DOUBLE)expected,
908 (UNITY_DOUBLE)actual);
909 UnityAddMsgIfSpecified(msg);
910 UNITY_FAIL_AND_BAIL;
911 }
912}
913
914/*-----------------------------------------------*/
915void UnityAssertFloatSpecial(const UNITY_FLOAT actual, const char *msg,
916 const UNITY_LINE_TYPE lineNumber,
917 const UNITY_FLOAT_TRAIT_T style) {
918 const char *trait_names[] = {UnityStrInf, UnityStrNegInf, UnityStrNaN,
919 UnityStrDet};
920 UNITY_INT should_be_trait = ((UNITY_INT)style & 1);
921 UNITY_INT is_trait = !should_be_trait;
922 UNITY_INT trait_index = (UNITY_INT)(style >> 1);
923
924 RETURN_IF_FAIL_OR_IGNORE;
925
926#pragma GCC diagnostic ignored "-Wswitch-enum"
927#pragma GCC diagnostic push
928 switch (style) {
929 case UNITY_FLOAT_IS_INF:
930 case UNITY_FLOAT_IS_NOT_INF:
931 is_trait = isinf(actual) && (actual > 0);
932 break;
933 case UNITY_FLOAT_IS_NEG_INF:
934 case UNITY_FLOAT_IS_NOT_NEG_INF:
935 is_trait = isinf(actual) && (actual < 0);
936 break;
937
938 case UNITY_FLOAT_IS_NAN:
939 case UNITY_FLOAT_IS_NOT_NAN:
940 is_trait = isnan(actual) ? 1 : 0;
941 break;
942
943 case UNITY_FLOAT_IS_DET: /* A determinate number is non infinite and not NaN.
944 */
945 case UNITY_FLOAT_IS_NOT_DET:
946 is_trait = !isinf(actual) && !isnan(actual);
947 break;
948
949 default:
950 trait_index = 0;
951 trait_names[0] = UnityStrInvalidFloatTrait;
952 break;
953 }
954#pragma GCC diagnostic pop
955
956 if (is_trait != should_be_trait) {
957 UnityTestResultsFailBegin(lineNumber);
958 UnityPrint(UnityStrExpected);
959 if (!should_be_trait) {
960 UnityPrint(UnityStrNot);
961 }
962 UnityPrint(trait_names[trait_index]);
963 UnityPrint(UnityStrWas);
964#ifndef UNITY_EXCLUDE_FLOAT_PRINT
965 UnityPrintFloat((UNITY_DOUBLE)actual);
966#else
967 if (should_be_trait) {
968 UnityPrint(UnityStrNot);
969 }
970 UnityPrint(trait_names[trait_index]);
971#endif
972 UnityAddMsgIfSpecified(msg);
973 UNITY_FAIL_AND_BAIL;
974 }
975}
976
977#endif /* not UNITY_EXCLUDE_FLOAT */
978
979/*-----------------------------------------------*/
980#ifndef UNITY_EXCLUDE_DOUBLE
981static int UnityDoublesWithin(UNITY_DOUBLE delta, UNITY_DOUBLE expected,
982 UNITY_DOUBLE actual) {
983 UNITY_DOUBLE diff;
984 UNITY_FLOAT_OR_DOUBLE_WITHIN(delta, expected, actual, diff);
985}
986
987/*-----------------------------------------------*/
988void UnityAssertEqualDoubleArray(
989 UNITY_PTR_ATTRIBUTE const UNITY_DOUBLE *expected,
990 UNITY_PTR_ATTRIBUTE const UNITY_DOUBLE *actual,
991 const UNITY_UINT32 num_elements, const char *msg,
992 const UNITY_LINE_TYPE lineNumber, const UNITY_FLAGS_T flags) {
993 UNITY_UINT32 elements = num_elements;
994 UNITY_PTR_ATTRIBUTE const UNITY_DOUBLE *ptr_expected = expected;
995 UNITY_PTR_ATTRIBUTE const UNITY_DOUBLE *ptr_actual = actual;
996
997 RETURN_IF_FAIL_OR_IGNORE;
998
999 if (elements == 0) {
1000 UnityPrintPointlessAndBail();
1001 }
1002
1003 if (expected == actual) {
1004 return; /* Both are NULL or same pointer */
1005 }
1006
1007 if (UnityIsOneArrayNull((UNITY_INTERNAL_PTR)expected,
1008 (UNITY_INTERNAL_PTR)actual, lineNumber, msg)) {
1009 UNITY_FAIL_AND_BAIL;
1010 }
1011
1012 while (elements--) {
1013 if (!UnityDoublesWithin(*ptr_expected * UNITY_DOUBLE_PRECISION,
1014 *ptr_expected, *ptr_actual)) {
1015 UnityTestResultsFailBegin(lineNumber);
1016 UnityPrint(UnityStrElement);
1017 UnityPrintNumberUnsigned(num_elements - elements - 1);
1018 UNITY_PRINT_EXPECTED_AND_ACTUAL_FLOAT(*ptr_expected, *ptr_actual);
1019 UnityAddMsgIfSpecified(msg);
1020 UNITY_FAIL_AND_BAIL;
1021 }
1022 if (flags == UNITY_ARRAY_TO_ARRAY) {
1023 ptr_expected++;
1024 }
1025 ptr_actual++;
1026 }
1027}
1028
1029/*-----------------------------------------------*/
1030void UnityAssertDoublesWithin(const UNITY_DOUBLE delta,
1031 const UNITY_DOUBLE expected,
1032 const UNITY_DOUBLE actual, const char *msg,
1033 const UNITY_LINE_TYPE lineNumber) {
1034 RETURN_IF_FAIL_OR_IGNORE;
1035
1036 if (!UnityDoublesWithin(delta, expected, actual)) {
1037 UnityTestResultsFailBegin(lineNumber);
1038 UNITY_PRINT_EXPECTED_AND_ACTUAL_FLOAT(expected, actual);
1039 UnityAddMsgIfSpecified(msg);
1040 UNITY_FAIL_AND_BAIL;
1041 }
1042}
1043
1044/*-----------------------------------------------*/
1045void UnityAssertDoubleSpecial(const UNITY_DOUBLE actual, const char *msg,
1046 const UNITY_LINE_TYPE lineNumber,
1047 const UNITY_FLOAT_TRAIT_T style) {
1048 const char *trait_names[] = {UnityStrInf, UnityStrNegInf, UnityStrNaN,
1049 UnityStrDet};
1050 UNITY_INT should_be_trait = ((UNITY_INT)style & 1);
1051 UNITY_INT is_trait = !should_be_trait;
1052 UNITY_INT trait_index = (UNITY_INT)(style >> 1);
1053
1054 RETURN_IF_FAIL_OR_IGNORE;
1055
1056 switch (style) {
1057 case UNITY_FLOAT_IS_INF:
1058 case UNITY_FLOAT_IS_NOT_INF:
1059 is_trait = isinf(actual) && (actual > 0);
1060 break;
1061 case UNITY_FLOAT_IS_NEG_INF:
1062 case UNITY_FLOAT_IS_NOT_NEG_INF:
1063 is_trait = isinf(actual) && (actual < 0);
1064 break;
1065
1066 case UNITY_FLOAT_IS_NAN:
1067 case UNITY_FLOAT_IS_NOT_NAN:
1068 is_trait = isnan(actual) ? 1 : 0;
1069 break;
1070
1071 case UNITY_FLOAT_IS_DET: /* A determinate number is non infinite and not NaN.
1072 */
1073 case UNITY_FLOAT_IS_NOT_DET:
1074 is_trait = !isinf(actual) && !isnan(actual);
1075 break;
1076
1077 default:
1078 trait_index = 0;
1079 trait_names[0] = UnityStrInvalidFloatTrait;
1080 break;
1081 }
1082
1083 if (is_trait != should_be_trait) {
1084 UnityTestResultsFailBegin(lineNumber);
1085 UnityPrint(UnityStrExpected);
1086 if (!should_be_trait) {
1087 UnityPrint(UnityStrNot);
1088 }
1089 UnityPrint(trait_names[trait_index]);
1090 UnityPrint(UnityStrWas);
1091#ifndef UNITY_EXCLUDE_FLOAT_PRINT
1092 UnityPrintFloat(actual);
1093#else
1094 if (should_be_trait) {
1095 UnityPrint(UnityStrNot);
1096 }
1097 UnityPrint(trait_names[trait_index]);
1098#endif
1099 UnityAddMsgIfSpecified(msg);
1100 UNITY_FAIL_AND_BAIL;
1101 }
1102}
1103
1104#endif /* not UNITY_EXCLUDE_DOUBLE */
1105
1106/*-----------------------------------------------*/
1107void UnityAssertNumbersWithin(const UNITY_UINT delta, const UNITY_INT expected,
1108 const UNITY_INT actual, const char *msg,
1109 const UNITY_LINE_TYPE lineNumber,
1110 const UNITY_DISPLAY_STYLE_T style) {
1111 RETURN_IF_FAIL_OR_IGNORE;
1112
1113 if ((style & UNITY_DISPLAY_RANGE_INT) == UNITY_DISPLAY_RANGE_INT) {
1114 if (actual > expected) {
1115 Unity.CurrentTestFailed =
1116 (((UNITY_UINT)actual - (UNITY_UINT)expected) > delta);
1117 } else {
1118 Unity.CurrentTestFailed =
1119 (((UNITY_UINT)expected - (UNITY_UINT)actual) > delta);
1120 }
1121 } else {
1122 if ((UNITY_UINT)actual > (UNITY_UINT)expected) {
1123 Unity.CurrentTestFailed =
1124 (((UNITY_UINT)actual - (UNITY_UINT)expected) > delta);
1125 } else {
1126 Unity.CurrentTestFailed =
1127 (((UNITY_UINT)expected - (UNITY_UINT)actual) > delta);
1128 }
1129 }
1130
1131 if (Unity.CurrentTestFailed) {
1132 UnityTestResultsFailBegin(lineNumber);
1133 UnityPrint(UnityStrDelta);
1134 UnityPrintNumberByStyle((UNITY_INT)delta, style);
1135 UnityPrint(UnityStrExpected);
1136 UnityPrintNumberByStyle(expected, style);
1137 UnityPrint(UnityStrWas);
1138 UnityPrintNumberByStyle(actual, style);
1139 UnityAddMsgIfSpecified(msg);
1140 UNITY_FAIL_AND_BAIL;
1141 }
1142}
1143
1144/*-----------------------------------------------*/
1145void UnityAssertNumbersArrayWithin(
1146 const UNITY_UINT delta, UNITY_INTERNAL_PTR expected,
1147 UNITY_INTERNAL_PTR actual, const UNITY_UINT32 num_elements, const char *msg,
1148 const UNITY_LINE_TYPE lineNumber, const UNITY_DISPLAY_STYLE_T style,
1149 const UNITY_FLAGS_T flags) {
1150 UNITY_UINT32 elements = num_elements;
1151 unsigned int length = style & 0xF;
1152 unsigned int increment = 0;
1153
1154 RETURN_IF_FAIL_OR_IGNORE;
1155
1156 if (num_elements == 0) {
1157 UnityPrintPointlessAndBail();
1158 }
1159
1160 if (expected == actual) {
1161 return; /* Both are NULL or same pointer */
1162 }
1163
1164 if (UnityIsOneArrayNull(expected, actual, lineNumber, msg)) {
1165 UNITY_FAIL_AND_BAIL;
1166 }
1167
1168 while ((elements > 0) && (elements--)) {
1169 UNITY_INT expect_val;
1170 UNITY_INT actual_val;
1171
1172 switch (length) {
1173 case 1:
1174 expect_val = *(UNITY_PTR_ATTRIBUTE const UNITY_INT8 *)expected;
1175 actual_val = *(UNITY_PTR_ATTRIBUTE const UNITY_INT8 *)actual;
1176 increment = sizeof(UNITY_INT8);
1177 break;
1178
1179 case 2:
1180 expect_val = *(UNITY_PTR_ATTRIBUTE const UNITY_INT16 *)expected;
1181 actual_val = *(UNITY_PTR_ATTRIBUTE const UNITY_INT16 *)actual;
1182 increment = sizeof(UNITY_INT16);
1183 break;
1184
1185#ifdef UNITY_SUPPORT_64
1186 case 8:
1187 expect_val = *(UNITY_PTR_ATTRIBUTE const UNITY_INT64 *)expected;
1188 actual_val = *(UNITY_PTR_ATTRIBUTE const UNITY_INT64 *)actual;
1189 increment = sizeof(UNITY_INT64);
1190 break;
1191#endif
1192
1193 default: /* default is length 4 bytes */
1194 case 4:
1195 expect_val = *(UNITY_PTR_ATTRIBUTE const UNITY_INT32 *)expected;
1196 actual_val = *(UNITY_PTR_ATTRIBUTE const UNITY_INT32 *)actual;
1197 increment = sizeof(UNITY_INT32);
1198 length = 4;
1199 break;
1200 }
1201
1202 if ((style & UNITY_DISPLAY_RANGE_INT) == UNITY_DISPLAY_RANGE_INT) {
1203 if (actual_val > expect_val) {
1204 Unity.CurrentTestFailed =
1205 (((UNITY_UINT)actual_val - (UNITY_UINT)expect_val) > delta);
1206 } else {
1207 Unity.CurrentTestFailed =
1208 (((UNITY_UINT)expect_val - (UNITY_UINT)actual_val) > delta);
1209 }
1210 } else {
1211 if ((UNITY_UINT)actual_val > (UNITY_UINT)expect_val) {
1212 Unity.CurrentTestFailed =
1213 (((UNITY_UINT)actual_val - (UNITY_UINT)expect_val) > delta);
1214 } else {
1215 Unity.CurrentTestFailed =
1216 (((UNITY_UINT)expect_val - (UNITY_UINT)actual_val) > delta);
1217 }
1218 }
1219
1220 if (Unity.CurrentTestFailed) {
1221 if ((style & UNITY_DISPLAY_RANGE_UINT) &&
1222 (length <
1223 (UNITY_INT_WIDTH / 8))) { /* For UINT, remove sign extension (padding
1224 1's) from signed type casts above */
1225 UNITY_INT mask = 1;
1226 mask = (mask << 8 * length) - 1;
1227 expect_val &= mask;
1228 actual_val &= mask;
1229 }
1230 UnityTestResultsFailBegin(lineNumber);
1231 UnityPrint(UnityStrDelta);
1232 UnityPrintNumberByStyle((UNITY_INT)delta, style);
1233 UnityPrint(UnityStrElement);
1234 UnityPrintNumberUnsigned(num_elements - elements - 1);
1235 UnityPrint(UnityStrExpected);
1236 UnityPrintNumberByStyle(expect_val, style);
1237 UnityPrint(UnityStrWas);
1238 UnityPrintNumberByStyle(actual_val, style);
1239 UnityAddMsgIfSpecified(msg);
1240 UNITY_FAIL_AND_BAIL;
1241 }
1242 /* Walk through array by incrementing the pointers */
1243 if (flags == UNITY_ARRAY_TO_ARRAY) {
1244 expected = (UNITY_INTERNAL_PTR)((const char *)expected + increment);
1245 }
1246 actual = (UNITY_INTERNAL_PTR)((const char *)actual + increment);
1247 }
1248}
1249
1250/*-----------------------------------------------*/
1251void UnityAssertEqualString(const char *expected, const char *actual,
1252 const char *msg, const UNITY_LINE_TYPE lineNumber) {
1253 UNITY_UINT32 i;
1254
1255 RETURN_IF_FAIL_OR_IGNORE;
1256
1257 /* if both pointers not null compare the strings */
1258 if (expected && actual) {
1259 for (i = 0; expected[i] || actual[i]; i++) {
1260 if (expected[i] != actual[i]) {
1261 Unity.CurrentTestFailed = 1;
1262 break;
1263 }
1264 }
1265 } else { /* handle case of one pointers being null (if both null, test should
1266 pass) */
1267 if (expected != actual) {
1268 Unity.CurrentTestFailed = 1;
1269 }
1270 }
1271
1272 if (Unity.CurrentTestFailed) {
1273 UnityTestResultsFailBegin(lineNumber);
1274 UnityPrintExpectedAndActualStrings(expected, actual);
1275 UnityAddMsgIfSpecified(msg);
1276 UNITY_FAIL_AND_BAIL;
1277 }
1278}
1279
1280/*-----------------------------------------------*/
1281void UnityAssertEqualStringLen(const char *expected, const char *actual,
1282 const UNITY_UINT32 length, const char *msg,
1283 const UNITY_LINE_TYPE lineNumber) {
1284 UNITY_UINT32 i;
1285
1286 RETURN_IF_FAIL_OR_IGNORE;
1287
1288 /* if both pointers not null compare the strings */
1289 if (expected && actual) {
1290 for (i = 0; (i < length) && (expected[i] || actual[i]); i++) {
1291 if (expected[i] != actual[i]) {
1292 Unity.CurrentTestFailed = 1;
1293 break;
1294 }
1295 }
1296 } else { /* handle case of one pointers being null (if both null, test should
1297 pass) */
1298 if (expected != actual) {
1299 Unity.CurrentTestFailed = 1;
1300 }
1301 }
1302
1303 if (Unity.CurrentTestFailed) {
1304 UnityTestResultsFailBegin(lineNumber);
1305 UnityPrintExpectedAndActualStringsLen(expected, actual, length);
1306 UnityAddMsgIfSpecified(msg);
1307 UNITY_FAIL_AND_BAIL;
1308 }
1309}
1310
1311/*-----------------------------------------------*/
1312void UnityAssertEqualStringArray(UNITY_INTERNAL_PTR expected,
1313 const char **actual,
1314 const UNITY_UINT32 num_elements,
1315 const char *msg,
1316 const UNITY_LINE_TYPE lineNumber,
1317 const UNITY_FLAGS_T flags) {
1318 UNITY_UINT32 i = 0;
1319 UNITY_UINT32 j = 0;
1320 const char *expd = NULL;
1321 const char *act = NULL;
1322
1323 RETURN_IF_FAIL_OR_IGNORE;
1324
1325 /* if no elements, it's an error */
1326 if (num_elements == 0) {
1327 UnityPrintPointlessAndBail();
1328 }
1329
1330 if ((const void *)expected == (const void *)actual) {
1331 return; /* Both are NULL or same pointer */
1332 }
1333
1334 if (UnityIsOneArrayNull((UNITY_INTERNAL_PTR)expected,
1335 (UNITY_INTERNAL_PTR)actual, lineNumber, msg)) {
1336 UNITY_FAIL_AND_BAIL;
1337 }
1338
1339 if (flags != UNITY_ARRAY_TO_ARRAY) {
1340 expd = (const char *)expected;
1341 }
1342
1343 do {
1344 act = actual[j];
1345 if (flags == UNITY_ARRAY_TO_ARRAY) {
1346 expd = ((const char *const *)expected)[j];
1347 }
1348
1349 /* if both pointers not null compare the strings */
1350 if (expd && act) {
1351 for (i = 0; expd[i] || act[i]; i++) {
1352 if (expd[i] != act[i]) {
1353 Unity.CurrentTestFailed = 1;
1354 break;
1355 }
1356 }
1357 } else { /* handle case of one pointers being null (if both null, test
1358 should pass) */
1359 if (expd != act) {
1360 Unity.CurrentTestFailed = 1;
1361 }
1362 }
1363
1364 if (Unity.CurrentTestFailed) {
1365 UnityTestResultsFailBegin(lineNumber);
1366 if (num_elements > 1) {
1367 UnityPrint(UnityStrElement);
1368 UnityPrintNumberUnsigned(j);
1369 }
1370 UnityPrintExpectedAndActualStrings(expd, act);
1371 UnityAddMsgIfSpecified(msg);
1372 UNITY_FAIL_AND_BAIL;
1373 }
1374 } while (++j < num_elements);
1375}
1376
1377/*-----------------------------------------------*/
1378void UnityAssertEqualMemory(UNITY_INTERNAL_PTR expected,
1379 UNITY_INTERNAL_PTR actual,
1380 const UNITY_UINT32 length,
1381 const UNITY_UINT32 num_elements, const char *msg,
1382 const UNITY_LINE_TYPE lineNumber,
1383 const UNITY_FLAGS_T flags) {
1384 UNITY_PTR_ATTRIBUTE const unsigned char *ptr_exp =
1385 (UNITY_PTR_ATTRIBUTE const unsigned char *)expected;
1386 UNITY_PTR_ATTRIBUTE const unsigned char *ptr_act =
1387 (UNITY_PTR_ATTRIBUTE const unsigned char *)actual;
1388 UNITY_UINT32 elements = num_elements;
1389 UNITY_UINT32 bytes;
1390
1391 RETURN_IF_FAIL_OR_IGNORE;
1392
1393 if ((elements == 0) || (length == 0)) {
1394 UnityPrintPointlessAndBail();
1395 }
1396
1397 if (expected == actual) {
1398 return; /* Both are NULL or same pointer */
1399 }
1400
1401 if (UnityIsOneArrayNull(expected, actual, lineNumber, msg)) {
1402 UNITY_FAIL_AND_BAIL;
1403 }
1404
1405 while (elements--) {
1406 bytes = length;
1407 while (bytes--) {
1408 if (*ptr_exp != *ptr_act) {
1409 UnityTestResultsFailBegin(lineNumber);
1410 UnityPrint(UnityStrMemory);
1411 if (num_elements > 1) {
1412 UnityPrint(UnityStrElement);
1413 UnityPrintNumberUnsigned(num_elements - elements - 1);
1414 }
1415 UnityPrint(UnityStrByte);
1416 UnityPrintNumberUnsigned(length - bytes - 1);
1417 UnityPrint(UnityStrExpected);
1418 UnityPrintNumberByStyle(*ptr_exp, UNITY_DISPLAY_STYLE_HEX8);
1419 UnityPrint(UnityStrWas);
1420 UnityPrintNumberByStyle(*ptr_act, UNITY_DISPLAY_STYLE_HEX8);
1421 UnityAddMsgIfSpecified(msg);
1422 UNITY_FAIL_AND_BAIL;
1423 }
1424 ptr_exp++;
1425 ptr_act++;
1426 }
1427 if (flags == UNITY_ARRAY_TO_VAL) {
1428 ptr_exp = (UNITY_PTR_ATTRIBUTE const unsigned char *)expected;
1429 }
1430 }
1431}
1432
1433/*-----------------------------------------------*/
1434
1435static union {
1436 UNITY_INT8 i8;
1437 UNITY_INT16 i16;
1438 UNITY_INT32 i32;
1439#ifdef UNITY_SUPPORT_64
1440 UNITY_INT64 i64;
1441#endif
1442#ifndef UNITY_EXCLUDE_FLOAT
1443 float f;
1444#endif
1445#ifndef UNITY_EXCLUDE_DOUBLE
1446 double d;
1447#endif
1448} UnityQuickCompare;
1449
1450UNITY_INTERNAL_PTR UnityNumToPtr(const UNITY_INT num, const UNITY_UINT8 size) {
1451 switch (size) {
1452 case 1:
1453 UnityQuickCompare.i8 = (UNITY_INT8)num;
1454 return (UNITY_INTERNAL_PTR)(&UnityQuickCompare.i8);
1455
1456 case 2:
1457 UnityQuickCompare.i16 = (UNITY_INT16)num;
1458 return (UNITY_INTERNAL_PTR)(&UnityQuickCompare.i16);
1459
1460#ifdef UNITY_SUPPORT_64
1461 case 8:
1462 UnityQuickCompare.i64 = (UNITY_INT64)num;
1463 return (UNITY_INTERNAL_PTR)(&UnityQuickCompare.i64);
1464#endif
1465
1466 default: /* 4 bytes */
1467 UnityQuickCompare.i32 = (UNITY_INT32)num;
1468 return (UNITY_INTERNAL_PTR)(&UnityQuickCompare.i32);
1469 }
1470}
1471
1472#ifndef UNITY_EXCLUDE_FLOAT
1473/*-----------------------------------------------*/
1474UNITY_INTERNAL_PTR UnityFloatToPtr(const float num) {
1475 UnityQuickCompare.f = num;
1476 return (UNITY_INTERNAL_PTR)(&UnityQuickCompare.f);
1477}
1478#endif
1479
1480#ifndef UNITY_EXCLUDE_DOUBLE
1481/*-----------------------------------------------*/
1482UNITY_INTERNAL_PTR UnityDoubleToPtr(const double num) {
1483 UnityQuickCompare.d = num;
1484 return (UNITY_INTERNAL_PTR)(&UnityQuickCompare.d);
1485}
1486#endif
1487
1488/*-----------------------------------------------
1489 * printf helper function
1490 *-----------------------------------------------*/
1491#ifdef UNITY_INCLUDE_PRINT_FORMATTED
1492static void UnityPrintFVA(const char *format, va_list va) {
1493 const char *pch = format;
1494 if (pch != NULL) {
1495 while (*pch) {
1496 /* format identification character */
1497 if (*pch == '%') {
1498 pch++;
1499
1500 if (pch != NULL) {
1501 switch (*pch) {
1502 case 'd':
1503 case 'i': {
1504 const int number = va_arg(va, int);
1505 UnityPrintNumber((UNITY_INT)number);
1506 break;
1507 }
1508#ifndef UNITY_EXCLUDE_FLOAT_PRINT
1509 case 'f':
1510 case 'g': {
1511 const double number = va_arg(va, double);
1512 UnityPrintFloat((UNITY_DOUBLE)number);
1513 break;
1514 }
1515#endif
1516 case 'u': {
1517 const unsigned int number = va_arg(va, unsigned int);
1518 UnityPrintNumberUnsigned((UNITY_UINT)number);
1519 break;
1520 }
1521 case 'b': {
1522 const unsigned int number = va_arg(va, unsigned int);
1523 const UNITY_UINT mask = (UNITY_UINT)0 - (UNITY_UINT)1;
1524 UNITY_OUTPUT_CHAR('0');
1525 UNITY_OUTPUT_CHAR('b');
1526 UnityPrintMask(mask, (UNITY_UINT)number);
1527 break;
1528 }
1529 case 'x':
1530 case 'X':
1531 case 'p': {
1532 const unsigned int number = va_arg(va, unsigned int);
1533 UNITY_OUTPUT_CHAR('0');
1534 UNITY_OUTPUT_CHAR('x');
1535 UnityPrintNumberHex((UNITY_UINT)number, 8);
1536 break;
1537 }
1538 case 'c': {
1539 const int ch = va_arg(va, int);
1540 UnityPrintChar((const char *)&ch);
1541 break;
1542 }
1543 case 's': {
1544 const char *string = va_arg(va, const char *);
1545 UnityPrint(string);
1546 break;
1547 }
1548 case '%': {
1549 UnityPrintChar(pch);
1550 break;
1551 }
1552 default: {
1553 /* print the unknown format character */
1554 UNITY_OUTPUT_CHAR('%');
1555 UnityPrintChar(pch);
1556 break;
1557 }
1558 }
1559 }
1560 }
1561#ifdef UNITY_OUTPUT_COLOR
1562 /* print ANSI escape code */
1563 else if ((*pch == 27) && (*(pch + 1) == '[')) {
1564 pch += UnityPrintAnsiEscapeString(pch);
1565 continue;
1566 }
1567#endif
1568 else if (*pch == '\n') {
1569 UNITY_PRINT_EOL();
1570 } else {
1571 UnityPrintChar(pch);
1572 }
1573
1574 pch++;
1575 }
1576 }
1577}
1578
1579void UnityPrintF(const UNITY_LINE_TYPE line, const char *format, ...) {
1580 UnityTestResultsBegin(Unity.TestFile, line);
1581 UnityPrint("INFO");
1582 if (format != NULL) {
1583 UnityPrint(": ");
1584 va_list va;
1585 va_start(va, format);
1586 UnityPrintFVA(format, va);
1587 va_end(va);
1588 }
1589 UNITY_PRINT_EOL();
1590}
1591#endif /* ! UNITY_INCLUDE_PRINT_FORMATTED */
1592
1593/*-----------------------------------------------
1594 * Control Functions
1595 *-----------------------------------------------*/
1596
1597/*-----------------------------------------------*/
1598void UnityFail(const char *msg, const UNITY_LINE_TYPE line) {
1599 RETURN_IF_FAIL_OR_IGNORE;
1600
1601 UnityTestResultsBegin(Unity.TestFile, line);
1602 UnityPrint(UnityStrFail);
1603 if (msg != NULL) {
1604 UNITY_OUTPUT_CHAR(':');
1605
1606#ifdef UNITY_PRINT_TEST_CONTEXT
1607 UNITY_PRINT_TEST_CONTEXT();
1608#endif
1609#ifndef UNITY_EXCLUDE_DETAILS
1610 if (Unity.CurrentDetail1) {
1611 UnityPrint(UnityStrDetail1Name);
1612 UnityPrint(Unity.CurrentDetail1);
1613 if (Unity.CurrentDetail2) {
1614 UnityPrint(UnityStrDetail2Name);
1615 UnityPrint(Unity.CurrentDetail2);
1616 }
1617 UnityPrint(UnityStrSpacer);
1618 }
1619#endif
1620 if (msg[0] != ' ') {
1621 UNITY_OUTPUT_CHAR(' ');
1622 }
1623 UnityPrint(msg);
1624 }
1625
1626 UNITY_FAIL_AND_BAIL;
1627}
1628
1629/*-----------------------------------------------*/
1630void UnityIgnore(const char *msg, const UNITY_LINE_TYPE line) {
1631 RETURN_IF_FAIL_OR_IGNORE;
1632
1633 UnityTestResultsBegin(Unity.TestFile, line);
1634 UnityPrint(UnityStrIgnore);
1635 if (msg != NULL) {
1636 UNITY_OUTPUT_CHAR(':');
1637 UNITY_OUTPUT_CHAR(' ');
1638 UnityPrint(msg);
1639 }
1640 UNITY_IGNORE_AND_BAIL;
1641}
1642
1643/*-----------------------------------------------*/
1644void UnityMessage(const char *msg, const UNITY_LINE_TYPE line) {
1645 UnityTestResultsBegin(Unity.TestFile, line);
1646 UnityPrint("INFO");
1647 if (msg != NULL) {
1648 UNITY_OUTPUT_CHAR(':');
1649 UNITY_OUTPUT_CHAR(' ');
1650 UnityPrint(msg);
1651 }
1652 UNITY_PRINT_EOL();
1653}
1654
1655/*-----------------------------------------------*/
1656/* If we have not defined our own test runner, then include our default test
1657 * runner to make life easier */
1658#ifndef UNITY_SKIP_DEFAULT_RUNNER
1659void UnityDefaultTestRun(UnityTestFunction Func, const char *FuncName,
1660 const int FuncLineNum) {
1661 Unity.CurrentTestName = FuncName;
1662 Unity.CurrentTestLineNumber = (UNITY_LINE_TYPE)FuncLineNum;
1663 Unity.NumberOfTests++;
1664 UNITY_CLR_DETAILS();
1665 UNITY_EXEC_TIME_START();
1666 if (TEST_PROTECT()) {
1667 setUp();
1668 Func();
1669 }
1670 if (TEST_PROTECT()) {
1671 tearDown();
1672 }
1673 UNITY_EXEC_TIME_STOP();
1674 UnityConcludeTest();
1675}
1676#endif
1677
1678/*-----------------------------------------------*/
1679void UnitySetTestFile(const char *filename) { Unity.TestFile = filename; }
1680
1681/*-----------------------------------------------*/
1682void UnityBegin(const char *filename) {
1683 Unity.TestFile = filename;
1684 Unity.CurrentTestName = NULL;
1685 Unity.CurrentTestLineNumber = 0;
1686 Unity.NumberOfTests = 0;
1687 Unity.TestFailures = 0;
1688 Unity.TestIgnores = 0;
1689 Unity.CurrentTestFailed = 0;
1690 Unity.CurrentTestIgnored = 0;
1691
1692 UNITY_CLR_DETAILS();
1693 UNITY_OUTPUT_START();
1694}
1695
1696/*-----------------------------------------------*/
1697int UnityEnd(void) {
1698 UNITY_PRINT_EOL();
1699 UnityPrint(UnityStrBreaker);
1700 UNITY_PRINT_EOL();
1701 UnityPrintNumber((UNITY_INT)(Unity.NumberOfTests));
1702 UnityPrint(UnityStrResultsTests);
1703 UnityPrintNumber((UNITY_INT)(Unity.TestFailures));
1704 UnityPrint(UnityStrResultsFailures);
1705 UnityPrintNumber((UNITY_INT)(Unity.TestIgnores));
1706 UnityPrint(UnityStrResultsIgnored);
1707 UNITY_PRINT_EOL();
1708 if (Unity.TestFailures == 0U) {
1709 UnityPrint(UnityStrOk);
1710 } else {
1711 UnityPrint(UnityStrFail);
1712#ifdef UNITY_DIFFERENTIATE_FINAL_FAIL
1713 UNITY_OUTPUT_CHAR('E');
1714 UNITY_OUTPUT_CHAR('D');
1715#endif
1716 }
1717 UNITY_PRINT_EOL();
1718 UNITY_FLUSH_CALL();
1719 UNITY_OUTPUT_COMPLETE();
1720 return (int)(Unity.TestFailures);
1721}
1722
1723/*-----------------------------------------------
1724 * Command Line Argument Support
1725 *-----------------------------------------------*/
1726#ifdef UNITY_USE_COMMAND_LINE_ARGS
1727
1728char *UnityOptionIncludeNamed = NULL;
1729char *UnityOptionExcludeNamed = NULL;
1730int UnityVerbosity = 1;
1731
1732/*-----------------------------------------------*/
1733int UnityParseOptions(int argc, char **argv) {
1734 int i;
1735 UnityOptionIncludeNamed = NULL;
1736 UnityOptionExcludeNamed = NULL;
1737
1738 for (i = 1; i < argc; i++) {
1739 if (argv[i][0] == '-') {
1740 switch (argv[i][1]) {
1741 case 'l': /* list tests */
1742 return -1;
1743 case 'n': /* include tests with name including this string */
1744 case 'f': /* an alias for -n */
1745 if (argv[i][2] == '=') {
1746 UnityOptionIncludeNamed = &argv[i][3];
1747 } else if (++i < argc) {
1748 UnityOptionIncludeNamed = argv[i];
1749 } else {
1750 UnityPrint("ERROR: No Test String to Include Matches For");
1751 UNITY_PRINT_EOL();
1752 return 1;
1753 }
1754 break;
1755 case 'q': /* quiet */
1756 UnityVerbosity = 0;
1757 break;
1758 case 'v': /* verbose */
1759 UnityVerbosity = 2;
1760 break;
1761 case 'x': /* exclude tests with name including this string */
1762 if (argv[i][2] == '=') {
1763 UnityOptionExcludeNamed = &argv[i][3];
1764 } else if (++i < argc) {
1765 UnityOptionExcludeNamed = argv[i];
1766 } else {
1767 UnityPrint("ERROR: No Test String to Exclude Matches For");
1768 UNITY_PRINT_EOL();
1769 return 1;
1770 }
1771 break;
1772 default:
1773 UnityPrint("ERROR: Unknown Option ");
1774 UNITY_OUTPUT_CHAR(argv[i][1]);
1775 UNITY_PRINT_EOL();
1776 return 1;
1777 }
1778 }
1779 }
1780
1781 return 0;
1782}
1783
1784/*-----------------------------------------------*/
1785int IsStringInBiggerString(const char *longstring, const char *shortstring) {
1786 const char *lptr = longstring;
1787 const char *sptr = shortstring;
1788 const char *lnext = lptr;
1789
1790 if (*sptr == '*') {
1791 return 1;
1792 }
1793
1794 while (*lptr) {
1795 lnext = lptr + 1;
1796
1797 /* If they current bytes match, go on to the next bytes */
1798 while (*lptr && *sptr && (*lptr == *sptr)) {
1799 lptr++;
1800 sptr++;
1801
1802 /* We're done if we match the entire string or up to a wildcard */
1803 if (*sptr == '*')
1804 return 1;
1805 if (*sptr == ',')
1806 return 1;
1807 if (*sptr == '"')
1808 return 1;
1809 if (*sptr == '\'')
1810 return 1;
1811 if (*sptr == ':')
1812 return 2;
1813 if (*sptr == 0)
1814 return 1;
1815 }
1816
1817 /* Otherwise we start in the long pointer 1 character further and try again
1818 */
1819 lptr = lnext;
1820 sptr = shortstring;
1821 }
1822
1823 return 0;
1824}
1825
1826/*-----------------------------------------------*/
1827int UnityStringArgumentMatches(const char *str) {
1828 int retval;
1829 const char *ptr1;
1830 const char *ptr2;
1831 const char *ptrf;
1832
1833 /* Go through the options and get the substrings for matching one at a time */
1834 ptr1 = str;
1835 while (ptr1[0] != 0) {
1836 if ((ptr1[0] == '"') || (ptr1[0] == '\'')) {
1837 ptr1++;
1838 }
1839
1840 /* look for the start of the next partial */
1841 ptr2 = ptr1;
1842 ptrf = 0;
1843 do {
1844 ptr2++;
1845 if ((ptr2[0] == ':') && (ptr2[1] != 0) && (ptr2[0] != '\'') &&
1846 (ptr2[0] != '"') && (ptr2[0] != ',')) {
1847 ptrf = &ptr2[1];
1848 }
1849 } while ((ptr2[0] != 0) && (ptr2[0] != '\'') && (ptr2[0] != '"') &&
1850 (ptr2[0] != ','));
1851
1852 while ((ptr2[0] != 0) && ((ptr2[0] == ':') || (ptr2[0] == '\'') ||
1853 (ptr2[0] == '"') || (ptr2[0] == ','))) {
1854 ptr2++;
1855 }
1856
1857 /* done if complete filename match */
1858 retval = IsStringInBiggerString(Unity.TestFile, ptr1);
1859 if (retval == 1) {
1860 return retval;
1861 }
1862
1863 /* done if testname match after filename partial match */
1864 if ((retval == 2) && (ptrf != 0)) {
1865 if (IsStringInBiggerString(Unity.CurrentTestName, ptrf)) {
1866 return 1;
1867 }
1868 }
1869
1870 /* done if complete testname match */
1871 if (IsStringInBiggerString(Unity.CurrentTestName, ptr1) == 1) {
1872 return 1;
1873 }
1874
1875 ptr1 = ptr2;
1876 }
1877
1878 /* we couldn't find a match for any substrings */
1879 return 0;
1880}
1881
1882/*-----------------------------------------------*/
1883int UnityTestMatches(void) {
1884 /* Check if this test name matches the included test pattern */
1885 int retval;
1886 if (UnityOptionIncludeNamed) {
1887 retval = UnityStringArgumentMatches(UnityOptionIncludeNamed);
1888 } else {
1889 retval = 1;
1890 }
1891
1892 /* Check if this test name matches the excluded test pattern */
1893 if (UnityOptionExcludeNamed) {
1894 if (UnityStringArgumentMatches(UnityOptionExcludeNamed)) {
1895 retval = 0;
1896 }
1897 }
1898
1899 return retval;
1900}
1901
1902#endif /* UNITY_USE_COMMAND_LINE_ARGS */
1903/*-----------------------------------------------*/