Skip to content

Commit bc8a650

Browse files
authored
Merge pull request #607 from ivankravets/patch-1
Make PROGMEM configurable // Resolve #606, Resolve #482
2 parents 4389bab + be65710 commit bc8a650

1 file changed

Lines changed: 44 additions & 46 deletions

File tree

src/unity.c

Lines changed: 44 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,8 @@
77
#include "unity.h"
88
#include <stddef.h>
99

10-
#ifdef AVR
11-
#include <avr/pgmspace.h>
12-
#else
13-
#define PROGMEM
10+
#ifndef UNITY_PROGMEM
11+
#define UNITY_PROGMEM
1412
#endif
1513

1614
/* If omitted from header, declare overrideable prototypes here so they're ready for use */
@@ -26,50 +24,50 @@ void UNITY_OUTPUT_CHAR(int);
2624
struct UNITY_STORAGE_T Unity;
2725

2826
#ifdef UNITY_OUTPUT_COLOR
29-
const char PROGMEM UnityStrOk[] = "\033[42mOK\033[0m";
30-
const char PROGMEM UnityStrPass[] = "\033[42mPASS\033[0m";
31-
const char PROGMEM UnityStrFail[] = "\033[41mFAIL\033[0m";
32-
const char PROGMEM UnityStrIgnore[] = "\033[43mIGNORE\033[0m";
27+
const char UNITY_PROGMEM UnityStrOk[] = "\033[42mOK\033[0m";
28+
const char UNITY_PROGMEM UnityStrPass[] = "\033[42mPASS\033[0m";
29+
const char UNITY_PROGMEM UnityStrFail[] = "\033[41mFAIL\033[0m";
30+
const char UNITY_PROGMEM UnityStrIgnore[] = "\033[43mIGNORE\033[0m";
3331
#else
34-
const char PROGMEM UnityStrOk[] = "OK";
35-
const char PROGMEM UnityStrPass[] = "PASS";
36-
const char PROGMEM UnityStrFail[] = "FAIL";
37-
const char PROGMEM UnityStrIgnore[] = "IGNORE";
32+
const char UNITY_PROGMEM UnityStrOk[] = "OK";
33+
const char UNITY_PROGMEM UnityStrPass[] = "PASS";
34+
const char UNITY_PROGMEM UnityStrFail[] = "FAIL";
35+
const char UNITY_PROGMEM UnityStrIgnore[] = "IGNORE";
3836
#endif
39-
static const char PROGMEM UnityStrNull[] = "NULL";
40-
static const char PROGMEM UnityStrSpacer[] = ". ";
41-
static const char PROGMEM UnityStrExpected[] = " Expected ";
42-
static const char PROGMEM UnityStrWas[] = " Was ";
43-
static const char PROGMEM UnityStrGt[] = " to be greater than ";
44-
static const char PROGMEM UnityStrLt[] = " to be less than ";
45-
static const char PROGMEM UnityStrOrEqual[] = "or equal to ";
46-
static const char PROGMEM UnityStrNotEqual[] = " to be not equal to ";
47-
static const char PROGMEM UnityStrElement[] = " Element ";
48-
static const char PROGMEM UnityStrByte[] = " Byte ";
49-
static const char PROGMEM UnityStrMemory[] = " Memory Mismatch.";
50-
static const char PROGMEM UnityStrDelta[] = " Values Not Within Delta ";
51-
static const char PROGMEM UnityStrPointless[] = " You Asked Me To Compare Nothing, Which Was Pointless.";
52-
static const char PROGMEM UnityStrNullPointerForExpected[] = " Expected pointer to be NULL";
53-
static const char PROGMEM UnityStrNullPointerForActual[] = " Actual pointer was NULL";
37+
static const char UNITY_PROGMEM UnityStrNull[] = "NULL";
38+
static const char UNITY_PROGMEM UnityStrSpacer[] = ". ";
39+
static const char UNITY_PROGMEM UnityStrExpected[] = " Expected ";
40+
static const char UNITY_PROGMEM UnityStrWas[] = " Was ";
41+
static const char UNITY_PROGMEM UnityStrGt[] = " to be greater than ";
42+
static const char UNITY_PROGMEM UnityStrLt[] = " to be less than ";
43+
static const char UNITY_PROGMEM UnityStrOrEqual[] = "or equal to ";
44+
static const char UNITY_PROGMEM UnityStrNotEqual[] = " to be not equal to ";
45+
static const char UNITY_PROGMEM UnityStrElement[] = " Element ";
46+
static const char UNITY_PROGMEM UnityStrByte[] = " Byte ";
47+
static const char UNITY_PROGMEM UnityStrMemory[] = " Memory Mismatch.";
48+
static const char UNITY_PROGMEM UnityStrDelta[] = " Values Not Within Delta ";
49+
static const char UNITY_PROGMEM UnityStrPointless[] = " You Asked Me To Compare Nothing, Which Was Pointless.";
50+
static const char UNITY_PROGMEM UnityStrNullPointerForExpected[] = " Expected pointer to be NULL";
51+
static const char UNITY_PROGMEM UnityStrNullPointerForActual[] = " Actual pointer was NULL";
5452
#ifndef UNITY_EXCLUDE_FLOAT
55-
static const char PROGMEM UnityStrNot[] = "Not ";
56-
static const char PROGMEM UnityStrInf[] = "Infinity";
57-
static const char PROGMEM UnityStrNegInf[] = "Negative Infinity";
58-
static const char PROGMEM UnityStrNaN[] = "NaN";
59-
static const char PROGMEM UnityStrDet[] = "Determinate";
60-
static const char PROGMEM UnityStrInvalidFloatTrait[] = "Invalid Float Trait";
53+
static const char UNITY_PROGMEM UnityStrNot[] = "Not ";
54+
static const char UNITY_PROGMEM UnityStrInf[] = "Infinity";
55+
static const char UNITY_PROGMEM UnityStrNegInf[] = "Negative Infinity";
56+
static const char UNITY_PROGMEM UnityStrNaN[] = "NaN";
57+
static const char UNITY_PROGMEM UnityStrDet[] = "Determinate";
58+
static const char UNITY_PROGMEM UnityStrInvalidFloatTrait[] = "Invalid Float Trait";
6159
#endif
62-
const char PROGMEM UnityStrErrShorthand[] = "Unity Shorthand Support Disabled";
63-
const char PROGMEM UnityStrErrFloat[] = "Unity Floating Point Disabled";
64-
const char PROGMEM UnityStrErrDouble[] = "Unity Double Precision Disabled";
65-
const char PROGMEM UnityStrErr64[] = "Unity 64-bit Support Disabled";
66-
static const char PROGMEM UnityStrBreaker[] = "-----------------------";
67-
static const char PROGMEM UnityStrResultsTests[] = " Tests ";
68-
static const char PROGMEM UnityStrResultsFailures[] = " Failures ";
69-
static const char PROGMEM UnityStrResultsIgnored[] = " Ignored ";
60+
const char UNITY_PROGMEM UnityStrErrShorthand[] = "Unity Shorthand Support Disabled";
61+
const char UNITY_PROGMEM UnityStrErrFloat[] = "Unity Floating Point Disabled";
62+
const char UNITY_PROGMEM UnityStrErrDouble[] = "Unity Double Precision Disabled";
63+
const char UNITY_PROGMEM UnityStrErr64[] = "Unity 64-bit Support Disabled";
64+
static const char UNITY_PROGMEM UnityStrBreaker[] = "-----------------------";
65+
static const char UNITY_PROGMEM UnityStrResultsTests[] = " Tests ";
66+
static const char UNITY_PROGMEM UnityStrResultsFailures[] = " Failures ";
67+
static const char UNITY_PROGMEM UnityStrResultsIgnored[] = " Ignored ";
7068
#ifndef UNITY_EXCLUDE_DETAILS
71-
static const char PROGMEM UnityStrDetail1Name[] = UNITY_DETAIL1_NAME " ";
72-
static const char PROGMEM UnityStrDetail2Name[] = " " UNITY_DETAIL2_NAME " ";
69+
static const char UNITY_PROGMEM UnityStrDetail1Name[] = UNITY_DETAIL1_NAME " ";
70+
static const char UNITY_PROGMEM UnityStrDetail2Name[] = " " UNITY_DETAIL2_NAME " ";
7371
#endif
7472
/*-----------------------------------------------
7573
* Pretty Printers & Test Result Output Handlers
@@ -587,9 +585,9 @@ static void UnityAddMsgIfSpecified(const char* msg)
587585
UnityPrint(Unity.CurrentDetail2);
588586
}
589587
}
590-
#endif
588+
#endif
591589
if (msg)
592-
{
590+
{
593591
UnityPrint(UnityStrSpacer);
594592
UnityPrint(msg);
595593
}
@@ -853,7 +851,7 @@ void UnityAssertEqualIntArray(UNITY_INTERNAL_PTR expected,
853851
default: /* default is length 4 bytes */
854852
case 4:
855853
expect_val = *(UNITY_PTR_ATTRIBUTE const UNITY_INT32*)expected;
856-
actual_val = *(UNITY_PTR_ATTRIBUTE const UNITY_INT32*)actual;
854+
actual_val = *(UNITY_PTR_ATTRIBUTE const UNITY_INT32*)actual;
857855
#ifdef UNITY_SUPPORT_64
858856
if (style & (UNITY_DISPLAY_RANGE_UINT | UNITY_DISPLAY_RANGE_HEX))
859857
{

0 commit comments

Comments
 (0)