unity.c
Go to the documentation of this file.
1 /* =========================================================================
2  Unity Project - A Test Framework for C
3  Copyright (c) 2007-14 Mike Karlesky, Mark VanderVoord, Greg Williams
4  [Released under MIT License. Please refer to license.txt for details]
5 ============================================================================ */
6 
7 #define UNITY_INCLUDE_SETUP_STUBS
8 #include "unity.h"
9 #include <stddef.h>
10 
11 /* If omitted from header, declare overrideable prototypes here so they're ready for use */
12 #ifdef UNITY_OMIT_OUTPUT_CHAR_HEADER_DECLARATION
13 void UNITY_OUTPUT_CHAR(int);
14 #endif
15 
16 /* Helpful macros for us to use here in Assert functions */
17 #define UNITY_FAIL_AND_BAIL { Unity.CurrentTestFailed = 1; TEST_ABORT(); }
18 #define UNITY_IGNORE_AND_BAIL { Unity.CurrentTestIgnored = 1; TEST_ABORT(); }
19 #define RETURN_IF_FAIL_OR_IGNORE if (Unity.CurrentTestFailed || Unity.CurrentTestIgnored) return
20 
22 
23 #ifdef UNITY_OUTPUT_COLOR
24 static const char UnityStrOk[] = "\033[42mOK\033[00m";
25 static const char UnityStrPass[] = "\033[42mPASS\033[00m";
26 static const char UnityStrFail[] = "\033[41mFAIL\033[00m";
27 static const char UnityStrIgnore[] = "\033[43mIGNORE\033[00m";
28 #else
29 static const char UnityStrOk[] = "OK";
30 static const char UnityStrPass[] = "PASS";
31 static const char UnityStrFail[] = "FAIL";
32 static const char UnityStrIgnore[] = "IGNORE";
33 #endif
34 static const char UnityStrNull[] = "NULL";
35 static const char UnityStrSpacer[] = ". ";
36 static const char UnityStrExpected[] = " Expected ";
37 static const char UnityStrWas[] = " Was ";
38 static const char UnityStrGt[] = " to be greater than ";
39 static const char UnityStrLt[] = " to be less than ";
40 static const char UnityStrOrEqual[] = "or equal to ";
41 static const char UnityStrElement[] = " Element ";
42 static const char UnityStrByte[] = " Byte ";
43 static const char UnityStrMemory[] = " Memory Mismatch.";
44 static const char UnityStrDelta[] = " Values Not Within Delta ";
45 static const char UnityStrPointless[] = " You Asked Me To Compare Nothing, Which Was Pointless.";
46 static const char UnityStrNullPointerForExpected[] = " Expected pointer to be NULL";
47 static const char UnityStrNullPointerForActual[] = " Actual pointer was NULL";
48 #ifndef UNITY_EXCLUDE_FLOAT
49 static const char UnityStrNot[] = "Not ";
50 static const char UnityStrInf[] = "Infinity";
51 static const char UnityStrNegInf[] = "Negative Infinity";
52 static const char UnityStrNaN[] = "NaN";
53 static const char UnityStrDet[] = "Determinate";
54 static const char UnityStrInvalidFloatTrait[] = "Invalid Float Trait";
55 #endif
56 const char UnityStrErrFloat[] = "Unity Floating Point Disabled";
57 const char UnityStrErrDouble[] = "Unity Double Precision Disabled";
58 const char UnityStrErr64[] = "Unity 64-bit Support Disabled";
59 static const char UnityStrBreaker[] = "-----------------------";
60 static const char UnityStrResultsTests[] = " Tests ";
61 static const char UnityStrResultsFailures[] = " Failures ";
62 static const char UnityStrResultsIgnored[] = " Ignored ";
63 static const char UnityStrDetail1Name[] = UNITY_DETAIL1_NAME " ";
64 static const char UnityStrDetail2Name[] = " " UNITY_DETAIL2_NAME " ";
65 
66 /*-----------------------------------------------
67  * Pretty Printers & Test Result Output Handlers
68  *-----------------------------------------------*/
69 
70 void UnityPrint(const char* string)
71 {
72  const char* pch = string;
73 
74  if (pch != NULL)
75  {
76  while (*pch)
77  {
78  /* printable characters plus CR & LF are printed */
79  if ((*pch <= 126) && (*pch >= 32))
80  {
81  UNITY_OUTPUT_CHAR(*pch);
82  }
83  /* write escaped carriage returns */
84  else if (*pch == 13)
85  {
86  UNITY_OUTPUT_CHAR('\\');
87  UNITY_OUTPUT_CHAR('r');
88  }
89  /* write escaped line feeds */
90  else if (*pch == 10)
91  {
92  UNITY_OUTPUT_CHAR('\\');
93  UNITY_OUTPUT_CHAR('n');
94  }
95 #ifdef UNITY_OUTPUT_COLOR
96  /* print ANSI escape code */
97  else if (*pch == 27 && *(pch + 1) == '[')
98  {
99  while (*pch && *pch != 'm')
100  {
101  UNITY_OUTPUT_CHAR(*pch);
102  pch++;
103  }
104  UNITY_OUTPUT_CHAR('m');
105  }
106 #endif
107  /* unprintable characters are shown as codes */
108  else
109  {
110  UNITY_OUTPUT_CHAR('\\');
111  UNITY_OUTPUT_CHAR('x');
113  }
114  pch++;
115  }
116  }
117 }
118 
119 void UnityPrintLen(const char* string, const UNITY_UINT32 length)
120 {
121  const char* pch = string;
122 
123  if (pch != NULL)
124  {
125  while (*pch && (UNITY_UINT32)(pch - string) < length)
126  {
127  /* printable characters plus CR & LF are printed */
128  if ((*pch <= 126) && (*pch >= 32))
129  {
130  UNITY_OUTPUT_CHAR(*pch);
131  }
132  /* write escaped carriage returns */
133  else if (*pch == 13)
134  {
135  UNITY_OUTPUT_CHAR('\\');
136  UNITY_OUTPUT_CHAR('r');
137  }
138  /* write escaped line feeds */
139  else if (*pch == 10)
140  {
141  UNITY_OUTPUT_CHAR('\\');
142  UNITY_OUTPUT_CHAR('n');
143  }
144  /* unprintable characters are shown as codes */
145  else
146  {
147  UNITY_OUTPUT_CHAR('\\');
148  UNITY_OUTPUT_CHAR('x');
150  }
151  pch++;
152  }
153  }
154 }
155 
156 /*-----------------------------------------------*/
158 {
160  {
162  }
164  {
166  }
167  else
168  {
169  UNITY_OUTPUT_CHAR('0');
170  UNITY_OUTPUT_CHAR('x');
171  UnityPrintNumberHex((UNITY_UINT)number, (char)((style & 0xF) * 2));
172  }
173 }
174 
175 /*-----------------------------------------------*/
176 void UnityPrintNumber(const UNITY_INT number_to_print)
177 {
178  UNITY_UINT number = (UNITY_UINT)number_to_print;
179 
180  if (number_to_print < 0)
181  {
182  /* A negative number, including MIN negative */
183  UNITY_OUTPUT_CHAR('-');
184  number = (UNITY_UINT)(-number_to_print);
185  }
187 }
188 
189 /*-----------------------------------------------
190  * basically do an itoa using as little ram as possible */
192 {
193  UNITY_UINT divisor = 1;
194 
195  /* figure out initial divisor */
196  while (number / divisor > 9)
197  {
198  divisor *= 10;
199  }
200 
201  /* now mod and print, then divide divisor */
202  do
203  {
204  UNITY_OUTPUT_CHAR((char)('0' + (number / divisor % 10)));
205  divisor /= 10;
206  } while (divisor > 0);
207 }
208 
209 /*-----------------------------------------------*/
210 void UnityPrintNumberHex(const UNITY_UINT number, const char nibbles_to_print)
211 {
212  int nibble;
213  char nibbles = nibbles_to_print;
214  if ((unsigned)nibbles > (2 * sizeof(number)))
215  nibbles = 2 * sizeof(number);
216 
217  while (nibbles > 0)
218  {
219  nibbles--;
220  nibble = (int)(number >> (nibbles * 4)) & 0x0F;
221  if (nibble <= 9)
222  {
223  UNITY_OUTPUT_CHAR((char)('0' + nibble));
224  }
225  else
226  {
227  UNITY_OUTPUT_CHAR((char)('A' - 10 + nibble));
228  }
229  }
230 }
231 
232 /*-----------------------------------------------*/
234 {
235  UNITY_UINT current_bit = (UNITY_UINT)1 << (UNITY_INT_WIDTH - 1);
236  UNITY_INT32 i;
237 
238  for (i = 0; i < UNITY_INT_WIDTH; i++)
239  {
240  if (current_bit & mask)
241  {
242  if (current_bit & number)
243  {
244  UNITY_OUTPUT_CHAR('1');
245  }
246  else
247  {
248  UNITY_OUTPUT_CHAR('0');
249  }
250  }
251  else
252  {
253  UNITY_OUTPUT_CHAR('X');
254  }
255  current_bit = current_bit >> 1;
256  }
257 }
258 
259 /*-----------------------------------------------*/
260 #ifndef UNITY_EXCLUDE_FLOAT_PRINT
261 /* This function prints a floating-point value in a format similar to
262  * printf("%.6g"). It can work with either single- or double-precision,
263  * but for simplicity, it prints only 6 significant digits in either case.
264  * Printing more than 6 digits accurately is hard (at least in the single-
265  * precision case) and isn't attempted here. */
266 void UnityPrintFloat(const UNITY_DOUBLE input_number)
267 {
268  UNITY_DOUBLE number = input_number;
269 
270  /* print minus sign (including for negative zero) */
271  if (number < 0.0f || (number == 0.0f && 1.0f / number < 0.0f))
272  {
273  UNITY_OUTPUT_CHAR('-');
274  number = -number;
275  }
276 
277  /* handle zero, NaN, and +/- infinity */
278  if (number == 0.0f) UnityPrint("0");
279  else if (isnan(number)) UnityPrint("nan");
280  else if (isinf(number)) UnityPrint("inf");
281  else
282  {
283  int exponent = 0;
284  int decimals, digits;
285  UNITY_INT32 n;
286  char buf[16];
287 
288  /* scale up or down by powers of 10 */
289  while (number < 100000.0f / 1e6f) { number *= 1e6f; exponent -= 6; }
290  while (number < 100000.0f) { number *= 10.0f; exponent--; }
291  while (number > 1000000.0f * 1e6f) { number /= 1e6f; exponent += 6; }
292  while (number > 1000000.0f) { number /= 10.0f; exponent++; }
293 
294  /* round to nearest integer */
295  n = ((UNITY_INT32)(number + number) + 1) / 2;
296  if (n > 999999)
297  {
298  n = 100000;
299  exponent++;
300  }
301 
302  /* determine where to place decimal point */
303  decimals = (exponent <= 0 && exponent >= -9) ? -exponent : 5;
304  exponent += decimals;
305 
306  /* truncate trailing zeroes after decimal point */
307  while (decimals > 0 && n % 10 == 0)
308  {
309  n /= 10;
310  decimals--;
311  }
312 
313  /* build up buffer in reverse order */
314  digits = 0;
315  while (n != 0 || digits < decimals + 1)
316  {
317  buf[digits++] = (char)('0' + n % 10);
318  n /= 10;
319  }
320  while (digits > 0)
321  {
322  if(digits == decimals) UNITY_OUTPUT_CHAR('.');
323  UNITY_OUTPUT_CHAR(buf[--digits]);
324  }
325 
326  /* print exponent if needed */
327  if (exponent != 0)
328  {
329  UNITY_OUTPUT_CHAR('e');
330 
331  if(exponent < 0)
332  {
333  UNITY_OUTPUT_CHAR('-');
334  exponent = -exponent;
335  }
336  else
337  {
338  UNITY_OUTPUT_CHAR('+');
339  }
340 
341  digits = 0;
342  while (exponent != 0 || digits < 2)
343  {
344  buf[digits++] = (char)('0' + exponent % 10);
345  exponent /= 10;
346  }
347  while (digits > 0)
348  {
349  UNITY_OUTPUT_CHAR(buf[--digits]);
350  }
351  }
352  }
353 }
354 #endif /* ! UNITY_EXCLUDE_FLOAT_PRINT */
355 
356 /*-----------------------------------------------*/
357 static void UnityTestResultsBegin(const char* file, const UNITY_LINE_TYPE line)
358 {
359  UnityPrint(file);
360  UNITY_OUTPUT_CHAR(':');
362  UNITY_OUTPUT_CHAR(':');
364  UNITY_OUTPUT_CHAR(':');
365 }
366 
367 /*-----------------------------------------------*/
369 {
372  UNITY_OUTPUT_CHAR(':');
373 }
374 
375 /*-----------------------------------------------*/
377 {
379  {
380  Unity.TestIgnores++;
381  }
382  else if (!Unity.CurrentTestFailed)
383  {
386  }
387  else
388  {
390  }
391 
394  UNITY_PRINT_EOL();
396 }
397 
398 /*-----------------------------------------------*/
399 static void UnityAddMsgIfSpecified(const char* msg)
400 {
401  if (msg)
402  {
404 #ifndef UNITY_EXCLUDE_DETAILS
405  if (Unity.CurrentDetail1)
406  {
409  if (Unity.CurrentDetail2)
410  {
413  }
415  }
416 #endif
417  UnityPrint(msg);
418  }
419 }
420 
421 /*-----------------------------------------------*/
422 static void UnityPrintExpectedAndActualStrings(const char* expected, const char* actual)
423 {
425  if (expected != NULL)
426  {
427  UNITY_OUTPUT_CHAR('\'');
428  UnityPrint(expected);
429  UNITY_OUTPUT_CHAR('\'');
430  }
431  else
432  {
434  }
436  if (actual != NULL)
437  {
438  UNITY_OUTPUT_CHAR('\'');
439  UnityPrint(actual);
440  UNITY_OUTPUT_CHAR('\'');
441  }
442  else
443  {
445  }
446 }
447 
448 /*-----------------------------------------------*/
449 static void UnityPrintExpectedAndActualStringsLen(const char* expected,
450  const char* actual,
451  const UNITY_UINT32 length)
452 {
454  if (expected != NULL)
455  {
456  UNITY_OUTPUT_CHAR('\'');
457  UnityPrintLen(expected, length);
458  UNITY_OUTPUT_CHAR('\'');
459  }
460  else
461  {
463  }
465  if (actual != NULL)
466  {
467  UNITY_OUTPUT_CHAR('\'');
468  UnityPrintLen(actual, length);
469  UNITY_OUTPUT_CHAR('\'');
470  }
471  else
472  {
474  }
475 }
476 
477 /*-----------------------------------------------
478  * Assertion & Control Helpers
479  *-----------------------------------------------*/
480 
482  UNITY_INTERNAL_PTR actual,
483  const UNITY_LINE_TYPE lineNumber,
484  const char* msg)
485 {
486  if (expected == actual) return 0; /* Both are NULL or same pointer */
487 
488  /* print and return true if just expected is NULL */
489  if (expected == NULL)
490  {
491  UnityTestResultsFailBegin(lineNumber);
494  return 1;
495  }
496 
497  /* print and return true if just actual is NULL */
498  if (actual == NULL)
499  {
500  UnityTestResultsFailBegin(lineNumber);
503  return 1;
504  }
505 
506  return 0; /* return false if neither is NULL */
507 }
508 
509 /*-----------------------------------------------
510  * Assertion Functions
511  *-----------------------------------------------*/
512 
514  const UNITY_INT expected,
515  const UNITY_INT actual,
516  const char* msg,
517  const UNITY_LINE_TYPE lineNumber)
518 {
520 
521  if ((mask & expected) != (mask & actual))
522  {
523  UnityTestResultsFailBegin(lineNumber);
530  }
531 }
532 
533 /*-----------------------------------------------*/
534 void UnityAssertEqualNumber(const UNITY_INT expected,
535  const UNITY_INT actual,
536  const char* msg,
537  const UNITY_LINE_TYPE lineNumber,
538  const UNITY_DISPLAY_STYLE_T style)
539 {
541 
542  if (expected != actual)
543  {
544  UnityTestResultsFailBegin(lineNumber);
546  UnityPrintNumberByStyle(expected, style);
548  UnityPrintNumberByStyle(actual, style);
551  }
552 }
553 
554 /*-----------------------------------------------*/
556  const UNITY_INT actual,
557  const UNITY_COMPARISON_T compare,
558  const char *msg,
559  const UNITY_LINE_TYPE lineNumber,
560  const UNITY_DISPLAY_STYLE_T style)
561 {
562  int failed = 0;
564 
565  if (threshold == actual && compare & UNITY_EQUAL_TO) return;
566  if (threshold == actual) failed = 1;
567 
569  {
570  if (actual > threshold && compare & UNITY_SMALLER_THAN) failed = 1;
571  if (actual < threshold && compare & UNITY_GREATER_THAN) failed = 1;
572  }
573  else /* UINT or HEX */
574  {
575  if ((UNITY_UINT)actual > (UNITY_UINT)threshold && compare & UNITY_SMALLER_THAN) failed = 1;
576  if ((UNITY_UINT)actual < (UNITY_UINT)threshold && compare & UNITY_GREATER_THAN) failed = 1;
577  }
578 
579  if (failed)
580  {
581  UnityTestResultsFailBegin(lineNumber);
583  UnityPrintNumberByStyle(actual, style);
584  if (compare & UNITY_GREATER_THAN) UnityPrint(UnityStrGt);
585  if (compare & UNITY_SMALLER_THAN) UnityPrint(UnityStrLt);
586  if (compare & UNITY_EQUAL_TO) UnityPrint(UnityStrOrEqual);
587  UnityPrintNumberByStyle(threshold, style);
590  }
591 }
592 
593 #define UnityPrintPointlessAndBail() \
594 { \
595  UnityTestResultsFailBegin(lineNumber); \
596  UnityPrint(UnityStrPointless); \
597  UnityAddMsgIfSpecified(msg); \
598  UNITY_FAIL_AND_BAIL; }
599 
600 /*-----------------------------------------------*/
602  UNITY_INTERNAL_PTR actual,
603  const UNITY_UINT32 num_elements,
604  const char* msg,
605  const UNITY_LINE_TYPE lineNumber,
606  const UNITY_DISPLAY_STYLE_T style,
607  const UNITY_FLAGS_T flags)
608 {
609  UNITY_UINT32 elements = num_elements;
610  unsigned int length = style & 0xF;
611 
613 
614  if (num_elements == 0)
615  {
617  }
618 
619  if (expected == actual) return; /* Both are NULL or same pointer */
620  if (UnityIsOneArrayNull(expected, actual, lineNumber, msg))
622 
623  while ((elements > 0) && elements--)
624  {
625  UNITY_INT expect_val;
626  UNITY_INT actual_val;
627  switch (length)
628  {
629  case 1:
630  expect_val = *(UNITY_PTR_ATTRIBUTE const UNITY_INT8*)expected;
631  actual_val = *(UNITY_PTR_ATTRIBUTE const UNITY_INT8*)actual;
632  break;
633  case 2:
634  expect_val = *(UNITY_PTR_ATTRIBUTE const UNITY_INT16*)expected;
635  actual_val = *(UNITY_PTR_ATTRIBUTE const UNITY_INT16*)actual;
636  break;
637 #ifdef UNITY_SUPPORT_64
638  case 8:
639  expect_val = *(UNITY_PTR_ATTRIBUTE const UNITY_INT64*)expected;
640  actual_val = *(UNITY_PTR_ATTRIBUTE const UNITY_INT64*)actual;
641  break;
642 #endif
643  default: /* length 4 bytes */
644  expect_val = *(UNITY_PTR_ATTRIBUTE const UNITY_INT32*)expected;
645  actual_val = *(UNITY_PTR_ATTRIBUTE const UNITY_INT32*)actual;
646  length = 4;
647  break;
648  }
649 
650  if (expect_val != actual_val)
651  {
652  if (style & UNITY_DISPLAY_RANGE_UINT && length < sizeof(expect_val))
653  { /* For UINT, remove sign extension (padding 1's) from signed type casts above */
654  UNITY_INT mask = 1;
655  mask = (mask << 8 * length) - 1;
656  expect_val &= mask;
657  actual_val &= mask;
658  }
659  UnityTestResultsFailBegin(lineNumber);
661  UnityPrintNumberUnsigned(num_elements - elements - 1);
663  UnityPrintNumberByStyle(expect_val, style);
665  UnityPrintNumberByStyle(actual_val, style);
668  }
670  {
671  expected = (UNITY_INTERNAL_PTR)(length + (const char*)expected);
672  }
673  actual = (UNITY_INTERNAL_PTR)(length + (const char*)actual);
674  }
675 }
676 
677 /*-----------------------------------------------*/
678 #ifndef UNITY_EXCLUDE_FLOAT
679 /* Wrap this define in a function with variable types as float or double */
680 #define UNITY_FLOAT_OR_DOUBLE_WITHIN(delta, expected, actual, diff) \
681  if (isinf(expected) && isinf(actual) && ((expected < 0) == (actual < 0))) return 1; \
682  if (UNITY_NAN_CHECK) return 1; \
683  diff = actual - expected; \
684  if (diff < 0) diff = -diff; \
685  if (delta < 0) delta = -delta; \
686  return !(isnan(diff) || isinf(diff) || (diff > delta))
687  /* This first part of this condition will catch any NaN or Infinite values */
688 #ifndef UNITY_NAN_NOT_EQUAL_NAN
689  #define UNITY_NAN_CHECK isnan(expected) && isnan(actual)
690 #else
691  #define UNITY_NAN_CHECK 0
692 #endif
693 
694 #ifndef UNITY_EXCLUDE_FLOAT_PRINT
695  #define UNITY_PRINT_EXPECTED_AND_ACTUAL_FLOAT(expected, actual) \
696  { \
697  UnityPrint(UnityStrExpected); \
698  UnityPrintFloat(expected); \
699  UnityPrint(UnityStrWas); \
700  UnityPrintFloat(actual); }
701 #else
702  #define UNITY_PRINT_EXPECTED_AND_ACTUAL_FLOAT(expected, actual) \
703  UnityPrint(UnityStrDelta)
704 #endif /* UNITY_EXCLUDE_FLOAT_PRINT */
705 
706 static int UnityFloatsWithin(UNITY_FLOAT delta, UNITY_FLOAT expected, UNITY_FLOAT actual)
707 {
708  UNITY_FLOAT diff;
709  UNITY_FLOAT_OR_DOUBLE_WITHIN(delta, expected, actual, diff);
710 }
711 
713  UNITY_PTR_ATTRIBUTE const UNITY_FLOAT* actual,
714  const UNITY_UINT32 num_elements,
715  const char* msg,
716  const UNITY_LINE_TYPE lineNumber,
717  const UNITY_FLAGS_T flags)
718 {
719  UNITY_UINT32 elements = num_elements;
720  UNITY_PTR_ATTRIBUTE const UNITY_FLOAT* ptr_expected = expected;
721  UNITY_PTR_ATTRIBUTE const UNITY_FLOAT* ptr_actual = actual;
722 
724 
725  if (elements == 0)
726  {
728  }
729 
730  if (expected == actual) return; /* Both are NULL or same pointer */
731  if (UnityIsOneArrayNull((UNITY_INTERNAL_PTR)expected, (UNITY_INTERNAL_PTR)actual, lineNumber, msg))
733 
734  while (elements--)
735  {
736  if (!UnityFloatsWithin(*ptr_expected * UNITY_FLOAT_PRECISION, *ptr_expected, *ptr_actual))
737  {
738  UnityTestResultsFailBegin(lineNumber);
740  UnityPrintNumberUnsigned(num_elements - elements - 1);
744  }
746  {
747  ptr_expected++;
748  }
749  ptr_actual++;
750  }
751 }
752 
753 /*-----------------------------------------------*/
755  const UNITY_FLOAT expected,
756  const UNITY_FLOAT actual,
757  const char* msg,
758  const UNITY_LINE_TYPE lineNumber)
759 {
761 
762 
763  if (!UnityFloatsWithin(delta, expected, actual))
764  {
765  UnityTestResultsFailBegin(lineNumber);
769  }
770 }
771 
772 /*-----------------------------------------------*/
774  const char* msg,
775  const UNITY_LINE_TYPE lineNumber,
776  const UNITY_FLOAT_TRAIT_T style)
777 {
778  const char* trait_names[] = {UnityStrInf, UnityStrNegInf, UnityStrNaN, UnityStrDet};
779  UNITY_INT should_be_trait = ((UNITY_INT)style & 1);
780  UNITY_INT is_trait = !should_be_trait;
781  UNITY_INT trait_index = (UNITY_INT)(style >> 1);
782 
784 
785  switch (style)
786  {
787  case UNITY_FLOAT_IS_INF:
789  is_trait = isinf(actual) && (actual > 0);
790  break;
793  is_trait = isinf(actual) && (actual < 0);
794  break;
795 
796  case UNITY_FLOAT_IS_NAN:
798  is_trait = isnan(actual) ? 1 : 0;
799  break;
800 
801  case UNITY_FLOAT_IS_DET: /* A determinate number is non infinite and not NaN. */
803  is_trait = !isinf(actual) && !isnan(actual);
804  break;
805 
806  default:
807  trait_index = 0;
808  trait_names[0] = UnityStrInvalidFloatTrait;
809  break;
810  }
811 
812  if (is_trait != should_be_trait)
813  {
814  UnityTestResultsFailBegin(lineNumber);
816  if (!should_be_trait)
818  UnityPrint(trait_names[trait_index]);
820 #ifndef UNITY_EXCLUDE_FLOAT_PRINT
821  UnityPrintFloat((UNITY_DOUBLE)actual);
822 #else
823  if (should_be_trait)
825  UnityPrint(trait_names[trait_index]);
826 #endif
829  }
830 }
831 
832 #endif /* not UNITY_EXCLUDE_FLOAT */
833 
834 /*-----------------------------------------------*/
835 #ifndef UNITY_EXCLUDE_DOUBLE
836 static int UnityDoublesWithin(UNITY_DOUBLE delta, UNITY_DOUBLE expected, UNITY_DOUBLE actual)
837 {
838  UNITY_DOUBLE diff;
839  UNITY_FLOAT_OR_DOUBLE_WITHIN(delta, expected, actual, diff);
840 }
841 
842 void UnityAssertEqualDoubleArray(UNITY_PTR_ATTRIBUTE const UNITY_DOUBLE* expected,
843  UNITY_PTR_ATTRIBUTE const UNITY_DOUBLE* actual,
844  const UNITY_UINT32 num_elements,
845  const char* msg,
846  const UNITY_LINE_TYPE lineNumber,
847  const UNITY_FLAGS_T flags)
848 {
849  UNITY_UINT32 elements = num_elements;
850  UNITY_PTR_ATTRIBUTE const UNITY_DOUBLE* ptr_expected = expected;
851  UNITY_PTR_ATTRIBUTE const UNITY_DOUBLE* ptr_actual = actual;
852 
854 
855  if (elements == 0)
856  {
858  }
859 
860  if (expected == actual) return; /* Both are NULL or same pointer */
861  if (UnityIsOneArrayNull((UNITY_INTERNAL_PTR)expected, (UNITY_INTERNAL_PTR)actual, lineNumber, msg))
863 
864  while (elements--)
865  {
866  if (!UnityDoublesWithin(*ptr_expected * UNITY_DOUBLE_PRECISION, *ptr_expected, *ptr_actual))
867  {
868  UnityTestResultsFailBegin(lineNumber);
870  UnityPrintNumberUnsigned(num_elements - elements - 1);
871  UNITY_PRINT_EXPECTED_AND_ACTUAL_FLOAT(*ptr_expected, *ptr_actual);
874  }
876  {
877  ptr_expected++;
878  }
879  ptr_actual++;
880  }
881 }
882 
883 /*-----------------------------------------------*/
884 void UnityAssertDoublesWithin(const UNITY_DOUBLE delta,
885  const UNITY_DOUBLE expected,
886  const UNITY_DOUBLE actual,
887  const char* msg,
888  const UNITY_LINE_TYPE lineNumber)
889 {
891 
892  if (!UnityDoublesWithin(delta, expected, actual))
893  {
894  UnityTestResultsFailBegin(lineNumber);
895  UNITY_PRINT_EXPECTED_AND_ACTUAL_FLOAT(expected, actual);
898  }
899 }
900 
901 /*-----------------------------------------------*/
902 
903 void UnityAssertDoubleSpecial(const UNITY_DOUBLE actual,
904  const char* msg,
905  const UNITY_LINE_TYPE lineNumber,
906  const UNITY_FLOAT_TRAIT_T style)
907 {
908  const char* trait_names[] = {UnityStrInf, UnityStrNegInf, UnityStrNaN, UnityStrDet};
909  UNITY_INT should_be_trait = ((UNITY_INT)style & 1);
910  UNITY_INT is_trait = !should_be_trait;
911  UNITY_INT trait_index = (UNITY_INT)(style >> 1);
912 
914 
915  switch (style)
916  {
917  case UNITY_FLOAT_IS_INF:
919  is_trait = isinf(actual) && (actual > 0);
920  break;
923  is_trait = isinf(actual) && (actual < 0);
924  break;
925 
926  case UNITY_FLOAT_IS_NAN:
928  is_trait = isnan(actual) ? 1 : 0;
929  break;
930 
931  case UNITY_FLOAT_IS_DET: /* A determinate number is non infinite and not NaN. */
933  is_trait = !isinf(actual) && !isnan(actual);
934  break;
935 
936  default:
937  trait_index = 0;
938  trait_names[0] = UnityStrInvalidFloatTrait;
939  break;
940  }
941 
942  if (is_trait != should_be_trait)
943  {
944  UnityTestResultsFailBegin(lineNumber);
946  if (!should_be_trait)
948  UnityPrint(trait_names[trait_index]);
950 #ifndef UNITY_EXCLUDE_FLOAT_PRINT
951  UnityPrintFloat(actual);
952 #else
953  if (should_be_trait)
955  UnityPrint(trait_names[trait_index]);
956 #endif
959  }
960 }
961 
962 #endif /* not UNITY_EXCLUDE_DOUBLE */
963 
964 /*-----------------------------------------------*/
966  const UNITY_INT expected,
967  const UNITY_INT actual,
968  const char* msg,
969  const UNITY_LINE_TYPE lineNumber,
970  const UNITY_DISPLAY_STYLE_T style)
971 {
973 
975  {
976  if (actual > expected)
977  Unity.CurrentTestFailed = (UNITY_UINT)((UNITY_UINT)(actual - expected) > delta);
978  else
979  Unity.CurrentTestFailed = (UNITY_UINT)((UNITY_UINT)(expected - actual) > delta);
980  }
981  else
982  {
983  if ((UNITY_UINT)actual > (UNITY_UINT)expected)
984  Unity.CurrentTestFailed = (UNITY_UINT)((UNITY_UINT)(actual - expected) > delta);
985  else
986  Unity.CurrentTestFailed = (UNITY_UINT)((UNITY_UINT)(expected - actual) > delta);
987  }
988 
990  {
991  UnityTestResultsFailBegin(lineNumber);
993  UnityPrintNumberByStyle((UNITY_INT)delta, style);
995  UnityPrintNumberByStyle(expected, style);
997  UnityPrintNumberByStyle(actual, style);
1000  }
1001 }
1002 
1003 /*-----------------------------------------------*/
1004 void UnityAssertEqualString(const char* expected,
1005  const char* actual,
1006  const char* msg,
1007  const UNITY_LINE_TYPE lineNumber)
1008 {
1009  UNITY_UINT32 i;
1010 
1012 
1013  /* if both pointers not null compare the strings */
1014  if (expected && actual)
1015  {
1016  for (i = 0; expected[i] || actual[i]; i++)
1017  {
1018  if (expected[i] != actual[i])
1019  {
1021  break;
1022  }
1023  }
1024  }
1025  else
1026  { /* handle case of one pointers being null (if both null, test should pass) */
1027  if (expected != actual)
1028  {
1030  }
1031  }
1032 
1034  {
1035  UnityTestResultsFailBegin(lineNumber);
1036  UnityPrintExpectedAndActualStrings(expected, actual);
1039  }
1040 }
1041 
1042 /*-----------------------------------------------*/
1043 void UnityAssertEqualStringLen(const char* expected,
1044  const char* actual,
1045  const UNITY_UINT32 length,
1046  const char* msg,
1047  const UNITY_LINE_TYPE lineNumber)
1048 {
1049  UNITY_UINT32 i;
1050 
1052 
1053  /* if both pointers not null compare the strings */
1054  if (expected && actual)
1055  {
1056  for (i = 0; (i < length) && (expected[i] || actual[i]); i++)
1057  {
1058  if (expected[i] != actual[i])
1059  {
1061  break;
1062  }
1063  }
1064  }
1065  else
1066  { /* handle case of one pointers being null (if both null, test should pass) */
1067  if (expected != actual)
1068  {
1070  }
1071  }
1072 
1074  {
1075  UnityTestResultsFailBegin(lineNumber);
1076  UnityPrintExpectedAndActualStringsLen(expected, actual, length);
1079  }
1080 }
1081 
1082 /*-----------------------------------------------*/
1084  const char** actual,
1085  const UNITY_UINT32 num_elements,
1086  const char* msg,
1087  const UNITY_LINE_TYPE lineNumber,
1088  const UNITY_FLAGS_T flags)
1089 {
1090  UNITY_UINT32 i = 0;
1091  UNITY_UINT32 j = 0;
1092  const char* expd = NULL;
1093  const char* act = NULL;
1094 
1096 
1097  /* if no elements, it's an error */
1098  if (num_elements == 0)
1099  {
1101  }
1102 
1103  if ((const void*)expected == (const void*)actual)
1104  {
1105  return; /* Both are NULL or same pointer */
1106  }
1107 
1108  if (UnityIsOneArrayNull((UNITY_INTERNAL_PTR)expected, (UNITY_INTERNAL_PTR)actual, lineNumber, msg))
1109  {
1111  }
1112 
1113  if (flags != UNITY_ARRAY_TO_ARRAY)
1114  {
1115  expd = (const char*)expected;
1116  }
1117 
1118  do
1119  {
1120  act = actual[j];
1121  if (flags == UNITY_ARRAY_TO_ARRAY)
1122  {
1123  expd = ((const char* const*)expected)[j];
1124  }
1125 
1126  /* if both pointers not null compare the strings */
1127  if (expd && act)
1128  {
1129  for (i = 0; expd[i] || act[i]; i++)
1130  {
1131  if (expd[i] != act[i])
1132  {
1134  break;
1135  }
1136  }
1137  }
1138  else
1139  { /* handle case of one pointers being null (if both null, test should pass) */
1140  if (expd != act)
1141  {
1143  }
1144  }
1145 
1147  {
1148  UnityTestResultsFailBegin(lineNumber);
1149  if (num_elements > 1)
1150  {
1153  }
1157  }
1158  } while (++j < num_elements);
1159 }
1160 
1161 /*-----------------------------------------------*/
1163  UNITY_INTERNAL_PTR actual,
1164  const UNITY_UINT32 length,
1165  const UNITY_UINT32 num_elements,
1166  const char* msg,
1167  const UNITY_LINE_TYPE lineNumber,
1168  const UNITY_FLAGS_T flags)
1169 {
1170  UNITY_PTR_ATTRIBUTE const unsigned char* ptr_exp = (UNITY_PTR_ATTRIBUTE const unsigned char*)expected;
1171  UNITY_PTR_ATTRIBUTE const unsigned char* ptr_act = (UNITY_PTR_ATTRIBUTE const unsigned char*)actual;
1172  UNITY_UINT32 elements = num_elements;
1174 
1176 
1177  if ((elements == 0) || (length == 0))
1178  {
1180  }
1181 
1182  if (expected == actual) return; /* Both are NULL or same pointer */
1183  if (UnityIsOneArrayNull(expected, actual, lineNumber, msg))
1185 
1186  while (elements--)
1187  {
1188  bytes = length;
1189  while (bytes--)
1190  {
1191  if (*ptr_exp != *ptr_act)
1192  {
1193  UnityTestResultsFailBegin(lineNumber);
1195  if (num_elements > 1)
1196  {
1198  UnityPrintNumberUnsigned(num_elements - elements - 1);
1199  }
1208  }
1209  ptr_exp++;
1210  ptr_act++;
1211  }
1212  if (flags == UNITY_ARRAY_TO_VAL)
1213  {
1214  ptr_exp = (UNITY_PTR_ATTRIBUTE const unsigned char*)expected;
1215  }
1216  }
1217 }
1218 
1219 /*-----------------------------------------------*/
1220 
1221 static union
1222 {
1226 #ifdef UNITY_SUPPORT_64
1227  UNITY_INT64 i64;
1228 #endif
1229 #ifndef UNITY_EXCLUDE_FLOAT
1230  float f;
1231 #endif
1232 #ifndef UNITY_EXCLUDE_DOUBLE
1233  double d;
1234 #endif
1236 
1238 {
1239  switch(size)
1240  {
1241  case 1:
1242  UnityQuickCompare.i8 = (UNITY_INT8)num;
1243  return (UNITY_INTERNAL_PTR)(&UnityQuickCompare.i8);
1244 
1245  case 2:
1246  UnityQuickCompare.i16 = (UNITY_INT16)num;
1247  return (UNITY_INTERNAL_PTR)(&UnityQuickCompare.i16);
1248 
1249 #ifdef UNITY_SUPPORT_64
1250  case 8:
1251  UnityQuickCompare.i64 = (UNITY_INT64)num;
1252  return (UNITY_INTERNAL_PTR)(&UnityQuickCompare.i64);
1253 #endif
1254  default: /* 4 bytes */
1255  UnityQuickCompare.i32 = (UNITY_INT32)num;
1256  return (UNITY_INTERNAL_PTR)(&UnityQuickCompare.i32);
1257  }
1258 }
1259 
1260 #ifndef UNITY_EXCLUDE_FLOAT
1262 {
1263  UnityQuickCompare.f = num;
1265 }
1266 #endif
1267 
1268 #ifndef UNITY_EXCLUDE_DOUBLE
1269 UNITY_INTERNAL_PTR UnityDoubleToPtr(const double num)
1270 {
1271  UnityQuickCompare.d = num;
1273 }
1274 #endif
1275 
1276 /*-----------------------------------------------
1277  * Control Functions
1278  *-----------------------------------------------*/
1279 
1280 void UnityFail(const char* msg, const UNITY_LINE_TYPE line)
1281 {
1283 
1286  if (msg != NULL)
1287  {
1288  UNITY_OUTPUT_CHAR(':');
1289 
1290 #ifndef UNITY_EXCLUDE_DETAILS
1291  if (Unity.CurrentDetail1)
1292  {
1295  if (Unity.CurrentDetail2)
1296  {
1299  }
1301  }
1302 #endif
1303  if (msg[0] != ' ')
1304  {
1305  UNITY_OUTPUT_CHAR(' ');
1306  }
1307  UnityPrint(msg);
1308  }
1309 
1311 }
1312 
1313 /*-----------------------------------------------*/
1314 void UnityIgnore(const char* msg, const UNITY_LINE_TYPE line)
1315 {
1317 
1320  if (msg != NULL)
1321  {
1322  UNITY_OUTPUT_CHAR(':');
1323  UNITY_OUTPUT_CHAR(' ');
1324  UnityPrint(msg);
1325  }
1327 }
1328 
1329 /*-----------------------------------------------*/
1330 void UnityDefaultTestRun(UnityTestFunction Func, const char* FuncName, const int FuncLineNum)
1331 {
1332  Unity.CurrentTestName = FuncName;
1334  Unity.NumberOfTests++;
1336  if (TEST_PROTECT())
1337  {
1338  setUp();
1339  Func();
1340  }
1341  if (TEST_PROTECT())
1342  {
1343  tearDown();
1344  }
1346 }
1347 
1348 /*-----------------------------------------------*/
1349 void UnityBegin(const char* filename)
1350 {
1351  Unity.TestFile = filename;
1354  Unity.NumberOfTests = 0;
1355  Unity.TestFailures = 0;
1356  Unity.TestIgnores = 0;
1359 
1362 }
1363 
1364 /*-----------------------------------------------*/
1365 int UnityEnd(void)
1366 {
1367  UNITY_PRINT_EOL();
1369  UNITY_PRINT_EOL();
1376  UNITY_PRINT_EOL();
1377  if (Unity.TestFailures == 0U)
1378  {
1380  }
1381  else
1382  {
1384 #ifdef UNITY_DIFFERENTIATE_FINAL_FAIL
1386 #endif
1387  }
1388  UNITY_PRINT_EOL();
1389  UNITY_FLUSH_CALL();
1391  return (int)(Unity.TestFailures);
1392 }
1393 
1394 /*-----------------------------------------------
1395  * Command Line Argument Support
1396  *-----------------------------------------------*/
1397 #ifdef UNITY_USE_COMMAND_LINE_ARGS
1398 
1399 char* UnityOptionIncludeNamed = NULL;
1400 char* UnityOptionExcludeNamed = NULL;
1401 int UnityVerbosity = 1;
1402 
1403 int UnityParseOptions(int argc, char** argv)
1404 {
1405  UnityOptionIncludeNamed = NULL;
1406  UnityOptionExcludeNamed = NULL;
1407 
1408  for (int i = 1; i < argc; i++)
1409  {
1410  if (argv[i][0] == '-')
1411  {
1412  switch (argv[i][1])
1413  {
1414  case 'l': /* list tests */
1415  return -1;
1416  case 'n': /* include tests with name including this string */
1417  case 'f': /* an alias for -n */
1418  if (argv[i][2] == '=')
1419  UnityOptionIncludeNamed = &argv[i][3];
1420  else if (++i < argc)
1421  UnityOptionIncludeNamed = argv[i];
1422  else
1423  {
1424  UnityPrint("ERROR: No Test String to Include Matches For");
1425  UNITY_PRINT_EOL();
1426  return 1;
1427  }
1428  break;
1429  case 'q': /* quiet */
1430  UnityVerbosity = 0;
1431  break;
1432  case 'v': /* verbose */
1433  UnityVerbosity = 2;
1434  break;
1435  case 'x': /* exclude tests with name including this string */
1436  if (argv[i][2] == '=')
1437  UnityOptionExcludeNamed = &argv[i][3];
1438  else if (++i < argc)
1439  UnityOptionExcludeNamed = argv[i];
1440  else
1441  {
1442  UnityPrint("ERROR: No Test String to Exclude Matches For");
1443  UNITY_PRINT_EOL();
1444  return 1;
1445  }
1446  break;
1447  default:
1448  UnityPrint("ERROR: Unknown Option ");
1449  UNITY_OUTPUT_CHAR(argv[i][1]);
1450  UNITY_PRINT_EOL();
1451  return 1;
1452  }
1453  }
1454  }
1455 
1456  return 0;
1457 }
1458 
1459 int IsStringInBiggerString(const char* longstring, const char* shortstring)
1460 {
1461  const char* lptr = longstring;
1462  const char* sptr = shortstring;
1463  const char* lnext = lptr;
1464 
1465  if (*sptr == '*')
1466  return 1;
1467 
1468  while (*lptr)
1469  {
1470  lnext = lptr + 1;
1471 
1472  /* If they current bytes match, go on to the next bytes */
1473  while (*lptr && *sptr && (*lptr == *sptr))
1474  {
1475  lptr++;
1476  sptr++;
1477 
1478  /* We're done if we match the entire string or up to a wildcard */
1479  if (*sptr == '*')
1480  return 1;
1481  if (*sptr == ',')
1482  return 1;
1483  if (*sptr == '"')
1484  return 1;
1485  if (*sptr == '\'')
1486  return 1;
1487  if (*sptr == ':')
1488  return 2;
1489  if (*sptr == 0)
1490  return 1;
1491  }
1492 
1493  /* Otherwise we start in the long pointer 1 character further and try again */
1494  lptr = lnext;
1495  sptr = shortstring;
1496  }
1497  return 0;
1498 }
1499 
1500 int UnityStringArgumentMatches(const char* str)
1501 {
1502  int retval;
1503  const char* ptr1;
1504  const char* ptr2;
1505  const char* ptrf;
1506 
1507  /* Go through the options and get the substrings for matching one at a time */
1508  ptr1 = str;
1509  while (ptr1[0] != 0)
1510  {
1511  if ((ptr1[0] == '"') || (ptr1[0] == '\''))
1512  ptr1++;
1513 
1514  /* look for the start of the next partial */
1515  ptr2 = ptr1;
1516  ptrf = 0;
1517  do
1518  {
1519  ptr2++;
1520  if ((ptr2[0] == ':') && (ptr2[1] != 0) && (ptr2[0] != '\'') && (ptr2[0] != '"') && (ptr2[0] != ','))
1521  ptrf = &ptr2[1];
1522  } while ((ptr2[0] != 0) && (ptr2[0] != '\'') && (ptr2[0] != '"') && (ptr2[0] != ','));
1523  while ((ptr2[0] != 0) && ((ptr2[0] == ':') || (ptr2[0] == '\'') || (ptr2[0] == '"') || (ptr2[0] == ',')))
1524  ptr2++;
1525 
1526  /* done if complete filename match */
1527  retval = IsStringInBiggerString(Unity.TestFile, ptr1);
1528  if (retval == 1)
1529  return retval;
1530 
1531  /* done if testname match after filename partial match */
1532  if ((retval == 2) && (ptrf != 0))
1533  {
1534  if (IsStringInBiggerString(Unity.CurrentTestName, ptrf))
1535  return 1;
1536  }
1537 
1538  /* done if complete testname match */
1539  if (IsStringInBiggerString(Unity.CurrentTestName, ptr1) == 1)
1540  return 1;
1541 
1542  ptr1 = ptr2;
1543  }
1544 
1545  /* we couldn't find a match for any substrings */
1546  return 0;
1547 }
1548 
1549 int UnityTestMatches(void)
1550 {
1551  /* Check if this test name matches the included test pattern */
1552  int retval;
1553  if (UnityOptionIncludeNamed)
1554  {
1555  retval = UnityStringArgumentMatches(UnityOptionIncludeNamed);
1556  }
1557  else
1558  retval = 1;
1559 
1560  /* Check if this test name matches the excluded test pattern */
1561  if (UnityOptionExcludeNamed)
1562  {
1563  if (UnityStringArgumentMatches(UnityOptionExcludeNamed))
1564  retval = 0;
1565  }
1566  return retval;
1567 }
1568 
1569 #endif /* UNITY_USE_COMMAND_LINE_ARGS */
1570 /*-----------------------------------------------*/
UNITY_FLOAT_IS_INF
@ UNITY_FLOAT_IS_INF
Definition: unity_internals.h:368
UNITY_INT_WIDTH
#define UNITY_INT_WIDTH
Definition: unity_internals.h:53
UnityStrLt
static const char UnityStrLt[]
Definition: unity.c:39
UnityAssertEqualNumber
void UnityAssertEqualNumber(const UNITY_INT expected, const UNITY_INT actual, const char *msg, const UNITY_LINE_TYPE lineNumber, const UNITY_DISPLAY_STYLE_T style)
Definition: unity.c:534
UnityPrintNumberHex
void UnityPrintNumberHex(const UNITY_UINT number, const char nibbles_to_print)
Definition: unity.c:210
UnityStrOk
static const char UnityStrOk[]
Definition: unity.c:29
UnityAddMsgIfSpecified
static void UnityAddMsgIfSpecified(const char *msg)
Definition: unity.c:399
UNITY_INT16
signed short UNITY_INT16
Definition: unity_internals.h:96
UNITY_FLOAT_IS_NEG_INF
@ UNITY_FLOAT_IS_NEG_INF
Definition: unity_internals.h:370
UnityDefaultTestRun
void UnityDefaultTestRun(UnityTestFunction Func, const char *FuncName, const int FuncLineNum)
Definition: unity.c:1330
UnityStrInvalidFloatTrait
static const char UnityStrInvalidFloatTrait[]
Definition: unity.c:54
UNITY_INT8
signed char UNITY_INT8
Definition: unity_internals.h:95
UNITY_STORAGE_T::CurrentDetail2
const char * CurrentDetail2
Definition: unity_internals.h:391
UnityStrBreaker
static const char UnityStrBreaker[]
Definition: unity.c:59
NULL
NULL
Definition: test_security_zap.cpp:405
UNITY_PTR_ATTRIBUTE
#define UNITY_PTR_ATTRIBUTE
Definition: unity_internals.h:158
length
GLenum GLuint GLenum GLsizei length
Definition: glcorearb.h:2695
UnityAssertFloatsWithin
void UnityAssertFloatsWithin(const UNITY_FLOAT delta, const UNITY_FLOAT expected, const UNITY_FLOAT actual, const char *msg, const UNITY_LINE_TYPE lineNumber)
Definition: unity.c:754
UNITY_DISPLAY_RANGE_UINT
#define UNITY_DISPLAY_RANGE_UINT
Definition: unity_internals.h:324
UnityPrintFloat
void UnityPrintFloat(const UNITY_DOUBLE input_number)
Definition: unity.c:266
UnityAssertEqualIntArray
void UnityAssertEqualIntArray(UNITY_INTERNAL_PTR expected, UNITY_INTERNAL_PTR actual, const UNITY_UINT32 num_elements, const char *msg, const UNITY_LINE_TYPE lineNumber, const UNITY_DISPLAY_STYLE_T style, const UNITY_FLAGS_T flags)
Definition: unity.c:601
UNITY_LINE_TYPE
#define UNITY_LINE_TYPE
Definition: unity_internals.h:293
UnityPrintLen
void UnityPrintLen(const char *string, const UNITY_UINT32 length)
Definition: unity.c:119
UNITY_DETAIL2_NAME
#define UNITY_DETAIL2_NAME
Definition: unity_internals.h:433
UNITY_INT32
signed int UNITY_INT32
Definition: unity_internals.h:97
UnityPrintExpectedAndActualStringsLen
static void UnityPrintExpectedAndActualStringsLen(const char *expected, const char *actual, const UNITY_UINT32 length)
Definition: unity.c:449
i8
UNITY_INT8 i8
Definition: unity.c:1223
UNITY_DISPLAY_STYLE_HEX8
@ UNITY_DISPLAY_STYLE_HEX8
Definition: unity_internals.h:345
UnityStrNot
static const char UnityStrNot[]
Definition: unity.c:49
UNITY_FLOAT_IS_NOT_DET
@ UNITY_FLOAT_IS_NOT_DET
Definition: unity_internals.h:373
UNITY_FLOAT_IS_NOT_NAN
@ UNITY_FLOAT_IS_NOT_NAN
Definition: unity_internals.h:371
UnityStrNull
static const char UnityStrNull[]
Definition: unity.c:34
isinf
#define isinf(d)
Definition: cJSON.c:74
UnityAssertGreaterOrLessOrEqualNumber
void UnityAssertGreaterOrLessOrEqualNumber(const UNITY_INT threshold, const UNITY_INT actual, const UNITY_COMPARISON_T compare, const char *msg, const UNITY_LINE_TYPE lineNumber, const UNITY_DISPLAY_STYLE_T style)
Definition: unity.c:555
UnityStrDetail1Name
static const char UnityStrDetail1Name[]
Definition: unity.c:63
UnityEnd
int UnityEnd(void)
Definition: unity.c:1365
UnityStrElement
static const char UnityStrElement[]
Definition: unity.c:41
string
GLsizei const GLchar *const * string
Definition: glcorearb.h:3083
UnityTestResultsBegin
static void UnityTestResultsBegin(const char *file, const UNITY_LINE_TYPE line)
Definition: unity.c:357
UnityFloatsWithin
static int UnityFloatsWithin(UNITY_FLOAT delta, UNITY_FLOAT expected, UNITY_FLOAT actual)
Definition: unity.c:706
UnityStrErr64
const char UnityStrErr64[]
Definition: unity.c:58
UNITY_FLOAT_IS_NOT_NEG_INF
@ UNITY_FLOAT_IS_NOT_NEG_INF
Definition: unity_internals.h:369
UnityIgnore
void UnityIgnore(const char *msg, const UNITY_LINE_TYPE line)
Definition: unity.c:1314
google::protobuf.internal::Func
static int Func(int i, int j)
Definition: src/google/protobuf/map_test.cc:981
UnityStrErrFloat
const char UnityStrErrFloat[]
Definition: unity.c:56
UnityBegin
void UnityBegin(const char *filename)
Definition: unity.c:1349
bytes
uint8 bytes[10]
Definition: coded_stream_unittest.cc:153
UNITY_UINT8
unsigned char UNITY_UINT8
Definition: unity_internals.h:92
flags
GLbitfield flags
Definition: glcorearb.h:3585
UnityStrByte
static const char UnityStrByte[]
Definition: unity.c:42
UNITY_STORAGE_T
Definition: unity_internals.h:385
UnityPrintExpectedAndActualStrings
static void UnityPrintExpectedAndActualStrings(const char *expected, const char *actual)
Definition: unity.c:422
UNITY_FLOAT_IS_NAN
@ UNITY_FLOAT_IS_NAN
Definition: unity_internals.h:372
tearDown
void tearDown(void)
Definition: test_ancillaries.cpp:17
i32
UNITY_INT32 i32
Definition: unity.c:1225
UnityStrIgnore
static const char UnityStrIgnore[]
Definition: unity.c:32
UnityStrNullPointerForActual
static const char UnityStrNullPointerForActual[]
Definition: unity.c:47
UnityQuickCompare
static union @22 UnityQuickCompare
UNITY_DOUBLE
UNITY_FLOAT UNITY_DOUBLE
Definition: unity_internals.h:222
UNITY_UINT32
unsigned int UNITY_UINT32
Definition: unity_internals.h:94
UNITY_DETAIL1_NAME
#define UNITY_DETAIL1_NAME
Definition: unity_internals.h:429
mask
GLint GLuint mask
Definition: glcorearb.h:2789
UnityTestFunction
void(* UnityTestFunction)(void)
Definition: unity_internals.h:321
UnityPrintPointlessAndBail
#define UnityPrintPointlessAndBail()
Definition: unity.c:593
UnityAssertEqualMemory
void UnityAssertEqualMemory(UNITY_INTERNAL_PTR expected, UNITY_INTERNAL_PTR actual, const UNITY_UINT32 length, const UNITY_UINT32 num_elements, const char *msg, const UNITY_LINE_TYPE lineNumber, const UNITY_FLAGS_T flags)
Definition: unity.c:1162
UnityStrPass
static const char UnityStrPass[]
Definition: unity.c:30
UnityStrResultsTests
static const char UnityStrResultsTests[]
Definition: unity.c:60
UNITY_STORAGE_T::CurrentTestIgnored
UNITY_COUNTER_TYPE CurrentTestIgnored
Definition: unity_internals.h:398
UnityStrSpacer
static const char UnityStrSpacer[]
Definition: unity.c:35
UnityStrResultsIgnored
static const char UnityStrResultsIgnored[]
Definition: unity.c:62
UnityStrGt
static const char UnityStrGt[]
Definition: unity.c:38
update_failure_list.str
str
Definition: update_failure_list.py:41
UnityStrDelta
static const char UnityStrDelta[]
Definition: unity.c:44
UnityStrMemory
static const char UnityStrMemory[]
Definition: unity.c:43
UNITY_STORAGE_T::CurrentTestFailed
UNITY_COUNTER_TYPE CurrentTestFailed
Definition: unity_internals.h:397
UNITY_FLOAT_IS_NOT_INF
@ UNITY_FLOAT_IS_NOT_INF
Definition: unity_internals.h:367
UnityStrInf
static const char UnityStrInf[]
Definition: unity.c:50
UNITY_STORAGE_T::CurrentTestLineNumber
UNITY_LINE_TYPE CurrentTestLineNumber
Definition: unity_internals.h:393
Unity
struct UNITY_STORAGE_T Unity
Definition: unity.c:21
UnityAssertEqualStringLen
void UnityAssertEqualStringLen(const char *expected, const char *actual, const UNITY_UINT32 length, const char *msg, const UNITY_LINE_TYPE lineNumber)
Definition: unity.c:1043
UnityIsOneArrayNull
static int UnityIsOneArrayNull(UNITY_INTERNAL_PTR expected, UNITY_INTERNAL_PTR actual, const UNITY_LINE_TYPE lineNumber, const char *msg)
Definition: unity.c:481
UnityFloatToPtr
UNITY_INTERNAL_PTR UnityFloatToPtr(const float num)
Definition: unity.c:1261
UNITY_STORAGE_T::TestIgnores
UNITY_COUNTER_TYPE TestIgnores
Definition: unity_internals.h:396
d
d
UNITY_DISPLAY_STYLE_T
UNITY_DISPLAY_STYLE_T
Definition: unity_internals.h:327
UnityPrintNumberUnsigned
void UnityPrintNumberUnsigned(const UNITY_UINT number)
Definition: unity.c:191
buf
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glcorearb.h:4175
TEST_PROTECT
#define TEST_PROTECT()
Definition: unity_internals.h:590
UNITY_STORAGE_T::NumberOfTests
UNITY_COUNTER_TYPE NumberOfTests
Definition: unity_internals.h:394
UNITY_GREATER_THAN
@ UNITY_GREATER_THAN
Definition: unity_internals.h:358
f
float f
Definition: unity.c:1230
UnityStrDetail2Name
static const char UnityStrDetail2Name[]
Definition: unity.c:64
UNITY_PRINT_EXPECTED_AND_ACTUAL_FLOAT
#define UNITY_PRINT_EXPECTED_AND_ACTUAL_FLOAT(expected, actual)
Definition: unity.c:695
n
GLdouble n
Definition: glcorearb.h:4153
UnityStrResultsFailures
static const char UnityStrResultsFailures[]
Definition: unity.c:61
UNITY_OUTPUT_COMPLETE
#define UNITY_OUTPUT_COMPLETE()
Definition: unity_internals.h:285
UnityConcludeTest
void UnityConcludeTest(void)
Definition: unity.c:376
setUp
void setUp(void)
Definition: test_ancillaries.cpp:13
i
int i
Definition: gmock-matchers_test.cc:764
UnityStrOrEqual
static const char UnityStrOrEqual[]
Definition: unity.c:40
UNITY_FLOAT
UNITY_FLOAT_TYPE UNITY_FLOAT
Definition: unity_internals.h:188
UnityAssertEqualFloatArray
void UnityAssertEqualFloatArray(UNITY_PTR_ATTRIBUTE const UNITY_FLOAT *expected, UNITY_PTR_ATTRIBUTE const UNITY_FLOAT *actual, const UNITY_UINT32 num_elements, const char *msg, const UNITY_LINE_TYPE lineNumber, const UNITY_FLAGS_T flags)
Definition: unity.c:712
unity.h
UNITY_IGNORE_AND_BAIL
#define UNITY_IGNORE_AND_BAIL
Definition: unity.c:18
UnityStrPointless
static const char UnityStrPointless[]
Definition: unity.c:45
UnityAssertEqualStringArray
void UnityAssertEqualStringArray(UNITY_INTERNAL_PTR expected, const char **actual, const UNITY_UINT32 num_elements, const char *msg, const UNITY_LINE_TYPE lineNumber, const UNITY_FLAGS_T flags)
Definition: unity.c:1083
UnityStrWas
static const char UnityStrWas[]
Definition: unity.c:37
UNITY_STORAGE_T::CurrentDetail1
const char * CurrentDetail1
Definition: unity_internals.h:390
UnityAssertNumbersWithin
void UnityAssertNumbersWithin(const UNITY_UINT delta, const UNITY_INT expected, const UNITY_INT actual, const char *msg, const UNITY_LINE_TYPE lineNumber, const UNITY_DISPLAY_STYLE_T style)
Definition: unity.c:965
UNITY_CLR_DETAILS
#define UNITY_CLR_DETAILS()
Definition: unity_internals.h:424
UNITY_OUTPUT_START
#define UNITY_OUTPUT_START()
Definition: unity_internals.h:281
UnityFail
void UnityFail(const char *msg, const UNITY_LINE_TYPE line)
Definition: unity.c:1280
UNITY_INT
UNITY_INT32 UNITY_INT
Definition: unity_internals.h:122
UNITY_INTERNAL_PTR
#define UNITY_INTERNAL_PTR
Definition: unity_internals.h:162
UnityPrint
void UnityPrint(const char *string)
Definition: unity.c:70
UNITY_EQUAL_TO
@ UNITY_EQUAL_TO
Definition: unity_internals.h:357
UnityPrintNumber
void UnityPrintNumber(const UNITY_INT number_to_print)
Definition: unity.c:176
size
GLsizeiptr size
Definition: glcorearb.h:2943
UnityAssertEqualString
void UnityAssertEqualString(const char *expected, const char *actual, const char *msg, const UNITY_LINE_TYPE lineNumber)
Definition: unity.c:1004
UnityNumToPtr
UNITY_INTERNAL_PTR UnityNumToPtr(const UNITY_INT num, const UNITY_UINT8 size)
Definition: unity.c:1237
UNITY_FLUSH_CALL
#define UNITY_FLUSH_CALL()
Definition: unity_internals.h:273
UNITY_FAIL_AND_BAIL
#define UNITY_FAIL_AND_BAIL
Definition: unity.c:17
UNITY_UINT
UNITY_UINT32 UNITY_UINT
Definition: unity_internals.h:121
UnityAssertBits
void UnityAssertBits(const UNITY_INT mask, const UNITY_INT expected, const UNITY_INT actual, const char *msg, const UNITY_LINE_TYPE lineNumber)
Definition: unity.c:513
UNITY_FLAGS_T
UNITY_FLAGS_T
Definition: unity_internals.h:379
UnityPrintNumberByStyle
void UnityPrintNumberByStyle(const UNITY_INT number, const UNITY_DISPLAY_STYLE_T style)
Definition: unity.c:157
UNITY_ARRAY_TO_VAL
@ UNITY_ARRAY_TO_VAL
Definition: unity_internals.h:381
UnityStrFail
static const char UnityStrFail[]
Definition: unity.c:31
UNITY_ARRAY_TO_ARRAY
@ UNITY_ARRAY_TO_ARRAY
Definition: unity_internals.h:382
UnityStrNegInf
static const char UnityStrNegInf[]
Definition: unity.c:51
UnityTestResultsFailBegin
static void UnityTestResultsFailBegin(const UNITY_LINE_TYPE line)
Definition: unity.c:368
divisor
GLuint divisor
Definition: glcorearb.h:3337
UNITY_STORAGE_T::TestFile
const char * TestFile
Definition: unity_internals.h:387
UNITY_SMALLER_THAN
@ UNITY_SMALLER_THAN
Definition: unity_internals.h:360
RETURN_IF_FAIL_OR_IGNORE
#define RETURN_IF_FAIL_OR_IGNORE
Definition: unity.c:19
f
GLfloat f
Definition: glcorearb.h:3964
UNITY_STORAGE_T::TestFailures
UNITY_COUNTER_TYPE TestFailures
Definition: unity_internals.h:395
UnityPrintMask
void UnityPrintMask(const UNITY_UINT mask, const UNITY_UINT number)
Definition: unity.c:233
UnityStrNullPointerForExpected
static const char UnityStrNullPointerForExpected[]
Definition: unity.c:46
UNITY_FLOAT_OR_DOUBLE_WITHIN
#define UNITY_FLOAT_OR_DOUBLE_WITHIN(delta, expected, actual, diff)
Definition: unity.c:680
UNITY_STORAGE_T::CurrentTestName
const char * CurrentTestName
Definition: unity_internals.h:388
UNITY_FLOAT_PRECISION
#define UNITY_FLOAT_PRECISION
Definition: unity_internals.h:183
UnityStrDet
static const char UnityStrDet[]
Definition: unity.c:53
i16
UNITY_INT16 i16
Definition: unity.c:1224
number
double number
Definition: cJSON.h:326
UnityAssertFloatSpecial
void UnityAssertFloatSpecial(const UNITY_FLOAT actual, const char *msg, const UNITY_LINE_TYPE lineNumber, const UNITY_FLOAT_TRAIT_T style)
Definition: unity.c:773
UNITY_PRINT_EOL
#define UNITY_PRINT_EOL()
Definition: unity_internals.h:277
UnityStrNaN
static const char UnityStrNaN[]
Definition: unity.c:52
isnan
#define isnan(d)
Definition: cJSON.c:77
UnityStrErrDouble
const char UnityStrErrDouble[]
Definition: unity.c:57
UNITY_COMPARISON_T
UNITY_COMPARISON_T
Definition: unity_internals.h:355
UnityStrExpected
static const char UnityStrExpected[]
Definition: unity.c:36
UNITY_OUTPUT_CHAR
#define UNITY_OUTPUT_CHAR(a)
Definition: unity_internals.h:246
UNITY_DISPLAY_RANGE_INT
#define UNITY_DISPLAY_RANGE_INT
Definition: unity_internals.h:323
UNITY_FLOAT_IS_DET
@ UNITY_FLOAT_IS_DET
Definition: unity_internals.h:374
UNITY_FLOAT_TRAIT_T
enum UNITY_FLOAT_TRAIT UNITY_FLOAT_TRAIT_T


libaditof
Author(s):
autogenerated on Wed May 21 2025 02:07:00