Go to the documentation of this file.
7 #define UNITY_INCLUDE_SETUP_STUBS
12 #ifdef UNITY_OMIT_OUTPUT_CHAR_HEADER_DECLARATION
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
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";
45 static const char UnityStrPointless[] =
" You Asked Me To Compare Nothing, Which Was Pointless.";
48 #ifndef UNITY_EXCLUDE_FLOAT
79 if ((*pch <= 126) && (*pch >= 32))
95 #ifdef UNITY_OUTPUT_COLOR
97 else if (*pch == 27 && *(pch + 1) ==
'[')
99 while (*pch && *pch !=
'm')
128 if ((*pch <= 126) && (*pch >= 32))
180 if (number_to_print < 0)
213 char nibbles = nibbles_to_print;
214 if ((
unsigned)nibbles > (2 *
sizeof(
number)))
215 nibbles = 2 *
sizeof(
number);
220 nibble = (int)(
number >> (nibbles * 4)) & 0x0F;
240 if (current_bit &
mask)
255 current_bit = current_bit >> 1;
260 #ifndef UNITY_EXCLUDE_FLOAT_PRINT
284 int decimals, digits;
289 while (
number < 100000.0
f / 1e6f) {
number *= 1e6f; exponent -= 6; }
291 while (
number > 1000000.0
f * 1e6f) {
number /= 1e6f; exponent += 6; }
303 decimals = (exponent <= 0 && exponent >= -9) ? -exponent : 5;
304 exponent += decimals;
307 while (decimals > 0 &&
n % 10 == 0)
315 while (
n != 0 || digits < decimals + 1)
317 buf[digits++] = (char)(
'0' +
n % 10);
334 exponent = -exponent;
342 while (exponent != 0 || digits < 2)
344 buf[digits++] = (char)(
'0' + exponent % 10);
404 #ifndef UNITY_EXCLUDE_DETAILS
425 if (expected !=
NULL)
454 if (expected !=
NULL)
486 if (expected == actual)
return 0;
489 if (expected ==
NULL)
521 if ((
mask & expected) != (
mask & actual))
542 if (expected != actual)
566 if (threshold == actual) failed = 1;
593 #define UnityPrintPointlessAndBail() \
595 UnityTestResultsFailBegin(lineNumber); \
596 UnityPrint(UnityStrPointless); \
597 UnityAddMsgIfSpecified(msg); \
598 UNITY_FAIL_AND_BAIL; }
610 unsigned int length = style & 0xF;
614 if (num_elements == 0)
619 if (expected == actual)
return;
623 while ((elements > 0) && elements--)
637 #ifdef UNITY_SUPPORT_64
650 if (expect_val != actual_val)
678 #ifndef UNITY_EXCLUDE_FLOAT
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))
688 #ifndef UNITY_NAN_NOT_EQUAL_NAN
689 #define UNITY_NAN_CHECK isnan(expected) && isnan(actual)
691 #define UNITY_NAN_CHECK 0
694 #ifndef UNITY_EXCLUDE_FLOAT_PRINT
695 #define UNITY_PRINT_EXPECTED_AND_ACTUAL_FLOAT(expected, actual) \
697 UnityPrint(UnityStrExpected); \
698 UnityPrintFloat(expected); \
699 UnityPrint(UnityStrWas); \
700 UnityPrintFloat(actual); }
702 #define UNITY_PRINT_EXPECTED_AND_ACTUAL_FLOAT(expected, actual) \
703 UnityPrint(UnityStrDelta)
730 if (expected == actual)
return;
789 is_trait =
isinf(actual) && (actual > 0);
793 is_trait =
isinf(actual) && (actual < 0);
798 is_trait =
isnan(actual) ? 1 : 0;
812 if (is_trait != should_be_trait)
816 if (!should_be_trait)
820 #ifndef UNITY_EXCLUDE_FLOAT_PRINT
835 #ifndef UNITY_EXCLUDE_DOUBLE
860 if (expected == actual)
return;
866 if (!UnityDoublesWithin(*ptr_expected * UNITY_DOUBLE_PRECISION, *ptr_expected, *ptr_actual))
892 if (!UnityDoublesWithin(delta, expected, actual))
903 void UnityAssertDoubleSpecial(
const UNITY_DOUBLE actual,
919 is_trait =
isinf(actual) && (actual > 0);
923 is_trait =
isinf(actual) && (actual < 0);
928 is_trait =
isnan(actual) ? 1 : 0;
942 if (is_trait != should_be_trait)
946 if (!should_be_trait)
950 #ifndef UNITY_EXCLUDE_FLOAT_PRINT
976 if (actual > expected)
1014 if (expected && actual)
1016 for (
i = 0; expected[
i] || actual[
i];
i++)
1018 if (expected[
i] != actual[
i])
1027 if (expected != actual)
1054 if (expected && actual)
1056 for (
i = 0; (
i <
length) && (expected[
i] || actual[
i]);
i++)
1058 if (expected[
i] != actual[
i])
1067 if (expected != actual)
1084 const char** actual,
1092 const char* expd =
NULL;
1093 const char* act =
NULL;
1098 if (num_elements == 0)
1103 if ((
const void*)expected == (
const void*)actual)
1115 expd = (
const char*)expected;
1123 expd = ((
const char*
const*)expected)[j];
1129 for (
i = 0; expd[
i] || act[
i];
i++)
1131 if (expd[
i] != act[
i])
1149 if (num_elements > 1)
1158 }
while (++j < num_elements);
1177 if ((elements == 0) || (
length == 0))
1182 if (expected == actual)
return;
1191 if (*ptr_exp != *ptr_act)
1195 if (num_elements > 1)
1226 #ifdef UNITY_SUPPORT_64
1229 #ifndef UNITY_EXCLUDE_FLOAT
1232 #ifndef UNITY_EXCLUDE_DOUBLE
1249 #ifdef UNITY_SUPPORT_64
1260 #ifndef UNITY_EXCLUDE_FLOAT
1268 #ifndef UNITY_EXCLUDE_DOUBLE
1290 #ifndef UNITY_EXCLUDE_DETAILS
1384 #ifdef UNITY_DIFFERENTIATE_FINAL_FAIL
1397 #ifdef UNITY_USE_COMMAND_LINE_ARGS
1399 char* UnityOptionIncludeNamed =
NULL;
1400 char* UnityOptionExcludeNamed =
NULL;
1401 int UnityVerbosity = 1;
1403 int UnityParseOptions(
int argc,
char** argv)
1405 UnityOptionIncludeNamed =
NULL;
1406 UnityOptionExcludeNamed =
NULL;
1408 for (
int i = 1;
i < argc;
i++)
1410 if (argv[
i][0] ==
'-')
1418 if (argv[
i][2] ==
'=')
1419 UnityOptionIncludeNamed = &argv[
i][3];
1420 else if (++
i < argc)
1421 UnityOptionIncludeNamed = argv[
i];
1424 UnityPrint(
"ERROR: No Test String to Include Matches For");
1436 if (argv[
i][2] ==
'=')
1437 UnityOptionExcludeNamed = &argv[
i][3];
1438 else if (++
i < argc)
1439 UnityOptionExcludeNamed = argv[
i];
1442 UnityPrint(
"ERROR: No Test String to Exclude Matches For");
1459 int IsStringInBiggerString(
const char* longstring,
const char* shortstring)
1461 const char* lptr = longstring;
1462 const char* sptr = shortstring;
1463 const char* lnext = lptr;
1473 while (*lptr && *sptr && (*lptr == *sptr))
1500 int UnityStringArgumentMatches(
const char*
str)
1509 while (ptr1[0] != 0)
1511 if ((ptr1[0] ==
'"') || (ptr1[0] ==
'\''))
1520 if ((ptr2[0] ==
':') && (ptr2[1] != 0) && (ptr2[0] !=
'\'') && (ptr2[0] !=
'"') && (ptr2[0] !=
','))
1522 }
while ((ptr2[0] != 0) && (ptr2[0] !=
'\'') && (ptr2[0] !=
'"') && (ptr2[0] !=
','));
1523 while ((ptr2[0] != 0) && ((ptr2[0] ==
':') || (ptr2[0] ==
'\'') || (ptr2[0] ==
'"') || (ptr2[0] ==
',')))
1532 if ((retval == 2) && (ptrf != 0))
1549 int UnityTestMatches(
void)
1553 if (UnityOptionIncludeNamed)
1555 retval = UnityStringArgumentMatches(UnityOptionIncludeNamed);
1561 if (UnityOptionExcludeNamed)
1563 if (UnityStringArgumentMatches(UnityOptionExcludeNamed))
static const char UnityStrLt[]
void UnityAssertEqualNumber(const UNITY_INT expected, const UNITY_INT actual, const char *msg, const UNITY_LINE_TYPE lineNumber, const UNITY_DISPLAY_STYLE_T style)
void UnityPrintNumberHex(const UNITY_UINT number, const char nibbles_to_print)
static const char UnityStrOk[]
static void UnityAddMsgIfSpecified(const char *msg)
void UnityDefaultTestRun(UnityTestFunction Func, const char *FuncName, const int FuncLineNum)
static const char UnityStrInvalidFloatTrait[]
const char * CurrentDetail2
static const char UnityStrBreaker[]
#define UNITY_PTR_ATTRIBUTE
GLenum GLuint GLenum GLsizei length
void UnityAssertFloatsWithin(const UNITY_FLOAT delta, const UNITY_FLOAT expected, const UNITY_FLOAT actual, const char *msg, const UNITY_LINE_TYPE lineNumber)
#define UNITY_DISPLAY_RANGE_UINT
void UnityPrintFloat(const UNITY_DOUBLE input_number)
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)
void UnityPrintLen(const char *string, const UNITY_UINT32 length)
#define UNITY_DETAIL2_NAME
static void UnityPrintExpectedAndActualStringsLen(const char *expected, const char *actual, const UNITY_UINT32 length)
@ UNITY_DISPLAY_STYLE_HEX8
static const char UnityStrNot[]
static const char UnityStrNull[]
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)
static const char UnityStrDetail1Name[]
static const char UnityStrElement[]
GLsizei const GLchar *const * string
static void UnityTestResultsBegin(const char *file, const UNITY_LINE_TYPE line)
static int UnityFloatsWithin(UNITY_FLOAT delta, UNITY_FLOAT expected, UNITY_FLOAT actual)
const char UnityStrErr64[]
@ UNITY_FLOAT_IS_NOT_NEG_INF
void UnityIgnore(const char *msg, const UNITY_LINE_TYPE line)
static int Func(int i, int j)
const char UnityStrErrFloat[]
void UnityBegin(const char *filename)
unsigned char UNITY_UINT8
static const char UnityStrByte[]
static void UnityPrintExpectedAndActualStrings(const char *expected, const char *actual)
static const char UnityStrIgnore[]
static const char UnityStrNullPointerForActual[]
static union @22 UnityQuickCompare
unsigned int UNITY_UINT32
#define UNITY_DETAIL1_NAME
void(* UnityTestFunction)(void)
#define UnityPrintPointlessAndBail()
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)
static const char UnityStrPass[]
static const char UnityStrResultsTests[]
UNITY_COUNTER_TYPE CurrentTestIgnored
static const char UnityStrSpacer[]
static const char UnityStrResultsIgnored[]
static const char UnityStrGt[]
static const char UnityStrDelta[]
static const char UnityStrMemory[]
UNITY_COUNTER_TYPE CurrentTestFailed
static const char UnityStrInf[]
UNITY_LINE_TYPE CurrentTestLineNumber
struct UNITY_STORAGE_T Unity
void UnityAssertEqualStringLen(const char *expected, const char *actual, const UNITY_UINT32 length, const char *msg, const UNITY_LINE_TYPE lineNumber)
static int UnityIsOneArrayNull(UNITY_INTERNAL_PTR expected, UNITY_INTERNAL_PTR actual, const UNITY_LINE_TYPE lineNumber, const char *msg)
UNITY_INTERNAL_PTR UnityFloatToPtr(const float num)
UNITY_COUNTER_TYPE TestIgnores
void UnityPrintNumberUnsigned(const UNITY_UINT number)
GLenum GLuint GLenum GLsizei const GLchar * buf
UNITY_COUNTER_TYPE NumberOfTests
static const char UnityStrDetail2Name[]
#define UNITY_PRINT_EXPECTED_AND_ACTUAL_FLOAT(expected, actual)
static const char UnityStrResultsFailures[]
#define UNITY_OUTPUT_COMPLETE()
void UnityConcludeTest(void)
static const char UnityStrOrEqual[]
UNITY_FLOAT_TYPE UNITY_FLOAT
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)
#define UNITY_IGNORE_AND_BAIL
static const char UnityStrPointless[]
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)
static const char UnityStrWas[]
const char * CurrentDetail1
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)
#define UNITY_CLR_DETAILS()
#define UNITY_OUTPUT_START()
void UnityFail(const char *msg, const UNITY_LINE_TYPE line)
#define UNITY_INTERNAL_PTR
void UnityPrint(const char *string)
void UnityPrintNumber(const UNITY_INT number_to_print)
void UnityAssertEqualString(const char *expected, const char *actual, const char *msg, const UNITY_LINE_TYPE lineNumber)
UNITY_INTERNAL_PTR UnityNumToPtr(const UNITY_INT num, const UNITY_UINT8 size)
#define UNITY_FLUSH_CALL()
#define UNITY_FAIL_AND_BAIL
void UnityAssertBits(const UNITY_INT mask, const UNITY_INT expected, const UNITY_INT actual, const char *msg, const UNITY_LINE_TYPE lineNumber)
void UnityPrintNumberByStyle(const UNITY_INT number, const UNITY_DISPLAY_STYLE_T style)
static const char UnityStrFail[]
static const char UnityStrNegInf[]
static void UnityTestResultsFailBegin(const UNITY_LINE_TYPE line)
#define RETURN_IF_FAIL_OR_IGNORE
UNITY_COUNTER_TYPE TestFailures
void UnityPrintMask(const UNITY_UINT mask, const UNITY_UINT number)
static const char UnityStrNullPointerForExpected[]
#define UNITY_FLOAT_OR_DOUBLE_WITHIN(delta, expected, actual, diff)
const char * CurrentTestName
#define UNITY_FLOAT_PRECISION
static const char UnityStrDet[]
void UnityAssertFloatSpecial(const UNITY_FLOAT actual, const char *msg, const UNITY_LINE_TYPE lineNumber, const UNITY_FLOAT_TRAIT_T style)
#define UNITY_PRINT_EOL()
static const char UnityStrNaN[]
const char UnityStrErrDouble[]
static const char UnityStrExpected[]
#define UNITY_OUTPUT_CHAR(a)
#define UNITY_DISPLAY_RANGE_INT
enum UNITY_FLOAT_TRAIT UNITY_FLOAT_TRAIT_T
libaditof
Author(s):
autogenerated on Wed May 21 2025 02:07:00