135375f98Sopenharmony_ci/* =========================================================================
235375f98Sopenharmony_ci    Unity Project - A Test Framework for C
335375f98Sopenharmony_ci    Copyright (c) 2007-21 Mike Karlesky, Mark VanderVoord, Greg Williams
435375f98Sopenharmony_ci    [Released under MIT License. Please refer to license.txt for details]
535375f98Sopenharmony_ci============================================================================ */
635375f98Sopenharmony_ci
735375f98Sopenharmony_ci#include "unity.h"
835375f98Sopenharmony_ci
935375f98Sopenharmony_ci#ifndef UNITY_PROGMEM
1035375f98Sopenharmony_ci#define UNITY_PROGMEM
1135375f98Sopenharmony_ci#endif
1235375f98Sopenharmony_ci
1335375f98Sopenharmony_ci/* If omitted from header, declare overrideable prototypes here so they're ready for use */
1435375f98Sopenharmony_ci#ifdef UNITY_OMIT_OUTPUT_CHAR_HEADER_DECLARATION
1535375f98Sopenharmony_civoid UNITY_OUTPUT_CHAR(int);
1635375f98Sopenharmony_ci#endif
1735375f98Sopenharmony_ci
1835375f98Sopenharmony_ci/* Helpful macros for us to use here in Assert functions */
1935375f98Sopenharmony_ci#define UNITY_FAIL_AND_BAIL         do { Unity.CurrentTestFailed  = 1; UNITY_OUTPUT_FLUSH(); TEST_ABORT(); } while (0)
2035375f98Sopenharmony_ci#define UNITY_IGNORE_AND_BAIL       do { Unity.CurrentTestIgnored = 1; UNITY_OUTPUT_FLUSH(); TEST_ABORT(); } while (0)
2135375f98Sopenharmony_ci#define RETURN_IF_FAIL_OR_IGNORE    do { if (Unity.CurrentTestFailed || Unity.CurrentTestIgnored) { TEST_ABORT(); } } while (0)
2235375f98Sopenharmony_ci
2335375f98Sopenharmony_cistruct UNITY_STORAGE_T Unity;
2435375f98Sopenharmony_ci
2535375f98Sopenharmony_ci#ifdef UNITY_OUTPUT_COLOR
2635375f98Sopenharmony_ciconst char UNITY_PROGMEM UnityStrOk[]                            = "\033[42mOK\033[0m";
2735375f98Sopenharmony_ciconst char UNITY_PROGMEM UnityStrPass[]                          = "\033[42mPASS\033[0m";
2835375f98Sopenharmony_ciconst char UNITY_PROGMEM UnityStrFail[]                          = "\033[41mFAIL\033[0m";
2935375f98Sopenharmony_ciconst char UNITY_PROGMEM UnityStrIgnore[]                        = "\033[43mIGNORE\033[0m";
3035375f98Sopenharmony_ci#else
3135375f98Sopenharmony_ciconst char UNITY_PROGMEM UnityStrOk[]                            = "OK";
3235375f98Sopenharmony_ciconst char UNITY_PROGMEM UnityStrPass[]                          = "PASS";
3335375f98Sopenharmony_ciconst char UNITY_PROGMEM UnityStrFail[]                          = "FAIL";
3435375f98Sopenharmony_ciconst char UNITY_PROGMEM UnityStrIgnore[]                        = "IGNORE";
3535375f98Sopenharmony_ci#endif
3635375f98Sopenharmony_cistatic const char UNITY_PROGMEM UnityStrNull[]                   = "NULL";
3735375f98Sopenharmony_cistatic const char UNITY_PROGMEM UnityStrSpacer[]                 = ". ";
3835375f98Sopenharmony_cistatic const char UNITY_PROGMEM UnityStrExpected[]               = " Expected ";
3935375f98Sopenharmony_cistatic const char UNITY_PROGMEM UnityStrWas[]                    = " Was ";
4035375f98Sopenharmony_cistatic const char UNITY_PROGMEM UnityStrGt[]                     = " to be greater than ";
4135375f98Sopenharmony_cistatic const char UNITY_PROGMEM UnityStrLt[]                     = " to be less than ";
4235375f98Sopenharmony_cistatic const char UNITY_PROGMEM UnityStrOrEqual[]                = "or equal to ";
4335375f98Sopenharmony_cistatic const char UNITY_PROGMEM UnityStrNotEqual[]               = " to be not equal to ";
4435375f98Sopenharmony_cistatic const char UNITY_PROGMEM UnityStrElement[]                = " Element ";
4535375f98Sopenharmony_cistatic const char UNITY_PROGMEM UnityStrByte[]                   = " Byte ";
4635375f98Sopenharmony_cistatic const char UNITY_PROGMEM UnityStrMemory[]                 = " Memory Mismatch.";
4735375f98Sopenharmony_cistatic const char UNITY_PROGMEM UnityStrDelta[]                  = " Values Not Within Delta ";
4835375f98Sopenharmony_cistatic const char UNITY_PROGMEM UnityStrPointless[]              = " You Asked Me To Compare Nothing, Which Was Pointless.";
4935375f98Sopenharmony_cistatic const char UNITY_PROGMEM UnityStrNullPointerForExpected[] = " Expected pointer to be NULL";
5035375f98Sopenharmony_cistatic const char UNITY_PROGMEM UnityStrNullPointerForActual[]   = " Actual pointer was NULL";
5135375f98Sopenharmony_ci#ifndef UNITY_EXCLUDE_FLOAT
5235375f98Sopenharmony_cistatic const char UNITY_PROGMEM UnityStrNot[]                    = "Not ";
5335375f98Sopenharmony_cistatic const char UNITY_PROGMEM UnityStrInf[]                    = "Infinity";
5435375f98Sopenharmony_cistatic const char UNITY_PROGMEM UnityStrNegInf[]                 = "Negative Infinity";
5535375f98Sopenharmony_cistatic const char UNITY_PROGMEM UnityStrNaN[]                    = "NaN";
5635375f98Sopenharmony_cistatic const char UNITY_PROGMEM UnityStrDet[]                    = "Determinate";
5735375f98Sopenharmony_cistatic const char UNITY_PROGMEM UnityStrInvalidFloatTrait[]      = "Invalid Float Trait";
5835375f98Sopenharmony_ci#endif
5935375f98Sopenharmony_ciconst char UNITY_PROGMEM UnityStrErrShorthand[]                  = "Unity Shorthand Support Disabled";
6035375f98Sopenharmony_ciconst char UNITY_PROGMEM UnityStrErrFloat[]                      = "Unity Floating Point Disabled";
6135375f98Sopenharmony_ciconst char UNITY_PROGMEM UnityStrErrDouble[]                     = "Unity Double Precision Disabled";
6235375f98Sopenharmony_ciconst char UNITY_PROGMEM UnityStrErr64[]                         = "Unity 64-bit Support Disabled";
6335375f98Sopenharmony_cistatic const char UNITY_PROGMEM UnityStrBreaker[]                = "-----------------------";
6435375f98Sopenharmony_cistatic const char UNITY_PROGMEM UnityStrResultsTests[]           = " Tests ";
6535375f98Sopenharmony_cistatic const char UNITY_PROGMEM UnityStrResultsFailures[]        = " Failures ";
6635375f98Sopenharmony_cistatic const char UNITY_PROGMEM UnityStrResultsIgnored[]         = " Ignored ";
6735375f98Sopenharmony_ci#ifndef UNITY_EXCLUDE_DETAILS
6835375f98Sopenharmony_cistatic const char UNITY_PROGMEM UnityStrDetail1Name[]            = UNITY_DETAIL1_NAME " ";
6935375f98Sopenharmony_cistatic const char UNITY_PROGMEM UnityStrDetail2Name[]            = " " UNITY_DETAIL2_NAME " ";
7035375f98Sopenharmony_ci#endif
7135375f98Sopenharmony_ci/*-----------------------------------------------
7235375f98Sopenharmony_ci * Pretty Printers & Test Result Output Handlers
7335375f98Sopenharmony_ci *-----------------------------------------------*/
7435375f98Sopenharmony_ci
7535375f98Sopenharmony_ci/*-----------------------------------------------*/
7635375f98Sopenharmony_ci/* Local helper function to print characters. */
7735375f98Sopenharmony_cistatic void UnityPrintChar(const char* pch)
7835375f98Sopenharmony_ci{
7935375f98Sopenharmony_ci    /* printable characters plus CR & LF are printed */
8035375f98Sopenharmony_ci    if ((*pch <= 126) && (*pch >= 32))
8135375f98Sopenharmony_ci    {
8235375f98Sopenharmony_ci        UNITY_OUTPUT_CHAR(*pch);
8335375f98Sopenharmony_ci    }
8435375f98Sopenharmony_ci    /* write escaped carriage returns */
8535375f98Sopenharmony_ci    else if (*pch == 13)
8635375f98Sopenharmony_ci    {
8735375f98Sopenharmony_ci        UNITY_OUTPUT_CHAR('\\');
8835375f98Sopenharmony_ci        UNITY_OUTPUT_CHAR('r');
8935375f98Sopenharmony_ci    }
9035375f98Sopenharmony_ci    /* write escaped line feeds */
9135375f98Sopenharmony_ci    else if (*pch == 10)
9235375f98Sopenharmony_ci    {
9335375f98Sopenharmony_ci        UNITY_OUTPUT_CHAR('\\');
9435375f98Sopenharmony_ci        UNITY_OUTPUT_CHAR('n');
9535375f98Sopenharmony_ci    }
9635375f98Sopenharmony_ci    /* unprintable characters are shown as codes */
9735375f98Sopenharmony_ci    else
9835375f98Sopenharmony_ci    {
9935375f98Sopenharmony_ci        UNITY_OUTPUT_CHAR('\\');
10035375f98Sopenharmony_ci        UNITY_OUTPUT_CHAR('x');
10135375f98Sopenharmony_ci        UnityPrintNumberHex((UNITY_UINT)*pch, 2);
10235375f98Sopenharmony_ci    }
10335375f98Sopenharmony_ci}
10435375f98Sopenharmony_ci
10535375f98Sopenharmony_ci/*-----------------------------------------------*/
10635375f98Sopenharmony_ci/* Local helper function to print ANSI escape strings e.g. "\033[42m". */
10735375f98Sopenharmony_ci#ifdef UNITY_OUTPUT_COLOR
10835375f98Sopenharmony_cistatic UNITY_UINT UnityPrintAnsiEscapeString(const char* string)
10935375f98Sopenharmony_ci{
11035375f98Sopenharmony_ci    const char* pch = string;
11135375f98Sopenharmony_ci    UNITY_UINT count = 0;
11235375f98Sopenharmony_ci
11335375f98Sopenharmony_ci    while (*pch && (*pch != 'm'))
11435375f98Sopenharmony_ci    {
11535375f98Sopenharmony_ci        UNITY_OUTPUT_CHAR(*pch);
11635375f98Sopenharmony_ci        pch++;
11735375f98Sopenharmony_ci        count++;
11835375f98Sopenharmony_ci    }
11935375f98Sopenharmony_ci    UNITY_OUTPUT_CHAR('m');
12035375f98Sopenharmony_ci    count++;
12135375f98Sopenharmony_ci
12235375f98Sopenharmony_ci    return count;
12335375f98Sopenharmony_ci}
12435375f98Sopenharmony_ci#endif
12535375f98Sopenharmony_ci
12635375f98Sopenharmony_ci/*-----------------------------------------------*/
12735375f98Sopenharmony_civoid UnityPrint(const char* string)
12835375f98Sopenharmony_ci{
12935375f98Sopenharmony_ci    const char* pch = string;
13035375f98Sopenharmony_ci
13135375f98Sopenharmony_ci    if (pch != NULL)
13235375f98Sopenharmony_ci    {
13335375f98Sopenharmony_ci        while (*pch)
13435375f98Sopenharmony_ci        {
13535375f98Sopenharmony_ci#ifdef UNITY_OUTPUT_COLOR
13635375f98Sopenharmony_ci            /* print ANSI escape code */
13735375f98Sopenharmony_ci            if ((*pch == 27) && (*(pch + 1) == '['))
13835375f98Sopenharmony_ci            {
13935375f98Sopenharmony_ci                pch += UnityPrintAnsiEscapeString(pch);
14035375f98Sopenharmony_ci                continue;
14135375f98Sopenharmony_ci            }
14235375f98Sopenharmony_ci#endif
14335375f98Sopenharmony_ci            UnityPrintChar(pch);
14435375f98Sopenharmony_ci            pch++;
14535375f98Sopenharmony_ci        }
14635375f98Sopenharmony_ci    }
14735375f98Sopenharmony_ci}
14835375f98Sopenharmony_ci/*-----------------------------------------------*/
14935375f98Sopenharmony_civoid UnityPrintLen(const char* string, const UNITY_UINT32 length)
15035375f98Sopenharmony_ci{
15135375f98Sopenharmony_ci    const char* pch = string;
15235375f98Sopenharmony_ci
15335375f98Sopenharmony_ci    if (pch != NULL)
15435375f98Sopenharmony_ci    {
15535375f98Sopenharmony_ci        while (*pch && ((UNITY_UINT32)(pch - string) < length))
15635375f98Sopenharmony_ci        {
15735375f98Sopenharmony_ci            /* printable characters plus CR & LF are printed */
15835375f98Sopenharmony_ci            if ((*pch <= 126) && (*pch >= 32))
15935375f98Sopenharmony_ci            {
16035375f98Sopenharmony_ci                UNITY_OUTPUT_CHAR(*pch);
16135375f98Sopenharmony_ci            }
16235375f98Sopenharmony_ci            /* write escaped carriage returns */
16335375f98Sopenharmony_ci            else if (*pch == 13)
16435375f98Sopenharmony_ci            {
16535375f98Sopenharmony_ci                UNITY_OUTPUT_CHAR('\\');
16635375f98Sopenharmony_ci                UNITY_OUTPUT_CHAR('r');
16735375f98Sopenharmony_ci            }
16835375f98Sopenharmony_ci            /* write escaped line feeds */
16935375f98Sopenharmony_ci            else if (*pch == 10)
17035375f98Sopenharmony_ci            {
17135375f98Sopenharmony_ci                UNITY_OUTPUT_CHAR('\\');
17235375f98Sopenharmony_ci                UNITY_OUTPUT_CHAR('n');
17335375f98Sopenharmony_ci            }
17435375f98Sopenharmony_ci            /* unprintable characters are shown as codes */
17535375f98Sopenharmony_ci            else
17635375f98Sopenharmony_ci            {
17735375f98Sopenharmony_ci                UNITY_OUTPUT_CHAR('\\');
17835375f98Sopenharmony_ci                UNITY_OUTPUT_CHAR('x');
17935375f98Sopenharmony_ci                UnityPrintNumberHex((UNITY_UINT)*pch, 2);
18035375f98Sopenharmony_ci            }
18135375f98Sopenharmony_ci            pch++;
18235375f98Sopenharmony_ci        }
18335375f98Sopenharmony_ci    }
18435375f98Sopenharmony_ci}
18535375f98Sopenharmony_ci
18635375f98Sopenharmony_ci/*-----------------------------------------------*/
18735375f98Sopenharmony_civoid UnityPrintNumberByStyle(const UNITY_INT number, const UNITY_DISPLAY_STYLE_T style)
18835375f98Sopenharmony_ci{
18935375f98Sopenharmony_ci    if ((style & UNITY_DISPLAY_RANGE_INT) == UNITY_DISPLAY_RANGE_INT)
19035375f98Sopenharmony_ci    {
19135375f98Sopenharmony_ci        if (style == UNITY_DISPLAY_STYLE_CHAR)
19235375f98Sopenharmony_ci        {
19335375f98Sopenharmony_ci            /* printable characters plus CR & LF are printed */
19435375f98Sopenharmony_ci            UNITY_OUTPUT_CHAR('\'');
19535375f98Sopenharmony_ci            if ((number <= 126) && (number >= 32))
19635375f98Sopenharmony_ci            {
19735375f98Sopenharmony_ci                UNITY_OUTPUT_CHAR((int)number);
19835375f98Sopenharmony_ci            }
19935375f98Sopenharmony_ci            /* write escaped carriage returns */
20035375f98Sopenharmony_ci            else if (number == 13)
20135375f98Sopenharmony_ci            {
20235375f98Sopenharmony_ci                UNITY_OUTPUT_CHAR('\\');
20335375f98Sopenharmony_ci                UNITY_OUTPUT_CHAR('r');
20435375f98Sopenharmony_ci            }
20535375f98Sopenharmony_ci            /* write escaped line feeds */
20635375f98Sopenharmony_ci            else if (number == 10)
20735375f98Sopenharmony_ci            {
20835375f98Sopenharmony_ci                UNITY_OUTPUT_CHAR('\\');
20935375f98Sopenharmony_ci                UNITY_OUTPUT_CHAR('n');
21035375f98Sopenharmony_ci            }
21135375f98Sopenharmony_ci            /* unprintable characters are shown as codes */
21235375f98Sopenharmony_ci            else
21335375f98Sopenharmony_ci            {
21435375f98Sopenharmony_ci                UNITY_OUTPUT_CHAR('\\');
21535375f98Sopenharmony_ci                UNITY_OUTPUT_CHAR('x');
21635375f98Sopenharmony_ci                UnityPrintNumberHex((UNITY_UINT)number, 2);
21735375f98Sopenharmony_ci            }
21835375f98Sopenharmony_ci            UNITY_OUTPUT_CHAR('\'');
21935375f98Sopenharmony_ci        }
22035375f98Sopenharmony_ci        else
22135375f98Sopenharmony_ci        {
22235375f98Sopenharmony_ci            UnityPrintNumber(number);
22335375f98Sopenharmony_ci        }
22435375f98Sopenharmony_ci    }
22535375f98Sopenharmony_ci    else if ((style & UNITY_DISPLAY_RANGE_UINT) == UNITY_DISPLAY_RANGE_UINT)
22635375f98Sopenharmony_ci    {
22735375f98Sopenharmony_ci        UnityPrintNumberUnsigned((UNITY_UINT)number);
22835375f98Sopenharmony_ci    }
22935375f98Sopenharmony_ci    else
23035375f98Sopenharmony_ci    {
23135375f98Sopenharmony_ci        UNITY_OUTPUT_CHAR('0');
23235375f98Sopenharmony_ci        UNITY_OUTPUT_CHAR('x');
23335375f98Sopenharmony_ci        UnityPrintNumberHex((UNITY_UINT)number, (char)((style & 0xF) * 2));
23435375f98Sopenharmony_ci    }
23535375f98Sopenharmony_ci}
23635375f98Sopenharmony_ci
23735375f98Sopenharmony_ci/*-----------------------------------------------*/
23835375f98Sopenharmony_civoid UnityPrintNumber(const UNITY_INT number_to_print)
23935375f98Sopenharmony_ci{
24035375f98Sopenharmony_ci    UNITY_UINT number = (UNITY_UINT)number_to_print;
24135375f98Sopenharmony_ci
24235375f98Sopenharmony_ci    if (number_to_print < 0)
24335375f98Sopenharmony_ci    {
24435375f98Sopenharmony_ci        /* A negative number, including MIN negative */
24535375f98Sopenharmony_ci        UNITY_OUTPUT_CHAR('-');
24635375f98Sopenharmony_ci        number = (~number) + 1;
24735375f98Sopenharmony_ci    }
24835375f98Sopenharmony_ci    UnityPrintNumberUnsigned(number);
24935375f98Sopenharmony_ci}
25035375f98Sopenharmony_ci
25135375f98Sopenharmony_ci/*-----------------------------------------------
25235375f98Sopenharmony_ci * basically do an itoa using as little ram as possible */
25335375f98Sopenharmony_civoid UnityPrintNumberUnsigned(const UNITY_UINT number)
25435375f98Sopenharmony_ci{
25535375f98Sopenharmony_ci    UNITY_UINT divisor = 1;
25635375f98Sopenharmony_ci
25735375f98Sopenharmony_ci    /* figure out initial divisor */
25835375f98Sopenharmony_ci    while (number / divisor > 9)
25935375f98Sopenharmony_ci    {
26035375f98Sopenharmony_ci        divisor *= 10;
26135375f98Sopenharmony_ci    }
26235375f98Sopenharmony_ci
26335375f98Sopenharmony_ci    /* now mod and print, then divide divisor */
26435375f98Sopenharmony_ci    do
26535375f98Sopenharmony_ci    {
26635375f98Sopenharmony_ci        UNITY_OUTPUT_CHAR((char)('0' + (number / divisor % 10)));
26735375f98Sopenharmony_ci        divisor /= 10;
26835375f98Sopenharmony_ci    } while (divisor > 0);
26935375f98Sopenharmony_ci}
27035375f98Sopenharmony_ci
27135375f98Sopenharmony_ci/*-----------------------------------------------*/
27235375f98Sopenharmony_civoid UnityPrintNumberHex(const UNITY_UINT number, const char nibbles_to_print)
27335375f98Sopenharmony_ci{
27435375f98Sopenharmony_ci    int nibble;
27535375f98Sopenharmony_ci    char nibbles = nibbles_to_print;
27635375f98Sopenharmony_ci
27735375f98Sopenharmony_ci    if ((unsigned)nibbles > UNITY_MAX_NIBBLES)
27835375f98Sopenharmony_ci    {
27935375f98Sopenharmony_ci        nibbles = UNITY_MAX_NIBBLES;
28035375f98Sopenharmony_ci    }
28135375f98Sopenharmony_ci
28235375f98Sopenharmony_ci    while (nibbles > 0)
28335375f98Sopenharmony_ci    {
28435375f98Sopenharmony_ci        nibbles--;
28535375f98Sopenharmony_ci        nibble = (int)(number >> (nibbles * 4)) & 0x0F;
28635375f98Sopenharmony_ci        if (nibble <= 9)
28735375f98Sopenharmony_ci        {
28835375f98Sopenharmony_ci            UNITY_OUTPUT_CHAR((char)('0' + nibble));
28935375f98Sopenharmony_ci        }
29035375f98Sopenharmony_ci        else
29135375f98Sopenharmony_ci        {
29235375f98Sopenharmony_ci            UNITY_OUTPUT_CHAR((char)('A' - 10 + nibble));
29335375f98Sopenharmony_ci        }
29435375f98Sopenharmony_ci    }
29535375f98Sopenharmony_ci}
29635375f98Sopenharmony_ci
29735375f98Sopenharmony_ci/*-----------------------------------------------*/
29835375f98Sopenharmony_civoid UnityPrintMask(const UNITY_UINT mask, const UNITY_UINT number)
29935375f98Sopenharmony_ci{
30035375f98Sopenharmony_ci    UNITY_UINT current_bit = (UNITY_UINT)1 << (UNITY_INT_WIDTH - 1);
30135375f98Sopenharmony_ci    UNITY_INT32 i;
30235375f98Sopenharmony_ci
30335375f98Sopenharmony_ci    for (i = 0; i < UNITY_INT_WIDTH; i++)
30435375f98Sopenharmony_ci    {
30535375f98Sopenharmony_ci        if (current_bit & mask)
30635375f98Sopenharmony_ci        {
30735375f98Sopenharmony_ci            if (current_bit & number)
30835375f98Sopenharmony_ci            {
30935375f98Sopenharmony_ci                UNITY_OUTPUT_CHAR('1');
31035375f98Sopenharmony_ci            }
31135375f98Sopenharmony_ci            else
31235375f98Sopenharmony_ci            {
31335375f98Sopenharmony_ci                UNITY_OUTPUT_CHAR('0');
31435375f98Sopenharmony_ci            }
31535375f98Sopenharmony_ci        }
31635375f98Sopenharmony_ci        else
31735375f98Sopenharmony_ci        {
31835375f98Sopenharmony_ci            UNITY_OUTPUT_CHAR('X');
31935375f98Sopenharmony_ci        }
32035375f98Sopenharmony_ci        current_bit = current_bit >> 1;
32135375f98Sopenharmony_ci    }
32235375f98Sopenharmony_ci}
32335375f98Sopenharmony_ci
32435375f98Sopenharmony_ci/*-----------------------------------------------*/
32535375f98Sopenharmony_ci#ifndef UNITY_EXCLUDE_FLOAT_PRINT
32635375f98Sopenharmony_ci/*
32735375f98Sopenharmony_ci * This function prints a floating-point value in a format similar to
32835375f98Sopenharmony_ci * printf("%.7g") on a single-precision machine or printf("%.9g") on a
32935375f98Sopenharmony_ci * double-precision machine.  The 7th digit won't always be totally correct
33035375f98Sopenharmony_ci * in single-precision operation (for that level of accuracy, a more
33135375f98Sopenharmony_ci * complicated algorithm would be needed).
33235375f98Sopenharmony_ci */
33335375f98Sopenharmony_civoid UnityPrintFloat(const UNITY_DOUBLE input_number)
33435375f98Sopenharmony_ci{
33535375f98Sopenharmony_ci#ifdef UNITY_INCLUDE_DOUBLE
33635375f98Sopenharmony_ci    static const int sig_digits = 9;
33735375f98Sopenharmony_ci    static const UNITY_INT32 min_scaled = 100000000;
33835375f98Sopenharmony_ci    static const UNITY_INT32 max_scaled = 1000000000;
33935375f98Sopenharmony_ci#else
34035375f98Sopenharmony_ci    static const int sig_digits = 7;
34135375f98Sopenharmony_ci    static const UNITY_INT32 min_scaled = 1000000;
34235375f98Sopenharmony_ci    static const UNITY_INT32 max_scaled = 10000000;
34335375f98Sopenharmony_ci#endif
34435375f98Sopenharmony_ci
34535375f98Sopenharmony_ci    UNITY_DOUBLE number = input_number;
34635375f98Sopenharmony_ci
34735375f98Sopenharmony_ci    /* print minus sign (does not handle negative zero) */
34835375f98Sopenharmony_ci    if (number < 0.0f)
34935375f98Sopenharmony_ci    {
35035375f98Sopenharmony_ci        UNITY_OUTPUT_CHAR('-');
35135375f98Sopenharmony_ci        number = -number;
35235375f98Sopenharmony_ci    }
35335375f98Sopenharmony_ci
35435375f98Sopenharmony_ci    /* handle zero, NaN, and +/- infinity */
35535375f98Sopenharmony_ci    if (number == 0.0f)
35635375f98Sopenharmony_ci    {
35735375f98Sopenharmony_ci        UnityPrint("0");
35835375f98Sopenharmony_ci    }
35935375f98Sopenharmony_ci    else if (UNITY_IS_NAN(number))
36035375f98Sopenharmony_ci    {
36135375f98Sopenharmony_ci        UnityPrint("nan");
36235375f98Sopenharmony_ci    }
36335375f98Sopenharmony_ci    else if (UNITY_IS_INF(number))
36435375f98Sopenharmony_ci    {
36535375f98Sopenharmony_ci        UnityPrint("inf");
36635375f98Sopenharmony_ci    }
36735375f98Sopenharmony_ci    else
36835375f98Sopenharmony_ci    {
36935375f98Sopenharmony_ci        UNITY_INT32 n_int = 0;
37035375f98Sopenharmony_ci        UNITY_INT32 n;
37135375f98Sopenharmony_ci        int         exponent = 0;
37235375f98Sopenharmony_ci        int         decimals;
37335375f98Sopenharmony_ci        int         digits;
37435375f98Sopenharmony_ci        char        buf[16] = {0};
37535375f98Sopenharmony_ci
37635375f98Sopenharmony_ci        /*
37735375f98Sopenharmony_ci         * Scale up or down by powers of 10.  To minimize rounding error,
37835375f98Sopenharmony_ci         * start with a factor/divisor of 10^10, which is the largest
37935375f98Sopenharmony_ci         * power of 10 that can be represented exactly.  Finally, compute
38035375f98Sopenharmony_ci         * (exactly) the remaining power of 10 and perform one more
38135375f98Sopenharmony_ci         * multiplication or division.
38235375f98Sopenharmony_ci         */
38335375f98Sopenharmony_ci        if (number < 1.0f)
38435375f98Sopenharmony_ci        {
38535375f98Sopenharmony_ci            UNITY_DOUBLE factor = 1.0f;
38635375f98Sopenharmony_ci
38735375f98Sopenharmony_ci            while (number < (UNITY_DOUBLE)max_scaled / 1e10f)  { number *= 1e10f; exponent -= 10; }
38835375f98Sopenharmony_ci            while (number * factor < (UNITY_DOUBLE)min_scaled) { factor *= 10.0f; exponent--; }
38935375f98Sopenharmony_ci
39035375f98Sopenharmony_ci            number *= factor;
39135375f98Sopenharmony_ci        }
39235375f98Sopenharmony_ci        else if (number > (UNITY_DOUBLE)max_scaled)
39335375f98Sopenharmony_ci        {
39435375f98Sopenharmony_ci            UNITY_DOUBLE divisor = 1.0f;
39535375f98Sopenharmony_ci
39635375f98Sopenharmony_ci            while (number > (UNITY_DOUBLE)min_scaled * 1e10f)   { number  /= 1e10f; exponent += 10; }
39735375f98Sopenharmony_ci            while (number / divisor > (UNITY_DOUBLE)max_scaled) { divisor *= 10.0f; exponent++; }
39835375f98Sopenharmony_ci
39935375f98Sopenharmony_ci            number /= divisor;
40035375f98Sopenharmony_ci        }
40135375f98Sopenharmony_ci        else
40235375f98Sopenharmony_ci        {
40335375f98Sopenharmony_ci            /*
40435375f98Sopenharmony_ci             * In this range, we can split off the integer part before
40535375f98Sopenharmony_ci             * doing any multiplications.  This reduces rounding error by
40635375f98Sopenharmony_ci             * freeing up significant bits in the fractional part.
40735375f98Sopenharmony_ci             */
40835375f98Sopenharmony_ci            UNITY_DOUBLE factor = 1.0f;
40935375f98Sopenharmony_ci            n_int = (UNITY_INT32)number;
41035375f98Sopenharmony_ci            number -= (UNITY_DOUBLE)n_int;
41135375f98Sopenharmony_ci
41235375f98Sopenharmony_ci            while (n_int < min_scaled) { n_int *= 10; factor *= 10.0f; exponent--; }
41335375f98Sopenharmony_ci
41435375f98Sopenharmony_ci            number *= factor;
41535375f98Sopenharmony_ci        }
41635375f98Sopenharmony_ci
41735375f98Sopenharmony_ci        /* round to nearest integer */
41835375f98Sopenharmony_ci        n = ((UNITY_INT32)(number + number) + 1) / 2;
41935375f98Sopenharmony_ci
42035375f98Sopenharmony_ci#ifndef UNITY_ROUND_TIES_AWAY_FROM_ZERO
42135375f98Sopenharmony_ci        /* round to even if exactly between two integers */
42235375f98Sopenharmony_ci        if ((n & 1) && (((UNITY_DOUBLE)n - number) == 0.5f))
42335375f98Sopenharmony_ci            n--;
42435375f98Sopenharmony_ci#endif
42535375f98Sopenharmony_ci
42635375f98Sopenharmony_ci        n += n_int;
42735375f98Sopenharmony_ci
42835375f98Sopenharmony_ci        if (n >= max_scaled)
42935375f98Sopenharmony_ci        {
43035375f98Sopenharmony_ci            n = min_scaled;
43135375f98Sopenharmony_ci            exponent++;
43235375f98Sopenharmony_ci        }
43335375f98Sopenharmony_ci
43435375f98Sopenharmony_ci        /* determine where to place decimal point */
43535375f98Sopenharmony_ci        decimals = ((exponent <= 0) && (exponent >= -(sig_digits + 3))) ? (-exponent) : (sig_digits - 1);
43635375f98Sopenharmony_ci        exponent += decimals;
43735375f98Sopenharmony_ci
43835375f98Sopenharmony_ci        /* truncate trailing zeroes after decimal point */
43935375f98Sopenharmony_ci        while ((decimals > 0) && ((n % 10) == 0))
44035375f98Sopenharmony_ci        {
44135375f98Sopenharmony_ci            n /= 10;
44235375f98Sopenharmony_ci            decimals--;
44335375f98Sopenharmony_ci        }
44435375f98Sopenharmony_ci
44535375f98Sopenharmony_ci        /* build up buffer in reverse order */
44635375f98Sopenharmony_ci        digits = 0;
44735375f98Sopenharmony_ci        while ((n != 0) || (digits <= decimals))
44835375f98Sopenharmony_ci        {
44935375f98Sopenharmony_ci            buf[digits++] = (char)('0' + n % 10);
45035375f98Sopenharmony_ci            n /= 10;
45135375f98Sopenharmony_ci        }
45235375f98Sopenharmony_ci
45335375f98Sopenharmony_ci        /* print out buffer (backwards) */
45435375f98Sopenharmony_ci        while (digits > 0)
45535375f98Sopenharmony_ci        {
45635375f98Sopenharmony_ci            if (digits == decimals)
45735375f98Sopenharmony_ci            {
45835375f98Sopenharmony_ci                UNITY_OUTPUT_CHAR('.');
45935375f98Sopenharmony_ci            }
46035375f98Sopenharmony_ci            UNITY_OUTPUT_CHAR(buf[--digits]);
46135375f98Sopenharmony_ci        }
46235375f98Sopenharmony_ci
46335375f98Sopenharmony_ci        /* print exponent if needed */
46435375f98Sopenharmony_ci        if (exponent != 0)
46535375f98Sopenharmony_ci        {
46635375f98Sopenharmony_ci            UNITY_OUTPUT_CHAR('e');
46735375f98Sopenharmony_ci
46835375f98Sopenharmony_ci            if (exponent < 0)
46935375f98Sopenharmony_ci            {
47035375f98Sopenharmony_ci                UNITY_OUTPUT_CHAR('-');
47135375f98Sopenharmony_ci                exponent = -exponent;
47235375f98Sopenharmony_ci            }
47335375f98Sopenharmony_ci            else
47435375f98Sopenharmony_ci            {
47535375f98Sopenharmony_ci                UNITY_OUTPUT_CHAR('+');
47635375f98Sopenharmony_ci            }
47735375f98Sopenharmony_ci
47835375f98Sopenharmony_ci            digits = 0;
47935375f98Sopenharmony_ci            while ((exponent != 0) || (digits < 2))
48035375f98Sopenharmony_ci            {
48135375f98Sopenharmony_ci                buf[digits++] = (char)('0' + exponent % 10);
48235375f98Sopenharmony_ci                exponent /= 10;
48335375f98Sopenharmony_ci            }
48435375f98Sopenharmony_ci            while (digits > 0)
48535375f98Sopenharmony_ci            {
48635375f98Sopenharmony_ci                UNITY_OUTPUT_CHAR(buf[--digits]);
48735375f98Sopenharmony_ci            }
48835375f98Sopenharmony_ci        }
48935375f98Sopenharmony_ci    }
49035375f98Sopenharmony_ci}
49135375f98Sopenharmony_ci#endif /* ! UNITY_EXCLUDE_FLOAT_PRINT */
49235375f98Sopenharmony_ci
49335375f98Sopenharmony_ci/*-----------------------------------------------*/
49435375f98Sopenharmony_cistatic void UnityTestResultsBegin(const char* file, const UNITY_LINE_TYPE line)
49535375f98Sopenharmony_ci{
49635375f98Sopenharmony_ci#ifdef UNITY_OUTPUT_FOR_ECLIPSE
49735375f98Sopenharmony_ci    UNITY_OUTPUT_CHAR('(');
49835375f98Sopenharmony_ci    UnityPrint(file);
49935375f98Sopenharmony_ci    UNITY_OUTPUT_CHAR(':');
50035375f98Sopenharmony_ci    UnityPrintNumber((UNITY_INT)line);
50135375f98Sopenharmony_ci    UNITY_OUTPUT_CHAR(')');
50235375f98Sopenharmony_ci    UNITY_OUTPUT_CHAR(' ');
50335375f98Sopenharmony_ci    UnityPrint(Unity.CurrentTestName);
50435375f98Sopenharmony_ci    UNITY_OUTPUT_CHAR(':');
50535375f98Sopenharmony_ci#else
50635375f98Sopenharmony_ci#ifdef UNITY_OUTPUT_FOR_IAR_WORKBENCH
50735375f98Sopenharmony_ci    UnityPrint("<SRCREF line=");
50835375f98Sopenharmony_ci    UnityPrintNumber((UNITY_INT)line);
50935375f98Sopenharmony_ci    UnityPrint(" file=\"");
51035375f98Sopenharmony_ci    UnityPrint(file);
51135375f98Sopenharmony_ci    UNITY_OUTPUT_CHAR('"');
51235375f98Sopenharmony_ci    UNITY_OUTPUT_CHAR('>');
51335375f98Sopenharmony_ci    UnityPrint(Unity.CurrentTestName);
51435375f98Sopenharmony_ci    UnityPrint("</SRCREF> ");
51535375f98Sopenharmony_ci#else
51635375f98Sopenharmony_ci#ifdef UNITY_OUTPUT_FOR_QT_CREATOR
51735375f98Sopenharmony_ci    UnityPrint("file://");
51835375f98Sopenharmony_ci    UnityPrint(file);
51935375f98Sopenharmony_ci    UNITY_OUTPUT_CHAR(':');
52035375f98Sopenharmony_ci    UnityPrintNumber((UNITY_INT)line);
52135375f98Sopenharmony_ci    UNITY_OUTPUT_CHAR(' ');
52235375f98Sopenharmony_ci    UnityPrint(Unity.CurrentTestName);
52335375f98Sopenharmony_ci    UNITY_OUTPUT_CHAR(':');
52435375f98Sopenharmony_ci#else
52535375f98Sopenharmony_ci    UnityPrint(file);
52635375f98Sopenharmony_ci    UNITY_OUTPUT_CHAR(':');
52735375f98Sopenharmony_ci    UnityPrintNumber((UNITY_INT)line);
52835375f98Sopenharmony_ci    UNITY_OUTPUT_CHAR(':');
52935375f98Sopenharmony_ci    UnityPrint(Unity.CurrentTestName);
53035375f98Sopenharmony_ci    UNITY_OUTPUT_CHAR(':');
53135375f98Sopenharmony_ci#endif
53235375f98Sopenharmony_ci#endif
53335375f98Sopenharmony_ci#endif
53435375f98Sopenharmony_ci}
53535375f98Sopenharmony_ci
53635375f98Sopenharmony_ci/*-----------------------------------------------*/
53735375f98Sopenharmony_cistatic void UnityTestResultsFailBegin(const UNITY_LINE_TYPE line)
53835375f98Sopenharmony_ci{
53935375f98Sopenharmony_ci    UnityTestResultsBegin(Unity.TestFile, line);
54035375f98Sopenharmony_ci    UnityPrint(UnityStrFail);
54135375f98Sopenharmony_ci    UNITY_OUTPUT_CHAR(':');
54235375f98Sopenharmony_ci}
54335375f98Sopenharmony_ci
54435375f98Sopenharmony_ci/*-----------------------------------------------*/
54535375f98Sopenharmony_civoid UnityConcludeTest(void)
54635375f98Sopenharmony_ci{
54735375f98Sopenharmony_ci    if (Unity.CurrentTestIgnored)
54835375f98Sopenharmony_ci    {
54935375f98Sopenharmony_ci        Unity.TestIgnores++;
55035375f98Sopenharmony_ci    }
55135375f98Sopenharmony_ci    else if (!Unity.CurrentTestFailed)
55235375f98Sopenharmony_ci    {
55335375f98Sopenharmony_ci        UnityTestResultsBegin(Unity.TestFile, Unity.CurrentTestLineNumber);
55435375f98Sopenharmony_ci        UnityPrint(UnityStrPass);
55535375f98Sopenharmony_ci    }
55635375f98Sopenharmony_ci    else
55735375f98Sopenharmony_ci    {
55835375f98Sopenharmony_ci        Unity.TestFailures++;
55935375f98Sopenharmony_ci    }
56035375f98Sopenharmony_ci
56135375f98Sopenharmony_ci    Unity.CurrentTestFailed = 0;
56235375f98Sopenharmony_ci    Unity.CurrentTestIgnored = 0;
56335375f98Sopenharmony_ci    UNITY_PRINT_EXEC_TIME();
56435375f98Sopenharmony_ci    UNITY_PRINT_EOL();
56535375f98Sopenharmony_ci    UNITY_FLUSH_CALL();
56635375f98Sopenharmony_ci}
56735375f98Sopenharmony_ci
56835375f98Sopenharmony_ci/*-----------------------------------------------*/
56935375f98Sopenharmony_cistatic void UnityAddMsgIfSpecified(const char* msg)
57035375f98Sopenharmony_ci{
57135375f98Sopenharmony_ci#ifdef UNITY_PRINT_TEST_CONTEXT
57235375f98Sopenharmony_ci    UnityPrint(UnityStrSpacer);
57335375f98Sopenharmony_ci    UNITY_PRINT_TEST_CONTEXT();
57435375f98Sopenharmony_ci#endif
57535375f98Sopenharmony_ci#ifndef UNITY_EXCLUDE_DETAILS
57635375f98Sopenharmony_ci    if (Unity.CurrentDetail1)
57735375f98Sopenharmony_ci    {
57835375f98Sopenharmony_ci        UnityPrint(UnityStrSpacer);
57935375f98Sopenharmony_ci        UnityPrint(UnityStrDetail1Name);
58035375f98Sopenharmony_ci        UnityPrint(Unity.CurrentDetail1);
58135375f98Sopenharmony_ci        if (Unity.CurrentDetail2)
58235375f98Sopenharmony_ci        {
58335375f98Sopenharmony_ci            UnityPrint(UnityStrDetail2Name);
58435375f98Sopenharmony_ci            UnityPrint(Unity.CurrentDetail2);
58535375f98Sopenharmony_ci        }
58635375f98Sopenharmony_ci    }
58735375f98Sopenharmony_ci#endif
58835375f98Sopenharmony_ci    if (msg)
58935375f98Sopenharmony_ci    {
59035375f98Sopenharmony_ci        UnityPrint(UnityStrSpacer);
59135375f98Sopenharmony_ci        UnityPrint(msg);
59235375f98Sopenharmony_ci    }
59335375f98Sopenharmony_ci}
59435375f98Sopenharmony_ci
59535375f98Sopenharmony_ci/*-----------------------------------------------*/
59635375f98Sopenharmony_cistatic void UnityPrintExpectedAndActualStrings(const char* expected, const char* actual)
59735375f98Sopenharmony_ci{
59835375f98Sopenharmony_ci    UnityPrint(UnityStrExpected);
59935375f98Sopenharmony_ci    if (expected != NULL)
60035375f98Sopenharmony_ci    {
60135375f98Sopenharmony_ci        UNITY_OUTPUT_CHAR('\'');
60235375f98Sopenharmony_ci        UnityPrint(expected);
60335375f98Sopenharmony_ci        UNITY_OUTPUT_CHAR('\'');
60435375f98Sopenharmony_ci    }
60535375f98Sopenharmony_ci    else
60635375f98Sopenharmony_ci    {
60735375f98Sopenharmony_ci        UnityPrint(UnityStrNull);
60835375f98Sopenharmony_ci    }
60935375f98Sopenharmony_ci    UnityPrint(UnityStrWas);
61035375f98Sopenharmony_ci    if (actual != NULL)
61135375f98Sopenharmony_ci    {
61235375f98Sopenharmony_ci        UNITY_OUTPUT_CHAR('\'');
61335375f98Sopenharmony_ci        UnityPrint(actual);
61435375f98Sopenharmony_ci        UNITY_OUTPUT_CHAR('\'');
61535375f98Sopenharmony_ci    }
61635375f98Sopenharmony_ci    else
61735375f98Sopenharmony_ci    {
61835375f98Sopenharmony_ci        UnityPrint(UnityStrNull);
61935375f98Sopenharmony_ci    }
62035375f98Sopenharmony_ci}
62135375f98Sopenharmony_ci
62235375f98Sopenharmony_ci/*-----------------------------------------------*/
62335375f98Sopenharmony_cistatic void UnityPrintExpectedAndActualStringsLen(const char* expected,
62435375f98Sopenharmony_ci                                                  const char* actual,
62535375f98Sopenharmony_ci                                                  const UNITY_UINT32 length)
62635375f98Sopenharmony_ci{
62735375f98Sopenharmony_ci    UnityPrint(UnityStrExpected);
62835375f98Sopenharmony_ci    if (expected != NULL)
62935375f98Sopenharmony_ci    {
63035375f98Sopenharmony_ci        UNITY_OUTPUT_CHAR('\'');
63135375f98Sopenharmony_ci        UnityPrintLen(expected, length);
63235375f98Sopenharmony_ci        UNITY_OUTPUT_CHAR('\'');
63335375f98Sopenharmony_ci    }
63435375f98Sopenharmony_ci    else
63535375f98Sopenharmony_ci    {
63635375f98Sopenharmony_ci        UnityPrint(UnityStrNull);
63735375f98Sopenharmony_ci    }
63835375f98Sopenharmony_ci    UnityPrint(UnityStrWas);
63935375f98Sopenharmony_ci    if (actual != NULL)
64035375f98Sopenharmony_ci    {
64135375f98Sopenharmony_ci        UNITY_OUTPUT_CHAR('\'');
64235375f98Sopenharmony_ci        UnityPrintLen(actual, length);
64335375f98Sopenharmony_ci        UNITY_OUTPUT_CHAR('\'');
64435375f98Sopenharmony_ci    }
64535375f98Sopenharmony_ci    else
64635375f98Sopenharmony_ci    {
64735375f98Sopenharmony_ci        UnityPrint(UnityStrNull);
64835375f98Sopenharmony_ci    }
64935375f98Sopenharmony_ci}
65035375f98Sopenharmony_ci
65135375f98Sopenharmony_ci/*-----------------------------------------------
65235375f98Sopenharmony_ci * Assertion & Control Helpers
65335375f98Sopenharmony_ci *-----------------------------------------------*/
65435375f98Sopenharmony_ci
65535375f98Sopenharmony_ci/*-----------------------------------------------*/
65635375f98Sopenharmony_cistatic int UnityIsOneArrayNull(UNITY_INTERNAL_PTR expected,
65735375f98Sopenharmony_ci                               UNITY_INTERNAL_PTR actual,
65835375f98Sopenharmony_ci                               const UNITY_LINE_TYPE lineNumber,
65935375f98Sopenharmony_ci                               const char* msg)
66035375f98Sopenharmony_ci{
66135375f98Sopenharmony_ci    /* Both are NULL or same pointer */
66235375f98Sopenharmony_ci    if (expected == actual) { return 0; }
66335375f98Sopenharmony_ci
66435375f98Sopenharmony_ci    /* print and return true if just expected is NULL */
66535375f98Sopenharmony_ci    if (expected == NULL)
66635375f98Sopenharmony_ci    {
66735375f98Sopenharmony_ci        UnityTestResultsFailBegin(lineNumber);
66835375f98Sopenharmony_ci        UnityPrint(UnityStrNullPointerForExpected);
66935375f98Sopenharmony_ci        UnityAddMsgIfSpecified(msg);
67035375f98Sopenharmony_ci        return 1;
67135375f98Sopenharmony_ci    }
67235375f98Sopenharmony_ci
67335375f98Sopenharmony_ci    /* print and return true if just actual is NULL */
67435375f98Sopenharmony_ci    if (actual == NULL)
67535375f98Sopenharmony_ci    {
67635375f98Sopenharmony_ci        UnityTestResultsFailBegin(lineNumber);
67735375f98Sopenharmony_ci        UnityPrint(UnityStrNullPointerForActual);
67835375f98Sopenharmony_ci        UnityAddMsgIfSpecified(msg);
67935375f98Sopenharmony_ci        return 1;
68035375f98Sopenharmony_ci    }
68135375f98Sopenharmony_ci
68235375f98Sopenharmony_ci    return 0; /* return false if neither is NULL */
68335375f98Sopenharmony_ci}
68435375f98Sopenharmony_ci
68535375f98Sopenharmony_ci/*-----------------------------------------------
68635375f98Sopenharmony_ci * Assertion Functions
68735375f98Sopenharmony_ci *-----------------------------------------------*/
68835375f98Sopenharmony_ci
68935375f98Sopenharmony_ci/*-----------------------------------------------*/
69035375f98Sopenharmony_civoid UnityAssertBits(const UNITY_INT mask,
69135375f98Sopenharmony_ci                     const UNITY_INT expected,
69235375f98Sopenharmony_ci                     const UNITY_INT actual,
69335375f98Sopenharmony_ci                     const char* msg,
69435375f98Sopenharmony_ci                     const UNITY_LINE_TYPE lineNumber)
69535375f98Sopenharmony_ci{
69635375f98Sopenharmony_ci    RETURN_IF_FAIL_OR_IGNORE;
69735375f98Sopenharmony_ci
69835375f98Sopenharmony_ci    if ((mask & expected) != (mask & actual))
69935375f98Sopenharmony_ci    {
70035375f98Sopenharmony_ci        UnityTestResultsFailBegin(lineNumber);
70135375f98Sopenharmony_ci        UnityPrint(UnityStrExpected);
70235375f98Sopenharmony_ci        UnityPrintMask((UNITY_UINT)mask, (UNITY_UINT)expected);
70335375f98Sopenharmony_ci        UnityPrint(UnityStrWas);
70435375f98Sopenharmony_ci        UnityPrintMask((UNITY_UINT)mask, (UNITY_UINT)actual);
70535375f98Sopenharmony_ci        UnityAddMsgIfSpecified(msg);
70635375f98Sopenharmony_ci        UNITY_FAIL_AND_BAIL;
70735375f98Sopenharmony_ci    }
70835375f98Sopenharmony_ci}
70935375f98Sopenharmony_ci
71035375f98Sopenharmony_ci/*-----------------------------------------------*/
71135375f98Sopenharmony_civoid UnityAssertEqualNumber(const UNITY_INT expected,
71235375f98Sopenharmony_ci                            const UNITY_INT actual,
71335375f98Sopenharmony_ci                            const char* msg,
71435375f98Sopenharmony_ci                            const UNITY_LINE_TYPE lineNumber,
71535375f98Sopenharmony_ci                            const UNITY_DISPLAY_STYLE_T style)
71635375f98Sopenharmony_ci{
71735375f98Sopenharmony_ci    RETURN_IF_FAIL_OR_IGNORE;
71835375f98Sopenharmony_ci
71935375f98Sopenharmony_ci    if (expected != actual)
72035375f98Sopenharmony_ci    {
72135375f98Sopenharmony_ci        UnityTestResultsFailBegin(lineNumber);
72235375f98Sopenharmony_ci        UnityPrint(UnityStrExpected);
72335375f98Sopenharmony_ci        UnityPrintNumberByStyle(expected, style);
72435375f98Sopenharmony_ci        UnityPrint(UnityStrWas);
72535375f98Sopenharmony_ci        UnityPrintNumberByStyle(actual, style);
72635375f98Sopenharmony_ci        UnityAddMsgIfSpecified(msg);
72735375f98Sopenharmony_ci        UNITY_FAIL_AND_BAIL;
72835375f98Sopenharmony_ci    }
72935375f98Sopenharmony_ci}
73035375f98Sopenharmony_ci
73135375f98Sopenharmony_ci/*-----------------------------------------------*/
73235375f98Sopenharmony_civoid UnityAssertGreaterOrLessOrEqualNumber(const UNITY_INT threshold,
73335375f98Sopenharmony_ci                                           const UNITY_INT actual,
73435375f98Sopenharmony_ci                                           const UNITY_COMPARISON_T compare,
73535375f98Sopenharmony_ci                                           const char *msg,
73635375f98Sopenharmony_ci                                           const UNITY_LINE_TYPE lineNumber,
73735375f98Sopenharmony_ci                                           const UNITY_DISPLAY_STYLE_T style)
73835375f98Sopenharmony_ci{
73935375f98Sopenharmony_ci    int failed = 0;
74035375f98Sopenharmony_ci    RETURN_IF_FAIL_OR_IGNORE;
74135375f98Sopenharmony_ci
74235375f98Sopenharmony_ci    if ((threshold == actual) && (compare & UNITY_EQUAL_TO)) { return; }
74335375f98Sopenharmony_ci    if ((threshold == actual))                               { failed = 1; }
74435375f98Sopenharmony_ci
74535375f98Sopenharmony_ci    if ((style & UNITY_DISPLAY_RANGE_INT) == UNITY_DISPLAY_RANGE_INT)
74635375f98Sopenharmony_ci    {
74735375f98Sopenharmony_ci        if ((actual > threshold) && (compare & UNITY_SMALLER_THAN)) { failed = 1; }
74835375f98Sopenharmony_ci        if ((actual < threshold) && (compare & UNITY_GREATER_THAN)) { failed = 1; }
74935375f98Sopenharmony_ci    }
75035375f98Sopenharmony_ci    else /* UINT or HEX */
75135375f98Sopenharmony_ci    {
75235375f98Sopenharmony_ci        if (((UNITY_UINT)actual > (UNITY_UINT)threshold) && (compare & UNITY_SMALLER_THAN)) { failed = 1; }
75335375f98Sopenharmony_ci        if (((UNITY_UINT)actual < (UNITY_UINT)threshold) && (compare & UNITY_GREATER_THAN)) { failed = 1; }
75435375f98Sopenharmony_ci    }
75535375f98Sopenharmony_ci
75635375f98Sopenharmony_ci    if (failed)
75735375f98Sopenharmony_ci    {
75835375f98Sopenharmony_ci        UnityTestResultsFailBegin(lineNumber);
75935375f98Sopenharmony_ci        UnityPrint(UnityStrExpected);
76035375f98Sopenharmony_ci        UnityPrintNumberByStyle(actual, style);
76135375f98Sopenharmony_ci        if (compare & UNITY_GREATER_THAN) { UnityPrint(UnityStrGt);       }
76235375f98Sopenharmony_ci        if (compare & UNITY_SMALLER_THAN) { UnityPrint(UnityStrLt);       }
76335375f98Sopenharmony_ci        if (compare & UNITY_EQUAL_TO)     { UnityPrint(UnityStrOrEqual);  }
76435375f98Sopenharmony_ci        if (compare == UNITY_NOT_EQUAL)   { UnityPrint(UnityStrNotEqual); }
76535375f98Sopenharmony_ci        UnityPrintNumberByStyle(threshold, style);
76635375f98Sopenharmony_ci        UnityAddMsgIfSpecified(msg);
76735375f98Sopenharmony_ci        UNITY_FAIL_AND_BAIL;
76835375f98Sopenharmony_ci    }
76935375f98Sopenharmony_ci}
77035375f98Sopenharmony_ci
77135375f98Sopenharmony_ci#define UnityPrintPointlessAndBail()       \
77235375f98Sopenharmony_cido {                                       \
77335375f98Sopenharmony_ci    UnityTestResultsFailBegin(lineNumber); \
77435375f98Sopenharmony_ci    UnityPrint(UnityStrPointless);         \
77535375f98Sopenharmony_ci    UnityAddMsgIfSpecified(msg);           \
77635375f98Sopenharmony_ci    UNITY_FAIL_AND_BAIL;                   \
77735375f98Sopenharmony_ci} while (0)
77835375f98Sopenharmony_ci
77935375f98Sopenharmony_ci/*-----------------------------------------------*/
78035375f98Sopenharmony_civoid UnityAssertEqualIntArray(UNITY_INTERNAL_PTR expected,
78135375f98Sopenharmony_ci                              UNITY_INTERNAL_PTR actual,
78235375f98Sopenharmony_ci                              const UNITY_UINT32 num_elements,
78335375f98Sopenharmony_ci                              const char* msg,
78435375f98Sopenharmony_ci                              const UNITY_LINE_TYPE lineNumber,
78535375f98Sopenharmony_ci                              const UNITY_DISPLAY_STYLE_T style,
78635375f98Sopenharmony_ci                              const UNITY_FLAGS_T flags)
78735375f98Sopenharmony_ci{
78835375f98Sopenharmony_ci    UNITY_UINT32 elements  = num_elements;
78935375f98Sopenharmony_ci    unsigned int length    = style & 0xF;
79035375f98Sopenharmony_ci    unsigned int increment = 0;
79135375f98Sopenharmony_ci
79235375f98Sopenharmony_ci    RETURN_IF_FAIL_OR_IGNORE;
79335375f98Sopenharmony_ci
79435375f98Sopenharmony_ci    if (num_elements == 0)
79535375f98Sopenharmony_ci    {
79635375f98Sopenharmony_ci#ifdef UNITY_COMPARE_PTRS_ON_ZERO_ARRAY
79735375f98Sopenharmony_ci        UNITY_TEST_ASSERT_EQUAL_PTR(expected, actual, lineNumber, msg);
79835375f98Sopenharmony_ci#else
79935375f98Sopenharmony_ci        UnityPrintPointlessAndBail();
80035375f98Sopenharmony_ci#endif
80135375f98Sopenharmony_ci    }
80235375f98Sopenharmony_ci
80335375f98Sopenharmony_ci    if (expected == actual)
80435375f98Sopenharmony_ci    {
80535375f98Sopenharmony_ci        return; /* Both are NULL or same pointer */
80635375f98Sopenharmony_ci    }
80735375f98Sopenharmony_ci
80835375f98Sopenharmony_ci    if (UnityIsOneArrayNull(expected, actual, lineNumber, msg))
80935375f98Sopenharmony_ci    {
81035375f98Sopenharmony_ci        UNITY_FAIL_AND_BAIL;
81135375f98Sopenharmony_ci    }
81235375f98Sopenharmony_ci
81335375f98Sopenharmony_ci    while ((elements > 0) && (elements--))
81435375f98Sopenharmony_ci    {
81535375f98Sopenharmony_ci        UNITY_INT expect_val;
81635375f98Sopenharmony_ci        UNITY_INT actual_val;
81735375f98Sopenharmony_ci
81835375f98Sopenharmony_ci        switch (length)
81935375f98Sopenharmony_ci        {
82035375f98Sopenharmony_ci            case 1:
82135375f98Sopenharmony_ci                expect_val = *(UNITY_PTR_ATTRIBUTE const UNITY_INT8*)expected;
82235375f98Sopenharmony_ci                actual_val = *(UNITY_PTR_ATTRIBUTE const UNITY_INT8*)actual;
82335375f98Sopenharmony_ci                if (style & (UNITY_DISPLAY_RANGE_UINT | UNITY_DISPLAY_RANGE_HEX))
82435375f98Sopenharmony_ci                {
82535375f98Sopenharmony_ci                    expect_val &= 0x000000FF;
82635375f98Sopenharmony_ci                    actual_val &= 0x000000FF;
82735375f98Sopenharmony_ci                }
82835375f98Sopenharmony_ci                increment  = sizeof(UNITY_INT8);
82935375f98Sopenharmony_ci                break;
83035375f98Sopenharmony_ci
83135375f98Sopenharmony_ci            case 2:
83235375f98Sopenharmony_ci                expect_val = *(UNITY_PTR_ATTRIBUTE const UNITY_INT16*)expected;
83335375f98Sopenharmony_ci                actual_val = *(UNITY_PTR_ATTRIBUTE const UNITY_INT16*)actual;
83435375f98Sopenharmony_ci                if (style & (UNITY_DISPLAY_RANGE_UINT | UNITY_DISPLAY_RANGE_HEX))
83535375f98Sopenharmony_ci                {
83635375f98Sopenharmony_ci                    expect_val &= 0x0000FFFF;
83735375f98Sopenharmony_ci                    actual_val &= 0x0000FFFF;
83835375f98Sopenharmony_ci                }
83935375f98Sopenharmony_ci                increment  = sizeof(UNITY_INT16);
84035375f98Sopenharmony_ci                break;
84135375f98Sopenharmony_ci
84235375f98Sopenharmony_ci#ifdef UNITY_SUPPORT_64
84335375f98Sopenharmony_ci            case 8:
84435375f98Sopenharmony_ci                expect_val = *(UNITY_PTR_ATTRIBUTE const UNITY_INT64*)expected;
84535375f98Sopenharmony_ci                actual_val = *(UNITY_PTR_ATTRIBUTE const UNITY_INT64*)actual;
84635375f98Sopenharmony_ci                increment  = sizeof(UNITY_INT64);
84735375f98Sopenharmony_ci                break;
84835375f98Sopenharmony_ci#endif
84935375f98Sopenharmony_ci
85035375f98Sopenharmony_ci            default: /* default is length 4 bytes */
85135375f98Sopenharmony_ci            case 4:
85235375f98Sopenharmony_ci                expect_val = *(UNITY_PTR_ATTRIBUTE const UNITY_INT32*)expected;
85335375f98Sopenharmony_ci                actual_val = *(UNITY_PTR_ATTRIBUTE const UNITY_INT32*)actual;
85435375f98Sopenharmony_ci#ifdef UNITY_SUPPORT_64
85535375f98Sopenharmony_ci                if (style & (UNITY_DISPLAY_RANGE_UINT | UNITY_DISPLAY_RANGE_HEX))
85635375f98Sopenharmony_ci                {
85735375f98Sopenharmony_ci                    expect_val &= 0x00000000FFFFFFFF;
85835375f98Sopenharmony_ci                    actual_val &= 0x00000000FFFFFFFF;
85935375f98Sopenharmony_ci                }
86035375f98Sopenharmony_ci#endif
86135375f98Sopenharmony_ci                increment  = sizeof(UNITY_INT32);
86235375f98Sopenharmony_ci                length = 4;
86335375f98Sopenharmony_ci                break;
86435375f98Sopenharmony_ci        }
86535375f98Sopenharmony_ci
86635375f98Sopenharmony_ci        if (expect_val != actual_val)
86735375f98Sopenharmony_ci        {
86835375f98Sopenharmony_ci            if ((style & UNITY_DISPLAY_RANGE_UINT) && (length < (UNITY_INT_WIDTH / 8)))
86935375f98Sopenharmony_ci            {   /* For UINT, remove sign extension (padding 1's) from signed type casts above */
87035375f98Sopenharmony_ci                UNITY_INT mask = 1;
87135375f98Sopenharmony_ci                mask = (mask << 8 * length) - 1;
87235375f98Sopenharmony_ci                expect_val &= mask;
87335375f98Sopenharmony_ci                actual_val &= mask;
87435375f98Sopenharmony_ci            }
87535375f98Sopenharmony_ci            UnityTestResultsFailBegin(lineNumber);
87635375f98Sopenharmony_ci            UnityPrint(UnityStrElement);
87735375f98Sopenharmony_ci            UnityPrintNumberUnsigned(num_elements - elements - 1);
87835375f98Sopenharmony_ci            UnityPrint(UnityStrExpected);
87935375f98Sopenharmony_ci            UnityPrintNumberByStyle(expect_val, style);
88035375f98Sopenharmony_ci            UnityPrint(UnityStrWas);
88135375f98Sopenharmony_ci            UnityPrintNumberByStyle(actual_val, style);
88235375f98Sopenharmony_ci            UnityAddMsgIfSpecified(msg);
88335375f98Sopenharmony_ci            UNITY_FAIL_AND_BAIL;
88435375f98Sopenharmony_ci        }
88535375f98Sopenharmony_ci        /* Walk through array by incrementing the pointers */
88635375f98Sopenharmony_ci        if (flags == UNITY_ARRAY_TO_ARRAY)
88735375f98Sopenharmony_ci        {
88835375f98Sopenharmony_ci            expected = (UNITY_INTERNAL_PTR)((const char*)expected + increment);
88935375f98Sopenharmony_ci        }
89035375f98Sopenharmony_ci        actual = (UNITY_INTERNAL_PTR)((const char*)actual + increment);
89135375f98Sopenharmony_ci    }
89235375f98Sopenharmony_ci}
89335375f98Sopenharmony_ci
89435375f98Sopenharmony_ci/*-----------------------------------------------*/
89535375f98Sopenharmony_ci#ifndef UNITY_EXCLUDE_FLOAT
89635375f98Sopenharmony_ci/* Wrap this define in a function with variable types as float or double */
89735375f98Sopenharmony_ci#define UNITY_FLOAT_OR_DOUBLE_WITHIN(delta, expected, actual, diff)                           \
89835375f98Sopenharmony_ci    if (UNITY_IS_INF(expected) && UNITY_IS_INF(actual) && (((expected) < 0) == ((actual) < 0))) return 1;   \
89935375f98Sopenharmony_ci    if (UNITY_NAN_CHECK) return 1;                                                            \
90035375f98Sopenharmony_ci    (diff) = (actual) - (expected);                                                           \
90135375f98Sopenharmony_ci    if ((diff) < 0) (diff) = -(diff);                                                         \
90235375f98Sopenharmony_ci    if ((delta) < 0) (delta) = -(delta);                                                      \
90335375f98Sopenharmony_ci    return !(UNITY_IS_NAN(diff) || UNITY_IS_INF(diff) || ((diff) > (delta)))
90435375f98Sopenharmony_ci    /* This first part of this condition will catch any NaN or Infinite values */
90535375f98Sopenharmony_ci#ifndef UNITY_NAN_NOT_EQUAL_NAN
90635375f98Sopenharmony_ci  #define UNITY_NAN_CHECK UNITY_IS_NAN(expected) && UNITY_IS_NAN(actual)
90735375f98Sopenharmony_ci#else
90835375f98Sopenharmony_ci  #define UNITY_NAN_CHECK 0
90935375f98Sopenharmony_ci#endif
91035375f98Sopenharmony_ci
91135375f98Sopenharmony_ci#ifndef UNITY_EXCLUDE_FLOAT_PRINT
91235375f98Sopenharmony_ci  #define UNITY_PRINT_EXPECTED_AND_ACTUAL_FLOAT(expected, actual) \
91335375f98Sopenharmony_ci  do {                                                            \
91435375f98Sopenharmony_ci    UnityPrint(UnityStrExpected);                                 \
91535375f98Sopenharmony_ci    UnityPrintFloat(expected);                                    \
91635375f98Sopenharmony_ci    UnityPrint(UnityStrWas);                                      \
91735375f98Sopenharmony_ci    UnityPrintFloat(actual);                                      \
91835375f98Sopenharmony_ci  } while (0)
91935375f98Sopenharmony_ci#else
92035375f98Sopenharmony_ci  #define UNITY_PRINT_EXPECTED_AND_ACTUAL_FLOAT(expected, actual) \
92135375f98Sopenharmony_ci    UnityPrint(UnityStrDelta)
92235375f98Sopenharmony_ci#endif /* UNITY_EXCLUDE_FLOAT_PRINT */
92335375f98Sopenharmony_ci
92435375f98Sopenharmony_ci/*-----------------------------------------------*/
92535375f98Sopenharmony_cistatic int UnityFloatsWithin(UNITY_FLOAT delta, UNITY_FLOAT expected, UNITY_FLOAT actual)
92635375f98Sopenharmony_ci{
92735375f98Sopenharmony_ci    UNITY_FLOAT diff;
92835375f98Sopenharmony_ci    UNITY_FLOAT_OR_DOUBLE_WITHIN(delta, expected, actual, diff);
92935375f98Sopenharmony_ci}
93035375f98Sopenharmony_ci
93135375f98Sopenharmony_ci/*-----------------------------------------------*/
93235375f98Sopenharmony_civoid UnityAssertWithinFloatArray(const UNITY_FLOAT delta,
93335375f98Sopenharmony_ci                                 UNITY_PTR_ATTRIBUTE const UNITY_FLOAT* expected,
93435375f98Sopenharmony_ci                                 UNITY_PTR_ATTRIBUTE const UNITY_FLOAT* actual,
93535375f98Sopenharmony_ci                                 const UNITY_UINT32 num_elements,
93635375f98Sopenharmony_ci                                 const char* msg,
93735375f98Sopenharmony_ci                                 const UNITY_LINE_TYPE lineNumber,
93835375f98Sopenharmony_ci                                 const UNITY_FLAGS_T flags)
93935375f98Sopenharmony_ci{
94035375f98Sopenharmony_ci    UNITY_UINT32 elements = num_elements;
94135375f98Sopenharmony_ci    UNITY_PTR_ATTRIBUTE const UNITY_FLOAT* ptr_expected = expected;
94235375f98Sopenharmony_ci    UNITY_PTR_ATTRIBUTE const UNITY_FLOAT* ptr_actual = actual;
94335375f98Sopenharmony_ci    UNITY_FLOAT in_delta = delta;
94435375f98Sopenharmony_ci    UNITY_FLOAT current_element_delta = delta;
94535375f98Sopenharmony_ci
94635375f98Sopenharmony_ci    RETURN_IF_FAIL_OR_IGNORE;
94735375f98Sopenharmony_ci
94835375f98Sopenharmony_ci    if (elements == 0)
94935375f98Sopenharmony_ci    {
95035375f98Sopenharmony_ci#ifdef UNITY_COMPARE_PTRS_ON_ZERO_ARRAY
95135375f98Sopenharmony_ci        UNITY_TEST_ASSERT_EQUAL_PTR(expected, actual, lineNumber, msg);
95235375f98Sopenharmony_ci#else
95335375f98Sopenharmony_ci        UnityPrintPointlessAndBail();
95435375f98Sopenharmony_ci#endif
95535375f98Sopenharmony_ci    }
95635375f98Sopenharmony_ci
95735375f98Sopenharmony_ci    if (UNITY_IS_INF(in_delta))
95835375f98Sopenharmony_ci    {
95935375f98Sopenharmony_ci        return; /* Arrays will be force equal with infinite delta */
96035375f98Sopenharmony_ci    }
96135375f98Sopenharmony_ci
96235375f98Sopenharmony_ci    if (UNITY_IS_NAN(in_delta))
96335375f98Sopenharmony_ci    {
96435375f98Sopenharmony_ci        /* Delta must be correct number */
96535375f98Sopenharmony_ci        UnityPrintPointlessAndBail();
96635375f98Sopenharmony_ci    }
96735375f98Sopenharmony_ci
96835375f98Sopenharmony_ci    if (expected == actual)
96935375f98Sopenharmony_ci    {
97035375f98Sopenharmony_ci        return; /* Both are NULL or same pointer */
97135375f98Sopenharmony_ci    }
97235375f98Sopenharmony_ci
97335375f98Sopenharmony_ci    if (UnityIsOneArrayNull((UNITY_INTERNAL_PTR)expected, (UNITY_INTERNAL_PTR)actual, lineNumber, msg))
97435375f98Sopenharmony_ci    {
97535375f98Sopenharmony_ci        UNITY_FAIL_AND_BAIL;
97635375f98Sopenharmony_ci    }
97735375f98Sopenharmony_ci
97835375f98Sopenharmony_ci    /* fix delta sign if need */
97935375f98Sopenharmony_ci    if (in_delta < 0)
98035375f98Sopenharmony_ci    {
98135375f98Sopenharmony_ci        in_delta = -in_delta;
98235375f98Sopenharmony_ci    }
98335375f98Sopenharmony_ci
98435375f98Sopenharmony_ci    while (elements--)
98535375f98Sopenharmony_ci    {
98635375f98Sopenharmony_ci        current_element_delta = *ptr_expected * UNITY_FLOAT_PRECISION;
98735375f98Sopenharmony_ci
98835375f98Sopenharmony_ci        if (current_element_delta < 0)
98935375f98Sopenharmony_ci        {
99035375f98Sopenharmony_ci            /* fix delta sign for correct calculations */
99135375f98Sopenharmony_ci            current_element_delta = -current_element_delta;
99235375f98Sopenharmony_ci        }
99335375f98Sopenharmony_ci
99435375f98Sopenharmony_ci        if (!UnityFloatsWithin(in_delta + current_element_delta, *ptr_expected, *ptr_actual))
99535375f98Sopenharmony_ci        {
99635375f98Sopenharmony_ci            UnityTestResultsFailBegin(lineNumber);
99735375f98Sopenharmony_ci            UnityPrint(UnityStrElement);
99835375f98Sopenharmony_ci            UnityPrintNumberUnsigned(num_elements - elements - 1);
99935375f98Sopenharmony_ci            UNITY_PRINT_EXPECTED_AND_ACTUAL_FLOAT((UNITY_DOUBLE)*ptr_expected, (UNITY_DOUBLE)*ptr_actual);
100035375f98Sopenharmony_ci            UnityAddMsgIfSpecified(msg);
100135375f98Sopenharmony_ci            UNITY_FAIL_AND_BAIL;
100235375f98Sopenharmony_ci        }
100335375f98Sopenharmony_ci        if (flags == UNITY_ARRAY_TO_ARRAY)
100435375f98Sopenharmony_ci        {
100535375f98Sopenharmony_ci            ptr_expected++;
100635375f98Sopenharmony_ci        }
100735375f98Sopenharmony_ci        ptr_actual++;
100835375f98Sopenharmony_ci    }
100935375f98Sopenharmony_ci}
101035375f98Sopenharmony_ci
101135375f98Sopenharmony_ci/*-----------------------------------------------*/
101235375f98Sopenharmony_civoid UnityAssertFloatsWithin(const UNITY_FLOAT delta,
101335375f98Sopenharmony_ci                             const UNITY_FLOAT expected,
101435375f98Sopenharmony_ci                             const UNITY_FLOAT actual,
101535375f98Sopenharmony_ci                             const char* msg,
101635375f98Sopenharmony_ci                             const UNITY_LINE_TYPE lineNumber)
101735375f98Sopenharmony_ci{
101835375f98Sopenharmony_ci    RETURN_IF_FAIL_OR_IGNORE;
101935375f98Sopenharmony_ci
102035375f98Sopenharmony_ci
102135375f98Sopenharmony_ci    if (!UnityFloatsWithin(delta, expected, actual))
102235375f98Sopenharmony_ci    {
102335375f98Sopenharmony_ci        UnityTestResultsFailBegin(lineNumber);
102435375f98Sopenharmony_ci        UNITY_PRINT_EXPECTED_AND_ACTUAL_FLOAT((UNITY_DOUBLE)expected, (UNITY_DOUBLE)actual);
102535375f98Sopenharmony_ci        UnityAddMsgIfSpecified(msg);
102635375f98Sopenharmony_ci        UNITY_FAIL_AND_BAIL;
102735375f98Sopenharmony_ci    }
102835375f98Sopenharmony_ci}
102935375f98Sopenharmony_ci
103035375f98Sopenharmony_ci/*-----------------------------------------------*/
103135375f98Sopenharmony_civoid UnityAssertFloatsNotWithin(const UNITY_FLOAT delta,
103235375f98Sopenharmony_ci                                const UNITY_FLOAT expected,
103335375f98Sopenharmony_ci                                const UNITY_FLOAT actual,
103435375f98Sopenharmony_ci                                const char* msg,
103535375f98Sopenharmony_ci                                const UNITY_LINE_TYPE lineNumber)
103635375f98Sopenharmony_ci{
103735375f98Sopenharmony_ci    RETURN_IF_FAIL_OR_IGNORE;
103835375f98Sopenharmony_ci
103935375f98Sopenharmony_ci    if (UnityFloatsWithin(delta, expected, actual))
104035375f98Sopenharmony_ci    {
104135375f98Sopenharmony_ci        UnityTestResultsFailBegin(lineNumber);
104235375f98Sopenharmony_ci        UnityPrint(UnityStrExpected);
104335375f98Sopenharmony_ci        UnityPrintFloat((UNITY_DOUBLE)expected);
104435375f98Sopenharmony_ci        UnityPrint(UnityStrNotEqual);
104535375f98Sopenharmony_ci        UnityPrintFloat((UNITY_DOUBLE)actual);
104635375f98Sopenharmony_ci        UnityAddMsgIfSpecified(msg);
104735375f98Sopenharmony_ci        UNITY_FAIL_AND_BAIL;
104835375f98Sopenharmony_ci    }
104935375f98Sopenharmony_ci}
105035375f98Sopenharmony_ci
105135375f98Sopenharmony_ci/*-----------------------------------------------*/
105235375f98Sopenharmony_civoid UnityAssertGreaterOrLessFloat(const UNITY_FLOAT threshold,
105335375f98Sopenharmony_ci                                   const UNITY_FLOAT actual,
105435375f98Sopenharmony_ci                                   const UNITY_COMPARISON_T compare,
105535375f98Sopenharmony_ci                                   const char* msg,
105635375f98Sopenharmony_ci                                   const UNITY_LINE_TYPE lineNumber)
105735375f98Sopenharmony_ci{
105835375f98Sopenharmony_ci    int failed;
105935375f98Sopenharmony_ci
106035375f98Sopenharmony_ci    RETURN_IF_FAIL_OR_IGNORE;
106135375f98Sopenharmony_ci
106235375f98Sopenharmony_ci    failed = 0;
106335375f98Sopenharmony_ci
106435375f98Sopenharmony_ci    /* Checking for "not success" rather than failure to get the right result for NaN */
106535375f98Sopenharmony_ci    if (!(actual < threshold) && (compare & UNITY_SMALLER_THAN)) { failed = 1; }
106635375f98Sopenharmony_ci    if (!(actual > threshold) && (compare & UNITY_GREATER_THAN)) { failed = 1; }
106735375f98Sopenharmony_ci
106835375f98Sopenharmony_ci    if ((compare & UNITY_EQUAL_TO) && UnityFloatsWithin(threshold * UNITY_FLOAT_PRECISION, threshold, actual)) { failed = 0; }
106935375f98Sopenharmony_ci
107035375f98Sopenharmony_ci    if (failed)
107135375f98Sopenharmony_ci    {
107235375f98Sopenharmony_ci        UnityTestResultsFailBegin(lineNumber);
107335375f98Sopenharmony_ci        UnityPrint(UnityStrExpected);
107435375f98Sopenharmony_ci        UnityPrintFloat(actual);
107535375f98Sopenharmony_ci        if (compare & UNITY_GREATER_THAN) { UnityPrint(UnityStrGt); }
107635375f98Sopenharmony_ci        if (compare & UNITY_SMALLER_THAN) { UnityPrint(UnityStrLt); }
107735375f98Sopenharmony_ci        if (compare & UNITY_EQUAL_TO)     { UnityPrint(UnityStrOrEqual);  }
107835375f98Sopenharmony_ci        UnityPrintFloat(threshold);
107935375f98Sopenharmony_ci        UnityAddMsgIfSpecified(msg);
108035375f98Sopenharmony_ci        UNITY_FAIL_AND_BAIL;
108135375f98Sopenharmony_ci    }
108235375f98Sopenharmony_ci}
108335375f98Sopenharmony_ci
108435375f98Sopenharmony_ci/*-----------------------------------------------*/
108535375f98Sopenharmony_civoid UnityAssertFloatSpecial(const UNITY_FLOAT actual,
108635375f98Sopenharmony_ci                             const char* msg,
108735375f98Sopenharmony_ci                             const UNITY_LINE_TYPE lineNumber,
108835375f98Sopenharmony_ci                             const UNITY_FLOAT_TRAIT_T style)
108935375f98Sopenharmony_ci{
109035375f98Sopenharmony_ci    const char* trait_names[] = {UnityStrInf, UnityStrNegInf, UnityStrNaN, UnityStrDet};
109135375f98Sopenharmony_ci    UNITY_INT should_be_trait = ((UNITY_INT)style & 1);
109235375f98Sopenharmony_ci    UNITY_INT is_trait        = !should_be_trait;
109335375f98Sopenharmony_ci    UNITY_INT trait_index     = (UNITY_INT)(style >> 1);
109435375f98Sopenharmony_ci
109535375f98Sopenharmony_ci    RETURN_IF_FAIL_OR_IGNORE;
109635375f98Sopenharmony_ci
109735375f98Sopenharmony_ci    switch (style)
109835375f98Sopenharmony_ci    {
109935375f98Sopenharmony_ci        case UNITY_FLOAT_IS_INF:
110035375f98Sopenharmony_ci        case UNITY_FLOAT_IS_NOT_INF:
110135375f98Sopenharmony_ci            is_trait = UNITY_IS_INF(actual) && (actual > 0);
110235375f98Sopenharmony_ci            break;
110335375f98Sopenharmony_ci        case UNITY_FLOAT_IS_NEG_INF:
110435375f98Sopenharmony_ci        case UNITY_FLOAT_IS_NOT_NEG_INF:
110535375f98Sopenharmony_ci            is_trait = UNITY_IS_INF(actual) && (actual < 0);
110635375f98Sopenharmony_ci            break;
110735375f98Sopenharmony_ci
110835375f98Sopenharmony_ci        case UNITY_FLOAT_IS_NAN:
110935375f98Sopenharmony_ci        case UNITY_FLOAT_IS_NOT_NAN:
111035375f98Sopenharmony_ci            is_trait = UNITY_IS_NAN(actual) ? 1 : 0;
111135375f98Sopenharmony_ci            break;
111235375f98Sopenharmony_ci
111335375f98Sopenharmony_ci        case UNITY_FLOAT_IS_DET: /* A determinate number is non infinite and not NaN. */
111435375f98Sopenharmony_ci        case UNITY_FLOAT_IS_NOT_DET:
111535375f98Sopenharmony_ci            is_trait = !UNITY_IS_INF(actual) && !UNITY_IS_NAN(actual);
111635375f98Sopenharmony_ci            break;
111735375f98Sopenharmony_ci
111835375f98Sopenharmony_ci        case UNITY_FLOAT_INVALID_TRAIT:  /* Supress warning */
111935375f98Sopenharmony_ci        default: /* including UNITY_FLOAT_INVALID_TRAIT */
112035375f98Sopenharmony_ci            trait_index = 0;
112135375f98Sopenharmony_ci            trait_names[0] = UnityStrInvalidFloatTrait;
112235375f98Sopenharmony_ci            break;
112335375f98Sopenharmony_ci    }
112435375f98Sopenharmony_ci
112535375f98Sopenharmony_ci    if (is_trait != should_be_trait)
112635375f98Sopenharmony_ci    {
112735375f98Sopenharmony_ci        UnityTestResultsFailBegin(lineNumber);
112835375f98Sopenharmony_ci        UnityPrint(UnityStrExpected);
112935375f98Sopenharmony_ci        if (!should_be_trait)
113035375f98Sopenharmony_ci        {
113135375f98Sopenharmony_ci            UnityPrint(UnityStrNot);
113235375f98Sopenharmony_ci        }
113335375f98Sopenharmony_ci        UnityPrint(trait_names[trait_index]);
113435375f98Sopenharmony_ci        UnityPrint(UnityStrWas);
113535375f98Sopenharmony_ci#ifndef UNITY_EXCLUDE_FLOAT_PRINT
113635375f98Sopenharmony_ci        UnityPrintFloat((UNITY_DOUBLE)actual);
113735375f98Sopenharmony_ci#else
113835375f98Sopenharmony_ci        if (should_be_trait)
113935375f98Sopenharmony_ci        {
114035375f98Sopenharmony_ci            UnityPrint(UnityStrNot);
114135375f98Sopenharmony_ci        }
114235375f98Sopenharmony_ci        UnityPrint(trait_names[trait_index]);
114335375f98Sopenharmony_ci#endif
114435375f98Sopenharmony_ci        UnityAddMsgIfSpecified(msg);
114535375f98Sopenharmony_ci        UNITY_FAIL_AND_BAIL;
114635375f98Sopenharmony_ci    }
114735375f98Sopenharmony_ci}
114835375f98Sopenharmony_ci
114935375f98Sopenharmony_ci#endif /* not UNITY_EXCLUDE_FLOAT */
115035375f98Sopenharmony_ci
115135375f98Sopenharmony_ci/*-----------------------------------------------*/
115235375f98Sopenharmony_ci#ifndef UNITY_EXCLUDE_DOUBLE
115335375f98Sopenharmony_cistatic int UnityDoublesWithin(UNITY_DOUBLE delta, UNITY_DOUBLE expected, UNITY_DOUBLE actual)
115435375f98Sopenharmony_ci{
115535375f98Sopenharmony_ci    UNITY_DOUBLE diff;
115635375f98Sopenharmony_ci    UNITY_FLOAT_OR_DOUBLE_WITHIN(delta, expected, actual, diff);
115735375f98Sopenharmony_ci}
115835375f98Sopenharmony_ci
115935375f98Sopenharmony_ci/*-----------------------------------------------*/
116035375f98Sopenharmony_civoid UnityAssertWithinDoubleArray(const UNITY_DOUBLE delta,
116135375f98Sopenharmony_ci                                  UNITY_PTR_ATTRIBUTE const UNITY_DOUBLE* expected,
116235375f98Sopenharmony_ci                                  UNITY_PTR_ATTRIBUTE const UNITY_DOUBLE* actual,
116335375f98Sopenharmony_ci                                  const UNITY_UINT32 num_elements,
116435375f98Sopenharmony_ci                                  const char* msg,
116535375f98Sopenharmony_ci                                  const UNITY_LINE_TYPE lineNumber,
116635375f98Sopenharmony_ci                                  const UNITY_FLAGS_T flags)
116735375f98Sopenharmony_ci{
116835375f98Sopenharmony_ci    UNITY_UINT32 elements = num_elements;
116935375f98Sopenharmony_ci    UNITY_PTR_ATTRIBUTE const UNITY_DOUBLE* ptr_expected = expected;
117035375f98Sopenharmony_ci    UNITY_PTR_ATTRIBUTE const UNITY_DOUBLE* ptr_actual = actual;
117135375f98Sopenharmony_ci    UNITY_DOUBLE in_delta = delta;
117235375f98Sopenharmony_ci    UNITY_DOUBLE current_element_delta = delta;
117335375f98Sopenharmony_ci
117435375f98Sopenharmony_ci    RETURN_IF_FAIL_OR_IGNORE;
117535375f98Sopenharmony_ci
117635375f98Sopenharmony_ci    if (elements == 0)
117735375f98Sopenharmony_ci    {
117835375f98Sopenharmony_ci#ifdef UNITY_COMPARE_PTRS_ON_ZERO_ARRAY
117935375f98Sopenharmony_ci        UNITY_TEST_ASSERT_EQUAL_PTR(expected, actual, lineNumber, msg);
118035375f98Sopenharmony_ci#else
118135375f98Sopenharmony_ci        UnityPrintPointlessAndBail();
118235375f98Sopenharmony_ci#endif
118335375f98Sopenharmony_ci    }
118435375f98Sopenharmony_ci
118535375f98Sopenharmony_ci    if (UNITY_IS_INF(in_delta))
118635375f98Sopenharmony_ci    {
118735375f98Sopenharmony_ci        return; /* Arrays will be force equal with infinite delta */
118835375f98Sopenharmony_ci    }
118935375f98Sopenharmony_ci
119035375f98Sopenharmony_ci    if (UNITY_IS_NAN(in_delta))
119135375f98Sopenharmony_ci    {
119235375f98Sopenharmony_ci        /* Delta must be correct number */
119335375f98Sopenharmony_ci        UnityPrintPointlessAndBail();
119435375f98Sopenharmony_ci    }
119535375f98Sopenharmony_ci
119635375f98Sopenharmony_ci    if (expected == actual)
119735375f98Sopenharmony_ci    {
119835375f98Sopenharmony_ci        return; /* Both are NULL or same pointer */
119935375f98Sopenharmony_ci    }
120035375f98Sopenharmony_ci
120135375f98Sopenharmony_ci    if (UnityIsOneArrayNull((UNITY_INTERNAL_PTR)expected, (UNITY_INTERNAL_PTR)actual, lineNumber, msg))
120235375f98Sopenharmony_ci    {
120335375f98Sopenharmony_ci        UNITY_FAIL_AND_BAIL;
120435375f98Sopenharmony_ci    }
120535375f98Sopenharmony_ci
120635375f98Sopenharmony_ci    /* fix delta sign if need */
120735375f98Sopenharmony_ci    if (in_delta < 0)
120835375f98Sopenharmony_ci    {
120935375f98Sopenharmony_ci        in_delta = -in_delta;
121035375f98Sopenharmony_ci    }
121135375f98Sopenharmony_ci
121235375f98Sopenharmony_ci    while (elements--)
121335375f98Sopenharmony_ci    {
121435375f98Sopenharmony_ci        current_element_delta = *ptr_expected * UNITY_DOUBLE_PRECISION;
121535375f98Sopenharmony_ci
121635375f98Sopenharmony_ci        if (current_element_delta < 0)
121735375f98Sopenharmony_ci        {
121835375f98Sopenharmony_ci            /* fix delta sign for correct calculations */
121935375f98Sopenharmony_ci            current_element_delta = -current_element_delta;
122035375f98Sopenharmony_ci        }
122135375f98Sopenharmony_ci
122235375f98Sopenharmony_ci        if (!UnityDoublesWithin(in_delta + current_element_delta, *ptr_expected, *ptr_actual))
122335375f98Sopenharmony_ci        {
122435375f98Sopenharmony_ci            UnityTestResultsFailBegin(lineNumber);
122535375f98Sopenharmony_ci            UnityPrint(UnityStrElement);
122635375f98Sopenharmony_ci            UnityPrintNumberUnsigned(num_elements - elements - 1);
122735375f98Sopenharmony_ci            UNITY_PRINT_EXPECTED_AND_ACTUAL_FLOAT(*ptr_expected, *ptr_actual);
122835375f98Sopenharmony_ci            UnityAddMsgIfSpecified(msg);
122935375f98Sopenharmony_ci            UNITY_FAIL_AND_BAIL;
123035375f98Sopenharmony_ci        }
123135375f98Sopenharmony_ci        if (flags == UNITY_ARRAY_TO_ARRAY)
123235375f98Sopenharmony_ci        {
123335375f98Sopenharmony_ci            ptr_expected++;
123435375f98Sopenharmony_ci        }
123535375f98Sopenharmony_ci        ptr_actual++;
123635375f98Sopenharmony_ci    }
123735375f98Sopenharmony_ci}
123835375f98Sopenharmony_ci
123935375f98Sopenharmony_ci/*-----------------------------------------------*/
124035375f98Sopenharmony_civoid UnityAssertDoublesWithin(const UNITY_DOUBLE delta,
124135375f98Sopenharmony_ci                              const UNITY_DOUBLE expected,
124235375f98Sopenharmony_ci                              const UNITY_DOUBLE actual,
124335375f98Sopenharmony_ci                              const char* msg,
124435375f98Sopenharmony_ci                              const UNITY_LINE_TYPE lineNumber)
124535375f98Sopenharmony_ci{
124635375f98Sopenharmony_ci    RETURN_IF_FAIL_OR_IGNORE;
124735375f98Sopenharmony_ci
124835375f98Sopenharmony_ci    if (!UnityDoublesWithin(delta, expected, actual))
124935375f98Sopenharmony_ci    {
125035375f98Sopenharmony_ci        UnityTestResultsFailBegin(lineNumber);
125135375f98Sopenharmony_ci        UNITY_PRINT_EXPECTED_AND_ACTUAL_FLOAT(expected, actual);
125235375f98Sopenharmony_ci        UnityAddMsgIfSpecified(msg);
125335375f98Sopenharmony_ci        UNITY_FAIL_AND_BAIL;
125435375f98Sopenharmony_ci    }
125535375f98Sopenharmony_ci}
125635375f98Sopenharmony_ci
125735375f98Sopenharmony_ci/*-----------------------------------------------*/
125835375f98Sopenharmony_civoid UnityAssertDoublesNotWithin(const UNITY_DOUBLE delta,
125935375f98Sopenharmony_ci                                 const UNITY_DOUBLE expected,
126035375f98Sopenharmony_ci                                 const UNITY_DOUBLE actual,
126135375f98Sopenharmony_ci                                 const char* msg,
126235375f98Sopenharmony_ci                                 const UNITY_LINE_TYPE lineNumber)
126335375f98Sopenharmony_ci{
126435375f98Sopenharmony_ci    RETURN_IF_FAIL_OR_IGNORE;
126535375f98Sopenharmony_ci
126635375f98Sopenharmony_ci    if (UnityDoublesWithin(delta, expected, actual))
126735375f98Sopenharmony_ci    {
126835375f98Sopenharmony_ci        UnityTestResultsFailBegin(lineNumber);
126935375f98Sopenharmony_ci        UnityPrint(UnityStrExpected);
127035375f98Sopenharmony_ci        UnityPrintFloat((UNITY_DOUBLE)expected);
127135375f98Sopenharmony_ci        UnityPrint(UnityStrNotEqual);
127235375f98Sopenharmony_ci        UnityPrintFloat((UNITY_DOUBLE)actual);
127335375f98Sopenharmony_ci        UnityAddMsgIfSpecified(msg);
127435375f98Sopenharmony_ci        UNITY_FAIL_AND_BAIL;
127535375f98Sopenharmony_ci    }
127635375f98Sopenharmony_ci}
127735375f98Sopenharmony_ci
127835375f98Sopenharmony_ci/*-----------------------------------------------*/
127935375f98Sopenharmony_civoid UnityAssertGreaterOrLessDouble(const UNITY_DOUBLE threshold,
128035375f98Sopenharmony_ci                                    const UNITY_DOUBLE actual,
128135375f98Sopenharmony_ci                                    const UNITY_COMPARISON_T compare,
128235375f98Sopenharmony_ci                                    const char* msg,
128335375f98Sopenharmony_ci                                    const UNITY_LINE_TYPE lineNumber)
128435375f98Sopenharmony_ci{
128535375f98Sopenharmony_ci    int failed;
128635375f98Sopenharmony_ci
128735375f98Sopenharmony_ci    RETURN_IF_FAIL_OR_IGNORE;
128835375f98Sopenharmony_ci
128935375f98Sopenharmony_ci    failed = 0;
129035375f98Sopenharmony_ci
129135375f98Sopenharmony_ci    /* Checking for "not success" rather than failure to get the right result for NaN */
129235375f98Sopenharmony_ci    if (!(actual < threshold) && (compare & UNITY_SMALLER_THAN)) { failed = 1; }
129335375f98Sopenharmony_ci    if (!(actual > threshold) && (compare & UNITY_GREATER_THAN)) { failed = 1; }
129435375f98Sopenharmony_ci
129535375f98Sopenharmony_ci    if ((compare & UNITY_EQUAL_TO) && UnityDoublesWithin(threshold * UNITY_DOUBLE_PRECISION, threshold, actual)) { failed = 0; }
129635375f98Sopenharmony_ci
129735375f98Sopenharmony_ci    if (failed)
129835375f98Sopenharmony_ci    {
129935375f98Sopenharmony_ci        UnityTestResultsFailBegin(lineNumber);
130035375f98Sopenharmony_ci        UnityPrint(UnityStrExpected);
130135375f98Sopenharmony_ci        UnityPrintFloat(actual);
130235375f98Sopenharmony_ci        if (compare & UNITY_GREATER_THAN) { UnityPrint(UnityStrGt); }
130335375f98Sopenharmony_ci        if (compare & UNITY_SMALLER_THAN) { UnityPrint(UnityStrLt); }
130435375f98Sopenharmony_ci        if (compare & UNITY_EQUAL_TO)     { UnityPrint(UnityStrOrEqual);  }
130535375f98Sopenharmony_ci        UnityPrintFloat(threshold);
130635375f98Sopenharmony_ci        UnityAddMsgIfSpecified(msg);
130735375f98Sopenharmony_ci        UNITY_FAIL_AND_BAIL;
130835375f98Sopenharmony_ci    }
130935375f98Sopenharmony_ci}
131035375f98Sopenharmony_ci
131135375f98Sopenharmony_ci/*-----------------------------------------------*/
131235375f98Sopenharmony_civoid UnityAssertDoubleSpecial(const UNITY_DOUBLE actual,
131335375f98Sopenharmony_ci                              const char* msg,
131435375f98Sopenharmony_ci                              const UNITY_LINE_TYPE lineNumber,
131535375f98Sopenharmony_ci                              const UNITY_FLOAT_TRAIT_T style)
131635375f98Sopenharmony_ci{
131735375f98Sopenharmony_ci    const char* trait_names[] = {UnityStrInf, UnityStrNegInf, UnityStrNaN, UnityStrDet};
131835375f98Sopenharmony_ci    UNITY_INT should_be_trait = ((UNITY_INT)style & 1);
131935375f98Sopenharmony_ci    UNITY_INT is_trait        = !should_be_trait;
132035375f98Sopenharmony_ci    UNITY_INT trait_index     = (UNITY_INT)(style >> 1);
132135375f98Sopenharmony_ci
132235375f98Sopenharmony_ci    RETURN_IF_FAIL_OR_IGNORE;
132335375f98Sopenharmony_ci
132435375f98Sopenharmony_ci    switch (style)
132535375f98Sopenharmony_ci    {
132635375f98Sopenharmony_ci        case UNITY_FLOAT_IS_INF:
132735375f98Sopenharmony_ci        case UNITY_FLOAT_IS_NOT_INF:
132835375f98Sopenharmony_ci            is_trait = UNITY_IS_INF(actual) && (actual > 0);
132935375f98Sopenharmony_ci            break;
133035375f98Sopenharmony_ci        case UNITY_FLOAT_IS_NEG_INF:
133135375f98Sopenharmony_ci        case UNITY_FLOAT_IS_NOT_NEG_INF:
133235375f98Sopenharmony_ci            is_trait = UNITY_IS_INF(actual) && (actual < 0);
133335375f98Sopenharmony_ci            break;
133435375f98Sopenharmony_ci
133535375f98Sopenharmony_ci        case UNITY_FLOAT_IS_NAN:
133635375f98Sopenharmony_ci        case UNITY_FLOAT_IS_NOT_NAN:
133735375f98Sopenharmony_ci            is_trait = UNITY_IS_NAN(actual) ? 1 : 0;
133835375f98Sopenharmony_ci            break;
133935375f98Sopenharmony_ci
134035375f98Sopenharmony_ci        case UNITY_FLOAT_IS_DET: /* A determinate number is non infinite and not NaN. */
134135375f98Sopenharmony_ci        case UNITY_FLOAT_IS_NOT_DET:
134235375f98Sopenharmony_ci            is_trait = !UNITY_IS_INF(actual) && !UNITY_IS_NAN(actual);
134335375f98Sopenharmony_ci            break;
134435375f98Sopenharmony_ci
134535375f98Sopenharmony_ci        case UNITY_FLOAT_INVALID_TRAIT:  /* Supress warning */
134635375f98Sopenharmony_ci        default: /* including UNITY_FLOAT_INVALID_TRAIT */
134735375f98Sopenharmony_ci            trait_index = 0;
134835375f98Sopenharmony_ci            trait_names[0] = UnityStrInvalidFloatTrait;
134935375f98Sopenharmony_ci            break;
135035375f98Sopenharmony_ci    }
135135375f98Sopenharmony_ci
135235375f98Sopenharmony_ci    if (is_trait != should_be_trait)
135335375f98Sopenharmony_ci    {
135435375f98Sopenharmony_ci        UnityTestResultsFailBegin(lineNumber);
135535375f98Sopenharmony_ci        UnityPrint(UnityStrExpected);
135635375f98Sopenharmony_ci        if (!should_be_trait)
135735375f98Sopenharmony_ci        {
135835375f98Sopenharmony_ci            UnityPrint(UnityStrNot);
135935375f98Sopenharmony_ci        }
136035375f98Sopenharmony_ci        UnityPrint(trait_names[trait_index]);
136135375f98Sopenharmony_ci        UnityPrint(UnityStrWas);
136235375f98Sopenharmony_ci#ifndef UNITY_EXCLUDE_FLOAT_PRINT
136335375f98Sopenharmony_ci        UnityPrintFloat(actual);
136435375f98Sopenharmony_ci#else
136535375f98Sopenharmony_ci        if (should_be_trait)
136635375f98Sopenharmony_ci        {
136735375f98Sopenharmony_ci            UnityPrint(UnityStrNot);
136835375f98Sopenharmony_ci        }
136935375f98Sopenharmony_ci        UnityPrint(trait_names[trait_index]);
137035375f98Sopenharmony_ci#endif
137135375f98Sopenharmony_ci        UnityAddMsgIfSpecified(msg);
137235375f98Sopenharmony_ci        UNITY_FAIL_AND_BAIL;
137335375f98Sopenharmony_ci    }
137435375f98Sopenharmony_ci}
137535375f98Sopenharmony_ci
137635375f98Sopenharmony_ci#endif /* not UNITY_EXCLUDE_DOUBLE */
137735375f98Sopenharmony_ci
137835375f98Sopenharmony_ci/*-----------------------------------------------*/
137935375f98Sopenharmony_civoid UnityAssertNumbersWithin(const UNITY_UINT delta,
138035375f98Sopenharmony_ci                              const UNITY_INT expected,
138135375f98Sopenharmony_ci                              const UNITY_INT actual,
138235375f98Sopenharmony_ci                              const char* msg,
138335375f98Sopenharmony_ci                              const UNITY_LINE_TYPE lineNumber,
138435375f98Sopenharmony_ci                              const UNITY_DISPLAY_STYLE_T style)
138535375f98Sopenharmony_ci{
138635375f98Sopenharmony_ci    RETURN_IF_FAIL_OR_IGNORE;
138735375f98Sopenharmony_ci
138835375f98Sopenharmony_ci    if ((style & UNITY_DISPLAY_RANGE_INT) == UNITY_DISPLAY_RANGE_INT)
138935375f98Sopenharmony_ci    {
139035375f98Sopenharmony_ci        if (actual > expected)
139135375f98Sopenharmony_ci        {
139235375f98Sopenharmony_ci            Unity.CurrentTestFailed = (((UNITY_UINT)actual - (UNITY_UINT)expected) > delta);
139335375f98Sopenharmony_ci        }
139435375f98Sopenharmony_ci        else
139535375f98Sopenharmony_ci        {
139635375f98Sopenharmony_ci            Unity.CurrentTestFailed = (((UNITY_UINT)expected - (UNITY_UINT)actual) > delta);
139735375f98Sopenharmony_ci        }
139835375f98Sopenharmony_ci    }
139935375f98Sopenharmony_ci    else
140035375f98Sopenharmony_ci    {
140135375f98Sopenharmony_ci        if ((UNITY_UINT)actual > (UNITY_UINT)expected)
140235375f98Sopenharmony_ci        {
140335375f98Sopenharmony_ci            Unity.CurrentTestFailed = (((UNITY_UINT)actual - (UNITY_UINT)expected) > delta);
140435375f98Sopenharmony_ci        }
140535375f98Sopenharmony_ci        else
140635375f98Sopenharmony_ci        {
140735375f98Sopenharmony_ci            Unity.CurrentTestFailed = (((UNITY_UINT)expected - (UNITY_UINT)actual) > delta);
140835375f98Sopenharmony_ci        }
140935375f98Sopenharmony_ci    }
141035375f98Sopenharmony_ci
141135375f98Sopenharmony_ci    if (Unity.CurrentTestFailed)
141235375f98Sopenharmony_ci    {
141335375f98Sopenharmony_ci        UnityTestResultsFailBegin(lineNumber);
141435375f98Sopenharmony_ci        UnityPrint(UnityStrDelta);
141535375f98Sopenharmony_ci        UnityPrintNumberByStyle((UNITY_INT)delta, style);
141635375f98Sopenharmony_ci        UnityPrint(UnityStrExpected);
141735375f98Sopenharmony_ci        UnityPrintNumberByStyle(expected, style);
141835375f98Sopenharmony_ci        UnityPrint(UnityStrWas);
141935375f98Sopenharmony_ci        UnityPrintNumberByStyle(actual, style);
142035375f98Sopenharmony_ci        UnityAddMsgIfSpecified(msg);
142135375f98Sopenharmony_ci        UNITY_FAIL_AND_BAIL;
142235375f98Sopenharmony_ci    }
142335375f98Sopenharmony_ci}
142435375f98Sopenharmony_ci
142535375f98Sopenharmony_ci/*-----------------------------------------------*/
142635375f98Sopenharmony_civoid UnityAssertNumbersArrayWithin(const UNITY_UINT delta,
142735375f98Sopenharmony_ci                                   UNITY_INTERNAL_PTR expected,
142835375f98Sopenharmony_ci                                   UNITY_INTERNAL_PTR actual,
142935375f98Sopenharmony_ci                                   const UNITY_UINT32 num_elements,
143035375f98Sopenharmony_ci                                   const char* msg,
143135375f98Sopenharmony_ci                                   const UNITY_LINE_TYPE lineNumber,
143235375f98Sopenharmony_ci                                   const UNITY_DISPLAY_STYLE_T style,
143335375f98Sopenharmony_ci                                   const UNITY_FLAGS_T flags)
143435375f98Sopenharmony_ci{
143535375f98Sopenharmony_ci    UNITY_UINT32 elements = num_elements;
143635375f98Sopenharmony_ci    unsigned int length   = style & 0xF;
143735375f98Sopenharmony_ci    unsigned int increment = 0;
143835375f98Sopenharmony_ci
143935375f98Sopenharmony_ci    RETURN_IF_FAIL_OR_IGNORE;
144035375f98Sopenharmony_ci
144135375f98Sopenharmony_ci    if (num_elements == 0)
144235375f98Sopenharmony_ci    {
144335375f98Sopenharmony_ci#ifdef UNITY_COMPARE_PTRS_ON_ZERO_ARRAY
144435375f98Sopenharmony_ci        UNITY_TEST_ASSERT_EQUAL_PTR(expected, actual, lineNumber, msg);
144535375f98Sopenharmony_ci#else
144635375f98Sopenharmony_ci        UnityPrintPointlessAndBail();
144735375f98Sopenharmony_ci#endif
144835375f98Sopenharmony_ci    }
144935375f98Sopenharmony_ci
145035375f98Sopenharmony_ci    if (expected == actual)
145135375f98Sopenharmony_ci    {
145235375f98Sopenharmony_ci        return; /* Both are NULL or same pointer */
145335375f98Sopenharmony_ci    }
145435375f98Sopenharmony_ci
145535375f98Sopenharmony_ci    if (UnityIsOneArrayNull(expected, actual, lineNumber, msg))
145635375f98Sopenharmony_ci    {
145735375f98Sopenharmony_ci        UNITY_FAIL_AND_BAIL;
145835375f98Sopenharmony_ci    }
145935375f98Sopenharmony_ci
146035375f98Sopenharmony_ci    while ((elements > 0) && (elements--))
146135375f98Sopenharmony_ci    {
146235375f98Sopenharmony_ci        UNITY_INT expect_val;
146335375f98Sopenharmony_ci        UNITY_INT actual_val;
146435375f98Sopenharmony_ci
146535375f98Sopenharmony_ci        switch (length)
146635375f98Sopenharmony_ci        {
146735375f98Sopenharmony_ci            case 1:
146835375f98Sopenharmony_ci                /* fixing problems with signed overflow on unsigned numbers */
146935375f98Sopenharmony_ci                if ((style & UNITY_DISPLAY_RANGE_INT) == UNITY_DISPLAY_RANGE_INT)
147035375f98Sopenharmony_ci                {
147135375f98Sopenharmony_ci                    expect_val = *(UNITY_PTR_ATTRIBUTE const UNITY_INT8*)expected;
147235375f98Sopenharmony_ci                    actual_val = *(UNITY_PTR_ATTRIBUTE const UNITY_INT8*)actual;
147335375f98Sopenharmony_ci                    increment  = sizeof(UNITY_INT8);
147435375f98Sopenharmony_ci                }
147535375f98Sopenharmony_ci                else
147635375f98Sopenharmony_ci                {
147735375f98Sopenharmony_ci                    expect_val = (UNITY_INT)*(UNITY_PTR_ATTRIBUTE const UNITY_UINT8*)expected;
147835375f98Sopenharmony_ci                    actual_val = (UNITY_INT)*(UNITY_PTR_ATTRIBUTE const UNITY_UINT8*)actual;
147935375f98Sopenharmony_ci                    increment  = sizeof(UNITY_UINT8);
148035375f98Sopenharmony_ci                }
148135375f98Sopenharmony_ci                break;
148235375f98Sopenharmony_ci
148335375f98Sopenharmony_ci            case 2:
148435375f98Sopenharmony_ci                /* fixing problems with signed overflow on unsigned numbers */
148535375f98Sopenharmony_ci                if ((style & UNITY_DISPLAY_RANGE_INT) == UNITY_DISPLAY_RANGE_INT)
148635375f98Sopenharmony_ci                {
148735375f98Sopenharmony_ci                    expect_val = *(UNITY_PTR_ATTRIBUTE const UNITY_INT16*)expected;
148835375f98Sopenharmony_ci                    actual_val = *(UNITY_PTR_ATTRIBUTE const UNITY_INT16*)actual;
148935375f98Sopenharmony_ci                    increment  = sizeof(UNITY_INT16);
149035375f98Sopenharmony_ci                }
149135375f98Sopenharmony_ci                else
149235375f98Sopenharmony_ci                {
149335375f98Sopenharmony_ci                    expect_val = (UNITY_INT)*(UNITY_PTR_ATTRIBUTE const UNITY_UINT16*)expected;
149435375f98Sopenharmony_ci                    actual_val = (UNITY_INT)*(UNITY_PTR_ATTRIBUTE const UNITY_UINT16*)actual;
149535375f98Sopenharmony_ci                    increment  = sizeof(UNITY_UINT16);
149635375f98Sopenharmony_ci                }
149735375f98Sopenharmony_ci                break;
149835375f98Sopenharmony_ci
149935375f98Sopenharmony_ci#ifdef UNITY_SUPPORT_64
150035375f98Sopenharmony_ci            case 8:
150135375f98Sopenharmony_ci                /* fixing problems with signed overflow on unsigned numbers */
150235375f98Sopenharmony_ci                if ((style & UNITY_DISPLAY_RANGE_INT) == UNITY_DISPLAY_RANGE_INT)
150335375f98Sopenharmony_ci                {
150435375f98Sopenharmony_ci                    expect_val = *(UNITY_PTR_ATTRIBUTE const UNITY_INT64*)expected;
150535375f98Sopenharmony_ci                    actual_val = *(UNITY_PTR_ATTRIBUTE const UNITY_INT64*)actual;
150635375f98Sopenharmony_ci                    increment  = sizeof(UNITY_INT64);
150735375f98Sopenharmony_ci                }
150835375f98Sopenharmony_ci                else
150935375f98Sopenharmony_ci                {
151035375f98Sopenharmony_ci                    expect_val = (UNITY_INT)*(UNITY_PTR_ATTRIBUTE const UNITY_UINT64*)expected;
151135375f98Sopenharmony_ci                    actual_val = (UNITY_INT)*(UNITY_PTR_ATTRIBUTE const UNITY_UINT64*)actual;
151235375f98Sopenharmony_ci                    increment  = sizeof(UNITY_UINT64);
151335375f98Sopenharmony_ci                }
151435375f98Sopenharmony_ci                break;
151535375f98Sopenharmony_ci#endif
151635375f98Sopenharmony_ci
151735375f98Sopenharmony_ci            default: /* default is length 4 bytes */
151835375f98Sopenharmony_ci            case 4:
151935375f98Sopenharmony_ci                /* fixing problems with signed overflow on unsigned numbers */
152035375f98Sopenharmony_ci                if ((style & UNITY_DISPLAY_RANGE_INT) == UNITY_DISPLAY_RANGE_INT)
152135375f98Sopenharmony_ci                {
152235375f98Sopenharmony_ci                    expect_val = *(UNITY_PTR_ATTRIBUTE const UNITY_INT32*)expected;
152335375f98Sopenharmony_ci                    actual_val = *(UNITY_PTR_ATTRIBUTE const UNITY_INT32*)actual;
152435375f98Sopenharmony_ci                    increment  = sizeof(UNITY_INT32);
152535375f98Sopenharmony_ci                }
152635375f98Sopenharmony_ci                else
152735375f98Sopenharmony_ci                {
152835375f98Sopenharmony_ci                    expect_val = (UNITY_INT)*(UNITY_PTR_ATTRIBUTE const UNITY_UINT32*)expected;
152935375f98Sopenharmony_ci                    actual_val = (UNITY_INT)*(UNITY_PTR_ATTRIBUTE const UNITY_UINT32*)actual;
153035375f98Sopenharmony_ci                    increment  = sizeof(UNITY_UINT32);
153135375f98Sopenharmony_ci                }
153235375f98Sopenharmony_ci                length = 4;
153335375f98Sopenharmony_ci                break;
153435375f98Sopenharmony_ci        }
153535375f98Sopenharmony_ci
153635375f98Sopenharmony_ci        if ((style & UNITY_DISPLAY_RANGE_INT) == UNITY_DISPLAY_RANGE_INT)
153735375f98Sopenharmony_ci        {
153835375f98Sopenharmony_ci            if (actual_val > expect_val)
153935375f98Sopenharmony_ci            {
154035375f98Sopenharmony_ci                Unity.CurrentTestFailed = (((UNITY_UINT)actual_val - (UNITY_UINT)expect_val) > delta);
154135375f98Sopenharmony_ci            }
154235375f98Sopenharmony_ci            else
154335375f98Sopenharmony_ci            {
154435375f98Sopenharmony_ci                Unity.CurrentTestFailed = (((UNITY_UINT)expect_val - (UNITY_UINT)actual_val) > delta);
154535375f98Sopenharmony_ci            }
154635375f98Sopenharmony_ci        }
154735375f98Sopenharmony_ci        else
154835375f98Sopenharmony_ci        {
154935375f98Sopenharmony_ci            if ((UNITY_UINT)actual_val > (UNITY_UINT)expect_val)
155035375f98Sopenharmony_ci            {
155135375f98Sopenharmony_ci                Unity.CurrentTestFailed = (((UNITY_UINT)actual_val - (UNITY_UINT)expect_val) > delta);
155235375f98Sopenharmony_ci            }
155335375f98Sopenharmony_ci            else
155435375f98Sopenharmony_ci            {
155535375f98Sopenharmony_ci                Unity.CurrentTestFailed = (((UNITY_UINT)expect_val - (UNITY_UINT)actual_val) > delta);
155635375f98Sopenharmony_ci            }
155735375f98Sopenharmony_ci        }
155835375f98Sopenharmony_ci
155935375f98Sopenharmony_ci        if (Unity.CurrentTestFailed)
156035375f98Sopenharmony_ci        {
156135375f98Sopenharmony_ci            if ((style & UNITY_DISPLAY_RANGE_UINT) && (length < (UNITY_INT_WIDTH / 8)))
156235375f98Sopenharmony_ci            {   /* For UINT, remove sign extension (padding 1's) from signed type casts above */
156335375f98Sopenharmony_ci                UNITY_INT mask = 1;
156435375f98Sopenharmony_ci                mask = (mask << 8 * length) - 1;
156535375f98Sopenharmony_ci                expect_val &= mask;
156635375f98Sopenharmony_ci                actual_val &= mask;
156735375f98Sopenharmony_ci            }
156835375f98Sopenharmony_ci            UnityTestResultsFailBegin(lineNumber);
156935375f98Sopenharmony_ci            UnityPrint(UnityStrDelta);
157035375f98Sopenharmony_ci            UnityPrintNumberByStyle((UNITY_INT)delta, style);
157135375f98Sopenharmony_ci            UnityPrint(UnityStrElement);
157235375f98Sopenharmony_ci            UnityPrintNumberUnsigned(num_elements - elements - 1);
157335375f98Sopenharmony_ci            UnityPrint(UnityStrExpected);
157435375f98Sopenharmony_ci            UnityPrintNumberByStyle(expect_val, style);
157535375f98Sopenharmony_ci            UnityPrint(UnityStrWas);
157635375f98Sopenharmony_ci            UnityPrintNumberByStyle(actual_val, style);
157735375f98Sopenharmony_ci            UnityAddMsgIfSpecified(msg);
157835375f98Sopenharmony_ci            UNITY_FAIL_AND_BAIL;
157935375f98Sopenharmony_ci        }
158035375f98Sopenharmony_ci        /* Walk through array by incrementing the pointers */
158135375f98Sopenharmony_ci        if (flags == UNITY_ARRAY_TO_ARRAY)
158235375f98Sopenharmony_ci        {
158335375f98Sopenharmony_ci            expected = (UNITY_INTERNAL_PTR)((const char*)expected + increment);
158435375f98Sopenharmony_ci        }
158535375f98Sopenharmony_ci        actual = (UNITY_INTERNAL_PTR)((const char*)actual + increment);
158635375f98Sopenharmony_ci    }
158735375f98Sopenharmony_ci}
158835375f98Sopenharmony_ci
158935375f98Sopenharmony_ci/*-----------------------------------------------*/
159035375f98Sopenharmony_civoid UnityAssertEqualString(const char* expected,
159135375f98Sopenharmony_ci                            const char* actual,
159235375f98Sopenharmony_ci                            const char* msg,
159335375f98Sopenharmony_ci                            const UNITY_LINE_TYPE lineNumber)
159435375f98Sopenharmony_ci{
159535375f98Sopenharmony_ci    UNITY_UINT32 i;
159635375f98Sopenharmony_ci
159735375f98Sopenharmony_ci    RETURN_IF_FAIL_OR_IGNORE;
159835375f98Sopenharmony_ci
159935375f98Sopenharmony_ci    /* if both pointers not null compare the strings */
160035375f98Sopenharmony_ci    if (expected && actual)
160135375f98Sopenharmony_ci    {
160235375f98Sopenharmony_ci        for (i = 0; expected[i] || actual[i]; i++)
160335375f98Sopenharmony_ci        {
160435375f98Sopenharmony_ci            if (expected[i] != actual[i])
160535375f98Sopenharmony_ci            {
160635375f98Sopenharmony_ci                Unity.CurrentTestFailed = 1;
160735375f98Sopenharmony_ci                break;
160835375f98Sopenharmony_ci            }
160935375f98Sopenharmony_ci        }
161035375f98Sopenharmony_ci    }
161135375f98Sopenharmony_ci    else
161235375f98Sopenharmony_ci    { /* fail if either null but not if both */
161335375f98Sopenharmony_ci        if (expected || actual)
161435375f98Sopenharmony_ci        {
161535375f98Sopenharmony_ci            Unity.CurrentTestFailed = 1;
161635375f98Sopenharmony_ci        }
161735375f98Sopenharmony_ci    }
161835375f98Sopenharmony_ci
161935375f98Sopenharmony_ci    if (Unity.CurrentTestFailed)
162035375f98Sopenharmony_ci    {
162135375f98Sopenharmony_ci        UnityTestResultsFailBegin(lineNumber);
162235375f98Sopenharmony_ci        UnityPrintExpectedAndActualStrings(expected, actual);
162335375f98Sopenharmony_ci        UnityAddMsgIfSpecified(msg);
162435375f98Sopenharmony_ci        UNITY_FAIL_AND_BAIL;
162535375f98Sopenharmony_ci    }
162635375f98Sopenharmony_ci}
162735375f98Sopenharmony_ci
162835375f98Sopenharmony_ci/*-----------------------------------------------*/
162935375f98Sopenharmony_civoid UnityAssertEqualStringLen(const char* expected,
163035375f98Sopenharmony_ci                               const char* actual,
163135375f98Sopenharmony_ci                               const UNITY_UINT32 length,
163235375f98Sopenharmony_ci                               const char* msg,
163335375f98Sopenharmony_ci                               const UNITY_LINE_TYPE lineNumber)
163435375f98Sopenharmony_ci{
163535375f98Sopenharmony_ci    UNITY_UINT32 i;
163635375f98Sopenharmony_ci
163735375f98Sopenharmony_ci    RETURN_IF_FAIL_OR_IGNORE;
163835375f98Sopenharmony_ci
163935375f98Sopenharmony_ci    /* if both pointers not null compare the strings */
164035375f98Sopenharmony_ci    if (expected && actual)
164135375f98Sopenharmony_ci    {
164235375f98Sopenharmony_ci        for (i = 0; (i < length) && (expected[i] || actual[i]); i++)
164335375f98Sopenharmony_ci        {
164435375f98Sopenharmony_ci            if (expected[i] != actual[i])
164535375f98Sopenharmony_ci            {
164635375f98Sopenharmony_ci                Unity.CurrentTestFailed = 1;
164735375f98Sopenharmony_ci                break;
164835375f98Sopenharmony_ci            }
164935375f98Sopenharmony_ci        }
165035375f98Sopenharmony_ci    }
165135375f98Sopenharmony_ci    else
165235375f98Sopenharmony_ci    { /* fail if either null but not if both */
165335375f98Sopenharmony_ci        if (expected || actual)
165435375f98Sopenharmony_ci        {
165535375f98Sopenharmony_ci            Unity.CurrentTestFailed = 1;
165635375f98Sopenharmony_ci        }
165735375f98Sopenharmony_ci    }
165835375f98Sopenharmony_ci
165935375f98Sopenharmony_ci    if (Unity.CurrentTestFailed)
166035375f98Sopenharmony_ci    {
166135375f98Sopenharmony_ci        UnityTestResultsFailBegin(lineNumber);
166235375f98Sopenharmony_ci        UnityPrintExpectedAndActualStringsLen(expected, actual, length);
166335375f98Sopenharmony_ci        UnityAddMsgIfSpecified(msg);
166435375f98Sopenharmony_ci        UNITY_FAIL_AND_BAIL;
166535375f98Sopenharmony_ci    }
166635375f98Sopenharmony_ci}
166735375f98Sopenharmony_ci
166835375f98Sopenharmony_ci/*-----------------------------------------------*/
166935375f98Sopenharmony_civoid UnityAssertEqualStringArray(UNITY_INTERNAL_PTR expected,
167035375f98Sopenharmony_ci                                 const char** actual,
167135375f98Sopenharmony_ci                                 const UNITY_UINT32 num_elements,
167235375f98Sopenharmony_ci                                 const char* msg,
167335375f98Sopenharmony_ci                                 const UNITY_LINE_TYPE lineNumber,
167435375f98Sopenharmony_ci                                 const UNITY_FLAGS_T flags)
167535375f98Sopenharmony_ci{
167635375f98Sopenharmony_ci    UNITY_UINT32 i = 0;
167735375f98Sopenharmony_ci    UNITY_UINT32 j = 0;
167835375f98Sopenharmony_ci    const char* expd = NULL;
167935375f98Sopenharmony_ci    const char* act = NULL;
168035375f98Sopenharmony_ci
168135375f98Sopenharmony_ci    RETURN_IF_FAIL_OR_IGNORE;
168235375f98Sopenharmony_ci
168335375f98Sopenharmony_ci    /* if no elements, it's an error */
168435375f98Sopenharmony_ci    if (num_elements == 0)
168535375f98Sopenharmony_ci    {
168635375f98Sopenharmony_ci#ifdef UNITY_COMPARE_PTRS_ON_ZERO_ARRAY
168735375f98Sopenharmony_ci        UNITY_TEST_ASSERT_EQUAL_PTR(expected, actual, lineNumber, msg);
168835375f98Sopenharmony_ci#else
168935375f98Sopenharmony_ci        UnityPrintPointlessAndBail();
169035375f98Sopenharmony_ci#endif
169135375f98Sopenharmony_ci    }
169235375f98Sopenharmony_ci
169335375f98Sopenharmony_ci    if ((const void*)expected == (const void*)actual)
169435375f98Sopenharmony_ci    {
169535375f98Sopenharmony_ci        return; /* Both are NULL or same pointer */
169635375f98Sopenharmony_ci    }
169735375f98Sopenharmony_ci
169835375f98Sopenharmony_ci    if (UnityIsOneArrayNull((UNITY_INTERNAL_PTR)expected, (UNITY_INTERNAL_PTR)actual, lineNumber, msg))
169935375f98Sopenharmony_ci    {
170035375f98Sopenharmony_ci        UNITY_FAIL_AND_BAIL;
170135375f98Sopenharmony_ci    }
170235375f98Sopenharmony_ci
170335375f98Sopenharmony_ci    if (flags != UNITY_ARRAY_TO_ARRAY)
170435375f98Sopenharmony_ci    {
170535375f98Sopenharmony_ci        expd = (const char*)expected;
170635375f98Sopenharmony_ci    }
170735375f98Sopenharmony_ci
170835375f98Sopenharmony_ci    do
170935375f98Sopenharmony_ci    {
171035375f98Sopenharmony_ci        act = actual[j];
171135375f98Sopenharmony_ci        if (flags == UNITY_ARRAY_TO_ARRAY)
171235375f98Sopenharmony_ci        {
171335375f98Sopenharmony_ci            expd = ((const char* const*)expected)[j];
171435375f98Sopenharmony_ci        }
171535375f98Sopenharmony_ci
171635375f98Sopenharmony_ci        /* if both pointers not null compare the strings */
171735375f98Sopenharmony_ci        if (expd && act)
171835375f98Sopenharmony_ci        {
171935375f98Sopenharmony_ci            for (i = 0; expd[i] || act[i]; i++)
172035375f98Sopenharmony_ci            {
172135375f98Sopenharmony_ci                if (expd[i] != act[i])
172235375f98Sopenharmony_ci                {
172335375f98Sopenharmony_ci                    Unity.CurrentTestFailed = 1;
172435375f98Sopenharmony_ci                    break;
172535375f98Sopenharmony_ci                }
172635375f98Sopenharmony_ci            }
172735375f98Sopenharmony_ci        }
172835375f98Sopenharmony_ci        else
172935375f98Sopenharmony_ci        { /* handle case of one pointers being null (if both null, test should pass) */
173035375f98Sopenharmony_ci            if (expd != act)
173135375f98Sopenharmony_ci            {
173235375f98Sopenharmony_ci                Unity.CurrentTestFailed = 1;
173335375f98Sopenharmony_ci            }
173435375f98Sopenharmony_ci        }
173535375f98Sopenharmony_ci
173635375f98Sopenharmony_ci        if (Unity.CurrentTestFailed)
173735375f98Sopenharmony_ci        {
173835375f98Sopenharmony_ci            UnityTestResultsFailBegin(lineNumber);
173935375f98Sopenharmony_ci            if (num_elements > 1)
174035375f98Sopenharmony_ci            {
174135375f98Sopenharmony_ci                UnityPrint(UnityStrElement);
174235375f98Sopenharmony_ci                UnityPrintNumberUnsigned(j);
174335375f98Sopenharmony_ci            }
174435375f98Sopenharmony_ci            UnityPrintExpectedAndActualStrings(expd, act);
174535375f98Sopenharmony_ci            UnityAddMsgIfSpecified(msg);
174635375f98Sopenharmony_ci            UNITY_FAIL_AND_BAIL;
174735375f98Sopenharmony_ci        }
174835375f98Sopenharmony_ci    } while (++j < num_elements);
174935375f98Sopenharmony_ci}
175035375f98Sopenharmony_ci
175135375f98Sopenharmony_ci/*-----------------------------------------------*/
175235375f98Sopenharmony_civoid UnityAssertEqualMemory(UNITY_INTERNAL_PTR expected,
175335375f98Sopenharmony_ci                            UNITY_INTERNAL_PTR actual,
175435375f98Sopenharmony_ci                            const UNITY_UINT32 length,
175535375f98Sopenharmony_ci                            const UNITY_UINT32 num_elements,
175635375f98Sopenharmony_ci                            const char* msg,
175735375f98Sopenharmony_ci                            const UNITY_LINE_TYPE lineNumber,
175835375f98Sopenharmony_ci                            const UNITY_FLAGS_T flags)
175935375f98Sopenharmony_ci{
176035375f98Sopenharmony_ci    UNITY_PTR_ATTRIBUTE const unsigned char* ptr_exp = (UNITY_PTR_ATTRIBUTE const unsigned char*)expected;
176135375f98Sopenharmony_ci    UNITY_PTR_ATTRIBUTE const unsigned char* ptr_act = (UNITY_PTR_ATTRIBUTE const unsigned char*)actual;
176235375f98Sopenharmony_ci    UNITY_UINT32 elements = num_elements;
176335375f98Sopenharmony_ci    UNITY_UINT32 bytes;
176435375f98Sopenharmony_ci
176535375f98Sopenharmony_ci    RETURN_IF_FAIL_OR_IGNORE;
176635375f98Sopenharmony_ci
176735375f98Sopenharmony_ci    if (elements == 0)
176835375f98Sopenharmony_ci    {
176935375f98Sopenharmony_ci#ifdef UNITY_COMPARE_PTRS_ON_ZERO_ARRAY
177035375f98Sopenharmony_ci        UNITY_TEST_ASSERT_EQUAL_PTR(expected, actual, lineNumber, msg);
177135375f98Sopenharmony_ci#else
177235375f98Sopenharmony_ci        UnityPrintPointlessAndBail();
177335375f98Sopenharmony_ci#endif
177435375f98Sopenharmony_ci    }
177535375f98Sopenharmony_ci    if (length == 0)
177635375f98Sopenharmony_ci    {
177735375f98Sopenharmony_ci        UnityPrintPointlessAndBail();
177835375f98Sopenharmony_ci    }
177935375f98Sopenharmony_ci
178035375f98Sopenharmony_ci    if (expected == actual)
178135375f98Sopenharmony_ci    {
178235375f98Sopenharmony_ci        return; /* Both are NULL or same pointer */
178335375f98Sopenharmony_ci    }
178435375f98Sopenharmony_ci
178535375f98Sopenharmony_ci    if (UnityIsOneArrayNull(expected, actual, lineNumber, msg))
178635375f98Sopenharmony_ci    {
178735375f98Sopenharmony_ci        UNITY_FAIL_AND_BAIL;
178835375f98Sopenharmony_ci    }
178935375f98Sopenharmony_ci
179035375f98Sopenharmony_ci    while (elements--)
179135375f98Sopenharmony_ci    {
179235375f98Sopenharmony_ci        bytes = length;
179335375f98Sopenharmony_ci        while (bytes--)
179435375f98Sopenharmony_ci        {
179535375f98Sopenharmony_ci            if (*ptr_exp != *ptr_act)
179635375f98Sopenharmony_ci            {
179735375f98Sopenharmony_ci                UnityTestResultsFailBegin(lineNumber);
179835375f98Sopenharmony_ci                UnityPrint(UnityStrMemory);
179935375f98Sopenharmony_ci                if (num_elements > 1)
180035375f98Sopenharmony_ci                {
180135375f98Sopenharmony_ci                    UnityPrint(UnityStrElement);
180235375f98Sopenharmony_ci                    UnityPrintNumberUnsigned(num_elements - elements - 1);
180335375f98Sopenharmony_ci                }
180435375f98Sopenharmony_ci                UnityPrint(UnityStrByte);
180535375f98Sopenharmony_ci                UnityPrintNumberUnsigned(length - bytes - 1);
180635375f98Sopenharmony_ci                UnityPrint(UnityStrExpected);
180735375f98Sopenharmony_ci                UnityPrintNumberByStyle(*ptr_exp, UNITY_DISPLAY_STYLE_HEX8);
180835375f98Sopenharmony_ci                UnityPrint(UnityStrWas);
180935375f98Sopenharmony_ci                UnityPrintNumberByStyle(*ptr_act, UNITY_DISPLAY_STYLE_HEX8);
181035375f98Sopenharmony_ci                UnityAddMsgIfSpecified(msg);
181135375f98Sopenharmony_ci                UNITY_FAIL_AND_BAIL;
181235375f98Sopenharmony_ci            }
181335375f98Sopenharmony_ci            ptr_exp++;
181435375f98Sopenharmony_ci            ptr_act++;
181535375f98Sopenharmony_ci        }
181635375f98Sopenharmony_ci        if (flags == UNITY_ARRAY_TO_VAL)
181735375f98Sopenharmony_ci        {
181835375f98Sopenharmony_ci            ptr_exp = (UNITY_PTR_ATTRIBUTE const unsigned char*)expected;
181935375f98Sopenharmony_ci        }
182035375f98Sopenharmony_ci    }
182135375f98Sopenharmony_ci}
182235375f98Sopenharmony_ci
182335375f98Sopenharmony_ci/*-----------------------------------------------*/
182435375f98Sopenharmony_ci
182535375f98Sopenharmony_cistatic union
182635375f98Sopenharmony_ci{
182735375f98Sopenharmony_ci    UNITY_INT8 i8;
182835375f98Sopenharmony_ci    UNITY_INT16 i16;
182935375f98Sopenharmony_ci    UNITY_INT32 i32;
183035375f98Sopenharmony_ci#ifdef UNITY_SUPPORT_64
183135375f98Sopenharmony_ci    UNITY_INT64 i64;
183235375f98Sopenharmony_ci#endif
183335375f98Sopenharmony_ci#ifndef UNITY_EXCLUDE_FLOAT
183435375f98Sopenharmony_ci    float f;
183535375f98Sopenharmony_ci#endif
183635375f98Sopenharmony_ci#ifndef UNITY_EXCLUDE_DOUBLE
183735375f98Sopenharmony_ci    double d;
183835375f98Sopenharmony_ci#endif
183935375f98Sopenharmony_ci} UnityQuickCompare;
184035375f98Sopenharmony_ci
184135375f98Sopenharmony_ciUNITY_INTERNAL_PTR UnityNumToPtr(const UNITY_INT num, const UNITY_UINT8 size)
184235375f98Sopenharmony_ci{
184335375f98Sopenharmony_ci    switch(size)
184435375f98Sopenharmony_ci    {
184535375f98Sopenharmony_ci        case 1:
184635375f98Sopenharmony_ci            UnityQuickCompare.i8 = (UNITY_INT8)num;
184735375f98Sopenharmony_ci            return (UNITY_INTERNAL_PTR)(&UnityQuickCompare.i8);
184835375f98Sopenharmony_ci
184935375f98Sopenharmony_ci        case 2:
185035375f98Sopenharmony_ci            UnityQuickCompare.i16 = (UNITY_INT16)num;
185135375f98Sopenharmony_ci            return (UNITY_INTERNAL_PTR)(&UnityQuickCompare.i16);
185235375f98Sopenharmony_ci
185335375f98Sopenharmony_ci#ifdef UNITY_SUPPORT_64
185435375f98Sopenharmony_ci        case 8:
185535375f98Sopenharmony_ci            UnityQuickCompare.i64 = (UNITY_INT64)num;
185635375f98Sopenharmony_ci            return (UNITY_INTERNAL_PTR)(&UnityQuickCompare.i64);
185735375f98Sopenharmony_ci#endif
185835375f98Sopenharmony_ci
185935375f98Sopenharmony_ci        default: /* 4 bytes */
186035375f98Sopenharmony_ci            UnityQuickCompare.i32 = (UNITY_INT32)num;
186135375f98Sopenharmony_ci            return (UNITY_INTERNAL_PTR)(&UnityQuickCompare.i32);
186235375f98Sopenharmony_ci    }
186335375f98Sopenharmony_ci}
186435375f98Sopenharmony_ci
186535375f98Sopenharmony_ci#ifndef UNITY_EXCLUDE_FLOAT
186635375f98Sopenharmony_ci/*-----------------------------------------------*/
186735375f98Sopenharmony_ciUNITY_INTERNAL_PTR UnityFloatToPtr(const float num)
186835375f98Sopenharmony_ci{
186935375f98Sopenharmony_ci    UnityQuickCompare.f = num;
187035375f98Sopenharmony_ci    return (UNITY_INTERNAL_PTR)(&UnityQuickCompare.f);
187135375f98Sopenharmony_ci}
187235375f98Sopenharmony_ci#endif
187335375f98Sopenharmony_ci
187435375f98Sopenharmony_ci#ifndef UNITY_EXCLUDE_DOUBLE
187535375f98Sopenharmony_ci/*-----------------------------------------------*/
187635375f98Sopenharmony_ciUNITY_INTERNAL_PTR UnityDoubleToPtr(const double num)
187735375f98Sopenharmony_ci{
187835375f98Sopenharmony_ci    UnityQuickCompare.d = num;
187935375f98Sopenharmony_ci    return (UNITY_INTERNAL_PTR)(&UnityQuickCompare.d);
188035375f98Sopenharmony_ci}
188135375f98Sopenharmony_ci#endif
188235375f98Sopenharmony_ci
188335375f98Sopenharmony_ci#ifdef UNITY_INCLUDE_PRINT_FORMATTED
188435375f98Sopenharmony_ci
188535375f98Sopenharmony_ci/*-----------------------------------------------
188635375f98Sopenharmony_ci * printf length modifier helpers
188735375f98Sopenharmony_ci *-----------------------------------------------*/
188835375f98Sopenharmony_ci
188935375f98Sopenharmony_cienum UnityLengthModifier {
189035375f98Sopenharmony_ci    UNITY_LENGTH_MODIFIER_NONE,
189135375f98Sopenharmony_ci    UNITY_LENGTH_MODIFIER_LONG_LONG,
189235375f98Sopenharmony_ci    UNITY_LENGTH_MODIFIER_LONG,
189335375f98Sopenharmony_ci};
189435375f98Sopenharmony_ci
189535375f98Sopenharmony_ci#define UNITY_EXTRACT_ARG(NUMBER_T, NUMBER, LENGTH_MOD, VA, ARG_T) \
189635375f98Sopenharmony_cido {                                                               \
189735375f98Sopenharmony_ci    switch (LENGTH_MOD)                                            \
189835375f98Sopenharmony_ci    {                                                              \
189935375f98Sopenharmony_ci        case UNITY_LENGTH_MODIFIER_LONG_LONG:                      \
190035375f98Sopenharmony_ci        {                                                          \
190135375f98Sopenharmony_ci            NUMBER = (NUMBER_T)va_arg(VA, long long ARG_T);        \
190235375f98Sopenharmony_ci            break;                                                 \
190335375f98Sopenharmony_ci        }                                                          \
190435375f98Sopenharmony_ci        case UNITY_LENGTH_MODIFIER_LONG:                           \
190535375f98Sopenharmony_ci        {                                                          \
190635375f98Sopenharmony_ci            NUMBER = (NUMBER_T)va_arg(VA, long ARG_T);             \
190735375f98Sopenharmony_ci            break;                                                 \
190835375f98Sopenharmony_ci        }                                                          \
190935375f98Sopenharmony_ci        case UNITY_LENGTH_MODIFIER_NONE:                           \
191035375f98Sopenharmony_ci        default:                                                   \
191135375f98Sopenharmony_ci        {                                                          \
191235375f98Sopenharmony_ci            NUMBER = (NUMBER_T)va_arg(VA, ARG_T);                  \
191335375f98Sopenharmony_ci            break;                                                 \
191435375f98Sopenharmony_ci        }                                                          \
191535375f98Sopenharmony_ci    }                                                              \
191635375f98Sopenharmony_ci} while (0)
191735375f98Sopenharmony_ci
191835375f98Sopenharmony_cistatic enum UnityLengthModifier UnityLengthModifierGet(const char *pch, int *length)
191935375f98Sopenharmony_ci{
192035375f98Sopenharmony_ci    enum UnityLengthModifier length_mod;
192135375f98Sopenharmony_ci    switch (pch[0])
192235375f98Sopenharmony_ci    {
192335375f98Sopenharmony_ci        case 'l':
192435375f98Sopenharmony_ci            {
192535375f98Sopenharmony_ci                if (pch[1] == 'l')
192635375f98Sopenharmony_ci                {
192735375f98Sopenharmony_ci                    *length = 2;
192835375f98Sopenharmony_ci                    length_mod = UNITY_LENGTH_MODIFIER_LONG_LONG;
192935375f98Sopenharmony_ci                }
193035375f98Sopenharmony_ci                else
193135375f98Sopenharmony_ci                {
193235375f98Sopenharmony_ci                    *length = 1;
193335375f98Sopenharmony_ci                    length_mod = UNITY_LENGTH_MODIFIER_LONG;
193435375f98Sopenharmony_ci                }
193535375f98Sopenharmony_ci                break;
193635375f98Sopenharmony_ci            }
193735375f98Sopenharmony_ci        case 'h':
193835375f98Sopenharmony_ci            {
193935375f98Sopenharmony_ci                // short and char are converted to int
194035375f98Sopenharmony_ci                length_mod = UNITY_LENGTH_MODIFIER_NONE;
194135375f98Sopenharmony_ci                if (pch[1] == 'h')
194235375f98Sopenharmony_ci                {
194335375f98Sopenharmony_ci                    *length = 2;
194435375f98Sopenharmony_ci                }
194535375f98Sopenharmony_ci                else
194635375f98Sopenharmony_ci                {
194735375f98Sopenharmony_ci                    *length = 1;
194835375f98Sopenharmony_ci                }
194935375f98Sopenharmony_ci                break;
195035375f98Sopenharmony_ci            }
195135375f98Sopenharmony_ci        case 'j':
195235375f98Sopenharmony_ci        case 'z':
195335375f98Sopenharmony_ci        case 't':
195435375f98Sopenharmony_ci        case 'L':
195535375f98Sopenharmony_ci            {
195635375f98Sopenharmony_ci                // Not supported, but should gobble up the length specifier anyway
195735375f98Sopenharmony_ci                length_mod = UNITY_LENGTH_MODIFIER_NONE;
195835375f98Sopenharmony_ci                *length = 1;
195935375f98Sopenharmony_ci                break;
196035375f98Sopenharmony_ci            }
196135375f98Sopenharmony_ci        default:
196235375f98Sopenharmony_ci            {
196335375f98Sopenharmony_ci                length_mod = UNITY_LENGTH_MODIFIER_NONE;
196435375f98Sopenharmony_ci                *length = 0;
196535375f98Sopenharmony_ci            }
196635375f98Sopenharmony_ci    }
196735375f98Sopenharmony_ci    return length_mod;
196835375f98Sopenharmony_ci}
196935375f98Sopenharmony_ci
197035375f98Sopenharmony_ci/*-----------------------------------------------
197135375f98Sopenharmony_ci * printf helper function
197235375f98Sopenharmony_ci *-----------------------------------------------*/
197335375f98Sopenharmony_cistatic void UnityPrintFVA(const char* format, va_list va)
197435375f98Sopenharmony_ci{
197535375f98Sopenharmony_ci    const char* pch = format;
197635375f98Sopenharmony_ci    if (pch != NULL)
197735375f98Sopenharmony_ci    {
197835375f98Sopenharmony_ci        while (*pch)
197935375f98Sopenharmony_ci        {
198035375f98Sopenharmony_ci            /* format identification character */
198135375f98Sopenharmony_ci            if (*pch == '%')
198235375f98Sopenharmony_ci            {
198335375f98Sopenharmony_ci                pch++;
198435375f98Sopenharmony_ci
198535375f98Sopenharmony_ci                if (pch != NULL)
198635375f98Sopenharmony_ci                {
198735375f98Sopenharmony_ci                    int length_mod_size;
198835375f98Sopenharmony_ci                    enum UnityLengthModifier length_mod = UnityLengthModifierGet(pch, &length_mod_size);
198935375f98Sopenharmony_ci                    pch += length_mod_size;
199035375f98Sopenharmony_ci
199135375f98Sopenharmony_ci                    switch (*pch)
199235375f98Sopenharmony_ci                    {
199335375f98Sopenharmony_ci                        case 'd':
199435375f98Sopenharmony_ci                        case 'i':
199535375f98Sopenharmony_ci                            {
199635375f98Sopenharmony_ci                                UNITY_INT number;
199735375f98Sopenharmony_ci                                UNITY_EXTRACT_ARG(UNITY_INT, number, length_mod, va, int);
199835375f98Sopenharmony_ci                                UnityPrintNumber((UNITY_INT)number);
199935375f98Sopenharmony_ci                                break;
200035375f98Sopenharmony_ci                            }
200135375f98Sopenharmony_ci#ifndef UNITY_EXCLUDE_FLOAT_PRINT
200235375f98Sopenharmony_ci                        case 'f':
200335375f98Sopenharmony_ci                        case 'g':
200435375f98Sopenharmony_ci                            {
200535375f98Sopenharmony_ci                                const double number = va_arg(va, double);
200635375f98Sopenharmony_ci                                UnityPrintFloat((UNITY_DOUBLE)number);
200735375f98Sopenharmony_ci                                break;
200835375f98Sopenharmony_ci                            }
200935375f98Sopenharmony_ci#endif
201035375f98Sopenharmony_ci                        case 'u':
201135375f98Sopenharmony_ci                            {
201235375f98Sopenharmony_ci                                UNITY_UINT number;
201335375f98Sopenharmony_ci                                UNITY_EXTRACT_ARG(UNITY_UINT, number, length_mod, va, unsigned int);
201435375f98Sopenharmony_ci                                UnityPrintNumberUnsigned(number);
201535375f98Sopenharmony_ci                                break;
201635375f98Sopenharmony_ci                            }
201735375f98Sopenharmony_ci                        case 'b':
201835375f98Sopenharmony_ci                            {
201935375f98Sopenharmony_ci                                UNITY_UINT number;
202035375f98Sopenharmony_ci                                UNITY_EXTRACT_ARG(UNITY_UINT, number, length_mod, va, unsigned int);
202135375f98Sopenharmony_ci                                const UNITY_UINT mask = (UNITY_UINT)0 - (UNITY_UINT)1;
202235375f98Sopenharmony_ci                                UNITY_OUTPUT_CHAR('0');
202335375f98Sopenharmony_ci                                UNITY_OUTPUT_CHAR('b');
202435375f98Sopenharmony_ci                                UnityPrintMask(mask, number);
202535375f98Sopenharmony_ci                                break;
202635375f98Sopenharmony_ci                            }
202735375f98Sopenharmony_ci                        case 'x':
202835375f98Sopenharmony_ci                        case 'X':
202935375f98Sopenharmony_ci                            {
203035375f98Sopenharmony_ci                                UNITY_UINT number;
203135375f98Sopenharmony_ci                                UNITY_EXTRACT_ARG(UNITY_UINT, number, length_mod, va, unsigned int);
203235375f98Sopenharmony_ci                                UNITY_OUTPUT_CHAR('0');
203335375f98Sopenharmony_ci                                UNITY_OUTPUT_CHAR('x');
203435375f98Sopenharmony_ci                                UnityPrintNumberHex(number, UNITY_MAX_NIBBLES);
203535375f98Sopenharmony_ci                                break;
203635375f98Sopenharmony_ci                            }
203735375f98Sopenharmony_ci                        case 'p':
203835375f98Sopenharmony_ci                            {
203935375f98Sopenharmony_ci                                UNITY_UINT number;
204035375f98Sopenharmony_ci                                char nibbles_to_print = 8;
204135375f98Sopenharmony_ci                                if (UNITY_POINTER_WIDTH == 64)
204235375f98Sopenharmony_ci                                {
204335375f98Sopenharmony_ci                                    length_mod = UNITY_LENGTH_MODIFIER_LONG_LONG;
204435375f98Sopenharmony_ci                                    nibbles_to_print = 16;
204535375f98Sopenharmony_ci                                }
204635375f98Sopenharmony_ci                                UNITY_EXTRACT_ARG(UNITY_UINT, number, length_mod, va, unsigned int);
204735375f98Sopenharmony_ci                                UNITY_OUTPUT_CHAR('0');
204835375f98Sopenharmony_ci                                UNITY_OUTPUT_CHAR('x');
204935375f98Sopenharmony_ci                                UnityPrintNumberHex((UNITY_UINT)number, nibbles_to_print);
205035375f98Sopenharmony_ci                                break;
205135375f98Sopenharmony_ci                            }
205235375f98Sopenharmony_ci                        case 'c':
205335375f98Sopenharmony_ci                            {
205435375f98Sopenharmony_ci                                const int ch = va_arg(va, int);
205535375f98Sopenharmony_ci                                UnityPrintChar((const char *)&ch);
205635375f98Sopenharmony_ci                                break;
205735375f98Sopenharmony_ci                            }
205835375f98Sopenharmony_ci                        case 's':
205935375f98Sopenharmony_ci                            {
206035375f98Sopenharmony_ci                                const char * string = va_arg(va, const char *);
206135375f98Sopenharmony_ci                                UnityPrint(string);
206235375f98Sopenharmony_ci                                break;
206335375f98Sopenharmony_ci                            }
206435375f98Sopenharmony_ci                        case '%':
206535375f98Sopenharmony_ci                            {
206635375f98Sopenharmony_ci                                UnityPrintChar(pch);
206735375f98Sopenharmony_ci                                break;
206835375f98Sopenharmony_ci                            }
206935375f98Sopenharmony_ci                        default:
207035375f98Sopenharmony_ci                            {
207135375f98Sopenharmony_ci                                /* print the unknown format character */
207235375f98Sopenharmony_ci                                UNITY_OUTPUT_CHAR('%');
207335375f98Sopenharmony_ci                                UnityPrintChar(pch);
207435375f98Sopenharmony_ci                                break;
207535375f98Sopenharmony_ci                            }
207635375f98Sopenharmony_ci                    }
207735375f98Sopenharmony_ci                }
207835375f98Sopenharmony_ci            }
207935375f98Sopenharmony_ci#ifdef UNITY_OUTPUT_COLOR
208035375f98Sopenharmony_ci            /* print ANSI escape code */
208135375f98Sopenharmony_ci            else if ((*pch == 27) && (*(pch + 1) == '['))
208235375f98Sopenharmony_ci            {
208335375f98Sopenharmony_ci                pch += UnityPrintAnsiEscapeString(pch);
208435375f98Sopenharmony_ci                continue;
208535375f98Sopenharmony_ci            }
208635375f98Sopenharmony_ci#endif
208735375f98Sopenharmony_ci            else if (*pch == '\n')
208835375f98Sopenharmony_ci            {
208935375f98Sopenharmony_ci                UNITY_PRINT_EOL();
209035375f98Sopenharmony_ci            }
209135375f98Sopenharmony_ci            else
209235375f98Sopenharmony_ci            {
209335375f98Sopenharmony_ci                UnityPrintChar(pch);
209435375f98Sopenharmony_ci            }
209535375f98Sopenharmony_ci
209635375f98Sopenharmony_ci            pch++;
209735375f98Sopenharmony_ci        }
209835375f98Sopenharmony_ci    }
209935375f98Sopenharmony_ci}
210035375f98Sopenharmony_ci
210135375f98Sopenharmony_civoid UnityPrintF(const UNITY_LINE_TYPE line, const char* format, ...)
210235375f98Sopenharmony_ci{
210335375f98Sopenharmony_ci    UnityTestResultsBegin(Unity.TestFile, line);
210435375f98Sopenharmony_ci    UnityPrint("INFO");
210535375f98Sopenharmony_ci    if(format != NULL)
210635375f98Sopenharmony_ci    {
210735375f98Sopenharmony_ci        UnityPrint(": ");
210835375f98Sopenharmony_ci        va_list va;
210935375f98Sopenharmony_ci        va_start(va, format);
211035375f98Sopenharmony_ci        UnityPrintFVA(format, va);
211135375f98Sopenharmony_ci        va_end(va);
211235375f98Sopenharmony_ci    }
211335375f98Sopenharmony_ci    UNITY_PRINT_EOL();
211435375f98Sopenharmony_ci}
211535375f98Sopenharmony_ci#endif /* ! UNITY_INCLUDE_PRINT_FORMATTED */
211635375f98Sopenharmony_ci
211735375f98Sopenharmony_ci
211835375f98Sopenharmony_ci/*-----------------------------------------------
211935375f98Sopenharmony_ci * Control Functions
212035375f98Sopenharmony_ci *-----------------------------------------------*/
212135375f98Sopenharmony_ci
212235375f98Sopenharmony_ci/*-----------------------------------------------*/
212335375f98Sopenharmony_civoid UnityFail(const char* msg, const UNITY_LINE_TYPE line)
212435375f98Sopenharmony_ci{
212535375f98Sopenharmony_ci    RETURN_IF_FAIL_OR_IGNORE;
212635375f98Sopenharmony_ci
212735375f98Sopenharmony_ci    UnityTestResultsBegin(Unity.TestFile, line);
212835375f98Sopenharmony_ci    UnityPrint(UnityStrFail);
212935375f98Sopenharmony_ci    if (msg != NULL)
213035375f98Sopenharmony_ci    {
213135375f98Sopenharmony_ci        UNITY_OUTPUT_CHAR(':');
213235375f98Sopenharmony_ci
213335375f98Sopenharmony_ci#ifdef UNITY_PRINT_TEST_CONTEXT
213435375f98Sopenharmony_ci        UNITY_PRINT_TEST_CONTEXT();
213535375f98Sopenharmony_ci#endif
213635375f98Sopenharmony_ci#ifndef UNITY_EXCLUDE_DETAILS
213735375f98Sopenharmony_ci        if (Unity.CurrentDetail1)
213835375f98Sopenharmony_ci        {
213935375f98Sopenharmony_ci            UnityPrint(UnityStrDetail1Name);
214035375f98Sopenharmony_ci            UnityPrint(Unity.CurrentDetail1);
214135375f98Sopenharmony_ci            if (Unity.CurrentDetail2)
214235375f98Sopenharmony_ci            {
214335375f98Sopenharmony_ci                UnityPrint(UnityStrDetail2Name);
214435375f98Sopenharmony_ci                UnityPrint(Unity.CurrentDetail2);
214535375f98Sopenharmony_ci            }
214635375f98Sopenharmony_ci            UnityPrint(UnityStrSpacer);
214735375f98Sopenharmony_ci        }
214835375f98Sopenharmony_ci#endif
214935375f98Sopenharmony_ci        if (msg[0] != ' ')
215035375f98Sopenharmony_ci        {
215135375f98Sopenharmony_ci            UNITY_OUTPUT_CHAR(' ');
215235375f98Sopenharmony_ci        }
215335375f98Sopenharmony_ci        UnityPrint(msg);
215435375f98Sopenharmony_ci    }
215535375f98Sopenharmony_ci
215635375f98Sopenharmony_ci    UNITY_FAIL_AND_BAIL;
215735375f98Sopenharmony_ci}
215835375f98Sopenharmony_ci
215935375f98Sopenharmony_ci/*-----------------------------------------------*/
216035375f98Sopenharmony_civoid UnityIgnore(const char* msg, const UNITY_LINE_TYPE line)
216135375f98Sopenharmony_ci{
216235375f98Sopenharmony_ci    RETURN_IF_FAIL_OR_IGNORE;
216335375f98Sopenharmony_ci
216435375f98Sopenharmony_ci    UnityTestResultsBegin(Unity.TestFile, line);
216535375f98Sopenharmony_ci    UnityPrint(UnityStrIgnore);
216635375f98Sopenharmony_ci    if (msg != NULL)
216735375f98Sopenharmony_ci    {
216835375f98Sopenharmony_ci        UNITY_OUTPUT_CHAR(':');
216935375f98Sopenharmony_ci        UNITY_OUTPUT_CHAR(' ');
217035375f98Sopenharmony_ci        UnityPrint(msg);
217135375f98Sopenharmony_ci    }
217235375f98Sopenharmony_ci    UNITY_IGNORE_AND_BAIL;
217335375f98Sopenharmony_ci}
217435375f98Sopenharmony_ci
217535375f98Sopenharmony_ci/*-----------------------------------------------*/
217635375f98Sopenharmony_civoid UnityMessage(const char* msg, const UNITY_LINE_TYPE line)
217735375f98Sopenharmony_ci{
217835375f98Sopenharmony_ci    UnityTestResultsBegin(Unity.TestFile, line);
217935375f98Sopenharmony_ci    UnityPrint("INFO");
218035375f98Sopenharmony_ci    if (msg != NULL)
218135375f98Sopenharmony_ci    {
218235375f98Sopenharmony_ci      UNITY_OUTPUT_CHAR(':');
218335375f98Sopenharmony_ci      UNITY_OUTPUT_CHAR(' ');
218435375f98Sopenharmony_ci      UnityPrint(msg);
218535375f98Sopenharmony_ci    }
218635375f98Sopenharmony_ci    UNITY_PRINT_EOL();
218735375f98Sopenharmony_ci}
218835375f98Sopenharmony_ci
218935375f98Sopenharmony_ci/*-----------------------------------------------*/
219035375f98Sopenharmony_ci/* If we have not defined our own test runner, then include our default test runner to make life easier */
219135375f98Sopenharmony_ci#ifndef UNITY_SKIP_DEFAULT_RUNNER
219235375f98Sopenharmony_civoid UnityDefaultTestRun(UnityTestFunction Func, const char* FuncName, const int FuncLineNum)
219335375f98Sopenharmony_ci{
219435375f98Sopenharmony_ci    Unity.CurrentTestName = FuncName;
219535375f98Sopenharmony_ci    Unity.CurrentTestLineNumber = (UNITY_LINE_TYPE)FuncLineNum;
219635375f98Sopenharmony_ci    Unity.NumberOfTests++;
219735375f98Sopenharmony_ci    UNITY_CLR_DETAILS();
219835375f98Sopenharmony_ci    UNITY_EXEC_TIME_START();
219935375f98Sopenharmony_ci    if (TEST_PROTECT())
220035375f98Sopenharmony_ci    {
220135375f98Sopenharmony_ci        setUp();
220235375f98Sopenharmony_ci        Func();
220335375f98Sopenharmony_ci    }
220435375f98Sopenharmony_ci    if (TEST_PROTECT())
220535375f98Sopenharmony_ci    {
220635375f98Sopenharmony_ci        tearDown();
220735375f98Sopenharmony_ci    }
220835375f98Sopenharmony_ci    UNITY_EXEC_TIME_STOP();
220935375f98Sopenharmony_ci    UnityConcludeTest();
221035375f98Sopenharmony_ci}
221135375f98Sopenharmony_ci#endif
221235375f98Sopenharmony_ci
221335375f98Sopenharmony_ci/*-----------------------------------------------*/
221435375f98Sopenharmony_civoid UnitySetTestFile(const char* filename)
221535375f98Sopenharmony_ci{
221635375f98Sopenharmony_ci    Unity.TestFile = filename;
221735375f98Sopenharmony_ci}
221835375f98Sopenharmony_ci
221935375f98Sopenharmony_ci/*-----------------------------------------------*/
222035375f98Sopenharmony_civoid UnityBegin(const char* filename)
222135375f98Sopenharmony_ci{
222235375f98Sopenharmony_ci    Unity.TestFile = filename;
222335375f98Sopenharmony_ci    Unity.CurrentTestName = NULL;
222435375f98Sopenharmony_ci    Unity.CurrentTestLineNumber = 0;
222535375f98Sopenharmony_ci    Unity.NumberOfTests = 0;
222635375f98Sopenharmony_ci    Unity.TestFailures = 0;
222735375f98Sopenharmony_ci    Unity.TestIgnores = 0;
222835375f98Sopenharmony_ci    Unity.CurrentTestFailed = 0;
222935375f98Sopenharmony_ci    Unity.CurrentTestIgnored = 0;
223035375f98Sopenharmony_ci
223135375f98Sopenharmony_ci    UNITY_CLR_DETAILS();
223235375f98Sopenharmony_ci    UNITY_OUTPUT_START();
223335375f98Sopenharmony_ci}
223435375f98Sopenharmony_ci
223535375f98Sopenharmony_ci/*-----------------------------------------------*/
223635375f98Sopenharmony_ciint UnityEnd(void)
223735375f98Sopenharmony_ci{
223835375f98Sopenharmony_ci    UNITY_PRINT_EOL();
223935375f98Sopenharmony_ci    UnityPrint(UnityStrBreaker);
224035375f98Sopenharmony_ci    UNITY_PRINT_EOL();
224135375f98Sopenharmony_ci    UnityPrintNumber((UNITY_INT)(Unity.NumberOfTests));
224235375f98Sopenharmony_ci    UnityPrint(UnityStrResultsTests);
224335375f98Sopenharmony_ci    UnityPrintNumber((UNITY_INT)(Unity.TestFailures));
224435375f98Sopenharmony_ci    UnityPrint(UnityStrResultsFailures);
224535375f98Sopenharmony_ci    UnityPrintNumber((UNITY_INT)(Unity.TestIgnores));
224635375f98Sopenharmony_ci    UnityPrint(UnityStrResultsIgnored);
224735375f98Sopenharmony_ci    UNITY_PRINT_EOL();
224835375f98Sopenharmony_ci    if (Unity.TestFailures == 0U)
224935375f98Sopenharmony_ci    {
225035375f98Sopenharmony_ci        UnityPrint(UnityStrOk);
225135375f98Sopenharmony_ci    }
225235375f98Sopenharmony_ci    else
225335375f98Sopenharmony_ci    {
225435375f98Sopenharmony_ci        UnityPrint(UnityStrFail);
225535375f98Sopenharmony_ci#ifdef UNITY_DIFFERENTIATE_FINAL_FAIL
225635375f98Sopenharmony_ci        UNITY_OUTPUT_CHAR('E'); UNITY_OUTPUT_CHAR('D');
225735375f98Sopenharmony_ci#endif
225835375f98Sopenharmony_ci    }
225935375f98Sopenharmony_ci    UNITY_PRINT_EOL();
226035375f98Sopenharmony_ci    UNITY_FLUSH_CALL();
226135375f98Sopenharmony_ci    UNITY_OUTPUT_COMPLETE();
226235375f98Sopenharmony_ci    return (int)(Unity.TestFailures);
226335375f98Sopenharmony_ci}
226435375f98Sopenharmony_ci
226535375f98Sopenharmony_ci/*-----------------------------------------------
226635375f98Sopenharmony_ci * Command Line Argument Support
226735375f98Sopenharmony_ci *-----------------------------------------------*/
226835375f98Sopenharmony_ci#ifdef UNITY_USE_COMMAND_LINE_ARGS
226935375f98Sopenharmony_ci
227035375f98Sopenharmony_cichar* UnityOptionIncludeNamed = NULL;
227135375f98Sopenharmony_cichar* UnityOptionExcludeNamed = NULL;
227235375f98Sopenharmony_ciint UnityVerbosity            = 1;
227335375f98Sopenharmony_ci
227435375f98Sopenharmony_ci/*-----------------------------------------------*/
227535375f98Sopenharmony_ciint UnityParseOptions(int argc, char** argv)
227635375f98Sopenharmony_ci{
227735375f98Sopenharmony_ci    int i;
227835375f98Sopenharmony_ci    UnityOptionIncludeNamed = NULL;
227935375f98Sopenharmony_ci    UnityOptionExcludeNamed = NULL;
228035375f98Sopenharmony_ci
228135375f98Sopenharmony_ci    for (i = 1; i < argc; i++)
228235375f98Sopenharmony_ci    {
228335375f98Sopenharmony_ci        if (argv[i][0] == '-')
228435375f98Sopenharmony_ci        {
228535375f98Sopenharmony_ci            switch (argv[i][1])
228635375f98Sopenharmony_ci            {
228735375f98Sopenharmony_ci                case 'l': /* list tests */
228835375f98Sopenharmony_ci                    return -1;
228935375f98Sopenharmony_ci                case 'n': /* include tests with name including this string */
229035375f98Sopenharmony_ci                case 'f': /* an alias for -n */
229135375f98Sopenharmony_ci                    if (argv[i][2] == '=')
229235375f98Sopenharmony_ci                    {
229335375f98Sopenharmony_ci                        UnityOptionIncludeNamed = &argv[i][3];
229435375f98Sopenharmony_ci                    }
229535375f98Sopenharmony_ci                    else if (++i < argc)
229635375f98Sopenharmony_ci                    {
229735375f98Sopenharmony_ci                        UnityOptionIncludeNamed = argv[i];
229835375f98Sopenharmony_ci                    }
229935375f98Sopenharmony_ci                    else
230035375f98Sopenharmony_ci                    {
230135375f98Sopenharmony_ci                        UnityPrint("ERROR: No Test String to Include Matches For");
230235375f98Sopenharmony_ci                        UNITY_PRINT_EOL();
230335375f98Sopenharmony_ci                        return 1;
230435375f98Sopenharmony_ci                    }
230535375f98Sopenharmony_ci                    break;
230635375f98Sopenharmony_ci                case 'q': /* quiet */
230735375f98Sopenharmony_ci                    UnityVerbosity = 0;
230835375f98Sopenharmony_ci                    break;
230935375f98Sopenharmony_ci                case 'v': /* verbose */
231035375f98Sopenharmony_ci                    UnityVerbosity = 2;
231135375f98Sopenharmony_ci                    break;
231235375f98Sopenharmony_ci                case 'x': /* exclude tests with name including this string */
231335375f98Sopenharmony_ci                    if (argv[i][2] == '=')
231435375f98Sopenharmony_ci                    {
231535375f98Sopenharmony_ci                        UnityOptionExcludeNamed = &argv[i][3];
231635375f98Sopenharmony_ci                    }
231735375f98Sopenharmony_ci                    else if (++i < argc)
231835375f98Sopenharmony_ci                    {
231935375f98Sopenharmony_ci                        UnityOptionExcludeNamed = argv[i];
232035375f98Sopenharmony_ci                    }
232135375f98Sopenharmony_ci                    else
232235375f98Sopenharmony_ci                    {
232335375f98Sopenharmony_ci                        UnityPrint("ERROR: No Test String to Exclude Matches For");
232435375f98Sopenharmony_ci                        UNITY_PRINT_EOL();
232535375f98Sopenharmony_ci                        return 1;
232635375f98Sopenharmony_ci                    }
232735375f98Sopenharmony_ci                    break;
232835375f98Sopenharmony_ci                default:
232935375f98Sopenharmony_ci                    UnityPrint("ERROR: Unknown Option ");
233035375f98Sopenharmony_ci                    UNITY_OUTPUT_CHAR(argv[i][1]);
233135375f98Sopenharmony_ci                    UNITY_PRINT_EOL();
233235375f98Sopenharmony_ci                    /* Now display help */
233335375f98Sopenharmony_ci                    /* FALLTHRU */
233435375f98Sopenharmony_ci                case 'h':
233535375f98Sopenharmony_ci                    UnityPrint("Options: "); UNITY_PRINT_EOL();
233635375f98Sopenharmony_ci                    UnityPrint("-l        List all tests and exit"); UNITY_PRINT_EOL();
233735375f98Sopenharmony_ci                    UnityPrint("-f NAME   Filter to run only tests whose name includes NAME"); UNITY_PRINT_EOL();
233835375f98Sopenharmony_ci                    UnityPrint("-n NAME   (deprecated) alias of -f"); UNITY_PRINT_EOL();
233935375f98Sopenharmony_ci                    UnityPrint("-h        show this Help menu"); UNITY_PRINT_EOL();
234035375f98Sopenharmony_ci                    UnityPrint("-q        Quiet/decrease verbosity"); UNITY_PRINT_EOL();
234135375f98Sopenharmony_ci                    UnityPrint("-v        increase Verbosity"); UNITY_PRINT_EOL();
234235375f98Sopenharmony_ci                    UnityPrint("-x NAME   eXclude tests whose name includes NAME"); UNITY_PRINT_EOL();
234335375f98Sopenharmony_ci                    UNITY_OUTPUT_FLUSH();
234435375f98Sopenharmony_ci                    return 1;
234535375f98Sopenharmony_ci            }
234635375f98Sopenharmony_ci        }
234735375f98Sopenharmony_ci    }
234835375f98Sopenharmony_ci
234935375f98Sopenharmony_ci    return 0;
235035375f98Sopenharmony_ci}
235135375f98Sopenharmony_ci
235235375f98Sopenharmony_ci/*-----------------------------------------------*/
235335375f98Sopenharmony_ciint IsStringInBiggerString(const char* longstring, const char* shortstring)
235435375f98Sopenharmony_ci{
235535375f98Sopenharmony_ci    const char* lptr = longstring;
235635375f98Sopenharmony_ci    const char* sptr = shortstring;
235735375f98Sopenharmony_ci    const char* lnext = lptr;
235835375f98Sopenharmony_ci
235935375f98Sopenharmony_ci    if (*sptr == '*')
236035375f98Sopenharmony_ci    {
236135375f98Sopenharmony_ci        return 1;
236235375f98Sopenharmony_ci    }
236335375f98Sopenharmony_ci
236435375f98Sopenharmony_ci    while (*lptr)
236535375f98Sopenharmony_ci    {
236635375f98Sopenharmony_ci        lnext = lptr + 1;
236735375f98Sopenharmony_ci
236835375f98Sopenharmony_ci        /* If they current bytes match, go on to the next bytes */
236935375f98Sopenharmony_ci        while (*lptr && *sptr && (*lptr == *sptr))
237035375f98Sopenharmony_ci        {
237135375f98Sopenharmony_ci            lptr++;
237235375f98Sopenharmony_ci            sptr++;
237335375f98Sopenharmony_ci
237435375f98Sopenharmony_ci            /* We're done if we match the entire string or up to a wildcard */
237535375f98Sopenharmony_ci            if (*sptr == '*')
237635375f98Sopenharmony_ci                return 1;
237735375f98Sopenharmony_ci            if (*sptr == ',')
237835375f98Sopenharmony_ci                return 1;
237935375f98Sopenharmony_ci            if (*sptr == '"')
238035375f98Sopenharmony_ci                return 1;
238135375f98Sopenharmony_ci            if (*sptr == '\'')
238235375f98Sopenharmony_ci                return 1;
238335375f98Sopenharmony_ci            if (*sptr == ':')
238435375f98Sopenharmony_ci                return 2;
238535375f98Sopenharmony_ci            if (*sptr == 0)
238635375f98Sopenharmony_ci                return 1;
238735375f98Sopenharmony_ci        }
238835375f98Sopenharmony_ci
238935375f98Sopenharmony_ci        /* Otherwise we start in the long pointer 1 character further and try again */
239035375f98Sopenharmony_ci        lptr = lnext;
239135375f98Sopenharmony_ci        sptr = shortstring;
239235375f98Sopenharmony_ci    }
239335375f98Sopenharmony_ci
239435375f98Sopenharmony_ci    return 0;
239535375f98Sopenharmony_ci}
239635375f98Sopenharmony_ci
239735375f98Sopenharmony_ci/*-----------------------------------------------*/
239835375f98Sopenharmony_ciint UnityStringArgumentMatches(const char* str)
239935375f98Sopenharmony_ci{
240035375f98Sopenharmony_ci    int retval;
240135375f98Sopenharmony_ci    const char* ptr1;
240235375f98Sopenharmony_ci    const char* ptr2;
240335375f98Sopenharmony_ci    const char* ptrf;
240435375f98Sopenharmony_ci
240535375f98Sopenharmony_ci    /* Go through the options and get the substrings for matching one at a time */
240635375f98Sopenharmony_ci    ptr1 = str;
240735375f98Sopenharmony_ci    while (ptr1[0] != 0)
240835375f98Sopenharmony_ci    {
240935375f98Sopenharmony_ci        if ((ptr1[0] == '"') || (ptr1[0] == '\''))
241035375f98Sopenharmony_ci        {
241135375f98Sopenharmony_ci            ptr1++;
241235375f98Sopenharmony_ci        }
241335375f98Sopenharmony_ci
241435375f98Sopenharmony_ci        /* look for the start of the next partial */
241535375f98Sopenharmony_ci        ptr2 = ptr1;
241635375f98Sopenharmony_ci        ptrf = 0;
241735375f98Sopenharmony_ci        do
241835375f98Sopenharmony_ci        {
241935375f98Sopenharmony_ci            ptr2++;
242035375f98Sopenharmony_ci            if ((ptr2[0] == ':') && (ptr2[1] != 0) && (ptr2[0] != '\'') && (ptr2[0] != '"') && (ptr2[0] != ','))
242135375f98Sopenharmony_ci            {
242235375f98Sopenharmony_ci                ptrf = &ptr2[1];
242335375f98Sopenharmony_ci            }
242435375f98Sopenharmony_ci        } while ((ptr2[0] != 0) && (ptr2[0] != '\'') && (ptr2[0] != '"') && (ptr2[0] != ','));
242535375f98Sopenharmony_ci
242635375f98Sopenharmony_ci        while ((ptr2[0] != 0) && ((ptr2[0] == ':') || (ptr2[0] == '\'') || (ptr2[0] == '"') || (ptr2[0] == ',')))
242735375f98Sopenharmony_ci        {
242835375f98Sopenharmony_ci            ptr2++;
242935375f98Sopenharmony_ci        }
243035375f98Sopenharmony_ci
243135375f98Sopenharmony_ci        /* done if complete filename match */
243235375f98Sopenharmony_ci        retval = IsStringInBiggerString(Unity.TestFile, ptr1);
243335375f98Sopenharmony_ci        if (retval == 1)
243435375f98Sopenharmony_ci        {
243535375f98Sopenharmony_ci            return retval;
243635375f98Sopenharmony_ci        }
243735375f98Sopenharmony_ci
243835375f98Sopenharmony_ci        /* done if testname match after filename partial match */
243935375f98Sopenharmony_ci        if ((retval == 2) && (ptrf != 0))
244035375f98Sopenharmony_ci        {
244135375f98Sopenharmony_ci            if (IsStringInBiggerString(Unity.CurrentTestName, ptrf))
244235375f98Sopenharmony_ci            {
244335375f98Sopenharmony_ci                return 1;
244435375f98Sopenharmony_ci            }
244535375f98Sopenharmony_ci        }
244635375f98Sopenharmony_ci
244735375f98Sopenharmony_ci        /* done if complete testname match */
244835375f98Sopenharmony_ci        if (IsStringInBiggerString(Unity.CurrentTestName, ptr1) == 1)
244935375f98Sopenharmony_ci        {
245035375f98Sopenharmony_ci            return 1;
245135375f98Sopenharmony_ci        }
245235375f98Sopenharmony_ci
245335375f98Sopenharmony_ci        ptr1 = ptr2;
245435375f98Sopenharmony_ci    }
245535375f98Sopenharmony_ci
245635375f98Sopenharmony_ci    /* we couldn't find a match for any substrings */
245735375f98Sopenharmony_ci    return 0;
245835375f98Sopenharmony_ci}
245935375f98Sopenharmony_ci
246035375f98Sopenharmony_ci/*-----------------------------------------------*/
246135375f98Sopenharmony_ciint UnityTestMatches(void)
246235375f98Sopenharmony_ci{
246335375f98Sopenharmony_ci    /* Check if this test name matches the included test pattern */
246435375f98Sopenharmony_ci    int retval;
246535375f98Sopenharmony_ci    if (UnityOptionIncludeNamed)
246635375f98Sopenharmony_ci    {
246735375f98Sopenharmony_ci        retval = UnityStringArgumentMatches(UnityOptionIncludeNamed);
246835375f98Sopenharmony_ci    }
246935375f98Sopenharmony_ci    else
247035375f98Sopenharmony_ci    {
247135375f98Sopenharmony_ci        retval = 1;
247235375f98Sopenharmony_ci    }
247335375f98Sopenharmony_ci
247435375f98Sopenharmony_ci    /* Check if this test name matches the excluded test pattern */
247535375f98Sopenharmony_ci    if (UnityOptionExcludeNamed)
247635375f98Sopenharmony_ci    {
247735375f98Sopenharmony_ci        if (UnityStringArgumentMatches(UnityOptionExcludeNamed))
247835375f98Sopenharmony_ci        {
247935375f98Sopenharmony_ci            retval = 0;
248035375f98Sopenharmony_ci        }
248135375f98Sopenharmony_ci    }
248235375f98Sopenharmony_ci
248335375f98Sopenharmony_ci    return retval;
248435375f98Sopenharmony_ci}
248535375f98Sopenharmony_ci
248635375f98Sopenharmony_ci#endif /* UNITY_USE_COMMAND_LINE_ARGS */
248735375f98Sopenharmony_ci/*-----------------------------------------------*/
2488