From f2fdf1a133e3b8a0ab42129d9b0485968022f82e Mon Sep 17 00:00:00 2001 From: Dom Postorivo Date: Sat, 13 May 2017 15:59:51 -0400 Subject: [PATCH 001/454] Added Greater than and Less than asserts from other PR --- README.md | 11 + docs/UnityAssertionsReference.md | 54 ++++ src/unity.c | 46 ++++ src/unity.h | 60 +++++ src/unity_internals.h | 40 +++ test/tests/testunity.c | 412 ++++++++++++++++++++++++++++++- 6 files changed, 622 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 17ab5747..ec73b4a1 100644 --- a/README.md +++ b/README.md @@ -118,6 +118,17 @@ Another way of calling TEST_ASSERT_EQUAL_INT Asserts that the actual value is within plus or minus delta of the expected value. This also comes in size specific variants. + + TEST_ASSERT_GREATER_THAN(threshold, actual) + +Asserts that the actual value is greater than the threshold. This also comes in size specific variants. + + + TEST_ASSERT_LESS_THAN(threshold, actual) + +Asserts that the actual value is less than the threshold. This also comes in size specific variants. + + Arrays ------ diff --git a/docs/UnityAssertionsReference.md b/docs/UnityAssertionsReference.md index 558f6dbb..2dcf5e3a 100644 --- a/docs/UnityAssertionsReference.md +++ b/docs/UnityAssertionsReference.md @@ -290,6 +290,60 @@ Asserts the specified bit of the `actual` parameter is high. Asserts the specified bit of the `actual` parameter is low. +### Integer Less Than / Greater Than + +These assertions verify that the `actual` parameter is less than or greater +than `threshold` (exclusive). For example, if the threshold value is 0 for the +greater than assertion will fail if it is 0 or less. + +##### `TEST_ASSERT_GREATER_THAN (threshold, actual)` + +##### `TEST_ASSERT_GREATER_THAN_INT (threshold, actual)` + +##### `TEST_ASSERT_GREATER_THAN_INT8 (threshold, actual)` + +##### `TEST_ASSERT_GREATER_THAN_INT16 (threshold, actual)` + +##### `TEST_ASSERT_GREATER_THAN_INT32 (threshold, actual)` + +##### `TEST_ASSERT_GREATER_THAN_UINT (threshold, actual)` + +##### `TEST_ASSERT_GREATER_THAN_UINT8 (threshold, actual)` + +##### `TEST_ASSERT_GREATER_THAN_UINT16 (threshold, actual)` + +##### `TEST_ASSERT_GREATER_THAN_UINT32 (threshold, actual)` + +##### `TEST_ASSERT_GREATER_THAN_HEX8 (threshold, actual)` + +##### `TEST_ASSERT_GREATER_THAN_HEX16 (threshold, actual)` + +##### `TEST_ASSERT_GREATER_THAN_HEX32 (threshold, actual)` + +##### `TEST_ASSERT_LESS_THAN (threshold, actual)` + +##### `TEST_ASSERT_LESS_THAN_INT (threshold, actual)` + +##### `TEST_ASSERT_LESS_THAN_INT8 (threshold, actual)` + +##### `TEST_ASSERT_LESS_THAN_INT16 (threshold, actual)` + +##### `TEST_ASSERT_LESS_THAN_INT32 (threshold, actual)` + +##### `TEST_ASSERT_LESS_THAN_UINT (threshold, actual)` + +##### `TEST_ASSERT_LESS_THAN_UINT8 (threshold, actual)` + +##### `TEST_ASSERT_LESS_THAN_UINT16 (threshold, actual)` + +##### `TEST_ASSERT_LESS_THAN_UINT32 (threshold, actual)` + +##### `TEST_ASSERT_LESS_THAN_HEX8 (threshold, actual)` + +##### `TEST_ASSERT_LESS_THAN_HEX16 (threshold, actual)` + +##### `TEST_ASSERT_LESS_THAN_HEX32 (threshold, actual)` + ### Integer Ranges (of all sizes) diff --git a/src/unity.c b/src/unity.c index 177af0f4..e4ad519e 100644 --- a/src/unity.c +++ b/src/unity.c @@ -27,6 +27,8 @@ static const char UnityStrNull[] = "NULL"; static const char UnityStrSpacer[] = ". "; static const char UnityStrExpected[] = " Expected "; static const char UnityStrWas[] = " Was "; +static const char UnityStrGt[] = " to be greater than "; +static const char UnityStrLt[] = " to be less than "; static const char UnityStrElement[] = " Element "; static const char UnityStrByte[] = " Byte "; static const char UnityStrMemory[] = " Memory Mismatch."; @@ -526,6 +528,50 @@ void UnityAssertEqualNumber(const UNITY_INT expected, } } +/*-----------------------------------------------*/ +void UnityAssertGreaterNumber(const UNITY_INT threshold, + const UNITY_INT actual, + const char *msg, + const UNITY_LINE_TYPE lineNumber, + const UNITY_DISPLAY_STYLE_T style) +{ + RETURN_IF_FAIL_OR_IGNORE; + + if (!(actual > threshold)) + { + UnityTestResultsFailBegin(lineNumber); + UnityPrint(UnityStrExpected); + UnityPrintNumberByStyle(actual, style); + UnityPrint(UnityStrGt); + UnityPrintNumberByStyle(threshold, style); + UnityAddMsgIfSpecified(msg); + UNITY_FAIL_AND_BAIL; + } +} + +/*-----------------------------------------------*/ +void UnityAssertSmallerNumber(const UNITY_INT threshold, + const UNITY_INT actual, + const char *msg, + const UNITY_LINE_TYPE lineNumber, + const UNITY_DISPLAY_STYLE_T style) +{ + RETURN_IF_FAIL_OR_IGNORE; + + if (!(actual < threshold)) + { + UnityTestResultsFailBegin(lineNumber); + UnityPrint(UnityStrExpected); + UnityPrintNumberByStyle(actual, style); + UnityPrint(UnityStrLt); + UnityPrintNumberByStyle(threshold, style); + UnityAddMsgIfSpecified(msg); + UNITY_FAIL_AND_BAIL; + } +} + + + #define UnityPrintPointlessAndBail() \ { \ UnityTestResultsFailBegin(lineNumber); \ diff --git a/src/unity.h b/src/unity.h index 64342383..258e21c9 100644 --- a/src/unity.h +++ b/src/unity.h @@ -114,6 +114,35 @@ void tearDown(void); #define TEST_ASSERT_BIT_HIGH(bit, actual) UNITY_TEST_ASSERT_BITS(((UNITY_UINT32)1 << (bit)), (UNITY_UINT32)(-1), (actual), __LINE__, NULL) #define TEST_ASSERT_BIT_LOW(bit, actual) UNITY_TEST_ASSERT_BITS(((UNITY_UINT32)1 << (bit)), (UNITY_UINT32)(0), (actual), __LINE__, NULL) +/* Integer Greater Than/ Less Than (of all sizes) */ +#define TEST_ASSERT_GREATER_THAN(threshold, actual) UNITY_TEST_ASSERT_GREATER_THAN_INT((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_GREATER_THAN_INT(threshold, actual) UNITY_TEST_ASSERT_GREATER_THAN_INT((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_GREATER_THAN_INT8(threshold, actual) UNITY_TEST_ASSERT_GREATER_THAN_INT8((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_GREATER_THAN_INT16(threshold, actual) UNITY_TEST_ASSERT_GREATER_THAN_INT16((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_GREATER_THAN_INT32(threshold, actual) UNITY_TEST_ASSERT_GREATER_THAN_INT32((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_GREATER_THAN_UINT(threshold, actual) UNITY_TEST_ASSERT_GREATER_THAN_UINT((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_GREATER_THAN_UINT8(threshold, actual) UNITY_TEST_ASSERT_GREATER_THAN_UINT8((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_GREATER_THAN_UINT16(threshold, actual) UNITY_TEST_ASSERT_GREATER_THAN_UINT16((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_GREATER_THAN_UINT32(threshold, actual) UNITY_TEST_ASSERT_GREATER_THAN_UINT32((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_GREATER_THAN_HEX8(threshold, actual) UNITY_TEST_ASSERT_GREATER_THAN_HEX8((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_GREATER_THAN_HEX16(threshold, actual) UNITY_TEST_ASSERT_GREATER_THAN_HEX16((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_GREATER_THAN_HEX32(threshold, actual) UNITY_TEST_ASSERT_GREATER_THAN_HEX32((threshold), (actual), __LINE__, NULL) + + +#define TEST_ASSERT_LESS_THAN(threshold, actual) UNITY_TEST_ASSERT_SMALLER_THAN_INT((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_LESS_THAN_INT(threshold, actual) UNITY_TEST_ASSERT_SMALLER_THAN_INT((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_LESS_THAN_INT8(threshold, actual) UNITY_TEST_ASSERT_SMALLER_THAN_INT8((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_LESS_THAN_INT16(threshold, actual) UNITY_TEST_ASSERT_SMALLER_THAN_INT16((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_LESS_THAN_INT32(threshold, actual) UNITY_TEST_ASSERT_SMALLER_THAN_INT32((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_LESS_THAN_UINT(threshold, actual) UNITY_TEST_ASSERT_SMALLER_THAN_UINT((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_LESS_THAN_UINT8(threshold, actual) UNITY_TEST_ASSERT_SMALLER_THAN_UINT8((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_LESS_THAN_UINT16(threshold, actual) UNITY_TEST_ASSERT_SMALLER_THAN_UINT16((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_LESS_THAN_UINT32(threshold, actual) UNITY_TEST_ASSERT_SMALLER_THAN_UINT32((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_LESS_THAN_HEX8(threshold, actual) UNITY_TEST_ASSERT_SMALLER_THAN_HEX8((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_LESS_THAN_HEX16(threshold, actual) UNITY_TEST_ASSERT_SMALLER_THAN_HEX16((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_LESS_THAN_HEX32(threshold, actual) UNITY_TEST_ASSERT_SMALLER_THAN_HEX32((threshold), (actual), __LINE__, NULL) + + /* Integer Ranges (of all sizes) */ #define TEST_ASSERT_INT_WITHIN(delta, expected, actual) UNITY_TEST_ASSERT_INT_WITHIN((delta), (expected), (actual), __LINE__, NULL) #define TEST_ASSERT_INT8_WITHIN(delta, expected, actual) UNITY_TEST_ASSERT_INT8_WITHIN((delta), (expected), (actual), __LINE__, NULL) @@ -157,6 +186,8 @@ void tearDown(void); #define TEST_ASSERT_EQUAL_STRING_ARRAY(expected, actual, num_elements) UNITY_TEST_ASSERT_EQUAL_STRING_ARRAY((expected), (actual), (num_elements), __LINE__, NULL) #define TEST_ASSERT_EQUAL_MEMORY_ARRAY(expected, actual, len, num_elements) UNITY_TEST_ASSERT_EQUAL_MEMORY_ARRAY((expected), (actual), (len), (num_elements), __LINE__, NULL) + + /* Arrays Compared To Single Value */ #define TEST_ASSERT_EACH_EQUAL_INT(expected, actual, num_elements) UNITY_TEST_ASSERT_EACH_EQUAL_INT((expected), (actual), (num_elements), __LINE__, NULL) #define TEST_ASSERT_EACH_EQUAL_INT8(expected, actual, num_elements) UNITY_TEST_ASSERT_EACH_EQUAL_INT8((expected), (actual), (num_elements), __LINE__, NULL) @@ -241,6 +272,35 @@ void tearDown(void); #define TEST_ASSERT_BIT_HIGH_MESSAGE(bit, actual, message) UNITY_TEST_ASSERT_BITS(((UNITY_UINT32)1 << (bit)), (UNITY_UINT32)(-1), (actual), __LINE__, (message)) #define TEST_ASSERT_BIT_LOW_MESSAGE(bit, actual, message) UNITY_TEST_ASSERT_BITS(((UNITY_UINT32)1 << (bit)), (UNITY_UINT32)(0), (actual), __LINE__, (message)) +/* Integer Greater Than/ Less Than (of all sizes) */ +#define TEST_ASSERT_GREATER_THAN_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_THAN_INT((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_GREATER_THAN_INT_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_THAN_INT((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_GREATER_THAN_INT8_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_THAN_INT8((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_GREATER_THAN_INT16_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_THAN_INT16((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_GREATER_THAN_INT32_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_THAN_INT32((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_GREATER_THAN_UINT_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_THAN_UINT((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_GREATER_THAN_UINT8_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_THAN_UINT8((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_GREATER_THAN_UINT16_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_THAN_UINT16((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_GREATER_THAN_UINT32_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_THAN_UINT32((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_GREATER_THAN_HEX8_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_THAN_HEX8((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_GREATER_THAN_HEX16_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_THAN_HEX16((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_GREATER_THAN_HEX32_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_THAN_HEX32((threshold), (actual), __LINE__, (message)) + + +#define TEST_ASSERT_LESS_THAN_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_THAN_INT((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_LESS_THAN_INT_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_THAN_INT((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_LESS_THAN_INT8_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_THAN_INT8((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_LESS_THAN_INT16_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_THAN_INT16((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_LESS_THAN_INT32_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_THAN_INT32((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_LESS_THAN_UINT_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_THAN_UINT((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_LESS_THAN_UINT8_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_THAN_UINT8((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_LESS_THAN_UINT16_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_THAN_UINT16((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_LESS_THAN_UINT32_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_THAN_UINT32((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_LESS_THAN_HEX8_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_THAN_HEX8((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_LESS_THAN_HEX16_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_THAN_HEX16((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_LESS_THAN_HEX32_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_THAN_HEX32((threshold), (actual), __LINE__, (message)) + + /* Integer Ranges (of all sizes) */ #define TEST_ASSERT_INT_WITHIN_MESSAGE(delta, expected, actual, message) UNITY_TEST_ASSERT_INT_WITHIN((delta), (expected), (actual), __LINE__, (message)) #define TEST_ASSERT_INT8_WITHIN_MESSAGE(delta, expected, actual, message) UNITY_TEST_ASSERT_INT8_WITHIN((delta), (expected), (actual), __LINE__, (message)) diff --git a/src/unity_internals.h b/src/unity_internals.h index cc20ea4f..5420abab 100644 --- a/src/unity_internals.h +++ b/src/unity_internals.h @@ -455,6 +455,18 @@ void UnityAssertEqualNumber(const UNITY_INT expected, const UNITY_LINE_TYPE lineNumber, const UNITY_DISPLAY_STYLE_T style); +void UnityAssertGreaterNumber(const UNITY_INT threshold, + const UNITY_INT actual, + const char* msg, + const UNITY_LINE_TYPE lineNumber, + const UNITY_DISPLAY_STYLE_T style); + +void UnityAssertSmallerNumber(const UNITY_INT threshold, + const UNITY_INT actual, + const char* msg, + const UNITY_LINE_TYPE lineNumber, + const UNITY_DISPLAY_STYLE_T style); + void UnityAssertEqualIntArray(UNITY_INTERNAL_PTR expected, UNITY_INTERNAL_PTR actual, const UNITY_UINT32 num_elements, @@ -652,6 +664,34 @@ int UnityTestMatches(void); #define UNITY_TEST_ASSERT_EQUAL_HEX32(expected, actual, line, message) UnityAssertEqualNumber((UNITY_INT)(UNITY_INT32)(expected), (UNITY_INT)(UNITY_INT32)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX32) #define UNITY_TEST_ASSERT_BITS(mask, expected, actual, line, message) UnityAssertBits((UNITY_INT)(mask), (UNITY_INT)(expected), (UNITY_INT)(actual), (message), (UNITY_LINE_TYPE)(line)) + +#define UNITY_TEST_ASSERT_GREATER_THAN_INT(threshold, actual, line, message) UnityAssertGreaterNumber((UNITY_INT)(threshold), (UNITY_INT)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT) +#define UNITY_TEST_ASSERT_GREATER_THAN_INT8(threshold, actual, line, message) UnityAssertGreaterNumber((UNITY_INT)(UNITY_INT8 )(threshold), (UNITY_INT)(UNITY_INT8 )(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT8) +#define UNITY_TEST_ASSERT_GREATER_THAN_INT16(threshold, actual, line, message) UnityAssertGreaterNumber((UNITY_INT)(UNITY_INT16)(threshold), (UNITY_INT)(UNITY_INT16)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT16) +#define UNITY_TEST_ASSERT_GREATER_THAN_INT32(threshold, actual, line, message) UnityAssertGreaterNumber((UNITY_INT)(UNITY_INT32)(threshold), (UNITY_INT)(UNITY_INT32)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT32) +#define UNITY_TEST_ASSERT_GREATER_THAN_UINT(threshold, actual, line, message) UnityAssertGreaterNumber((UNITY_INT)(threshold), (UNITY_INT)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT) +#define UNITY_TEST_ASSERT_GREATER_THAN_UINT8(threshold, actual, line, message) UnityAssertGreaterNumber((UNITY_INT)(UNITY_UINT8 )(threshold), (UNITY_INT)(UNITY_UINT8 )(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT8) +#define UNITY_TEST_ASSERT_GREATER_THAN_UINT16(threshold, actual, line, message) UnityAssertGreaterNumber((UNITY_INT)(UNITY_UINT16)(threshold), (UNITY_INT)(UNITY_UINT16)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT16) +#define UNITY_TEST_ASSERT_GREATER_THAN_UINT32(threshold, actual, line, message) UnityAssertGreaterNumber((UNITY_INT)(UNITY_UINT32)(threshold), (UNITY_INT)(UNITY_UINT32)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT32) +#define UNITY_TEST_ASSERT_GREATER_THAN_HEX8(threshold, actual, line, message) UnityAssertGreaterNumber((UNITY_INT)(UNITY_UINT8 )(threshold), (UNITY_INT)(UNITY_UINT8 )(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX8) +#define UNITY_TEST_ASSERT_GREATER_THAN_HEX16(threshold, actual, line, message) UnityAssertGreaterNumber((UNITY_INT)(UNITY_UINT16)(threshold), (UNITY_INT)(UNITY_UINT16)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX16) +#define UNITY_TEST_ASSERT_GREATER_THAN_HEX32(threshold, actual, line, message) UnityAssertGreaterNumber((UNITY_INT)(UNITY_UINT32)(threshold), (UNITY_INT)(UNITY_UINT32)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX32) + + +#define UNITY_TEST_ASSERT_SMALLER_THAN_INT(threshold, actual, line, message) UnityAssertSmallerNumber((UNITY_INT)(threshold), (UNITY_INT)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT) +#define UNITY_TEST_ASSERT_SMALLER_THAN_INT8(threshold, actual, line, message) UnityAssertSmallerNumber((UNITY_INT)(UNITY_INT8 )(threshold), (UNITY_INT)(UNITY_INT8 )(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT8) +#define UNITY_TEST_ASSERT_SMALLER_THAN_INT16(threshold, actual, line, message) UnityAssertSmallerNumber((UNITY_INT)(UNITY_INT16)(threshold), (UNITY_INT)(UNITY_INT16)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT16) +#define UNITY_TEST_ASSERT_SMALLER_THAN_INT32(threshold, actual, line, message) UnityAssertSmallerNumber((UNITY_INT)(UNITY_INT32)(threshold), (UNITY_INT)(UNITY_INT32)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT32) +#define UNITY_TEST_ASSERT_SMALLER_THAN_UINT(threshold, actual, line, message) UnityAssertSmallerNumber((UNITY_INT)(threshold), (UNITY_INT)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT) +#define UNITY_TEST_ASSERT_SMALLER_THAN_UINT8(threshold, actual, line, message) UnityAssertSmallerNumber((UNITY_INT)(UNITY_UINT8 )(threshold), (UNITY_INT)(UNITY_UINT8 )(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT8) +#define UNITY_TEST_ASSERT_SMALLER_THAN_UINT16(threshold, actual, line, message) UnityAssertSmallerNumber((UNITY_INT)(UNITY_UINT16)(threshold), (UNITY_INT)(UNITY_UINT16)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT16) +#define UNITY_TEST_ASSERT_SMALLER_THAN_UINT32(threshold, actual, line, message) UnityAssertSmallerNumber((UNITY_INT)(UNITY_UINT32)(threshold), (UNITY_INT)(UNITY_UINT32)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT32) +#define UNITY_TEST_ASSERT_SMALLER_THAN_HEX8(threshold, actual, line, message) UnityAssertSmallerNumber((UNITY_INT)(UNITY_UINT8 )(threshold), (UNITY_INT)(UNITY_UINT8 )(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX8) +#define UNITY_TEST_ASSERT_SMALLER_THAN_HEX16(threshold, actual, line, message) UnityAssertSmallerNumber((UNITY_INT)(UNITY_UINT16)(threshold), (UNITY_INT)(UNITY_UINT16)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX16) +#define UNITY_TEST_ASSERT_SMALLER_THAN_HEX32(threshold, actual, line, message) UnityAssertSmallerNumber((UNITY_INT)(UNITY_UINT32)(threshold), (UNITY_INT)(UNITY_UINT32)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX32) + + + #define UNITY_TEST_ASSERT_INT_WITHIN(delta, expected, actual, line, message) UnityAssertNumbersWithin((delta), (UNITY_INT)(expected), (UNITY_INT)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT) #define UNITY_TEST_ASSERT_INT8_WITHIN(delta, expected, actual, line, message) UnityAssertNumbersWithin((UNITY_UINT8 )(delta), (UNITY_INT)(UNITY_INT8 )(expected), (UNITY_INT)(UNITY_INT8 )(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT8) #define UNITY_TEST_ASSERT_INT16_WITHIN(delta, expected, actual, line, message) UnityAssertNumbersWithin((UNITY_UINT16)(delta), (UNITY_INT)(UNITY_INT16)(expected), (UNITY_INT)(UNITY_INT16)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT16) diff --git a/test/tests/testunity.c b/test/tests/testunity.c index 3555fb2d..320f22c9 100644 --- a/test/tests/testunity.c +++ b/test/tests/testunity.c @@ -764,8 +764,9 @@ void testNotEqualBitsLow(void) EXPECT_ABORT_BEGIN TEST_ASSERT_BITS_LOW(v0, v1); VERIFY_FAILS_END - } + + void testEqualShorts(void) { short v0, v1; @@ -1305,6 +1306,415 @@ void testINT8sNotWithinDeltaAndCustomMessage(void) VERIFY_FAILS_END } + +//----------------- +void testGreaterThan(void) +{ + UNITY_INT v0, v1; + UNITY_INT *p0, *p1; + + v0 = 0; + v1 = 1; + p0 = &v0; + p1 = &v1; + + TEST_ASSERT_GREATER_THAN(v0, v1); + TEST_ASSERT_GREATER_THAN(*p0, v1); + TEST_ASSERT_GREATER_THAN(v0, *p1); + TEST_ASSERT_GREATER_THAN(*p0, *p1); +} + +void testGreaterThanINT(void) +{ + UNITY_INT v0, v1; + UNITY_INT *p0, *p1; + + v0 = 302; + v1 = 3334; + p0 = &v0; + p1 = &v1; + + TEST_ASSERT_GREATER_THAN_INT(v0, v1); + TEST_ASSERT_GREATER_THAN_INT(*p0, v1); + TEST_ASSERT_GREATER_THAN_INT(v0, *p1); + TEST_ASSERT_GREATER_THAN_INT(*p0, *p1); +} + + +void testGreaterThanINT8(void) +{ + UNITY_INT8 v0, v1; + UNITY_INT8 *p0, *p1; + + v0 = -128; + v1 = 127; + p0 = &v0; + p1 = &v1; + + TEST_ASSERT_GREATER_THAN_INT8(v0, v1); + TEST_ASSERT_GREATER_THAN_INT8(*p0, v1); + TEST_ASSERT_GREATER_THAN_INT8(v0, *p1); + TEST_ASSERT_GREATER_THAN_INT8(*p0, *p1); +} + +void testGreaterThanINT16(void) +{ + UNITY_INT16 v0, v1; + UNITY_INT16 *p0, *p1; + + v0 = -32768; + v1 = 32767; + p0 = &v0; + p1 = &v1; + + TEST_ASSERT_GREATER_THAN_INT16(v0, v1); + TEST_ASSERT_GREATER_THAN_INT16(*p0, v1); + TEST_ASSERT_GREATER_THAN_INT16(v0, *p1); + TEST_ASSERT_GREATER_THAN_INT16(*p0, *p1); +} + +void testGreaterThanINT32(void) +{ + UNITY_INT32 v0, v1; + UNITY_INT32 *p0, *p1; + + v0 = -214783648; + v1 = 214783647; + p0 = &v0; + p1 = &v1; + + TEST_ASSERT_GREATER_THAN_INT32(v0, v1); + TEST_ASSERT_GREATER_THAN_INT32(*p0, v1); + TEST_ASSERT_GREATER_THAN_INT32(v0, *p1); + TEST_ASSERT_GREATER_THAN_INT32(*p0, *p1); +} + +void testGreaterThanUINT(void) +{ + UNITY_UINT v0, v1; + UNITY_UINT *p0, *p1; + + v0 = 0; + v1 = 1; + p0 = &v0; + p1 = &v1; + + TEST_ASSERT_GREATER_THAN_UINT(v0, v1); + TEST_ASSERT_GREATER_THAN_UINT(*p0, v1); + TEST_ASSERT_GREATER_THAN_UINT(v0, *p1); + TEST_ASSERT_GREATER_THAN_UINT(*p0, *p1); +} + + +void testGreaterThanUINT8(void) +{ + UNITY_UINT8 v0, v1; + UNITY_UINT8 *p0, *p1; + + v0 = 0; + v1 = 255; + p0 = &v0; + p1 = &v1; + + TEST_ASSERT_GREATER_THAN_UINT8(v0, v1); + TEST_ASSERT_GREATER_THAN_UINT8(*p0, v1); + TEST_ASSERT_GREATER_THAN_UINT8(v0, *p1); + TEST_ASSERT_GREATER_THAN_UINT8(*p0, *p1); +} + +void testGreaterThanUINT16(void) +{ + UNITY_UINT16 v0, v1; + UNITY_UINT16 *p0, *p1; + + v0 = 0; + v1 = 65535; + p0 = &v0; + p1 = &v1; + + TEST_ASSERT_GREATER_THAN_UINT16(v0, v1); + TEST_ASSERT_GREATER_THAN_UINT16(*p0, v1); + TEST_ASSERT_GREATER_THAN_UINT16(v0, *p1); + TEST_ASSERT_GREATER_THAN_UINT16(*p0, *p1); +} + +void testGreaterThanUINT32(void) +{ + UNITY_UINT32 v0, v1; + UNITY_UINT32 *p0, *p1; + + v0 = 0; + v1 = 4294967295; + p0 = &v0; + p1 = &v1; + + TEST_ASSERT_GREATER_THAN_UINT32(v0, v1); + TEST_ASSERT_GREATER_THAN_UINT32(*p0, v1); + TEST_ASSERT_GREATER_THAN_UINT32(v0, *p1); + TEST_ASSERT_GREATER_THAN_UINT32(*p0, *p1); +} + +void testGreaterThanHEX8(void) +{ + UNITY_UINT8 v0, v1; + UNITY_UINT8 *p0, *p1; + + v0 = 0x00; + v1 = 0xFF; + p0 = &v0; + p1 = &v1; + + TEST_ASSERT_GREATER_THAN_HEX8(v0, v1); + TEST_ASSERT_GREATER_THAN_HEX8(*p0, v1); + TEST_ASSERT_GREATER_THAN_HEX8(v0, *p1); + TEST_ASSERT_GREATER_THAN_HEX8(*p0, *p1); +} + +void testGreaterThanHEX16(void) +{ + UNITY_UINT16 v0, v1; + UNITY_UINT16 *p0, *p1; + + v0 = 0x0000; + v1 = 0xFFFF; + p0 = &v0; + p1 = &v1; + + TEST_ASSERT_GREATER_THAN_HEX16(v0, v1); + TEST_ASSERT_GREATER_THAN_HEX16(*p0, v1); + TEST_ASSERT_GREATER_THAN_HEX16(v0, *p1); + TEST_ASSERT_GREATER_THAN_HEX16(*p0, *p1); +} + +void testGreaterThanHEX32(void) +{ + UNITY_UINT32 v0, v1; + UNITY_UINT32 *p0, *p1; + + v0 = 0x00000000; + v1 = 0xFFFFFFFF; + p0 = &v0; + p1 = &v1; + + TEST_ASSERT_GREATER_THAN_HEX32(v0, v1); + TEST_ASSERT_GREATER_THAN_HEX32(*p0, v1); + TEST_ASSERT_GREATER_THAN_HEX32(v0, *p1); + TEST_ASSERT_GREATER_THAN_HEX32(*p0, *p1); +} + + +void testNotGreaterThan(void) +{ + EXPECT_ABORT_BEGIN + TEST_ASSERT_GREATER_THAN(0, -1); + VERIFY_FAILS_END +} + +void testLessThan(void) +{ + UNITY_INT v0, v1; + UNITY_INT *p0, *p1; + + v0 = 0; + v1 = -1; + p0 = &v0; + p1 = &v1; + + TEST_ASSERT_LESS_THAN(v0, v1); + TEST_ASSERT_LESS_THAN(*p0, v1); + TEST_ASSERT_LESS_THAN(v0, *p1); + TEST_ASSERT_LESS_THAN(*p0, *p1); +} + +void testLessThanINT(void) +{ + UNITY_INT v0, v1; + UNITY_INT *p0, *p1; + + v0 = 3334; + v1 = 302; + p0 = &v0; + p1 = &v1; + + TEST_ASSERT_LESS_THAN_INT(v0, v1); + TEST_ASSERT_LESS_THAN_INT(*p0, v1); + TEST_ASSERT_LESS_THAN_INT(v0, *p1); + TEST_ASSERT_LESS_THAN_INT(*p0, *p1); +} + + +void testLessThanINT8(void) +{ + UNITY_INT8 v0, v1; + UNITY_INT8 *p0, *p1; + + v0 = 127; + v1 = -128; + p0 = &v0; + p1 = &v1; + + TEST_ASSERT_LESS_THAN_INT8(v0, v1); + TEST_ASSERT_LESS_THAN_INT8(*p0, v1); + TEST_ASSERT_LESS_THAN_INT8(v0, *p1); + TEST_ASSERT_LESS_THAN_INT8(*p0, *p1); +} + +void testLessThanINT16(void) +{ + UNITY_INT16 v0, v1; + UNITY_INT16 *p0, *p1; + + v0 = 32767; + v1 = -32768; + p0 = &v0; + p1 = &v1; + + TEST_ASSERT_LESS_THAN_INT16(v0, v1); + TEST_ASSERT_LESS_THAN_INT16(*p0, v1); + TEST_ASSERT_LESS_THAN_INT16(v0, *p1); + TEST_ASSERT_LESS_THAN_INT16(*p0, *p1); +} + +void testLessThanINT32(void) +{ + UNITY_INT32 v0, v1; + UNITY_INT32 *p0, *p1; + + v0 = 214783647; + v1 = -214783648; + p0 = &v0; + p1 = &v1; + + TEST_ASSERT_LESS_THAN_INT32(v0, v1); + TEST_ASSERT_LESS_THAN_INT32(*p0, v1); + TEST_ASSERT_LESS_THAN_INT32(v0, *p1); + TEST_ASSERT_LESS_THAN_INT32(*p0, *p1); +} + +void testLessThanUINT(void) +{ + UNITY_UINT v0, v1; + UNITY_UINT *p0, *p1; + + v0 = 1; + v1 = 0; + p0 = &v0; + p1 = &v1; + + TEST_ASSERT_LESS_THAN_UINT(v0, v1); + TEST_ASSERT_LESS_THAN_UINT(*p0, v1); + TEST_ASSERT_LESS_THAN_UINT(v0, *p1); + TEST_ASSERT_LESS_THAN_UINT(*p0, *p1); +} + + +void testLessThanUINT8(void) +{ + UNITY_UINT8 v0, v1; + UNITY_UINT8 *p0, *p1; + + v0 = 255; + v1 = 0; + p0 = &v0; + p1 = &v1; + + TEST_ASSERT_LESS_THAN_UINT8(v0, v1); + TEST_ASSERT_LESS_THAN_UINT8(*p0, v1); + TEST_ASSERT_LESS_THAN_UINT8(v0, *p1); + TEST_ASSERT_LESS_THAN_UINT8(*p0, *p1); +} + +void testLessThanUINT16(void) +{ + UNITY_UINT16 v0, v1; + UNITY_UINT16 *p0, *p1; + + v0 = 65535; + v1 = 0; + p0 = &v0; + p1 = &v1; + + TEST_ASSERT_LESS_THAN_UINT16(v0, v1); + TEST_ASSERT_LESS_THAN_UINT16(*p0, v1); + TEST_ASSERT_LESS_THAN_UINT16(v0, *p1); + TEST_ASSERT_LESS_THAN_UINT16(*p0, *p1); +} + +void testLessThanUINT32(void) +{ + UNITY_UINT32 v0, v1; + UNITY_UINT32 *p0, *p1; + + v0 = 4294967295; + v1 = 0; + p0 = &v0; + p1 = &v1; + + TEST_ASSERT_LESS_THAN_UINT32(v0, v1); + TEST_ASSERT_LESS_THAN_UINT32(*p0, v1); + TEST_ASSERT_LESS_THAN_UINT32(v0, *p1); + TEST_ASSERT_LESS_THAN_UINT32(*p0, *p1); +} + +void testLessThanHEX8(void) +{ + UNITY_UINT8 v0, v1; + UNITY_UINT8 *p0, *p1; + + v0 = 0xFF; + v1 = 0x00; + p0 = &v0; + p1 = &v1; + + TEST_ASSERT_LESS_THAN_HEX8(v0, v1); + TEST_ASSERT_LESS_THAN_HEX8(*p0, v1); + TEST_ASSERT_LESS_THAN_HEX8(v0, *p1); + TEST_ASSERT_LESS_THAN_HEX8(*p0, *p1); +} + +void testLessThanHEX16(void) +{ + UNITY_UINT16 v0, v1; + UNITY_UINT16 *p0, *p1; + + v0 = 0xFFFF; + v1 = 0x0000; + p0 = &v0; + p1 = &v1; + + TEST_ASSERT_LESS_THAN_HEX16(v0, v1); + TEST_ASSERT_LESS_THAN_HEX16(*p0, v1); + TEST_ASSERT_LESS_THAN_HEX16(v0, *p1); + TEST_ASSERT_LESS_THAN_HEX16(*p0, *p1); +} + +void testLessThanHEX32(void) +{ + UNITY_UINT32 v0, v1; + UNITY_UINT32 *p0, *p1; + + v0 = 0xFFFFFFFF; + v1 = 0x00000000; + p0 = &v0; + p1 = &v1; + + TEST_ASSERT_LESS_THAN_HEX32(v0, v1); + TEST_ASSERT_LESS_THAN_HEX32(*p0, v1); + TEST_ASSERT_LESS_THAN_HEX32(v0, *p1); + TEST_ASSERT_LESS_THAN_HEX32(*p0, *p1); +} + + +void testNotLessThan(void) +{ + EXPECT_ABORT_BEGIN + TEST_ASSERT_LESS_THAN(0, 1); + VERIFY_FAILS_END +} + + + +//----------------- void testEqualStrings(void) { const char *testString = "foo"; From c1bc32dc58d13df092d5d2037ce8b169d275199f Mon Sep 17 00:00:00 2001 From: Mark VanderVoord Date: Sun, 25 Jun 2017 13:58:31 -0400 Subject: [PATCH 002/454] - Generator will not change names by default - Fixed some style issues. --- auto/colour_prompt.rb | 2 +- auto/generate_module.rb | 6 +++--- auto/stylize_as_junit.rb | 0 examples/example_3/rakefile.rb | 4 ++-- extras/fixture/rakefile.rb | 8 ++++---- 5 files changed, 10 insertions(+), 10 deletions(-) mode change 100644 => 100755 auto/stylize_as_junit.rb diff --git a/auto/colour_prompt.rb b/auto/colour_prompt.rb index 0f1dc4e0..c8618070 100644 --- a/auto/colour_prompt.rb +++ b/auto/colour_prompt.rb @@ -24,7 +24,7 @@ def initialize return unless RUBY_PLATFORM =~ /(win|w)32$/ get_std_handle = Win32API.new('kernel32', 'GetStdHandle', ['L'], 'L') @set_console_txt_attrb = - Win32API.new('kernel32', 'SetConsoleTextAttribute', %w(L N), 'I') + Win32API.new('kernel32', 'SetConsoleTextAttribute', %w[L N], 'I') @hout = get_std_handle.call(-11) end diff --git a/auto/generate_module.rb b/auto/generate_module.rb index ade4f1a9..13b4cc74 100644 --- a/auto/generate_module.rb +++ b/auto/generate_module.rb @@ -172,7 +172,7 @@ def create_filename(part1, part2 = '') when 'camel' then part1 when 'snake' then part1.downcase when 'caps' then part1.upcase - else part1.downcase + else part1 end else case (@options[:naming]) @@ -180,7 +180,7 @@ def create_filename(part1, part2 = '') when 'camel' then part1 + part2 when 'snake' then part1.downcase + '_' + part2.downcase when 'caps' then part1.upcase + '_' + part2.upcase - else part1.downcase + '_' + part2.downcase + else part1 + '_' + part2 end end end @@ -290,7 +290,7 @@ def destroy(module_name, pattern = nil) ' -n"camel" sets the file naming convention.', ' bumpy - BumpyCaseFilenames.', ' camel - camelCaseFilenames.', - ' snake - snake_case_filenames. (DEFAULT)', + ' snake - snake_case_filenames.', ' caps - CAPS_CASE_FILENAMES.', ' -u update subversion too (requires subversion command line)', ' -y"my.yml" selects a different yaml config file for module generation', diff --git a/auto/stylize_as_junit.rb b/auto/stylize_as_junit.rb old mode 100644 new mode 100755 diff --git a/examples/example_3/rakefile.rb b/examples/example_3/rakefile.rb index bf9f42be..8bedd4f0 100644 --- a/examples/example_3/rakefile.rb +++ b/examples/example_3/rakefile.rb @@ -32,8 +32,8 @@ end desc 'Build and test Unity' -task all: %i(clean unit summary) -task default: %i(clobber all) +task all: %i[clean unit summary] +task default: %i[clobber all] task ci: [:default] task cruise: [:default] diff --git a/extras/fixture/rakefile.rb b/extras/fixture/rakefile.rb index 7603e574..8528afc9 100644 --- a/extras/fixture/rakefile.rb +++ b/extras/fixture/rakefile.rb @@ -33,10 +33,10 @@ end desc 'Build and test Unity Framework' -task all: %i(clean unit) -task default: %i(clobber all) -task ci: %i(no_color default) -task cruise: %i(no_color default) +task all: %i[clean unit] +task default: %i[clobber all] +task ci: %i[no_color default] +task cruise: %i[no_color default] desc 'Load configuration' task :config, :config_file do |_t, args| From a07d07cd1a2726b6d798f5b0bb3d9123dd63ab59 Mon Sep 17 00:00:00 2001 From: Aviv Palivoda Date: Tue, 1 Aug 2017 21:49:38 +0300 Subject: [PATCH 003/454] Allow specifying custom header declaration The user can specify UNITY_OUTPUT_CHAR_HEADER_DECLARATION and UNITY_OUTPUT_FLUSH_HEADER_DECLARATION when he would like to declare UNITY_OUTPUT_CHAT or UNITY_OUTPUT_FLUSH respectivly --- examples/unity_config.h | 10 ++++++---- src/unity_internals.h | 14 +++++++------- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/examples/unity_config.h b/examples/unity_config.h index 355d9bf8..da3c2af1 100644 --- a/examples/unity_config.h +++ b/examples/unity_config.h @@ -201,10 +201,12 @@ * `stdout` option. You decide to route your test result output to a custom * serial `RS232_putc()` function you wrote like thus: */ -/* #define UNITY_OUTPUT_CHAR(a) RS232_putc(a) */ -/* #define UNITY_OUTPUT_FLUSH() RS232_flush() */ -/* #define UNITY_OUTPUT_START() RS232_config(115200,1,8,0) */ -/* #define UNITY_OUTPUT_COMPLETE() RS232_close() */ +/* #define UNITY_OUTPUT_CHAR(a) RS232_putc(a) */ +/* #define UNITY_OUTPUT_CHAR_HEADER_DECLARATION RS232_putc(int) */ +/* #define UNITY_OUTPUT_FLUSH() RS232_flush() */ +/* #define UNITY_OUTPUT_FLUSH_HEADER_DECLARATION RS232_flush(void) */ +/* #define UNITY_OUTPUT_START() RS232_config(115200,1,8,0) */ +/* #define UNITY_OUTPUT_COMPLETE() RS232_close() */ /* For some targets, Unity can make the otherwise required `setUp()` and * `tearDown()` functions optional. This is a nice convenience for test writers diff --git a/src/unity_internals.h b/src/unity_internals.h index c08db955..9504451a 100644 --- a/src/unity_internals.h +++ b/src/unity_internals.h @@ -246,8 +246,8 @@ typedef UNITY_FLOAT_TYPE UNITY_FLOAT; #define UNITY_OUTPUT_CHAR(a) (void)putchar(a) #else /* If defined as something else, make sure we declare it here so it's ready for use */ - #ifndef UNITY_OMIT_OUTPUT_CHAR_HEADER_DECLARATION -extern void UNITY_OUTPUT_CHAR(int); + #ifdef UNITY_OUTPUT_CHAR_HEADER_DECLARATION +extern void UNITY_OUTPUT_CHAR_HEADER_DECLARATION; #endif #endif @@ -255,22 +255,22 @@ extern void UNITY_OUTPUT_CHAR(int); #ifdef UNITY_USE_FLUSH_STDOUT /* We want to use the stdout flush utility */ #include -#define UNITY_OUTPUT_FLUSH (void)fflush(stdout) +#define UNITY_OUTPUT_FLUSH() (void)fflush(stdout) #else /* We've specified nothing, therefore flush should just be ignored */ -#define UNITY_OUTPUT_FLUSH +#define UNITY_OUTPUT_FLUSH() #endif #else /* We've defined flush as something else, so make sure we declare it here so it's ready for use */ -#ifndef UNITY_OMIT_OUTPUT_FLUSH_HEADER_DECLARATION -extern void UNITY_OUTPUT_FLUSH(void); +#ifdef UNITY_OUTPUT_FLUSH_HEADER_DECLARATION +extern void UNITY_OMIT_OUTPUT_FLUSH_HEADER_DECLARATION; #endif #endif #ifndef UNITY_OUTPUT_FLUSH #define UNITY_FLUSH_CALL() #else -#define UNITY_FLUSH_CALL() UNITY_OUTPUT_FLUSH +#define UNITY_FLUSH_CALL() UNITY_OUTPUT_FLUSH() #endif #ifndef UNITY_PRINT_EOL From 59182c4ea963103915a4e0290edfee18e2ef3e7c Mon Sep 17 00:00:00 2001 From: Aviv Palivoda Date: Tue, 1 Aug 2017 22:56:52 +0300 Subject: [PATCH 004/454] Add UNITY_OUTPUT_CHAR_HEADER_DECLARATION to tests Makefile defines --- test/Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/test/Makefile b/test/Makefile index 03b59bc4..9de7a49a 100644 --- a/test/Makefile +++ b/test/Makefile @@ -14,6 +14,7 @@ CFLAGS += -Wbad-function-cast -Wcast-qual -Wold-style-definition -Wshadow -Wstri #DEBUG = -O0 -g CFLAGS += $(DEBUG) DEFINES = -D UNITY_OUTPUT_CHAR=putcharSpy +DEFINES += -D UNITY_OUTPUT_CHAR_HEADER_DECLARATION=putcharSpy\(int\) DEFINES += -D UNITY_SUPPORT_64 -D UNITY_INCLUDE_DOUBLE SRC = ../src/unity.c tests/testunity.c build/testunityRunner.c INC_DIR = -I ../src From b3de931d697e40987d180730a441f9c7ce062784 Mon Sep 17 00:00:00 2001 From: Aviv Palivoda Date: Tue, 1 Aug 2017 23:36:13 +0300 Subject: [PATCH 005/454] Add UNITY_OUTPUT_CHAR_HEADER_DECLARATION to fixture tests Makefile defines --- extras/fixture/test/Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/extras/fixture/test/Makefile b/extras/fixture/test/Makefile index 80e124f4..e6c62552 100644 --- a/extras/fixture/test/Makefile +++ b/extras/fixture/test/Makefile @@ -6,6 +6,7 @@ endif CFLAGS += -std=c99 -pedantic -Wall -Wextra -Werror CFLAGS += $(DEBUG) DEFINES = -D UNITY_OUTPUT_CHAR=UnityOutputCharSpy_OutputChar +DEFINES += -D UNITY_OUTPUT_CHAR_HEADER_DECLARATION=UnityOutputCharSpy_OutputChar\(int\) SRC = ../src/unity_fixture.c \ ../../../src/unity.c \ unity_fixture_Test.c \ From ad373024f28b1efbfca6f5178f9ee4c612d5b4d6 Mon Sep 17 00:00:00 2001 From: Aviv Palivoda Date: Fri, 4 Aug 2017 14:40:34 +0300 Subject: [PATCH 006/454] Add UNITY_OUTPUT_CHAR_HEADER_DECLARATION to tests rakefile_helper.rb --- test/rakefile_helper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/rakefile_helper.rb b/test/rakefile_helper.rb index be5bf3ea..1fd60c5f 100644 --- a/test/rakefile_helper.rb +++ b/test/rakefile_helper.rb @@ -91,7 +91,7 @@ def build_compiler_fields(inject_defines) defines = if $cfg['compiler']['defines']['items'].nil? '' else - squash($cfg['compiler']['defines']['prefix'], $cfg['compiler']['defines']['items'] + ['UNITY_OUTPUT_CHAR=putcharSpy'] + inject_defines) + squash($cfg['compiler']['defines']['prefix'], $cfg['compiler']['defines']['items'] + ['UNITY_OUTPUT_CHAR=putcharSpy'] + ['UNITY_OUTPUT_CHAR_HEADER_DECLARATION=putcharSpy\(int\)'] + inject_defines) end options = squash('', $cfg['compiler']['options']) includes = squash($cfg['compiler']['includes']['prefix'], $cfg['compiler']['includes']['items']) From e56378e4376fe1764cc42ad05f1a42f24cb11404 Mon Sep 17 00:00:00 2001 From: Aviv Palivoda Date: Fri, 4 Aug 2017 14:43:14 +0300 Subject: [PATCH 007/454] Add UNITY_OUTPUT_CHAR_HEADER_DECLARATION to fixture tests rakefile_helper.rb --- extras/fixture/rakefile_helper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extras/fixture/rakefile_helper.rb b/extras/fixture/rakefile_helper.rb index 5aa8e56a..c45b2393 100644 --- a/extras/fixture/rakefile_helper.rb +++ b/extras/fixture/rakefile_helper.rb @@ -53,7 +53,7 @@ def build_compiler_fields defines = if $cfg['compiler']['defines']['items'].nil? '' else - squash($cfg['compiler']['defines']['prefix'], $cfg['compiler']['defines']['items'] + ['UNITY_OUTPUT_CHAR=UnityOutputCharSpy_OutputChar']) + squash($cfg['compiler']['defines']['prefix'], $cfg['compiler']['defines']['items'] + ['UNITY_OUTPUT_CHAR=UnityOutputCharSpy_OutputChar'] + ['UNITY_OUTPUT_CHAR_HEADER_DECLARATION=UnityOutputCharSpy_OutputChar\(int\)']) end options = squash('', $cfg['compiler']['options']) includes = squash($cfg['compiler']['includes']['prefix'], $cfg['compiler']['includes']['items']) From 0e7eb545b9dd3f2337ff2460188604ce67c44259 Mon Sep 17 00:00:00 2001 From: John Lindgren Date: Fri, 25 Aug 2017 14:22:35 -0400 Subject: [PATCH 008/454] Rewrite UnityPrintFloat to match printf("%.6g"). The existing implementation was not very good: - It printed all very small values as "0.000000..." - It did not distinguish positive and negative zero - In some cases it printed extra garbage digits for single-precision values (e.g. 3.9e+30 was printed as 3.90000013+30) Tests have been updated to check that we now match printf("%.6g") for 1,000,000 randomly chosen values, except for rounding of the 6th digit. --- src/unity.c | 149 +++++++++++------------ test/tests/testunity.c | 262 +++++++++++++++-------------------------- 2 files changed, 171 insertions(+), 240 deletions(-) diff --git a/src/unity.c b/src/unity.c index 177af0f4..d5f26cf3 100644 --- a/src/unity.c +++ b/src/unity.c @@ -235,95 +235,96 @@ void UnityPrintMask(const UNITY_UINT mask, const UNITY_UINT number) /*-----------------------------------------------*/ #ifndef UNITY_EXCLUDE_FLOAT_PRINT -static void UnityPrintDecimalAndNumberWithLeadingZeros(UNITY_INT32 fraction_part, UNITY_INT32 divisor) -{ - UNITY_OUTPUT_CHAR('.'); - while (divisor > 0) - { - UNITY_OUTPUT_CHAR('0' + fraction_part / divisor); - fraction_part %= divisor; - divisor /= 10; - if (fraction_part == 0) break; /* Truncate trailing 0's */ - } -} -#ifndef UNITY_ROUND_TIES_AWAY_FROM_ZERO -/* If rounds up && remainder 0.5 && result odd && below cutoff for double precision issues */ - #define ROUND_TIES_TO_EVEN(orig, num_int, num) \ - if (num_int > (num) && (num) - (num_int-1) <= 0.5 && (num_int & 1) == 1 && orig < 1e22) \ - num_int -= 1 /* => a tie to round down to even */ -#else - #define ROUND_TIES_TO_EVEN(orig, num_int, num) /* Remove macro */ -#endif - -/* Printing floating point numbers is hard. Some goals of this implementation: works for embedded - * systems, floats or doubles, and has a reasonable format. The key paper in this area, - * 'How to Print Floating-Point Numbers Accurately' by Steele & White, shows an approximation by - * scaling called Dragon 2. This code uses a similar idea. The other core algorithm uses casts and - * floating subtraction to give exact remainders after the decimal, to be scaled into an integer. - * Extra trailing 0's are excluded. The output defaults to rounding to nearest, ties to even. You - * can enable rounding ties away from zero. Note: UNITY_DOUBLE param can typedef to float or double - - * The old version required compiling in snprintf. For reference, with a similar format as now: - * char buf[19]; - * if (number > 4294967296.0 || -number > 4294967296.0) snprintf(buf, sizeof buf, "%.8e", number); - * else snprintf(buf, sizeof buf, "%.6f", number); - * UnityPrint(buf); - */ +/* This function prints a floating-point value in a format similar to + * printf("%.6g"). It can work with either single- or double-precision, + * but for simplicity, it prints only 6 significant digits in either case. + * Printing more than 6 digits accurately is hard (at least in the single- + * precision case) and isn't attempted here. */ void UnityPrintFloat(const UNITY_DOUBLE input_number) { - UNITY_DOUBLE number; + UNITY_DOUBLE number = input_number; - if (input_number < 0) + /* print minus sign (including for negative zero) */ + if (number < 0.0f || (number == 0.0f && 1.0f / number < 0.0f)) { UNITY_OUTPUT_CHAR('-'); - number = -input_number; - } else - { - number = input_number; + number = -number; } - if (isnan(number)) UnityPrint(UnityStrNaN); - else if (isinf(number)) UnityPrintLen(UnityStrInf, 3); - else if (number <= 0.0000005 && number > 0) UnityPrint("0.000000..."); /* Small number */ - else if (number < 4294967295.9999995) /* Rounded result fits in 32 bits, "%.6f" format */ + /* handle zero, NaN, and +/- infinity */ + if (number == 0.0f) UnityPrint("0"); + else if (isnan(number)) UnityPrint("nan"); + else if (isinf(number)) UnityPrint("inf"); + else { - const UNITY_INT32 divisor = 1000000/10; - UNITY_UINT32 integer_part = (UNITY_UINT32)number; - UNITY_INT32 fraction_part = (UNITY_INT32)((number - (UNITY_DOUBLE)integer_part)*1000000.0 + 0.5); - /* Double precision calculation gives best performance for six rounded decimal places */ - ROUND_TIES_TO_EVEN(number, fraction_part, (number - (UNITY_DOUBLE)integer_part)*1000000.0); + int exponent = 0; + + /* scale up or down by powers of 10 */ + while (number < 100000.0f / 1e6f) { number *= 1e6f; exponent -= 6; } + while (number < 100000.0f) { number *= 10.0f; exponent--; } + while (number > 1000000.0f * 1e6f) { number /= 1e6f; exponent += 6; } + while (number > 1000000.0f) { number /= 10.0f; exponent++; } - if (fraction_part == 1000000) /* Carry across the decimal point */ + /* round to nearest integer */ + UNITY_INT32 n = ((UNITY_INT32)(number + number) + 1) / 2; + if (n > 999999) { - fraction_part = 0; - integer_part += 1; + n = 100000; + exponent++; } - UnityPrintNumberUnsigned(integer_part); - UnityPrintDecimalAndNumberWithLeadingZeros(fraction_part, divisor); - } - else /* Number is larger, use exponential format of 9 digits, "%.8e" */ - { - const UNITY_INT32 divisor = 1000000000/10; - UNITY_INT32 integer_part; - UNITY_DOUBLE_TYPE divide = 10.0; - int exponent = 9; + /* determine where to place decimal point */ + int decimals = (exponent <= 0 && exponent >= -9) ? -exponent : 5; - while (number / divide >= 1000000000.0 - 0.5) + exponent += decimals; + + /* truncate trailing zeroes after decimal point */ + while (decimals > 0 && n % 10 == 0) { - divide *= 10; - exponent++; + n /= 10; + decimals--; + } + + /* build up buffer in reverse order */ + char buf[16]; + int digits = 0; + while (n != 0 || digits < decimals + 1) + { + buf[digits++] = (char)('0' + n % 10); + n /= 10; + } + while (digits > 0) + { + if(digits == decimals) UNITY_OUTPUT_CHAR('.'); + UNITY_OUTPUT_CHAR(buf[--digits]); + } + + /* print exponent if needed */ + if (exponent != 0) + { + UNITY_OUTPUT_CHAR('e'); + + if(exponent < 0) + { + UNITY_OUTPUT_CHAR('-'); + exponent = -exponent; + } + else + { + UNITY_OUTPUT_CHAR('+'); + } + + digits = 0; + while (exponent != 0 || digits < 2) + { + buf[digits++] = (char)('0' + exponent % 10); + exponent /= 10; + } + while (digits > 0) + { + UNITY_OUTPUT_CHAR(buf[--digits]); + } } - integer_part = (UNITY_INT32)(number / divide + 0.5); - /* Double precision calculation required for float, to produce 9 rounded digits */ - ROUND_TIES_TO_EVEN(number, integer_part, number / divide); - - UNITY_OUTPUT_CHAR('0' + integer_part / divisor); - UnityPrintDecimalAndNumberWithLeadingZeros(integer_part % divisor, divisor / 10); - UNITY_OUTPUT_CHAR('e'); - UNITY_OUTPUT_CHAR('+'); - if (exponent < 10) UNITY_OUTPUT_CHAR('0'); - UnityPrintNumber(exponent); } } #endif /* ! UNITY_EXCLUDE_FLOAT_PRINT */ diff --git a/test/tests/testunity.c b/test/tests/testunity.c index 3555fb2d..bec2a818 100644 --- a/test/tests/testunity.c +++ b/test/tests/testunity.c @@ -4056,61 +4056,46 @@ void testFloatPrinting(void) #if defined(UNITY_EXCLUDE_FLOAT_PRINT) || !defined(USING_OUTPUT_SPY) TEST_IGNORE(); #else - TEST_ASSERT_EQUAL_PRINT_FLOATING("0.0", 0.0f); - TEST_ASSERT_EQUAL_PRINT_FLOATING("0.000000...", 0.000000499f); - TEST_ASSERT_EQUAL_PRINT_FLOATING("0.000001", 0.00000050000005f); - TEST_ASSERT_EQUAL_PRINT_FLOATING("0.100469", 0.100469499f); - TEST_ASSERT_EQUAL_PRINT_FLOATING("1.0", 0.9999995f); /*Rounding to int place*/ - TEST_ASSERT_EQUAL_PRINT_FLOATING("1.0", 1.0f); - TEST_ASSERT_EQUAL_PRINT_FLOATING("1.25", 1.25f); - TEST_ASSERT_EQUAL_PRINT_FLOATING("7.999999", 7.999999f); /*Not rounding*/ - TEST_ASSERT_EQUAL_PRINT_FLOATING("16.000002", 16.000002f); - TEST_ASSERT_EQUAL_PRINT_FLOATING("16.000004", 16.000004f); - TEST_ASSERT_EQUAL_PRINT_FLOATING("16.000006", 16.000006f); - TEST_ASSERT_EQUAL_PRINT_FLOATING("4294967040.0", 4294967040.0f); /*Last full print integer*/ - - TEST_ASSERT_EQUAL_PRINT_FLOATING("0.0", -0.0f); - TEST_ASSERT_EQUAL_PRINT_FLOATING("-0.000000...",-0.000000499f); - TEST_ASSERT_EQUAL_PRINT_FLOATING("-0.000001", -0.00000050000005f); - TEST_ASSERT_EQUAL_PRINT_FLOATING("-0.100469", -0.100469499f); - TEST_ASSERT_EQUAL_PRINT_FLOATING("-1.0", -0.9999995f); /*Rounding to int place*/ - TEST_ASSERT_EQUAL_PRINT_FLOATING("-1.0", -1.0f); - TEST_ASSERT_EQUAL_PRINT_FLOATING("-1.25", -1.25f); - TEST_ASSERT_EQUAL_PRINT_FLOATING("-7.999999", -7.999999f); /*Not rounding*/ - TEST_ASSERT_EQUAL_PRINT_FLOATING("-16.000002", -16.000002f); - TEST_ASSERT_EQUAL_PRINT_FLOATING("-16.000004", -16.000004f); - TEST_ASSERT_EQUAL_PRINT_FLOATING("-16.000006", -16.000006f); - TEST_ASSERT_EQUAL_PRINT_FLOATING("-4294967040.0",-4294967040.0f); /*Last full print integer*/ - - TEST_ASSERT_EQUAL_PRINT_FLOATING("4.2949673e+09", 4294967296.0f); - TEST_ASSERT_EQUAL_PRINT_FLOATING("5.0e+09", 5000000000.0f); - TEST_ASSERT_EQUAL_PRINT_FLOATING("8.0e+09", 8.0e+09f); - TEST_ASSERT_EQUAL_PRINT_FLOATING("8.3099991e+09", 8309999104.0f); - TEST_ASSERT_EQUAL_PRINT_FLOATING("1.0e+10", 1.0e+10f); - TEST_ASSERT_EQUAL_PRINT_FLOATING("1.0e+10", 10000000000.0f); + TEST_ASSERT_EQUAL_PRINT_FLOATING("0", 0.0f); + TEST_ASSERT_EQUAL_PRINT_FLOATING("4.99e-07", 0.000000499f); + TEST_ASSERT_EQUAL_PRINT_FLOATING("5e-07", 0.00000050000005f); + TEST_ASSERT_EQUAL_PRINT_FLOATING("0.100469", 0.100469499f); + TEST_ASSERT_EQUAL_PRINT_FLOATING("1", 0.9999995f); /*Rounding to int place*/ + TEST_ASSERT_EQUAL_PRINT_FLOATING("1", 1.0f); + TEST_ASSERT_EQUAL_PRINT_FLOATING("1.25", 1.25f); + TEST_ASSERT_EQUAL_PRINT_FLOATING("7.99999", 7.99999f); /*Not rounding*/ + TEST_ASSERT_EQUAL_PRINT_FLOATING("16.0002", 16.0002f); + TEST_ASSERT_EQUAL_PRINT_FLOATING("16.0004", 16.0004f); + TEST_ASSERT_EQUAL_PRINT_FLOATING("16.0006", 16.0006f); + TEST_ASSERT_EQUAL_PRINT_FLOATING("999999", 999999.0f); /*Last full print integer*/ + + TEST_ASSERT_EQUAL_PRINT_FLOATING("-0", -0.0f); + TEST_ASSERT_EQUAL_PRINT_FLOATING("-4.99e-07", -0.000000499f); + TEST_ASSERT_EQUAL_PRINT_FLOATING("-5e-07", -0.00000050000005f); + TEST_ASSERT_EQUAL_PRINT_FLOATING("-0.100469", -0.100469499f); + TEST_ASSERT_EQUAL_PRINT_FLOATING("-1", -0.9999995f); /*Rounding to int place*/ + TEST_ASSERT_EQUAL_PRINT_FLOATING("-1", -1.0f); + TEST_ASSERT_EQUAL_PRINT_FLOATING("-1.25", -1.25f); + TEST_ASSERT_EQUAL_PRINT_FLOATING("-7.99999", -7.99999f); /*Not rounding*/ + TEST_ASSERT_EQUAL_PRINT_FLOATING("-16.0002", -16.0002f); + TEST_ASSERT_EQUAL_PRINT_FLOATING("-16.0004", -16.0004f); + TEST_ASSERT_EQUAL_PRINT_FLOATING("-16.0006", -16.0006f); + TEST_ASSERT_EQUAL_PRINT_FLOATING("-999999", -999999.0f); /*Last full print integer*/ + + TEST_ASSERT_EQUAL_PRINT_FLOATING("4.29497e+09", 4294967296.0f); + TEST_ASSERT_EQUAL_PRINT_FLOATING("5e+09", 5000000000.0f); + TEST_ASSERT_EQUAL_PRINT_FLOATING("8e+09", 8.0e+09f); + TEST_ASSERT_EQUAL_PRINT_FLOATING("8.31e+09", 8309999104.0f); + TEST_ASSERT_EQUAL_PRINT_FLOATING("1e+10", 1.0e+10f); + TEST_ASSERT_EQUAL_PRINT_FLOATING("1e+10", 10000000000.0f); /* Some compilers have trouble with inexact float constants, a float cast works generally */ - TEST_ASSERT_EQUAL_PRINT_FLOATING("1.00005499e+10", (float)1.000055e+10f); - TEST_ASSERT_EQUAL_PRINT_FLOATING("1.10000006e+38", (float)1.10000005e+38f); - TEST_ASSERT_EQUAL_PRINT_FLOATING("1.63529943e+10", 1.63529943e+10f); - TEST_ASSERT_EQUAL_PRINT_FLOATING("3.40282347e+38", 3.40282346638e38f); + TEST_ASSERT_EQUAL_PRINT_FLOATING("1.00005e+10", (float)1.000054e+10f); + TEST_ASSERT_EQUAL_PRINT_FLOATING("1.1e+38", (float)1.10000005e+38f); + TEST_ASSERT_EQUAL_PRINT_FLOATING("1.6353e+10", 1.63529943e+10f); + TEST_ASSERT_EQUAL_PRINT_FLOATING("3.40282e+38", 3.40282346638e38f); - TEST_ASSERT_EQUAL_PRINT_FLOATING("-1.0e+10", -1.0e+10f); - TEST_ASSERT_EQUAL_PRINT_FLOATING("-3.40282347e+38",-3.40282346638e38f); -#endif -} - -void testFloatPrintingRoundTiesToEven(void) -{ -#if defined(UNITY_EXCLUDE_FLOAT_PRINT) || !defined(USING_OUTPUT_SPY) - TEST_IGNORE(); -#else - #ifdef UNITY_ROUND_TIES_AWAY_FROM_ZERO - TEST_ASSERT_EQUAL_PRINT_FLOATING("0.007813", 0.0078125f); - TEST_ASSERT_EQUAL_PRINT_FLOATING("0.976563", 0.9765625f); - #else /* Default to Round ties to even */ - TEST_ASSERT_EQUAL_PRINT_FLOATING("0.007182", 0.0071825f); - TEST_ASSERT_EQUAL_PRINT_FLOATING("0.976562", 0.9765625f); - #endif + TEST_ASSERT_EQUAL_PRINT_FLOATING("-1e+10", -1.0e+10f); + TEST_ASSERT_EQUAL_PRINT_FLOATING("-3.40282e+38", -3.40282346638e38f); #endif } @@ -4119,107 +4104,67 @@ void testFloatPrintingInfinityAndNaN(void) #if defined(UNITY_EXCLUDE_FLOAT_PRINT) || !defined(USING_OUTPUT_SPY) TEST_IGNORE(); #else - TEST_ASSERT_EQUAL_PRINT_FLOATING("Inf", 1.0f / f_zero); - TEST_ASSERT_EQUAL_PRINT_FLOATING("-Inf", -1.0f / f_zero); + TEST_ASSERT_EQUAL_PRINT_FLOATING("inf", 1.0f / f_zero); + TEST_ASSERT_EQUAL_PRINT_FLOATING("-inf", -1.0f / f_zero); - TEST_ASSERT_EQUAL_PRINT_FLOATING("NaN", 0.0f / f_zero); + TEST_ASSERT_EQUAL_PRINT_FLOATING("nan", 0.0f / f_zero); #endif } #if defined(UNITY_TEST_ALL_FLOATS_PRINT_OK) && defined(USING_OUTPUT_SPY) -static void AllFloatPrinting_LessThan32Bits(void) +static void printFloatValue(float f) { char expected[18]; - union { float f_value; int32_t int_value; } u; - /* Float representations are laid out in integer order, walk up the list */ - for (u.f_value = 0.00000050000005f; u.f_value <= 4294967040.0f; u.int_value += 1) - { - startPutcharSpy(); - - UnityPrintFloat(u.f_value); /*1.5x as fast as sprintf 5e-7f - 0.01f, 20s vs 30s*/ - int len = sprintf(expected, "%.6f", u.f_value); - - while (expected[len - 1] == '0' && expected[len - 2] != '.') { len--; } - expected[len] = '\0'; /* delete trailing 0's */ - - if (strcmp(expected, getBufferPutcharSpy()) != 0) - { - double six_digits = ((double)u.f_value - (uint32_t)u.f_value)*1000000.0; - /* Not a tie (remainder != 0.5) => Can't explain the different strings */ - if (six_digits - (uint32_t)six_digits != 0.5) - { - /* Fail with diagnostic printing */ - TEST_ASSERT_EQUAL_PRINT_FLOATING(expected, u.f_value); - } - } - } -} + char expected_lower[18]; + char expected_higher[18]; -/* Compared to perfect, floats are occasionally rounded wrong. It doesn't affect - * correctness, though. Two examples (of 13 total found during testing): - * Printed: 6.19256349e+20, Exact: 619256348499999981568.0f <= Eliminated by ROUND_TIES_TO_EVEN - * Printed: 2.19012272e+35, Exact: 219012271499999993621766990196637696.0f */ -static void AllFloatPrinting_Larger(const float start, const float end) -{ - unsigned int wrong = 0; - char expected[18]; - union { float f_value; int32_t int_value; } u; - for (u.f_value = start; u.f_value <= end; u.int_value += 1) - { - startPutcharSpy(); + startPutcharSpy(); - UnityPrintFloat(u.f_value); /*Twice as fast as sprintf 2**32-1e12, 10s vs 21s*/ - sprintf(expected, "%.8e", u.f_value); + UnityPrintFloat(f); - int len = 11 - 1; /* 11th char is 'e' in exponential format */ - while (expected[len - 1] == '0' && expected[len - 2] != '.') { len --; } - if (expected[14] != '\0') memmove(&expected[12], &expected[13], 3); /* Two char exponent */ - memmove(&expected[len], &expected[11 - 1], sizeof "e+09"); /* 5 char length */ + sprintf(expected, "%.6g", f); - if (strcmp(expected, getBufferPutcharSpy()) != 0) - { - wrong++; - /* endPutcharSpy(); UnityPrint("Expected "); UnityPrint(expected); - UnityPrint(" Was "); UnityPrint(getBufferPutcharSpy()); UNITY_OUTPUT_CHAR('\n'); */ + /* We print all NaN's as "nan", not "-nan" */ + if(strcmp(expected, "-nan") == 0) strcpy(expected, "nan"); - if (wrong > 10 || (wrong > 3 && end <= 1e25f)) - TEST_ASSERT_EQUAL_PRINT_FLOATING(expected, u.f_value); - /* Empirical values from the current routine, don't be worse when making changes */ - } + /* Allow for rounding differences in last digit */ + double lower = (double)f * 0.9999995; + double higher = (double)f * 1.0000005; + + if (isfinite(lower)) sprintf(expected_lower, "%.6g", lower); else strcpy(expected_lower, expected); + if (isfinite(higher)) sprintf(expected_higher, "%.6g", higher); else strcpy(expected_higher, expected); + + if (strcmp(expected, getBufferPutcharSpy()) != 0 && + strcmp(expected_lower, getBufferPutcharSpy()) != 0 && + strcmp(expected_higher, getBufferPutcharSpy()) != 0) + { + /* Fail with diagnostic printing */ + TEST_ASSERT_EQUAL_PRINT_FLOATING(expected, f); } } -#endif -/* Exhaustive testing of all float values we differentiate when printing. Doubles - * are not explored here -- too many. These tests confirm that the routine works - * for all floats > 5e-7, positives only. Off by default due to test time. - * Compares Unity's routine to your sprintf() C lib, tested to pass on 3 platforms. - * Part1 takes a long time, around 3 minutes compiled with -O2 - * Runs through all floats from 0.000001 - 2**32, ~300 million values */ -void testAllFloatPrintingPart1_LessThan32Bits(void) +void testFloatPrintingRandomSamples(void) { -#if defined(UNITY_TEST_ALL_FLOATS_PRINT_OK) && defined(USING_OUTPUT_SPY) - AllFloatPrinting_LessThan32Bits(); -#else - TEST_IGNORE(); /* Ignore one of three */ -#endif -} + union { float f_value; uint32_t int_value; } u; -/* Test takes a long time, around 3.5 minutes compiled with -O2, try ~500 million values */ -void testAllFloatPrintingPart2_Larger(void) -{ -#if defined(UNITY_TEST_ALL_FLOATS_PRINT_OK) && defined(USING_OUTPUT_SPY) - AllFloatPrinting_Larger(4294967296.0f, 1e25f); -#endif -} + /* These values are not covered by the MINSTD generator */ + u.int_value = 0x00000000; printFloatValue(u.f_value); + u.int_value = 0x80000000; printFloatValue(u.f_value); + u.int_value = 0x7fffffff; printFloatValue(u.f_value); + u.int_value = 0xffffffff; printFloatValue(u.f_value); -/* Test takes a long time, around 3.5 minutes compiled with -O2, try ~500 million values */ -void testAllFloatPrintingPart3_LargerStill(void) -{ -#if defined(UNITY_TEST_ALL_FLOATS_PRINT_OK) && defined(USING_OUTPUT_SPY) - AllFloatPrinting_Larger(1e25f, 3.40282347e+38f); -#endif + uint32_t a = 1; + for(int num_tested = 0; num_tested < 1000000; num_tested++) + { + /* MINSTD pseudo-random number generator */ + a = (uint32_t)(((uint64_t)a * 48271u) % 2147483647u); + + /* MINSTD does not set the highest bit; test both possibilities */ + u.int_value = a; printFloatValue(u.f_value); + u.int_value = a | 0x80000000; printFloatValue(u.f_value); + } } +#endif // ===================== THESE TEST WILL RUN IF YOUR CONFIG INCLUDES DOUBLE SUPPORT ================== @@ -4893,35 +4838,20 @@ void testDoublePrinting(void) #if defined(UNITY_EXCLUDE_FLOAT_PRINT) || defined(UNITY_EXCLUDE_DOUBLE) || !defined(USING_OUTPUT_SPY) TEST_IGNORE(); #else - TEST_ASSERT_EQUAL_PRINT_FLOATING("0.100469", 0.10046949999999999); - TEST_ASSERT_EQUAL_PRINT_FLOATING("4294967295.999999", 4294967295.999999); - TEST_ASSERT_EQUAL_PRINT_FLOATING("4.2949673e+09", 4294967295.9999995); - TEST_ASSERT_EQUAL_PRINT_FLOATING("4.2949673e+09", 4294967296.0); - TEST_ASSERT_EQUAL_PRINT_FLOATING("1.0e+10", 9999999995.0); - TEST_ASSERT_EQUAL_PRINT_FLOATING("9.00719925e+15", 9007199254740990.0); - TEST_ASSERT_EQUAL_PRINT_FLOATING("7.0e+100", 7.0e+100); - TEST_ASSERT_EQUAL_PRINT_FLOATING("3.0e+200", 3.0e+200); - TEST_ASSERT_EQUAL_PRINT_FLOATING("9.23456789e+300", 9.23456789e+300); - - TEST_ASSERT_EQUAL_PRINT_FLOATING("-0.100469", -0.10046949999999999); - TEST_ASSERT_EQUAL_PRINT_FLOATING("-4294967295.999999", -4294967295.999999); - TEST_ASSERT_EQUAL_PRINT_FLOATING("-4.2949673e+09", -4294967295.9999995); - TEST_ASSERT_EQUAL_PRINT_FLOATING("-7.0e+100", -7.0e+100); -#endif -} + TEST_ASSERT_EQUAL_PRINT_FLOATING("0.100469", 0.10046949999999999); + TEST_ASSERT_EQUAL_PRINT_FLOATING("4.29497e+09", 4294967295.999999); + TEST_ASSERT_EQUAL_PRINT_FLOATING("4.29497e+09", 4294967295.9999995); + TEST_ASSERT_EQUAL_PRINT_FLOATING("4.29497e+09", 4294967296.0); + TEST_ASSERT_EQUAL_PRINT_FLOATING("1e+10", 9999999995.0); + TEST_ASSERT_EQUAL_PRINT_FLOATING("9.0072e+15", 9007199254740990.0); + TEST_ASSERT_EQUAL_PRINT_FLOATING("7e+100", 7.0e+100); + TEST_ASSERT_EQUAL_PRINT_FLOATING("3e+200", 3.0e+200); + TEST_ASSERT_EQUAL_PRINT_FLOATING("9.23457e+300", 9.23456789e+300); -void testDoublePrintingRoundTiesToEven(void) -{ -#if defined(UNITY_EXCLUDE_FLOAT_PRINT) || defined(UNITY_EXCLUDE_DOUBLE) || !defined(USING_OUTPUT_SPY) - TEST_IGNORE(); -#else - #ifdef UNITY_ROUND_TIES_AWAY_FROM_ZERO - TEST_ASSERT_EQUAL_PRINT_FLOATING("1.00000001e+10", 10000000050.0); - TEST_ASSERT_EQUAL_PRINT_FLOATING("9.00719925e+15", 9007199245000000.0); - #else /* Default to Round ties to even */ - TEST_ASSERT_EQUAL_PRINT_FLOATING("1.0e+10", 10000000050.0); - TEST_ASSERT_EQUAL_PRINT_FLOATING("9.00719924e+15", 9007199245000000.0); - #endif + TEST_ASSERT_EQUAL_PRINT_FLOATING("-0.100469", -0.10046949999999999); + TEST_ASSERT_EQUAL_PRINT_FLOATING("-4.29497e+09", -4294967295.999999); + TEST_ASSERT_EQUAL_PRINT_FLOATING("-4.29497e+09", -4294967295.9999995); + TEST_ASSERT_EQUAL_PRINT_FLOATING("-7e+100", -7.0e+100); #endif } @@ -4930,10 +4860,10 @@ void testDoublePrintingInfinityAndNaN(void) #if defined(UNITY_EXCLUDE_FLOAT_PRINT) || defined(UNITY_EXCLUDE_DOUBLE) || !defined(USING_OUTPUT_SPY) TEST_IGNORE(); #else - TEST_ASSERT_EQUAL_PRINT_FLOATING("Inf", 1.0 / d_zero); - TEST_ASSERT_EQUAL_PRINT_FLOATING("-Inf", -1.0 / d_zero); + TEST_ASSERT_EQUAL_PRINT_FLOATING("inf", 1.0 / d_zero); + TEST_ASSERT_EQUAL_PRINT_FLOATING("-inf", -1.0 / d_zero); - TEST_ASSERT_EQUAL_PRINT_FLOATING("NaN", 0.0 / d_zero); + TEST_ASSERT_EQUAL_PRINT_FLOATING("nan", 0.0 / d_zero); #endif } From dbdd168e46cb4bde13ac63191676265068a36f1e Mon Sep 17 00:00:00 2001 From: John Lindgren Date: Fri, 25 Aug 2017 15:47:40 -0400 Subject: [PATCH 009/454] Fix test link error. --- test/tests/testunity.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/test/tests/testunity.c b/test/tests/testunity.c index bec2a818..55a9b5d7 100644 --- a/test/tests/testunity.c +++ b/test/tests/testunity.c @@ -4142,9 +4142,13 @@ static void printFloatValue(float f) TEST_ASSERT_EQUAL_PRINT_FLOATING(expected, f); } } +#endif void testFloatPrintingRandomSamples(void) { +#if !defined(UNITY_TEST_ALL_FLOATS_PRINT_OK) || !defined(USING_OUTPUT_SPY) + TEST_IGNORE(); +#else union { float f_value; uint32_t int_value; } u; /* These values are not covered by the MINSTD generator */ @@ -4163,8 +4167,8 @@ void testFloatPrintingRandomSamples(void) u.int_value = a; printFloatValue(u.f_value); u.int_value = a | 0x80000000; printFloatValue(u.f_value); } -} #endif +} // ===================== THESE TEST WILL RUN IF YOUR CONFIG INCLUDES DOUBLE SUPPORT ================== From 2ae2bdb3768d15e3e9e3bfc600d81227c78213c0 Mon Sep 17 00:00:00 2001 From: John Lindgren Date: Fri, 25 Aug 2017 15:52:06 -0400 Subject: [PATCH 010/454] Make code C89-compliant. --- src/unity.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/unity.c b/src/unity.c index d5f26cf3..e12af266 100644 --- a/src/unity.c +++ b/src/unity.c @@ -258,6 +258,9 @@ void UnityPrintFloat(const UNITY_DOUBLE input_number) else { int exponent = 0; + int decimals, digits; + UNITY_INT32 n; + char buf[16]; /* scale up or down by powers of 10 */ while (number < 100000.0f / 1e6f) { number *= 1e6f; exponent -= 6; } @@ -266,7 +269,7 @@ void UnityPrintFloat(const UNITY_DOUBLE input_number) while (number > 1000000.0f) { number /= 10.0f; exponent++; } /* round to nearest integer */ - UNITY_INT32 n = ((UNITY_INT32)(number + number) + 1) / 2; + n = ((UNITY_INT32)(number + number) + 1) / 2; if (n > 999999) { n = 100000; @@ -274,8 +277,7 @@ void UnityPrintFloat(const UNITY_DOUBLE input_number) } /* determine where to place decimal point */ - int decimals = (exponent <= 0 && exponent >= -9) ? -exponent : 5; - + decimals = (exponent <= 0 && exponent >= -9) ? -exponent : 5; exponent += decimals; /* truncate trailing zeroes after decimal point */ @@ -286,8 +288,7 @@ void UnityPrintFloat(const UNITY_DOUBLE input_number) } /* build up buffer in reverse order */ - char buf[16]; - int digits = 0; + digits = 0; while (n != 0 || digits < decimals + 1) { buf[digits++] = (char)('0' + n % 10); From 05daf95d4eeef8adf6bb6030d0221cb0abc01ed6 Mon Sep 17 00:00:00 2001 From: Mark VanderVoord Date: Fri, 8 Sep 2017 15:37:31 -0400 Subject: [PATCH 011/454] Update to match Ruby style guide --- auto/colour_prompt.rb | 2 +- examples/example_3/rakefile.rb | 4 ++-- extras/fixture/rakefile.rb | 8 ++++---- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/auto/colour_prompt.rb b/auto/colour_prompt.rb index c8618070..0f1dc4e0 100644 --- a/auto/colour_prompt.rb +++ b/auto/colour_prompt.rb @@ -24,7 +24,7 @@ def initialize return unless RUBY_PLATFORM =~ /(win|w)32$/ get_std_handle = Win32API.new('kernel32', 'GetStdHandle', ['L'], 'L') @set_console_txt_attrb = - Win32API.new('kernel32', 'SetConsoleTextAttribute', %w[L N], 'I') + Win32API.new('kernel32', 'SetConsoleTextAttribute', %w(L N), 'I') @hout = get_std_handle.call(-11) end diff --git a/examples/example_3/rakefile.rb b/examples/example_3/rakefile.rb index 8bedd4f0..bf9f42be 100644 --- a/examples/example_3/rakefile.rb +++ b/examples/example_3/rakefile.rb @@ -32,8 +32,8 @@ end desc 'Build and test Unity' -task all: %i[clean unit summary] -task default: %i[clobber all] +task all: %i(clean unit summary) +task default: %i(clobber all) task ci: [:default] task cruise: [:default] diff --git a/extras/fixture/rakefile.rb b/extras/fixture/rakefile.rb index 8528afc9..7603e574 100644 --- a/extras/fixture/rakefile.rb +++ b/extras/fixture/rakefile.rb @@ -33,10 +33,10 @@ end desc 'Build and test Unity Framework' -task all: %i[clean unit] -task default: %i[clobber all] -task ci: %i[no_color default] -task cruise: %i[no_color default] +task all: %i(clean unit) +task default: %i(clobber all) +task ci: %i(no_color default) +task cruise: %i(no_color default) desc 'Load configuration' task :config, :config_file do |_t, args| From cc909efed33165be83732e2f6a502459663914c1 Mon Sep 17 00:00:00 2001 From: balaksh Date: Mon, 10 Apr 2017 15:08:01 +1200 Subject: [PATCH 012/454] Implement optional printing of execution time for each test --- examples/unity_config.h | 8 +++++ extras/fixture/src/unity_fixture.c | 4 +++ src/unity.c | 4 ++- src/unity_internals.h | 52 ++++++++++++++++++++++++++++++ test/tests/testunity.c | 8 +++++ 5 files changed, 75 insertions(+), 1 deletion(-) diff --git a/examples/unity_config.h b/examples/unity_config.h index da3c2af1..d586448a 100644 --- a/examples/unity_config.h +++ b/examples/unity_config.h @@ -236,4 +236,12 @@ /* #define UNITY_PTR_ATTRIBUTE __attribute__((far)) */ /* #define UNITY_PTR_ATTRIBUTE near */ +/* Print execution time of each test when executed in verbose mode + * + * Example: + * + * TEST - PASS (10 ms) + */ +/* #define UNITY_INCLUDE_EXEC_TIME */ + #endif /* UNITY_CONFIG_H */ diff --git a/extras/fixture/src/unity_fixture.c b/extras/fixture/src/unity_fixture.c index 3872bd8f..36c1fb16 100644 --- a/extras/fixture/src/unity_fixture.c +++ b/extras/fixture/src/unity_fixture.c @@ -93,6 +93,8 @@ void UnityTestRunner(unityfunction* setup, UnityMalloc_StartTest(); UnityPointer_Init(); + UNITY_EXEC_TIME_START(); + if (TEST_PROTECT()) { setup(); @@ -418,6 +420,8 @@ void UnityConcludeFixtureTest(void) if (UnityFixture.Verbose) { UnityPrint(" PASS"); + UNITY_EXEC_TIME_STOP(); + UNITY_PRINT_EXEC_TIME(); UNITY_PRINT_EOL(); } } diff --git a/src/unity.c b/src/unity.c index a493b766..cae7bbd0 100644 --- a/src/unity.c +++ b/src/unity.c @@ -370,6 +370,7 @@ void UnityConcludeTest(void) Unity.CurrentTestFailed = 0; Unity.CurrentTestIgnored = 0; + UNITY_EXEC_TIME_RESET(); UNITY_PRINT_EOL(); UNITY_FLUSH_CALL(); } @@ -958,7 +959,7 @@ void UnityAssertNumbersWithin(const UNITY_UINT delta, if ((style & UNITY_DISPLAY_RANGE_INT) == UNITY_DISPLAY_RANGE_INT) { if (actual > expected) - Unity.CurrentTestFailed = (UNITY_UINT)((UNITY_UINT)(actual - expected) > delta); + Unity.CurrentTestFailed = (UNITY_UINT)((UNITY_UINT)(actual - expected) > delta); else Unity.CurrentTestFailed = (UNITY_UINT)((UNITY_UINT)(expected - actual) > delta); } @@ -1351,6 +1352,7 @@ void UnityBegin(const char* filename) Unity.TestIgnores = 0; Unity.CurrentTestFailed = 0; Unity.CurrentTestIgnored = 0; + UNITY_EXEC_TIME_RESET(); UNITY_CLR_DETAILS(); UNITY_OUTPUT_START(); diff --git a/src/unity_internals.h b/src/unity_internals.h index 1b57cd02..e1616275 100644 --- a/src/unity_internals.h +++ b/src/unity_internals.h @@ -32,6 +32,10 @@ #include #endif +#ifndef UNITY_EXCLUDE_TIME_H +#include +#endif + /*------------------------------------------------------- * Guess Widths If Not Specified *-------------------------------------------------------*/ @@ -285,6 +289,44 @@ extern void UNITY_OMIT_OUTPUT_FLUSH_HEADER_DECLARATION; #define UNITY_OUTPUT_COMPLETE() #endif +#ifndef UNITY_EXEC_TIME_RESET +#ifdef UNITY_INCLUDE_EXEC_TIME +#define UNITY_EXEC_TIME_RESET()\ + Unity.CurrentTestStartTime = 0;\ + Unity.CurrentTestStopTime = 0; +#else +#define UNITY_EXEC_TIME_RESET() +#endif +#endif + +#ifndef UNITY_EXEC_TIME_START +#ifdef UNITY_INCLUDE_EXEC_TIME +#define UNITY_EXEC_TIME_START() Unity.CurrentTestStartTime = UNITY_CLOCK_MS(); +#else +#define UNITY_EXEC_TIME_START() +#endif +#endif + +#ifndef UNITY_EXEC_TIME_START +#ifdef UNITY_INCLUDE_EXEC_TIME +#define UNITY_EXEC_TIME_STOP() Unity.CurrentTestStopTime = UNITY_CLOCK_MS(); +#else +#define UNITY_EXEC_TIME_STOP() +#endif +#endif + +#ifndef UNITY_PRINT_EXEC_TIME +#ifdef UNITY_INCLUDE_EXEC_TIME +#define UNITY_PRINT_EXEC_TIME() \ + UnityPrint(" (");\ + UNITY_COUNTER_TYPE execTimeMs = (Unity.CurrentTestStopTime - Unity.CurrentTestStartTime); + UnityPrintNumberUnsigned(execTimeMs);\ + UnityPrint(" ms)"); +#else +#define UNITY_PRINT_EXEC_TIME() +#endif +#endif + /*------------------------------------------------------- * Footprint *-------------------------------------------------------*/ @@ -387,6 +429,10 @@ struct UNITY_STORAGE_T UNITY_COUNTER_TYPE TestIgnores; UNITY_COUNTER_TYPE CurrentTestFailed; UNITY_COUNTER_TYPE CurrentTestIgnored; +#ifdef UNITY_INCLUDE_EXEC_TIME + UNITY_COUNTER_TYPE CurrentTestStartTime; + UNITY_COUNTER_TYPE CurrentTestStopTime; +#endif #ifndef UNITY_EXCLUDE_SETJMP_H jmp_buf AbortFrame; #endif @@ -590,6 +636,12 @@ extern const char UnityStrErr64[]; #define TEST_ABORT() return #endif +#ifndef UNITY_EXCLUDE_TIME_H +#define UNITY_CLOCK_MS() (UNITY_COUNTER_TYPE)((clock() * 1000) / CLOCKS_PER_SEC) +#else +#define UNITY_CLOCK_MS() +#endif + /* This tricky series of macros gives us an optional line argument to treat it as RUN_TEST(func, num=__LINE__) */ #ifndef RUN_TEST #ifdef __STDC_VERSION__ diff --git a/test/tests/testunity.c b/test/tests/testunity.c index af06647f..88fb2842 100644 --- a/test/tests/testunity.c +++ b/test/tests/testunity.c @@ -99,6 +99,10 @@ void testUnitySizeInitializationReminder(void) UNITY_COUNTER_TYPE TestIgnores; UNITY_COUNTER_TYPE CurrentTestFailed; UNITY_COUNTER_TYPE CurrentTestIgnored; +#ifdef UNITY_INCLUDE_EXEC_TIME + UNITY_COUNTER_TYPE CurrentTestStartTime; + UNITY_COUNTER_TYPE CurrentTestStopTime; +#endif #ifndef UNITY_EXCLUDE_SETJMP_H jmp_buf AbortFrame; #endif @@ -115,6 +119,10 @@ void testUnitySizeInitializationReminder(void) UNITY_COUNTER_TYPE TestIgnores; UNITY_COUNTER_TYPE CurrentTestFailed; UNITY_COUNTER_TYPE CurrentTestIgnored; +#ifdef UNITY_INCLUDE_EXEC_TIME + UNITY_COUNTER_TYPE CurrentTestStartTime; + UNITY_COUNTER_TYPE CurrentTestStopTime; +#endif #ifndef UNITY_EXCLUDE_SETJMP_H jmp_buf AbortFrame; #endif From fcd4883c5eecf2eb7062e36ed945122b76dfb15b Mon Sep 17 00:00:00 2001 From: John Lindgren Date: Mon, 11 Sep 2017 10:00:39 -0400 Subject: [PATCH 013/454] Fix compiler warning due to reusing symbol 'exp'. --- src/unity.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/unity.c b/src/unity.c index a493b766..9783efac 100644 --- a/src/unity.c +++ b/src/unity.c @@ -1073,7 +1073,7 @@ void UnityAssertEqualStringArray(UNITY_INTERNAL_PTR expected, { UNITY_UINT32 i = 0; UNITY_UINT32 j = 0; - const char* exp = NULL; + const char* expd = NULL; const char* act = NULL; RETURN_IF_FAIL_OR_IGNORE; @@ -1096,7 +1096,7 @@ void UnityAssertEqualStringArray(UNITY_INTERNAL_PTR expected, if (flags != UNITY_ARRAY_TO_ARRAY) { - exp = (const char*)expected; + expd = (const char*)expected; } do @@ -1104,15 +1104,15 @@ void UnityAssertEqualStringArray(UNITY_INTERNAL_PTR expected, act = actual[j]; if (flags == UNITY_ARRAY_TO_ARRAY) { - exp = ((const char* const*)expected)[j]; + expd = ((const char* const*)expected)[j]; } /* if both pointers not null compare the strings */ - if (exp && act) + if (expd && act) { - for (i = 0; exp[i] || act[i]; i++) + for (i = 0; expd[i] || act[i]; i++) { - if (exp[i] != act[i]) + if (expd[i] != act[i]) { Unity.CurrentTestFailed = 1; break; @@ -1121,7 +1121,7 @@ void UnityAssertEqualStringArray(UNITY_INTERNAL_PTR expected, } else { /* handle case of one pointers being null (if both null, test should pass) */ - if (exp != act) + if (expd != act) { Unity.CurrentTestFailed = 1; } @@ -1135,7 +1135,7 @@ void UnityAssertEqualStringArray(UNITY_INTERNAL_PTR expected, UnityPrint(UnityStrElement); UnityPrintNumberUnsigned(j); } - UnityPrintExpectedAndActualStrings(exp, act); + UnityPrintExpectedAndActualStrings(expd, act); UnityAddMsgIfSpecified(msg); UNITY_FAIL_AND_BAIL; } From f278c18fd910146bc40281dad77f611b682f9bfd Mon Sep 17 00:00:00 2001 From: Mark VanderVoord Date: Mon, 11 Sep 2017 15:39:17 -0400 Subject: [PATCH 014/454] Fix bug #288 - invalid line numbers on partial name matches --- auto/generate_test_runner.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/auto/generate_test_runner.rb b/auto/generate_test_runner.rb index 2c5e56a9..07bde814 100644 --- a/auto/generate_test_runner.rb +++ b/auto/generate_test_runner.rb @@ -119,7 +119,7 @@ def find_tests(source) source_index = 0 tests_and_line_numbers.size.times do |i| source_lines[source_index..-1].each_with_index do |line, index| - next unless line =~ /#{tests_and_line_numbers[i][:test]}/ + next unless line =~ /\s+#{tests_and_line_numbers[i][:test]}(?:\s|\()/ source_index += index tests_and_line_numbers[i][:line_number] = source_index + 1 break From 60b13f0685246b009810aecbffafe17fb665d970 Mon Sep 17 00:00:00 2001 From: Mark VanderVoord Date: Mon, 11 Sep 2017 15:43:17 -0400 Subject: [PATCH 015/454] Bump version in preparation of release. --- release/build.info | 2 +- release/version.info | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/release/build.info b/release/build.info index 207634b2..50fb6eaf 100644 --- a/release/build.info +++ b/release/build.info @@ -1,2 +1,2 @@ -120 +121 diff --git a/release/version.info b/release/version.info index 3b904b68..b674b923 100644 --- a/release/version.info +++ b/release/version.info @@ -1,2 +1,2 @@ -2.4.1 +2.4.2 From 60def109a7cfa90aafee6758e7a61c199b83ac4f Mon Sep 17 00:00:00 2001 From: Mark VanderVoord Date: Wed, 13 Sep 2017 09:39:52 -0400 Subject: [PATCH 016/454] Update configuration docs --- docs/UnityConfigurationGuide.md | 116 ++++++++++++++++++++------------ 1 file changed, 73 insertions(+), 43 deletions(-) diff --git a/docs/UnityConfigurationGuide.md b/docs/UnityConfigurationGuide.md index 283d7799..49202eb2 100644 --- a/docs/UnityConfigurationGuide.md +++ b/docs/UnityConfigurationGuide.md @@ -79,18 +79,7 @@ _Example:_ #define UNITY_EXCLUDE_LIMITS_H -##### `UNITY_EXCLUDE_SIZEOF` - -The third and final attempt to guess your types is to use the `sizeof()` -operator. Even if the first two options don't work, this one covers most cases. -There _is_ a rare compiler or two out there that doesn't support sizeof() in the -preprocessing stage, though. For these, you have the ability to disable this -feature as well. - -_Example:_ - #define UNITY_EXCLUDE_SIZEOF - -If you've disabled all of the automatic options above, you're going to have to +If you've disabled both of the automatic options above, you're going to have to do the configuration yourself. Don't worry. Even this isn't too bad... there are just a handful of defines that you are going to specify if you don't like the defaults. @@ -127,7 +116,7 @@ _Example:_ #define UNITY_POINTER_WIDTH 64 -##### `UNITY_INCLUDE_64` +##### `UNITY_SUPPORT_64` Unity will automatically include 64-bit support if it auto-detects it, or if your `int`, `long`, or pointer widths are greater than 32-bits. Define this to @@ -136,7 +125,7 @@ can be a significant size and speed impact to enabling 64-bit support on small targets, so don't define it if you don't need it. _Example:_ - #define UNITY_INCLUDE_64 + #define UNITY_SUPPORT_64 ### Floating Point Types @@ -170,24 +159,20 @@ _Example:_ #define UNITY_INCLUDE_DOUBLE -##### `UNITY_FLOAT_VERBOSE` - -##### `UNITY_DOUBLE_VERBOSE` +##### `UNITY_EXCLUDE_FLOAT_PRINT` Unity aims for as small of a footprint as possible and avoids most standard -library calls (some embedded platforms don't have a standard library!). Because +library calls (some embedded platforms don’t have a standard library!). Because of this, its routines for printing integer values are minimalist and hand-coded. -To keep Unity universal, though, we chose to _not_ develop our own floating -point print routines. Instead, the display of floating point values during a -failure are optional. By default, Unity will not print the actual results of -floating point assertion failure. So a failed assertion will produce a message -like `"Values Not Within Delta"`. If you would like verbose failure messages for -floating point assertions, use these options to give more explicit failure -messages (e.g. `"Expected 4.56 Was 4.68"`). Note that this feature requires the -use of `sprintf` so might not be desirable in all cases. +Therefore, the display of floating point values during a failure are optional. +By default, Unity will print the actual results of floating point assertion +failure (e.g. ”Expected 4.56 Was 4.68”). To not include this extra support, you +can use this define to instead respond to a failed assertion with a message like +”Values Not Within Delta”. If you would like verbose failure messages for floating +point assertions, use these options to give more explicit failure messages. _Example:_ - #define UNITY_DOUBLE_VERBOSE + #define UNITY_EXCLUDE_FLOAT_PRINT ##### `UNITY_FLOAT_TYPE` @@ -277,25 +262,32 @@ will declare an instance of your function by default. If you want to disable this behavior, add `UNITY_OMIT_OUTPUT_FLUSH_HEADER_DECLARATION`. -##### `UNITY_SUPPORT_WEAK` +##### `UNITY_WEAK_ATTRIBUTE` + +##### `UNITY_WEAK_PRAGMA` + +##### `UNITY_NO_WEAK` -For some targets, Unity can make the otherwise required `setUp()` and -`tearDown()` functions optional. This is a nice convenience for test writers -since `setUp` and `tearDown` don't often actually _do_ anything. If you're using -gcc or clang, this option is automatically defined for you. Other compilers can -also support this behavior, if they support a C feature called weak functions. A -weak function is a function that is compiled into your executable _unless_ a -non-weak version of the same function is defined elsewhere. If a non-weak -version is found, the weak version is ignored as if it never existed. If your -compiler supports this feature, you can let Unity know by defining -`UNITY_SUPPORT_WEAK` as the function attributes that would need to be applied to -identify a function as weak. If your compiler lacks support for weak functions, -you will always need to define `setUp` and `tearDown` functions (though they can -be and often will be just empty). The most common options for this feature are: +For some targets, Unity can make the otherwise required setUp() and tearDown() +functions optional. This is a nice convenience for test writers since setUp and +tearDown don’t often actually do anything. If you’re using gcc or clang, this +option is automatically defined for you. Other compilers can also support this +behavior, if they support a C feature called weak functions. A weak function is +a function that is compiled into your executable unless a non-weak version of +the same function is defined elsewhere. If a non-weak version is found, the weak +version is ignored as if it never existed. If your compiler supports this feature, +you can let Unity know by defining UNITY_WEAK_ATTRIBUTE or UNITY_WEAK_PRAGMA as +the function attributes that would need to be applied to identify a function as +weak. If your compiler lacks support for weak functions, you will always need to +define setUp and tearDown functions (though they can be and often will be just +empty). You can also force Unity to NOT use weak functions by defining +UNITY_NO_WEAK. The most common options for this feature are: _Example:_ - #define UNITY_SUPPORT_WEAK weak - #define UNITY_SUPPORT_WEAK __attribute__((weak)) + #define UNITY_WEAK_ATTRIBUTE weak + #define UNITY_WEAK_ATTRIBUTE __attribute__((weak)) + #define UNITY_WEAK_PRAGMA + #define UNITY_NO_WEAK ##### `UNITY_PTR_ATTRIBUTE` @@ -309,6 +301,44 @@ _Example:_ #define UNITY_PTR_ATTRIBUTE near +##### `UNITY_PRINT_EOL` + +By default, Unity outputs \n at the end of each line of output. This is easy +to parse by the scripts, by Ceedling, etc, but it might not be ideal for YOUR +system. Feel free to override this and to make it whatever you wish. + +_Example:_ + #define UNITY_PRINT_EOL { UNITY_OUTPUT_CHAR('\r'); UNITY_OUTPUT_CHAR('\n') } + + + +##### `UNITY_EXCLUDE_DETAILS` + +This is an option for if you absolutely must squeeze every byte of memory out of +your system. Unity stores a set of internal scratchpads which are used to pass +extra detail information around. It's used by systems like CMock in order to +report which function or argument flagged an error. If you're not using CMock and +you're not using these details for other things, then you can exclude them. + +_Example:_ + #define UNITY_EXCLUDE_DETAILS + + + +##### `UNITY_EXCLUDE_SETJMP` + +If your embedded system doesn't support the standard library setjmp, you can +exclude Unity's reliance on this by using this define. This dropped dependence +comes at a price, though. You will be unable to use custom helper functions for +your tests, and you will be unable to use tools like CMock. Very likely, if your +compiler doesn't support setjmp, you wouldn't have had the memory space for those +things anyway, though... so this option exists for those situations. + +_Example:_ + #define UNITY_EXCLUDE_SETJMP + + + ## Getting Into The Guts There will be cases where the options above aren't quite going to get everything From 2593c31bb7e69219deaffd360d90def3711bce8f Mon Sep 17 00:00:00 2001 From: John Lindgren Date: Wed, 13 Sep 2017 17:59:52 -0400 Subject: [PATCH 017/454] Allow suiteSetUp() and suiteTearDown() to be provided as normal C functions. This is simpler and more flexible than embedding C code in the Ruby options (:suite_setup and :suite_teardown). However, support for :suite_setup and :suite_teardown is kept for backwards compatibility. Several configurations are possible: 1. :suite_setup and :suite_teardown options provided and used. 2. :suite_setup and :suite_teardown options not provided (nil): 2a. Weak symbols not supported; suiteSetUp() and suiteTearDown() are not called. It would be simpler to make user-provided functions mandatory in this case, but it could break some pre-existing test suites. 2b. Weak symbols are supported and the stub implementations of suiteSetUp() and suiteTearDown() are called if there are no user-provided functions. 2c. Weak symbols are supported but overridden by user-provided suiteSetUp() and suiteTearDown() functions. --- auto/generate_test_runner.rb | 30 ++++++++++++++++++++++-------- src/unity.c | 6 ++++++ src/unity.h | 11 +++++++++++ 3 files changed, 39 insertions(+), 8 deletions(-) diff --git a/auto/generate_test_runner.rb b/auto/generate_test_runner.rb index 07bde814..edb79894 100644 --- a/auto/generate_test_runner.rb +++ b/auto/generate_test_runner.rb @@ -235,22 +235,36 @@ def create_mock_management(output, mock_headers) end def create_suite_setup(output) - return if @options[:suite_setup].nil? - output.puts("\n/*=======Suite Setup=====*/") output.puts('static void suite_setup(void)') output.puts('{') - output.puts(@options[:suite_setup]) + if @options[:suite_setup].nil? + # New style, call suiteSetUp() if we can use weak symbols + output.puts('#if defined(UNITY_WEAK_ATTRIBUTE) || defined(UNITY_WEAK_PRAGMA)') + output.puts(' suiteSetUp();') + output.puts('#endif') + else + # Old style, C code embedded in the :suite_setup option + output.puts(@options[:suite_setup]) + end output.puts('}') end def create_suite_teardown(output) - return if @options[:suite_teardown].nil? - output.puts("\n/*=======Suite Teardown=====*/") output.puts('static int suite_teardown(int num_failures)') output.puts('{') - output.puts(@options[:suite_teardown]) + if @options[:suite_teardown].nil? + # New style, call suiteTearDown() if we can use weak symbols + output.puts('#if defined(UNITY_WEAK_ATTRIBUTE) || defined(UNITY_WEAK_PRAGMA)') + output.puts(' return suiteTearDown(num_failures);') + output.puts('#else') + output.puts(' return num_failures;') + output.puts('#endif') + else + # Old style, C code embedded in the :suite_teardown option + output.puts(@options[:suite_teardown]) + end output.puts('}') end @@ -342,7 +356,7 @@ def create_main(output, filename, tests, used_mocks) output.puts("int #{main_name}(void)") output.puts('{') end - output.puts(' suite_setup();') unless @options[:suite_setup].nil? + output.puts(' suite_setup();') output.puts(" UnityBegin(\"#{filename.gsub(/\\/, '\\\\\\')}\");") if @options[:use_param_tests] tests.each do |test| @@ -357,7 +371,7 @@ def create_main(output, filename, tests, used_mocks) end output.puts output.puts(' CMock_Guts_MemFreeFinal();') unless used_mocks.empty? - output.puts(" return #{@options[:suite_teardown].nil? ? '' : 'suite_teardown'}(UnityEnd());") + output.puts(" return suite_teardown(UnityEnd());") output.puts('}') end diff --git a/src/unity.c b/src/unity.c index 9783efac..08ecf63a 100644 --- a/src/unity.c +++ b/src/unity.c @@ -1314,11 +1314,17 @@ void UnityIgnore(const char* msg, const UNITY_LINE_TYPE line) #if defined(UNITY_WEAK_ATTRIBUTE) UNITY_WEAK_ATTRIBUTE void setUp(void) { } UNITY_WEAK_ATTRIBUTE void tearDown(void) { } + UNITY_WEAK_ATTRIBUTE void suiteSetUp(void) { } + UNITY_WEAK_ATTRIBUTE int suiteTearDown(int num_failures) { return num_failures; } #elif defined(UNITY_WEAK_PRAGMA) #pragma weak setUp void setUp(void) { } #pragma weak tearDown void tearDown(void) { } + #pragma weak suiteSetUp + void suiteSetUp(void) { } + #pragma weak suiteTearDown + int suiteTearDown(int num_failures) { return num_failures; } #endif /*-----------------------------------------------*/ diff --git a/src/unity.h b/src/unity.h index 258e21c9..1fa8b945 100644 --- a/src/unity.h +++ b/src/unity.h @@ -15,9 +15,20 @@ extern "C" #include "unity_internals.h" +/* These functions are intended to be called before and after each test. Unity + * provides stub implementations annotated as weak symbols (if supported by the + * compiler). */ void setUp(void); void tearDown(void); +/* These functions are intended to be called at the beginning and end of an + * entire test suite. suiteTearDown() is passed the number of tests that + * failed, and its return value becomes the exit code of main(). Unity + * provides stub implementations annotated as weak symbols (if supported by the + * compiler). */ +void suiteSetUp(void); +int suiteTearDown(int num_failures); + /*------------------------------------------------------- * Configuration Options *------------------------------------------------------- From 1381a1a4cbf1f48ed582466d00fab3b14e8e8abd Mon Sep 17 00:00:00 2001 From: John Lindgren Date: Wed, 13 Sep 2017 18:24:07 -0400 Subject: [PATCH 018/454] Update documentation. --- docs/UnityHelperScriptsGuide.md | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/docs/UnityHelperScriptsGuide.md b/docs/UnityHelperScriptsGuide.md index 3a930096..42429900 100644 --- a/docs/UnityHelperScriptsGuide.md +++ b/docs/UnityHelperScriptsGuide.md @@ -124,7 +124,7 @@ demonstrates using a Ruby hash. ##### `:includes` -This option specifies an array of file names to be ?#include?'d at the top of +This option specifies an array of file names to be `#include`'d at the top of your runner C file. You might use it to reference custom types or anything else universally needed in your generated runners. @@ -133,11 +133,23 @@ universally needed in your generated runners. Define this option with C code to be executed _before any_ test cases are run. +Alternatively, if your C compiler supports weak symbols, you can leave this +option unset and instead provide a `void suiteSetUp(void)` function in your test +suite. The linker will look for this symbol and fall back to a Unity-provided +stub if it is not found. + ##### `:suite_teardown` -Define this option with C code to be executed ?after all?test cases have -finished. +Define this option with C code to be executed _after all_ test cases have +finished. An integer variable `num_failures` is available for diagnostics. +The code should end with a `return` statement; the value returned will become +the exit code of `main`. You can normally just return `num_failures`. + +Alternatively, if your C compiler supports weak symbols, you can leave this +option unset and instead provide a `int suiteTearDown(int num_failures)` +function in your test suite. The linker will look for this symbol and fall +back to a Unity-provided stub if it is not found. ##### `:enforce_strict_ordering` From 8caade7e6857504edf41abc9317c934e5c9b5d0f Mon Sep 17 00:00:00 2001 From: jsalling Date: Wed, 20 Sep 2017 18:13:12 -0500 Subject: [PATCH 019/454] Fix bug in greater/less than asserts on unsigned int Check for unsigned types, add 'or equal to' support Consolidate to one function to remove repeated code --- src/unity.c | 50 +++++++++++++--------------- src/unity_internals.h | 76 +++++++++++++++++++++---------------------- 2 files changed, 61 insertions(+), 65 deletions(-) diff --git a/src/unity.c b/src/unity.c index 9783efac..216e005d 100644 --- a/src/unity.c +++ b/src/unity.c @@ -29,6 +29,7 @@ static const char UnityStrExpected[] = " Expected "; static const char UnityStrWas[] = " Was "; static const char UnityStrGt[] = " to be greater than "; static const char UnityStrLt[] = " to be less than "; +static const char UnityStrOrEqual[] = "or equal to "; static const char UnityStrElement[] = " Element "; static const char UnityStrByte[] = " Byte "; static const char UnityStrMemory[] = " Memory Mismatch."; @@ -531,49 +532,44 @@ void UnityAssertEqualNumber(const UNITY_INT expected, } /*-----------------------------------------------*/ -void UnityAssertGreaterNumber(const UNITY_INT threshold, - const UNITY_INT actual, - const char *msg, - const UNITY_LINE_TYPE lineNumber, - const UNITY_DISPLAY_STYLE_T style) +void UnityAssertGreaterOrLessOrEqualNumber(const UNITY_INT threshold, + const UNITY_INT actual, + const UNITY_COMPARISON_T compare, + const char *msg, + const UNITY_LINE_TYPE lineNumber, + const UNITY_DISPLAY_STYLE_T style) { + int failed = 0; RETURN_IF_FAIL_OR_IGNORE; - if (!(actual > threshold)) + if (threshold == actual && compare & UNITY_EQUAL_TO) return; + if (threshold == actual) failed = 1; + + if ((style & UNITY_DISPLAY_RANGE_INT) == UNITY_DISPLAY_RANGE_INT) { - UnityTestResultsFailBegin(lineNumber); - UnityPrint(UnityStrExpected); - UnityPrintNumberByStyle(actual, style); - UnityPrint(UnityStrGt); - UnityPrintNumberByStyle(threshold, style); - UnityAddMsgIfSpecified(msg); - UNITY_FAIL_AND_BAIL; + if (actual > threshold && compare & UNITY_SMALLER_THAN) failed = 1; + if (actual < threshold && compare & UNITY_GREATER_THAN) failed = 1; + } + else /* UINT or HEX */ + { + if ((UNITY_UINT)actual > (UNITY_UINT)threshold && compare & UNITY_SMALLER_THAN) failed = 1; + if ((UNITY_UINT)actual < (UNITY_UINT)threshold && compare & UNITY_GREATER_THAN) failed = 1; } -} - -/*-----------------------------------------------*/ -void UnityAssertSmallerNumber(const UNITY_INT threshold, - const UNITY_INT actual, - const char *msg, - const UNITY_LINE_TYPE lineNumber, - const UNITY_DISPLAY_STYLE_T style) -{ - RETURN_IF_FAIL_OR_IGNORE; - if (!(actual < threshold)) + if (failed) { UnityTestResultsFailBegin(lineNumber); UnityPrint(UnityStrExpected); UnityPrintNumberByStyle(actual, style); - UnityPrint(UnityStrLt); + if (compare & UNITY_GREATER_THAN) UnityPrint(UnityStrGt); + if (compare & UNITY_SMALLER_THAN) UnityPrint(UnityStrLt); + if (compare & UNITY_EQUAL_TO) UnityPrint(UnityStrOrEqual); UnityPrintNumberByStyle(threshold, style); UnityAddMsgIfSpecified(msg); UNITY_FAIL_AND_BAIL; } } - - #define UnityPrintPointlessAndBail() \ { \ UnityTestResultsFailBegin(lineNumber); \ diff --git a/src/unity_internals.h b/src/unity_internals.h index 1b57cd02..124b8c70 100644 --- a/src/unity_internals.h +++ b/src/unity_internals.h @@ -352,6 +352,15 @@ UNITY_DISPLAY_STYLE_UINT = sizeof(unsigned) + UNITY_DISPLAY_RANGE_UINT, UNITY_DISPLAY_STYLE_UNKNOWN } UNITY_DISPLAY_STYLE_T; +typedef enum +{ + UNITY_EQUAL_TO = 1, + UNITY_GREATER_THAN = 2, + UNITY_GREATER_OR_EQUAL = 2 + UNITY_EQUAL_TO, + UNITY_SMALLER_THAN = 4, + UNITY_SMALLER_OR_EQUAL = 4 + UNITY_EQUAL_TO +} UNITY_COMPARISON_T; + #ifndef UNITY_EXCLUDE_FLOAT typedef enum UNITY_FLOAT_TRAIT { @@ -455,17 +464,12 @@ void UnityAssertEqualNumber(const UNITY_INT expected, const UNITY_LINE_TYPE lineNumber, const UNITY_DISPLAY_STYLE_T style); -void UnityAssertGreaterNumber(const UNITY_INT threshold, - const UNITY_INT actual, - const char* msg, - const UNITY_LINE_TYPE lineNumber, - const UNITY_DISPLAY_STYLE_T style); - -void UnityAssertSmallerNumber(const UNITY_INT threshold, - const UNITY_INT actual, - const char* msg, - const UNITY_LINE_TYPE lineNumber, - const UNITY_DISPLAY_STYLE_T style); +void UnityAssertGreaterOrLessOrEqualNumber(const UNITY_INT threshold, + const UNITY_INT actual, + const UNITY_COMPARISON_T compare, + const char *msg, + const UNITY_LINE_TYPE lineNumber, + const UNITY_DISPLAY_STYLE_T style); void UnityAssertEqualIntArray(UNITY_INTERNAL_PTR expected, UNITY_INTERNAL_PTR actual, @@ -664,33 +668,29 @@ int UnityTestMatches(void); #define UNITY_TEST_ASSERT_EQUAL_HEX32(expected, actual, line, message) UnityAssertEqualNumber((UNITY_INT)(UNITY_INT32)(expected), (UNITY_INT)(UNITY_INT32)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX32) #define UNITY_TEST_ASSERT_BITS(mask, expected, actual, line, message) UnityAssertBits((UNITY_INT)(mask), (UNITY_INT)(expected), (UNITY_INT)(actual), (message), (UNITY_LINE_TYPE)(line)) - -#define UNITY_TEST_ASSERT_GREATER_THAN_INT(threshold, actual, line, message) UnityAssertGreaterNumber((UNITY_INT)(threshold), (UNITY_INT)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT) -#define UNITY_TEST_ASSERT_GREATER_THAN_INT8(threshold, actual, line, message) UnityAssertGreaterNumber((UNITY_INT)(UNITY_INT8 )(threshold), (UNITY_INT)(UNITY_INT8 )(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT8) -#define UNITY_TEST_ASSERT_GREATER_THAN_INT16(threshold, actual, line, message) UnityAssertGreaterNumber((UNITY_INT)(UNITY_INT16)(threshold), (UNITY_INT)(UNITY_INT16)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT16) -#define UNITY_TEST_ASSERT_GREATER_THAN_INT32(threshold, actual, line, message) UnityAssertGreaterNumber((UNITY_INT)(UNITY_INT32)(threshold), (UNITY_INT)(UNITY_INT32)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT32) -#define UNITY_TEST_ASSERT_GREATER_THAN_UINT(threshold, actual, line, message) UnityAssertGreaterNumber((UNITY_INT)(threshold), (UNITY_INT)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT) -#define UNITY_TEST_ASSERT_GREATER_THAN_UINT8(threshold, actual, line, message) UnityAssertGreaterNumber((UNITY_INT)(UNITY_UINT8 )(threshold), (UNITY_INT)(UNITY_UINT8 )(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT8) -#define UNITY_TEST_ASSERT_GREATER_THAN_UINT16(threshold, actual, line, message) UnityAssertGreaterNumber((UNITY_INT)(UNITY_UINT16)(threshold), (UNITY_INT)(UNITY_UINT16)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT16) -#define UNITY_TEST_ASSERT_GREATER_THAN_UINT32(threshold, actual, line, message) UnityAssertGreaterNumber((UNITY_INT)(UNITY_UINT32)(threshold), (UNITY_INT)(UNITY_UINT32)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT32) -#define UNITY_TEST_ASSERT_GREATER_THAN_HEX8(threshold, actual, line, message) UnityAssertGreaterNumber((UNITY_INT)(UNITY_UINT8 )(threshold), (UNITY_INT)(UNITY_UINT8 )(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX8) -#define UNITY_TEST_ASSERT_GREATER_THAN_HEX16(threshold, actual, line, message) UnityAssertGreaterNumber((UNITY_INT)(UNITY_UINT16)(threshold), (UNITY_INT)(UNITY_UINT16)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX16) -#define UNITY_TEST_ASSERT_GREATER_THAN_HEX32(threshold, actual, line, message) UnityAssertGreaterNumber((UNITY_INT)(UNITY_UINT32)(threshold), (UNITY_INT)(UNITY_UINT32)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX32) - - -#define UNITY_TEST_ASSERT_SMALLER_THAN_INT(threshold, actual, line, message) UnityAssertSmallerNumber((UNITY_INT)(threshold), (UNITY_INT)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT) -#define UNITY_TEST_ASSERT_SMALLER_THAN_INT8(threshold, actual, line, message) UnityAssertSmallerNumber((UNITY_INT)(UNITY_INT8 )(threshold), (UNITY_INT)(UNITY_INT8 )(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT8) -#define UNITY_TEST_ASSERT_SMALLER_THAN_INT16(threshold, actual, line, message) UnityAssertSmallerNumber((UNITY_INT)(UNITY_INT16)(threshold), (UNITY_INT)(UNITY_INT16)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT16) -#define UNITY_TEST_ASSERT_SMALLER_THAN_INT32(threshold, actual, line, message) UnityAssertSmallerNumber((UNITY_INT)(UNITY_INT32)(threshold), (UNITY_INT)(UNITY_INT32)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT32) -#define UNITY_TEST_ASSERT_SMALLER_THAN_UINT(threshold, actual, line, message) UnityAssertSmallerNumber((UNITY_INT)(threshold), (UNITY_INT)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT) -#define UNITY_TEST_ASSERT_SMALLER_THAN_UINT8(threshold, actual, line, message) UnityAssertSmallerNumber((UNITY_INT)(UNITY_UINT8 )(threshold), (UNITY_INT)(UNITY_UINT8 )(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT8) -#define UNITY_TEST_ASSERT_SMALLER_THAN_UINT16(threshold, actual, line, message) UnityAssertSmallerNumber((UNITY_INT)(UNITY_UINT16)(threshold), (UNITY_INT)(UNITY_UINT16)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT16) -#define UNITY_TEST_ASSERT_SMALLER_THAN_UINT32(threshold, actual, line, message) UnityAssertSmallerNumber((UNITY_INT)(UNITY_UINT32)(threshold), (UNITY_INT)(UNITY_UINT32)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT32) -#define UNITY_TEST_ASSERT_SMALLER_THAN_HEX8(threshold, actual, line, message) UnityAssertSmallerNumber((UNITY_INT)(UNITY_UINT8 )(threshold), (UNITY_INT)(UNITY_UINT8 )(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX8) -#define UNITY_TEST_ASSERT_SMALLER_THAN_HEX16(threshold, actual, line, message) UnityAssertSmallerNumber((UNITY_INT)(UNITY_UINT16)(threshold), (UNITY_INT)(UNITY_UINT16)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX16) -#define UNITY_TEST_ASSERT_SMALLER_THAN_HEX32(threshold, actual, line, message) UnityAssertSmallerNumber((UNITY_INT)(UNITY_UINT32)(threshold), (UNITY_INT)(UNITY_UINT32)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX32) - - +#define UNITY_TEST_ASSERT_GREATER_THAN_INT(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(threshold), (UNITY_INT)(actual), UNITY_GREATER_THAN, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT) +#define UNITY_TEST_ASSERT_GREATER_THAN_INT8(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_INT8 )(threshold), (UNITY_INT)(UNITY_INT8 )(actual), UNITY_GREATER_THAN, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT8) +#define UNITY_TEST_ASSERT_GREATER_THAN_INT16(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_INT16)(threshold), (UNITY_INT)(UNITY_INT16)(actual), UNITY_GREATER_THAN, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT16) +#define UNITY_TEST_ASSERT_GREATER_THAN_INT32(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_INT32)(threshold), (UNITY_INT)(UNITY_INT32)(actual), UNITY_GREATER_THAN, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT32) +#define UNITY_TEST_ASSERT_GREATER_THAN_UINT(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(threshold), (UNITY_INT)(actual), UNITY_GREATER_THAN, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT) +#define UNITY_TEST_ASSERT_GREATER_THAN_UINT8(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_UINT8 )(threshold), (UNITY_INT)(UNITY_UINT8 )(actual), UNITY_GREATER_THAN, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT8) +#define UNITY_TEST_ASSERT_GREATER_THAN_UINT16(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_UINT16)(threshold), (UNITY_INT)(UNITY_UINT16)(actual), UNITY_GREATER_THAN, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT16) +#define UNITY_TEST_ASSERT_GREATER_THAN_UINT32(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_UINT32)(threshold), (UNITY_INT)(UNITY_UINT32)(actual), UNITY_GREATER_THAN, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT32) +#define UNITY_TEST_ASSERT_GREATER_THAN_HEX8(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_UINT8 )(threshold), (UNITY_INT)(UNITY_UINT8 )(actual), UNITY_GREATER_THAN, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX8) +#define UNITY_TEST_ASSERT_GREATER_THAN_HEX16(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_UINT16)(threshold), (UNITY_INT)(UNITY_UINT16)(actual), UNITY_GREATER_THAN, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX16) +#define UNITY_TEST_ASSERT_GREATER_THAN_HEX32(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_UINT32)(threshold), (UNITY_INT)(UNITY_UINT32)(actual), UNITY_GREATER_THAN, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX32) + +#define UNITY_TEST_ASSERT_SMALLER_THAN_INT(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(threshold), (UNITY_INT)(actual), UNITY_SMALLER_THAN, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT) +#define UNITY_TEST_ASSERT_SMALLER_THAN_INT8(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_INT8 )(threshold), (UNITY_INT)(UNITY_INT8 )(actual), UNITY_SMALLER_THAN, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT8) +#define UNITY_TEST_ASSERT_SMALLER_THAN_INT16(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_INT16)(threshold), (UNITY_INT)(UNITY_INT16)(actual), UNITY_SMALLER_THAN, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT16) +#define UNITY_TEST_ASSERT_SMALLER_THAN_INT32(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_INT32)(threshold), (UNITY_INT)(UNITY_INT32)(actual), UNITY_SMALLER_THAN, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT32) +#define UNITY_TEST_ASSERT_SMALLER_THAN_UINT(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(threshold), (UNITY_INT)(actual), UNITY_SMALLER_THAN, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT) +#define UNITY_TEST_ASSERT_SMALLER_THAN_UINT8(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_UINT8 )(threshold), (UNITY_INT)(UNITY_UINT8 )(actual), UNITY_SMALLER_THAN, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT8) +#define UNITY_TEST_ASSERT_SMALLER_THAN_UINT16(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_UINT16)(threshold), (UNITY_INT)(UNITY_UINT16)(actual), UNITY_SMALLER_THAN, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT16) +#define UNITY_TEST_ASSERT_SMALLER_THAN_UINT32(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_UINT32)(threshold), (UNITY_INT)(UNITY_UINT32)(actual), UNITY_SMALLER_THAN, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT32) +#define UNITY_TEST_ASSERT_SMALLER_THAN_HEX8(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_UINT8 )(threshold), (UNITY_INT)(UNITY_UINT8 )(actual), UNITY_SMALLER_THAN, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX8) +#define UNITY_TEST_ASSERT_SMALLER_THAN_HEX16(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_UINT16)(threshold), (UNITY_INT)(UNITY_UINT16)(actual), UNITY_SMALLER_THAN, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX16) +#define UNITY_TEST_ASSERT_SMALLER_THAN_HEX32(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_UINT32)(threshold), (UNITY_INT)(UNITY_UINT32)(actual), UNITY_SMALLER_THAN, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX32) #define UNITY_TEST_ASSERT_INT_WITHIN(delta, expected, actual, line, message) UnityAssertNumbersWithin((delta), (UNITY_INT)(expected), (UNITY_INT)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT) #define UNITY_TEST_ASSERT_INT8_WITHIN(delta, expected, actual, line, message) UnityAssertNumbersWithin((UNITY_UINT8 )(delta), (UNITY_INT)(UNITY_INT8 )(expected), (UNITY_INT)(UNITY_INT8 )(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT8) From 91bcbe186d90b65147bcae0c19a26e365b4913e9 Mon Sep 17 00:00:00 2001 From: jsalling Date: Wed, 20 Sep 2017 18:24:23 -0500 Subject: [PATCH 020/454] Add 'greater/less or equal to' asserts on integers Make all comparison operators on integers available --- src/unity.h | 51 +++++++++++++++++++++++++++++++++++++++++++ src/unity_internals.h | 24 ++++++++++++++++++++ 2 files changed, 75 insertions(+) diff --git a/src/unity.h b/src/unity.h index 258e21c9..2d2e2d5b 100644 --- a/src/unity.h +++ b/src/unity.h @@ -143,6 +143,32 @@ void tearDown(void); #define TEST_ASSERT_LESS_THAN_HEX32(threshold, actual) UNITY_TEST_ASSERT_SMALLER_THAN_HEX32((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_GREATER_OR_EQUAL(threshold, actual) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_INT((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_GREATER_OR_EQUAL_INT(threshold, actual) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_INT((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_GREATER_OR_EQUAL_INT8(threshold, actual) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_INT8((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_GREATER_OR_EQUAL_INT16(threshold, actual) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_INT16((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_GREATER_OR_EQUAL_INT32(threshold, actual) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_INT32((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_GREATER_OR_EQUAL_UINT(threshold, actual) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_UINT((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_GREATER_OR_EQUAL_UINT8(threshold, actual) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_UINT8((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_GREATER_OR_EQUAL_UINT16(threshold, actual) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_UINT16((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_GREATER_OR_EQUAL_UINT32(threshold, actual) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_UINT32((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_GREATER_OR_EQUAL_HEX8(threshold, actual) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_HEX8((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_GREATER_OR_EQUAL_HEX16(threshold, actual) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_HEX16((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_GREATER_OR_EQUAL_HEX32(threshold, actual) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_HEX32((threshold), (actual), __LINE__, NULL) + +#define TEST_ASSERT_LESS_OR_EQUAL(threshold, actual) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_INT((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_LESS_OR_EQUAL_INT(threshold, actual) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_INT((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_LESS_OR_EQUAL_INT8(threshold, actual) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_INT8((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_LESS_OR_EQUAL_INT16(threshold, actual) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_INT16((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_LESS_OR_EQUAL_INT32(threshold, actual) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_INT32((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_LESS_OR_EQUAL_UINT(threshold, actual) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_UINT((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_LESS_OR_EQUAL_UINT8(threshold, actual) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_UINT8((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_LESS_OR_EQUAL_UINT16(threshold, actual) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_UINT16((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_LESS_OR_EQUAL_UINT32(threshold, actual) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_UINT32((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_LESS_OR_EQUAL_HEX8(threshold, actual) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_HEX8((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_LESS_OR_EQUAL_HEX16(threshold, actual) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_HEX16((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_LESS_OR_EQUAL_HEX32(threshold, actual) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_HEX32((threshold), (actual), __LINE__, NULL) + /* Integer Ranges (of all sizes) */ #define TEST_ASSERT_INT_WITHIN(delta, expected, actual) UNITY_TEST_ASSERT_INT_WITHIN((delta), (expected), (actual), __LINE__, NULL) #define TEST_ASSERT_INT8_WITHIN(delta, expected, actual) UNITY_TEST_ASSERT_INT8_WITHIN((delta), (expected), (actual), __LINE__, NULL) @@ -300,6 +326,31 @@ void tearDown(void); #define TEST_ASSERT_LESS_THAN_HEX16_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_THAN_HEX16((threshold), (actual), __LINE__, (message)) #define TEST_ASSERT_LESS_THAN_HEX32_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_THAN_HEX32((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_GREATER_OR_EQUAL_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_INT((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_GREATER_OR_EQUAL_INT_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_INT((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_GREATER_OR_EQUAL_INT8_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_INT8((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_GREATER_OR_EQUAL_INT16_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_INT16((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_GREATER_OR_EQUAL_INT32_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_INT32((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_GREATER_OR_EQUAL_UINT_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_UINT((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_GREATER_OR_EQUAL_UINT8_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_UINT8((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_GREATER_OR_EQUAL_UINT16_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_UINT16((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_GREATER_OR_EQUAL_UINT32_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_UINT32((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_GREATER_OR_EQUAL_HEX8_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_HEX8((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_GREATER_OR_EQUAL_HEX16_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_HEX16((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_GREATER_OR_EQUAL_HEX32_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_HEX32((threshold), (actual), __LINE__, (message)) + +#define TEST_ASSERT_LESS_OR_EQUAL_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_INT((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_LESS_OR_EQUAL_INT_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_INT((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_LESS_OR_EQUAL_INT8_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_INT8((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_LESS_OR_EQUAL_INT16_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_INT16((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_LESS_OR_EQUAL_INT32_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_INT32((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_LESS_OR_EQUAL_UINT_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_UINT((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_LESS_OR_EQUAL_UINT8_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_UINT8((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_LESS_OR_EQUAL_UINT16_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_UINT16((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_LESS_OR_EQUAL_UINT32_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_UINT32((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_LESS_OR_EQUAL_HEX8_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_HEX8((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_LESS_OR_EQUAL_HEX16_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_HEX16((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_LESS_OR_EQUAL_HEX32_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_THAN_HEX32((threshold), (actual), __LINE__, (message)) /* Integer Ranges (of all sizes) */ #define TEST_ASSERT_INT_WITHIN_MESSAGE(delta, expected, actual, message) UNITY_TEST_ASSERT_INT_WITHIN((delta), (expected), (actual), __LINE__, (message)) diff --git a/src/unity_internals.h b/src/unity_internals.h index 124b8c70..d3d43341 100644 --- a/src/unity_internals.h +++ b/src/unity_internals.h @@ -692,6 +692,30 @@ int UnityTestMatches(void); #define UNITY_TEST_ASSERT_SMALLER_THAN_HEX16(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_UINT16)(threshold), (UNITY_INT)(UNITY_UINT16)(actual), UNITY_SMALLER_THAN, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX16) #define UNITY_TEST_ASSERT_SMALLER_THAN_HEX32(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_UINT32)(threshold), (UNITY_INT)(UNITY_UINT32)(actual), UNITY_SMALLER_THAN, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX32) +#define UNITY_TEST_ASSERT_GREATER_OR_EQUAL_INT(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(threshold), (UNITY_INT)(actual), UNITY_GREATER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT) +#define UNITY_TEST_ASSERT_GREATER_OR_EQUAL_INT8(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_INT8 )(threshold), (UNITY_INT)(UNITY_INT8 )(actual), UNITY_GREATER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT8) +#define UNITY_TEST_ASSERT_GREATER_OR_EQUAL_INT16(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_INT16)(threshold), (UNITY_INT)(UNITY_INT16)(actual), UNITY_GREATER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT16) +#define UNITY_TEST_ASSERT_GREATER_OR_EQUAL_INT32(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_INT32)(threshold), (UNITY_INT)(UNITY_INT32)(actual), UNITY_GREATER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT32) +#define UNITY_TEST_ASSERT_GREATER_OR_EQUAL_UINT(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(threshold), (UNITY_INT)(actual), UNITY_GREATER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT) +#define UNITY_TEST_ASSERT_GREATER_OR_EQUAL_UINT8(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_UINT8 )(threshold), (UNITY_INT)(UNITY_UINT8 )(actual), UNITY_GREATER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT8) +#define UNITY_TEST_ASSERT_GREATER_OR_EQUAL_UINT16(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_UINT16)(threshold), (UNITY_INT)(UNITY_UINT16)(actual), UNITY_GREATER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT16) +#define UNITY_TEST_ASSERT_GREATER_OR_EQUAL_UINT32(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_UINT32)(threshold), (UNITY_INT)(UNITY_UINT32)(actual), UNITY_GREATER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT32) +#define UNITY_TEST_ASSERT_GREATER_OR_EQUAL_HEX8(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_UINT8 )(threshold), (UNITY_INT)(UNITY_UINT8 )(actual), UNITY_GREATER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX8) +#define UNITY_TEST_ASSERT_GREATER_OR_EQUAL_HEX16(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_UINT16)(threshold), (UNITY_INT)(UNITY_UINT16)(actual), UNITY_GREATER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX16) +#define UNITY_TEST_ASSERT_GREATER_OR_EQUAL_HEX32(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_UINT32)(threshold), (UNITY_INT)(UNITY_UINT32)(actual), UNITY_GREATER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX32) + +#define UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_INT(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(threshold), (UNITY_INT)(actual), UNITY_SMALLER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT) +#define UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_INT8(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_INT8 )(threshold), (UNITY_INT)(UNITY_INT8 )(actual), UNITY_SMALLER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT8) +#define UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_INT16(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_INT16)(threshold), (UNITY_INT)(UNITY_INT16)(actual), UNITY_SMALLER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT16) +#define UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_INT32(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_INT32)(threshold), (UNITY_INT)(UNITY_INT32)(actual), UNITY_SMALLER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT32) +#define UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_UINT(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(threshold), (UNITY_INT)(actual), UNITY_SMALLER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT) +#define UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_UINT8(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_UINT8 )(threshold), (UNITY_INT)(UNITY_UINT8 )(actual), UNITY_SMALLER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT8) +#define UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_UINT16(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_UINT16)(threshold), (UNITY_INT)(UNITY_UINT16)(actual), UNITY_SMALLER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT16) +#define UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_UINT32(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_UINT32)(threshold), (UNITY_INT)(UNITY_UINT32)(actual), UNITY_SMALLER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT32) +#define UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_HEX8(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_UINT8 )(threshold), (UNITY_INT)(UNITY_UINT8 )(actual), UNITY_SMALLER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX8) +#define UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_HEX16(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_UINT16)(threshold), (UNITY_INT)(UNITY_UINT16)(actual), UNITY_SMALLER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX16) +#define UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_HEX32(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_UINT32)(threshold), (UNITY_INT)(UNITY_UINT32)(actual), UNITY_SMALLER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX32) + #define UNITY_TEST_ASSERT_INT_WITHIN(delta, expected, actual, line, message) UnityAssertNumbersWithin((delta), (UNITY_INT)(expected), (UNITY_INT)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT) #define UNITY_TEST_ASSERT_INT8_WITHIN(delta, expected, actual, line, message) UnityAssertNumbersWithin((UNITY_UINT8 )(delta), (UNITY_INT)(UNITY_INT8 )(expected), (UNITY_INT)(UNITY_INT8 )(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT8) #define UNITY_TEST_ASSERT_INT16_WITHIN(delta, expected, actual, line, message) UnityAssertNumbersWithin((UNITY_UINT16)(delta), (UNITY_INT)(UNITY_INT16)(expected), (UNITY_INT)(UNITY_INT16)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT16) From b119919c4f82307c1ac9e9d49f95c08b2561628f Mon Sep 17 00:00:00 2001 From: jsalling Date: Wed, 20 Sep 2017 18:26:17 -0500 Subject: [PATCH 021/454] Add 64-bit comparison asserts --- src/unity.h | 29 ++++++++++++++++++++++++----- src/unity_internals.h | 24 ++++++++++++++++++++++++ 2 files changed, 48 insertions(+), 5 deletions(-) diff --git a/src/unity.h b/src/unity.h index 2d2e2d5b..0add3f53 100644 --- a/src/unity.h +++ b/src/unity.h @@ -120,54 +120,64 @@ void tearDown(void); #define TEST_ASSERT_GREATER_THAN_INT8(threshold, actual) UNITY_TEST_ASSERT_GREATER_THAN_INT8((threshold), (actual), __LINE__, NULL) #define TEST_ASSERT_GREATER_THAN_INT16(threshold, actual) UNITY_TEST_ASSERT_GREATER_THAN_INT16((threshold), (actual), __LINE__, NULL) #define TEST_ASSERT_GREATER_THAN_INT32(threshold, actual) UNITY_TEST_ASSERT_GREATER_THAN_INT32((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_GREATER_THAN_INT64(threshold, actual) UNITY_TEST_ASSERT_GREATER_THAN_INT64((threshold), (actual), __LINE__, NULL) #define TEST_ASSERT_GREATER_THAN_UINT(threshold, actual) UNITY_TEST_ASSERT_GREATER_THAN_UINT((threshold), (actual), __LINE__, NULL) #define TEST_ASSERT_GREATER_THAN_UINT8(threshold, actual) UNITY_TEST_ASSERT_GREATER_THAN_UINT8((threshold), (actual), __LINE__, NULL) #define TEST_ASSERT_GREATER_THAN_UINT16(threshold, actual) UNITY_TEST_ASSERT_GREATER_THAN_UINT16((threshold), (actual), __LINE__, NULL) #define TEST_ASSERT_GREATER_THAN_UINT32(threshold, actual) UNITY_TEST_ASSERT_GREATER_THAN_UINT32((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_GREATER_THAN_UINT64(threshold, actual) UNITY_TEST_ASSERT_GREATER_THAN_UINT64((threshold), (actual), __LINE__, NULL) #define TEST_ASSERT_GREATER_THAN_HEX8(threshold, actual) UNITY_TEST_ASSERT_GREATER_THAN_HEX8((threshold), (actual), __LINE__, NULL) #define TEST_ASSERT_GREATER_THAN_HEX16(threshold, actual) UNITY_TEST_ASSERT_GREATER_THAN_HEX16((threshold), (actual), __LINE__, NULL) #define TEST_ASSERT_GREATER_THAN_HEX32(threshold, actual) UNITY_TEST_ASSERT_GREATER_THAN_HEX32((threshold), (actual), __LINE__, NULL) - +#define TEST_ASSERT_GREATER_THAN_HEX64(threshold, actual) UNITY_TEST_ASSERT_GREATER_THAN_HEX64((threshold), (actual), __LINE__, NULL) #define TEST_ASSERT_LESS_THAN(threshold, actual) UNITY_TEST_ASSERT_SMALLER_THAN_INT((threshold), (actual), __LINE__, NULL) #define TEST_ASSERT_LESS_THAN_INT(threshold, actual) UNITY_TEST_ASSERT_SMALLER_THAN_INT((threshold), (actual), __LINE__, NULL) #define TEST_ASSERT_LESS_THAN_INT8(threshold, actual) UNITY_TEST_ASSERT_SMALLER_THAN_INT8((threshold), (actual), __LINE__, NULL) #define TEST_ASSERT_LESS_THAN_INT16(threshold, actual) UNITY_TEST_ASSERT_SMALLER_THAN_INT16((threshold), (actual), __LINE__, NULL) #define TEST_ASSERT_LESS_THAN_INT32(threshold, actual) UNITY_TEST_ASSERT_SMALLER_THAN_INT32((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_LESS_THAN_INT64(threshold, actual) UNITY_TEST_ASSERT_SMALLER_THAN_INT64((threshold), (actual), __LINE__, NULL) #define TEST_ASSERT_LESS_THAN_UINT(threshold, actual) UNITY_TEST_ASSERT_SMALLER_THAN_UINT((threshold), (actual), __LINE__, NULL) #define TEST_ASSERT_LESS_THAN_UINT8(threshold, actual) UNITY_TEST_ASSERT_SMALLER_THAN_UINT8((threshold), (actual), __LINE__, NULL) #define TEST_ASSERT_LESS_THAN_UINT16(threshold, actual) UNITY_TEST_ASSERT_SMALLER_THAN_UINT16((threshold), (actual), __LINE__, NULL) #define TEST_ASSERT_LESS_THAN_UINT32(threshold, actual) UNITY_TEST_ASSERT_SMALLER_THAN_UINT32((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_LESS_THAN_UINT64(threshold, actual) UNITY_TEST_ASSERT_SMALLER_THAN_UINT64((threshold), (actual), __LINE__, NULL) #define TEST_ASSERT_LESS_THAN_HEX8(threshold, actual) UNITY_TEST_ASSERT_SMALLER_THAN_HEX8((threshold), (actual), __LINE__, NULL) #define TEST_ASSERT_LESS_THAN_HEX16(threshold, actual) UNITY_TEST_ASSERT_SMALLER_THAN_HEX16((threshold), (actual), __LINE__, NULL) #define TEST_ASSERT_LESS_THAN_HEX32(threshold, actual) UNITY_TEST_ASSERT_SMALLER_THAN_HEX32((threshold), (actual), __LINE__, NULL) - +#define TEST_ASSERT_LESS_THAN_HEX64(threshold, actual) UNITY_TEST_ASSERT_SMALLER_THAN_HEX64((threshold), (actual), __LINE__, NULL) #define TEST_ASSERT_GREATER_OR_EQUAL(threshold, actual) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_INT((threshold), (actual), __LINE__, NULL) #define TEST_ASSERT_GREATER_OR_EQUAL_INT(threshold, actual) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_INT((threshold), (actual), __LINE__, NULL) #define TEST_ASSERT_GREATER_OR_EQUAL_INT8(threshold, actual) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_INT8((threshold), (actual), __LINE__, NULL) #define TEST_ASSERT_GREATER_OR_EQUAL_INT16(threshold, actual) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_INT16((threshold), (actual), __LINE__, NULL) #define TEST_ASSERT_GREATER_OR_EQUAL_INT32(threshold, actual) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_INT32((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_GREATER_OR_EQUAL_INT64(threshold, actual) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_INT64((threshold), (actual), __LINE__, NULL) #define TEST_ASSERT_GREATER_OR_EQUAL_UINT(threshold, actual) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_UINT((threshold), (actual), __LINE__, NULL) #define TEST_ASSERT_GREATER_OR_EQUAL_UINT8(threshold, actual) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_UINT8((threshold), (actual), __LINE__, NULL) #define TEST_ASSERT_GREATER_OR_EQUAL_UINT16(threshold, actual) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_UINT16((threshold), (actual), __LINE__, NULL) #define TEST_ASSERT_GREATER_OR_EQUAL_UINT32(threshold, actual) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_UINT32((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_GREATER_OR_EQUAL_UINT64(threshold, actual) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_UINT64((threshold), (actual), __LINE__, NULL) #define TEST_ASSERT_GREATER_OR_EQUAL_HEX8(threshold, actual) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_HEX8((threshold), (actual), __LINE__, NULL) #define TEST_ASSERT_GREATER_OR_EQUAL_HEX16(threshold, actual) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_HEX16((threshold), (actual), __LINE__, NULL) #define TEST_ASSERT_GREATER_OR_EQUAL_HEX32(threshold, actual) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_HEX32((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_GREATER_OR_EQUAL_HEX64(threshold, actual) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_HEX64((threshold), (actual), __LINE__, NULL) #define TEST_ASSERT_LESS_OR_EQUAL(threshold, actual) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_INT((threshold), (actual), __LINE__, NULL) #define TEST_ASSERT_LESS_OR_EQUAL_INT(threshold, actual) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_INT((threshold), (actual), __LINE__, NULL) #define TEST_ASSERT_LESS_OR_EQUAL_INT8(threshold, actual) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_INT8((threshold), (actual), __LINE__, NULL) #define TEST_ASSERT_LESS_OR_EQUAL_INT16(threshold, actual) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_INT16((threshold), (actual), __LINE__, NULL) #define TEST_ASSERT_LESS_OR_EQUAL_INT32(threshold, actual) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_INT32((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_LESS_OR_EQUAL_INT64(threshold, actual) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_INT64((threshold), (actual), __LINE__, NULL) #define TEST_ASSERT_LESS_OR_EQUAL_UINT(threshold, actual) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_UINT((threshold), (actual), __LINE__, NULL) #define TEST_ASSERT_LESS_OR_EQUAL_UINT8(threshold, actual) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_UINT8((threshold), (actual), __LINE__, NULL) #define TEST_ASSERT_LESS_OR_EQUAL_UINT16(threshold, actual) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_UINT16((threshold), (actual), __LINE__, NULL) #define TEST_ASSERT_LESS_OR_EQUAL_UINT32(threshold, actual) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_UINT32((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_LESS_OR_EQUAL_UINT64(threshold, actual) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_UINT64((threshold), (actual), __LINE__, NULL) #define TEST_ASSERT_LESS_OR_EQUAL_HEX8(threshold, actual) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_HEX8((threshold), (actual), __LINE__, NULL) #define TEST_ASSERT_LESS_OR_EQUAL_HEX16(threshold, actual) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_HEX16((threshold), (actual), __LINE__, NULL) #define TEST_ASSERT_LESS_OR_EQUAL_HEX32(threshold, actual) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_HEX32((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_LESS_OR_EQUAL_HEX64(threshold, actual) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_HEX64((threshold), (actual), __LINE__, NULL) /* Integer Ranges (of all sizes) */ #define TEST_ASSERT_INT_WITHIN(delta, expected, actual) UNITY_TEST_ASSERT_INT_WITHIN((delta), (expected), (actual), __LINE__, NULL) @@ -212,8 +222,6 @@ void tearDown(void); #define TEST_ASSERT_EQUAL_STRING_ARRAY(expected, actual, num_elements) UNITY_TEST_ASSERT_EQUAL_STRING_ARRAY((expected), (actual), (num_elements), __LINE__, NULL) #define TEST_ASSERT_EQUAL_MEMORY_ARRAY(expected, actual, len, num_elements) UNITY_TEST_ASSERT_EQUAL_MEMORY_ARRAY((expected), (actual), (len), (num_elements), __LINE__, NULL) - - /* Arrays Compared To Single Value */ #define TEST_ASSERT_EACH_EQUAL_INT(expected, actual, num_elements) UNITY_TEST_ASSERT_EACH_EQUAL_INT((expected), (actual), (num_elements), __LINE__, NULL) #define TEST_ASSERT_EACH_EQUAL_INT8(expected, actual, num_elements) UNITY_TEST_ASSERT_EACH_EQUAL_INT8((expected), (actual), (num_elements), __LINE__, NULL) @@ -304,53 +312,64 @@ void tearDown(void); #define TEST_ASSERT_GREATER_THAN_INT8_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_THAN_INT8((threshold), (actual), __LINE__, (message)) #define TEST_ASSERT_GREATER_THAN_INT16_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_THAN_INT16((threshold), (actual), __LINE__, (message)) #define TEST_ASSERT_GREATER_THAN_INT32_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_THAN_INT32((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_GREATER_THAN_INT64_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_THAN_INT64((threshold), (actual), __LINE__, (message)) #define TEST_ASSERT_GREATER_THAN_UINT_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_THAN_UINT((threshold), (actual), __LINE__, (message)) #define TEST_ASSERT_GREATER_THAN_UINT8_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_THAN_UINT8((threshold), (actual), __LINE__, (message)) #define TEST_ASSERT_GREATER_THAN_UINT16_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_THAN_UINT16((threshold), (actual), __LINE__, (message)) #define TEST_ASSERT_GREATER_THAN_UINT32_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_THAN_UINT32((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_GREATER_THAN_UINT64_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_THAN_UINT64((threshold), (actual), __LINE__, (message)) #define TEST_ASSERT_GREATER_THAN_HEX8_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_THAN_HEX8((threshold), (actual), __LINE__, (message)) #define TEST_ASSERT_GREATER_THAN_HEX16_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_THAN_HEX16((threshold), (actual), __LINE__, (message)) #define TEST_ASSERT_GREATER_THAN_HEX32_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_THAN_HEX32((threshold), (actual), __LINE__, (message)) - +#define TEST_ASSERT_GREATER_THAN_HEX64_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_THAN_HEX64((threshold), (actual), __LINE__, (message)) #define TEST_ASSERT_LESS_THAN_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_THAN_INT((threshold), (actual), __LINE__, (message)) #define TEST_ASSERT_LESS_THAN_INT_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_THAN_INT((threshold), (actual), __LINE__, (message)) #define TEST_ASSERT_LESS_THAN_INT8_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_THAN_INT8((threshold), (actual), __LINE__, (message)) #define TEST_ASSERT_LESS_THAN_INT16_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_THAN_INT16((threshold), (actual), __LINE__, (message)) #define TEST_ASSERT_LESS_THAN_INT32_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_THAN_INT32((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_LESS_THAN_INT64_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_THAN_INT64((threshold), (actual), __LINE__, (message)) #define TEST_ASSERT_LESS_THAN_UINT_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_THAN_UINT((threshold), (actual), __LINE__, (message)) #define TEST_ASSERT_LESS_THAN_UINT8_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_THAN_UINT8((threshold), (actual), __LINE__, (message)) #define TEST_ASSERT_LESS_THAN_UINT16_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_THAN_UINT16((threshold), (actual), __LINE__, (message)) #define TEST_ASSERT_LESS_THAN_UINT32_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_THAN_UINT32((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_LESS_THAN_UINT64_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_THAN_UINT64((threshold), (actual), __LINE__, (message)) #define TEST_ASSERT_LESS_THAN_HEX8_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_THAN_HEX8((threshold), (actual), __LINE__, (message)) #define TEST_ASSERT_LESS_THAN_HEX16_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_THAN_HEX16((threshold), (actual), __LINE__, (message)) #define TEST_ASSERT_LESS_THAN_HEX32_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_THAN_HEX32((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_LESS_THAN_HEX64_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_THAN_HEX64((threshold), (actual), __LINE__, (message)) #define TEST_ASSERT_GREATER_OR_EQUAL_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_INT((threshold), (actual), __LINE__, (message)) #define TEST_ASSERT_GREATER_OR_EQUAL_INT_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_INT((threshold), (actual), __LINE__, (message)) #define TEST_ASSERT_GREATER_OR_EQUAL_INT8_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_INT8((threshold), (actual), __LINE__, (message)) #define TEST_ASSERT_GREATER_OR_EQUAL_INT16_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_INT16((threshold), (actual), __LINE__, (message)) #define TEST_ASSERT_GREATER_OR_EQUAL_INT32_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_INT32((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_GREATER_OR_EQUAL_INT64_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_INT64((threshold), (actual), __LINE__, (message)) #define TEST_ASSERT_GREATER_OR_EQUAL_UINT_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_UINT((threshold), (actual), __LINE__, (message)) #define TEST_ASSERT_GREATER_OR_EQUAL_UINT8_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_UINT8((threshold), (actual), __LINE__, (message)) #define TEST_ASSERT_GREATER_OR_EQUAL_UINT16_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_UINT16((threshold), (actual), __LINE__, (message)) #define TEST_ASSERT_GREATER_OR_EQUAL_UINT32_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_UINT32((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_GREATER_OR_EQUAL_UINT64_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_UINT64((threshold), (actual), __LINE__, (message)) #define TEST_ASSERT_GREATER_OR_EQUAL_HEX8_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_HEX8((threshold), (actual), __LINE__, (message)) #define TEST_ASSERT_GREATER_OR_EQUAL_HEX16_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_HEX16((threshold), (actual), __LINE__, (message)) #define TEST_ASSERT_GREATER_OR_EQUAL_HEX32_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_HEX32((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_GREATER_OR_EQUAL_HEX64_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_HEX64((threshold), (actual), __LINE__, (message)) #define TEST_ASSERT_LESS_OR_EQUAL_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_INT((threshold), (actual), __LINE__, (message)) #define TEST_ASSERT_LESS_OR_EQUAL_INT_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_INT((threshold), (actual), __LINE__, (message)) #define TEST_ASSERT_LESS_OR_EQUAL_INT8_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_INT8((threshold), (actual), __LINE__, (message)) #define TEST_ASSERT_LESS_OR_EQUAL_INT16_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_INT16((threshold), (actual), __LINE__, (message)) #define TEST_ASSERT_LESS_OR_EQUAL_INT32_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_INT32((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_LESS_OR_EQUAL_INT64_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_INT64((threshold), (actual), __LINE__, (message)) #define TEST_ASSERT_LESS_OR_EQUAL_UINT_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_UINT((threshold), (actual), __LINE__, (message)) #define TEST_ASSERT_LESS_OR_EQUAL_UINT8_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_UINT8((threshold), (actual), __LINE__, (message)) #define TEST_ASSERT_LESS_OR_EQUAL_UINT16_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_UINT16((threshold), (actual), __LINE__, (message)) #define TEST_ASSERT_LESS_OR_EQUAL_UINT32_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_UINT32((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_LESS_OR_EQUAL_UINT64_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_UINT64((threshold), (actual), __LINE__, (message)) #define TEST_ASSERT_LESS_OR_EQUAL_HEX8_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_HEX8((threshold), (actual), __LINE__, (message)) #define TEST_ASSERT_LESS_OR_EQUAL_HEX16_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_HEX16((threshold), (actual), __LINE__, (message)) #define TEST_ASSERT_LESS_OR_EQUAL_HEX32_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_THAN_HEX32((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_LESS_OR_EQUAL_HEX64_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_THAN_HEX64((threshold), (actual), __LINE__, (message)) /* Integer Ranges (of all sizes) */ #define TEST_ASSERT_INT_WITHIN_MESSAGE(delta, expected, actual, message) UNITY_TEST_ASSERT_INT_WITHIN((delta), (expected), (actual), __LINE__, (message)) diff --git a/src/unity_internals.h b/src/unity_internals.h index d3d43341..283d8ea1 100644 --- a/src/unity_internals.h +++ b/src/unity_internals.h @@ -776,6 +776,18 @@ int UnityTestMatches(void); #define UNITY_TEST_ASSERT_INT64_WITHIN(delta, expected, actual, line, message) UnityAssertNumbersWithin((delta), (UNITY_INT)(expected), (UNITY_INT)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT64) #define UNITY_TEST_ASSERT_UINT64_WITHIN(delta, expected, actual, line, message) UnityAssertNumbersWithin((delta), (UNITY_INT)(expected), (UNITY_INT)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT64) #define UNITY_TEST_ASSERT_HEX64_WITHIN(delta, expected, actual, line, message) UnityAssertNumbersWithin((delta), (UNITY_INT)(expected), (UNITY_INT)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX64) +#define UNITY_TEST_ASSERT_GREATER_THAN_INT64(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(threshold), (UNITY_INT)(actual), UNITY_GREATER_THAN, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT64) +#define UNITY_TEST_ASSERT_GREATER_THAN_UINT64(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(threshold), (UNITY_INT)(actual), UNITY_GREATER_THAN, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT64) +#define UNITY_TEST_ASSERT_GREATER_THAN_HEX64(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(threshold), (UNITY_INT)(actual), UNITY_GREATER_THAN, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX64) +#define UNITY_TEST_ASSERT_GREATER_OR_EQUAL_INT64(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(threshold), (UNITY_INT)(actual), UNITY_GREATER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT64) +#define UNITY_TEST_ASSERT_GREATER_OR_EQUAL_UINT64(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(threshold), (UNITY_INT)(actual), UNITY_GREATER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT64) +#define UNITY_TEST_ASSERT_GREATER_OR_EQUAL_HEX64(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(threshold), (UNITY_INT)(actual), UNITY_GREATER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX64) +#define UNITY_TEST_ASSERT_SMALLER_THAN_INT64(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(threshold), (UNITY_INT)(actual), UNITY_SMALLER_THAN, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT64) +#define UNITY_TEST_ASSERT_SMALLER_THAN_UINT64(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(threshold), (UNITY_INT)(actual), UNITY_SMALLER_THAN, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT64) +#define UNITY_TEST_ASSERT_SMALLER_THAN_HEX64(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(threshold), (UNITY_INT)(actual), UNITY_SMALLER_THAN, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX64) +#define UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_INT64(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(threshold), (UNITY_INT)(actual), UNITY_SMALLER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT64) +#define UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_UINT64(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(threshold), (UNITY_INT)(actual), UNITY_SMALLER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT64) +#define UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_HEX64(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(threshold), (UNITY_INT)(actual), UNITY_SMALLER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX64) #else #define UNITY_TEST_ASSERT_EQUAL_INT64(expected, actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErr64) #define UNITY_TEST_ASSERT_EQUAL_UINT64(expected, actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErr64) @@ -786,6 +798,18 @@ int UnityTestMatches(void); #define UNITY_TEST_ASSERT_INT64_WITHIN(delta, expected, actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErr64) #define UNITY_TEST_ASSERT_UINT64_WITHIN(delta, expected, actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErr64) #define UNITY_TEST_ASSERT_HEX64_WITHIN(delta, expected, actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErr64) +#define UNITY_TEST_ASSERT_GREATER_THAN_INT64(threshold, actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErr64) +#define UNITY_TEST_ASSERT_GREATER_THAN_UINT64(threshold, actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErr64) +#define UNITY_TEST_ASSERT_GREATER_THAN_HEX64(threshold, actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErr64) +#define UNITY_TEST_ASSERT_GREATER_OR_EQUAL_INT64(threshold, actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErr64) +#define UNITY_TEST_ASSERT_GREATER_OR_EQUAL_UINT64(threshold, actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErr64) +#define UNITY_TEST_ASSERT_GREATER_OR_EQUAL_HEX64(threshold, actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErr64) +#define UNITY_TEST_ASSERT_SMALLER_THAN_INT64(threshold, actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErr64) +#define UNITY_TEST_ASSERT_SMALLER_THAN_UINT64(threshold, actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErr64) +#define UNITY_TEST_ASSERT_SMALLER_THAN_HEX64(threshold, actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErr64) +#define UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_INT64(threshold, actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErr64) +#define UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_UINT64(threshold, actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErr64) +#define UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_HEX64(threshold, actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErr64) #endif #ifdef UNITY_EXCLUDE_FLOAT From 94a3008a9dd04913d4d67e6f8ac806607f31e9d0 Mon Sep 17 00:00:00 2001 From: jsalling Date: Thu, 21 Sep 2017 21:24:41 -0500 Subject: [PATCH 022/454] Update continuous integration to build 32-bit Unity --- .travis.yml | 4 +++- test/Makefile | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 8ae9fa0c..bd165b1e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -18,7 +18,9 @@ install: script: - cd test && rake ci - make -s - - make -s DEBUG=-m32 + - make -s DEBUG=-m32 #32-bit architecture with 64-bit support + - make -s DEBUG=-m32 UNITY_SUPPORT_64= #32-bit build without 64-bit types + - make -s UNITY_INCLUDE_DOUBLE= # without double - cd ../extras/fixture/test && rake ci - make -s default noStdlibMalloc - make -s C89 diff --git a/test/Makefile b/test/Makefile index 9de7a49a..c2710f1f 100644 --- a/test/Makefile +++ b/test/Makefile @@ -15,7 +15,9 @@ CFLAGS += -Wbad-function-cast -Wcast-qual -Wold-style-definition -Wshadow -Wstri CFLAGS += $(DEBUG) DEFINES = -D UNITY_OUTPUT_CHAR=putcharSpy DEFINES += -D UNITY_OUTPUT_CHAR_HEADER_DECLARATION=putcharSpy\(int\) -DEFINES += -D UNITY_SUPPORT_64 -D UNITY_INCLUDE_DOUBLE +DEFINES += $(UNITY_SUPPORT_64) $(UNITY_INCLUDE_DOUBLE) +UNITY_SUPPORT_64 = -D UNITY_SUPPORT_64 +UNITY_INCLUDE_DOUBLE = -D UNITY_INCLUDE_DOUBLE SRC = ../src/unity.c tests/testunity.c build/testunityRunner.c INC_DIR = -I ../src COV_FLAGS = -fprofile-arcs -ftest-coverage -I ../../src From a7e8797e0cabd738cb4cfcc54ce4348b3522f2d1 Mon Sep 17 00:00:00 2001 From: John Lindgren Date: Mon, 9 Oct 2017 10:49:58 -0400 Subject: [PATCH 023/454] Fix link errors with MinGW. MinGW supports a limited form of weak symbols, with the restriction that weak/default implementations need to be defined in the same translation unit they are called from. Strong/overriding symbols may of course be specified in a different translation unit. --- auto/generate_test_runner.rb | 1 + src/unity.c | 18 +----------------- src/unity_setup.h | 33 +++++++++++++++++++++++++++++++++ 3 files changed, 35 insertions(+), 17 deletions(-) create mode 100644 src/unity_setup.h diff --git a/auto/generate_test_runner.rb b/auto/generate_test_runner.rb index edb79894..f436634f 100644 --- a/auto/generate_test_runner.rb +++ b/auto/generate_test_runner.rb @@ -158,6 +158,7 @@ def create_header(output, mocks, testfile_includes = []) create_runtest(output, mocks) output.puts("\n/*=======Automagically Detected Files To Include=====*/") output.puts("#include \"#{@options[:framework]}.h\"") + output.puts("#include \"#{@options[:framework]}_setup.h\"") output.puts('#include "cmock.h"') unless mocks.empty? output.puts('#include ') output.puts('#include ') diff --git a/src/unity.c b/src/unity.c index 08ecf63a..739358f2 100644 --- a/src/unity.c +++ b/src/unity.c @@ -5,6 +5,7 @@ ============================================================================ */ #include "unity.h" +#include "unity_setup.h" #include /* If omitted from header, declare overrideable prototypes here so they're ready for use */ @@ -1310,23 +1311,6 @@ void UnityIgnore(const char* msg, const UNITY_LINE_TYPE line) UNITY_IGNORE_AND_BAIL; } -/*-----------------------------------------------*/ -#if defined(UNITY_WEAK_ATTRIBUTE) - UNITY_WEAK_ATTRIBUTE void setUp(void) { } - UNITY_WEAK_ATTRIBUTE void tearDown(void) { } - UNITY_WEAK_ATTRIBUTE void suiteSetUp(void) { } - UNITY_WEAK_ATTRIBUTE int suiteTearDown(int num_failures) { return num_failures; } -#elif defined(UNITY_WEAK_PRAGMA) - #pragma weak setUp - void setUp(void) { } - #pragma weak tearDown - void tearDown(void) { } - #pragma weak suiteSetUp - void suiteSetUp(void) { } - #pragma weak suiteTearDown - int suiteTearDown(int num_failures) { return num_failures; } -#endif - /*-----------------------------------------------*/ void UnityDefaultTestRun(UnityTestFunction Func, const char* FuncName, const int FuncLineNum) { diff --git a/src/unity_setup.h b/src/unity_setup.h new file mode 100644 index 00000000..4672b76c --- /dev/null +++ b/src/unity_setup.h @@ -0,0 +1,33 @@ +/* ========================================== + Unity Project - A Test Framework for C + Copyright (c) 2007-14 Mike Karlesky, Mark VanderVoord, Greg Williams + [Released under MIT License. Please refer to license.txt for details] +========================================== */ + +#ifndef UNITY_SETUP_H +#define UNITY_SETUP_H + +#include "unity_internals.h" + +/* On some platforms (MinGW for example), weak function implementations + * need to be in the same translation unit they are called from. This + * header can be included to provide implementations of setUp(), tearDown(), + * suiteSetUp(), and suiteTearDown(). */ + +#if defined(UNITY_WEAK_ATTRIBUTE) + UNITY_WEAK_ATTRIBUTE void setUp(void) { } + UNITY_WEAK_ATTRIBUTE void tearDown(void) { } + UNITY_WEAK_ATTRIBUTE void suiteSetUp(void) { } + UNITY_WEAK_ATTRIBUTE int suiteTearDown(int num_failures) { return num_failures; } +#elif defined(UNITY_WEAK_PRAGMA) + #pragma weak setUp + void setUp(void) { } + #pragma weak tearDown + void tearDown(void) { } + #pragma weak suiteSetUp + void suiteSetUp(void) { } + #pragma weak suiteTearDown + int suiteTearDown(int num_failures) { return num_failures; } +#endif + +#endif From df78aade4bdf78e34f35d6aedeb79e55411a9b62 Mon Sep 17 00:00:00 2001 From: John Lindgren Date: Mon, 9 Oct 2017 11:38:08 -0400 Subject: [PATCH 024/454] Make weak symbol usage more portable: - Enable support for Green Hills Software compiler - Define weak implementations only once except on Windows --- auto/generate_test_runner.rb | 2 ++ src/unity_internals.h | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/auto/generate_test_runner.rb b/auto/generate_test_runner.rb index f436634f..b049bca9 100644 --- a/auto/generate_test_runner.rb +++ b/auto/generate_test_runner.rb @@ -158,7 +158,9 @@ def create_header(output, mocks, testfile_includes = []) create_runtest(output, mocks) output.puts("\n/*=======Automagically Detected Files To Include=====*/") output.puts("#include \"#{@options[:framework]}.h\"") + output.puts('#ifdef __WIN32__') output.puts("#include \"#{@options[:framework]}_setup.h\"") + output.puts('#endif') output.puts('#include "cmock.h"') unless mocks.empty? output.puts('#include ') output.puts('#include ') diff --git a/src/unity_internals.h b/src/unity_internals.h index 1b57cd02..4761253a 100644 --- a/src/unity_internals.h +++ b/src/unity_internals.h @@ -301,7 +301,7 @@ extern void UNITY_OMIT_OUTPUT_FLUSH_HEADER_DECLARATION; * Language Features Available *-------------------------------------------------------*/ #if !defined(UNITY_WEAK_ATTRIBUTE) && !defined(UNITY_WEAK_PRAGMA) -# ifdef __GNUC__ /* includes clang */ +# if defined(__GNUC__) || defined(__ghs__) /* __GNUC__ includes clang */ # if !(defined(__WIN32__) && defined(__clang__)) && !defined(__TMS470__) # define UNITY_WEAK_ATTRIBUTE __attribute__((weak)) # endif From 17d4ea92e158eeb67f6fd7453814c54e342b794d Mon Sep 17 00:00:00 2001 From: Victor Lambret Date: Tue, 24 Oct 2017 07:25:29 +0200 Subject: [PATCH 025/454] Color test results using ANSI escape codes Help error detection by adding specific colors for test results. This behavior is activated only when unity if compiled with UNITY_COLOR flag. --- docs/UnityConfigurationGuide.md | 7 +++++++ src/unity.c | 19 +++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/docs/UnityConfigurationGuide.md b/docs/UnityConfigurationGuide.md index 49202eb2..96e5358d 100644 --- a/docs/UnityConfigurationGuide.md +++ b/docs/UnityConfigurationGuide.md @@ -337,6 +337,13 @@ things anyway, though... so this option exists for those situations. _Example:_ #define UNITY_EXCLUDE_SETJMP +##### `UNITY_OUTPUT_COLOR` + +If you want to add color using ANSI escape codes you can use this define. +t +_Example:_ + #define UNITY_OUTPUT_COLOR + ## Getting Into The Guts diff --git a/src/unity.c b/src/unity.c index 9783efac..da04be67 100644 --- a/src/unity.c +++ b/src/unity.c @@ -19,10 +19,17 @@ void UNITY_OUTPUT_CHAR(int); struct UNITY_STORAGE_T Unity; +#ifdef UNITY_OUTPUT_COLOR +static const char UnityStrOk[] = "\033[42mOK\033[00m"; +static const char UnityStrPass[] = "\033[42mPASS\033[00m"; +static const char UnityStrFail[] = "\033[41mFAIL\033[00m"; +static const char UnityStrIgnore[] = "\033[43mIGNORE\033[00m"; +#else static const char UnityStrOk[] = "OK"; static const char UnityStrPass[] = "PASS"; static const char UnityStrFail[] = "FAIL"; static const char UnityStrIgnore[] = "IGNORE"; +#endif static const char UnityStrNull[] = "NULL"; static const char UnityStrSpacer[] = ". "; static const char UnityStrExpected[] = " Expected "; @@ -83,6 +90,18 @@ void UnityPrint(const char* string) UNITY_OUTPUT_CHAR('\\'); UNITY_OUTPUT_CHAR('n'); } +#ifdef UNITY_OUTPUT_COLOR + /* print ANSI escape code */ + else if (*pch == 27 && *(pch + 1) == '[') + { + while (*pch && *pch != 'm') + { + UNITY_OUTPUT_CHAR(*pch); + pch++; + } + UNITY_OUTPUT_CHAR('m'); + } +#endif /* unprintable characters are shown as codes */ else { From 5ee55fefda8a7f89e32fdca9edc38beb9bf1933d Mon Sep 17 00:00:00 2001 From: Kate Hart Date: Mon, 30 Oct 2017 17:44:32 -0700 Subject: [PATCH 026/454] Fix missing TEST_ASSERT_EACH_EQUAL_HEX_MESSAGE --- src/unity.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/unity.h b/src/unity.h index 0add3f53..f650e168 100644 --- a/src/unity.h +++ b/src/unity.h @@ -425,7 +425,7 @@ void tearDown(void); #define TEST_ASSERT_EACH_EQUAL_UINT16_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EACH_EQUAL_UINT16((expected), (actual), (num_elements), __LINE__, (message)) #define TEST_ASSERT_EACH_EQUAL_UINT32_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EACH_EQUAL_UINT32((expected), (actual), (num_elements), __LINE__, (message)) #define TEST_ASSERT_EACH_EQUAL_UINT64_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EACH_EQUAL_UINT64((expected), (actual), (num_elements), __LINE__, (message)) -#define TEST_ASSERT_EACH_EQUAL_HEX32_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EACH_EQUAL_HEX32((expected), (actual), (num_elements), __LINE__, (message)) +#define TEST_ASSERT_EACH_EQUAL_HEX_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EACH_EQUAL_HEX32((expected), (actual), (num_elements), __LINE__, (message)) #define TEST_ASSERT_EACH_EQUAL_HEX8_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EACH_EQUAL_HEX8((expected), (actual), (num_elements), __LINE__, (message)) #define TEST_ASSERT_EACH_EQUAL_HEX16_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EACH_EQUAL_HEX16((expected), (actual), (num_elements), __LINE__, (message)) #define TEST_ASSERT_EACH_EQUAL_HEX32_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EACH_EQUAL_HEX32((expected), (actual), (num_elements), __LINE__, (message)) From 629b86d5412e3a6768987610c67172de0eff538d Mon Sep 17 00:00:00 2001 From: John Lindgren Date: Wed, 1 Nov 2017 11:36:26 -0400 Subject: [PATCH 027/454] Merge unity_setup.h into unity.h. --- auto/generate_test_runner.rb | 4 ++-- src/unity.c | 2 +- src/unity.h | 35 +++++++++++++++++++++++++++++------ src/unity_setup.h | 33 --------------------------------- 4 files changed, 32 insertions(+), 42 deletions(-) delete mode 100644 src/unity_setup.h diff --git a/auto/generate_test_runner.rb b/auto/generate_test_runner.rb index b049bca9..344a2d0f 100644 --- a/auto/generate_test_runner.rb +++ b/auto/generate_test_runner.rb @@ -157,10 +157,10 @@ def create_header(output, mocks, testfile_includes = []) output.puts('/* AUTOGENERATED FILE. DO NOT EDIT. */') create_runtest(output, mocks) output.puts("\n/*=======Automagically Detected Files To Include=====*/") - output.puts("#include \"#{@options[:framework]}.h\"") output.puts('#ifdef __WIN32__') - output.puts("#include \"#{@options[:framework]}_setup.h\"") + output.puts('#define UNITY_INCLUDE_SETUP_STUBS') output.puts('#endif') + output.puts("#include \"#{@options[:framework]}.h\"") output.puts('#include "cmock.h"') unless mocks.empty? output.puts('#include ') output.puts('#include ') diff --git a/src/unity.c b/src/unity.c index 739358f2..ab1e2fd4 100644 --- a/src/unity.c +++ b/src/unity.c @@ -4,8 +4,8 @@ [Released under MIT License. Please refer to license.txt for details] ============================================================================ */ +#define UNITY_INCLUDE_SETUP_STUBS #include "unity.h" -#include "unity_setup.h" #include /* If omitted from header, declare overrideable prototypes here so they're ready for use */ diff --git a/src/unity.h b/src/unity.h index 1fa8b945..d95f1c1f 100644 --- a/src/unity.h +++ b/src/unity.h @@ -15,20 +15,43 @@ extern "C" #include "unity_internals.h" -/* These functions are intended to be called before and after each test. Unity - * provides stub implementations annotated as weak symbols (if supported by the - * compiler). */ +/*------------------------------------------------------- + * Test Setup / Teardown + *-------------------------------------------------------*/ + +/* These functions are intended to be called before and after each test. */ void setUp(void); void tearDown(void); /* These functions are intended to be called at the beginning and end of an * entire test suite. suiteTearDown() is passed the number of tests that - * failed, and its return value becomes the exit code of main(). Unity - * provides stub implementations annotated as weak symbols (if supported by the - * compiler). */ + * failed, and its return value becomes the exit code of main(). */ void suiteSetUp(void); int suiteTearDown(int num_failures); +/* If the compiler supports it, the following block provides stub + * implementations of the above functions as weak symbols. Note that on + * some platforms (MinGW for example), weak function implementations need + * to be in the same translation unit they are called from. This can be + * achieved by defining UNITY_INCLUDE_SETUP_STUBS before including unity.h. */ +#ifdef UNITY_INCLUDE_SETUP_STUBS + #ifdef UNITY_WEAK_ATTRIBUTE + UNITY_WEAK_ATTRIBUTE void setUp(void) { } + UNITY_WEAK_ATTRIBUTE void tearDown(void) { } + UNITY_WEAK_ATTRIBUTE void suiteSetUp(void) { } + UNITY_WEAK_ATTRIBUTE int suiteTearDown(int num_failures) { return num_failures; } + #elif defined(UNITY_WEAK_PRAGMA) + #pragma weak setUp + void setUp(void) { } + #pragma weak tearDown + void tearDown(void) { } + #pragma weak suiteSetUp + void suiteSetUp(void) { } + #pragma weak suiteTearDown + int suiteTearDown(int num_failures) { return num_failures; } + #endif +#endif + /*------------------------------------------------------- * Configuration Options *------------------------------------------------------- diff --git a/src/unity_setup.h b/src/unity_setup.h deleted file mode 100644 index 4672b76c..00000000 --- a/src/unity_setup.h +++ /dev/null @@ -1,33 +0,0 @@ -/* ========================================== - Unity Project - A Test Framework for C - Copyright (c) 2007-14 Mike Karlesky, Mark VanderVoord, Greg Williams - [Released under MIT License. Please refer to license.txt for details] -========================================== */ - -#ifndef UNITY_SETUP_H -#define UNITY_SETUP_H - -#include "unity_internals.h" - -/* On some platforms (MinGW for example), weak function implementations - * need to be in the same translation unit they are called from. This - * header can be included to provide implementations of setUp(), tearDown(), - * suiteSetUp(), and suiteTearDown(). */ - -#if defined(UNITY_WEAK_ATTRIBUTE) - UNITY_WEAK_ATTRIBUTE void setUp(void) { } - UNITY_WEAK_ATTRIBUTE void tearDown(void) { } - UNITY_WEAK_ATTRIBUTE void suiteSetUp(void) { } - UNITY_WEAK_ATTRIBUTE int suiteTearDown(int num_failures) { return num_failures; } -#elif defined(UNITY_WEAK_PRAGMA) - #pragma weak setUp - void setUp(void) { } - #pragma weak tearDown - void tearDown(void) { } - #pragma weak suiteSetUp - void suiteSetUp(void) { } - #pragma weak suiteTearDown - int suiteTearDown(int num_failures) { return num_failures; } -#endif - -#endif From 8ff74d6000b352ea47ace8895e1bd66146e6086b Mon Sep 17 00:00:00 2001 From: John Lindgren Date: Thu, 14 Sep 2017 13:47:04 -0400 Subject: [PATCH 028/454] Allow UnityPrintFloat() to print a 7th digit. --- src/unity.c | 49 ++++++++++++----- test/tests/testunity.c | 120 +++++++++++++++++++++++------------------ 2 files changed, 105 insertions(+), 64 deletions(-) diff --git a/src/unity.c b/src/unity.c index 0f2d2dea..429ff065 100644 --- a/src/unity.c +++ b/src/unity.c @@ -258,11 +258,14 @@ void UnityPrintMask(const UNITY_UINT mask, const UNITY_UINT number) /*-----------------------------------------------*/ #ifndef UNITY_EXCLUDE_FLOAT_PRINT -/* This function prints a floating-point value in a format similar to - * printf("%.6g"). It can work with either single- or double-precision, - * but for simplicity, it prints only 6 significant digits in either case. - * Printing more than 6 digits accurately is hard (at least in the single- - * precision case) and isn't attempted here. */ +/* + * This function prints a floating-point value in a format similar to + * printf("%.7g"). It can work with either single- or double-precision, + * but for simplicity, it prints only 7 significant digits in either case. + * The 7th digit won't always be totally correct in single-precision + * operation (for that level of accuracy, a more complicated algorithm + * would be needed). + */ void UnityPrintFloat(const UNITY_DOUBLE input_number) { UNITY_DOUBLE number = input_number; @@ -285,22 +288,42 @@ void UnityPrintFloat(const UNITY_DOUBLE input_number) UNITY_INT32 n; char buf[16]; - /* scale up or down by powers of 10 */ - while (number < 100000.0f / 1e6f) { number *= 1e6f; exponent -= 6; } - while (number < 100000.0f) { number *= 10.0f; exponent--; } - while (number > 1000000.0f * 1e6f) { number /= 1e6f; exponent += 6; } - while (number > 1000000.0f) { number /= 10.0f; exponent++; } + /* + * Scale up or down by powers of 10. To minimize rounding error, + * start with a factor/divisor of 10^10, which is the largest + * power of 10 that can be represented exactly. Finally, compute + * (exactly) the remaining power of 10 and perform one more + * multiplication or division. + */ + if(number < 1e6f) + { + UNITY_DOUBLE factor = 1.0f; + + while(number < 1e7f / 1e10f) { number *= 1e10f; exponent -= 10; } + while(number * factor < 1e6f) { factor *= 10.0f; exponent--; } + + number *= factor; + } + else if(number > 1e7f) + { + UNITY_DOUBLE divisor = 1.0f; + + while(number > 1e6f * 1e10f) { number /= 1e10f; exponent += 10; } + while(number / divisor > 1e7f) { divisor *= 10.0f; exponent++; } + + number /= divisor; + } /* round to nearest integer */ n = ((UNITY_INT32)(number + number) + 1) / 2; - if (n > 999999) + if (n > 9999999) { - n = 100000; + n = 1000000; exponent++; } /* determine where to place decimal point */ - decimals = (exponent <= 0 && exponent >= -9) ? -exponent : 5; + decimals = (exponent <= 0 && exponent >= -10) ? -exponent : 6; exponent += decimals; /* truncate trailing zeroes after decimal point */ diff --git a/test/tests/testunity.c b/test/tests/testunity.c index af06647f..752c3b28 100644 --- a/test/tests/testunity.c +++ b/test/tests/testunity.c @@ -4466,46 +4466,48 @@ void testFloatPrinting(void) #if defined(UNITY_EXCLUDE_FLOAT_PRINT) || !defined(USING_OUTPUT_SPY) TEST_IGNORE(); #else + /* Some failures are expected due to differences in the last digit + * if UnityPrintFloat uses single-precision calculations. */ TEST_ASSERT_EQUAL_PRINT_FLOATING("0", 0.0f); TEST_ASSERT_EQUAL_PRINT_FLOATING("4.99e-07", 0.000000499f); - TEST_ASSERT_EQUAL_PRINT_FLOATING("5e-07", 0.00000050000005f); - TEST_ASSERT_EQUAL_PRINT_FLOATING("0.100469", 0.100469499f); - TEST_ASSERT_EQUAL_PRINT_FLOATING("1", 0.9999995f); /*Rounding to int place*/ + TEST_ASSERT_EQUAL_PRINT_FLOATING("5e-07", 0.0000005f); + TEST_ASSERT_EQUAL_PRINT_FLOATING("0.1004695", 0.1004695f); + TEST_ASSERT_EQUAL_PRINT_FLOATING("2", 1.9999995f); /*Rounding to int place*/ TEST_ASSERT_EQUAL_PRINT_FLOATING("1", 1.0f); TEST_ASSERT_EQUAL_PRINT_FLOATING("1.25", 1.25f); - TEST_ASSERT_EQUAL_PRINT_FLOATING("7.99999", 7.99999f); /*Not rounding*/ - TEST_ASSERT_EQUAL_PRINT_FLOATING("16.0002", 16.0002f); - TEST_ASSERT_EQUAL_PRINT_FLOATING("16.0004", 16.0004f); - TEST_ASSERT_EQUAL_PRINT_FLOATING("16.0006", 16.0006f); - TEST_ASSERT_EQUAL_PRINT_FLOATING("999999", 999999.0f); /*Last full print integer*/ + TEST_ASSERT_EQUAL_PRINT_FLOATING("7.999999", 7.999999f); /*Not rounding*/ + TEST_ASSERT_EQUAL_PRINT_FLOATING("16.00002", 16.00002f); + TEST_ASSERT_EQUAL_PRINT_FLOATING("16.00004", 16.00004f); + TEST_ASSERT_EQUAL_PRINT_FLOATING("16.00006", 16.00006f); + TEST_ASSERT_EQUAL_PRINT_FLOATING("9999999", 9999999.0f); /*Last full print integer*/ TEST_ASSERT_EQUAL_PRINT_FLOATING("-0", -0.0f); TEST_ASSERT_EQUAL_PRINT_FLOATING("-4.99e-07", -0.000000499f); - TEST_ASSERT_EQUAL_PRINT_FLOATING("-5e-07", -0.00000050000005f); - TEST_ASSERT_EQUAL_PRINT_FLOATING("-0.100469", -0.100469499f); - TEST_ASSERT_EQUAL_PRINT_FLOATING("-1", -0.9999995f); /*Rounding to int place*/ + TEST_ASSERT_EQUAL_PRINT_FLOATING("-5e-07", -0.0000005f); + TEST_ASSERT_EQUAL_PRINT_FLOATING("-0.1004695", -0.1004695f); + TEST_ASSERT_EQUAL_PRINT_FLOATING("-2", -1.9999995f); /*Rounding to int place*/ TEST_ASSERT_EQUAL_PRINT_FLOATING("-1", -1.0f); TEST_ASSERT_EQUAL_PRINT_FLOATING("-1.25", -1.25f); - TEST_ASSERT_EQUAL_PRINT_FLOATING("-7.99999", -7.99999f); /*Not rounding*/ - TEST_ASSERT_EQUAL_PRINT_FLOATING("-16.0002", -16.0002f); - TEST_ASSERT_EQUAL_PRINT_FLOATING("-16.0004", -16.0004f); - TEST_ASSERT_EQUAL_PRINT_FLOATING("-16.0006", -16.0006f); - TEST_ASSERT_EQUAL_PRINT_FLOATING("-999999", -999999.0f); /*Last full print integer*/ - - TEST_ASSERT_EQUAL_PRINT_FLOATING("4.29497e+09", 4294967296.0f); - TEST_ASSERT_EQUAL_PRINT_FLOATING("5e+09", 5000000000.0f); - TEST_ASSERT_EQUAL_PRINT_FLOATING("8e+09", 8.0e+09f); - TEST_ASSERT_EQUAL_PRINT_FLOATING("8.31e+09", 8309999104.0f); - TEST_ASSERT_EQUAL_PRINT_FLOATING("1e+10", 1.0e+10f); - TEST_ASSERT_EQUAL_PRINT_FLOATING("1e+10", 10000000000.0f); + TEST_ASSERT_EQUAL_PRINT_FLOATING("-7.999999", -7.999999f); /*Not rounding*/ + TEST_ASSERT_EQUAL_PRINT_FLOATING("-16.00002", -16.00002f); + TEST_ASSERT_EQUAL_PRINT_FLOATING("-16.00004", -16.00004f); + TEST_ASSERT_EQUAL_PRINT_FLOATING("-16.00006", -16.00006f); + TEST_ASSERT_EQUAL_PRINT_FLOATING("-9999999", -9999999.0f); /*Last full print integer*/ + + TEST_ASSERT_EQUAL_PRINT_FLOATING("4.294967e+09", 4294967296.0f); + TEST_ASSERT_EQUAL_PRINT_FLOATING("5e+09", 5000000000.0f); + TEST_ASSERT_EQUAL_PRINT_FLOATING("8e+09", 8.0e+09f); + TEST_ASSERT_EQUAL_PRINT_FLOATING("8.309999e+09", 8309999104.0f); + TEST_ASSERT_EQUAL_PRINT_FLOATING("1e+10", 1.0e+10f); + TEST_ASSERT_EQUAL_PRINT_FLOATING("1e+10", 10000000000.0f); /* Some compilers have trouble with inexact float constants, a float cast works generally */ - TEST_ASSERT_EQUAL_PRINT_FLOATING("1.00005e+10", (float)1.000054e+10f); - TEST_ASSERT_EQUAL_PRINT_FLOATING("1.1e+38", (float)1.10000005e+38f); - TEST_ASSERT_EQUAL_PRINT_FLOATING("1.6353e+10", 1.63529943e+10f); - TEST_ASSERT_EQUAL_PRINT_FLOATING("3.40282e+38", 3.40282346638e38f); + TEST_ASSERT_EQUAL_PRINT_FLOATING("1.000055e+10", (float)1.000055e+10f); + TEST_ASSERT_EQUAL_PRINT_FLOATING("1.1e+38", (float)1.10000005e+38f); + TEST_ASSERT_EQUAL_PRINT_FLOATING("1.635299e+10", 1.63529943e+10f); + TEST_ASSERT_EQUAL_PRINT_FLOATING("3.402823e+38", 3.40282346638e38f); - TEST_ASSERT_EQUAL_PRINT_FLOATING("-1e+10", -1.0e+10f); - TEST_ASSERT_EQUAL_PRINT_FLOATING("-3.40282e+38", -3.40282346638e38f); + TEST_ASSERT_EQUAL_PRINT_FLOATING("-1e+10", -1.0e+10f); + TEST_ASSERT_EQUAL_PRINT_FLOATING("-3.402823e+38", -3.40282346638e38f); #endif } @@ -4526,27 +4528,43 @@ static void printFloatValue(float f) { char expected[18]; char expected_lower[18]; + char expected_lower2[18]; + char expected_lower3[18]; char expected_higher[18]; + char expected_higher2[18]; + char expected_higher3[18]; startPutcharSpy(); UnityPrintFloat(f); - sprintf(expected, "%.6g", f); + sprintf(expected, "%.7g", f); /* We print all NaN's as "nan", not "-nan" */ if(strcmp(expected, "-nan") == 0) strcpy(expected, "nan"); - /* Allow for rounding differences in last digit */ - double lower = (double)f * 0.9999995; - double higher = (double)f * 1.0000005; - - if (isfinite(lower)) sprintf(expected_lower, "%.6g", lower); else strcpy(expected_lower, expected); - if (isfinite(higher)) sprintf(expected_higher, "%.6g", higher); else strcpy(expected_higher, expected); + /* Allow for relative error of +/-2.5e-7 */ + double lower = (double)f * 0.99999995; + double lower2 = (double)f * 0.99999985; + double lower3 = (double)f * 0.99999975; + double higher = (double)f * 1.00000005; + double higher2 = (double)f * 1.00000015; + double higher3 = (double)f * 1.00000025; + + if(isfinite(lower)) sprintf(expected_lower, "%.7g", lower); else strcpy(expected_lower, expected); + if(isfinite(lower2)) sprintf(expected_lower2, "%.7g", lower2); else strcpy(expected_lower2, expected); + if(isfinite(lower3)) sprintf(expected_lower3, "%.7g", lower3); else strcpy(expected_lower3, expected); + if(isfinite(higher)) sprintf(expected_higher, "%.7g", higher); else strcpy(expected_higher, expected); + if(isfinite(higher2)) sprintf(expected_higher2, "%.7g", higher2); else strcpy(expected_higher2, expected); + if(isfinite(higher3)) sprintf(expected_higher3, "%.7g", higher3); else strcpy(expected_higher3, expected); if (strcmp(expected, getBufferPutcharSpy()) != 0 && strcmp(expected_lower, getBufferPutcharSpy()) != 0 && - strcmp(expected_higher, getBufferPutcharSpy()) != 0) + strcmp(expected_lower2, getBufferPutcharSpy()) != 0 && + strcmp(expected_lower3, getBufferPutcharSpy()) != 0 && + strcmp(expected_higher, getBufferPutcharSpy()) != 0 && + strcmp(expected_higher2, getBufferPutcharSpy()) != 0 && + strcmp(expected_higher3, getBufferPutcharSpy()) != 0) { /* Fail with diagnostic printing */ TEST_ASSERT_EQUAL_PRINT_FLOATING(expected, f); @@ -5252,20 +5270,20 @@ void testDoublePrinting(void) #if defined(UNITY_EXCLUDE_FLOAT_PRINT) || defined(UNITY_EXCLUDE_DOUBLE) || !defined(USING_OUTPUT_SPY) TEST_IGNORE(); #else - TEST_ASSERT_EQUAL_PRINT_FLOATING("0.100469", 0.10046949999999999); - TEST_ASSERT_EQUAL_PRINT_FLOATING("4.29497e+09", 4294967295.999999); - TEST_ASSERT_EQUAL_PRINT_FLOATING("4.29497e+09", 4294967295.9999995); - TEST_ASSERT_EQUAL_PRINT_FLOATING("4.29497e+09", 4294967296.0); - TEST_ASSERT_EQUAL_PRINT_FLOATING("1e+10", 9999999995.0); - TEST_ASSERT_EQUAL_PRINT_FLOATING("9.0072e+15", 9007199254740990.0); - TEST_ASSERT_EQUAL_PRINT_FLOATING("7e+100", 7.0e+100); - TEST_ASSERT_EQUAL_PRINT_FLOATING("3e+200", 3.0e+200); - TEST_ASSERT_EQUAL_PRINT_FLOATING("9.23457e+300", 9.23456789e+300); - - TEST_ASSERT_EQUAL_PRINT_FLOATING("-0.100469", -0.10046949999999999); - TEST_ASSERT_EQUAL_PRINT_FLOATING("-4.29497e+09", -4294967295.999999); - TEST_ASSERT_EQUAL_PRINT_FLOATING("-4.29497e+09", -4294967295.9999995); - TEST_ASSERT_EQUAL_PRINT_FLOATING("-7e+100", -7.0e+100); + TEST_ASSERT_EQUAL_PRINT_FLOATING("0.1004695", 0.10046949999999999); + TEST_ASSERT_EQUAL_PRINT_FLOATING("4.294967e+09", 4294967295.999999); + TEST_ASSERT_EQUAL_PRINT_FLOATING("4.294967e+09", 4294967295.9999995); + TEST_ASSERT_EQUAL_PRINT_FLOATING("4.294967e+09", 4294967296.0); + TEST_ASSERT_EQUAL_PRINT_FLOATING("1e+10", 9999999995.0); + TEST_ASSERT_EQUAL_PRINT_FLOATING("9.007199e+15", 9007199254740990.0); + TEST_ASSERT_EQUAL_PRINT_FLOATING("7e+100", 7.0e+100); + TEST_ASSERT_EQUAL_PRINT_FLOATING("3e+200", 3.0e+200); + TEST_ASSERT_EQUAL_PRINT_FLOATING("9.234568e+300", 9.23456789e+300); + + TEST_ASSERT_EQUAL_PRINT_FLOATING("-0.1004695", -0.10046949999999999); + TEST_ASSERT_EQUAL_PRINT_FLOATING("-4.294967e+09", -4294967295.999999); + TEST_ASSERT_EQUAL_PRINT_FLOATING("-4.294967e+09", -4294967295.9999995); + TEST_ASSERT_EQUAL_PRINT_FLOATING("-7e+100", -7.0e+100); #endif } From 74ba70283a026cfcb83cf8a1998c6727535ab5a4 Mon Sep 17 00:00:00 2001 From: John Lindgren Date: Thu, 14 Sep 2017 19:19:49 -0400 Subject: [PATCH 029/454] Improve accuracy of UnityPrintFloat() for common cases. --- src/unity.c | 21 ++++++++++++++++++--- test/tests/testunity.c | 37 +++++++++++++++++++++++++------------ 2 files changed, 43 insertions(+), 15 deletions(-) diff --git a/src/unity.c b/src/unity.c index 429ff065..d82e78bb 100644 --- a/src/unity.c +++ b/src/unity.c @@ -283,9 +283,9 @@ void UnityPrintFloat(const UNITY_DOUBLE input_number) else if (isinf(number)) UnityPrint("inf"); else { + UNITY_INT32 n = 0; int exponent = 0; int decimals, digits; - UNITY_INT32 n; char buf[16]; /* @@ -295,7 +295,7 @@ void UnityPrintFloat(const UNITY_DOUBLE input_number) * (exactly) the remaining power of 10 and perform one more * multiplication or division. */ - if(number < 1e6f) + if(number < 1.0f) { UNITY_DOUBLE factor = 1.0f; @@ -313,9 +313,24 @@ void UnityPrintFloat(const UNITY_DOUBLE input_number) number /= divisor; } + else + { + /* + * In this range, we can split off the integer part before + * doing any multiplications. This reduces rounding error by + * freeing up significant bits in the fractional part. + */ + UNITY_DOUBLE factor = 1.0f; + n = (UNITY_INT32)number; + number -= (UNITY_DOUBLE)n; + + while(n < 1000000) { n *= 10; factor *= 10.0f; exponent--; } + + number *= factor; + } /* round to nearest integer */ - n = ((UNITY_INT32)(number + number) + 1) / 2; + n += ((UNITY_INT32)(number + number) + 1) / 2; if (n > 9999999) { n = 1000000; diff --git a/test/tests/testunity.c b/test/tests/testunity.c index 752c3b28..626bb25e 100644 --- a/test/tests/testunity.c +++ b/test/tests/testunity.c @@ -4543,20 +4543,33 @@ static void printFloatValue(float f) /* We print all NaN's as "nan", not "-nan" */ if(strcmp(expected, "-nan") == 0) strcpy(expected, "nan"); - /* Allow for relative error of +/-2.5e-7 */ + strcpy(expected_lower, expected); + strcpy(expected_lower2, expected); + strcpy(expected_lower3, expected); + strcpy(expected_higher, expected); + strcpy(expected_higher2, expected); + strcpy(expected_higher3, expected); + + /* Allow for rounding differences in the last digit */ double lower = (double)f * 0.99999995; - double lower2 = (double)f * 0.99999985; - double lower3 = (double)f * 0.99999975; double higher = (double)f * 1.00000005; - double higher2 = (double)f * 1.00000015; - double higher3 = (double)f * 1.00000025; - - if(isfinite(lower)) sprintf(expected_lower, "%.7g", lower); else strcpy(expected_lower, expected); - if(isfinite(lower2)) sprintf(expected_lower2, "%.7g", lower2); else strcpy(expected_lower2, expected); - if(isfinite(lower3)) sprintf(expected_lower3, "%.7g", lower3); else strcpy(expected_lower3, expected); - if(isfinite(higher)) sprintf(expected_higher, "%.7g", higher); else strcpy(expected_higher, expected); - if(isfinite(higher2)) sprintf(expected_higher2, "%.7g", higher2); else strcpy(expected_higher2, expected); - if(isfinite(higher3)) sprintf(expected_higher3, "%.7g", higher3); else strcpy(expected_higher3, expected); + + if(isfinite(lower)) sprintf(expected_lower, "%.7g", lower); + if(isfinite(higher)) sprintf(expected_higher, "%.7g", higher); + + /* Outside [1,10000000] allow for relative error of +/-2.5e-7 */ + if(f < 1.0 || f > 10000000) + { + double lower2 = (double)f * 0.99999985; + double lower3 = (double)f * 0.99999975; + double higher2 = (double)f * 1.00000015; + double higher3 = (double)f * 1.00000025; + + if(isfinite(lower2)) sprintf(expected_lower2, "%.7g", lower2); + if(isfinite(lower3)) sprintf(expected_lower3, "%.7g", lower3); + if(isfinite(higher2)) sprintf(expected_higher2, "%.7g", higher2); + if(isfinite(higher3)) sprintf(expected_higher3, "%.7g", higher3); + } if (strcmp(expected, getBufferPutcharSpy()) != 0 && strcmp(expected_lower, getBufferPutcharSpy()) != 0 && From 2d4e32cda1adafd521e13abefe493e9c93618c29 Mon Sep 17 00:00:00 2001 From: John Lindgren Date: Tue, 7 Nov 2017 22:44:59 -0500 Subject: [PATCH 030/454] Print 9 digits if we have double precision capability. --- src/unity.c | 39 ++++++---- test/tests/testunity.c | 158 ++++++++++++++++++++++++++++------------- 2 files changed, 134 insertions(+), 63 deletions(-) diff --git a/src/unity.c b/src/unity.c index d82e78bb..03d3fbfe 100644 --- a/src/unity.c +++ b/src/unity.c @@ -260,14 +260,23 @@ void UnityPrintMask(const UNITY_UINT mask, const UNITY_UINT number) #ifndef UNITY_EXCLUDE_FLOAT_PRINT /* * This function prints a floating-point value in a format similar to - * printf("%.7g"). It can work with either single- or double-precision, - * but for simplicity, it prints only 7 significant digits in either case. - * The 7th digit won't always be totally correct in single-precision - * operation (for that level of accuracy, a more complicated algorithm - * would be needed). + * printf("%.7g") on a single-precision machine or printf("%.9g") on a + * double-precision machine. The 7th digit won't always be totally correct + * in single-precision operation (for that level of accuracy, a more + * complicated algorithm would be needed). */ void UnityPrintFloat(const UNITY_DOUBLE input_number) { +#ifdef UNITY_INCLUDE_DOUBLE + static const int sig_digits = 9; + static const UNITY_INT32 min_scaled = 100000000; + static const UNITY_INT32 max_scaled = 1000000000; +#else + static const int sig_digits = 7; + static const UNITY_INT32 min_scaled = 1000000; + static const UNITY_INT32 max_scaled = 10000000; +#endif + UNITY_DOUBLE number = input_number; /* print minus sign (including for negative zero) */ @@ -295,21 +304,21 @@ void UnityPrintFloat(const UNITY_DOUBLE input_number) * (exactly) the remaining power of 10 and perform one more * multiplication or division. */ - if(number < 1.0f) + if (number < 1.0f) { UNITY_DOUBLE factor = 1.0f; - while(number < 1e7f / 1e10f) { number *= 1e10f; exponent -= 10; } - while(number * factor < 1e6f) { factor *= 10.0f; exponent--; } + while (number < (UNITY_DOUBLE)max_scaled / 1e10f) { number *= 1e10f; exponent -= 10; } + while (number * factor < (UNITY_DOUBLE)min_scaled) { factor *= 10.0f; exponent--; } number *= factor; } - else if(number > 1e7f) + else if (number > (UNITY_DOUBLE)max_scaled) { UNITY_DOUBLE divisor = 1.0f; - while(number > 1e6f * 1e10f) { number /= 1e10f; exponent += 10; } - while(number / divisor > 1e7f) { divisor *= 10.0f; exponent++; } + while (number > (UNITY_DOUBLE)min_scaled * 1e10f) { number /= 1e10f; exponent += 10; } + while (number / divisor > (UNITY_DOUBLE)max_scaled) { divisor *= 10.0f; exponent++; } number /= divisor; } @@ -324,21 +333,21 @@ void UnityPrintFloat(const UNITY_DOUBLE input_number) n = (UNITY_INT32)number; number -= (UNITY_DOUBLE)n; - while(n < 1000000) { n *= 10; factor *= 10.0f; exponent--; } + while (n < min_scaled) { n *= 10; factor *= 10.0f; exponent--; } number *= factor; } /* round to nearest integer */ n += ((UNITY_INT32)(number + number) + 1) / 2; - if (n > 9999999) + if (n >= max_scaled) { - n = 1000000; + n = min_scaled; exponent++; } /* determine where to place decimal point */ - decimals = (exponent <= 0 && exponent >= -10) ? -exponent : 6; + decimals = (exponent <= 0 && exponent >= -(sig_digits + 3)) ? -exponent : (sig_digits - 1); exponent += decimals; /* truncate trailing zeroes after decimal point */ diff --git a/test/tests/testunity.c b/test/tests/testunity.c index 626bb25e..0aa69147 100644 --- a/test/tests/testunity.c +++ b/test/tests/testunity.c @@ -4463,38 +4463,37 @@ void testNotEqualFloatEachEqualLengthZero(void) void testFloatPrinting(void) { -#if defined(UNITY_EXCLUDE_FLOAT_PRINT) || !defined(USING_OUTPUT_SPY) - TEST_IGNORE(); -#else - /* Some failures are expected due to differences in the last digit - * if UnityPrintFloat uses single-precision calculations. */ - TEST_ASSERT_EQUAL_PRINT_FLOATING("0", 0.0f); - TEST_ASSERT_EQUAL_PRINT_FLOATING("4.99e-07", 0.000000499f); - TEST_ASSERT_EQUAL_PRINT_FLOATING("5e-07", 0.0000005f); - TEST_ASSERT_EQUAL_PRINT_FLOATING("0.1004695", 0.1004695f); - TEST_ASSERT_EQUAL_PRINT_FLOATING("2", 1.9999995f); /*Rounding to int place*/ - TEST_ASSERT_EQUAL_PRINT_FLOATING("1", 1.0f); - TEST_ASSERT_EQUAL_PRINT_FLOATING("1.25", 1.25f); - TEST_ASSERT_EQUAL_PRINT_FLOATING("7.999999", 7.999999f); /*Not rounding*/ - TEST_ASSERT_EQUAL_PRINT_FLOATING("16.00002", 16.00002f); - TEST_ASSERT_EQUAL_PRINT_FLOATING("16.00004", 16.00004f); - TEST_ASSERT_EQUAL_PRINT_FLOATING("16.00006", 16.00006f); - TEST_ASSERT_EQUAL_PRINT_FLOATING("9999999", 9999999.0f); /*Last full print integer*/ - - TEST_ASSERT_EQUAL_PRINT_FLOATING("-0", -0.0f); - TEST_ASSERT_EQUAL_PRINT_FLOATING("-4.99e-07", -0.000000499f); - TEST_ASSERT_EQUAL_PRINT_FLOATING("-5e-07", -0.0000005f); - TEST_ASSERT_EQUAL_PRINT_FLOATING("-0.1004695", -0.1004695f); - TEST_ASSERT_EQUAL_PRINT_FLOATING("-2", -1.9999995f); /*Rounding to int place*/ - TEST_ASSERT_EQUAL_PRINT_FLOATING("-1", -1.0f); - TEST_ASSERT_EQUAL_PRINT_FLOATING("-1.25", -1.25f); - TEST_ASSERT_EQUAL_PRINT_FLOATING("-7.999999", -7.999999f); /*Not rounding*/ - TEST_ASSERT_EQUAL_PRINT_FLOATING("-16.00002", -16.00002f); - TEST_ASSERT_EQUAL_PRINT_FLOATING("-16.00004", -16.00004f); - TEST_ASSERT_EQUAL_PRINT_FLOATING("-16.00006", -16.00006f); - TEST_ASSERT_EQUAL_PRINT_FLOATING("-9999999", -9999999.0f); /*Last full print integer*/ - - TEST_ASSERT_EQUAL_PRINT_FLOATING("4.294967e+09", 4294967296.0f); +#if defined(UNITY_EXCLUDE_FLOAT_PRINT) || defined(UNITY_INCLUDE_DOUBLE) || !defined(USING_OUTPUT_SPY) + TEST_IGNORE(); +#else + TEST_ASSERT_EQUAL_PRINT_FLOATING("0", 0.0f); + TEST_ASSERT_EQUAL_PRINT_FLOATING("4.99e-07", 0.000000499f); + TEST_ASSERT_EQUAL_PRINT_FLOATING("5.000001e-07", 0.00000050000005f); + TEST_ASSERT_EQUAL_PRINT_FLOATING("0.1004695", 0.100469499f); + TEST_ASSERT_EQUAL_PRINT_FLOATING("2", 1.9999995f); /*Rounding to int place*/ + TEST_ASSERT_EQUAL_PRINT_FLOATING("1", 1.0f); + TEST_ASSERT_EQUAL_PRINT_FLOATING("1.25", 1.25f); + TEST_ASSERT_EQUAL_PRINT_FLOATING("7.999999", 7.999999f); /*Not rounding*/ + TEST_ASSERT_EQUAL_PRINT_FLOATING("16.00002", 16.00002f); + TEST_ASSERT_EQUAL_PRINT_FLOATING("16.00004", 16.00004f); + TEST_ASSERT_EQUAL_PRINT_FLOATING("16.00006", 16.00006f); + TEST_ASSERT_EQUAL_PRINT_FLOATING("9999999", 9999999.0f); /*Last full print integer*/ + + TEST_ASSERT_EQUAL_PRINT_FLOATING("-0", -0.0f); + TEST_ASSERT_EQUAL_PRINT_FLOATING("-4.99e-07", -0.000000499f); + TEST_ASSERT_EQUAL_PRINT_FLOATING("-5.000001e-07", -0.00000050000005f); + TEST_ASSERT_EQUAL_PRINT_FLOATING("-0.1004695", -0.100469499f); + TEST_ASSERT_EQUAL_PRINT_FLOATING("-2", -1.9999995f); /*Rounding to int place*/ + TEST_ASSERT_EQUAL_PRINT_FLOATING("-1", -1.0f); + TEST_ASSERT_EQUAL_PRINT_FLOATING("-1.25", -1.25f); + TEST_ASSERT_EQUAL_PRINT_FLOATING("-7.999999", -7.999999f); /*Not rounding*/ + TEST_ASSERT_EQUAL_PRINT_FLOATING("-16.00002", -16.00002f); + TEST_ASSERT_EQUAL_PRINT_FLOATING("-16.00004", -16.00004f); + TEST_ASSERT_EQUAL_PRINT_FLOATING("-16.00006", -16.00006f); + TEST_ASSERT_EQUAL_PRINT_FLOATING("-9999999", -9999999.0f); /*Last full print integer*/ + + /* Fails, prints "4.294968e+09" due to FP math imprecision + * TEST_ASSERT_EQUAL_PRINT_FLOATING("4.294967e+09", 4294967296.0f); */ TEST_ASSERT_EQUAL_PRINT_FLOATING("5e+09", 5000000000.0f); TEST_ASSERT_EQUAL_PRINT_FLOATING("8e+09", 8.0e+09f); TEST_ASSERT_EQUAL_PRINT_FLOATING("8.309999e+09", 8309999104.0f); @@ -4504,10 +4503,12 @@ void testFloatPrinting(void) TEST_ASSERT_EQUAL_PRINT_FLOATING("1.000055e+10", (float)1.000055e+10f); TEST_ASSERT_EQUAL_PRINT_FLOATING("1.1e+38", (float)1.10000005e+38f); TEST_ASSERT_EQUAL_PRINT_FLOATING("1.635299e+10", 1.63529943e+10f); - TEST_ASSERT_EQUAL_PRINT_FLOATING("3.402823e+38", 3.40282346638e38f); + /* Fails, prints "3.402824e+38" due to FP math imprecision + * TEST_ASSERT_EQUAL_PRINT_FLOATING("3.402823e+38", 3.40282346638e38f); */ TEST_ASSERT_EQUAL_PRINT_FLOATING("-1e+10", -1.0e+10f); - TEST_ASSERT_EQUAL_PRINT_FLOATING("-3.402823e+38", -3.40282346638e38f); + /* Fails, prints "-3.402824e+38" due to FP math imprecision + * TEST_ASSERT_EQUAL_PRINT_FLOATING("-3.402823e+38", -3.40282346638e38f); */ #endif } @@ -4524,6 +4525,41 @@ void testFloatPrintingInfinityAndNaN(void) } #if defined(UNITY_TEST_ALL_FLOATS_PRINT_OK) && defined(USING_OUTPUT_SPY) +#ifdef UNITY_INCLUDE_DOUBLE +static void printFloatValue(float f) +{ + char expected[18]; + char expected_lower[18]; + char expected_higher[18]; + + startPutcharSpy(); + + UnityPrintFloat(f); + + sprintf(expected, "%.9g", f); + + /* We print all NaN's as "nan", not "-nan" */ + if(strcmp(expected, "-nan") == 0) strcpy(expected, "nan"); + + strcpy(expected_lower, expected); + strcpy(expected_higher, expected); + + /* Allow for rounding differences in the last digit */ + double lower = (double)f * 0.9999999995; + double higher = (double)f * 1.0000000005; + + if(isfinite(lower)) sprintf(expected_lower, "%.9g", lower); + if(isfinite(higher)) sprintf(expected_higher, "%.9g", higher); + + if (strcmp(expected, getBufferPutcharSpy()) != 0 && + strcmp(expected_lower, getBufferPutcharSpy()) != 0 && + strcmp(expected_higher, getBufferPutcharSpy()) != 0) + { + /* Fail with diagnostic printing */ + TEST_ASSERT_EQUAL_PRINT_FLOATING(expected, f); + } +} +#else static void printFloatValue(float f) { char expected[18]; @@ -4584,6 +4620,7 @@ static void printFloatValue(float f) } } #endif +#endif void testFloatPrintingRandomSamples(void) { @@ -5283,20 +5320,45 @@ void testDoublePrinting(void) #if defined(UNITY_EXCLUDE_FLOAT_PRINT) || defined(UNITY_EXCLUDE_DOUBLE) || !defined(USING_OUTPUT_SPY) TEST_IGNORE(); #else - TEST_ASSERT_EQUAL_PRINT_FLOATING("0.1004695", 0.10046949999999999); - TEST_ASSERT_EQUAL_PRINT_FLOATING("4.294967e+09", 4294967295.999999); - TEST_ASSERT_EQUAL_PRINT_FLOATING("4.294967e+09", 4294967295.9999995); - TEST_ASSERT_EQUAL_PRINT_FLOATING("4.294967e+09", 4294967296.0); - TEST_ASSERT_EQUAL_PRINT_FLOATING("1e+10", 9999999995.0); - TEST_ASSERT_EQUAL_PRINT_FLOATING("9.007199e+15", 9007199254740990.0); - TEST_ASSERT_EQUAL_PRINT_FLOATING("7e+100", 7.0e+100); - TEST_ASSERT_EQUAL_PRINT_FLOATING("3e+200", 3.0e+200); - TEST_ASSERT_EQUAL_PRINT_FLOATING("9.234568e+300", 9.23456789e+300); - - TEST_ASSERT_EQUAL_PRINT_FLOATING("-0.1004695", -0.10046949999999999); - TEST_ASSERT_EQUAL_PRINT_FLOATING("-4.294967e+09", -4294967295.999999); - TEST_ASSERT_EQUAL_PRINT_FLOATING("-4.294967e+09", -4294967295.9999995); - TEST_ASSERT_EQUAL_PRINT_FLOATING("-7e+100", -7.0e+100); + TEST_ASSERT_EQUAL_PRINT_FLOATING("0", 0.0); + TEST_ASSERT_EQUAL_PRINT_FLOATING("4.99e-07", 0.000000499); + TEST_ASSERT_EQUAL_PRINT_FLOATING("5.0000005e-07", 0.00000050000005); + TEST_ASSERT_EQUAL_PRINT_FLOATING("0.100469499", 0.100469499); + TEST_ASSERT_EQUAL_PRINT_FLOATING("1", 0.9999999995); /*Rounding to int place*/ + TEST_ASSERT_EQUAL_PRINT_FLOATING("1", 1.0); + TEST_ASSERT_EQUAL_PRINT_FLOATING("1.25", 1.25); + TEST_ASSERT_EQUAL_PRINT_FLOATING("7.99999999", 7.99999999); /*Not rounding*/ + TEST_ASSERT_EQUAL_PRINT_FLOATING("16.0000002", 16.0000002); + TEST_ASSERT_EQUAL_PRINT_FLOATING("16.0000004", 16.0000004); + TEST_ASSERT_EQUAL_PRINT_FLOATING("16.0000006", 16.0000006); + TEST_ASSERT_EQUAL_PRINT_FLOATING("999999999", 999999999.0); /*Last full print integer*/ + + TEST_ASSERT_EQUAL_PRINT_FLOATING("-0", -0.0); + TEST_ASSERT_EQUAL_PRINT_FLOATING("-4.99e-07", -0.000000499); + TEST_ASSERT_EQUAL_PRINT_FLOATING("-5.0000005e-07", -0.00000050000005); + TEST_ASSERT_EQUAL_PRINT_FLOATING("-0.100469499", -0.100469499); + TEST_ASSERT_EQUAL_PRINT_FLOATING("-1", -0.9999999995); /*Rounding to int place*/ + TEST_ASSERT_EQUAL_PRINT_FLOATING("-1", -1.0); + TEST_ASSERT_EQUAL_PRINT_FLOATING("-1.25", -1.25); + TEST_ASSERT_EQUAL_PRINT_FLOATING("-7.99999999", -7.99999999); /*Not rounding*/ + TEST_ASSERT_EQUAL_PRINT_FLOATING("-16.0000002", -16.0000002); + TEST_ASSERT_EQUAL_PRINT_FLOATING("-16.0000004", -16.0000004); + TEST_ASSERT_EQUAL_PRINT_FLOATING("-16.0000006", -16.0000006); + TEST_ASSERT_EQUAL_PRINT_FLOATING("-999999999", -999999999.0); /*Last full print integer*/ + + TEST_ASSERT_EQUAL_PRINT_FLOATING("0.1004695", 0.10046949999999999); + TEST_ASSERT_EQUAL_PRINT_FLOATING("4.2949673e+09", 4294967295.9); + TEST_ASSERT_EQUAL_PRINT_FLOATING("4.2949673e+09", 4294967296.0); + TEST_ASSERT_EQUAL_PRINT_FLOATING("1e+10", 9999999995.0); + TEST_ASSERT_EQUAL_PRINT_FLOATING("9.00719925e+15", 9007199254740990.0); + TEST_ASSERT_EQUAL_PRINT_FLOATING("7e+100", 7.0e+100); + TEST_ASSERT_EQUAL_PRINT_FLOATING("3e+200", 3.0e+200); + TEST_ASSERT_EQUAL_PRINT_FLOATING("9.23456789e+300", 9.23456789e+300); + + TEST_ASSERT_EQUAL_PRINT_FLOATING("-0.1004695", -0.10046949999999999); + TEST_ASSERT_EQUAL_PRINT_FLOATING("-4.2949673e+09", -4294967295.9); + TEST_ASSERT_EQUAL_PRINT_FLOATING("-4.2949673e+09", -4294967296.0); + TEST_ASSERT_EQUAL_PRINT_FLOATING("-7e+100", -7.0e+100); #endif } From a6d3f3a59aedb401c89b530b108f4df24e1e4cb5 Mon Sep 17 00:00:00 2001 From: John Lindgren Date: Tue, 7 Nov 2017 23:25:27 -0500 Subject: [PATCH 031/454] Restore round-to-even behavior. --- src/unity.c | 19 +++++++++--- test/tests/testunity.c | 70 +++++++++++++++++++++++++----------------- 2 files changed, 56 insertions(+), 33 deletions(-) diff --git a/src/unity.c b/src/unity.c index 03d3fbfe..fc3ae531 100644 --- a/src/unity.c +++ b/src/unity.c @@ -292,7 +292,7 @@ void UnityPrintFloat(const UNITY_DOUBLE input_number) else if (isinf(number)) UnityPrint("inf"); else { - UNITY_INT32 n = 0; + UNITY_INT32 n_int = 0, n; int exponent = 0; int decimals, digits; char buf[16]; @@ -330,16 +330,25 @@ void UnityPrintFloat(const UNITY_DOUBLE input_number) * freeing up significant bits in the fractional part. */ UNITY_DOUBLE factor = 1.0f; - n = (UNITY_INT32)number; - number -= (UNITY_DOUBLE)n; + n_int = (UNITY_INT32)number; + number -= (UNITY_DOUBLE)n_int; - while (n < min_scaled) { n *= 10; factor *= 10.0f; exponent--; } + while (n_int < min_scaled) { n_int *= 10; factor *= 10.0f; exponent--; } number *= factor; } /* round to nearest integer */ - n += ((UNITY_INT32)(number + number) + 1) / 2; + n = ((UNITY_INT32)(number + number) + 1) / 2; + +#ifndef UNITY_ROUND_TIES_AWAY_FROM_ZERO + /* round to even if exactly between two integers */ + if ((n & 1) && ((UNITY_DOUBLE)n - number == 0.5f)) + n--; +#endif + + n += n_int; + if (n >= max_scaled) { n = min_scaled; diff --git a/test/tests/testunity.c b/test/tests/testunity.c index 0aa69147..2d6a5ab8 100644 --- a/test/tests/testunity.c +++ b/test/tests/testunity.c @@ -4468,7 +4468,6 @@ void testFloatPrinting(void) #else TEST_ASSERT_EQUAL_PRINT_FLOATING("0", 0.0f); TEST_ASSERT_EQUAL_PRINT_FLOATING("4.99e-07", 0.000000499f); - TEST_ASSERT_EQUAL_PRINT_FLOATING("5.000001e-07", 0.00000050000005f); TEST_ASSERT_EQUAL_PRINT_FLOATING("0.1004695", 0.100469499f); TEST_ASSERT_EQUAL_PRINT_FLOATING("2", 1.9999995f); /*Rounding to int place*/ TEST_ASSERT_EQUAL_PRINT_FLOATING("1", 1.0f); @@ -4481,7 +4480,6 @@ void testFloatPrinting(void) TEST_ASSERT_EQUAL_PRINT_FLOATING("-0", -0.0f); TEST_ASSERT_EQUAL_PRINT_FLOATING("-4.99e-07", -0.000000499f); - TEST_ASSERT_EQUAL_PRINT_FLOATING("-5.000001e-07", -0.00000050000005f); TEST_ASSERT_EQUAL_PRINT_FLOATING("-0.1004695", -0.100469499f); TEST_ASSERT_EQUAL_PRINT_FLOATING("-2", -1.9999995f); /*Rounding to int place*/ TEST_ASSERT_EQUAL_PRINT_FLOATING("-1", -1.0f); @@ -4512,6 +4510,25 @@ void testFloatPrinting(void) #endif } +void testFloatPrintingRoundTiesToEven(void) +{ +#if defined(UNITY_EXCLUDE_FLOAT_PRINT) || defined(UNITY_INCLUDE_DOUBLE) || !defined(USING_OUTPUT_SPY) + TEST_IGNORE(); +#else + #ifdef UNITY_ROUND_TIES_AWAY_FROM_ZERO + TEST_ASSERT_EQUAL_PRINT_FLOATING("0.0004882813", 0.00048828125f); + TEST_ASSERT_EQUAL_PRINT_FLOATING("488281.3", 488281.25f); + TEST_ASSERT_EQUAL_PRINT_FLOATING("5.000001e-07", 0.00000050000005f); + TEST_ASSERT_EQUAL_PRINT_FLOATING("-5.000001e-07", -0.00000050000005f); + #else /* Default to Round ties to even */ + TEST_ASSERT_EQUAL_PRINT_FLOATING("0.0004882812", 0.00048828125f); + TEST_ASSERT_EQUAL_PRINT_FLOATING("488281.2", 488281.25f); + TEST_ASSERT_EQUAL_PRINT_FLOATING("5e-07", 0.00000050000005f); + TEST_ASSERT_EQUAL_PRINT_FLOATING("-5e-07", -0.00000050000005f); + #endif +#endif +} + void testFloatPrintingInfinityAndNaN(void) { #if defined(UNITY_EXCLUDE_FLOAT_PRINT) || !defined(USING_OUTPUT_SPY) @@ -4529,31 +4546,15 @@ void testFloatPrintingInfinityAndNaN(void) static void printFloatValue(float f) { char expected[18]; - char expected_lower[18]; - char expected_higher[18]; startPutcharSpy(); - UnityPrintFloat(f); sprintf(expected, "%.9g", f); - /* We print all NaN's as "nan", not "-nan" */ - if(strcmp(expected, "-nan") == 0) strcpy(expected, "nan"); - - strcpy(expected_lower, expected); - strcpy(expected_higher, expected); - - /* Allow for rounding differences in the last digit */ - double lower = (double)f * 0.9999999995; - double higher = (double)f * 1.0000000005; - - if(isfinite(lower)) sprintf(expected_lower, "%.9g", lower); - if(isfinite(higher)) sprintf(expected_higher, "%.9g", higher); + if (strcmp(expected, "-nan") == 0) strcpy(expected, "nan"); - if (strcmp(expected, getBufferPutcharSpy()) != 0 && - strcmp(expected_lower, getBufferPutcharSpy()) != 0 && - strcmp(expected_higher, getBufferPutcharSpy()) != 0) + if (strcmp(expected, getBufferPutcharSpy())) { /* Fail with diagnostic printing */ TEST_ASSERT_EQUAL_PRINT_FLOATING(expected, f); @@ -4571,13 +4572,11 @@ static void printFloatValue(float f) char expected_higher3[18]; startPutcharSpy(); - UnityPrintFloat(f); sprintf(expected, "%.7g", f); - /* We print all NaN's as "nan", not "-nan" */ - if(strcmp(expected, "-nan") == 0) strcpy(expected, "nan"); + if (strcmp(expected, "-nan") == 0) strcpy(expected, "nan"); strcpy(expected_lower, expected); strcpy(expected_lower2, expected); @@ -4594,17 +4593,17 @@ static void printFloatValue(float f) if(isfinite(higher)) sprintf(expected_higher, "%.7g", higher); /* Outside [1,10000000] allow for relative error of +/-2.5e-7 */ - if(f < 1.0 || f > 10000000) + if (f < 1.0 || f > 10000000) { double lower2 = (double)f * 0.99999985; double lower3 = (double)f * 0.99999975; double higher2 = (double)f * 1.00000015; double higher3 = (double)f * 1.00000025; - if(isfinite(lower2)) sprintf(expected_lower2, "%.7g", lower2); - if(isfinite(lower3)) sprintf(expected_lower3, "%.7g", lower3); - if(isfinite(higher2)) sprintf(expected_higher2, "%.7g", higher2); - if(isfinite(higher3)) sprintf(expected_higher3, "%.7g", higher3); + if (isfinite(lower2)) sprintf(expected_lower2, "%.7g", lower2); + if (isfinite(lower3)) sprintf(expected_lower3, "%.7g", lower3); + if (isfinite(higher2)) sprintf(expected_higher2, "%.7g", higher2); + if (isfinite(higher3)) sprintf(expected_higher3, "%.7g", higher3); } if (strcmp(expected, getBufferPutcharSpy()) != 0 && @@ -5362,6 +5361,21 @@ void testDoublePrinting(void) #endif } +void testDoublePrintingRoundTiesToEven(void) +{ +#if defined(UNITY_EXCLUDE_FLOAT_PRINT) || defined(UNITY_EXCLUDE_DOUBLE) || !defined(USING_OUTPUT_SPY) + TEST_IGNORE(); +#else + #ifdef UNITY_ROUND_TIES_AWAY_FROM_ZERO + TEST_ASSERT_EQUAL_PRINT_FLOATING("1.00000001e+10", 10000000050.0); + TEST_ASSERT_EQUAL_PRINT_FLOATING("9.00719925e+15", 9007199245000000.0); + #else /* Default to Round ties to even */ + TEST_ASSERT_EQUAL_PRINT_FLOATING("1e+10", 10000000050.0); + TEST_ASSERT_EQUAL_PRINT_FLOATING("9.00719924e+15", 9007199245000000.0); + #endif +#endif +} + void testDoublePrintingInfinityAndNaN(void) { #if defined(UNITY_EXCLUDE_FLOAT_PRINT) || defined(UNITY_EXCLUDE_DOUBLE) || !defined(USING_OUTPUT_SPY) From 287e076962ec711cd2bdf08364a8df9ce51e106b Mon Sep 17 00:00:00 2001 From: Mark VanderVoord Date: Tue, 14 Nov 2017 16:26:16 -0500 Subject: [PATCH 032/454] Post release --- release/build.info | 2 +- release/version.info | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/release/build.info b/release/build.info index 50fb6eaf..56d59128 100644 --- a/release/build.info +++ b/release/build.info @@ -1,2 +1,2 @@ -121 +122 diff --git a/release/version.info b/release/version.info index b674b923..cf12b30d 100644 --- a/release/version.info +++ b/release/version.info @@ -1,2 +1,2 @@ -2.4.2 +2.4.3 From 53f0f95ef8af7f903ef0080d0492df33e517ed9c Mon Sep 17 00:00:00 2001 From: Krzysztof Kwiatkowski Date: Mon, 20 Nov 2017 09:46:30 +0000 Subject: [PATCH 033/454] Test runner generation: Wrap setjmp.h inclusion in ifdefs Auto generated test runner should generate a code which includes setjmp.h only if UNITY_EXCLUDE_SETJMP_H is not defined --- auto/generate_test_runner.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/auto/generate_test_runner.rb b/auto/generate_test_runner.rb index 344a2d0f..427c5136 100644 --- a/auto/generate_test_runner.rb +++ b/auto/generate_test_runner.rb @@ -162,7 +162,9 @@ def create_header(output, mocks, testfile_includes = []) output.puts('#endif') output.puts("#include \"#{@options[:framework]}.h\"") output.puts('#include "cmock.h"') unless mocks.empty? + output.puts('#ifndef UNITY_EXCLUDE_SETJMP_H') output.puts('#include ') + output.puts("#endif") output.puts('#include ') if @options[:defines] && !@options[:defines].empty? @options[:defines].each { |d| output.puts("#define #{d}") } From 4325773e7627eb6b6ba4779de264e42512fce538 Mon Sep 17 00:00:00 2001 From: Shreyas Balakrishna Date: Thu, 23 Nov 2017 14:58:45 +1300 Subject: [PATCH 034/454] Fix unsigned integer underflow in UnityAssertEqualIntArray --- src/unity.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/unity.c b/src/unity.c index 177af0f4..209efe72 100644 --- a/src/unity.c +++ b/src/unity.c @@ -556,7 +556,7 @@ void UnityAssertEqualIntArray(UNITY_INTERNAL_PTR expected, if (UnityIsOneArrayNull(expected, actual, lineNumber, msg)) UNITY_FAIL_AND_BAIL; - while (elements--) + while ((elements > 0) && elements--) { UNITY_INT expect_val; UNITY_INT actual_val; From b4aca70fd9e0ddf0afbdafb1b826f5edcfc1049b Mon Sep 17 00:00:00 2001 From: Mark VanderVoord Date: Wed, 6 Dec 2017 10:08:56 -0500 Subject: [PATCH 035/454] Update UnityGettingStartedGuide.md Added more detail on test naming. --- docs/UnityGettingStartedGuide.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/docs/UnityGettingStartedGuide.md b/docs/UnityGettingStartedGuide.md index 50fc91c7..81d03987 100644 --- a/docs/UnityGettingStartedGuide.md +++ b/docs/UnityGettingStartedGuide.md @@ -100,10 +100,11 @@ find setUp or tearDown when it links, you'll know you need to at least include an empty function for these. The majority of the file will be a series of test functions. Test functions -follow the convention of starting with the word "test" or "spec". You don't HAVE +follow the convention of starting with the word "test_" or "spec_". You don't HAVE to name them this way, but it makes it clear what functions are tests for other -developers. Test functions take no arguments and return nothing. All test -accounting is handled internally in Unity. +developers. Also, the automated scripts that come with Unity or Ceedling will default +to looking for test functions to be prefixed this way. Test functions take no arguments +and return nothing. All test accounting is handled internally in Unity. Finally, at the bottom of your test file, you will write a `main()` function. This function will call `UNITY_BEGIN()`, then `RUN_TEST` for each test, and From 07602308294c5f30b4d732cd87bd98d0c5e6a693 Mon Sep 17 00:00:00 2001 From: Fabian Zahn Date: Mon, 29 Jan 2018 21:00:46 +0100 Subject: [PATCH 036/454] Some minor changes - String split now works correctly for windows and unix (cross platform) - Removed unnecessary whitespaces in the xml output (beautifies the output) - Added support for TEST_IGNORE() (without message) --- auto/parse_output.rb | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/auto/parse_output.rb b/auto/parse_output.rb index f16cdb03..f3e076f2 100644 --- a/auto/parse_output.rb +++ b/auto/parse_output.rb @@ -47,7 +47,12 @@ def test_suite_verify(test_suite_name) @test_flag = true # Split the path name - test_name = test_suite_name.split('/') + test_name = if @class_name == 1 + test_suite_name.split('\\') # Windows + else + test_suite_name.split('/') # Unix based + end + # Remove the extension base_name = test_name[test_name.size - 1].split('.') @test_suite = 'test.' + base_name[0] @@ -78,11 +83,11 @@ def test_passed_unity_fixture(array) @array_list.push ' ' end - # Test was flagged as being ingored so format the output + # Test was flagged as being ignored so format the output def test_ignored(array) last_item = array.length - 1 test_name = array[last_item - 2] - reason = array[last_item].chomp + reason = array[last_item].chomp.lstrip test_suite_verify(array[@class_name]) printf "%-40s IGNORED\n", test_name @@ -96,7 +101,7 @@ def test_ignored(array) return unless @xml_out @array_list.push ' ' - @array_list.push ' ' + reason + ' ' + @array_list.push ' ' + reason + '' @array_list.push ' ' end @@ -104,7 +109,7 @@ def test_ignored(array) def test_failed(array) last_item = array.length - 1 test_name = array[last_item - 2] - reason = array[last_item].chomp + ' at line: ' + array[last_item - 3] + reason = array[last_item].chomp.lstrip + ' at line: ' + array[last_item - 3] test_suite_verify(array[@class_name]) printf "%-40s FAILED\n", test_name @@ -118,11 +123,11 @@ def test_failed(array) return unless @xml_out @array_list.push ' ' - @array_list.push ' ' + reason + ' ' + @array_list.push ' ' + reason + '' @array_list.push ' ' end - # Figure out what OS we are running on. For now we are assuming if it's not Windows it must + # Figure out what OS we are running on. For now we are assuming if it's not Windows it must # be Unix based. def detect_os os = RUBY_PLATFORM.split('-') @@ -168,12 +173,16 @@ def process(name) if line.include? ':PASS' test_passed(line_array) test_pass += 1 - elsif line.include? ':FAIL:' + elsif line.include? ':FAIL' test_failed(line_array) test_fail += 1 elsif line.include? ':IGNORE:' test_ignored(line_array) test_ignore += 1 + elsif line.include? ':IGNORE' + line_array.push('No reason given') + test_ignored(line_array) + test_ignore += 1 elsif line.start_with? 'TEST(' if line.include? ' PASS' line_array = line.split(' ') @@ -199,7 +208,7 @@ def process(name) return unless @xml_out - heading = '' + heading = '' @array_list.insert(0, heading) write_xml_output end From 91a23535266b4c8a0cdc38e116bc9572d6912093 Mon Sep 17 00:00:00 2001 From: Jeremy Hannon Date: Sat, 10 Feb 2018 13:15:34 -0600 Subject: [PATCH 037/454] MISRA 16.4: param names match func decl & defn parameter names should match between declaration and definition. (MISRA 2004 rule 16.4) --- extras/fixture/src/unity_fixture.h | 2 +- extras/fixture/src/unity_fixture_internals.h | 4 ++-- src/unity_internals.h | 8 ++++---- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/extras/fixture/src/unity_fixture.h b/extras/fixture/src/unity_fixture.h index 6f8d6234..2dcf473c 100644 --- a/extras/fixture/src/unity_fixture.h +++ b/extras/fixture/src/unity_fixture.h @@ -78,6 +78,6 @@ int UnityMain(int argc, const char* argv[], void (*runAllTests)(void)); #endif /* You must compile with malloc replacement, as defined in unity_fixture_malloc_overrides.h */ -void UnityMalloc_MakeMallocFailAfterCount(int count); +void UnityMalloc_MakeMallocFailAfterCount(int countdown); #endif /* UNITY_FIXTURE_H_ */ diff --git a/extras/fixture/src/unity_fixture_internals.h b/extras/fixture/src/unity_fixture_internals.h index aa0d9e7c..00cee883 100644 --- a/extras/fixture/src/unity_fixture_internals.h +++ b/extras/fixture/src/unity_fixture_internals.h @@ -24,7 +24,7 @@ extern struct UNITY_FIXTURE_T UnityFixture; typedef void unityfunction(void); void UnityTestRunner(unityfunction* setup, - unityfunction* body, + unityfunction* testBody, unityfunction* teardown, const char* printableName, const char* group, @@ -37,7 +37,7 @@ void UnityMalloc_EndTest(void); int UnityGetCommandLineOptions(int argc, const char* argv[]); void UnityConcludeFixtureTest(void); -void UnityPointer_Set(void** ptr, void* newValue, UNITY_LINE_TYPE line); +void UnityPointer_Set(void** pointer, void* newValue, UNITY_LINE_TYPE line); void UnityPointer_UndoAllSets(void); void UnityPointer_Init(void); #ifndef UNITY_MAX_POINTERS diff --git a/src/unity_internals.h b/src/unity_internals.h index 67e219b8..97f86ef3 100644 --- a/src/unity_internals.h +++ b/src/unity_internals.h @@ -442,9 +442,9 @@ void UnityPrint(const char* string); void UnityPrintLen(const char* string, const UNITY_UINT32 length); void UnityPrintMask(const UNITY_UINT mask, const UNITY_UINT number); void UnityPrintNumberByStyle(const UNITY_INT number, const UNITY_DISPLAY_STYLE_T style); -void UnityPrintNumber(const UNITY_INT number); +void UnityPrintNumber(const UNITY_INT number_to_print); void UnityPrintNumberUnsigned(const UNITY_UINT number); -void UnityPrintNumberHex(const UNITY_UINT number, const char nibbles); +void UnityPrintNumberHex(const UNITY_UINT number, const char nibbles_to_print); #ifndef UNITY_EXCLUDE_FLOAT_PRINT void UnityPrintFloat(const UNITY_DOUBLE input_number); @@ -518,9 +518,9 @@ void UnityAssertNumbersWithin(const UNITY_UINT delta, const UNITY_LINE_TYPE lineNumber, const UNITY_DISPLAY_STYLE_T style); -void UnityFail(const char* message, const UNITY_LINE_TYPE line); +void UnityFail(const char* msg, const UNITY_LINE_TYPE line); -void UnityIgnore(const char* message, const UNITY_LINE_TYPE line); +void UnityIgnore(const char* msg, const UNITY_LINE_TYPE line); #ifndef UNITY_EXCLUDE_FLOAT void UnityAssertFloatsWithin(const UNITY_FLOAT delta, From 9bada282f471a5565f351bad346677f34ec36ec6 Mon Sep 17 00:00:00 2001 From: Jeremy Hannon Date: Sat, 10 Feb 2018 14:27:03 -0600 Subject: [PATCH 038/454] MISRA 19.10: parentheses around macro params MISRA 2004 rule 19.10: inside macros, surround each parameter usage with parentheses. --- src/unity.c | 14 +++++++------- src/unity_internals.h | 28 ++++++++++++++-------------- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/src/unity.c b/src/unity.c index 03dcc02a..136e9d7b 100644 --- a/src/unity.c +++ b/src/unity.c @@ -677,13 +677,13 @@ void UnityAssertEqualIntArray(UNITY_INTERNAL_PTR expected, /*-----------------------------------------------*/ #ifndef UNITY_EXCLUDE_FLOAT /* Wrap this define in a function with variable types as float or double */ -#define UNITY_FLOAT_OR_DOUBLE_WITHIN(delta, expected, actual, diff) \ - if (isinf(expected) && isinf(actual) && ((expected < 0) == (actual < 0))) return 1; \ - if (UNITY_NAN_CHECK) return 1; \ - diff = actual - expected; \ - if (diff < 0) diff = -diff; \ - if (delta < 0) delta = -delta; \ - return !(isnan(diff) || isinf(diff) || (diff > delta)) +#define UNITY_FLOAT_OR_DOUBLE_WITHIN(delta, expected, actual, diff) \ + if (isinf(expected) && isinf(actual) && (((expected) < 0) == ((actual) < 0))) return 1; \ + if (UNITY_NAN_CHECK) return 1; \ + (diff) = (actual) - (expected); \ + if ((diff) < 0) (diff) = -(diff); \ + if ((delta) < 0) (delta) = -(delta); \ + return !(isnan(diff) || isinf(diff) || ((diff) > (delta))) /* This first part of this condition will catch any NaN or Infinite values */ #ifndef UNITY_NAN_NOT_EQUAL_NAN #define UNITY_NAN_CHECK isnan(expected) && isnan(actual) diff --git a/src/unity_internals.h b/src/unity_internals.h index 97f86ef3..3ba6fae7 100644 --- a/src/unity_internals.h +++ b/src/unity_internals.h @@ -422,8 +422,8 @@ void UnityDefaultTestRun(UnityTestFunction Func, const char* FuncName, const int #define UNITY_SET_DETAILS(d1,d2) #else #define UNITY_CLR_DETAILS() { Unity.CurrentDetail1 = 0; Unity.CurrentDetail2 = 0; } -#define UNITY_SET_DETAIL(d1) { Unity.CurrentDetail1 = d1; Unity.CurrentDetail2 = 0; } -#define UNITY_SET_DETAILS(d1,d2) { Unity.CurrentDetail1 = d1; Unity.CurrentDetail2 = d2; } +#define UNITY_SET_DETAIL(d1) { Unity.CurrentDetail1 = (d1); Unity.CurrentDetail2 = 0; } +#define UNITY_SET_DETAILS(d1,d2) { Unity.CurrentDetail1 = (d1); Unity.CurrentDetail2 = (d2); } #ifndef UNITY_DETAIL1_NAME #define UNITY_DETAIL1_NAME "Function" @@ -748,18 +748,18 @@ int UnityTestMatches(void); #define UNITY_TEST_ASSERT_EQUAL_STRING_ARRAY(expected, actual, num_elements, line, message) UnityAssertEqualStringArray((UNITY_INTERNAL_PTR)(expected), (const char**)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_ARRAY_TO_ARRAY) #define UNITY_TEST_ASSERT_EQUAL_MEMORY_ARRAY(expected, actual, len, num_elements, line, message) UnityAssertEqualMemory((UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(len), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_ARRAY_TO_ARRAY) -#define UNITY_TEST_ASSERT_EACH_EQUAL_INT(expected, actual, num_elements, line, message) UnityAssertEqualIntArray(UnityNumToPtr((UNITY_INT) expected, sizeof(int)), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT, UNITY_ARRAY_TO_VAL) -#define UNITY_TEST_ASSERT_EACH_EQUAL_INT8(expected, actual, num_elements, line, message) UnityAssertEqualIntArray(UnityNumToPtr((UNITY_INT)(UNITY_INT8 )expected, 1), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT8, UNITY_ARRAY_TO_VAL) -#define UNITY_TEST_ASSERT_EACH_EQUAL_INT16(expected, actual, num_elements, line, message) UnityAssertEqualIntArray(UnityNumToPtr((UNITY_INT)(UNITY_INT16 )expected, 2), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT16, UNITY_ARRAY_TO_VAL) -#define UNITY_TEST_ASSERT_EACH_EQUAL_INT32(expected, actual, num_elements, line, message) UnityAssertEqualIntArray(UnityNumToPtr((UNITY_INT)(UNITY_INT32 )expected, 4), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT32, UNITY_ARRAY_TO_VAL) -#define UNITY_TEST_ASSERT_EACH_EQUAL_UINT(expected, actual, num_elements, line, message) UnityAssertEqualIntArray(UnityNumToPtr((UNITY_INT) expected, sizeof(unsigned int)), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT, UNITY_ARRAY_TO_VAL) -#define UNITY_TEST_ASSERT_EACH_EQUAL_UINT8(expected, actual, num_elements, line, message) UnityAssertEqualIntArray(UnityNumToPtr((UNITY_INT)(UNITY_UINT8 )expected, 1), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT8, UNITY_ARRAY_TO_VAL) -#define UNITY_TEST_ASSERT_EACH_EQUAL_UINT16(expected, actual, num_elements, line, message) UnityAssertEqualIntArray(UnityNumToPtr((UNITY_INT)(UNITY_UINT16)expected, 2), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT16, UNITY_ARRAY_TO_VAL) -#define UNITY_TEST_ASSERT_EACH_EQUAL_UINT32(expected, actual, num_elements, line, message) UnityAssertEqualIntArray(UnityNumToPtr((UNITY_INT)(UNITY_UINT32)expected, 4), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT32, UNITY_ARRAY_TO_VAL) -#define UNITY_TEST_ASSERT_EACH_EQUAL_HEX8(expected, actual, num_elements, line, message) UnityAssertEqualIntArray(UnityNumToPtr((UNITY_INT)(UNITY_INT8 )expected, 1), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX8, UNITY_ARRAY_TO_VAL) -#define UNITY_TEST_ASSERT_EACH_EQUAL_HEX16(expected, actual, num_elements, line, message) UnityAssertEqualIntArray(UnityNumToPtr((UNITY_INT)(UNITY_INT16 )expected, 2), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX16, UNITY_ARRAY_TO_VAL) -#define UNITY_TEST_ASSERT_EACH_EQUAL_HEX32(expected, actual, num_elements, line, message) UnityAssertEqualIntArray(UnityNumToPtr((UNITY_INT)(UNITY_INT32 )expected, 4), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX32, UNITY_ARRAY_TO_VAL) -#define UNITY_TEST_ASSERT_EACH_EQUAL_PTR(expected, actual, num_elements, line, message) UnityAssertEqualIntArray(UnityNumToPtr((UNITY_PTR_TO_INT) expected, sizeof(int*)), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_POINTER, UNITY_ARRAY_TO_VAL) +#define UNITY_TEST_ASSERT_EACH_EQUAL_INT(expected, actual, num_elements, line, message) UnityAssertEqualIntArray(UnityNumToPtr((UNITY_INT) (expected), sizeof(int)), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT, UNITY_ARRAY_TO_VAL) +#define UNITY_TEST_ASSERT_EACH_EQUAL_INT8(expected, actual, num_elements, line, message) UnityAssertEqualIntArray(UnityNumToPtr((UNITY_INT)(UNITY_INT8 )(expected), 1), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT8, UNITY_ARRAY_TO_VAL) +#define UNITY_TEST_ASSERT_EACH_EQUAL_INT16(expected, actual, num_elements, line, message) UnityAssertEqualIntArray(UnityNumToPtr((UNITY_INT)(UNITY_INT16 )(expected), 2), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT16, UNITY_ARRAY_TO_VAL) +#define UNITY_TEST_ASSERT_EACH_EQUAL_INT32(expected, actual, num_elements, line, message) UnityAssertEqualIntArray(UnityNumToPtr((UNITY_INT)(UNITY_INT32 )(expected), 4), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT32, UNITY_ARRAY_TO_VAL) +#define UNITY_TEST_ASSERT_EACH_EQUAL_UINT(expected, actual, num_elements, line, message) UnityAssertEqualIntArray(UnityNumToPtr((UNITY_INT) (expected), sizeof(unsigned int)), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT, UNITY_ARRAY_TO_VAL) +#define UNITY_TEST_ASSERT_EACH_EQUAL_UINT8(expected, actual, num_elements, line, message) UnityAssertEqualIntArray(UnityNumToPtr((UNITY_INT)(UNITY_UINT8 )(expected), 1), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT8, UNITY_ARRAY_TO_VAL) +#define UNITY_TEST_ASSERT_EACH_EQUAL_UINT16(expected, actual, num_elements, line, message) UnityAssertEqualIntArray(UnityNumToPtr((UNITY_INT)(UNITY_UINT16)(expected), 2), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT16, UNITY_ARRAY_TO_VAL) +#define UNITY_TEST_ASSERT_EACH_EQUAL_UINT32(expected, actual, num_elements, line, message) UnityAssertEqualIntArray(UnityNumToPtr((UNITY_INT)(UNITY_UINT32)(expected), 4), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT32, UNITY_ARRAY_TO_VAL) +#define UNITY_TEST_ASSERT_EACH_EQUAL_HEX8(expected, actual, num_elements, line, message) UnityAssertEqualIntArray(UnityNumToPtr((UNITY_INT)(UNITY_INT8 )(expected), 1), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX8, UNITY_ARRAY_TO_VAL) +#define UNITY_TEST_ASSERT_EACH_EQUAL_HEX16(expected, actual, num_elements, line, message) UnityAssertEqualIntArray(UnityNumToPtr((UNITY_INT)(UNITY_INT16 )(expected), 2), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX16, UNITY_ARRAY_TO_VAL) +#define UNITY_TEST_ASSERT_EACH_EQUAL_HEX32(expected, actual, num_elements, line, message) UnityAssertEqualIntArray(UnityNumToPtr((UNITY_INT)(UNITY_INT32 )(expected), 4), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX32, UNITY_ARRAY_TO_VAL) +#define UNITY_TEST_ASSERT_EACH_EQUAL_PTR(expected, actual, num_elements, line, message) UnityAssertEqualIntArray(UnityNumToPtr((UNITY_PTR_TO_INT) (expected), sizeof(int*)), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_POINTER, UNITY_ARRAY_TO_VAL) #define UNITY_TEST_ASSERT_EACH_EQUAL_STRING(expected, actual, num_elements, line, message) UnityAssertEqualStringArray((UNITY_INTERNAL_PTR)(expected), (const char**)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_ARRAY_TO_VAL) #define UNITY_TEST_ASSERT_EACH_EQUAL_MEMORY(expected, actual, len, num_elements, line, message) UnityAssertEqualMemory((UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(len), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_ARRAY_TO_VAL) From dc9c7a7b4b316cb4e0605283f1ce981d7d6dfac9 Mon Sep 17 00:00:00 2001 From: Fabian Zahn Date: Sun, 11 Feb 2018 13:02:26 +0100 Subject: [PATCH 039/454] Removed leading whitespace --- auto/parse_output.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/auto/parse_output.rb b/auto/parse_output.rb index f3e076f2..0f9de4d8 100644 --- a/auto/parse_output.rb +++ b/auto/parse_output.rb @@ -123,7 +123,7 @@ def test_failed(array) return unless @xml_out @array_list.push ' ' - @array_list.push ' ' + reason + '' + @array_list.push ' ' + reason + '' @array_list.push ' ' end From 4dfb512a275370a1ad2f9328d25946d9a650d4c6 Mon Sep 17 00:00:00 2001 From: Fabian Zahn Date: Mon, 12 Feb 2018 06:44:26 +0100 Subject: [PATCH 040/454] Added ".to_s" to the test suite name (explicit type conversion) --- auto/parse_output.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/auto/parse_output.rb b/auto/parse_output.rb index 0f9de4d8..b5132a01 100644 --- a/auto/parse_output.rb +++ b/auto/parse_output.rb @@ -208,7 +208,7 @@ def process(name) return unless @xml_out - heading = '' + heading = '' @array_list.insert(0, heading) write_xml_output end From 8efa8ffc621e0986d82a77a63362a96af7d5ca59 Mon Sep 17 00:00:00 2001 From: Fabian Zahn Date: Sun, 18 Feb 2018 13:57:34 +0100 Subject: [PATCH 041/454] Removed UNITY_OMIT_OUTPUT_FLUSH_HEADER_DECLARATION to simplify the behaviour --- docs/UnityConfigurationGuide.md | 8 +++----- src/unity_internals.h | 32 ++++++++++++++++---------------- 2 files changed, 19 insertions(+), 21 deletions(-) diff --git a/docs/UnityConfigurationGuide.md b/docs/UnityConfigurationGuide.md index 96e5358d..1b698287 100644 --- a/docs/UnityConfigurationGuide.md +++ b/docs/UnityConfigurationGuide.md @@ -248,7 +248,8 @@ _Example:_ Say you are forced to run your test suite on an embedded processor with no `stdout` option. You decide to route your test result output to a custom serial `RS232_putc()` function you wrote like thus: - + #include "RS232_header.h" + ... #define UNITY_OUTPUT_CHAR(a) RS232_putc(a) #define UNITY_OUTPUT_START() RS232_config(115200,1,8,0) #define UNITY_OUTPUT_FLUSH() RS232_flush() @@ -256,10 +257,7 @@ Say you are forced to run your test suite on an embedded processor with no _Note:_ `UNITY_OUTPUT_FLUSH()` can be set to the standard out flush function simply by -specifying `UNITY_USE_FLUSH_STDOUT`. No other defines are required. If you -specify a custom flush function instead with `UNITY_OUTPUT_FLUSH` directly, it -will declare an instance of your function by default. If you want to disable -this behavior, add `UNITY_OMIT_OUTPUT_FLUSH_HEADER_DECLARATION`. +specifying `UNITY_USE_FLUSH_STDOUT`. No other defines are required. ##### `UNITY_WEAK_ATTRIBUTE` diff --git a/src/unity_internals.h b/src/unity_internals.h index 3ba6fae7..415a29b0 100644 --- a/src/unity_internals.h +++ b/src/unity_internals.h @@ -241,30 +241,30 @@ typedef UNITY_FLOAT_TYPE UNITY_FLOAT; * Output Method: stdout (DEFAULT) *-------------------------------------------------------*/ #ifndef UNITY_OUTPUT_CHAR -/* Default to using putchar, which is defined in stdio.h */ -#include -#define UNITY_OUTPUT_CHAR(a) (void)putchar(a) + /* Default to using putchar, which is defined in stdio.h */ + #include + #define UNITY_OUTPUT_CHAR(a) (void)putchar(a) #else /* If defined as something else, make sure we declare it here so it's ready for use */ #ifdef UNITY_OUTPUT_CHAR_HEADER_DECLARATION -extern void UNITY_OUTPUT_CHAR_HEADER_DECLARATION; + extern void UNITY_OUTPUT_CHAR_HEADER_DECLARATION; #endif #endif #ifndef UNITY_OUTPUT_FLUSH -#ifdef UNITY_USE_FLUSH_STDOUT -/* We want to use the stdout flush utility */ -#include -#define UNITY_OUTPUT_FLUSH() (void)fflush(stdout) -#else -/* We've specified nothing, therefore flush should just be ignored */ -#define UNITY_OUTPUT_FLUSH() -#endif + #ifdef UNITY_USE_FLUSH_STDOUT + /* We want to use the stdout flush utility */ + #include + #define UNITY_OUTPUT_FLUSH() (void)fflush(stdout) + #else + /* We've specified nothing, therefore flush should just be ignored */ + #define UNITY_OUTPUT_FLUSH() + #endif #else -/* We've defined flush as something else, so make sure we declare it here so it's ready for use */ -#ifdef UNITY_OUTPUT_FLUSH_HEADER_DECLARATION -extern void UNITY_OMIT_OUTPUT_FLUSH_HEADER_DECLARATION; -#endif + /* If defined as something else, make sure we declare it here so it's ready for use */ + #ifdef UNITY_OUTPUT_FLUSH_HEADER_DECLARATION + extern void UNITY_OUTPUT_FLUSH_HEADER_DECLARATION; + #endif #endif #ifndef UNITY_OUTPUT_FLUSH From fe950b9fa3466077b96fa93031f8f8fe1e2875bd Mon Sep 17 00:00:00 2001 From: Fabian Zahn Date: Sun, 18 Feb 2018 14:11:19 +0100 Subject: [PATCH 042/454] Makefile preparations --- test/Makefile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/Makefile b/test/Makefile index c2710f1f..f37b9ea6 100644 --- a/test/Makefile +++ b/test/Makefile @@ -15,6 +15,8 @@ CFLAGS += -Wbad-function-cast -Wcast-qual -Wold-style-definition -Wshadow -Wstri CFLAGS += $(DEBUG) DEFINES = -D UNITY_OUTPUT_CHAR=putcharSpy DEFINES += -D UNITY_OUTPUT_CHAR_HEADER_DECLARATION=putcharSpy\(int\) +#DEFINES += -D UNITY_OUTPUT_FLUSH=flushSpy +#DEFINES += -D UNITY_OUTPUT_FLUSH_HEADER_DECLARATION=flushSpy\(void\) DEFINES += $(UNITY_SUPPORT_64) $(UNITY_INCLUDE_DOUBLE) UNITY_SUPPORT_64 = -D UNITY_SUPPORT_64 UNITY_INCLUDE_DOUBLE = -D UNITY_INCLUDE_DOUBLE From 456759296b407189c0b48b02dd3c479b4ddff4f3 Mon Sep 17 00:00:00 2001 From: Fabian Zahn Date: Sun, 18 Feb 2018 14:23:26 +0100 Subject: [PATCH 043/454] Added flushSpy --- test/Makefile | 4 ++-- test/testdata/testRunnerGenerator.c | 5 ++++- test/testdata/testRunnerGeneratorSmall.c | 5 ++++- test/testdata/testRunnerGeneratorWithMocks.c | 5 ++++- test/tests/testparameterized.c | 7 +++++-- test/tests/testunity.c | 8 ++++++++ 6 files changed, 27 insertions(+), 7 deletions(-) diff --git a/test/Makefile b/test/Makefile index f37b9ea6..89ece81d 100644 --- a/test/Makefile +++ b/test/Makefile @@ -15,8 +15,8 @@ CFLAGS += -Wbad-function-cast -Wcast-qual -Wold-style-definition -Wshadow -Wstri CFLAGS += $(DEBUG) DEFINES = -D UNITY_OUTPUT_CHAR=putcharSpy DEFINES += -D UNITY_OUTPUT_CHAR_HEADER_DECLARATION=putcharSpy\(int\) -#DEFINES += -D UNITY_OUTPUT_FLUSH=flushSpy -#DEFINES += -D UNITY_OUTPUT_FLUSH_HEADER_DECLARATION=flushSpy\(void\) +DEFINES += -D UNITY_OUTPUT_FLUSH=flushSpy +DEFINES += -D UNITY_OUTPUT_FLUSH_HEADER_DECLARATION=flushSpy\(void\) DEFINES += $(UNITY_SUPPORT_64) $(UNITY_INCLUDE_DOUBLE) UNITY_SUPPORT_64 = -D UNITY_SUPPORT_64 UNITY_INCLUDE_DOUBLE = -D UNITY_INCLUDE_DOUBLE diff --git a/test/testdata/testRunnerGenerator.c b/test/testdata/testRunnerGenerator.c index e036dd96..7a4d63b8 100644 --- a/test/testdata/testRunnerGenerator.c +++ b/test/testdata/testRunnerGenerator.c @@ -21,7 +21,10 @@ /* Support for Meta Test Rig */ #define TEST_CASE(a) -void putcharSpy(int c) { (void)putchar(c);} // include passthrough for linking tests + +/* Include Passthroughs for Linking Tests */ +void putcharSpy(int c) { (void)putchar(c);} +void flushSpy(int c) {} /* Global Variables Used During These Tests */ int CounterSetup = 0; diff --git a/test/testdata/testRunnerGeneratorSmall.c b/test/testdata/testRunnerGeneratorSmall.c index c6837494..a8707fb6 100644 --- a/test/testdata/testRunnerGeneratorSmall.c +++ b/test/testdata/testRunnerGeneratorSmall.c @@ -13,7 +13,10 @@ TEST_FILE("some_file.c") /* Support for Meta Test Rig */ #define TEST_CASE(a) -void putcharSpy(int c) { (void)putchar(c);} // include passthrough for linking tests + +/* Include Passthroughs for Linking Tests */ +void putcharSpy(int c) { (void)putchar(c);} +void flushSpy(int c) {} /* Global Variables Used During These Tests */ int CounterSetup = 0; diff --git a/test/testdata/testRunnerGeneratorWithMocks.c b/test/testdata/testRunnerGeneratorWithMocks.c index 7eb0b671..a7d622d5 100644 --- a/test/testdata/testRunnerGeneratorWithMocks.c +++ b/test/testdata/testRunnerGeneratorWithMocks.c @@ -22,7 +22,10 @@ /* Support for Meta Test Rig */ #define TEST_CASE(a) -void putcharSpy(int c) { (void)putchar(c);} // include passthrough for linking tests + +/* Include Passthroughs for Linking Tests */ +void putcharSpy(int c) { (void)putchar(c);} +void flushSpy(int c) {} /* Global Variables Used During These Tests */ int CounterSetup = 0; diff --git a/test/tests/testparameterized.c b/test/tests/testparameterized.c index aa6d1732..7be7f2bd 100644 --- a/test/tests/testparameterized.c +++ b/test/tests/testparameterized.c @@ -8,10 +8,13 @@ #include #include "unity.h" -void putcharSpy(int c) { (void)putchar(c);} // include passthrough for linking tests - +/* Support for Meta Test Rig */ #define TEST_CASE(...) +/* Include Passthroughs for Linking Tests */ +void putcharSpy(int c) { (void)putchar(c);} +void flushSpy(int c) {} + #define EXPECT_ABORT_BEGIN \ if (TEST_PROTECT()) \ { diff --git a/test/tests/testunity.c b/test/tests/testunity.c index af06647f..1884cbb1 100644 --- a/test/tests/testunity.c +++ b/test/tests/testunity.c @@ -3335,6 +3335,14 @@ void putcharSpy(int c) #endif } +#if 0 +void flushSpy(void) +{ + static unsigned int calls = 0; + calls++; // count every call +} +#endif + void testFailureCountIncrementsAndIsReturnedAtEnd(void) { UNITY_UINT savedFailures = Unity.TestFailures; From 25804f3ab4bec897019333022bbb44472f5b6534 Mon Sep 17 00:00:00 2001 From: Fabian Zahn Date: Sun, 18 Feb 2018 14:46:42 +0100 Subject: [PATCH 044/454] Added flushSpy and the respective helper functions --- test/tests/testunity.c | 31 +++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/test/tests/testunity.c b/test/tests/testunity.c index 1884cbb1..34969902 100644 --- a/test/tests/testunity.c +++ b/test/tests/testunity.c @@ -54,6 +54,10 @@ void startPutcharSpy(void); void endPutcharSpy(void); char* getBufferPutcharSpy(void); +void startFlushSpy(void); +void endFlushSpy(void); +unsigned int getFlushSpyCalls(void); + static int SetToOneToFailInTearDown; static int SetToOneMeanWeAlreadyCheckedThisGuy; @@ -3335,13 +3339,18 @@ void putcharSpy(int c) #endif } -#if 0 +/* This is for counting the calls to the flushSpy */ +static int flushSpyEnabled; +static unsigned int flushSpyCalls = 0; + +void startFlushSpy(void) { flushSpyCalls = 0; flushSpyEnabled = 1; } +void endFlushSpy(void) { flushSpyCalls = 0; flushSpyEnabled = 0; } +unsigned int getFlushSpyCalls(void) { return flushSpyCalls; } + void flushSpy(void) { - static unsigned int calls = 0; - calls++; // count every call + if (flushSpyEnabled){ flushSpyCalls++; } } -#endif void testFailureCountIncrementsAndIsReturnedAtEnd(void) { @@ -3420,6 +3429,20 @@ void testPrintNumbersUnsigned32(void) #endif } + +/* This is for counting the calls to the flushSpy */ +static int flushSpyEnabled; +static unsigned int flushSpyCalls = 0; + +void startFlushSpy(void) { flushSpyCalls = 0; flushSpyEnabled = 1; } +void endFlushSpy(void) { flushSpyCalls = 0; flushSpyEnabled = 0; } +unsigned int getFlushSpyCalls(void) { return flushSpyCalls; } + +void flushSpy(void) +{ + if (flushSpyEnabled){ flushSpyCalls++; } +} + // ===================== THESE TEST WILL RUN IF YOUR CONFIG INCLUDES 64 BIT SUPPORT ================== void testPrintNumbersInt64(void) From 37271e8a131d12bb73bfdf2a1fc5612d3f142b03 Mon Sep 17 00:00:00 2001 From: Fabian Zahn Date: Sun, 18 Feb 2018 14:53:39 +0100 Subject: [PATCH 045/454] Fixed copy and paste error --- test/tests/testunity.c | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/test/tests/testunity.c b/test/tests/testunity.c index 34969902..0f74bc50 100644 --- a/test/tests/testunity.c +++ b/test/tests/testunity.c @@ -3430,19 +3430,6 @@ void testPrintNumbersUnsigned32(void) } -/* This is for counting the calls to the flushSpy */ -static int flushSpyEnabled; -static unsigned int flushSpyCalls = 0; - -void startFlushSpy(void) { flushSpyCalls = 0; flushSpyEnabled = 1; } -void endFlushSpy(void) { flushSpyCalls = 0; flushSpyEnabled = 0; } -unsigned int getFlushSpyCalls(void) { return flushSpyCalls; } - -void flushSpy(void) -{ - if (flushSpyEnabled){ flushSpyCalls++; } -} - // ===================== THESE TEST WILL RUN IF YOUR CONFIG INCLUDES 64 BIT SUPPORT ================== void testPrintNumbersInt64(void) From 5f67ac6ab2b3adf37f9cf62bda1eb3efe1383f88 Mon Sep 17 00:00:00 2001 From: Fabian Zahn Date: Sun, 18 Feb 2018 16:32:04 +0100 Subject: [PATCH 046/454] Fixed copy and paste error, changed the signature from: void flushSpy(int c) {} to: void flushSpy(void) {} --- test/testdata/testRunnerGenerator.c | 2 +- test/testdata/testRunnerGeneratorSmall.c | 2 +- test/testdata/testRunnerGeneratorWithMocks.c | 2 +- test/tests/testparameterized.c | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/test/testdata/testRunnerGenerator.c b/test/testdata/testRunnerGenerator.c index 7a4d63b8..62989a0d 100644 --- a/test/testdata/testRunnerGenerator.c +++ b/test/testdata/testRunnerGenerator.c @@ -24,7 +24,7 @@ /* Include Passthroughs for Linking Tests */ void putcharSpy(int c) { (void)putchar(c);} -void flushSpy(int c) {} +void flushSpy(void) {} /* Global Variables Used During These Tests */ int CounterSetup = 0; diff --git a/test/testdata/testRunnerGeneratorSmall.c b/test/testdata/testRunnerGeneratorSmall.c index a8707fb6..c8aaf747 100644 --- a/test/testdata/testRunnerGeneratorSmall.c +++ b/test/testdata/testRunnerGeneratorSmall.c @@ -16,7 +16,7 @@ TEST_FILE("some_file.c") /* Include Passthroughs for Linking Tests */ void putcharSpy(int c) { (void)putchar(c);} -void flushSpy(int c) {} +void flushSpy(void) {} /* Global Variables Used During These Tests */ int CounterSetup = 0; diff --git a/test/testdata/testRunnerGeneratorWithMocks.c b/test/testdata/testRunnerGeneratorWithMocks.c index a7d622d5..4aacbf9a 100644 --- a/test/testdata/testRunnerGeneratorWithMocks.c +++ b/test/testdata/testRunnerGeneratorWithMocks.c @@ -25,7 +25,7 @@ /* Include Passthroughs for Linking Tests */ void putcharSpy(int c) { (void)putchar(c);} -void flushSpy(int c) {} +void flushSpy(void) {} /* Global Variables Used During These Tests */ int CounterSetup = 0; diff --git a/test/tests/testparameterized.c b/test/tests/testparameterized.c index 7be7f2bd..136cd2f4 100644 --- a/test/tests/testparameterized.c +++ b/test/tests/testparameterized.c @@ -13,7 +13,7 @@ /* Include Passthroughs for Linking Tests */ void putcharSpy(int c) { (void)putchar(c);} -void flushSpy(int c) {} +void flushSpy(void) {} #define EXPECT_ABORT_BEGIN \ if (TEST_PROTECT()) \ From 2480a6124e6ace123041bbdaa14b0f42bcefafe1 Mon Sep 17 00:00:00 2001 From: Fabian Zahn Date: Sun, 18 Feb 2018 17:08:49 +0100 Subject: [PATCH 047/454] Added unit test for the call to flush --- test/tests/testunity.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/test/tests/testunity.c b/test/tests/testunity.c index 0f74bc50..5258b6e8 100644 --- a/test/tests/testunity.c +++ b/test/tests/testunity.c @@ -56,7 +56,7 @@ char* getBufferPutcharSpy(void); void startFlushSpy(void); void endFlushSpy(void); -unsigned int getFlushSpyCalls(void); +int getFlushSpyCalls(void); static int SetToOneToFailInTearDown; static int SetToOneMeanWeAlreadyCheckedThisGuy; @@ -3341,11 +3341,11 @@ void putcharSpy(int c) /* This is for counting the calls to the flushSpy */ static int flushSpyEnabled; -static unsigned int flushSpyCalls = 0; +static int flushSpyCalls = 0; void startFlushSpy(void) { flushSpyCalls = 0; flushSpyEnabled = 1; } void endFlushSpy(void) { flushSpyCalls = 0; flushSpyEnabled = 0; } -unsigned int getFlushSpyCalls(void) { return flushSpyCalls; } +int getFlushSpyCalls(void) { return flushSpyCalls; } void flushSpy(void) { @@ -3357,9 +3357,13 @@ void testFailureCountIncrementsAndIsReturnedAtEnd(void) UNITY_UINT savedFailures = Unity.TestFailures; Unity.CurrentTestFailed = 1; startPutcharSpy(); // Suppress output + startFlushSpy(); + TEST_ASSERT_EQUAL(0, getFlushSpyCalls()); UnityConcludeTest(); endPutcharSpy(); TEST_ASSERT_EQUAL(savedFailures + 1, Unity.TestFailures); + TEST_ASSERT_EQUAL(1, getFlushSpyCalls()); + endFlushSpy(); startPutcharSpy(); // Suppress output int failures = UnityEnd(); From 436a46d8efea78c23b6fe163214a30ff2bb10f51 Mon Sep 17 00:00:00 2001 From: Fabian Zahn Date: Sun, 18 Feb 2018 17:43:08 +0100 Subject: [PATCH 048/454] Got the tests running --- test/Makefile | 1 + test/tests/testunity.c | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/test/Makefile b/test/Makefile index 89ece81d..f3981bd1 100644 --- a/test/Makefile +++ b/test/Makefile @@ -17,6 +17,7 @@ DEFINES = -D UNITY_OUTPUT_CHAR=putcharSpy DEFINES += -D UNITY_OUTPUT_CHAR_HEADER_DECLARATION=putcharSpy\(int\) DEFINES += -D UNITY_OUTPUT_FLUSH=flushSpy DEFINES += -D UNITY_OUTPUT_FLUSH_HEADER_DECLARATION=flushSpy\(void\) +DEFINES += -D USING_FLUSH_SPY DEFINES += $(UNITY_SUPPORT_64) $(UNITY_INCLUDE_DOUBLE) UNITY_SUPPORT_64 = -D UNITY_SUPPORT_64 UNITY_INCLUDE_DOUBLE = -D UNITY_INCLUDE_DOUBLE diff --git a/test/tests/testunity.c b/test/tests/testunity.c index 5258b6e8..e05b2ba0 100644 --- a/test/tests/testunity.c +++ b/test/tests/testunity.c @@ -3357,13 +3357,17 @@ void testFailureCountIncrementsAndIsReturnedAtEnd(void) UNITY_UINT savedFailures = Unity.TestFailures; Unity.CurrentTestFailed = 1; startPutcharSpy(); // Suppress output +#ifdef USING_FLUSH_SPY startFlushSpy(); TEST_ASSERT_EQUAL(0, getFlushSpyCalls()); +#endif UnityConcludeTest(); endPutcharSpy(); TEST_ASSERT_EQUAL(savedFailures + 1, Unity.TestFailures); +#ifdef USING_FLUSH_SPY TEST_ASSERT_EQUAL(1, getFlushSpyCalls()); endFlushSpy(); +#endif startPutcharSpy(); // Suppress output int failures = UnityEnd(); From e038ae2ade1e9436322a92a043d3a5abf3866a6e Mon Sep 17 00:00:00 2001 From: Fabian Zahn Date: Sun, 18 Feb 2018 18:44:58 +0100 Subject: [PATCH 049/454] Refactored the test evaluation of the flushSpy --- test/Makefile | 1 - test/tests/testunity.c | 8 ++++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/test/Makefile b/test/Makefile index f3981bd1..89ece81d 100644 --- a/test/Makefile +++ b/test/Makefile @@ -17,7 +17,6 @@ DEFINES = -D UNITY_OUTPUT_CHAR=putcharSpy DEFINES += -D UNITY_OUTPUT_CHAR_HEADER_DECLARATION=putcharSpy\(int\) DEFINES += -D UNITY_OUTPUT_FLUSH=flushSpy DEFINES += -D UNITY_OUTPUT_FLUSH_HEADER_DECLARATION=flushSpy\(void\) -DEFINES += -D USING_FLUSH_SPY DEFINES += $(UNITY_SUPPORT_64) $(UNITY_INCLUDE_DOUBLE) UNITY_SUPPORT_64 = -D UNITY_SUPPORT_64 UNITY_INCLUDE_DOUBLE = -D UNITY_INCLUDE_DOUBLE diff --git a/test/tests/testunity.c b/test/tests/testunity.c index e05b2ba0..95c82804 100644 --- a/test/tests/testunity.c +++ b/test/tests/testunity.c @@ -3357,17 +3357,17 @@ void testFailureCountIncrementsAndIsReturnedAtEnd(void) UNITY_UINT savedFailures = Unity.TestFailures; Unity.CurrentTestFailed = 1; startPutcharSpy(); // Suppress output -#ifdef USING_FLUSH_SPY startFlushSpy(); TEST_ASSERT_EQUAL(0, getFlushSpyCalls()); -#endif UnityConcludeTest(); endPutcharSpy(); TEST_ASSERT_EQUAL(savedFailures + 1, Unity.TestFailures); -#ifdef USING_FLUSH_SPY +#if defined(UNITY_OUTPUT_FLUSH) && defined(UNITY_OUTPUT_FLUSH_HEADER_DECLARATION) TEST_ASSERT_EQUAL(1, getFlushSpyCalls()); - endFlushSpy(); +#else + TEST_ASSERT_EQUAL(0, getFlushSpyCalls()); #endif + endFlushSpy(); startPutcharSpy(); // Suppress output int failures = UnityEnd(); From 0937bf728caed9503e2b5aae306036f9bb68e088 Mon Sep 17 00:00:00 2001 From: Fabian Zahn Date: Thu, 22 Feb 2018 19:55:40 +0100 Subject: [PATCH 050/454] - Removed member variable @test_flag - Fixed stdout output if fixture is active - Refactored the state manipulation of @test_suite and moved it completely into test_suite_verify() --- auto/parse_output.rb | 61 ++++++++++++++++++++++++-------------------- 1 file changed, 34 insertions(+), 27 deletions(-) diff --git a/auto/parse_output.rb b/auto/parse_output.rb index b5132a01..33d1f719 100644 --- a/auto/parse_output.rb +++ b/auto/parse_output.rb @@ -18,11 +18,11 @@ class ParseOutput def initialize - @test_flag = false @xml_out = false @array_list = false + @class_name = 0 + @test_suite = nil @total_tests = false - @class_index = false end # Set the flag to indicate if there will be an XML output file or not @@ -30,7 +30,7 @@ def set_xml_output @xml_out = true end - # if write our output to XML + # If write our output to XML def write_xml_output output = File.open('report.xml', 'w') output << "\n" @@ -40,12 +40,10 @@ def write_xml_output output << "\n" end - # This function will try and determine when the suite is changed. This is + # This function will try and determine when the suite is changed. This is # is the name that gets added to the classname parameter. def test_suite_verify(test_suite_name) - return if @test_flag - @test_flag = true # Split the path name test_name = if @class_name == 1 test_suite_name.split('\\') # Windows @@ -53,10 +51,15 @@ def test_suite_verify(test_suite_name) test_suite_name.split('/') # Unix based end - # Remove the extension - base_name = test_name[test_name.size - 1].split('.') - @test_suite = 'test.' + base_name[0] - printf "New Test: %s\n", @test_suite + # Remove the extension and extract the base_name + base_name = test_name[test_name.size - 1].split('.')[0] + + # Is this a new test suite? + if base_name.to_s != @test_suite.to_s + @test_suite = base_name + printf "New Test: %s\n", @test_suite + end + end # Test was flagged as having passed so format the output @@ -77,7 +80,8 @@ def test_passed_unity_fixture(array) test_suite = array[0].sub('TEST(', '') test_suite = test_suite.sub(',', '') test_name = array[1].sub(')', '') - + test_suite_verify(array[@class_name]) + printf "%-40s PASS\n", test_name return unless @xml_out @array_list.push ' ' @@ -88,16 +92,21 @@ def test_ignored(array) last_item = array.length - 1 test_name = array[last_item - 2] reason = array[last_item].chomp.lstrip - test_suite_verify(array[@class_name]) - printf "%-40s IGNORED\n", test_name + class_name = array[@class_name] if test_name.start_with? 'TEST(' array2 = test_name.split(' ') - @test_suite = array2[0].sub('TEST(', '') - @test_suite = @test_suite.sub(',', '') + + test_suite = array2[0].sub('TEST(', '') + test_suite = test_suite.sub(',', '') + class_name = test_suite + test_name = array2[1].sub(')', '') end + test_suite_verify(class_name) + printf "%-40s IGNORED\n", test_name + return unless @xml_out @array_list.push ' ' @@ -110,16 +119,21 @@ def test_failed(array) last_item = array.length - 1 test_name = array[last_item - 2] reason = array[last_item].chomp.lstrip + ' at line: ' + array[last_item - 3] - test_suite_verify(array[@class_name]) - printf "%-40s FAILED\n", test_name + class_name = array[@class_name] if test_name.start_with? 'TEST(' array2 = test_name.split(' ') - @test_suite = array2[0].sub('TEST(', '') - @test_suite = @test_suite.sub(',', '') + + test_suite = array2[0].sub('TEST(', '') + test_suite = test_suite.sub(',', '') + class_name = test_suite + test_name = array2[1].sub(')', '') end + test_suite_verify(class_name) + printf "%-40s FAILED\n", test_name + return unless @xml_out @array_list.push ' ' @@ -144,7 +158,6 @@ def detect_os # Main function used to parse the file that was captured. def process(name) - @test_flag = false @array_list = [] detect_os @@ -189,13 +202,7 @@ def process(name) test_passed_unity_fixture(line_array) test_pass += 1 end - # If none of the keywords are found there are no more tests for this suite so clear - # the test flag - else - @test_flag = false end - else - @test_flag = false end end puts '' @@ -208,7 +215,7 @@ def process(name) return unless @xml_out - heading = '' + heading = '' @array_list.insert(0, heading) write_xml_output end From ea51e2b35cb10fad3cbdc101142543daf96ea80f Mon Sep 17 00:00:00 2001 From: Fabian Zahn Date: Thu, 22 Feb 2018 21:21:32 +0100 Subject: [PATCH 051/454] Refactored the os specific settings, it is now possible to convert both styles on every system (and even mixed) --- auto/parse_output.rb | 36 +++++++++++++++--------------------- 1 file changed, 15 insertions(+), 21 deletions(-) diff --git a/auto/parse_output.rb b/auto/parse_output.rb index 33d1f719..02adbdc4 100644 --- a/auto/parse_output.rb +++ b/auto/parse_output.rb @@ -23,6 +23,7 @@ def initialize @class_name = 0 @test_suite = nil @total_tests = false + @path_delim = nil end # Set the flag to indicate if there will be an XML output file or not @@ -45,11 +46,7 @@ def write_xml_output def test_suite_verify(test_suite_name) # Split the path name - test_name = if @class_name == 1 - test_suite_name.split('\\') # Windows - else - test_suite_name.split('/') # Unix based - end + test_name = test_suite_name.split(@path_delim) # Remove the extension and extract the base_name base_name = test_name[test_name.size - 1].split('.')[0] @@ -59,7 +56,6 @@ def test_suite_verify(test_suite_name) @test_suite = base_name printf "New Test: %s\n", @test_suite end - end # Test was flagged as having passed so format the output @@ -141,27 +137,24 @@ def test_failed(array) @array_list.push ' ' end - # Figure out what OS we are running on. For now we are assuming if it's not Windows it must - # be Unix based. - def detect_os - os = RUBY_PLATFORM.split('-') - @class_name = if os.size == 2 - if os[1] == 'mingw32' - 1 - else - 0 - end - else - 0 - end + # Adjusts the os specific members according to the current path style + # (Windows or Unix based) + def set_os_specifics(line) + if line.include? '\\' + # Windows X:\Y\Z + @class_name = 1 + @path_delim = '\\' + else + # Unix Based /X/Y/Z + @class_name = 0 + @path_delim = '/' + end end # Main function used to parse the file that was captured. def process(name) @array_list = [] - detect_os - puts 'Parsing file: ' + name test_pass = 0 @@ -177,6 +170,7 @@ def process(name) # /.c:115:test_tc5100_initCanVoidPtrs:PASS # # where path is different on Unix vs Windows devices (Windows leads with a drive letter) + set_os_specifics(line) line_array = line.split(':') # If we were able to split the line then we can look to see if any of our target words From 7a437665864a99320e88606bb6e901a64bc763da Mon Sep 17 00:00:00 2001 From: Fabian Zahn Date: Thu, 22 Feb 2018 21:33:11 +0100 Subject: [PATCH 052/454] - Fixed whitespaces and formatting - Added more expressiveness to the code - Fixed some of the rubocop hints --- auto/parse_output.rb | 37 +++++++++++++++++++------------------ 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/auto/parse_output.rb b/auto/parse_output.rb index 02adbdc4..edb69fbb 100644 --- a/auto/parse_output.rb +++ b/auto/parse_output.rb @@ -1,21 +1,22 @@ #============================================================ # Author: John Theofanopoulos -# A simple parser. Takes the output files generated during the build process and -# extracts information relating to the tests. +# A simple parser. Takes the output files generated during the +# build process and extracts information relating to the tests. # # Notes: # To capture an output file under VS builds use the following: # devenv [build instructions] > Output.txt & type Output.txt # -# To capture an output file under GCC/Linux builds use the following: +# To capture an output file under Linux builds use the following: # make | tee Output.txt # # To use this parser use the following command # ruby parseOutput.rb [options] [file] # options: -xml : produce a JUnit compatible XML file -# file : file to scan for results +# file: file to scan for results #============================================================ +# Parser class for handling the input file class ParseOutput def initialize @xml_out = false @@ -26,12 +27,12 @@ def initialize @path_delim = nil end - # Set the flag to indicate if there will be an XML output file or not + # Set the flag to indicate if there will be an XML output file or not def set_xml_output @xml_out = true end - # If write our output to XML + # If write our output to XML def write_xml_output output = File.open('report.xml', 'w') output << "\n" @@ -44,18 +45,17 @@ def write_xml_output # This function will try and determine when the suite is changed. This is # is the name that gets added to the classname parameter. def test_suite_verify(test_suite_name) - # Split the path name test_name = test_suite_name.split(@path_delim) # Remove the extension and extract the base_name base_name = test_name[test_name.size - 1].split('.')[0] - # Is this a new test suite? - if base_name.to_s != @test_suite.to_s - @test_suite = base_name - printf "New Test: %s\n", @test_suite - end + # Return if the test suite hasn't changed + return unless base_name.to_s != @test_suite.to_s + + @test_suite = base_name + printf "New Test: %s\n", @test_suite end # Test was flagged as having passed so format the output @@ -78,6 +78,7 @@ def test_passed_unity_fixture(array) test_name = array[1].sub(')', '') test_suite_verify(array[@class_name]) printf "%-40s PASS\n", test_name + return unless @xml_out @array_list.push ' ' @@ -152,10 +153,10 @@ def set_os_specifics(line) end # Main function used to parse the file that was captured. - def process(name) + def process(file_name) @array_list = [] - puts 'Parsing file: ' + name + puts 'Parsing file: ' + file_name test_pass = 0 test_fail = 0 @@ -163,7 +164,7 @@ def process(name) puts '' puts '=================== RESULTS =====================' puts '' - File.open(name).each do |line| + File.open(file_name).each do |line| # Typical test lines look like this: # /.c:36:test_tc1000_opsys:FAIL: Expected 1 Was 0 # /.c:112:test_tc5004_initCanChannel:IGNORE: Not Yet Implemented @@ -219,11 +220,11 @@ def process(name) parse_my_file = ParseOutput.new if ARGV.size >= 1 - ARGV.each do |a| - if a == '-xml' + ARGV.each do |arg| + if arg == '-xml' parse_my_file.set_xml_output else - parse_my_file.process(a) + parse_my_file.process(arg) break end end From 1994bf9d68d792ece33f2750d62bb7c361f12ed8 Mon Sep 17 00:00:00 2001 From: Fabian Zahn Date: Mon, 26 Feb 2018 22:13:29 +0100 Subject: [PATCH 053/454] Fixed unity fixture output and added methods for each of the different outputs. Added documentation. Fixed some whitespaces. Refactored class_name to class_name_idx (expressiveness). Refactored the xml output to methods (extensibility). --- auto/parse_output.rb | 210 +++++++++++++++++++++++++++++-------------- 1 file changed, 142 insertions(+), 68 deletions(-) diff --git a/auto/parse_output.rb b/auto/parse_output.rb index edb69fbb..cbafd7c9 100644 --- a/auto/parse_output.rb +++ b/auto/parse_output.rb @@ -1,30 +1,38 @@ #============================================================ -# Author: John Theofanopoulos -# A simple parser. Takes the output files generated during the +# Author: John Theofanopoulos +# A simple parser. Takes the output files generated during the # build process and extracts information relating to the tests. # # Notes: # To capture an output file under VS builds use the following: -# devenv [build instructions] > Output.txt & type Output.txt +# devenv [build instructions] > Output.txt & type Output.txt # # To capture an output file under Linux builds use the following: # make | tee Output.txt # # To use this parser use the following command # ruby parseOutput.rb [options] [file] -# options: -xml : produce a JUnit compatible XML file -# file: file to scan for results +# options: -xml : produce a JUnit compatible XML file +# file: file to scan for results #============================================================ # Parser class for handling the input file class ParseOutput def initialize + # internal data + @class_name_idx = 0 + @path_delim = nil + + # xml output related @xml_out = false @array_list = false - @class_name = 0 + + # current suite name and statistics @test_suite = nil - @total_tests = false - @path_delim = nil + @total_tests = 0 + @test_passed = 0 + @test_failed = 0 + @test_ignored = 0 end # Set the flag to indicate if there will be an XML output file or not @@ -39,7 +47,34 @@ def write_xml_output @array_list.each do |item| output << item << "\n" end - output << "\n" + end + + # Pushes the suite info as xml to the array list, which will be written later + def push_xml_output_suite_info + # Insert opening tag at front + heading = '' + @array_list.insert(0, heading) + # Push back the closing tag + @array_list.push '' + end + + # Pushes xml output data to the array list, which will be written later + def push_xml_output_passed(test_name) + @array_list.push ' ' + end + + # Pushes xml output data to the array list, which will be written later + def push_xml_output_failed(test_name, reason) + @array_list.push ' ' + @array_list.push ' ' + reason + '' + @array_list.push ' ' + end + + # Pushes xml output data to the array list, which will be written later + def push_xml_output_ignored(test_name, reason) + @array_list.push ' ' + @array_list.push ' ' + reason + '' + @array_list.push ' ' end # This function will try and determine when the suite is changed. This is @@ -58,38 +93,76 @@ def test_suite_verify(test_suite_name) printf "New Test: %s\n", @test_suite end - # Test was flagged as having passed so format the output - def test_passed(array) - last_item = array.length - 1 - test_name = array[last_item - 1] - test_suite_verify(array[@class_name]) + # Prepares the line for verbose fixture output ("-v") + def prepare_fixture_line(line) + line = line.sub('IGNORE_TEST(', '') + line = line.sub('TEST(', '') + line = line.sub(')', ',') + line = line.chomp + array = line.split(',') + array.map { |x| x.to_s.lstrip.chomp } + end + + # Test was flagged as having passed so format the output. + # This is using the Unity fixture output and not the original Unity output. + def test_passed_unity_fixture(array) + class_name = array[0] + test_name = array[1] + test_suite_verify(class_name) printf "%-40s PASS\n", test_name - return unless @xml_out + push_xml_output_passed(test_name) if @xml_out + end - @array_list.push ' ' + # Test was flagged as having failed so format the output. + # This is using the Unity fixture output and not the original Unity output. + def test_failed_unity_fixture(array) + class_name = array[0] + test_name = array[1] + test_suite_verify(class_name) + reason_array = array[2].split(':') + reason = reason_array[-1].lstrip.chomp + ' at line: ' + reason_array[-4] + + printf "%-40s FAILED\n", test_name + + push_xml_output_failed(test_name, reason) if @xml_out end - # Test was flagged as having passed so format the output. + # Test was flagged as being ignored so format the output. # This is using the Unity fixture output and not the original Unity output. - def test_passed_unity_fixture(array) - test_suite = array[0].sub('TEST(', '') - test_suite = test_suite.sub(',', '') - test_name = array[1].sub(')', '') - test_suite_verify(array[@class_name]) + def test_ignored_unity_fixture(array) + class_name = array[0] + test_name = array[1] + reason = 'No reason given' + if array.size > 2 + reason_array = array[2].split(':') + tmp_reason = reason_array[-1].lstrip.chomp + reason = tmp_reason == 'IGNORE' ? 'No reason given' : tmp_reason + end + test_suite_verify(class_name) + printf "%-40s IGNORED\n", test_name + + push_xml_output_ignored(test_name, reason) if @xml_out + end + + # Test was flagged as having passed so format the output + def test_passed(array) + last_item = array.length - 1 + test_name = array[last_item - 1] + test_suite_verify(array[@class_name_idx]) printf "%-40s PASS\n", test_name return unless @xml_out - @array_list.push ' ' + push_xml_output_passed(test_name) if @xml_out end - # Test was flagged as being ignored so format the output - def test_ignored(array) + # Test was flagged as having failed so format the line + def test_failed(array) last_item = array.length - 1 test_name = array[last_item - 2] - reason = array[last_item].chomp.lstrip - class_name = array[@class_name] + reason = array[last_item].chomp.lstrip + ' at line: ' + array[last_item - 3] + class_name = array[@class_name_idx] if test_name.start_with? 'TEST(' array2 = test_name.split(' ') @@ -102,21 +175,17 @@ def test_ignored(array) end test_suite_verify(class_name) - printf "%-40s IGNORED\n", test_name - - return unless @xml_out + printf "%-40s FAILED\n", test_name - @array_list.push ' ' - @array_list.push ' ' + reason + '' - @array_list.push ' ' + push_xml_output_failed(test_name, reason) if @xml_out end - # Test was flagged as having failed so format the line - def test_failed(array) + # Test was flagged as being ignored so format the output + def test_ignored(array) last_item = array.length - 1 test_name = array[last_item - 2] - reason = array[last_item].chomp.lstrip + ' at line: ' + array[last_item - 3] - class_name = array[@class_name] + reason = array[last_item].chomp.lstrip + class_name = array[@class_name_idx] if test_name.start_with? 'TEST(' array2 = test_name.split(' ') @@ -129,13 +198,9 @@ def test_failed(array) end test_suite_verify(class_name) - printf "%-40s FAILED\n", test_name - - return unless @xml_out + printf "%-40s IGNORED\n", test_name - @array_list.push ' ' - @array_list.push ' ' + reason + '' - @array_list.push ' ' + push_xml_output_ignored(test_name, reason) if @xml_out end # Adjusts the os specific members according to the current path style @@ -143,11 +208,11 @@ def test_failed(array) def set_os_specifics(line) if line.include? '\\' # Windows X:\Y\Z - @class_name = 1 + @class_name_idx = 1 @path_delim = '\\' else # Unix Based /X/Y/Z - @class_name = 0 + @class_name_idx = 0 @path_delim = '/' end end @@ -158,9 +223,9 @@ def process(file_name) puts 'Parsing file: ' + file_name - test_pass = 0 - test_fail = 0 - test_ignore = 0 + @test_passed = 0 + @test_failed = 0 + @test_ignored = 0 puts '' puts '=================== RESULTS =====================' puts '' @@ -175,43 +240,52 @@ def process(file_name) line_array = line.split(':') # If we were able to split the line then we can look to see if any of our target words - # were found. Case is important. - if (line_array.size >= 4) || (line.start_with? 'TEST(') - # Determine if this test passed - if line.include? ':PASS' + # were found. Case is important. + if (line_array.size >= 4) || (line.start_with? 'TEST(') || (line.start_with? 'IGNORE_TEST(') + + # check if the output is fixture output (with verbose flag "-v") + if (line.start_with? 'TEST(') || (line.start_with? 'IGNORE_TEST(') + line_array = prepare_fixture_line(line) + if line.include? ' PASS' + test_passed_unity_fixture(line_array) + @test_passed += 1 + elsif line.include? 'FAIL' + test_failed_unity_fixture(line_array) + @test_failed += 1 + elsif line.include? 'IGNORE' + test_ignored_unity_fixture(line_array) + @test_ignored += 1 + end + # normal output / fixture output (without verbose "-v") + elsif line.include? ':PASS' test_passed(line_array) - test_pass += 1 + @test_passed += 1 elsif line.include? ':FAIL' test_failed(line_array) - test_fail += 1 + @test_failed += 1 elsif line.include? ':IGNORE:' test_ignored(line_array) - test_ignore += 1 + @test_ignored += 1 elsif line.include? ':IGNORE' line_array.push('No reason given') test_ignored(line_array) - test_ignore += 1 - elsif line.start_with? 'TEST(' - if line.include? ' PASS' - line_array = line.split(' ') - test_passed_unity_fixture(line_array) - test_pass += 1 - end + @test_ignored += 1 end + @total_tests = @test_passed + @test_failed + @test_ignored end end puts '' puts '=================== SUMMARY =====================' puts '' - puts 'Tests Passed : ' + test_pass.to_s - puts 'Tests Failed : ' + test_fail.to_s - puts 'Tests Ignored : ' + test_ignore.to_s - @total_tests = test_pass + test_fail + test_ignore + puts 'Tests Passed : ' + @test_passed.to_s + puts 'Tests Failed : ' + @test_failed.to_s + puts 'Tests Ignored : ' + @test_ignored.to_s return unless @xml_out - heading = '' - @array_list.insert(0, heading) + # push information about the suite + push_xml_output_suite_info + # write xml output file write_xml_output end end From 38e1ee872ccf2989ff873415ce98fd20ba9c2f1a Mon Sep 17 00:00:00 2001 From: Fabian Zahn Date: Tue, 27 Feb 2018 07:23:18 +0100 Subject: [PATCH 054/454] Added some useful documentation which states the output formats that are parseable by this script. --- auto/parse_output.rb | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/auto/parse_output.rb b/auto/parse_output.rb index cbafd7c9..f04508fb 100644 --- a/auto/parse_output.rb +++ b/auto/parse_output.rb @@ -10,6 +10,11 @@ # To capture an output file under Linux builds use the following: # make | tee Output.txt # +# This script can handle the following output formats: +# - normal output (raw unity) +# - fixture output (unity_fixture.h/.c) +# - fixture output with verbose flag set ("-v") +# # To use this parser use the following command # ruby parseOutput.rb [options] [file] # options: -xml : produce a JUnit compatible XML file @@ -230,12 +235,25 @@ def process(file_name) puts '=================== RESULTS =====================' puts '' File.open(file_name).each do |line| - # Typical test lines look like this: + # Typical test lines look like these: + # ---------------------------------------------------- + # 1. normal output: # /.c:36:test_tc1000_opsys:FAIL: Expected 1 Was 0 # /.c:112:test_tc5004_initCanChannel:IGNORE: Not Yet Implemented # /.c:115:test_tc5100_initCanVoidPtrs:PASS # - # where path is different on Unix vs Windows devices (Windows leads with a drive letter) + # 2. fixture output + # /.c:63:TEST(, ):FAIL: Expected 0x00001234 Was 0x00005A5A + # /.c:36:TEST(, ):IGNORE + # Note: "PASS" information won't be generated in this mode + # + # 3. fixture output with verbose information ("-v") + # TEST()/:168::FAIL: Expected 0x8D Was 0x8C + # TEST(, )/:22::IGNORE: This Test Was Ignored On Purpose + # IGNORE_TEST() + # TEST() PASS + # + # Note: Where path is different on Unix vs Windows devices (Windows leads with a drive letter)! set_os_specifics(line) line_array = line.split(':') From ceecf1fae8129662381559686fd9adfe7b12a1cf Mon Sep 17 00:00:00 2001 From: Trond Einar Snekvik Date: Thu, 7 Jun 2018 10:06:39 +0200 Subject: [PATCH 055/454] Add support for :mock_suffix Adds support for :mock_suffix when generating mock setup and teardown functions. Also documents both prefix and suffix in the helper script guide. --- auto/generate_test_runner.rb | 3 ++- docs/UnityHelperScriptsGuide.md | 6 ++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/auto/generate_test_runner.rb b/auto/generate_test_runner.rb index 427c5136..84daa42d 100644 --- a/auto/generate_test_runner.rb +++ b/auto/generate_test_runner.rb @@ -26,6 +26,7 @@ def self.default_options framework: :unity, test_prefix: 'test|spec|should', mock_prefix: 'Mock', + mock_suffix: '', setup_name: 'setUp', teardown_name: 'tearDown', main_name: 'main', # set to :auto to automatically generate each time @@ -148,7 +149,7 @@ def find_mocks(includes) mock_headers = [] includes.each do |include_path| include_file = File.basename(include_path) - mock_headers << include_path if include_file =~ /^#{@options[:mock_prefix]}/i + mock_headers << include_path if include_file =~ /^#{@options[:mock_prefix]}.*#{@options[:mock_suffix]}$/i end mock_headers end diff --git a/docs/UnityHelperScriptsGuide.md b/docs/UnityHelperScriptsGuide.md index 42429900..8b0df1b8 100644 --- a/docs/UnityHelperScriptsGuide.md +++ b/docs/UnityHelperScriptsGuide.md @@ -159,6 +159,12 @@ CMock (see CMock documentation). This generates extra variables required for everything to run smoothly. If you provide the same YAML to the generator as used in CMock's configuration, you've already configured the generator properly. +##### `:mock_prefix` and `:mock_suffix` + +Unity automatically generates calls to Init, Verify and Destroy for every file +included in the main test file that starts with the given mock prefix and ends +with the given mock suffix, file extension not included. By default, Unity +assumes a `Mock` prefix and no suffix. ##### `:plugins` From 40af5e23eb8ff9402ce1d0419ff44513554e1c02 Mon Sep 17 00:00:00 2001 From: Mark VanderVoord Date: Wed, 18 Jul 2018 11:20:29 -0400 Subject: [PATCH 056/454] Update travis to specify valid version of rubocop --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index bd165b1e..5a15f037 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,7 +14,7 @@ before_install: - if [ "$TRAVIS_OS_NAME" == "linux" ]; then sudo apt-get install --assume-yes --quiet gcc-multilib; fi install: - gem install rspec - - gem install rubocop + - gem install rubocop -v 0.57.2 script: - cd test && rake ci - make -s From 2c5d09bf203a88bcbda5da19843437fcfe7b4525 Mon Sep 17 00:00:00 2001 From: Xenoamor Date: Wed, 18 Jul 2018 16:05:10 +0100 Subject: [PATCH 057/454] Flush unity output before a potential longjmp Flush the unity stdout buffer before calling TEST_ABORT(). This is because if TEST_PROTECT() has not previously been called this will cause a segmentation fault and the stdout buffer will fail to print Although the segmentation fault will still occur, the error that caused it will at least be displayed --- src/unity.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/unity.c b/src/unity.c index 136e9d7b..44a80032 100644 --- a/src/unity.c +++ b/src/unity.c @@ -14,8 +14,8 @@ void UNITY_OUTPUT_CHAR(int); #endif /* Helpful macros for us to use here in Assert functions */ -#define UNITY_FAIL_AND_BAIL { Unity.CurrentTestFailed = 1; TEST_ABORT(); } -#define UNITY_IGNORE_AND_BAIL { Unity.CurrentTestIgnored = 1; TEST_ABORT(); } +#define UNITY_FAIL_AND_BAIL { Unity.CurrentTestFailed = 1; UNITY_OUTPUT_FLUSH(); TEST_ABORT(); } +#define UNITY_IGNORE_AND_BAIL { Unity.CurrentTestIgnored = 1; UNITY_OUTPUT_FLUSH(); TEST_ABORT(); } #define RETURN_IF_FAIL_OR_IGNORE if (Unity.CurrentTestFailed || Unity.CurrentTestIgnored) return struct UNITY_STORAGE_T Unity; From ac3cde30f5257c13bffae48676a69d410dcb639f Mon Sep 17 00:00:00 2001 From: Roland Stahn Date: Sat, 21 Jul 2018 16:57:53 +0200 Subject: [PATCH 058/454] Added notes on _MESSAGE assertions (#331) Added notes, why _MESSAGE assertions do not support printf style formatting and how users can work around this limitation (see #331) --- docs/UnityAssertionsReference.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/docs/UnityAssertionsReference.md b/docs/UnityAssertionsReference.md index 2dcf5e3a..d569e765 100644 --- a/docs/UnityAssertionsReference.md +++ b/docs/UnityAssertionsReference.md @@ -104,6 +104,15 @@ becomes messageified like thus... TEST_ASSERT_X_MESSAGE( {modifiers}, {expected}, actual, {size/count}, message ) +Notes: +- The `_MESSAGE` variants intentionally do not support `printf` style formatting + since many embedded projects don't support or avoid `printf` for various reasons. + It is possible to use `sprintf` before the assertion to assemble a complex fail + message, if necessary. +- If you want to output a counter value within an assertion fail message (e.g. from + a loop) , building up an array of results and then using one of the `_ARRAY` + assertions (see below) might be a handy alternative to `sprintf`. + #### TEST_ASSERT_X_ARRAY Variants From 6a1d2e8d44fb256ee47368bdee49ed8eb020ee4d Mon Sep 17 00:00:00 2001 From: Roland Stahn Date: Wed, 25 Jul 2018 22:57:44 +0200 Subject: [PATCH 059/454] Fix LESS_OR_EQUAL_MESSAGE asserts for HEX32/HEX64 Macros TEST_ASSERT_LESS_OR_EQUAL_HEX32_MESSAGE() and TEST_ASSERT_LESS_OR_EQUAL_HEX64_MESSAGE() need to be mapped to UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_HEXnn() instead of UNITY_TEST_ASSERT_SMALLER_THAN_HEXnn() --- src/unity.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/unity.h b/src/unity.h index 32ff0e6d..a0c301d2 100644 --- a/src/unity.h +++ b/src/unity.h @@ -402,8 +402,8 @@ int suiteTearDown(int num_failures); #define TEST_ASSERT_LESS_OR_EQUAL_UINT64_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_UINT64((threshold), (actual), __LINE__, (message)) #define TEST_ASSERT_LESS_OR_EQUAL_HEX8_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_HEX8((threshold), (actual), __LINE__, (message)) #define TEST_ASSERT_LESS_OR_EQUAL_HEX16_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_HEX16((threshold), (actual), __LINE__, (message)) -#define TEST_ASSERT_LESS_OR_EQUAL_HEX32_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_THAN_HEX32((threshold), (actual), __LINE__, (message)) -#define TEST_ASSERT_LESS_OR_EQUAL_HEX64_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_THAN_HEX64((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_LESS_OR_EQUAL_HEX32_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_HEX32((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_LESS_OR_EQUAL_HEX64_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_HEX64((threshold), (actual), __LINE__, (message)) /* Integer Ranges (of all sizes) */ #define TEST_ASSERT_INT_WITHIN_MESSAGE(delta, expected, actual, message) UNITY_TEST_ASSERT_INT_WITHIN((delta), (expected), (actual), __LINE__, (message)) From fb4b13904339b90b51a57b5cca9e6efb4681402d Mon Sep 17 00:00:00 2001 From: elliot Date: Sat, 28 Jul 2018 20:14:00 +0100 Subject: [PATCH 060/454] Fixed UNITY_EXEC_TIME_STOP macro ifdef --- src/unity_internals.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/unity_internals.h b/src/unity_internals.h index 9c0d4ee3..351d9fe6 100644 --- a/src/unity_internals.h +++ b/src/unity_internals.h @@ -307,7 +307,7 @@ typedef UNITY_FLOAT_TYPE UNITY_FLOAT; #endif #endif -#ifndef UNITY_EXEC_TIME_START +#ifndef UNITY_EXEC_TIME_STOP #ifdef UNITY_INCLUDE_EXEC_TIME #define UNITY_EXEC_TIME_STOP() Unity.CurrentTestStopTime = UNITY_CLOCK_MS(); #else From e72dfafd440054ccdf6c8034112e36cd0156c1fb Mon Sep 17 00:00:00 2001 From: Deryew <40446717+Deryew@users.noreply.github.com> Date: Mon, 30 Jul 2018 10:53:02 +0800 Subject: [PATCH 061/454] Fixed some grammar errors on docs Fixed grammar errors and some sentences to make it easier to understand --- docs/ThrowTheSwitchCodingStandard.md | 19 +++++++++---------- docs/UnityAssertionsReference.md | 4 ++-- docs/UnityConfigurationGuide.md | 8 ++++---- docs/UnityGettingStartedGuide.md | 4 ++-- docs/UnityHelperScriptsGuide.md | 4 ++-- 5 files changed, 19 insertions(+), 20 deletions(-) diff --git a/docs/ThrowTheSwitchCodingStandard.md b/docs/ThrowTheSwitchCodingStandard.md index a85adef3..bf4c099b 100644 --- a/docs/ThrowTheSwitchCodingStandard.md +++ b/docs/ThrowTheSwitchCodingStandard.md @@ -1,4 +1,4 @@ -# ThrowTheSwitch.org Coding Standard +# ThrowTheSwitch.org Coding Standard Hi. Welcome to the coding standard for ThrowTheSwitch.org. For the most part, we try to follow these standards to unify our contributors' code into a cohesive @@ -11,7 +11,7 @@ and we'll try to be polite when we notice yours. ## Why Have A Coding Standard? -Being consistent makes code easier to understand. We've made an attempt to keep +Being consistent makes code easier to understand. We've tried to keep our standard simple because we also believe that we can only expect someone to follow something that is understandable. Please do your best. @@ -51,11 +51,11 @@ much as they can, but give the user the power to override it when it's wrong. Let's talk about naming things. Programming is all about naming things. We name files, functions, variables, and so much more. While we're not always going to -find the best name for something, we actually put quite a bit of effort into +find the best name for something, we actually put a bit of effort into finding *What Something WANTS to be Called*™. -When naming things, we more or less follow this hierarchy, the first being the -most important to us (but we do all four whenever possible): +When naming things, we follow this hierarchy, the first being the +most important to us (but we do all four when possible): 1. Readable 2. Descriptive 3. Consistent @@ -74,7 +74,7 @@ abbreviations (sticking to ones we feel are common). We like descriptive names for things, especially functions and variables. Finding the right name for something is an important endeavor. You might notice from poking around our code that this often results in names that are a little -longer than the average. Guilty. We're okay with a tiny bit more typing if it +longer than the average. Guilty. We're okay with a bit more typing if it means our code is easier to understand. There are two exceptions to this rule that we also stick to as religiously as @@ -82,8 +82,7 @@ possible: First, while we realize hungarian notation (and similar systems for encoding type information into variable names) is providing a more descriptive name, we -feel that (for the average developer) it takes away from readability and -therefore is to be avoided. +feel that (for the average developer) it takes away from readability and is to be avoided. Second, loop counters and other local throw-away variables often have a purpose which is obvious. There's no need, therefore, to get carried away with complex @@ -128,7 +127,7 @@ the same. It will only hurt a little. We promise. #### Whitespace Our C-style is to use spaces and to use 4 of them per indent level. It's a nice -power-of-2 number that looks decent on a wide screen. We have no more reason +power-of-2 number that looks decent on a wide-screen. We have no more reason than that. We break that rule when we have lines that wrap (macros or function arguments or whatnot). When that happens, we like to indent further to line things up in nice tidy columns. @@ -200,7 +199,7 @@ that happens, we like to indent further to line things up in nice tidy columns. ## Documentation -Egad. Really? We use markdown and we like pdf files because they can be made to +Egad. Really? We use mark down and we like pdf files because they can be made to look nice while still being portable. Good enough? diff --git a/docs/UnityAssertionsReference.md b/docs/UnityAssertionsReference.md index d569e765..eb855f3c 100644 --- a/docs/UnityAssertionsReference.md +++ b/docs/UnityAssertionsReference.md @@ -80,7 +80,7 @@ marked as an optional parameter because some assertions only need a single "actual" parameter (e.g. null check). "Size/count" refers to string lengths, number of array elements, etc. -Many of Unity's assertions are apparent duplications in that the same data type +Many of Unity's assertions are clear duplications in that the same data type is handled by several assertions. The differences among these are in how failure messages are presented. For instance, a `_HEX` variant of an assertion prints the expected and actual values of that assertion formatted as hexadecimal. @@ -703,7 +703,7 @@ point value. So what happens when it's zero? Zero - even more than other floating point values - can be represented many different ways. It doesn't matter if you have -0 x 20or 0 x 263.It's still zero, right? Luckily, if you +0 x 20 or 0 x 263.It's still zero, right? Luckily, if you subtract these values from each other, they will always produce a difference of zero, which will still fall between 0 plus or minus a delta of 0. So it still works! diff --git a/docs/UnityConfigurationGuide.md b/docs/UnityConfigurationGuide.md index 1b698287..dace20c5 100644 --- a/docs/UnityConfigurationGuide.md +++ b/docs/UnityConfigurationGuide.md @@ -1,4 +1,4 @@ -# Unity Configuration Guide +# Unity Configuration Guide ## C Standards, Compilers and Microcontrollers @@ -19,7 +19,7 @@ definitions. A couple are macros with arguments. They live inside the unity_internals.h header file. We don't necessarily recommend opening that file unless you really need to. That file is proof that a cross-platform library is challenging to build. From a more positive perspective, it is also proof that a -great deal of complexity can be centralized primarily to one place in order to +great deal of complexity can be centralized primarily to one place to provide a more consistent and simple experience elsewhere. @@ -58,7 +58,7 @@ sizes. It starts off by trying to do it automatically. ##### `UNITY_EXCLUDE_STDINT_H` The first thing that Unity does to guess your types is check `stdint.h`. -This file includes defines like `UINT_MAX` that Unity can make use of to +This file includes defines like `UINT_MAX` that Unity can use to learn a lot about your system. It's possible you don't want it to do this (um. why not?) or (more likely) it's possible that your system doesn't support `stdint.h`. If that's the case, you're going to want to define this. @@ -222,7 +222,7 @@ In addition to the options listed above, there are a number of other options which will come in handy to customize Unity's behavior for your specific toolchain. It is possible that you may not need to touch any of these... but certain platforms, particularly those running in simulators, may need to jump -through extra hoops to operate properly. These macros will help in those +through extra hoops to run properly. These macros will help in those situations. diff --git a/docs/UnityGettingStartedGuide.md b/docs/UnityGettingStartedGuide.md index 81d03987..5e4427ce 100644 --- a/docs/UnityGettingStartedGuide.md +++ b/docs/UnityGettingStartedGuide.md @@ -11,7 +11,7 @@ functional. The core Unity test framework is three files: a single C file and a couple header files. These team up to provide functions and macros to make testing easier. -Unity was designed to be cross platform. It works hard to stick with C standards +Unity was designed to be cross-platform. It works hard to stick with C standards while still providing support for the many embedded C compilers that bend the rules. Unity has been used with many compilers, including GCC, IAR, Clang, Green Hills, Microchip, and MS Visual Studio. It's not much work to get it to @@ -149,7 +149,7 @@ int main(void) { } ``` -It's possible that you will require more customization than this, eventually. +It's possible that you will need more customization than this, eventually. For that sort of thing, you're going to want to look at the configuration guide. This should be enough to get you going, though. diff --git a/docs/UnityHelperScriptsGuide.md b/docs/UnityHelperScriptsGuide.md index 8b0df1b8..12d68d30 100644 --- a/docs/UnityHelperScriptsGuide.md +++ b/docs/UnityHelperScriptsGuide.md @@ -3,7 +3,7 @@ ## With a Little Help From Our Friends Sometimes what it takes to be a really efficient C programmer is a little non-C. -The Unity project includes a couple Ruby scripts for making your life just a tad +The Unity project includes a couple of Ruby scripts for making your life just a tad easier. They are completely optional. If you choose to use them, you'll need a copy of Ruby, of course. Just install whatever the latest version is, and it is likely to work. You can find Ruby at [ruby-lang.org](https://ruby-labg.org/). @@ -105,7 +105,7 @@ UnityTestRunnerGenerator.new.run(testfile, runner_name, options) If you have multiple files to generate in a build script (such as a Rakefile), you might want to instantiate a generator object with your options and call it -to generate each runner thereafter. Like thus: +to generate each runner afterwards. Like thus: ```Ruby gen = UnityTestRunnerGenerator.new(options) From 9987824da794ce53ff77137f237dcebec91f3dd6 Mon Sep 17 00:00:00 2001 From: Mark VanderVoord Date: Thu, 9 Aug 2018 08:48:08 -0400 Subject: [PATCH 062/454] Added support to inject "extern C" into runners when generated. --- auto/generate_test_runner.rb | 3 +++ docs/UnityHelperScriptsGuide.md | 6 ++++++ 2 files changed, 9 insertions(+) diff --git a/auto/generate_test_runner.rb b/auto/generate_test_runner.rb index 84daa42d..2f149665 100644 --- a/auto/generate_test_runner.rb +++ b/auto/generate_test_runner.rb @@ -197,9 +197,11 @@ def create_externs(output, tests, _mocks) output.puts("\n/*=======External Functions This Runner Calls=====*/") output.puts("extern void #{@options[:setup_name]}(void);") output.puts("extern void #{@options[:teardown_name]}(void);") + output.puts("\n#ifdef __cplusplus\nextern \"C\"\n{\n#endif") if @options[:externc] tests.each do |test| output.puts("extern void #{test[:test]}(#{test[:call] || 'void'});") end + output.puts("#ifdef __cplusplus\n}\n#endif") if @options[:externc] output.puts('') end @@ -439,6 +441,7 @@ def create_h_file(output, filename, tests, testfile_includes, used_mocks) ' *.h - header files are added as #includes in runner', ' options:', ' -cexception - include cexception support', + ' -externc - add extern "C" for cpp support', ' --setup_name="" - redefine setUp func name to something else', ' --teardown_name="" - redefine tearDown func name to something else', ' --main_name="" - redefine main func name to something else', diff --git a/docs/UnityHelperScriptsGuide.md b/docs/UnityHelperScriptsGuide.md index 12d68d30..da56db2e 100644 --- a/docs/UnityHelperScriptsGuide.md +++ b/docs/UnityHelperScriptsGuide.md @@ -159,6 +159,12 @@ CMock (see CMock documentation). This generates extra variables required for everything to run smoothly. If you provide the same YAML to the generator as used in CMock's configuration, you've already configured the generator properly. + +##### `:externc` + +This option should be defined if you are mixing C and CPP and want your test +runners to automatically include extern "C" support when they are generated. + ##### `:mock_prefix` and `:mock_suffix` Unity automatically generates calls to Init, Verify and Destroy for every file From 020a531e4b1969178c9bd1c002fef443b35225fb Mon Sep 17 00:00:00 2001 From: Kyle Krueger Date: Fri, 7 Sep 2018 14:33:51 +0200 Subject: [PATCH 063/454] add link to test_runner file --- docs/UnityGettingStartedGuide.md | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/docs/UnityGettingStartedGuide.md b/docs/UnityGettingStartedGuide.md index 5e4427ce..b774ae47 100644 --- a/docs/UnityGettingStartedGuide.md +++ b/docs/UnityGettingStartedGuide.md @@ -114,10 +114,10 @@ call. Remembering to add each test to the main function can get to be tedious. If you enjoy using helper scripts in your build process, you might consider making use -of our handy generate_test_runner.rb script. This will create the main function -and all the calls for you, assuming that you have followed the suggested naming -conventions. In this case, there is no need for you to include the main function -in your test file at all. +of our handy [generate_test_runner.rb](../auto/generate_test_runner.rb) script. +This will create the main function and all the calls for you, assuming that you +have followed the suggested naming conventions. In this case, there is no need +for you to include the main function in your test file at all. When you're done, your test file will look something like this: @@ -141,6 +141,7 @@ void test_function_should_doAlsoDoBlah(void) { //more test stuff } +// not needed when using generate_test_runner.rb int main(void) { UNITY_BEGIN(); RUN_TEST(test_function_should_doBlahAndBlah); From ea5e51ffccf8ac0b3c09db2b5b85a27e66bcb76d Mon Sep 17 00:00:00 2001 From: Kyle Krueger Date: Fri, 7 Sep 2018 14:46:20 +0200 Subject: [PATCH 064/454] move some details from main readme to docs, and link to getting started --- README.md | 50 +++------------------------- docs/UnityGettingStartedGuide.md | 57 ++++++++++++++++++++++++++++++++ 2 files changed, 62 insertions(+), 45 deletions(-) diff --git a/README.md b/README.md index ec73b4a1..cb37731c 100644 --- a/README.md +++ b/README.md @@ -4,54 +4,14 @@ Unity Test API [![Unity Build Status](https://api.travis-ci.org/ThrowTheSwitch/Unity.png?branch=master)](https://travis-ci.org/ThrowTheSwitch/Unity) __Copyright (c) 2007 - 2017 Unity Project by Mike Karlesky, Mark VanderVoord, and Greg Williams__ -Running Tests -------------- - - RUN_TEST(func, linenum) - -Each Test is run within the macro `RUN_TEST`. This macro performs necessary setup before the test is called and handles cleanup and result tabulation afterwards. - -Ignoring Tests --------------- - -There are times when a test is incomplete or not valid for some reason. At these times, TEST_IGNORE can be called. Control will immediately be returned to the caller of the test, and no failures will be returned. - - TEST_IGNORE() - -Ignore this test and return immediately - - TEST_IGNORE_MESSAGE (message) - -Ignore this test and return immediately. Output a message stating why the test was ignored. - -Aborting Tests --------------- - -There are times when a test will contain an infinite loop on error conditions, or there may be reason to escape from the test early without executing the rest of the test. A pair of macros support this functionality in Unity. The first `TEST_PROTECT` sets up the feature, and handles emergency abort cases. `TEST_ABORT` can then be used at any time within the tests to return to the last `TEST_PROTECT` call. - - TEST_PROTECT() - -Setup and Catch macro - - TEST_ABORT() - -Abort Test macro - -Example: - - main() - { - if (TEST_PROTECT()) - { - MyTest(); - } - } - -If MyTest calls `TEST_ABORT`, program control will immediately return to `TEST_PROTECT` with a return value of zero. - +Getting Started +=============== +The [docs](docs/) folder contains a [getting started guide](docs/UnityGettingStartedGuide.md) +and much more tips about using Unity. Unity Assertion Summary ======================= +For the full list, see [UnityAssertionsReference.md](docs/UnityAssertionsReference.md). Basic Validity Tests -------------------- diff --git a/docs/UnityGettingStartedGuide.md b/docs/UnityGettingStartedGuide.md index b774ae47..eb7041d8 100644 --- a/docs/UnityGettingStartedGuide.md +++ b/docs/UnityGettingStartedGuide.md @@ -154,6 +154,63 @@ It's possible that you will need more customization than this, eventually. For that sort of thing, you're going to want to look at the configuration guide. This should be enough to get you going, though. +### Running Test Functions +When writing your own `main()` functions, for a test-runner. There are two ways +to execute the test. + +The classic variant +``` c +RUN_TEST(func, linenum) +``` +or its simpler replacement that starts at the beginning of the function. +``` c +RUN_TEST(func) +``` +These macros perform the necessary setup before the test is called and +handles cleanup and result tabulation afterwards. + +### Ignoring Test Functions +There are times when a test is incomplete or not valid for some reason. +At these times, TEST_IGNORE can be called. Control will immediately be +returned to the caller of the test, and no failures will be returned. +This is useful when your test runners are automatically generated. + +``` c +TEST_IGNORE() +``` + +Ignore this test and return immediately + +``` c +TEST_IGNORE_MESSAGE (message) +``` + +Ignore this test and return immediately. Output a message stating why the test was ignored. + +### Aborting Tests +There are times when a test will contain an infinite loop on error conditions, or there may be reason to escape from the test early without executing the rest of the test. A pair of macros support this functionality in Unity. The first `TEST_PROTECT` sets up the feature, and handles emergency abort cases. `TEST_ABORT` can then be used at any time within the tests to return to the last `TEST_PROTECT` call. + + TEST_PROTECT() + +Setup and Catch macro + + TEST_ABORT() + +Abort Test macro + +Example: + + main() + { + if (TEST_PROTECT()) + { + MyTest(); + } + } + +If MyTest calls `TEST_ABORT`, program control will immediately return to `TEST_PROTECT` with a return value of zero. + + ## How to Build and Run A Test File From f60ab920c918519f30c32403f494aca5fec5a489 Mon Sep 17 00:00:00 2001 From: Kyle Krueger Date: Mon, 10 Sep 2018 10:38:55 +0200 Subject: [PATCH 065/454] switch hardcoded string to reference existing value --- examples/example_3/target_gcc_32.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/example_3/target_gcc_32.yml b/examples/example_3/target_gcc_32.yml index f155508c..8e772b03 100644 --- a/examples/example_3/target_gcc_32.yml +++ b/examples/example_3/target_gcc_32.yml @@ -15,7 +15,7 @@ compiler: includes: prefix: '-I' items: - - 'src/' + - *source_path - '../../src/' - *unit_tests_path defines: From c64cc7d4f41555b33cd47a9f478f6e92ea3189f2 Mon Sep 17 00:00:00 2001 From: Kyle Krueger Date: Mon, 10 Sep 2018 10:51:14 +0200 Subject: [PATCH 066/454] fix new references --- examples/example_3/target_gcc_32.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/examples/example_3/target_gcc_32.yml b/examples/example_3/target_gcc_32.yml index 8e772b03..124e6742 100644 --- a/examples/example_3/target_gcc_32.yml +++ b/examples/example_3/target_gcc_32.yml @@ -1,8 +1,9 @@ # Copied from ~Unity/targets/gcc_32.yml unity_root: &unity_root '../..' +unity_source: &unity_source '../../src' compiler: path: gcc - source_path: 'src/' + source_path: &source_path 'src/' unit_tests_path: &unit_tests_path 'test/' build_path: &build_path 'build/' options: @@ -15,8 +16,8 @@ compiler: includes: prefix: '-I' items: - - *source_path - - '../../src/' + - *source_path + - *unity_source - *unit_tests_path defines: prefix: '-D' From 5d2ef07054c201776520b2c3ada19b819f56253c Mon Sep 17 00:00:00 2001 From: Kyle Krueger Date: Mon, 10 Sep 2018 11:21:41 +0200 Subject: [PATCH 067/454] remove change that slipped in from other project --- examples/example_3/target_gcc_32.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/example_3/target_gcc_32.yml b/examples/example_3/target_gcc_32.yml index 124e6742..4acc294c 100644 --- a/examples/example_3/target_gcc_32.yml +++ b/examples/example_3/target_gcc_32.yml @@ -1,6 +1,6 @@ # Copied from ~Unity/targets/gcc_32.yml unity_root: &unity_root '../..' -unity_source: &unity_source '../../src' +unity_source: &unity_source '../../' compiler: path: gcc source_path: &source_path 'src/' From 8ba35a0e523c0a8efbb6cd4e5eb9f2d2ce4fc0a6 Mon Sep 17 00:00:00 2001 From: Kyle Krueger Date: Mon, 10 Sep 2018 11:26:13 +0200 Subject: [PATCH 068/454] Revert "remove change that slipped in from other project" This reverts commit 5d2ef07054c201776520b2c3ada19b819f56253c. --- examples/example_3/target_gcc_32.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/example_3/target_gcc_32.yml b/examples/example_3/target_gcc_32.yml index 4acc294c..124e6742 100644 --- a/examples/example_3/target_gcc_32.yml +++ b/examples/example_3/target_gcc_32.yml @@ -1,6 +1,6 @@ # Copied from ~Unity/targets/gcc_32.yml unity_root: &unity_root '../..' -unity_source: &unity_source '../../' +unity_source: &unity_source '../../src' compiler: path: gcc source_path: &source_path 'src/' From 56f16460876b34c5b5708909c06957f7761db1c5 Mon Sep 17 00:00:00 2001 From: Kyle Krueger Date: Mon, 10 Sep 2018 15:19:15 +0200 Subject: [PATCH 069/454] add missing trailing slash --- examples/example_3/target_gcc_32.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/example_3/target_gcc_32.yml b/examples/example_3/target_gcc_32.yml index 124e6742..d7568ab8 100644 --- a/examples/example_3/target_gcc_32.yml +++ b/examples/example_3/target_gcc_32.yml @@ -1,6 +1,6 @@ # Copied from ~Unity/targets/gcc_32.yml unity_root: &unity_root '../..' -unity_source: &unity_source '../../src' +unity_source: &unity_source '../../src/' compiler: path: gcc source_path: &source_path 'src/' From e0d52d1a7908a4c0a78c439919c31c71bc2dc8d5 Mon Sep 17 00:00:00 2001 From: Kyle Krueger Date: Wed, 12 Sep 2018 17:46:11 +0200 Subject: [PATCH 070/454] fix uninitialzed value warning --- src/unity.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/unity.c b/src/unity.c index 103bde21..4bad2c21 100644 --- a/src/unity.c +++ b/src/unity.c @@ -283,7 +283,7 @@ void UnityPrintFloat(const UNITY_DOUBLE input_number) int exponent = 0; int decimals, digits; UNITY_INT32 n; - char buf[16]; + char buf[16] = {0}; /* scale up or down by powers of 10 */ while (number < 100000.0f / 1e6f) { number *= 1e6f; exponent -= 6; } From e2e549a22f55465074e9f73c4012473a9a7f56e3 Mon Sep 17 00:00:00 2001 From: Fabian Zahn Date: Sun, 14 Oct 2018 14:08:09 +0200 Subject: [PATCH 071/454] Added include of 'stddef.h' to 'unity_internals.h' if 'UNITY_EXCLUDE_STDDEF_H' is not defined. This adds compiler independent support for the 'NULL' macro. --- docs/UnityConfigurationGuide.md | 12 ++++++++++++ src/unity_internals.h | 4 ++++ 2 files changed, 16 insertions(+) diff --git a/docs/UnityConfigurationGuide.md b/docs/UnityConfigurationGuide.md index dace20c5..b88eeee9 100644 --- a/docs/UnityConfigurationGuide.md +++ b/docs/UnityConfigurationGuide.md @@ -215,6 +215,18 @@ Guide. _Example:_ #define UNITY_FLOAT_PRECISION 0.001f +### Miscellaneous + +##### `UNITY_EXCLUDE_STDDEF_H` + +Unity uses the `NULL` macro, which defines the value of a null pointer constant, +defined in `stddef.h` by default. If you want to provide +your own macro for this, you should exclude the `stddef.h` header file by adding this +define to your configuration. + +_Example:_ + #define UNITY_EXCLUDE_STDDEF_H + ### Toolset Customization diff --git a/src/unity_internals.h b/src/unity_internals.h index 351d9fe6..4c55ef89 100644 --- a/src/unity_internals.h +++ b/src/unity_internals.h @@ -19,6 +19,10 @@ #include #endif +#ifndef UNITY_EXCLUDE_STDDEF_H +#include +#endif + /* Unity Attempts to Auto-Detect Integer Types * Attempt 1: UINT_MAX, ULONG_MAX in , or default to 32 bits * Attempt 2: UINTPTR_MAX in , or default to same size as long From 7cc3cf478bfae76b516f245ac3e5ff12f09f3ef4 Mon Sep 17 00:00:00 2001 From: Levin Messing Date: Thu, 18 Oct 2018 23:55:38 +0200 Subject: [PATCH 072/454] fixed compile error UNITY_PRINT_EXEC_TIME() --- src/unity_internals.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/unity_internals.h b/src/unity_internals.h index 4c55ef89..7249fc79 100644 --- a/src/unity_internals.h +++ b/src/unity_internals.h @@ -323,7 +323,7 @@ typedef UNITY_FLOAT_TYPE UNITY_FLOAT; #ifdef UNITY_INCLUDE_EXEC_TIME #define UNITY_PRINT_EXEC_TIME() \ UnityPrint(" (");\ - UNITY_COUNTER_TYPE execTimeMs = (Unity.CurrentTestStopTime - Unity.CurrentTestStartTime); + UNITY_COUNTER_TYPE execTimeMs = (Unity.CurrentTestStopTime - Unity.CurrentTestStartTime);\ UnityPrintNumberUnsigned(execTimeMs);\ UnityPrint(" ms)"); #else From 01cbce870a55037cc808235b71e83d29ef1417ae Mon Sep 17 00:00:00 2001 From: Filip Michalak Date: Mon, 22 Oct 2018 15:32:22 +0200 Subject: [PATCH 073/454] Changed some text issues --- README.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index ec73b4a1..abddd4c5 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ Running Tests RUN_TEST(func, linenum) -Each Test is run within the macro `RUN_TEST`. This macro performs necessary setup before the test is called and handles cleanup and result tabulation afterwards. +Each Test is run within the macro `RUN_TEST`. This macro performs necessary setup before the test is called and handles cleanup and result tabulation afterwards. Ignoring Tests -------------- @@ -75,7 +75,7 @@ Another way of calling `TEST_ASSERT_FALSE` TEST_FAIL() TEST_FAIL_MESSAGE(message) -This test is automatically marked as a failure. The message is output stating why. +This test is automatically marked as a failure. The message is output stating why. Numerical Assertions: Integers ------------------------------ @@ -87,7 +87,7 @@ Numerical Assertions: Integers TEST_ASSERT_EQUAL_INT64(expected, actual) Compare two integers for equality and display errors as signed integers. A cast will be performed -to your natural integer size so often this can just be used. When you need to specify the exact size, +to your natural integer size so often this can just be used. When you need to specify the exact size, like when comparing arrays, you can use a specific version: TEST_ASSERT_EQUAL_UINT(expected, actual) @@ -96,7 +96,7 @@ like when comparing arrays, you can use a specific version: TEST_ASSERT_EQUAL_UINT32(expected, actual) TEST_ASSERT_EQUAL_UINT64(expected, actual) -Compare two integers for equality and display errors as unsigned integers. Like INT, there are +Compare two integers for equality and display errors as unsigned integers. Like INT, there are variants for different sizes also. TEST_ASSERT_EQUAL_HEX(expected, actual) @@ -105,7 +105,7 @@ variants for different sizes also. TEST_ASSERT_EQUAL_HEX32(expected, actual) TEST_ASSERT_EQUAL_HEX64(expected, actual) -Compares two integers for equality and display errors as hexadecimal. Like the other integer comparisons, +Compares two integers for equality and display errors as hexadecimal. Like the other integer comparisons, you can specify the size... here the size will also effect how many nibbles are shown (for example, `HEX16` will show 4 nibbles). @@ -115,7 +115,7 @@ Another way of calling TEST_ASSERT_EQUAL_INT TEST_ASSERT_INT_WITHIN(delta, expected, actual) -Asserts that the actual value is within plus or minus delta of the expected value. This also comes in +Asserts that the actual value is within plus or minus delta of the expected value. This also comes in size specific variants. @@ -199,12 +199,12 @@ Compare two null-terminate strings. Fail if any character is different or if th TEST_ASSERT_EQUAL_STRING_LEN_MESSAGE(expected, actual, len, message) -Compare two strings. Fail if any character is different, stop comparing after len characters. Output a custom message on failure. +Compare two strings. Fail if any character is different, stop comparing after len characters. Output a custom message on failure. Pointer Assertions ------------------ -Most pointer operations can be performed by simply using the integer comparisons above. However, a couple of special cases are added for clarity. +Most pointer operations can be performed by simply using the integer comparisons above. However, a couple of special cases are added for clarity. TEST_ASSERT_NULL(pointer) From e84cb29acc0e01e22728bc6bf093329b67710588 Mon Sep 17 00:00:00 2001 From: Fabian Zahn Date: Sat, 27 Oct 2018 11:24:29 +0200 Subject: [PATCH 074/454] Fixed an "array index out of bounds violation" in the examples (regarding issue #360). --- examples/example_1/src/ProductionCode.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/example_1/src/ProductionCode.c b/examples/example_1/src/ProductionCode.c index d039c3e8..db128e5b 100644 --- a/examples/example_1/src/ProductionCode.c +++ b/examples/example_1/src/ProductionCode.c @@ -4,14 +4,14 @@ int Counter = 0; int NumbersToFind[9] = { 0, 34, 55, 66, 32, 11, 1, 77, 888 }; /* some obnoxious array to search that is 1-based indexing instead of 0. */ -/* This function is supposed to search through NumbersToFind and find a particular number. - * If it finds it, the index is returned. Otherwise 0 is returned which sorta makes sense since - * NumbersToFind is indexed from 1. Unfortunately it's broken +/* This function is supposed to search through NumbersToFind and find a particular number. + * If it finds it, the index is returned. Otherwise 0 is returned which sorta makes sense since + * NumbersToFind is indexed from 1. Unfortunately it's broken * (and should therefore be caught by our tests) */ int FindFunction_WhichIsBroken(int NumberToFind) { int i = 0; - while (i <= 8) /* Notice I should have been in braces */ + while (i < 8) /* Notice I should have been in braces */ i++; if (NumbersToFind[i] == NumberToFind) /* Yikes! I'm getting run after the loop finishes instead of during it! */ return i; From b4ab81bbe994adfe1aaf401196deddf999c67250 Mon Sep 17 00:00:00 2001 From: Fabian Zahn Date: Sat, 27 Oct 2018 16:00:52 +0200 Subject: [PATCH 075/454] Added first working implementation. --- src/unity.c | 158 ++++++++++++++++++++++++++++++++++++------ src/unity_internals.h | 9 +++ 2 files changed, 144 insertions(+), 23 deletions(-) diff --git a/src/unity.c b/src/unity.c index 103bde21..ea50b316 100644 --- a/src/unity.c +++ b/src/unity.c @@ -67,6 +67,57 @@ static const char UnityStrDetail2Name[] = " " UNITY_DETAIL2_NAME " "; * Pretty Printers & Test Result Output Handlers *-----------------------------------------------*/ +/*-----------------------------------------------*/ +/* Local helper function to print characters. */ +static void UnityPrintChar(const char* pch) +{ + /* printable characters plus CR & LF are printed */ + if ((*pch <= 126) && (*pch >= 32)) + { + UNITY_OUTPUT_CHAR(*pch); + } + /* write escaped carriage returns */ + else if (*pch == 13) + { + UNITY_OUTPUT_CHAR('\\'); + UNITY_OUTPUT_CHAR('r'); + } + /* write escaped line feeds */ + else if (*pch == 10) + { + UNITY_OUTPUT_CHAR('\\'); + UNITY_OUTPUT_CHAR('n'); + } + /* unprintable characters are shown as codes */ + else + { + UNITY_OUTPUT_CHAR('\\'); + UNITY_OUTPUT_CHAR('x'); + UnityPrintNumberHex((UNITY_UINT)*pch, 2); + } +} + +/*-----------------------------------------------*/ +#ifdef UNITY_OUTPUT_COLOR +static UNITY_UINT UnityPrintAnsiEscapeString(const char* string) +{ + const char* pch = string; + UNITY_UINT count = 0; + + while (*pch && *pch != 'm') + { + UNITY_OUTPUT_CHAR(*pch); + pch++; + count++; + } + UNITY_OUTPUT_CHAR('m'); + count++; + + return count; +} +#endif + +/*-----------------------------------------------*/ void UnityPrint(const char* string) { const char* pch = string; @@ -75,47 +126,108 @@ void UnityPrint(const char* string) { while (*pch) { - /* printable characters plus CR & LF are printed */ - if ((*pch <= 126) && (*pch >= 32)) - { - UNITY_OUTPUT_CHAR(*pch); - } - /* write escaped carriage returns */ - else if (*pch == 13) +#ifdef UNITY_OUTPUT_COLOR + /* print ANSI escape code */ + if (*pch == 27 && *(pch + 1) == '[') { - UNITY_OUTPUT_CHAR('\\'); - UNITY_OUTPUT_CHAR('r'); + pch += UnityPrintAnsiEscapeString(pch); + continue; } - /* write escaped line feeds */ - else if (*pch == 10) +#endif + UnityPrintChar(pch); + pch++; + } + } +} + +/*-----------------------------------------------*/ +#ifndef UNITY_EXCLUDE_PRINT_FORMATTED +void UnityPrintFormatted(const char* format, ... ) +{ + const char* pch = format; + va_list va; + va_start(va, format); + + if (pch != NULL) + { + while (*pch) + { + /* format identification character */ + if (*pch == '%') { - UNITY_OUTPUT_CHAR('\\'); - UNITY_OUTPUT_CHAR('n'); + pch++; + + if (pch != NULL) + { + switch (*pch) + { + case 'd': + case 'i': + { + const UNITY_INT number = va_arg(va, UNITY_INT); + UnityPrintNumber(number); + break; + } + case 'u': + { + const UNITY_UINT number = va_arg(va, UNITY_UINT); + UnityPrintNumberUnsigned(number); + break; + } + case 'x': + case 'X': + case 'p': + { + const UNITY_UINT number = va_arg(va, UNITY_UINT); + UNITY_OUTPUT_CHAR('0'); + UNITY_OUTPUT_CHAR('x'); + UnityPrintNumberHex(number, 8); + break; + } + case 'c': + { + const UNITY_INT ch = va_arg(va, UNITY_INT); + UnityPrintChar((const char *)&ch); + break; + } + case 's': + { const char * string = va_arg(va, const char *); + UnityPrint(string); + break; + } + case '%': + default: + UnityPrintChar(pch); + break; + } + } } #ifdef UNITY_OUTPUT_COLOR /* print ANSI escape code */ else if (*pch == 27 && *(pch + 1) == '[') { - while (*pch && *pch != 'm') - { - UNITY_OUTPUT_CHAR(*pch); - pch++; - } - UNITY_OUTPUT_CHAR('m'); + pch += UnityPrintAnsiEscapeString(pch); + continue; } #endif - /* unprintable characters are shown as codes */ + else if (*pch == '\n') + { + UNITY_PRINT_EOL(); + } else { - UNITY_OUTPUT_CHAR('\\'); - UNITY_OUTPUT_CHAR('x'); - UnityPrintNumberHex((UNITY_UINT)*pch, 2); + UnityPrintChar(pch); } + pch++; } } + + va_end(va); } +#endif /* ! UNITY_EXCLUDE_PRINT_FORMATTED */ +/*-----------------------------------------------*/ void UnityPrintLen(const char* string, const UNITY_UINT32 length) { const char* pch = string; diff --git a/src/unity_internals.h b/src/unity_internals.h index 7249fc79..69e08a53 100644 --- a/src/unity_internals.h +++ b/src/unity_internals.h @@ -23,6 +23,10 @@ #include #endif +#ifndef UNITY_EXCLUDE_PRINT_FORMATTED +#include +#endif + /* Unity Attempts to Auto-Detect Integer Types * Attempt 1: UINT_MAX, ULONG_MAX in , or default to 32 bits * Attempt 2: UINTPTR_MAX in , or default to same size as long @@ -489,6 +493,11 @@ void UnityDefaultTestRun(UnityTestFunction Func, const char* FuncName, const int *-------------------------------------------------------*/ void UnityPrint(const char* string); + +#ifndef UNITY_EXCLUDE_PRINT_FORMATTED +void UnityPrintFormatted(const char* format, ... ); +#endif + void UnityPrintLen(const char* string, const UNITY_UINT32 length); void UnityPrintMask(const UNITY_UINT mask, const UNITY_UINT number); void UnityPrintNumberByStyle(const UNITY_INT number, const UNITY_DISPLAY_STYLE_T style); From f1100dd19a12763fcc2a0027ffa54b9958746ed7 Mon Sep 17 00:00:00 2001 From: Fabian Zahn Date: Sat, 27 Oct 2018 18:21:01 +0200 Subject: [PATCH 076/454] Added support for %b (bits / binary), %f (float) and %g (double). --- src/unity.c | 44 ++++++++++++++++++++++++++++++++++--------- src/unity_internals.h | 2 +- 2 files changed, 36 insertions(+), 10 deletions(-) diff --git a/src/unity.c b/src/unity.c index ea50b316..0f71b91b 100644 --- a/src/unity.c +++ b/src/unity.c @@ -164,29 +164,47 @@ void UnityPrintFormatted(const char* format, ... ) case 'd': case 'i': { - const UNITY_INT number = va_arg(va, UNITY_INT); - UnityPrintNumber(number); + const int number = va_arg(va, int); + UnityPrintNumber((UNITY_INT)number); break; } +#ifndef UNITY_EXCLUDE_FLOAT_PRINT + case 'f': + case 'g': + { + const double number = va_arg(va, double); + UnityPrintFloat((UNITY_DOUBLE)number); + break; + } +#endif case 'u': { - const UNITY_UINT number = va_arg(va, UNITY_UINT); - UnityPrintNumberUnsigned(number); + const unsigned int number = va_arg(va, unsigned int); + UnityPrintNumberUnsigned((UNITY_UINT)number); + break; + } + case 'b': + { + const unsigned int number = va_arg(va, unsigned int); + const UNITY_UINT mask = (UNITY_UINT)0 - (UNITY_UINT)1; + UNITY_OUTPUT_CHAR('0'); + UNITY_OUTPUT_CHAR('b'); + UnityPrintMask(mask, (UNITY_UINT)number); break; } case 'x': case 'X': case 'p': { - const UNITY_UINT number = va_arg(va, UNITY_UINT); + const unsigned int number = va_arg(va, unsigned int); UNITY_OUTPUT_CHAR('0'); UNITY_OUTPUT_CHAR('x'); - UnityPrintNumberHex(number, 8); + UnityPrintNumberHex((UNITY_UINT)number, 8); break; } case 'c': { - const UNITY_INT ch = va_arg(va, UNITY_INT); + const int ch = va_arg(va, int); UnityPrintChar((const char *)&ch); break; } @@ -196,9 +214,17 @@ void UnityPrintFormatted(const char* format, ... ) break; } case '%': + { + UnityPrintChar(pch); + break; + } default: - UnityPrintChar(pch); - break; + { + /* print the unknown character */ + UNITY_OUTPUT_CHAR('%'); + UnityPrintChar(pch); + break; + } } } } diff --git a/src/unity_internals.h b/src/unity_internals.h index 69e08a53..9bdd171c 100644 --- a/src/unity_internals.h +++ b/src/unity_internals.h @@ -134,7 +134,7 @@ typedef UNITY_INT32 UNITY_INT; #else - /* 64-bit Support */ + /* 64-bit Support */ #if (UNITY_LONG_WIDTH == 32) typedef unsigned long long UNITY_UINT64; typedef signed long long UNITY_INT64; From be765649f1f4203de9ea79241f6c9f929b056502 Mon Sep 17 00:00:00 2001 From: Kochise Date: Wed, 31 Oct 2018 11:24:37 +0100 Subject: [PATCH 077/454] Some cleanup --- src/unity_internals.h | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/src/unity_internals.h b/src/unity_internals.h index 7249fc79..0d047da6 100644 --- a/src/unity_internals.h +++ b/src/unity_internals.h @@ -359,7 +359,6 @@ typedef UNITY_FLOAT_TYPE UNITY_FLOAT; # undef UNITY_WEAK_PRAGMA #endif - /*------------------------------------------------------- * Internal Structs Needed *-------------------------------------------------------*/ @@ -400,11 +399,13 @@ UNITY_DISPLAY_STYLE_UINT = sizeof(unsigned) + UNITY_DISPLAY_RANGE_UINT, typedef enum { + UNITY_WITHIN = 0, UNITY_EQUAL_TO = 1, UNITY_GREATER_THAN = 2, UNITY_GREATER_OR_EQUAL = 2 + UNITY_EQUAL_TO, UNITY_SMALLER_THAN = 4, - UNITY_SMALLER_OR_EQUAL = 4 + UNITY_EQUAL_TO + UNITY_SMALLER_OR_EQUAL = 4 + UNITY_EQUAL_TO, + UNITY_UNKNOWN } UNITY_COMPARISON_T; #ifndef UNITY_EXCLUDE_FLOAT @@ -425,7 +426,8 @@ typedef enum UNITY_FLOAT_TRAIT typedef enum { UNITY_ARRAY_TO_VAL = 0, - UNITY_ARRAY_TO_ARRAY + UNITY_ARRAY_TO_ARRAY, + UNITY_ARRAY_UNKNOWN } UNITY_FLAGS_T; struct UNITY_STORAGE_T @@ -568,9 +570,9 @@ void UnityAssertNumbersWithin(const UNITY_UINT delta, const UNITY_LINE_TYPE lineNumber, const UNITY_DISPLAY_STYLE_T style); -void UnityFail(const char* msg, const UNITY_LINE_TYPE line); +void UnityFail(const char* message, const UNITY_LINE_TYPE line); -void UnityIgnore(const char* msg, const UNITY_LINE_TYPE line); +void UnityIgnore(const char* message, const UNITY_LINE_TYPE line); #ifndef UNITY_EXCLUDE_FLOAT void UnityAssertFloatsWithin(const UNITY_FLOAT delta, @@ -826,9 +828,9 @@ int UnityTestMatches(void); #define UNITY_TEST_ASSERT_EQUAL_INT64_ARRAY(expected, actual, num_elements, line, message) UnityAssertEqualIntArray((UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT64, UNITY_ARRAY_TO_ARRAY) #define UNITY_TEST_ASSERT_EQUAL_UINT64_ARRAY(expected, actual, num_elements, line, message) UnityAssertEqualIntArray((UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT64, UNITY_ARRAY_TO_ARRAY) #define UNITY_TEST_ASSERT_EQUAL_HEX64_ARRAY(expected, actual, num_elements, line, message) UnityAssertEqualIntArray((UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX64, UNITY_ARRAY_TO_ARRAY) -#define UNITY_TEST_ASSERT_EACH_EQUAL_INT64(expected, actual, num_elements, line, message) UnityAssertEqualIntArray(UnityNumToPtr((UNITY_INT)(UNITY_INT64)expected, 8), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT64, UNITY_ARRAY_TO_VAL) -#define UNITY_TEST_ASSERT_EACH_EQUAL_UINT64(expected, actual, num_elements, line, message) UnityAssertEqualIntArray(UnityNumToPtr((UNITY_INT)(UNITY_UINT64)expected, 8), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT64, UNITY_ARRAY_TO_VAL) -#define UNITY_TEST_ASSERT_EACH_EQUAL_HEX64(expected, actual, num_elements, line, message) UnityAssertEqualIntArray(UnityNumToPtr((UNITY_INT)(UNITY_INT64)expected, 8), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX64, UNITY_ARRAY_TO_VAL) +#define UNITY_TEST_ASSERT_EACH_EQUAL_INT64(expected, actual, num_elements, line, message) UnityAssertEqualIntArray(UnityNumToPtr((UNITY_INT)(UNITY_INT64)(expected), 8), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT64, UNITY_ARRAY_TO_VAL) +#define UNITY_TEST_ASSERT_EACH_EQUAL_UINT64(expected, actual, num_elements, line, message) UnityAssertEqualIntArray(UnityNumToPtr((UNITY_INT)(UNITY_UINT64)(expected), 8), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT64, UNITY_ARRAY_TO_VAL) +#define UNITY_TEST_ASSERT_EACH_EQUAL_HEX64(expected, actual, num_elements, line, message) UnityAssertEqualIntArray(UnityNumToPtr((UNITY_INT)(UNITY_INT64)(expected), 8), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX64, UNITY_ARRAY_TO_VAL) #define UNITY_TEST_ASSERT_INT64_WITHIN(delta, expected, actual, line, message) UnityAssertNumbersWithin((delta), (UNITY_INT)(expected), (UNITY_INT)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT64) #define UNITY_TEST_ASSERT_UINT64_WITHIN(delta, expected, actual, line, message) UnityAssertNumbersWithin((delta), (UNITY_INT)(expected), (UNITY_INT)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT64) #define UNITY_TEST_ASSERT_HEX64_WITHIN(delta, expected, actual, line, message) UnityAssertNumbersWithin((delta), (UNITY_INT)(expected), (UNITY_INT)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX64) @@ -910,10 +912,10 @@ int UnityTestMatches(void); #define UNITY_TEST_ASSERT_DOUBLE_IS_NOT_NAN(actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErrDouble) #define UNITY_TEST_ASSERT_DOUBLE_IS_NOT_DETERMINATE(actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErrDouble) #else -#define UNITY_TEST_ASSERT_DOUBLE_WITHIN(delta, expected, actual, line, message) UnityAssertDoublesWithin((UNITY_DOUBLE)(delta), (UNITY_DOUBLE)(expected), (UNITY_DOUBLE)(actual), (message), (UNITY_LINE_TYPE)line) -#define UNITY_TEST_ASSERT_EQUAL_DOUBLE(expected, actual, line, message) UNITY_TEST_ASSERT_DOUBLE_WITHIN((UNITY_DOUBLE)(expected) * (UNITY_DOUBLE)UNITY_DOUBLE_PRECISION, (UNITY_DOUBLE)expected, (UNITY_DOUBLE)actual, (UNITY_LINE_TYPE)(line), message) -#define UNITY_TEST_ASSERT_EQUAL_DOUBLE_ARRAY(expected, actual, num_elements, line, message) UnityAssertEqualDoubleArray((UNITY_DOUBLE*)(expected), (UNITY_DOUBLE*)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)line, UNITY_ARRAY_TO_ARRAY) -#define UNITY_TEST_ASSERT_EACH_EQUAL_DOUBLE(expected, actual, num_elements, line, message) UnityAssertEqualDoubleArray(UnityDoubleToPtr(expected), (UNITY_DOUBLE*)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)line, UNITY_ARRAY_TO_VAL) +#define UNITY_TEST_ASSERT_DOUBLE_WITHIN(delta, expected, actual, line, message) UnityAssertDoublesWithin((UNITY_DOUBLE)(delta), (UNITY_DOUBLE)(expected), (UNITY_DOUBLE)(actual), (message), (UNITY_LINE_TYPE)(line)) +#define UNITY_TEST_ASSERT_EQUAL_DOUBLE(expected, actual, line, message) UNITY_TEST_ASSERT_DOUBLE_WITHIN((UNITY_DOUBLE)(expected) * (UNITY_DOUBLE)UNITY_DOUBLE_PRECISION, (UNITY_DOUBLE)(expected), (UNITY_DOUBLE)(actual), (UNITY_LINE_TYPE)(line), (message)) +#define UNITY_TEST_ASSERT_EQUAL_DOUBLE_ARRAY(expected, actual, num_elements, line, message) UnityAssertEqualDoubleArray((UNITY_DOUBLE*)(expected), (UNITY_DOUBLE*)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_ARRAY_TO_ARRAY) +#define UNITY_TEST_ASSERT_EACH_EQUAL_DOUBLE(expected, actual, num_elements, line, message) UnityAssertEqualDoubleArray(UnityDoubleToPtr(expected), (UNITY_DOUBLE*)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_ARRAY_TO_VAL) #define UNITY_TEST_ASSERT_DOUBLE_IS_INF(actual, line, message) UnityAssertDoubleSpecial((UNITY_DOUBLE)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_FLOAT_IS_INF) #define UNITY_TEST_ASSERT_DOUBLE_IS_NEG_INF(actual, line, message) UnityAssertDoubleSpecial((UNITY_DOUBLE)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_FLOAT_IS_NEG_INF) #define UNITY_TEST_ASSERT_DOUBLE_IS_NAN(actual, line, message) UnityAssertDoubleSpecial((UNITY_DOUBLE)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_FLOAT_IS_NAN) From 96127581a041a2c76a3a6ae6659499dbb7dc1678 Mon Sep 17 00:00:00 2001 From: Kochise Date: Wed, 31 Oct 2018 11:30:13 +0100 Subject: [PATCH 078/454] Some cleanup --- src/unity.c | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/src/unity.c b/src/unity.c index 103bde21..4efc47fe 100644 --- a/src/unity.c +++ b/src/unity.c @@ -67,6 +67,7 @@ static const char UnityStrDetail2Name[] = " " UNITY_DETAIL2_NAME " "; * Pretty Printers & Test Result Output Handlers *-----------------------------------------------*/ +/*-----------------------------------------------*/ void UnityPrint(const char* string) { const char* pch = string; @@ -116,6 +117,7 @@ void UnityPrint(const char* string) } } +/*-----------------------------------------------*/ void UnityPrintLen(const char* string, const UNITY_UINT32 length) { const char* pch = string; @@ -479,6 +481,7 @@ static void UnityPrintExpectedAndActualStringsLen(const char* expected, * Assertion & Control Helpers *-----------------------------------------------*/ +/*-----------------------------------------------*/ static int UnityIsOneArrayNull(UNITY_INTERNAL_PTR expected, UNITY_INTERNAL_PTR actual, const UNITY_LINE_TYPE lineNumber, @@ -511,6 +514,7 @@ static int UnityIsOneArrayNull(UNITY_INTERNAL_PTR expected, * Assertion Functions *-----------------------------------------------*/ +/*-----------------------------------------------*/ void UnityAssertBits(const UNITY_INT mask, const UNITY_INT expected, const UNITY_INT actual, @@ -704,12 +708,14 @@ void UnityAssertEqualIntArray(UNITY_INTERNAL_PTR expected, UnityPrint(UnityStrDelta) #endif /* UNITY_EXCLUDE_FLOAT_PRINT */ +/*-----------------------------------------------*/ static int UnityFloatsWithin(UNITY_FLOAT delta, UNITY_FLOAT expected, UNITY_FLOAT actual) { UNITY_FLOAT diff; UNITY_FLOAT_OR_DOUBLE_WITHIN(delta, expected, actual, diff); } +/*-----------------------------------------------*/ void UnityAssertEqualFloatArray(UNITY_PTR_ATTRIBUTE const UNITY_FLOAT* expected, UNITY_PTR_ATTRIBUTE const UNITY_FLOAT* actual, const UNITY_UINT32 num_elements, @@ -840,6 +846,7 @@ static int UnityDoublesWithin(UNITY_DOUBLE delta, UNITY_DOUBLE expected, UNITY_D UNITY_FLOAT_OR_DOUBLE_WITHIN(delta, expected, actual, diff); } +/*-----------------------------------------------*/ void UnityAssertEqualDoubleArray(UNITY_PTR_ATTRIBUTE const UNITY_DOUBLE* expected, UNITY_PTR_ATTRIBUTE const UNITY_DOUBLE* actual, const UNITY_UINT32 num_elements, @@ -900,7 +907,6 @@ void UnityAssertDoublesWithin(const UNITY_DOUBLE delta, } /*-----------------------------------------------*/ - void UnityAssertDoubleSpecial(const UNITY_DOUBLE actual, const char* msg, const UNITY_LINE_TYPE lineNumber, @@ -1259,6 +1265,7 @@ UNITY_INTERNAL_PTR UnityNumToPtr(const UNITY_INT num, const UNITY_UINT8 size) } #ifndef UNITY_EXCLUDE_FLOAT +/*-----------------------------------------------*/ UNITY_INTERNAL_PTR UnityFloatToPtr(const float num) { UnityQuickCompare.f = num; @@ -1267,6 +1274,7 @@ UNITY_INTERNAL_PTR UnityFloatToPtr(const float num) #endif #ifndef UNITY_EXCLUDE_DOUBLE +/*-----------------------------------------------*/ UNITY_INTERNAL_PTR UnityDoubleToPtr(const double num) { UnityQuickCompare.d = num; @@ -1278,6 +1286,7 @@ UNITY_INTERNAL_PTR UnityDoubleToPtr(const double num) * Control Functions *-----------------------------------------------*/ +/*-----------------------------------------------*/ void UnityFail(const char* msg, const UNITY_LINE_TYPE line) { RETURN_IF_FAIL_OR_IGNORE; @@ -1402,6 +1411,7 @@ char* UnityOptionIncludeNamed = NULL; char* UnityOptionExcludeNamed = NULL; int UnityVerbosity = 1; +/*-----------------------------------------------*/ int UnityParseOptions(int argc, char** argv) { UnityOptionIncludeNamed = NULL; @@ -1458,6 +1468,7 @@ int UnityParseOptions(int argc, char** argv) return 0; } +/*-----------------------------------------------*/ int IsStringInBiggerString(const char* longstring, const char* shortstring) { const char* lptr = longstring; @@ -1496,9 +1507,11 @@ int IsStringInBiggerString(const char* longstring, const char* shortstring) lptr = lnext; sptr = shortstring; } + return 0; } +/*-----------------------------------------------*/ int UnityStringArgumentMatches(const char* str) { int retval; @@ -1522,24 +1535,33 @@ int UnityStringArgumentMatches(const char* str) if ((ptr2[0] == ':') && (ptr2[1] != 0) && (ptr2[0] != '\'') && (ptr2[0] != '"') && (ptr2[0] != ',')) ptrf = &ptr2[1]; } while ((ptr2[0] != 0) && (ptr2[0] != '\'') && (ptr2[0] != '"') && (ptr2[0] != ',')); + while ((ptr2[0] != 0) && ((ptr2[0] == ':') || (ptr2[0] == '\'') || (ptr2[0] == '"') || (ptr2[0] == ','))) + { ptr2++; + } /* done if complete filename match */ retval = IsStringInBiggerString(Unity.TestFile, ptr1); if (retval == 1) + { return retval; + } /* done if testname match after filename partial match */ if ((retval == 2) && (ptrf != 0)) { if (IsStringInBiggerString(Unity.CurrentTestName, ptrf)) + { return 1; + } } /* done if complete testname match */ if (IsStringInBiggerString(Unity.CurrentTestName, ptr1) == 1) + { return 1; + } ptr1 = ptr2; } @@ -1548,6 +1570,7 @@ int UnityStringArgumentMatches(const char* str) return 0; } +/*-----------------------------------------------*/ int UnityTestMatches(void) { /* Check if this test name matches the included test pattern */ From 50ce8a880af6d27dabab5d3655bbd26a3a16d295 Mon Sep 17 00:00:00 2001 From: Kochise Date: Wed, 31 Oct 2018 11:41:44 +0100 Subject: [PATCH 079/454] Some cleanup --- src/unity.c | 84 ++++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 77 insertions(+), 7 deletions(-) diff --git a/src/unity.c b/src/unity.c index 4efc47fe..732db55a 100644 --- a/src/unity.c +++ b/src/unity.c @@ -214,7 +214,9 @@ void UnityPrintNumberHex(const UNITY_UINT number, const char nibbles_to_print) int nibble; char nibbles = nibbles_to_print; if ((unsigned)nibbles > (2 * sizeof(number))) + { nibbles = 2 * sizeof(number); + } while (nibbles > 0) { @@ -277,9 +279,18 @@ void UnityPrintFloat(const UNITY_DOUBLE input_number) } /* handle zero, NaN, and +/- infinity */ - if (number == 0.0f) UnityPrint("0"); - else if (isnan(number)) UnityPrint("nan"); - else if (isinf(number)) UnityPrint("inf"); + if (number == 0.0f) + { + UnityPrint("0"); + } + else if (isnan(number)) + { + UnityPrint("nan"); + } + else if (isinf(number)) + { + UnityPrint("inf"); + } else { int exponent = 0; @@ -621,9 +632,15 @@ void UnityAssertEqualIntArray(UNITY_INTERNAL_PTR expected, UnityPrintPointlessAndBail(); } - if (expected == actual) return; /* Both are NULL or same pointer */ + if (expected == actual) + { + return; /* Both are NULL or same pointer */ + } + if (UnityIsOneArrayNull(expected, actual, lineNumber, msg)) + { UNITY_FAIL_AND_BAIL; + } while ((elements > 0) && elements--) { @@ -734,9 +751,15 @@ void UnityAssertEqualFloatArray(UNITY_PTR_ATTRIBUTE const UNITY_FLOAT* expected, UnityPrintPointlessAndBail(); } - if (expected == actual) return; /* Both are NULL or same pointer */ + if (expected == actual) + { + return; /* Both are NULL or same pointer */ + } + if (UnityIsOneArrayNull((UNITY_INTERNAL_PTR)expected, (UNITY_INTERNAL_PTR)actual, lineNumber, msg)) + { UNITY_FAIL_AND_BAIL; + } while (elements--) { @@ -821,14 +844,18 @@ void UnityAssertFloatSpecial(const UNITY_FLOAT actual, UnityTestResultsFailBegin(lineNumber); UnityPrint(UnityStrExpected); if (!should_be_trait) + { UnityPrint(UnityStrNot); + } UnityPrint(trait_names[trait_index]); UnityPrint(UnityStrWas); #ifndef UNITY_EXCLUDE_FLOAT_PRINT UnityPrintFloat((UNITY_DOUBLE)actual); #else if (should_be_trait) + { UnityPrint(UnityStrNot); + } UnityPrint(trait_names[trait_index]); #endif UnityAddMsgIfSpecified(msg); @@ -865,9 +892,15 @@ void UnityAssertEqualDoubleArray(UNITY_PTR_ATTRIBUTE const UNITY_DOUBLE* expecte UnityPrintPointlessAndBail(); } - if (expected == actual) return; /* Both are NULL or same pointer */ + if (expected == actual) + { + return; /* Both are NULL or same pointer */ + } + if (UnityIsOneArrayNull((UNITY_INTERNAL_PTR)expected, (UNITY_INTERNAL_PTR)actual, lineNumber, msg)) + { UNITY_FAIL_AND_BAIL; + } while (elements--) { @@ -951,14 +984,18 @@ void UnityAssertDoubleSpecial(const UNITY_DOUBLE actual, UnityTestResultsFailBegin(lineNumber); UnityPrint(UnityStrExpected); if (!should_be_trait) + { UnityPrint(UnityStrNot); + } UnityPrint(trait_names[trait_index]); UnityPrint(UnityStrWas); #ifndef UNITY_EXCLUDE_FLOAT_PRINT UnityPrintFloat(actual); #else if (should_be_trait) + { UnityPrint(UnityStrNot); + } UnityPrint(trait_names[trait_index]); #endif UnityAddMsgIfSpecified(msg); @@ -981,16 +1018,24 @@ void UnityAssertNumbersWithin(const UNITY_UINT delta, if ((style & UNITY_DISPLAY_RANGE_INT) == UNITY_DISPLAY_RANGE_INT) { if (actual > expected) + { Unity.CurrentTestFailed = (UNITY_UINT)((UNITY_UINT)(actual - expected) > delta); + } else + { Unity.CurrentTestFailed = (UNITY_UINT)((UNITY_UINT)(expected - actual) > delta); + } } else { if ((UNITY_UINT)actual > (UNITY_UINT)expected) + { Unity.CurrentTestFailed = (UNITY_UINT)((UNITY_UINT)(actual - expected) > delta); + } else + { Unity.CurrentTestFailed = (UNITY_UINT)((UNITY_UINT)(expected - actual) > delta); + } } if (Unity.CurrentTestFailed) @@ -1186,9 +1231,15 @@ void UnityAssertEqualMemory(UNITY_INTERNAL_PTR expected, UnityPrintPointlessAndBail(); } - if (expected == actual) return; /* Both are NULL or same pointer */ + if (expected == actual) + { + return; /* Both are NULL or same pointer */ + } + if (UnityIsOneArrayNull(expected, actual, lineNumber, msg)) + { UNITY_FAIL_AND_BAIL; + } while (elements--) { @@ -1428,9 +1479,13 @@ int UnityParseOptions(int argc, char** argv) case 'n': /* include tests with name including this string */ case 'f': /* an alias for -n */ if (argv[i][2] == '=') + { UnityOptionIncludeNamed = &argv[i][3]; + } else if (++i < argc) + { UnityOptionIncludeNamed = argv[i]; + } else { UnityPrint("ERROR: No Test String to Include Matches For"); @@ -1446,9 +1501,13 @@ int UnityParseOptions(int argc, char** argv) break; case 'x': /* exclude tests with name including this string */ if (argv[i][2] == '=') + { UnityOptionExcludeNamed = &argv[i][3]; + } else if (++i < argc) + { UnityOptionExcludeNamed = argv[i]; + } else { UnityPrint("ERROR: No Test String to Exclude Matches For"); @@ -1476,7 +1535,9 @@ int IsStringInBiggerString(const char* longstring, const char* shortstring) const char* lnext = lptr; if (*sptr == '*') + { return 1; + } while (*lptr) { @@ -1524,7 +1585,9 @@ int UnityStringArgumentMatches(const char* str) while (ptr1[0] != 0) { if ((ptr1[0] == '"') || (ptr1[0] == '\'')) + { ptr1++; + } /* look for the start of the next partial */ ptr2 = ptr1; @@ -1533,7 +1596,9 @@ int UnityStringArgumentMatches(const char* str) { ptr2++; if ((ptr2[0] == ':') && (ptr2[1] != 0) && (ptr2[0] != '\'') && (ptr2[0] != '"') && (ptr2[0] != ',')) + { ptrf = &ptr2[1]; + } } while ((ptr2[0] != 0) && (ptr2[0] != '\'') && (ptr2[0] != '"') && (ptr2[0] != ',')); while ((ptr2[0] != 0) && ((ptr2[0] == ':') || (ptr2[0] == '\'') || (ptr2[0] == '"') || (ptr2[0] == ','))) @@ -1580,14 +1645,19 @@ int UnityTestMatches(void) retval = UnityStringArgumentMatches(UnityOptionIncludeNamed); } else + { retval = 1; + } /* Check if this test name matches the excluded test pattern */ if (UnityOptionExcludeNamed) { if (UnityStringArgumentMatches(UnityOptionExcludeNamed)) + { retval = 0; + } } + return retval; } From 7dd21c333e56098b2e047a6fedd1c7ddfc4a88ab Mon Sep 17 00:00:00 2001 From: Mark VanderVoord Date: Fri, 2 Nov 2018 07:42:47 -0400 Subject: [PATCH 080/454] Fix unintended array overrun in example (#360. Thanks @quantum-leaps) --- examples/example_1/src/ProductionCode.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/example_1/src/ProductionCode.c b/examples/example_1/src/ProductionCode.c index d039c3e8..db128e5b 100644 --- a/examples/example_1/src/ProductionCode.c +++ b/examples/example_1/src/ProductionCode.c @@ -4,14 +4,14 @@ int Counter = 0; int NumbersToFind[9] = { 0, 34, 55, 66, 32, 11, 1, 77, 888 }; /* some obnoxious array to search that is 1-based indexing instead of 0. */ -/* This function is supposed to search through NumbersToFind and find a particular number. - * If it finds it, the index is returned. Otherwise 0 is returned which sorta makes sense since - * NumbersToFind is indexed from 1. Unfortunately it's broken +/* This function is supposed to search through NumbersToFind and find a particular number. + * If it finds it, the index is returned. Otherwise 0 is returned which sorta makes sense since + * NumbersToFind is indexed from 1. Unfortunately it's broken * (and should therefore be caught by our tests) */ int FindFunction_WhichIsBroken(int NumberToFind) { int i = 0; - while (i <= 8) /* Notice I should have been in braces */ + while (i < 8) /* Notice I should have been in braces */ i++; if (NumbersToFind[i] == NumberToFind) /* Yikes! I'm getting run after the loop finishes instead of during it! */ return i; From 100c73d37feef84c63530535793c739b30b23c0f Mon Sep 17 00:00:00 2001 From: Dan Yeaw Date: Tue, 13 Nov 2018 21:07:05 -0500 Subject: [PATCH 081/454] Move license for GitHub detection --- docs/license.txt => LICENSE.txt | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename docs/license.txt => LICENSE.txt (100%) diff --git a/docs/license.txt b/LICENSE.txt similarity index 100% rename from docs/license.txt rename to LICENSE.txt From 6b657c6f17ca45c240dd7ad74e8096dd17ab3ad1 Mon Sep 17 00:00:00 2001 From: John Lindgren Date: Wed, 28 Nov 2018 13:27:00 -0500 Subject: [PATCH 082/454] Fix (most) Rubocop warnings. --- auto/colour_prompt.rb | 4 +- auto/colour_reporter.rb | 2 +- auto/generate_module.rb | 8 ++-- auto/generate_test_runner.rb | 8 ++-- auto/parse_output.rb | 57 +++++++++++++-------------- auto/stylize_as_junit.rb | 12 ++---- auto/test_file_filter.rb | 4 +- auto/unity_test_summary.rb | 4 -- examples/example_3/rakefile.rb | 11 ++---- examples/example_3/rakefile_helper.rb | 8 ++-- extras/fixture/rakefile.rb | 14 +++---- test/.rubocop.yml | 2 +- test/rakefile | 7 ++-- test/rakefile_helper.rb | 8 ++-- 14 files changed, 65 insertions(+), 84 deletions(-) diff --git a/auto/colour_prompt.rb b/auto/colour_prompt.rb index 0f1dc4e0..bf09d028 100644 --- a/auto/colour_prompt.rb +++ b/auto/colour_prompt.rb @@ -24,7 +24,7 @@ def initialize return unless RUBY_PLATFORM =~ /(win|w)32$/ get_std_handle = Win32API.new('kernel32', 'GetStdHandle', ['L'], 'L') @set_console_txt_attrb = - Win32API.new('kernel32', 'SetConsoleTextAttribute', %w(L N), 'I') + Win32API.new('kernel32', 'SetConsoleTextAttribute', %w[L N], 'I') @hout = get_std_handle.call(-11) end @@ -107,7 +107,7 @@ def out_c(mode, colour, str) $stdout.print("#{change_to(colour)}#{str}\033[0m") if mode == :print end end -end # ColourCommandLine +end def colour_puts(role, str) ColourCommandLine.new.out_c(:puts, role, str) diff --git a/auto/colour_reporter.rb b/auto/colour_reporter.rb index bb1fbfce..1c3bc216 100644 --- a/auto/colour_reporter.rb +++ b/auto/colour_reporter.rb @@ -4,7 +4,7 @@ # [Released under MIT License. Please refer to license.txt for details] # ========================================== -require "#{File.expand_path(File.dirname(__FILE__))}/colour_prompt" +require_relative 'colour_prompt' $colour_output = true diff --git a/auto/generate_module.rb b/auto/generate_module.rb index 13b4cc74..fb8c7ac4 100644 --- a/auto/generate_module.rb +++ b/auto/generate_module.rb @@ -45,8 +45,6 @@ class UnityModuleGenerator ############################ def initialize(options = nil) - here = File.expand_path(File.dirname(__FILE__)) + '/' - @options = UnityModuleGenerator.default_options case options when NilClass then @options @@ -56,9 +54,9 @@ def initialize(options = nil) end # Create default file paths if none were provided - @options[:path_src] = here + '../src/' if @options[:path_src].nil? - @options[:path_inc] = @options[:path_src] if @options[:path_inc].nil? - @options[:path_tst] = here + '../test/' if @options[:path_tst].nil? + @options[:path_src] = "#{__dir__}/../src/" if @options[:path_src].nil? + @options[:path_inc] = @options[:path_src] if @options[:path_inc].nil? + @options[:path_tst] = "#{__dir__}/../test/" if @options[:path_tst].nil? @options[:path_src] += '/' unless @options[:path_src][-1] == 47 @options[:path_inc] += '/' unless @options[:path_inc][-1] == 47 @options[:path_tst] += '/' unless @options[:path_tst][-1] == 47 diff --git a/auto/generate_test_runner.rb b/auto/generate_test_runner.rb index 2f149665..377db6fc 100644 --- a/auto/generate_test_runner.rb +++ b/auto/generate_test_runner.rb @@ -4,8 +4,6 @@ # [Released under MIT License. Please refer to license.txt for details] # ========================================== -File.expand_path(File.join(File.dirname(__FILE__), 'colour_prompt')) - class UnityTestRunnerGenerator def initialize(options = nil) @options = UnityTestRunnerGenerator.default_options @@ -15,7 +13,7 @@ def initialize(options = nil) when Hash then @options.merge!(options) else raise 'If you specify arguments, it should be a filename or a hash of options' end - require "#{File.expand_path(File.dirname(__FILE__))}/type_sanitizer" + require_relative 'type_sanitizer' end def self.default_options @@ -165,7 +163,7 @@ def create_header(output, mocks, testfile_includes = []) output.puts('#include "cmock.h"') unless mocks.empty? output.puts('#ifndef UNITY_EXCLUDE_SETJMP_H') output.puts('#include ') - output.puts("#endif") + output.puts('#endif') output.puts('#include ') if @options[:defines] && !@options[:defines].empty? @options[:defines].each { |d| output.puts("#define #{d}") } @@ -379,7 +377,7 @@ def create_main(output, filename, tests, used_mocks) end output.puts output.puts(' CMock_Guts_MemFreeFinal();') unless used_mocks.empty? - output.puts(" return suite_teardown(UnityEnd());") + output.puts(' return suite_teardown(UnityEnd());') output.puts('}') end diff --git a/auto/parse_output.rb b/auto/parse_output.rb index f04508fb..fa07b7db 100644 --- a/auto/parse_output.rb +++ b/auto/parse_output.rb @@ -210,7 +210,7 @@ def test_ignored(array) # Adjusts the os specific members according to the current path style # (Windows or Unix based) - def set_os_specifics(line) + def detect_os_specifics(line) if line.include? '\\' # Windows X:\Y\Z @class_name_idx = 1 @@ -254,43 +254,42 @@ def process(file_name) # TEST() PASS # # Note: Where path is different on Unix vs Windows devices (Windows leads with a drive letter)! - set_os_specifics(line) + detect_os_specifics(line) line_array = line.split(':') # If we were able to split the line then we can look to see if any of our target words # were found. Case is important. - if (line_array.size >= 4) || (line.start_with? 'TEST(') || (line.start_with? 'IGNORE_TEST(') - - # check if the output is fixture output (with verbose flag "-v") - if (line.start_with? 'TEST(') || (line.start_with? 'IGNORE_TEST(') - line_array = prepare_fixture_line(line) - if line.include? ' PASS' - test_passed_unity_fixture(line_array) - @test_passed += 1 - elsif line.include? 'FAIL' - test_failed_unity_fixture(line_array) - @test_failed += 1 - elsif line.include? 'IGNORE' - test_ignored_unity_fixture(line_array) - @test_ignored += 1 - end - # normal output / fixture output (without verbose "-v") - elsif line.include? ':PASS' - test_passed(line_array) + next unless (line_array.size >= 4) || (line.start_with? 'TEST(') || (line.start_with? 'IGNORE_TEST(') + + # check if the output is fixture output (with verbose flag "-v") + if (line.start_with? 'TEST(') || (line.start_with? 'IGNORE_TEST(') + line_array = prepare_fixture_line(line) + if line.include? ' PASS' + test_passed_unity_fixture(line_array) @test_passed += 1 - elsif line.include? ':FAIL' - test_failed(line_array) + elsif line.include? 'FAIL' + test_failed_unity_fixture(line_array) @test_failed += 1 - elsif line.include? ':IGNORE:' - test_ignored(line_array) - @test_ignored += 1 - elsif line.include? ':IGNORE' - line_array.push('No reason given') - test_ignored(line_array) + elsif line.include? 'IGNORE' + test_ignored_unity_fixture(line_array) @test_ignored += 1 end - @total_tests = @test_passed + @test_failed + @test_ignored + # normal output / fixture output (without verbose "-v") + elsif line.include? ':PASS' + test_passed(line_array) + @test_passed += 1 + elsif line.include? ':FAIL' + test_failed(line_array) + @test_failed += 1 + elsif line.include? ':IGNORE:' + test_ignored(line_array) + @test_ignored += 1 + elsif line.include? ':IGNORE' + line_array.push('No reason given') + test_ignored(line_array) + @test_ignored += 1 end + @total_tests = @test_passed + @test_failed + @test_ignored end puts '' puts '=================== SUMMARY =====================' diff --git a/auto/stylize_as_junit.rb b/auto/stylize_as_junit.rb index b3d8f409..a53f85f7 100755 --- a/auto/stylize_as_junit.rb +++ b/auto/stylize_as_junit.rb @@ -61,8 +61,8 @@ def self.parse(args) opts.parse!(args) options - end # parse() -end # class OptparseExample + end +end class UnityToJUnit include FileUtils::Verbose @@ -155,10 +155,6 @@ def parse_test_summary(summary) [Regexp.last_match(1).to_i, Regexp.last_match(2).to_i, Regexp.last_match(3).to_i] end - def here - File.expand_path(File.dirname(__FILE__)) - end - private def results_structure @@ -221,9 +217,9 @@ def write_suite_footer(stream) def write_suites_footer(stream) stream.puts '' end -end # UnityToJUnit +end -if __FILE__ == $0 +if $0 == __FILE__ # parse out the command options options = ArgvParser.parse(ARGV) diff --git a/auto/test_file_filter.rb b/auto/test_file_filter.rb index aad28e38..5c3a79fc 100644 --- a/auto/test_file_filter.rb +++ b/auto/test_file_filter.rb @@ -11,8 +11,8 @@ class TestFileFilter def initialize(all_files = false) @all_files = all_files - return false unless @all_files - return false unless File.exist?('test_file_filter.yml') + return unless @all_files + return unless File.exist?('test_file_filter.yml') filters = YAML.load_file('test_file_filter.yml') @all_files = filters[:all_files] diff --git a/auto/unity_test_summary.rb b/auto/unity_test_summary.rb index b37dc5fa..810fdbd1 100644 --- a/auto/unity_test_summary.rb +++ b/auto/unity_test_summary.rb @@ -101,10 +101,6 @@ def parse_test_summary(summary) raise "Couldn't parse test results: #{summary}" unless summary.find { |v| v =~ /(\d+) Tests (\d+) Failures (\d+) Ignored/ } [Regexp.last_match(1).to_i, Regexp.last_match(2).to_i, Regexp.last_match(3).to_i] end - - def here - File.expand_path(File.dirname(__FILE__)) - end end if $0 == __FILE__ diff --git a/examples/example_3/rakefile.rb b/examples/example_3/rakefile.rb index bf9f42be..d0149299 100644 --- a/examples/example_3/rakefile.rb +++ b/examples/example_3/rakefile.rb @@ -1,12 +1,9 @@ -HERE = File.expand_path(File.dirname(__FILE__)) + '/' -UNITY_ROOT = File.expand_path(File.dirname(__FILE__)) + '/../..' - require 'rake' require 'rake/clean' -require HERE + 'rakefile_helper' +require_relative 'rakefile_helper' TEMP_DIRS = [ - File.join(HERE, 'build') + File.join(__dir__, 'build') ].freeze TEMP_DIRS.each do |dir| @@ -32,8 +29,8 @@ end desc 'Build and test Unity' -task all: %i(clean unit summary) -task default: %i(clobber all) +task all: %i[clean unit summary] +task default: %i[clobber all] task ci: [:default] task cruise: [:default] diff --git a/examples/example_3/rakefile_helper.rb b/examples/example_3/rakefile_helper.rb index a186cf0f..f1f51d4f 100644 --- a/examples/example_3/rakefile_helper.rb +++ b/examples/example_3/rakefile_helper.rb @@ -1,8 +1,8 @@ require 'yaml' require 'fileutils' -require UNITY_ROOT + '/auto/unity_test_summary' -require UNITY_ROOT + '/auto/generate_test_runner' -require UNITY_ROOT + '/auto/colour_reporter' +require_relative '../../auto/unity_test_summary' +require_relative '../../auto/generate_test_runner' +require_relative '../../auto/colour_reporter' module RakefileHelpers C_EXTENSION = '.c'.freeze @@ -149,7 +149,7 @@ def execute(command_string, verbose = true, raise_on_fail = true) def report_summary summary = UnityTestSummary.new - summary.root = HERE + summary.root = __dir__ results_glob = "#{$cfg['compiler']['build_path']}*.test*" results_glob.tr!('\\', '/') results = Dir[results_glob] diff --git a/extras/fixture/rakefile.rb b/extras/fixture/rakefile.rb index 7603e574..8b5319c5 100644 --- a/extras/fixture/rakefile.rb +++ b/extras/fixture/rakefile.rb @@ -4,15 +4,13 @@ # [Released under MIT License. Please refer to license.txt for details] # ========================================== -HERE = File.expand_path(File.dirname(__FILE__)) + '/' - require 'rake' require 'rake/clean' require 'rake/testtask' -require HERE + 'rakefile_helper' +require_relative 'rakefile_helper' TEMP_DIRS = [ - File.join(HERE, 'build') + File.join(__dir__, 'build') ].freeze TEMP_DIRS.each do |dir| @@ -33,10 +31,10 @@ end desc 'Build and test Unity Framework' -task all: %i(clean unit) -task default: %i(clobber all) -task ci: %i(no_color default) -task cruise: %i(no_color default) +task all: %i[clean unit] +task default: %i[clobber all] +task ci: %i[no_color default] +task cruise: %i[no_color default] desc 'Load configuration' task :config, :config_file do |_t, args| diff --git a/test/.rubocop.yml b/test/.rubocop.yml index c074ca9a..3bfe31a9 100644 --- a/test/.rubocop.yml +++ b/test/.rubocop.yml @@ -18,7 +18,7 @@ Style/HashSyntax: EnforcedStyle: no_mixed_keys # This is disabled because it seems to get confused over nested hashes -Style/AlignHash: +Layout/AlignHash: Enabled: false EnforcedHashRocketStyle: table EnforcedColonStyle: table diff --git a/test/rakefile b/test/rakefile index 4a2f3d2c..770feadc 100644 --- a/test/rakefile +++ b/test/rakefile @@ -4,17 +4,16 @@ # [Released under MIT License. Please refer to license.txt for details] # ========================================== -UNITY_ROOT = File.expand_path(File.dirname(__FILE__)) + '/' $verbose = false require 'rake' require 'rake/clean' -require UNITY_ROOT + 'rakefile_helper' +require_relative 'rakefile_helper' require 'rspec/core/rake_task' TEMP_DIRS = [ - File.join(UNITY_ROOT, 'build'), - File.join(UNITY_ROOT, 'sandbox') + File.join(__dir__, 'build'), + File.join(__dir__, 'sandbox') ] TEMP_DIRS.each do |dir| diff --git a/test/rakefile_helper.rb b/test/rakefile_helper.rb index 1fd60c5f..d4335ec1 100644 --- a/test/rakefile_helper.rb +++ b/test/rakefile_helper.rb @@ -6,9 +6,9 @@ require 'yaml' require 'fileutils' -require UNITY_ROOT + '../auto/unity_test_summary' -require UNITY_ROOT + '../auto/generate_test_runner' -require UNITY_ROOT + '../auto/colour_reporter' +require_relative '../auto/unity_test_summary' +require_relative '../auto/generate_test_runner' +require_relative '../auto/colour_reporter' module RakefileHelpers C_EXTENSION = '.c'.freeze @@ -179,7 +179,7 @@ def execute(command_string, ok_to_fail = false) def report_summary summary = UnityTestSummary.new - summary.root = UNITY_ROOT + summary.root = __dir__ results_glob = "#{$cfg['compiler']['build_path']}*.test*" results_glob.tr!('\\', '/') results = Dir[results_glob] From 5cd1c33b0e99bfaa1c1c1a2c950854286e6c5eb3 Mon Sep 17 00:00:00 2001 From: John Lindgren Date: Wed, 28 Nov 2018 13:36:27 -0500 Subject: [PATCH 083/454] Fix uninitialized constant --- extras/fixture/rakefile_helper.rb | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/extras/fixture/rakefile_helper.rb b/extras/fixture/rakefile_helper.rb index c45b2393..71e752b9 100644 --- a/extras/fixture/rakefile_helper.rb +++ b/extras/fixture/rakefile_helper.rb @@ -6,9 +6,9 @@ require 'yaml' require 'fileutils' -require HERE + '../../auto/unity_test_summary' -require HERE + '../../auto/generate_test_runner' -require HERE + '../../auto/colour_reporter' +require_relative '../../auto/unity_test_summary' +require_relative '../../auto/generate_test_runner' +require_relative '../../auto/colour_reporter' module RakefileHelpers C_EXTENSION = '.c'.freeze @@ -16,7 +16,7 @@ module RakefileHelpers def load_configuration(config_file) return if $configured - $cfg_file = HERE + "../../test/targets/#{config_file}" unless config_file =~ /[\\|\/]/ + $cfg_file = "#{__dir__}/../../test/targets/#{config_file}" unless config_file =~ /[\\|\/]/ $cfg = YAML.load(File.read($cfg_file)) $colour_output = false unless $cfg['colour'] $configured = true if config_file != DEFAULT_CONFIG_FILE @@ -128,7 +128,7 @@ def execute(command_string, verbose = true) def report_summary summary = UnityTestSummary.new - summary.root = HERE + summary.root = __dir__ results_glob = "#{$cfg['compiler']['build_path']}*.test*" results_glob.tr!('\\', '/') results = Dir[results_glob] @@ -145,9 +145,9 @@ def run_tests $cfg['compiler']['defines']['items'] = [] if $cfg['compiler']['defines']['items'].nil? # Get a list of all source files needed - src_files = Dir[HERE + 'src/*.c'] - src_files += Dir[HERE + 'test/*.c'] - src_files += Dir[HERE + 'test/main/*.c'] + src_files = Dir["#{__dir__}/src/*.c"] + src_files += Dir["#{__dir__}/test/*.c"] + src_files += Dir["#{__dir__}/test/main/*.c"] src_files << '../../src/unity.c' # Build object files From 8a77f48634a055a11edf1583babd1b7a86e7d3a6 Mon Sep 17 00:00:00 2001 From: John Lindgren Date: Wed, 28 Nov 2018 14:40:40 -0500 Subject: [PATCH 084/454] Fix undefined behavior when printing INT_MIN/INT64_MIN. Negating the most-negative signed integer results in overflow, which is undefined behavior. Fix this by casting to an unsigned type first (unsigned overflow is well-defined as it uses modular arithmetic). --- src/unity.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/unity.c b/src/unity.c index d1dda410..00c94127 100644 --- a/src/unity.c +++ b/src/unity.c @@ -183,7 +183,7 @@ void UnityPrintNumber(const UNITY_INT number_to_print) { /* A negative number, including MIN negative */ UNITY_OUTPUT_CHAR('-'); - number = (UNITY_UINT)(-number_to_print); + number = -number; } UnityPrintNumberUnsigned(number); } From d09f4953ffd67bcaf774d3f0e6476a9ec33265f4 Mon Sep 17 00:00:00 2001 From: John Lindgren Date: Wed, 28 Nov 2018 15:17:25 -0500 Subject: [PATCH 085/454] Fix another signed integer overflow. --- src/unity.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/unity.c b/src/unity.c index 00c94127..70c6b269 100644 --- a/src/unity.c +++ b/src/unity.c @@ -1019,22 +1019,22 @@ void UnityAssertNumbersWithin(const UNITY_UINT delta, { if (actual > expected) { - Unity.CurrentTestFailed = (UNITY_UINT)((UNITY_UINT)(actual - expected) > delta); + Unity.CurrentTestFailed = (((UNITY_UINT)actual - (UNITY_UINT)expected) > delta); } else { - Unity.CurrentTestFailed = (UNITY_UINT)((UNITY_UINT)(expected - actual) > delta); + Unity.CurrentTestFailed = (((UNITY_UINT)expected - (UNITY_UINT)actual) > delta); } } else { if ((UNITY_UINT)actual > (UNITY_UINT)expected) { - Unity.CurrentTestFailed = (UNITY_UINT)((UNITY_UINT)(actual - expected) > delta); + Unity.CurrentTestFailed = (((UNITY_UINT)actual - (UNITY_UINT)expected) > delta); } else { - Unity.CurrentTestFailed = (UNITY_UINT)((UNITY_UINT)(expected - actual) > delta); + Unity.CurrentTestFailed = (((UNITY_UINT)expected - (UNITY_UINT)actual) > delta); } } From 5db2a3dbd9b72070c236eda6549520a38ca0ada1 Mon Sep 17 00:00:00 2001 From: Elliot Gawthrop Date: Sun, 9 Dec 2018 21:21:46 +0000 Subject: [PATCH 086/454] Add support for strings in TEST_CASE() --- auto/generate_test_runner.rb | 15 ++++++++- test/tests/testparameterized.c | 61 ++++++++++++++++++++++++++++++++++ 2 files changed, 75 insertions(+), 1 deletion(-) diff --git a/auto/generate_test_runner.rb b/auto/generate_test_runner.rb index 377db6fc..9f64b443 100644 --- a/auto/generate_test_runner.rb +++ b/auto/generate_test_runner.rb @@ -90,12 +90,25 @@ def generate(input_file, output_file, tests, used_mocks, testfile_includes) def find_tests(source) tests_and_line_numbers = [] + # contains characters which will be substituted from within strings, doing + # this prevents these characters from interferring with scrubbers + # @ is not a valid C character, so there should be no clashes with files genuinely containing these markers + substring_subs = { '{' => '@co@', '}' => '@cc@', ';' => '@ss@', '/' => '@fs@' } + substring_re = Regexp.union(substring_subs.keys) + substring_unsubs = substring_subs.invert # the inverse map will be used to fix the strings afterwords + substring_unsubs['@quote@'] = '\\"' + substring_unsubs['@apos@'] = '\\\'' + substring_unre = Regexp.union(substring_unsubs.keys) source_scrubbed = source.clone - source_scrubbed = source_scrubbed.gsub(/"[^"\n]*"/, '') # remove things in strings + source_scrubbed = source_scrubbed.gsub(/\\"/, '@quote@') # hide escaped quotes to allow capture of the full string/char + source_scrubbed = source_scrubbed.gsub(/\\'/, '@apos@') # hide escaped apostrophes to allow capture of the full string/char + source_scrubbed = source_scrubbed.gsub(/("[^"\n]*")|('[^'\n]*')/) { |s| s.gsub(substring_re, substring_subs) } # temporarily hide problematic + # characters within strings source_scrubbed = source_scrubbed.gsub(/\/\/.*$/, '') # remove line comments source_scrubbed = source_scrubbed.gsub(/\/\*.*?\*\//m, '') # remove block comments lines = source_scrubbed.split(/(^\s*\#.*$) # Treat preprocessor directives as a logical line | (;|\{|\}) /x) # Match ;, {, and } as end of lines + .map { |line| line.gsub(substring_unre, substring_unsubs) } # unhide the problematic characters previously removed lines.each_with_index do |line, _index| # find tests diff --git a/test/tests/testparameterized.c b/test/tests/testparameterized.c index 136cd2f4..6100834f 100644 --- a/test/tests/testparameterized.c +++ b/test/tests/testparameterized.c @@ -46,6 +46,14 @@ void flushSpy(void) {} int SetToOneToFailInTearDown; int SetToOneMeanWeAlreadyCheckedThisGuy; +static unsigned NextExpectedStringIndex; +static unsigned NextExpectedCharIndex; + +void suiteSetUp(void) +{ + NextExpectedStringIndex = 0; + NextExpectedCharIndex = 0; +} void setUp(void) { @@ -111,3 +119,56 @@ void test_NormalFailsStillWork(void) TEST_ASSERT_TRUE(0); VERIFY_FAILS_END } + +TEST_CASE(0, "abc") +TEST_CASE(1, "{") +TEST_CASE(2, "}") +TEST_CASE(3, ";") +TEST_CASE(4, "\"quoted\"") +void test_StringsArePreserved(unsigned index, const char * str) +{ + static const char * const expected[] = + { + "abc", + "{", + "}", + ";", + "\"quoted\"" + }; + + /* Ensure that no test cases are skipped by tracking the next expected index */ + TEST_ASSERT_EQUAL_UINT32(NextExpectedStringIndex, index); + TEST_ASSERT_LESS_THAN(sizeof(expected) / sizeof(expected[0]), index); + TEST_ASSERT_EQUAL_STRING(expected[index], str); + + NextExpectedStringIndex++; +} + +TEST_CASE(0, 'x') +TEST_CASE(1, '{') +TEST_CASE(2, '}') +TEST_CASE(3, ';') +TEST_CASE(4, '\'') +TEST_CASE(5, '"') +void test_CharsArePreserved(unsigned index, char c) +{ + static const char expected[] = + { + 'x', + '{', + '}', + ';', + '\'', + '"' + }; + + /* Ensure that no test cases are skipped by tracking the next expected index */ + TEST_ASSERT_EQUAL_UINT32(NextExpectedCharIndex, index); + TEST_ASSERT_LESS_THAN(sizeof(expected) / sizeof(expected[0]), index); + TEST_ASSERT_EQUAL(expected[index], c); + + NextExpectedCharIndex++; +} + + + From 516f7be04526b4573e0a5bc37fad2917e9e189aa Mon Sep 17 00:00:00 2001 From: Dom Postorivo Date: Wed, 13 Jun 2018 23:44:58 -0400 Subject: [PATCH 087/454] generate runner defines with #ifndef guards --- auto/generate_test_runner.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/auto/generate_test_runner.rb b/auto/generate_test_runner.rb index 9f64b443..2acda0f3 100644 --- a/auto/generate_test_runner.rb +++ b/auto/generate_test_runner.rb @@ -179,7 +179,7 @@ def create_header(output, mocks, testfile_includes = []) output.puts('#endif') output.puts('#include ') if @options[:defines] && !@options[:defines].empty? - @options[:defines].each { |d| output.puts("#define #{d}") } + @options[:defines].each { |d| output.puts("#ifndef #{d}\n#define #{d}\n#endif /* #{d} */") } end if @options[:header_file] && !@options[:header_file].empty? output.puts("#include \"#{File.basename(@options[:header_file])}\"") From 95ccc6edc11814052552c4d306d3e3adb10ece89 Mon Sep 17 00:00:00 2001 From: Fabian Zahn Date: Thu, 24 Jan 2019 18:42:51 +0100 Subject: [PATCH 088/454] Changed the compiler switch behaviour for printf (default: disabled). Macro UNITY_EXCLUDE_PRINT_FORMATTED changed to UNITY_INCLUDE_PRINT_FORMATTED. Enable printf via "-DUNITY_INCLUDE_PRINT_FORMATTED" compiler option. --- src/unity.c | 6 +++--- src/unity_internals.h | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/unity.c b/src/unity.c index fa1847ba..98741083 100644 --- a/src/unity.c +++ b/src/unity.c @@ -141,8 +141,8 @@ void UnityPrint(const char* string) } /*-----------------------------------------------*/ -#ifndef UNITY_EXCLUDE_PRINT_FORMATTED -void UnityPrintFormatted(const char* format, ... ) +#ifdef UNITY_INCLUDE_PRINT_FORMATTED +void UnityPrintFormatted(const char* format, ...) { const char* pch = format; va_list va; @@ -251,7 +251,7 @@ void UnityPrintFormatted(const char* format, ... ) va_end(va); } -#endif /* ! UNITY_EXCLUDE_PRINT_FORMATTED */ +#endif /* ! UNITY_INCLUDE_PRINT_FORMATTED */ /*-----------------------------------------------*/ void UnityPrintLen(const char* string, const UNITY_UINT32 length) diff --git a/src/unity_internals.h b/src/unity_internals.h index 2a306823..e91d9bc9 100644 --- a/src/unity_internals.h +++ b/src/unity_internals.h @@ -23,7 +23,7 @@ #include #endif -#ifndef UNITY_EXCLUDE_PRINT_FORMATTED +#ifdef UNITY_INCLUDE_PRINT_FORMATTED #include #endif @@ -496,8 +496,8 @@ void UnityDefaultTestRun(UnityTestFunction Func, const char* FuncName, const int void UnityPrint(const char* string); -#ifndef UNITY_EXCLUDE_PRINT_FORMATTED -void UnityPrintFormatted(const char* format, ... ); +#ifdef UNITY_INCLUDE_PRINT_FORMATTED +void UnityPrintFormatted(const char* format, ...); #endif void UnityPrintLen(const char* string, const UNITY_UINT32 length); From 4f8656f65845bfc2d6aa2e9561cb2c77e767161e Mon Sep 17 00:00:00 2001 From: Fabian Zahn Date: Thu, 24 Jan 2019 19:21:08 +0100 Subject: [PATCH 089/454] Added some documentation for the helper function. --- src/unity.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/unity.c b/src/unity.c index 98741083..5cb03652 100644 --- a/src/unity.c +++ b/src/unity.c @@ -98,6 +98,7 @@ static void UnityPrintChar(const char* pch) } /*-----------------------------------------------*/ +/* Local helper function to print ANSI escape strings e.g. "\033[42m". */ #ifdef UNITY_OUTPUT_COLOR static UNITY_UINT UnityPrintAnsiEscapeString(const char* string) { @@ -209,7 +210,8 @@ void UnityPrintFormatted(const char* format, ...) break; } case 's': - { const char * string = va_arg(va, const char *); + { + const char * string = va_arg(va, const char *); UnityPrint(string); break; } @@ -220,7 +222,7 @@ void UnityPrintFormatted(const char* format, ...) } default: { - /* print the unknown character */ + /* print the unknown format character */ UNITY_OUTPUT_CHAR('%'); UnityPrintChar(pch); break; From 92a345b2644d9f0838b7c252f7e4f9cc12a9c958 Mon Sep 17 00:00:00 2001 From: Fabian Zahn Date: Thu, 24 Jan 2019 20:12:16 +0100 Subject: [PATCH 090/454] Added documentation and changed all the code examples to backtick (code) blocks. --- docs/UnityConfigurationGuide.md | 179 ++++++++++++++++++++++---------- 1 file changed, 127 insertions(+), 52 deletions(-) diff --git a/docs/UnityConfigurationGuide.md b/docs/UnityConfigurationGuide.md index b88eeee9..1275ca76 100644 --- a/docs/UnityConfigurationGuide.md +++ b/docs/UnityConfigurationGuide.md @@ -66,7 +66,9 @@ That way, Unity will know to skip the inclusion of this file and you won't be left with a compiler error. _Example:_ - #define UNITY_EXCLUDE_STDINT_H +```C +#define UNITY_EXCLUDE_STDINT_H +``` ##### `UNITY_EXCLUDE_LIMITS_H` @@ -76,8 +78,9 @@ that don't support `stdint.h` could include `limits.h` instead. If you don't want Unity to check this file either, define this to make it skip the inclusion. _Example:_ - #define UNITY_EXCLUDE_LIMITS_H - +```C +#define UNITY_EXCLUDE_LIMITS_H +``` If you've disabled both of the automatic options above, you're going to have to do the configuration yourself. Don't worry. Even this isn't too bad... there are @@ -91,7 +94,9 @@ Define this to be the number of bits an `int` takes up on your system. The default, if not autodetected, is 32 bits. _Example:_ - #define UNITY_INT_WIDTH 16 +```C +#define UNITY_INT_WIDTH 16 +``` ##### `UNITY_LONG_WIDTH` @@ -103,7 +108,9 @@ of 64-bit support your system can handle. Does it need to specify a `long` or a ignored. _Example:_ - #define UNITY_LONG_WIDTH 16 +```C +#define UNITY_LONG_WIDTH 16 +``` ##### `UNITY_POINTER_WIDTH` @@ -113,7 +120,9 @@ default, if not autodetected, is 32-bits. If you're getting ugly compiler warnings about casting from pointers, this is the one to look at. _Example:_ - #define UNITY_POINTER_WIDTH 64 +```C +#define UNITY_POINTER_WIDTH 64 +``` ##### `UNITY_SUPPORT_64` @@ -125,7 +134,9 @@ can be a significant size and speed impact to enabling 64-bit support on small targets, so don't define it if you don't need it. _Example:_ - #define UNITY_SUPPORT_64 +```C +#define UNITY_SUPPORT_64 +``` ### Floating Point Types @@ -153,10 +164,11 @@ suits your needs. For features that are enabled, the following floating point options also become available. _Example:_ - - //what manner of strange processor is this? - #define UNITY_EXCLUDE_FLOAT - #define UNITY_INCLUDE_DOUBLE +```C +//what manner of strange processor is this? +#define UNITY_EXCLUDE_FLOAT +#define UNITY_INCLUDE_DOUBLE +``` ##### `UNITY_EXCLUDE_FLOAT_PRINT` @@ -172,7 +184,9 @@ can use this define to instead respond to a failed assertion with a message like point assertions, use these options to give more explicit failure messages. _Example:_ - #define UNITY_EXCLUDE_FLOAT_PRINT +```C +#define UNITY_EXCLUDE_FLOAT_PRINT +``` ##### `UNITY_FLOAT_TYPE` @@ -182,7 +196,9 @@ floats. If your compiler supports a specialty floating point type, you can always override this behavior by using this definition. _Example:_ - #define UNITY_FLOAT_TYPE float16_t +```C +#define UNITY_FLOAT_TYPE float16_t +``` ##### `UNITY_DOUBLE_TYPE` @@ -194,7 +210,9 @@ could enable gargantuan floating point types on your 64-bit processor instead of the standard `double`. _Example:_ - #define UNITY_DOUBLE_TYPE long double +```C +#define UNITY_DOUBLE_TYPE long double +``` ##### `UNITY_FLOAT_PRECISION` @@ -213,7 +231,10 @@ For further details on how this works, see the appendix of the Unity Assertion Guide. _Example:_ - #define UNITY_FLOAT_PRECISION 0.001f +```C +#define UNITY_FLOAT_PRECISION 0.001f +``` + ### Miscellaneous @@ -225,7 +246,47 @@ your own macro for this, you should exclude the `stddef.h` header file by adding define to your configuration. _Example:_ - #define UNITY_EXCLUDE_STDDEF_H +```C +#define UNITY_EXCLUDE_STDDEF_H +``` + + +#### `UNITY_INCLUDE_PRINT_FORMATTED` + +Unity provides a simple (and very basic) printf-like string output implementation, +which is able to print a string modified by the following format string modifiers: + +- __%d__ - signed value (decimal) +- __%i__ - same as __%i__ +- __%u__ - unsigned value (decimal) +- __%f__ - float/Double (if float support is activated) +- __%g__ - same as __%f__ +- __%b__ - binary prefixed with "0b" +- __%x__ - hexadecimal (upper case) prefixed with "0x" +- __%X__ - same as __%x__ +- __%p__ - pointer (same as __%x__ or __%X__) +- __%c__ - a single character +- __%s__ - a string (e.g. "string") +- __%%__ - The "%" symbol (escaped) + +_Example:_ +```C +#define UNITY_INCLUDE_PRINT_FORMATTED + +int a = 0xfab1; +UnityPrintFormatted("Decimal %d\n", -7); +UnityPrintFormatted("Unsigned %u\n", 987); +UnityPrintFormatted("Float %f\n", 3.1415926535897932384); +UnityPrintFormatted("Binary %b\n", 0xA); +UnityPrintFormatted("Hex %X\n", 0xFAB); +UnityPrintFormatted("Pointer %p\n", &a); +UnityPrintFormatted("Character %c\n", 'F'); +UnityPrintFormatted("String %s\n", "My string"); +UnityPrintFormatted("Percent %%\n"); +UnityPrintFormatted("Color Red \033[41mFAIL\033[00m\n"); +UnityPrintFormatted("\n"); +UnityPrintFormatted("Multiple (%d) (%i) (%u) (%x)\n", -100, 0, 200, 0x12345); +``` ### Toolset Customization @@ -260,12 +321,14 @@ _Example:_ Say you are forced to run your test suite on an embedded processor with no `stdout` option. You decide to route your test result output to a custom serial `RS232_putc()` function you wrote like thus: - #include "RS232_header.h" - ... - #define UNITY_OUTPUT_CHAR(a) RS232_putc(a) - #define UNITY_OUTPUT_START() RS232_config(115200,1,8,0) - #define UNITY_OUTPUT_FLUSH() RS232_flush() - #define UNITY_OUTPUT_COMPLETE() RS232_close() +```C +#include "RS232_header.h" +... +#define UNITY_OUTPUT_CHAR(a) RS232_putc(a) +#define UNITY_OUTPUT_START() RS232_config(115200,1,8,0) +#define UNITY_OUTPUT_FLUSH() RS232_flush() +#define UNITY_OUTPUT_COMPLETE() RS232_close() +``` _Note:_ `UNITY_OUTPUT_FLUSH()` can be set to the standard out flush function simply by @@ -294,10 +357,12 @@ empty). You can also force Unity to NOT use weak functions by defining UNITY_NO_WEAK. The most common options for this feature are: _Example:_ - #define UNITY_WEAK_ATTRIBUTE weak - #define UNITY_WEAK_ATTRIBUTE __attribute__((weak)) - #define UNITY_WEAK_PRAGMA - #define UNITY_NO_WEAK +```C +#define UNITY_WEAK_ATTRIBUTE weak +#define UNITY_WEAK_ATTRIBUTE __attribute__((weak)) +#define UNITY_WEAK_PRAGMA +#define UNITY_NO_WEAK +``` ##### `UNITY_PTR_ATTRIBUTE` @@ -307,9 +372,10 @@ Some compilers require a custom attribute to be assigned to pointers, like defining this option with the attribute you would like. _Example:_ - #define UNITY_PTR_ATTRIBUTE __attribute__((far)) - #define UNITY_PTR_ATTRIBUTE near - +```C +#define UNITY_PTR_ATTRIBUTE __attribute__((far)) +#define UNITY_PTR_ATTRIBUTE near +``` ##### `UNITY_PRINT_EOL` @@ -318,8 +384,9 @@ to parse by the scripts, by Ceedling, etc, but it might not be ideal for YOUR system. Feel free to override this and to make it whatever you wish. _Example:_ - #define UNITY_PRINT_EOL { UNITY_OUTPUT_CHAR('\r'); UNITY_OUTPUT_CHAR('\n') } - +```C +#define UNITY_PRINT_EOL { UNITY_OUTPUT_CHAR('\r'); UNITY_OUTPUT_CHAR('\n') } +``` ##### `UNITY_EXCLUDE_DETAILS` @@ -331,8 +398,9 @@ report which function or argument flagged an error. If you're not using CMock an you're not using these details for other things, then you can exclude them. _Example:_ - #define UNITY_EXCLUDE_DETAILS - +```C +#define UNITY_EXCLUDE_DETAILS +``` ##### `UNITY_EXCLUDE_SETJMP` @@ -345,15 +413,18 @@ compiler doesn't support setjmp, you wouldn't have had the memory space for thos things anyway, though... so this option exists for those situations. _Example:_ - #define UNITY_EXCLUDE_SETJMP +```C +#define UNITY_EXCLUDE_SETJMP +``` ##### `UNITY_OUTPUT_COLOR` If you want to add color using ANSI escape codes you can use this define. t _Example:_ - #define UNITY_OUTPUT_COLOR - +```C +#define UNITY_OUTPUT_COLOR +``` ## Getting Into The Guts @@ -380,13 +451,15 @@ output of your test results. A simple main function looks something like this: - int main(void) { - UNITY_BEGIN(); - RUN_TEST(test_TheFirst); - RUN_TEST(test_TheSecond); - RUN_TEST(test_TheThird); - return UNITY_END(); - } +```C +int main(void) { + UNITY_BEGIN(); + RUN_TEST(test_TheFirst); + RUN_TEST(test_TheSecond); + RUN_TEST(test_TheThird); + return UNITY_END(); +} +``` You can see that our main function doesn't bother taking any arguments. For our most barebones case, we'll never have arguments because we just run all the @@ -409,15 +482,17 @@ case function. This includes catching failures, calling the test module's using CMock or test coverage, there will be additional stubs in use here. A simple minimalist RUN_TEST macro looks something like this: - #define RUN_TEST(testfunc) \ - UNITY_NEW_TEST(#testfunc) \ - if (TEST_PROTECT()) { \ - setUp(); \ - testfunc(); \ - } \ - if (TEST_PROTECT() && (!TEST_IS_IGNORED)) \ - tearDown(); \ - UnityConcludeTest(); +```C +#define RUN_TEST(testfunc) \ + UNITY_NEW_TEST(#testfunc) \ + if (TEST_PROTECT()) { \ + setUp(); \ + testfunc(); \ + } \ + if (TEST_PROTECT() && (!TEST_IS_IGNORED)) \ + tearDown(); \ + UnityConcludeTest(); +``` So that's quite a macro, huh? It gives you a glimpse of what kind of stuff Unity has to deal with for every single test case. For each test case, we declare that From 5074a3d8b29978636c4f88670da7b64a44f37546 Mon Sep 17 00:00:00 2001 From: Luca Boccassi Date: Thu, 24 Jan 2019 21:44:34 +0000 Subject: [PATCH 091/454] Make unity.c compatible with c90 Avoid declaring the loop variable inside the for statement to keep compatibility with c90: unity.c:1408: error: for' loop initial declaration used outside C99 mode --- src/unity.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/unity.c b/src/unity.c index 38e7d680..be8dbc84 100644 --- a/src/unity.c +++ b/src/unity.c @@ -1523,8 +1523,9 @@ int UnityParseOptions(int argc, char** argv) { UnityOptionIncludeNamed = NULL; UnityOptionExcludeNamed = NULL; + int i; - for (int i = 1; i < argc; i++) + for (i = 1; i < argc; i++) { if (argv[i][0] == '-') { From a6e9f85f71a621ffa94d6277dcc13cc318c73c3d Mon Sep 17 00:00:00 2001 From: Fabian Zahn Date: Fri, 25 Jan 2019 07:00:32 +0100 Subject: [PATCH 092/454] Added examples for the configuration of UnityPrintFormatted and exclusion of --- examples/unity_config.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/examples/unity_config.h b/examples/unity_config.h index d586448a..bc66e7f6 100644 --- a/examples/unity_config.h +++ b/examples/unity_config.h @@ -176,6 +176,22 @@ /* #define UNITY_DOUBLE_PRECISION 0.001f */ +/* *************************** MISCELLANEOUS *********************************** + * Miscellaneous configuration options for Unity + **************************************************************************** */ + +/* Unity uses the stddef.h header included in the C standard library for the + * "NULL" macro. Define this in order to disable the include of stddef.h. If you + * do this, you have to make sure to provide your own "NULL" definition. + */ +/* #define UNITY_EXCLUDE_STDDEF_H */ + +/* Define this to enable the unity formatted print function: + * "UnityPrintFormatted" + */ +/* #define UNITY_INCLUDE_PRINT_FORMATTED */ + + /* *************************** TOOLSET CUSTOMIZATION *************************** * In addition to the options listed above, there are a number of other options * which will come in handy to customize Unity's behavior for your specific From 9d1ffe26d60f19b1ef1bc895996b2cb72ae7caea Mon Sep 17 00:00:00 2001 From: teaguecl Date: Fri, 25 Jan 2019 21:22:55 -0800 Subject: [PATCH 093/454] Fix error in example_1 This test case had an error: test_FindFunction_WhichIsBroken_ShouldReturnZeroIfItemIsNotInList_WhichWorksEvenInOurBrokenCode It was supposed to be a list of values that are NOT in the list, and none of them should be found. It incorrectly included '1' which is a value in the list. The compile option -Wno-misleading-indentation was also added to remove a compiler warning produced by gcc 7.3.0 --- examples/example_1/makefile | 1 + examples/example_1/test/TestProductionCode.c | 12 ++++++------ 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/examples/example_1/makefile b/examples/example_1/makefile index cca79b42..ee0cf730 100644 --- a/examples/example_1/makefile +++ b/examples/example_1/makefile @@ -41,6 +41,7 @@ CFLAGS += -Wno-unknown-pragmas CFLAGS += -Wstrict-prototypes CFLAGS += -Wundef CFLAGS += -Wold-style-definition +CFLAGS += -Wno-misleading-indentation TARGET_BASE1=test1 TARGET_BASE2=test2 diff --git a/examples/example_1/test/TestProductionCode.c b/examples/example_1/test/TestProductionCode.c index 80608862..404c3718 100644 --- a/examples/example_1/test/TestProductionCode.c +++ b/examples/example_1/test/TestProductionCode.c @@ -5,7 +5,7 @@ /* sometimes you may want to get at local data in a module. * for example: If you plan to pass by reference, this could be useful * however, it should often be avoided */ -extern int Counter; +extern int Counter; void setUp(void) { @@ -21,7 +21,7 @@ void test_FindFunction_WhichIsBroken_ShouldReturnZeroIfItemIsNotInList_WhichWork { /* All of these should pass */ TEST_ASSERT_EQUAL(0, FindFunction_WhichIsBroken(78)); - TEST_ASSERT_EQUAL(0, FindFunction_WhichIsBroken(1)); + TEST_ASSERT_EQUAL(0, FindFunction_WhichIsBroken(2)); TEST_ASSERT_EQUAL(0, FindFunction_WhichIsBroken(33)); TEST_ASSERT_EQUAL(0, FindFunction_WhichIsBroken(999)); TEST_ASSERT_EQUAL(0, FindFunction_WhichIsBroken(-1)); @@ -31,9 +31,9 @@ void test_FindFunction_WhichIsBroken_ShouldReturnTheIndexForItemsInList_WhichWil { /* You should see this line fail in your test summary */ TEST_ASSERT_EQUAL(1, FindFunction_WhichIsBroken(34)); - - /* Notice the rest of these didn't get a chance to run because the line above failed. - * Unit tests abort each test function on the first sign of trouble. + + /* Notice the rest of these didn't get a chance to run because the line above failed. + * Unit tests abort each test function on the first sign of trouble. * Then NEXT test function runs as normal. */ TEST_ASSERT_EQUAL(8, FindFunction_WhichIsBroken(8888)); } @@ -42,7 +42,7 @@ void test_FunctionWhichReturnsLocalVariable_ShouldReturnTheCurrentCounterValue(v { /* This should be true because setUp set this up for us before this test */ TEST_ASSERT_EQUAL_HEX(0x5a5a, FunctionWhichReturnsLocalVariable()); - + /* This should be true because we can still change our answer */ Counter = 0x1234; TEST_ASSERT_EQUAL_HEX(0x1234, FunctionWhichReturnsLocalVariable()); From bc2ab233eeb6d316f6a27a4d9e7e59357c03d93b Mon Sep 17 00:00:00 2001 From: teaguecl Date: Fri, 25 Jan 2019 21:51:25 -0800 Subject: [PATCH 094/454] Fix error in example_1 and example_2 This test case had an error in both examples: test_FindFunction_WhichIsBroken_ShouldReturnZeroIfItemIsNotInList_WhichWorksEvenInOurBrokenCode It was supposed to be a list of values that are NOT in the list, and none of them should be found. It incorrectly included '1' --- examples/example_1/makefile | 1 - examples/example_2/test/TestProductionCode.c | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/examples/example_1/makefile b/examples/example_1/makefile index ee0cf730..cca79b42 100644 --- a/examples/example_1/makefile +++ b/examples/example_1/makefile @@ -41,7 +41,6 @@ CFLAGS += -Wno-unknown-pragmas CFLAGS += -Wstrict-prototypes CFLAGS += -Wundef CFLAGS += -Wold-style-definition -CFLAGS += -Wno-misleading-indentation TARGET_BASE1=test1 TARGET_BASE2=test2 diff --git a/examples/example_2/test/TestProductionCode.c b/examples/example_2/test/TestProductionCode.c index ff318abb..b8fb95c0 100644 --- a/examples/example_2/test/TestProductionCode.c +++ b/examples/example_2/test/TestProductionCode.c @@ -23,7 +23,7 @@ TEST(ProductionCode, FindFunction_WhichIsBroken_ShouldReturnZeroIfItemIsNotInLis { //All of these should pass TEST_ASSERT_EQUAL(0, FindFunction_WhichIsBroken(78)); - TEST_ASSERT_EQUAL(0, FindFunction_WhichIsBroken(1)); + TEST_ASSERT_EQUAL(0, FindFunction_WhichIsBroken(2)); TEST_ASSERT_EQUAL(0, FindFunction_WhichIsBroken(33)); TEST_ASSERT_EQUAL(0, FindFunction_WhichIsBroken(999)); TEST_ASSERT_EQUAL(0, FindFunction_WhichIsBroken(-1)); From b723c9f25012155b34d698094155164f465a0412 Mon Sep 17 00:00:00 2001 From: Fabian Zahn Date: Wed, 30 Jan 2019 21:10:23 +0100 Subject: [PATCH 095/454] Added braces to avoid implementation solely based on operator precedence. --- src/unity.c | 51 ++++++++++++++++++++++--------------------- src/unity_internals.h | 12 +++++----- 2 files changed, 32 insertions(+), 31 deletions(-) diff --git a/src/unity.c b/src/unity.c index f4d8ed20..42bc47ab 100644 --- a/src/unity.c +++ b/src/unity.c @@ -105,7 +105,7 @@ static UNITY_UINT UnityPrintAnsiEscapeString(const char* string) const char* pch = string; UNITY_UINT count = 0; - while (*pch && *pch != 'm') + while (*pch && (*pch != 'm')) { UNITY_OUTPUT_CHAR(*pch); pch++; @@ -129,7 +129,7 @@ void UnityPrint(const char* string) { #ifdef UNITY_OUTPUT_COLOR /* print ANSI escape code */ - if (*pch == 27 && *(pch + 1) == '[') + if ((*pch == 27) && (*(pch + 1) == '[')) { pch += UnityPrintAnsiEscapeString(pch); continue; @@ -232,7 +232,7 @@ void UnityPrintFormatted(const char* format, ...) } #ifdef UNITY_OUTPUT_COLOR /* print ANSI escape code */ - else if (*pch == 27 && *(pch + 1) == '[') + else if ((*pch == 27) && (*(pch + 1) == '[')) { pch += UnityPrintAnsiEscapeString(pch); continue; @@ -262,7 +262,7 @@ void UnityPrintLen(const char* string, const UNITY_UINT32 length) if (pch != NULL) { - while (*pch && (UNITY_UINT32)(pch - string) < length) + while (*pch && ((UNITY_UINT32)(pch - string) < length)) { /* printable characters plus CR & LF are printed */ if ((*pch <= 126) && (*pch >= 32)) @@ -351,6 +351,7 @@ void UnityPrintNumberHex(const UNITY_UINT number, const char nibbles_to_print) { int nibble; char nibbles = nibbles_to_print; + if ((unsigned)nibbles > (2 * sizeof(number))) { nibbles = 2 * sizeof(number); @@ -422,7 +423,7 @@ void UnityPrintFloat(const UNITY_DOUBLE input_number) UNITY_DOUBLE number = input_number; /* print minus sign (including for negative zero) */ - if (number < 0.0f || (number == 0.0f && 1.0f / number < 0.0f)) + if ((number < 0.0f) || ((number == 0.0f) && ((1.0f / number) < 0.0f))) { UNITY_OUTPUT_CHAR('-'); number = -number; @@ -459,7 +460,7 @@ void UnityPrintFloat(const UNITY_DOUBLE input_number) { UNITY_DOUBLE factor = 1.0f; - while (number < (UNITY_DOUBLE)max_scaled / 1e10f) { number *= 1e10f; exponent -= 10; } + while (number < (UNITY_DOUBLE)max_scaled / 1e10f) { number *= 1e10f; exponent -= 10; } while (number * factor < (UNITY_DOUBLE)min_scaled) { factor *= 10.0f; exponent--; } number *= factor; @@ -468,7 +469,7 @@ void UnityPrintFloat(const UNITY_DOUBLE input_number) { UNITY_DOUBLE divisor = 1.0f; - while (number > (UNITY_DOUBLE)min_scaled * 1e10f) { number /= 1e10f; exponent += 10; } + while (number > (UNITY_DOUBLE)min_scaled * 1e10f) { number /= 1e10f; exponent += 10; } while (number / divisor > (UNITY_DOUBLE)max_scaled) { divisor *= 10.0f; exponent++; } number /= divisor; @@ -494,7 +495,7 @@ void UnityPrintFloat(const UNITY_DOUBLE input_number) #ifndef UNITY_ROUND_TIES_AWAY_FROM_ZERO /* round to even if exactly between two integers */ - if ((n & 1) && ((UNITY_DOUBLE)n - number == 0.5f)) + if ((n & 1) && (((UNITY_DOUBLE)n - number) == 0.5f)) n--; #endif @@ -507,11 +508,11 @@ void UnityPrintFloat(const UNITY_DOUBLE input_number) } /* determine where to place decimal point */ - decimals = (exponent <= 0 && exponent >= -(sig_digits + 3)) ? -exponent : (sig_digits - 1); + decimals = ((exponent <= 0) && (exponent >= -(sig_digits + 3))) ? (-exponent) : (sig_digits - 1); exponent += decimals; /* truncate trailing zeroes after decimal point */ - while (decimals > 0 && n % 10 == 0) + while ((decimals > 0) && ((n % 10) == 0)) { n /= 10; decimals--; @@ -519,14 +520,14 @@ void UnityPrintFloat(const UNITY_DOUBLE input_number) /* build up buffer in reverse order */ digits = 0; - while (n != 0 || digits < decimals + 1) + while ((n != 0) || (digits < (decimals + 1))) { buf[digits++] = (char)('0' + n % 10); n /= 10; } while (digits > 0) { - if(digits == decimals) UNITY_OUTPUT_CHAR('.'); + if (digits == decimals) { UNITY_OUTPUT_CHAR('.'); } UNITY_OUTPUT_CHAR(buf[--digits]); } @@ -535,7 +536,7 @@ void UnityPrintFloat(const UNITY_DOUBLE input_number) { UNITY_OUTPUT_CHAR('e'); - if(exponent < 0) + if (exponent < 0) { UNITY_OUTPUT_CHAR('-'); exponent = -exponent; @@ -546,7 +547,7 @@ void UnityPrintFloat(const UNITY_DOUBLE input_number) } digits = 0; - while (exponent != 0 || digits < 2) + while ((exponent != 0) || (digits < 2)) { buf[digits++] = (char)('0' + exponent % 10); exponent /= 10; @@ -772,18 +773,18 @@ void UnityAssertGreaterOrLessOrEqualNumber(const UNITY_INT threshold, int failed = 0; RETURN_IF_FAIL_OR_IGNORE; - if (threshold == actual && compare & UNITY_EQUAL_TO) return; - if (threshold == actual) failed = 1; + if ((threshold == actual) && (compare & UNITY_EQUAL_TO)) { return; } + if ((threshold == actual)) { failed = 1; } if ((style & UNITY_DISPLAY_RANGE_INT) == UNITY_DISPLAY_RANGE_INT) { - if (actual > threshold && compare & UNITY_SMALLER_THAN) failed = 1; - if (actual < threshold && compare & UNITY_GREATER_THAN) failed = 1; + if ((actual > threshold) && (compare & UNITY_SMALLER_THAN)) { failed = 1; } + if ((actual < threshold) && (compare & UNITY_GREATER_THAN)) { failed = 1; } } else /* UINT or HEX */ { - if ((UNITY_UINT)actual > (UNITY_UINT)threshold && compare & UNITY_SMALLER_THAN) failed = 1; - if ((UNITY_UINT)actual < (UNITY_UINT)threshold && compare & UNITY_GREATER_THAN) failed = 1; + if (((UNITY_UINT)actual > (UNITY_UINT)threshold) && (compare & UNITY_SMALLER_THAN)) { failed = 1; } + if (((UNITY_UINT)actual < (UNITY_UINT)threshold) && (compare & UNITY_GREATER_THAN)) { failed = 1; } } if (failed) @@ -791,9 +792,9 @@ void UnityAssertGreaterOrLessOrEqualNumber(const UNITY_INT threshold, UnityTestResultsFailBegin(lineNumber); UnityPrint(UnityStrExpected); UnityPrintNumberByStyle(actual, style); - if (compare & UNITY_GREATER_THAN) UnityPrint(UnityStrGt); - if (compare & UNITY_SMALLER_THAN) UnityPrint(UnityStrLt); - if (compare & UNITY_EQUAL_TO) UnityPrint(UnityStrOrEqual); + if (compare & UNITY_GREATER_THAN) { UnityPrint(UnityStrGt); } + if (compare & UNITY_SMALLER_THAN) { UnityPrint(UnityStrLt); } + if (compare & UNITY_EQUAL_TO) { UnityPrint(UnityStrOrEqual); } UnityPrintNumberByStyle(threshold, style); UnityAddMsgIfSpecified(msg); UNITY_FAIL_AND_BAIL; @@ -836,7 +837,7 @@ void UnityAssertEqualIntArray(UNITY_INTERNAL_PTR expected, UNITY_FAIL_AND_BAIL; } - while ((elements > 0) && elements--) + while ((elements > 0) && (elements--)) { UNITY_INT expect_val; UNITY_INT actual_val; @@ -865,7 +866,7 @@ void UnityAssertEqualIntArray(UNITY_INTERNAL_PTR expected, if (expect_val != actual_val) { - if (style & UNITY_DISPLAY_RANGE_UINT && length < sizeof(expect_val)) + if ((style & UNITY_DISPLAY_RANGE_UINT) && (length < sizeof(expect_val))) { /* For UINT, remove sign extension (padding 1's) from signed type casts above */ UNITY_INT mask = 1; mask = (mask << 8 * length) - 1; diff --git a/src/unity_internals.h b/src/unity_internals.h index e91d9bc9..0024d918 100644 --- a/src/unity_internals.h +++ b/src/unity_internals.h @@ -403,12 +403,12 @@ UNITY_DISPLAY_STYLE_UINT = sizeof(unsigned) + UNITY_DISPLAY_RANGE_UINT, typedef enum { - UNITY_WITHIN = 0, - UNITY_EQUAL_TO = 1, - UNITY_GREATER_THAN = 2, - UNITY_GREATER_OR_EQUAL = 2 + UNITY_EQUAL_TO, - UNITY_SMALLER_THAN = 4, - UNITY_SMALLER_OR_EQUAL = 4 + UNITY_EQUAL_TO, + UNITY_WITHIN = 0x0, + UNITY_EQUAL_TO = 0x1, + UNITY_GREATER_THAN = 0x2, + UNITY_GREATER_OR_EQUAL = 0x2 + UNITY_EQUAL_TO, + UNITY_SMALLER_THAN = 0x4, + UNITY_SMALLER_OR_EQUAL = 0x4 + UNITY_EQUAL_TO, UNITY_UNKNOWN } UNITY_COMPARISON_T; From 145691519b8865f5275d7e0ca2e1e06fe8942830 Mon Sep 17 00:00:00 2001 From: elliot Date: Wed, 5 Dec 2018 21:14:25 +0000 Subject: [PATCH 096/454] Add ability to override name of the 'resetTest' function This allows multiple groups to be compiled into the same executable by naming each function uniquely. --- auto/generate_test_runner.rb | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/auto/generate_test_runner.rb b/auto/generate_test_runner.rb index 2acda0f3..51e004bd 100644 --- a/auto/generate_test_runner.rb +++ b/auto/generate_test_runner.rb @@ -27,6 +27,7 @@ def self.default_options mock_suffix: '', setup_name: 'setUp', teardown_name: 'tearDown', + test_reset_name: 'resetTest', main_name: 'main', # set to :auto to automatically generate each time main_export_decl: '', cmdline_args: false, @@ -322,8 +323,8 @@ def create_runtest(output, used_mocks) def create_reset(output, used_mocks) output.puts("\n/*=======Test Reset Option=====*/") - output.puts('void resetTest(void);') - output.puts('void resetTest(void)') + output.puts("void #{@options[:test_reset_name]}(void);") + output.puts("void #{@options[:test_reset_name]}(void)") output.puts('{') output.puts(' CMock_Verify();') unless used_mocks.empty? output.puts(' CMock_Destroy();') unless used_mocks.empty? @@ -457,6 +458,7 @@ def create_h_file(output, filename, tests, testfile_includes, used_mocks) ' --teardown_name="" - redefine tearDown func name to something else', ' --main_name="" - redefine main func name to something else', ' --test_prefix="" - redefine test prefix from default test|spec|should', + ' --test_reset_name="" - redefine resetTest func name to something else', ' --suite_setup="" - code to execute for setup of entire suite', ' --suite_teardown="" - code to execute for teardown of entire suite', ' --use_param_tests=1 - enable parameterized tests (disabled by default)', @@ -468,4 +470,4 @@ def create_h_file(output, filename, tests, testfile_includes, used_mocks) ARGV[1] = ARGV[0].gsub('.c', '_Runner.c') unless ARGV[1] UnityTestRunnerGenerator.new(options).run(ARGV[0], ARGV[1]) -end +end \ No newline at end of file From 076f0fff5625ec7f7592fd702abd24b0442a2151 Mon Sep 17 00:00:00 2001 From: elliot Date: Sat, 1 Dec 2018 21:43:49 +0000 Subject: [PATCH 097/454] Improvements to the execution time feature - Running time macros have been made more portable, previously it was not possible to override all macros - Running time macros will be executed by default test runner, and auto test runners - Adds a default execution time implementation for unix. (Previous default implementation only worked on Windows) - For embedded platforms there is a simple method of getting a default implementation by defining a single macro UNITY_CLOCK_MS() - Removed need for UNITY_EXEC_TIME_RESET. This was not being used for the default implementations, if anything ever did need reset-like functionality it could simply be wrapped up with the start or stop macros for that platform --- auto/generate_test_runner.rb | 2 + src/unity.c | 5 +- src/unity_internals.h | 89 +++++++++++++++++++++--------------- test/tests/testunity.c | 4 +- 4 files changed, 59 insertions(+), 41 deletions(-) diff --git a/auto/generate_test_runner.rb b/auto/generate_test_runner.rb index 2acda0f3..c83cbb4e 100644 --- a/auto/generate_test_runner.rb +++ b/auto/generate_test_runner.rb @@ -299,6 +299,7 @@ def create_runtest(output, used_mocks) output.puts(' Unity.CurrentTestLineNumber = TestLineNum; \\') output.puts(' if (UnityTestMatches()) { \\') if @options[:cmdline_args] output.puts(' Unity.NumberOfTests++; \\') + output.puts(' UNITY_EXEC_TIME_START(); \\') output.puts(' CMock_Init(); \\') unless used_mocks.empty? output.puts(' UNITY_CLR_DETAILS(); \\') unless used_mocks.empty? output.puts(' if (TEST_PROTECT()) \\') @@ -315,6 +316,7 @@ def create_runtest(output, used_mocks) output.puts(' CMock_Verify(); \\') unless used_mocks.empty? output.puts(' } \\') output.puts(' CMock_Destroy(); \\') unless used_mocks.empty? + output.puts(' UNITY_EXEC_TIME_STOP(); \\') output.puts(' UnityConcludeTest(); \\') output.puts(' } \\') if @options[:cmdline_args] output.puts("}\n") diff --git a/src/unity.c b/src/unity.c index 42bc47ab..c7976496 100644 --- a/src/unity.c +++ b/src/unity.c @@ -599,7 +599,7 @@ void UnityConcludeTest(void) Unity.CurrentTestFailed = 0; Unity.CurrentTestIgnored = 0; - UNITY_EXEC_TIME_RESET(); + UNITY_PRINT_EXEC_TIME(); UNITY_PRINT_EOL(); UNITY_FLUSH_CALL(); } @@ -1589,6 +1589,7 @@ void UnityDefaultTestRun(UnityTestFunction Func, const char* FuncName, const int Unity.CurrentTestLineNumber = (UNITY_LINE_TYPE)FuncLineNum; Unity.NumberOfTests++; UNITY_CLR_DETAILS(); + UNITY_EXEC_TIME_START(); if (TEST_PROTECT()) { setUp(); @@ -1598,6 +1599,7 @@ void UnityDefaultTestRun(UnityTestFunction Func, const char* FuncName, const int { tearDown(); } + UNITY_EXEC_TIME_STOP(); UnityConcludeTest(); } @@ -1612,7 +1614,6 @@ void UnityBegin(const char* filename) Unity.TestIgnores = 0; Unity.CurrentTestFailed = 0; Unity.CurrentTestIgnored = 0; - UNITY_EXEC_TIME_RESET(); UNITY_CLR_DETAILS(); UNITY_OUTPUT_START(); diff --git a/src/unity_internals.h b/src/unity_internals.h index 0024d918..7539bc95 100644 --- a/src/unity_internals.h +++ b/src/unity_internals.h @@ -40,10 +40,6 @@ #include #endif -#ifndef UNITY_EXCLUDE_TIME_H -#include -#endif - /*------------------------------------------------------- * Guess Widths If Not Specified *-------------------------------------------------------*/ @@ -297,42 +293,67 @@ typedef UNITY_FLOAT_TYPE UNITY_FLOAT; #define UNITY_OUTPUT_COMPLETE() #endif -#ifndef UNITY_EXEC_TIME_RESET #ifdef UNITY_INCLUDE_EXEC_TIME -#define UNITY_EXEC_TIME_RESET()\ - Unity.CurrentTestStartTime = 0;\ - Unity.CurrentTestStopTime = 0; -#else -#define UNITY_EXEC_TIME_RESET() -#endif + #if !defined(UNITY_EXEC_TIME_START) && \ + !defined(UNITY_EXEC_TIME_STOP) && \ + !defined(UNITY_PRINT_EXEC_TIME) && \ + !defined(UNITY_TIME_TYPE) + /* If none any of these macros are defined then try to provide a default implementation */ + + #if defined(UNITY_CLOCK_MS) + /* This is a simple way to get a default implementation on platforms that support getting a millisecond counter */ + #define UNITY_TIME_TYPE UNITY_UINT + #define UNITY_EXEC_TIME_START() Unity.CurrentTestStartTime = UNITY_CLOCK_MS() + #define UNITY_EXEC_TIME_STOP() Unity.CurrentTestStopTime = UNITY_CLOCK_MS() + #define UNITY_PRINT_EXEC_TIME() { \ + UNITY_UINT execTimeMs = (Unity.CurrentTestStopTime - Unity.CurrentTestStartTime); \ + UnityPrint(" ("); \ + UnityPrintNumberUnsigned(execTimeMs); \ + UnityPrint(" ms)"); \ + } + #elif defined(_WIN32) + #include + #define UNITY_TIME_TYPE clock_t + #define UNITY_GET_TIME(t) t = (clock_t)((clock() * 1000) / CLOCKS_PER_SEC) + #define UNITY_EXEC_TIME_START() UNITY_GET_TIME(Unity.CurrentTestStartTime) + #define UNITY_EXEC_TIME_STOP() UNITY_GET_TIME(Unity.CurrentTestStopTime) + #define UNITY_PRINT_EXEC_TIME() { \ + UNITY_UINT execTimeMs = (Unity.CurrentTestStopTime - Unity.CurrentTestStartTime); \ + UnityPrint(" ("); \ + UnityPrintNumberUnsigned(execTimeMs); \ + UnityPrint(" ms)"); \ + } + #elif defined(__unix__) + #include + #define UNITY_TIME_TYPE struct timespec + #define UNITY_GET_TIME(t) clock_gettime(CLOCK_MONOTONIC, &t) + #define UNITY_EXEC_TIME_START() UNITY_GET_TIME(Unity.CurrentTestStartTime) + #define UNITY_EXEC_TIME_STOP() UNITY_GET_TIME(Unity.CurrentTestStopTime) + #define UNITY_PRINT_EXEC_TIME() { \ + UNITY_UINT execTimeMs = ((Unity.CurrentTestStopTime.tv_sec - Unity.CurrentTestStartTime.tv_sec) * 1000L); \ + execTimeMs += ((Unity.CurrentTestStopTime.tv_nsec - Unity.CurrentTestStartTime.tv_nsec) / 1000000L); \ + UnityPrint(" ("); \ + UnityPrintNumberUnsigned(execTimeMs); \ + UnityPrint(" ms)"); \ + } + #endif + #endif #endif #ifndef UNITY_EXEC_TIME_START -#ifdef UNITY_INCLUDE_EXEC_TIME -#define UNITY_EXEC_TIME_START() Unity.CurrentTestStartTime = UNITY_CLOCK_MS(); -#else -#define UNITY_EXEC_TIME_START() -#endif +#define UNITY_EXEC_TIME_START() do{}while(0) #endif #ifndef UNITY_EXEC_TIME_STOP -#ifdef UNITY_INCLUDE_EXEC_TIME -#define UNITY_EXEC_TIME_STOP() Unity.CurrentTestStopTime = UNITY_CLOCK_MS(); -#else -#define UNITY_EXEC_TIME_STOP() +#define UNITY_EXEC_TIME_STOP() do{}while(0) #endif + +#ifndef UNITY_TIME_TYPE +#define UNITY_TIME_TYPE UNITY_UINT #endif #ifndef UNITY_PRINT_EXEC_TIME -#ifdef UNITY_INCLUDE_EXEC_TIME -#define UNITY_PRINT_EXEC_TIME() \ - UnityPrint(" (");\ - UNITY_COUNTER_TYPE execTimeMs = (Unity.CurrentTestStopTime - Unity.CurrentTestStartTime);\ - UnityPrintNumberUnsigned(execTimeMs);\ - UnityPrint(" ms)"); -#else -#define UNITY_PRINT_EXEC_TIME() -#endif +#define UNITY_PRINT_EXEC_TIME() do{}while(0) #endif /*------------------------------------------------------- @@ -449,8 +470,8 @@ struct UNITY_STORAGE_T UNITY_COUNTER_TYPE CurrentTestFailed; UNITY_COUNTER_TYPE CurrentTestIgnored; #ifdef UNITY_INCLUDE_EXEC_TIME - UNITY_COUNTER_TYPE CurrentTestStartTime; - UNITY_COUNTER_TYPE CurrentTestStopTime; + UNITY_TIME_TYPE CurrentTestStartTime; + UNITY_TIME_TYPE CurrentTestStopTime; #endif #ifndef UNITY_EXCLUDE_SETJMP_H jmp_buf AbortFrame; @@ -655,12 +676,6 @@ extern const char UnityStrErr64[]; #define TEST_ABORT() return #endif -#ifndef UNITY_EXCLUDE_TIME_H -#define UNITY_CLOCK_MS() (UNITY_COUNTER_TYPE)((clock() * 1000) / CLOCKS_PER_SEC) -#else -#define UNITY_CLOCK_MS() -#endif - /* This tricky series of macros gives us an optional line argument to treat it as RUN_TEST(func, num=__LINE__) */ #ifndef RUN_TEST #ifdef __STDC_VERSION__ diff --git a/test/tests/testunity.c b/test/tests/testunity.c index 366deba3..aecd272a 100644 --- a/test/tests/testunity.c +++ b/test/tests/testunity.c @@ -104,8 +104,8 @@ void testUnitySizeInitializationReminder(void) UNITY_COUNTER_TYPE CurrentTestFailed; UNITY_COUNTER_TYPE CurrentTestIgnored; #ifdef UNITY_INCLUDE_EXEC_TIME - UNITY_COUNTER_TYPE CurrentTestStartTime; - UNITY_COUNTER_TYPE CurrentTestStopTime; + UNITY_TIME_TYPE CurrentTestStartTime; + UNITY_TIME_TYPE CurrentTestStopTime; #endif #ifndef UNITY_EXCLUDE_SETJMP_H jmp_buf AbortFrame; From 9dc7cb1b5cf9d0cbfc3227b7acbde446190054b0 Mon Sep 17 00:00:00 2001 From: Michael Brockus Date: Mon, 18 Feb 2019 12:35:53 -0800 Subject: [PATCH 098/454] Adding CMake script to unity test framework. --- CMakeLists.txt | 68 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 00000000..282ea4ca --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,68 @@ +##################################################### +# FILE NAME CMakeLists.txt # +# # +# PURPOSE contains CMake statements. # +# # +##################################################### +cmake_minimum_required(VERSION 3.13.2.0 FATAL_ERROR) + + + +# +# CMake: Declare project +# +project(unity LANGUAGES C DESCRIPTION "C Unit testing framework.") + + + +# +# CMake: Creation of library +# +add_library("unity" STATIC) + + + +# +# CMake: Adding source to target +# +target_sources("unity" PRIVATE "src/unity.c") + + + +# +# CMake: Including directories to target +# +target_include_directories("unity" + PUBLIC + "$" + "$" + + PRIVATE "src" +) + + + +# +# CMake: Give target an alias +# +add_library("unity::framework" ALIAS "unity") + + + +# +# CMake: export project +# +install(TARGETS "unity" EXPORT "unityConfig" + ARCHIVE DESTINATION "${CMAKE_CURRENT_SOURCE_DIR}/${CMAKE_INSTALL_LIBDIR}" + LIBRARY DESTINATION "${CMAKE_CURRENT_SOURCE_DIR}/${CMAKE_INSTALL_LIBDIR}" + RUNTIME DESTINATION "${CMAKE_CURRENT_SOURCE_DIR}/${CMAKE_INSTALL_BINDIR}" + + INCLUDES DESTINATION "${CMAKE_INSTALL_LIBDIR}" +) + +install(DIRECTORY src/ DESTINATION src) + +install(EXPORT unityConfig DESTINATION share/unityConfig/cmake) + +# This makes the project importable from the build directory +export(TARGETS unity FILE unityConfig.cmake) \ No newline at end of file From 3e4d064c42cf8db428b96d72c463b7dd71b5cc71 Mon Sep 17 00:00:00 2001 From: Michael Brockus Date: Tue, 19 Feb 2019 09:45:50 -0800 Subject: [PATCH 099/454] Singing my name on the script. --- CMakeLists.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 282ea4ca..0eddcd7e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,8 @@ ##################################################### # FILE NAME CMakeLists.txt # # # +# WRITTEN BY Michael Brockus. # +# # # PURPOSE contains CMake statements. # # # ##################################################### @@ -65,4 +67,4 @@ install(DIRECTORY src/ DESTINATION src) install(EXPORT unityConfig DESTINATION share/unityConfig/cmake) # This makes the project importable from the build directory -export(TARGETS unity FILE unityConfig.cmake) \ No newline at end of file +export(TARGETS unity FILE unityConfig.cmake) From ead95b3ab8ebed0c5d51f6a20b939b942899144f Mon Sep 17 00:00:00 2001 From: Jason Heeris Date: Fri, 22 Feb 2019 08:38:29 +1100 Subject: [PATCH 100/454] Removed leading underscore from module generator header guards. --- auto/generate_module.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/auto/generate_module.rb b/auto/generate_module.rb index fb8c7ac4..92aa5146 100644 --- a/auto/generate_module.rb +++ b/auto/generate_module.rb @@ -35,11 +35,11 @@ '.freeze # TEMPLATE_INC -TEMPLATE_INC ||= '#ifndef _%3$s_H -#define _%3$s_H +TEMPLATE_INC ||= '#ifndef %3$s_H +#define %3$s_H %2$s -#endif // _%3$s_H +#endif // %3$s_H '.freeze class UnityModuleGenerator From 0dafa0b306154697ff91a505153354cc7946f600 Mon Sep 17 00:00:00 2001 From: Alexander Brevig Date: Tue, 12 Mar 2019 00:17:37 +0100 Subject: [PATCH 101/454] use unary minus on the incoming int instead of the casted uint --- src/unity.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/unity.c b/src/unity.c index 42bc47ab..4888962f 100644 --- a/src/unity.c +++ b/src/unity.c @@ -321,7 +321,7 @@ void UnityPrintNumber(const UNITY_INT number_to_print) { /* A negative number, including MIN negative */ UNITY_OUTPUT_CHAR('-'); - number = -number; + number = (UNITY_UINT)-number_to_print; } UnityPrintNumberUnsigned(number); } From 6315c4c4c345afda673c72fd1339e94394fc060b Mon Sep 17 00:00:00 2001 From: Dom Postorivo Date: Sat, 23 Mar 2019 19:58:15 -0400 Subject: [PATCH 102/454] Fix travis config --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 5a15f037..8d32264a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,7 +10,7 @@ matrix: compiler: gcc before_install: - - if [ "$TRAVIS_OS_NAME" == "osx" ]; then rvm install 2.1 && rvm use 2.1 && ruby -v; fi + - if [ "$TRAVIS_OS_NAME" == "osx" ]; then rvm install 2.3 && rvm use 2.3 && ruby -v; fi - if [ "$TRAVIS_OS_NAME" == "linux" ]; then sudo apt-get install --assume-yes --quiet gcc-multilib; fi install: - gem install rspec From aecc642594245cdd069d547e83256ad92dbfcde2 Mon Sep 17 00:00:00 2001 From: Tomer Yogev Date: Tue, 26 Mar 2019 17:32:30 +0200 Subject: [PATCH 103/454] recursive search for target test files in test summary python script --- auto/unity_test_summary.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/auto/unity_test_summary.py b/auto/unity_test_summary.py index 4c20e528..00c0da8c 100644 --- a/auto/unity_test_summary.py +++ b/auto/unity_test_summary.py @@ -121,7 +121,7 @@ def parse_test_summary(self, summary): targets_dir = sys.argv[1] else: targets_dir = './' - targets = list(map(lambda x: x.replace('\\', '/'), glob(targets_dir + '*.test*'))) + targets = list(map(lambda x: x.replace('\\', '/'), glob(targets_dir + '**/*.test*', recursive=True))) if len(targets) == 0: raise Exception("No *.testpass or *.testfail files found in '%s'" % targets_dir) uts.set_targets(targets) From 2191b2ba8ef4b22de43a2707a31d92322475be29 Mon Sep 17 00:00:00 2001 From: Fredrik Rothamel Date: Wed, 13 Mar 2019 13:41:29 +0100 Subject: [PATCH 104/454] Allow multi line test-function definitions. --- auto/generate_test_runner.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/auto/generate_test_runner.rb b/auto/generate_test_runner.rb index 2acda0f3..e7ca698c 100644 --- a/auto/generate_test_runner.rb +++ b/auto/generate_test_runner.rb @@ -112,7 +112,7 @@ def find_tests(source) lines.each_with_index do |line, _index| # find tests - next unless line =~ /^((?:\s*TEST_CASE\s*\(.*?\)\s*)*)\s*void\s+((?:#{@options[:test_prefix]}).*)\s*\(\s*(.*)\s*\)/ + next unless line =~ /^((?:\s*TEST_CASE\s*\(.*?\)\s*)*)\s*void\s+((?:#{@options[:test_prefix]}).*)\s*\(\s*(.*)\s*\)/m arguments = Regexp.last_match(1) name = Regexp.last_match(2) call = Regexp.last_match(3) From 52ff8613a234248df3ab8d0ea794d54bd646e699 Mon Sep 17 00:00:00 2001 From: Fabian Zahn Date: Sun, 7 Apr 2019 11:56:34 +0200 Subject: [PATCH 105/454] Fixed maximum number of nibbles for processor where sizeof() operator doesn't return the size of a type in 8-bit bytes (e.g. the TI C2000 series). --- src/unity.c | 4 ++-- src/unity_internals.h | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/unity.c b/src/unity.c index 4888962f..8022e24d 100644 --- a/src/unity.c +++ b/src/unity.c @@ -352,9 +352,9 @@ void UnityPrintNumberHex(const UNITY_UINT number, const char nibbles_to_print) int nibble; char nibbles = nibbles_to_print; - if ((unsigned)nibbles > (2 * sizeof(number))) + if ((unsigned)nibbles > UNITY_MAX_NIBBLES) { - nibbles = 2 * sizeof(number); + nibbles = UNITY_MAX_NIBBLES; } while (nibbles > 0) diff --git a/src/unity_internals.h b/src/unity_internals.h index 0024d918..88b8baa4 100644 --- a/src/unity_internals.h +++ b/src/unity_internals.h @@ -122,18 +122,20 @@ * 64-bit Support *-------------------------------------------------------*/ +/* Auto-detect 64 Bit Support */ #ifndef UNITY_SUPPORT_64 #if UNITY_LONG_WIDTH == 64 || UNITY_POINTER_WIDTH == 64 #define UNITY_SUPPORT_64 #endif #endif +/* 64-Bit Support Dependent Configuration */ #ifndef UNITY_SUPPORT_64 /* No 64-bit Support */ typedef UNITY_UINT32 UNITY_UINT; typedef UNITY_INT32 UNITY_INT; + #define UNITY_MAX_NIBBLES (8) /* Maximum number of nibbles in a UNITY_(U)INT */ #else - /* 64-bit Support */ #if (UNITY_LONG_WIDTH == 32) typedef unsigned long long UNITY_UINT64; @@ -146,7 +148,7 @@ #endif typedef UNITY_UINT64 UNITY_UINT; typedef UNITY_INT64 UNITY_INT; - + #define UNITY_MAX_NIBBLES (16) /* Maximum number of nibbles in a UNITY_(U)INT */ #endif /*------------------------------------------------------- From d01e32299ee792aa72e35e91682c8b6d8696d9ec Mon Sep 17 00:00:00 2001 From: Fabian Zahn Date: Sat, 6 Apr 2019 11:55:24 +0200 Subject: [PATCH 106/454] Used sizeof() operator for pointer increments and substituted sizeof() operator for the unsigned int mask calculation to "UNITY_INT_WIDTH / 8" in function "UnityAssertEqualIntArray". --- src/unity.c | 45 ++++++++++++++++++++++++++++--------------- src/unity.h | 2 +- src/unity_internals.h | 6 +++--- 3 files changed, 33 insertions(+), 20 deletions(-) diff --git a/src/unity.c b/src/unity.c index 4888962f..38dc8019 100644 --- a/src/unity.c +++ b/src/unity.c @@ -1,6 +1,6 @@ /* ========================================================================= Unity Project - A Test Framework for C - Copyright (c) 2007-14 Mike Karlesky, Mark VanderVoord, Greg Williams + Copyright (c) 2007-19 Mike Karlesky, Mark VanderVoord, Greg Williams [Released under MIT License. Please refer to license.txt for details] ============================================================================ */ @@ -693,7 +693,8 @@ static int UnityIsOneArrayNull(UNITY_INTERNAL_PTR expected, const UNITY_LINE_TYPE lineNumber, const char* msg) { - if (expected == actual) return 0; /* Both are NULL or same pointer */ + /* Both are NULL or same pointer */ + if (expected == actual) { return 0; } /* print and return true if just expected is NULL */ if (expected == NULL) @@ -817,8 +818,9 @@ void UnityAssertEqualIntArray(UNITY_INTERNAL_PTR expected, const UNITY_DISPLAY_STYLE_T style, const UNITY_FLAGS_T flags) { - UNITY_UINT32 elements = num_elements; - unsigned int length = style & 0xF; + UNITY_UINT32 elements = num_elements; + unsigned int length = style & 0xF; + unsigned int increment = 0; RETURN_IF_FAIL_OR_IGNORE; @@ -841,32 +843,41 @@ void UnityAssertEqualIntArray(UNITY_INTERNAL_PTR expected, { UNITY_INT expect_val; UNITY_INT actual_val; + switch (length) { case 1: expect_val = *(UNITY_PTR_ATTRIBUTE const UNITY_INT8*)expected; actual_val = *(UNITY_PTR_ATTRIBUTE const UNITY_INT8*)actual; + increment = sizeof(UNITY_INT8); break; + case 2: expect_val = *(UNITY_PTR_ATTRIBUTE const UNITY_INT16*)expected; actual_val = *(UNITY_PTR_ATTRIBUTE const UNITY_INT16*)actual; + increment = sizeof(UNITY_INT16); break; + #ifdef UNITY_SUPPORT_64 case 8: expect_val = *(UNITY_PTR_ATTRIBUTE const UNITY_INT64*)expected; actual_val = *(UNITY_PTR_ATTRIBUTE const UNITY_INT64*)actual; + increment = sizeof(UNITY_INT64); break; #endif - default: /* length 4 bytes */ + + default: /* default is length 4 bytes */ + case 4: expect_val = *(UNITY_PTR_ATTRIBUTE const UNITY_INT32*)expected; actual_val = *(UNITY_PTR_ATTRIBUTE const UNITY_INT32*)actual; + increment = sizeof(UNITY_INT32); length = 4; break; } if (expect_val != actual_val) { - if ((style & UNITY_DISPLAY_RANGE_UINT) && (length < sizeof(expect_val))) + if ((style & UNITY_DISPLAY_RANGE_UINT) && (length < (UNITY_INT_WIDTH / 8))) { /* For UINT, remove sign extension (padding 1's) from signed type casts above */ UNITY_INT mask = 1; mask = (mask << 8 * length) - 1; @@ -883,11 +894,12 @@ void UnityAssertEqualIntArray(UNITY_INTERNAL_PTR expected, UnityAddMsgIfSpecified(msg); UNITY_FAIL_AND_BAIL; } + /* Walk through array by incrementing the pointers */ if (flags == UNITY_ARRAY_TO_ARRAY) { - expected = (UNITY_INTERNAL_PTR)(length + (const char*)expected); + expected = (UNITY_INTERNAL_PTR)((const char*)expected + increment); } - actual = (UNITY_INTERNAL_PTR)(length + (const char*)actual); + actual = (UNITY_INTERNAL_PTR)((const char*)actual + increment); } } @@ -1492,21 +1504,22 @@ UNITY_INTERNAL_PTR UnityNumToPtr(const UNITY_INT num, const UNITY_UINT8 size) switch(size) { case 1: - UnityQuickCompare.i8 = (UNITY_INT8)num; - return (UNITY_INTERNAL_PTR)(&UnityQuickCompare.i8); + UnityQuickCompare.i8 = (UNITY_INT8)num; + return (UNITY_INTERNAL_PTR)(&UnityQuickCompare.i8); case 2: - UnityQuickCompare.i16 = (UNITY_INT16)num; - return (UNITY_INTERNAL_PTR)(&UnityQuickCompare.i16); + UnityQuickCompare.i16 = (UNITY_INT16)num; + return (UNITY_INTERNAL_PTR)(&UnityQuickCompare.i16); #ifdef UNITY_SUPPORT_64 case 8: - UnityQuickCompare.i64 = (UNITY_INT64)num; - return (UNITY_INTERNAL_PTR)(&UnityQuickCompare.i64); + UnityQuickCompare.i64 = (UNITY_INT64)num; + return (UNITY_INTERNAL_PTR)(&UnityQuickCompare.i64); #endif + default: /* 4 bytes */ - UnityQuickCompare.i32 = (UNITY_INT32)num; - return (UNITY_INTERNAL_PTR)(&UnityQuickCompare.i32); + UnityQuickCompare.i32 = (UNITY_INT32)num; + return (UNITY_INTERNAL_PTR)(&UnityQuickCompare.i32); } } diff --git a/src/unity.h b/src/unity.h index a0c301d2..c51267cf 100644 --- a/src/unity.h +++ b/src/unity.h @@ -1,6 +1,6 @@ /* ========================================== Unity Project - A Test Framework for C - Copyright (c) 2007-14 Mike Karlesky, Mark VanderVoord, Greg Williams + Copyright (c) 2007-19 Mike Karlesky, Mark VanderVoord, Greg Williams [Released under MIT License. Please refer to license.txt for details] ========================================== */ diff --git a/src/unity_internals.h b/src/unity_internals.h index 0024d918..70edadc2 100644 --- a/src/unity_internals.h +++ b/src/unity_internals.h @@ -1,6 +1,6 @@ /* ========================================== Unity Project - A Test Framework for C - Copyright (c) 2007-14 Mike Karlesky, Mark VanderVoord, Greg Williams + Copyright (c) 2007-19 Mike Karlesky, Mark VanderVoord, Greg Williams [Released under MIT License. Please refer to license.txt for details] ========================================== */ @@ -375,7 +375,7 @@ typedef void (*UnityTestFunction)(void); typedef enum { -UNITY_DISPLAY_STYLE_INT = sizeof(int)+ UNITY_DISPLAY_RANGE_INT, + UNITY_DISPLAY_STYLE_INT = sizeof(int) + UNITY_DISPLAY_RANGE_INT, UNITY_DISPLAY_STYLE_INT8 = 1 + UNITY_DISPLAY_RANGE_INT, UNITY_DISPLAY_STYLE_INT16 = 2 + UNITY_DISPLAY_RANGE_INT, UNITY_DISPLAY_STYLE_INT32 = 4 + UNITY_DISPLAY_RANGE_INT, @@ -383,7 +383,7 @@ UNITY_DISPLAY_STYLE_INT = sizeof(int)+ UNITY_DISPLAY_RANGE_INT, UNITY_DISPLAY_STYLE_INT64 = 8 + UNITY_DISPLAY_RANGE_INT, #endif -UNITY_DISPLAY_STYLE_UINT = sizeof(unsigned) + UNITY_DISPLAY_RANGE_UINT, + UNITY_DISPLAY_STYLE_UINT = sizeof(unsigned) + UNITY_DISPLAY_RANGE_UINT, UNITY_DISPLAY_STYLE_UINT8 = 1 + UNITY_DISPLAY_RANGE_UINT, UNITY_DISPLAY_STYLE_UINT16 = 2 + UNITY_DISPLAY_RANGE_UINT, UNITY_DISPLAY_STYLE_UINT32 = 4 + UNITY_DISPLAY_RANGE_UINT, From f69fbe8a95c24935fa62cb04e72fb348f962296f Mon Sep 17 00:00:00 2001 From: Dom Postorivo Date: Sat, 13 Apr 2019 11:45:27 -0400 Subject: [PATCH 107/454] expliticly show test failures of unequal strings --- test/tests/testunity.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/test/tests/testunity.c b/test/tests/testunity.c index 366deba3..bba555a3 100644 --- a/test/tests/testunity.c +++ b/test/tests/testunity.c @@ -1852,6 +1852,20 @@ void testNotEqualStringLen_ActualStringIsNull(void) VERIFY_FAILS_END } +void testNotEqualString_ExpectedStringIsLonger(void) +{ + EXPECT_ABORT_BEGIN + TEST_ASSERT_EQUAL_STRING("foo2", "foo"); + VERIFY_FAILS_END +} + +void testNotEqualString_ActualStringIsLonger(void) +{ + EXPECT_ABORT_BEGIN + TEST_ASSERT_EQUAL_STRING("foo", "foo2"); + VERIFY_FAILS_END +} + void testEqualStringArrays(void) { const char *testStrings[] = { "foo", "boo", "woo", "moo" }; From 0bd6bf7b2b9665959ceae793ae03103c15e36a54 Mon Sep 17 00:00:00 2001 From: Dom Postorivo Date: Sat, 13 Apr 2019 14:08:45 -0400 Subject: [PATCH 108/454] Use Pass string from unity.c in unity_fixture.c to garuntee colour behavior --- extras/fixture/src/unity_fixture.c | 3 ++- src/unity.c | 16 ++++++++-------- src/unity_internals.h | 5 +++++ 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/extras/fixture/src/unity_fixture.c b/extras/fixture/src/unity_fixture.c index 36c1fb16..2771198f 100644 --- a/extras/fixture/src/unity_fixture.c +++ b/extras/fixture/src/unity_fixture.c @@ -419,7 +419,8 @@ void UnityConcludeFixtureTest(void) { if (UnityFixture.Verbose) { - UnityPrint(" PASS"); + UnityPrint(" "); + UnityPrint(UnityStrPass); UNITY_EXEC_TIME_STOP(); UNITY_PRINT_EXEC_TIME(); UNITY_PRINT_EOL(); diff --git a/src/unity.c b/src/unity.c index 4888962f..7ed85e0b 100644 --- a/src/unity.c +++ b/src/unity.c @@ -21,15 +21,15 @@ void UNITY_OUTPUT_CHAR(int); struct UNITY_STORAGE_T Unity; #ifdef UNITY_OUTPUT_COLOR -static const char UnityStrOk[] = "\033[42mOK\033[00m"; -static const char UnityStrPass[] = "\033[42mPASS\033[00m"; -static const char UnityStrFail[] = "\033[41mFAIL\033[00m"; -static const char UnityStrIgnore[] = "\033[43mIGNORE\033[00m"; +const char UnityStrOk[] = "\033[42mOK\033[00m"; +const char UnityStrPass[] = "\033[42mPASS\033[00m"; +const char UnityStrFail[] = "\033[41mFAIL\033[00m"; +const char UnityStrIgnore[] = "\033[43mIGNORE\033[00m"; #else -static const char UnityStrOk[] = "OK"; -static const char UnityStrPass[] = "PASS"; -static const char UnityStrFail[] = "FAIL"; -static const char UnityStrIgnore[] = "IGNORE"; +const char UnityStrOk[] = "OK"; +const char UnityStrPass[] = "PASS"; +const char UnityStrFail[] = "FAIL"; +const char UnityStrIgnore[] = "IGNORE"; #endif static const char UnityStrNull[] = "NULL"; static const char UnityStrSpacer[] = ". "; diff --git a/src/unity_internals.h b/src/unity_internals.h index 0024d918..ad12fde6 100644 --- a/src/unity_internals.h +++ b/src/unity_internals.h @@ -639,6 +639,11 @@ UNITY_INTERNAL_PTR UnityDoubleToPtr(const double num); * Error Strings We Might Need *-------------------------------------------------------*/ +extern const char UnityStrOk[]; +extern const char UnityStrPass[]; +extern const char UnityStrFail[]; +extern const char UnityStrIgnore[]; + extern const char UnityStrErrFloat[]; extern const char UnityStrErrDouble[]; extern const char UnityStrErr64[]; From 89465c88b03ac7b3cfef846fbf5ad6270aa52b57 Mon Sep 17 00:00:00 2001 From: Dom Postorivo Date: Sun, 14 Apr 2019 15:59:40 -0400 Subject: [PATCH 109/454] Add tests for GREATER_OR_EQUAL, LESS_OR_EQUAL, LESS_THAN, and GREATER_THAN --- test/tests/testunity.c | 855 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 850 insertions(+), 5 deletions(-) diff --git a/test/tests/testunity.c b/test/tests/testunity.c index bba555a3..65a746fb 100644 --- a/test/tests/testunity.c +++ b/test/tests/testunity.c @@ -1318,8 +1318,8 @@ void testINT8sNotWithinDeltaAndCustomMessage(void) VERIFY_FAILS_END } - //----------------- + void testGreaterThan(void) { UNITY_INT v0, v1; @@ -1336,6 +1336,13 @@ void testGreaterThan(void) TEST_ASSERT_GREATER_THAN(*p0, *p1); } +void testNotGreaterThan(void) +{ + EXPECT_ABORT_BEGIN + TEST_ASSERT_GREATER_THAN(0, -1); + VERIFY_FAILS_END +} + void testGreaterThanINT(void) { UNITY_INT v0, v1; @@ -1352,6 +1359,12 @@ void testGreaterThanINT(void) TEST_ASSERT_GREATER_THAN_INT(*p0, *p1); } +void testNotGreaterThanINT(void) +{ + EXPECT_ABORT_BEGIN + TEST_ASSERT_GREATER_THAN_INT(3334, 302); + VERIFY_FAILS_END +} void testGreaterThanINT8(void) { @@ -1369,6 +1382,13 @@ void testGreaterThanINT8(void) TEST_ASSERT_GREATER_THAN_INT8(*p0, *p1); } +void testNotGreaterThanINT8(void) +{ + EXPECT_ABORT_BEGIN + TEST_ASSERT_GREATER_THAN_INT8(127, -128); + VERIFY_FAILS_END +} + void testGreaterThanINT16(void) { UNITY_INT16 v0, v1; @@ -1385,6 +1405,13 @@ void testGreaterThanINT16(void) TEST_ASSERT_GREATER_THAN_INT16(*p0, *p1); } +void testNotGreaterThanINT16(void) +{ + EXPECT_ABORT_BEGIN + TEST_ASSERT_GREATER_THAN_INT16(32768, -32768); + VERIFY_FAILS_END +} + void testGreaterThanINT32(void) { UNITY_INT32 v0, v1; @@ -1401,6 +1428,13 @@ void testGreaterThanINT32(void) TEST_ASSERT_GREATER_THAN_INT32(*p0, *p1); } +void testNotGreaterThanINT32(void) +{ + EXPECT_ABORT_BEGIN + TEST_ASSERT_GREATER_THAN_INT32(214783647, -214783648); + VERIFY_FAILS_END +} + void testGreaterThanUINT(void) { UNITY_UINT v0, v1; @@ -1417,6 +1451,12 @@ void testGreaterThanUINT(void) TEST_ASSERT_GREATER_THAN_UINT(*p0, *p1); } +void testNotGreaterThanUINT(void) +{ + EXPECT_ABORT_BEGIN + TEST_ASSERT_GREATER_THAN_UINT(1, 0); + VERIFY_FAILS_END +} void testGreaterThanUINT8(void) { @@ -1434,6 +1474,13 @@ void testGreaterThanUINT8(void) TEST_ASSERT_GREATER_THAN_UINT8(*p0, *p1); } +void testNotGreaterThanUINT8(void) +{ + EXPECT_ABORT_BEGIN + TEST_ASSERT_GREATER_THAN_UINT8(255, 0); + VERIFY_FAILS_END +} + void testGreaterThanUINT16(void) { UNITY_UINT16 v0, v1; @@ -1450,6 +1497,13 @@ void testGreaterThanUINT16(void) TEST_ASSERT_GREATER_THAN_UINT16(*p0, *p1); } +void testNotGreaterThanUINT16(void) +{ + EXPECT_ABORT_BEGIN + TEST_ASSERT_GREATER_THAN_UINT16(65535, 0); + VERIFY_FAILS_END +} + void testGreaterThanUINT32(void) { UNITY_UINT32 v0, v1; @@ -1466,6 +1520,13 @@ void testGreaterThanUINT32(void) TEST_ASSERT_GREATER_THAN_UINT32(*p0, *p1); } +void testNotGreaterThanUINT32(void) +{ + EXPECT_ABORT_BEGIN + TEST_ASSERT_GREATER_THAN_UINT32(4294967295, 0); + VERIFY_FAILS_END +} + void testGreaterThanHEX8(void) { UNITY_UINT8 v0, v1; @@ -1482,6 +1543,13 @@ void testGreaterThanHEX8(void) TEST_ASSERT_GREATER_THAN_HEX8(*p0, *p1); } +void testNotGreaterThanHEX8(void) +{ + EXPECT_ABORT_BEGIN + TEST_ASSERT_GREATER_THAN_HEX8(0xFF, 0x00); + VERIFY_FAILS_END +} + void testGreaterThanHEX16(void) { UNITY_UINT16 v0, v1; @@ -1498,6 +1566,13 @@ void testGreaterThanHEX16(void) TEST_ASSERT_GREATER_THAN_HEX16(*p0, *p1); } +void testNotGreaterThanHEX16(void) +{ + EXPECT_ABORT_BEGIN + TEST_ASSERT_GREATER_THAN_HEX16(0xFFFF, 0x00); + VERIFY_FAILS_END +} + void testGreaterThanHEX32(void) { UNITY_UINT32 v0, v1; @@ -1514,14 +1589,364 @@ void testGreaterThanHEX32(void) TEST_ASSERT_GREATER_THAN_HEX32(*p0, *p1); } +void testNotGreaterThanHEX32(void) +{ + EXPECT_ABORT_BEGIN + TEST_ASSERT_GREATER_THAN_HEX32(0xFFFFFFFF, 0x00); + VERIFY_FAILS_END +} -void testNotGreaterThan(void) +void testGreaterOrEqual(void) +{ + UNITY_INT v0, v1, v2; + UNITY_INT *p0, *p1, *p2; + + v0 = 0; + v1 = 1; + v2 = 0; + p0 = &v0; + p1 = &v1; + p2 = &v2; + + TEST_ASSERT_GREATER_OR_EQUAL(v0, v1); + TEST_ASSERT_GREATER_OR_EQUAL(*p0, v1); + TEST_ASSERT_GREATER_OR_EQUAL(v0, *p1); + TEST_ASSERT_GREATER_OR_EQUAL(*p0, *p1); + TEST_ASSERT_GREATER_OR_EQUAL(v0, v2); + TEST_ASSERT_GREATER_OR_EQUAL(*p0, v2); + TEST_ASSERT_GREATER_OR_EQUAL(v0, *p2); + TEST_ASSERT_GREATER_OR_EQUAL(*p0, *p2); +} + +void testNotGreaterOrEqual(void) { EXPECT_ABORT_BEGIN - TEST_ASSERT_GREATER_THAN(0, -1); + TEST_ASSERT_GREATER_OR_EQUAL(0, -1); + VERIFY_FAILS_END +} + +void testGreaterOrEqualINT(void) +{ + UNITY_INT v0, v1, v2; + UNITY_INT *p0, *p1, *p2; + + v0 = 302; + v1 = 3334; + v2 = 302; + p0 = &v0; + p1 = &v1; + p2 = &v2; + + TEST_ASSERT_GREATER_OR_EQUAL_INT(v0, v1); + TEST_ASSERT_GREATER_OR_EQUAL_INT(*p0, v1); + TEST_ASSERT_GREATER_OR_EQUAL_INT(v0, *p1); + TEST_ASSERT_GREATER_OR_EQUAL_INT(*p0, *p1); + TEST_ASSERT_GREATER_OR_EQUAL_INT(v0, v2); + TEST_ASSERT_GREATER_OR_EQUAL_INT(*p0, v2); + TEST_ASSERT_GREATER_OR_EQUAL_INT(v0, *p2); + TEST_ASSERT_GREATER_OR_EQUAL_INT(*p0, *p2); +} + +void testNotGreaterOrEqualINT(void) +{ + EXPECT_ABORT_BEGIN + TEST_ASSERT_GREATER_OR_EQUAL_INT(3334, 302); + VERIFY_FAILS_END +} + +void testGreaterOrEqualINT8(void) +{ + UNITY_INT8 v0, v1, v2; + UNITY_INT8 *p0, *p1, *p2; + + v0 = -128; + v1 = 127; + v2 = -128; + p0 = &v0; + p1 = &v1; + p2 = &v2; + + TEST_ASSERT_GREATER_OR_EQUAL_INT8(v0, v1); + TEST_ASSERT_GREATER_OR_EQUAL_INT8(*p0, v1); + TEST_ASSERT_GREATER_OR_EQUAL_INT8(v0, *p1); + TEST_ASSERT_GREATER_OR_EQUAL_INT8(*p0, *p1); + TEST_ASSERT_GREATER_OR_EQUAL_INT8(v0, v2); + TEST_ASSERT_GREATER_OR_EQUAL_INT8(*p0, v2); + TEST_ASSERT_GREATER_OR_EQUAL_INT8(v0, *p2); + TEST_ASSERT_GREATER_OR_EQUAL_INT8(*p0, *p2); +} + +void testNotGreaterOrEqualINT8(void) +{ + EXPECT_ABORT_BEGIN + TEST_ASSERT_GREATER_OR_EQUAL_INT8(127, -128); + VERIFY_FAILS_END +} + +void testGreaterOrEqualINT16(void) +{ + UNITY_INT16 v0, v1, v2; + UNITY_INT16 *p0, *p1, *p2; + + v0 = -32768; + v1 = 32767; + v2 = -32768; + p0 = &v0; + p1 = &v1; + p2 = &v2; + + TEST_ASSERT_GREATER_OR_EQUAL_INT16(v0, v1); + TEST_ASSERT_GREATER_OR_EQUAL_INT16(*p0, v1); + TEST_ASSERT_GREATER_OR_EQUAL_INT16(v0, *p1); + TEST_ASSERT_GREATER_OR_EQUAL_INT16(*p0, *p1); + TEST_ASSERT_GREATER_OR_EQUAL_INT16(v0, v2); + TEST_ASSERT_GREATER_OR_EQUAL_INT16(*p0, v2); + TEST_ASSERT_GREATER_OR_EQUAL_INT16(v0, *p2); + TEST_ASSERT_GREATER_OR_EQUAL_INT16(*p0, *p2); +} + +void testNotGreaterOrEqualINT16(void) +{ + EXPECT_ABORT_BEGIN + TEST_ASSERT_GREATER_OR_EQUAL_INT16(32767, -32768); + VERIFY_FAILS_END +} + +void testGreaterOrEqualINT32(void) +{ + UNITY_INT32 v0, v1, v2; + UNITY_INT32 *p0, *p1, *p2; + + v0 = -214783648; + v1 = 214783647; + v2 = -214783648; + p0 = &v0; + p1 = &v1; + p2 = &v2; + + TEST_ASSERT_GREATER_OR_EQUAL_INT32(v0, v1); + TEST_ASSERT_GREATER_OR_EQUAL_INT32(*p0, v1); + TEST_ASSERT_GREATER_OR_EQUAL_INT32(v0, *p1); + TEST_ASSERT_GREATER_OR_EQUAL_INT32(*p0, *p1); + TEST_ASSERT_GREATER_OR_EQUAL_INT32(v0, v2); + TEST_ASSERT_GREATER_OR_EQUAL_INT32(*p0, v2); + TEST_ASSERT_GREATER_OR_EQUAL_INT32(v0, *p2); + TEST_ASSERT_GREATER_OR_EQUAL_INT32(*p0, *p2); +} + +void testNotGreaterOrEqualINT32(void) +{ + EXPECT_ABORT_BEGIN + TEST_ASSERT_GREATER_OR_EQUAL_INT32(214783647, -214783648); + VERIFY_FAILS_END +} + +void testGreaterOrEqualUINT(void) +{ + UNITY_UINT v0, v1, v2; + UNITY_UINT *p0, *p1, *p2; + + v0 = 0; + v1 = 1; + v2 = 0; + p0 = &v0; + p1 = &v1; + p2 = &v2; + + TEST_ASSERT_GREATER_OR_EQUAL_UINT(v0, v1); + TEST_ASSERT_GREATER_OR_EQUAL_UINT(*p0, v1); + TEST_ASSERT_GREATER_OR_EQUAL_UINT(v0, *p1); + TEST_ASSERT_GREATER_OR_EQUAL_UINT(*p0, *p1); + TEST_ASSERT_GREATER_OR_EQUAL_UINT(v0, v2); + TEST_ASSERT_GREATER_OR_EQUAL_UINT(*p0, v2); + TEST_ASSERT_GREATER_OR_EQUAL_UINT(v0, *p2); + TEST_ASSERT_GREATER_OR_EQUAL_UINT(*p0, *p2); +} + +void testNotGreaterOrEqualUINT(void) +{ + EXPECT_ABORT_BEGIN + TEST_ASSERT_GREATER_OR_EQUAL_UINT(1, 0); + VERIFY_FAILS_END +} + +void testGreaterOrEqualUINT8(void) +{ + UNITY_UINT8 v0, v1, v2; + UNITY_UINT8 *p0, *p1, *p2; + + v0 = 0; + v1 = 255; + v2 = 0; + p0 = &v0; + p1 = &v1; + p2 = &v2; + + TEST_ASSERT_GREATER_OR_EQUAL_UINT8(v0, v1); + TEST_ASSERT_GREATER_OR_EQUAL_UINT8(*p0, v1); + TEST_ASSERT_GREATER_OR_EQUAL_UINT8(v0, *p1); + TEST_ASSERT_GREATER_OR_EQUAL_UINT8(*p0, *p1); + TEST_ASSERT_GREATER_OR_EQUAL_UINT8(v0, v2); + TEST_ASSERT_GREATER_OR_EQUAL_UINT8(*p0, v2); + TEST_ASSERT_GREATER_OR_EQUAL_UINT8(v0, *p2); + TEST_ASSERT_GREATER_OR_EQUAL_UINT8(*p0, *p2); +} + +void testNotGreaterOrEqualUINT8(void) +{ + EXPECT_ABORT_BEGIN + TEST_ASSERT_GREATER_OR_EQUAL_UINT8(255, 0); + VERIFY_FAILS_END +} + +void testGreaterOrEqualUINT16(void) +{ + UNITY_UINT16 v0, v1, v2; + UNITY_UINT16 *p0, *p1, *p2; + + v0 = 0; + v1 = 65535; + v2 = 0; + p0 = &v0; + p1 = &v1; + p2 = &v2; + + TEST_ASSERT_GREATER_OR_EQUAL_UINT16(v0, v1); + TEST_ASSERT_GREATER_OR_EQUAL_UINT16(*p0, v1); + TEST_ASSERT_GREATER_OR_EQUAL_UINT16(v0, *p1); + TEST_ASSERT_GREATER_OR_EQUAL_UINT16(*p0, *p1); + TEST_ASSERT_GREATER_OR_EQUAL_UINT16(v0, v2); + TEST_ASSERT_GREATER_OR_EQUAL_UINT16(*p0, v2); + TEST_ASSERT_GREATER_OR_EQUAL_UINT16(v0, *p2); + TEST_ASSERT_GREATER_OR_EQUAL_UINT16(*p0, *p2); +} + +void testNotGreaterOrEqualUINT16(void) +{ + EXPECT_ABORT_BEGIN + TEST_ASSERT_GREATER_OR_EQUAL_UINT16(65535, 0); + VERIFY_FAILS_END +} + +void testGreaterOrEqualUINT32(void) +{ + UNITY_UINT32 v0, v1, v2; + UNITY_UINT32 *p0, *p1, *p2; + + v0 = 0; + v1 = 4294967295; + v2 = 0; + p0 = &v0; + p1 = &v1; + p2 = &v2; + + TEST_ASSERT_GREATER_OR_EQUAL_UINT32(v0, v1); + TEST_ASSERT_GREATER_OR_EQUAL_UINT32(*p0, v1); + TEST_ASSERT_GREATER_OR_EQUAL_UINT32(v0, *p1); + TEST_ASSERT_GREATER_OR_EQUAL_UINT32(*p0, *p1); + TEST_ASSERT_GREATER_OR_EQUAL_UINT32(v0, v2); + TEST_ASSERT_GREATER_OR_EQUAL_UINT32(*p0, v2); + TEST_ASSERT_GREATER_OR_EQUAL_UINT32(v0, *p2); + TEST_ASSERT_GREATER_OR_EQUAL_UINT32(*p0, *p2); +} + +void testNotGreaterOrEqualUINT32(void) +{ + EXPECT_ABORT_BEGIN + TEST_ASSERT_GREATER_OR_EQUAL_UINT32(4294967295, 0); + VERIFY_FAILS_END +} + +void testGreaterOrEqualHEX8(void) +{ + UNITY_UINT8 v0, v1, v2; + UNITY_UINT8 *p0, *p1, *p2; + + v0 = 0x00; + v1 = 0xFF; + v2 = 0x00; + p0 = &v0; + p1 = &v1; + p2 = &v2; + + TEST_ASSERT_GREATER_OR_EQUAL_HEX8(v0, v1); + TEST_ASSERT_GREATER_OR_EQUAL_HEX8(*p0, v1); + TEST_ASSERT_GREATER_OR_EQUAL_HEX8(v0, *p1); + TEST_ASSERT_GREATER_OR_EQUAL_HEX8(*p0, *p1); + TEST_ASSERT_GREATER_OR_EQUAL_HEX8(v0, v2); + TEST_ASSERT_GREATER_OR_EQUAL_HEX8(*p0, v2); + TEST_ASSERT_GREATER_OR_EQUAL_HEX8(v0, *p2); + TEST_ASSERT_GREATER_OR_EQUAL_HEX8(*p0, *p2); +} + +void testNotGreaterOrEqualHEX8(void) +{ + EXPECT_ABORT_BEGIN + TEST_ASSERT_GREATER_OR_EQUAL_HEX8(0xFF, 0x00); + VERIFY_FAILS_END +} + +void testGreaterOrEqualHEX16(void) +{ + UNITY_UINT16 v0, v1, v2; + UNITY_UINT16 *p0, *p1, *p2; + + v0 = 0x0000; + v1 = 0xFFFF; + v2 = 0x0000; + p0 = &v0; + p1 = &v1; + p2 = &v2; + + TEST_ASSERT_GREATER_OR_EQUAL_HEX16(v0, v1); + TEST_ASSERT_GREATER_OR_EQUAL_HEX16(*p0, v1); + TEST_ASSERT_GREATER_OR_EQUAL_HEX16(v0, *p1); + TEST_ASSERT_GREATER_OR_EQUAL_HEX16(*p0, *p1); + TEST_ASSERT_GREATER_OR_EQUAL_HEX16(v0, v2); + TEST_ASSERT_GREATER_OR_EQUAL_HEX16(*p0, v2); + TEST_ASSERT_GREATER_OR_EQUAL_HEX16(v0, *p2); + TEST_ASSERT_GREATER_OR_EQUAL_HEX16(*p0, *p2); +} + +void testNotGreaterOrEqualHEX16(void) +{ + EXPECT_ABORT_BEGIN + TEST_ASSERT_GREATER_OR_EQUAL_HEX16(0xFFFF, 0x00); + VERIFY_FAILS_END +} + +void testGreaterOrEqualHEX32(void) +{ + UNITY_UINT32 v0, v1, v2; + UNITY_UINT32 *p0, *p1, *p2; + + v0 = 0x00000000; + v1 = 0xFFFFFFFF; + v2 = 0x00000000; + p0 = &v0; + p1 = &v1; + p2 = &v2; + + TEST_ASSERT_GREATER_OR_EQUAL_HEX32(v0, v1); + TEST_ASSERT_GREATER_OR_EQUAL_HEX32(*p0, v1); + TEST_ASSERT_GREATER_OR_EQUAL_HEX32(v0, *p1); + TEST_ASSERT_GREATER_OR_EQUAL_HEX32(*p0, *p1); + TEST_ASSERT_GREATER_OR_EQUAL_HEX32(v0, v2); + TEST_ASSERT_GREATER_OR_EQUAL_HEX32(*p0, v2); + TEST_ASSERT_GREATER_OR_EQUAL_HEX32(v0, *p2); + TEST_ASSERT_GREATER_OR_EQUAL_HEX32(*p0, *p2); +} + +void testNotGreaterOrEqualHEX32(void) +{ + EXPECT_ABORT_BEGIN + TEST_ASSERT_GREATER_OR_EQUAL_HEX32(0xFFFFFFFF, 0x00); VERIFY_FAILS_END } +//----------------- + + void testLessThan(void) { UNITY_INT v0, v1; @@ -1538,6 +1963,13 @@ void testLessThan(void) TEST_ASSERT_LESS_THAN(*p0, *p1); } +void testNotLessThan(void) +{ + EXPECT_ABORT_BEGIN + TEST_ASSERT_LESS_THAN(0, 1); + VERIFY_FAILS_END +} + void testLessThanINT(void) { UNITY_INT v0, v1; @@ -1554,6 +1986,12 @@ void testLessThanINT(void) TEST_ASSERT_LESS_THAN_INT(*p0, *p1); } +void testNotLessThanINT(void) +{ + EXPECT_ABORT_BEGIN + TEST_ASSERT_LESS_THAN_INT(302, 3334); + VERIFY_FAILS_END +} void testLessThanINT8(void) { @@ -1571,6 +2009,13 @@ void testLessThanINT8(void) TEST_ASSERT_LESS_THAN_INT8(*p0, *p1); } +void testNotLessThanINT8(void) +{ + EXPECT_ABORT_BEGIN + TEST_ASSERT_LESS_THAN_INT8(-128, 127); + VERIFY_FAILS_END +} + void testLessThanINT16(void) { UNITY_INT16 v0, v1; @@ -1587,6 +2032,13 @@ void testLessThanINT16(void) TEST_ASSERT_LESS_THAN_INT16(*p0, *p1); } +void testNotLessThanINT16(void) +{ + EXPECT_ABORT_BEGIN + TEST_ASSERT_LESS_THAN_INT16(-32768, 32767); + VERIFY_FAILS_END +} + void testLessThanINT32(void) { UNITY_INT32 v0, v1; @@ -1603,6 +2055,13 @@ void testLessThanINT32(void) TEST_ASSERT_LESS_THAN_INT32(*p0, *p1); } +void testNotLessThanINT32(void) +{ + EXPECT_ABORT_BEGIN + TEST_ASSERT_LESS_THAN_INT32(-214783648, 214783647); + VERIFY_FAILS_END +} + void testLessThanUINT(void) { UNITY_UINT v0, v1; @@ -1619,6 +2078,12 @@ void testLessThanUINT(void) TEST_ASSERT_LESS_THAN_UINT(*p0, *p1); } +void testNotLessThanUINT(void) +{ + EXPECT_ABORT_BEGIN + TEST_ASSERT_LESS_THAN_UINT(0, 1); + VERIFY_FAILS_END +} void testLessThanUINT8(void) { @@ -1636,6 +2101,13 @@ void testLessThanUINT8(void) TEST_ASSERT_LESS_THAN_UINT8(*p0, *p1); } +void testNotLessThanUINT8(void) +{ + EXPECT_ABORT_BEGIN + TEST_ASSERT_LESS_THAN_UINT8(0, 255); + VERIFY_FAILS_END +} + void testLessThanUINT16(void) { UNITY_UINT16 v0, v1; @@ -1652,6 +2124,13 @@ void testLessThanUINT16(void) TEST_ASSERT_LESS_THAN_UINT16(*p0, *p1); } +void testNotLessThanUINT16(void) +{ + EXPECT_ABORT_BEGIN + TEST_ASSERT_LESS_THAN_UINT16(0, 65535); + VERIFY_FAILS_END +} + void testLessThanUINT32(void) { UNITY_UINT32 v0, v1; @@ -1668,6 +2147,13 @@ void testLessThanUINT32(void) TEST_ASSERT_LESS_THAN_UINT32(*p0, *p1); } +void testNotLessThanUINT32(void) +{ + EXPECT_ABORT_BEGIN + TEST_ASSERT_LESS_THAN_UINT32(0, 4294967295); + VERIFY_FAILS_END +} + void testLessThanHEX8(void) { UNITY_UINT8 v0, v1; @@ -1684,6 +2170,13 @@ void testLessThanHEX8(void) TEST_ASSERT_LESS_THAN_HEX8(*p0, *p1); } +void testNotLessThanHEX8(void) +{ + EXPECT_ABORT_BEGIN + TEST_ASSERT_LESS_THAN_HEX8(0x00, 0xFF); + VERIFY_FAILS_END +} + void testLessThanHEX16(void) { UNITY_UINT16 v0, v1; @@ -1700,6 +2193,13 @@ void testLessThanHEX16(void) TEST_ASSERT_LESS_THAN_HEX16(*p0, *p1); } +void testNotLessThanHEX16(void) +{ + EXPECT_ABORT_BEGIN + TEST_ASSERT_LESS_THAN_HEX16(0x0000, 0xFFFF); + VERIFY_FAILS_END +} + void testLessThanHEX32(void) { UNITY_UINT32 v0, v1; @@ -1716,15 +2216,360 @@ void testLessThanHEX32(void) TEST_ASSERT_LESS_THAN_HEX32(*p0, *p1); } +void testNotLessThanHEX32(void) +{ + EXPECT_ABORT_BEGIN + TEST_ASSERT_LESS_THAN_HEX32(0x00000000, 0xFFFFFFFF); + VERIFY_FAILS_END +} -void testNotLessThan(void) +void testLessOrEqual(void) +{ + UNITY_INT v0, v1, v2; + UNITY_INT *p0, *p1, *p2; + + v0 = 0; + v1 = -1; + v2 = 0; + p0 = &v0; + p1 = &v1; + p2 = &v2; + + TEST_ASSERT_LESS_OR_EQUAL(v0, v1); + TEST_ASSERT_LESS_OR_EQUAL(*p0, v1); + TEST_ASSERT_LESS_OR_EQUAL(v0, *p1); + TEST_ASSERT_LESS_OR_EQUAL(*p0, *p1); + TEST_ASSERT_LESS_OR_EQUAL(v0, v2); + TEST_ASSERT_LESS_OR_EQUAL(*p0, v2); + TEST_ASSERT_LESS_OR_EQUAL(v0, *p2); + TEST_ASSERT_LESS_OR_EQUAL(*p0, *p2); +} + +void testNotLessOrEqual(void) { EXPECT_ABORT_BEGIN - TEST_ASSERT_LESS_THAN(0, 1); + TEST_ASSERT_LESS_OR_EQUAL(0, 1); + VERIFY_FAILS_END +} + +void testLessOrEqualINT(void) +{ + UNITY_INT v0, v1, v2; + UNITY_INT *p0, *p1, *p2; + + v0 = 3334; + v1 = 302; + v2 = 3334; + p0 = &v0; + p1 = &v1; + p2 = &v2; + + TEST_ASSERT_LESS_OR_EQUAL_INT(v0, v1); + TEST_ASSERT_LESS_OR_EQUAL_INT(*p0, v1); + TEST_ASSERT_LESS_OR_EQUAL_INT(v0, *p1); + TEST_ASSERT_LESS_OR_EQUAL_INT(*p0, *p1); + TEST_ASSERT_LESS_OR_EQUAL_INT(v0, v2); + TEST_ASSERT_LESS_OR_EQUAL_INT(*p0, v2); + TEST_ASSERT_LESS_OR_EQUAL_INT(v0, *p2); + TEST_ASSERT_LESS_OR_EQUAL_INT(*p0, *p2); +} + +void testNotLessOrEqualINT(void) +{ + EXPECT_ABORT_BEGIN + TEST_ASSERT_LESS_OR_EQUAL_INT(302, 3334); + VERIFY_FAILS_END +} + +void testLessOrEqualINT8(void) +{ + UNITY_INT8 v0, v1, v2; + UNITY_INT8 *p0, *p1, *p2; + + v0 = 127; + v1 = -128; + v2 = 127; + p0 = &v0; + p1 = &v1; + p2 = &v2; + + TEST_ASSERT_LESS_OR_EQUAL_INT8(v0, v1); + TEST_ASSERT_LESS_OR_EQUAL_INT8(*p0, v1); + TEST_ASSERT_LESS_OR_EQUAL_INT8(v0, *p1); + TEST_ASSERT_LESS_OR_EQUAL_INT8(*p0, *p1); + TEST_ASSERT_LESS_OR_EQUAL_INT8(v0, v2); + TEST_ASSERT_LESS_OR_EQUAL_INT8(*p0, v2); + TEST_ASSERT_LESS_OR_EQUAL_INT8(v0, *p2); + TEST_ASSERT_LESS_OR_EQUAL_INT8(*p0, *p2); +} + +void testNotLessOrEqualINT8(void) +{ + EXPECT_ABORT_BEGIN + TEST_ASSERT_LESS_OR_EQUAL_INT8(-128, 127); VERIFY_FAILS_END } +void testLessOrEqualINT16(void) +{ + UNITY_INT16 v0, v1, v2; + UNITY_INT16 *p0, *p1, *p2; + + v0 = 32767; + v1 = -32768; + v2 = 32767; + p0 = &v0; + p1 = &v1; + p2 = &v2; + + TEST_ASSERT_LESS_OR_EQUAL_INT16(v0, v1); + TEST_ASSERT_LESS_OR_EQUAL_INT16(*p0, v1); + TEST_ASSERT_LESS_OR_EQUAL_INT16(v0, *p1); + TEST_ASSERT_LESS_OR_EQUAL_INT16(*p0, *p1); + TEST_ASSERT_LESS_OR_EQUAL_INT16(v0, v2); + TEST_ASSERT_LESS_OR_EQUAL_INT16(*p0, v2); + TEST_ASSERT_LESS_OR_EQUAL_INT16(v0, *p2); + TEST_ASSERT_LESS_OR_EQUAL_INT16(*p0, *p2); +} +void testNotLessOrEqualINT16(void) +{ + EXPECT_ABORT_BEGIN + TEST_ASSERT_LESS_OR_EQUAL_INT16(-32768, 32767); + VERIFY_FAILS_END +} + +void testLessOrEqualINT32(void) +{ + UNITY_INT32 v0, v1, v2; + UNITY_INT32 *p0, *p1, *p2; + + v0 = 214783647; + v1 = -214783648; + v2 = 214783647; + p0 = &v0; + p1 = &v1; + p2 = &v2; + + TEST_ASSERT_LESS_OR_EQUAL_INT32(v0, v1); + TEST_ASSERT_LESS_OR_EQUAL_INT32(*p0, v1); + TEST_ASSERT_LESS_OR_EQUAL_INT32(v0, *p1); + TEST_ASSERT_LESS_OR_EQUAL_INT32(*p0, *p1); + TEST_ASSERT_LESS_OR_EQUAL_INT32(v0, v2); + TEST_ASSERT_LESS_OR_EQUAL_INT32(*p0, v2); + TEST_ASSERT_LESS_OR_EQUAL_INT32(v0, *p2); + TEST_ASSERT_LESS_OR_EQUAL_INT32(*p0, *p2); +} + +void testNotLessOrEqualINT32(void) +{ + EXPECT_ABORT_BEGIN + TEST_ASSERT_LESS_OR_EQUAL_INT32(-214783648, 214783647); + VERIFY_FAILS_END +} + +void testLessOrEqualUINT(void) +{ + UNITY_UINT v0, v1, v2; + UNITY_UINT *p0, *p1, *p2; + + v0 = 1; + v1 = 0; + v2 = 1; + p0 = &v0; + p1 = &v1; + p2 = &v2; + + TEST_ASSERT_LESS_OR_EQUAL_UINT(v0, v1); + TEST_ASSERT_LESS_OR_EQUAL_UINT(*p0, v1); + TEST_ASSERT_LESS_OR_EQUAL_UINT(v0, *p1); + TEST_ASSERT_LESS_OR_EQUAL_UINT(*p0, *p1); + TEST_ASSERT_LESS_OR_EQUAL_UINT(v0, v2); + TEST_ASSERT_LESS_OR_EQUAL_UINT(*p0, v2); + TEST_ASSERT_LESS_OR_EQUAL_UINT(v0, *p2); + TEST_ASSERT_LESS_OR_EQUAL_UINT(*p0, *p2); +} + +void testNotLessOrEqualUINT(void) +{ + EXPECT_ABORT_BEGIN + TEST_ASSERT_LESS_OR_EQUAL_UINT(0, 1); + VERIFY_FAILS_END +} + +void testLessOrEqualUINT8(void) +{ + UNITY_UINT8 v0, v1, v2; + UNITY_UINT8 *p0, *p1, *p2; + + v0 = 255; + v1 = 0; + v2 = 255; + p0 = &v0; + p1 = &v1; + p2 = &v2; + + TEST_ASSERT_LESS_OR_EQUAL_UINT8(v0, v1); + TEST_ASSERT_LESS_OR_EQUAL_UINT8(*p0, v1); + TEST_ASSERT_LESS_OR_EQUAL_UINT8(v0, *p1); + TEST_ASSERT_LESS_OR_EQUAL_UINT8(*p0, *p1); + TEST_ASSERT_LESS_OR_EQUAL_UINT8(v0, v2); + TEST_ASSERT_LESS_OR_EQUAL_UINT8(*p0, v2); + TEST_ASSERT_LESS_OR_EQUAL_UINT8(v0, *p2); + TEST_ASSERT_LESS_OR_EQUAL_UINT8(*p0, *p2); +} + +void testNotLessOrEqualUINT8(void) +{ + EXPECT_ABORT_BEGIN + TEST_ASSERT_LESS_OR_EQUAL_UINT8(0, 255); + VERIFY_FAILS_END +} + +void testLessOrEqualUINT16(void) +{ + UNITY_UINT16 v0, v1, v2; + UNITY_UINT16 *p0, *p1, *p2; + + v0 = 65535; + v1 = 0; + v2 = 65535; + p0 = &v0; + p1 = &v1; + p2 = &v2; + + TEST_ASSERT_LESS_OR_EQUAL_UINT16(v0, v1); + TEST_ASSERT_LESS_OR_EQUAL_UINT16(*p0, v1); + TEST_ASSERT_LESS_OR_EQUAL_UINT16(v0, *p1); + TEST_ASSERT_LESS_OR_EQUAL_UINT16(*p0, *p1); + TEST_ASSERT_LESS_OR_EQUAL_UINT16(v0, v2); + TEST_ASSERT_LESS_OR_EQUAL_UINT16(*p0, v2); + TEST_ASSERT_LESS_OR_EQUAL_UINT16(v0, *p2); + TEST_ASSERT_LESS_OR_EQUAL_UINT16(*p0, *p2); +} + +void testNotLessOrEqualUINT16(void) +{ + EXPECT_ABORT_BEGIN + TEST_ASSERT_LESS_OR_EQUAL_UINT16(0, 65535); + VERIFY_FAILS_END +} + +void testLessOrEqualUINT32(void) +{ + UNITY_UINT32 v0, v1, v2; + UNITY_UINT32 *p0, *p1, *p2; + + v0 = 4294967295; + v1 = 0; + v2 = 4294967295; + p0 = &v0; + p1 = &v1; + p2 = &v2; + + TEST_ASSERT_LESS_OR_EQUAL_UINT32(v0, v1); + TEST_ASSERT_LESS_OR_EQUAL_UINT32(*p0, v1); + TEST_ASSERT_LESS_OR_EQUAL_UINT32(v0, *p1); + TEST_ASSERT_LESS_OR_EQUAL_UINT32(*p0, *p1); + TEST_ASSERT_LESS_OR_EQUAL_UINT32(v0, v2); + TEST_ASSERT_LESS_OR_EQUAL_UINT32(*p0, v2); + TEST_ASSERT_LESS_OR_EQUAL_UINT32(v0, *p2); + TEST_ASSERT_LESS_OR_EQUAL_UINT32(*p0, *p2); +} + +void testNotLessOrEqualUINT32(void) +{ + EXPECT_ABORT_BEGIN + TEST_ASSERT_LESS_OR_EQUAL_UINT32(0, 4294967295); + VERIFY_FAILS_END +} + +void testLessOrEqualHEX8(void) +{ + UNITY_UINT8 v0, v1, v2; + UNITY_UINT8 *p0, *p1, *p2; + + v0 = 0xFF; + v1 = 0x00; + v2 = 0xFF; + p0 = &v0; + p1 = &v1; + p2 = &v2; + + TEST_ASSERT_LESS_OR_EQUAL_HEX8(v0, v1); + TEST_ASSERT_LESS_OR_EQUAL_HEX8(*p0, v1); + TEST_ASSERT_LESS_OR_EQUAL_HEX8(v0, *p1); + TEST_ASSERT_LESS_OR_EQUAL_HEX8(*p0, *p1); + TEST_ASSERT_LESS_OR_EQUAL_HEX8(v0, v2); + TEST_ASSERT_LESS_OR_EQUAL_HEX8(*p0, v2); + TEST_ASSERT_LESS_OR_EQUAL_HEX8(v0, *p2); + TEST_ASSERT_LESS_OR_EQUAL_HEX8(*p0, *p2); +} + +void testNotLessOrEqualHEX8(void) +{ + EXPECT_ABORT_BEGIN + TEST_ASSERT_LESS_OR_EQUAL_HEX8(0x00, 0xFF); + VERIFY_FAILS_END +} + +void testLessOrEqualHEX16(void) +{ + UNITY_UINT16 v0, v1, v2; + UNITY_UINT16 *p0, *p1, *p2; + + v0 = 0xFFFF; + v1 = 0x0000; + v2 = 0xFFFF; + p0 = &v0; + p1 = &v1; + p2 = &v2; + + TEST_ASSERT_LESS_OR_EQUAL_HEX16(v0, v1); + TEST_ASSERT_LESS_OR_EQUAL_HEX16(*p0, v1); + TEST_ASSERT_LESS_OR_EQUAL_HEX16(v0, *p1); + TEST_ASSERT_LESS_OR_EQUAL_HEX16(*p0, *p1); + TEST_ASSERT_LESS_OR_EQUAL_HEX16(v0, v2); + TEST_ASSERT_LESS_OR_EQUAL_HEX16(*p0, v2); + TEST_ASSERT_LESS_OR_EQUAL_HEX16(v0, *p2); + TEST_ASSERT_LESS_OR_EQUAL_HEX16(*p0, *p2); +} + +void testNotLessOrEqualHEX16(void) +{ + EXPECT_ABORT_BEGIN + TEST_ASSERT_LESS_OR_EQUAL_HEX16(0x0000, 0xFFFF); + VERIFY_FAILS_END +} + +void testLessOrEqualHEX32(void) +{ + UNITY_UINT32 v0, v1, v2; + UNITY_UINT32 *p0, *p1, *p2; + + v0 = 0xFFFFFFFF; + v1 = 0x00000000; + v2 = 0xFFFFFFFF; + p0 = &v0; + p1 = &v1; + p2 = &v2; + + TEST_ASSERT_LESS_OR_EQUAL_HEX32(v0, v1); + TEST_ASSERT_LESS_OR_EQUAL_HEX32(*p0, v1); + TEST_ASSERT_LESS_OR_EQUAL_HEX32(v0, *p1); + TEST_ASSERT_LESS_OR_EQUAL_HEX32(*p0, *p1); + TEST_ASSERT_LESS_OR_EQUAL_HEX32(v0, v2); + TEST_ASSERT_LESS_OR_EQUAL_HEX32(*p0, v2); + TEST_ASSERT_LESS_OR_EQUAL_HEX32(v0, *p2); + TEST_ASSERT_LESS_OR_EQUAL_HEX32(*p0, *p2); +} + +void testNotLessOrEqualHEX32(void) +{ + EXPECT_ABORT_BEGIN + TEST_ASSERT_LESS_OR_EQUAL_HEX32(0x00000000, 0xFFFFFFFF); + VERIFY_FAILS_END +} //----------------- void testEqualStrings(void) From 93405827974740ac5be4b3fa02b3b6fb7aa8ccdc Mon Sep 17 00:00:00 2001 From: Dom Postorivo Date: Mon, 15 Apr 2019 21:33:56 -0400 Subject: [PATCH 110/454] ARRAY_WITHIN in unity --- docs/UnityAssertionsReference.md | 37 +- src/unity.c | 110 +++ src/unity.h | 36 + src/unity_internals.h | 29 + test/tests/testunity.c | 1469 ++++++++++++++++++++++++++++++ 5 files changed, 1680 insertions(+), 1 deletion(-) diff --git a/docs/UnityAssertionsReference.md b/docs/UnityAssertionsReference.md index eb855f3c..0f1aaa2c 100644 --- a/docs/UnityAssertionsReference.md +++ b/docs/UnityAssertionsReference.md @@ -391,7 +391,6 @@ of 7 - 13. ##### `TEST_ASSERT_HEX64_WITHIN (delta, expected, actual)` - ### Structs and Strings ##### `TEST_ASSERT_EQUAL_PTR (expected, actual)` @@ -466,6 +465,42 @@ match. Failure messages specify the array index of the failed comparison. `len` is the memory in bytes to be compared at each array element. +### Integer Array Ranges (of all sizes) + +These assertions verify that the `expected` array parameter is within +/- `delta` +(inclusive) of the `actual` array parameter. For example, if the expected value is +\[10, 12\] and the delta is 3 then the assertion will fail for any value +outside the range of \[7 - 13, 9 - 15\]. + +##### `TEST_ASSERT_INT_ARRAY_WITHIN (delta, expected, actual)` + +##### `TEST_ASSERT_INT8_ARRAY_WITHIN (delta, expected, actual)` + +##### `TEST_ASSERT_INT16_ARRAY_WITHIN (delta, expected, actual)` + +##### `TEST_ASSERT_INT32_ARRAY_WITHIN (delta, expected, actual)` + +##### `TEST_ASSERT_INT64_ARRAY_WITHIN (delta, expected, actual)` + +##### `TEST_ASSERT_UINT_ARRAY_WITHIN (delta, expected, actual)` + +##### `TEST_ASSERT_UINT8_ARRAY_WITHIN (delta, expected, actual)` + +##### `TEST_ASSERT_UINT16_ARRAY_WITHIN (delta, expected, actual)` + +##### `TEST_ASSERT_UINT32_ARRAY_WITHIN (delta, expected, actual)` + +##### `TEST_ASSERT_UINT64_ARRAY_WITHIN (delta, expected, actual)` + +##### `TEST_ASSERT_HEX_ARRAY_WITHIN (delta, expected, actual)` + +##### `TEST_ASSERT_HEX8_ARRAY_WITHIN (delta, expected, actual)` + +##### `TEST_ASSERT_HEX16_ARRAY_WITHIN (delta, expected, actual)` + +##### `TEST_ASSERT_HEX32_ARRAY_WITHIN (delta, expected, actual)` + +##### `TEST_ASSERT_HEX64_ARRAY_WITHIN (delta, expected, actual)` ### Each Equal (Arrays to Single Value) diff --git a/src/unity.c b/src/unity.c index 7ed85e0b..3d090eef 100644 --- a/src/unity.c +++ b/src/unity.c @@ -1247,6 +1247,116 @@ void UnityAssertNumbersWithin(const UNITY_UINT delta, } } +/*-----------------------------------------------*/ +void UnityAssertNumbersArrayWithin(const UNITY_UINT delta, + UNITY_INTERNAL_PTR expected, + UNITY_INTERNAL_PTR actual, + const UNITY_UINT32 num_elements, + const char* msg, + const UNITY_LINE_TYPE lineNumber, + const UNITY_DISPLAY_STYLE_T style, + const UNITY_FLAGS_T flags) +{ + UNITY_UINT32 elements = num_elements; + unsigned int length = style & 0xF; + + RETURN_IF_FAIL_OR_IGNORE; + if (num_elements == 0) + { + UnityPrintPointlessAndBail(); + } + + if (expected == actual) + { + return; /* Both are NULL or same pointer */ + } + + if (UnityIsOneArrayNull(expected, actual, lineNumber, msg)) + { + UNITY_FAIL_AND_BAIL; + } + + while ((elements > 0) && (elements--)) + { + UNITY_INT expect_val; + UNITY_INT actual_val; + + switch (length) + { + case 1: + expect_val = *(UNITY_PTR_ATTRIBUTE const UNITY_INT8*)expected; + actual_val = *(UNITY_PTR_ATTRIBUTE const UNITY_INT8*)actual; + break; + case 2: + expect_val = *(UNITY_PTR_ATTRIBUTE const UNITY_INT16*)expected; + actual_val = *(UNITY_PTR_ATTRIBUTE const UNITY_INT16*)actual; + break; +#ifdef UNITY_SUPPORT_64 + case 8: + expect_val = *(UNITY_PTR_ATTRIBUTE const UNITY_INT64*)expected; + actual_val = *(UNITY_PTR_ATTRIBUTE const UNITY_INT64*)actual; + break; +#endif + default: /* length 4 bytes */ + expect_val = *(UNITY_PTR_ATTRIBUTE const UNITY_INT32*)expected; + actual_val = *(UNITY_PTR_ATTRIBUTE const UNITY_INT32*)actual; + length = 4; + break; + } + + if ((style & UNITY_DISPLAY_RANGE_INT) == UNITY_DISPLAY_RANGE_INT) + { + if (actual_val > expect_val) + { + Unity.CurrentTestFailed = (((UNITY_UINT)actual_val - (UNITY_UINT)expect_val) > delta); + } + else + { + Unity.CurrentTestFailed = (((UNITY_UINT)expect_val - (UNITY_UINT)actual_val) > delta); + } + } + else + { + if ((UNITY_UINT)actual_val > (UNITY_UINT)expect_val) + { + Unity.CurrentTestFailed = (((UNITY_UINT)actual_val - (UNITY_UINT)expect_val) > delta); + } + else + { + Unity.CurrentTestFailed = (((UNITY_UINT)expect_val - (UNITY_UINT)actual_val) > delta); + } + } + + if (Unity.CurrentTestFailed) + { + if ((style & UNITY_DISPLAY_RANGE_UINT) && (length < sizeof(expect_val))) + { /* For UINT, remove sign extension (padding 1's) from signed type casts above */ + UNITY_INT mask = 1; + mask = (mask << 8 * length) - 1; + expect_val &= mask; + actual_val &= mask; + } + UnityTestResultsFailBegin(lineNumber); + UnityPrint(UnityStrDelta); + UnityPrintNumberByStyle((UNITY_INT)delta, style); + UnityPrint(UnityStrElement); + UnityPrintNumberUnsigned(num_elements - elements - 1); + UnityPrint(UnityStrExpected); + UnityPrintNumberByStyle(expect_val, style); + UnityPrint(UnityStrWas); + UnityPrintNumberByStyle(actual_val, style); + UnityAddMsgIfSpecified(msg); + UNITY_FAIL_AND_BAIL; + } + if (flags == UNITY_ARRAY_TO_ARRAY) + { + expected = (UNITY_INTERNAL_PTR)(length + (const char*)expected); + } + actual = (UNITY_INTERNAL_PTR)(length + (const char*)actual); + } + +} + /*-----------------------------------------------*/ void UnityAssertEqualString(const char* expected, const char* actual, diff --git a/src/unity.h b/src/unity.h index a0c301d2..f7f31a63 100644 --- a/src/unity.h +++ b/src/unity.h @@ -230,6 +230,24 @@ int suiteTearDown(int num_failures); #define TEST_ASSERT_HEX32_WITHIN(delta, expected, actual) UNITY_TEST_ASSERT_HEX32_WITHIN((delta), (expected), (actual), __LINE__, NULL) #define TEST_ASSERT_HEX64_WITHIN(delta, expected, actual) UNITY_TEST_ASSERT_HEX64_WITHIN((delta), (expected), (actual), __LINE__, NULL) +/* Integer Array Ranges (of all sizes) */ +#define TEST_ASSERT_INT_ARRAY_WITHIN(delta, expected, actual, num_elements) UNITY_TEST_ASSERT_INT_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, NULL) +#define TEST_ASSERT_INT8_ARRAY_WITHIN(delta, expected, actual, num_elements) UNITY_TEST_ASSERT_INT8_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, NULL) +#define TEST_ASSERT_INT16_ARRAY_WITHIN(delta, expected, actual, num_elements) UNITY_TEST_ASSERT_INT16_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, NULL) +#define TEST_ASSERT_INT32_ARRAY_WITHIN(delta, expected, actual, num_elements) UNITY_TEST_ASSERT_INT32_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, NULL) +#define TEST_ASSERT_INT64_ARRAY_WITHIN(delta, expected, actual, num_elements) UNITY_TEST_ASSERT_INT64_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, NULL) +#define TEST_ASSERT_UINT_ARRAY_WITHIN(delta, expected, actual, num_elements) UNITY_TEST_ASSERT_UINT_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, NULL) +#define TEST_ASSERT_UINT8_ARRAY_WITHIN(delta, expected, actual, num_elements) UNITY_TEST_ASSERT_UINT8_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, NULL) +#define TEST_ASSERT_UINT16_ARRAY_WITHIN(delta, expected, actual, num_elements) UNITY_TEST_ASSERT_UINT16_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, NULL) +#define TEST_ASSERT_UINT32_ARRAY_WITHIN(delta, expected, actual, num_elements) UNITY_TEST_ASSERT_UINT32_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, NULL) +#define TEST_ASSERT_UINT64_ARRAY_WITHIN(delta, expected, actual, num_elements) UNITY_TEST_ASSERT_UINT64_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, NULL) +#define TEST_ASSERT_HEX_ARRAY_WITHIN(delta, expected, actual, num_elements) UNITY_TEST_ASSERT_HEX32_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, NULL) +#define TEST_ASSERT_HEX8_ARRAY_WITHIN(delta, expected, actual, num_elements) UNITY_TEST_ASSERT_HEX8_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, NULL) +#define TEST_ASSERT_HEX16_ARRAY_WITHIN(delta, expected, actual, num_elements) UNITY_TEST_ASSERT_HEX16_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, NULL) +#define TEST_ASSERT_HEX32_ARRAY_WITHIN(delta, expected, actual, num_elements) UNITY_TEST_ASSERT_HEX32_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, NULL) +#define TEST_ASSERT_HEX64_ARRAY_WITHIN(delta, expected, actual, num_elements) UNITY_TEST_ASSERT_HEX64_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, NULL) + + /* Structs and Strings */ #define TEST_ASSERT_EQUAL_PTR(expected, actual) UNITY_TEST_ASSERT_EQUAL_PTR((expected), (actual), __LINE__, NULL) #define TEST_ASSERT_EQUAL_STRING(expected, actual) UNITY_TEST_ASSERT_EQUAL_STRING((expected), (actual), __LINE__, NULL) @@ -422,6 +440,24 @@ int suiteTearDown(int num_failures); #define TEST_ASSERT_HEX32_WITHIN_MESSAGE(delta, expected, actual, message) UNITY_TEST_ASSERT_HEX32_WITHIN((delta), (expected), (actual), __LINE__, (message)) #define TEST_ASSERT_HEX64_WITHIN_MESSAGE(delta, expected, actual, message) UNITY_TEST_ASSERT_HEX64_WITHIN((delta), (expected), (actual), __LINE__, (message)) +/* Integer Array Ranges (of all sizes) */ +#define TEST_ASSERT_INT_ARRAY_WITHIN_MESSAGE(delta, expected, actual, num_elements, message) UNITY_TEST_ASSERT_INT_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, (message)) +#define TEST_ASSERT_INT8_ARRAY_WITHIN_MESSAGE(delta, expected, actual, num_elements, message) UNITY_TEST_ASSERT_INT8_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, (message)) +#define TEST_ASSERT_INT16_ARRAY_WITHIN_MESSAGE(delta, expected, actual, num_elements, message) UNITY_TEST_ASSERT_INT16_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, (message)) +#define TEST_ASSERT_INT32_ARRAY_WITHIN_MESSAGE(delta, expected, actual, num_elements, message) UNITY_TEST_ASSERT_INT32_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, (message)) +#define TEST_ASSERT_INT64_ARRAY_WITHIN_MESSAGE(delta, expected, actual, num_elements, message) UNITY_TEST_ASSERT_INT64_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, (message)) +#define TEST_ASSERT_UINT_ARRAY_WITHIN_MESSAGE(delta, expected, actual, num_elements, message) UNITY_TEST_ASSERT_UINT_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, (message)) +#define TEST_ASSERT_UINT8_ARRAY_WITHIN_MESSAGE(delta, expected, actual, num_elements, message) UNITY_TEST_ASSERT_UINT8_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, (message)) +#define TEST_ASSERT_UINT16_ARRAY_WITHIN_MESSAGE(delta, expected, actual, num_elements, message) UNITY_TEST_ASSERT_UINT16_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, (message)) +#define TEST_ASSERT_UINT32_ARRAY_WITHIN_MESSAGE(delta, expected, actual, num_elements, message) UNITY_TEST_ASSERT_UINT32_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, (message)) +#define TEST_ASSERT_UINT64_ARRAY_WITHIN_MESSAGE(delta, expected, actual, num_elements, message) UNITY_TEST_ASSERT_UINT64_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, (message)) +#define TEST_ASSERT_HEX_ARRAY_WITHIN_MESSAGE(delta, expected, actual, num_elements, message) UNITY_TEST_ASSERT_HEX32_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, (message)) +#define TEST_ASSERT_HEX8_ARRAY_WITHIN_MESSAGE(delta, expected, actual, num_elements, message) UNITY_TEST_ASSERT_HEX8_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, (message)) +#define TEST_ASSERT_HEX16_ARRAY_WITHIN_MESSAGE(delta, expected, actual, num_elements, message) UNITY_TEST_ASSERT_HEX16_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, (message)) +#define TEST_ASSERT_HEX32_ARRAY_WITHIN_MESSAGE(delta, expected, actual, num_elements, message) UNITY_TEST_ASSERT_HEX32_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, (message)) +#define TEST_ASSERT_HEX64_ARRAY_WITHIN_MESSAGE(delta, expected, actual, num_elements, message) UNITY_TEST_ASSERT_HEX64_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, (message)) + + /* Structs and Strings */ #define TEST_ASSERT_EQUAL_PTR_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_PTR((expected), (actual), __LINE__, (message)) #define TEST_ASSERT_EQUAL_STRING_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_STRING((expected), (actual), __LINE__, (message)) diff --git a/src/unity_internals.h b/src/unity_internals.h index ad12fde6..45cdd3f4 100644 --- a/src/unity_internals.h +++ b/src/unity_internals.h @@ -579,6 +579,15 @@ void UnityAssertNumbersWithin(const UNITY_UINT delta, const UNITY_LINE_TYPE lineNumber, const UNITY_DISPLAY_STYLE_T style); +void UnityAssertNumbersArrayWithin(const UNITY_UINT delta, + UNITY_INTERNAL_PTR expected, + UNITY_INTERNAL_PTR actual, + const UNITY_UINT32 num_elements, + const char* msg, + const UNITY_LINE_TYPE lineNumber, + const UNITY_DISPLAY_STYLE_T style, + const UNITY_FLAGS_T flags); + void UnityFail(const char* message, const UNITY_LINE_TYPE line); void UnityIgnore(const char* message, const UNITY_LINE_TYPE line); @@ -800,6 +809,20 @@ int UnityTestMatches(void); #define UNITY_TEST_ASSERT_HEX16_WITHIN(delta, expected, actual, line, message) UnityAssertNumbersWithin((UNITY_UINT16)(delta), (UNITY_INT)(UNITY_UINT)(UNITY_UINT16)(expected), (UNITY_INT)(UNITY_UINT)(UNITY_UINT16)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX16) #define UNITY_TEST_ASSERT_HEX32_WITHIN(delta, expected, actual, line, message) UnityAssertNumbersWithin((UNITY_UINT32)(delta), (UNITY_INT)(UNITY_UINT)(UNITY_UINT32)(expected), (UNITY_INT)(UNITY_UINT)(UNITY_UINT32)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX32) + +#define UNITY_TEST_ASSERT_INT_ARRAY_WITHIN(delta, expected, actual, num_elements, line, message) UnityAssertNumbersArrayWithin((delta), (UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), ((UNITY_UINT32)(num_elements)), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT, UNITY_ARRAY_TO_ARRAY) +#define UNITY_TEST_ASSERT_INT8_ARRAY_WITHIN(delta, expected, actual, num_elements, line, message) UnityAssertNumbersArrayWithin((UNITY_UINT8 )(delta), (UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), ((UNITY_UINT32)(num_elements)), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT8, UNITY_ARRAY_TO_ARRAY) +#define UNITY_TEST_ASSERT_INT16_ARRAY_WITHIN(delta, expected, actual, num_elements, line, message) UnityAssertNumbersArrayWithin((UNITY_UINT16)(delta), (UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), ((UNITY_UINT32)(num_elements)), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT16, UNITY_ARRAY_TO_ARRAY) +#define UNITY_TEST_ASSERT_INT32_ARRAY_WITHIN(delta, expected, actual, num_elements, line, message) UnityAssertNumbersArrayWithin((UNITY_UINT32)(delta), (UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), ((UNITY_UINT32)(num_elements)), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT32, UNITY_ARRAY_TO_ARRAY) +#define UNITY_TEST_ASSERT_UINT_ARRAY_WITHIN(delta, expected, actual, num_elements, line, message) UnityAssertNumbersArrayWithin((delta), (UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), ((UNITY_UINT32)(num_elements)), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT, UNITY_ARRAY_TO_ARRAY) +#define UNITY_TEST_ASSERT_UINT8_ARRAY_WITHIN(delta, expected, actual, num_elements, line, message) UnityAssertNumbersArrayWithin((UNITY_UINT16)(delta), (UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), ((UNITY_UINT32)(num_elements)), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT8, UNITY_ARRAY_TO_ARRAY) +#define UNITY_TEST_ASSERT_UINT16_ARRAY_WITHIN(delta, expected, actual, num_elements, line, message) UnityAssertNumbersArrayWithin((UNITY_UINT16)(delta), (UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), ((UNITY_UINT32)(num_elements)), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT16, UNITY_ARRAY_TO_ARRAY) +#define UNITY_TEST_ASSERT_UINT32_ARRAY_WITHIN(delta, expected, actual, num_elements, line, message) UnityAssertNumbersArrayWithin((UNITY_UINT32)(delta), (UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), ((UNITY_UINT32)(num_elements)), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT32, UNITY_ARRAY_TO_ARRAY) +#define UNITY_TEST_ASSERT_HEX8_ARRAY_WITHIN(delta, expected, actual, num_elements, line, message) UnityAssertNumbersArrayWithin((UNITY_UINT8 )(delta), (UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), ((UNITY_UINT32)(num_elements)), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX8, UNITY_ARRAY_TO_ARRAY) +#define UNITY_TEST_ASSERT_HEX16_ARRAY_WITHIN(delta, expected, actual, num_elements, line, message) UnityAssertNumbersArrayWithin((UNITY_UINT16)(delta), (UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), ((UNITY_UINT32)(num_elements)), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX16, UNITY_ARRAY_TO_ARRAY) +#define UNITY_TEST_ASSERT_HEX32_ARRAY_WITHIN(delta, expected, actual, num_elements, line, message) UnityAssertNumbersArrayWithin((UNITY_UINT32)(delta), (UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), ((UNITY_UINT32)(num_elements)), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX32, UNITY_ARRAY_TO_ARRAY) + + #define UNITY_TEST_ASSERT_EQUAL_PTR(expected, actual, line, message) UnityAssertEqualNumber((UNITY_PTR_TO_INT)(expected), (UNITY_PTR_TO_INT)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_POINTER) #define UNITY_TEST_ASSERT_EQUAL_STRING(expected, actual, line, message) UnityAssertEqualString((const char*)(expected), (const char*)(actual), (message), (UNITY_LINE_TYPE)(line)) #define UNITY_TEST_ASSERT_EQUAL_STRING_LEN(expected, actual, len, line, message) UnityAssertEqualStringLen((const char*)(expected), (const char*)(actual), (UNITY_UINT32)(len), (message), (UNITY_LINE_TYPE)(line)) @@ -860,6 +883,9 @@ int UnityTestMatches(void); #define UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_INT64(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(threshold), (UNITY_INT)(actual), UNITY_SMALLER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT64) #define UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_UINT64(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(threshold), (UNITY_INT)(actual), UNITY_SMALLER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT64) #define UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_HEX64(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(threshold), (UNITY_INT)(actual), UNITY_SMALLER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX64) +#define UNITY_TEST_ASSERT_INT64_ARRAY_WITHIN(delta, expected, actual, num_elements, line, message) UnityAssertNumbersArrayWithin((UNITY_UINT32)(delta), (UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT32, UNITY_ARRAY_TO_ARRAY) +#define UNITY_TEST_ASSERT_UINT64_ARRAY_WITHIN(delta, expected, actual, num_elements, line, message) UnityAssertNumbersArrayWithin((UNITY_UINT32)(delta), (UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT32, UNITY_ARRAY_TO_ARRAY) +#define UNITY_TEST_ASSERT_HEX64_ARRAY_WITHIN(delta, expected, actual, num_elements, line, message) UnityAssertNumbersArrayWithin((UNITY_UINT32)(delta), (UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX64, UNITY_ARRAY_TO_ARRAY) #else #define UNITY_TEST_ASSERT_EQUAL_INT64(expected, actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErr64) #define UNITY_TEST_ASSERT_EQUAL_UINT64(expected, actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErr64) @@ -882,6 +908,9 @@ int UnityTestMatches(void); #define UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_INT64(threshold, actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErr64) #define UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_UINT64(threshold, actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErr64) #define UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_HEX64(threshold, actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErr64) +#define UNITY_TEST_ASSERT_INT64_ARRAY_WITHIN(delta, expected, actual, num_elements, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErr64) +#define UNITY_TEST_ASSERT_UINT64_ARRAY_WITHIN(delta, expected, actual, num_elements, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErr64) +#define UNITY_TEST_ASSERT_HEX64_ARRAY_WITHIN(delta, expected, actual, num_elements, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErr64) #endif #ifdef UNITY_EXCLUDE_FLOAT diff --git a/test/tests/testunity.c b/test/tests/testunity.c index bba555a3..66752012 100644 --- a/test/tests/testunity.c +++ b/test/tests/testunity.c @@ -1318,8 +1318,1477 @@ void testINT8sNotWithinDeltaAndCustomMessage(void) VERIFY_FAILS_END } +//------------------------ + +void testInt64ArrayWithinDelta(void) +{ +#ifndef UNITY_SUPPORT_64 + TEST_IGNORE(); +#else + UNITY_INT64 expected[] = {12345000, -12344995, 12345005}; + UNITY_INT64 acutalSmallDelta[] = {12345001, -12344996, 12345005}; + UNITY_INT64 acutalBigDelta[] = {12345101, -12344896, 12345055}; + + TEST_ASSERT_INT64_ARRAY_WITHIN(1, expected, acutalSmallDelta, 3); + TEST_ASSERT_INT64_ARRAY_WITHIN(110, expected, acutalBigDelta, 3); +#endif +} + +void testInt64ArrayWithinDeltaAndMessage(void) +{ +#ifndef UNITY_SUPPORT_64 + TEST_IGNORE(); +#else + UNITY_INT64 expected[] = {12345000, -12344995, 12345005}; + UNITY_INT64 acutalSmallDelta[] = {12345001, -12344996, 12345005}; + UNITY_INT64 acutalBigDelta[] = {12345101, -12344896, 12345055}; + + TEST_ASSERT_INT64_ARRAY_WITHIN_MESSAGE(1, expected, acutalSmallDelta, 3, "Custom Message."); + TEST_ASSERT_INT64_ARRAY_WITHIN_MESSAGE(110, expected, acutalBigDelta, 3, "Custom Message."); +#endif +} + +void tesUInt64ArrayNotWithinDelta(void) +{ +#ifndef UNITY_SUPPORT_64 + TEST_IGNORE(); +#else + UNITY_INT64 expected[] = {12345000, -12344995, 12345005}; + UNITY_INT64 acutalBigDelta[] = {12345101, -12344896, 12345055}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_UINT64_ARRAY_WITHIN(1, expected, acutalBigDelta, 3); + VERIFY_FAILS_END +#endif +} + +void testInt64ArrayNotWithinDeltaAndMessage(void) +{ +#ifndef UNITY_SUPPORT_64 + TEST_IGNORE(); +#else + UNITY_INT64 expected[] = {12345000, -12344995, 12345005}; + UNITY_INT64 acutalBigDelta[] = {12345101, -12344896, 12345055}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_INT64_ARRAY_WITHIN_MESSAGE(1, expected, acutalBigDelta, 3, "Custom Message."); + VERIFY_FAILS_END +#endif +} + +void testInt64ArrayWithinDeltaPointless(void) +{ +#ifndef UNITY_SUPPORT_64 + TEST_IGNORE(); +#else + UNITY_INT64 expected[] = {12345000, -12344995, 12345005}; + UNITY_INT64 acutalBigDelta[] = {12345101, -12344896, 12345055}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_INT64_ARRAY_WITHIN(110, expected, acutalBigDelta, 0); + VERIFY_FAILS_END +#endif +} + +void testInt64ArrayWithinDeltaPointlessAndMessage(void) +{ +#ifndef UNITY_SUPPORT_64 + TEST_IGNORE(); +#else + UNITY_INT64 expected[] = {12345000, -12344995, 12345005}; + UNITY_INT64 acutalBigDelta[] = {12345101, -12344896, 12345055}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_INT64_ARRAY_WITHIN_MESSAGE(110, expected, acutalBigDelta, 0, "Custom Message."); + VERIFY_FAILS_END +#endif +} + +void testInt64ArrayWithinDeltaExpectedNull(void) +{ +#ifndef UNITY_SUPPORT_64 + TEST_IGNORE(); +#else + UNITY_INT64 acutalBigDelta[] = {12345101, -12344896, 12345055}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_INT64_ARRAY_WITHIN(110, NULL, acutalBigDelta, 3); + VERIFY_FAILS_END +#endif +} + +void testInt64ArrayWithinDeltaExpectedNullAndMessage(void) +{ +#ifndef UNITY_SUPPORT_64 + TEST_IGNORE(); +#else + UNITY_INT64 acutalBigDelta[] = {12345101, -12344896, 12345055}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_INT64_ARRAY_WITHIN_MESSAGE(110, NULL, acutalBigDelta, 3, "Custom Message."); + VERIFY_FAILS_END +#endif +} + +void testInt64ArrayWithinDeltaActualNull(void) +{ +#ifndef UNITY_SUPPORT_64 + TEST_IGNORE(); +#else + UNITY_INT64 expected[] = {12345000, -12344995, 12345005}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_INT64_ARRAY_WITHIN(110, expected, NULL, 3); + VERIFY_FAILS_END +#endif +} + +void testInt64ArrayWithinDeltaActualNullAndMessage(void) +{ +#ifndef UNITY_SUPPORT_64 + TEST_IGNORE(); +#else + UNITY_INT64 expected[] = {12345000, -12344995, 12345005}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_INT64_ARRAY_WITHIN_MESSAGE(110, expected, NULL, 3, "Custom Message."); + VERIFY_FAILS_END +#endif +} + +void testInt64ArrayWithinDeltaSamePointer(void) +{ +#ifndef UNITY_SUPPORT_64 + TEST_IGNORE(); +#else + UNITY_INT64 expected[] = {12345000, -12344995, 12345005}; + + TEST_ASSERT_UINT64_ARRAY_WITHIN(110, expected, expected, 3); +#endif +} + +void testInt64ArrayWithinDeltaSamePointerAndMessage(void) +{ +#ifndef UNITY_SUPPORT_64 + TEST_IGNORE(); +#else + UNITY_INT64 expected[] = {12345000, -12344995, 12345005}; + + TEST_ASSERT_INT64_ARRAY_WITHIN_MESSAGE(110, expected, expected, 3, "Custom Message."); +#endif +} + +void testIntArrayWithinDelta(void) +{ + UNITY_INT expected[] = {5000, -4995, 5005}; + UNITY_INT acutalSmallDelta[] = {5001, -4996, 5005}; + UNITY_INT acutalBigDelta[] = {5101, -4896, 5055}; + + TEST_ASSERT_INT_ARRAY_WITHIN(1, expected, acutalSmallDelta, 3); + TEST_ASSERT_INT_ARRAY_WITHIN(110, expected, acutalBigDelta, 3); +} + +void testIntArrayWithinDeltaAndMessage(void) +{ + UNITY_INT expected[] = {5000, -4995, 5005}; + UNITY_INT acutalSmallDelta[] = {5001, -4996, 5005}; + UNITY_INT acutalBigDelta[] = {5101, -4896, 5055}; + + TEST_ASSERT_INT_ARRAY_WITHIN_MESSAGE(1, expected, acutalSmallDelta, 3, "Custom Message."); + TEST_ASSERT_INT_ARRAY_WITHIN_MESSAGE(110, expected, acutalBigDelta, 3, "Custom Message."); +} + +void testIntArrayNotWithinDelta(void) +{ + UNITY_INT expected[] = {5000, -4995, 5005}; + UNITY_INT acutalBigDelta[] = {5101, -4896, 5055}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_INT_ARRAY_WITHIN(1, expected, acutalBigDelta, 3); + VERIFY_FAILS_END +} + +void testIntArrayNotWithinDeltaAndMessage(void) +{ + UNITY_INT expected[] = {5000, -4995, 5005}; + UNITY_INT acutalBigDelta[] = {5101, -4896, 5055}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_INT_ARRAY_WITHIN_MESSAGE(1, expected, acutalBigDelta, 3, "Custom Message."); + VERIFY_FAILS_END +} + +void testIntArrayWithinDeltaPointless(void) +{ + UNITY_INT expected[] = {5000, -4995, 5005}; + UNITY_INT acutalBigDelta[] = {5101, -4896, 5055}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_INT_ARRAY_WITHIN(110, expected, acutalBigDelta, 0); + VERIFY_FAILS_END +} + +void testIntArrayWithinDeltaPointlessAndMessage(void) +{ + UNITY_INT expected[] = {5000, -4995, 5005}; + UNITY_INT acutalBigDelta[] = {5101, -4896, 5055}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_INT_ARRAY_WITHIN_MESSAGE(110, expected, acutalBigDelta, 0, "Custom Message."); + VERIFY_FAILS_END +} + +void testIntArrayWithinDeltaExpectedNull(void) +{ + UNITY_INT acutalBigDelta[] = {5101, -4896, 5055}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_INT_ARRAY_WITHIN(110, NULL, acutalBigDelta, 3); + VERIFY_FAILS_END +} + +void testIntArrayWithinDeltaExpectedNullAndMessage(void) +{ + UNITY_INT acutalBigDelta[] = {5101, -4896, 5055}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_INT_ARRAY_WITHIN_MESSAGE(110, NULL, acutalBigDelta, 3, "Custom Message."); + VERIFY_FAILS_END +} + +void testIntArrayWithinDeltaActualNull(void) +{ + UNITY_INT expected[] = {5000, -4995, 5005}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_INT_ARRAY_WITHIN(110, expected, NULL, 3); + VERIFY_FAILS_END +} + +void testIntArrayWithinDeltaActualNullAndMessage(void) +{ + UNITY_INT expected[] = {5000, -4995, 5005}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_INT_ARRAY_WITHIN_MESSAGE(110, expected, NULL, 3, "Custom Message."); + VERIFY_FAILS_END +} + +void testIntArrayWithinDeltaSamePointer(void) +{ + UNITY_INT expected[] = {5000, -4995, 5005}; + + TEST_ASSERT_INT_ARRAY_WITHIN(110, expected, expected, 3); +} + +void testIntArrayWithinDeltaSamePointerAndMessage(void) +{ + UNITY_INT expected[] = {5000, -4995, 5005}; + + TEST_ASSERT_INT_ARRAY_WITHIN_MESSAGE(110, expected, expected, 3, "Custom Message."); +} + +void testInt16ArrayWithinDelta(void) +{ + UNITY_INT16 expected[] = {5000, -4995, 5005}; + UNITY_INT16 acutalSmallDelta[] = {5001, -4996, 5005}; + UNITY_INT16 acutalBigDelta[] = {5101, -4896, 5055}; + + TEST_ASSERT_INT16_ARRAY_WITHIN(1, expected, acutalSmallDelta, 3); + TEST_ASSERT_INT16_ARRAY_WITHIN(110, expected, acutalBigDelta, 3); +} + +void testInt16ArrayWithinDeltaAndMessage(void) +{ + UNITY_INT16 expected[] = {5000, -4995, 5005}; + UNITY_INT16 acutalSmallDelta[] = {5001, -4996, 5005}; + UNITY_INT16 acutalBigDelta[] = {5101, -4896, 5055}; + + TEST_ASSERT_INT16_ARRAY_WITHIN_MESSAGE(1, expected, acutalSmallDelta, 3, "Custom Message."); + TEST_ASSERT_INT16_ARRAY_WITHIN_MESSAGE(110, expected, acutalBigDelta, 3, "Custom Message."); +} + +void testInt16ArrayNotWithinDelta(void) +{ + UNITY_INT16 expected[] = {5000, -4995, 5005}; + UNITY_INT16 acutalBigDelta[] = {5101, -4896, 5055}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_UINT16_ARRAY_WITHIN(1, expected, acutalBigDelta, 3); + VERIFY_FAILS_END +} + +void testInt16ArrayNotWithinDeltaAndMessage(void) +{ + UNITY_INT16 expected[] = {5000, -4995, 5005}; + UNITY_INT16 acutalBigDelta[] = {5101, -4896, 5055}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_INT16_ARRAY_WITHIN_MESSAGE(1, expected, acutalBigDelta, 3, "Custom Message."); + VERIFY_FAILS_END +} + +void testInt16ArrayWithinDeltaPointless(void) +{ + UNITY_INT16 expected[] = {5000, -4995, 5005}; + UNITY_INT16 acutalBigDelta[] = {5101, -4896, 5055}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_INT16_ARRAY_WITHIN(110, expected, acutalBigDelta, 0); + VERIFY_FAILS_END +} + +void testInt16ArrayWithinDeltaPointlessAndMessage(void) +{ + UNITY_INT16 expected[] = {5000, -4995, 5005}; + UNITY_INT16 acutalBigDelta[] = {5101, -4896, 5055}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_INT16_ARRAY_WITHIN_MESSAGE(110, expected, acutalBigDelta, 0, "Custom Message."); + VERIFY_FAILS_END +} + +void testInt16ArrayWithinDeltaExpectedNull(void) +{ + UNITY_INT16 acutalBigDelta[] = {5101, -4896, 5055}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_INT16_ARRAY_WITHIN(110, NULL, acutalBigDelta, 3); + VERIFY_FAILS_END +} + +void testInt16ArrayWithinDeltaExpectedNullAndMessage(void) +{ + UNITY_INT16 acutalBigDelta[] = {5101, -4896, 5055}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_INT16_ARRAY_WITHIN_MESSAGE(110, NULL, acutalBigDelta, 3, "Custom Message."); + VERIFY_FAILS_END +} + +void testInt16ArrayWithinDeltaActualNull(void) +{ + UNITY_INT16 expected[] = {5000, -4995, 5005}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_INT16_ARRAY_WITHIN(110, expected, NULL, 3); + VERIFY_FAILS_END +} + +void testInt16ArrayWithinDeltaActualNullAndMessage(void) +{ + UNITY_INT16 expected[] = {5000, -4995, 5005}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_INT16_ARRAY_WITHIN_MESSAGE(110, expected, NULL, 3, "Custom Message."); + VERIFY_FAILS_END +} + +void testInt16ArrayWithinDeltaSamePointer(void) +{ + UNITY_INT16 expected[] = {5000, -4995, 5005}; + + TEST_ASSERT_INT16_ARRAY_WITHIN(110, expected, expected, 3); +} + +void testInt16ArrayWithinDeltaSamePointerAndMessage(void) +{ + UNITY_INT16 expected[] = {5000, -4995, 5005}; + + TEST_ASSERT_INT16_ARRAY_WITHIN_MESSAGE(110, expected, expected, 3, "Custom Message."); +} + +void testInt8ArrayWithinDelta(void) +{ + UNITY_INT8 expected[] = {20, -95, 55}; + UNITY_INT8 acutalSmallDelta[] = {21, -94, 55}; + UNITY_INT8 acutalBigDelta[] = {11, -86, 45}; + + TEST_ASSERT_INT8_ARRAY_WITHIN(1, expected, acutalSmallDelta, 3); + TEST_ASSERT_INT8_ARRAY_WITHIN(11, expected, acutalBigDelta, 3); +} + +void testInt8ArrayWithinDeltaAndMessage(void) +{ + UNITY_INT8 expected[] = {20, -95, 55}; + UNITY_INT8 acutalSmallDelta[] = {21, -94, 55}; + UNITY_INT8 acutalBigDelta[] = {11, -86, 45}; + + TEST_ASSERT_INT8_ARRAY_WITHIN_MESSAGE(1, expected, acutalSmallDelta, 3, "Custom Message."); + TEST_ASSERT_INT8_ARRAY_WITHIN_MESSAGE(11, expected, acutalBigDelta, 3, "Custom Message."); +} + +void testInt8ArrayNotWithinDelta(void) +{ + UNITY_INT8 expected[] = {20, -95, 55}; + UNITY_INT8 acutalBigDelta[] = {11, -86, 45}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_INT8_ARRAY_WITHIN(1, expected, acutalBigDelta, 3); + VERIFY_FAILS_END +} + +void testInt8ArrayNotWithinDeltaAndMessage(void) +{ + UNITY_INT8 expected[] = {20, -95, 55}; + UNITY_INT8 acutalBigDelta[] = {11, -86, 45}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_INT8_ARRAY_WITHIN_MESSAGE(1, expected, acutalBigDelta, 3, "Custom Message."); + VERIFY_FAILS_END +} + +void testInt8ArrayWithinDeltaPointless(void) +{ + UNITY_INT8 expected[] = {20, -95, 55}; + UNITY_INT8 acutalBigDelta[] = {11, -86, 45}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_INT8_ARRAY_WITHIN(11, expected, acutalBigDelta, 0); + VERIFY_FAILS_END +} + +void testInt8ArrayWithinDeltaPointlessAndMessage(void) +{ + UNITY_INT8 expected[] = {20, -95, 55}; + UNITY_INT8 acutalBigDelta[] = {11, -86, 45}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_INT8_ARRAY_WITHIN_MESSAGE(11, expected, acutalBigDelta, 0, "Custom Message."); + VERIFY_FAILS_END +} + +void testInt8ArrayWithinDeltaExpectedNull(void) +{ + UNITY_INT8 acutalBigDelta[] = {11, -86, 45}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_INT8_ARRAY_WITHIN(11, NULL, acutalBigDelta, 3); + VERIFY_FAILS_END +} + +void testInt8ArrayWithinDeltaExpectedNullAndMessage(void) +{ + UNITY_INT8 acutalBigDelta[] = {11, -86, 45}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_INT8_ARRAY_WITHIN_MESSAGE(11, NULL, acutalBigDelta, 3, "Custom Message."); + VERIFY_FAILS_END +} + +void testInt8ArrayWithinDeltaActualNull(void) +{ + UNITY_INT8 expected[] = {20, -95, 55}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_INT8_ARRAY_WITHIN(11, expected, NULL, 3); + VERIFY_FAILS_END +} + +void testInt8ArrayWithinDeltaActualNullAndMessage(void) +{ + UNITY_INT8 expected[] = {20, -95, 55}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_INT8_ARRAY_WITHIN_MESSAGE(11, expected, NULL, 3, "Custom Message."); + VERIFY_FAILS_END +} + +void testInt8ArrayWithinDeltaSamePointer(void) +{ + UNITY_INT8 expected[] = {20, -95, 55}; + + TEST_ASSERT_INT8_ARRAY_WITHIN(11, expected, expected, 3); +} + +void testInt8ArrayWithinDeltaSamePointerAndMessage(void) +{ + UNITY_INT8 expected[] = {20, -95, 55}; + + TEST_ASSERT_INT8_ARRAY_WITHIN_MESSAGE(11, expected, expected, 3, "Custom Message."); +} + +void testUInt64ArrayWithinDelta(void) +{ +#ifndef UNITY_SUPPORT_64 + TEST_IGNORE(); +#else + UNITY_UINT64 expected[] = {12345000, 12344995, 12345005}; + UNITY_UINT64 acutalSmallDelta[] = {12345001, 12344996, 12345005}; + UNITY_UINT64 acutalBigDelta[] = {12345101, 12344896, 12345055}; + + TEST_ASSERT_UINT64_ARRAY_WITHIN(1, expected, acutalSmallDelta, 3); + TEST_ASSERT_UINT64_ARRAY_WITHIN(110, expected, acutalBigDelta, 3); +#endif +} + +void testUInt64ArrayWithinDeltaAndMessage(void) +{ +#ifndef UNITY_SUPPORT_64 + TEST_IGNORE(); +#else + UNITY_UINT64 expected[] = {12345000, 12344995, 12345005}; + UNITY_UINT64 acutalSmallDelta[] = {12345001, 12344996, 12345005}; + UNITY_UINT64 acutalBigDelta[] = {12345101, 12344896, 12345055}; + + TEST_ASSERT_UINT64_ARRAY_WITHIN_MESSAGE(1, expected, acutalSmallDelta, 3, "Custom Message."); + TEST_ASSERT_UINT64_ARRAY_WITHIN_MESSAGE(110, expected, acutalBigDelta, 3, "Custom Message."); +#endif +} + +void testUInt64ArrayNotWithinDelta(void) +{ +#ifndef UNITY_SUPPORT_64 + TEST_IGNORE(); +#else + UNITY_UINT64 expected[] = {12345000, 12344995, 12345005}; + UNITY_UINT64 acutalBigDelta[] = {12345101, 12344896, 12345055}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_UINT64_ARRAY_WITHIN(1, expected, acutalBigDelta, 3); + VERIFY_FAILS_END +#endif +} + +void testUInt64ArrayNotWithinDeltaAndMessage(void) +{ +#ifndef UNITY_SUPPORT_64 + TEST_IGNORE(); +#else + UNITY_UINT64 expected[] = {12345000, 12344995, 12345005}; + UNITY_UINT64 acutalBigDelta[] = {12345101, 12344896, 12345055}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_UINT64_ARRAY_WITHIN_MESSAGE(1, expected, acutalBigDelta, 3, "Custom Message."); + VERIFY_FAILS_END +#endif +} + +void testUInt64ArrayWithinDeltaPointless(void) +{ +#ifndef UNITY_SUPPORT_64 + TEST_IGNORE(); +#else + UNITY_UINT64 expected[] = {12345000, 12344995, 12345005}; + UNITY_UINT64 acutalBigDelta[] = {12345101, 12344896, 12345055}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_UINT64_ARRAY_WITHIN(110, expected, acutalBigDelta, 0); + VERIFY_FAILS_END +#endif +} + +void testUInt64ArrayWithinDeltaPointlessAndMessage(void) +{ +#ifndef UNITY_SUPPORT_64 + TEST_IGNORE(); +#else + UNITY_UINT64 expected[] = {12345000, 12344995, 12345005}; + UNITY_UINT64 acutalBigDelta[] = {12345101, 12344896, 12345055}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_UINT64_ARRAY_WITHIN_MESSAGE(110, expected, acutalBigDelta, 0, "Custom Message."); + VERIFY_FAILS_END +#endif +} + +void testUInt64ArrayWithinDeltaExpectedNull(void) +{ +#ifndef UNITY_SUPPORT_64 + TEST_IGNORE(); +#else + UNITY_UINT64 acutalBigDelta[] = {12345101, 12344896, 12345055}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_UINT64_ARRAY_WITHIN(110, NULL, acutalBigDelta, 3); + VERIFY_FAILS_END +#endif +} + +void testUInt64ArrayWithinDeltaExpectedNullAndMessage(void) +{ +#ifndef UNITY_SUPPORT_64 + TEST_IGNORE(); +#else + UNITY_UINT64 acutalBigDelta[] = {12345101, 12344896, 12345055}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_UINT64_ARRAY_WITHIN_MESSAGE(110, NULL, acutalBigDelta, 3, "Custom Message."); + VERIFY_FAILS_END +#endif +} + +void testUInt64ArrayWithinDeltaActualNull(void) +{ +#ifndef UNITY_SUPPORT_64 + TEST_IGNORE(); +#else + UNITY_UINT64 expected[] = {12345000, 12344995, 12345005}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_UINT64_ARRAY_WITHIN(110, expected, NULL, 3); + VERIFY_FAILS_END +#endif +} + +void testUInt64ArrayWithinDeltaActualNullAndMessage(void) +{ +#ifndef UNITY_SUPPORT_64 + TEST_IGNORE(); +#else + UNITY_UINT64 expected[] = {12345000, 12344995, 12345005}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_UINT64_ARRAY_WITHIN_MESSAGE(110, expected, NULL, 3, "Custom Message."); + VERIFY_FAILS_END +#endif +} + +void testUInt64ArrayWithinDeltaSamePointer(void) +{ +#ifndef UNITY_SUPPORT_64 + TEST_IGNORE(); +#else + UNITY_UINT64 expected[] = {12345000, 12344995, 12345005}; + + TEST_ASSERT_UINT64_ARRAY_WITHIN(110, expected, expected, 3); +#endif +} + +void testUInt64ArrayWithinDeltaSamePointerAndMessage(void) +{ +#ifndef UNITY_SUPPORT_64 + TEST_IGNORE(); +#else + UNITY_UINT64 expected[] = {12345000, 12344995, 12345005}; + + TEST_ASSERT_UINT64_ARRAY_WITHIN_MESSAGE(110, expected, expected, 3, "Custom Message."); +#endif +} + +void testUIntArrayWithinDelta(void) +{ + UNITY_UINT expected[] = {125000, 124995, 125005}; + UNITY_UINT acutalSmallDelta[] = {125001, 124996, 125005}; + UNITY_UINT acutalBigDelta[] = {125101, 124896, 125055}; + + TEST_ASSERT_UINT_ARRAY_WITHIN(1, expected, acutalSmallDelta, 3); + TEST_ASSERT_UINT_ARRAY_WITHIN(110, expected, acutalBigDelta, 3); +} + +void testUIntArrayWithinDeltaAndMessage(void) +{ + UNITY_UINT expected[] = {125000, 124995, 125005}; + UNITY_UINT acutalSmallDelta[] = {125001, 124996, 125005}; + UNITY_UINT acutalBigDelta[] = {125101, 124896, 125055}; + + TEST_ASSERT_UINT_ARRAY_WITHIN_MESSAGE(1, expected, acutalSmallDelta, 3, "Custom Message."); + TEST_ASSERT_UINT_ARRAY_WITHIN_MESSAGE(110, expected, acutalBigDelta, 3, "Custom Message."); +} + +void testUIntArrayNotWithinDelta(void) +{ + UNITY_UINT expected[] = {125000, 124995, 125005}; + UNITY_UINT acutalBigDelta[] = {125101, 124896, 125055}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_UINT_ARRAY_WITHIN(1, expected, acutalBigDelta, 3); + VERIFY_FAILS_END +} + +void testUIntArrayNotWithinDeltaAndMessage(void) +{ + UNITY_UINT expected[] = {125000, 124995, 125005}; + UNITY_UINT acutalBigDelta[] = {125101, 124896, 125055}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_UINT_ARRAY_WITHIN_MESSAGE(1, expected, acutalBigDelta, 3, "Custom Message."); + VERIFY_FAILS_END +} + +void testUIntArrayWithinDeltaPointless(void) +{ + UNITY_UINT expected[] = {125000, 124995, 125005}; + UNITY_UINT acutalBigDelta[] = {125101, 124896, 125055}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_UINT_ARRAY_WITHIN(110, expected, acutalBigDelta, 0); + VERIFY_FAILS_END +} + +void testUIntArrayWithinDeltaPointlessAndMessage(void) +{ + UNITY_UINT expected[] = {125000, 124995, 125005}; + UNITY_UINT acutalBigDelta[] = {125101, 124896, 125055}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_UINT_ARRAY_WITHIN_MESSAGE(110, expected, acutalBigDelta, 0, "Custom Message."); + VERIFY_FAILS_END +} + +void testUIntArrayWithinDeltaExpectedNull(void) +{ + UNITY_UINT acutalBigDelta[] = {125101, 124896, 125055}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_UINT_ARRAY_WITHIN(110, NULL, acutalBigDelta, 3); + VERIFY_FAILS_END +} + +void testUIntArrayWithinDeltaExpectedNullAndMessage(void) +{ + UNITY_UINT acutalBigDelta[] = {125101, 124896, 125055}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_UINT_ARRAY_WITHIN_MESSAGE(110, NULL, acutalBigDelta, 3, "Custom Message."); + VERIFY_FAILS_END +} + +void testUIntArrayWithinDeltaActualNull(void) +{ + UNITY_UINT expected[] = {125000, 124995, 125005}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_UINT_ARRAY_WITHIN(110, expected, NULL, 3); + VERIFY_FAILS_END +} + +void testUIntArrayWithinDeltaActualNullAndMessage(void) +{ + UNITY_UINT expected[] = {125000, 124995, 125005}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_UINT_ARRAY_WITHIN_MESSAGE(110, expected, NULL, 3, "Custom Message."); + VERIFY_FAILS_END +} + +void testUIntArrayWithinDeltaSamePointer(void) +{ + UNITY_UINT expected[] = {125000, 124995, 125005}; + + TEST_ASSERT_UINT_ARRAY_WITHIN(110, expected, expected, 3); +} + +void testUIntArrayWithinDeltaSamePointerAndMessage(void) +{ + UNITY_UINT expected[] = {125000, 124995, 125005}; + + TEST_ASSERT_UINT_ARRAY_WITHIN_MESSAGE(110, expected, expected, 3, "Custom Message."); +} + +void testUInt16ArrayWithinDelta(void) +{ + UNITY_UINT16 expected[] = {5000, 4995, 5005}; + UNITY_UINT16 acutalSmallDelta[] = {5001, 4996, 5005}; + UNITY_UINT16 acutalBigDelta[] = {5101, 4896, 5055}; + + TEST_ASSERT_UINT16_ARRAY_WITHIN(1, expected, acutalSmallDelta, 3); + TEST_ASSERT_UINT16_ARRAY_WITHIN(110, expected, acutalBigDelta, 3); +} + +void testUInt16ArrayWithinDeltaAndMessage(void) +{ + UNITY_UINT16 expected[] = {5000, 4995, 5005}; + UNITY_UINT16 acutalSmallDelta[] = {5001, 4996, 5005}; + UNITY_UINT16 acutalBigDelta[] = {5101, 4896, 5055}; + + TEST_ASSERT_UINT16_ARRAY_WITHIN_MESSAGE(1, expected, acutalSmallDelta, 3, "Custom Message."); + TEST_ASSERT_UINT16_ARRAY_WITHIN_MESSAGE(110, expected, acutalBigDelta, 3, "Custom Message."); +} + +void testUInt16ArrayNotWithinDelta(void) +{ + UNITY_UINT16 expected[] = {5000, 4995, 5005}; + UNITY_UINT16 acutalBigDelta[] = {5101, 4896, 5055}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_UINT16_ARRAY_WITHIN(1, expected, acutalBigDelta, 3); + VERIFY_FAILS_END +} + +void testUInt16ArrayNotWithinDeltaAndMessage(void) +{ + UNITY_UINT16 expected[] = {5000, 4995, 5005}; + UNITY_UINT16 acutalBigDelta[] = {5101, 4896, 5055}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_UINT16_ARRAY_WITHIN_MESSAGE(1, expected, acutalBigDelta, 3, "Custom Message."); + VERIFY_FAILS_END +} + +void testUInt16ArrayWithinDeltaPointless(void) +{ + UNITY_UINT16 expected[] = {5000, 4995, 5005}; + UNITY_UINT16 acutalBigDelta[] = {5101, 4896, 5055}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_UINT16_ARRAY_WITHIN(110, expected, acutalBigDelta, 0); + VERIFY_FAILS_END +} + +void testUInt16ArrayWithinDeltaPointlessAndMessage(void) +{ + UNITY_UINT16 expected[] = {5000, 4995, 5005}; + UNITY_UINT16 acutalBigDelta[] = {5101, 4896, 5055}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_UINT16_ARRAY_WITHIN_MESSAGE(110, expected, acutalBigDelta, 0, "Custom Message."); + VERIFY_FAILS_END +} + +void testUInt16ArrayWithinDeltaExpectedNull(void) +{ + UNITY_UINT16 acutalBigDelta[] = {5101, 4896, 5055}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_UINT16_ARRAY_WITHIN(110, NULL, acutalBigDelta, 3); + VERIFY_FAILS_END +} + +void testUInt16ArrayWithinDeltaExpectedNullAndMessage(void) +{ + UNITY_UINT16 acutalBigDelta[] = {5101, 4896, 5055}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_UINT16_ARRAY_WITHIN_MESSAGE(110, NULL, acutalBigDelta, 3, "Custom Message."); + VERIFY_FAILS_END +} + +void testUInt16ArrayWithinDeltaActualNull(void) +{ + UNITY_UINT16 expected[] = {5000, 4995, 5005}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_UINT16_ARRAY_WITHIN(110, expected, NULL, 3); + VERIFY_FAILS_END +} + +void testUInt16ArrayWithinDeltaActualNullAndMessage(void) +{ + UNITY_UINT16 expected[] = {5000, 4995, 5005}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_UINT16_ARRAY_WITHIN_MESSAGE(110, expected, NULL, 3, "Custom Message."); + VERIFY_FAILS_END +} + +void testUInt16ArrayWithinDeltaSamePointer(void) +{ + UNITY_UINT16 expected[] = {5000, 4995, 5005}; + + TEST_ASSERT_UINT16_ARRAY_WITHIN(110, expected, expected, 3); +} + +void testUInt16ArrayWithinDeltaSamePointerAndMessage(void) +{ + UNITY_UINT16 expected[] = {5000, 4995, 5005}; + + TEST_ASSERT_UINT16_ARRAY_WITHIN_MESSAGE(110, expected, expected, 3, "Custom Message."); +} + +void testUInt8ArrayWithinDelta(void) +{ + UNITY_UINT8 expected[] = {20, 95, 55}; + UNITY_UINT8 acutalSmallDelta[] = {21, 94, 55}; + UNITY_UINT8 acutalBigDelta[] = {11, 86, 45}; + + TEST_ASSERT_UINT8_ARRAY_WITHIN(1, expected, acutalSmallDelta, 3); + TEST_ASSERT_UINT8_ARRAY_WITHIN(11, expected, acutalBigDelta, 3); +} + +void testUInt8ArrayWithinDeltaAndMessage(void) +{ + UNITY_UINT8 expected[] = {20, 95, 55}; + UNITY_UINT8 acutalSmallDelta[] = {21, 94, 55}; + UNITY_UINT8 acutalBigDelta[] = {11, 86, 45}; + + TEST_ASSERT_UINT8_ARRAY_WITHIN_MESSAGE(1, expected, acutalSmallDelta, 3, "Custom Message."); + TEST_ASSERT_UINT8_ARRAY_WITHIN_MESSAGE(11, expected, acutalBigDelta, 3, "Custom Message."); +} + +void testUInt8ArrayNotWithinDelta(void) +{ + UNITY_UINT8 expected[] = {20, 95, 55}; + UNITY_UINT8 acutalBigDelta[] = {11, 86, 45}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_UINT8_ARRAY_WITHIN(1, expected, acutalBigDelta, 3); + VERIFY_FAILS_END +} + +void testUInt8ArrayNotWithinDeltaAndMessage(void) +{ + UNITY_UINT8 expected[] = {20, 95, 55}; + UNITY_UINT8 acutalBigDelta[] = {11, 86, 45}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_UINT8_ARRAY_WITHIN_MESSAGE(1, expected, acutalBigDelta, 3, "Custom Message."); + VERIFY_FAILS_END +} + +void testUInt8ArrayWithinDeltaPointless(void) +{ + UNITY_UINT8 expected[] = {20, 95, 55}; + UNITY_UINT8 acutalBigDelta[] = {11, 86, 45}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_UINT8_ARRAY_WITHIN(11, expected, acutalBigDelta, 0); + VERIFY_FAILS_END +} + +void testUInt8ArrayWithinDeltaPointlessAndMessage(void) +{ + UNITY_UINT8 expected[] = {20, 95, 55}; + UNITY_UINT8 acutalBigDelta[] = {11, 86, 45}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_UINT8_ARRAY_WITHIN_MESSAGE(11, expected, acutalBigDelta, 0, "Custom Message."); + VERIFY_FAILS_END +} + +void testUInt8ArrayWithinDeltaExpectedNull(void) +{ + UNITY_UINT8 acutalBigDelta[] = {11, 86, 45}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_UINT8_ARRAY_WITHIN(11, NULL, acutalBigDelta, 3); + VERIFY_FAILS_END +} + +void testUInt8ArrayWithinDeltaExpectedNullAndMessage(void) +{ + UNITY_UINT8 acutalBigDelta[] = {11, 86, 45}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_UINT8_ARRAY_WITHIN_MESSAGE(11, NULL, acutalBigDelta, 3, "Custom Message."); + VERIFY_FAILS_END +} + +void testUInt8ArrayWithinDeltaActualNull(void) +{ + UNITY_UINT8 expected[] = {20, 95, 55}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_UINT8_ARRAY_WITHIN(11, expected, NULL, 3); + VERIFY_FAILS_END +} + +void testUInt8ArrayWithinDeltaActualNullAndMessage(void) +{ + UNITY_UINT8 expected[] = {20, 95, 55}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_UINT8_ARRAY_WITHIN_MESSAGE(11, expected, NULL, 3, "Custom Message."); + VERIFY_FAILS_END +} + +void testUInt8ArrayWithinDeltaSamePointer(void) +{ + UNITY_UINT8 expected[] = {20, 95, 55}; + + TEST_ASSERT_UINT8_ARRAY_WITHIN(11, expected, expected, 3); +} + +void testUInt8ArrayWithinDeltaSamePointerAndMessage(void) +{ + UNITY_UINT8 expected[] = {20, 95, 55}; + + TEST_ASSERT_UINT8_ARRAY_WITHIN_MESSAGE(11, expected, expected, 3, "Custom Message."); +} + + +void testHEX64ArrayWithinDelta(void) +{ +#ifndef UNITY_SUPPORT_64 + TEST_IGNORE(); +#else + UNITY_UINT64 expected[] = {0xABCD1234, 0xABCD1122, 0xABCD1277}; + UNITY_UINT64 acutalSmallDelta[] = {0xABCD1235, 0xABCD1121, 0xABCD1277}; + UNITY_UINT64 acutalBigDelta[] = {0xABCD1267, 0xABCD1188, 0xABCD12AC}; + + TEST_ASSERT_HEX64_ARRAY_WITHIN(1, expected, acutalSmallDelta, 3); + TEST_ASSERT_HEX64_ARRAY_WITHIN(110, expected, acutalBigDelta, 3); +#endif +} + +void testHEX64ArrayWithinDeltaAndMessage(void) +{ +#ifndef UNITY_SUPPORT_64 + TEST_IGNORE(); +#else + UNITY_UINT64 expected[] = {0xABCD1234, 0xABCD1122, 0xABCD1277}; + UNITY_UINT64 acutalSmallDelta[] = {0xABCD1235, 0xABCD1121, 0xABCD1277}; + UNITY_UINT64 acutalBigDelta[] = {0xABCD1267, 0xABCD1188, 0xABCD12AC}; + + TEST_ASSERT_HEX64_ARRAY_WITHIN_MESSAGE(1, expected, acutalSmallDelta, 3, "Custom Message."); + TEST_ASSERT_HEX64_ARRAY_WITHIN_MESSAGE(110, expected, acutalBigDelta, 3, "Custom Message."); +#endif +} + +void testHEX64ArrayNotWithinDelta(void) +{ +#ifndef UNITY_SUPPORT_64 + TEST_IGNORE(); +#else + UNITY_UINT64 expected[] = {0xABCD1234, 0xABCD1122, 0xABCD1277}; + UNITY_UINT64 acutalBigDelta[] = {0xABCD1267, 0xABCD1188, 0xABCD12AC}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_HEX64_ARRAY_WITHIN(1, expected, acutalBigDelta, 3); + VERIFY_FAILS_END +#endif +} + +void testHEX64ArrayNotWithinDeltaAndMessage(void) +{ +#ifndef UNITY_SUPPORT_64 + TEST_IGNORE(); +#else + UNITY_UINT64 expected[] = {0xABCD1234, 0xABCD1122, 0xABCD1277}; + UNITY_UINT64 acutalBigDelta[] = {0xABCD1267, 0xABCD1188, 0xABCD12AC}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_HEX64_ARRAY_WITHIN_MESSAGE(1, expected, acutalBigDelta, 3, "Custom Message."); + VERIFY_FAILS_END +#endif +} + +void testHEX64ArrayWithinDeltaPointless(void) +{ +#ifndef UNITY_SUPPORT_64 + TEST_IGNORE(); +#else + UNITY_UINT64 expected[] = {0xABCD1234, 0xABCD1122, 0xABCD1277}; + UNITY_UINT64 acutalBigDelta[] = {0xABCD1267, 0xABCD1188, 0xABCD12AC}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_HEX64_ARRAY_WITHIN(110, expected, acutalBigDelta, 0); + VERIFY_FAILS_END +#endif +} + +void testHEX64ArrayWithinDeltaPointlessAndMessage(void) +{ +#ifndef UNITY_SUPPORT_64 + TEST_IGNORE(); +#else + UNITY_UINT64 expected[] = {0xABCD1234, 0xABCD1122, 0xABCD1277}; + UNITY_UINT64 acutalBigDelta[] = {0xABCD1267, 0xABCD1188, 0xABCD12AC}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_HEX64_ARRAY_WITHIN_MESSAGE(110, expected, acutalBigDelta, 0, "Custom Message."); + VERIFY_FAILS_END +#endif +} + +void testHEX64ArrayWithinDeltaExpectedNull(void) +{ +#ifndef UNITY_SUPPORT_64 + TEST_IGNORE(); +#else + UNITY_UINT64 acutalBigDelta[] = {0xABCD1267, 0xABCD1188, 0xABCD12AC}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_HEX64_ARRAY_WITHIN(110, NULL, acutalBigDelta, 3); + VERIFY_FAILS_END +#endif +} + +void testHEX64ArrayWithinDeltaExpectedNullAndMessage(void) +{ +#ifndef UNITY_SUPPORT_64 + TEST_IGNORE(); +#else + UNITY_UINT64 acutalBigDelta[] = {0xABCD1267, 0xABCD1188, 0xABCD12AC}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_HEX64_ARRAY_WITHIN_MESSAGE(110, NULL, acutalBigDelta, 3, "Custom Message."); + VERIFY_FAILS_END +#endif +} + +void testHEX64ArrayWithinDeltaActualNull(void) +{ +#ifndef UNITY_SUPPORT_64 + TEST_IGNORE(); +#else + UNITY_UINT64 expected[] = {0xABCD1234, 0xABCD1122, 0xABCD1277}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_HEX64_ARRAY_WITHIN(110, expected, NULL, 3); + VERIFY_FAILS_END +#endif +} + +void testHEX64ArrayWithinDeltaActualNullAndMessage(void) +{ +#ifndef UNITY_SUPPORT_64 + TEST_IGNORE(); +#else + UNITY_UINT64 expected[] = {0xABCD1234, 0xABCD1122, 0xABCD1277}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_HEX64_ARRAY_WITHIN_MESSAGE(110, expected, NULL, 3, "Custom Message."); + VERIFY_FAILS_END +#endif +} + +void testHEX64ArrayWithinDeltaSamePointer(void) +{ +#ifndef UNITY_SUPPORT_64 + TEST_IGNORE(); +#else + UNITY_UINT64 expected[] = {0xABCD1234, 0xABCD1122, 0xABCD1277}; + + TEST_ASSERT_HEX64_ARRAY_WITHIN(110, expected, expected, 3); +#endif +} + +void testHEX64ArrayWithinDeltaSamePointerAndMessage(void) +{ +#ifndef UNITY_SUPPORT_64 + TEST_IGNORE(); +#else + UNITY_UINT64 expected[] = {0xABCD11234, 0xABCD1122, 0xABCD1277}; + + TEST_ASSERT_HEX64_ARRAY_WITHIN_MESSAGE(110, expected, expected, 3, "Custom Message."); +#endif +} + + +void testHEX32ArrayWithinDelta(void) +{ + UNITY_UINT expected[] = {0xABCD1234, 0xABCD1122, 0xABCD1277}; + UNITY_UINT acutalSmallDelta[] = {0xABCD1235, 0xABCD1121, 0xABCD1277}; + UNITY_UINT acutalBigDelta[] = {0xABCD1267, 0xABCD1188, 0xABCD12AC}; + + TEST_ASSERT_HEX32_ARRAY_WITHIN(1, expected, acutalSmallDelta, 3); + TEST_ASSERT_HEX32_ARRAY_WITHIN(110, expected, acutalBigDelta, 3); +} + +void testHEX32ArrayWithinDeltaAndMessage(void) +{ + UNITY_UINT expected[] = {0xABCD1234, 0xABCD1122, 0xABCD1277}; + UNITY_UINT acutalSmallDelta[] = {0xABCD1235, 0xABCD1121, 0xABCD1277}; + UNITY_UINT acutalBigDelta[] = {0xABCD1267, 0xABCD1188, 0xABCD12AC}; + + TEST_ASSERT_HEX32_ARRAY_WITHIN_MESSAGE(1, expected, acutalSmallDelta, 3, "Custom Message."); + TEST_ASSERT_HEX32_ARRAY_WITHIN_MESSAGE(110, expected, acutalBigDelta, 3, "Custom Message."); +} + +void testHEX32ArrayNotWithinDelta(void) +{ + UNITY_UINT expected[] = {0xABCD1234, 0xABCD1122, 0xABCD1277}; + UNITY_UINT acutalBigDelta[] = {0xABCD1267, 0xABCD1188, 0xABCD12AC}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_HEX32_ARRAY_WITHIN(1, expected, acutalBigDelta, 3); + VERIFY_FAILS_END +} + +void testHEX32ArrayNotWithinDeltaAndMessage(void) +{ + UNITY_UINT expected[] = {0xABCD1234, 0xABCD1122, 0xABCD1277}; + UNITY_UINT acutalBigDelta[] = {0xABCD1267, 0xABCD1188, 0xABCD12AC}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_HEX32_ARRAY_WITHIN_MESSAGE(1, expected, acutalBigDelta, 3, "Custom Message."); + VERIFY_FAILS_END +} + +void testHEX32ArrayWithinDeltaPointless(void) +{ + UNITY_UINT expected[] = {0xABCD1234, 0xABCD1122, 0xABCD1277}; + UNITY_UINT acutalBigDelta[] = {0xABCD1267, 0xABCD1188, 0xABCD12AC}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_HEX32_ARRAY_WITHIN(110, expected, acutalBigDelta, 0); + VERIFY_FAILS_END +} + +void testHEX32ArrayWithinDeltaPointlessAndMessage(void) +{ + UNITY_UINT expected[] = {0xABCD1234, 0xABCD1122, 0xABCD1277}; + UNITY_UINT acutalBigDelta[] = {0xABCD1267, 0xABCD1188, 0xABCD12AC}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_HEX32_ARRAY_WITHIN_MESSAGE(110, expected, acutalBigDelta, 0, "Custom Message."); + VERIFY_FAILS_END +} + +void testHEX32ArrayWithinDeltaExpectedNull(void) +{ + UNITY_UINT acutalBigDelta[] = {0xABCD1267, 0xABCD1188, 0xABCD12AC}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_HEX32_ARRAY_WITHIN(110, NULL, acutalBigDelta, 3); + VERIFY_FAILS_END +} + +void testHEX32ArrayWithinDeltaExpectedNullAndMessage(void) +{ + UNITY_UINT acutalBigDelta[] = {0xABCD1267, 0xABCD1188, 0xABCD12AC}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_HEX32_ARRAY_WITHIN_MESSAGE(110, NULL, acutalBigDelta, 3, "Custom Message."); + VERIFY_FAILS_END +} + +void testHEX32ArrayWithinDeltaActualNull(void) +{ + UNITY_UINT expected[] = {0xABCD1234, 0xABCD1122, 0xABCD1277}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_HEX32_ARRAY_WITHIN(110, expected, NULL, 3); + VERIFY_FAILS_END +} + +void testHEX32ArrayWithinDeltaActualNullAndMessage(void) +{ + UNITY_UINT expected[] = {0xABCD1234, 0xABCD1122, 0xABCD1277}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_HEX32_ARRAY_WITHIN_MESSAGE(110, expected, NULL, 3, "Custom Message."); + VERIFY_FAILS_END +} + +void testHEX32ArrayWithinDeltaSamePointer(void) +{ + UNITY_UINT expected[] = {0xABCD1234, 0xABCD1122, 0xABCD1277}; + + TEST_ASSERT_HEX32_ARRAY_WITHIN(110, expected, expected, 3); +} + +void testHEX32ArrayWithinDeltaSamePointerAndMessage(void) +{ + UNITY_UINT expected[] = {0xABCD1234, 0xABCD1122, 0xABCD1277}; + + TEST_ASSERT_HEX32_ARRAY_WITHIN_MESSAGE(110, expected, expected, 3, "Custom Message."); +} + + +void testHEX16ArrayWithinDelta(void) +{ + UNITY_UINT16 expected[] = {0x1234, 0x1122, 0x1277}; + UNITY_UINT16 acutalSmallDelta[] = {0x1235, 0x1121, 0x1277}; + UNITY_UINT16 acutalBigDelta[] = {0x1267, 0x1188, 0x12AC}; + + TEST_ASSERT_HEX16_ARRAY_WITHIN(1, expected, acutalSmallDelta, 3); + TEST_ASSERT_HEX16_ARRAY_WITHIN(110, expected, acutalBigDelta, 3); +} + +void testHEX16ArrayWithinDeltaAndMessage(void) +{ + UNITY_UINT16 expected[] = {0x1234, 0x1122, 0x1277}; + UNITY_UINT16 acutalSmallDelta[] = {0x1235, 0x1121, 0x1277}; + UNITY_UINT16 acutalBigDelta[] = {0x1267, 0x1188, 0x12AC}; + + TEST_ASSERT_HEX16_ARRAY_WITHIN_MESSAGE(1, expected, acutalSmallDelta, 3, "Custom Message."); + TEST_ASSERT_HEX16_ARRAY_WITHIN_MESSAGE(110, expected, acutalBigDelta, 3, "Custom Message."); +} + +void testHEX16ArrayNotWithinDelta(void) +{ + UNITY_UINT16 expected[] = {0x1234, 0x1122, 0x1277}; + UNITY_UINT16 acutalBigDelta[] = {0x1267, 0x1188, 0x12AC}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_HEX16_ARRAY_WITHIN(1, expected, acutalBigDelta, 3); + VERIFY_FAILS_END +} + +void testHEX16ArrayNotWithinDeltaAndMessage(void) +{ + UNITY_UINT16 expected[] = {0x1234, 0x1122, 0x1277}; + UNITY_UINT16 acutalBigDelta[] = {0x1267, 0x1188, 0x12AC}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_HEX16_ARRAY_WITHIN_MESSAGE(1, expected, acutalBigDelta, 3, "Custom Message."); + VERIFY_FAILS_END +} + +void testHEX16ArrayWithinDeltaPointless(void) +{ + UNITY_UINT16 expected[] = {0x1234, 0x1122, 0x1277}; + UNITY_UINT16 acutalBigDelta[] = {0x1267, 0x1188, 0x12AC}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_HEX16_ARRAY_WITHIN(110, expected, acutalBigDelta, 0); + VERIFY_FAILS_END +} + +void testHEX16ArrayWithinDeltaPointlessAndMessage(void) +{ + UNITY_UINT16 expected[] = {0x1234, 0x1122, 0x1277}; + UNITY_UINT16 acutalBigDelta[] = {0x1267, 0x1188, 0x12AC}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_HEX16_ARRAY_WITHIN_MESSAGE(110, expected, acutalBigDelta, 0, "Custom Message."); + VERIFY_FAILS_END +} + +void testHEX16ArrayWithinDeltaExpectedNull(void) +{ + UNITY_UINT16 acutalBigDelta[] = {0x1267, 0x1188, 0x12AC}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_HEX16_ARRAY_WITHIN(110, NULL, acutalBigDelta, 3); + VERIFY_FAILS_END +} + +void testHEX16ArrayWithinDeltaExpectedNullAndMessage(void) +{ + UNITY_UINT16 acutalBigDelta[] = {0x1267, 0x1188, 0x12AC}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_HEX16_ARRAY_WITHIN_MESSAGE(110, NULL, acutalBigDelta, 3, "Custom Message."); + VERIFY_FAILS_END +} + +void testHEX16ArrayWithinDeltaActualNull(void) +{ + UNITY_UINT16 expected[] = {0x1234, 0x1122, 0x1277}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_HEX16_ARRAY_WITHIN(110, expected, NULL, 3); + VERIFY_FAILS_END +} + +void testHEX16ArrayWithinDeltaActualNullAndMessage(void) +{ + UNITY_UINT16 expected[] = {0x1234, 0x1122, 0x1277}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_HEX16_ARRAY_WITHIN_MESSAGE(110, expected, NULL, 3, "Custom Message."); + VERIFY_FAILS_END +} + +void testHEX16ArrayWithinDeltaSamePointer(void) +{ + UNITY_UINT16 expected[] = {0x1234, 0x1122, 0x1277}; + + TEST_ASSERT_HEX16_ARRAY_WITHIN(110, expected, expected, 3); +} + +void testHEX16ArrayWithinDeltaSamePointerAndMessage(void) +{ + UNITY_UINT16 expected[] = {0x1234, 0x1122, 0x1277}; + + TEST_ASSERT_HEX16_ARRAY_WITHIN_MESSAGE(110, expected, expected, 3, "Custom Message."); +} + +void testHEX8ArrayWithinDelta(void) +{ + UNITY_UINT8 expected[] = {0x34, 0x22, 0x77}; + UNITY_UINT8 acutalSmallDelta[] = {0x35, 0x21, 0x77}; + UNITY_UINT8 acutalBigDelta[] = {0x47, 0x48, 0x4C}; + + TEST_ASSERT_HEX8_ARRAY_WITHIN(1, expected, acutalSmallDelta, 3); + TEST_ASSERT_HEX8_ARRAY_WITHIN(60, expected, acutalBigDelta, 3); +} + +void testHEX8ArrayWithinDeltaAndMessage(void) +{ + UNITY_UINT8 expected[] = {0x34, 0x22, 0x77}; + UNITY_UINT8 acutalSmallDelta[] = {0x35, 0x21, 0x77}; + UNITY_UINT8 acutalBigDelta[] = {0x47, 0x48, 0x4C}; + + TEST_ASSERT_HEX8_ARRAY_WITHIN_MESSAGE(1, expected, acutalSmallDelta, 3, "Custom Message."); + TEST_ASSERT_HEX8_ARRAY_WITHIN_MESSAGE(60, expected, acutalBigDelta, 3, "Custom Message."); +} + +void testHEX8ArrayNotWithinDelta(void) +{ + UNITY_UINT8 expected[] = {0x34, 0x22, 0x77}; + UNITY_UINT8 acutalBigDelta[] = {0x67, 0x88, 0xAC}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_HEX8_ARRAY_WITHIN(1, expected, acutalBigDelta, 3); + VERIFY_FAILS_END +} + +void testHEX8ArrayNotWithinDeltaAndMessage(void) +{ + UNITY_UINT8 expected[] = {0x34, 0x22, 0x77}; + UNITY_UINT8 acutalBigDelta[] = {0x67, 0x88, 0xAC}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_HEX8_ARRAY_WITHIN_MESSAGE(1, expected, acutalBigDelta, 3, "Custom Message."); + VERIFY_FAILS_END +} + +void testHEX8ArrayWithinDeltaPointless(void) +{ + UNITY_UINT8 expected[] = {0x34, 0x22, 0x77}; + UNITY_UINT8 acutalBigDelta[] = {0x67, 0x88, 0xAC}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_HEX8_ARRAY_WITHIN(60, expected, acutalBigDelta, 0); + VERIFY_FAILS_END +} + +void testHEX8ArrayWithinDeltaPointlessAndMessage(void) +{ + UNITY_UINT8 expected[] = {0x34, 0x22, 0x77}; + UNITY_UINT8 acutalBigDelta[] = {0x67, 0x88, 0xAC}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_HEX8_ARRAY_WITHIN_MESSAGE(60, expected, acutalBigDelta, 0, "Custom Message."); + VERIFY_FAILS_END +} + +void testHEX8ArrayWithinDeltaExpectedNull(void) +{ + UNITY_UINT8 acutalBigDelta[] = {0x67, 0x88, 0xAC}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_HEX8_ARRAY_WITHIN(60, NULL, acutalBigDelta, 3); + VERIFY_FAILS_END +} + +void testHEX8ArrayWithinDeltaExpectedNullAndMessage(void) +{ + UNITY_UINT8 acutalBigDelta[] = {0x67, 0x88, 0xAC}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_HEX8_ARRAY_WITHIN_MESSAGE(60, NULL, acutalBigDelta, 3, "Custom Message."); + VERIFY_FAILS_END +} + +void testHEX8ArrayWithinDeltaActualNull(void) +{ + UNITY_UINT8 expected[] = {0x34, 0x22, 0x77}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_HEX8_ARRAY_WITHIN(60, expected, NULL, 3); + VERIFY_FAILS_END +} + +void testHEX8ArrayWithinDeltaActualNullAndMessage(void) +{ + UNITY_UINT8 expected[] = {0x34, 0x22, 0x77}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_HEX8_ARRAY_WITHIN_MESSAGE(60, expected, NULL, 3, "Custom Message."); + VERIFY_FAILS_END +} + +void testHEX8ArrayWithinDeltaSamePointer(void) +{ + UNITY_UINT8 expected[] = {0x34, 0x22, 0x77}; + + TEST_ASSERT_HEX8_ARRAY_WITHIN(60, expected, expected, 3); +} + +void testHEX8ArrayWithinDeltaSamePointerAndMessage(void) +{ + UNITY_UINT8 expected[] = {0x34, 0x22, 0x77}; + + TEST_ASSERT_HEX8_ARRAY_WITHIN_MESSAGE(60, expected, expected, 3, "Custom Message."); +} //----------------- + void testGreaterThan(void) { UNITY_INT v0, v1; From 18430d3b4fdacdbf82a1a45d02ab1c52869b1b71 Mon Sep 17 00:00:00 2001 From: Fabian Zahn Date: Sat, 4 May 2019 16:01:44 +0200 Subject: [PATCH 111/454] Added initial .editorconfig file. --- .editorconfig | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 .editorconfig diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 00000000..7b7a47a0 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,27 @@ +############################################################################### +# Unity Project - A Test Framework for C +# .editorconfig - F. Zahn 2019 +############################################################################### + +# This is the topmost .editorconfig file +root = true + +# Settings that apply to all languages / files +[*] +charset = utf-8 +indent_size = 4 +indent_style = space +insert_final_newline = true +trim_trailing_whitespace = true + +[*.md] +trim_trailing_whitespace = false + +[*.txt] +trim_trailing_whitespace = false + +[*.rb] +indent_size = 2 + +[*.yml] +indent_size = 2 From 01a907393a64df8845c29b9735ef04ab45a80ae2 Mon Sep 17 00:00:00 2001 From: Dom Postorivo Date: Sat, 20 Apr 2019 15:39:55 -0400 Subject: [PATCH 112/454] silent mode in unity fixture --- extras/fixture/src/unity_fixture.c | 30 ++++++++++++++++---- extras/fixture/src/unity_fixture_internals.h | 1 + 2 files changed, 25 insertions(+), 6 deletions(-) diff --git a/extras/fixture/src/unity_fixture.c b/extras/fixture/src/unity_fixture.c index 2771198f..0a16f6cb 100644 --- a/extras/fixture/src/unity_fixture.c +++ b/extras/fixture/src/unity_fixture.c @@ -79,15 +79,21 @@ void UnityTestRunner(unityfunction* setup, Unity.TestFile = file; Unity.CurrentTestName = printableName; Unity.CurrentTestLineNumber = line; - if (!UnityFixture.Verbose) - UNITY_OUTPUT_CHAR('.'); - else + if (UnityFixture.Verbose) { UnityPrint(printableName); #ifndef UNITY_REPEAT_TEST_NAME Unity.CurrentTestName = NULL; #endif } + else if (UnityFixture.Silent) + { + /* Do Nothing */ + } + else + { + UNITY_OUTPUT_CHAR('.'); + } Unity.NumberOfTests++; UnityMalloc_StartTest(); @@ -120,13 +126,19 @@ void UnityIgnoreTest(const char* printableName, const char* group, const char* n { Unity.NumberOfTests++; Unity.TestIgnores++; - if (!UnityFixture.Verbose) - UNITY_OUTPUT_CHAR('!'); - else + if (UnityFixture.Verbose) { UnityPrint(printableName); UNITY_PRINT_EOL(); } + else if (UnityFixture.Silent) + { + /* Do Nothing */ + } + else + { + UNITY_OUTPUT_CHAR('!'); + } } } @@ -350,6 +362,7 @@ int UnityGetCommandLineOptions(int argc, const char* argv[]) { int i; UnityFixture.Verbose = 0; + UnityFixture.Silent = 0; UnityFixture.GroupFilter = 0; UnityFixture.NameFilter = 0; UnityFixture.RepeatCount = 1; @@ -364,6 +377,11 @@ int UnityGetCommandLineOptions(int argc, const char* argv[]) UnityFixture.Verbose = 1; i++; } + else if (strcmp(argv[i], "-s") == 0) + { + UnityFixture.Silent = 1; + i++; + } else if (strcmp(argv[i], "-g") == 0) { i++; diff --git a/extras/fixture/src/unity_fixture_internals.h b/extras/fixture/src/unity_fixture_internals.h index 00cee883..98d4d443 100644 --- a/extras/fixture/src/unity_fixture_internals.h +++ b/extras/fixture/src/unity_fixture_internals.h @@ -16,6 +16,7 @@ extern "C" struct UNITY_FIXTURE_T { int Verbose; + int Silent; unsigned int RepeatCount; const char* NameFilter; const char* GroupFilter; From 8168382b917fa093f9c6466fb2da252b96a2a326 Mon Sep 17 00:00:00 2001 From: Fabian Zahn Date: Sun, 12 May 2019 09:16:41 +0200 Subject: [PATCH 113/454] Adjust testHexPrintsUpToMaxNumberOfNibbles (independent of sizeof operator and arithmetics) --- test/tests/testunity.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/test/tests/testunity.c b/test/tests/testunity.c index 56f0328b..f5a3a074 100644 --- a/test/tests/testunity.c +++ b/test/tests/testunity.c @@ -5730,7 +5730,11 @@ void testHexPrintsUpToMaxNumberOfNibbles(void) startPutcharSpy(); UnityPrintNumberHex(0xBEE, 21); endPutcharSpy(); - TEST_ASSERT_EQUAL_INT(sizeof(UNITY_INT)*2, strlen(getBufferPutcharSpy())); +#ifdef UNITY_SUPPORT_64 + TEST_ASSERT_EQUAL_INT(16, strlen(getBufferPutcharSpy())); +#else + TEST_ASSERT_EQUAL_INT( 8, strlen(getBufferPutcharSpy())); +#endif #endif } From ae3aad7b8964ca7bd728011a5315ae59151c4637 Mon Sep 17 00:00:00 2001 From: Fabian Zahn Date: Sun, 12 May 2019 09:24:49 +0200 Subject: [PATCH 114/454] Remove the remaining sizeof() operators from internal interface sizeof() is a hell of an operator and returns the size of a data type in terms of "addressable units" which is not necessarily the size in bytes. To circumvent this problem and in order to keep the API clean we try to remove all sizeof() from the API. --- src/unity_internals.h | 66 ++++++++++++++++++++++--------------------- 1 file changed, 34 insertions(+), 32 deletions(-) diff --git a/src/unity_internals.h b/src/unity_internals.h index 050fbdbf..62d6d18a 100644 --- a/src/unity_internals.h +++ b/src/unity_internals.h @@ -47,6 +47,8 @@ /* Determine the size of an int, if not already specified. * We cannot use sizeof(int), because it is not yet defined * at this stage in the translation of the C program. + * Also sizeof(int) does return the size in addressable units on all platforms, + * which may not necessarily be the size in bytes. * Therefore, infer it from UINT_MAX if possible. */ #ifndef UNITY_INT_WIDTH #ifdef UINT_MAX @@ -398,7 +400,7 @@ typedef void (*UnityTestFunction)(void); typedef enum { - UNITY_DISPLAY_STYLE_INT = sizeof(int) + UNITY_DISPLAY_RANGE_INT, + UNITY_DISPLAY_STYLE_INT = (UNITY_INT_WIDTH / 8) + UNITY_DISPLAY_RANGE_INT, UNITY_DISPLAY_STYLE_INT8 = 1 + UNITY_DISPLAY_RANGE_INT, UNITY_DISPLAY_STYLE_INT16 = 2 + UNITY_DISPLAY_RANGE_INT, UNITY_DISPLAY_STYLE_INT32 = 4 + UNITY_DISPLAY_RANGE_INT, @@ -406,7 +408,7 @@ typedef enum UNITY_DISPLAY_STYLE_INT64 = 8 + UNITY_DISPLAY_RANGE_INT, #endif - UNITY_DISPLAY_STYLE_UINT = sizeof(unsigned) + UNITY_DISPLAY_RANGE_UINT, + UNITY_DISPLAY_STYLE_UINT = (UNITY_INT_WIDTH / 8) + UNITY_DISPLAY_RANGE_UINT, UNITY_DISPLAY_STYLE_UINT8 = 1 + UNITY_DISPLAY_RANGE_UINT, UNITY_DISPLAY_STYLE_UINT16 = 2 + UNITY_DISPLAY_RANGE_UINT, UNITY_DISPLAY_STYLE_UINT32 = 4 + UNITY_DISPLAY_RANGE_UINT, @@ -790,11 +792,11 @@ int UnityTestMatches(void); #define UNITY_TEST_ASSERT_SMALLER_THAN_HEX16(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_UINT16)(threshold), (UNITY_INT)(UNITY_UINT16)(actual), UNITY_SMALLER_THAN, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX16) #define UNITY_TEST_ASSERT_SMALLER_THAN_HEX32(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_UINT32)(threshold), (UNITY_INT)(UNITY_UINT32)(actual), UNITY_SMALLER_THAN, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX32) -#define UNITY_TEST_ASSERT_GREATER_OR_EQUAL_INT(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(threshold), (UNITY_INT)(actual), UNITY_GREATER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT) -#define UNITY_TEST_ASSERT_GREATER_OR_EQUAL_INT8(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_INT8 )(threshold), (UNITY_INT)(UNITY_INT8 )(actual), UNITY_GREATER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT8) -#define UNITY_TEST_ASSERT_GREATER_OR_EQUAL_INT16(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_INT16)(threshold), (UNITY_INT)(UNITY_INT16)(actual), UNITY_GREATER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT16) -#define UNITY_TEST_ASSERT_GREATER_OR_EQUAL_INT32(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_INT32)(threshold), (UNITY_INT)(UNITY_INT32)(actual), UNITY_GREATER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT32) -#define UNITY_TEST_ASSERT_GREATER_OR_EQUAL_UINT(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(threshold), (UNITY_INT)(actual), UNITY_GREATER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT) +#define UNITY_TEST_ASSERT_GREATER_OR_EQUAL_INT(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT) (threshold), (UNITY_INT) (actual), UNITY_GREATER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT) +#define UNITY_TEST_ASSERT_GREATER_OR_EQUAL_INT8(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_INT8 ) (threshold), (UNITY_INT)(UNITY_INT8 ) (actual), UNITY_GREATER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT8) +#define UNITY_TEST_ASSERT_GREATER_OR_EQUAL_INT16(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_INT16) (threshold), (UNITY_INT)(UNITY_INT16) (actual), UNITY_GREATER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT16) +#define UNITY_TEST_ASSERT_GREATER_OR_EQUAL_INT32(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_INT32) (threshold), (UNITY_INT)(UNITY_INT32) (actual), UNITY_GREATER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT32) +#define UNITY_TEST_ASSERT_GREATER_OR_EQUAL_UINT(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT) (threshold), (UNITY_INT) (actual), UNITY_GREATER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT) #define UNITY_TEST_ASSERT_GREATER_OR_EQUAL_UINT8(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_UINT8 )(threshold), (UNITY_INT)(UNITY_UINT8 )(actual), UNITY_GREATER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT8) #define UNITY_TEST_ASSERT_GREATER_OR_EQUAL_UINT16(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_UINT16)(threshold), (UNITY_INT)(UNITY_UINT16)(actual), UNITY_GREATER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT16) #define UNITY_TEST_ASSERT_GREATER_OR_EQUAL_UINT32(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_UINT32)(threshold), (UNITY_INT)(UNITY_UINT32)(actual), UNITY_GREATER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT32) @@ -802,11 +804,11 @@ int UnityTestMatches(void); #define UNITY_TEST_ASSERT_GREATER_OR_EQUAL_HEX16(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_UINT16)(threshold), (UNITY_INT)(UNITY_UINT16)(actual), UNITY_GREATER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX16) #define UNITY_TEST_ASSERT_GREATER_OR_EQUAL_HEX32(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_UINT32)(threshold), (UNITY_INT)(UNITY_UINT32)(actual), UNITY_GREATER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX32) -#define UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_INT(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(threshold), (UNITY_INT)(actual), UNITY_SMALLER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT) -#define UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_INT8(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_INT8 )(threshold), (UNITY_INT)(UNITY_INT8 )(actual), UNITY_SMALLER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT8) -#define UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_INT16(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_INT16)(threshold), (UNITY_INT)(UNITY_INT16)(actual), UNITY_SMALLER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT16) -#define UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_INT32(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_INT32)(threshold), (UNITY_INT)(UNITY_INT32)(actual), UNITY_SMALLER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT32) -#define UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_UINT(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(threshold), (UNITY_INT)(actual), UNITY_SMALLER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT) +#define UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_INT(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT) (threshold), (UNITY_INT) (actual), UNITY_SMALLER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT) +#define UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_INT8(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_INT8 )(threshold), (UNITY_INT)(UNITY_INT8 ) (actual), UNITY_SMALLER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT8) +#define UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_INT16(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_INT16)(threshold), (UNITY_INT)(UNITY_INT16) (actual), UNITY_SMALLER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT16) +#define UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_INT32(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_INT32)(threshold), (UNITY_INT)(UNITY_INT32) (actual), UNITY_SMALLER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT32) +#define UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_UINT(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT) (threshold), (UNITY_INT) (actual), UNITY_SMALLER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT) #define UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_UINT8(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_UINT8 )(threshold), (UNITY_INT)(UNITY_UINT8 )(actual), UNITY_SMALLER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT8) #define UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_UINT16(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_UINT16)(threshold), (UNITY_INT)(UNITY_UINT16)(actual), UNITY_SMALLER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT16) #define UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_UINT32(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_UINT32)(threshold), (UNITY_INT)(UNITY_UINT32)(actual), UNITY_SMALLER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT32) @@ -814,11 +816,11 @@ int UnityTestMatches(void); #define UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_HEX16(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_UINT16)(threshold), (UNITY_INT)(UNITY_UINT16)(actual), UNITY_SMALLER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX16) #define UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_HEX32(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_UINT32)(threshold), (UNITY_INT)(UNITY_UINT32)(actual), UNITY_SMALLER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX32) -#define UNITY_TEST_ASSERT_INT_WITHIN(delta, expected, actual, line, message) UnityAssertNumbersWithin((delta), (UNITY_INT)(expected), (UNITY_INT)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT) -#define UNITY_TEST_ASSERT_INT8_WITHIN(delta, expected, actual, line, message) UnityAssertNumbersWithin((UNITY_UINT8 )(delta), (UNITY_INT)(UNITY_INT8 )(expected), (UNITY_INT)(UNITY_INT8 )(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT8) -#define UNITY_TEST_ASSERT_INT16_WITHIN(delta, expected, actual, line, message) UnityAssertNumbersWithin((UNITY_UINT16)(delta), (UNITY_INT)(UNITY_INT16)(expected), (UNITY_INT)(UNITY_INT16)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT16) -#define UNITY_TEST_ASSERT_INT32_WITHIN(delta, expected, actual, line, message) UnityAssertNumbersWithin((UNITY_UINT32)(delta), (UNITY_INT)(UNITY_INT32)(expected), (UNITY_INT)(UNITY_INT32)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT32) -#define UNITY_TEST_ASSERT_UINT_WITHIN(delta, expected, actual, line, message) UnityAssertNumbersWithin((delta), (UNITY_INT)(expected), (UNITY_INT)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT) +#define UNITY_TEST_ASSERT_INT_WITHIN(delta, expected, actual, line, message) UnityAssertNumbersWithin( (delta), (UNITY_INT) (expected), (UNITY_INT) (actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT) +#define UNITY_TEST_ASSERT_INT8_WITHIN(delta, expected, actual, line, message) UnityAssertNumbersWithin((UNITY_UINT8 )(delta), (UNITY_INT)(UNITY_INT8 ) (expected), (UNITY_INT)(UNITY_INT8 ) (actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT8) +#define UNITY_TEST_ASSERT_INT16_WITHIN(delta, expected, actual, line, message) UnityAssertNumbersWithin((UNITY_UINT16)(delta), (UNITY_INT)(UNITY_INT16) (expected), (UNITY_INT)(UNITY_INT16) (actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT16) +#define UNITY_TEST_ASSERT_INT32_WITHIN(delta, expected, actual, line, message) UnityAssertNumbersWithin((UNITY_UINT32)(delta), (UNITY_INT)(UNITY_INT32) (expected), (UNITY_INT)(UNITY_INT32) (actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT32) +#define UNITY_TEST_ASSERT_UINT_WITHIN(delta, expected, actual, line, message) UnityAssertNumbersWithin( (delta), (UNITY_INT) (expected), (UNITY_INT) (actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT) #define UNITY_TEST_ASSERT_UINT8_WITHIN(delta, expected, actual, line, message) UnityAssertNumbersWithin((UNITY_UINT8 )(delta), (UNITY_INT)(UNITY_UINT)(UNITY_UINT8 )(expected), (UNITY_INT)(UNITY_UINT)(UNITY_UINT8 )(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT8) #define UNITY_TEST_ASSERT_UINT16_WITHIN(delta, expected, actual, line, message) UnityAssertNumbersWithin((UNITY_UINT16)(delta), (UNITY_INT)(UNITY_UINT)(UNITY_UINT16)(expected), (UNITY_INT)(UNITY_UINT)(UNITY_UINT16)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT16) #define UNITY_TEST_ASSERT_UINT32_WITHIN(delta, expected, actual, line, message) UnityAssertNumbersWithin((UNITY_UINT32)(delta), (UNITY_INT)(UNITY_UINT)(UNITY_UINT32)(expected), (UNITY_INT)(UNITY_UINT)(UNITY_UINT32)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT32) @@ -827,12 +829,12 @@ int UnityTestMatches(void); #define UNITY_TEST_ASSERT_HEX32_WITHIN(delta, expected, actual, line, message) UnityAssertNumbersWithin((UNITY_UINT32)(delta), (UNITY_INT)(UNITY_UINT)(UNITY_UINT32)(expected), (UNITY_INT)(UNITY_UINT)(UNITY_UINT32)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX32) -#define UNITY_TEST_ASSERT_INT_ARRAY_WITHIN(delta, expected, actual, num_elements, line, message) UnityAssertNumbersArrayWithin((delta), (UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), ((UNITY_UINT32)(num_elements)), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT, UNITY_ARRAY_TO_ARRAY) +#define UNITY_TEST_ASSERT_INT_ARRAY_WITHIN(delta, expected, actual, num_elements, line, message) UnityAssertNumbersArrayWithin( (delta), (UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), ((UNITY_UINT32)(num_elements)), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT, UNITY_ARRAY_TO_ARRAY) #define UNITY_TEST_ASSERT_INT8_ARRAY_WITHIN(delta, expected, actual, num_elements, line, message) UnityAssertNumbersArrayWithin((UNITY_UINT8 )(delta), (UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), ((UNITY_UINT32)(num_elements)), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT8, UNITY_ARRAY_TO_ARRAY) #define UNITY_TEST_ASSERT_INT16_ARRAY_WITHIN(delta, expected, actual, num_elements, line, message) UnityAssertNumbersArrayWithin((UNITY_UINT16)(delta), (UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), ((UNITY_UINT32)(num_elements)), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT16, UNITY_ARRAY_TO_ARRAY) #define UNITY_TEST_ASSERT_INT32_ARRAY_WITHIN(delta, expected, actual, num_elements, line, message) UnityAssertNumbersArrayWithin((UNITY_UINT32)(delta), (UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), ((UNITY_UINT32)(num_elements)), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT32, UNITY_ARRAY_TO_ARRAY) -#define UNITY_TEST_ASSERT_UINT_ARRAY_WITHIN(delta, expected, actual, num_elements, line, message) UnityAssertNumbersArrayWithin((delta), (UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), ((UNITY_UINT32)(num_elements)), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT, UNITY_ARRAY_TO_ARRAY) -#define UNITY_TEST_ASSERT_UINT8_ARRAY_WITHIN(delta, expected, actual, num_elements, line, message) UnityAssertNumbersArrayWithin((UNITY_UINT16)(delta), (UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), ((UNITY_UINT32)(num_elements)), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT8, UNITY_ARRAY_TO_ARRAY) +#define UNITY_TEST_ASSERT_UINT_ARRAY_WITHIN(delta, expected, actual, num_elements, line, message) UnityAssertNumbersArrayWithin( (delta), (UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), ((UNITY_UINT32)(num_elements)), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT, UNITY_ARRAY_TO_ARRAY) +#define UNITY_TEST_ASSERT_UINT8_ARRAY_WITHIN(delta, expected, actual, num_elements, line, message) UnityAssertNumbersArrayWithin( (UNITY_UINT16)(delta), (UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), ((UNITY_UINT32)(num_elements)), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT8, UNITY_ARRAY_TO_ARRAY) #define UNITY_TEST_ASSERT_UINT16_ARRAY_WITHIN(delta, expected, actual, num_elements, line, message) UnityAssertNumbersArrayWithin((UNITY_UINT16)(delta), (UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), ((UNITY_UINT32)(num_elements)), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT16, UNITY_ARRAY_TO_ARRAY) #define UNITY_TEST_ASSERT_UINT32_ARRAY_WITHIN(delta, expected, actual, num_elements, line, message) UnityAssertNumbersArrayWithin((UNITY_UINT32)(delta), (UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), ((UNITY_UINT32)(num_elements)), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT32, UNITY_ARRAY_TO_ARRAY) #define UNITY_TEST_ASSERT_HEX8_ARRAY_WITHIN(delta, expected, actual, num_elements, line, message) UnityAssertNumbersArrayWithin((UNITY_UINT8 )(delta), (UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), ((UNITY_UINT32)(num_elements)), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX8, UNITY_ARRAY_TO_ARRAY) @@ -860,18 +862,18 @@ int UnityTestMatches(void); #define UNITY_TEST_ASSERT_EQUAL_STRING_ARRAY(expected, actual, num_elements, line, message) UnityAssertEqualStringArray((UNITY_INTERNAL_PTR)(expected), (const char**)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_ARRAY_TO_ARRAY) #define UNITY_TEST_ASSERT_EQUAL_MEMORY_ARRAY(expected, actual, len, num_elements, line, message) UnityAssertEqualMemory((UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(len), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_ARRAY_TO_ARRAY) -#define UNITY_TEST_ASSERT_EACH_EQUAL_INT(expected, actual, num_elements, line, message) UnityAssertEqualIntArray(UnityNumToPtr((UNITY_INT) (expected), sizeof(int)), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT, UNITY_ARRAY_TO_VAL) -#define UNITY_TEST_ASSERT_EACH_EQUAL_INT8(expected, actual, num_elements, line, message) UnityAssertEqualIntArray(UnityNumToPtr((UNITY_INT)(UNITY_INT8 )(expected), 1), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT8, UNITY_ARRAY_TO_VAL) -#define UNITY_TEST_ASSERT_EACH_EQUAL_INT16(expected, actual, num_elements, line, message) UnityAssertEqualIntArray(UnityNumToPtr((UNITY_INT)(UNITY_INT16 )(expected), 2), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT16, UNITY_ARRAY_TO_VAL) -#define UNITY_TEST_ASSERT_EACH_EQUAL_INT32(expected, actual, num_elements, line, message) UnityAssertEqualIntArray(UnityNumToPtr((UNITY_INT)(UNITY_INT32 )(expected), 4), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT32, UNITY_ARRAY_TO_VAL) -#define UNITY_TEST_ASSERT_EACH_EQUAL_UINT(expected, actual, num_elements, line, message) UnityAssertEqualIntArray(UnityNumToPtr((UNITY_INT) (expected), sizeof(unsigned int)), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT, UNITY_ARRAY_TO_VAL) -#define UNITY_TEST_ASSERT_EACH_EQUAL_UINT8(expected, actual, num_elements, line, message) UnityAssertEqualIntArray(UnityNumToPtr((UNITY_INT)(UNITY_UINT8 )(expected), 1), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT8, UNITY_ARRAY_TO_VAL) -#define UNITY_TEST_ASSERT_EACH_EQUAL_UINT16(expected, actual, num_elements, line, message) UnityAssertEqualIntArray(UnityNumToPtr((UNITY_INT)(UNITY_UINT16)(expected), 2), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT16, UNITY_ARRAY_TO_VAL) -#define UNITY_TEST_ASSERT_EACH_EQUAL_UINT32(expected, actual, num_elements, line, message) UnityAssertEqualIntArray(UnityNumToPtr((UNITY_INT)(UNITY_UINT32)(expected), 4), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT32, UNITY_ARRAY_TO_VAL) -#define UNITY_TEST_ASSERT_EACH_EQUAL_HEX8(expected, actual, num_elements, line, message) UnityAssertEqualIntArray(UnityNumToPtr((UNITY_INT)(UNITY_INT8 )(expected), 1), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX8, UNITY_ARRAY_TO_VAL) -#define UNITY_TEST_ASSERT_EACH_EQUAL_HEX16(expected, actual, num_elements, line, message) UnityAssertEqualIntArray(UnityNumToPtr((UNITY_INT)(UNITY_INT16 )(expected), 2), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX16, UNITY_ARRAY_TO_VAL) -#define UNITY_TEST_ASSERT_EACH_EQUAL_HEX32(expected, actual, num_elements, line, message) UnityAssertEqualIntArray(UnityNumToPtr((UNITY_INT)(UNITY_INT32 )(expected), 4), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX32, UNITY_ARRAY_TO_VAL) -#define UNITY_TEST_ASSERT_EACH_EQUAL_PTR(expected, actual, num_elements, line, message) UnityAssertEqualIntArray(UnityNumToPtr((UNITY_PTR_TO_INT) (expected), sizeof(int*)), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_POINTER, UNITY_ARRAY_TO_VAL) +#define UNITY_TEST_ASSERT_EACH_EQUAL_INT(expected, actual, num_elements, line, message) UnityAssertEqualIntArray(UnityNumToPtr((UNITY_INT) (expected), (UNITY_INT_WIDTH / 8)), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT, UNITY_ARRAY_TO_VAL) +#define UNITY_TEST_ASSERT_EACH_EQUAL_INT8(expected, actual, num_elements, line, message) UnityAssertEqualIntArray(UnityNumToPtr((UNITY_INT)(UNITY_INT8 )(expected), 1), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT8, UNITY_ARRAY_TO_VAL) +#define UNITY_TEST_ASSERT_EACH_EQUAL_INT16(expected, actual, num_elements, line, message) UnityAssertEqualIntArray(UnityNumToPtr((UNITY_INT)(UNITY_INT16 )(expected), 2), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT16, UNITY_ARRAY_TO_VAL) +#define UNITY_TEST_ASSERT_EACH_EQUAL_INT32(expected, actual, num_elements, line, message) UnityAssertEqualIntArray(UnityNumToPtr((UNITY_INT)(UNITY_INT32 )(expected), 4), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT32, UNITY_ARRAY_TO_VAL) +#define UNITY_TEST_ASSERT_EACH_EQUAL_UINT(expected, actual, num_elements, line, message) UnityAssertEqualIntArray(UnityNumToPtr((UNITY_INT) (expected), (UNITY_INT_WIDTH / 8)), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT, UNITY_ARRAY_TO_VAL) +#define UNITY_TEST_ASSERT_EACH_EQUAL_UINT8(expected, actual, num_elements, line, message) UnityAssertEqualIntArray(UnityNumToPtr((UNITY_INT)(UNITY_UINT8 )(expected), 1), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT8, UNITY_ARRAY_TO_VAL) +#define UNITY_TEST_ASSERT_EACH_EQUAL_UINT16(expected, actual, num_elements, line, message) UnityAssertEqualIntArray(UnityNumToPtr((UNITY_INT)(UNITY_UINT16)(expected), 2), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT16, UNITY_ARRAY_TO_VAL) +#define UNITY_TEST_ASSERT_EACH_EQUAL_UINT32(expected, actual, num_elements, line, message) UnityAssertEqualIntArray(UnityNumToPtr((UNITY_INT)(UNITY_UINT32)(expected), 4), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT32, UNITY_ARRAY_TO_VAL) +#define UNITY_TEST_ASSERT_EACH_EQUAL_HEX8(expected, actual, num_elements, line, message) UnityAssertEqualIntArray(UnityNumToPtr((UNITY_INT)(UNITY_INT8 )(expected), 1), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX8, UNITY_ARRAY_TO_VAL) +#define UNITY_TEST_ASSERT_EACH_EQUAL_HEX16(expected, actual, num_elements, line, message) UnityAssertEqualIntArray(UnityNumToPtr((UNITY_INT)(UNITY_INT16 )(expected), 2), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX16, UNITY_ARRAY_TO_VAL) +#define UNITY_TEST_ASSERT_EACH_EQUAL_HEX32(expected, actual, num_elements, line, message) UnityAssertEqualIntArray(UnityNumToPtr((UNITY_INT)(UNITY_INT32 )(expected), 4), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX32, UNITY_ARRAY_TO_VAL) +#define UNITY_TEST_ASSERT_EACH_EQUAL_PTR(expected, actual, num_elements, line, message) UnityAssertEqualIntArray(UnityNumToPtr((UNITY_PTR_TO_INT) (expected), (UNITY_POINTER_WIDTH / 8)), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_POINTER, UNITY_ARRAY_TO_VAL) #define UNITY_TEST_ASSERT_EACH_EQUAL_STRING(expected, actual, num_elements, line, message) UnityAssertEqualStringArray((UNITY_INTERNAL_PTR)(expected), (const char**)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_ARRAY_TO_VAL) #define UNITY_TEST_ASSERT_EACH_EQUAL_MEMORY(expected, actual, len, num_elements, line, message) UnityAssertEqualMemory((UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(len), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_ARRAY_TO_VAL) From 885ae9638e8146401562e55d44d5473e8357ee6f Mon Sep 17 00:00:00 2001 From: Fabian Zahn Date: Sun, 12 May 2019 09:31:26 +0200 Subject: [PATCH 115/454] Introduce patch from "UnityAssertEqualIntArray" for "UnityAssertNumbersArrayWithin" in order to get rid of the sizeof() operator --- src/unity.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/src/unity.c b/src/unity.c index 1fd508f8..6ca2d0d8 100644 --- a/src/unity.c +++ b/src/unity.c @@ -1271,8 +1271,10 @@ void UnityAssertNumbersArrayWithin(const UNITY_UINT delta, { UNITY_UINT32 elements = num_elements; unsigned int length = style & 0xF; + unsigned int increment = 0; RETURN_IF_FAIL_OR_IGNORE; + if (num_elements == 0) { UnityPrintPointlessAndBail(); @@ -1298,20 +1300,28 @@ void UnityAssertNumbersArrayWithin(const UNITY_UINT delta, case 1: expect_val = *(UNITY_PTR_ATTRIBUTE const UNITY_INT8*)expected; actual_val = *(UNITY_PTR_ATTRIBUTE const UNITY_INT8*)actual; + increment = sizeof(UNITY_INT8); break; + case 2: expect_val = *(UNITY_PTR_ATTRIBUTE const UNITY_INT16*)expected; actual_val = *(UNITY_PTR_ATTRIBUTE const UNITY_INT16*)actual; + increment = sizeof(UNITY_INT16); break; + #ifdef UNITY_SUPPORT_64 case 8: expect_val = *(UNITY_PTR_ATTRIBUTE const UNITY_INT64*)expected; actual_val = *(UNITY_PTR_ATTRIBUTE const UNITY_INT64*)actual; + increment = sizeof(UNITY_INT64); break; #endif - default: /* length 4 bytes */ + + default: /* default is length 4 bytes */ + case 4: expect_val = *(UNITY_PTR_ATTRIBUTE const UNITY_INT32*)expected; actual_val = *(UNITY_PTR_ATTRIBUTE const UNITY_INT32*)actual; + increment = sizeof(UNITY_INT32); length = 4; break; } @@ -1341,7 +1351,7 @@ void UnityAssertNumbersArrayWithin(const UNITY_UINT delta, if (Unity.CurrentTestFailed) { - if ((style & UNITY_DISPLAY_RANGE_UINT) && (length < sizeof(expect_val))) + if ((style & UNITY_DISPLAY_RANGE_UINT) && (length < (UNITY_INT_WIDTH / 8))) { /* For UINT, remove sign extension (padding 1's) from signed type casts above */ UNITY_INT mask = 1; mask = (mask << 8 * length) - 1; @@ -1360,13 +1370,13 @@ void UnityAssertNumbersArrayWithin(const UNITY_UINT delta, UnityAddMsgIfSpecified(msg); UNITY_FAIL_AND_BAIL; } + /* Walk through array by incrementing the pointers */ if (flags == UNITY_ARRAY_TO_ARRAY) { - expected = (UNITY_INTERNAL_PTR)(length + (const char*)expected); + expected = (UNITY_INTERNAL_PTR)((const char*)expected + increment); } - actual = (UNITY_INTERNAL_PTR)(length + (const char*)actual); + actual = (UNITY_INTERNAL_PTR)((const char*)actual + increment); } - } /*-----------------------------------------------*/ From 06ddace18d8537ed1a26858761fffbfd3efd03e6 Mon Sep 17 00:00:00 2001 From: Fabian Zahn Date: Sun, 12 May 2019 19:44:02 +0200 Subject: [PATCH 116/454] Update documentation of "UNITY_POINTER_WIDTH" --- docs/UnityConfigurationGuide.md | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/docs/UnityConfigurationGuide.md b/docs/UnityConfigurationGuide.md index 1275ca76..7b281cbe 100644 --- a/docs/UnityConfigurationGuide.md +++ b/docs/UnityConfigurationGuide.md @@ -1,4 +1,4 @@ -# Unity Configuration Guide +# Unity Configuration Guide ## C Standards, Compilers and Microcontrollers @@ -119,9 +119,17 @@ Define this to be the number of bits a pointer takes up on your system. The default, if not autodetected, is 32-bits. If you're getting ugly compiler warnings about casting from pointers, this is the one to look at. +_Hint:_ In order to support exotic processors (for example TI C55x with a pointer +width of 23-bit), choose the next power of two (in this case 32-bit). + +_Supported values:_ 16, 32 and 64 + _Example:_ ```C -#define UNITY_POINTER_WIDTH 64 +// Choose on of these #defines to set your pointer width (if not autodetected) +//#define UNITY_POINTER_WIDTH 16 +//#define UNITY_POINTER_WIDTH 32 +#define UNITY_POINTER_WIDTH 64 // Set UNITY_POINTER_WIDTH to 64-bit ``` From 2b250055bc52df2c4abec0e9d476bf4350afd18d Mon Sep 17 00:00:00 2001 From: Fabian Zahn Date: Sun, 12 May 2019 19:57:54 +0200 Subject: [PATCH 117/454] Add indentation for type autodetection macros --- src/unity_internals.h | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/unity_internals.h b/src/unity_internals.h index 62d6d18a..a51430ba 100644 --- a/src/unity_internals.h +++ b/src/unity_internals.h @@ -131,7 +131,7 @@ #ifndef UNITY_SUPPORT_64 /* No 64-bit Support */ typedef UNITY_UINT32 UNITY_UINT; - typedef UNITY_INT32 UNITY_INT; + typedef UNITY_INT32 UNITY_INT; #define UNITY_MAX_NIBBLES (8) /* Maximum number of nibbles in a UNITY_(U)INT */ #else /* 64-bit Support */ @@ -145,7 +145,7 @@ #error Invalid UNITY_LONG_WIDTH specified! (32 or 64 are supported) #endif typedef UNITY_UINT64 UNITY_UINT; - typedef UNITY_INT64 UNITY_INT; + typedef UNITY_INT64 UNITY_INT; #define UNITY_MAX_NIBBLES (16) /* Maximum number of nibbles in a UNITY_(U)INT */ #endif @@ -154,24 +154,24 @@ *-------------------------------------------------------*/ #if (UNITY_POINTER_WIDTH == 32) -#define UNITY_PTR_TO_INT UNITY_INT32 -#define UNITY_DISPLAY_STYLE_POINTER UNITY_DISPLAY_STYLE_HEX32 + #define UNITY_PTR_TO_INT UNITY_INT32 + #define UNITY_DISPLAY_STYLE_POINTER UNITY_DISPLAY_STYLE_HEX32 #elif (UNITY_POINTER_WIDTH == 64) -#define UNITY_PTR_TO_INT UNITY_INT64 -#define UNITY_DISPLAY_STYLE_POINTER UNITY_DISPLAY_STYLE_HEX64 + #define UNITY_PTR_TO_INT UNITY_INT64 + #define UNITY_DISPLAY_STYLE_POINTER UNITY_DISPLAY_STYLE_HEX64 #elif (UNITY_POINTER_WIDTH == 16) -#define UNITY_PTR_TO_INT UNITY_INT16 -#define UNITY_DISPLAY_STYLE_POINTER UNITY_DISPLAY_STYLE_HEX16 + #define UNITY_PTR_TO_INT UNITY_INT16 + #define UNITY_DISPLAY_STYLE_POINTER UNITY_DISPLAY_STYLE_HEX16 #else - #error Invalid UNITY_POINTER_WIDTH specified! (16, 32 or 64 are supported) + #error Invalid UNITY_POINTER_WIDTH specified! (16, 32 or 64 are supported) #endif #ifndef UNITY_PTR_ATTRIBUTE -#define UNITY_PTR_ATTRIBUTE + #define UNITY_PTR_ATTRIBUTE #endif #ifndef UNITY_INTERNAL_PTR -#define UNITY_INTERNAL_PTR UNITY_PTR_ATTRIBUTE const void* + #define UNITY_INTERNAL_PTR UNITY_PTR_ATTRIBUTE const void* #endif /*------------------------------------------------------- From a59db2bdbf3d32bc4a26470ffd81aa551f13fe2b Mon Sep 17 00:00:00 2001 From: Nico Tonnhofer Date: Thu, 27 Jun 2019 08:26:07 +0200 Subject: [PATCH 118/454] add a blank line after #include "unity.h" The include must be in the first line, else you may expect some issues. Some autoformat tools could sort the includes alphabetically and could break the test. --- auto/generate_module.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/auto/generate_module.rb b/auto/generate_module.rb index 92aa5146..def5d088 100644 --- a/auto/generate_module.rb +++ b/auto/generate_module.rb @@ -14,6 +14,7 @@ # TEMPLATE_TST TEMPLATE_TST ||= '#include "unity.h" + %2$s#include "%1$s.h" void setUp(void) From 7dbfc4be56f006954f7cc440e2f542b22d004ff6 Mon Sep 17 00:00:00 2001 From: Michael Brockus Date: Tue, 2 Jul 2019 19:57:55 -0700 Subject: [PATCH 119/454] Adding root meson.build file. --- meson.build | 79 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 meson.build diff --git a/meson.build b/meson.build new file mode 100644 index 00000000..0c6a3449 --- /dev/null +++ b/meson.build @@ -0,0 +1,79 @@ +################################################################################### +# # +# NAME: meson.build # +# # +# AUTHOR: Mike Karlesky, Mark VanderVoord, Greg Williams. # +# WRITTEN BY: Michael Brockus. # +# # +# License: MIT # +# # +################################################################################### + + + +project('unity', 'c', + license : 'MIT', + meson_version : '>=0.50.0', + default_options : + [ + 'werror=true', + 'optimization=3', + 'warning_level=3', + 'b_sanitize=address,undefined', + 'b_lto=true', + 'b_lundef=true' + ]) +cc = meson.get_compiler('c') +args_for_langs = 'c' + +if cc.get_id() == 'clang' + add_project_arguments( + '-Wweak-vtables', + '-Wexit-time-destructors', + '-Wglobal-constructors', + '-Wmissing-noreturn', language: args_for_langs) +endif + +if cc.get_argument_syntax() == 'gcc' + add_project_arguments( + '-Wall', + '-Wextra', + '-Wunreachable-code', + '-Wmissing-declarations', + '-Wmissing-prototypes', + '-Wredundant-decls', + '-Wundef', + '-Wwrite-strings', + '-Wformat', + '-Wformat-nonliteral', + '-Wformat-security', + '-Wold-style-definition', + '-Winit-self', + '-Wmissing-include-dirs', + '-Waddress', + '-Waggregate-return', + '-Wno-multichar', + '-Wdeclaration-after-statement', + '-Wvla', + '-Wpointer-arith',language: args_for_langs) +endif + +if cc.get_id() == 'msvc' + add_project_arguments( + '/W4', + '/w44265', + '/w44061', + '/w44062', + '/wd4018', # implicit signed/unsigned conversion + '/wd4146', # unary minus on unsigned (beware INT_MIN) + '/wd4244', # lossy type conversion (e.g. double -> int) + '/wd4305', # truncating type conversion (e.g. double -> float) + mesno.get_supported_arguments(['/utf-8']), language: args_for_langs) +endif + +subdir('src') + +unity_dep = declare_dependency( + version: meson.project_version(), + link_with: unity_lib, + include_directories: unity_dir) From bd4d35ddd0755d7214fa7a8df53a8b7ce9ccaea6 Mon Sep 17 00:00:00 2001 From: Michael Brockus Date: Tue, 2 Jul 2019 19:58:16 -0700 Subject: [PATCH 120/454] Added meson.build in src directory. --- src/meson.build | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 src/meson.build diff --git a/src/meson.build b/src/meson.build new file mode 100644 index 00000000..5d8c4528 --- /dev/null +++ b/src/meson.build @@ -0,0 +1,20 @@ +################################################################################### +# # +# NAME: src/meson.build # +# # +# AUTHOR: Mike Karlesky, Mark VanderVoord, Greg Williams. # +# WRITTEN BY: Michael Brockus. # +# # +# License: MIT # +# # +################################################################################### + + + +unity_src = files('unity.c') + +unity_dir = include_directories('.') + +unity_lib = library(meson.project_name(), + sources: unity_src, + include_directories: unity_dir) \ No newline at end of file From f2d826c7c56971b97c2329be18db139eeebcf8bc Mon Sep 17 00:00:00 2001 From: Mark VanderVoord Date: Wed, 3 Jul 2019 15:03:03 -0400 Subject: [PATCH 121/454] - Added options for how to handle TEST_ASSERT_EQUAL shorthand - Tweak a couple style problems with Ruby scripts. --- auto/generate_test_runner.rb | 5 ++-- docs/UnityAssertionsReference.md | 10 ++----- docs/UnityConfigurationGuide.md | 24 ++++++++++++++- release/version.info | 2 +- src/unity.c | 1 + src/unity.h | 50 +++++++++++++++++++++++++++++--- src/unity_internals.h | 10 +++++++ 7 files changed, 86 insertions(+), 16 deletions(-) diff --git a/auto/generate_test_runner.rb b/auto/generate_test_runner.rb index 66e0b063..aebecb1a 100644 --- a/auto/generate_test_runner.rb +++ b/auto/generate_test_runner.rb @@ -103,8 +103,7 @@ def find_tests(source) source_scrubbed = source.clone source_scrubbed = source_scrubbed.gsub(/\\"/, '@quote@') # hide escaped quotes to allow capture of the full string/char source_scrubbed = source_scrubbed.gsub(/\\'/, '@apos@') # hide escaped apostrophes to allow capture of the full string/char - source_scrubbed = source_scrubbed.gsub(/("[^"\n]*")|('[^'\n]*')/) { |s| s.gsub(substring_re, substring_subs) } # temporarily hide problematic - # characters within strings + source_scrubbed = source_scrubbed.gsub(/("[^"\n]*")|('[^'\n]*')/) { |s| s.gsub(substring_re, substring_subs) } # temporarily hide problematic characters within strings source_scrubbed = source_scrubbed.gsub(/\/\/.*$/, '') # remove line comments source_scrubbed = source_scrubbed.gsub(/\/\*.*?\*\//m, '') # remove block comments lines = source_scrubbed.split(/(^\s*\#.*$) # Treat preprocessor directives as a logical line @@ -472,4 +471,4 @@ def create_h_file(output, filename, tests, testfile_includes, used_mocks) ARGV[1] = ARGV[0].gsub('.c', '_Runner.c') unless ARGV[1] UnityTestRunnerGenerator.new(options).run(ARGV[0], ARGV[1]) -end \ No newline at end of file +end diff --git a/docs/UnityAssertionsReference.md b/docs/UnityAssertionsReference.md index 0f1aaa2c..efb03ffc 100644 --- a/docs/UnityAssertionsReference.md +++ b/docs/UnityAssertionsReference.md @@ -105,12 +105,12 @@ becomes messageified like thus... TEST_ASSERT_X_MESSAGE( {modifiers}, {expected}, actual, {size/count}, message ) Notes: -- The `_MESSAGE` variants intentionally do not support `printf` style formatting +- The `_MESSAGE` variants intentionally do not support `printf` style formatting since many embedded projects don't support or avoid `printf` for various reasons. It is possible to use `sprintf` before the assertion to assemble a complex fail message, if necessary. -- If you want to output a counter value within an assertion fail message (e.g. from - a loop) , building up an array of results and then using one of the `_ARRAY` +- If you want to output a counter value within an assertion fail message (e.g. from + a loop) , building up an array of results and then using one of the `_ARRAY` assertions (see below) might be a handy alternative to `sprintf`. @@ -237,10 +237,6 @@ sizes. ##### `TEST_ASSERT_EQUAL_INT64 (expected, actual)` -##### `TEST_ASSERT_EQUAL (expected, actual)` - -##### `TEST_ASSERT_NOT_EQUAL (expected, actual)` - ##### `TEST_ASSERT_EQUAL_UINT (expected, actual)` ##### `TEST_ASSERT_EQUAL_UINT8 (expected, actual)` diff --git a/docs/UnityConfigurationGuide.md b/docs/UnityConfigurationGuide.md index 1275ca76..1aeb6c45 100644 --- a/docs/UnityConfigurationGuide.md +++ b/docs/UnityConfigurationGuide.md @@ -420,12 +420,34 @@ _Example:_ ##### `UNITY_OUTPUT_COLOR` If you want to add color using ANSI escape codes you can use this define. -t + _Example:_ ```C #define UNITY_OUTPUT_COLOR ``` +##### `UNITY_SHORTHAND_AS_INT` +##### `UNITY_SHORTHAND_AS_MEM` +##### `UNITY_SHORTHAND_AS_RAW` +##### `UNITY_SHORTHAND_AS_NONE` + +These options give you control of the `TEST_ASSERT_EQUAL` and the +`TEST_ASSERT_NOT_EQUAL` shorthand assertions. Historically, Unity treated the +former as an alias for an integer comparison. It treated the latter as a direct +comparison using `!=`. This assymetry was confusing, but there was much +disagreement as to how best to treat this pair of assertions. These four options +will allow you to specify how Unity will treat these assertions. + + - AS INT - the values will be cast to integers and directly compared. Arguments + that don't cast easily to integers will cause compiler errors. + - AS MEM - the address of both values will be taken and the entire object's + memory footprint will be compared byte by byte. Directly placing + constant numbers like `456` as expected values will cause errors. + - AS_RAW - Unity assumes that you can compare the two values using `==` and `!=` + and will do so. No details are given about mismatches, because it + doesn't really know what type it's dealing with. + - AS_NONE - Unity will disallow the use of these shorthand macros altogether, + insisting that developers choose a more descriptive option. ## Getting Into The Guts diff --git a/release/version.info b/release/version.info index cf12b30d..b2031148 100644 --- a/release/version.info +++ b/release/version.info @@ -1,2 +1,2 @@ -2.4.3 +2.4.4 diff --git a/src/unity.c b/src/unity.c index 1fd508f8..d7d3c640 100644 --- a/src/unity.c +++ b/src/unity.c @@ -53,6 +53,7 @@ static const char UnityStrNaN[] = "NaN"; static const char UnityStrDet[] = "Determinate"; static const char UnityStrInvalidFloatTrait[] = "Invalid Float Trait"; #endif +const char UnityStrErrShorthand[] = "Unity Shorthand Support Disabled"; const char UnityStrErrFloat[] = "Unity Floating Point Disabled"; const char UnityStrErrDouble[] = "Unity Double Precision Disabled"; const char UnityStrErr64[] = "Unity 64-bit Support Disabled"; diff --git a/src/unity.h b/src/unity.h index 0f64653a..af2b549b 100644 --- a/src/unity.h +++ b/src/unity.h @@ -130,8 +130,6 @@ int suiteTearDown(int num_failures); #define TEST_ASSERT_EQUAL_INT16(expected, actual) UNITY_TEST_ASSERT_EQUAL_INT16((expected), (actual), __LINE__, NULL) #define TEST_ASSERT_EQUAL_INT32(expected, actual) UNITY_TEST_ASSERT_EQUAL_INT32((expected), (actual), __LINE__, NULL) #define TEST_ASSERT_EQUAL_INT64(expected, actual) UNITY_TEST_ASSERT_EQUAL_INT64((expected), (actual), __LINE__, NULL) -#define TEST_ASSERT_EQUAL(expected, actual) UNITY_TEST_ASSERT_EQUAL_INT((expected), (actual), __LINE__, NULL) -#define TEST_ASSERT_NOT_EQUAL(expected, actual) UNITY_TEST_ASSERT(((expected) != (actual)), __LINE__, " Expected Not-Equal") #define TEST_ASSERT_EQUAL_UINT(expected, actual) UNITY_TEST_ASSERT_EQUAL_UINT( (expected), (actual), __LINE__, NULL) #define TEST_ASSERT_EQUAL_UINT8(expected, actual) UNITY_TEST_ASSERT_EQUAL_UINT8( (expected), (actual), __LINE__, NULL) #define TEST_ASSERT_EQUAL_UINT16(expected, actual) UNITY_TEST_ASSERT_EQUAL_UINT16( (expected), (actual), __LINE__, NULL) @@ -322,6 +320,29 @@ int suiteTearDown(int num_failures); #define TEST_ASSERT_DOUBLE_IS_NOT_NAN(actual) UNITY_TEST_ASSERT_DOUBLE_IS_NOT_NAN((actual), __LINE__, NULL) #define TEST_ASSERT_DOUBLE_IS_NOT_DETERMINATE(actual) UNITY_TEST_ASSERT_DOUBLE_IS_NOT_DETERMINATE((actual), __LINE__, NULL) +/* Shorthand */ +#ifdef UNITY_SHORTHAND_AS_OLD +#define TEST_ASSERT_EQUAL(expected, actual) UNITY_TEST_ASSERT_EQUAL_INT((expected), (actual), __LINE__, NULL) +#define TEST_ASSERT_NOT_EQUAL(expected, actual) UNITY_TEST_ASSERT(((expected) != (actual)), __LINE__, " Expected Not-Equal") +#endif +#ifdef UNITY_SHORTHAND_AS_INT +#define TEST_ASSERT_EQUAL(expected, actual) UNITY_TEST_ASSERT_EQUAL_INT((expected), (actual), __LINE__, NULL) +#define TEST_ASSERT_NOT_EQUAL(expected, actual) UNITY_TEST_FAIL(__LINE__, UnityStrErrShorthand) +#endif +#ifdef UNITY_SHORTHAND_AS_MEM +#define TEST_ASSERT_EQUAL(expected, actual) UNITY_TEST_ASSERT_EQUAL_MEMORY((&expected), (&actual), sizeof(expected), __LINE__, NULL) +#define TEST_ASSERT_NOT_EQUAL(expected, actual) UNITY_TEST_FAIL(__LINE__, UnityStrErrShorthand) +#endif +#ifdef UNITY_SHORTHAND_AS_RAW +#define TEST_ASSERT_EQUAL(expected, actual) UNITY_TEST_ASSERT(((expected) == (actual)), __LINE__, " Expected Equal") +#define TEST_ASSERT_NOT_EQUAL(expected, actual) UNITY_TEST_ASSERT(((expected) != (actual)), __LINE__, " Expected Not-Equal") +#endif +#ifdef UNITY_SHORTHAND_AS_NONE +const char UnityStrErrShorthand[]; +#define TEST_ASSERT_EQUAL(expected, actual) UNITY_TEST_FAIL(__LINE__, UnityStrErrShorthand) +#define TEST_ASSERT_NOT_EQUAL(expected, actual) UNITY_TEST_FAIL(__LINE__, UnityStrErrShorthand) +#endif + /*------------------------------------------------------- * Test Asserts (with additional messages) *-------------------------------------------------------*/ @@ -340,8 +361,6 @@ int suiteTearDown(int num_failures); #define TEST_ASSERT_EQUAL_INT16_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_INT16((expected), (actual), __LINE__, (message)) #define TEST_ASSERT_EQUAL_INT32_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_INT32((expected), (actual), __LINE__, (message)) #define TEST_ASSERT_EQUAL_INT64_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_INT64((expected), (actual), __LINE__, (message)) -#define TEST_ASSERT_EQUAL_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_INT((expected), (actual), __LINE__, (message)) -#define TEST_ASSERT_NOT_EQUAL_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT(((expected) != (actual)), __LINE__, (message)) #define TEST_ASSERT_EQUAL_UINT_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_UINT( (expected), (actual), __LINE__, (message)) #define TEST_ASSERT_EQUAL_UINT8_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_UINT8( (expected), (actual), __LINE__, (message)) #define TEST_ASSERT_EQUAL_UINT16_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_UINT16( (expected), (actual), __LINE__, (message)) @@ -532,6 +551,29 @@ int suiteTearDown(int num_failures); #define TEST_ASSERT_DOUBLE_IS_NOT_NAN_MESSAGE(actual, message) UNITY_TEST_ASSERT_DOUBLE_IS_NOT_NAN((actual), __LINE__, (message)) #define TEST_ASSERT_DOUBLE_IS_NOT_DETERMINATE_MESSAGE(actual, message) UNITY_TEST_ASSERT_DOUBLE_IS_NOT_DETERMINATE((actual), __LINE__, (message)) +/* Shorthand */ +#ifdef UNITY_SHORTHAND_AS_OLD +#define TEST_ASSERT_EQUAL_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_INT((expected), (actual), __LINE__, (message)) +#define TEST_ASSERT_NOT_EQUAL_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT(((expected) != (actual)), __LINE__, (message)) +#endif +#ifdef UNITY_SHORTHAND_AS_INT +#define TEST_ASSERT_EQUAL_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_INT((expected), (actual), __LINE__, message) +#define TEST_ASSERT_NOT_EQUAL_MESSAGE(expected, actual, message) UNITY_TEST_FAIL(__LINE__, UnityStrErrShorthand) +#endif +#ifdef UNITY_SHORTHAND_AS_MEM +#define TEST_ASSERT_EQUAL_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_MEMORY((&expected), (&actual), sizeof(expected), __LINE__, message) +#define TEST_ASSERT_NOT_EQUAL_MESSAGE(expected, actual, message) UNITY_TEST_FAIL(__LINE__, UnityStrErrShorthand) +#endif +#ifdef UNITY_SHORTHAND_AS_RAW +#define TEST_ASSERT_EQUAL_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT(((expected) == (actual)), __LINE__, message) +#define TEST_ASSERT_NOT_EQUAL_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT(((expected) != (actual)), __LINE__, message) +#endif +#ifdef UNITY_SHORTHAND_AS_NONE +const char UnityStrErrShorthand[]; +#define TEST_ASSERT_EQUAL_MESSAGE(expected, actual, message) UNITY_TEST_FAIL(__LINE__, UnityStrErrShorthand) +#define TEST_ASSERT_NOT_EQUAL_MESSAGE(expected, actual, message) UNITY_TEST_FAIL(__LINE__, UnityStrErrShorthand) +#endif + /* end of UNITY_FRAMEWORK_H */ #ifdef __cplusplus } diff --git a/src/unity_internals.h b/src/unity_internals.h index 050fbdbf..c2c5fa6b 100644 --- a/src/unity_internals.h +++ b/src/unity_internals.h @@ -729,6 +729,16 @@ extern const char UnityStrErr64[]; #define UNITY_END() UnityEnd() #endif +#ifndef UNITY_SHORTHAND_AS_INT +#ifndef UNITY_SHORTHAND_AS_MEM +#ifndef UNITY_SHORTHAND_AS_NONE +#ifndef UNITY_SHORTHAND_AS_RAW +#define UNITY_SHORTHAND_AS_OLD +#endif +#endif +#endif +#endif + /*----------------------------------------------- * Command Line Argument Support *-----------------------------------------------*/ From c30730faf63e75c1bda73cc3161e5f8dc38de7b1 Mon Sep 17 00:00:00 2001 From: Mark VanderVoord Date: Wed, 3 Jul 2019 15:07:44 -0400 Subject: [PATCH 122/454] cleanup warning. --- src/unity.h | 2 -- src/unity_internals.h | 1 + 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/src/unity.h b/src/unity.h index af2b549b..9e26067d 100644 --- a/src/unity.h +++ b/src/unity.h @@ -338,7 +338,6 @@ int suiteTearDown(int num_failures); #define TEST_ASSERT_NOT_EQUAL(expected, actual) UNITY_TEST_ASSERT(((expected) != (actual)), __LINE__, " Expected Not-Equal") #endif #ifdef UNITY_SHORTHAND_AS_NONE -const char UnityStrErrShorthand[]; #define TEST_ASSERT_EQUAL(expected, actual) UNITY_TEST_FAIL(__LINE__, UnityStrErrShorthand) #define TEST_ASSERT_NOT_EQUAL(expected, actual) UNITY_TEST_FAIL(__LINE__, UnityStrErrShorthand) #endif @@ -569,7 +568,6 @@ const char UnityStrErrShorthand[]; #define TEST_ASSERT_NOT_EQUAL_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT(((expected) != (actual)), __LINE__, message) #endif #ifdef UNITY_SHORTHAND_AS_NONE -const char UnityStrErrShorthand[]; #define TEST_ASSERT_EQUAL_MESSAGE(expected, actual, message) UNITY_TEST_FAIL(__LINE__, UnityStrErrShorthand) #define TEST_ASSERT_NOT_EQUAL_MESSAGE(expected, actual, message) UNITY_TEST_FAIL(__LINE__, UnityStrErrShorthand) #endif diff --git a/src/unity_internals.h b/src/unity_internals.h index c2c5fa6b..a3f39cac 100644 --- a/src/unity_internals.h +++ b/src/unity_internals.h @@ -679,6 +679,7 @@ extern const char UnityStrIgnore[]; extern const char UnityStrErrFloat[]; extern const char UnityStrErrDouble[]; extern const char UnityStrErr64[]; +extern const char UnityStrErrShorthand[]; /*------------------------------------------------------- * Test Running Macros From ab9f8d0959969dcc06216d801ae98bc10e71f394 Mon Sep 17 00:00:00 2001 From: Michael Brockus Date: Wed, 3 Jul 2019 15:30:50 -0700 Subject: [PATCH 123/454] Added example 4 in examples directory. --- examples/example_4/meson.build | 17 +++++ examples/example_4/readme.txt | 5 ++ examples/example_4/src/ProductionCode.c | 24 +++++++ examples/example_4/src/ProductionCode.h | 3 + examples/example_4/src/ProductionCode2.c | 11 ++++ examples/example_4/src/ProductionCode2.h | 2 + examples/example_4/src/meson.build | 23 +++++++ examples/example_4/test/TestProductionCode.c | 62 +++++++++++++++++++ examples/example_4/test/TestProductionCode2.c | 31 ++++++++++ examples/example_4/test/meson.build | 14 +++++ .../test_runners/TestProductionCode2_Runner.c | 53 ++++++++++++++++ .../test_runners/TestProductionCode_Runner.c | 57 +++++++++++++++++ .../example_4/test/test_runners/meson.build | 24 +++++++ examples/meson.build | 14 +++++ meson_options.txt | 17 +++++ 15 files changed, 357 insertions(+) create mode 100644 examples/example_4/meson.build create mode 100644 examples/example_4/readme.txt create mode 100644 examples/example_4/src/ProductionCode.c create mode 100644 examples/example_4/src/ProductionCode.h create mode 100644 examples/example_4/src/ProductionCode2.c create mode 100644 examples/example_4/src/ProductionCode2.h create mode 100644 examples/example_4/src/meson.build create mode 100644 examples/example_4/test/TestProductionCode.c create mode 100644 examples/example_4/test/TestProductionCode2.c create mode 100644 examples/example_4/test/meson.build create mode 100644 examples/example_4/test/test_runners/TestProductionCode2_Runner.c create mode 100644 examples/example_4/test/test_runners/TestProductionCode_Runner.c create mode 100644 examples/example_4/test/test_runners/meson.build create mode 100644 examples/meson.build create mode 100755 meson_options.txt diff --git a/examples/example_4/meson.build b/examples/example_4/meson.build new file mode 100644 index 00000000..5e34a334 --- /dev/null +++ b/examples/example_4/meson.build @@ -0,0 +1,17 @@ +################################################################################### +# # +# NAME: examples/example_4/meson.build # +# # +# AUTHOR: Mike Karlesky, Mark VanderVoord, Greg Williams. # +# WRITTEN BY: Michael Brockus. # +# # +# License: MIT # +# # +################################################################################### + + + +example_dir = include_directories('.', join_paths('.', 'src')) + +subdir('src') +subdir('test') \ No newline at end of file diff --git a/examples/example_4/readme.txt b/examples/example_4/readme.txt new file mode 100644 index 00000000..dfed8150 --- /dev/null +++ b/examples/example_4/readme.txt @@ -0,0 +1,5 @@ +Example 1 +========= + +Close to the simplest possible example of Unity, using only basic features. +Run make to build & run the example tests. \ No newline at end of file diff --git a/examples/example_4/src/ProductionCode.c b/examples/example_4/src/ProductionCode.c new file mode 100644 index 00000000..db128e5b --- /dev/null +++ b/examples/example_4/src/ProductionCode.c @@ -0,0 +1,24 @@ + +#include "ProductionCode.h" + +int Counter = 0; +int NumbersToFind[9] = { 0, 34, 55, 66, 32, 11, 1, 77, 888 }; /* some obnoxious array to search that is 1-based indexing instead of 0. */ + +/* This function is supposed to search through NumbersToFind and find a particular number. + * If it finds it, the index is returned. Otherwise 0 is returned which sorta makes sense since + * NumbersToFind is indexed from 1. Unfortunately it's broken + * (and should therefore be caught by our tests) */ +int FindFunction_WhichIsBroken(int NumberToFind) +{ + int i = 0; + while (i < 8) /* Notice I should have been in braces */ + i++; + if (NumbersToFind[i] == NumberToFind) /* Yikes! I'm getting run after the loop finishes instead of during it! */ + return i; + return 0; +} + +int FunctionWhichReturnsLocalVariable(void) +{ + return Counter; +} diff --git a/examples/example_4/src/ProductionCode.h b/examples/example_4/src/ProductionCode.h new file mode 100644 index 00000000..250ca0dc --- /dev/null +++ b/examples/example_4/src/ProductionCode.h @@ -0,0 +1,3 @@ + +int FindFunction_WhichIsBroken(int NumberToFind); +int FunctionWhichReturnsLocalVariable(void); diff --git a/examples/example_4/src/ProductionCode2.c b/examples/example_4/src/ProductionCode2.c new file mode 100644 index 00000000..98ee7eeb --- /dev/null +++ b/examples/example_4/src/ProductionCode2.c @@ -0,0 +1,11 @@ + +#include "ProductionCode2.h" + +char* ThisFunctionHasNotBeenTested(int Poor, char* LittleFunction) +{ + (void)Poor; + (void)LittleFunction; + /* Since There Are No Tests Yet, This Function Could Be Empty For All We Know. + * Which isn't terribly useful... but at least we put in a TEST_IGNORE so we won't forget */ + return (char*)0; +} diff --git a/examples/example_4/src/ProductionCode2.h b/examples/example_4/src/ProductionCode2.h new file mode 100644 index 00000000..34ae980d --- /dev/null +++ b/examples/example_4/src/ProductionCode2.h @@ -0,0 +1,2 @@ + +char* ThisFunctionHasNotBeenTested(int Poor, char* LittleFunction); diff --git a/examples/example_4/src/meson.build b/examples/example_4/src/meson.build new file mode 100644 index 00000000..77c39196 --- /dev/null +++ b/examples/example_4/src/meson.build @@ -0,0 +1,23 @@ +################################################################################### +# # +# NAME: examples/example_4/src/meson.build # +# # +# AUTHOR: Mike Karlesky, Mark VanderVoord, Greg Williams. # +# WRITTEN BY: Michael Brockus. # +# # +# License: MIT # +# # +################################################################################### + + + +example_src = files('ProductionCode.c', 'ProductionCode2.c') + +example_lib = library(meson.project_name(), + sources: example_src, + include_directories: example_dir) + +example_dep = declare_dependency( + version: meson.project_version(), + link_with: example_lib, + include_directories: example_dir) \ No newline at end of file diff --git a/examples/example_4/test/TestProductionCode.c b/examples/example_4/test/TestProductionCode.c new file mode 100644 index 00000000..404c3718 --- /dev/null +++ b/examples/example_4/test/TestProductionCode.c @@ -0,0 +1,62 @@ + +#include "ProductionCode.h" +#include "unity.h" + +/* sometimes you may want to get at local data in a module. + * for example: If you plan to pass by reference, this could be useful + * however, it should often be avoided */ +extern int Counter; + +void setUp(void) +{ + /* This is run before EACH TEST */ + Counter = 0x5a5a; +} + +void tearDown(void) +{ +} + +void test_FindFunction_WhichIsBroken_ShouldReturnZeroIfItemIsNotInList_WhichWorksEvenInOurBrokenCode(void) +{ + /* All of these should pass */ + TEST_ASSERT_EQUAL(0, FindFunction_WhichIsBroken(78)); + TEST_ASSERT_EQUAL(0, FindFunction_WhichIsBroken(2)); + TEST_ASSERT_EQUAL(0, FindFunction_WhichIsBroken(33)); + TEST_ASSERT_EQUAL(0, FindFunction_WhichIsBroken(999)); + TEST_ASSERT_EQUAL(0, FindFunction_WhichIsBroken(-1)); +} + +void test_FindFunction_WhichIsBroken_ShouldReturnTheIndexForItemsInList_WhichWillFailBecauseOurFunctionUnderTestIsBroken(void) +{ + /* You should see this line fail in your test summary */ + TEST_ASSERT_EQUAL(1, FindFunction_WhichIsBroken(34)); + + /* Notice the rest of these didn't get a chance to run because the line above failed. + * Unit tests abort each test function on the first sign of trouble. + * Then NEXT test function runs as normal. */ + TEST_ASSERT_EQUAL(8, FindFunction_WhichIsBroken(8888)); +} + +void test_FunctionWhichReturnsLocalVariable_ShouldReturnTheCurrentCounterValue(void) +{ + /* This should be true because setUp set this up for us before this test */ + TEST_ASSERT_EQUAL_HEX(0x5a5a, FunctionWhichReturnsLocalVariable()); + + /* This should be true because we can still change our answer */ + Counter = 0x1234; + TEST_ASSERT_EQUAL_HEX(0x1234, FunctionWhichReturnsLocalVariable()); +} + +void test_FunctionWhichReturnsLocalVariable_ShouldReturnTheCurrentCounterValueAgain(void) +{ + /* This should be true again because setup was rerun before this test (and after we changed it to 0x1234) */ + TEST_ASSERT_EQUAL_HEX(0x5a5a, FunctionWhichReturnsLocalVariable()); +} + +void test_FunctionWhichReturnsLocalVariable_ShouldReturnCurrentCounter_ButFailsBecauseThisTestIsActuallyFlawed(void) +{ + /* Sometimes you get the test wrong. When that happens, you get a failure too... and a quick look should tell + * you what actually happened...which in this case was a failure to setup the initial condition. */ + TEST_ASSERT_EQUAL_HEX(0x1234, FunctionWhichReturnsLocalVariable()); +} diff --git a/examples/example_4/test/TestProductionCode2.c b/examples/example_4/test/TestProductionCode2.c new file mode 100644 index 00000000..7d940c17 --- /dev/null +++ b/examples/example_4/test/TestProductionCode2.c @@ -0,0 +1,31 @@ + +#include "ProductionCode2.h" +#include "unity.h" + +/* These should be ignored because they are commented out in various ways: +#include "whatever.h" +#include "somethingelse.h" +*/ + +void setUp(void) +{ +} + +void tearDown(void) +{ +} + +void test_IgnoredTest(void) +{ + TEST_IGNORE_MESSAGE("This Test Was Ignored On Purpose"); +} + +void test_AnotherIgnoredTest(void) +{ + TEST_IGNORE_MESSAGE("These Can Be Useful For Leaving Yourself Notes On What You Need To Do Yet"); +} + +void test_ThisFunctionHasNotBeenTested_NeedsToBeImplemented(void) +{ + TEST_IGNORE(); /* Like This */ +} diff --git a/examples/example_4/test/meson.build b/examples/example_4/test/meson.build new file mode 100644 index 00000000..d551df90 --- /dev/null +++ b/examples/example_4/test/meson.build @@ -0,0 +1,14 @@ +################################################################################### +# # +# NAME: examples/example_4/test/meson.build # +# # +# AUTHOR: Mike Karlesky, Mark VanderVoord, Greg Williams. # +# WRITTEN BY: Michael Brockus. # +# # +# License: MIT # +# # +################################################################################### + + + +subdir('test_runners') \ No newline at end of file diff --git a/examples/example_4/test/test_runners/TestProductionCode2_Runner.c b/examples/example_4/test/test_runners/TestProductionCode2_Runner.c new file mode 100644 index 00000000..cf72c219 --- /dev/null +++ b/examples/example_4/test/test_runners/TestProductionCode2_Runner.c @@ -0,0 +1,53 @@ +/* AUTOGENERATED FILE. DO NOT EDIT. */ + +/*=======Test Runner Used To Run Each Test Below=====*/ +#define RUN_TEST(TestFunc, TestLineNum) \ +{ \ + Unity.CurrentTestName = #TestFunc; \ + Unity.CurrentTestLineNumber = TestLineNum; \ + Unity.NumberOfTests++; \ + if (TEST_PROTECT()) \ + { \ + setUp(); \ + TestFunc(); \ + } \ + if (TEST_PROTECT()) \ + { \ + tearDown(); \ + } \ + UnityConcludeTest(); \ +} + +/*=======Automagically Detected Files To Include=====*/ +#include "unity.h" +#include +#include +#include "ProductionCode2.h" + +/*=======External Functions This Runner Calls=====*/ +extern void setUp(void); +extern void tearDown(void); +extern void test_IgnoredTest(void); +extern void test_AnotherIgnoredTest(void); +extern void test_ThisFunctionHasNotBeenTested_NeedsToBeImplemented(void); + + +/*=======Test Reset Option=====*/ +void resetTest(void); +void resetTest(void) +{ + tearDown(); + setUp(); +} + + +/*=======MAIN=====*/ +int main(void) +{ + UnityBegin("test/TestProductionCode2.c"); + RUN_TEST(test_IgnoredTest, 18); + RUN_TEST(test_AnotherIgnoredTest, 23); + RUN_TEST(test_ThisFunctionHasNotBeenTested_NeedsToBeImplemented, 28); + + return (UnityEnd()); +} diff --git a/examples/example_4/test/test_runners/TestProductionCode_Runner.c b/examples/example_4/test/test_runners/TestProductionCode_Runner.c new file mode 100644 index 00000000..3b49af74 --- /dev/null +++ b/examples/example_4/test/test_runners/TestProductionCode_Runner.c @@ -0,0 +1,57 @@ +/* AUTOGENERATED FILE. DO NOT EDIT. */ + +/*=======Test Runner Used To Run Each Test Below=====*/ +#define RUN_TEST(TestFunc, TestLineNum) \ +{ \ + Unity.CurrentTestName = #TestFunc; \ + Unity.CurrentTestLineNumber = TestLineNum; \ + Unity.NumberOfTests++; \ + if (TEST_PROTECT()) \ + { \ + setUp(); \ + TestFunc(); \ + } \ + if (TEST_PROTECT()) \ + { \ + tearDown(); \ + } \ + UnityConcludeTest(); \ +} + +/*=======Automagically Detected Files To Include=====*/ +#include "unity.h" +#include +#include +#include "ProductionCode.h" + +/*=======External Functions This Runner Calls=====*/ +extern void setUp(void); +extern void tearDown(void); +extern void test_FindFunction_WhichIsBroken_ShouldReturnZeroIfItemIsNotInList_WhichWorksEvenInOurBrokenCode(void); +extern void test_FindFunction_WhichIsBroken_ShouldReturnTheIndexForItemsInList_WhichWillFailBecauseOurFunctionUnderTestIsBroken(void); +extern void test_FunctionWhichReturnsLocalVariable_ShouldReturnTheCurrentCounterValue(void); +extern void test_FunctionWhichReturnsLocalVariable_ShouldReturnTheCurrentCounterValueAgain(void); +extern void test_FunctionWhichReturnsLocalVariable_ShouldReturnCurrentCounter_ButFailsBecauseThisTestIsActuallyFlawed(void); + + +/*=======Test Reset Option=====*/ +void resetTest(void); +void resetTest(void) +{ + tearDown(); + setUp(); +} + + +/*=======MAIN=====*/ +int main(void) +{ + UnityBegin("test/TestProductionCode.c"); + RUN_TEST(test_FindFunction_WhichIsBroken_ShouldReturnZeroIfItemIsNotInList_WhichWorksEvenInOurBrokenCode, 20); + RUN_TEST(test_FindFunction_WhichIsBroken_ShouldReturnTheIndexForItemsInList_WhichWillFailBecauseOurFunctionUnderTestIsBroken, 30); + RUN_TEST(test_FunctionWhichReturnsLocalVariable_ShouldReturnTheCurrentCounterValue, 41); + RUN_TEST(test_FunctionWhichReturnsLocalVariable_ShouldReturnTheCurrentCounterValueAgain, 51); + RUN_TEST(test_FunctionWhichReturnsLocalVariable_ShouldReturnCurrentCounter_ButFailsBecauseThisTestIsActuallyFlawed, 57); + + return (UnityEnd()); +} diff --git a/examples/example_4/test/test_runners/meson.build b/examples/example_4/test/test_runners/meson.build new file mode 100644 index 00000000..edf35bb0 --- /dev/null +++ b/examples/example_4/test/test_runners/meson.build @@ -0,0 +1,24 @@ +################################################################################### +# # +# NAME: examples/example_4/test/test_runners/meson.build # +# # +# AUTHOR: Mike Karlesky, Mark VanderVoord, Greg Williams. # +# WRITTEN BY: Michael Brockus. # +# # +# License: MIT # +# # +################################################################################### + + + +test_src_1 = [ + 'TestProductionCode_Runner.c', + join_paths('..' ,'TestProductionCode.c') + ] +test_src_2 = [ + 'TestProductionCode2_Runner.c', + join_paths('..' ,'TestProductionCode2.c') + ] + +test('Test production code one', executable('test-1', test_src_1, dependencies: [ example_dep, unity_dep ])) +test('Test production code two', executable('test-2', test_src_2, dependencies: [ example_dep, unity_dep ])) \ No newline at end of file diff --git a/examples/meson.build b/examples/meson.build new file mode 100644 index 00000000..df0e7fe7 --- /dev/null +++ b/examples/meson.build @@ -0,0 +1,14 @@ +################################################################################### +# # +# NAME: examples/meson.build # +# # +# AUTHOR: Mike Karlesky, Mark VanderVoord, Greg Williams. # +# WRITTEN BY: Michael Brockus. # +# # +# License: MIT # +# # +################################################################################### + + + +subdir('example_4') \ No newline at end of file diff --git a/meson_options.txt b/meson_options.txt new file mode 100755 index 00000000..89f43a0c --- /dev/null +++ b/meson_options.txt @@ -0,0 +1,17 @@ +################################################################################### +# # +# NAME: meson_options.txt # +# # +# AUTHOR: Mike Karlesky, Mark VanderVoord, Greg Williams. # +# WRITTEN BY: Michael Brockus. # +# # +# License: MIT # +# # +################################################################################### + + + +option('with_examples', + type: 'feature', value : 'disabled', + description: 'Enable Unity for unit testing.' +) \ No newline at end of file From b1fd5ad887cebf96b61c2feb9e144c79168a085d Mon Sep 17 00:00:00 2001 From: Michael Brockus Date: Wed, 3 Jul 2019 15:31:26 -0700 Subject: [PATCH 124/454] Added option with_examples and version info. --- meson.build | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/meson.build b/meson.build index 0c6a3449..68f081b1 100644 --- a/meson.build +++ b/meson.build @@ -12,6 +12,7 @@ project('unity', 'c', + version : '2.4.3', license : 'MIT', meson_version : '>=0.50.0', default_options : @@ -77,3 +78,8 @@ unity_dep = declare_dependency( version: meson.project_version(), link_with: unity_lib, include_directories: unity_dir) + + +if get_option('with_examples').enabled() + subdir('examples') +endif \ No newline at end of file From e89b281e433cab49f67d73a4514258acb3d00801 Mon Sep 17 00:00:00 2001 From: Michael Brockus Date: Wed, 3 Jul 2019 15:54:19 -0700 Subject: [PATCH 125/454] Wrote info in readme.txt --- examples/example_4/readme.txt | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/examples/example_4/readme.txt b/examples/example_4/readme.txt index dfed8150..790a6fbb 100644 --- a/examples/example_4/readme.txt +++ b/examples/example_4/readme.txt @@ -1,5 +1,14 @@ -Example 1 +Example 4 ========= Close to the simplest possible example of Unity, using only basic features. -Run make to build & run the example tests. \ No newline at end of file +to build this example run meson setup . + +Meson uses the Ninja build system to actually build the code. To start the +build, simply type the following command. + +"ninja -C " + +Meson provides native support for running tests. The command to do that is simple. + +"meson test -C ". \ No newline at end of file From c7185b3a5a000b9ed1d1b574357d2e263246f5e0 Mon Sep 17 00:00:00 2001 From: Michael Brockus Date: Wed, 3 Jul 2019 15:55:19 -0700 Subject: [PATCH 126/454] Added prototypes to stop errors when Ninja. --- examples/example_4/test/TestProductionCode.c | 6 ++++++ examples/example_4/test/TestProductionCode2.c | 4 ++++ 2 files changed, 10 insertions(+) diff --git a/examples/example_4/test/TestProductionCode.c b/examples/example_4/test/TestProductionCode.c index 404c3718..b6c00aed 100644 --- a/examples/example_4/test/TestProductionCode.c +++ b/examples/example_4/test/TestProductionCode.c @@ -17,6 +17,12 @@ void tearDown(void) { } +void test_FindFunction_WhichIsBroken_ShouldReturnZeroIfItemIsNotInList_WhichWorksEvenInOurBrokenCode(void); +void test_FindFunction_WhichIsBroken_ShouldReturnTheIndexForItemsInList_WhichWillFailBecauseOurFunctionUnderTestIsBroken(void); +void test_FunctionWhichReturnsLocalVariable_ShouldReturnTheCurrentCounterValue(void); +void test_FunctionWhichReturnsLocalVariable_ShouldReturnTheCurrentCounterValueAgain(void); +void test_FunctionWhichReturnsLocalVariable_ShouldReturnCurrentCounter_ButFailsBecauseThisTestIsActuallyFlawed(void); + void test_FindFunction_WhichIsBroken_ShouldReturnZeroIfItemIsNotInList_WhichWorksEvenInOurBrokenCode(void) { /* All of these should pass */ diff --git a/examples/example_4/test/TestProductionCode2.c b/examples/example_4/test/TestProductionCode2.c index 7d940c17..2578ca94 100644 --- a/examples/example_4/test/TestProductionCode2.c +++ b/examples/example_4/test/TestProductionCode2.c @@ -15,6 +15,10 @@ void tearDown(void) { } +void test_IgnoredTest(void); +void test_AnotherIgnoredTest(void); +void test_ThisFunctionHasNotBeenTested_NeedsToBeImplemented(void); + void test_IgnoredTest(void) { TEST_IGNORE_MESSAGE("This Test Was Ignored On Purpose"); From c10f87f1e60c19a04c4feabae3964c25837e9a9a Mon Sep 17 00:00:00 2001 From: Michael Brockus Date: Wed, 3 Jul 2019 21:03:39 -0700 Subject: [PATCH 127/454] Fixed issues regarding the example Meson project. --- examples/example_4/meson.build | 3 +++ examples/example_4/readme.txt | 5 +++-- examples/example_4/src/meson.build | 20 +++++++++++++------ examples/example_4/subprojects/unity.wrap | 4 ++++ examples/example_4/test/TestProductionCode.c | 5 ----- .../example_4/test/test_runners/meson.build | 4 ++-- examples/meson.build | 14 ------------- meson.build | 7 +------ meson_options.txt | 17 ---------------- 9 files changed, 27 insertions(+), 52 deletions(-) create mode 100755 examples/example_4/subprojects/unity.wrap delete mode 100644 examples/meson.build delete mode 100755 meson_options.txt diff --git a/examples/example_4/meson.build b/examples/example_4/meson.build index 5e34a334..21d1001c 100644 --- a/examples/example_4/meson.build +++ b/examples/example_4/meson.build @@ -10,6 +10,9 @@ ################################################################################### +project('example-4') + +unity_dep = dependency('unity', fallback : ['unity', 'unity_dep']) example_dir = include_directories('.', join_paths('.', 'src')) diff --git a/examples/example_4/readme.txt b/examples/example_4/readme.txt index 790a6fbb..c8f45a81 100644 --- a/examples/example_4/readme.txt +++ b/examples/example_4/readme.txt @@ -2,7 +2,7 @@ Example 4 ========= Close to the simplest possible example of Unity, using only basic features. -to build this example run meson setup . +to build this example run "meson setup ". Meson uses the Ninja build system to actually build the code. To start the build, simply type the following command. @@ -11,4 +11,5 @@ build, simply type the following command. Meson provides native support for running tests. The command to do that is simple. -"meson test -C ". \ No newline at end of file +"meson test -C ". + \ No newline at end of file diff --git a/examples/example_4/src/meson.build b/examples/example_4/src/meson.build index 77c39196..5f7e5da1 100644 --- a/examples/example_4/src/meson.build +++ b/examples/example_4/src/meson.build @@ -11,13 +11,21 @@ -example_src = files('ProductionCode.c', 'ProductionCode2.c') +a_lib = library( + 'production-code-1', + 'ProductionCode.c', + include_directories: example_dir) + +b_lib = library( + 'production-code-2', + 'ProductionCode2.c', + include_directories: example_dir) + -example_lib = library(meson.project_name(), - sources: example_src, +a_dep = declare_dependency( + link_with: a_lib, include_directories: example_dir) -example_dep = declare_dependency( - version: meson.project_version(), - link_with: example_lib, +b_dep = declare_dependency( + link_with: b_lib, include_directories: example_dir) \ No newline at end of file diff --git a/examples/example_4/subprojects/unity.wrap b/examples/example_4/subprojects/unity.wrap new file mode 100755 index 00000000..bc5b386a --- /dev/null +++ b/examples/example_4/subprojects/unity.wrap @@ -0,0 +1,4 @@ +[wrap-git] +directory = unity +url = https://github.com/squidfarts/Unity.git +revision = head diff --git a/examples/example_4/test/TestProductionCode.c b/examples/example_4/test/TestProductionCode.c index b6c00aed..526a84eb 100644 --- a/examples/example_4/test/TestProductionCode.c +++ b/examples/example_4/test/TestProductionCode.c @@ -17,11 +17,6 @@ void tearDown(void) { } -void test_FindFunction_WhichIsBroken_ShouldReturnZeroIfItemIsNotInList_WhichWorksEvenInOurBrokenCode(void); -void test_FindFunction_WhichIsBroken_ShouldReturnTheIndexForItemsInList_WhichWillFailBecauseOurFunctionUnderTestIsBroken(void); -void test_FunctionWhichReturnsLocalVariable_ShouldReturnTheCurrentCounterValue(void); -void test_FunctionWhichReturnsLocalVariable_ShouldReturnTheCurrentCounterValueAgain(void); -void test_FunctionWhichReturnsLocalVariable_ShouldReturnCurrentCounter_ButFailsBecauseThisTestIsActuallyFlawed(void); void test_FindFunction_WhichIsBroken_ShouldReturnZeroIfItemIsNotInList_WhichWorksEvenInOurBrokenCode(void) { diff --git a/examples/example_4/test/test_runners/meson.build b/examples/example_4/test/test_runners/meson.build index edf35bb0..005ca67e 100644 --- a/examples/example_4/test/test_runners/meson.build +++ b/examples/example_4/test/test_runners/meson.build @@ -20,5 +20,5 @@ test_src_2 = [ join_paths('..' ,'TestProductionCode2.c') ] -test('Test production code one', executable('test-1', test_src_1, dependencies: [ example_dep, unity_dep ])) -test('Test production code two', executable('test-2', test_src_2, dependencies: [ example_dep, unity_dep ])) \ No newline at end of file +test('Test production code one', executable('test-1', test_src_1, dependencies: [ a_dep, unity_dep ])) +test('Test production code two', executable('test-2', test_src_2, dependencies: [ b_dep, unity_dep ])) \ No newline at end of file diff --git a/examples/meson.build b/examples/meson.build deleted file mode 100644 index df0e7fe7..00000000 --- a/examples/meson.build +++ /dev/null @@ -1,14 +0,0 @@ -################################################################################### -# # -# NAME: examples/meson.build # -# # -# AUTHOR: Mike Karlesky, Mark VanderVoord, Greg Williams. # -# WRITTEN BY: Michael Brockus. # -# # -# License: MIT # -# # -################################################################################### - - - -subdir('example_4') \ No newline at end of file diff --git a/meson.build b/meson.build index 68f081b1..7b9732a1 100644 --- a/meson.build +++ b/meson.build @@ -77,9 +77,4 @@ subdir('src') unity_dep = declare_dependency( version: meson.project_version(), link_with: unity_lib, - include_directories: unity_dir) - - -if get_option('with_examples').enabled() - subdir('examples') -endif \ No newline at end of file + include_directories: unity_dir) \ No newline at end of file diff --git a/meson_options.txt b/meson_options.txt deleted file mode 100755 index 89f43a0c..00000000 --- a/meson_options.txt +++ /dev/null @@ -1,17 +0,0 @@ -################################################################################### -# # -# NAME: meson_options.txt # -# # -# AUTHOR: Mike Karlesky, Mark VanderVoord, Greg Williams. # -# WRITTEN BY: Michael Brockus. # -# # -# License: MIT # -# # -################################################################################### - - - -option('with_examples', - type: 'feature', value : 'disabled', - description: 'Enable Unity for unit testing.' -) \ No newline at end of file From af4c20fa20c51963652471bf4ab73db9a3492ba7 Mon Sep 17 00:00:00 2001 From: Michael Brockus Date: Wed, 3 Jul 2019 21:04:07 -0700 Subject: [PATCH 128/454] Updating CMakeLists.txt. --- CMakeLists.txt | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0eddcd7e..bf74cecc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,11 +1,13 @@ -##################################################### -# FILE NAME CMakeLists.txt # -# # -# WRITTEN BY Michael Brockus. # -# # -# PURPOSE contains CMake statements. # -# # -##################################################### +################################################################################### +# # +# NAME: CMakeLsits.txt # +# # +# AUTHOR: Mike Karlesky, Mark VanderVoord, Greg Williams. # +# WRITTEN BY: Michael Brockus. # +# # +# License: MIT # +# # +################################################################################### cmake_minimum_required(VERSION 3.13.2.0 FATAL_ERROR) @@ -58,12 +60,9 @@ install(TARGETS "unity" EXPORT "unityConfig" ARCHIVE DESTINATION "${CMAKE_CURRENT_SOURCE_DIR}/${CMAKE_INSTALL_LIBDIR}" LIBRARY DESTINATION "${CMAKE_CURRENT_SOURCE_DIR}/${CMAKE_INSTALL_LIBDIR}" RUNTIME DESTINATION "${CMAKE_CURRENT_SOURCE_DIR}/${CMAKE_INSTALL_BINDIR}" - - INCLUDES DESTINATION "${CMAKE_INSTALL_LIBDIR}" -) + INCLUDES DESTINATION "${CMAKE_INSTALL_LIBDIR}") install(DIRECTORY src/ DESTINATION src) - install(EXPORT unityConfig DESTINATION share/unityConfig/cmake) # This makes the project importable from the build directory From 6b2eb52468dea293b9e46dcbf56deadd1c174aa5 Mon Sep 17 00:00:00 2001 From: Mark VanderVoord Date: Fri, 5 Jul 2019 15:35:40 -0400 Subject: [PATCH 129/454] Add test to verify comment-stripping is working with http-style comments. --- test/testdata/testRunnerGenerator.c | 1 + 1 file changed, 1 insertion(+) diff --git a/test/testdata/testRunnerGenerator.c b/test/testdata/testRunnerGenerator.c index 62989a0d..b3c0cdde 100644 --- a/test/testdata/testRunnerGenerator.c +++ b/test/testdata/testRunnerGenerator.c @@ -120,6 +120,7 @@ void test_NotBeConfusedByLongComplicatedStrings(void) TEST_ASSERT_EQUAL_STRING_MESSAGE(crazyString, crazyString, "These Strings Are The Same"); } +/* The next test should still appear even though we have this confusing nested comment thing going on http://looks_like_comments.com */ void test_NotDisappearJustBecauseTheTestBeforeAndAfterHaveCrazyStrings(void) { TEST_ASSERT_TRUE_MESSAGE(1, "1 Should be True"); From 45020b0d3b03f0313a25ebbc15107de39bb901da Mon Sep 17 00:00:00 2001 From: Mark VanderVoord Date: Fri, 5 Jul 2019 19:14:22 -0400 Subject: [PATCH 130/454] Cleanup issue #417 --- auto/generate_test_runner.rb | 4 +--- src/unity.c | 1 - 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/auto/generate_test_runner.rb b/auto/generate_test_runner.rb index aebecb1a..dab5096c 100644 --- a/auto/generate_test_runner.rb +++ b/auto/generate_test_runner.rb @@ -169,9 +169,7 @@ def create_header(output, mocks, testfile_includes = []) output.puts('/* AUTOGENERATED FILE. DO NOT EDIT. */') create_runtest(output, mocks) output.puts("\n/*=======Automagically Detected Files To Include=====*/") - output.puts('#ifdef __WIN32__') - output.puts('#define UNITY_INCLUDE_SETUP_STUBS') - output.puts('#endif') + output.puts('#define UNITY_INCLUDE_SETUP_STUBS') if @options[:suite_setup].nil? output.puts("#include \"#{@options[:framework]}.h\"") output.puts('#include "cmock.h"') unless mocks.empty? output.puts('#ifndef UNITY_EXCLUDE_SETJMP_H') diff --git a/src/unity.c b/src/unity.c index b821173b..8c45bd93 100644 --- a/src/unity.c +++ b/src/unity.c @@ -4,7 +4,6 @@ [Released under MIT License. Please refer to license.txt for details] ============================================================================ */ -#define UNITY_INCLUDE_SETUP_STUBS #include "unity.h" #include From a54d58a8fd5dff81eadd5838ee134305efecfa4e Mon Sep 17 00:00:00 2001 From: Mark VanderVoord Date: Fri, 5 Jul 2019 19:29:21 -0400 Subject: [PATCH 131/454] It doesn't seem like there is a time where setUp and tearDown aren't required in Fixture. --- extras/fixture/src/unity_fixture.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/extras/fixture/src/unity_fixture.c b/extras/fixture/src/unity_fixture.c index 0a16f6cb..67807e15 100644 --- a/extras/fixture/src/unity_fixture.c +++ b/extras/fixture/src/unity_fixture.c @@ -15,10 +15,8 @@ struct UNITY_FIXTURE_T UnityFixture; * Build with -D UNITY_OUTPUT_CHAR=outputChar and include * int (*outputChar)(int) = putchar; */ -#if !defined(UNITY_WEAK_ATTRIBUTE) && !defined(UNITY_WEAK_PRAGMA) void setUp(void) { /*does nothing*/ } void tearDown(void) { /*does nothing*/ } -#endif static void announceTestRun(unsigned int runNumber) { From a2f25d05d893f5644f14715222e927aa2e8773cf Mon Sep 17 00:00:00 2001 From: Michael Brockus Date: Fri, 5 Jul 2019 18:10:58 -0700 Subject: [PATCH 132/454] Added 'c' in example 4 --- examples/example_4/meson.build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/example_4/meson.build b/examples/example_4/meson.build index 21d1001c..ffa2f5e9 100644 --- a/examples/example_4/meson.build +++ b/examples/example_4/meson.build @@ -10,7 +10,7 @@ ################################################################################### -project('example-4') +project('example-4', 'c') unity_dep = dependency('unity', fallback : ['unity', 'unity_dep']) From 0000f1e6d2607d8e081be2f96440e22dd81bfb38 Mon Sep 17 00:00:00 2001 From: Mark VanderVoord Date: Sat, 6 Jul 2019 11:02:32 -0400 Subject: [PATCH 133/454] Add TEST_MESSAGE for outputting messages without aborting a test and _MESSAGE variant to TEST_PASS collection. --- docs/UnityAssertionsReference.md | 21 ++++++++++++++++++++- src/unity.c | 14 ++++++++++++++ src/unity.h | 2 ++ src/unity_internals.h | 2 +- test/tests/testunity.c | 22 ++++++++++++++++++++++ 5 files changed, 59 insertions(+), 2 deletions(-) diff --git a/docs/UnityAssertionsReference.md b/docs/UnityAssertionsReference.md index efb03ffc..db97cec6 100644 --- a/docs/UnityAssertionsReference.md +++ b/docs/UnityAssertionsReference.md @@ -178,10 +178,12 @@ documentation for specifics. ## The Assertions in All Their Blessed Glory -### Basic Fail and Ignore +### Basic Fail, Pass and Ignore ##### `TEST_FAIL()` +##### `TEST_FAIL_MESSAGE("message")` + This fella is most often used in special conditions where your test code is performing logic beyond a simple assertion. That is, in practice, `TEST_FAIL()` will always be found inside a conditional code block. @@ -192,13 +194,30 @@ code then verifies as a final step. - Triggering an exception and verifying it (as in Try / Catch / Throw - see the [CException](https://github.com/ThrowTheSwitch/CException) project). +##### `TEST_PASS()` + +##### `TEST_PASS_MESSAGE("message")` + +This will abort the remainder of the test, but count the test as a pass. Under +normal circumstances, it is not necessary to include this macro in your tests... +a lack of failure will automatically be counted as a `PASS`. It is occasionally +useful for tests with `#ifdef`s and such. + ##### `TEST_IGNORE()` +##### `TEST_IGNORE_MESSAGE("message")` + Marks a test case (i.e. function meant to contain test assertions) as ignored. Usually this is employed as a breadcrumb to come back and implement a test case. An ignored test case has effects if other assertions are in the enclosing test case (see Unity documentation for more). +##### `TEST_MESSAGE(message)` + +This can be useful for outputting `INFO` messages into the Unity output stream +without actually ending the test. Like pass and fail messages, it will be output +with the filename and line number. + ### Boolean ##### `TEST_ASSERT (condition)` diff --git a/src/unity.c b/src/unity.c index 8c45bd93..77a6521d 100644 --- a/src/unity.c +++ b/src/unity.c @@ -1715,6 +1715,20 @@ void UnityIgnore(const char* msg, const UNITY_LINE_TYPE line) UNITY_IGNORE_AND_BAIL; } +//----------------------------------------------- +void UnityMessage(const char* msg, const UNITY_LINE_TYPE line) +{ + UnityTestResultsBegin(Unity.TestFile, line); + UnityPrint("INFO"); + if (msg != NULL) + { + UNITY_OUTPUT_CHAR(':'); + UNITY_OUTPUT_CHAR(' '); + UnityPrint(msg); + } + UNITY_PRINT_EOL(); +} + /*-----------------------------------------------*/ void UnityDefaultTestRun(UnityTestFunction Func, const char* FuncName, const int FuncLineNum) { diff --git a/src/unity.h b/src/unity.h index 9e26067d..8f1fe2e5 100644 --- a/src/unity.h +++ b/src/unity.h @@ -102,11 +102,13 @@ int suiteTearDown(int num_failures); #define TEST_FAIL() UNITY_TEST_FAIL(__LINE__, NULL) #define TEST_IGNORE_MESSAGE(message) UNITY_TEST_IGNORE(__LINE__, (message)) #define TEST_IGNORE() UNITY_TEST_IGNORE(__LINE__, NULL) +#define TEST_MESSAGE(message) UnityMessage((message), __LINE__) #define TEST_ONLY() /* It is not necessary for you to call PASS. A PASS condition is assumed if nothing fails. * This method allows you to abort a test immediately with a PASS state, ignoring the remainder of the test. */ #define TEST_PASS() TEST_ABORT() +#define TEST_PASS_MESSAGE(message) do { UnityMessage((message), __LINE__); TEST_ABORT(); } while(0) /* This macro does nothing, but it is useful for build tools (like Ceedling) to make use of this to figure out * which files should be linked to in order to perform a test. Use it like TEST_FILE("sandwiches.c") */ diff --git a/src/unity_internals.h b/src/unity_internals.h index 6a601277..0dd08fb5 100644 --- a/src/unity_internals.h +++ b/src/unity_internals.h @@ -614,8 +614,8 @@ void UnityAssertNumbersArrayWithin(const UNITY_UINT delta, const UNITY_FLAGS_T flags); void UnityFail(const char* message, const UNITY_LINE_TYPE line); - void UnityIgnore(const char* message, const UNITY_LINE_TYPE line); +void UnityMessage(const char* message, const UNITY_LINE_TYPE line); #ifndef UNITY_EXCLUDE_FLOAT void UnityAssertFloatsWithin(const UNITY_FLOAT delta, diff --git a/test/tests/testunity.c b/test/tests/testunity.c index f5a3a074..297849fc 100644 --- a/test/tests/testunity.c +++ b/test/tests/testunity.c @@ -147,6 +147,28 @@ void testPassShouldEndImmediatelyWithPass(void) TEST_FAIL_MESSAGE("We should have passed already and finished this test"); } +void testPassShouldEndImmediatelyWithPassAndMessage(void) +{ + TEST_PASS_MESSAGE("Woohoo! This Automatically Passes!"); + TEST_FAIL_MESSAGE("We should have passed already and finished this test"); +} + +void testMessageShouldDisplayMessageWithoutEndingAndGoOnToPass(void) +{ + TEST_MESSAGE("This is just a message"); + TEST_MESSAGE("This is another message"); + TEST_PASS(); +} + +void testMessageShouldDisplayMessageWithoutEndingAndGoOnToFail(void) +{ + TEST_MESSAGE("This is yet another message"); + + EXPECT_ABORT_BEGIN + TEST_FAIL(); + VERIFY_FAILS_END +} + void testTrue(void) { TEST_ASSERT(1); From 3e82c0a96f0d94d5427d2f4f79ce11e9d1913b2c Mon Sep 17 00:00:00 2001 From: Mark VanderVoord Date: Sat, 6 Jul 2019 11:07:00 -0400 Subject: [PATCH 134/454] sigh. wrong comment style --- src/unity.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/unity.c b/src/unity.c index 77a6521d..510cad0d 100644 --- a/src/unity.c +++ b/src/unity.c @@ -1715,7 +1715,7 @@ void UnityIgnore(const char* msg, const UNITY_LINE_TYPE line) UNITY_IGNORE_AND_BAIL; } -//----------------------------------------------- +/*-----------------------------------------------*/ void UnityMessage(const char* msg, const UNITY_LINE_TYPE line) { UnityTestResultsBegin(Unity.TestFile, line); From 0892db23760b0dbe06f2644384ad29c3f7d14779 Mon Sep 17 00:00:00 2001 From: Mark VanderVoord Date: Sat, 6 Jul 2019 11:31:31 -0400 Subject: [PATCH 135/454] Protect against nil return codes in rakefiles --- examples/example_3/rakefile_helper.rb | 2 +- test/rakefile_helper.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/example_3/rakefile_helper.rb b/examples/example_3/rakefile_helper.rb index f1f51d4f..0e249b79 100644 --- a/examples/example_3/rakefile_helper.rb +++ b/examples/example_3/rakefile_helper.rb @@ -141,7 +141,7 @@ def execute(command_string, verbose = true, raise_on_fail = true) report command_string output = `#{command_string}`.chomp report(output) if verbose && !output.nil? && !output.empty? - if !$?.exitstatus.zero? && raise_on_fail + if !$?.nil? && !$?.exitstatus.zero? && raise_on_fail raise "Command failed. (Returned #{$?.exitstatus})" end output diff --git a/test/rakefile_helper.rb b/test/rakefile_helper.rb index d4335ec1..97c416f5 100644 --- a/test/rakefile_helper.rb +++ b/test/rakefile_helper.rb @@ -173,7 +173,7 @@ def execute(command_string, ok_to_fail = false) report command_string if $verbose output = `#{command_string}`.chomp report(output) if $verbose && !output.nil? && !output.empty? - raise "Command failed. (Returned #{$?.exitstatus})" if !$?.exitstatus.zero? && !ok_to_fail + raise "Command failed. (Returned #{$?.exitstatus})" if !$?.nil? && !$?.exitstatus.zero? && !ok_to_fail output end From 3afc0412e1c5f0f7bd8b264bff3560ad21586254 Mon Sep 17 00:00:00 2001 From: Michael Brockus Date: Sat, 6 Jul 2019 08:54:07 -0700 Subject: [PATCH 136/454] Changed source of Unity. --- examples/example_4/subprojects/unity.wrap | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/example_4/subprojects/unity.wrap b/examples/example_4/subprojects/unity.wrap index bc5b386a..f2e54c84 100755 --- a/examples/example_4/subprojects/unity.wrap +++ b/examples/example_4/subprojects/unity.wrap @@ -1,4 +1,4 @@ [wrap-git] directory = unity -url = https://github.com/squidfarts/Unity.git +url = https://github.com/ThrowTheSwitch/Unity.git revision = head From 3ac73efe626b90e544bbefe28efd1369f067ee96 Mon Sep 17 00:00:00 2001 From: Aurelien Labrosse Date: Tue, 9 Jul 2019 09:58:48 +0200 Subject: [PATCH 137/454] optimisation(AVR): Store static string in AVR EEPROM * This can save a lot of program memory and allow to run test on ATTiny --- src/unity.c | 82 ++++++++++++++++++++++++++++------------------------- 1 file changed, 44 insertions(+), 38 deletions(-) diff --git a/src/unity.c b/src/unity.c index 510cad0d..660bfd6c 100644 --- a/src/unity.c +++ b/src/unity.c @@ -7,6 +7,12 @@ #include "unity.h" #include +#ifdef AVR +#include +#else +#define PROGMEM +#endif + /* If omitted from header, declare overrideable prototypes here so they're ready for use */ #ifdef UNITY_OMIT_OUTPUT_CHAR_HEADER_DECLARATION void UNITY_OUTPUT_CHAR(int); @@ -20,48 +26,48 @@ void UNITY_OUTPUT_CHAR(int); struct UNITY_STORAGE_T Unity; #ifdef UNITY_OUTPUT_COLOR -const char UnityStrOk[] = "\033[42mOK\033[00m"; -const char UnityStrPass[] = "\033[42mPASS\033[00m"; -const char UnityStrFail[] = "\033[41mFAIL\033[00m"; -const char UnityStrIgnore[] = "\033[43mIGNORE\033[00m"; +const char PROGMEM UnityStrOk[] = "\033[42mOK\033[00m"; +const char PROGMEM UnityStrPass[] = "\033[42mPASS\033[00m"; +const char PROGMEM UnityStrFail[] = "\033[41mFAIL\033[00m"; +const char PROGMEM UnityStrIgnore[] = "\033[43mIGNORE\033[00m"; #else -const char UnityStrOk[] = "OK"; -const char UnityStrPass[] = "PASS"; -const char UnityStrFail[] = "FAIL"; -const char UnityStrIgnore[] = "IGNORE"; +const char PROGMEM UnityStrOk[] = "OK"; +const char PROGMEM UnityStrPass[] = "PASS"; +const char PROGMEM UnityStrFail[] = "FAIL"; +const char PROGMEM UnityStrIgnore[] = "IGNORE"; #endif -static const char UnityStrNull[] = "NULL"; -static const char UnityStrSpacer[] = ". "; -static const char UnityStrExpected[] = " Expected "; -static const char UnityStrWas[] = " Was "; -static const char UnityStrGt[] = " to be greater than "; -static const char UnityStrLt[] = " to be less than "; -static const char UnityStrOrEqual[] = "or equal to "; -static const char UnityStrElement[] = " Element "; -static const char UnityStrByte[] = " Byte "; -static const char UnityStrMemory[] = " Memory Mismatch."; -static const char UnityStrDelta[] = " Values Not Within Delta "; -static const char UnityStrPointless[] = " You Asked Me To Compare Nothing, Which Was Pointless."; -static const char UnityStrNullPointerForExpected[] = " Expected pointer to be NULL"; -static const char UnityStrNullPointerForActual[] = " Actual pointer was NULL"; +static const char PROGMEM UnityStrNull[] = "NULL"; +static const char PROGMEM UnityStrSpacer[] = ". "; +static const char PROGMEM UnityStrExpected[] = " Expected "; +static const char PROGMEM UnityStrWas[] = " Was "; +static const char PROGMEM UnityStrGt[] = " to be greater than "; +static const char PROGMEM UnityStrLt[] = " to be less than "; +static const char PROGMEM UnityStrOrEqual[] = "or equal to "; +static const char PROGMEM UnityStrElement[] = " Element "; +static const char PROGMEM UnityStrByte[] = " Byte "; +static const char PROGMEM UnityStrMemory[] = " Memory Mismatch."; +static const char PROGMEM UnityStrDelta[] = " Values Not Within Delta "; +static const char PROGMEM UnityStrPointless[] = " You Asked Me To Compare Nothing, Which Was Pointless."; +static const char PROGMEM UnityStrNullPointerForExpected[] = " Expected pointer to be NULL"; +static const char PROGMEM UnityStrNullPointerForActual[] = " Actual pointer was NULL"; #ifndef UNITY_EXCLUDE_FLOAT -static const char UnityStrNot[] = "Not "; -static const char UnityStrInf[] = "Infinity"; -static const char UnityStrNegInf[] = "Negative Infinity"; -static const char UnityStrNaN[] = "NaN"; -static const char UnityStrDet[] = "Determinate"; -static const char UnityStrInvalidFloatTrait[] = "Invalid Float Trait"; +static const char PROGMEM UnityStrNot[] = "Not "; +static const char PROGMEM UnityStrInf[] = "Infinity"; +static const char PROGMEM UnityStrNegInf[] = "Negative Infinity"; +static const char PROGMEM UnityStrNaN[] = "NaN"; +static const char PROGMEM UnityStrDet[] = "Determinate"; +static const char PROGMEM UnityStrInvalidFloatTrait[] = "Invalid Float Trait"; #endif -const char UnityStrErrShorthand[] = "Unity Shorthand Support Disabled"; -const char UnityStrErrFloat[] = "Unity Floating Point Disabled"; -const char UnityStrErrDouble[] = "Unity Double Precision Disabled"; -const char UnityStrErr64[] = "Unity 64-bit Support Disabled"; -static const char UnityStrBreaker[] = "-----------------------"; -static const char UnityStrResultsTests[] = " Tests "; -static const char UnityStrResultsFailures[] = " Failures "; -static const char UnityStrResultsIgnored[] = " Ignored "; -static const char UnityStrDetail1Name[] = UNITY_DETAIL1_NAME " "; -static const char UnityStrDetail2Name[] = " " UNITY_DETAIL2_NAME " "; +const char PROGMEM UnityStrErrShorthand[] = "Unity Shorthand Support Disabled"; +const char PROGMEM UnityStrErrFloat[] = "Unity Floating Point Disabled"; +const char PROGMEM UnityStrErrDouble[] = "Unity Double Precision Disabled"; +const char PROGMEM UnityStrErr64[] = "Unity 64-bit Support Disabled"; +static const char PROGMEM UnityStrBreaker[] = "-----------------------"; +static const char PROGMEM UnityStrResultsTests[] = " Tests "; +static const char PROGMEM UnityStrResultsFailures[] = " Failures "; +static const char PROGMEM UnityStrResultsIgnored[] = " Ignored "; +static const char PROGMEM UnityStrDetail1Name[] = UNITY_DETAIL1_NAME " "; +static const char PROGMEM UnityStrDetail2Name[] = " " UNITY_DETAIL2_NAME " "; /*----------------------------------------------- * Pretty Printers & Test Result Output Handlers From 2939c420ed9f2697bcb82c1b193bb48c4a8ad7a9 Mon Sep 17 00:00:00 2001 From: Mark VanderVoord Date: Mon, 12 Aug 2019 15:40:43 -0400 Subject: [PATCH 138/454] Better protection against nested comments (and things that look like comments) --- auto/generate_test_runner.rb | 8 ++++---- test/testdata/testRunnerGenerator.c | 2 ++ 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/auto/generate_test_runner.rb b/auto/generate_test_runner.rb index dab5096c..6dc90e05 100644 --- a/auto/generate_test_runner.rb +++ b/auto/generate_test_runner.rb @@ -104,10 +104,10 @@ def find_tests(source) source_scrubbed = source_scrubbed.gsub(/\\"/, '@quote@') # hide escaped quotes to allow capture of the full string/char source_scrubbed = source_scrubbed.gsub(/\\'/, '@apos@') # hide escaped apostrophes to allow capture of the full string/char source_scrubbed = source_scrubbed.gsub(/("[^"\n]*")|('[^'\n]*')/) { |s| s.gsub(substring_re, substring_subs) } # temporarily hide problematic characters within strings - source_scrubbed = source_scrubbed.gsub(/\/\/.*$/, '') # remove line comments - source_scrubbed = source_scrubbed.gsub(/\/\*.*?\*\//m, '') # remove block comments - lines = source_scrubbed.split(/(^\s*\#.*$) # Treat preprocessor directives as a logical line - | (;|\{|\}) /x) # Match ;, {, and } as end of lines + source_scrubbed = source_scrubbed.gsub(/\/\/(?:.+\/\*|\*(?:$|[^\/])).*$/, '') # remove line comments that comment out the start of blocks + source_scrubbed = source_scrubbed.gsub(/\/\*.*?\*\//m, '') # remove block comments + source_scrubbed = source_scrubbed.gsub(/\/\/.*$/, '') # remove line comments (all that remain) + lines = source_scrubbed.split(/(^\s*\#.*$) | (;|\{|\}) /x) # Treat preprocessor directives as a logical line. Match ;, {, and } as end of lines .map { |line| line.gsub(substring_unre, substring_unsubs) } # unhide the problematic characters previously removed lines.each_with_index do |line, _index| diff --git a/test/testdata/testRunnerGenerator.c b/test/testdata/testRunnerGenerator.c index b3c0cdde..11399392 100644 --- a/test/testdata/testRunnerGenerator.c +++ b/test/testdata/testRunnerGenerator.c @@ -124,7 +124,9 @@ void test_NotBeConfusedByLongComplicatedStrings(void) void test_NotDisappearJustBecauseTheTestBeforeAndAfterHaveCrazyStrings(void) { TEST_ASSERT_TRUE_MESSAGE(1, "1 Should be True"); + /* still should not break anything */ } +/* nor should this */ void test_StillNotBeConfusedByLongComplicatedStrings(void) { From 46263fc148909cd0a4c8c2f218129ea9b3100cbe Mon Sep 17 00:00:00 2001 From: Mark VanderVoord Date: Tue, 10 Sep 2019 15:52:37 -0400 Subject: [PATCH 139/454] Get the 2's compliment of the unsigned int `number` when printing results without relying on problematic recasting of a negated int. (see #439) --- src/unity.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/unity.c b/src/unity.c index 660bfd6c..9883fd75 100644 --- a/src/unity.c +++ b/src/unity.c @@ -327,7 +327,7 @@ void UnityPrintNumber(const UNITY_INT number_to_print) { /* A negative number, including MIN negative */ UNITY_OUTPUT_CHAR('-'); - number = (UNITY_UINT)-number_to_print; + number = (~number) + 1; } UnityPrintNumberUnsigned(number); } From 9578a382ccf5339bb75289a0be2d07e234c93ee0 Mon Sep 17 00:00:00 2001 From: John Lindgren Date: Fri, 13 Sep 2019 16:19:46 -0400 Subject: [PATCH 140/454] Fix "rake scripts" when running on Windows. cmd.exe does not recognize backslash as an escape character, leading to errors like the following: error: stray '\' in program note: in definition of macro 'UNITY_OUTPUT_CHAR_HEADER_DECLARATION' It does, however, recognize double quotes, so we can use those as a portable method of escaping special characters on both Windows and UNIX. --- test/rakefile_helper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/rakefile_helper.rb b/test/rakefile_helper.rb index 97c416f5..71068689 100644 --- a/test/rakefile_helper.rb +++ b/test/rakefile_helper.rb @@ -91,7 +91,7 @@ def build_compiler_fields(inject_defines) defines = if $cfg['compiler']['defines']['items'].nil? '' else - squash($cfg['compiler']['defines']['prefix'], $cfg['compiler']['defines']['items'] + ['UNITY_OUTPUT_CHAR=putcharSpy'] + ['UNITY_OUTPUT_CHAR_HEADER_DECLARATION=putcharSpy\(int\)'] + inject_defines) + squash($cfg['compiler']['defines']['prefix'], $cfg['compiler']['defines']['items'] + ['UNITY_OUTPUT_CHAR=putcharSpy'] + ['UNITY_OUTPUT_CHAR_HEADER_DECLARATION="putcharSpy(int)"'] + inject_defines) end options = squash('', $cfg['compiler']['options']) includes = squash($cfg['compiler']['includes']['prefix'], $cfg['compiler']['includes']['items']) From c2c42ce14fb6b54c491f9be9c60c5b34aeeac8a0 Mon Sep 17 00:00:00 2001 From: Michael Brockus <55331536+michaelbadcrumble@users.noreply.github.com> Date: Tue, 17 Sep 2019 09:31:26 -0700 Subject: [PATCH 141/454] Update meson.build Cleaned up compiler flags in root meson.build, renamed a variable and removed 'c_std=' because Meson sets C standard flag to C11 by default. --- meson.build | 87 ++++++++++++++++++++++++----------------------------- 1 file changed, 40 insertions(+), 47 deletions(-) diff --git a/meson.build b/meson.build index 7b9732a1..6d1ee3dd 100644 --- a/meson.build +++ b/meson.build @@ -15,61 +15,54 @@ project('unity', 'c', version : '2.4.3', license : 'MIT', meson_version : '>=0.50.0', - default_options : - [ - 'werror=true', + default_options: [ + 'buildtype=minsize', 'optimization=3', - 'warning_level=3', - 'b_sanitize=address,undefined', - 'b_lto=true', - 'b_lundef=true' - ]) -cc = meson.get_compiler('c') -args_for_langs = 'c' + 'warning_level=3', + 'werror=true', + ] +) +lang = 'c' +cc = meson.get_compiler(lang) + +## +# +# Meson: Add compiler flags +# +## if cc.get_id() == 'clang' - add_project_arguments( - '-Wweak-vtables', - '-Wexit-time-destructors', - '-Wglobal-constructors', - '-Wmissing-noreturn', language: args_for_langs) + add_project_arguments(cc.get_supported_arguments( + [ + '-Wweak-vtables', '-Wexit-time-destructors', + '-Wglobal-constructors', '-Wmissing-noreturn' + ] + ), language: lang) endif if cc.get_argument_syntax() == 'gcc' - add_project_arguments( - '-Wall', - '-Wextra', - '-Wunreachable-code', - '-Wmissing-declarations', - '-Wmissing-prototypes', - '-Wredundant-decls', - '-Wundef', - '-Wwrite-strings', - '-Wformat', - '-Wformat-nonliteral', - '-Wformat-security', - '-Wold-style-definition', - '-Winit-self', - '-Wmissing-include-dirs', - '-Waddress', - '-Waggregate-return', - '-Wno-multichar', - '-Wdeclaration-after-statement', - '-Wvla', - '-Wpointer-arith',language: args_for_langs) + add_project_arguments(cc.get_supported_arguments( + [ + '-Wformat', '-Waddress', '-Winit-self', '-Wno-multichar', + '-Wpointer-arith' , '-Wwrite-strings' , + '-Wno-parentheses' , '-Wno-type-limits' , + '-Wformat-security' , '-Wunreachable-code' , + '-Waggregate-return' , '-Wformat-nonliteral' , + '-Wmissing-prototypes' , '-Wold-style-definition' , + '-Wmissing-declarations', '-Wmissing-include-dirs' , + '-Wno-unused-parameter' , '-Wdeclaration-after-statement' + ] + ), language: lang) endif if cc.get_id() == 'msvc' - add_project_arguments( - '/W4', - '/w44265', - '/w44061', - '/w44062', - '/wd4018', # implicit signed/unsigned conversion - '/wd4146', # unary minus on unsigned (beware INT_MIN) - '/wd4244', # lossy type conversion (e.g. double -> int) - '/wd4305', # truncating type conversion (e.g. double -> float) - mesno.get_supported_arguments(['/utf-8']), language: args_for_langs) + add_project_arguments(cc.get_supported_arguments( + [ + '/w44265', '/w44061', '/w44062', + '/wd4018', '/wd4146', '/wd4244', + '/wd4305', + ] + ), language: lang) endif subdir('src') @@ -77,4 +70,4 @@ subdir('src') unity_dep = declare_dependency( version: meson.project_version(), link_with: unity_lib, - include_directories: unity_dir) \ No newline at end of file + include_directories: unity_dir) From 822e244bd4a950038c65feb2e76f7301bc7d8129 Mon Sep 17 00:00:00 2001 From: Michael Brockus <55331536+michaelbadcrumble@users.noreply.github.com> Date: Tue, 17 Sep 2019 09:37:41 -0700 Subject: [PATCH 142/454] Update source meson.build Removed 'unity_src' variable because Unity only one source file, changed library method to static only because there was some issues with using Unity as a shared library, cleaned sub meson.build script and fixed comment in sub source root. --- src/meson.build | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/meson.build b/src/meson.build index 5d8c4528..f5e01465 100644 --- a/src/meson.build +++ b/src/meson.build @@ -1,6 +1,6 @@ ################################################################################### # # -# NAME: src/meson.build # +# NAME: meson.build # # # # AUTHOR: Mike Karlesky, Mark VanderVoord, Greg Williams. # # WRITTEN BY: Michael Brockus. # @@ -9,12 +9,8 @@ # # ################################################################################### - - -unity_src = files('unity.c') - unity_dir = include_directories('.') -unity_lib = library(meson.project_name(), - sources: unity_src, - include_directories: unity_dir) \ No newline at end of file +unity_lib = static_library(meson.project_name(), + sources: ['unity.c'], + include_directories: unity_dir) From f2711a87a63efe7fbbee5178cfacfbdb1a7615b9 Mon Sep 17 00:00:00 2001 From: Michael Brockus <55331536+michaelbadcrumble@users.noreply.github.com> Date: Tue, 17 Sep 2019 11:25:17 -0700 Subject: [PATCH 143/454] Update meson.build Moved example dir variable into source meson.build script, fixed comment. --- examples/example_4/meson.build | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/examples/example_4/meson.build b/examples/example_4/meson.build index ffa2f5e9..4bf968cb 100644 --- a/examples/example_4/meson.build +++ b/examples/example_4/meson.build @@ -1,6 +1,6 @@ ################################################################################### # # -# NAME: examples/example_4/meson.build # +# NAME: meson.build # # # # AUTHOR: Mike Karlesky, Mark VanderVoord, Greg Williams. # # WRITTEN BY: Michael Brockus. # @@ -9,12 +9,9 @@ # # ################################################################################### - project('example-4', 'c') unity_dep = dependency('unity', fallback : ['unity', 'unity_dep']) -example_dir = include_directories('.', join_paths('.', 'src')) - subdir('src') -subdir('test') \ No newline at end of file +subdir('test') From 964a58c0534df65eec430f38c1d470cf1c707149 Mon Sep 17 00:00:00 2001 From: Michael Brockus <55331536+michaelbadcrumble@users.noreply.github.com> Date: Tue, 17 Sep 2019 11:28:47 -0700 Subject: [PATCH 144/454] Updated sub meson script in example src. Added foreach loop to avoid DRY, Put source files in map structors, fixed comment. --- examples/example_4/src/meson.build | 28 +++++++++------------------- 1 file changed, 9 insertions(+), 19 deletions(-) diff --git a/examples/example_4/src/meson.build b/examples/example_4/src/meson.build index 5f7e5da1..8fac6c4a 100644 --- a/examples/example_4/src/meson.build +++ b/examples/example_4/src/meson.build @@ -1,6 +1,6 @@ ################################################################################### # # -# NAME: examples/example_4/src/meson.build # +# NAME: meson.build # # # # AUTHOR: Mike Karlesky, Mark VanderVoord, Greg Williams. # # WRITTEN BY: Michael Brockus. # @@ -9,23 +9,13 @@ # # ################################################################################### +inc_dir = include_directories('.') +lib_list = {'a': ['ProductionCode.c' ], 'b': ['ProductionCode2.c']} +foreach lib, src : lib_list + set_variable(lib + '_lib', + static_library(lib + '_lib', sources: src, include_directories: inc_dir)) +endforeach -a_lib = library( - 'production-code-1', - 'ProductionCode.c', - include_directories: example_dir) - -b_lib = library( - 'production-code-2', - 'ProductionCode2.c', - include_directories: example_dir) - - -a_dep = declare_dependency( - link_with: a_lib, - include_directories: example_dir) - -b_dep = declare_dependency( - link_with: b_lib, - include_directories: example_dir) \ No newline at end of file +a_dep = declare_dependency(link_with: a_lib, include_directories: inc_dir) +b_dep = declare_dependency(link_with: b_lib, include_directories: inc_dir) From 29af4c0e0d05c69d93bcc909defef8ee871eaeee Mon Sep 17 00:00:00 2001 From: Michael Brockus <55331536+michaelbadcrumble@users.noreply.github.com> Date: Tue, 17 Sep 2019 11:30:07 -0700 Subject: [PATCH 145/454] Updated sub meson.build in example test dir. Removed newlines and fixed comment. --- examples/example_4/test/meson.build | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/examples/example_4/test/meson.build b/examples/example_4/test/meson.build index d551df90..876a78c1 100644 --- a/examples/example_4/test/meson.build +++ b/examples/example_4/test/meson.build @@ -1,6 +1,6 @@ ################################################################################### # # -# NAME: examples/example_4/test/meson.build # +# NAME: meson.build # # # # AUTHOR: Mike Karlesky, Mark VanderVoord, Greg Williams. # # WRITTEN BY: Michael Brockus. # @@ -9,6 +9,4 @@ # # ################################################################################### - - -subdir('test_runners') \ No newline at end of file +subdir('test_runners') From 31ab99b860eb884b44879750215573154250dc0a Mon Sep 17 00:00:00 2001 From: Michael Brockus <55331536+michaelbadcrumble@users.noreply.github.com> Date: Tue, 17 Sep 2019 11:33:31 -0700 Subject: [PATCH 146/454] Update sub meson.build in test runner dir. Put source in an array, cleaned up script and fixed comment. --- .../example_4/test/test_runners/meson.build | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/examples/example_4/test/test_runners/meson.build b/examples/example_4/test/test_runners/meson.build index 005ca67e..33c105f9 100644 --- a/examples/example_4/test/test_runners/meson.build +++ b/examples/example_4/test/test_runners/meson.build @@ -1,6 +1,6 @@ ################################################################################### # # -# NAME: examples/example_4/test/test_runners/meson.build # +# NAME: meson.build # # # # AUTHOR: Mike Karlesky, Mark VanderVoord, Greg Williams. # # WRITTEN BY: Michael Brockus. # @@ -9,16 +9,8 @@ # # ################################################################################### +cases = [['TestProductionCode_Runner.c', join_paths('..' ,'TestProductionCode.c')], + ['TestProductionCode2_Runner.c', join_paths('..' ,'TestProductionCode2.c')]] - -test_src_1 = [ - 'TestProductionCode_Runner.c', - join_paths('..' ,'TestProductionCode.c') - ] -test_src_2 = [ - 'TestProductionCode2_Runner.c', - join_paths('..' ,'TestProductionCode2.c') - ] - -test('Test production code one', executable('test-1', test_src_1, dependencies: [ a_dep, unity_dep ])) -test('Test production code two', executable('test-2', test_src_2, dependencies: [ b_dep, unity_dep ])) \ No newline at end of file +test('Running: 01-test-case', executable('01-test-case', cases[0], dependencies: [ a_dep, unity_dep ])) +test('Running: 02-test-case', executable('02-test-case', cases[1], dependencies: [ b_dep, unity_dep ])) From e6f38c2792b2000fa470e9a947f68089f07d34c0 Mon Sep 17 00:00:00 2001 From: Michael Brockus <55331536+michaelbadcrumble@users.noreply.github.com> Date: Tue, 17 Sep 2019 12:14:47 -0700 Subject: [PATCH 147/454] Update CMakeLists.txt Moved the add library method into sub dir. Also made this CMakeLists.txt script compatible for versions os CMake starting from 3.x and up. --- CMakeLists.txt | 33 ++------------------------------- 1 file changed, 2 insertions(+), 31 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index bf74cecc..1954949e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,34 +8,15 @@ # License: MIT # # # ################################################################################### -cmake_minimum_required(VERSION 3.13.2.0 FATAL_ERROR) +cmake_minimum_required(VERSION 3 FATAL_ERROR) - -# -# CMake: Declare project -# project(unity LANGUAGES C DESCRIPTION "C Unit testing framework.") - -# -# CMake: Creation of library -# -add_library("unity" STATIC) - - - -# -# CMake: Adding source to target -# -target_sources("unity" PRIVATE "src/unity.c") +add_subdirectory("src") - -# -# CMake: Including directories to target -# target_include_directories("unity" PUBLIC "$" @@ -44,18 +25,8 @@ target_include_directories("unity" PRIVATE "src" ) - - -# -# CMake: Give target an alias -# add_library("unity::framework" ALIAS "unity") - - -# -# CMake: export project -# install(TARGETS "unity" EXPORT "unityConfig" ARCHIVE DESTINATION "${CMAKE_CURRENT_SOURCE_DIR}/${CMAKE_INSTALL_LIBDIR}" LIBRARY DESTINATION "${CMAKE_CURRENT_SOURCE_DIR}/${CMAKE_INSTALL_LIBDIR}" From bc7d89a891e19bc004528dfbb6fb42c603bda6d9 Mon Sep 17 00:00:00 2001 From: Michael Brockus <55331536+michaelbadcrumble@users.noreply.github.com> Date: Tue, 17 Sep 2019 12:17:22 -0700 Subject: [PATCH 148/454] Create CMakeLists.txt Added new CMakeLists.txt here in the src dir, moved add library method from root script to sub script. --- src/CMakeLists.txt | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 src/CMakeLists.txt diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt new file mode 100644 index 00000000..b07a82fa --- /dev/null +++ b/src/CMakeLists.txt @@ -0,0 +1,16 @@ +################################################################################### +# # +# NAME: CMakeLsits.txt # +# # +# AUTHOR: Mike Karlesky, Mark VanderVoord, Greg Williams. # +# WRITTEN BY: Michael Brockus. # +# # +# License: MIT # +# # +################################################################################### +cmake_minimum_required(VERSION 3.13.2.0 FATAL_ERROR) + + +add_library("unity" STATIC) + +target_sources("unity" PRIVATE "unity.c") From f4251bf87db984222b7c3818767cd6a81a8e7c47 Mon Sep 17 00:00:00 2001 From: Michael Brockus <55331536+michaelbadcrumble@users.noreply.github.com> Date: Tue, 17 Sep 2019 12:23:28 -0700 Subject: [PATCH 149/454] Remove Unity version number. Removed Unity version number from Meson build scripts so there is one less thing to change when doing updates to this script. --- meson.build | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/meson.build b/meson.build index 6d1ee3dd..a2c0a152 100644 --- a/meson.build +++ b/meson.build @@ -12,7 +12,6 @@ project('unity', 'c', - version : '2.4.3', license : 'MIT', meson_version : '>=0.50.0', default_options: [ @@ -67,7 +66,4 @@ endif subdir('src') -unity_dep = declare_dependency( - version: meson.project_version(), - link_with: unity_lib, - include_directories: unity_dir) +unity_dep = declare_dependency(link_with: unity_lib, include_directories: unity_dir) From 7e3804545c5fc84c84951b8ac2aed49f9686b998 Mon Sep 17 00:00:00 2001 From: Michael Brockus <55331536+michaelbadcrumble@users.noreply.github.com> Date: Sun, 22 Sep 2019 06:59:35 -0700 Subject: [PATCH 150/454] Fixed typo in sub CMakeLists.txt. Fixed a simple mistake. --- src/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index b07a82fa..4aa2bcbd 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,6 +1,6 @@ ################################################################################### # # -# NAME: CMakeLsits.txt # +# NAME: CMakeLists.txt # # # # AUTHOR: Mike Karlesky, Mark VanderVoord, Greg Williams. # # WRITTEN BY: Michael Brockus. # From fc148563217e7bdd055668ac4376289a3ffa3303 Mon Sep 17 00:00:00 2001 From: Alessio Centazzo Date: Sun, 29 Sep 2019 15:08:48 -0700 Subject: [PATCH 151/454] Fix malloc alignment Make sure the malloc alignment is always aligned to the architecture's pointer size --- extras/fixture/src/unity_fixture.c | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/extras/fixture/src/unity_fixture.c b/extras/fixture/src/unity_fixture.c index 67807e15..4a064c32 100644 --- a/extras/fixture/src/unity_fixture.c +++ b/extras/fixture/src/unity_fixture.c @@ -188,13 +188,26 @@ typedef struct GuardBytes } Guard; +#define UNITY_MALLOC_ALIGNMENT (UNITY_POINTER_WIDTH / 8) static const char end[] = "END"; + +static size_t unity_size_round_up(size_t size) +{ + size_t rounded_size; + + rounded_size = ((size + UNITY_MALLOC_ALIGNMENT - 1) / UNITY_MALLOC_ALIGNMENT) * UNITY_MALLOC_ALIGNMENT; + + return rounded_size; +} + void* unity_malloc(size_t size) { char* mem; Guard* guard; - size_t total_size = size + sizeof(Guard) + sizeof(end); + size_t total_size; + + total_size = sizeof(Guard) + unity_size_round_up(size + sizeof(end)); if (malloc_fail_countdown != MALLOC_DONT_FAIL) { @@ -243,9 +256,13 @@ static void release_memory(void* mem) malloc_count--; #ifdef UNITY_EXCLUDE_STDLIB_MALLOC - if (mem == unity_heap + heap_index - guard->size - sizeof(end)) + size_t block_size; + + block_size = unity_size_round_up(guard->size + sizeof(end)); + + if (mem == unity_heap + heap_index - block_size) { - heap_index -= (guard->size + sizeof(Guard) + sizeof(end)); + heap_index -= (sizeof(Guard) + block_size); } #else UNITY_FIXTURE_FREE(guard); From 75e88a9bc47ec47646e9a26b3aa6c5b20a4c38bf Mon Sep 17 00:00:00 2001 From: Alessio Centazzo Date: Sun, 29 Sep 2019 21:45:51 -0700 Subject: [PATCH 152/454] Fix MallocThenReallocGrowsMemoryInPlace The realloc was not taking in account extra bytes needed for the the pointer proper alignment --- extras/fixture/src/unity_fixture.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/extras/fixture/src/unity_fixture.c b/extras/fixture/src/unity_fixture.c index 4a064c32..7272a8af 100644 --- a/extras/fixture/src/unity_fixture.c +++ b/extras/fixture/src/unity_fixture.c @@ -317,11 +317,15 @@ void* unity_realloc(void* oldMem, size_t size) if (guard->size >= size) return oldMem; #ifdef UNITY_EXCLUDE_STDLIB_MALLOC /* Optimization if memory is expandable */ - if (oldMem == unity_heap + heap_index - guard->size - sizeof(end) && - heap_index + size - guard->size <= UNITY_INTERNAL_HEAP_SIZE_BYTES) { - release_memory(oldMem); /* Not thread-safe, like unity_heap generally */ - return unity_malloc(size); /* No memcpy since data is in place */ + size_t old_total_size = unity_size_round_up(guard->size + sizeof(end)); + + if ((oldMem == unity_heap + heap_index - old_total_size) && + ((heap_index - old_total_size + unity_size_round_up(size + sizeof(end))) <= UNITY_INTERNAL_HEAP_SIZE_BYTES)) + { + release_memory(oldMem); /* Not thread-safe, like unity_heap generally */ + return unity_malloc(size); /* No memcpy since data is in place */ + } } #endif newMem = unity_malloc(size); From 7df6cca794743459b0fe274a81d24d587e5f1b88 Mon Sep 17 00:00:00 2001 From: Alessio Centazzo Date: Sun, 29 Sep 2019 22:01:03 -0700 Subject: [PATCH 153/454] Fix compiler warning Fix compiler complaint about declaration after statement --- extras/fixture/src/unity_fixture.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/extras/fixture/src/unity_fixture.c b/extras/fixture/src/unity_fixture.c index 7272a8af..958a37fc 100644 --- a/extras/fixture/src/unity_fixture.c +++ b/extras/fixture/src/unity_fixture.c @@ -256,13 +256,15 @@ static void release_memory(void* mem) malloc_count--; #ifdef UNITY_EXCLUDE_STDLIB_MALLOC - size_t block_size; + { + size_t block_size; - block_size = unity_size_round_up(guard->size + sizeof(end)); + block_size = unity_size_round_up(guard->size + sizeof(end)); - if (mem == unity_heap + heap_index - block_size) - { - heap_index -= (sizeof(Guard) + block_size); + if (mem == unity_heap + heap_index - block_size) + { + heap_index -= (sizeof(Guard) + block_size); + } } #else UNITY_FIXTURE_FREE(guard); From 53916f823c22dd1f163befe97fbc0b9f0919b0e3 Mon Sep 17 00:00:00 2001 From: richardhob Date: Wed, 2 Oct 2019 11:38:48 -0700 Subject: [PATCH 154/454] Update CMakeLists.txt Update the CMAKE minimum version from `3` to `3.0` to fix error in Windows 10 x64 with CMAKE 3.15.4: cmake_minimum_required could not parse VERSION "3". --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1954949e..dfc243c4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,7 +8,7 @@ # License: MIT # # # ################################################################################### -cmake_minimum_required(VERSION 3 FATAL_ERROR) +cmake_minimum_required(VERSION 3.0 FATAL_ERROR) project(unity LANGUAGES C DESCRIPTION "C Unit testing framework.") From bcbb476e20d6c4a10985d687e2ed2e96bb4fc94a Mon Sep 17 00:00:00 2001 From: Michael Brockus <55331536+michaelbadcrumble@users.noreply.github.com> Date: Sat, 12 Oct 2019 08:38:10 -0700 Subject: [PATCH 155/454] Upgrade Meson support version number two 0.52.0. This is because Meson now has better support for static libraries. --- meson.build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/meson.build b/meson.build index a2c0a152..062fcad5 100644 --- a/meson.build +++ b/meson.build @@ -13,7 +13,7 @@ project('unity', 'c', license : 'MIT', - meson_version : '>=0.50.0', + meson_version : '>=0.52.0', default_options: [ 'buildtype=minsize', 'optimization=3', From 8227ea2c36e49d86be44e4f76aa25bd03d0b7074 Mon Sep 17 00:00:00 2001 From: Michael Brockus <55331536+michaelbadcrumble@users.noreply.github.com> Date: Sat, 12 Oct 2019 08:44:03 -0700 Subject: [PATCH 156/454] Update .gitattributes Adding Meson build script into hit attributes as text. --- .gitattributes | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitattributes b/.gitattributes index ad952260..f84c1623 100644 --- a/.gitattributes +++ b/.gitattributes @@ -16,6 +16,7 @@ *.md text makefile text rakefile text +meson.build text #These files are binary and should not be normalized From 1748f00fc75993ff77882ace3fc470d45ef067a1 Mon Sep 17 00:00:00 2001 From: Michael Brockus <55331536+michaelbadcrumble@users.noreply.github.com> Date: Sat, 12 Oct 2019 08:50:58 -0700 Subject: [PATCH 157/454] Adding ignore entries. Adding basic ignore entry for example and main build directories. --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index a383c3cc..083b4f89 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ build/ +builddir/ test/sandbox .DS_Store examples/example_1/test1.exe @@ -7,3 +8,4 @@ examples/example_2/all_tests.exe examples/example_1/test1.out examples/example_1/test2.out examples/example_2/all_tests.out +examples/example_4/builddir From 77008edca972a5b62a08a3e7094584ffcb419862 Mon Sep 17 00:00:00 2001 From: Mark VanderVoord Date: Mon, 21 Oct 2019 08:32:35 -0400 Subject: [PATCH 158/454] Support size_t macros --- src/unity.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/unity.h b/src/unity.h index 8f1fe2e5..3209b9f0 100644 --- a/src/unity.h +++ b/src/unity.h @@ -137,6 +137,7 @@ int suiteTearDown(int num_failures); #define TEST_ASSERT_EQUAL_UINT16(expected, actual) UNITY_TEST_ASSERT_EQUAL_UINT16( (expected), (actual), __LINE__, NULL) #define TEST_ASSERT_EQUAL_UINT32(expected, actual) UNITY_TEST_ASSERT_EQUAL_UINT32( (expected), (actual), __LINE__, NULL) #define TEST_ASSERT_EQUAL_UINT64(expected, actual) UNITY_TEST_ASSERT_EQUAL_UINT64( (expected), (actual), __LINE__, NULL) +#define TEST_ASSERT_EQUAL_size_t(expected, actual) UNITY_TEST_ASSERT_EQUAL_UINT((expected), (actual), __LINE__, NULL) #define TEST_ASSERT_EQUAL_HEX(expected, actual) UNITY_TEST_ASSERT_EQUAL_HEX32((expected), (actual), __LINE__, NULL) #define TEST_ASSERT_EQUAL_HEX8(expected, actual) UNITY_TEST_ASSERT_EQUAL_HEX8( (expected), (actual), __LINE__, NULL) #define TEST_ASSERT_EQUAL_HEX16(expected, actual) UNITY_TEST_ASSERT_EQUAL_HEX16((expected), (actual), __LINE__, NULL) @@ -160,6 +161,7 @@ int suiteTearDown(int num_failures); #define TEST_ASSERT_GREATER_THAN_UINT16(threshold, actual) UNITY_TEST_ASSERT_GREATER_THAN_UINT16((threshold), (actual), __LINE__, NULL) #define TEST_ASSERT_GREATER_THAN_UINT32(threshold, actual) UNITY_TEST_ASSERT_GREATER_THAN_UINT32((threshold), (actual), __LINE__, NULL) #define TEST_ASSERT_GREATER_THAN_UINT64(threshold, actual) UNITY_TEST_ASSERT_GREATER_THAN_UINT64((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_GREATER_THAN_size_t(threshold, actual) UNITY_TEST_ASSERT_GREATER_THAN_UINT((threshold), (actual), __LINE__, NULL) #define TEST_ASSERT_GREATER_THAN_HEX8(threshold, actual) UNITY_TEST_ASSERT_GREATER_THAN_HEX8((threshold), (actual), __LINE__, NULL) #define TEST_ASSERT_GREATER_THAN_HEX16(threshold, actual) UNITY_TEST_ASSERT_GREATER_THAN_HEX16((threshold), (actual), __LINE__, NULL) #define TEST_ASSERT_GREATER_THAN_HEX32(threshold, actual) UNITY_TEST_ASSERT_GREATER_THAN_HEX32((threshold), (actual), __LINE__, NULL) @@ -176,6 +178,7 @@ int suiteTearDown(int num_failures); #define TEST_ASSERT_LESS_THAN_UINT16(threshold, actual) UNITY_TEST_ASSERT_SMALLER_THAN_UINT16((threshold), (actual), __LINE__, NULL) #define TEST_ASSERT_LESS_THAN_UINT32(threshold, actual) UNITY_TEST_ASSERT_SMALLER_THAN_UINT32((threshold), (actual), __LINE__, NULL) #define TEST_ASSERT_LESS_THAN_UINT64(threshold, actual) UNITY_TEST_ASSERT_SMALLER_THAN_UINT64((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_LESS_THAN_size_t(threshold, actual) UNITY_TEST_ASSERT_SMALLER_THAN_UINT((threshold), (actual), __LINE__, NULL) #define TEST_ASSERT_LESS_THAN_HEX8(threshold, actual) UNITY_TEST_ASSERT_SMALLER_THAN_HEX8((threshold), (actual), __LINE__, NULL) #define TEST_ASSERT_LESS_THAN_HEX16(threshold, actual) UNITY_TEST_ASSERT_SMALLER_THAN_HEX16((threshold), (actual), __LINE__, NULL) #define TEST_ASSERT_LESS_THAN_HEX32(threshold, actual) UNITY_TEST_ASSERT_SMALLER_THAN_HEX32((threshold), (actual), __LINE__, NULL) @@ -192,6 +195,7 @@ int suiteTearDown(int num_failures); #define TEST_ASSERT_GREATER_OR_EQUAL_UINT16(threshold, actual) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_UINT16((threshold), (actual), __LINE__, NULL) #define TEST_ASSERT_GREATER_OR_EQUAL_UINT32(threshold, actual) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_UINT32((threshold), (actual), __LINE__, NULL) #define TEST_ASSERT_GREATER_OR_EQUAL_UINT64(threshold, actual) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_UINT64((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_GREATER_OR_EQUAL_size_t(threshold, actual) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_UINT((threshold), (actual), __LINE__, NULL) #define TEST_ASSERT_GREATER_OR_EQUAL_HEX8(threshold, actual) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_HEX8((threshold), (actual), __LINE__, NULL) #define TEST_ASSERT_GREATER_OR_EQUAL_HEX16(threshold, actual) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_HEX16((threshold), (actual), __LINE__, NULL) #define TEST_ASSERT_GREATER_OR_EQUAL_HEX32(threshold, actual) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_HEX32((threshold), (actual), __LINE__, NULL) @@ -208,6 +212,7 @@ int suiteTearDown(int num_failures); #define TEST_ASSERT_LESS_OR_EQUAL_UINT16(threshold, actual) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_UINT16((threshold), (actual), __LINE__, NULL) #define TEST_ASSERT_LESS_OR_EQUAL_UINT32(threshold, actual) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_UINT32((threshold), (actual), __LINE__, NULL) #define TEST_ASSERT_LESS_OR_EQUAL_UINT64(threshold, actual) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_UINT64((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_LESS_OR_EQUAL_size_t(threshold, actual) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_UINT((threshold), (actual), __LINE__, NULL) #define TEST_ASSERT_LESS_OR_EQUAL_HEX8(threshold, actual) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_HEX8((threshold), (actual), __LINE__, NULL) #define TEST_ASSERT_LESS_OR_EQUAL_HEX16(threshold, actual) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_HEX16((threshold), (actual), __LINE__, NULL) #define TEST_ASSERT_LESS_OR_EQUAL_HEX32(threshold, actual) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_HEX32((threshold), (actual), __LINE__, NULL) @@ -224,6 +229,7 @@ int suiteTearDown(int num_failures); #define TEST_ASSERT_UINT16_WITHIN(delta, expected, actual) UNITY_TEST_ASSERT_UINT16_WITHIN((delta), (expected), (actual), __LINE__, NULL) #define TEST_ASSERT_UINT32_WITHIN(delta, expected, actual) UNITY_TEST_ASSERT_UINT32_WITHIN((delta), (expected), (actual), __LINE__, NULL) #define TEST_ASSERT_UINT64_WITHIN(delta, expected, actual) UNITY_TEST_ASSERT_UINT64_WITHIN((delta), (expected), (actual), __LINE__, NULL) +#define TEST_ASSERT_size_t_WITHIN(delta, expected, actual) UNITY_TEST_ASSERT_UINT_WITHIN((delta), (expected), (actual), __LINE__, NULL) #define TEST_ASSERT_HEX_WITHIN(delta, expected, actual) UNITY_TEST_ASSERT_HEX32_WITHIN((delta), (expected), (actual), __LINE__, NULL) #define TEST_ASSERT_HEX8_WITHIN(delta, expected, actual) UNITY_TEST_ASSERT_HEX8_WITHIN((delta), (expected), (actual), __LINE__, NULL) #define TEST_ASSERT_HEX16_WITHIN(delta, expected, actual) UNITY_TEST_ASSERT_HEX16_WITHIN((delta), (expected), (actual), __LINE__, NULL) @@ -241,6 +247,7 @@ int suiteTearDown(int num_failures); #define TEST_ASSERT_UINT16_ARRAY_WITHIN(delta, expected, actual, num_elements) UNITY_TEST_ASSERT_UINT16_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, NULL) #define TEST_ASSERT_UINT32_ARRAY_WITHIN(delta, expected, actual, num_elements) UNITY_TEST_ASSERT_UINT32_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, NULL) #define TEST_ASSERT_UINT64_ARRAY_WITHIN(delta, expected, actual, num_elements) UNITY_TEST_ASSERT_UINT64_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, NULL) +#define TEST_ASSERT_size_t_ARRAY_WITHIN(delta, expected, actual, num_elements) UNITY_TEST_ASSERT_UINT_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, NULL) #define TEST_ASSERT_HEX_ARRAY_WITHIN(delta, expected, actual, num_elements) UNITY_TEST_ASSERT_HEX32_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, NULL) #define TEST_ASSERT_HEX8_ARRAY_WITHIN(delta, expected, actual, num_elements) UNITY_TEST_ASSERT_HEX8_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, NULL) #define TEST_ASSERT_HEX16_ARRAY_WITHIN(delta, expected, actual, num_elements) UNITY_TEST_ASSERT_HEX16_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, NULL) @@ -265,6 +272,7 @@ int suiteTearDown(int num_failures); #define TEST_ASSERT_EQUAL_UINT16_ARRAY(expected, actual, num_elements) UNITY_TEST_ASSERT_EQUAL_UINT16_ARRAY((expected), (actual), (num_elements), __LINE__, NULL) #define TEST_ASSERT_EQUAL_UINT32_ARRAY(expected, actual, num_elements) UNITY_TEST_ASSERT_EQUAL_UINT32_ARRAY((expected), (actual), (num_elements), __LINE__, NULL) #define TEST_ASSERT_EQUAL_UINT64_ARRAY(expected, actual, num_elements) UNITY_TEST_ASSERT_EQUAL_UINT64_ARRAY((expected), (actual), (num_elements), __LINE__, NULL) +#define TEST_ASSERT_EQUAL_size_t_ARRAY(expected, actual, num_elements) UNITY_TEST_ASSERT_EQUAL_UINT_ARRAY((expected), (actual), (num_elements), __LINE__, NULL) #define TEST_ASSERT_EQUAL_HEX_ARRAY(expected, actual, num_elements) UNITY_TEST_ASSERT_EQUAL_HEX32_ARRAY((expected), (actual), (num_elements), __LINE__, NULL) #define TEST_ASSERT_EQUAL_HEX8_ARRAY(expected, actual, num_elements) UNITY_TEST_ASSERT_EQUAL_HEX8_ARRAY((expected), (actual), (num_elements), __LINE__, NULL) #define TEST_ASSERT_EQUAL_HEX16_ARRAY(expected, actual, num_elements) UNITY_TEST_ASSERT_EQUAL_HEX16_ARRAY((expected), (actual), (num_elements), __LINE__, NULL) @@ -285,6 +293,7 @@ int suiteTearDown(int num_failures); #define TEST_ASSERT_EACH_EQUAL_UINT16(expected, actual, num_elements) UNITY_TEST_ASSERT_EACH_EQUAL_UINT16((expected), (actual), (num_elements), __LINE__, NULL) #define TEST_ASSERT_EACH_EQUAL_UINT32(expected, actual, num_elements) UNITY_TEST_ASSERT_EACH_EQUAL_UINT32((expected), (actual), (num_elements), __LINE__, NULL) #define TEST_ASSERT_EACH_EQUAL_UINT64(expected, actual, num_elements) UNITY_TEST_ASSERT_EACH_EQUAL_UINT64((expected), (actual), (num_elements), __LINE__, NULL) +#define TEST_ASSERT_EACH_EQUAL_size_t(expected, actual, num_elements) UNITY_TEST_ASSERT_EACH_EQUAL_UINT((expected), (actual), (num_elements), __LINE__, NULL) #define TEST_ASSERT_EACH_EQUAL_HEX(expected, actual, num_elements) UNITY_TEST_ASSERT_EACH_EQUAL_HEX32((expected), (actual), (num_elements), __LINE__, NULL) #define TEST_ASSERT_EACH_EQUAL_HEX8(expected, actual, num_elements) UNITY_TEST_ASSERT_EACH_EQUAL_HEX8((expected), (actual), (num_elements), __LINE__, NULL) #define TEST_ASSERT_EACH_EQUAL_HEX16(expected, actual, num_elements) UNITY_TEST_ASSERT_EACH_EQUAL_HEX16((expected), (actual), (num_elements), __LINE__, NULL) @@ -367,6 +376,7 @@ int suiteTearDown(int num_failures); #define TEST_ASSERT_EQUAL_UINT16_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_UINT16( (expected), (actual), __LINE__, (message)) #define TEST_ASSERT_EQUAL_UINT32_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_UINT32( (expected), (actual), __LINE__, (message)) #define TEST_ASSERT_EQUAL_UINT64_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_UINT64( (expected), (actual), __LINE__, (message)) +#define TEST_ASSERT_EQUAL_size_t_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_UINT( (expected), (actual), __LINE__, (message)) #define TEST_ASSERT_EQUAL_HEX_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_HEX32((expected), (actual), __LINE__, (message)) #define TEST_ASSERT_EQUAL_HEX8_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_HEX8( (expected), (actual), __LINE__, (message)) #define TEST_ASSERT_EQUAL_HEX16_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_HEX16((expected), (actual), __LINE__, (message)) @@ -390,6 +400,7 @@ int suiteTearDown(int num_failures); #define TEST_ASSERT_GREATER_THAN_UINT16_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_THAN_UINT16((threshold), (actual), __LINE__, (message)) #define TEST_ASSERT_GREATER_THAN_UINT32_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_THAN_UINT32((threshold), (actual), __LINE__, (message)) #define TEST_ASSERT_GREATER_THAN_UINT64_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_THAN_UINT64((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_GREATER_THAN_size_t_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_THAN_UINT((threshold), (actual), __LINE__, (message)) #define TEST_ASSERT_GREATER_THAN_HEX8_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_THAN_HEX8((threshold), (actual), __LINE__, (message)) #define TEST_ASSERT_GREATER_THAN_HEX16_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_THAN_HEX16((threshold), (actual), __LINE__, (message)) #define TEST_ASSERT_GREATER_THAN_HEX32_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_THAN_HEX32((threshold), (actual), __LINE__, (message)) @@ -406,6 +417,7 @@ int suiteTearDown(int num_failures); #define TEST_ASSERT_LESS_THAN_UINT16_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_THAN_UINT16((threshold), (actual), __LINE__, (message)) #define TEST_ASSERT_LESS_THAN_UINT32_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_THAN_UINT32((threshold), (actual), __LINE__, (message)) #define TEST_ASSERT_LESS_THAN_UINT64_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_THAN_UINT64((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_LESS_THAN_size_t_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_THAN_UINT((threshold), (actual), __LINE__, (message)) #define TEST_ASSERT_LESS_THAN_HEX8_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_THAN_HEX8((threshold), (actual), __LINE__, (message)) #define TEST_ASSERT_LESS_THAN_HEX16_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_THAN_HEX16((threshold), (actual), __LINE__, (message)) #define TEST_ASSERT_LESS_THAN_HEX32_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_THAN_HEX32((threshold), (actual), __LINE__, (message)) @@ -422,6 +434,7 @@ int suiteTearDown(int num_failures); #define TEST_ASSERT_GREATER_OR_EQUAL_UINT16_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_UINT16((threshold), (actual), __LINE__, (message)) #define TEST_ASSERT_GREATER_OR_EQUAL_UINT32_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_UINT32((threshold), (actual), __LINE__, (message)) #define TEST_ASSERT_GREATER_OR_EQUAL_UINT64_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_UINT64((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_GREATER_OR_EQUAL_size_t_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_UINT((threshold), (actual), __LINE__, (message)) #define TEST_ASSERT_GREATER_OR_EQUAL_HEX8_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_HEX8((threshold), (actual), __LINE__, (message)) #define TEST_ASSERT_GREATER_OR_EQUAL_HEX16_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_HEX16((threshold), (actual), __LINE__, (message)) #define TEST_ASSERT_GREATER_OR_EQUAL_HEX32_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_HEX32((threshold), (actual), __LINE__, (message)) @@ -438,6 +451,7 @@ int suiteTearDown(int num_failures); #define TEST_ASSERT_LESS_OR_EQUAL_UINT16_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_UINT16((threshold), (actual), __LINE__, (message)) #define TEST_ASSERT_LESS_OR_EQUAL_UINT32_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_UINT32((threshold), (actual), __LINE__, (message)) #define TEST_ASSERT_LESS_OR_EQUAL_UINT64_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_UINT64((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_LESS_OR_EQUAL_size_t_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_UINT((threshold), (actual), __LINE__, (message)) #define TEST_ASSERT_LESS_OR_EQUAL_HEX8_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_HEX8((threshold), (actual), __LINE__, (message)) #define TEST_ASSERT_LESS_OR_EQUAL_HEX16_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_HEX16((threshold), (actual), __LINE__, (message)) #define TEST_ASSERT_LESS_OR_EQUAL_HEX32_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_HEX32((threshold), (actual), __LINE__, (message)) @@ -454,6 +468,7 @@ int suiteTearDown(int num_failures); #define TEST_ASSERT_UINT16_WITHIN_MESSAGE(delta, expected, actual, message) UNITY_TEST_ASSERT_UINT16_WITHIN((delta), (expected), (actual), __LINE__, (message)) #define TEST_ASSERT_UINT32_WITHIN_MESSAGE(delta, expected, actual, message) UNITY_TEST_ASSERT_UINT32_WITHIN((delta), (expected), (actual), __LINE__, (message)) #define TEST_ASSERT_UINT64_WITHIN_MESSAGE(delta, expected, actual, message) UNITY_TEST_ASSERT_UINT64_WITHIN((delta), (expected), (actual), __LINE__, (message)) +#define TEST_ASSERT_size_t_WITHIN_MESSAGE(delta, expected, actual, message) UNITY_TEST_ASSERT_UINT_WITHIN((delta), (expected), (actual), __LINE__, (message)) #define TEST_ASSERT_HEX_WITHIN_MESSAGE(delta, expected, actual, message) UNITY_TEST_ASSERT_HEX32_WITHIN((delta), (expected), (actual), __LINE__, (message)) #define TEST_ASSERT_HEX8_WITHIN_MESSAGE(delta, expected, actual, message) UNITY_TEST_ASSERT_HEX8_WITHIN((delta), (expected), (actual), __LINE__, (message)) #define TEST_ASSERT_HEX16_WITHIN_MESSAGE(delta, expected, actual, message) UNITY_TEST_ASSERT_HEX16_WITHIN((delta), (expected), (actual), __LINE__, (message)) @@ -471,6 +486,7 @@ int suiteTearDown(int num_failures); #define TEST_ASSERT_UINT16_ARRAY_WITHIN_MESSAGE(delta, expected, actual, num_elements, message) UNITY_TEST_ASSERT_UINT16_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, (message)) #define TEST_ASSERT_UINT32_ARRAY_WITHIN_MESSAGE(delta, expected, actual, num_elements, message) UNITY_TEST_ASSERT_UINT32_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, (message)) #define TEST_ASSERT_UINT64_ARRAY_WITHIN_MESSAGE(delta, expected, actual, num_elements, message) UNITY_TEST_ASSERT_UINT64_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, (message)) +#define TEST_ASSERT_size_t_ARRAY_WITHIN_MESSAGE(delta, expected, actual, num_elements, message) UNITY_TEST_ASSERT_UINT_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, (message)) #define TEST_ASSERT_HEX_ARRAY_WITHIN_MESSAGE(delta, expected, actual, num_elements, message) UNITY_TEST_ASSERT_HEX32_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, (message)) #define TEST_ASSERT_HEX8_ARRAY_WITHIN_MESSAGE(delta, expected, actual, num_elements, message) UNITY_TEST_ASSERT_HEX8_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, (message)) #define TEST_ASSERT_HEX16_ARRAY_WITHIN_MESSAGE(delta, expected, actual, num_elements, message) UNITY_TEST_ASSERT_HEX16_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, (message)) @@ -495,6 +511,7 @@ int suiteTearDown(int num_failures); #define TEST_ASSERT_EQUAL_UINT16_ARRAY_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EQUAL_UINT16_ARRAY((expected), (actual), (num_elements), __LINE__, (message)) #define TEST_ASSERT_EQUAL_UINT32_ARRAY_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EQUAL_UINT32_ARRAY((expected), (actual), (num_elements), __LINE__, (message)) #define TEST_ASSERT_EQUAL_UINT64_ARRAY_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EQUAL_UINT64_ARRAY((expected), (actual), (num_elements), __LINE__, (message)) +#define TEST_ASSERT_EQUAL_size_t_ARRAY_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EQUAL_UINT_ARRAY((expected), (actual), (num_elements), __LINE__, (message)) #define TEST_ASSERT_EQUAL_HEX_ARRAY_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EQUAL_HEX32_ARRAY((expected), (actual), (num_elements), __LINE__, (message)) #define TEST_ASSERT_EQUAL_HEX8_ARRAY_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EQUAL_HEX8_ARRAY((expected), (actual), (num_elements), __LINE__, (message)) #define TEST_ASSERT_EQUAL_HEX16_ARRAY_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EQUAL_HEX16_ARRAY((expected), (actual), (num_elements), __LINE__, (message)) @@ -515,6 +532,7 @@ int suiteTearDown(int num_failures); #define TEST_ASSERT_EACH_EQUAL_UINT16_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EACH_EQUAL_UINT16((expected), (actual), (num_elements), __LINE__, (message)) #define TEST_ASSERT_EACH_EQUAL_UINT32_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EACH_EQUAL_UINT32((expected), (actual), (num_elements), __LINE__, (message)) #define TEST_ASSERT_EACH_EQUAL_UINT64_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EACH_EQUAL_UINT64((expected), (actual), (num_elements), __LINE__, (message)) +#define TEST_ASSERT_EACH_EQUAL_size_t_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EACH_EQUAL_UINT((expected), (actual), (num_elements), __LINE__, (message)) #define TEST_ASSERT_EACH_EQUAL_HEX_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EACH_EQUAL_HEX32((expected), (actual), (num_elements), __LINE__, (message)) #define TEST_ASSERT_EACH_EQUAL_HEX8_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EACH_EQUAL_HEX8((expected), (actual), (num_elements), __LINE__, (message)) #define TEST_ASSERT_EACH_EQUAL_HEX16_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EACH_EQUAL_HEX16((expected), (actual), (num_elements), __LINE__, (message)) From 9842a4d03ddb3a2f3ef48e247a470e99921eb134 Mon Sep 17 00:00:00 2001 From: Mark VanderVoord Date: Mon, 21 Oct 2019 10:12:59 -0400 Subject: [PATCH 159/454] Switching to universal version being in the header file itself. --- release/build.info | 2 -- release/version.info | 2 -- src/unity.h | 5 +++++ 3 files changed, 5 insertions(+), 4 deletions(-) delete mode 100644 release/build.info delete mode 100644 release/version.info diff --git a/release/build.info b/release/build.info deleted file mode 100644 index 56d59128..00000000 --- a/release/build.info +++ /dev/null @@ -1,2 +0,0 @@ -122 - diff --git a/release/version.info b/release/version.info deleted file mode 100644 index b2031148..00000000 --- a/release/version.info +++ /dev/null @@ -1,2 +0,0 @@ -2.4.4 - diff --git a/src/unity.h b/src/unity.h index 3209b9f0..d1f8a1b8 100644 --- a/src/unity.h +++ b/src/unity.h @@ -8,6 +8,11 @@ #define UNITY_FRAMEWORK_H #define UNITY +#define UNITY_VERSION_MAJOR 2 +#define UNITY_VERSION_MINOR 5 +#define UNITY_VERSION_BUILD 0 +#define UNITY_VERSION ((UNITY_VERSION_MAJOR << 16) | (UNITY_VERSION_MINOR << 8) | UNITY_VERSION_BUILD) + #ifdef __cplusplus extern "C" { From 0793de9ef1bd7b8927f0388adefcd76cd4d9ded3 Mon Sep 17 00:00:00 2001 From: Mark VanderVoord Date: Mon, 21 Oct 2019 11:27:28 -0400 Subject: [PATCH 160/454] Do not fail makefile just because example fails. --- examples/example_1/makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/example_1/makefile b/examples/example_1/makefile index cca79b42..545476a6 100644 --- a/examples/example_1/makefile +++ b/examples/example_1/makefile @@ -57,7 +57,7 @@ default: $(SRC_FILES1) $(SRC_FILES2) $(C_COMPILER) $(CFLAGS) $(INC_DIRS) $(SYMBOLS) $(SRC_FILES1) -o $(TARGET1) $(C_COMPILER) $(CFLAGS) $(INC_DIRS) $(SYMBOLS) $(SRC_FILES2) -o $(TARGET2) - ./$(TARGET1) - ./$(TARGET2) + - ./$(TARGET2) test/test_runners/TestProductionCode_Runner.c: test/TestProductionCode.c ruby $(UNITY_ROOT)/auto/generate_test_runner.rb test/TestProductionCode.c test/test_runners/TestProductionCode_Runner.c From d9b0edf2827d7703722d16b64487be1d1ad71006 Mon Sep 17 00:00:00 2001 From: Mark VanderVoord Date: Mon, 21 Oct 2019 14:21:52 -0400 Subject: [PATCH 161/454] Switch from the inconsistent use of weak symbols to handling setup, etc in script generators --- auto/generate_test_runner.rb | 75 +++++++++++++++++++----------------- src/unity.h | 33 ++++------------ src/unity_internals.h | 16 -------- 3 files changed, 48 insertions(+), 76 deletions(-) diff --git a/auto/generate_test_runner.rb b/auto/generate_test_runner.rb index 6dc90e05..c7ec6005 100644 --- a/auto/generate_test_runner.rb +++ b/auto/generate_test_runner.rb @@ -58,6 +58,7 @@ def run(input_file, output_file, options = nil) used_mocks = find_mocks(testfile_includes) testfile_includes = (testfile_includes - used_mocks) testfile_includes.delete_if { |inc| inc =~ /(unity|cmock)/ } + find_setup_and_teardown() # build runner file generate(input_file, output_file, tests, used_mocks, testfile_includes) @@ -165,11 +166,17 @@ def find_mocks(includes) mock_headers end + def find_setup_and_teardown(source) + @has_setup = source =~ /void\s+#{@options[setup_name]}\s*\(/ + @has_teardown = source =~ /void\s+#{@options[teardown_name]}\s*\(/ + @has_suite_setup = (!@options[:suite_setup].nil?) || (source =~ /void\s+suiteSetUp\s*\(/) + @has_suite_teardown = (!@options[:suite_teardown].nil?) || (source =~ /void\s+suiteTearDown\s*\(/) + end + def create_header(output, mocks, testfile_includes = []) output.puts('/* AUTOGENERATED FILE. DO NOT EDIT. */') create_runtest(output, mocks) output.puts("\n/*=======Automagically Detected Files To Include=====*/") - output.puts('#define UNITY_INCLUDE_SETUP_STUBS') if @options[:suite_setup].nil? output.puts("#include \"#{@options[:framework]}.h\"") output.puts('#include "cmock.h"') unless mocks.empty? output.puts('#ifndef UNITY_EXCLUDE_SETJMP_H') @@ -204,8 +211,8 @@ def create_header(output, mocks, testfile_includes = []) def create_externs(output, tests, _mocks) output.puts("\n/*=======External Functions This Runner Calls=====*/") - output.puts("extern void #{@options[:setup_name]}(void);") - output.puts("extern void #{@options[:teardown_name]}(void);") + output.puts("extern void #{@options[:setup_name]}(void);") if @has_setup + output.puts("extern void #{@options[:teardown_name]}(void);") if @has_teardown output.puts("\n#ifdef __cplusplus\nextern \"C\"\n{\n#endif") if @options[:externc] tests.each do |test| output.puts("extern void #{test[:test]}(#{test[:call] || 'void'});") @@ -252,37 +259,31 @@ def create_mock_management(output, mock_headers) end def create_suite_setup(output) - output.puts("\n/*=======Suite Setup=====*/") - output.puts('static void suite_setup(void)') - output.puts('{') - if @options[:suite_setup].nil? - # New style, call suiteSetUp() if we can use weak symbols - output.puts('#if defined(UNITY_WEAK_ATTRIBUTE) || defined(UNITY_WEAK_PRAGMA)') - output.puts(' suiteSetUp();') - output.puts('#endif') - else - # Old style, C code embedded in the :suite_setup option - output.puts(@options[:suite_setup]) + if @has_suite_setup + if @options[:suite_setup].nil? + output.puts("\n/*=======Suite Setup=====*/") + output.puts('static void suiteSetUp(void)') + output.puts('{') + output.puts(@options[:suite_setup]) + output.puts('}') + else + output.puts('extern void suiteSetUp(void);') + end end - output.puts('}') end def create_suite_teardown(output) - output.puts("\n/*=======Suite Teardown=====*/") - output.puts('static int suite_teardown(int num_failures)') - output.puts('{') - if @options[:suite_teardown].nil? - # New style, call suiteTearDown() if we can use weak symbols - output.puts('#if defined(UNITY_WEAK_ATTRIBUTE) || defined(UNITY_WEAK_PRAGMA)') - output.puts(' return suiteTearDown(num_failures);') - output.puts('#else') - output.puts(' return num_failures;') - output.puts('#endif') - else - # Old style, C code embedded in the :suite_teardown option - output.puts(@options[:suite_teardown]) + if (@has_suite_teardown) + if @options[:suite_teardown].nil? + output.puts("\n/*=======Suite Teardown=====*/") + output.puts('static int suite_teardown(int num_failures)') + output.puts('{') + output.puts(@options[:suite_teardown]) + output.puts('}') + else + output.puts('extern int suite_teardown(int num_failures);') + end end - output.puts('}') end def create_runtest(output, used_mocks) @@ -304,13 +305,13 @@ def create_runtest(output, used_mocks) output.puts(' { \\') output.puts(' CEXCEPTION_T e; \\') if cexception output.puts(' Try { \\') if cexception - output.puts(" #{@options[:setup_name]}(); \\") + output.puts(" #{@options[:setup_name]}(); \\") if @has_setup output.puts(" TestFunc(#{va_args2}); \\") output.puts(' } Catch(e) { TEST_ASSERT_EQUAL_HEX32_MESSAGE(CEXCEPTION_NONE, e, "Unhandled Exception!"); } \\') if cexception output.puts(' } \\') output.puts(' if (TEST_PROTECT()) \\') output.puts(' { \\') - output.puts(" #{@options[:teardown_name]}(); \\") + output.puts(" #{@options[:teardown_name]}(); \\") if @has_teardown output.puts(' CMock_Verify(); \\') unless used_mocks.empty? output.puts(' } \\') output.puts(' CMock_Destroy(); \\') unless used_mocks.empty? @@ -327,9 +328,9 @@ def create_reset(output, used_mocks) output.puts('{') output.puts(' CMock_Verify();') unless used_mocks.empty? output.puts(' CMock_Destroy();') unless used_mocks.empty? - output.puts(" #{@options[:teardown_name]}();") + output.puts(" #{@options[:teardown_name]}();") if @has_teardown output.puts(' CMock_Init();') unless used_mocks.empty? - output.puts(" #{@options[:setup_name]}();") + output.puts(" #{@options[:setup_name]}();") if @has_setup output.puts('}') end @@ -375,7 +376,7 @@ def create_main(output, filename, tests, used_mocks) output.puts("int #{main_name}(void)") output.puts('{') end - output.puts(' suite_setup();') + output.puts(' suiteSetUp();') if @has_suite_setup output.puts(" UnityBegin(\"#{filename.gsub(/\\/, '\\\\\\')}\");") if @options[:use_param_tests] tests.each do |test| @@ -390,7 +391,11 @@ def create_main(output, filename, tests, used_mocks) end output.puts output.puts(' CMock_Guts_MemFreeFinal();') unless used_mocks.empty? - output.puts(' return suite_teardown(UnityEnd());') + if (@has_suite_teardown) + output.puts(' return suiteTearDown(UnityEnd());') + else + output.puts(' return UnityEnd();') + end output.puts('}') end diff --git a/src/unity.h b/src/unity.h index d1f8a1b8..f97d1414 100644 --- a/src/unity.h +++ b/src/unity.h @@ -24,39 +24,22 @@ extern "C" * Test Setup / Teardown *-------------------------------------------------------*/ -/* These functions are intended to be called before and after each test. */ +/* These functions are intended to be called before and after each test. + * If using unity directly, these will need to be provided for each test + * executable built. If you are using the test runner generator and/or + * Ceedling, these are optional. */ void setUp(void); void tearDown(void); /* These functions are intended to be called at the beginning and end of an * entire test suite. suiteTearDown() is passed the number of tests that - * failed, and its return value becomes the exit code of main(). */ + * failed, and its return value becomes the exit code of main(). If using + * Unity directly, you're in charge of calling these if they are desired. + * If using Ceedling or the test runner generator, these will be called + * automatically if they exist. */ void suiteSetUp(void); int suiteTearDown(int num_failures); -/* If the compiler supports it, the following block provides stub - * implementations of the above functions as weak symbols. Note that on - * some platforms (MinGW for example), weak function implementations need - * to be in the same translation unit they are called from. This can be - * achieved by defining UNITY_INCLUDE_SETUP_STUBS before including unity.h. */ -#ifdef UNITY_INCLUDE_SETUP_STUBS - #ifdef UNITY_WEAK_ATTRIBUTE - UNITY_WEAK_ATTRIBUTE void setUp(void) { } - UNITY_WEAK_ATTRIBUTE void tearDown(void) { } - UNITY_WEAK_ATTRIBUTE void suiteSetUp(void) { } - UNITY_WEAK_ATTRIBUTE int suiteTearDown(int num_failures) { return num_failures; } - #elif defined(UNITY_WEAK_PRAGMA) - #pragma weak setUp - void setUp(void) { } - #pragma weak tearDown - void tearDown(void) { } - #pragma weak suiteSetUp - void suiteSetUp(void) { } - #pragma weak suiteTearDown - int suiteTearDown(int num_failures) { return num_failures; } - #endif -#endif - /*------------------------------------------------------- * Configuration Options *------------------------------------------------------- diff --git a/src/unity_internals.h b/src/unity_internals.h index 0dd08fb5..09952815 100644 --- a/src/unity_internals.h +++ b/src/unity_internals.h @@ -372,22 +372,6 @@ typedef UNITY_FLOAT_TYPE UNITY_FLOAT; #define UNITY_COUNTER_TYPE UNITY_UINT #endif -/*------------------------------------------------------- - * Language Features Available - *-------------------------------------------------------*/ -#if !defined(UNITY_WEAK_ATTRIBUTE) && !defined(UNITY_WEAK_PRAGMA) -# if defined(__GNUC__) || defined(__ghs__) /* __GNUC__ includes clang */ -# if !(defined(__WIN32__) && defined(__clang__)) && !defined(__TMS470__) -# define UNITY_WEAK_ATTRIBUTE __attribute__((weak)) -# endif -# endif -#endif - -#ifdef UNITY_NO_WEAK -# undef UNITY_WEAK_ATTRIBUTE -# undef UNITY_WEAK_PRAGMA -#endif - /*------------------------------------------------------- * Internal Structs Needed *-------------------------------------------------------*/ From 9fdcc2d3ff86cda3b448c68ccad8e0cf272d4257 Mon Sep 17 00:00:00 2001 From: Mark VanderVoord Date: Mon, 21 Oct 2019 14:29:52 -0400 Subject: [PATCH 162/454] Catch up documentation to match these changes. --- docs/UnityConfigurationGuide.md | 34 ++------------------------------ docs/UnityGettingStartedGuide.md | 13 ++++++------ 2 files changed, 9 insertions(+), 38 deletions(-) diff --git a/docs/UnityConfigurationGuide.md b/docs/UnityConfigurationGuide.md index 75dbf675..68fb1067 100644 --- a/docs/UnityConfigurationGuide.md +++ b/docs/UnityConfigurationGuide.md @@ -119,10 +119,10 @@ Define this to be the number of bits a pointer takes up on your system. The default, if not autodetected, is 32-bits. If you're getting ugly compiler warnings about casting from pointers, this is the one to look at. -_Hint:_ In order to support exotic processors (for example TI C55x with a pointer +_Hint:_ In order to support exotic processors (for example TI C55x with a pointer width of 23-bit), choose the next power of two (in this case 32-bit). -_Supported values:_ 16, 32 and 64 +_Supported values:_ 16, 32 and 64 _Example:_ ```C @@ -343,36 +343,6 @@ _Note:_ specifying `UNITY_USE_FLUSH_STDOUT`. No other defines are required. -##### `UNITY_WEAK_ATTRIBUTE` - -##### `UNITY_WEAK_PRAGMA` - -##### `UNITY_NO_WEAK` - -For some targets, Unity can make the otherwise required setUp() and tearDown() -functions optional. This is a nice convenience for test writers since setUp and -tearDown don’t often actually do anything. If you’re using gcc or clang, this -option is automatically defined for you. Other compilers can also support this -behavior, if they support a C feature called weak functions. A weak function is -a function that is compiled into your executable unless a non-weak version of -the same function is defined elsewhere. If a non-weak version is found, the weak -version is ignored as if it never existed. If your compiler supports this feature, -you can let Unity know by defining UNITY_WEAK_ATTRIBUTE or UNITY_WEAK_PRAGMA as -the function attributes that would need to be applied to identify a function as -weak. If your compiler lacks support for weak functions, you will always need to -define setUp and tearDown functions (though they can be and often will be just -empty). You can also force Unity to NOT use weak functions by defining -UNITY_NO_WEAK. The most common options for this feature are: - -_Example:_ -```C -#define UNITY_WEAK_ATTRIBUTE weak -#define UNITY_WEAK_ATTRIBUTE __attribute__((weak)) -#define UNITY_WEAK_PRAGMA -#define UNITY_NO_WEAK -``` - - ##### `UNITY_PTR_ATTRIBUTE` Some compilers require a custom attribute to be assigned to pointers, like diff --git a/docs/UnityGettingStartedGuide.md b/docs/UnityGettingStartedGuide.md index eb7041d8..c054b361 100644 --- a/docs/UnityGettingStartedGuide.md +++ b/docs/UnityGettingStartedGuide.md @@ -93,8 +93,9 @@ Next, a test file will include a `setUp()` and `tearDown()` function. The setUp function can contain anything you would like to run before each test. The tearDown function can contain anything you would like to run after each test. Both functions accept no arguments and return nothing. You may leave either or -both of these blank if you have no need for them. If you're using a compiler -that is configured to make these functions optional, you may leave them off +both of these blank if you have no need for them. + +If you're using Ceedling or the test runner generator script, you may leave these off completely. Not sure? Give it a try. If you compiler complains that it can't find setUp or tearDown when it links, you'll know you need to at least include an empty function for these. @@ -103,7 +104,7 @@ The majority of the file will be a series of test functions. Test functions follow the convention of starting with the word "test_" or "spec_". You don't HAVE to name them this way, but it makes it clear what functions are tests for other developers. Also, the automated scripts that come with Unity or Ceedling will default -to looking for test functions to be prefixed this way. Test functions take no arguments +to looking for test functions to be prefixed this way. Test functions take no arguments and return nothing. All test accounting is handled internally in Unity. Finally, at the bottom of your test file, you will write a `main()` function. @@ -156,7 +157,7 @@ This should be enough to get you going, though. ### Running Test Functions When writing your own `main()` functions, for a test-runner. There are two ways -to execute the test. +to execute the test. The classic variant ``` c @@ -170,8 +171,8 @@ These macros perform the necessary setup before the test is called and handles cleanup and result tabulation afterwards. ### Ignoring Test Functions -There are times when a test is incomplete or not valid for some reason. -At these times, TEST_IGNORE can be called. Control will immediately be +There are times when a test is incomplete or not valid for some reason. +At these times, TEST_IGNORE can be called. Control will immediately be returned to the caller of the test, and no failures will be returned. This is useful when your test runners are automatically generated. From c19e3f99ce0fdc65d705e150f241a6e4dd7e2c92 Mon Sep 17 00:00:00 2001 From: Mark VanderVoord Date: Mon, 21 Oct 2019 14:45:56 -0400 Subject: [PATCH 163/454] missed function call arguments --- auto/generate_test_runner.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/auto/generate_test_runner.rb b/auto/generate_test_runner.rb index c7ec6005..f6e6a735 100644 --- a/auto/generate_test_runner.rb +++ b/auto/generate_test_runner.rb @@ -58,7 +58,7 @@ def run(input_file, output_file, options = nil) used_mocks = find_mocks(testfile_includes) testfile_includes = (testfile_includes - used_mocks) testfile_includes.delete_if { |inc| inc =~ /(unity|cmock)/ } - find_setup_and_teardown() + find_setup_and_teardown(source) # build runner file generate(input_file, output_file, tests, used_mocks, testfile_includes) From cb8744c4969cef513ce2da977f21a5ee9a9d39cc Mon Sep 17 00:00:00 2001 From: Mark VanderVoord Date: Mon, 21 Oct 2019 14:59:31 -0400 Subject: [PATCH 164/454] More argument fixing (I hate flying blind... can't wait to get back on my laptop) --- auto/generate_test_runner.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/auto/generate_test_runner.rb b/auto/generate_test_runner.rb index f6e6a735..bd61d5d5 100644 --- a/auto/generate_test_runner.rb +++ b/auto/generate_test_runner.rb @@ -167,8 +167,8 @@ def find_mocks(includes) end def find_setup_and_teardown(source) - @has_setup = source =~ /void\s+#{@options[setup_name]}\s*\(/ - @has_teardown = source =~ /void\s+#{@options[teardown_name]}\s*\(/ + @has_setup = source =~ /void\s+#{@options[:setup_name]}\s*\(/ + @has_teardown = source =~ /void\s+#{@options[:teardown_name]}\s*\(/ @has_suite_setup = (!@options[:suite_setup].nil?) || (source =~ /void\s+suiteSetUp\s*\(/) @has_suite_teardown = (!@options[:suite_teardown].nil?) || (source =~ /void\s+suiteTearDown\s*\(/) end From 2d8a69e0d1809bd20dd5374009d30b45835962e3 Mon Sep 17 00:00:00 2001 From: Mark VanderVoord Date: Tue, 22 Oct 2019 06:27:26 -0400 Subject: [PATCH 165/454] update handling of when suite_setup/teardown in use --- auto/generate_test_runner.rb | 45 +++++++++++++++++++++--------------- 1 file changed, 27 insertions(+), 18 deletions(-) diff --git a/auto/generate_test_runner.rb b/auto/generate_test_runner.rb index bd61d5d5..f8c93fc5 100644 --- a/auto/generate_test_runner.rb +++ b/auto/generate_test_runner.rb @@ -8,10 +8,19 @@ class UnityTestRunnerGenerator def initialize(options = nil) @options = UnityTestRunnerGenerator.default_options case options - when NilClass then @options - when String then @options.merge!(UnityTestRunnerGenerator.grab_config(options)) - when Hash then @options.merge!(options) - else raise 'If you specify arguments, it should be a filename or a hash of options' + when NilClass + @options + when String + @options.merge!(UnityTestRunnerGenerator.grab_config(options)) + when Hash + # Check if some of these have been specified + @options[:has_setup] = !options[:setup_name].nil? + @options[:has_teardown] = !options[:teardown_name].nil? + @options[:has_suite_setup] = !options[:suite_setup].nil? + @options[:has_suite_teardown] = !options[:suite_teardown].nil? + @options.merge!(options) + else + raise 'If you specify arguments, it should be a filename or a hash of options' end require_relative 'type_sanitizer' end @@ -167,10 +176,10 @@ def find_mocks(includes) end def find_setup_and_teardown(source) - @has_setup = source =~ /void\s+#{@options[:setup_name]}\s*\(/ - @has_teardown = source =~ /void\s+#{@options[:teardown_name]}\s*\(/ - @has_suite_setup = (!@options[:suite_setup].nil?) || (source =~ /void\s+suiteSetUp\s*\(/) - @has_suite_teardown = (!@options[:suite_teardown].nil?) || (source =~ /void\s+suiteTearDown\s*\(/) + @options[:has_setup] = source =~ /void\s+#{@options[:setup_name]}\s*\(/ + @options[:has_teardown] = source =~ /void\s+#{@options[:teardown_name]}\s*\(/ + @options[:has_suite_setup] ||= (source =~ /void\s+suiteSetUp\s*\(/) + @options[:has_suite_teardown] ||= (source =~ /void\s+suiteTearDown\s*\(/) end def create_header(output, mocks, testfile_includes = []) @@ -211,8 +220,8 @@ def create_header(output, mocks, testfile_includes = []) def create_externs(output, tests, _mocks) output.puts("\n/*=======External Functions This Runner Calls=====*/") - output.puts("extern void #{@options[:setup_name]}(void);") if @has_setup - output.puts("extern void #{@options[:teardown_name]}(void);") if @has_teardown + output.puts("extern void #{@options[:setup_name]}(void);") if @options[:has_setup] + output.puts("extern void #{@options[:teardown_name]}(void);") if @options[:has_teardown] output.puts("\n#ifdef __cplusplus\nextern \"C\"\n{\n#endif") if @options[:externc] tests.each do |test| output.puts("extern void #{test[:test]}(#{test[:call] || 'void'});") @@ -259,7 +268,7 @@ def create_mock_management(output, mock_headers) end def create_suite_setup(output) - if @has_suite_setup + if @options[:has_suite_setup] if @options[:suite_setup].nil? output.puts("\n/*=======Suite Setup=====*/") output.puts('static void suiteSetUp(void)') @@ -273,7 +282,7 @@ def create_suite_setup(output) end def create_suite_teardown(output) - if (@has_suite_teardown) + if @options[:has_suite_teardown] if @options[:suite_teardown].nil? output.puts("\n/*=======Suite Teardown=====*/") output.puts('static int suite_teardown(int num_failures)') @@ -305,13 +314,13 @@ def create_runtest(output, used_mocks) output.puts(' { \\') output.puts(' CEXCEPTION_T e; \\') if cexception output.puts(' Try { \\') if cexception - output.puts(" #{@options[:setup_name]}(); \\") if @has_setup + output.puts(" #{@options[:setup_name]}(); \\") if @options[:has_setup] output.puts(" TestFunc(#{va_args2}); \\") output.puts(' } Catch(e) { TEST_ASSERT_EQUAL_HEX32_MESSAGE(CEXCEPTION_NONE, e, "Unhandled Exception!"); } \\') if cexception output.puts(' } \\') output.puts(' if (TEST_PROTECT()) \\') output.puts(' { \\') - output.puts(" #{@options[:teardown_name]}(); \\") if @has_teardown + output.puts(" #{@options[:teardown_name]}(); \\") if @options[:has_teardown] output.puts(' CMock_Verify(); \\') unless used_mocks.empty? output.puts(' } \\') output.puts(' CMock_Destroy(); \\') unless used_mocks.empty? @@ -328,9 +337,9 @@ def create_reset(output, used_mocks) output.puts('{') output.puts(' CMock_Verify();') unless used_mocks.empty? output.puts(' CMock_Destroy();') unless used_mocks.empty? - output.puts(" #{@options[:teardown_name]}();") if @has_teardown + output.puts(" #{@options[:teardown_name]}();") if @options[:has_teardown] output.puts(' CMock_Init();') unless used_mocks.empty? - output.puts(" #{@options[:setup_name]}();") if @has_setup + output.puts(" #{@options[:setup_name]}();") if @options[:has_setup] output.puts('}') end @@ -376,7 +385,7 @@ def create_main(output, filename, tests, used_mocks) output.puts("int #{main_name}(void)") output.puts('{') end - output.puts(' suiteSetUp();') if @has_suite_setup + output.puts(' suiteSetUp();') if @options[:has_suite_setup] output.puts(" UnityBegin(\"#{filename.gsub(/\\/, '\\\\\\')}\");") if @options[:use_param_tests] tests.each do |test| @@ -391,7 +400,7 @@ def create_main(output, filename, tests, used_mocks) end output.puts output.puts(' CMock_Guts_MemFreeFinal();') unless used_mocks.empty? - if (@has_suite_teardown) + if @options[:has_suite_teardown] output.puts(' return suiteTearDown(UnityEnd());') else output.puts(' return UnityEnd();') From ac427b28fc85727228cd7c261ff834d0fc7ec98b Mon Sep 17 00:00:00 2001 From: Mark VanderVoord Date: Tue, 22 Oct 2019 06:37:28 -0400 Subject: [PATCH 166/454] Fixed backwards case. --- auto/generate_test_runner.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/auto/generate_test_runner.rb b/auto/generate_test_runner.rb index f8c93fc5..19fa6c12 100644 --- a/auto/generate_test_runner.rb +++ b/auto/generate_test_runner.rb @@ -269,7 +269,7 @@ def create_mock_management(output, mock_headers) def create_suite_setup(output) if @options[:has_suite_setup] - if @options[:suite_setup].nil? + if !@options[:suite_setup].nil? output.puts("\n/*=======Suite Setup=====*/") output.puts('static void suiteSetUp(void)') output.puts('{') @@ -283,7 +283,7 @@ def create_suite_setup(output) def create_suite_teardown(output) if @options[:has_suite_teardown] - if @options[:suite_teardown].nil? + if !@options[:suite_teardown].nil? output.puts("\n/*=======Suite Teardown=====*/") output.puts('static int suite_teardown(int num_failures)') output.puts('{') From ff697ad29c31d92103c307b6c9946f1e36cf2222 Mon Sep 17 00:00:00 2001 From: Mark VanderVoord Date: Tue, 22 Oct 2019 06:45:47 -0400 Subject: [PATCH 167/454] suite setup and teardown no longer static (simplifies test-supplied instance) --- auto/generate_test_runner.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/auto/generate_test_runner.rb b/auto/generate_test_runner.rb index 19fa6c12..9c8cb35a 100644 --- a/auto/generate_test_runner.rb +++ b/auto/generate_test_runner.rb @@ -271,7 +271,7 @@ def create_suite_setup(output) if @options[:has_suite_setup] if !@options[:suite_setup].nil? output.puts("\n/*=======Suite Setup=====*/") - output.puts('static void suiteSetUp(void)') + output.puts('void suiteSetUp(void)') output.puts('{') output.puts(@options[:suite_setup]) output.puts('}') @@ -285,7 +285,7 @@ def create_suite_teardown(output) if @options[:has_suite_teardown] if !@options[:suite_teardown].nil? output.puts("\n/*=======Suite Teardown=====*/") - output.puts('static int suite_teardown(int num_failures)') + output.puts('int suite_teardown(int num_failures)') output.puts('{') output.puts(@options[:suite_teardown]) output.puts('}') From 5fc72fbca19153252704fc7d646a744622b8fd8f Mon Sep 17 00:00:00 2001 From: Mark VanderVoord Date: Tue, 22 Oct 2019 06:52:25 -0400 Subject: [PATCH 168/454] fix name of teardown function --- auto/generate_test_runner.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/auto/generate_test_runner.rb b/auto/generate_test_runner.rb index 9c8cb35a..34762cfd 100644 --- a/auto/generate_test_runner.rb +++ b/auto/generate_test_runner.rb @@ -285,12 +285,12 @@ def create_suite_teardown(output) if @options[:has_suite_teardown] if !@options[:suite_teardown].nil? output.puts("\n/*=======Suite Teardown=====*/") - output.puts('int suite_teardown(int num_failures)') + output.puts('int suiteTearDown(int num_failures)') output.puts('{') output.puts(@options[:suite_teardown]) output.puts('}') else - output.puts('extern int suite_teardown(int num_failures);') + output.puts('extern int suiteTearDown(int num_failures);') end end end From 68cc45a91849b4b176067e1434a8c4f94eaf5e56 Mon Sep 17 00:00:00 2001 From: John Lindgren Date: Tue, 22 Oct 2019 15:04:03 -0400 Subject: [PATCH 169/454] Make sure setUp/tearDown are always defined. --- auto/generate_test_runner.rb | 60 +++++++++++++++++++----------------- 1 file changed, 32 insertions(+), 28 deletions(-) diff --git a/auto/generate_test_runner.rb b/auto/generate_test_runner.rb index 34762cfd..0d8bc94b 100644 --- a/auto/generate_test_runner.rb +++ b/auto/generate_test_runner.rb @@ -85,6 +85,8 @@ def generate(input_file, output_file, tests, used_mocks, testfile_includes) create_header(output, used_mocks, testfile_includes) create_externs(output, tests, used_mocks) create_mock_management(output, used_mocks) + create_setup(output) + create_teardown(output) create_suite_setup(output) create_suite_teardown(output) create_reset(output, used_mocks) @@ -220,8 +222,8 @@ def create_header(output, mocks, testfile_includes = []) def create_externs(output, tests, _mocks) output.puts("\n/*=======External Functions This Runner Calls=====*/") - output.puts("extern void #{@options[:setup_name]}(void);") if @options[:has_setup] - output.puts("extern void #{@options[:teardown_name]}(void);") if @options[:has_teardown] + output.puts("extern void #{@options[:setup_name]}(void);") + output.puts("extern void #{@options[:teardown_name]}(void);") output.puts("\n#ifdef __cplusplus\nextern \"C\"\n{\n#endif") if @options[:externc] tests.each do |test| output.puts("extern void #{test[:test]}(#{test[:call] || 'void'});") @@ -267,32 +269,34 @@ def create_mock_management(output, mock_headers) output.puts("}\n") end + def create_setup(output) + return if @options[:has_setup] + output.puts("\n/*=======Setup (stub)=====*/") + output.puts("void #{@options[:setup_name]}(void) {}") + end + + def create_teardown(output) + return if @options[:has_teardown] + output.puts("\n/*=======Teardown (stub)=====*/") + output.puts("void #{@options[:teardown_name]}(void) {}") + end + def create_suite_setup(output) - if @options[:has_suite_setup] - if !@options[:suite_setup].nil? - output.puts("\n/*=======Suite Setup=====*/") - output.puts('void suiteSetUp(void)') - output.puts('{') - output.puts(@options[:suite_setup]) - output.puts('}') - else - output.puts('extern void suiteSetUp(void);') - end - end + return if @options[:suite_setup].nil? + output.puts("\n/*=======Suite Setup=====*/") + output.puts('void suiteSetUp(void)') + output.puts('{') + output.puts(@options[:suite_setup]) + output.puts('}') end def create_suite_teardown(output) - if @options[:has_suite_teardown] - if !@options[:suite_teardown].nil? - output.puts("\n/*=======Suite Teardown=====*/") - output.puts('int suiteTearDown(int num_failures)') - output.puts('{') - output.puts(@options[:suite_teardown]) - output.puts('}') - else - output.puts('extern int suiteTearDown(int num_failures);') - end - end + return if @options[:suite_teardown].nil? + output.puts("\n/*=======Suite Teardown=====*/") + output.puts('int suiteTearDown(int num_failures)') + output.puts('{') + output.puts(@options[:suite_teardown]) + output.puts('}') end def create_runtest(output, used_mocks) @@ -314,13 +318,13 @@ def create_runtest(output, used_mocks) output.puts(' { \\') output.puts(' CEXCEPTION_T e; \\') if cexception output.puts(' Try { \\') if cexception - output.puts(" #{@options[:setup_name]}(); \\") if @options[:has_setup] + output.puts(" #{@options[:setup_name]}(); \\") output.puts(" TestFunc(#{va_args2}); \\") output.puts(' } Catch(e) { TEST_ASSERT_EQUAL_HEX32_MESSAGE(CEXCEPTION_NONE, e, "Unhandled Exception!"); } \\') if cexception output.puts(' } \\') output.puts(' if (TEST_PROTECT()) \\') output.puts(' { \\') - output.puts(" #{@options[:teardown_name]}(); \\") if @options[:has_teardown] + output.puts(" #{@options[:teardown_name]}(); \\") output.puts(' CMock_Verify(); \\') unless used_mocks.empty? output.puts(' } \\') output.puts(' CMock_Destroy(); \\') unless used_mocks.empty? @@ -337,9 +341,9 @@ def create_reset(output, used_mocks) output.puts('{') output.puts(' CMock_Verify();') unless used_mocks.empty? output.puts(' CMock_Destroy();') unless used_mocks.empty? - output.puts(" #{@options[:teardown_name]}();") if @options[:has_teardown] + output.puts(" #{@options[:teardown_name]}();") output.puts(' CMock_Init();') unless used_mocks.empty? - output.puts(" #{@options[:setup_name]}();") if @options[:has_setup] + output.puts(" #{@options[:setup_name]}();") output.puts('}') end From d10cf6645d24dfb782f38f4badf47c9d0426ffd3 Mon Sep 17 00:00:00 2001 From: John Lindgren Date: Tue, 22 Oct 2019 15:05:34 -0400 Subject: [PATCH 170/454] Remove unnecessary #includes. --- auto/generate_test_runner.rb | 4 ---- 1 file changed, 4 deletions(-) diff --git a/auto/generate_test_runner.rb b/auto/generate_test_runner.rb index 0d8bc94b..7484e6f2 100644 --- a/auto/generate_test_runner.rb +++ b/auto/generate_test_runner.rb @@ -190,10 +190,6 @@ def create_header(output, mocks, testfile_includes = []) output.puts("\n/*=======Automagically Detected Files To Include=====*/") output.puts("#include \"#{@options[:framework]}.h\"") output.puts('#include "cmock.h"') unless mocks.empty? - output.puts('#ifndef UNITY_EXCLUDE_SETJMP_H') - output.puts('#include ') - output.puts('#endif') - output.puts('#include ') if @options[:defines] && !@options[:defines].empty? @options[:defines].each { |d| output.puts("#ifndef #{d}\n#define #{d}\n#endif /* #{d} */") } end From 277e844beda748a68e522d66b4890c5c7a108b53 Mon Sep 17 00:00:00 2001 From: John Lindgren Date: Tue, 22 Oct 2019 15:18:20 -0400 Subject: [PATCH 171/454] Convert RUN_TEST() to a function (generated from an ERB template). Converting RUN_TEST() from a macro to a function significantly reduces the size of the compiled binary. On amd64, the largest test runner in the test suite (testsample_DefaultsThroughCommandLine_runner.o) was reduced from 3.4 kB to 2.4 kB (stripped). --- auto/generate_test_runner.rb | 108 ++++++++++-------------- auto/run_test.erb | 36 ++++++++ test/tests/test_generate_test_runner.rb | 14 +-- 3 files changed, 87 insertions(+), 71 deletions(-) create mode 100644 auto/run_test.erb diff --git a/auto/generate_test_runner.rb b/auto/generate_test_runner.rb index 7484e6f2..9016f9a5 100644 --- a/auto/generate_test_runner.rb +++ b/auto/generate_test_runner.rb @@ -89,7 +89,9 @@ def generate(input_file, output_file, tests, used_mocks, testfile_includes) create_teardown(output) create_suite_setup(output) create_suite_teardown(output) - create_reset(output, used_mocks) + create_reset(output) + create_run_test(output) + create_args_wrappers(output, tests) create_main(output, input_file, tests, used_mocks) end @@ -186,7 +188,6 @@ def find_setup_and_teardown(source) def create_header(output, mocks, testfile_includes = []) output.puts('/* AUTOGENERATED FILE. DO NOT EDIT. */') - create_runtest(output, mocks) output.puts("\n/*=======Automagically Detected Files To Include=====*/") output.puts("#include \"#{@options[:framework]}.h\"") output.puts('#include "cmock.h"') unless mocks.empty? @@ -229,8 +230,6 @@ def create_externs(output, tests, _mocks) end def create_mock_management(output, mock_headers) - return if mock_headers.empty? - output.puts("\n/*=======Mock Management=====*/") output.puts('static void CMock_Init(void)') output.puts('{') @@ -295,54 +294,39 @@ def create_suite_teardown(output) output.puts('}') end - def create_runtest(output, used_mocks) - cexception = @options[:plugins].include? :cexception - va_args1 = @options[:use_param_tests] ? ', ...' : '' - va_args2 = @options[:use_param_tests] ? '__VA_ARGS__' : '' - output.puts("\n/*=======Test Runner Used To Run Each Test Below=====*/") - output.puts('#define RUN_TEST_NO_ARGS') if @options[:use_param_tests] - output.puts("#define RUN_TEST(TestFunc, TestLineNum#{va_args1}) \\") - output.puts('{ \\') - output.puts(" Unity.CurrentTestName = #TestFunc#{va_args2.empty? ? '' : " \"(\" ##{va_args2} \")\""}; \\") - output.puts(' Unity.CurrentTestLineNumber = TestLineNum; \\') - output.puts(' if (UnityTestMatches()) { \\') if @options[:cmdline_args] - output.puts(' Unity.NumberOfTests++; \\') - output.puts(' UNITY_EXEC_TIME_START(); \\') - output.puts(' CMock_Init(); \\') unless used_mocks.empty? - output.puts(' UNITY_CLR_DETAILS(); \\') unless used_mocks.empty? - output.puts(' if (TEST_PROTECT()) \\') - output.puts(' { \\') - output.puts(' CEXCEPTION_T e; \\') if cexception - output.puts(' Try { \\') if cexception - output.puts(" #{@options[:setup_name]}(); \\") - output.puts(" TestFunc(#{va_args2}); \\") - output.puts(' } Catch(e) { TEST_ASSERT_EQUAL_HEX32_MESSAGE(CEXCEPTION_NONE, e, "Unhandled Exception!"); } \\') if cexception - output.puts(' } \\') - output.puts(' if (TEST_PROTECT()) \\') - output.puts(' { \\') - output.puts(" #{@options[:teardown_name]}(); \\") - output.puts(' CMock_Verify(); \\') unless used_mocks.empty? - output.puts(' } \\') - output.puts(' CMock_Destroy(); \\') unless used_mocks.empty? - output.puts(' UNITY_EXEC_TIME_STOP(); \\') - output.puts(' UnityConcludeTest(); \\') - output.puts(' } \\') if @options[:cmdline_args] - output.puts("}\n") - end - - def create_reset(output, used_mocks) + def create_reset(output) output.puts("\n/*=======Test Reset Option=====*/") output.puts("void #{@options[:test_reset_name]}(void);") output.puts("void #{@options[:test_reset_name]}(void)") output.puts('{') - output.puts(' CMock_Verify();') unless used_mocks.empty? - output.puts(' CMock_Destroy();') unless used_mocks.empty? output.puts(" #{@options[:teardown_name]}();") - output.puts(' CMock_Init();') unless used_mocks.empty? + output.puts(' CMock_Verify();') + output.puts(' CMock_Destroy();') + output.puts(' CMock_Init();') output.puts(" #{@options[:setup_name]}();") output.puts('}') end + def create_run_test(output) + require 'erb' + template = ERB.new(File.read(File.join(__dir__, 'run_test.erb'))) + output.puts(template.result(binding)) + end + + def create_args_wrappers(output, tests) + return unless @options[:use_param_tests] + output.puts("\n/*=======Parameterized Test Wrappers=====*/") + tests.each do |test| + next if test[:args].nil? || test[:args].empty? + test[:args].each.with_index(1) do |args, idx| + output.puts("static void runner_args#{idx}_#{test[:test]}(void)") + output.puts('{') + output.puts(" #{test[:test]}(#{args});") + output.puts("}\n") + end + end + end + def create_main(output, filename, tests, used_mocks) output.puts("\n\n/*=======MAIN=====*/") main_name = @options[:main_name].to_sym == :auto ? "main_#{filename.gsub('.c', '')}" : (@options[:main_name]).to_s @@ -359,24 +343,20 @@ def create_main(output, filename, tests, used_mocks) output.puts(' {') output.puts(" UnityPrint(\"#{filename.gsub('.c', '')}.\");") output.puts(' UNITY_PRINT_EOL();') - if @options[:use_param_tests] - tests.each do |test| - if test[:args].nil? || test[:args].empty? - output.puts(" UnityPrint(\" #{test[:test]}(RUN_TEST_NO_ARGS)\");") + tests.each do |test| + if (!@options[:use_param_tests]) || test[:args].nil? || test[:args].empty? + output.puts(" UnityPrint(\" #{test[:test]}\");") + output.puts(' UNITY_PRINT_EOL();') + else + test[:args].each do |args| + output.puts(" UnityPrint(\" #{test[:test]}(#{args})\");") output.puts(' UNITY_PRINT_EOL();') - else - test[:args].each do |args| - output.puts(" UnityPrint(\" #{test[:test]}(#{args})\");") - output.puts(' UNITY_PRINT_EOL();') - end end end - else - tests.each { |test| output.puts(" UnityPrint(\" #{test[:test]}\");\n UNITY_PRINT_EOL();") } end - output.puts(' return 0;') + output.puts(' return 0;') output.puts(' }') - output.puts(' return parse_status;') + output.puts(' return parse_status;') output.puts(' }') else if main_name != 'main' @@ -387,16 +367,16 @@ def create_main(output, filename, tests, used_mocks) end output.puts(' suiteSetUp();') if @options[:has_suite_setup] output.puts(" UnityBegin(\"#{filename.gsub(/\\/, '\\\\\\')}\");") - if @options[:use_param_tests] - tests.each do |test| - if test[:args].nil? || test[:args].empty? - output.puts(" RUN_TEST(#{test[:test]}, #{test[:line_number]}, RUN_TEST_NO_ARGS);") - else - test[:args].each { |args| output.puts(" RUN_TEST(#{test[:test]}, #{test[:line_number]}, #{args});") } + tests.each do |test| + if (!@options[:use_param_tests]) || test[:args].nil? || test[:args].empty? + output.puts(" run_test(#{test[:test]}, \"#{test[:test]}\", #{test[:line_number]});") + else + test[:args].each.with_index(1) do |args, idx| + wrapper = "runner_args#{idx}_#{test[:test]}" + testname = "#{test[:test]}(#{args})".dump + output.puts(" run_test(#{wrapper}, #{testname}, #{test[:line_number]});") end end - else - tests.each { |test| output.puts(" RUN_TEST(#{test[:test]}, #{test[:line_number]});") } end output.puts output.puts(' CMock_Guts_MemFreeFinal();') unless used_mocks.empty? diff --git a/auto/run_test.erb b/auto/run_test.erb new file mode 100644 index 00000000..3d3b6d1e --- /dev/null +++ b/auto/run_test.erb @@ -0,0 +1,36 @@ +/*=======Test Runner Used To Run Each Test=====*/ +static void run_test(UnityTestFunction func, const char* name, int line_num) +{ + Unity.CurrentTestName = name; + Unity.CurrentTestLineNumber = line_num; +#ifdef UNITY_USE_COMMAND_LINE_ARGS + if (!UnityTestMatches()) + return; +#endif + Unity.NumberOfTests++; + UNITY_CLR_DETAILS(); + UNITY_EXEC_TIME_START(); + CMock_Init(); + if (TEST_PROTECT()) + { +<% if @options[:plugins].include?(:cexception) %> + CEXCEPTION_T e; + Try { +<% end %> + <%= @options[:setup_name] %>(); + func(); +<% if @options[:plugins].include?(:cexception) %> + } Catch(e) { + TEST_ASSERT_EQUAL_HEX32_MESSAGE(CEXCEPTION_NONE, e, "Unhandled Exception!"); + } +<% end %> + } + if (TEST_PROTECT()) + { + <%= @options[:teardown_name] %>(); + CMock_Verify(); + } + CMock_Destroy(); + UNITY_EXEC_TIME_STOP(); + UnityConcludeTest(); +} diff --git a/test/tests/test_generate_test_runner.rb b/test/tests/test_generate_test_runner.rb index a3536d36..0b51bcd4 100644 --- a/test/tests/test_generate_test_runner.rb +++ b/test/tests/test_generate_test_runner.rb @@ -149,7 +149,7 @@ 'paratest_ShouldHandleParameterizedTests\(125\)', 'paratest_ShouldHandleParameterizedTests\(5\)', 'paratest_ShouldHandleParameterizedTests2\(7\)', - 'paratest_ShouldHandleNonParameterizedTestsWhenParameterizationValid\(RUN_TEST_NO_ARGS\)', + 'paratest_ShouldHandleNonParameterizedTestsWhenParameterizationValid', ], :to_fail => [ 'paratest_ShouldHandleParameterizedTestsThatFail\(17\)' ], :to_ignore => [ ], @@ -165,7 +165,7 @@ 'paratest_ShouldHandleParameterizedTests\(125\)', 'paratest_ShouldHandleParameterizedTests\(5\)', 'paratest_ShouldHandleParameterizedTests2\(7\)', - 'paratest_ShouldHandleNonParameterizedTestsWhenParameterizationValid\(RUN_TEST_NO_ARGS\)', + 'paratest_ShouldHandleNonParameterizedTestsWhenParameterizationValid', ], :to_fail => [ 'paratest_ShouldHandleParameterizedTestsThatFail\(17\)' ], :to_ignore => [ ], @@ -184,7 +184,7 @@ 'paratest_ShouldHandleParameterizedTests\(125\)', 'paratest_ShouldHandleParameterizedTests\(5\)', 'paratest_ShouldHandleParameterizedTests2\(7\)', - 'paratest_ShouldHandleNonParameterizedTestsWhenParameterizationValid\(RUN_TEST_NO_ARGS\)', + 'paratest_ShouldHandleNonParameterizedTestsWhenParameterizationValid', ], :to_fail => [ 'paratest_ShouldHandleParameterizedTestsThatFail\(17\)' ], :to_ignore => [ ], @@ -473,7 +473,7 @@ 'paratest_ShouldHandleParameterizedTests\(125\)', 'paratest_ShouldHandleParameterizedTests\(5\)', 'paratest_ShouldHandleParameterizedTests2\(7\)', - 'paratest_ShouldHandleNonParameterizedTestsWhenParameterizationValid\(RUN_TEST_NO_ARGS\)', + 'paratest_ShouldHandleNonParameterizedTestsWhenParameterizationValid', ], :to_fail => [ 'paratest_ShouldHandleParameterizedTestsThatFail\(17\)' ], :to_ignore => [ ], @@ -489,7 +489,7 @@ 'paratest_ShouldHandleParameterizedTests\(125\)', 'paratest_ShouldHandleParameterizedTests\(5\)', 'paratest_ShouldHandleParameterizedTests2\(7\)', - 'paratest_ShouldHandleNonParameterizedTestsWhenParameterizationValid\(RUN_TEST_NO_ARGS\)', + 'paratest_ShouldHandleNonParameterizedTestsWhenParameterizationValid', ], :to_fail => [ 'paratest_ShouldHandleParameterizedTestsThatFail\(17\)' ], :to_ignore => [ ], @@ -508,7 +508,7 @@ 'paratest_ShouldHandleParameterizedTests\(125\)', 'paratest_ShouldHandleParameterizedTests\(5\)', 'paratest_ShouldHandleParameterizedTests2\(7\)', - 'paratest_ShouldHandleNonParameterizedTestsWhenParameterizationValid\(RUN_TEST_NO_ARGS\)', + 'paratest_ShouldHandleNonParameterizedTestsWhenParameterizationValid', ], :to_fail => [ 'paratest_ShouldHandleParameterizedTestsThatFail\(17\)' ], :to_ignore => [ ], @@ -1099,7 +1099,7 @@ 'paratest_ShouldHandleParameterizedTests\(125\)', 'paratest_ShouldHandleParameterizedTests\(5\)', 'paratest_ShouldHandleParameterizedTests2\(7\)', - 'paratest_ShouldHandleNonParameterizedTestsWhenParameterizationValid\(RUN_TEST_NO_ARGS\)', + 'paratest_ShouldHandleNonParameterizedTestsWhenParameterizationValid', 'paratest_ShouldHandleParameterizedTestsThatFail\(17\)' ], } From eb0bd42f0d3bf968107d8f24e2c50d14979c1b72 Mon Sep 17 00:00:00 2001 From: mvandervoord Date: Thu, 24 Oct 2019 15:33:41 -0400 Subject: [PATCH 172/454] Updated to newer coding standard --- auto/colour_prompt.rb | 1 + auto/generate_module.rb | 2 + auto/generate_test_runner.rb | 21 +- auto/parse_output.rb | 6 +- auto/stylize_as_junit.rb | 3 + auto/unity_test_summary.rb | 3 + examples/example_3/rakefile.rb | 2 - examples/example_3/rakefile_helper.rb | 415 +++++++++++++------------- extras/fixture/rakefile.rb | 2 - extras/fixture/rakefile_helper.rb | 325 ++++++++++---------- test/.rubocop.yml | 12 +- 11 files changed, 410 insertions(+), 382 deletions(-) diff --git a/auto/colour_prompt.rb b/auto/colour_prompt.rb index bf09d028..85cbfd80 100644 --- a/auto/colour_prompt.rb +++ b/auto/colour_prompt.rb @@ -22,6 +22,7 @@ class ColourCommandLine def initialize return unless RUBY_PLATFORM =~ /(win|w)32$/ + get_std_handle = Win32API.new('kernel32', 'GetStdHandle', ['L'], 'L') @set_console_txt_attrb = Win32API.new('kernel32', 'SetConsoleTextAttribute', %w[L N], 'I') diff --git a/auto/generate_module.rb b/auto/generate_module.rb index def5d088..eb2cebd4 100644 --- a/auto/generate_module.rb +++ b/auto/generate_module.rb @@ -264,6 +264,7 @@ def destroy(module_name, pattern = nil) when /^-y\"?(.+)\"?/ then options = UnityModuleGenerator.grab_config(Regexp.last_match(1)) when /^(\w+)/ raise "ERROR: You can't have more than one Module name specified!" unless module_name.nil? + module_name = arg when /^-(h|-help)/ ARGV = [].freeze @@ -298,6 +299,7 @@ def destroy(module_name, pattern = nil) end raise 'ERROR: You must have a Module name specified! (use option -h for help)' if module_name.nil? + if destroy UnityModuleGenerator.new(options).destroy(module_name) else diff --git a/auto/generate_test_runner.rb b/auto/generate_test_runner.rb index 9016f9a5..ea75f4c8 100644 --- a/auto/generate_test_runner.rb +++ b/auto/generate_test_runner.rb @@ -61,11 +61,11 @@ def run(input_file, output_file, options = nil) # pull required data from source file source = File.read(input_file) source = source.force_encoding('ISO-8859-1').encode('utf-8', replace: nil) - tests = find_tests(source) - headers = find_includes(source) - testfile_includes = (headers[:local] + headers[:system]) - used_mocks = find_mocks(testfile_includes) - testfile_includes = (testfile_includes - used_mocks) + tests = find_tests(source) + headers = find_includes(source) + testfile_includes = (headers[:local] + headers[:system]) + used_mocks = find_mocks(testfile_includes) + testfile_includes = (testfile_includes - used_mocks) testfile_includes.delete_if { |inc| inc =~ /(unity|cmock)/ } find_setup_and_teardown(source) @@ -127,17 +127,21 @@ def find_tests(source) lines.each_with_index do |line, _index| # find tests next unless line =~ /^((?:\s*TEST_CASE\s*\(.*?\)\s*)*)\s*void\s+((?:#{@options[:test_prefix]}).*)\s*\(\s*(.*)\s*\)/m + arguments = Regexp.last_match(1) name = Regexp.last_match(2) call = Regexp.last_match(3) params = Regexp.last_match(4) args = nil + if @options[:use_param_tests] && !arguments.empty? args = [] arguments.scan(/\s*TEST_CASE\s*\((.*)\)\s*$/) { |a| args << a[0] } end + tests_and_line_numbers << { test: name, args: args, call: call, params: params, line_number: 0 } end + tests_and_line_numbers.uniq! { |v| v[:test] } # determine line numbers and create tests to run @@ -146,6 +150,7 @@ def find_tests(source) tests_and_line_numbers.size.times do |i| source_lines[source_index..-1].each_with_index do |line, index| next unless line =~ /\s+#{tests_and_line_numbers[i][:test]}(?:\s|\()/ + source_index += index tests_and_line_numbers[i][:line_number] = source_index + 1 break @@ -266,18 +271,21 @@ def create_mock_management(output, mock_headers) def create_setup(output) return if @options[:has_setup] + output.puts("\n/*=======Setup (stub)=====*/") output.puts("void #{@options[:setup_name]}(void) {}") end def create_teardown(output) return if @options[:has_teardown] + output.puts("\n/*=======Teardown (stub)=====*/") output.puts("void #{@options[:teardown_name]}(void) {}") end def create_suite_setup(output) return if @options[:suite_setup].nil? + output.puts("\n/*=======Suite Setup=====*/") output.puts('void suiteSetUp(void)') output.puts('{') @@ -287,6 +295,7 @@ def create_suite_setup(output) def create_suite_teardown(output) return if @options[:suite_teardown].nil? + output.puts("\n/*=======Suite Teardown=====*/") output.puts('int suiteTearDown(int num_failures)') output.puts('{') @@ -315,9 +324,11 @@ def create_run_test(output) def create_args_wrappers(output, tests) return unless @options[:use_param_tests] + output.puts("\n/*=======Parameterized Test Wrappers=====*/") tests.each do |test| next if test[:args].nil? || test[:args].empty? + test[:args].each.with_index(1) do |args, idx| output.puts("static void runner_args#{idx}_#{test[:test]}(void)") output.puts('{') diff --git a/auto/parse_output.rb b/auto/parse_output.rb index fa07b7db..d72c6e8b 100644 --- a/auto/parse_output.rb +++ b/auto/parse_output.rb @@ -34,9 +34,9 @@ def initialize # current suite name and statistics @test_suite = nil - @total_tests = 0 - @test_passed = 0 - @test_failed = 0 + @total_tests = 0 + @test_passed = 0 + @test_failed = 0 @test_ignored = 0 end diff --git a/auto/stylize_as_junit.rb b/auto/stylize_as_junit.rb index a53f85f7..e01f7912 100755 --- a/auto/stylize_as_junit.rb +++ b/auto/stylize_as_junit.rb @@ -152,6 +152,7 @@ def get_details(_result_file, lines) def parse_test_summary(summary) raise "Couldn't parse test results: #{summary}" unless summary.find { |v| v =~ /(\d+) Tests (\d+) Failures (\d+) Ignored/ } + [Regexp.last_match(1).to_i, Regexp.last_match(2).to_i, Regexp.last_match(3).to_i] end @@ -230,7 +231,9 @@ def write_suites_footer(stream) targets = "#{options.results_dir.tr('\\', '/')}**/*.test*" results = Dir[targets] + raise "No *.testpass, *.testfail, or *.testresults files found in '#{targets}'" if results.empty? + utj.targets = results # set the root path diff --git a/auto/unity_test_summary.rb b/auto/unity_test_summary.rb index 810fdbd1..b3fe8a69 100644 --- a/auto/unity_test_summary.rb +++ b/auto/unity_test_summary.rb @@ -99,6 +99,7 @@ def get_details(_result_file, lines) def parse_test_summary(summary) raise "Couldn't parse test results: #{summary}" unless summary.find { |v| v =~ /(\d+) Tests (\d+) Failures (\d+) Ignored/ } + [Regexp.last_match(1).to_i, Regexp.last_match(2).to_i, Regexp.last_match(3).to_i] end end @@ -117,7 +118,9 @@ def parse_test_summary(summary) args[0] ||= './' targets = "#{ARGV[0].tr('\\', '/')}**/*.test*" results = Dir[targets] + raise "No *.testpass, *.testfail, or *.testresults files found in '#{targets}'" if results.empty? + uts.targets = results # set the root path diff --git a/examples/example_3/rakefile.rb b/examples/example_3/rakefile.rb index d0149299..c095af38 100644 --- a/examples/example_3/rakefile.rb +++ b/examples/example_3/rakefile.rb @@ -13,8 +13,6 @@ task prepare_for_tests: TEMP_DIRS -include RakefileHelpers - # Load default configuration, for now DEFAULT_CONFIG_FILE = 'target_gcc_32.yml'.freeze configure_toolchain(DEFAULT_CONFIG_FILE) diff --git a/examples/example_3/rakefile_helper.rb b/examples/example_3/rakefile_helper.rb index 0e249b79..64d20c95 100644 --- a/examples/example_3/rakefile_helper.rb +++ b/examples/example_3/rakefile_helper.rb @@ -4,246 +4,247 @@ require_relative '../../auto/generate_test_runner' require_relative '../../auto/colour_reporter' -module RakefileHelpers - C_EXTENSION = '.c'.freeze +C_EXTENSION = '.c'.freeze - def load_configuration(config_file) - $cfg_file = config_file - $cfg = YAML.load(File.read($cfg_file)) - end +def load_configuration(config_file) + $cfg_file = config_file + $cfg = YAML.load(File.read($cfg_file)) +end - def configure_clean - CLEAN.include($cfg['compiler']['build_path'] + '*.*') unless $cfg['compiler']['build_path'].nil? - end +def configure_clean + CLEAN.include($cfg['compiler']['build_path'] + '*.*') unless $cfg['compiler']['build_path'].nil? +end - def configure_toolchain(config_file = DEFAULT_CONFIG_FILE) - config_file += '.yml' unless config_file =~ /\.yml$/ - load_configuration(config_file) - configure_clean - end +def configure_toolchain(config_file = DEFAULT_CONFIG_FILE) + config_file += '.yml' unless config_file =~ /\.yml$/ + load_configuration(config_file) + configure_clean +end - def unit_test_files - path = $cfg['compiler']['unit_tests_path'] + 'Test*' + C_EXTENSION - path.tr!('\\', '/') - FileList.new(path) - end +def unit_test_files + path = $cfg['compiler']['unit_tests_path'] + 'Test*' + C_EXTENSION + path.tr!('\\', '/') + FileList.new(path) +end - def local_include_dirs - include_dirs = $cfg['compiler']['includes']['items'].dup - include_dirs.delete_if { |dir| dir.is_a?(Array) } - include_dirs - end +def local_include_dirs + include_dirs = $cfg['compiler']['includes']['items'].dup + include_dirs.delete_if { |dir| dir.is_a?(Array) } + include_dirs +end - def extract_headers(filename) - includes = [] - lines = File.readlines(filename) - lines.each do |line| - m = line.match(/^\s*#include\s+\"\s*(.+\.[hH])\s*\"/) - includes << m[1] unless m.nil? - end - includes +def extract_headers(filename) + includes = [] + lines = File.readlines(filename) + lines.each do |line| + m = line.match(/^\s*#include\s+\"\s*(.+\.[hH])\s*\"/) + includes << m[1] unless m.nil? end + includes +end - def find_source_file(header, paths) - paths.each do |dir| - src_file = dir + header.ext(C_EXTENSION) - return src_file if File.exist?(src_file) - end - nil +def find_source_file(header, paths) + paths.each do |dir| + src_file = dir + header.ext(C_EXTENSION) + return src_file if File.exist?(src_file) end + nil +end + +def tackit(strings) + result = if strings.is_a?(Array) + "\"#{strings.join}\"" + else + strings + end + result +end - def tackit(strings) - result = if strings.is_a?(Array) - "\"#{strings.join}\"" +def squash(prefix, items) + result = '' + items.each { |item| result += " #{prefix}#{tackit(item)}" } + result +end + +def build_compiler_fields + command = tackit($cfg['compiler']['path']) + defines = if $cfg['compiler']['defines']['items'].nil? + '' + else + squash($cfg['compiler']['defines']['prefix'], $cfg['compiler']['defines']['items']) + end + options = squash('', $cfg['compiler']['options']) + includes = squash($cfg['compiler']['includes']['prefix'], $cfg['compiler']['includes']['items']) + includes = includes.gsub(/\\ /, ' ').gsub(/\\\"/, '"').gsub(/\\$/, '') # Remove trailing slashes (for IAR) + + { command: command, defines: defines, options: options, includes: includes } +end + +def compile(file, _defines = []) + compiler = build_compiler_fields + cmd_str = "#{compiler[:command]}#{compiler[:defines]}#{compiler[:options]}#{compiler[:includes]} #{file} " \ + "#{$cfg['compiler']['object_files']['prefix']}#{$cfg['compiler']['object_files']['destination']}" + obj_file = "#{File.basename(file, C_EXTENSION)}#{$cfg['compiler']['object_files']['extension']}" + execute(cmd_str + obj_file) + obj_file +end + +def build_linker_fields + command = tackit($cfg['linker']['path']) + options = if $cfg['linker']['options'].nil? + '' + else + squash('', $cfg['linker']['options']) + end + includes = if $cfg['linker']['includes'].nil? || $cfg['linker']['includes']['items'].nil? + '' else - strings - end - result - end + squash($cfg['linker']['includes']['prefix'], $cfg['linker']['includes']['items']) + end.gsub(/\\ /, ' ').gsub(/\\\"/, '"').gsub(/\\$/, '') # Remove trailing slashes (for IAR) - def squash(prefix, items) - result = '' - items.each { |item| result += " #{prefix}#{tackit(item)}" } - result - end + { command: command, options: options, includes: includes } +end - def build_compiler_fields - command = tackit($cfg['compiler']['path']) - defines = if $cfg['compiler']['defines']['items'].nil? - '' - else - squash($cfg['compiler']['defines']['prefix'], $cfg['compiler']['defines']['items']) - end - options = squash('', $cfg['compiler']['options']) - includes = squash($cfg['compiler']['includes']['prefix'], $cfg['compiler']['includes']['items']) - includes = includes.gsub(/\\ /, ' ').gsub(/\\\"/, '"').gsub(/\\$/, '') # Remove trailing slashes (for IAR) +def link_it(exe_name, obj_list) + linker = build_linker_fields + cmd_str = "#{linker[:command]}#{linker[:options]}#{linker[:includes]} " + + (obj_list.map { |obj| "#{$cfg['linker']['object_files']['path']}#{obj} " }).join + + $cfg['linker']['bin_files']['prefix'] + ' ' + + $cfg['linker']['bin_files']['destination'] + + exe_name + $cfg['linker']['bin_files']['extension'] + execute(cmd_str) +end - { command: command, defines: defines, options: options, includes: includes } - end +def build_simulator_fields + return nil if $cfg['simulator'].nil? - def compile(file, _defines = []) - compiler = build_compiler_fields - cmd_str = "#{compiler[:command]}#{compiler[:defines]}#{compiler[:options]}#{compiler[:includes]} #{file} " \ - "#{$cfg['compiler']['object_files']['prefix']}#{$cfg['compiler']['object_files']['destination']}" - obj_file = "#{File.basename(file, C_EXTENSION)}#{$cfg['compiler']['object_files']['extension']}" - execute(cmd_str + obj_file) - obj_file - end + command = if $cfg['simulator']['path'].nil? + '' + else + (tackit($cfg['simulator']['path']) + ' ') + end + pre_support = if $cfg['simulator']['pre_support'].nil? + '' + else + squash('', $cfg['simulator']['pre_support']) + end + post_support = if $cfg['simulator']['post_support'].nil? + '' + else + squash('', $cfg['simulator']['post_support']) + end - def build_linker_fields - command = tackit($cfg['linker']['path']) - options = if $cfg['linker']['options'].nil? - '' - else - squash('', $cfg['linker']['options']) - end - includes = if $cfg['linker']['includes'].nil? || $cfg['linker']['includes']['items'].nil? - '' - else - squash($cfg['linker']['includes']['prefix'], $cfg['linker']['includes']['items']) - end.gsub(/\\ /, ' ').gsub(/\\\"/, '"').gsub(/\\$/, '') # Remove trailing slashes (for IAR) + { command: command, pre_support: pre_support, post_support: post_support } +end - { command: command, options: options, includes: includes } - end +def execute(command_string, verbose = true, raise_on_fail = true) + report command_string + output = `#{command_string}`.chomp + report(output) if verbose && !output.nil? && !output.empty? - def link_it(exe_name, obj_list) - linker = build_linker_fields - cmd_str = "#{linker[:command]}#{linker[:options]}#{linker[:includes]} " + - (obj_list.map { |obj| "#{$cfg['linker']['object_files']['path']}#{obj} " }).join + - $cfg['linker']['bin_files']['prefix'] + ' ' + - $cfg['linker']['bin_files']['destination'] + - exe_name + $cfg['linker']['bin_files']['extension'] - execute(cmd_str) + if !$?.nil? && !$?.exitstatus.zero? && raise_on_fail + raise "Command failed. (Returned #{$?.exitstatus})" end - def build_simulator_fields - return nil if $cfg['simulator'].nil? - command = if $cfg['simulator']['path'].nil? - '' - else - (tackit($cfg['simulator']['path']) + ' ') - end - pre_support = if $cfg['simulator']['pre_support'].nil? - '' - else - squash('', $cfg['simulator']['pre_support']) - end - post_support = if $cfg['simulator']['post_support'].nil? - '' - else - squash('', $cfg['simulator']['post_support']) - end - - { command: command, pre_support: pre_support, post_support: post_support } - end + output +end - def execute(command_string, verbose = true, raise_on_fail = true) - report command_string - output = `#{command_string}`.chomp - report(output) if verbose && !output.nil? && !output.empty? - if !$?.nil? && !$?.exitstatus.zero? && raise_on_fail - raise "Command failed. (Returned #{$?.exitstatus})" - end - output - end +def report_summary + summary = UnityTestSummary.new + summary.root = __dir__ + results_glob = "#{$cfg['compiler']['build_path']}*.test*" + results_glob.tr!('\\', '/') + results = Dir[results_glob] + summary.targets = results + summary.run + fail_out 'FAIL: There were failures' if summary.failures > 0 +end - def report_summary - summary = UnityTestSummary.new - summary.root = __dir__ - results_glob = "#{$cfg['compiler']['build_path']}*.test*" - results_glob.tr!('\\', '/') - results = Dir[results_glob] - summary.targets = results - summary.run - fail_out 'FAIL: There were failures' if summary.failures > 0 - end +def run_tests(test_files) + report 'Running system tests...' - def run_tests(test_files) - report 'Running system tests...' - - # Tack on TEST define for compiling unit tests - load_configuration($cfg_file) - test_defines = ['TEST'] - $cfg['compiler']['defines']['items'] = [] if $cfg['compiler']['defines']['items'].nil? - $cfg['compiler']['defines']['items'] << 'TEST' - - include_dirs = local_include_dirs - - # Build and execute each unit test - test_files.each do |test| - obj_list = [] - - # Detect dependencies and build required required modules - extract_headers(test).each do |header| - # Compile corresponding source file if it exists - src_file = find_source_file(header, include_dirs) - obj_list << compile(src_file, test_defines) unless src_file.nil? - end - - # Build the test runner (generate if configured to do so) - test_base = File.basename(test, C_EXTENSION) - runner_name = test_base + '_Runner.c' - if $cfg['compiler']['runner_path'].nil? - runner_path = $cfg['compiler']['build_path'] + runner_name - test_gen = UnityTestRunnerGenerator.new($cfg_file) - test_gen.run(test, runner_path) - else - runner_path = $cfg['compiler']['runner_path'] + runner_name - end - - obj_list << compile(runner_path, test_defines) - - # Build the test module - obj_list << compile(test, test_defines) - - # Link the test executable - link_it(test_base, obj_list) - - # Execute unit test and generate results file - simulator = build_simulator_fields - executable = $cfg['linker']['bin_files']['destination'] + test_base + $cfg['linker']['bin_files']['extension'] - cmd_str = if simulator.nil? - executable - else - "#{simulator[:command]} #{simulator[:pre_support]} #{executable} #{simulator[:post_support]}" - end - output = execute(cmd_str, true, false) - test_results = $cfg['compiler']['build_path'] + test_base - test_results += if output.match(/OK$/m).nil? - '.testfail' - else - '.testpass' - end - File.open(test_results, 'w') { |f| f.print output } - end - end + # Tack on TEST define for compiling unit tests + load_configuration($cfg_file) + test_defines = ['TEST'] + $cfg['compiler']['defines']['items'] = [] if $cfg['compiler']['defines']['items'].nil? + $cfg['compiler']['defines']['items'] << 'TEST' - def build_application(main) - report 'Building application...' + include_dirs = local_include_dirs + # Build and execute each unit test + test_files.each do |test| obj_list = [] - load_configuration($cfg_file) - main_path = $cfg['compiler']['source_path'] + main + C_EXTENSION # Detect dependencies and build required required modules - include_dirs = get_local_include_dirs - extract_headers(main_path).each do |header| + extract_headers(test).each do |header| + # Compile corresponding source file if it exists src_file = find_source_file(header, include_dirs) - obj_list << compile(src_file) unless src_file.nil? + obj_list << compile(src_file, test_defines) unless src_file.nil? + end + + # Build the test runner (generate if configured to do so) + test_base = File.basename(test, C_EXTENSION) + runner_name = test_base + '_Runner.c' + if $cfg['compiler']['runner_path'].nil? + runner_path = $cfg['compiler']['build_path'] + runner_name + test_gen = UnityTestRunnerGenerator.new($cfg_file) + test_gen.run(test, runner_path) + else + runner_path = $cfg['compiler']['runner_path'] + runner_name end - # Build the main source file - main_base = File.basename(main_path, C_EXTENSION) - obj_list << compile(main_path) + obj_list << compile(runner_path, test_defines) - # Create the executable - link_it(main_base, obj_list) + # Build the test module + obj_list << compile(test, test_defines) + + # Link the test executable + link_it(test_base, obj_list) + + # Execute unit test and generate results file + simulator = build_simulator_fields + executable = $cfg['linker']['bin_files']['destination'] + test_base + $cfg['linker']['bin_files']['extension'] + cmd_str = if simulator.nil? + executable + else + "#{simulator[:command]} #{simulator[:pre_support]} #{executable} #{simulator[:post_support]}" + end + output = execute(cmd_str, true, false) + test_results = $cfg['compiler']['build_path'] + test_base + test_results += if output.match(/OK$/m).nil? + '.testfail' + else + '.testpass' + end + File.open(test_results, 'w') { |f| f.print output } end +end + +def build_application(main) + report 'Building application...' - def fail_out(msg) - puts msg - puts 'Not returning exit code so continuous integration can pass' - # exit(-1) # Only removed to pass example_3, which has failing tests on purpose. - # Still fail if the build fails for any other reason. + obj_list = [] + load_configuration($cfg_file) + main_path = $cfg['compiler']['source_path'] + main + C_EXTENSION + + # Detect dependencies and build required required modules + include_dirs = get_local_include_dirs + extract_headers(main_path).each do |header| + src_file = find_source_file(header, include_dirs) + obj_list << compile(src_file) unless src_file.nil? end + + # Build the main source file + main_base = File.basename(main_path, C_EXTENSION) + obj_list << compile(main_path) + + # Create the executable + link_it(main_base, obj_list) +end + +def fail_out(msg) + puts msg + puts 'Not returning exit code so continuous integration can pass' + # exit(-1) # Only removed to pass example_3, which has failing tests on purpose. + # Still fail if the build fails for any other reason. end diff --git a/extras/fixture/rakefile.rb b/extras/fixture/rakefile.rb index 8b5319c5..f7465601 100644 --- a/extras/fixture/rakefile.rb +++ b/extras/fixture/rakefile.rb @@ -20,8 +20,6 @@ task prepare_for_tests: TEMP_DIRS -include RakefileHelpers - # Load default configuration, for now DEFAULT_CONFIG_FILE = 'gcc_auto_stdint.yml'.freeze configure_toolchain(DEFAULT_CONFIG_FILE) diff --git a/extras/fixture/rakefile_helper.rb b/extras/fixture/rakefile_helper.rb index 71e752b9..8bdb09d9 100644 --- a/extras/fixture/rakefile_helper.rb +++ b/extras/fixture/rakefile_helper.rb @@ -10,169 +10,170 @@ require_relative '../../auto/generate_test_runner' require_relative '../../auto/colour_reporter' -module RakefileHelpers - C_EXTENSION = '.c'.freeze - - def load_configuration(config_file) - return if $configured - - $cfg_file = "#{__dir__}/../../test/targets/#{config_file}" unless config_file =~ /[\\|\/]/ - $cfg = YAML.load(File.read($cfg_file)) - $colour_output = false unless $cfg['colour'] - $configured = true if config_file != DEFAULT_CONFIG_FILE - end - - def configure_clean - CLEAN.include($cfg['compiler']['build_path'] + '*.*') unless $cfg['compiler']['build_path'].nil? - end - - def configure_toolchain(config_file = DEFAULT_CONFIG_FILE) - config_file += '.yml' unless config_file =~ /\.yml$/ - config_file = config_file unless config_file =~ /[\\|\/]/ - load_configuration(config_file) - configure_clean - end - - def tackit(strings) - result = if strings.is_a?(Array) - "\"#{strings.join}\"" +C_EXTENSION = '.c'.freeze + +def load_configuration(config_file) + return if $configured + + $cfg_file = "#{__dir__}/../../test/targets/#{config_file}" unless config_file =~ /[\\|\/]/ + $cfg = YAML.load(File.read($cfg_file)) + $colour_output = false unless $cfg['colour'] + $configured = true if config_file != DEFAULT_CONFIG_FILE +end + +def configure_clean + CLEAN.include($cfg['compiler']['build_path'] + '*.*') unless $cfg['compiler']['build_path'].nil? +end + +def configure_toolchain(config_file = DEFAULT_CONFIG_FILE) + config_file += '.yml' unless config_file =~ /\.yml$/ + config_file = config_file unless config_file =~ /[\\|\/]/ + load_configuration(config_file) + configure_clean +end + +def tackit(strings) + result = if strings.is_a?(Array) + "\"#{strings.join}\"" + else + strings + end + result +end + +def squash(prefix, items) + result = '' + items.each { |item| result += " #{prefix}#{tackit(item)}" } + result +end + +def build_compiler_fields + command = tackit($cfg['compiler']['path']) + defines = if $cfg['compiler']['defines']['items'].nil? + '' + else + squash($cfg['compiler']['defines']['prefix'], $cfg['compiler']['defines']['items'] + ['UNITY_OUTPUT_CHAR=UnityOutputCharSpy_OutputChar'] + ['UNITY_OUTPUT_CHAR_HEADER_DECLARATION=UnityOutputCharSpy_OutputChar\(int\)']) + end + options = squash('', $cfg['compiler']['options']) + includes = squash($cfg['compiler']['includes']['prefix'], $cfg['compiler']['includes']['items']) + includes = includes.gsub(/\\ /, ' ').gsub(/\\\"/, '"').gsub(/\\$/, '') # Remove trailing slashes (for IAR) + + { command: command, defines: defines, options: options, includes: includes } +end + +def compile(file, _defines = []) + compiler = build_compiler_fields + unity_include = $cfg['compiler']['includes']['prefix'] + '../../src' + cmd_str = "#{compiler[:command]}#{compiler[:defines]}#{compiler[:options]}#{compiler[:includes]} #{unity_include} #{file} " \ + "#{$cfg['compiler']['object_files']['prefix']}#{$cfg['compiler']['object_files']['destination']}" \ + "#{File.basename(file, C_EXTENSION)}#{$cfg['compiler']['object_files']['extension']}" + + execute(cmd_str) +end + +def build_linker_fields + command = tackit($cfg['linker']['path']) + options = if $cfg['linker']['options'].nil? + '' + else + squash('', $cfg['linker']['options']) + end + includes = if $cfg['linker']['includes'].nil? || $cfg['linker']['includes']['items'].nil? + '' else - strings - end - result - end - - def squash(prefix, items) - result = '' - items.each { |item| result += " #{prefix}#{tackit(item)}" } - result - end - - def build_compiler_fields - command = tackit($cfg['compiler']['path']) - defines = if $cfg['compiler']['defines']['items'].nil? - '' - else - squash($cfg['compiler']['defines']['prefix'], $cfg['compiler']['defines']['items'] + ['UNITY_OUTPUT_CHAR=UnityOutputCharSpy_OutputChar'] + ['UNITY_OUTPUT_CHAR_HEADER_DECLARATION=UnityOutputCharSpy_OutputChar\(int\)']) - end - options = squash('', $cfg['compiler']['options']) - includes = squash($cfg['compiler']['includes']['prefix'], $cfg['compiler']['includes']['items']) - includes = includes.gsub(/\\ /, ' ').gsub(/\\\"/, '"').gsub(/\\$/, '') # Remove trailing slashes (for IAR) - - { command: command, defines: defines, options: options, includes: includes } - end - - def compile(file, _defines = []) - compiler = build_compiler_fields - unity_include = $cfg['compiler']['includes']['prefix'] + '../../src' - cmd_str = "#{compiler[:command]}#{compiler[:defines]}#{compiler[:options]}#{compiler[:includes]} #{unity_include} #{file} " \ - "#{$cfg['compiler']['object_files']['prefix']}#{$cfg['compiler']['object_files']['destination']}" \ - "#{File.basename(file, C_EXTENSION)}#{$cfg['compiler']['object_files']['extension']}" - - execute(cmd_str) - end - - def build_linker_fields - command = tackit($cfg['linker']['path']) - options = if $cfg['linker']['options'].nil? - '' - else - squash('', $cfg['linker']['options']) - end - includes = if $cfg['linker']['includes'].nil? || $cfg['linker']['includes']['items'].nil? - '' - else - squash($cfg['linker']['includes']['prefix'], $cfg['linker']['includes']['items']) - end.gsub(/\\ /, ' ').gsub(/\\\"/, '"').gsub(/\\$/, '') # Remove trailing slashes (for IAR) - - { command: command, options: options, includes: includes } - end - - def link_it(exe_name, obj_list) - linker = build_linker_fields - cmd_str = "#{linker[:command]}#{linker[:options]}#{linker[:includes]} " + - (obj_list.map { |obj| "#{$cfg['linker']['object_files']['path']}#{obj} " }).join + - $cfg['linker']['bin_files']['prefix'] + ' ' + - $cfg['linker']['bin_files']['destination'] + - exe_name + $cfg['linker']['bin_files']['extension'] - execute(cmd_str) - end - - def build_simulator_fields - return nil if $cfg['simulator'].nil? - command = if $cfg['simulator']['path'].nil? - '' - else - (tackit($cfg['simulator']['path']) + ' ') - end - pre_support = if $cfg['simulator']['pre_support'].nil? - '' + squash($cfg['linker']['includes']['prefix'], $cfg['linker']['includes']['items']) + end.gsub(/\\ /, ' ').gsub(/\\\"/, '"').gsub(/\\$/, '') # Remove trailing slashes (for IAR) + + { command: command, options: options, includes: includes } +end + +def link_it(exe_name, obj_list) + linker = build_linker_fields + cmd_str = "#{linker[:command]}#{linker[:options]}#{linker[:includes]} " + + (obj_list.map { |obj| "#{$cfg['linker']['object_files']['path']}#{obj} " }).join + + $cfg['linker']['bin_files']['prefix'] + ' ' + + $cfg['linker']['bin_files']['destination'] + + exe_name + $cfg['linker']['bin_files']['extension'] + execute(cmd_str) +end + +def build_simulator_fields + return nil if $cfg['simulator'].nil? + + command = if $cfg['simulator']['path'].nil? + '' + else + (tackit($cfg['simulator']['path']) + ' ') + end + pre_support = if $cfg['simulator']['pre_support'].nil? + '' + else + squash('', $cfg['simulator']['pre_support']) + end + post_support = if $cfg['simulator']['post_support'].nil? + '' + else + squash('', $cfg['simulator']['post_support']) + end + { command: command, pre_support: pre_support, post_support: post_support } +end + +def execute(command_string, verbose = true) + report command_string + output = `#{command_string}`.chomp + report(output) if verbose && !output.nil? && !output.empty? + + raise "Command failed. (Returned #{$?.exitstatus})" if $?.exitstatus != 0 + + output +end + +def report_summary + summary = UnityTestSummary.new + summary.root = __dir__ + results_glob = "#{$cfg['compiler']['build_path']}*.test*" + results_glob.tr!('\\', '/') + results = Dir[results_glob] + summary.targets = results + summary.run +end + +def run_tests + report 'Running Unity system tests...' + + # Tack on TEST define for compiling unit tests + load_configuration($cfg_file) + test_defines = ['TEST'] + $cfg['compiler']['defines']['items'] = [] if $cfg['compiler']['defines']['items'].nil? + + # Get a list of all source files needed + src_files = Dir["#{__dir__}/src/*.c"] + src_files += Dir["#{__dir__}/test/*.c"] + src_files += Dir["#{__dir__}/test/main/*.c"] + src_files << '../../src/unity.c' + + # Build object files + src_files.each { |f| compile(f, test_defines) } + obj_list = src_files.map { |f| File.basename(f.ext($cfg['compiler']['object_files']['extension'])) } + + # Link the test executable + test_base = 'framework_test' + link_it(test_base, obj_list) + + # Execute unit test and generate results file + simulator = build_simulator_fields + executable = $cfg['linker']['bin_files']['destination'] + test_base + $cfg['linker']['bin_files']['extension'] + cmd_str = if simulator.nil? + executable + ' -v -r' + else + "#{simulator[:command]} #{simulator[:pre_support]} #{executable} #{simulator[:post_support]}" + end + output = execute(cmd_str) + test_results = $cfg['compiler']['build_path'] + test_base + test_results += if output.match(/OK$/m).nil? + '.testfail' else - squash('', $cfg['simulator']['pre_support']) + '.testpass' end - post_support = if $cfg['simulator']['post_support'].nil? - '' - else - squash('', $cfg['simulator']['post_support']) - end - { command: command, pre_support: pre_support, post_support: post_support } - end - - def execute(command_string, verbose = true) - report command_string - output = `#{command_string}`.chomp - report(output) if verbose && !output.nil? && !output.empty? - raise "Command failed. (Returned #{$?.exitstatus})" if $?.exitstatus != 0 - output - end - - def report_summary - summary = UnityTestSummary.new - summary.root = __dir__ - results_glob = "#{$cfg['compiler']['build_path']}*.test*" - results_glob.tr!('\\', '/') - results = Dir[results_glob] - summary.targets = results - summary.run - end - - def run_tests - report 'Running Unity system tests...' - - # Tack on TEST define for compiling unit tests - load_configuration($cfg_file) - test_defines = ['TEST'] - $cfg['compiler']['defines']['items'] = [] if $cfg['compiler']['defines']['items'].nil? - - # Get a list of all source files needed - src_files = Dir["#{__dir__}/src/*.c"] - src_files += Dir["#{__dir__}/test/*.c"] - src_files += Dir["#{__dir__}/test/main/*.c"] - src_files << '../../src/unity.c' - - # Build object files - src_files.each { |f| compile(f, test_defines) } - obj_list = src_files.map { |f| File.basename(f.ext($cfg['compiler']['object_files']['extension'])) } - - # Link the test executable - test_base = 'framework_test' - link_it(test_base, obj_list) - - # Execute unit test and generate results file - simulator = build_simulator_fields - executable = $cfg['linker']['bin_files']['destination'] + test_base + $cfg['linker']['bin_files']['extension'] - cmd_str = if simulator.nil? - executable + ' -v -r' - else - "#{simulator[:command]} #{simulator[:pre_support]} #{executable} #{simulator[:post_support]}" - end - output = execute(cmd_str) - test_results = $cfg['compiler']['build_path'] + test_base - test_results += if output.match(/OK$/m).nil? - '.testfail' - else - '.testpass' - end - File.open(test_results, 'w') { |f| f.print output } - end + File.open(test_results, 'w') { |f| f.print output } end diff --git a/test/.rubocop.yml b/test/.rubocop.yml index 3bfe31a9..7c130767 100644 --- a/test/.rubocop.yml +++ b/test/.rubocop.yml @@ -3,7 +3,7 @@ #inherit_from: .rubocop_todo.yml AllCops: - TargetRubyVersion: 2.1 + TargetRubyVersion: 2.3 # These are areas where ThrowTheSwitch's coding style diverges from the Ruby standard Style/SpecialGlobalVars: @@ -12,10 +12,20 @@ Style/FormatString: Enabled: false Style/GlobalVars: Enabled: false +Style/FrozenStringLiteralComment: + Enabled: false Style/RegexpLiteral: AllowInnerSlashes: true Style/HashSyntax: EnforcedStyle: no_mixed_keys +Style/NumericPredicate: + Enabled: false + +# These are also places we diverge... but we will likely comply down the road +Style/IfUnlessModifier: + Enabled: false +Style/FormatStringToken: + Enabled: false # This is disabled because it seems to get confused over nested hashes Layout/AlignHash: From 86b19304edef1c9fb593d4c81088abb618d90e1d Mon Sep 17 00:00:00 2001 From: Jason Heeris Date: Fri, 25 Oct 2019 14:37:00 +1100 Subject: [PATCH 173/454] Added num_elements parameter to docs for TEST_ASSERT_INTn_ARRAY_WITHIN(). --- docs/UnityAssertionsReference.md | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/docs/UnityAssertionsReference.md b/docs/UnityAssertionsReference.md index db97cec6..3dd787d1 100644 --- a/docs/UnityAssertionsReference.md +++ b/docs/UnityAssertionsReference.md @@ -487,35 +487,35 @@ These assertions verify that the `expected` array parameter is within +/- `delta \[10, 12\] and the delta is 3 then the assertion will fail for any value outside the range of \[7 - 13, 9 - 15\]. -##### `TEST_ASSERT_INT_ARRAY_WITHIN (delta, expected, actual)` +##### `TEST_ASSERT_INT_ARRAY_WITHIN (delta, expected, actual, num_elements)` -##### `TEST_ASSERT_INT8_ARRAY_WITHIN (delta, expected, actual)` +##### `TEST_ASSERT_INT8_ARRAY_WITHIN (delta, expected, actual, num_elements)` -##### `TEST_ASSERT_INT16_ARRAY_WITHIN (delta, expected, actual)` +##### `TEST_ASSERT_INT16_ARRAY_WITHIN (delta, expected, actual, num_elements)` -##### `TEST_ASSERT_INT32_ARRAY_WITHIN (delta, expected, actual)` +##### `TEST_ASSERT_INT32_ARRAY_WITHIN (delta, expected, actual, num_elements)` -##### `TEST_ASSERT_INT64_ARRAY_WITHIN (delta, expected, actual)` +##### `TEST_ASSERT_INT64_ARRAY_WITHIN (delta, expected, actual, num_elements)` -##### `TEST_ASSERT_UINT_ARRAY_WITHIN (delta, expected, actual)` +##### `TEST_ASSERT_UINT_ARRAY_WITHIN (delta, expected, actual, num_elements)` -##### `TEST_ASSERT_UINT8_ARRAY_WITHIN (delta, expected, actual)` +##### `TEST_ASSERT_UINT8_ARRAY_WITHIN (delta, expected, actual, num_elements)` -##### `TEST_ASSERT_UINT16_ARRAY_WITHIN (delta, expected, actual)` +##### `TEST_ASSERT_UINT16_ARRAY_WITHIN (delta, expected, actual, num_elements)` -##### `TEST_ASSERT_UINT32_ARRAY_WITHIN (delta, expected, actual)` +##### `TEST_ASSERT_UINT32_ARRAY_WITHIN (delta, expected, actual, num_elements)` -##### `TEST_ASSERT_UINT64_ARRAY_WITHIN (delta, expected, actual)` +##### `TEST_ASSERT_UINT64_ARRAY_WITHIN (delta, expected, actual, num_elements)` -##### `TEST_ASSERT_HEX_ARRAY_WITHIN (delta, expected, actual)` +##### `TEST_ASSERT_HEX_ARRAY_WITHIN (delta, expected, actual, num_elements)` -##### `TEST_ASSERT_HEX8_ARRAY_WITHIN (delta, expected, actual)` +##### `TEST_ASSERT_HEX8_ARRAY_WITHIN (delta, expected, actual, num_elements)` -##### `TEST_ASSERT_HEX16_ARRAY_WITHIN (delta, expected, actual)` +##### `TEST_ASSERT_HEX16_ARRAY_WITHIN (delta, expected, actual, num_elements)` -##### `TEST_ASSERT_HEX32_ARRAY_WITHIN (delta, expected, actual)` +##### `TEST_ASSERT_HEX32_ARRAY_WITHIN (delta, expected, actual, num_elements)` -##### `TEST_ASSERT_HEX64_ARRAY_WITHIN (delta, expected, actual)` +##### `TEST_ASSERT_HEX64_ARRAY_WITHIN (delta, expected, actual, num_elements)` ### Each Equal (Arrays to Single Value) From d16c27b08571f4bb46da72571d17da8197c544c8 Mon Sep 17 00:00:00 2001 From: mvandervoord Date: Fri, 25 Oct 2019 10:17:12 -0400 Subject: [PATCH 174/454] - added target for checking ANSI compliance - fixed ANSI (C89) issues, including #418 --- docs/UnityConfigurationGuide.md | 9 +++ extras/fixture/test/unity_fixture_Test.c | 4 +- src/unity.c | 2 +- src/unity_internals.h | 5 +- test/rakefile_helper.rb | 9 +++ test/targets/ansi.yml | 48 ++++++++++++++ test/testdata/CException.h | 2 +- test/testdata/Defs.h | 2 +- test/testdata/cmock.h | 2 +- test/testdata/mockMock.h | 2 +- test/testdata/testRunnerGenerator.c | 4 +- test/testdata/testRunnerGeneratorWithMocks.c | 2 + test/tests/test_generate_test_runner.rb | 20 +++++- test/tests/testparameterized.c | 3 - test/tests/testunity.c | 66 +++++++++++--------- 15 files changed, 134 insertions(+), 46 deletions(-) create mode 100644 test/targets/ansi.yml diff --git a/docs/UnityConfigurationGuide.md b/docs/UnityConfigurationGuide.md index 68fb1067..bdfb8539 100644 --- a/docs/UnityConfigurationGuide.md +++ b/docs/UnityConfigurationGuide.md @@ -427,6 +427,15 @@ will allow you to specify how Unity will treat these assertions. - AS_NONE - Unity will disallow the use of these shorthand macros altogether, insisting that developers choose a more descriptive option. +#### `UNITY_SUPPORT_VARIADIC_MACROS` + +This will force Unity to support variadic macros when using it's own built-in +RUN_TEST macro. This will rarely be necessary. Most often, Unity will automatically +detect if the compiler supports variadic macros by checking to see if it's C99+ +compatible. In the event that the compiler supports variadic macros, but is primarily +C89 (ANSI), defining this option will allow you to use them. This option is also not +necessary when using Ceedling or the test runner generator script. + ## Getting Into The Guts There will be cases where the options above aren't quite going to get everything diff --git a/extras/fixture/test/unity_fixture_Test.c b/extras/fixture/test/unity_fixture_Test.c index a842b085..da44d5d9 100644 --- a/extras/fixture/test/unity_fixture_Test.c +++ b/extras/fixture/test/unity_fixture_Test.c @@ -345,7 +345,7 @@ TEST_TEAR_DOWN(LeakDetection) /* This tricky set of defines lets us see if we are using the Spy, returns 1 if true */ #ifdef __STDC_VERSION__ -#if __STDC_VERSION__ >= 199901L +#if UNITY_SUPPORT_VARIADIC_MACROS #define USING_SPY_AS(a) EXPAND_AND_USE_2ND(ASSIGN_VALUE(a), 0) #define ASSIGN_VALUE(a) VAL_##a #define VAL_UnityOutputCharSpy_OutputChar 0, 1 @@ -354,7 +354,7 @@ TEST_TEAR_DOWN(LeakDetection) #if USING_SPY_AS(UNITY_OUTPUT_CHAR) #define USING_OUTPUT_SPY /* UNITY_OUTPUT_CHAR = UnityOutputCharSpy_OutputChar */ #endif -#endif /* >= 199901 */ +#endif /* UNITY_SUPPORT_VARIADIC_MACROS */ #else /* __STDC_VERSION__ else */ #define UnityOutputCharSpy_OutputChar 42 diff --git a/src/unity.c b/src/unity.c index 9883fd75..bcc0283a 100644 --- a/src/unity.c +++ b/src/unity.c @@ -1814,9 +1814,9 @@ int UnityVerbosity = 1; /*-----------------------------------------------*/ int UnityParseOptions(int argc, char** argv) { + int i; UnityOptionIncludeNamed = NULL; UnityOptionExcludeNamed = NULL; - int i; for (i = 1; i < argc; i++) { diff --git a/src/unity_internals.h b/src/unity_internals.h index 09952815..0b8578e0 100644 --- a/src/unity_internals.h +++ b/src/unity_internals.h @@ -683,6 +683,10 @@ extern const char UnityStrErrShorthand[]; #ifndef RUN_TEST #ifdef __STDC_VERSION__ #if __STDC_VERSION__ >= 199901L +#define UNITY_SUPPORT_VARIADIC +#endif +#endif +#ifdef UNITY_SUPPORT_VARIADIC_MACROS #define RUN_TEST(...) UnityDefaultTestRun(RUN_TEST_FIRST(__VA_ARGS__), RUN_TEST_SECOND(__VA_ARGS__)) #define RUN_TEST_FIRST(...) RUN_TEST_FIRST_HELPER(__VA_ARGS__, throwaway) #define RUN_TEST_FIRST_HELPER(first, ...) (first), #first @@ -690,7 +694,6 @@ extern const char UnityStrErrShorthand[]; #define RUN_TEST_SECOND_HELPER(first, second, ...) (second) #endif #endif -#endif /* If we can't do the tricky version, we'll just have to require them to always include the line number */ #ifndef RUN_TEST diff --git a/test/rakefile_helper.rb b/test/rakefile_helper.rb index 71068689..56f6dcc0 100644 --- a/test/rakefile_helper.rb +++ b/test/rakefile_helper.rb @@ -200,6 +200,15 @@ def run_tests(test_files) # Build and execute each unit test test_files.each do |test| + + # Drop Out if we're skipping this type of test + if $cfg[:skip_tests] + if $cfg[:skip_tests].include?(:parameterized) && test.match(/parameterized/) + report("Skipping Parameterized Tests for this Target:IGNORE") + next + end + end + obj_list = [] unless $cfg['compiler']['aux_sources'].nil? diff --git a/test/targets/ansi.yml b/test/targets/ansi.yml new file mode 100644 index 00000000..9cc393d6 --- /dev/null +++ b/test/targets/ansi.yml @@ -0,0 +1,48 @@ +compiler: + path: gcc + source_path: '../src/' + unit_tests_path: &unit_tests_path 'tests/' + build_path: &build_path 'build/' + options: + - '-c' + - '-m64' + - '-Wall' + - '-Wno-address' + - '-ansi' + #- '-pedantic' + includes: + prefix: '-I' + items: + - 'src/' + - '../src/' + - 'testdata/' + - *unit_tests_path + defines: + prefix: '-D' + items: + - UNITY_INCLUDE_DOUBLE + - UNITY_SUPPORT_TEST_CASES + - UNITY_EXCLUDE_TESTING_NEW_COMMENTS + object_files: + prefix: '-o' + extension: '.o' + destination: *build_path +linker: + path: gcc + options: + - -lm + - '-m64' + includes: + prefix: '-I' + object_files: + path: *build_path + extension: '.o' + bin_files: + prefix: '-o' + extension: '.exe' + destination: *build_path +colour: true +:unity: + :plugins: [] +:skip_tests: + - :parameterized \ No newline at end of file diff --git a/test/testdata/CException.h b/test/testdata/CException.h index 91ad3e1b..3872fa75 100644 --- a/test/testdata/CException.h +++ b/test/testdata/CException.h @@ -8,4 +8,4 @@ #define Try if (e) #define Catch(a) if (!a) -#endif //CEXCEPTION_H +#endif diff --git a/test/testdata/Defs.h b/test/testdata/Defs.h index d3a90c0d..b1dc83e9 100644 --- a/test/testdata/Defs.h +++ b/test/testdata/Defs.h @@ -5,4 +5,4 @@ extern int CounterSuiteSetup; -#endif //DEF_H +#endif diff --git a/test/testdata/cmock.h b/test/testdata/cmock.h index c6149be1..33ddbfc5 100644 --- a/test/testdata/cmock.h +++ b/test/testdata/cmock.h @@ -11,4 +11,4 @@ void mockMock_Init(void) { mockMock_Init_Counter++; } void mockMock_Verify(void) { mockMock_Verify_Counter++; } void mockMock_Destroy(void) { mockMock_Destroy_Counter++; } -#endif //CMOCK_H +#endif diff --git a/test/testdata/mockMock.h b/test/testdata/mockMock.h index 0a2c616f..5c6829d7 100644 --- a/test/testdata/mockMock.h +++ b/test/testdata/mockMock.h @@ -10,4 +10,4 @@ void mockMock_Init(void); void mockMock_Verify(void); void mockMock_Destroy(void); -#endif //MOCK_MOCK_H +#endif diff --git a/test/testdata/testRunnerGenerator.c b/test/testdata/testRunnerGenerator.c index 11399392..b5dd97f5 100644 --- a/test/testdata/testRunnerGenerator.c +++ b/test/testdata/testRunnerGenerator.c @@ -108,10 +108,12 @@ void custtest_ThisTestPassesWhenCustomTeardownRan(void) TEST_ASSERT_EQUAL_MESSAGE(2, CounterTeardown, "Custom Teardown Wasn't Run"); } +#ifndef UNITY_EXCLUDE_TESTING_NEW_COMMENTS //void test_NewStyleCommentsShouldBeIgnored(void) //{ // TEST_ASSERT_FAIL("New Style Comments Should Be Ignored"); //} +#endif void test_NotBeConfusedByLongComplicatedStrings(void) { @@ -185,5 +187,3 @@ void suitetest_ThisTestPassesWhenCustomSuiteSetupAndTeardownRan(void) { TEST_ASSERT_EQUAL_MESSAGE(1, CounterSuiteSetup, "Suite Setup Should Have Run"); } - - diff --git a/test/testdata/testRunnerGeneratorWithMocks.c b/test/testdata/testRunnerGeneratorWithMocks.c index 4aacbf9a..aaceda44 100644 --- a/test/testdata/testRunnerGeneratorWithMocks.c +++ b/test/testdata/testRunnerGeneratorWithMocks.c @@ -109,10 +109,12 @@ void custtest_ThisTestPassesWhenCustomTeardownRan(void) TEST_ASSERT_EQUAL_MESSAGE(2, CounterTeardown, "Custom Teardown Wasn't Run"); } +#ifndef UNITY_EXCLUDE_TESTING_NEW_COMMENTS //void test_NewStyleCommentsShouldBeIgnored(void) //{ // TEST_ASSERT_FAIL("New Style Comments Should Be Ignored"); //} +#endif void test_NotBeConfusedByLongComplicatedStrings(void) { diff --git a/test/tests/test_generate_test_runner.rb b/test/tests/test_generate_test_runner.rb index 0b51bcd4..ebf011dc 100644 --- a/test/tests/test_generate_test_runner.rb +++ b/test/tests/test_generate_test_runner.rb @@ -144,6 +144,7 @@ :test_prefix => "paratest", :use_param_tests => true, }, + :features => [ :parameterized ], :expected => { :to_pass => [ 'paratest_ShouldHandleParameterizedTests\(25\)', 'paratest_ShouldHandleParameterizedTests\(125\)', @@ -160,6 +161,7 @@ :testfile => 'testdata/testRunnerGenerator.c', :testdefines => ['TEST'], :cmdline => " --test_prefix=\"paratest\" --use_param_tests=1", + :features => [ :parameterized ], :expected => { :to_pass => [ 'paratest_ShouldHandleParameterizedTests\(25\)', 'paratest_ShouldHandleParameterizedTests\(125\)', @@ -179,6 +181,7 @@ :yaml => { :test_prefix => "paratest" }, + :features => [ :parameterized ], :expected => { :to_pass => [ 'paratest_ShouldHandleParameterizedTests\(25\)', 'paratest_ShouldHandleParameterizedTests\(125\)', @@ -468,6 +471,7 @@ :test_prefix => "paratest", :use_param_tests => true, }, + :features => [ :parameterized ], :expected => { :to_pass => [ 'paratest_ShouldHandleParameterizedTests\(25\)', 'paratest_ShouldHandleParameterizedTests\(125\)', @@ -484,6 +488,7 @@ :testfile => 'testdata/testRunnerGeneratorWithMocks.c', :testdefines => ['TEST'], :cmdline => " --test_prefix=\"paratest\" --use_param_tests=1", + :features => [ :parameterized ], :expected => { :to_pass => [ 'paratest_ShouldHandleParameterizedTests\(25\)', 'paratest_ShouldHandleParameterizedTests\(125\)', @@ -503,6 +508,7 @@ :yaml => { :test_prefix => "paratest" }, + :features => [ :parameterized ], :expected => { :to_pass => [ 'paratest_ShouldHandleParameterizedTests\(25\)', 'paratest_ShouldHandleParameterizedTests\(125\)', @@ -1044,6 +1050,7 @@ :test_prefix => "paratest" }, :cmdline_args => "-n ShouldHandleParameterizedTests", + :features => [ :parameterized ], :expected => { :to_pass => [ 'paratest_ShouldHandleParameterizedTests\(25\)', 'paratest_ShouldHandleParameterizedTests\(125\)', @@ -1090,6 +1097,7 @@ :cmdline_args => true, }, :cmdline_args => "-l", + :features => [ :parameterized ], :expected => { :to_pass => [ ], :to_fail => [ ], @@ -1151,10 +1159,18 @@ }, ] -def runner_test(test, runner, expected, test_defines, cmdline_args) +def runner_test(test, runner, expected, test_defines, cmdline_args, features) # Tack on TEST define for compiling unit tests load_configuration($cfg_file) + # Drop Out if we're skipping this type of test + if $cfg[:skip_tests] && features + if $cfg[:skip_tests].include?(:parameterized) && features.include?(:parameterized) + report("Skipping Parameterized Tests for this Target:IGNORE") + return true + end + end + #compile objects obj_list = [ compile(runner, test_defines), @@ -1239,7 +1255,7 @@ def verify_number(expected, expression, output) end #test the script against the specified test file and check results - if (runner_test(testset[:testfile], runner_name, testset[:expected], testset[:testdefines], testset[:cmdline_args])) + if (runner_test(testset[:testfile], runner_name, testset[:expected], testset[:testdefines], testset[:cmdline_args], testset[:features])) report "#{testset_name}:PASS" else report "#{testset_name}:FAIL" diff --git a/test/tests/testparameterized.c b/test/tests/testparameterized.c index 6100834f..0583cb74 100644 --- a/test/tests/testparameterized.c +++ b/test/tests/testparameterized.c @@ -169,6 +169,3 @@ void test_CharsArePreserved(unsigned index, char c) NextExpectedCharIndex++; } - - - diff --git a/test/tests/testunity.c b/test/tests/testunity.c index 297849fc..2771a995 100644 --- a/test/tests/testunity.c +++ b/test/tests/testunity.c @@ -8,8 +8,9 @@ #include #include -// Dividing by these constants produces +/- infinity. -// The rationale is given in UnityAssertFloatIsInf's body. +/* Dividing by these constants produces +/- infinity. + * The rationale is given in UnityAssertFloatIsInf's body. + */ #ifndef UNITY_EXCLUDE_FLOAT static const UNITY_FLOAT f_zero = 0.0f; #endif @@ -297,7 +298,9 @@ void testNotEqualInt16s(void) void testNotEqualInt32s(void) { EXPECT_ABORT_BEGIN - TEST_ASSERT_EQUAL_INT32(-2147483647, -2147483648); //use largest 32 bit negative to test printability + /*use largest 32 bit negative to test printability*/ + /*note: (-2147483647 - 1) is used instead of -2147483648 because of C90 casting rules */ + TEST_ASSERT_EQUAL_INT32(-2147483647, (-2147483647 - 1)); VERIFY_FAILS_END } @@ -336,8 +339,8 @@ void testNotEqualUInt16s(void) { UNITY_UINT16 v0, v1; - v0 = 65535; - v1 = 65534; + v0 = 65535u; + v1 = 65534u; EXPECT_ABORT_BEGIN TEST_ASSERT_EQUAL_UINT16(v0, v1); @@ -348,8 +351,8 @@ void testNotEqualUInt32s(void) { UNITY_UINT32 v0, v1; - v0 = 4294967295; - v1 = 4294967294; + v0 = 4294967295u; + v1 = 4294967294u; EXPECT_ABORT_BEGIN TEST_ASSERT_EQUAL_UINT32(v0, v1); @@ -1116,7 +1119,7 @@ void testHEX8sNotWithinDeltaAndCustomMessage(void) VERIFY_FAILS_END } -//----------------- +/*-----------------*/ void testUINT32sWithinDelta(void) { @@ -1340,7 +1343,7 @@ void testINT8sNotWithinDeltaAndCustomMessage(void) VERIFY_FAILS_END } -//------------------------ +/*------------------------*/ void testInt64ArrayWithinDelta(void) { @@ -2807,7 +2810,7 @@ void testHEX8ArrayWithinDeltaSamePointerAndMessage(void) TEST_ASSERT_HEX8_ARRAY_WITHIN_MESSAGE(60, expected, expected, 3, "Custom Message."); } -//----------------- +/*-----------------*/ void testGreaterThan(void) { @@ -2998,8 +3001,8 @@ void testGreaterThanUINT32(void) UNITY_UINT32 v0, v1; UNITY_UINT32 *p0, *p1; - v0 = 0; - v1 = 4294967295; + v0 = 0u; + v1 = 4294967295u; p0 = &v0; p1 = &v1; @@ -3012,7 +3015,7 @@ void testGreaterThanUINT32(void) void testNotGreaterThanUINT32(void) { EXPECT_ABORT_BEGIN - TEST_ASSERT_GREATER_THAN_UINT32(4294967295, 0); + TEST_ASSERT_GREATER_THAN_UINT32(4294967295u, 0); VERIFY_FAILS_END } @@ -3323,7 +3326,7 @@ void testGreaterOrEqualUINT32(void) UNITY_UINT32 *p0, *p1, *p2; v0 = 0; - v1 = 4294967295; + v1 = 4294967295u; v2 = 0; p0 = &v0; p1 = &v1; @@ -3342,7 +3345,7 @@ void testGreaterOrEqualUINT32(void) void testNotGreaterOrEqualUINT32(void) { EXPECT_ABORT_BEGIN - TEST_ASSERT_GREATER_OR_EQUAL_UINT32(4294967295, 0); + TEST_ASSERT_GREATER_OR_EQUAL_UINT32(4294967295u, 0); VERIFY_FAILS_END } @@ -3433,8 +3436,7 @@ void testNotGreaterOrEqualHEX32(void) VERIFY_FAILS_END } -//----------------- - +/*-----------------*/ void testLessThan(void) { @@ -3625,7 +3627,7 @@ void testLessThanUINT32(void) UNITY_UINT32 v0, v1; UNITY_UINT32 *p0, *p1; - v0 = 4294967295; + v0 = 4294967295u; v1 = 0; p0 = &v0; p1 = &v1; @@ -3639,7 +3641,7 @@ void testLessThanUINT32(void) void testNotLessThanUINT32(void) { EXPECT_ABORT_BEGIN - TEST_ASSERT_LESS_THAN_UINT32(0, 4294967295); + TEST_ASSERT_LESS_THAN_UINT32(0, 4294967295u); VERIFY_FAILS_END } @@ -3949,9 +3951,9 @@ void testLessOrEqualUINT32(void) UNITY_UINT32 v0, v1, v2; UNITY_UINT32 *p0, *p1, *p2; - v0 = 4294967295; + v0 = 4294967295u; v1 = 0; - v2 = 4294967295; + v2 = 4294967295u; p0 = &v0; p1 = &v1; p2 = &v2; @@ -3969,7 +3971,7 @@ void testLessOrEqualUINT32(void) void testNotLessOrEqualUINT32(void) { EXPECT_ABORT_BEGIN - TEST_ASSERT_LESS_OR_EQUAL_UINT32(0, 4294967295); + TEST_ASSERT_LESS_OR_EQUAL_UINT32(0, 4294967295u); VERIFY_FAILS_END } @@ -4060,7 +4062,8 @@ void testNotLessOrEqualHEX32(void) VERIFY_FAILS_END } -//----------------- +/*-----------------*/ + void testEqualStrings(void) { const char *testString = "foo"; @@ -5651,14 +5654,14 @@ void testIgnoredAndThenFailInTearDown(void) TEST_IGNORE(); } -// Tricky series of macros to set USING_OUTPUT_SPY +/* Tricky series of macros to set USING_OUTPUT_SPY */ #define USING_SPY_AS(a) EXPAND_AND_USE_2ND(ASSIGN_VALUE(a), 0) #define ASSIGN_VALUE(a) VAL_##a #define VAL_putcharSpy 0, 1 #define EXPAND_AND_USE_2ND(a, b) SECOND_PARAM(a, b, throwaway) #define SECOND_PARAM(a, b, ...) b #if USING_SPY_AS(UNITY_OUTPUT_CHAR) - #define USING_OUTPUT_SPY // true only if UNITY_OUTPUT_CHAR = putcharSpy + #define USING_OUTPUT_SPY /* true only if UNITY_OUTPUT_CHAR = putcharSpy */ #endif #ifdef USING_OUTPUT_SPY @@ -5712,7 +5715,7 @@ void testFailureCountIncrementsAndIsReturnedAtEnd(void) { UNITY_UINT savedFailures = Unity.TestFailures; Unity.CurrentTestFailed = 1; - startPutcharSpy(); // Suppress output + startPutcharSpy(); /* Suppress output */ startFlushSpy(); TEST_ASSERT_EQUAL(0, getFlushSpyCalls()); UnityConcludeTest(); @@ -5725,7 +5728,7 @@ void testFailureCountIncrementsAndIsReturnedAtEnd(void) #endif endFlushSpy(); - startPutcharSpy(); // Suppress output + startPutcharSpy(); /* Suppress output */ int failures = UnityEnd(); Unity.TestFailures--; endPutcharSpy(); @@ -5798,7 +5801,7 @@ void testPrintNumbersUnsigned32(void) } -// ===================== THESE TEST WILL RUN IF YOUR CONFIG INCLUDES 64 BIT SUPPORT ================== +/* ===================== THESE TEST WILL RUN IF YOUR CONFIG INCLUDES 64 BIT SUPPORT ================== */ void testPrintNumbersInt64(void) { @@ -6175,7 +6178,8 @@ void testNotEqualInt64Arrays(void) VERIFY_FAILS_END #endif } -// ===================== THESE TEST WILL RUN IF YOUR CONFIG INCLUDES FLOAT SUPPORT ================== + +/* ===================== THESE TEST WILL RUN IF YOUR CONFIG INCLUDES FLOAT SUPPORT ================== */ void testFloatsWithinDelta(void) { @@ -7033,7 +7037,7 @@ void testFloatPrintingRandomSamples(void) #endif } -// ===================== THESE TEST WILL RUN IF YOUR CONFIG INCLUDES DOUBLE SUPPORT ================== +/* ===================== THESE TEST WILL RUN IF YOUR CONFIG INCLUDES DOUBLE SUPPORT ================== */ void testDoublesWithinDelta(void) { @@ -7774,7 +7778,7 @@ void testDoublePrintingInfinityAndNaN(void) #endif } -// ===================== THESE TEST WILL RUN IF YOUR CONFIG INCLUDES DETAIL SUPPORT ================== +/* ===================== THESE TEST WILL RUN IF YOUR CONFIG INCLUDES DETAIL SUPPORT ================== */ void testThatDetailsCanBeHandleOneDetail(void) { From 368a7d897059a52bb244ffd314bbe84a830f0f68 Mon Sep 17 00:00:00 2001 From: mvandervoord Date: Fri, 25 Oct 2019 11:20:25 -0400 Subject: [PATCH 175/454] Fixed a couple of mistakes in last commit --- src/unity_internals.h | 2 +- test/Makefile | 5 ++--- test/targets/ansi.yml | 1 + 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/unity_internals.h b/src/unity_internals.h index 0b8578e0..11524f06 100644 --- a/src/unity_internals.h +++ b/src/unity_internals.h @@ -683,7 +683,7 @@ extern const char UnityStrErrShorthand[]; #ifndef RUN_TEST #ifdef __STDC_VERSION__ #if __STDC_VERSION__ >= 199901L -#define UNITY_SUPPORT_VARIADIC +#define UNITY_SUPPORT_VARIADIC_MACROS #endif #endif #ifdef UNITY_SUPPORT_VARIADIC_MACROS diff --git a/test/Makefile b/test/Makefile index 89ece81d..7803f386 100644 --- a/test/Makefile +++ b/test/Makefile @@ -13,13 +13,13 @@ CFLAGS += -Wbad-function-cast -Wcast-qual -Wold-style-definition -Wshadow -Wstri -Wstrict-prototypes -Wswitch-default -Wundef #DEBUG = -O0 -g CFLAGS += $(DEBUG) +UNITY_SUPPORT_64 = -D UNITY_SUPPORT_64 +UNITY_INCLUDE_DOUBLE = -D UNITY_INCLUDE_DOUBLE DEFINES = -D UNITY_OUTPUT_CHAR=putcharSpy DEFINES += -D UNITY_OUTPUT_CHAR_HEADER_DECLARATION=putcharSpy\(int\) DEFINES += -D UNITY_OUTPUT_FLUSH=flushSpy DEFINES += -D UNITY_OUTPUT_FLUSH_HEADER_DECLARATION=flushSpy\(void\) DEFINES += $(UNITY_SUPPORT_64) $(UNITY_INCLUDE_DOUBLE) -UNITY_SUPPORT_64 = -D UNITY_SUPPORT_64 -UNITY_INCLUDE_DOUBLE = -D UNITY_INCLUDE_DOUBLE SRC = ../src/unity.c tests/testunity.c build/testunityRunner.c INC_DIR = -I ../src COV_FLAGS = -fprofile-arcs -ftest-coverage -I ../../src @@ -30,7 +30,6 @@ TARGET = build/testunity-cov.exe # For verbose output of all the tests, run 'make test'. default: coverage .PHONY: default coverage test clean -coverage: DEFINES += -D UNITY_NO_WEAK coverage: $(BUILD_DIR)/testunityRunner.c cd $(BUILD_DIR) && \ $(CC) $(CFLAGS) $(DEFINES) $(foreach i,$(SRC), ../$i) $(COV_FLAGS) -o ../$(TARGET) diff --git a/test/targets/ansi.yml b/test/targets/ansi.yml index 9cc393d6..182071ad 100644 --- a/test/targets/ansi.yml +++ b/test/targets/ansi.yml @@ -23,6 +23,7 @@ compiler: - UNITY_INCLUDE_DOUBLE - UNITY_SUPPORT_TEST_CASES - UNITY_EXCLUDE_TESTING_NEW_COMMENTS + - UNITY_SUPPORT_64 object_files: prefix: '-o' extension: '.o' From 8d044e60c6c4b6285800e76fa6b25b01aeb23f66 Mon Sep 17 00:00:00 2001 From: mvandervoord Date: Fri, 25 Oct 2019 11:41:27 -0400 Subject: [PATCH 176/454] update fixture tests too --- extras/fixture/rakefile_helper.rb | 2 +- extras/fixture/test/Makefile | 2 +- extras/fixture/test/unity_fixture_Test.c | 4 +++- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/extras/fixture/rakefile_helper.rb b/extras/fixture/rakefile_helper.rb index 8bdb09d9..94a90be0 100644 --- a/extras/fixture/rakefile_helper.rb +++ b/extras/fixture/rakefile_helper.rb @@ -52,7 +52,7 @@ def build_compiler_fields defines = if $cfg['compiler']['defines']['items'].nil? '' else - squash($cfg['compiler']['defines']['prefix'], $cfg['compiler']['defines']['items'] + ['UNITY_OUTPUT_CHAR=UnityOutputCharSpy_OutputChar'] + ['UNITY_OUTPUT_CHAR_HEADER_DECLARATION=UnityOutputCharSpy_OutputChar\(int\)']) + squash($cfg['compiler']['defines']['prefix'], $cfg['compiler']['defines']['items'] + ['UNITY_OUTPUT_CHAR=UnityOutputCharSpy_OutputChar'] + ['UNITY_OUTPUT_CHAR_HEADER_DECLARATION=UnityOutputCharSpy_OutputChar(int)']) end options = squash('', $cfg['compiler']['options']) includes = squash($cfg['compiler']['includes']['prefix'], $cfg['compiler']['includes']['items']) diff --git a/extras/fixture/test/Makefile b/extras/fixture/test/Makefile index e6c62552..b8eef211 100644 --- a/extras/fixture/test/Makefile +++ b/extras/fixture/test/Makefile @@ -6,7 +6,7 @@ endif CFLAGS += -std=c99 -pedantic -Wall -Wextra -Werror CFLAGS += $(DEBUG) DEFINES = -D UNITY_OUTPUT_CHAR=UnityOutputCharSpy_OutputChar -DEFINES += -D UNITY_OUTPUT_CHAR_HEADER_DECLARATION=UnityOutputCharSpy_OutputChar\(int\) +DEFINES += -D UNITY_OUTPUT_CHAR_HEADER_DECLARATION=UnityOutputCharSpy_OutputChar(int) SRC = ../src/unity_fixture.c \ ../../../src/unity.c \ unity_fixture_Test.c \ diff --git a/extras/fixture/test/unity_fixture_Test.c b/extras/fixture/test/unity_fixture_Test.c index da44d5d9..4b59d988 100644 --- a/extras/fixture/test/unity_fixture_Test.c +++ b/extras/fixture/test/unity_fixture_Test.c @@ -345,7 +345,7 @@ TEST_TEAR_DOWN(LeakDetection) /* This tricky set of defines lets us see if we are using the Spy, returns 1 if true */ #ifdef __STDC_VERSION__ -#if UNITY_SUPPORT_VARIADIC_MACROS +#ifdef UNITY_SUPPORT_VARIADIC_MACROS #define USING_SPY_AS(a) EXPAND_AND_USE_2ND(ASSIGN_VALUE(a), 0) #define ASSIGN_VALUE(a) VAL_##a #define VAL_UnityOutputCharSpy_OutputChar 0, 1 @@ -357,11 +357,13 @@ TEST_TEAR_DOWN(LeakDetection) #endif /* UNITY_SUPPORT_VARIADIC_MACROS */ #else /* __STDC_VERSION__ else */ + #define UnityOutputCharSpy_OutputChar 42 #if UNITY_OUTPUT_CHAR == UnityOutputCharSpy_OutputChar /* Works if no -Wundef -Werror */ #define USING_OUTPUT_SPY #endif #undef UnityOutputCharSpy_OutputChar + #endif /* __STDC_VERSION__ */ TEST(LeakDetection, DetectsLeak) From 15631f1c781ab3b5533ceaaa1284c4224a494d92 Mon Sep 17 00:00:00 2001 From: mvandervoord Date: Fri, 25 Oct 2019 11:53:59 -0400 Subject: [PATCH 177/454] More tweaking to make it happy on both windows and *nix --- extras/fixture/rakefile_helper.rb | 10 +++++++++- extras/fixture/test/Makefile | 6 +++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/extras/fixture/rakefile_helper.rb b/extras/fixture/rakefile_helper.rb index 94a90be0..cad220ac 100644 --- a/extras/fixture/rakefile_helper.rb +++ b/extras/fixture/rakefile_helper.rb @@ -6,10 +6,13 @@ require 'yaml' require 'fileutils' +require 'rbconfig' require_relative '../../auto/unity_test_summary' require_relative '../../auto/generate_test_runner' require_relative '../../auto/colour_reporter' +$is_windows = (RbConfig::CONFIG['host_os'] =~ /mswin|mingw|cygwin/) + C_EXTENSION = '.c'.freeze def load_configuration(config_file) @@ -52,7 +55,12 @@ def build_compiler_fields defines = if $cfg['compiler']['defines']['items'].nil? '' else - squash($cfg['compiler']['defines']['prefix'], $cfg['compiler']['defines']['items'] + ['UNITY_OUTPUT_CHAR=UnityOutputCharSpy_OutputChar'] + ['UNITY_OUTPUT_CHAR_HEADER_DECLARATION=UnityOutputCharSpy_OutputChar(int)']) + if $is_windows + decl = 'UNITY_OUTPUT_CHAR_HEADER_DECLARATION=UnityOutputCharSpy_OutputChar(int)' + else + decl = 'UNITY_OUTPUT_CHAR_HEADER_DECLARATION=UnityOutputCharSpy_OutputChar\(int\)' + end + squash($cfg['compiler']['defines']['prefix'], $cfg['compiler']['defines']['items'] + ['UNITY_OUTPUT_CHAR=UnityOutputCharSpy_OutputChar'] + [decl]) end options = squash('', $cfg['compiler']['options']) includes = squash($cfg['compiler']['includes']['prefix'], $cfg['compiler']['includes']['items']) diff --git a/extras/fixture/test/Makefile b/extras/fixture/test/Makefile index b8eef211..2560868d 100644 --- a/extras/fixture/test/Makefile +++ b/extras/fixture/test/Makefile @@ -6,7 +6,11 @@ endif CFLAGS += -std=c99 -pedantic -Wall -Wextra -Werror CFLAGS += $(DEBUG) DEFINES = -D UNITY_OUTPUT_CHAR=UnityOutputCharSpy_OutputChar -DEFINES += -D UNITY_OUTPUT_CHAR_HEADER_DECLARATION=UnityOutputCharSpy_OutputChar(int) +ifeq ($(OS),Windows_NT) + DEFINES += -D UNITY_OUTPUT_CHAR_HEADER_DECLARATION=UnityOutputCharSpy_OutputChar(int) +else + DEFINES += -D UNITY_OUTPUT_CHAR_HEADER_DECLARATION=UnityOutputCharSpy_OutputChar\(int\) +endif SRC = ../src/unity_fixture.c \ ../../../src/unity.c \ unity_fixture_Test.c \ From b75b19c969e2f714893b86af218925e020e5d57f Mon Sep 17 00:00:00 2001 From: Aurelien Labrosse Date: Tue, 8 Oct 2019 19:40:04 +0000 Subject: [PATCH 178/454] CMakeLists fixes --- CMakeLists.txt | 19 +++++-------------- src/CMakeLists.txt | 12 +++++++++--- 2 files changed, 14 insertions(+), 17 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index dfc243c4..08fafd9d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ ################################################################################### # # -# NAME: CMakeLsits.txt # +# NAME: CMakeLists.txt # # # # AUTHOR: Mike Karlesky, Mark VanderVoord, Greg Williams. # # WRITTEN BY: Michael Brockus. # @@ -13,11 +13,8 @@ cmake_minimum_required(VERSION 3.0 FATAL_ERROR) project(unity LANGUAGES C DESCRIPTION "C Unit testing framework.") - -add_subdirectory("src") - - -target_include_directories("unity" +add_subdirectory(src) +target_include_directories(unity PUBLIC "$" "$" @@ -25,15 +22,9 @@ target_include_directories("unity" PRIVATE "src" ) -add_library("unity::framework" ALIAS "unity") - -install(TARGETS "unity" EXPORT "unityConfig" - ARCHIVE DESTINATION "${CMAKE_CURRENT_SOURCE_DIR}/${CMAKE_INSTALL_LIBDIR}" - LIBRARY DESTINATION "${CMAKE_CURRENT_SOURCE_DIR}/${CMAKE_INSTALL_LIBDIR}" - RUNTIME DESTINATION "${CMAKE_CURRENT_SOURCE_DIR}/${CMAKE_INSTALL_BINDIR}" - INCLUDES DESTINATION "${CMAKE_INSTALL_LIBDIR}") +add_library(unity::framework ALIAS unity) -install(DIRECTORY src/ DESTINATION src) +install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/src/ DESTINATION src) install(EXPORT unityConfig DESTINATION share/unityConfig/cmake) # This makes the project importable from the build directory diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 4aa2bcbd..c747cb0a 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -8,9 +8,15 @@ # License: MIT # # # ################################################################################### -cmake_minimum_required(VERSION 3.13.2.0 FATAL_ERROR) +cmake_minimum_required(VERSION 3.0 FATAL_ERROR) -add_library("unity" STATIC) +add_library(unity STATIC "unity.c") + +install(TARGETS unity EXPORT unityConfig + ARCHIVE DESTINATION "${CMAKE_CURRENT_SOURCE_DIR}/${CMAKE_INSTALL_LIBDIR}" + LIBRARY DESTINATION "${CMAKE_CURRENT_SOURCE_DIR}/${CMAKE_INSTALL_LIBDIR}" + RUNTIME DESTINATION "${CMAKE_CURRENT_SOURCE_DIR}/${CMAKE_INSTALL_BINDIR}" + INCLUDES DESTINATION "${CMAKE_INSTALL_LIBDIR}") + -target_sources("unity" PRIVATE "unity.c") From be87d790c7f11c14053f57d9bad1bb3cbd5667f2 Mon Sep 17 00:00:00 2001 From: mvandervoord Date: Mon, 28 Oct 2019 10:32:22 -0400 Subject: [PATCH 179/454] Add verifyTest option to go with resetTest. Fix docs. --- auto/generate_test_runner.rb | 11 ++++++++++- docs/UnityConfigurationGuide.md | 2 +- extras/fixture/rakefile_helper.rb | 10 +++++----- src/unity.h | 12 ++++++++++++ 4 files changed, 28 insertions(+), 7 deletions(-) diff --git a/auto/generate_test_runner.rb b/auto/generate_test_runner.rb index ea75f4c8..bd555370 100644 --- a/auto/generate_test_runner.rb +++ b/auto/generate_test_runner.rb @@ -37,6 +37,7 @@ def self.default_options setup_name: 'setUp', teardown_name: 'tearDown', test_reset_name: 'resetTest', + test_verify_name: 'verifyTest', main_name: 'main', # set to :auto to automatically generate each time main_export_decl: '', cmdline_args: false, @@ -304,7 +305,7 @@ def create_suite_teardown(output) end def create_reset(output) - output.puts("\n/*=======Test Reset Option=====*/") + output.puts("\n/*=======Test Reset Options=====*/") output.puts("void #{@options[:test_reset_name]}(void);") output.puts("void #{@options[:test_reset_name]}(void)") output.puts('{') @@ -314,6 +315,13 @@ def create_reset(output) output.puts(' CMock_Init();') output.puts(" #{@options[:setup_name]}();") output.puts('}') + output.puts("void #{@options[:test_verify_name]}(void);") + output.puts("void #{@options[:test_verify_name]}(void)") + output.puts('{') + output.puts(' CMock_Verify();') + output.puts(' CMock_Destroy();') + output.puts(' CMock_Init();') + output.puts('}') end def create_run_test(output) @@ -463,6 +471,7 @@ def create_h_file(output, filename, tests, testfile_includes, used_mocks) ' --main_name="" - redefine main func name to something else', ' --test_prefix="" - redefine test prefix from default test|spec|should', ' --test_reset_name="" - redefine resetTest func name to something else', + ' --test_verify_name="" - redefine verifyTest func name to something else', ' --suite_setup="" - code to execute for setup of entire suite', ' --suite_teardown="" - code to execute for teardown of entire suite', ' --use_param_tests=1 - enable parameterized tests (disabled by default)', diff --git a/docs/UnityConfigurationGuide.md b/docs/UnityConfigurationGuide.md index bdfb8539..e8e415fb 100644 --- a/docs/UnityConfigurationGuide.md +++ b/docs/UnityConfigurationGuide.md @@ -429,7 +429,7 @@ will allow you to specify how Unity will treat these assertions. #### `UNITY_SUPPORT_VARIADIC_MACROS` -This will force Unity to support variadic macros when using it's own built-in +This will force Unity to support variadic macros when using its own built-in RUN_TEST macro. This will rarely be necessary. Most often, Unity will automatically detect if the compiler supports variadic macros by checking to see if it's C99+ compatible. In the event that the compiler supports variadic macros, but is primarily diff --git a/extras/fixture/rakefile_helper.rb b/extras/fixture/rakefile_helper.rb index cad220ac..91dafaf7 100644 --- a/extras/fixture/rakefile_helper.rb +++ b/extras/fixture/rakefile_helper.rb @@ -55,11 +55,11 @@ def build_compiler_fields defines = if $cfg['compiler']['defines']['items'].nil? '' else - if $is_windows - decl = 'UNITY_OUTPUT_CHAR_HEADER_DECLARATION=UnityOutputCharSpy_OutputChar(int)' - else - decl = 'UNITY_OUTPUT_CHAR_HEADER_DECLARATION=UnityOutputCharSpy_OutputChar\(int\)' - end + decl = if $is_windows + 'UNITY_OUTPUT_CHAR_HEADER_DECLARATION=UnityOutputCharSpy_OutputChar(int)' + else + 'UNITY_OUTPUT_CHAR_HEADER_DECLARATION=UnityOutputCharSpy_OutputChar\(int\)' + end squash($cfg['compiler']['defines']['prefix'], $cfg['compiler']['defines']['items'] + ['UNITY_OUTPUT_CHAR=UnityOutputCharSpy_OutputChar'] + [decl]) end options = squash('', $cfg['compiler']['options']) diff --git a/src/unity.h b/src/unity.h index f97d1414..afda5d9a 100644 --- a/src/unity.h +++ b/src/unity.h @@ -40,6 +40,18 @@ void tearDown(void); void suiteSetUp(void); int suiteTearDown(int num_failures); +/*------------------------------------------------------- + * Test Reset and Verify + *-------------------------------------------------------*/ + +/* These functions are intended to be called before during tests in order + * to support complex test loops, etc. Both are NOT built into Unity. Instead + * the test runner generator will create them. resetTest will run teardown and + * setup again, verifying any end-of-test needs between. verifyTest will only + * run the verification. */ +void resetTest(void); +void verifyTest(void); + /*------------------------------------------------------- * Configuration Options *------------------------------------------------------- From e1dca8fa48765f977c9b70969f6737fa3dfdc456 Mon Sep 17 00:00:00 2001 From: mvandervoord Date: Mon, 28 Oct 2019 12:43:11 -0400 Subject: [PATCH 180/454] Add options for different output formats --- docs/UnityConfigurationGuide.md | 12 ++++++++++++ src/unity.c | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+) diff --git a/docs/UnityConfigurationGuide.md b/docs/UnityConfigurationGuide.md index e8e415fb..8155a0f6 100644 --- a/docs/UnityConfigurationGuide.md +++ b/docs/UnityConfigurationGuide.md @@ -343,6 +343,18 @@ _Note:_ specifying `UNITY_USE_FLUSH_STDOUT`. No other defines are required. +##### `UNITY_OUTPUT_FOR_ECLIPSE` + +##### `UNITY_OUTPUT_FOR_IAR_WORKBENCH` + +##### `UNITY_OUTPUT_FOR_QT_CREATOR` + +When managing your own builds, it is often handy to have messages output in a format which is +recognized by your IDE. These are some standard formats which can be supported. If you're using +Ceedling to manage your builds, it is better to stick with the standard format (leaving these +all undefined) and allow Ceedling to use its own decorators. + + ##### `UNITY_PTR_ATTRIBUTE` Some compilers require a custom attribute to be assigned to pointers, like diff --git a/src/unity.c b/src/unity.c index bcc0283a..9b80605e 100644 --- a/src/unity.c +++ b/src/unity.c @@ -570,12 +570,44 @@ void UnityPrintFloat(const UNITY_DOUBLE input_number) /*-----------------------------------------------*/ static void UnityTestResultsBegin(const char* file, const UNITY_LINE_TYPE line) { +#ifdef UNITY_OUTPUT_FOR_ECLIPSE + UNITY_OUTPUT_CHAR('('); UnityPrint(file); UNITY_OUTPUT_CHAR(':'); UnityPrintNumber((UNITY_INT)line); + UNITY_OUTPUT_CHAR(')'); + UNITY_OUTPUT_CHAR(' '); + UnityPrint(Unity.CurrentTestName); + UNITY_OUTPUT_CHAR(':'); +#else +#ifdef UNITY_OUTPUT_FOR_IAR_WORKBENCH + UnityPrint("'); + UnityPrint(Unity.CurrentTestName); + UnityPrint(" "); +#else +#ifdef UNITY_OUTPUT_FOR_QT_CREATOR + UnityPrint("file://"); + UnityPrint(file); UNITY_OUTPUT_CHAR(':'); + UnityPrintNumber((UNITY_INT)line); + UNITY_OUTPUT_CHAR(' '); UnityPrint(Unity.CurrentTestName); UNITY_OUTPUT_CHAR(':'); +#else + UnityPrint(file); + UNITY_OUTPUT_CHAR(':'); + UnityPrintNumber((UNITY_INT)line); + UNITY_OUTPUT_CHAR(':'); + UnityPrint(Unity.CurrentTestName); + UNITY_OUTPUT_CHAR(':'); +#endif +#endif +#endif } /*-----------------------------------------------*/ From 60b23dc8a4c90215407fda2fba8b7c1b4872b4e0 Mon Sep 17 00:00:00 2001 From: mvandervoord Date: Mon, 28 Oct 2019 13:43:32 -0400 Subject: [PATCH 181/454] Stopped supported -0 as a float output because (a) it is non-portable, only existing on some architectures and (b) relies on the undefined behavior of 1.0/0.0 --- src/unity.c | 4 ++-- test/tests/testunity.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/unity.c b/src/unity.c index 9b80605e..1b557914 100644 --- a/src/unity.c +++ b/src/unity.c @@ -429,14 +429,14 @@ void UnityPrintFloat(const UNITY_DOUBLE input_number) UNITY_DOUBLE number = input_number; /* print minus sign (including for negative zero) */ - if ((number < 0.0f) || ((number == 0.0f) && ((1.0f / number) < 0.0f))) + if (number < 0.0f) { UNITY_OUTPUT_CHAR('-'); number = -number; } /* handle zero, NaN, and +/- infinity */ - if (number == 0.0f) + if (number == 0.0f) { UnityPrint("0"); } diff --git a/test/tests/testunity.c b/test/tests/testunity.c index 2771a995..c9712eda 100644 --- a/test/tests/testunity.c +++ b/test/tests/testunity.c @@ -7722,7 +7722,7 @@ void testDoublePrinting(void) TEST_ASSERT_EQUAL_PRINT_FLOATING("16.0000006", 16.0000006); TEST_ASSERT_EQUAL_PRINT_FLOATING("999999999", 999999999.0); /*Last full print integer*/ - TEST_ASSERT_EQUAL_PRINT_FLOATING("-0", -0.0); + TEST_ASSERT_EQUAL_PRINT_FLOATING("0", -0.0); /* -0 no supported on all targets */ TEST_ASSERT_EQUAL_PRINT_FLOATING("-4.99e-07", -0.000000499); TEST_ASSERT_EQUAL_PRINT_FLOATING("-5.0000005e-07", -0.00000050000005); TEST_ASSERT_EQUAL_PRINT_FLOATING("-0.100469499", -0.100469499); From 354e2b4da6f099b0bf41671a6382232a2c8f74d8 Mon Sep 17 00:00:00 2001 From: mvandervoord Date: Mon, 28 Oct 2019 16:54:32 -0400 Subject: [PATCH 182/454] Added set of assertions for checking CHAR's and CHAR arrays (not as strings) --- docs/UnityAssertionsReference.md | 21 + src/unity.c | 40 +- src/unity.h | 18 + src/unity_internals.h | 13 +- test/tests/testunity.c | 740 ++++++++++++++++++++++--------- 5 files changed, 626 insertions(+), 206 deletions(-) diff --git a/docs/UnityAssertionsReference.md b/docs/UnityAssertionsReference.md index 3dd787d1..a395d614 100644 --- a/docs/UnityAssertionsReference.md +++ b/docs/UnityAssertionsReference.md @@ -284,6 +284,15 @@ in hexadecimal. Unity output is big endian. ##### `TEST_ASSERT_EQUAL_HEX64 (expected, actual)` +### Characters + +While you can use the 8-bit integer assertions to compare `char`, another option is +to use this specialized assertion which will show printable characters as printables, +otherwise showing the HEX escape code for the characters. + +##### `TEST_ASSERT_EQUAL_CHAR (expected, actual)` + + ### Masked and Bit-level Assertions Masked and bit-level assertions produce output formatted in hexadecimal. Unity @@ -344,6 +353,8 @@ greater than assertion will fail if it is 0 or less. ##### `TEST_ASSERT_GREATER_THAN_HEX32 (threshold, actual)` +##### `TEST_ASSERT_GREATER_THAN_CHAR (threshold, actual)` + ##### `TEST_ASSERT_LESS_THAN (threshold, actual)` ##### `TEST_ASSERT_LESS_THAN_INT (threshold, actual)` @@ -368,6 +379,8 @@ greater than assertion will fail if it is 0 or less. ##### `TEST_ASSERT_LESS_THAN_HEX32 (threshold, actual)` +##### `TEST_ASSERT_LESS_THAN_CHAR (threshold, actual)` + ### Integer Ranges (of all sizes) @@ -406,6 +419,8 @@ of 7 - 13. ##### `TEST_ASSERT_HEX64_WITHIN (delta, expected, actual)` +##### `TEST_ASSERT_CHAR_WITHIN (delta, expected, actual)` + ### Structs and Strings ##### `TEST_ASSERT_EQUAL_PTR (expected, actual)` @@ -472,6 +487,8 @@ match. Failure messages specify the array index of the failed comparison. ##### `TEST_ASSERT_EQUAL_HEX64_ARRAY (expected, actual, num_elements)` +##### `TEST_ASSERT_EQUAL_CHAR_ARRAY (expected, actual, num_elements)` + ##### `TEST_ASSERT_EQUAL_PTR_ARRAY (expected, actual, num_elements)` ##### `TEST_ASSERT_EQUAL_STRING_ARRAY (expected, actual, num_elements)` @@ -517,6 +534,8 @@ outside the range of \[7 - 13, 9 - 15\]. ##### `TEST_ASSERT_HEX64_ARRAY_WITHIN (delta, expected, actual, num_elements)` +##### `TEST_ASSERT_CHAR_ARRAY_WITHIN (delta, expected, actual, num_elements)` + ### Each Equal (Arrays to Single Value) `expected` are single values and `actual` are arrays. `num_elements` specifies @@ -558,6 +577,8 @@ match. Failure messages specify the array index of the failed comparison. #### `TEST_ASSERT_EACH_EQUAL_HEX64 (expected, actual, num_elements)` +#### `TEST_ASSERT_EACH_EQUAL_CHAR (expected, actual, num_elements)` + #### `TEST_ASSERT_EACH_EQUAL_PTR (expected, actual, num_elements)` #### `TEST_ASSERT_EACH_EQUAL_STRING (expected, actual, num_elements)` diff --git a/src/unity.c b/src/unity.c index 1b557914..ee575bdd 100644 --- a/src/unity.c +++ b/src/unity.c @@ -304,13 +304,49 @@ void UnityPrintNumberByStyle(const UNITY_INT number, const UNITY_DISPLAY_STYLE_T { if ((style & UNITY_DISPLAY_RANGE_INT) == UNITY_DISPLAY_RANGE_INT) { - UnityPrintNumber(number); + if (style == UNITY_DISPLAY_STYLE_CHAR) + { + /* printable characters plus CR & LF are printed */ + UNITY_OUTPUT_CHAR('\''); + if ((number <= 126) && (number >= 32)) + { + UNITY_OUTPUT_CHAR(number); + } + /* write escaped carriage returns */ + else if (number == 13) + { + UNITY_OUTPUT_CHAR('\\'); + UNITY_OUTPUT_CHAR('r'); + } + /* write escaped line feeds */ + else if (number == 10) + { + UNITY_OUTPUT_CHAR('\\'); + UNITY_OUTPUT_CHAR('n'); + } + /* unprintable characters are shown as codes */ + else + { + UNITY_OUTPUT_CHAR('\\'); + UNITY_OUTPUT_CHAR('x'); + UnityPrintNumberHex((UNITY_UINT)number, 2); + } + UNITY_OUTPUT_CHAR('\''); + } + else + { + UnityPrintNumber(number); + } } else if ((style & UNITY_DISPLAY_RANGE_UINT) == UNITY_DISPLAY_RANGE_UINT) { UnityPrintNumberUnsigned((UNITY_UINT)number); } - else + else if ((style & UNITY_DISPLAY_RANGE_UINT) == UNITY_DISPLAY_RANGE_UINT) + { + UnityPrintNumberUnsigned((UNITY_UINT)number); + } + else { UNITY_OUTPUT_CHAR('0'); UNITY_OUTPUT_CHAR('x'); diff --git a/src/unity.h b/src/unity.h index afda5d9a..34d7f93a 100644 --- a/src/unity.h +++ b/src/unity.h @@ -143,6 +143,7 @@ void verifyTest(void); #define TEST_ASSERT_EQUAL_HEX16(expected, actual) UNITY_TEST_ASSERT_EQUAL_HEX16((expected), (actual), __LINE__, NULL) #define TEST_ASSERT_EQUAL_HEX32(expected, actual) UNITY_TEST_ASSERT_EQUAL_HEX32((expected), (actual), __LINE__, NULL) #define TEST_ASSERT_EQUAL_HEX64(expected, actual) UNITY_TEST_ASSERT_EQUAL_HEX64((expected), (actual), __LINE__, NULL) +#define TEST_ASSERT_EQUAL_CHAR(expected, actual) UNITY_TEST_ASSERT_EQUAL_CHAR((expected), (actual), __LINE__, NULL) #define TEST_ASSERT_BITS(mask, expected, actual) UNITY_TEST_ASSERT_BITS((mask), (expected), (actual), __LINE__, NULL) #define TEST_ASSERT_BITS_HIGH(mask, actual) UNITY_TEST_ASSERT_BITS((mask), (UNITY_UINT32)(-1), (actual), __LINE__, NULL) #define TEST_ASSERT_BITS_LOW(mask, actual) UNITY_TEST_ASSERT_BITS((mask), (UNITY_UINT32)(0), (actual), __LINE__, NULL) @@ -166,6 +167,7 @@ void verifyTest(void); #define TEST_ASSERT_GREATER_THAN_HEX16(threshold, actual) UNITY_TEST_ASSERT_GREATER_THAN_HEX16((threshold), (actual), __LINE__, NULL) #define TEST_ASSERT_GREATER_THAN_HEX32(threshold, actual) UNITY_TEST_ASSERT_GREATER_THAN_HEX32((threshold), (actual), __LINE__, NULL) #define TEST_ASSERT_GREATER_THAN_HEX64(threshold, actual) UNITY_TEST_ASSERT_GREATER_THAN_HEX64((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_GREATER_THAN_CHAR(threshold, actual) UNITY_TEST_ASSERT_GREATER_THAN_CHAR((threshold), (actual), __LINE__, NULL) #define TEST_ASSERT_LESS_THAN(threshold, actual) UNITY_TEST_ASSERT_SMALLER_THAN_INT((threshold), (actual), __LINE__, NULL) #define TEST_ASSERT_LESS_THAN_INT(threshold, actual) UNITY_TEST_ASSERT_SMALLER_THAN_INT((threshold), (actual), __LINE__, NULL) @@ -183,6 +185,7 @@ void verifyTest(void); #define TEST_ASSERT_LESS_THAN_HEX16(threshold, actual) UNITY_TEST_ASSERT_SMALLER_THAN_HEX16((threshold), (actual), __LINE__, NULL) #define TEST_ASSERT_LESS_THAN_HEX32(threshold, actual) UNITY_TEST_ASSERT_SMALLER_THAN_HEX32((threshold), (actual), __LINE__, NULL) #define TEST_ASSERT_LESS_THAN_HEX64(threshold, actual) UNITY_TEST_ASSERT_SMALLER_THAN_HEX64((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_LESS_THAN_CHAR(threshold, actual) UNITY_TEST_ASSERT_SMALLER_THAN_CHAR((threshold), (actual), __LINE__, NULL) #define TEST_ASSERT_GREATER_OR_EQUAL(threshold, actual) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_INT((threshold), (actual), __LINE__, NULL) #define TEST_ASSERT_GREATER_OR_EQUAL_INT(threshold, actual) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_INT((threshold), (actual), __LINE__, NULL) @@ -200,6 +203,7 @@ void verifyTest(void); #define TEST_ASSERT_GREATER_OR_EQUAL_HEX16(threshold, actual) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_HEX16((threshold), (actual), __LINE__, NULL) #define TEST_ASSERT_GREATER_OR_EQUAL_HEX32(threshold, actual) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_HEX32((threshold), (actual), __LINE__, NULL) #define TEST_ASSERT_GREATER_OR_EQUAL_HEX64(threshold, actual) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_HEX64((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_GREATER_OR_EQUAL_CHAR(threshold, actual) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_CHAR((threshold), (actual), __LINE__, NULL) #define TEST_ASSERT_LESS_OR_EQUAL(threshold, actual) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_INT((threshold), (actual), __LINE__, NULL) #define TEST_ASSERT_LESS_OR_EQUAL_INT(threshold, actual) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_INT((threshold), (actual), __LINE__, NULL) @@ -217,6 +221,7 @@ void verifyTest(void); #define TEST_ASSERT_LESS_OR_EQUAL_HEX16(threshold, actual) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_HEX16((threshold), (actual), __LINE__, NULL) #define TEST_ASSERT_LESS_OR_EQUAL_HEX32(threshold, actual) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_HEX32((threshold), (actual), __LINE__, NULL) #define TEST_ASSERT_LESS_OR_EQUAL_HEX64(threshold, actual) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_HEX64((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_LESS_OR_EQUAL_CHAR(threshold, actual) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_CHAR((threshold), (actual), __LINE__, NULL) /* Integer Ranges (of all sizes) */ #define TEST_ASSERT_INT_WITHIN(delta, expected, actual) UNITY_TEST_ASSERT_INT_WITHIN((delta), (expected), (actual), __LINE__, NULL) @@ -235,6 +240,7 @@ void verifyTest(void); #define TEST_ASSERT_HEX16_WITHIN(delta, expected, actual) UNITY_TEST_ASSERT_HEX16_WITHIN((delta), (expected), (actual), __LINE__, NULL) #define TEST_ASSERT_HEX32_WITHIN(delta, expected, actual) UNITY_TEST_ASSERT_HEX32_WITHIN((delta), (expected), (actual), __LINE__, NULL) #define TEST_ASSERT_HEX64_WITHIN(delta, expected, actual) UNITY_TEST_ASSERT_HEX64_WITHIN((delta), (expected), (actual), __LINE__, NULL) +#define TEST_ASSERT_CHAR_WITHIN(delta, expected, actual) UNITY_TEST_ASSERT_CHAR_WITHIN((delta), (expected), (actual), __LINE__, NULL) /* Integer Array Ranges (of all sizes) */ #define TEST_ASSERT_INT_ARRAY_WITHIN(delta, expected, actual, num_elements) UNITY_TEST_ASSERT_INT_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, NULL) @@ -253,6 +259,7 @@ void verifyTest(void); #define TEST_ASSERT_HEX16_ARRAY_WITHIN(delta, expected, actual, num_elements) UNITY_TEST_ASSERT_HEX16_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, NULL) #define TEST_ASSERT_HEX32_ARRAY_WITHIN(delta, expected, actual, num_elements) UNITY_TEST_ASSERT_HEX32_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, NULL) #define TEST_ASSERT_HEX64_ARRAY_WITHIN(delta, expected, actual, num_elements) UNITY_TEST_ASSERT_HEX64_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, NULL) +#define TEST_ASSERT_CHAR_ARRAY_WITHIN(delta, expected, actual, num_elements) UNITY_TEST_ASSERT_CHAR_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, NULL) /* Structs and Strings */ @@ -281,6 +288,7 @@ void verifyTest(void); #define TEST_ASSERT_EQUAL_PTR_ARRAY(expected, actual, num_elements) UNITY_TEST_ASSERT_EQUAL_PTR_ARRAY((expected), (actual), (num_elements), __LINE__, NULL) #define TEST_ASSERT_EQUAL_STRING_ARRAY(expected, actual, num_elements) UNITY_TEST_ASSERT_EQUAL_STRING_ARRAY((expected), (actual), (num_elements), __LINE__, NULL) #define TEST_ASSERT_EQUAL_MEMORY_ARRAY(expected, actual, len, num_elements) UNITY_TEST_ASSERT_EQUAL_MEMORY_ARRAY((expected), (actual), (len), (num_elements), __LINE__, NULL) +#define TEST_ASSERT_EQUAL_CHAR_ARRAY(expected, actual, num_elements) UNITY_TEST_ASSERT_EQUAL_CHAR_ARRAY((expected), (actual), (num_elements), __LINE__, NULL) /* Arrays Compared To Single Value */ #define TEST_ASSERT_EACH_EQUAL_INT(expected, actual, num_elements) UNITY_TEST_ASSERT_EACH_EQUAL_INT((expected), (actual), (num_elements), __LINE__, NULL) @@ -302,6 +310,7 @@ void verifyTest(void); #define TEST_ASSERT_EACH_EQUAL_PTR(expected, actual, num_elements) UNITY_TEST_ASSERT_EACH_EQUAL_PTR((expected), (actual), (num_elements), __LINE__, NULL) #define TEST_ASSERT_EACH_EQUAL_STRING(expected, actual, num_elements) UNITY_TEST_ASSERT_EACH_EQUAL_STRING((expected), (actual), (num_elements), __LINE__, NULL) #define TEST_ASSERT_EACH_EQUAL_MEMORY(expected, actual, len, num_elements) UNITY_TEST_ASSERT_EACH_EQUAL_MEMORY((expected), (actual), (len), (num_elements), __LINE__, NULL) +#define TEST_ASSERT_EACH_EQUAL_CHAR(expected, actual, num_elements) UNITY_TEST_ASSERT_EACH_EQUAL_CHAR((expected), (actual), (num_elements), __LINE__, NULL) /* Floating Point (If Enabled) */ #define TEST_ASSERT_FLOAT_WITHIN(delta, expected, actual) UNITY_TEST_ASSERT_FLOAT_WITHIN((delta), (expected), (actual), __LINE__, NULL) @@ -387,6 +396,7 @@ void verifyTest(void); #define TEST_ASSERT_BITS_LOW_MESSAGE(mask, actual, message) UNITY_TEST_ASSERT_BITS((mask), (UNITY_UINT32)(0), (actual), __LINE__, (message)) #define TEST_ASSERT_BIT_HIGH_MESSAGE(bit, actual, message) UNITY_TEST_ASSERT_BITS(((UNITY_UINT32)1 << (bit)), (UNITY_UINT32)(-1), (actual), __LINE__, (message)) #define TEST_ASSERT_BIT_LOW_MESSAGE(bit, actual, message) UNITY_TEST_ASSERT_BITS(((UNITY_UINT32)1 << (bit)), (UNITY_UINT32)(0), (actual), __LINE__, (message)) +#define TEST_ASSERT_EQUAL_CHAR_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_CHAR((expected), (actual), __LINE__, (message)) /* Integer Greater Than/ Less Than (of all sizes) */ #define TEST_ASSERT_GREATER_THAN_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_THAN_INT((threshold), (actual), __LINE__, (message)) @@ -405,6 +415,7 @@ void verifyTest(void); #define TEST_ASSERT_GREATER_THAN_HEX16_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_THAN_HEX16((threshold), (actual), __LINE__, (message)) #define TEST_ASSERT_GREATER_THAN_HEX32_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_THAN_HEX32((threshold), (actual), __LINE__, (message)) #define TEST_ASSERT_GREATER_THAN_HEX64_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_THAN_HEX64((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_GREATER_THAN_CHAR_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_THAN_CHAR((threshold), (actual), __LINE__, (message)) #define TEST_ASSERT_LESS_THAN_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_THAN_INT((threshold), (actual), __LINE__, (message)) #define TEST_ASSERT_LESS_THAN_INT_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_THAN_INT((threshold), (actual), __LINE__, (message)) @@ -422,6 +433,7 @@ void verifyTest(void); #define TEST_ASSERT_LESS_THAN_HEX16_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_THAN_HEX16((threshold), (actual), __LINE__, (message)) #define TEST_ASSERT_LESS_THAN_HEX32_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_THAN_HEX32((threshold), (actual), __LINE__, (message)) #define TEST_ASSERT_LESS_THAN_HEX64_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_THAN_HEX64((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_LESS_THAN_CHAR_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_THAN_CHAR((threshold), (actual), __LINE__, (message)) #define TEST_ASSERT_GREATER_OR_EQUAL_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_INT((threshold), (actual), __LINE__, (message)) #define TEST_ASSERT_GREATER_OR_EQUAL_INT_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_INT((threshold), (actual), __LINE__, (message)) @@ -439,6 +451,7 @@ void verifyTest(void); #define TEST_ASSERT_GREATER_OR_EQUAL_HEX16_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_HEX16((threshold), (actual), __LINE__, (message)) #define TEST_ASSERT_GREATER_OR_EQUAL_HEX32_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_HEX32((threshold), (actual), __LINE__, (message)) #define TEST_ASSERT_GREATER_OR_EQUAL_HEX64_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_HEX64((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_GREATER_OR_EQUAL_CHAR_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_CHAR((threshold), (actual), __LINE__, (message)) #define TEST_ASSERT_LESS_OR_EQUAL_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_INT((threshold), (actual), __LINE__, (message)) #define TEST_ASSERT_LESS_OR_EQUAL_INT_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_INT((threshold), (actual), __LINE__, (message)) @@ -456,6 +469,7 @@ void verifyTest(void); #define TEST_ASSERT_LESS_OR_EQUAL_HEX16_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_HEX16((threshold), (actual), __LINE__, (message)) #define TEST_ASSERT_LESS_OR_EQUAL_HEX32_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_HEX32((threshold), (actual), __LINE__, (message)) #define TEST_ASSERT_LESS_OR_EQUAL_HEX64_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_HEX64((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_LESS_OR_EQUAL_CHAR_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_CHAR((threshold), (actual), __LINE__, (message)) /* Integer Ranges (of all sizes) */ #define TEST_ASSERT_INT_WITHIN_MESSAGE(delta, expected, actual, message) UNITY_TEST_ASSERT_INT_WITHIN((delta), (expected), (actual), __LINE__, (message)) @@ -474,6 +488,7 @@ void verifyTest(void); #define TEST_ASSERT_HEX16_WITHIN_MESSAGE(delta, expected, actual, message) UNITY_TEST_ASSERT_HEX16_WITHIN((delta), (expected), (actual), __LINE__, (message)) #define TEST_ASSERT_HEX32_WITHIN_MESSAGE(delta, expected, actual, message) UNITY_TEST_ASSERT_HEX32_WITHIN((delta), (expected), (actual), __LINE__, (message)) #define TEST_ASSERT_HEX64_WITHIN_MESSAGE(delta, expected, actual, message) UNITY_TEST_ASSERT_HEX64_WITHIN((delta), (expected), (actual), __LINE__, (message)) +#define TEST_ASSERT_CHAR_WITHIN_MESSAGE(delta, expected, actual, message) UNITY_TEST_ASSERT_CHAR_WITHIN((delta), (expected), (actual), __LINE__, (message)) /* Integer Array Ranges (of all sizes) */ #define TEST_ASSERT_INT_ARRAY_WITHIN_MESSAGE(delta, expected, actual, num_elements, message) UNITY_TEST_ASSERT_INT_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, (message)) @@ -492,6 +507,7 @@ void verifyTest(void); #define TEST_ASSERT_HEX16_ARRAY_WITHIN_MESSAGE(delta, expected, actual, num_elements, message) UNITY_TEST_ASSERT_HEX16_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, (message)) #define TEST_ASSERT_HEX32_ARRAY_WITHIN_MESSAGE(delta, expected, actual, num_elements, message) UNITY_TEST_ASSERT_HEX32_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, (message)) #define TEST_ASSERT_HEX64_ARRAY_WITHIN_MESSAGE(delta, expected, actual, num_elements, message) UNITY_TEST_ASSERT_HEX64_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, (message)) +#define TEST_ASSERT_CHAR_ARRAY_WITHIN_MESSAGE(delta, expected, actual, num_elements, message) UNITY_TEST_ASSERT_CHAR_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, (message)) /* Structs and Strings */ @@ -520,6 +536,7 @@ void verifyTest(void); #define TEST_ASSERT_EQUAL_PTR_ARRAY_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EQUAL_PTR_ARRAY((expected), (actual), (num_elements), __LINE__, (message)) #define TEST_ASSERT_EQUAL_STRING_ARRAY_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EQUAL_STRING_ARRAY((expected), (actual), (num_elements), __LINE__, (message)) #define TEST_ASSERT_EQUAL_MEMORY_ARRAY_MESSAGE(expected, actual, len, num_elements, message) UNITY_TEST_ASSERT_EQUAL_MEMORY_ARRAY((expected), (actual), (len), (num_elements), __LINE__, (message)) +#define TEST_ASSERT_EQUAL_CHAR_ARRAY_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EQUAL_CHAR_ARRAY((expected), (actual), (num_elements), __LINE__, (message)) /* Arrays Compared To Single Value*/ #define TEST_ASSERT_EACH_EQUAL_INT_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EACH_EQUAL_INT((expected), (actual), (num_elements), __LINE__, (message)) @@ -541,6 +558,7 @@ void verifyTest(void); #define TEST_ASSERT_EACH_EQUAL_PTR_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EACH_EQUAL_PTR((expected), (actual), (num_elements), __LINE__, (message)) #define TEST_ASSERT_EACH_EQUAL_STRING_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EACH_EQUAL_STRING((expected), (actual), (num_elements), __LINE__, (message)) #define TEST_ASSERT_EACH_EQUAL_MEMORY_MESSAGE(expected, actual, len, num_elements, message) UNITY_TEST_ASSERT_EACH_EQUAL_MEMORY((expected), (actual), (len), (num_elements), __LINE__, (message)) +#define TEST_ASSERT_EACH_EQUAL_CHAR_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EACH_EQUAL_CHAR((expected), (actual), (num_elements), __LINE__, (message)) /* Floating Point (If Enabled) */ #define TEST_ASSERT_FLOAT_WITHIN_MESSAGE(delta, expected, actual, message) UNITY_TEST_ASSERT_FLOAT_WITHIN((delta), (expected), (actual), __LINE__, (message)) diff --git a/src/unity_internals.h b/src/unity_internals.h index 11524f06..7e2024f8 100644 --- a/src/unity_internals.h +++ b/src/unity_internals.h @@ -381,6 +381,7 @@ typedef void (*UnityTestFunction)(void); #define UNITY_DISPLAY_RANGE_INT (0x10) #define UNITY_DISPLAY_RANGE_UINT (0x20) #define UNITY_DISPLAY_RANGE_HEX (0x40) +#define UNITY_DISPLAY_RANGE_CHAR (0x80) typedef enum { @@ -407,6 +408,8 @@ typedef enum UNITY_DISPLAY_STYLE_HEX64 = 8 + UNITY_DISPLAY_RANGE_HEX, #endif + UNITY_DISPLAY_STYLE_CHAR = 1 + UNITY_DISPLAY_RANGE_CHAR + UNITY_DISPLAY_RANGE_INT, + UNITY_DISPLAY_STYLE_UNKNOWN } UNITY_DISPLAY_STYLE_T; @@ -764,6 +767,7 @@ int UnityTestMatches(void); #define UNITY_TEST_ASSERT_EQUAL_HEX8(expected, actual, line, message) UnityAssertEqualNumber((UNITY_INT)(UNITY_INT8 )(expected), (UNITY_INT)(UNITY_INT8 )(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX8) #define UNITY_TEST_ASSERT_EQUAL_HEX16(expected, actual, line, message) UnityAssertEqualNumber((UNITY_INT)(UNITY_INT16)(expected), (UNITY_INT)(UNITY_INT16)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX16) #define UNITY_TEST_ASSERT_EQUAL_HEX32(expected, actual, line, message) UnityAssertEqualNumber((UNITY_INT)(UNITY_INT32)(expected), (UNITY_INT)(UNITY_INT32)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX32) +#define UNITY_TEST_ASSERT_EQUAL_CHAR(expected, actual, line, message) UnityAssertEqualNumber((UNITY_INT)(UNITY_INT8 )(expected), (UNITY_INT)(UNITY_INT8 )(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_CHAR) #define UNITY_TEST_ASSERT_BITS(mask, expected, actual, line, message) UnityAssertBits((UNITY_INT)(mask), (UNITY_INT)(expected), (UNITY_INT)(actual), (message), (UNITY_LINE_TYPE)(line)) #define UNITY_TEST_ASSERT_GREATER_THAN_INT(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(threshold), (UNITY_INT)(actual), UNITY_GREATER_THAN, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT) @@ -777,6 +781,7 @@ int UnityTestMatches(void); #define UNITY_TEST_ASSERT_GREATER_THAN_HEX8(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_UINT8 )(threshold), (UNITY_INT)(UNITY_UINT8 )(actual), UNITY_GREATER_THAN, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX8) #define UNITY_TEST_ASSERT_GREATER_THAN_HEX16(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_UINT16)(threshold), (UNITY_INT)(UNITY_UINT16)(actual), UNITY_GREATER_THAN, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX16) #define UNITY_TEST_ASSERT_GREATER_THAN_HEX32(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_UINT32)(threshold), (UNITY_INT)(UNITY_UINT32)(actual), UNITY_GREATER_THAN, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX32) +#define UNITY_TEST_ASSERT_GREATER_THAN_CHAR(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_INT8 )(threshold), (UNITY_INT)(UNITY_INT8 )(actual), UNITY_GREATER_THAN, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_CHAR) #define UNITY_TEST_ASSERT_SMALLER_THAN_INT(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(threshold), (UNITY_INT)(actual), UNITY_SMALLER_THAN, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT) #define UNITY_TEST_ASSERT_SMALLER_THAN_INT8(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_INT8 )(threshold), (UNITY_INT)(UNITY_INT8 )(actual), UNITY_SMALLER_THAN, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT8) @@ -789,6 +794,7 @@ int UnityTestMatches(void); #define UNITY_TEST_ASSERT_SMALLER_THAN_HEX8(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_UINT8 )(threshold), (UNITY_INT)(UNITY_UINT8 )(actual), UNITY_SMALLER_THAN, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX8) #define UNITY_TEST_ASSERT_SMALLER_THAN_HEX16(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_UINT16)(threshold), (UNITY_INT)(UNITY_UINT16)(actual), UNITY_SMALLER_THAN, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX16) #define UNITY_TEST_ASSERT_SMALLER_THAN_HEX32(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_UINT32)(threshold), (UNITY_INT)(UNITY_UINT32)(actual), UNITY_SMALLER_THAN, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX32) +#define UNITY_TEST_ASSERT_SMALLER_THAN_CHAR(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_INT8 )(threshold), (UNITY_INT)(UNITY_INT8 )(actual), UNITY_SMALLER_THAN, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_CHAR) #define UNITY_TEST_ASSERT_GREATER_OR_EQUAL_INT(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT) (threshold), (UNITY_INT) (actual), UNITY_GREATER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT) #define UNITY_TEST_ASSERT_GREATER_OR_EQUAL_INT8(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_INT8 ) (threshold), (UNITY_INT)(UNITY_INT8 ) (actual), UNITY_GREATER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT8) @@ -801,6 +807,7 @@ int UnityTestMatches(void); #define UNITY_TEST_ASSERT_GREATER_OR_EQUAL_HEX8(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_UINT8 )(threshold), (UNITY_INT)(UNITY_UINT8 )(actual), UNITY_GREATER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX8) #define UNITY_TEST_ASSERT_GREATER_OR_EQUAL_HEX16(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_UINT16)(threshold), (UNITY_INT)(UNITY_UINT16)(actual), UNITY_GREATER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX16) #define UNITY_TEST_ASSERT_GREATER_OR_EQUAL_HEX32(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_UINT32)(threshold), (UNITY_INT)(UNITY_UINT32)(actual), UNITY_GREATER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX32) +#define UNITY_TEST_ASSERT_GREATER_OR_EQUAL_CHAR(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_INT8 ) (threshold), (UNITY_INT)(UNITY_INT8 ) (actual), UNITY_GREATER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_CHAR) #define UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_INT(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT) (threshold), (UNITY_INT) (actual), UNITY_SMALLER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT) #define UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_INT8(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_INT8 )(threshold), (UNITY_INT)(UNITY_INT8 ) (actual), UNITY_SMALLER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT8) @@ -813,6 +820,7 @@ int UnityTestMatches(void); #define UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_HEX8(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_UINT8 )(threshold), (UNITY_INT)(UNITY_UINT8 )(actual), UNITY_SMALLER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX8) #define UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_HEX16(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_UINT16)(threshold), (UNITY_INT)(UNITY_UINT16)(actual), UNITY_SMALLER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX16) #define UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_HEX32(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_UINT32)(threshold), (UNITY_INT)(UNITY_UINT32)(actual), UNITY_SMALLER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX32) +#define UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_CHAR(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_INT8 )(threshold), (UNITY_INT)(UNITY_INT8 ) (actual), UNITY_SMALLER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_CHAR) #define UNITY_TEST_ASSERT_INT_WITHIN(delta, expected, actual, line, message) UnityAssertNumbersWithin( (delta), (UNITY_INT) (expected), (UNITY_INT) (actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT) #define UNITY_TEST_ASSERT_INT8_WITHIN(delta, expected, actual, line, message) UnityAssertNumbersWithin((UNITY_UINT8 )(delta), (UNITY_INT)(UNITY_INT8 ) (expected), (UNITY_INT)(UNITY_INT8 ) (actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT8) @@ -825,7 +833,7 @@ int UnityTestMatches(void); #define UNITY_TEST_ASSERT_HEX8_WITHIN(delta, expected, actual, line, message) UnityAssertNumbersWithin((UNITY_UINT8 )(delta), (UNITY_INT)(UNITY_UINT)(UNITY_UINT8 )(expected), (UNITY_INT)(UNITY_UINT)(UNITY_UINT8 )(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX8) #define UNITY_TEST_ASSERT_HEX16_WITHIN(delta, expected, actual, line, message) UnityAssertNumbersWithin((UNITY_UINT16)(delta), (UNITY_INT)(UNITY_UINT)(UNITY_UINT16)(expected), (UNITY_INT)(UNITY_UINT)(UNITY_UINT16)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX16) #define UNITY_TEST_ASSERT_HEX32_WITHIN(delta, expected, actual, line, message) UnityAssertNumbersWithin((UNITY_UINT32)(delta), (UNITY_INT)(UNITY_UINT)(UNITY_UINT32)(expected), (UNITY_INT)(UNITY_UINT)(UNITY_UINT32)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX32) - +#define UNITY_TEST_ASSERT_CHAR_WITHIN(delta, expected, actual, line, message) UnityAssertNumbersWithin((UNITY_UINT8 )(delta), (UNITY_INT)(UNITY_INT8 ) (expected), (UNITY_INT)(UNITY_INT8 ) (actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_CHAR) #define UNITY_TEST_ASSERT_INT_ARRAY_WITHIN(delta, expected, actual, num_elements, line, message) UnityAssertNumbersArrayWithin( (delta), (UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), ((UNITY_UINT32)(num_elements)), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT, UNITY_ARRAY_TO_ARRAY) #define UNITY_TEST_ASSERT_INT8_ARRAY_WITHIN(delta, expected, actual, num_elements, line, message) UnityAssertNumbersArrayWithin((UNITY_UINT8 )(delta), (UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), ((UNITY_UINT32)(num_elements)), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT8, UNITY_ARRAY_TO_ARRAY) @@ -838,6 +846,7 @@ int UnityTestMatches(void); #define UNITY_TEST_ASSERT_HEX8_ARRAY_WITHIN(delta, expected, actual, num_elements, line, message) UnityAssertNumbersArrayWithin((UNITY_UINT8 )(delta), (UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), ((UNITY_UINT32)(num_elements)), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX8, UNITY_ARRAY_TO_ARRAY) #define UNITY_TEST_ASSERT_HEX16_ARRAY_WITHIN(delta, expected, actual, num_elements, line, message) UnityAssertNumbersArrayWithin((UNITY_UINT16)(delta), (UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), ((UNITY_UINT32)(num_elements)), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX16, UNITY_ARRAY_TO_ARRAY) #define UNITY_TEST_ASSERT_HEX32_ARRAY_WITHIN(delta, expected, actual, num_elements, line, message) UnityAssertNumbersArrayWithin((UNITY_UINT32)(delta), (UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), ((UNITY_UINT32)(num_elements)), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX32, UNITY_ARRAY_TO_ARRAY) +#define UNITY_TEST_ASSERT_CHAR_ARRAY_WITHIN(delta, expected, actual, num_elements, line, message) UnityAssertNumbersArrayWithin((UNITY_UINT8 )(delta), (UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), ((UNITY_UINT32)(num_elements)), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_CHAR, UNITY_ARRAY_TO_ARRAY) #define UNITY_TEST_ASSERT_EQUAL_PTR(expected, actual, line, message) UnityAssertEqualNumber((UNITY_PTR_TO_INT)(expected), (UNITY_PTR_TO_INT)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_POINTER) @@ -859,6 +868,7 @@ int UnityTestMatches(void); #define UNITY_TEST_ASSERT_EQUAL_PTR_ARRAY(expected, actual, num_elements, line, message) UnityAssertEqualIntArray((UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_POINTER, UNITY_ARRAY_TO_ARRAY) #define UNITY_TEST_ASSERT_EQUAL_STRING_ARRAY(expected, actual, num_elements, line, message) UnityAssertEqualStringArray((UNITY_INTERNAL_PTR)(expected), (const char**)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_ARRAY_TO_ARRAY) #define UNITY_TEST_ASSERT_EQUAL_MEMORY_ARRAY(expected, actual, len, num_elements, line, message) UnityAssertEqualMemory((UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(len), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_ARRAY_TO_ARRAY) +#define UNITY_TEST_ASSERT_EQUAL_CHAR_ARRAY(expected, actual, num_elements, line, message) UnityAssertEqualIntArray((UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_CHAR, UNITY_ARRAY_TO_ARRAY) #define UNITY_TEST_ASSERT_EACH_EQUAL_INT(expected, actual, num_elements, line, message) UnityAssertEqualIntArray(UnityNumToPtr((UNITY_INT) (expected), (UNITY_INT_WIDTH / 8)), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT, UNITY_ARRAY_TO_VAL) #define UNITY_TEST_ASSERT_EACH_EQUAL_INT8(expected, actual, num_elements, line, message) UnityAssertEqualIntArray(UnityNumToPtr((UNITY_INT)(UNITY_INT8 )(expected), 1), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT8, UNITY_ARRAY_TO_VAL) @@ -874,6 +884,7 @@ int UnityTestMatches(void); #define UNITY_TEST_ASSERT_EACH_EQUAL_PTR(expected, actual, num_elements, line, message) UnityAssertEqualIntArray(UnityNumToPtr((UNITY_PTR_TO_INT) (expected), (UNITY_POINTER_WIDTH / 8)), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_POINTER, UNITY_ARRAY_TO_VAL) #define UNITY_TEST_ASSERT_EACH_EQUAL_STRING(expected, actual, num_elements, line, message) UnityAssertEqualStringArray((UNITY_INTERNAL_PTR)(expected), (const char**)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_ARRAY_TO_VAL) #define UNITY_TEST_ASSERT_EACH_EQUAL_MEMORY(expected, actual, len, num_elements, line, message) UnityAssertEqualMemory((UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(len), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_ARRAY_TO_VAL) +#define UNITY_TEST_ASSERT_EACH_EQUAL_CHAR(expected, actual, num_elements, line, message) UnityAssertEqualIntArray(UnityNumToPtr((UNITY_INT)(UNITY_INT8 )(expected), 1), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_CHAR, UNITY_ARRAY_TO_VAL) #ifdef UNITY_SUPPORT_64 #define UNITY_TEST_ASSERT_EQUAL_INT64(expected, actual, line, message) UnityAssertEqualNumber((UNITY_INT)(expected), (UNITY_INT)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT64) diff --git a/test/tests/testunity.c b/test/tests/testunity.c index c9712eda..9f2d6928 100644 --- a/test/tests/testunity.c +++ b/test/tests/testunity.c @@ -288,6 +288,13 @@ void testNotEqualInt8s(void) VERIFY_FAILS_END } +void testNotEqualChars(void) +{ + EXPECT_ABORT_BEGIN + TEST_ASSERT_EQUAL_CHAR('A', 'a'); + VERIFY_FAILS_END +} + void testNotEqualInt16s(void) { EXPECT_ABORT_BEGIN @@ -476,6 +483,32 @@ void testEqualInt8sWhenThereAreDifferencesOutside8Bits(void) TEST_ASSERT_EQUAL_INT8(0xFF21,0x0021); } +void testEqualChars(void) +{ + char v0, v1; + char *p0, *p1; + + v0 = 'A'; + v1 = 'A'; + p0 = &v0; + p1 = &v1; + + TEST_ASSERT_EQUAL_CHAR('A', 'A'); + TEST_ASSERT_EQUAL_CHAR(v0, v1); + TEST_ASSERT_EQUAL_CHAR('A', v1); + TEST_ASSERT_EQUAL_CHAR(v0, 'A'); + TEST_ASSERT_EQUAL_CHAR(*p0, v1); + TEST_ASSERT_EQUAL_CHAR(*p0, *p1); + TEST_ASSERT_EQUAL_CHAR(*p0, 'A'); +} + +void testEqualCharsWhenThereAreDifferencesOutside8Bits(void) +{ + TEST_ASSERT_EQUAL_CHAR(0x321,0x421); + TEST_ASSERT_EQUAL_CHAR(0xFF21,0x0021); +} + + void testEqualInt16s(void) { UNITY_INT16 v0, v1; @@ -844,24 +877,24 @@ void testEqualUShorts(void) TEST_ASSERT_EQUAL_UINT(*p0, 19467); } -void testEqualChars(void) +void testEqualUInts(void) { - signed char v0, v1; - signed char *p0, *p1; + unsigned char v0, v1; + unsigned char *p0, *p1; v0 = 109; v1 = 109; p0 = &v0; p1 = &v1; - TEST_ASSERT_EQUAL_INT(42, 42); - TEST_ASSERT_EQUAL_INT(-116, -116); - TEST_ASSERT_EQUAL_INT(v0, v1); - TEST_ASSERT_EQUAL_INT(109, v1); - TEST_ASSERT_EQUAL_INT(v0, 109); - TEST_ASSERT_EQUAL_INT(*p0, v1); - TEST_ASSERT_EQUAL_INT(*p0, *p1); - TEST_ASSERT_EQUAL_INT(*p0, 109); + TEST_ASSERT_EQUAL_UINT(42, 42); + TEST_ASSERT_EQUAL_UINT(-116, -116); + TEST_ASSERT_EQUAL_UINT(v0, v1); + TEST_ASSERT_EQUAL_UINT(109, v1); + TEST_ASSERT_EQUAL_UINT(v0, 109); + TEST_ASSERT_EQUAL_UINT(*p0, v1); + TEST_ASSERT_EQUAL_UINT(*p0, *p1); + TEST_ASSERT_EQUAL_UINT(*p0, 109); } void testEqualUChars(void) @@ -1343,6 +1376,42 @@ void testINT8sNotWithinDeltaAndCustomMessage(void) VERIFY_FAILS_END } +void testCHARsWithinDelta(void) +{ + TEST_ASSERT_CHAR_WITHIN(1, 'M', 'L'); + TEST_ASSERT_CHAR_WITHIN(5, -2, 2); + TEST_ASSERT_CHAR_WITHIN(5, 2, -2); +} + +void testCHARsWithinDeltaAndCustomMessage(void) +{ + TEST_ASSERT_CHAR_WITHIN_MESSAGE(5, 1, 4, "Custom Message."); +} + +void testCHARsWithinDeltaWhenThereAreDifferenceOutsideOf8Bits(void) +{ + TEST_ASSERT_CHAR_WITHIN(5, 0x123, 0xF23); +} + +void testCHARsWithinDeltaWhenThereAreDifferenceOutsideOf8BitsAndCustomMessage(void) +{ + TEST_ASSERT_CHAR_WITHIN_MESSAGE(5, 0x123, 0xF23, "Custom Message."); +} + +void testCHARsNotWithinDelta(void) +{ + EXPECT_ABORT_BEGIN + TEST_ASSERT_CHAR_WITHIN(2, -3, 0); + VERIFY_FAILS_END +} + +void testCHARsNotWithinDeltaAndCustomMessage(void) +{ + EXPECT_ABORT_BEGIN + TEST_ASSERT_CHAR_WITHIN_MESSAGE(2, -4, 0, "Custom Message."); + VERIFY_FAILS_END +} + /*------------------------*/ void testInt64ArrayWithinDelta(void) @@ -1352,10 +1421,10 @@ void testInt64ArrayWithinDelta(void) #else UNITY_INT64 expected[] = {12345000, -12344995, 12345005}; UNITY_INT64 acutalSmallDelta[] = {12345001, -12344996, 12345005}; - UNITY_INT64 acutalBigDelta[] = {12345101, -12344896, 12345055}; + UNITY_INT64 actualBigDelta[] = {12345101, -12344896, 12345055}; TEST_ASSERT_INT64_ARRAY_WITHIN(1, expected, acutalSmallDelta, 3); - TEST_ASSERT_INT64_ARRAY_WITHIN(110, expected, acutalBigDelta, 3); + TEST_ASSERT_INT64_ARRAY_WITHIN(110, expected, actualBigDelta, 3); #endif } @@ -1366,10 +1435,10 @@ void testInt64ArrayWithinDeltaAndMessage(void) #else UNITY_INT64 expected[] = {12345000, -12344995, 12345005}; UNITY_INT64 acutalSmallDelta[] = {12345001, -12344996, 12345005}; - UNITY_INT64 acutalBigDelta[] = {12345101, -12344896, 12345055}; + UNITY_INT64 actualBigDelta[] = {12345101, -12344896, 12345055}; TEST_ASSERT_INT64_ARRAY_WITHIN_MESSAGE(1, expected, acutalSmallDelta, 3, "Custom Message."); - TEST_ASSERT_INT64_ARRAY_WITHIN_MESSAGE(110, expected, acutalBigDelta, 3, "Custom Message."); + TEST_ASSERT_INT64_ARRAY_WITHIN_MESSAGE(110, expected, actualBigDelta, 3, "Custom Message."); #endif } @@ -1379,10 +1448,10 @@ void tesUInt64ArrayNotWithinDelta(void) TEST_IGNORE(); #else UNITY_INT64 expected[] = {12345000, -12344995, 12345005}; - UNITY_INT64 acutalBigDelta[] = {12345101, -12344896, 12345055}; + UNITY_INT64 actualBigDelta[] = {12345101, -12344896, 12345055}; EXPECT_ABORT_BEGIN - TEST_ASSERT_UINT64_ARRAY_WITHIN(1, expected, acutalBigDelta, 3); + TEST_ASSERT_UINT64_ARRAY_WITHIN(1, expected, actualBigDelta, 3); VERIFY_FAILS_END #endif } @@ -1393,10 +1462,10 @@ void testInt64ArrayNotWithinDeltaAndMessage(void) TEST_IGNORE(); #else UNITY_INT64 expected[] = {12345000, -12344995, 12345005}; - UNITY_INT64 acutalBigDelta[] = {12345101, -12344896, 12345055}; + UNITY_INT64 actualBigDelta[] = {12345101, -12344896, 12345055}; EXPECT_ABORT_BEGIN - TEST_ASSERT_INT64_ARRAY_WITHIN_MESSAGE(1, expected, acutalBigDelta, 3, "Custom Message."); + TEST_ASSERT_INT64_ARRAY_WITHIN_MESSAGE(1, expected, actualBigDelta, 3, "Custom Message."); VERIFY_FAILS_END #endif } @@ -1407,10 +1476,10 @@ void testInt64ArrayWithinDeltaPointless(void) TEST_IGNORE(); #else UNITY_INT64 expected[] = {12345000, -12344995, 12345005}; - UNITY_INT64 acutalBigDelta[] = {12345101, -12344896, 12345055}; + UNITY_INT64 actualBigDelta[] = {12345101, -12344896, 12345055}; EXPECT_ABORT_BEGIN - TEST_ASSERT_INT64_ARRAY_WITHIN(110, expected, acutalBigDelta, 0); + TEST_ASSERT_INT64_ARRAY_WITHIN(110, expected, actualBigDelta, 0); VERIFY_FAILS_END #endif } @@ -1421,10 +1490,10 @@ void testInt64ArrayWithinDeltaPointlessAndMessage(void) TEST_IGNORE(); #else UNITY_INT64 expected[] = {12345000, -12344995, 12345005}; - UNITY_INT64 acutalBigDelta[] = {12345101, -12344896, 12345055}; + UNITY_INT64 actualBigDelta[] = {12345101, -12344896, 12345055}; EXPECT_ABORT_BEGIN - TEST_ASSERT_INT64_ARRAY_WITHIN_MESSAGE(110, expected, acutalBigDelta, 0, "Custom Message."); + TEST_ASSERT_INT64_ARRAY_WITHIN_MESSAGE(110, expected, actualBigDelta, 0, "Custom Message."); VERIFY_FAILS_END #endif } @@ -1434,10 +1503,10 @@ void testInt64ArrayWithinDeltaExpectedNull(void) #ifndef UNITY_SUPPORT_64 TEST_IGNORE(); #else - UNITY_INT64 acutalBigDelta[] = {12345101, -12344896, 12345055}; + UNITY_INT64 actualBigDelta[] = {12345101, -12344896, 12345055}; EXPECT_ABORT_BEGIN - TEST_ASSERT_INT64_ARRAY_WITHIN(110, NULL, acutalBigDelta, 3); + TEST_ASSERT_INT64_ARRAY_WITHIN(110, NULL, actualBigDelta, 3); VERIFY_FAILS_END #endif } @@ -1447,10 +1516,10 @@ void testInt64ArrayWithinDeltaExpectedNullAndMessage(void) #ifndef UNITY_SUPPORT_64 TEST_IGNORE(); #else - UNITY_INT64 acutalBigDelta[] = {12345101, -12344896, 12345055}; + UNITY_INT64 actualBigDelta[] = {12345101, -12344896, 12345055}; EXPECT_ABORT_BEGIN - TEST_ASSERT_INT64_ARRAY_WITHIN_MESSAGE(110, NULL, acutalBigDelta, 3, "Custom Message."); + TEST_ASSERT_INT64_ARRAY_WITHIN_MESSAGE(110, NULL, actualBigDelta, 3, "Custom Message."); VERIFY_FAILS_END #endif } @@ -1507,77 +1576,77 @@ void testIntArrayWithinDelta(void) { UNITY_INT expected[] = {5000, -4995, 5005}; UNITY_INT acutalSmallDelta[] = {5001, -4996, 5005}; - UNITY_INT acutalBigDelta[] = {5101, -4896, 5055}; + UNITY_INT actualBigDelta[] = {5101, -4896, 5055}; TEST_ASSERT_INT_ARRAY_WITHIN(1, expected, acutalSmallDelta, 3); - TEST_ASSERT_INT_ARRAY_WITHIN(110, expected, acutalBigDelta, 3); + TEST_ASSERT_INT_ARRAY_WITHIN(110, expected, actualBigDelta, 3); } void testIntArrayWithinDeltaAndMessage(void) { UNITY_INT expected[] = {5000, -4995, 5005}; UNITY_INT acutalSmallDelta[] = {5001, -4996, 5005}; - UNITY_INT acutalBigDelta[] = {5101, -4896, 5055}; + UNITY_INT actualBigDelta[] = {5101, -4896, 5055}; TEST_ASSERT_INT_ARRAY_WITHIN_MESSAGE(1, expected, acutalSmallDelta, 3, "Custom Message."); - TEST_ASSERT_INT_ARRAY_WITHIN_MESSAGE(110, expected, acutalBigDelta, 3, "Custom Message."); + TEST_ASSERT_INT_ARRAY_WITHIN_MESSAGE(110, expected, actualBigDelta, 3, "Custom Message."); } void testIntArrayNotWithinDelta(void) { UNITY_INT expected[] = {5000, -4995, 5005}; - UNITY_INT acutalBigDelta[] = {5101, -4896, 5055}; + UNITY_INT actualBigDelta[] = {5101, -4896, 5055}; EXPECT_ABORT_BEGIN - TEST_ASSERT_INT_ARRAY_WITHIN(1, expected, acutalBigDelta, 3); + TEST_ASSERT_INT_ARRAY_WITHIN(1, expected, actualBigDelta, 3); VERIFY_FAILS_END } void testIntArrayNotWithinDeltaAndMessage(void) { UNITY_INT expected[] = {5000, -4995, 5005}; - UNITY_INT acutalBigDelta[] = {5101, -4896, 5055}; + UNITY_INT actualBigDelta[] = {5101, -4896, 5055}; EXPECT_ABORT_BEGIN - TEST_ASSERT_INT_ARRAY_WITHIN_MESSAGE(1, expected, acutalBigDelta, 3, "Custom Message."); + TEST_ASSERT_INT_ARRAY_WITHIN_MESSAGE(1, expected, actualBigDelta, 3, "Custom Message."); VERIFY_FAILS_END } void testIntArrayWithinDeltaPointless(void) { UNITY_INT expected[] = {5000, -4995, 5005}; - UNITY_INT acutalBigDelta[] = {5101, -4896, 5055}; + UNITY_INT actualBigDelta[] = {5101, -4896, 5055}; EXPECT_ABORT_BEGIN - TEST_ASSERT_INT_ARRAY_WITHIN(110, expected, acutalBigDelta, 0); + TEST_ASSERT_INT_ARRAY_WITHIN(110, expected, actualBigDelta, 0); VERIFY_FAILS_END } void testIntArrayWithinDeltaPointlessAndMessage(void) { UNITY_INT expected[] = {5000, -4995, 5005}; - UNITY_INT acutalBigDelta[] = {5101, -4896, 5055}; + UNITY_INT actualBigDelta[] = {5101, -4896, 5055}; EXPECT_ABORT_BEGIN - TEST_ASSERT_INT_ARRAY_WITHIN_MESSAGE(110, expected, acutalBigDelta, 0, "Custom Message."); + TEST_ASSERT_INT_ARRAY_WITHIN_MESSAGE(110, expected, actualBigDelta, 0, "Custom Message."); VERIFY_FAILS_END } void testIntArrayWithinDeltaExpectedNull(void) { - UNITY_INT acutalBigDelta[] = {5101, -4896, 5055}; + UNITY_INT actualBigDelta[] = {5101, -4896, 5055}; EXPECT_ABORT_BEGIN - TEST_ASSERT_INT_ARRAY_WITHIN(110, NULL, acutalBigDelta, 3); + TEST_ASSERT_INT_ARRAY_WITHIN(110, NULL, actualBigDelta, 3); VERIFY_FAILS_END } void testIntArrayWithinDeltaExpectedNullAndMessage(void) { - UNITY_INT acutalBigDelta[] = {5101, -4896, 5055}; + UNITY_INT actualBigDelta[] = {5101, -4896, 5055}; EXPECT_ABORT_BEGIN - TEST_ASSERT_INT_ARRAY_WITHIN_MESSAGE(110, NULL, acutalBigDelta, 3, "Custom Message."); + TEST_ASSERT_INT_ARRAY_WITHIN_MESSAGE(110, NULL, actualBigDelta, 3, "Custom Message."); VERIFY_FAILS_END } @@ -1617,77 +1686,77 @@ void testInt16ArrayWithinDelta(void) { UNITY_INT16 expected[] = {5000, -4995, 5005}; UNITY_INT16 acutalSmallDelta[] = {5001, -4996, 5005}; - UNITY_INT16 acutalBigDelta[] = {5101, -4896, 5055}; + UNITY_INT16 actualBigDelta[] = {5101, -4896, 5055}; TEST_ASSERT_INT16_ARRAY_WITHIN(1, expected, acutalSmallDelta, 3); - TEST_ASSERT_INT16_ARRAY_WITHIN(110, expected, acutalBigDelta, 3); + TEST_ASSERT_INT16_ARRAY_WITHIN(110, expected, actualBigDelta, 3); } void testInt16ArrayWithinDeltaAndMessage(void) { UNITY_INT16 expected[] = {5000, -4995, 5005}; UNITY_INT16 acutalSmallDelta[] = {5001, -4996, 5005}; - UNITY_INT16 acutalBigDelta[] = {5101, -4896, 5055}; + UNITY_INT16 actualBigDelta[] = {5101, -4896, 5055}; TEST_ASSERT_INT16_ARRAY_WITHIN_MESSAGE(1, expected, acutalSmallDelta, 3, "Custom Message."); - TEST_ASSERT_INT16_ARRAY_WITHIN_MESSAGE(110, expected, acutalBigDelta, 3, "Custom Message."); + TEST_ASSERT_INT16_ARRAY_WITHIN_MESSAGE(110, expected, actualBigDelta, 3, "Custom Message."); } void testInt16ArrayNotWithinDelta(void) { UNITY_INT16 expected[] = {5000, -4995, 5005}; - UNITY_INT16 acutalBigDelta[] = {5101, -4896, 5055}; + UNITY_INT16 actualBigDelta[] = {5101, -4896, 5055}; EXPECT_ABORT_BEGIN - TEST_ASSERT_UINT16_ARRAY_WITHIN(1, expected, acutalBigDelta, 3); + TEST_ASSERT_UINT16_ARRAY_WITHIN(1, expected, actualBigDelta, 3); VERIFY_FAILS_END } void testInt16ArrayNotWithinDeltaAndMessage(void) { UNITY_INT16 expected[] = {5000, -4995, 5005}; - UNITY_INT16 acutalBigDelta[] = {5101, -4896, 5055}; + UNITY_INT16 actualBigDelta[] = {5101, -4896, 5055}; EXPECT_ABORT_BEGIN - TEST_ASSERT_INT16_ARRAY_WITHIN_MESSAGE(1, expected, acutalBigDelta, 3, "Custom Message."); + TEST_ASSERT_INT16_ARRAY_WITHIN_MESSAGE(1, expected, actualBigDelta, 3, "Custom Message."); VERIFY_FAILS_END } void testInt16ArrayWithinDeltaPointless(void) { UNITY_INT16 expected[] = {5000, -4995, 5005}; - UNITY_INT16 acutalBigDelta[] = {5101, -4896, 5055}; + UNITY_INT16 actualBigDelta[] = {5101, -4896, 5055}; EXPECT_ABORT_BEGIN - TEST_ASSERT_INT16_ARRAY_WITHIN(110, expected, acutalBigDelta, 0); + TEST_ASSERT_INT16_ARRAY_WITHIN(110, expected, actualBigDelta, 0); VERIFY_FAILS_END } void testInt16ArrayWithinDeltaPointlessAndMessage(void) { UNITY_INT16 expected[] = {5000, -4995, 5005}; - UNITY_INT16 acutalBigDelta[] = {5101, -4896, 5055}; + UNITY_INT16 actualBigDelta[] = {5101, -4896, 5055}; EXPECT_ABORT_BEGIN - TEST_ASSERT_INT16_ARRAY_WITHIN_MESSAGE(110, expected, acutalBigDelta, 0, "Custom Message."); + TEST_ASSERT_INT16_ARRAY_WITHIN_MESSAGE(110, expected, actualBigDelta, 0, "Custom Message."); VERIFY_FAILS_END } void testInt16ArrayWithinDeltaExpectedNull(void) { - UNITY_INT16 acutalBigDelta[] = {5101, -4896, 5055}; + UNITY_INT16 actualBigDelta[] = {5101, -4896, 5055}; EXPECT_ABORT_BEGIN - TEST_ASSERT_INT16_ARRAY_WITHIN(110, NULL, acutalBigDelta, 3); + TEST_ASSERT_INT16_ARRAY_WITHIN(110, NULL, actualBigDelta, 3); VERIFY_FAILS_END } void testInt16ArrayWithinDeltaExpectedNullAndMessage(void) { - UNITY_INT16 acutalBigDelta[] = {5101, -4896, 5055}; + UNITY_INT16 actualBigDelta[] = {5101, -4896, 5055}; EXPECT_ABORT_BEGIN - TEST_ASSERT_INT16_ARRAY_WITHIN_MESSAGE(110, NULL, acutalBigDelta, 3, "Custom Message."); + TEST_ASSERT_INT16_ARRAY_WITHIN_MESSAGE(110, NULL, actualBigDelta, 3, "Custom Message."); VERIFY_FAILS_END } @@ -1727,77 +1796,77 @@ void testInt8ArrayWithinDelta(void) { UNITY_INT8 expected[] = {20, -95, 55}; UNITY_INT8 acutalSmallDelta[] = {21, -94, 55}; - UNITY_INT8 acutalBigDelta[] = {11, -86, 45}; + UNITY_INT8 actualBigDelta[] = {11, -86, 45}; TEST_ASSERT_INT8_ARRAY_WITHIN(1, expected, acutalSmallDelta, 3); - TEST_ASSERT_INT8_ARRAY_WITHIN(11, expected, acutalBigDelta, 3); + TEST_ASSERT_INT8_ARRAY_WITHIN(11, expected, actualBigDelta, 3); } void testInt8ArrayWithinDeltaAndMessage(void) { UNITY_INT8 expected[] = {20, -95, 55}; UNITY_INT8 acutalSmallDelta[] = {21, -94, 55}; - UNITY_INT8 acutalBigDelta[] = {11, -86, 45}; + UNITY_INT8 actualBigDelta[] = {11, -86, 45}; TEST_ASSERT_INT8_ARRAY_WITHIN_MESSAGE(1, expected, acutalSmallDelta, 3, "Custom Message."); - TEST_ASSERT_INT8_ARRAY_WITHIN_MESSAGE(11, expected, acutalBigDelta, 3, "Custom Message."); + TEST_ASSERT_INT8_ARRAY_WITHIN_MESSAGE(11, expected, actualBigDelta, 3, "Custom Message."); } void testInt8ArrayNotWithinDelta(void) { UNITY_INT8 expected[] = {20, -95, 55}; - UNITY_INT8 acutalBigDelta[] = {11, -86, 45}; + UNITY_INT8 actualBigDelta[] = {11, -86, 45}; EXPECT_ABORT_BEGIN - TEST_ASSERT_INT8_ARRAY_WITHIN(1, expected, acutalBigDelta, 3); + TEST_ASSERT_INT8_ARRAY_WITHIN(1, expected, actualBigDelta, 3); VERIFY_FAILS_END } void testInt8ArrayNotWithinDeltaAndMessage(void) { UNITY_INT8 expected[] = {20, -95, 55}; - UNITY_INT8 acutalBigDelta[] = {11, -86, 45}; + UNITY_INT8 actualBigDelta[] = {11, -86, 45}; EXPECT_ABORT_BEGIN - TEST_ASSERT_INT8_ARRAY_WITHIN_MESSAGE(1, expected, acutalBigDelta, 3, "Custom Message."); + TEST_ASSERT_INT8_ARRAY_WITHIN_MESSAGE(1, expected, actualBigDelta, 3, "Custom Message."); VERIFY_FAILS_END } void testInt8ArrayWithinDeltaPointless(void) { UNITY_INT8 expected[] = {20, -95, 55}; - UNITY_INT8 acutalBigDelta[] = {11, -86, 45}; + UNITY_INT8 actualBigDelta[] = {11, -86, 45}; EXPECT_ABORT_BEGIN - TEST_ASSERT_INT8_ARRAY_WITHIN(11, expected, acutalBigDelta, 0); + TEST_ASSERT_INT8_ARRAY_WITHIN(11, expected, actualBigDelta, 0); VERIFY_FAILS_END } void testInt8ArrayWithinDeltaPointlessAndMessage(void) { UNITY_INT8 expected[] = {20, -95, 55}; - UNITY_INT8 acutalBigDelta[] = {11, -86, 45}; + UNITY_INT8 actualBigDelta[] = {11, -86, 45}; EXPECT_ABORT_BEGIN - TEST_ASSERT_INT8_ARRAY_WITHIN_MESSAGE(11, expected, acutalBigDelta, 0, "Custom Message."); + TEST_ASSERT_INT8_ARRAY_WITHIN_MESSAGE(11, expected, actualBigDelta, 0, "Custom Message."); VERIFY_FAILS_END } void testInt8ArrayWithinDeltaExpectedNull(void) { - UNITY_INT8 acutalBigDelta[] = {11, -86, 45}; + UNITY_INT8 actualBigDelta[] = {11, -86, 45}; EXPECT_ABORT_BEGIN - TEST_ASSERT_INT8_ARRAY_WITHIN(11, NULL, acutalBigDelta, 3); + TEST_ASSERT_INT8_ARRAY_WITHIN(11, NULL, actualBigDelta, 3); VERIFY_FAILS_END } void testInt8ArrayWithinDeltaExpectedNullAndMessage(void) { - UNITY_INT8 acutalBigDelta[] = {11, -86, 45}; + UNITY_INT8 actualBigDelta[] = {11, -86, 45}; EXPECT_ABORT_BEGIN - TEST_ASSERT_INT8_ARRAY_WITHIN_MESSAGE(11, NULL, acutalBigDelta, 3, "Custom Message."); + TEST_ASSERT_INT8_ARRAY_WITHIN_MESSAGE(11, NULL, actualBigDelta, 3, "Custom Message."); VERIFY_FAILS_END } @@ -1833,6 +1902,120 @@ void testInt8ArrayWithinDeltaSamePointerAndMessage(void) TEST_ASSERT_INT8_ARRAY_WITHIN_MESSAGE(11, expected, expected, 3, "Custom Message."); } + + + + +void testCHARArrayWithinDelta(void) +{ + char expected[] = {20, -95, 55}; + char acutalSmallDelta[] = {21, -94, 55}; + char actualBigDelta[] = {11, -86, 45}; + + TEST_ASSERT_CHAR_ARRAY_WITHIN(1, expected, acutalSmallDelta, 3); + TEST_ASSERT_CHAR_ARRAY_WITHIN(11, expected, actualBigDelta, 3); +} + +void testCHARArrayWithinDeltaAndMessage(void) +{ + char expected[] = {20, -95, 55}; + char acutalSmallDelta[] = {21, -94, 55}; + char actualBigDelta[] = {11, -86, 45}; + + TEST_ASSERT_CHAR_ARRAY_WITHIN_MESSAGE(1, expected, acutalSmallDelta, 3, "Custom Message."); + TEST_ASSERT_CHAR_ARRAY_WITHIN_MESSAGE(11, expected, actualBigDelta, 3, "Custom Message."); +} + +void testCHARArrayNotWithinDelta(void) +{ + char expected[] = {20, -95, 55}; + char actualBigDelta[] = {11, -86, 45}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_CHAR_ARRAY_WITHIN(1, expected, actualBigDelta, 3); + VERIFY_FAILS_END +} + +void testCHARArrayNotWithinDeltaAndMessage(void) +{ + char expected[] = {20, -95, 55}; + char actualBigDelta[] = {11, -86, 45}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_CHAR_ARRAY_WITHIN_MESSAGE(1, expected, actualBigDelta, 3, "Custom Message."); + VERIFY_FAILS_END +} + +void testCHARArrayWithinDeltaPointless(void) +{ + char expected[] = {20, -95, 55}; + char actualBigDelta[] = {11, -86, 45}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_CHAR_ARRAY_WITHIN(11, expected, actualBigDelta, 0); + VERIFY_FAILS_END +} + +void testCHARArrayWithinDeltaPointlessAndMessage(void) +{ + char expected[] = {20, -95, 55}; + char actualBigDelta[] = {11, -86, 45}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_CHAR_ARRAY_WITHIN_MESSAGE(11, expected, actualBigDelta, 0, "Custom Message."); + VERIFY_FAILS_END +} + +void testCHARArrayWithinDeltaExpectedNull(void) +{ + char actualBigDelta[] = {11, -86, 45}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_CHAR_ARRAY_WITHIN(11, NULL, actualBigDelta, 3); + VERIFY_FAILS_END +} + +void testCHARArrayWithinDeltaExpectedNullAndMessage(void) +{ + char actualBigDelta[] = {11, -86, 45}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_CHAR_ARRAY_WITHIN_MESSAGE(11, NULL, actualBigDelta, 3, "Custom Message."); + VERIFY_FAILS_END +} + +void testCHARArrayWithinDeltaActualNull(void) +{ + char expected[] = {20, -95, 55}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_CHAR_ARRAY_WITHIN(11, expected, NULL, 3); + VERIFY_FAILS_END +} + +void testCHARArrayWithinDeltaActualNullAndMessage(void) +{ + char expected[] = {20, -95, 55}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_CHAR_ARRAY_WITHIN_MESSAGE(11, expected, NULL, 3, "Custom Message."); + VERIFY_FAILS_END +} + +void testCHARArrayWithinDeltaSamePointer(void) +{ + char expected[] = {20, -95, 55}; + + TEST_ASSERT_CHAR_ARRAY_WITHIN(11, expected, expected, 3); +} + +void testCHARArrayWithinDeltaSamePointerAndMessage(void) +{ + char expected[] = {20, -95, 55}; + + TEST_ASSERT_CHAR_ARRAY_WITHIN_MESSAGE(11, expected, expected, 3, "Custom Message."); +} + void testUInt64ArrayWithinDelta(void) { #ifndef UNITY_SUPPORT_64 @@ -1840,10 +2023,10 @@ void testUInt64ArrayWithinDelta(void) #else UNITY_UINT64 expected[] = {12345000, 12344995, 12345005}; UNITY_UINT64 acutalSmallDelta[] = {12345001, 12344996, 12345005}; - UNITY_UINT64 acutalBigDelta[] = {12345101, 12344896, 12345055}; + UNITY_UINT64 actualBigDelta[] = {12345101, 12344896, 12345055}; TEST_ASSERT_UINT64_ARRAY_WITHIN(1, expected, acutalSmallDelta, 3); - TEST_ASSERT_UINT64_ARRAY_WITHIN(110, expected, acutalBigDelta, 3); + TEST_ASSERT_UINT64_ARRAY_WITHIN(110, expected, actualBigDelta, 3); #endif } @@ -1854,10 +2037,10 @@ void testUInt64ArrayWithinDeltaAndMessage(void) #else UNITY_UINT64 expected[] = {12345000, 12344995, 12345005}; UNITY_UINT64 acutalSmallDelta[] = {12345001, 12344996, 12345005}; - UNITY_UINT64 acutalBigDelta[] = {12345101, 12344896, 12345055}; + UNITY_UINT64 actualBigDelta[] = {12345101, 12344896, 12345055}; TEST_ASSERT_UINT64_ARRAY_WITHIN_MESSAGE(1, expected, acutalSmallDelta, 3, "Custom Message."); - TEST_ASSERT_UINT64_ARRAY_WITHIN_MESSAGE(110, expected, acutalBigDelta, 3, "Custom Message."); + TEST_ASSERT_UINT64_ARRAY_WITHIN_MESSAGE(110, expected, actualBigDelta, 3, "Custom Message."); #endif } @@ -1867,10 +2050,10 @@ void testUInt64ArrayNotWithinDelta(void) TEST_IGNORE(); #else UNITY_UINT64 expected[] = {12345000, 12344995, 12345005}; - UNITY_UINT64 acutalBigDelta[] = {12345101, 12344896, 12345055}; + UNITY_UINT64 actualBigDelta[] = {12345101, 12344896, 12345055}; EXPECT_ABORT_BEGIN - TEST_ASSERT_UINT64_ARRAY_WITHIN(1, expected, acutalBigDelta, 3); + TEST_ASSERT_UINT64_ARRAY_WITHIN(1, expected, actualBigDelta, 3); VERIFY_FAILS_END #endif } @@ -1881,10 +2064,10 @@ void testUInt64ArrayNotWithinDeltaAndMessage(void) TEST_IGNORE(); #else UNITY_UINT64 expected[] = {12345000, 12344995, 12345005}; - UNITY_UINT64 acutalBigDelta[] = {12345101, 12344896, 12345055}; + UNITY_UINT64 actualBigDelta[] = {12345101, 12344896, 12345055}; EXPECT_ABORT_BEGIN - TEST_ASSERT_UINT64_ARRAY_WITHIN_MESSAGE(1, expected, acutalBigDelta, 3, "Custom Message."); + TEST_ASSERT_UINT64_ARRAY_WITHIN_MESSAGE(1, expected, actualBigDelta, 3, "Custom Message."); VERIFY_FAILS_END #endif } @@ -1895,10 +2078,10 @@ void testUInt64ArrayWithinDeltaPointless(void) TEST_IGNORE(); #else UNITY_UINT64 expected[] = {12345000, 12344995, 12345005}; - UNITY_UINT64 acutalBigDelta[] = {12345101, 12344896, 12345055}; + UNITY_UINT64 actualBigDelta[] = {12345101, 12344896, 12345055}; EXPECT_ABORT_BEGIN - TEST_ASSERT_UINT64_ARRAY_WITHIN(110, expected, acutalBigDelta, 0); + TEST_ASSERT_UINT64_ARRAY_WITHIN(110, expected, actualBigDelta, 0); VERIFY_FAILS_END #endif } @@ -1909,10 +2092,10 @@ void testUInt64ArrayWithinDeltaPointlessAndMessage(void) TEST_IGNORE(); #else UNITY_UINT64 expected[] = {12345000, 12344995, 12345005}; - UNITY_UINT64 acutalBigDelta[] = {12345101, 12344896, 12345055}; + UNITY_UINT64 actualBigDelta[] = {12345101, 12344896, 12345055}; EXPECT_ABORT_BEGIN - TEST_ASSERT_UINT64_ARRAY_WITHIN_MESSAGE(110, expected, acutalBigDelta, 0, "Custom Message."); + TEST_ASSERT_UINT64_ARRAY_WITHIN_MESSAGE(110, expected, actualBigDelta, 0, "Custom Message."); VERIFY_FAILS_END #endif } @@ -1922,10 +2105,10 @@ void testUInt64ArrayWithinDeltaExpectedNull(void) #ifndef UNITY_SUPPORT_64 TEST_IGNORE(); #else - UNITY_UINT64 acutalBigDelta[] = {12345101, 12344896, 12345055}; + UNITY_UINT64 actualBigDelta[] = {12345101, 12344896, 12345055}; EXPECT_ABORT_BEGIN - TEST_ASSERT_UINT64_ARRAY_WITHIN(110, NULL, acutalBigDelta, 3); + TEST_ASSERT_UINT64_ARRAY_WITHIN(110, NULL, actualBigDelta, 3); VERIFY_FAILS_END #endif } @@ -1935,10 +2118,10 @@ void testUInt64ArrayWithinDeltaExpectedNullAndMessage(void) #ifndef UNITY_SUPPORT_64 TEST_IGNORE(); #else - UNITY_UINT64 acutalBigDelta[] = {12345101, 12344896, 12345055}; + UNITY_UINT64 actualBigDelta[] = {12345101, 12344896, 12345055}; EXPECT_ABORT_BEGIN - TEST_ASSERT_UINT64_ARRAY_WITHIN_MESSAGE(110, NULL, acutalBigDelta, 3, "Custom Message."); + TEST_ASSERT_UINT64_ARRAY_WITHIN_MESSAGE(110, NULL, actualBigDelta, 3, "Custom Message."); VERIFY_FAILS_END #endif } @@ -1995,77 +2178,77 @@ void testUIntArrayWithinDelta(void) { UNITY_UINT expected[] = {125000, 124995, 125005}; UNITY_UINT acutalSmallDelta[] = {125001, 124996, 125005}; - UNITY_UINT acutalBigDelta[] = {125101, 124896, 125055}; + UNITY_UINT actualBigDelta[] = {125101, 124896, 125055}; TEST_ASSERT_UINT_ARRAY_WITHIN(1, expected, acutalSmallDelta, 3); - TEST_ASSERT_UINT_ARRAY_WITHIN(110, expected, acutalBigDelta, 3); + TEST_ASSERT_UINT_ARRAY_WITHIN(110, expected, actualBigDelta, 3); } void testUIntArrayWithinDeltaAndMessage(void) { UNITY_UINT expected[] = {125000, 124995, 125005}; UNITY_UINT acutalSmallDelta[] = {125001, 124996, 125005}; - UNITY_UINT acutalBigDelta[] = {125101, 124896, 125055}; + UNITY_UINT actualBigDelta[] = {125101, 124896, 125055}; TEST_ASSERT_UINT_ARRAY_WITHIN_MESSAGE(1, expected, acutalSmallDelta, 3, "Custom Message."); - TEST_ASSERT_UINT_ARRAY_WITHIN_MESSAGE(110, expected, acutalBigDelta, 3, "Custom Message."); + TEST_ASSERT_UINT_ARRAY_WITHIN_MESSAGE(110, expected, actualBigDelta, 3, "Custom Message."); } void testUIntArrayNotWithinDelta(void) { UNITY_UINT expected[] = {125000, 124995, 125005}; - UNITY_UINT acutalBigDelta[] = {125101, 124896, 125055}; + UNITY_UINT actualBigDelta[] = {125101, 124896, 125055}; EXPECT_ABORT_BEGIN - TEST_ASSERT_UINT_ARRAY_WITHIN(1, expected, acutalBigDelta, 3); + TEST_ASSERT_UINT_ARRAY_WITHIN(1, expected, actualBigDelta, 3); VERIFY_FAILS_END } void testUIntArrayNotWithinDeltaAndMessage(void) { UNITY_UINT expected[] = {125000, 124995, 125005}; - UNITY_UINT acutalBigDelta[] = {125101, 124896, 125055}; + UNITY_UINT actualBigDelta[] = {125101, 124896, 125055}; EXPECT_ABORT_BEGIN - TEST_ASSERT_UINT_ARRAY_WITHIN_MESSAGE(1, expected, acutalBigDelta, 3, "Custom Message."); + TEST_ASSERT_UINT_ARRAY_WITHIN_MESSAGE(1, expected, actualBigDelta, 3, "Custom Message."); VERIFY_FAILS_END } void testUIntArrayWithinDeltaPointless(void) { UNITY_UINT expected[] = {125000, 124995, 125005}; - UNITY_UINT acutalBigDelta[] = {125101, 124896, 125055}; + UNITY_UINT actualBigDelta[] = {125101, 124896, 125055}; EXPECT_ABORT_BEGIN - TEST_ASSERT_UINT_ARRAY_WITHIN(110, expected, acutalBigDelta, 0); + TEST_ASSERT_UINT_ARRAY_WITHIN(110, expected, actualBigDelta, 0); VERIFY_FAILS_END } void testUIntArrayWithinDeltaPointlessAndMessage(void) { UNITY_UINT expected[] = {125000, 124995, 125005}; - UNITY_UINT acutalBigDelta[] = {125101, 124896, 125055}; + UNITY_UINT actualBigDelta[] = {125101, 124896, 125055}; EXPECT_ABORT_BEGIN - TEST_ASSERT_UINT_ARRAY_WITHIN_MESSAGE(110, expected, acutalBigDelta, 0, "Custom Message."); + TEST_ASSERT_UINT_ARRAY_WITHIN_MESSAGE(110, expected, actualBigDelta, 0, "Custom Message."); VERIFY_FAILS_END } void testUIntArrayWithinDeltaExpectedNull(void) { - UNITY_UINT acutalBigDelta[] = {125101, 124896, 125055}; + UNITY_UINT actualBigDelta[] = {125101, 124896, 125055}; EXPECT_ABORT_BEGIN - TEST_ASSERT_UINT_ARRAY_WITHIN(110, NULL, acutalBigDelta, 3); + TEST_ASSERT_UINT_ARRAY_WITHIN(110, NULL, actualBigDelta, 3); VERIFY_FAILS_END } void testUIntArrayWithinDeltaExpectedNullAndMessage(void) { - UNITY_UINT acutalBigDelta[] = {125101, 124896, 125055}; + UNITY_UINT actualBigDelta[] = {125101, 124896, 125055}; EXPECT_ABORT_BEGIN - TEST_ASSERT_UINT_ARRAY_WITHIN_MESSAGE(110, NULL, acutalBigDelta, 3, "Custom Message."); + TEST_ASSERT_UINT_ARRAY_WITHIN_MESSAGE(110, NULL, actualBigDelta, 3, "Custom Message."); VERIFY_FAILS_END } @@ -2105,77 +2288,77 @@ void testUInt16ArrayWithinDelta(void) { UNITY_UINT16 expected[] = {5000, 4995, 5005}; UNITY_UINT16 acutalSmallDelta[] = {5001, 4996, 5005}; - UNITY_UINT16 acutalBigDelta[] = {5101, 4896, 5055}; + UNITY_UINT16 actualBigDelta[] = {5101, 4896, 5055}; TEST_ASSERT_UINT16_ARRAY_WITHIN(1, expected, acutalSmallDelta, 3); - TEST_ASSERT_UINT16_ARRAY_WITHIN(110, expected, acutalBigDelta, 3); + TEST_ASSERT_UINT16_ARRAY_WITHIN(110, expected, actualBigDelta, 3); } void testUInt16ArrayWithinDeltaAndMessage(void) { UNITY_UINT16 expected[] = {5000, 4995, 5005}; UNITY_UINT16 acutalSmallDelta[] = {5001, 4996, 5005}; - UNITY_UINT16 acutalBigDelta[] = {5101, 4896, 5055}; + UNITY_UINT16 actualBigDelta[] = {5101, 4896, 5055}; TEST_ASSERT_UINT16_ARRAY_WITHIN_MESSAGE(1, expected, acutalSmallDelta, 3, "Custom Message."); - TEST_ASSERT_UINT16_ARRAY_WITHIN_MESSAGE(110, expected, acutalBigDelta, 3, "Custom Message."); + TEST_ASSERT_UINT16_ARRAY_WITHIN_MESSAGE(110, expected, actualBigDelta, 3, "Custom Message."); } void testUInt16ArrayNotWithinDelta(void) { UNITY_UINT16 expected[] = {5000, 4995, 5005}; - UNITY_UINT16 acutalBigDelta[] = {5101, 4896, 5055}; + UNITY_UINT16 actualBigDelta[] = {5101, 4896, 5055}; EXPECT_ABORT_BEGIN - TEST_ASSERT_UINT16_ARRAY_WITHIN(1, expected, acutalBigDelta, 3); + TEST_ASSERT_UINT16_ARRAY_WITHIN(1, expected, actualBigDelta, 3); VERIFY_FAILS_END } void testUInt16ArrayNotWithinDeltaAndMessage(void) { UNITY_UINT16 expected[] = {5000, 4995, 5005}; - UNITY_UINT16 acutalBigDelta[] = {5101, 4896, 5055}; + UNITY_UINT16 actualBigDelta[] = {5101, 4896, 5055}; EXPECT_ABORT_BEGIN - TEST_ASSERT_UINT16_ARRAY_WITHIN_MESSAGE(1, expected, acutalBigDelta, 3, "Custom Message."); + TEST_ASSERT_UINT16_ARRAY_WITHIN_MESSAGE(1, expected, actualBigDelta, 3, "Custom Message."); VERIFY_FAILS_END } void testUInt16ArrayWithinDeltaPointless(void) { UNITY_UINT16 expected[] = {5000, 4995, 5005}; - UNITY_UINT16 acutalBigDelta[] = {5101, 4896, 5055}; + UNITY_UINT16 actualBigDelta[] = {5101, 4896, 5055}; EXPECT_ABORT_BEGIN - TEST_ASSERT_UINT16_ARRAY_WITHIN(110, expected, acutalBigDelta, 0); + TEST_ASSERT_UINT16_ARRAY_WITHIN(110, expected, actualBigDelta, 0); VERIFY_FAILS_END } void testUInt16ArrayWithinDeltaPointlessAndMessage(void) { UNITY_UINT16 expected[] = {5000, 4995, 5005}; - UNITY_UINT16 acutalBigDelta[] = {5101, 4896, 5055}; + UNITY_UINT16 actualBigDelta[] = {5101, 4896, 5055}; EXPECT_ABORT_BEGIN - TEST_ASSERT_UINT16_ARRAY_WITHIN_MESSAGE(110, expected, acutalBigDelta, 0, "Custom Message."); + TEST_ASSERT_UINT16_ARRAY_WITHIN_MESSAGE(110, expected, actualBigDelta, 0, "Custom Message."); VERIFY_FAILS_END } void testUInt16ArrayWithinDeltaExpectedNull(void) { - UNITY_UINT16 acutalBigDelta[] = {5101, 4896, 5055}; + UNITY_UINT16 actualBigDelta[] = {5101, 4896, 5055}; EXPECT_ABORT_BEGIN - TEST_ASSERT_UINT16_ARRAY_WITHIN(110, NULL, acutalBigDelta, 3); + TEST_ASSERT_UINT16_ARRAY_WITHIN(110, NULL, actualBigDelta, 3); VERIFY_FAILS_END } void testUInt16ArrayWithinDeltaExpectedNullAndMessage(void) { - UNITY_UINT16 acutalBigDelta[] = {5101, 4896, 5055}; + UNITY_UINT16 actualBigDelta[] = {5101, 4896, 5055}; EXPECT_ABORT_BEGIN - TEST_ASSERT_UINT16_ARRAY_WITHIN_MESSAGE(110, NULL, acutalBigDelta, 3, "Custom Message."); + TEST_ASSERT_UINT16_ARRAY_WITHIN_MESSAGE(110, NULL, actualBigDelta, 3, "Custom Message."); VERIFY_FAILS_END } @@ -2215,77 +2398,77 @@ void testUInt8ArrayWithinDelta(void) { UNITY_UINT8 expected[] = {20, 95, 55}; UNITY_UINT8 acutalSmallDelta[] = {21, 94, 55}; - UNITY_UINT8 acutalBigDelta[] = {11, 86, 45}; + UNITY_UINT8 actualBigDelta[] = {11, 86, 45}; TEST_ASSERT_UINT8_ARRAY_WITHIN(1, expected, acutalSmallDelta, 3); - TEST_ASSERT_UINT8_ARRAY_WITHIN(11, expected, acutalBigDelta, 3); + TEST_ASSERT_UINT8_ARRAY_WITHIN(11, expected, actualBigDelta, 3); } void testUInt8ArrayWithinDeltaAndMessage(void) { UNITY_UINT8 expected[] = {20, 95, 55}; UNITY_UINT8 acutalSmallDelta[] = {21, 94, 55}; - UNITY_UINT8 acutalBigDelta[] = {11, 86, 45}; + UNITY_UINT8 actualBigDelta[] = {11, 86, 45}; TEST_ASSERT_UINT8_ARRAY_WITHIN_MESSAGE(1, expected, acutalSmallDelta, 3, "Custom Message."); - TEST_ASSERT_UINT8_ARRAY_WITHIN_MESSAGE(11, expected, acutalBigDelta, 3, "Custom Message."); + TEST_ASSERT_UINT8_ARRAY_WITHIN_MESSAGE(11, expected, actualBigDelta, 3, "Custom Message."); } void testUInt8ArrayNotWithinDelta(void) { UNITY_UINT8 expected[] = {20, 95, 55}; - UNITY_UINT8 acutalBigDelta[] = {11, 86, 45}; + UNITY_UINT8 actualBigDelta[] = {11, 86, 45}; EXPECT_ABORT_BEGIN - TEST_ASSERT_UINT8_ARRAY_WITHIN(1, expected, acutalBigDelta, 3); + TEST_ASSERT_UINT8_ARRAY_WITHIN(1, expected, actualBigDelta, 3); VERIFY_FAILS_END } void testUInt8ArrayNotWithinDeltaAndMessage(void) { UNITY_UINT8 expected[] = {20, 95, 55}; - UNITY_UINT8 acutalBigDelta[] = {11, 86, 45}; + UNITY_UINT8 actualBigDelta[] = {11, 86, 45}; EXPECT_ABORT_BEGIN - TEST_ASSERT_UINT8_ARRAY_WITHIN_MESSAGE(1, expected, acutalBigDelta, 3, "Custom Message."); + TEST_ASSERT_UINT8_ARRAY_WITHIN_MESSAGE(1, expected, actualBigDelta, 3, "Custom Message."); VERIFY_FAILS_END } void testUInt8ArrayWithinDeltaPointless(void) { UNITY_UINT8 expected[] = {20, 95, 55}; - UNITY_UINT8 acutalBigDelta[] = {11, 86, 45}; + UNITY_UINT8 actualBigDelta[] = {11, 86, 45}; EXPECT_ABORT_BEGIN - TEST_ASSERT_UINT8_ARRAY_WITHIN(11, expected, acutalBigDelta, 0); + TEST_ASSERT_UINT8_ARRAY_WITHIN(11, expected, actualBigDelta, 0); VERIFY_FAILS_END } void testUInt8ArrayWithinDeltaPointlessAndMessage(void) { UNITY_UINT8 expected[] = {20, 95, 55}; - UNITY_UINT8 acutalBigDelta[] = {11, 86, 45}; + UNITY_UINT8 actualBigDelta[] = {11, 86, 45}; EXPECT_ABORT_BEGIN - TEST_ASSERT_UINT8_ARRAY_WITHIN_MESSAGE(11, expected, acutalBigDelta, 0, "Custom Message."); + TEST_ASSERT_UINT8_ARRAY_WITHIN_MESSAGE(11, expected, actualBigDelta, 0, "Custom Message."); VERIFY_FAILS_END } void testUInt8ArrayWithinDeltaExpectedNull(void) { - UNITY_UINT8 acutalBigDelta[] = {11, 86, 45}; + UNITY_UINT8 actualBigDelta[] = {11, 86, 45}; EXPECT_ABORT_BEGIN - TEST_ASSERT_UINT8_ARRAY_WITHIN(11, NULL, acutalBigDelta, 3); + TEST_ASSERT_UINT8_ARRAY_WITHIN(11, NULL, actualBigDelta, 3); VERIFY_FAILS_END } void testUInt8ArrayWithinDeltaExpectedNullAndMessage(void) { - UNITY_UINT8 acutalBigDelta[] = {11, 86, 45}; + UNITY_UINT8 actualBigDelta[] = {11, 86, 45}; EXPECT_ABORT_BEGIN - TEST_ASSERT_UINT8_ARRAY_WITHIN_MESSAGE(11, NULL, acutalBigDelta, 3, "Custom Message."); + TEST_ASSERT_UINT8_ARRAY_WITHIN_MESSAGE(11, NULL, actualBigDelta, 3, "Custom Message."); VERIFY_FAILS_END } @@ -2328,10 +2511,10 @@ void testHEX64ArrayWithinDelta(void) #else UNITY_UINT64 expected[] = {0xABCD1234, 0xABCD1122, 0xABCD1277}; UNITY_UINT64 acutalSmallDelta[] = {0xABCD1235, 0xABCD1121, 0xABCD1277}; - UNITY_UINT64 acutalBigDelta[] = {0xABCD1267, 0xABCD1188, 0xABCD12AC}; + UNITY_UINT64 actualBigDelta[] = {0xABCD1267, 0xABCD1188, 0xABCD12AC}; TEST_ASSERT_HEX64_ARRAY_WITHIN(1, expected, acutalSmallDelta, 3); - TEST_ASSERT_HEX64_ARRAY_WITHIN(110, expected, acutalBigDelta, 3); + TEST_ASSERT_HEX64_ARRAY_WITHIN(110, expected, actualBigDelta, 3); #endif } @@ -2342,10 +2525,10 @@ void testHEX64ArrayWithinDeltaAndMessage(void) #else UNITY_UINT64 expected[] = {0xABCD1234, 0xABCD1122, 0xABCD1277}; UNITY_UINT64 acutalSmallDelta[] = {0xABCD1235, 0xABCD1121, 0xABCD1277}; - UNITY_UINT64 acutalBigDelta[] = {0xABCD1267, 0xABCD1188, 0xABCD12AC}; + UNITY_UINT64 actualBigDelta[] = {0xABCD1267, 0xABCD1188, 0xABCD12AC}; TEST_ASSERT_HEX64_ARRAY_WITHIN_MESSAGE(1, expected, acutalSmallDelta, 3, "Custom Message."); - TEST_ASSERT_HEX64_ARRAY_WITHIN_MESSAGE(110, expected, acutalBigDelta, 3, "Custom Message."); + TEST_ASSERT_HEX64_ARRAY_WITHIN_MESSAGE(110, expected, actualBigDelta, 3, "Custom Message."); #endif } @@ -2355,10 +2538,10 @@ void testHEX64ArrayNotWithinDelta(void) TEST_IGNORE(); #else UNITY_UINT64 expected[] = {0xABCD1234, 0xABCD1122, 0xABCD1277}; - UNITY_UINT64 acutalBigDelta[] = {0xABCD1267, 0xABCD1188, 0xABCD12AC}; + UNITY_UINT64 actualBigDelta[] = {0xABCD1267, 0xABCD1188, 0xABCD12AC}; EXPECT_ABORT_BEGIN - TEST_ASSERT_HEX64_ARRAY_WITHIN(1, expected, acutalBigDelta, 3); + TEST_ASSERT_HEX64_ARRAY_WITHIN(1, expected, actualBigDelta, 3); VERIFY_FAILS_END #endif } @@ -2369,10 +2552,10 @@ void testHEX64ArrayNotWithinDeltaAndMessage(void) TEST_IGNORE(); #else UNITY_UINT64 expected[] = {0xABCD1234, 0xABCD1122, 0xABCD1277}; - UNITY_UINT64 acutalBigDelta[] = {0xABCD1267, 0xABCD1188, 0xABCD12AC}; + UNITY_UINT64 actualBigDelta[] = {0xABCD1267, 0xABCD1188, 0xABCD12AC}; EXPECT_ABORT_BEGIN - TEST_ASSERT_HEX64_ARRAY_WITHIN_MESSAGE(1, expected, acutalBigDelta, 3, "Custom Message."); + TEST_ASSERT_HEX64_ARRAY_WITHIN_MESSAGE(1, expected, actualBigDelta, 3, "Custom Message."); VERIFY_FAILS_END #endif } @@ -2383,10 +2566,10 @@ void testHEX64ArrayWithinDeltaPointless(void) TEST_IGNORE(); #else UNITY_UINT64 expected[] = {0xABCD1234, 0xABCD1122, 0xABCD1277}; - UNITY_UINT64 acutalBigDelta[] = {0xABCD1267, 0xABCD1188, 0xABCD12AC}; + UNITY_UINT64 actualBigDelta[] = {0xABCD1267, 0xABCD1188, 0xABCD12AC}; EXPECT_ABORT_BEGIN - TEST_ASSERT_HEX64_ARRAY_WITHIN(110, expected, acutalBigDelta, 0); + TEST_ASSERT_HEX64_ARRAY_WITHIN(110, expected, actualBigDelta, 0); VERIFY_FAILS_END #endif } @@ -2397,10 +2580,10 @@ void testHEX64ArrayWithinDeltaPointlessAndMessage(void) TEST_IGNORE(); #else UNITY_UINT64 expected[] = {0xABCD1234, 0xABCD1122, 0xABCD1277}; - UNITY_UINT64 acutalBigDelta[] = {0xABCD1267, 0xABCD1188, 0xABCD12AC}; + UNITY_UINT64 actualBigDelta[] = {0xABCD1267, 0xABCD1188, 0xABCD12AC}; EXPECT_ABORT_BEGIN - TEST_ASSERT_HEX64_ARRAY_WITHIN_MESSAGE(110, expected, acutalBigDelta, 0, "Custom Message."); + TEST_ASSERT_HEX64_ARRAY_WITHIN_MESSAGE(110, expected, actualBigDelta, 0, "Custom Message."); VERIFY_FAILS_END #endif } @@ -2410,10 +2593,10 @@ void testHEX64ArrayWithinDeltaExpectedNull(void) #ifndef UNITY_SUPPORT_64 TEST_IGNORE(); #else - UNITY_UINT64 acutalBigDelta[] = {0xABCD1267, 0xABCD1188, 0xABCD12AC}; + UNITY_UINT64 actualBigDelta[] = {0xABCD1267, 0xABCD1188, 0xABCD12AC}; EXPECT_ABORT_BEGIN - TEST_ASSERT_HEX64_ARRAY_WITHIN(110, NULL, acutalBigDelta, 3); + TEST_ASSERT_HEX64_ARRAY_WITHIN(110, NULL, actualBigDelta, 3); VERIFY_FAILS_END #endif } @@ -2423,10 +2606,10 @@ void testHEX64ArrayWithinDeltaExpectedNullAndMessage(void) #ifndef UNITY_SUPPORT_64 TEST_IGNORE(); #else - UNITY_UINT64 acutalBigDelta[] = {0xABCD1267, 0xABCD1188, 0xABCD12AC}; + UNITY_UINT64 actualBigDelta[] = {0xABCD1267, 0xABCD1188, 0xABCD12AC}; EXPECT_ABORT_BEGIN - TEST_ASSERT_HEX64_ARRAY_WITHIN_MESSAGE(110, NULL, acutalBigDelta, 3, "Custom Message."); + TEST_ASSERT_HEX64_ARRAY_WITHIN_MESSAGE(110, NULL, actualBigDelta, 3, "Custom Message."); VERIFY_FAILS_END #endif } @@ -2483,77 +2666,77 @@ void testHEX32ArrayWithinDelta(void) { UNITY_UINT expected[] = {0xABCD1234, 0xABCD1122, 0xABCD1277}; UNITY_UINT acutalSmallDelta[] = {0xABCD1235, 0xABCD1121, 0xABCD1277}; - UNITY_UINT acutalBigDelta[] = {0xABCD1267, 0xABCD1188, 0xABCD12AC}; + UNITY_UINT actualBigDelta[] = {0xABCD1267, 0xABCD1188, 0xABCD12AC}; TEST_ASSERT_HEX32_ARRAY_WITHIN(1, expected, acutalSmallDelta, 3); - TEST_ASSERT_HEX32_ARRAY_WITHIN(110, expected, acutalBigDelta, 3); + TEST_ASSERT_HEX32_ARRAY_WITHIN(110, expected, actualBigDelta, 3); } void testHEX32ArrayWithinDeltaAndMessage(void) { UNITY_UINT expected[] = {0xABCD1234, 0xABCD1122, 0xABCD1277}; UNITY_UINT acutalSmallDelta[] = {0xABCD1235, 0xABCD1121, 0xABCD1277}; - UNITY_UINT acutalBigDelta[] = {0xABCD1267, 0xABCD1188, 0xABCD12AC}; + UNITY_UINT actualBigDelta[] = {0xABCD1267, 0xABCD1188, 0xABCD12AC}; TEST_ASSERT_HEX32_ARRAY_WITHIN_MESSAGE(1, expected, acutalSmallDelta, 3, "Custom Message."); - TEST_ASSERT_HEX32_ARRAY_WITHIN_MESSAGE(110, expected, acutalBigDelta, 3, "Custom Message."); + TEST_ASSERT_HEX32_ARRAY_WITHIN_MESSAGE(110, expected, actualBigDelta, 3, "Custom Message."); } void testHEX32ArrayNotWithinDelta(void) { UNITY_UINT expected[] = {0xABCD1234, 0xABCD1122, 0xABCD1277}; - UNITY_UINT acutalBigDelta[] = {0xABCD1267, 0xABCD1188, 0xABCD12AC}; + UNITY_UINT actualBigDelta[] = {0xABCD1267, 0xABCD1188, 0xABCD12AC}; EXPECT_ABORT_BEGIN - TEST_ASSERT_HEX32_ARRAY_WITHIN(1, expected, acutalBigDelta, 3); + TEST_ASSERT_HEX32_ARRAY_WITHIN(1, expected, actualBigDelta, 3); VERIFY_FAILS_END } void testHEX32ArrayNotWithinDeltaAndMessage(void) { UNITY_UINT expected[] = {0xABCD1234, 0xABCD1122, 0xABCD1277}; - UNITY_UINT acutalBigDelta[] = {0xABCD1267, 0xABCD1188, 0xABCD12AC}; + UNITY_UINT actualBigDelta[] = {0xABCD1267, 0xABCD1188, 0xABCD12AC}; EXPECT_ABORT_BEGIN - TEST_ASSERT_HEX32_ARRAY_WITHIN_MESSAGE(1, expected, acutalBigDelta, 3, "Custom Message."); + TEST_ASSERT_HEX32_ARRAY_WITHIN_MESSAGE(1, expected, actualBigDelta, 3, "Custom Message."); VERIFY_FAILS_END } void testHEX32ArrayWithinDeltaPointless(void) { UNITY_UINT expected[] = {0xABCD1234, 0xABCD1122, 0xABCD1277}; - UNITY_UINT acutalBigDelta[] = {0xABCD1267, 0xABCD1188, 0xABCD12AC}; + UNITY_UINT actualBigDelta[] = {0xABCD1267, 0xABCD1188, 0xABCD12AC}; EXPECT_ABORT_BEGIN - TEST_ASSERT_HEX32_ARRAY_WITHIN(110, expected, acutalBigDelta, 0); + TEST_ASSERT_HEX32_ARRAY_WITHIN(110, expected, actualBigDelta, 0); VERIFY_FAILS_END } void testHEX32ArrayWithinDeltaPointlessAndMessage(void) { UNITY_UINT expected[] = {0xABCD1234, 0xABCD1122, 0xABCD1277}; - UNITY_UINT acutalBigDelta[] = {0xABCD1267, 0xABCD1188, 0xABCD12AC}; + UNITY_UINT actualBigDelta[] = {0xABCD1267, 0xABCD1188, 0xABCD12AC}; EXPECT_ABORT_BEGIN - TEST_ASSERT_HEX32_ARRAY_WITHIN_MESSAGE(110, expected, acutalBigDelta, 0, "Custom Message."); + TEST_ASSERT_HEX32_ARRAY_WITHIN_MESSAGE(110, expected, actualBigDelta, 0, "Custom Message."); VERIFY_FAILS_END } void testHEX32ArrayWithinDeltaExpectedNull(void) { - UNITY_UINT acutalBigDelta[] = {0xABCD1267, 0xABCD1188, 0xABCD12AC}; + UNITY_UINT actualBigDelta[] = {0xABCD1267, 0xABCD1188, 0xABCD12AC}; EXPECT_ABORT_BEGIN - TEST_ASSERT_HEX32_ARRAY_WITHIN(110, NULL, acutalBigDelta, 3); + TEST_ASSERT_HEX32_ARRAY_WITHIN(110, NULL, actualBigDelta, 3); VERIFY_FAILS_END } void testHEX32ArrayWithinDeltaExpectedNullAndMessage(void) { - UNITY_UINT acutalBigDelta[] = {0xABCD1267, 0xABCD1188, 0xABCD12AC}; + UNITY_UINT actualBigDelta[] = {0xABCD1267, 0xABCD1188, 0xABCD12AC}; EXPECT_ABORT_BEGIN - TEST_ASSERT_HEX32_ARRAY_WITHIN_MESSAGE(110, NULL, acutalBigDelta, 3, "Custom Message."); + TEST_ASSERT_HEX32_ARRAY_WITHIN_MESSAGE(110, NULL, actualBigDelta, 3, "Custom Message."); VERIFY_FAILS_END } @@ -2594,77 +2777,77 @@ void testHEX16ArrayWithinDelta(void) { UNITY_UINT16 expected[] = {0x1234, 0x1122, 0x1277}; UNITY_UINT16 acutalSmallDelta[] = {0x1235, 0x1121, 0x1277}; - UNITY_UINT16 acutalBigDelta[] = {0x1267, 0x1188, 0x12AC}; + UNITY_UINT16 actualBigDelta[] = {0x1267, 0x1188, 0x12AC}; TEST_ASSERT_HEX16_ARRAY_WITHIN(1, expected, acutalSmallDelta, 3); - TEST_ASSERT_HEX16_ARRAY_WITHIN(110, expected, acutalBigDelta, 3); + TEST_ASSERT_HEX16_ARRAY_WITHIN(110, expected, actualBigDelta, 3); } void testHEX16ArrayWithinDeltaAndMessage(void) { UNITY_UINT16 expected[] = {0x1234, 0x1122, 0x1277}; UNITY_UINT16 acutalSmallDelta[] = {0x1235, 0x1121, 0x1277}; - UNITY_UINT16 acutalBigDelta[] = {0x1267, 0x1188, 0x12AC}; + UNITY_UINT16 actualBigDelta[] = {0x1267, 0x1188, 0x12AC}; TEST_ASSERT_HEX16_ARRAY_WITHIN_MESSAGE(1, expected, acutalSmallDelta, 3, "Custom Message."); - TEST_ASSERT_HEX16_ARRAY_WITHIN_MESSAGE(110, expected, acutalBigDelta, 3, "Custom Message."); + TEST_ASSERT_HEX16_ARRAY_WITHIN_MESSAGE(110, expected, actualBigDelta, 3, "Custom Message."); } void testHEX16ArrayNotWithinDelta(void) { UNITY_UINT16 expected[] = {0x1234, 0x1122, 0x1277}; - UNITY_UINT16 acutalBigDelta[] = {0x1267, 0x1188, 0x12AC}; + UNITY_UINT16 actualBigDelta[] = {0x1267, 0x1188, 0x12AC}; EXPECT_ABORT_BEGIN - TEST_ASSERT_HEX16_ARRAY_WITHIN(1, expected, acutalBigDelta, 3); + TEST_ASSERT_HEX16_ARRAY_WITHIN(1, expected, actualBigDelta, 3); VERIFY_FAILS_END } void testHEX16ArrayNotWithinDeltaAndMessage(void) { UNITY_UINT16 expected[] = {0x1234, 0x1122, 0x1277}; - UNITY_UINT16 acutalBigDelta[] = {0x1267, 0x1188, 0x12AC}; + UNITY_UINT16 actualBigDelta[] = {0x1267, 0x1188, 0x12AC}; EXPECT_ABORT_BEGIN - TEST_ASSERT_HEX16_ARRAY_WITHIN_MESSAGE(1, expected, acutalBigDelta, 3, "Custom Message."); + TEST_ASSERT_HEX16_ARRAY_WITHIN_MESSAGE(1, expected, actualBigDelta, 3, "Custom Message."); VERIFY_FAILS_END } void testHEX16ArrayWithinDeltaPointless(void) { UNITY_UINT16 expected[] = {0x1234, 0x1122, 0x1277}; - UNITY_UINT16 acutalBigDelta[] = {0x1267, 0x1188, 0x12AC}; + UNITY_UINT16 actualBigDelta[] = {0x1267, 0x1188, 0x12AC}; EXPECT_ABORT_BEGIN - TEST_ASSERT_HEX16_ARRAY_WITHIN(110, expected, acutalBigDelta, 0); + TEST_ASSERT_HEX16_ARRAY_WITHIN(110, expected, actualBigDelta, 0); VERIFY_FAILS_END } void testHEX16ArrayWithinDeltaPointlessAndMessage(void) { UNITY_UINT16 expected[] = {0x1234, 0x1122, 0x1277}; - UNITY_UINT16 acutalBigDelta[] = {0x1267, 0x1188, 0x12AC}; + UNITY_UINT16 actualBigDelta[] = {0x1267, 0x1188, 0x12AC}; EXPECT_ABORT_BEGIN - TEST_ASSERT_HEX16_ARRAY_WITHIN_MESSAGE(110, expected, acutalBigDelta, 0, "Custom Message."); + TEST_ASSERT_HEX16_ARRAY_WITHIN_MESSAGE(110, expected, actualBigDelta, 0, "Custom Message."); VERIFY_FAILS_END } void testHEX16ArrayWithinDeltaExpectedNull(void) { - UNITY_UINT16 acutalBigDelta[] = {0x1267, 0x1188, 0x12AC}; + UNITY_UINT16 actualBigDelta[] = {0x1267, 0x1188, 0x12AC}; EXPECT_ABORT_BEGIN - TEST_ASSERT_HEX16_ARRAY_WITHIN(110, NULL, acutalBigDelta, 3); + TEST_ASSERT_HEX16_ARRAY_WITHIN(110, NULL, actualBigDelta, 3); VERIFY_FAILS_END } void testHEX16ArrayWithinDeltaExpectedNullAndMessage(void) { - UNITY_UINT16 acutalBigDelta[] = {0x1267, 0x1188, 0x12AC}; + UNITY_UINT16 actualBigDelta[] = {0x1267, 0x1188, 0x12AC}; EXPECT_ABORT_BEGIN - TEST_ASSERT_HEX16_ARRAY_WITHIN_MESSAGE(110, NULL, acutalBigDelta, 3, "Custom Message."); + TEST_ASSERT_HEX16_ARRAY_WITHIN_MESSAGE(110, NULL, actualBigDelta, 3, "Custom Message."); VERIFY_FAILS_END } @@ -2704,77 +2887,77 @@ void testHEX8ArrayWithinDelta(void) { UNITY_UINT8 expected[] = {0x34, 0x22, 0x77}; UNITY_UINT8 acutalSmallDelta[] = {0x35, 0x21, 0x77}; - UNITY_UINT8 acutalBigDelta[] = {0x47, 0x48, 0x4C}; + UNITY_UINT8 actualBigDelta[] = {0x47, 0x48, 0x4C}; TEST_ASSERT_HEX8_ARRAY_WITHIN(1, expected, acutalSmallDelta, 3); - TEST_ASSERT_HEX8_ARRAY_WITHIN(60, expected, acutalBigDelta, 3); + TEST_ASSERT_HEX8_ARRAY_WITHIN(60, expected, actualBigDelta, 3); } void testHEX8ArrayWithinDeltaAndMessage(void) { UNITY_UINT8 expected[] = {0x34, 0x22, 0x77}; UNITY_UINT8 acutalSmallDelta[] = {0x35, 0x21, 0x77}; - UNITY_UINT8 acutalBigDelta[] = {0x47, 0x48, 0x4C}; + UNITY_UINT8 actualBigDelta[] = {0x47, 0x48, 0x4C}; TEST_ASSERT_HEX8_ARRAY_WITHIN_MESSAGE(1, expected, acutalSmallDelta, 3, "Custom Message."); - TEST_ASSERT_HEX8_ARRAY_WITHIN_MESSAGE(60, expected, acutalBigDelta, 3, "Custom Message."); + TEST_ASSERT_HEX8_ARRAY_WITHIN_MESSAGE(60, expected, actualBigDelta, 3, "Custom Message."); } void testHEX8ArrayNotWithinDelta(void) { UNITY_UINT8 expected[] = {0x34, 0x22, 0x77}; - UNITY_UINT8 acutalBigDelta[] = {0x67, 0x88, 0xAC}; + UNITY_UINT8 actualBigDelta[] = {0x67, 0x88, 0xAC}; EXPECT_ABORT_BEGIN - TEST_ASSERT_HEX8_ARRAY_WITHIN(1, expected, acutalBigDelta, 3); + TEST_ASSERT_HEX8_ARRAY_WITHIN(1, expected, actualBigDelta, 3); VERIFY_FAILS_END } void testHEX8ArrayNotWithinDeltaAndMessage(void) { UNITY_UINT8 expected[] = {0x34, 0x22, 0x77}; - UNITY_UINT8 acutalBigDelta[] = {0x67, 0x88, 0xAC}; + UNITY_UINT8 actualBigDelta[] = {0x67, 0x88, 0xAC}; EXPECT_ABORT_BEGIN - TEST_ASSERT_HEX8_ARRAY_WITHIN_MESSAGE(1, expected, acutalBigDelta, 3, "Custom Message."); + TEST_ASSERT_HEX8_ARRAY_WITHIN_MESSAGE(1, expected, actualBigDelta, 3, "Custom Message."); VERIFY_FAILS_END } void testHEX8ArrayWithinDeltaPointless(void) { UNITY_UINT8 expected[] = {0x34, 0x22, 0x77}; - UNITY_UINT8 acutalBigDelta[] = {0x67, 0x88, 0xAC}; + UNITY_UINT8 actualBigDelta[] = {0x67, 0x88, 0xAC}; EXPECT_ABORT_BEGIN - TEST_ASSERT_HEX8_ARRAY_WITHIN(60, expected, acutalBigDelta, 0); + TEST_ASSERT_HEX8_ARRAY_WITHIN(60, expected, actualBigDelta, 0); VERIFY_FAILS_END } void testHEX8ArrayWithinDeltaPointlessAndMessage(void) { UNITY_UINT8 expected[] = {0x34, 0x22, 0x77}; - UNITY_UINT8 acutalBigDelta[] = {0x67, 0x88, 0xAC}; + UNITY_UINT8 actualBigDelta[] = {0x67, 0x88, 0xAC}; EXPECT_ABORT_BEGIN - TEST_ASSERT_HEX8_ARRAY_WITHIN_MESSAGE(60, expected, acutalBigDelta, 0, "Custom Message."); + TEST_ASSERT_HEX8_ARRAY_WITHIN_MESSAGE(60, expected, actualBigDelta, 0, "Custom Message."); VERIFY_FAILS_END } void testHEX8ArrayWithinDeltaExpectedNull(void) { - UNITY_UINT8 acutalBigDelta[] = {0x67, 0x88, 0xAC}; + UNITY_UINT8 actualBigDelta[] = {0x67, 0x88, 0xAC}; EXPECT_ABORT_BEGIN - TEST_ASSERT_HEX8_ARRAY_WITHIN(60, NULL, acutalBigDelta, 3); + TEST_ASSERT_HEX8_ARRAY_WITHIN(60, NULL, actualBigDelta, 3); VERIFY_FAILS_END } void testHEX8ArrayWithinDeltaExpectedNullAndMessage(void) { - UNITY_UINT8 acutalBigDelta[] = {0x67, 0x88, 0xAC}; + UNITY_UINT8 actualBigDelta[] = {0x67, 0x88, 0xAC}; EXPECT_ABORT_BEGIN - TEST_ASSERT_HEX8_ARRAY_WITHIN_MESSAGE(60, NULL, acutalBigDelta, 3, "Custom Message."); + TEST_ASSERT_HEX8_ARRAY_WITHIN_MESSAGE(60, NULL, actualBigDelta, 3, "Custom Message."); VERIFY_FAILS_END } @@ -2881,6 +3064,29 @@ void testNotGreaterThanINT8(void) VERIFY_FAILS_END } +void testGreaterThanCHAR(void) +{ + char v0, v1; + char *p0, *p1; + + v0 = -128; + v1 = 127; + p0 = &v0; + p1 = &v1; + + TEST_ASSERT_GREATER_THAN_CHAR(v0, v1); + TEST_ASSERT_GREATER_THAN_CHAR(*p0, v1); + TEST_ASSERT_GREATER_THAN_CHAR(v0, *p1); + TEST_ASSERT_GREATER_THAN_CHAR(*p0, *p1); +} + +void testNotGreaterThanCHAR(void) +{ + EXPECT_ABORT_BEGIN + TEST_ASSERT_GREATER_THAN_CHAR(127, -128); + VERIFY_FAILS_END +} + void testGreaterThanINT16(void) { UNITY_INT16 v0, v1; @@ -3175,6 +3381,35 @@ void testNotGreaterOrEqualINT8(void) VERIFY_FAILS_END } +void testGreaterOrEqualCHAR(void) +{ + char v0, v1, v2; + char *p0, *p1, *p2; + + v0 = -128; + v1 = 127; + v2 = -128; + p0 = &v0; + p1 = &v1; + p2 = &v2; + + TEST_ASSERT_GREATER_OR_EQUAL_CHAR(v0, v1); + TEST_ASSERT_GREATER_OR_EQUAL_CHAR(*p0, v1); + TEST_ASSERT_GREATER_OR_EQUAL_CHAR(v0, *p1); + TEST_ASSERT_GREATER_OR_EQUAL_CHAR(*p0, *p1); + TEST_ASSERT_GREATER_OR_EQUAL_CHAR(v0, v2); + TEST_ASSERT_GREATER_OR_EQUAL_CHAR(*p0, v2); + TEST_ASSERT_GREATER_OR_EQUAL_CHAR(v0, *p2); + TEST_ASSERT_GREATER_OR_EQUAL_CHAR(*p0, *p2); +} + +void testNotGreaterOrEqualCHAR(void) +{ + EXPECT_ABORT_BEGIN + TEST_ASSERT_GREATER_OR_EQUAL_CHAR(127, -128); + VERIFY_FAILS_END +} + void testGreaterOrEqualINT16(void) { UNITY_INT16 v0, v1, v2; @@ -3507,6 +3742,29 @@ void testNotLessThanINT8(void) VERIFY_FAILS_END } +void testLessThanCHAR(void) +{ + char v0, v1; + char *p0, *p1; + + v0 = 127; + v1 = -128; + p0 = &v0; + p1 = &v1; + + TEST_ASSERT_LESS_THAN_CHAR(v0, v1); + TEST_ASSERT_LESS_THAN_CHAR(*p0, v1); + TEST_ASSERT_LESS_THAN_CHAR(v0, *p1); + TEST_ASSERT_LESS_THAN_CHAR(*p0, *p1); +} + +void testNotLessThanCHAR(void) +{ + EXPECT_ABORT_BEGIN + TEST_ASSERT_LESS_THAN_CHAR(-128, 127); + VERIFY_FAILS_END +} + void testLessThanINT16(void) { UNITY_INT16 v0, v1; @@ -3801,6 +4059,35 @@ void testNotLessOrEqualINT8(void) VERIFY_FAILS_END } +void testLessOrEqualCHAR(void) +{ + char v0, v1, v2; + char *p0, *p1, *p2; + + v0 = 127; + v1 = -128; + v2 = 127; + p0 = &v0; + p1 = &v1; + p2 = &v2; + + TEST_ASSERT_LESS_OR_EQUAL_CHAR(v0, v1); + TEST_ASSERT_LESS_OR_EQUAL_CHAR(*p0, v1); + TEST_ASSERT_LESS_OR_EQUAL_CHAR(v0, *p1); + TEST_ASSERT_LESS_OR_EQUAL_CHAR(*p0, *p1); + TEST_ASSERT_LESS_OR_EQUAL_CHAR(v0, v2); + TEST_ASSERT_LESS_OR_EQUAL_CHAR(*p0, v2); + TEST_ASSERT_LESS_OR_EQUAL_CHAR(v0, *p2); + TEST_ASSERT_LESS_OR_EQUAL_CHAR(*p0, *p2); +} + +void testNotLessOrEqualCHAR(void) +{ + EXPECT_ABORT_BEGIN + TEST_ASSERT_LESS_OR_EQUAL_CHAR(-128, 127); + VERIFY_FAILS_END +} + void testLessOrEqualINT16(void) { UNITY_INT16 v0, v1, v2; @@ -4726,6 +5013,53 @@ void testNotEqualInt8EachEqual(void) VERIFY_FAILS_END } +void testEqualCHARArrays(void) +{ + char p0[] = {1, 8, 117, -2}; + char p1[] = {1, 8, 117, -2}; + char p2[] = {1, 8, 117, 2}; + char p3[] = {1, 50, 60, 70}; + + TEST_ASSERT_EQUAL_CHAR_ARRAY(p0, p0, 1); + TEST_ASSERT_EQUAL_CHAR_ARRAY(p0, p0, 4); + TEST_ASSERT_EQUAL_CHAR_ARRAY(p0, p1, 4); + TEST_ASSERT_EQUAL_CHAR_ARRAY(p0, p2, 3); + TEST_ASSERT_EQUAL_CHAR_ARRAY(p0, p3, 1); +} + +void testNotEqualCHARArrays(void) +{ + char p0[] = {1, 8, 36, -2}; + char p1[] = {1, 8, 36, 2}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_EQUAL_CHAR_ARRAY(p0, p1, 4); + VERIFY_FAILS_END +} + +void testEqualCHAREachEqual(void) +{ + char p0[] = {1, 1, 1, 1}; + char p1[] = {117, 117, 117, -2}; + char p2[] = {-1, -1, 117, 2}; + char p3[] = {1, 50, 60, 70}; + + TEST_ASSERT_EACH_EQUAL_CHAR(1, p0, 1); + TEST_ASSERT_EACH_EQUAL_CHAR(1, p0, 4); + TEST_ASSERT_EACH_EQUAL_CHAR(117, p1, 3); + TEST_ASSERT_EACH_EQUAL_CHAR(-1, p2, 2); + TEST_ASSERT_EACH_EQUAL_CHAR(1, p3, 1); +} + +void testNotEqualCHAREachEqual(void) +{ + char p0[] = {1, 8, 36, -2}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_EACH_EQUAL_CHAR(1, p0, 2); + VERIFY_FAILS_END +} + void testEqualUIntArrays(void) { unsigned int p0[] = {1, 8, 987, 65132u}; From 74d47e8afaa7364980ad8881e7a750c60e6f6070 Mon Sep 17 00:00:00 2001 From: mvandervoord Date: Tue, 29 Oct 2019 06:34:09 -0400 Subject: [PATCH 183/454] Add missed casting --- src/unity.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/unity.c b/src/unity.c index ee575bdd..2b932440 100644 --- a/src/unity.c +++ b/src/unity.c @@ -310,7 +310,7 @@ void UnityPrintNumberByStyle(const UNITY_INT number, const UNITY_DISPLAY_STYLE_T UNITY_OUTPUT_CHAR('\''); if ((number <= 126) && (number >= 32)) { - UNITY_OUTPUT_CHAR(number); + UNITY_OUTPUT_CHAR((int)number); } /* write escaped carriage returns */ else if (number == 13) From cf5b2d2568deb0d4cf9b54edfdd5dfe80e8b67d8 Mon Sep 17 00:00:00 2001 From: John Lindgren Date: Tue, 29 Oct 2019 13:21:34 -0400 Subject: [PATCH 184/454] Make verifyTest() leave Ignores and Callbacks intact. --- auto/generate_test_runner.rb | 2 -- 1 file changed, 2 deletions(-) diff --git a/auto/generate_test_runner.rb b/auto/generate_test_runner.rb index bd555370..3b979d0a 100644 --- a/auto/generate_test_runner.rb +++ b/auto/generate_test_runner.rb @@ -319,8 +319,6 @@ def create_reset(output) output.puts("void #{@options[:test_verify_name]}(void)") output.puts('{') output.puts(' CMock_Verify();') - output.puts(' CMock_Destroy();') - output.puts(' CMock_Init();') output.puts('}') end From 9c82fac380ba235ce152cc17e6412ce3239ca706 Mon Sep 17 00:00:00 2001 From: John Lindgren Date: Tue, 29 Oct 2019 13:21:59 -0400 Subject: [PATCH 185/454] Update incorrect comment. --- src/unity.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/unity.c b/src/unity.c index 2b932440..72d3855d 100644 --- a/src/unity.c +++ b/src/unity.c @@ -346,7 +346,7 @@ void UnityPrintNumberByStyle(const UNITY_INT number, const UNITY_DISPLAY_STYLE_T { UnityPrintNumberUnsigned((UNITY_UINT)number); } - else + else { UNITY_OUTPUT_CHAR('0'); UNITY_OUTPUT_CHAR('x'); @@ -464,7 +464,7 @@ void UnityPrintFloat(const UNITY_DOUBLE input_number) UNITY_DOUBLE number = input_number; - /* print minus sign (including for negative zero) */ + /* print minus sign (does not handle negative zero) */ if (number < 0.0f) { UNITY_OUTPUT_CHAR('-'); @@ -472,7 +472,7 @@ void UnityPrintFloat(const UNITY_DOUBLE input_number) } /* handle zero, NaN, and +/- infinity */ - if (number == 0.0f) + if (number == 0.0f) { UnityPrint("0"); } From a303e0885931ecda0c03c57de8864f0b919724cb Mon Sep 17 00:00:00 2001 From: anon Date: Tue, 29 Oct 2019 19:38:43 +0000 Subject: [PATCH 186/454] Option to omit UnityBegin/UnityEnd calls in generate_test_runner By passing --omit_begin_end=1 to generate_test_runner.rb, the script will now omit calls to UnityBegin and UnityEnd when running tests in a suite. This allows multiple suites to be executed in a row, and then have an overall summary of the tests which were executed across all suites. --- auto/generate_test_runner.rb | 21 ++++++++++++++++----- src/unity.c | 6 ++++++ src/unity_internals.h | 1 + 3 files changed, 23 insertions(+), 5 deletions(-) diff --git a/auto/generate_test_runner.rb b/auto/generate_test_runner.rb index 3b979d0a..5053210d 100644 --- a/auto/generate_test_runner.rb +++ b/auto/generate_test_runner.rb @@ -41,6 +41,7 @@ def self.default_options main_name: 'main', # set to :auto to automatically generate each time main_export_decl: '', cmdline_args: false, + omit_begin_end: false, use_param_tests: false } end @@ -376,14 +377,19 @@ def create_main(output, filename, tests, used_mocks) output.puts(' return parse_status;') output.puts(' }') else + main_return = @options[:omit_begin_end] ? 'void' : 'int' if main_name != 'main' - output.puts("#{@options[:main_export_decl]} int #{main_name}(void);") + output.puts("#{@options[:main_export_decl]} #{main_return} #{main_name}(void);") end - output.puts("int #{main_name}(void)") + output.puts("#{main_return} #{main_name}(void)") output.puts('{') end output.puts(' suiteSetUp();') if @options[:has_suite_setup] - output.puts(" UnityBegin(\"#{filename.gsub(/\\/, '\\\\\\')}\");") + if @options[:omit_begin_end] + output.puts(" UnitySetTestFile(\"#{filename.gsub(/\\/, '\\\\\\')}\");") + else + output.puts(" UnityBegin(\"#{filename.gsub(/\\/, '\\\\\\')}\");") + end tests.each do |test| if (!@options[:use_param_tests]) || test[:args].nil? || test[:args].empty? output.puts(" run_test(#{test[:test]}, \"#{test[:test]}\", #{test[:line_number]});") @@ -398,9 +404,13 @@ def create_main(output, filename, tests, used_mocks) output.puts output.puts(' CMock_Guts_MemFreeFinal();') unless used_mocks.empty? if @options[:has_suite_teardown] - output.puts(' return suiteTearDown(UnityEnd());') + if @options[:omit_begin_end] + output.puts(' (void) suite_teardown(0);') + else + output.puts(' return suiteTearDown(UnityEnd());') + end else - output.puts(' return UnityEnd();') + output.puts(' return UnityEnd();') if not @options[:omit_begin_end] end output.puts('}') end @@ -473,6 +483,7 @@ def create_h_file(output, filename, tests, testfile_includes, used_mocks) ' --suite_setup="" - code to execute for setup of entire suite', ' --suite_teardown="" - code to execute for teardown of entire suite', ' --use_param_tests=1 - enable parameterized tests (disabled by default)', + ' --omit_begin_end=1 - omit calls to UnityBegin and UnityEnd (disabled by default)', ' --header_file="" - path/name of test header file to generate too'].join("\n") exit 1 end diff --git a/src/unity.c b/src/unity.c index 72d3855d..5cc481e3 100644 --- a/src/unity.c +++ b/src/unity.c @@ -1824,6 +1824,12 @@ void UnityDefaultTestRun(UnityTestFunction Func, const char* FuncName, const int UnityConcludeTest(); } +/*-----------------------------------------------*/ +void UnitySetTestFile(const char* filename) +{ + Unity.TestFile = filename; +} + /*-----------------------------------------------*/ void UnityBegin(const char* filename) { diff --git a/src/unity_internals.h b/src/unity_internals.h index 7e2024f8..3d5e60ae 100644 --- a/src/unity_internals.h +++ b/src/unity_internals.h @@ -477,6 +477,7 @@ extern struct UNITY_STORAGE_T Unity; void UnityBegin(const char* filename); int UnityEnd(void); +void UnitySetTestFile(const char* filename); void UnityConcludeTest(void); void UnityDefaultTestRun(UnityTestFunction Func, const char* FuncName, const int FuncLineNum); From 32e6d93ab026de86210bbcb5b474dc235308fb7e Mon Sep 17 00:00:00 2001 From: John Lindgren Date: Tue, 29 Oct 2019 16:59:59 -0400 Subject: [PATCH 187/454] Fix TEST_ASSERT_HEX64_ARRAY_WITHIN truncating delta to 32 bits. --- src/unity_internals.h | 6 +- test/tests/testunity.c | 166 ++++++++++++++++++++--------------------- 2 files changed, 86 insertions(+), 86 deletions(-) diff --git a/src/unity_internals.h b/src/unity_internals.h index 7e2024f8..c73a340a 100644 --- a/src/unity_internals.h +++ b/src/unity_internals.h @@ -911,9 +911,9 @@ int UnityTestMatches(void); #define UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_INT64(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(threshold), (UNITY_INT)(actual), UNITY_SMALLER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT64) #define UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_UINT64(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(threshold), (UNITY_INT)(actual), UNITY_SMALLER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT64) #define UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_HEX64(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(threshold), (UNITY_INT)(actual), UNITY_SMALLER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX64) -#define UNITY_TEST_ASSERT_INT64_ARRAY_WITHIN(delta, expected, actual, num_elements, line, message) UnityAssertNumbersArrayWithin((UNITY_UINT32)(delta), (UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT32, UNITY_ARRAY_TO_ARRAY) -#define UNITY_TEST_ASSERT_UINT64_ARRAY_WITHIN(delta, expected, actual, num_elements, line, message) UnityAssertNumbersArrayWithin((UNITY_UINT32)(delta), (UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT32, UNITY_ARRAY_TO_ARRAY) -#define UNITY_TEST_ASSERT_HEX64_ARRAY_WITHIN(delta, expected, actual, num_elements, line, message) UnityAssertNumbersArrayWithin((UNITY_UINT32)(delta), (UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX64, UNITY_ARRAY_TO_ARRAY) +#define UNITY_TEST_ASSERT_INT64_ARRAY_WITHIN(delta, expected, actual, num_elements, line, message) UnityAssertNumbersArrayWithin((UNITY_UINT64)(delta), (UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT64, UNITY_ARRAY_TO_ARRAY) +#define UNITY_TEST_ASSERT_UINT64_ARRAY_WITHIN(delta, expected, actual, num_elements, line, message) UnityAssertNumbersArrayWithin((UNITY_UINT64)(delta), (UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT64, UNITY_ARRAY_TO_ARRAY) +#define UNITY_TEST_ASSERT_HEX64_ARRAY_WITHIN(delta, expected, actual, num_elements, line, message) UnityAssertNumbersArrayWithin((UNITY_UINT64)(delta), (UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX64, UNITY_ARRAY_TO_ARRAY) #else #define UNITY_TEST_ASSERT_EQUAL_INT64(expected, actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErr64) #define UNITY_TEST_ASSERT_EQUAL_UINT64(expected, actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErr64) diff --git a/test/tests/testunity.c b/test/tests/testunity.c index 9f2d6928..13b6c251 100644 --- a/test/tests/testunity.c +++ b/test/tests/testunity.c @@ -307,7 +307,7 @@ void testNotEqualInt32s(void) EXPECT_ABORT_BEGIN /*use largest 32 bit negative to test printability*/ /*note: (-2147483647 - 1) is used instead of -2147483648 because of C90 casting rules */ - TEST_ASSERT_EQUAL_INT32(-2147483647, (-2147483647 - 1)); + TEST_ASSERT_EQUAL_INT32(-2147483647, (-2147483647 - 1)); VERIFY_FAILS_END } @@ -1420,10 +1420,10 @@ void testInt64ArrayWithinDelta(void) TEST_IGNORE(); #else UNITY_INT64 expected[] = {12345000, -12344995, 12345005}; - UNITY_INT64 acutalSmallDelta[] = {12345001, -12344996, 12345005}; + UNITY_INT64 actualSmallDelta[] = {12345001, -12344996, 12345005}; UNITY_INT64 actualBigDelta[] = {12345101, -12344896, 12345055}; - TEST_ASSERT_INT64_ARRAY_WITHIN(1, expected, acutalSmallDelta, 3); + TEST_ASSERT_INT64_ARRAY_WITHIN(1, expected, actualSmallDelta, 3); TEST_ASSERT_INT64_ARRAY_WITHIN(110, expected, actualBigDelta, 3); #endif } @@ -1434,10 +1434,10 @@ void testInt64ArrayWithinDeltaAndMessage(void) TEST_IGNORE(); #else UNITY_INT64 expected[] = {12345000, -12344995, 12345005}; - UNITY_INT64 acutalSmallDelta[] = {12345001, -12344996, 12345005}; + UNITY_INT64 actualSmallDelta[] = {12345001, -12344996, 12345005}; UNITY_INT64 actualBigDelta[] = {12345101, -12344896, 12345055}; - TEST_ASSERT_INT64_ARRAY_WITHIN_MESSAGE(1, expected, acutalSmallDelta, 3, "Custom Message."); + TEST_ASSERT_INT64_ARRAY_WITHIN_MESSAGE(1, expected, actualSmallDelta, 3, "Custom Message."); TEST_ASSERT_INT64_ARRAY_WITHIN_MESSAGE(110, expected, actualBigDelta, 3, "Custom Message."); #endif } @@ -1575,20 +1575,20 @@ void testInt64ArrayWithinDeltaSamePointerAndMessage(void) void testIntArrayWithinDelta(void) { UNITY_INT expected[] = {5000, -4995, 5005}; - UNITY_INT acutalSmallDelta[] = {5001, -4996, 5005}; + UNITY_INT actualSmallDelta[] = {5001, -4996, 5005}; UNITY_INT actualBigDelta[] = {5101, -4896, 5055}; - TEST_ASSERT_INT_ARRAY_WITHIN(1, expected, acutalSmallDelta, 3); + TEST_ASSERT_INT_ARRAY_WITHIN(1, expected, actualSmallDelta, 3); TEST_ASSERT_INT_ARRAY_WITHIN(110, expected, actualBigDelta, 3); } void testIntArrayWithinDeltaAndMessage(void) { UNITY_INT expected[] = {5000, -4995, 5005}; - UNITY_INT acutalSmallDelta[] = {5001, -4996, 5005}; + UNITY_INT actualSmallDelta[] = {5001, -4996, 5005}; UNITY_INT actualBigDelta[] = {5101, -4896, 5055}; - TEST_ASSERT_INT_ARRAY_WITHIN_MESSAGE(1, expected, acutalSmallDelta, 3, "Custom Message."); + TEST_ASSERT_INT_ARRAY_WITHIN_MESSAGE(1, expected, actualSmallDelta, 3, "Custom Message."); TEST_ASSERT_INT_ARRAY_WITHIN_MESSAGE(110, expected, actualBigDelta, 3, "Custom Message."); } @@ -1685,20 +1685,20 @@ void testIntArrayWithinDeltaSamePointerAndMessage(void) void testInt16ArrayWithinDelta(void) { UNITY_INT16 expected[] = {5000, -4995, 5005}; - UNITY_INT16 acutalSmallDelta[] = {5001, -4996, 5005}; + UNITY_INT16 actualSmallDelta[] = {5001, -4996, 5005}; UNITY_INT16 actualBigDelta[] = {5101, -4896, 5055}; - TEST_ASSERT_INT16_ARRAY_WITHIN(1, expected, acutalSmallDelta, 3); + TEST_ASSERT_INT16_ARRAY_WITHIN(1, expected, actualSmallDelta, 3); TEST_ASSERT_INT16_ARRAY_WITHIN(110, expected, actualBigDelta, 3); } void testInt16ArrayWithinDeltaAndMessage(void) { UNITY_INT16 expected[] = {5000, -4995, 5005}; - UNITY_INT16 acutalSmallDelta[] = {5001, -4996, 5005}; + UNITY_INT16 actualSmallDelta[] = {5001, -4996, 5005}; UNITY_INT16 actualBigDelta[] = {5101, -4896, 5055}; - TEST_ASSERT_INT16_ARRAY_WITHIN_MESSAGE(1, expected, acutalSmallDelta, 3, "Custom Message."); + TEST_ASSERT_INT16_ARRAY_WITHIN_MESSAGE(1, expected, actualSmallDelta, 3, "Custom Message."); TEST_ASSERT_INT16_ARRAY_WITHIN_MESSAGE(110, expected, actualBigDelta, 3, "Custom Message."); } @@ -1795,20 +1795,20 @@ void testInt16ArrayWithinDeltaSamePointerAndMessage(void) void testInt8ArrayWithinDelta(void) { UNITY_INT8 expected[] = {20, -95, 55}; - UNITY_INT8 acutalSmallDelta[] = {21, -94, 55}; + UNITY_INT8 actualSmallDelta[] = {21, -94, 55}; UNITY_INT8 actualBigDelta[] = {11, -86, 45}; - TEST_ASSERT_INT8_ARRAY_WITHIN(1, expected, acutalSmallDelta, 3); + TEST_ASSERT_INT8_ARRAY_WITHIN(1, expected, actualSmallDelta, 3); TEST_ASSERT_INT8_ARRAY_WITHIN(11, expected, actualBigDelta, 3); } void testInt8ArrayWithinDeltaAndMessage(void) { UNITY_INT8 expected[] = {20, -95, 55}; - UNITY_INT8 acutalSmallDelta[] = {21, -94, 55}; + UNITY_INT8 actualSmallDelta[] = {21, -94, 55}; UNITY_INT8 actualBigDelta[] = {11, -86, 45}; - TEST_ASSERT_INT8_ARRAY_WITHIN_MESSAGE(1, expected, acutalSmallDelta, 3, "Custom Message."); + TEST_ASSERT_INT8_ARRAY_WITHIN_MESSAGE(1, expected, actualSmallDelta, 3, "Custom Message."); TEST_ASSERT_INT8_ARRAY_WITHIN_MESSAGE(11, expected, actualBigDelta, 3, "Custom Message."); } @@ -1909,20 +1909,20 @@ void testInt8ArrayWithinDeltaSamePointerAndMessage(void) void testCHARArrayWithinDelta(void) { char expected[] = {20, -95, 55}; - char acutalSmallDelta[] = {21, -94, 55}; + char actualSmallDelta[] = {21, -94, 55}; char actualBigDelta[] = {11, -86, 45}; - TEST_ASSERT_CHAR_ARRAY_WITHIN(1, expected, acutalSmallDelta, 3); + TEST_ASSERT_CHAR_ARRAY_WITHIN(1, expected, actualSmallDelta, 3); TEST_ASSERT_CHAR_ARRAY_WITHIN(11, expected, actualBigDelta, 3); } void testCHARArrayWithinDeltaAndMessage(void) { char expected[] = {20, -95, 55}; - char acutalSmallDelta[] = {21, -94, 55}; + char actualSmallDelta[] = {21, -94, 55}; char actualBigDelta[] = {11, -86, 45}; - TEST_ASSERT_CHAR_ARRAY_WITHIN_MESSAGE(1, expected, acutalSmallDelta, 3, "Custom Message."); + TEST_ASSERT_CHAR_ARRAY_WITHIN_MESSAGE(1, expected, actualSmallDelta, 3, "Custom Message."); TEST_ASSERT_CHAR_ARRAY_WITHIN_MESSAGE(11, expected, actualBigDelta, 3, "Custom Message."); } @@ -2022,10 +2022,10 @@ void testUInt64ArrayWithinDelta(void) TEST_IGNORE(); #else UNITY_UINT64 expected[] = {12345000, 12344995, 12345005}; - UNITY_UINT64 acutalSmallDelta[] = {12345001, 12344996, 12345005}; + UNITY_UINT64 actualSmallDelta[] = {12345001, 12344996, 12345005}; UNITY_UINT64 actualBigDelta[] = {12345101, 12344896, 12345055}; - TEST_ASSERT_UINT64_ARRAY_WITHIN(1, expected, acutalSmallDelta, 3); + TEST_ASSERT_UINT64_ARRAY_WITHIN(1, expected, actualSmallDelta, 3); TEST_ASSERT_UINT64_ARRAY_WITHIN(110, expected, actualBigDelta, 3); #endif } @@ -2036,10 +2036,10 @@ void testUInt64ArrayWithinDeltaAndMessage(void) TEST_IGNORE(); #else UNITY_UINT64 expected[] = {12345000, 12344995, 12345005}; - UNITY_UINT64 acutalSmallDelta[] = {12345001, 12344996, 12345005}; + UNITY_UINT64 actualSmallDelta[] = {12345001, 12344996, 12345005}; UNITY_UINT64 actualBigDelta[] = {12345101, 12344896, 12345055}; - TEST_ASSERT_UINT64_ARRAY_WITHIN_MESSAGE(1, expected, acutalSmallDelta, 3, "Custom Message."); + TEST_ASSERT_UINT64_ARRAY_WITHIN_MESSAGE(1, expected, actualSmallDelta, 3, "Custom Message."); TEST_ASSERT_UINT64_ARRAY_WITHIN_MESSAGE(110, expected, actualBigDelta, 3, "Custom Message."); #endif } @@ -2177,20 +2177,20 @@ void testUInt64ArrayWithinDeltaSamePointerAndMessage(void) void testUIntArrayWithinDelta(void) { UNITY_UINT expected[] = {125000, 124995, 125005}; - UNITY_UINT acutalSmallDelta[] = {125001, 124996, 125005}; + UNITY_UINT actualSmallDelta[] = {125001, 124996, 125005}; UNITY_UINT actualBigDelta[] = {125101, 124896, 125055}; - TEST_ASSERT_UINT_ARRAY_WITHIN(1, expected, acutalSmallDelta, 3); + TEST_ASSERT_UINT_ARRAY_WITHIN(1, expected, actualSmallDelta, 3); TEST_ASSERT_UINT_ARRAY_WITHIN(110, expected, actualBigDelta, 3); } void testUIntArrayWithinDeltaAndMessage(void) { UNITY_UINT expected[] = {125000, 124995, 125005}; - UNITY_UINT acutalSmallDelta[] = {125001, 124996, 125005}; + UNITY_UINT actualSmallDelta[] = {125001, 124996, 125005}; UNITY_UINT actualBigDelta[] = {125101, 124896, 125055}; - TEST_ASSERT_UINT_ARRAY_WITHIN_MESSAGE(1, expected, acutalSmallDelta, 3, "Custom Message."); + TEST_ASSERT_UINT_ARRAY_WITHIN_MESSAGE(1, expected, actualSmallDelta, 3, "Custom Message."); TEST_ASSERT_UINT_ARRAY_WITHIN_MESSAGE(110, expected, actualBigDelta, 3, "Custom Message."); } @@ -2287,20 +2287,20 @@ void testUIntArrayWithinDeltaSamePointerAndMessage(void) void testUInt16ArrayWithinDelta(void) { UNITY_UINT16 expected[] = {5000, 4995, 5005}; - UNITY_UINT16 acutalSmallDelta[] = {5001, 4996, 5005}; + UNITY_UINT16 actualSmallDelta[] = {5001, 4996, 5005}; UNITY_UINT16 actualBigDelta[] = {5101, 4896, 5055}; - TEST_ASSERT_UINT16_ARRAY_WITHIN(1, expected, acutalSmallDelta, 3); + TEST_ASSERT_UINT16_ARRAY_WITHIN(1, expected, actualSmallDelta, 3); TEST_ASSERT_UINT16_ARRAY_WITHIN(110, expected, actualBigDelta, 3); } void testUInt16ArrayWithinDeltaAndMessage(void) { UNITY_UINT16 expected[] = {5000, 4995, 5005}; - UNITY_UINT16 acutalSmallDelta[] = {5001, 4996, 5005}; + UNITY_UINT16 actualSmallDelta[] = {5001, 4996, 5005}; UNITY_UINT16 actualBigDelta[] = {5101, 4896, 5055}; - TEST_ASSERT_UINT16_ARRAY_WITHIN_MESSAGE(1, expected, acutalSmallDelta, 3, "Custom Message."); + TEST_ASSERT_UINT16_ARRAY_WITHIN_MESSAGE(1, expected, actualSmallDelta, 3, "Custom Message."); TEST_ASSERT_UINT16_ARRAY_WITHIN_MESSAGE(110, expected, actualBigDelta, 3, "Custom Message."); } @@ -2397,20 +2397,20 @@ void testUInt16ArrayWithinDeltaSamePointerAndMessage(void) void testUInt8ArrayWithinDelta(void) { UNITY_UINT8 expected[] = {20, 95, 55}; - UNITY_UINT8 acutalSmallDelta[] = {21, 94, 55}; + UNITY_UINT8 actualSmallDelta[] = {21, 94, 55}; UNITY_UINT8 actualBigDelta[] = {11, 86, 45}; - TEST_ASSERT_UINT8_ARRAY_WITHIN(1, expected, acutalSmallDelta, 3); + TEST_ASSERT_UINT8_ARRAY_WITHIN(1, expected, actualSmallDelta, 3); TEST_ASSERT_UINT8_ARRAY_WITHIN(11, expected, actualBigDelta, 3); } void testUInt8ArrayWithinDeltaAndMessage(void) { UNITY_UINT8 expected[] = {20, 95, 55}; - UNITY_UINT8 acutalSmallDelta[] = {21, 94, 55}; + UNITY_UINT8 actualSmallDelta[] = {21, 94, 55}; UNITY_UINT8 actualBigDelta[] = {11, 86, 45}; - TEST_ASSERT_UINT8_ARRAY_WITHIN_MESSAGE(1, expected, acutalSmallDelta, 3, "Custom Message."); + TEST_ASSERT_UINT8_ARRAY_WITHIN_MESSAGE(1, expected, actualSmallDelta, 3, "Custom Message."); TEST_ASSERT_UINT8_ARRAY_WITHIN_MESSAGE(11, expected, actualBigDelta, 3, "Custom Message."); } @@ -2509,12 +2509,12 @@ void testHEX64ArrayWithinDelta(void) #ifndef UNITY_SUPPORT_64 TEST_IGNORE(); #else - UNITY_UINT64 expected[] = {0xABCD1234, 0xABCD1122, 0xABCD1277}; - UNITY_UINT64 acutalSmallDelta[] = {0xABCD1235, 0xABCD1121, 0xABCD1277}; - UNITY_UINT64 actualBigDelta[] = {0xABCD1267, 0xABCD1188, 0xABCD12AC}; + UNITY_UINT64 expected[] = {0xABCD123400000000, 0xABCD112200000000, 0xABCD127700000000}; + UNITY_UINT64 actualSmallDelta[] = {0xABCD123500000000, 0xABCD112100000000, 0xABCD127700000000}; + UNITY_UINT64 actualBigDelta[] = {0xABCD126700000000, 0xABCD118800000000, 0xABCD12AC00000000}; - TEST_ASSERT_HEX64_ARRAY_WITHIN(1, expected, acutalSmallDelta, 3); - TEST_ASSERT_HEX64_ARRAY_WITHIN(110, expected, actualBigDelta, 3); + TEST_ASSERT_HEX64_ARRAY_WITHIN(0x100000000, expected, actualSmallDelta, 3); + TEST_ASSERT_HEX64_ARRAY_WITHIN(0x6E00000000, expected, actualBigDelta, 3); #endif } @@ -2523,12 +2523,12 @@ void testHEX64ArrayWithinDeltaAndMessage(void) #ifndef UNITY_SUPPORT_64 TEST_IGNORE(); #else - UNITY_UINT64 expected[] = {0xABCD1234, 0xABCD1122, 0xABCD1277}; - UNITY_UINT64 acutalSmallDelta[] = {0xABCD1235, 0xABCD1121, 0xABCD1277}; - UNITY_UINT64 actualBigDelta[] = {0xABCD1267, 0xABCD1188, 0xABCD12AC}; + UNITY_UINT64 expected[] = {0xABCD123400000000, 0xABCD112200000000, 0xABCD127700000000}; + UNITY_UINT64 actualSmallDelta[] = {0xABCD123500000000, 0xABCD112100000000, 0xABCD127700000000}; + UNITY_UINT64 actualBigDelta[] = {0xABCD126700000000, 0xABCD118800000000, 0xABCD12AC00000000}; - TEST_ASSERT_HEX64_ARRAY_WITHIN_MESSAGE(1, expected, acutalSmallDelta, 3, "Custom Message."); - TEST_ASSERT_HEX64_ARRAY_WITHIN_MESSAGE(110, expected, actualBigDelta, 3, "Custom Message."); + TEST_ASSERT_HEX64_ARRAY_WITHIN_MESSAGE(0x100000000, expected, actualSmallDelta, 3, "Custom Message."); + TEST_ASSERT_HEX64_ARRAY_WITHIN_MESSAGE(0x6E00000000, expected, actualBigDelta, 3, "Custom Message."); #endif } @@ -2537,11 +2537,11 @@ void testHEX64ArrayNotWithinDelta(void) #ifndef UNITY_SUPPORT_64 TEST_IGNORE(); #else - UNITY_UINT64 expected[] = {0xABCD1234, 0xABCD1122, 0xABCD1277}; - UNITY_UINT64 actualBigDelta[] = {0xABCD1267, 0xABCD1188, 0xABCD12AC}; + UNITY_UINT64 expected[] = {0xABCD123400000000, 0xABCD112200000000, 0xABCD127700000000}; + UNITY_UINT64 actualBigDelta[] = {0xABCD126700000000, 0xABCD118800000000, 0xABCD12AC00000000}; EXPECT_ABORT_BEGIN - TEST_ASSERT_HEX64_ARRAY_WITHIN(1, expected, actualBigDelta, 3); + TEST_ASSERT_HEX64_ARRAY_WITHIN(0x100000000, expected, actualBigDelta, 3); VERIFY_FAILS_END #endif } @@ -2551,11 +2551,11 @@ void testHEX64ArrayNotWithinDeltaAndMessage(void) #ifndef UNITY_SUPPORT_64 TEST_IGNORE(); #else - UNITY_UINT64 expected[] = {0xABCD1234, 0xABCD1122, 0xABCD1277}; - UNITY_UINT64 actualBigDelta[] = {0xABCD1267, 0xABCD1188, 0xABCD12AC}; + UNITY_UINT64 expected[] = {0xABCD123400000000, 0xABCD112200000000, 0xABCD127700000000}; + UNITY_UINT64 actualBigDelta[] = {0xABCD126700000000, 0xABCD118800000000, 0xABCD12AC00000000}; EXPECT_ABORT_BEGIN - TEST_ASSERT_HEX64_ARRAY_WITHIN_MESSAGE(1, expected, actualBigDelta, 3, "Custom Message."); + TEST_ASSERT_HEX64_ARRAY_WITHIN_MESSAGE(0x100000000, expected, actualBigDelta, 3, "Custom Message."); VERIFY_FAILS_END #endif } @@ -2565,11 +2565,11 @@ void testHEX64ArrayWithinDeltaPointless(void) #ifndef UNITY_SUPPORT_64 TEST_IGNORE(); #else - UNITY_UINT64 expected[] = {0xABCD1234, 0xABCD1122, 0xABCD1277}; - UNITY_UINT64 actualBigDelta[] = {0xABCD1267, 0xABCD1188, 0xABCD12AC}; + UNITY_UINT64 expected[] = {0xABCD123400000000, 0xABCD112200000000, 0xABCD127700000000}; + UNITY_UINT64 actualBigDelta[] = {0xABCD126700000000, 0xABCD118800000000, 0xABCD12AC00000000}; EXPECT_ABORT_BEGIN - TEST_ASSERT_HEX64_ARRAY_WITHIN(110, expected, actualBigDelta, 0); + TEST_ASSERT_HEX64_ARRAY_WITHIN(0x6E00000000, expected, actualBigDelta, 0); VERIFY_FAILS_END #endif } @@ -2579,11 +2579,11 @@ void testHEX64ArrayWithinDeltaPointlessAndMessage(void) #ifndef UNITY_SUPPORT_64 TEST_IGNORE(); #else - UNITY_UINT64 expected[] = {0xABCD1234, 0xABCD1122, 0xABCD1277}; - UNITY_UINT64 actualBigDelta[] = {0xABCD1267, 0xABCD1188, 0xABCD12AC}; + UNITY_UINT64 expected[] = {0xABCD123400000000, 0xABCD112200000000, 0xABCD127700000000}; + UNITY_UINT64 actualBigDelta[] = {0xABCD126700000000, 0xABCD118800000000, 0xABCD12AC00000000}; EXPECT_ABORT_BEGIN - TEST_ASSERT_HEX64_ARRAY_WITHIN_MESSAGE(110, expected, actualBigDelta, 0, "Custom Message."); + TEST_ASSERT_HEX64_ARRAY_WITHIN_MESSAGE(0x6E00000000, expected, actualBigDelta, 0, "Custom Message."); VERIFY_FAILS_END #endif } @@ -2593,10 +2593,10 @@ void testHEX64ArrayWithinDeltaExpectedNull(void) #ifndef UNITY_SUPPORT_64 TEST_IGNORE(); #else - UNITY_UINT64 actualBigDelta[] = {0xABCD1267, 0xABCD1188, 0xABCD12AC}; + UNITY_UINT64 actualBigDelta[] = {0xABCD126700000000, 0xABCD118800000000, 0xABCD12AC00000000}; EXPECT_ABORT_BEGIN - TEST_ASSERT_HEX64_ARRAY_WITHIN(110, NULL, actualBigDelta, 3); + TEST_ASSERT_HEX64_ARRAY_WITHIN(0x6E00000000, NULL, actualBigDelta, 3); VERIFY_FAILS_END #endif } @@ -2606,10 +2606,10 @@ void testHEX64ArrayWithinDeltaExpectedNullAndMessage(void) #ifndef UNITY_SUPPORT_64 TEST_IGNORE(); #else - UNITY_UINT64 actualBigDelta[] = {0xABCD1267, 0xABCD1188, 0xABCD12AC}; + UNITY_UINT64 actualBigDelta[] = {0xABCD126700000000, 0xABCD118800000000, 0xABCD12AC00000000}; EXPECT_ABORT_BEGIN - TEST_ASSERT_HEX64_ARRAY_WITHIN_MESSAGE(110, NULL, actualBigDelta, 3, "Custom Message."); + TEST_ASSERT_HEX64_ARRAY_WITHIN_MESSAGE(0x6E00000000, NULL, actualBigDelta, 3, "Custom Message."); VERIFY_FAILS_END #endif } @@ -2619,10 +2619,10 @@ void testHEX64ArrayWithinDeltaActualNull(void) #ifndef UNITY_SUPPORT_64 TEST_IGNORE(); #else - UNITY_UINT64 expected[] = {0xABCD1234, 0xABCD1122, 0xABCD1277}; + UNITY_UINT64 expected[] = {0xABCD123400000000, 0xABCD112200000000, 0xABCD127700000000}; EXPECT_ABORT_BEGIN - TEST_ASSERT_HEX64_ARRAY_WITHIN(110, expected, NULL, 3); + TEST_ASSERT_HEX64_ARRAY_WITHIN(0x6E00000000, expected, NULL, 3); VERIFY_FAILS_END #endif } @@ -2632,10 +2632,10 @@ void testHEX64ArrayWithinDeltaActualNullAndMessage(void) #ifndef UNITY_SUPPORT_64 TEST_IGNORE(); #else - UNITY_UINT64 expected[] = {0xABCD1234, 0xABCD1122, 0xABCD1277}; + UNITY_UINT64 expected[] = {0xABCD123400000000, 0xABCD112200000000, 0xABCD127700000000}; EXPECT_ABORT_BEGIN - TEST_ASSERT_HEX64_ARRAY_WITHIN_MESSAGE(110, expected, NULL, 3, "Custom Message."); + TEST_ASSERT_HEX64_ARRAY_WITHIN_MESSAGE(0x6E00000000, expected, NULL, 3, "Custom Message."); VERIFY_FAILS_END #endif } @@ -2645,9 +2645,9 @@ void testHEX64ArrayWithinDeltaSamePointer(void) #ifndef UNITY_SUPPORT_64 TEST_IGNORE(); #else - UNITY_UINT64 expected[] = {0xABCD1234, 0xABCD1122, 0xABCD1277}; + UNITY_UINT64 expected[] = {0xABCD123400000000, 0xABCD112200000000, 0xABCD127700000000}; - TEST_ASSERT_HEX64_ARRAY_WITHIN(110, expected, expected, 3); + TEST_ASSERT_HEX64_ARRAY_WITHIN(0x6E00000000, expected, expected, 3); #endif } @@ -2656,29 +2656,29 @@ void testHEX64ArrayWithinDeltaSamePointerAndMessage(void) #ifndef UNITY_SUPPORT_64 TEST_IGNORE(); #else - UNITY_UINT64 expected[] = {0xABCD11234, 0xABCD1122, 0xABCD1277}; + UNITY_UINT64 expected[] = {0xABCD123400000000, 0xABCD112200000000, 0xABCD127700000000}; - TEST_ASSERT_HEX64_ARRAY_WITHIN_MESSAGE(110, expected, expected, 3, "Custom Message."); + TEST_ASSERT_HEX64_ARRAY_WITHIN_MESSAGE(0x6E00000000, expected, expected, 3, "Custom Message."); #endif } void testHEX32ArrayWithinDelta(void) { UNITY_UINT expected[] = {0xABCD1234, 0xABCD1122, 0xABCD1277}; - UNITY_UINT acutalSmallDelta[] = {0xABCD1235, 0xABCD1121, 0xABCD1277}; + UNITY_UINT actualSmallDelta[] = {0xABCD1235, 0xABCD1121, 0xABCD1277}; UNITY_UINT actualBigDelta[] = {0xABCD1267, 0xABCD1188, 0xABCD12AC}; - TEST_ASSERT_HEX32_ARRAY_WITHIN(1, expected, acutalSmallDelta, 3); + TEST_ASSERT_HEX32_ARRAY_WITHIN(1, expected, actualSmallDelta, 3); TEST_ASSERT_HEX32_ARRAY_WITHIN(110, expected, actualBigDelta, 3); } void testHEX32ArrayWithinDeltaAndMessage(void) { UNITY_UINT expected[] = {0xABCD1234, 0xABCD1122, 0xABCD1277}; - UNITY_UINT acutalSmallDelta[] = {0xABCD1235, 0xABCD1121, 0xABCD1277}; + UNITY_UINT actualSmallDelta[] = {0xABCD1235, 0xABCD1121, 0xABCD1277}; UNITY_UINT actualBigDelta[] = {0xABCD1267, 0xABCD1188, 0xABCD12AC}; - TEST_ASSERT_HEX32_ARRAY_WITHIN_MESSAGE(1, expected, acutalSmallDelta, 3, "Custom Message."); + TEST_ASSERT_HEX32_ARRAY_WITHIN_MESSAGE(1, expected, actualSmallDelta, 3, "Custom Message."); TEST_ASSERT_HEX32_ARRAY_WITHIN_MESSAGE(110, expected, actualBigDelta, 3, "Custom Message."); } @@ -2776,20 +2776,20 @@ void testHEX32ArrayWithinDeltaSamePointerAndMessage(void) void testHEX16ArrayWithinDelta(void) { UNITY_UINT16 expected[] = {0x1234, 0x1122, 0x1277}; - UNITY_UINT16 acutalSmallDelta[] = {0x1235, 0x1121, 0x1277}; + UNITY_UINT16 actualSmallDelta[] = {0x1235, 0x1121, 0x1277}; UNITY_UINT16 actualBigDelta[] = {0x1267, 0x1188, 0x12AC}; - TEST_ASSERT_HEX16_ARRAY_WITHIN(1, expected, acutalSmallDelta, 3); + TEST_ASSERT_HEX16_ARRAY_WITHIN(1, expected, actualSmallDelta, 3); TEST_ASSERT_HEX16_ARRAY_WITHIN(110, expected, actualBigDelta, 3); } void testHEX16ArrayWithinDeltaAndMessage(void) { UNITY_UINT16 expected[] = {0x1234, 0x1122, 0x1277}; - UNITY_UINT16 acutalSmallDelta[] = {0x1235, 0x1121, 0x1277}; + UNITY_UINT16 actualSmallDelta[] = {0x1235, 0x1121, 0x1277}; UNITY_UINT16 actualBigDelta[] = {0x1267, 0x1188, 0x12AC}; - TEST_ASSERT_HEX16_ARRAY_WITHIN_MESSAGE(1, expected, acutalSmallDelta, 3, "Custom Message."); + TEST_ASSERT_HEX16_ARRAY_WITHIN_MESSAGE(1, expected, actualSmallDelta, 3, "Custom Message."); TEST_ASSERT_HEX16_ARRAY_WITHIN_MESSAGE(110, expected, actualBigDelta, 3, "Custom Message."); } @@ -2886,20 +2886,20 @@ void testHEX16ArrayWithinDeltaSamePointerAndMessage(void) void testHEX8ArrayWithinDelta(void) { UNITY_UINT8 expected[] = {0x34, 0x22, 0x77}; - UNITY_UINT8 acutalSmallDelta[] = {0x35, 0x21, 0x77}; + UNITY_UINT8 actualSmallDelta[] = {0x35, 0x21, 0x77}; UNITY_UINT8 actualBigDelta[] = {0x47, 0x48, 0x4C}; - TEST_ASSERT_HEX8_ARRAY_WITHIN(1, expected, acutalSmallDelta, 3); + TEST_ASSERT_HEX8_ARRAY_WITHIN(1, expected, actualSmallDelta, 3); TEST_ASSERT_HEX8_ARRAY_WITHIN(60, expected, actualBigDelta, 3); } void testHEX8ArrayWithinDeltaAndMessage(void) { UNITY_UINT8 expected[] = {0x34, 0x22, 0x77}; - UNITY_UINT8 acutalSmallDelta[] = {0x35, 0x21, 0x77}; + UNITY_UINT8 actualSmallDelta[] = {0x35, 0x21, 0x77}; UNITY_UINT8 actualBigDelta[] = {0x47, 0x48, 0x4C}; - TEST_ASSERT_HEX8_ARRAY_WITHIN_MESSAGE(1, expected, acutalSmallDelta, 3, "Custom Message."); + TEST_ASSERT_HEX8_ARRAY_WITHIN_MESSAGE(1, expected, actualSmallDelta, 3, "Custom Message."); TEST_ASSERT_HEX8_ARRAY_WITHIN_MESSAGE(60, expected, actualBigDelta, 3, "Custom Message."); } From 8072c5c94698aa3c2f750f67fc357ba753252e6d Mon Sep 17 00:00:00 2001 From: John Lindgren Date: Tue, 29 Oct 2019 17:10:45 -0400 Subject: [PATCH 188/454] Remove exactly duplicated 'else if' branch. --- src/unity.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/unity.c b/src/unity.c index 72d3855d..578870a1 100644 --- a/src/unity.c +++ b/src/unity.c @@ -342,10 +342,6 @@ void UnityPrintNumberByStyle(const UNITY_INT number, const UNITY_DISPLAY_STYLE_T { UnityPrintNumberUnsigned((UNITY_UINT)number); } - else if ((style & UNITY_DISPLAY_RANGE_UINT) == UNITY_DISPLAY_RANGE_UINT) - { - UnityPrintNumberUnsigned((UNITY_UINT)number); - } else { UNITY_OUTPUT_CHAR('0'); From fbded74349f9d163a0690c5904c0819ab3b1f80c Mon Sep 17 00:00:00 2001 From: mvandervoord Date: Wed, 30 Oct 2019 07:52:07 -0400 Subject: [PATCH 189/454] Split memory from fixtures and make it's own addon --- .travis.yml | 3 + extras/fixture/rakefile_helper.rb | 7 +- extras/fixture/readme.md | 17 + extras/fixture/readme.txt | 9 - extras/fixture/src/unity_fixture.c | 201 ------------ extras/fixture/src/unity_fixture.h | 4 - extras/fixture/src/unity_fixture_internals.h | 2 - extras/fixture/test/Makefile | 7 - extras/fixture/test/main/AllTests.c | 2 - extras/fixture/test/unity_fixture_Test.c | 300 ------------------ .../fixture/test/unity_fixture_TestRunner.c | 25 -- extras/memory/rakefile.rb | 45 +++ extras/memory/rakefile_helper.rb | 187 +++++++++++ extras/memory/readme.md | 49 +++ extras/memory/src/unity_memory.c | 201 ++++++++++++ .../src/unity_memory.h} | 39 ++- extras/memory/test/Makefile | 78 +++++ extras/memory/test/unity_memory_Test.c | 300 ++++++++++++++++++ extras/memory/test/unity_memory_TestRunner.c | 49 +++ .../test/unity_output_Spy.c | 7 +- .../test/unity_output_Spy.h | 7 +- 21 files changed, 962 insertions(+), 577 deletions(-) create mode 100644 extras/fixture/readme.md delete mode 100644 extras/fixture/readme.txt create mode 100644 extras/memory/rakefile.rb create mode 100644 extras/memory/rakefile_helper.rb create mode 100644 extras/memory/readme.md create mode 100644 extras/memory/src/unity_memory.c rename extras/{fixture/src/unity_fixture_malloc_overrides.h => memory/src/unity_memory.h} (58%) create mode 100644 extras/memory/test/Makefile create mode 100644 extras/memory/test/unity_memory_Test.c create mode 100644 extras/memory/test/unity_memory_TestRunner.c rename extras/{fixture => memory}/test/unity_output_Spy.c (88%) rename extras/{fixture => memory}/test/unity_output_Spy.h (72%) diff --git a/.travis.yml b/.travis.yml index 8d32264a..ebd4672a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -24,6 +24,9 @@ script: - cd ../extras/fixture/test && rake ci - make -s default noStdlibMalloc - make -s C89 + - cd ../extras/memory/test && rake ci + - make -s default noStdlibMalloc + - make -s C89 - cd ../../../examples/example_1 && make -s ci - cd ../example_2 && make -s ci - cd ../example_3 && rake diff --git a/extras/fixture/rakefile_helper.rb b/extras/fixture/rakefile_helper.rb index 91dafaf7..c543d10b 100644 --- a/extras/fixture/rakefile_helper.rb +++ b/extras/fixture/rakefile_helper.rb @@ -55,12 +55,7 @@ def build_compiler_fields defines = if $cfg['compiler']['defines']['items'].nil? '' else - decl = if $is_windows - 'UNITY_OUTPUT_CHAR_HEADER_DECLARATION=UnityOutputCharSpy_OutputChar(int)' - else - 'UNITY_OUTPUT_CHAR_HEADER_DECLARATION=UnityOutputCharSpy_OutputChar\(int\)' - end - squash($cfg['compiler']['defines']['prefix'], $cfg['compiler']['defines']['items'] + ['UNITY_OUTPUT_CHAR=UnityOutputCharSpy_OutputChar'] + [decl]) + squash($cfg['compiler']['defines']['prefix'], $cfg['compiler']['defines']['items']) end options = squash('', $cfg['compiler']['options']) includes = squash($cfg['compiler']['includes']['prefix'], $cfg['compiler']['includes']['items']) diff --git a/extras/fixture/readme.md b/extras/fixture/readme.md new file mode 100644 index 00000000..38a31321 --- /dev/null +++ b/extras/fixture/readme.md @@ -0,0 +1,17 @@ +# Unity Fixtures + +This Framework is an optional add-on to Unity. By including unity_framework.h in place of unity.h, +you may now work with Unity in a manner similar to CppUTest. This framework adds the concepts of +test groups and gives finer control of your tests over the command line. + +This framework is primarily supplied for those working through James Grenning's book on Embedded +Test Driven Development, or those coming to Unity from CppUTest. We should note that using this +framework glosses over some of the features of Unity, and makes it more difficult +to integrate with other testing tools like Ceedling and CMock. + +# Dependency Notification + +Fixtures, by default, uses the Memory addon as well. This is to make it simple for those trying to +follow along with James' book. Using them together is completely optional. You may choose to use +Fixtures without Memory handling by defining `UNITY_FIXTURE_NO_EXTRAS`. It will then stop automatically +pulling in extras and leave you to do it as desired. diff --git a/extras/fixture/readme.txt b/extras/fixture/readme.txt deleted file mode 100644 index 6b9a78c1..00000000 --- a/extras/fixture/readme.txt +++ /dev/null @@ -1,9 +0,0 @@ -Copyright (c) 2010 James Grenning and Contributed to Unity Project - -Unity Project - A Test Framework for C -Copyright (c) 2007 Mike Karlesky, Mark VanderVoord, Greg Williams -[Released under MIT License. Please refer to license.txt for details] - -This Framework is an optional add-on to Unity. By including unity_framework.h in place of unity.h, -you may now work with Unity in a manner similar to CppUTest. This framework adds the concepts of -test groups and gives finer control of your tests over the command line. \ No newline at end of file diff --git a/extras/fixture/src/unity_fixture.c b/extras/fixture/src/unity_fixture.c index 958a37fc..3b66a6d1 100644 --- a/extras/fixture/src/unity_fixture.c +++ b/extras/fixture/src/unity_fixture.c @@ -94,7 +94,6 @@ void UnityTestRunner(unityfunction* setup, } Unity.NumberOfTests++; - UnityMalloc_StartTest(); UnityPointer_Init(); UNITY_EXEC_TIME_START(); @@ -111,8 +110,6 @@ void UnityTestRunner(unityfunction* setup, if (TEST_PROTECT()) { UnityPointer_UndoAllSets(); - if (!Unity.CurrentTestFailed) - UnityMalloc_EndTest(); } UnityConcludeFixtureTest(); } @@ -140,204 +137,6 @@ void UnityIgnoreTest(const char* printableName, const char* group, const char* n } } - -/*------------------------------------------------- */ -/* Malloc and free stuff */ -#define MALLOC_DONT_FAIL -1 -static int malloc_count; -static int malloc_fail_countdown = MALLOC_DONT_FAIL; - -void UnityMalloc_StartTest(void) -{ - malloc_count = 0; - malloc_fail_countdown = MALLOC_DONT_FAIL; -} - -void UnityMalloc_EndTest(void) -{ - malloc_fail_countdown = MALLOC_DONT_FAIL; - if (malloc_count != 0) - { - UNITY_TEST_FAIL(Unity.CurrentTestLineNumber, "This test leaks!"); - } -} - -void UnityMalloc_MakeMallocFailAfterCount(int countdown) -{ - malloc_fail_countdown = countdown; -} - -/* These definitions are always included from unity_fixture_malloc_overrides.h */ -/* We undef to use them or avoid conflict with per the C standard */ -#undef malloc -#undef free -#undef calloc -#undef realloc - -#ifdef UNITY_EXCLUDE_STDLIB_MALLOC -static unsigned char unity_heap[UNITY_INTERNAL_HEAP_SIZE_BYTES]; -static size_t heap_index; -#else -#include -#endif - -typedef struct GuardBytes -{ - size_t size; - size_t guard_space; -} Guard; - - -#define UNITY_MALLOC_ALIGNMENT (UNITY_POINTER_WIDTH / 8) -static const char end[] = "END"; - - -static size_t unity_size_round_up(size_t size) -{ - size_t rounded_size; - - rounded_size = ((size + UNITY_MALLOC_ALIGNMENT - 1) / UNITY_MALLOC_ALIGNMENT) * UNITY_MALLOC_ALIGNMENT; - - return rounded_size; -} - -void* unity_malloc(size_t size) -{ - char* mem; - Guard* guard; - size_t total_size; - - total_size = sizeof(Guard) + unity_size_round_up(size + sizeof(end)); - - if (malloc_fail_countdown != MALLOC_DONT_FAIL) - { - if (malloc_fail_countdown == 0) - return NULL; - malloc_fail_countdown--; - } - - if (size == 0) return NULL; -#ifdef UNITY_EXCLUDE_STDLIB_MALLOC - if (heap_index + total_size > UNITY_INTERNAL_HEAP_SIZE_BYTES) - { - guard = NULL; - } - else - { - guard = (Guard*)&unity_heap[heap_index]; - heap_index += total_size; - } -#else - guard = (Guard*)UNITY_FIXTURE_MALLOC(total_size); -#endif - if (guard == NULL) return NULL; - malloc_count++; - guard->size = size; - guard->guard_space = 0; - mem = (char*)&(guard[1]); - memcpy(&mem[size], end, sizeof(end)); - - return (void*)mem; -} - -static int isOverrun(void* mem) -{ - Guard* guard = (Guard*)mem; - char* memAsChar = (char*)mem; - guard--; - - return guard->guard_space != 0 || strcmp(&memAsChar[guard->size], end) != 0; -} - -static void release_memory(void* mem) -{ - Guard* guard = (Guard*)mem; - guard--; - - malloc_count--; -#ifdef UNITY_EXCLUDE_STDLIB_MALLOC - { - size_t block_size; - - block_size = unity_size_round_up(guard->size + sizeof(end)); - - if (mem == unity_heap + heap_index - block_size) - { - heap_index -= (sizeof(Guard) + block_size); - } - } -#else - UNITY_FIXTURE_FREE(guard); -#endif -} - -void unity_free(void* mem) -{ - int overrun; - - if (mem == NULL) - { - return; - } - - overrun = isOverrun(mem); - release_memory(mem); - if (overrun) - { - UNITY_TEST_FAIL(Unity.CurrentTestLineNumber, "Buffer overrun detected during free()"); - } -} - -void* unity_calloc(size_t num, size_t size) -{ - void* mem = unity_malloc(num * size); - if (mem == NULL) return NULL; - memset(mem, 0, num * size); - return mem; -} - -void* unity_realloc(void* oldMem, size_t size) -{ - Guard* guard = (Guard*)oldMem; - void* newMem; - - if (oldMem == NULL) return unity_malloc(size); - - guard--; - if (isOverrun(oldMem)) - { - release_memory(oldMem); - UNITY_TEST_FAIL(Unity.CurrentTestLineNumber, "Buffer overrun detected during realloc()"); - } - - if (size == 0) - { - release_memory(oldMem); - return NULL; - } - - if (guard->size >= size) return oldMem; - -#ifdef UNITY_EXCLUDE_STDLIB_MALLOC /* Optimization if memory is expandable */ - { - size_t old_total_size = unity_size_round_up(guard->size + sizeof(end)); - - if ((oldMem == unity_heap + heap_index - old_total_size) && - ((heap_index - old_total_size + unity_size_round_up(size + sizeof(end))) <= UNITY_INTERNAL_HEAP_SIZE_BYTES)) - { - release_memory(oldMem); /* Not thread-safe, like unity_heap generally */ - return unity_malloc(size); /* No memcpy since data is in place */ - } - } -#endif - newMem = unity_malloc(size); - if (newMem == NULL) return NULL; /* Do not release old memory */ - memcpy(newMem, oldMem, guard->size); - release_memory(oldMem); - return newMem; -} - - /*-------------------------------------------------------- */ /*Automatic pointer restoration functions */ struct PointerPair diff --git a/extras/fixture/src/unity_fixture.h b/extras/fixture/src/unity_fixture.h index 2dcf473c..c042a264 100644 --- a/extras/fixture/src/unity_fixture.h +++ b/extras/fixture/src/unity_fixture.h @@ -10,7 +10,6 @@ #include "unity.h" #include "unity_internals.h" -#include "unity_fixture_malloc_overrides.h" #include "unity_fixture_internals.h" int UnityMain(int argc, const char* argv[], void (*runAllTests)(void)); @@ -77,7 +76,4 @@ int UnityMain(int argc, const char* argv[], void (*runAllTests)(void)); #define DOUBLES_EQUAL(expected, actual, delta) TEST_ASSERT_DOUBLE_WITHIN((delta), (expected), (actual)) #endif -/* You must compile with malloc replacement, as defined in unity_fixture_malloc_overrides.h */ -void UnityMalloc_MakeMallocFailAfterCount(int countdown); - #endif /* UNITY_FIXTURE_H_ */ diff --git a/extras/fixture/src/unity_fixture_internals.h b/extras/fixture/src/unity_fixture_internals.h index 98d4d443..1c51aa98 100644 --- a/extras/fixture/src/unity_fixture_internals.h +++ b/extras/fixture/src/unity_fixture_internals.h @@ -33,8 +33,6 @@ void UnityTestRunner(unityfunction* setup, const char* file, unsigned int line); void UnityIgnoreTest(const char* printableName, const char* group, const char* name); -void UnityMalloc_StartTest(void); -void UnityMalloc_EndTest(void); int UnityGetCommandLineOptions(int argc, const char* argv[]); void UnityConcludeFixtureTest(void); diff --git a/extras/fixture/test/Makefile b/extras/fixture/test/Makefile index 2560868d..897c5dce 100644 --- a/extras/fixture/test/Makefile +++ b/extras/fixture/test/Makefile @@ -5,17 +5,10 @@ endif #DEBUG = -O0 -g CFLAGS += -std=c99 -pedantic -Wall -Wextra -Werror CFLAGS += $(DEBUG) -DEFINES = -D UNITY_OUTPUT_CHAR=UnityOutputCharSpy_OutputChar -ifeq ($(OS),Windows_NT) - DEFINES += -D UNITY_OUTPUT_CHAR_HEADER_DECLARATION=UnityOutputCharSpy_OutputChar(int) -else - DEFINES += -D UNITY_OUTPUT_CHAR_HEADER_DECLARATION=UnityOutputCharSpy_OutputChar\(int\) -endif SRC = ../src/unity_fixture.c \ ../../../src/unity.c \ unity_fixture_Test.c \ unity_fixture_TestRunner.c \ - unity_output_Spy.c \ main/AllTests.c INC_DIR = -I../src -I../../../src/ diff --git a/extras/fixture/test/main/AllTests.c b/extras/fixture/test/main/AllTests.c index e30dd853..30242cb3 100644 --- a/extras/fixture/test/main/AllTests.c +++ b/extras/fixture/test/main/AllTests.c @@ -11,8 +11,6 @@ static void runAllTests(void) { RUN_TEST_GROUP(UnityFixture); RUN_TEST_GROUP(UnityCommandOptions); - RUN_TEST_GROUP(LeakDetection); - RUN_TEST_GROUP(InternalMalloc); } int main(int argc, const char* argv[]) diff --git a/extras/fixture/test/unity_fixture_Test.c b/extras/fixture/test/unity_fixture_Test.c index 4b59d988..1422b489 100644 --- a/extras/fixture/test/unity_fixture_Test.c +++ b/extras/fixture/test/unity_fixture_Test.c @@ -6,7 +6,6 @@ * ========================================== */ #include "unity_fixture.h" -#include "unity_output_Spy.h" #include #include @@ -44,71 +43,6 @@ TEST(UnityFixture, PointerSetting) TEST_ASSERT_POINTERS_EQUAL(pointer3, (int*)3); } -TEST(UnityFixture, ForceMallocFail) -{ - void* m; - void* mfails; - UnityMalloc_MakeMallocFailAfterCount(1); - m = malloc(10); - CHECK(m); - mfails = malloc(10); - TEST_ASSERT_POINTERS_EQUAL(0, mfails); - free(m); -} - -TEST(UnityFixture, ReallocSmallerIsUnchanged) -{ - void* m1 = malloc(10); - void* m2 = realloc(m1, 5); - TEST_ASSERT_POINTERS_EQUAL(m1, m2); - free(m2); -} - -TEST(UnityFixture, ReallocSameIsUnchanged) -{ - void* m1 = malloc(10); - void* m2 = realloc(m1, 10); - TEST_ASSERT_POINTERS_EQUAL(m1, m2); - free(m2); -} - -TEST(UnityFixture, ReallocLargerNeeded) -{ - void* m1 = malloc(10); - void* m2; - CHECK(m1); - strcpy((char*)m1, "123456789"); - m2 = realloc(m1, 15); - /* CHECK(m1 != m2); //Depends on implementation */ - STRCMP_EQUAL("123456789", m2); - free(m2); -} - -TEST(UnityFixture, ReallocNullPointerIsLikeMalloc) -{ - void* m = realloc(0, 15); - CHECK(m != 0); - free(m); -} - -TEST(UnityFixture, ReallocSizeZeroFreesMemAndReturnsNullPointer) -{ - void* m1 = malloc(10); - void* m2 = realloc(m1, 0); - TEST_ASSERT_POINTERS_EQUAL(0, m2); -} - -TEST(UnityFixture, CallocFillsWithZero) -{ - void* m = calloc(3, sizeof(char)); - char* s = (char*)m; - CHECK(m); - TEST_ASSERT_BYTES_EQUAL(0, s[0]); - TEST_ASSERT_BYTES_EQUAL(0, s[1]); - TEST_ASSERT_BYTES_EQUAL(0, s[2]); - free(m); -} - static char *p1; static char *p2; @@ -140,12 +74,10 @@ TEST(UnityFixture, ConcludeTestIncrementsFailCount) { UNITY_UINT savedFails = Unity.TestFailures; UNITY_UINT savedIgnores = Unity.TestIgnores; - UnityOutputCharSpy_Enable(1); Unity.CurrentTestFailed = 1; UnityConcludeFixtureTest(); /* Resets TestFailed for this test to pass */ Unity.CurrentTestIgnored = 1; UnityConcludeFixtureTest(); /* Resets TestIgnored */ - UnityOutputCharSpy_Enable(0); TEST_ASSERT_EQUAL(savedFails + 1, Unity.TestFailures); TEST_ASSERT_EQUAL(savedIgnores + 1, Unity.TestIgnores); Unity.TestFailures = savedFails; @@ -311,235 +243,3 @@ IGNORE_TEST(UnityCommandOptions, TestShouldBeIgnored) { TEST_FAIL_MESSAGE("This test should not run!"); } - -/*------------------------------------------------------------ */ - -TEST_GROUP(LeakDetection); - -TEST_SETUP(LeakDetection) -{ -#ifdef UNITY_EXCLUDE_STDLIB_MALLOC - UnityOutputCharSpy_Create(200); -#else - UnityOutputCharSpy_Create(1000); -#endif -} - -TEST_TEAR_DOWN(LeakDetection) -{ - UnityOutputCharSpy_Destroy(); -} - -#define EXPECT_ABORT_BEGIN \ - { \ - jmp_buf TestAbortFrame; \ - memcpy(TestAbortFrame, Unity.AbortFrame, sizeof(jmp_buf)); \ - if (TEST_PROTECT()) \ - { - -#define EXPECT_ABORT_END \ - } \ - memcpy(Unity.AbortFrame, TestAbortFrame, sizeof(jmp_buf)); \ - } - -/* This tricky set of defines lets us see if we are using the Spy, returns 1 if true */ -#ifdef __STDC_VERSION__ - -#ifdef UNITY_SUPPORT_VARIADIC_MACROS -#define USING_SPY_AS(a) EXPAND_AND_USE_2ND(ASSIGN_VALUE(a), 0) -#define ASSIGN_VALUE(a) VAL_##a -#define VAL_UnityOutputCharSpy_OutputChar 0, 1 -#define EXPAND_AND_USE_2ND(a, b) SECOND_PARAM(a, b, throwaway) -#define SECOND_PARAM(a, b, ...) b -#if USING_SPY_AS(UNITY_OUTPUT_CHAR) - #define USING_OUTPUT_SPY /* UNITY_OUTPUT_CHAR = UnityOutputCharSpy_OutputChar */ -#endif -#endif /* UNITY_SUPPORT_VARIADIC_MACROS */ - -#else /* __STDC_VERSION__ else */ - -#define UnityOutputCharSpy_OutputChar 42 -#if UNITY_OUTPUT_CHAR == UnityOutputCharSpy_OutputChar /* Works if no -Wundef -Werror */ - #define USING_OUTPUT_SPY -#endif -#undef UnityOutputCharSpy_OutputChar - -#endif /* __STDC_VERSION__ */ - -TEST(LeakDetection, DetectsLeak) -{ -#ifndef USING_OUTPUT_SPY - TEST_IGNORE_MESSAGE("Build with '-D UNITY_OUTPUT_CHAR=UnityOutputCharSpy_OutputChar' to enable tests"); -#else - void* m = malloc(10); - TEST_ASSERT_NOT_NULL(m); - UnityOutputCharSpy_Enable(1); - EXPECT_ABORT_BEGIN - UnityMalloc_EndTest(); - EXPECT_ABORT_END - UnityOutputCharSpy_Enable(0); - Unity.CurrentTestFailed = 0; - CHECK(strstr(UnityOutputCharSpy_Get(), "This test leaks!")); - free(m); -#endif -} - -TEST(LeakDetection, BufferOverrunFoundDuringFree) -{ -#ifndef USING_OUTPUT_SPY - TEST_IGNORE(); -#else - void* m = malloc(10); - char* s = (char*)m; - TEST_ASSERT_NOT_NULL(m); - s[10] = (char)0xFF; - UnityOutputCharSpy_Enable(1); - EXPECT_ABORT_BEGIN - free(m); - EXPECT_ABORT_END - UnityOutputCharSpy_Enable(0); - Unity.CurrentTestFailed = 0; - CHECK(strstr(UnityOutputCharSpy_Get(), "Buffer overrun detected during free()")); -#endif -} - -TEST(LeakDetection, BufferOverrunFoundDuringRealloc) -{ -#ifndef USING_OUTPUT_SPY - TEST_IGNORE(); -#else - void* m = malloc(10); - char* s = (char*)m; - TEST_ASSERT_NOT_NULL(m); - s[10] = (char)0xFF; - UnityOutputCharSpy_Enable(1); - EXPECT_ABORT_BEGIN - m = realloc(m, 100); - EXPECT_ABORT_END - UnityOutputCharSpy_Enable(0); - Unity.CurrentTestFailed = 0; - CHECK(strstr(UnityOutputCharSpy_Get(), "Buffer overrun detected during realloc()")); -#endif -} - -TEST(LeakDetection, BufferGuardWriteFoundDuringFree) -{ -#ifndef USING_OUTPUT_SPY - TEST_IGNORE(); -#else - void* m = malloc(10); - char* s = (char*)m; - TEST_ASSERT_NOT_NULL(m); - s[-1] = (char)0x00; /* Will not detect 0 */ - s[-2] = (char)0x01; - UnityOutputCharSpy_Enable(1); - EXPECT_ABORT_BEGIN - free(m); - EXPECT_ABORT_END - UnityOutputCharSpy_Enable(0); - Unity.CurrentTestFailed = 0; - CHECK(strstr(UnityOutputCharSpy_Get(), "Buffer overrun detected during free()")); -#endif -} - -TEST(LeakDetection, BufferGuardWriteFoundDuringRealloc) -{ -#ifndef USING_OUTPUT_SPY - TEST_IGNORE(); -#else - void* m = malloc(10); - char* s = (char*)m; - TEST_ASSERT_NOT_NULL(m); - s[-1] = (char)0x0A; - UnityOutputCharSpy_Enable(1); - EXPECT_ABORT_BEGIN - m = realloc(m, 100); - EXPECT_ABORT_END - UnityOutputCharSpy_Enable(0); - Unity.CurrentTestFailed = 0; - CHECK(strstr(UnityOutputCharSpy_Get(), "Buffer overrun detected during realloc()")); -#endif -} - -TEST(LeakDetection, PointerSettingMax) -{ -#ifndef USING_OUTPUT_SPY - TEST_IGNORE(); -#else - int i; - for (i = 0; i < UNITY_MAX_POINTERS; i++) UT_PTR_SET(pointer1, &int1); - UnityOutputCharSpy_Enable(1); - EXPECT_ABORT_BEGIN - UT_PTR_SET(pointer1, &int1); - EXPECT_ABORT_END - UnityOutputCharSpy_Enable(0); - Unity.CurrentTestFailed = 0; - CHECK(strstr(UnityOutputCharSpy_Get(), "Too many pointers set")); -#endif -} - -/*------------------------------------------------------------ */ - -TEST_GROUP(InternalMalloc); -#define TEST_ASSERT_MEMORY_ALL_FREE_LIFO_ORDER(first_mem_ptr, ptr) \ - ptr = malloc(10); free(ptr); \ - TEST_ASSERT_EQUAL_PTR_MESSAGE(first_mem_ptr, ptr, "Memory was stranded, free in LIFO order"); - - -TEST_SETUP(InternalMalloc) { } -TEST_TEAR_DOWN(InternalMalloc) { } - -TEST(InternalMalloc, MallocPastBufferFails) -{ -#ifdef UNITY_EXCLUDE_STDLIB_MALLOC - void* m = malloc(UNITY_INTERNAL_HEAP_SIZE_BYTES/2 + 1); - void* n = malloc(UNITY_INTERNAL_HEAP_SIZE_BYTES/2); - free(m); - TEST_ASSERT_NOT_NULL(m); - TEST_ASSERT_NULL(n); - TEST_ASSERT_MEMORY_ALL_FREE_LIFO_ORDER(m, n); -#endif -} - -TEST(InternalMalloc, CallocPastBufferFails) -{ -#ifdef UNITY_EXCLUDE_STDLIB_MALLOC - void* m = calloc(1, UNITY_INTERNAL_HEAP_SIZE_BYTES/2 + 1); - void* n = calloc(1, UNITY_INTERNAL_HEAP_SIZE_BYTES/2); - free(m); - TEST_ASSERT_NOT_NULL(m); - TEST_ASSERT_NULL(n); - TEST_ASSERT_MEMORY_ALL_FREE_LIFO_ORDER(m, n); -#endif -} - -TEST(InternalMalloc, MallocThenReallocGrowsMemoryInPlace) -{ -#ifdef UNITY_EXCLUDE_STDLIB_MALLOC - void* m = malloc(UNITY_INTERNAL_HEAP_SIZE_BYTES/2 + 1); - void* n = realloc(m, UNITY_INTERNAL_HEAP_SIZE_BYTES/2 + 9); - free(n); - TEST_ASSERT_NOT_NULL(m); - TEST_ASSERT_EQUAL(m, n); - TEST_ASSERT_MEMORY_ALL_FREE_LIFO_ORDER(m, n); -#endif -} - -TEST(InternalMalloc, ReallocFailDoesNotFreeMem) -{ -#ifdef UNITY_EXCLUDE_STDLIB_MALLOC - void* m = malloc(UNITY_INTERNAL_HEAP_SIZE_BYTES/2); - void* n1 = malloc(10); - void* out_of_mem = realloc(n1, UNITY_INTERNAL_HEAP_SIZE_BYTES/2 + 1); - void* n2 = malloc(10); - - free(n2); - if (out_of_mem == NULL) free(n1); - free(m); - - TEST_ASSERT_NOT_NULL(m); /* Got a real memory location */ - TEST_ASSERT_NULL(out_of_mem); /* The realloc should have failed */ - TEST_ASSERT_NOT_EQUAL(n2, n1); /* If n1 != n2 then realloc did not free n1 */ - TEST_ASSERT_MEMORY_ALL_FREE_LIFO_ORDER(m, n2); -#endif -} diff --git a/extras/fixture/test/unity_fixture_TestRunner.c b/extras/fixture/test/unity_fixture_TestRunner.c index e8713e1b..7b78c49c 100644 --- a/extras/fixture/test/unity_fixture_TestRunner.c +++ b/extras/fixture/test/unity_fixture_TestRunner.c @@ -10,13 +10,6 @@ TEST_GROUP_RUNNER(UnityFixture) { RUN_TEST_CASE(UnityFixture, PointerSetting); - RUN_TEST_CASE(UnityFixture, ForceMallocFail); - RUN_TEST_CASE(UnityFixture, ReallocSmallerIsUnchanged); - RUN_TEST_CASE(UnityFixture, ReallocSameIsUnchanged); - RUN_TEST_CASE(UnityFixture, ReallocLargerNeeded); - RUN_TEST_CASE(UnityFixture, ReallocNullPointerIsLikeMalloc); - RUN_TEST_CASE(UnityFixture, ReallocSizeZeroFreesMemAndReturnsNullPointer); - RUN_TEST_CASE(UnityFixture, CallocFillsWithZero); RUN_TEST_CASE(UnityFixture, PointerSet); RUN_TEST_CASE(UnityFixture, FreeNULLSafety); RUN_TEST_CASE(UnityFixture, ConcludeTestIncrementsFailCount); @@ -37,21 +30,3 @@ TEST_GROUP_RUNNER(UnityCommandOptions) RUN_TEST_CASE(UnityCommandOptions, GroupFilterReallyFilters); RUN_TEST_CASE(UnityCommandOptions, TestShouldBeIgnored); } - -TEST_GROUP_RUNNER(LeakDetection) -{ - RUN_TEST_CASE(LeakDetection, DetectsLeak); - RUN_TEST_CASE(LeakDetection, BufferOverrunFoundDuringFree); - RUN_TEST_CASE(LeakDetection, BufferOverrunFoundDuringRealloc); - RUN_TEST_CASE(LeakDetection, BufferGuardWriteFoundDuringFree); - RUN_TEST_CASE(LeakDetection, BufferGuardWriteFoundDuringRealloc); - RUN_TEST_CASE(LeakDetection, PointerSettingMax); -} - -TEST_GROUP_RUNNER(InternalMalloc) -{ - RUN_TEST_CASE(InternalMalloc, MallocPastBufferFails); - RUN_TEST_CASE(InternalMalloc, CallocPastBufferFails); - RUN_TEST_CASE(InternalMalloc, MallocThenReallocGrowsMemoryInPlace); - RUN_TEST_CASE(InternalMalloc, ReallocFailDoesNotFreeMem); -} diff --git a/extras/memory/rakefile.rb b/extras/memory/rakefile.rb new file mode 100644 index 00000000..328f3c68 --- /dev/null +++ b/extras/memory/rakefile.rb @@ -0,0 +1,45 @@ +# ========================================== +# Unity Project - A Test Framework for C +# Copyright (c) 2007 Mike Karlesky, Mark VanderVoord, Greg Williams +# [Released under MIT License. Please refer to license.txt for details] +# ========================================== + +require 'rake' +require 'rake/clean' +require 'rake/testtask' +require_relative 'rakefile_helper' + +TEMP_DIRS = [ + File.join(__dir__, 'build') +].freeze + +TEMP_DIRS.each do |dir| + directory(dir) + CLOBBER.include(dir) +end + +task prepare_for_tests: TEMP_DIRS + +# Load default configuration, for now +DEFAULT_CONFIG_FILE = 'gcc_auto_stdint.yml'.freeze +configure_toolchain(DEFAULT_CONFIG_FILE) + +task unit: [:prepare_for_tests] do + run_tests(false) + run_tests(true) +end + +desc 'Build and test Unity Framework' +task all: %i[clean unit] +task default: %i[clobber all] +task ci: %i[no_color default] +task cruise: %i[no_color default] + +desc 'Load configuration' +task :config, :config_file do |_t, args| + configure_toolchain(args[:config_file]) +end + +task :no_color do + $colour_output = false +end diff --git a/extras/memory/rakefile_helper.rb b/extras/memory/rakefile_helper.rb new file mode 100644 index 00000000..f91106fd --- /dev/null +++ b/extras/memory/rakefile_helper.rb @@ -0,0 +1,187 @@ +# ========================================== +# Unity Project - A Test Framework for C +# Copyright (c) 2007 Mike Karlesky, Mark VanderVoord, Greg Williams +# [Released under MIT License. Please refer to license.txt for details] +# ========================================== + +require 'yaml' +require 'fileutils' +require 'rbconfig' +require_relative '../../auto/unity_test_summary' +require_relative '../../auto/generate_test_runner' +require_relative '../../auto/colour_reporter' + +$is_windows = (RbConfig::CONFIG['host_os'] =~ /mswin|mingw|cygwin/) + +C_EXTENSION = '.c'.freeze + +def load_configuration(config_file) + return if $configured + + $cfg_file = "#{__dir__}/../../test/targets/#{config_file}" unless config_file =~ /[\\|\/]/ + $cfg = YAML.load(File.read($cfg_file)) + $colour_output = false unless $cfg['colour'] + $configured = true if config_file != DEFAULT_CONFIG_FILE +end + +def configure_clean + CLEAN.include($cfg['compiler']['build_path'] + '*.*') unless $cfg['compiler']['build_path'].nil? +end + +def configure_toolchain(config_file = DEFAULT_CONFIG_FILE) + config_file += '.yml' unless config_file =~ /\.yml$/ + config_file = config_file unless config_file =~ /[\\|\/]/ + load_configuration(config_file) + configure_clean +end + +def tackit(strings) + result = if strings.is_a?(Array) + "\"#{strings.join}\"" + else + strings + end + result +end + +def squash(prefix, items) + result = '' + items.each { |item| result += " #{prefix}#{tackit(item)}" } + result +end + +def build_compiler_fields + command = tackit($cfg['compiler']['path']) + defines = if $cfg['compiler']['defines']['items'].nil? + '' + else + decl = if $is_windows + 'UNITY_OUTPUT_CHAR_HEADER_DECLARATION=UnityOutputCharSpy_OutputChar(int)' + else + 'UNITY_OUTPUT_CHAR_HEADER_DECLARATION=UnityOutputCharSpy_OutputChar\(int\)' + end + squash($cfg['compiler']['defines']['prefix'], $cfg['compiler']['defines']['items'] + ['UNITY_OUTPUT_CHAR=UnityOutputCharSpy_OutputChar'] + [decl]) + end + options = squash('', $cfg['compiler']['options']) + includes = squash($cfg['compiler']['includes']['prefix'], $cfg['compiler']['includes']['items']) + includes = includes.gsub(/\\ /, ' ').gsub(/\\\"/, '"').gsub(/\\$/, '') # Remove trailing slashes (for IAR) + + { command: command, defines: defines, options: options, includes: includes } +end + +def compile(file, _defines = []) + compiler = build_compiler_fields + unity_include = $cfg['compiler']['includes']['prefix'] + '../../src' + cmd_str = "#{compiler[:command]}#{compiler[:defines]}#{compiler[:options]}#{compiler[:includes]} #{unity_include} #{file} " \ + "#{$cfg['compiler']['object_files']['prefix']}#{$cfg['compiler']['object_files']['destination']}" \ + "#{File.basename(file, C_EXTENSION)}#{$cfg['compiler']['object_files']['extension']}" + + execute(cmd_str) +end + +def build_linker_fields + command = tackit($cfg['linker']['path']) + options = if $cfg['linker']['options'].nil? + '' + else + squash('', $cfg['linker']['options']) + end + includes = if $cfg['linker']['includes'].nil? || $cfg['linker']['includes']['items'].nil? + '' + else + squash($cfg['linker']['includes']['prefix'], $cfg['linker']['includes']['items']) + end.gsub(/\\ /, ' ').gsub(/\\\"/, '"').gsub(/\\$/, '') # Remove trailing slashes (for IAR) + + { command: command, options: options, includes: includes } +end + +def link_it(exe_name, obj_list) + linker = build_linker_fields + cmd_str = "#{linker[:command]}#{linker[:options]}#{linker[:includes]} " + + (obj_list.map { |obj| "#{$cfg['linker']['object_files']['path']}#{obj} " }).join + + $cfg['linker']['bin_files']['prefix'] + ' ' + + $cfg['linker']['bin_files']['destination'] + + exe_name + $cfg['linker']['bin_files']['extension'] + execute(cmd_str) +end + +def build_simulator_fields + return nil if $cfg['simulator'].nil? + + command = if $cfg['simulator']['path'].nil? + '' + else + (tackit($cfg['simulator']['path']) + ' ') + end + pre_support = if $cfg['simulator']['pre_support'].nil? + '' + else + squash('', $cfg['simulator']['pre_support']) + end + post_support = if $cfg['simulator']['post_support'].nil? + '' + else + squash('', $cfg['simulator']['post_support']) + end + { command: command, pre_support: pre_support, post_support: post_support } +end + +def execute(command_string, verbose = true) + report command_string + output = `#{command_string}`.chomp + report(output) if verbose && !output.nil? && !output.empty? + + raise "Command failed. (Returned #{$?.exitstatus})" if $?.exitstatus != 0 + + output +end + +def report_summary + summary = UnityTestSummary.new + summary.root = __dir__ + results_glob = "#{$cfg['compiler']['build_path']}*.test*" + results_glob.tr!('\\', '/') + results = Dir[results_glob] + summary.targets = results + summary.run +end + +def run_tests(exclude_stdlib=false) + report 'Running Unity system tests...' + + # Tack on TEST define for compiling unit tests + load_configuration($cfg_file) + test_defines = ['TEST'] + $cfg['compiler']['defines']['items'] = [] if $cfg['compiler']['defines']['items'].nil? + $cfg['compiler']['defines']['items'] << 'UNITY_EXCLUDE_STDLIB_MALLOC' if exclude_stdlib + + # Get a list of all source files needed + src_files = Dir["#{__dir__}/src/*.c"] + src_files += Dir["#{__dir__}/test/*.c"] + src_files << '../../src/unity.c' + + # Build object files + src_files.each { |f| compile(f, test_defines) } + obj_list = src_files.map { |f| File.basename(f.ext($cfg['compiler']['object_files']['extension'])) } + + # Link the test executable + test_base = 'framework_test' + link_it(test_base, obj_list) + + # Execute unit test and generate results file + simulator = build_simulator_fields + executable = $cfg['linker']['bin_files']['destination'] + test_base + $cfg['linker']['bin_files']['extension'] + cmd_str = if simulator.nil? + executable + ' -v -r' + else + "#{simulator[:command]} #{simulator[:pre_support]} #{executable} #{simulator[:post_support]}" + end + output = execute(cmd_str) + test_results = $cfg['compiler']['build_path'] + test_base + test_results += if output.match(/OK$/m).nil? + '.testfail' + else + '.testpass' + end + File.open(test_results, 'w') { |f| f.print output } +end diff --git a/extras/memory/readme.md b/extras/memory/readme.md new file mode 100644 index 00000000..37769825 --- /dev/null +++ b/extras/memory/readme.md @@ -0,0 +1,49 @@ +# Unity Memory + +This Framework is an optional add-on to Unity. By including unity.h and then +unity_memory.h, you have the added ability to track malloc and free calls. This +addon requires that the stdlib functions be overridden by its own defines. These +defines will still malloc / realloc / free etc, but will also track the calls +in order to ensure that you don't have any memory leaks in your programs. + +Note that this is only useful in situations where a unit is in charge of both +the allocation and deallocation of memory. When it is not symmetric, unit testing +can report a number of false failures. A more advanced runtime tool is required to +track complete system memory handling. + +# Module API + +## `UnityMalloc_StartTest` and `UnityMalloc_EndTest` + +These must be called at the beginning and end of each test. For simplicity, they can +be added to `setUp` and `tearDown` in order to do their job. When using the test +runner generator scripts, these will be automatically added to the runner whenever +unity_memory.h is included. + +## `UnityMalloc_MakeMallocFailAfterCount` + +This can be called from the tests themselves. Passing this function a number will +force the reference counter to start keeping track of malloc calls. During that test, +if the number of malloc calls exceeds the number given, malloc will immediately +start returning `NULL`. This allows you to test error conditions. Think of it as a +simplified mock. + +# Configuration + +## `UNITY_MALLOC` and `UNITY_FREE` + +By default, this module tries to use the real stdlib `malloc` and `free` internally. +If you would prefer it to use something else, like FreeRTOS's `pvPortMalloc` and +`pvPortFree`, then you can use these defines to make it so. + +## `UNITY_EXCLUDE_STDLIB_MALLOC` + +If you would like this library to ignore stdlib or other heap engines completely, and +manage the memory on its own, then define this. All memory will be handled internally +(and at likely lower overhead). Note that this is not a very featureful memory manager, +but is sufficient for most testing purposes. + +## `UNITY_INTERNAL_HEAP_SIZE_BYTES` + +When using the built-in memory manager (see `UNITY_EXCLUDE_STDLIB_MALLOC`) this define +allows you to set the heap size this library will use to manage the memory. diff --git a/extras/memory/src/unity_memory.c b/extras/memory/src/unity_memory.c new file mode 100644 index 00000000..e112e8d5 --- /dev/null +++ b/extras/memory/src/unity_memory.c @@ -0,0 +1,201 @@ +/* ========================================== + * Unity Project - A Test Framework for C + * Copyright (c) 2007 Mike Karlesky, Mark VanderVoord, Greg Williams + * [Released under MIT License. Please refer to license.txt for details] + * ========================================== */ + +#include "unity.h" +#include "unity_memory.h" +#include + +#define MALLOC_DONT_FAIL -1 +static int malloc_count; +static int malloc_fail_countdown = MALLOC_DONT_FAIL; + +void UnityMalloc_StartTest(void) +{ + malloc_count = 0; + malloc_fail_countdown = MALLOC_DONT_FAIL; +} + +void UnityMalloc_EndTest(void) +{ + malloc_fail_countdown = MALLOC_DONT_FAIL; + if (malloc_count != 0) + { + UNITY_TEST_FAIL(Unity.CurrentTestLineNumber, "This test leaks!"); + } +} + +void UnityMalloc_MakeMallocFailAfterCount(int countdown) +{ + malloc_fail_countdown = countdown; +} + +/* These definitions are always included from unity_fixture_malloc_overrides.h */ +/* We undef to use them or avoid conflict with per the C standard */ +#undef malloc +#undef free +#undef calloc +#undef realloc + +#ifdef UNITY_EXCLUDE_STDLIB_MALLOC +static unsigned char unity_heap[UNITY_INTERNAL_HEAP_SIZE_BYTES]; +static size_t heap_index; +#else +#include +#endif + +typedef struct GuardBytes +{ + size_t size; + size_t guard_space; +} Guard; + +#define UNITY_MALLOC_ALIGNMENT (UNITY_POINTER_WIDTH / 8) +static const char end[] = "END"; + +static size_t unity_size_round_up(size_t size) +{ + size_t rounded_size; + + rounded_size = ((size + UNITY_MALLOC_ALIGNMENT - 1) / UNITY_MALLOC_ALIGNMENT) * UNITY_MALLOC_ALIGNMENT; + + return rounded_size; +} + +void* unity_malloc(size_t size) +{ + char* mem; + Guard* guard; + size_t total_size; + + total_size = sizeof(Guard) + unity_size_round_up(size + sizeof(end)); + + if (malloc_fail_countdown != MALLOC_DONT_FAIL) + { + if (malloc_fail_countdown == 0) + return NULL; + malloc_fail_countdown--; + } + + if (size == 0) return NULL; +#ifdef UNITY_EXCLUDE_STDLIB_MALLOC + if (heap_index + total_size > UNITY_INTERNAL_HEAP_SIZE_BYTES) + { + guard = NULL; + } + else + { + guard = (Guard*)&unity_heap[heap_index]; + heap_index += total_size; + } +#else + guard = (Guard*)UNITY_MALLOC(total_size); +#endif + if (guard == NULL) return NULL; + malloc_count++; + guard->size = size; + guard->guard_space = 0; + mem = (char*)&(guard[1]); + memcpy(&mem[size], end, sizeof(end)); + + return (void*)mem; +} + +static int isOverrun(void* mem) +{ + Guard* guard = (Guard*)mem; + char* memAsChar = (char*)mem; + guard--; + + return guard->guard_space != 0 || strcmp(&memAsChar[guard->size], end) != 0; +} + +static void release_memory(void* mem) +{ + Guard* guard = (Guard*)mem; + guard--; + + malloc_count--; +#ifdef UNITY_EXCLUDE_STDLIB_MALLOC + { + size_t block_size; + + block_size = unity_size_round_up(guard->size + sizeof(end)); + + if (mem == unity_heap + heap_index - block_size) + { + heap_index -= (sizeof(Guard) + block_size); + } + } +#else + UNITY_FREE(guard); +#endif +} + +void unity_free(void* mem) +{ + int overrun; + + if (mem == NULL) + { + return; + } + + overrun = isOverrun(mem); + release_memory(mem); + if (overrun) + { + UNITY_TEST_FAIL(Unity.CurrentTestLineNumber, "Buffer overrun detected during free()"); + } +} + +void* unity_calloc(size_t num, size_t size) +{ + void* mem = unity_malloc(num * size); + if (mem == NULL) return NULL; + memset(mem, 0, num * size); + return mem; +} + +void* unity_realloc(void* oldMem, size_t size) +{ + Guard* guard = (Guard*)oldMem; + void* newMem; + + if (oldMem == NULL) return unity_malloc(size); + + guard--; + if (isOverrun(oldMem)) + { + release_memory(oldMem); + UNITY_TEST_FAIL(Unity.CurrentTestLineNumber, "Buffer overrun detected during realloc()"); + } + + if (size == 0) + { + release_memory(oldMem); + return NULL; + } + + if (guard->size >= size) return oldMem; + +#ifdef UNITY_EXCLUDE_STDLIB_MALLOC /* Optimization if memory is expandable */ + { + size_t old_total_size = unity_size_round_up(guard->size + sizeof(end)); + + if ((oldMem == unity_heap + heap_index - old_total_size) && + ((heap_index - old_total_size + unity_size_round_up(size + sizeof(end))) <= UNITY_INTERNAL_HEAP_SIZE_BYTES)) + { + release_memory(oldMem); /* Not thread-safe, like unity_heap generally */ + return unity_malloc(size); /* No memcpy since data is in place */ + } + } +#endif + newMem = unity_malloc(size); + if (newMem == NULL) return NULL; /* Do not release old memory */ + memcpy(newMem, oldMem, guard->size); + release_memory(oldMem); + return newMem; +} diff --git a/extras/fixture/src/unity_fixture_malloc_overrides.h b/extras/memory/src/unity_memory.h similarity index 58% rename from extras/fixture/src/unity_fixture_malloc_overrides.h rename to extras/memory/src/unity_memory.h index 7daba50a..ccdb826f 100644 --- a/extras/fixture/src/unity_fixture_malloc_overrides.h +++ b/extras/memory/src/unity_memory.h @@ -1,12 +1,16 @@ -/* Copyright (c) 2010 James Grenning and Contributed to Unity Project - * ========================================== +/* ========================================== * Unity Project - A Test Framework for C * Copyright (c) 2007 Mike Karlesky, Mark VanderVoord, Greg Williams * [Released under MIT License. Please refer to license.txt for details] * ========================================== */ -#ifndef UNITY_FIXTURE_MALLOC_OVERRIDES_H_ -#define UNITY_FIXTURE_MALLOC_OVERRIDES_H_ +#ifndef UNITY_MEMORY_OVERRIDES_H_ +#define UNITY_MEMORY_OVERRIDES_H_ + +#ifdef __cplusplus +extern "C" +{ +#endif #include @@ -21,17 +25,17 @@ #endif #endif -/* These functions are used by the Unity Fixture to allocate and release memory +/* These functions are used by Unity to allocate and release memory * on the heap and can be overridden with platform-specific implementations. - * For example, when using FreeRTOS UNITY_FIXTURE_MALLOC becomes pvPortMalloc() - * and UNITY_FIXTURE_FREE becomes vPortFree(). */ -#if !defined(UNITY_FIXTURE_MALLOC) || !defined(UNITY_FIXTURE_FREE) + * For example, when using FreeRTOS UNITY_MALLOC becomes pvPortMalloc() + * and UNITY_FREE becomes vPortFree(). */ +#if !defined(UNITY_MALLOC) || !defined(UNITY_FREE) #include - #define UNITY_FIXTURE_MALLOC(size) malloc(size) - #define UNITY_FIXTURE_FREE(ptr) free(ptr) + #define UNITY_MALLOC(size) malloc(size) + #define UNITY_FREE(ptr) free(ptr) #else - extern void* UNITY_FIXTURE_MALLOC(size_t size); - extern void UNITY_FIXTURE_FREE(void* ptr); + extern void* UNITY_MALLOC(size_t size); + extern void UNITY_FREE(void* ptr); #endif #define malloc unity_malloc @@ -44,4 +48,13 @@ void* unity_calloc(size_t num, size_t size); void* unity_realloc(void * oldMem, size_t size); void unity_free(void * mem); -#endif /* UNITY_FIXTURE_MALLOC_OVERRIDES_H_ */ +/* You must compile with malloc replacement, as defined in unity_fixture_malloc_overrides.h */ +void UnityMalloc_StartTest(void); +void UnityMalloc_EndTest(void); +void UnityMalloc_MakeMallocFailAfterCount(int countdown); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/extras/memory/test/Makefile b/extras/memory/test/Makefile new file mode 100644 index 00000000..f3f86ce6 --- /dev/null +++ b/extras/memory/test/Makefile @@ -0,0 +1,78 @@ +CC = gcc +ifeq ($(shell uname -s), Darwin) +CC = clang +endif +#DEBUG = -O0 -g +CFLAGS += -std=c99 -pedantic -Wall -Wextra -Werror +CFLAGS += $(DEBUG) +DEFINES = -D UNITY_OUTPUT_CHAR=UnityOutputCharSpy_OutputChar +ifeq ($(OS),Windows_NT) + DEFINES += -D UNITY_OUTPUT_CHAR_HEADER_DECLARATION=UnityOutputCharSpy_OutputChar(int) +else + DEFINES += -D UNITY_OUTPUT_CHAR_HEADER_DECLARATION=UnityOutputCharSpy_OutputChar\(int\) +endif +SRC = ../src/unity_memory.c \ + ../../../src/unity.c \ + unity_memory_Test.c \ + unity_memory_TestRunner.c \ + unity_output_Spy.c \ + +INC_DIR = -I../src -I../../../src/ +BUILD_DIR = ../build +TARGET = ../build/memory_tests.exe + +all: default noStdlibMalloc 32bits + +default: $(BUILD_DIR) + $(CC) $(CFLAGS) $(DEFINES) $(SRC) $(INC_DIR) -o $(TARGET) -D UNITY_SUPPORT_64 + @ echo "default build" + ./$(TARGET) + +32bits: $(BUILD_DIR) + $(CC) $(CFLAGS) $(DEFINES) $(SRC) $(INC_DIR) -o $(TARGET) -m32 + @ echo "32bits build" + ./$(TARGET) + +noStdlibMalloc: $(BUILD_DIR) + $(CC) $(CFLAGS) $(DEFINES) $(SRC) $(INC_DIR) -o $(TARGET) -D UNITY_EXCLUDE_STDLIB_MALLOC + @ echo "build with noStdlibMalloc" + ./$(TARGET) + +C89: CFLAGS += -D UNITY_EXCLUDE_STDINT_H # C89 did not have type 'long long', +C89: $(BUILD_DIR) + $(CC) $(CFLAGS) $(DEFINES) $(SRC) $(INC_DIR) -o $(TARGET) -std=c89 && ./$(TARGET) + $(CC) $(CFLAGS) $(DEFINES) $(SRC) $(INC_DIR) -o $(TARGET) -D UNITY_EXCLUDE_STDLIB_MALLOC -std=c89 + ./$(TARGET) + +$(BUILD_DIR): + mkdir -p $(BUILD_DIR) + +clean: + rm -f $(TARGET) $(BUILD_DIR)/*.gc* + +cov: $(BUILD_DIR) + cd $(BUILD_DIR) && \ + $(CC) $(DEFINES) $(foreach i, $(SRC), ../test/$(i)) $(INC_DIR) -o $(TARGET) -fprofile-arcs -ftest-coverage + rm -f $(BUILD_DIR)/*.gcda + ./$(TARGET) > /dev/null ; ./$(TARGET) -v > /dev/null + cd $(BUILD_DIR) && \ + gcov unity_memory.c | head -3 + grep '###' $(BUILD_DIR)/unity_memory.c.gcov -C2 || true # Show uncovered lines + +# These extended flags DO get included before any target build runs +CFLAGS += -Wbad-function-cast +CFLAGS += -Wcast-qual +CFLAGS += -Wconversion +CFLAGS += -Wformat=2 +CFLAGS += -Wmissing-prototypes +CFLAGS += -Wold-style-definition +CFLAGS += -Wpointer-arith +CFLAGS += -Wshadow +CFLAGS += -Wstrict-overflow=5 +CFLAGS += -Wstrict-prototypes +CFLAGS += -Wswitch-default +CFLAGS += -Wundef +CFLAGS += -Wno-error=undef # Warning only, this should not stop the build +CFLAGS += -Wunreachable-code +CFLAGS += -Wunused +CFLAGS += -fstrict-aliasing diff --git a/extras/memory/test/unity_memory_Test.c b/extras/memory/test/unity_memory_Test.c new file mode 100644 index 00000000..65eebce8 --- /dev/null +++ b/extras/memory/test/unity_memory_Test.c @@ -0,0 +1,300 @@ +/* ========================================== + * Unity Project - A Test Framework for C + * Copyright (c) 2007 Mike Karlesky, Mark VanderVoord, Greg Williams + * [Released under MIT License. Please refer to license.txt for details] + * ========================================== */ + +#include "unity.h" +#include "unity_memory.h" +#include "unity_output_Spy.h" +#include +#include + +void setUp(void) +{ +#ifdef UNITY_EXCLUDE_STDLIB_MALLOC + UnityOutputCharSpy_Create(200); +#else + UnityOutputCharSpy_Create(1000); +#endif + UnityMalloc_StartTest(); +} + +void tearDown(void) +{ + UnityMalloc_EndTest(); + UnityOutputCharSpy_Destroy(); +} + +void test_ForceMallocFail(void) +{ + void* m; + void* mfails; + UnityMalloc_MakeMallocFailAfterCount(1); + m = malloc(10); + TEST_ASSERT_NOT_NULL(m); + mfails = malloc(10); + TEST_ASSERT_EQUAL_PTR(0, mfails); + free(m); +} + +void test_ReallocSmallerIsUnchanged(void) +{ + void* m1 = malloc(10); + void* m2 = realloc(m1, 5); + TEST_ASSERT_NOT_NULL(m1); + TEST_ASSERT_EQUAL_PTR(m1, m2); + free(m2); +} + +void test_ReallocSameIsUnchanged(void) +{ + void* m1 = malloc(10); + void* m2 = realloc(m1, 10); + TEST_ASSERT_NOT_NULL(m1); + TEST_ASSERT_EQUAL_PTR(m1, m2); + free(m2); +} + +void test_ReallocLargerNeeded(void) +{ + void* m2; + void* m1 = malloc(10); + TEST_ASSERT_NOT_NULL(m1); + strcpy((char*)m1, "123456789"); + m2 = realloc(m1, 15); + TEST_ASSERT_EQUAL_STRING("123456789", m2); + free(m2); +} + +void test_ReallocNullPointerIsLikeMalloc(void) +{ + void* m = realloc(0, 15); + TEST_ASSERT_NOT_NULL(m); + free(m); +} + +void test_ReallocSizeZeroFreesMemAndReturnsNullPointer(void) +{ + void* m1 = malloc(10); + void* m2 = realloc(m1, 0); + TEST_ASSERT_EQUAL_PTR(0, m2); +} + +void test_CallocFillsWithZero(void) +{ + void* m = calloc(3, sizeof(char)); + char* s = (char*)m; + TEST_ASSERT_NOT_NULL(m); + TEST_ASSERT_EQUAL_HEX8(0, s[0]); + TEST_ASSERT_EQUAL_HEX8(0, s[1]); + TEST_ASSERT_EQUAL_HEX8(0, s[2]); + free(m); +} + +void test_FreeNULLSafety(void) +{ + free(NULL); +} + +/*------------------------------------------------------------ */ + +#define EXPECT_ABORT_BEGIN \ + { \ + jmp_buf TestAbortFrame; \ + memcpy(TestAbortFrame, Unity.AbortFrame, sizeof(jmp_buf)); \ + if (TEST_PROTECT()) \ + { + +#define EXPECT_ABORT_END \ + } \ + memcpy(Unity.AbortFrame, TestAbortFrame, sizeof(jmp_buf)); \ + } + +/* This tricky set of defines lets us see if we are using the Spy, returns 1 if true */ +#ifdef __STDC_VERSION__ + +#ifdef UNITY_SUPPORT_VARIADIC_MACROS +#define USING_SPY_AS(a) EXPAND_AND_USE_2ND(ASSIGN_VALUE(a), 0) +#define ASSIGN_VALUE(a) VAL_##a +#define VAL_UnityOutputCharSpy_OutputChar 0, 1 +#define EXPAND_AND_USE_2ND(a, b) SECOND_PARAM(a, b, throwaway) +#define SECOND_PARAM(a, b, ...) b +#if USING_SPY_AS(UNITY_OUTPUT_CHAR) + #define USING_OUTPUT_SPY /* UNITY_OUTPUT_CHAR = UnityOutputCharSpy_OutputChar */ +#endif +#endif /* UNITY_SUPPORT_VARIADIC_MACROS */ + +#else /* __STDC_VERSION__ else */ + +#define UnityOutputCharSpy_OutputChar 42 +#if UNITY_OUTPUT_CHAR == UnityOutputCharSpy_OutputChar /* Works if no -Wundef -Werror */ + #define USING_OUTPUT_SPY +#endif +#undef UnityOutputCharSpy_OutputChar + +#endif /* __STDC_VERSION__ */ + +void test_DetectsLeak(void) +{ +#ifdef USING_OUTPUT_SPY + void* m = malloc(10); + TEST_ASSERT_NOT_NULL(m); + UnityOutputCharSpy_Enable(1); + EXPECT_ABORT_BEGIN + UnityMalloc_EndTest(); + EXPECT_ABORT_END + UnityOutputCharSpy_Enable(0); + Unity.CurrentTestFailed = 0; + TEST_ASSERT_NOT_NULL(strstr(UnityOutputCharSpy_Get(), "This test leaks!")); + free(m); +#else + TEST_IGNORE_MESSAGE("Enable USING_OUTPUT_SPY To Run This Test"); +#endif +} + +void test_BufferOverrunFoundDuringFree(void) +{ +#ifdef USING_OUTPUT_SPY + void* m = malloc(10); + char* s = (char*)m; + TEST_ASSERT_NOT_NULL(m); + s[10] = (char)0xFF; + UnityOutputCharSpy_Enable(1); + EXPECT_ABORT_BEGIN + free(m); + EXPECT_ABORT_END + UnityOutputCharSpy_Enable(0); + Unity.CurrentTestFailed = 0; + TEST_ASSERT_NOT_NULL(strstr(UnityOutputCharSpy_Get(), "Buffer overrun detected during free()")); +#else + TEST_IGNORE_MESSAGE("Enable USING_OUTPUT_SPY To Run This Test"); +#endif +} + +void test_BufferOverrunFoundDuringRealloc(void) +{ +#ifdef USING_OUTPUT_SPY + void* m = malloc(10); + char* s = (char*)m; + TEST_ASSERT_NOT_NULL(m); + s[10] = (char)0xFF; + UnityOutputCharSpy_Enable(1); + EXPECT_ABORT_BEGIN + m = realloc(m, 100); + EXPECT_ABORT_END + UnityOutputCharSpy_Enable(0); + Unity.CurrentTestFailed = 0; + TEST_ASSERT_NOT_NULL(strstr(UnityOutputCharSpy_Get(), "Buffer overrun detected during realloc()")); +#else + TEST_IGNORE_MESSAGE("Enable USING_OUTPUT_SPY To Run This Test"); +#endif +} + +void test_BufferGuardWriteFoundDuringFree(void) +{ +#ifdef USING_OUTPUT_SPY + void* m = malloc(10); + char* s = (char*)m; + TEST_ASSERT_NOT_NULL(m); + s[-1] = (char)0x00; /* Will not detect 0 */ + s[-2] = (char)0x01; + UnityOutputCharSpy_Enable(1); + EXPECT_ABORT_BEGIN + free(m); + EXPECT_ABORT_END + UnityOutputCharSpy_Enable(0); + Unity.CurrentTestFailed = 0; + TEST_ASSERT_NOT_NULL(strstr(UnityOutputCharSpy_Get(), "Buffer overrun detected during free()")); +#else + TEST_IGNORE_MESSAGE("Enable USING_OUTPUT_SPY To Run This Test"); +#endif +} + +void test_BufferGuardWriteFoundDuringRealloc(void) +{ +#ifdef USING_OUTPUT_SPY + void* m = malloc(10); + char* s = (char*)m; + TEST_ASSERT_NOT_NULL(m); + s[-1] = (char)0x0A; + UnityOutputCharSpy_Enable(1); + EXPECT_ABORT_BEGIN + m = realloc(m, 100); + EXPECT_ABORT_END + UnityOutputCharSpy_Enable(0); + Unity.CurrentTestFailed = 0; + TEST_ASSERT_NOT_NULL(strstr(UnityOutputCharSpy_Get(), "Buffer overrun detected during realloc()")); +#else + TEST_IGNORE_MESSAGE("Enable USING_OUTPUT_SPY To Run This Test"); +#endif +} + +/*------------------------------------------------------------ */ + +#define TEST_ASSERT_MEMORY_ALL_FREE_LIFO_ORDER(first_mem_ptr, ptr) \ + ptr = malloc(10); free(ptr); \ + TEST_ASSERT_EQUAL_PTR_MESSAGE(first_mem_ptr, ptr, "Memory was stranded, free in LIFO order"); + +void test_MallocPastBufferFails(void) +{ +#ifdef UNITY_EXCLUDE_STDLIB_MALLOC + void* m = malloc(UNITY_INTERNAL_HEAP_SIZE_BYTES/2 + 1); + void* n = malloc(UNITY_INTERNAL_HEAP_SIZE_BYTES/2); + free(m); + TEST_ASSERT_NOT_NULL(m); + TEST_ASSERT_NULL(n); + TEST_ASSERT_MEMORY_ALL_FREE_LIFO_ORDER(m, n); +#else + TEST_IGNORE_MESSAGE("Enable UNITY_EXCLUDE_STDLIB_MALLOC to Run This Test"); +#endif +} + +void test_CallocPastBufferFails(void) +{ +#ifdef UNITY_EXCLUDE_STDLIB_MALLOC + void* m = calloc(1, UNITY_INTERNAL_HEAP_SIZE_BYTES/2 + 1); + void* n = calloc(1, UNITY_INTERNAL_HEAP_SIZE_BYTES/2); + free(m); + TEST_ASSERT_NOT_NULL(m); + TEST_ASSERT_NULL(n); + TEST_ASSERT_MEMORY_ALL_FREE_LIFO_ORDER(m, n); +#else + TEST_IGNORE_MESSAGE("Enable UNITY_EXCLUDE_STDLIB_MALLOC to Run This Test"); +#endif +} + +void test_MallocThenReallocGrowsMemoryInPlace(void) +{ +#ifdef UNITY_EXCLUDE_STDLIB_MALLOC + void* m = malloc(UNITY_INTERNAL_HEAP_SIZE_BYTES/2 + 1); + void* n = realloc(m, UNITY_INTERNAL_HEAP_SIZE_BYTES/2 + 9); + free(n); + TEST_ASSERT_NOT_NULL(m); + TEST_ASSERT_EQUAL(m, n); + TEST_ASSERT_MEMORY_ALL_FREE_LIFO_ORDER(m, n); +#else + TEST_IGNORE_MESSAGE("Enable UNITY_EXCLUDE_STDLIB_MALLOC to Run This Test"); +#endif +} + +void test_ReallocFailDoesNotFreeMem(void) +{ +#ifdef UNITY_EXCLUDE_STDLIB_MALLOC + void* m = malloc(UNITY_INTERNAL_HEAP_SIZE_BYTES/2); + void* n1 = malloc(10); + void* out_of_mem = realloc(n1, UNITY_INTERNAL_HEAP_SIZE_BYTES/2 + 1); + void* n2 = malloc(10); + + free(n2); + if (out_of_mem == NULL) free(n1); + free(m); + + TEST_ASSERT_NOT_NULL(m); /* Got a real memory location */ + TEST_ASSERT_NULL(out_of_mem); /* The realloc should have failed */ + TEST_ASSERT_NOT_EQUAL(n2, n1); /* If n1 != n2 then realloc did not free n1 */ + TEST_ASSERT_MEMORY_ALL_FREE_LIFO_ORDER(m, n2); +#else + TEST_IGNORE_MESSAGE("Enable UNITY_EXCLUDE_STDLIB_MALLOC to Run This Test"); +#endif +} diff --git a/extras/memory/test/unity_memory_TestRunner.c b/extras/memory/test/unity_memory_TestRunner.c new file mode 100644 index 00000000..4c91a599 --- /dev/null +++ b/extras/memory/test/unity_memory_TestRunner.c @@ -0,0 +1,49 @@ +/* ========================================== + * Unity Project - A Test Framework for C + * Copyright (c) 2007 Mike Karlesky, Mark VanderVoord, Greg Williams + * [Released under MIT License. Please refer to license.txt for details] + * ========================================== */ + +#include "unity.h" +#include "unity_memory.h" + +extern void test_ForceMallocFail(void); +extern void test_ReallocSmallerIsUnchanged(void); +extern void test_ReallocSameIsUnchanged(void); +extern void test_ReallocLargerNeeded(void); +extern void test_ReallocNullPointerIsLikeMalloc(void); +extern void test_ReallocSizeZeroFreesMemAndReturnsNullPointer(void); +extern void test_CallocFillsWithZero(void); +extern void test_FreeNULLSafety(void); +extern void test_DetectsLeak(void); +extern void test_BufferOverrunFoundDuringFree(void); +extern void test_BufferOverrunFoundDuringRealloc(void); +extern void test_BufferGuardWriteFoundDuringFree(void); +extern void test_BufferGuardWriteFoundDuringRealloc(void); +extern void test_MallocPastBufferFails(void); +extern void test_CallocPastBufferFails(void); +extern void test_MallocThenReallocGrowsMemoryInPlace(void); +extern void test_ReallocFailDoesNotFreeMem(void); + +int main(void) +{ + UnityBegin("unity_memory_Test.c"); + RUN_TEST(test_ForceMallocFail); + RUN_TEST(test_ReallocSmallerIsUnchanged); + RUN_TEST(test_ReallocSameIsUnchanged); + RUN_TEST(test_ReallocLargerNeeded); + RUN_TEST(test_ReallocNullPointerIsLikeMalloc); + RUN_TEST(test_ReallocSizeZeroFreesMemAndReturnsNullPointer); + RUN_TEST(test_CallocFillsWithZero); + RUN_TEST(test_FreeNULLSafety); + RUN_TEST(test_DetectsLeak); + RUN_TEST(test_BufferOverrunFoundDuringFree); + RUN_TEST(test_BufferOverrunFoundDuringRealloc); + RUN_TEST(test_BufferGuardWriteFoundDuringFree); + RUN_TEST(test_BufferGuardWriteFoundDuringRealloc); + RUN_TEST(test_MallocPastBufferFails); + RUN_TEST(test_CallocPastBufferFails); + RUN_TEST(test_MallocThenReallocGrowsMemoryInPlace); + RUN_TEST(test_ReallocFailDoesNotFreeMem); + return UnityEnd(); +} diff --git a/extras/fixture/test/unity_output_Spy.c b/extras/memory/test/unity_output_Spy.c similarity index 88% rename from extras/fixture/test/unity_output_Spy.c rename to extras/memory/test/unity_output_Spy.c index be87bd58..772fe0bd 100644 --- a/extras/fixture/test/unity_output_Spy.c +++ b/extras/memory/test/unity_output_Spy.c @@ -1,16 +1,15 @@ -/* Copyright (c) 2010 James Grenning and Contributed to Unity Project - * ========================================== +/* ========================================== * Unity Project - A Test Framework for C * Copyright (c) 2007 Mike Karlesky, Mark VanderVoord, Greg Williams * [Released under MIT License. Please refer to license.txt for details] * ========================================== */ - +#include "unity.h" #include "unity_output_Spy.h" -#include "unity_fixture.h" #include #include +#include static int size; static int count; diff --git a/extras/fixture/test/unity_output_Spy.h b/extras/memory/test/unity_output_Spy.h similarity index 72% rename from extras/fixture/test/unity_output_Spy.h rename to extras/memory/test/unity_output_Spy.h index b30a7f13..e2e401c4 100644 --- a/extras/fixture/test/unity_output_Spy.h +++ b/extras/memory/test/unity_output_Spy.h @@ -1,12 +1,11 @@ -/* Copyright (c) 2010 James Grenning and Contributed to Unity Project - * ========================================== +/* ========================================== * Unity Project - A Test Framework for C * Copyright (c) 2007 Mike Karlesky, Mark VanderVoord, Greg Williams * [Released under MIT License. Please refer to license.txt for details] * ========================================== */ -#ifndef D_unity_output_Spy_H -#define D_unity_output_Spy_H +#ifndef UNITY_OUTPUT_SPY_H +#define UNITY_OUTPUT_SPY_H void UnityOutputCharSpy_Create(int s); void UnityOutputCharSpy_Destroy(void); From efd02920caa479541e6ac80618160d8d2bc01414 Mon Sep 17 00:00:00 2001 From: mvandervoord Date: Wed, 30 Oct 2019 08:06:52 -0400 Subject: [PATCH 190/454] Fix path problem in Travis CI --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index ebd4672a..718fe16d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -24,7 +24,7 @@ script: - cd ../extras/fixture/test && rake ci - make -s default noStdlibMalloc - make -s C89 - - cd ../extras/memory/test && rake ci + - cd ../../../extras/memory/test && rake ci - make -s default noStdlibMalloc - make -s C89 - cd ../../../examples/example_1 && make -s ci From e40b0bf2b56ca8a1cc1703ecc4c9288bbd671ba7 Mon Sep 17 00:00:00 2001 From: mvandervoord Date: Wed, 30 Oct 2019 08:42:46 -0400 Subject: [PATCH 191/454] Let's just go with it. Why fight the warnings when they could catch other issues? --- extras/memory/test/unity_memory_Test.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/extras/memory/test/unity_memory_Test.c b/extras/memory/test/unity_memory_Test.c index 65eebce8..6f832e27 100644 --- a/extras/memory/test/unity_memory_Test.c +++ b/extras/memory/test/unity_memory_Test.c @@ -10,6 +10,31 @@ #include #include +/* This test module includes the following tests: */ + +void test_ForceMallocFail(void); +void test_ReallocSmallerIsUnchanged(void); +void test_ReallocSameIsUnchanged(void); +void test_ReallocLargerNeeded(void); +void test_ReallocNullPointerIsLikeMalloc(void); +void test_ReallocSizeZeroFreesMemAndReturnsNullPointer(void); +void test_CallocFillsWithZero(void); +void test_FreeNULLSafety(void); +void test_DetectsLeak(void); +void test_BufferOverrunFoundDuringFree(void); +void test_BufferOverrunFoundDuringRealloc(void); +void test_BufferGuardWriteFoundDuringFree(void); +void test_BufferGuardWriteFoundDuringRealloc(void); +void test_MallocPastBufferFails(void); +void test_CallocPastBufferFails(void); +void test_MallocThenReallocGrowsMemoryInPlace(void); +void test_ReallocFailDoesNotFreeMem(void); + +/* It makes use of the following features */ +void setUp(void); +void tearDown(void); + +/* Let's Go! */ void setUp(void) { #ifdef UNITY_EXCLUDE_STDLIB_MALLOC From 94dc637d03fb62eeffd1b4c4d6fda5b596d200af Mon Sep 17 00:00:00 2001 From: mvandervoord Date: Wed, 30 Oct 2019 08:48:08 -0400 Subject: [PATCH 192/454] While we're fixing warnings / errors, disable this (otherwise helpful) error because we are purposefully making this example file fail for this. --- examples/example_1/makefile | 1 + examples/example_2/makefile | 1 + 2 files changed, 2 insertions(+) diff --git a/examples/example_1/makefile b/examples/example_1/makefile index 545476a6..46799cf0 100644 --- a/examples/example_1/makefile +++ b/examples/example_1/makefile @@ -41,6 +41,7 @@ CFLAGS += -Wno-unknown-pragmas CFLAGS += -Wstrict-prototypes CFLAGS += -Wundef CFLAGS += -Wold-style-definition +CFLAGS += -Wno-misleading-indentation TARGET_BASE1=test1 TARGET_BASE2=test2 diff --git a/examples/example_2/makefile b/examples/example_2/makefile index 99d8d968..49cfc24c 100644 --- a/examples/example_2/makefile +++ b/examples/example_2/makefile @@ -41,6 +41,7 @@ CFLAGS += -Wno-unknown-pragmas CFLAGS += -Wstrict-prototypes CFLAGS += -Wundef CFLAGS += -Wold-style-definition +CFLAGS += -Wno-misleading-indentation TARGET_BASE1=all_tests TARGET1 = $(TARGET_BASE1)$(TARGET_EXTENSION) From 5dd59311148c19af7ce27a4f61d293781a589175 Mon Sep 17 00:00:00 2001 From: mvandervoord Date: Wed, 30 Oct 2019 08:53:08 -0400 Subject: [PATCH 193/454] Try to keep compiler from complaining about this cast that we KNOW is okay. --- extras/memory/src/unity_memory.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/extras/memory/src/unity_memory.c b/extras/memory/src/unity_memory.c index e112e8d5..e4dc6654 100644 --- a/extras/memory/src/unity_memory.c +++ b/extras/memory/src/unity_memory.c @@ -87,7 +87,8 @@ void* unity_malloc(size_t size) } else { - guard = (Guard*)&unity_heap[heap_index]; + /* We know we can get away with this cast because we aligned memory already */ + guard = (Guard*)(void*)(&unity_heap[heap_index]); heap_index += total_size; } #else From 179b492e1842b434786735c7e0438b634387d5cf Mon Sep 17 00:00:00 2001 From: mvandervoord Date: Wed, 30 Oct 2019 09:00:53 -0400 Subject: [PATCH 194/454] Sigh. had to NOT disable these warnings by default because the gcc on our test rig doesn't understand it --- examples/example_1/makefile | 2 +- examples/example_2/makefile | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/example_1/makefile b/examples/example_1/makefile index 46799cf0..28409c10 100644 --- a/examples/example_1/makefile +++ b/examples/example_1/makefile @@ -41,7 +41,7 @@ CFLAGS += -Wno-unknown-pragmas CFLAGS += -Wstrict-prototypes CFLAGS += -Wundef CFLAGS += -Wold-style-definition -CFLAGS += -Wno-misleading-indentation +#CFLAGS += -Wno-misleading-indentation TARGET_BASE1=test1 TARGET_BASE2=test2 diff --git a/examples/example_2/makefile b/examples/example_2/makefile index 49cfc24c..c6854e06 100644 --- a/examples/example_2/makefile +++ b/examples/example_2/makefile @@ -41,7 +41,7 @@ CFLAGS += -Wno-unknown-pragmas CFLAGS += -Wstrict-prototypes CFLAGS += -Wundef CFLAGS += -Wold-style-definition -CFLAGS += -Wno-misleading-indentation +#CFLAGS += -Wno-misleading-indentation TARGET_BASE1=all_tests TARGET1 = $(TARGET_BASE1)$(TARGET_EXTENSION) From ded22fef63b381b2755b1ff9ac5624e05c8a4cc0 Mon Sep 17 00:00:00 2001 From: mvandervoord Date: Wed, 30 Oct 2019 09:50:22 -0400 Subject: [PATCH 195/454] Make memory handling optional in fixtures --- extras/fixture/rakefile_helper.rb | 1 + extras/fixture/src/unity_fixture.h | 4 ++++ extras/fixture/test/Makefile | 2 +- 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/extras/fixture/rakefile_helper.rb b/extras/fixture/rakefile_helper.rb index c543d10b..91c83441 100644 --- a/extras/fixture/rakefile_helper.rb +++ b/extras/fixture/rakefile_helper.rb @@ -148,6 +148,7 @@ def run_tests load_configuration($cfg_file) test_defines = ['TEST'] $cfg['compiler']['defines']['items'] = [] if $cfg['compiler']['defines']['items'].nil? + $cfg['compiler']['defines']['items'] << "UNITY_FIXTURE_NO_EXTRAS" # Get a list of all source files needed src_files = Dir["#{__dir__}/src/*.c"] diff --git a/extras/fixture/src/unity_fixture.h b/extras/fixture/src/unity_fixture.h index c042a264..4cc403ef 100644 --- a/extras/fixture/src/unity_fixture.h +++ b/extras/fixture/src/unity_fixture.h @@ -12,6 +12,10 @@ #include "unity_internals.h" #include "unity_fixture_internals.h" +#ifndef UNITY_FIXTURE_NO_EXTRAS +#include "unity_memory.h" +#endif + int UnityMain(int argc, const char* argv[], void (*runAllTests)(void)); diff --git a/extras/fixture/test/Makefile b/extras/fixture/test/Makefile index 897c5dce..bbe32410 100644 --- a/extras/fixture/test/Makefile +++ b/extras/fixture/test/Makefile @@ -3,7 +3,7 @@ ifeq ($(shell uname -s), Darwin) CC = clang endif #DEBUG = -O0 -g -CFLAGS += -std=c99 -pedantic -Wall -Wextra -Werror +CFLAGS += -std=c99 -pedantic -Wall -Wextra -Werror -DUNITY_FIXTURE_NO_EXTRAS CFLAGS += $(DEBUG) SRC = ../src/unity_fixture.c \ ../../../src/unity.c \ From c3d7662a1e692aa0934fa61a2a67229f3b73a5a2 Mon Sep 17 00:00:00 2001 From: mvandervoord Date: Wed, 30 Oct 2019 10:05:49 -0400 Subject: [PATCH 196/454] fixture example doesn't use memory extra --- examples/example_2/makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/example_2/makefile b/examples/example_2/makefile index c6854e06..e2832173 100644 --- a/examples/example_2/makefile +++ b/examples/example_2/makefile @@ -56,7 +56,7 @@ SRC_FILES1=\ test/test_runners/TestProductionCode2_Runner.c \ test/test_runners/all_tests.c INC_DIRS=-Isrc -I$(UNITY_ROOT)/src -I$(UNITY_ROOT)/extras/fixture/src -SYMBOLS= +SYMBOLS=-DUNITY_FIXTURE_NO_EXTRAS all: clean default From e2682ae43ae503d37009d3e5d94e41c1a9c69641 Mon Sep 17 00:00:00 2001 From: mvandervoord Date: Tue, 12 Nov 2019 18:26:15 -0500 Subject: [PATCH 197/454] update (commented out) example of using WEAK (which is not supported any longer) --- examples/unity_config.h | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/examples/unity_config.h b/examples/unity_config.h index bc66e7f6..9127bcca 100644 --- a/examples/unity_config.h +++ b/examples/unity_config.h @@ -224,25 +224,6 @@ /* #define UNITY_OUTPUT_START() RS232_config(115200,1,8,0) */ /* #define UNITY_OUTPUT_COMPLETE() RS232_close() */ -/* For some targets, Unity can make the otherwise required `setUp()` and - * `tearDown()` functions optional. This is a nice convenience for test writers - * since `setUp` and `tearDown` don't often actually _do_ anything. If you're - * using gcc or clang, this option is automatically defined for you. Other - * compilers can also support this behavior, if they support a C feature called - * weak functions. A weak function is a function that is compiled into your - * executable _unless_ a non-weak version of the same function is defined - * elsewhere. If a non-weak version is found, the weak version is ignored as if - * it never existed. If your compiler supports this feature, you can let Unity - * know by defining `UNITY_SUPPORT_WEAK` as the function attributes that would - * need to be applied to identify a function as weak. If your compiler lacks - * support for weak functions, you will always need to define `setUp` and - * `tearDown` functions (though they can be and often will be just empty). The - * most common options for this feature are: - */ -/* #define UNITY_SUPPORT_WEAK weak */ -/* #define UNITY_SUPPORT_WEAK __attribute__((weak)) */ -/* #define UNITY_NO_WEAK */ - /* Some compilers require a custom attribute to be assigned to pointers, like * `near` or `far`. In these cases, you can give Unity a safe default for these * by defining this option with the attribute you would like. From 3fb17f33e252d734e8b9f8706a21f1531917fab7 Mon Sep 17 00:00:00 2001 From: Michael Brockus Date: Tue, 3 Dec 2019 22:45:37 -0800 Subject: [PATCH 198/454] Update root meson.build --- meson.build | 35 ++++++++++++++++------------------- 1 file changed, 16 insertions(+), 19 deletions(-) diff --git a/meson.build b/meson.build index 062fcad5..1a99470e 100644 --- a/meson.build +++ b/meson.build @@ -14,12 +14,7 @@ project('unity', 'c', license : 'MIT', meson_version : '>=0.52.0', - default_options: [ - 'buildtype=minsize', - 'optimization=3', - 'warning_level=3', - 'werror=true', - ] + default_options: ['warning_level=3', 'werror=true', 'c_std=c11'] ) lang = 'c' cc = meson.get_compiler(lang) @@ -33,8 +28,10 @@ cc = meson.get_compiler(lang) if cc.get_id() == 'clang' add_project_arguments(cc.get_supported_arguments( [ - '-Wweak-vtables', '-Wexit-time-destructors', - '-Wglobal-constructors', '-Wmissing-noreturn' + '-Wcast-qual', '-Wshadow', '-Wcast-align', '-Wweak-vtables', + '-Wold-style-cast', '-Wpointer-arith', '-Wconversion', + '-Wexit-time-destructors', '-Wglobal-constructors', + '-Wmissing-noreturn', '-Wmissing-prototypes', '-Wno-missing-braces' ] ), language: lang) endif @@ -42,14 +39,14 @@ endif if cc.get_argument_syntax() == 'gcc' add_project_arguments(cc.get_supported_arguments( [ - '-Wformat', '-Waddress', '-Winit-self', '-Wno-multichar', - '-Wpointer-arith' , '-Wwrite-strings' , - '-Wno-parentheses' , '-Wno-type-limits' , - '-Wformat-security' , '-Wunreachable-code' , - '-Waggregate-return' , '-Wformat-nonliteral' , - '-Wmissing-prototypes' , '-Wold-style-definition' , - '-Wmissing-declarations', '-Wmissing-include-dirs' , - '-Wno-unused-parameter' , '-Wdeclaration-after-statement' + '-Wformat', '-Waddress', '-Winit-self', '-Wno-multichar', + '-Wpointer-arith' , '-Wwrite-strings' , + '-Wno-parentheses' , '-Wno-type-limits' , + '-Wformat-security' , '-Wunreachable-code' , + '-Waggregate-return' , '-Wformat-nonliteral' , + '-Wmissing-prototypes' , '-Wold-style-definition' , + '-Wmissing-declarations', '-Wmissing-include-dirs' , + '-Wno-unused-parameter' , '-Wdeclaration-after-statement' ] ), language: lang) endif @@ -57,9 +54,9 @@ endif if cc.get_id() == 'msvc' add_project_arguments(cc.get_supported_arguments( [ - '/w44265', '/w44061', '/w44062', - '/wd4018', '/wd4146', '/wd4244', - '/wd4305', + '/w44265', '/w44061', '/w44062', + '/wd4018', '/wd4146', '/wd4244', + '/wd4305', '/D _CRT_SECURE_NO_WARNINGS' ] ), language: lang) endif From de1cb75e4c1821c1340130c03e36031debd2a372 Mon Sep 17 00:00:00 2001 From: Michael Brockus Date: Tue, 3 Dec 2019 22:49:22 -0800 Subject: [PATCH 199/454] Keep Meson support back to version 0.50.0 --- meson.build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/meson.build b/meson.build index 1a99470e..3b4ddcc0 100644 --- a/meson.build +++ b/meson.build @@ -13,7 +13,7 @@ project('unity', 'c', license : 'MIT', - meson_version : '>=0.52.0', + meson_version : '>=0.50.0', default_options: ['warning_level=3', 'werror=true', 'c_std=c11'] ) lang = 'c' From c5c36ab29fa69622a65dbcc1c8bef5b014e5fb04 Mon Sep 17 00:00:00 2001 From: mvandervoord Date: Thu, 5 Dec 2019 13:19:43 -0500 Subject: [PATCH 200/454] Do NOT include the default test runner if a custom runner has been defined. Cleanup some style issues. --- README.md | 6 +++--- auto/generate_test_runner.rb | 2 +- extras/fixture/rakefile_helper.rb | 2 +- extras/memory/rakefile_helper.rb | 2 +- src/unity.c | 3 +++ src/unity_internals.h | 3 +++ test/rakefile | 7 ++++++- 7 files changed, 18 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 983f33de..e32fafff 100644 --- a/README.md +++ b/README.md @@ -182,10 +182,10 @@ Memory Assertions Compare two blocks of memory. This is a good generic assertion for types that can't be coerced into acting like standard types... but since it's a memory compare, you have to be careful that your data types are packed. -_MESSAGE --------- +\_MESSAGE +--------- -you can append _MESSAGE to any of the macros to make them take an additional argument. This argument +you can append \_MESSAGE to any of the macros to make them take an additional argument. This argument is a string that will be printed at the end of the failure strings. This is useful for specifying more information about the problem. diff --git a/auto/generate_test_runner.rb b/auto/generate_test_runner.rb index 5053210d..4944e0be 100644 --- a/auto/generate_test_runner.rb +++ b/auto/generate_test_runner.rb @@ -410,7 +410,7 @@ def create_main(output, filename, tests, used_mocks) output.puts(' return suiteTearDown(UnityEnd());') end else - output.puts(' return UnityEnd();') if not @options[:omit_begin_end] + output.puts(' return UnityEnd();') unless @options[:omit_begin_end] end output.puts('}') end diff --git a/extras/fixture/rakefile_helper.rb b/extras/fixture/rakefile_helper.rb index 91c83441..4de82462 100644 --- a/extras/fixture/rakefile_helper.rb +++ b/extras/fixture/rakefile_helper.rb @@ -148,7 +148,7 @@ def run_tests load_configuration($cfg_file) test_defines = ['TEST'] $cfg['compiler']['defines']['items'] = [] if $cfg['compiler']['defines']['items'].nil? - $cfg['compiler']['defines']['items'] << "UNITY_FIXTURE_NO_EXTRAS" + $cfg['compiler']['defines']['items'] << 'UNITY_FIXTURE_NO_EXTRAS' # Get a list of all source files needed src_files = Dir["#{__dir__}/src/*.c"] diff --git a/extras/memory/rakefile_helper.rb b/extras/memory/rakefile_helper.rb index f91106fd..26ce71d8 100644 --- a/extras/memory/rakefile_helper.rb +++ b/extras/memory/rakefile_helper.rb @@ -146,7 +146,7 @@ def report_summary summary.run end -def run_tests(exclude_stdlib=false) +def run_tests(exclude_stdlib = false) report 'Running Unity system tests...' # Tack on TEST define for compiling unit tests diff --git a/src/unity.c b/src/unity.c index c7be02cc..7b200334 100644 --- a/src/unity.c +++ b/src/unity.c @@ -1800,6 +1800,8 @@ void UnityMessage(const char* msg, const UNITY_LINE_TYPE line) } /*-----------------------------------------------*/ +/* If we have not defined our own test runner, then include our default test runner to make life easier */ +#ifndef RUN_TEST void UnityDefaultTestRun(UnityTestFunction Func, const char* FuncName, const int FuncLineNum) { Unity.CurrentTestName = FuncName; @@ -1819,6 +1821,7 @@ void UnityDefaultTestRun(UnityTestFunction Func, const char* FuncName, const int UNITY_EXEC_TIME_STOP(); UnityConcludeTest(); } +#endif /*-----------------------------------------------*/ void UnitySetTestFile(const char* filename) diff --git a/src/unity_internals.h b/src/unity_internals.h index a9a7ea23..9f610a26 100644 --- a/src/unity_internals.h +++ b/src/unity_internals.h @@ -479,7 +479,10 @@ void UnityBegin(const char* filename); int UnityEnd(void); void UnitySetTestFile(const char* filename); void UnityConcludeTest(void); + +#ifndef RUN_TEST void UnityDefaultTestRun(UnityTestFunction Func, const char* FuncName, const int FuncLineNum); +#endif /*------------------------------------------------------- * Details Support diff --git a/test/rakefile b/test/rakefile index 770feadc..f6cd95ce 100644 --- a/test/rakefile +++ b/test/rakefile @@ -51,7 +51,12 @@ task :summary do report_summary end -desc "Build and test Unity" +namespace :test do + desc "Build and test Unity" + task :all => [:clean, :prepare_for_tests, :scripts, :unit, :style, :summary] +end + +# Shorthand for many common tasks task :all => [:clean, :prepare_for_tests, :scripts, :unit, :style, :summary] task :default => [:clobber, :all] task :ci => [:no_color, :default] From e3132cdddd779cb5a813887b2d0d7facb7f3f90a Mon Sep 17 00:00:00 2001 From: mvandervoord Date: Thu, 5 Dec 2019 13:51:55 -0500 Subject: [PATCH 201/454] Change the way we ignore the default runner. --- src/unity.c | 2 +- src/unity_internals.h | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/unity.c b/src/unity.c index 7b200334..55af324c 100644 --- a/src/unity.c +++ b/src/unity.c @@ -1801,7 +1801,7 @@ void UnityMessage(const char* msg, const UNITY_LINE_TYPE line) /*-----------------------------------------------*/ /* If we have not defined our own test runner, then include our default test runner to make life easier */ -#ifndef RUN_TEST +#ifdef UNITY_SKIP_DEFAULT_RUNNER void UnityDefaultTestRun(UnityTestFunction Func, const char* FuncName, const int FuncLineNum) { Unity.CurrentTestName = FuncName; diff --git a/src/unity_internals.h b/src/unity_internals.h index 9f610a26..fae40184 100644 --- a/src/unity_internals.h +++ b/src/unity_internals.h @@ -481,6 +481,7 @@ void UnitySetTestFile(const char* filename); void UnityConcludeTest(void); #ifndef RUN_TEST +#define UNITY_SKIP_DEFAULT_RUNNER void UnityDefaultTestRun(UnityTestFunction Func, const char* FuncName, const int FuncLineNum); #endif From 86caf7ec97f6445f87f241f9870827531107fdde Mon Sep 17 00:00:00 2001 From: Lino Mastrodomenico Date: Sun, 8 Dec 2019 22:32:18 +0000 Subject: [PATCH 202/454] Fix access outside array bounds. --- examples/example_2/src/ProductionCode.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/example_2/src/ProductionCode.c b/examples/example_2/src/ProductionCode.c index 500b44b5..3bafe205 100644 --- a/examples/example_2/src/ProductionCode.c +++ b/examples/example_2/src/ProductionCode.c @@ -11,7 +11,7 @@ int NumbersToFind[9] = { 0, 34, 55, 66, 32, 11, 1, 77, 888 }; //some obnoxious a int FindFunction_WhichIsBroken(int NumberToFind) { int i = 0; - while (i <= 8) //Notice I should have been in braces + while (i < 8) //Notice I should have been in braces i++; if (NumbersToFind[i] == NumberToFind) //Yikes! I'm getting run after the loop finishes instead of during it! return i; From e59185cd8de1e9b4095a9b0cf33c3de4b99da018 Mon Sep 17 00:00:00 2001 From: Lino Mastrodomenico Date: Sun, 8 Dec 2019 22:34:47 +0000 Subject: [PATCH 203/454] Fix another access outside array bounds. --- examples/example_3/src/ProductionCode.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/example_3/src/ProductionCode.c b/examples/example_3/src/ProductionCode.c index 500b44b5..3bafe205 100644 --- a/examples/example_3/src/ProductionCode.c +++ b/examples/example_3/src/ProductionCode.c @@ -11,7 +11,7 @@ int NumbersToFind[9] = { 0, 34, 55, 66, 32, 11, 1, 77, 888 }; //some obnoxious a int FindFunction_WhichIsBroken(int NumberToFind) { int i = 0; - while (i <= 8) //Notice I should have been in braces + while (i < 8) //Notice I should have been in braces i++; if (NumbersToFind[i] == NumberToFind) //Yikes! I'm getting run after the loop finishes instead of during it! return i; From 5c5773720fe19a76334e30965f30199a8e72e77f Mon Sep 17 00:00:00 2001 From: Lino Mastrodomenico Date: Mon, 9 Dec 2019 00:25:28 +0000 Subject: [PATCH 204/454] Implement an -h/--help flag for Unity Fixtures and add documentation --- extras/fixture/readme.md | 12 ++++++++++ extras/fixture/src/unity_fixture.c | 37 +++++++++++++++++++++++++++++- 2 files changed, 48 insertions(+), 1 deletion(-) diff --git a/extras/fixture/readme.md b/extras/fixture/readme.md index 38a31321..2e0c2f06 100644 --- a/extras/fixture/readme.md +++ b/extras/fixture/readme.md @@ -15,3 +15,15 @@ Fixtures, by default, uses the Memory addon as well. This is to make it simple f follow along with James' book. Using them together is completely optional. You may choose to use Fixtures without Memory handling by defining `UNITY_FIXTURE_NO_EXTRAS`. It will then stop automatically pulling in extras and leave you to do it as desired. + +# Usage information + +By default the test executables produced by Unity Fixtures run all tests once, but the behavior can +be configured with command-line flags. Run the test executable with the `--help` flag for more +information. + +It's possible to add a custom line at the end of the help message, typically to point to +project-specific or company-specific unit test documentation. Define `UNITY_CUSTOM_HELP_MSG` to +provide a custom message, e.g.: + + #define UNITY_CUSTOM_HELP_MSG "If any test fails see https://example.com/troubleshooting" diff --git a/extras/fixture/src/unity_fixture.c b/extras/fixture/src/unity_fixture.c index 3b66a6d1..c3dda796 100644 --- a/extras/fixture/src/unity_fixture.c +++ b/extras/fixture/src/unity_fixture.c @@ -192,7 +192,42 @@ int UnityGetCommandLineOptions(int argc, const char* argv[]) for (i = 1; i < argc; ) { - if (strcmp(argv[i], "-v") == 0) + if (strcmp(argv[i], "-h") == 0 || strcmp(argv[i], "--help") == 0) + { + /* Usage */ + UnityPrint("Runs a series of unit tests."); + UNITY_PRINT_EOL(); + UNITY_PRINT_EOL(); + UnityPrint("When no flag is specified, all tests are run."); + UNITY_PRINT_EOL(); + UNITY_PRINT_EOL(); + UnityPrint("Optional flags:"); + UNITY_PRINT_EOL(); + UnityPrint(" -v Verbose output: show all tests executed even if they pass"); + UNITY_PRINT_EOL(); + UnityPrint(" -s Silent mode: minimal output showing only test failures"); + UNITY_PRINT_EOL(); + UnityPrint(" -g NAME Only run tests in groups that contain the string NAME"); + UNITY_PRINT_EOL(); + UnityPrint(" -n NAME Only run tests whose name contains the string NAME"); + UNITY_PRINT_EOL(); + UnityPrint(" -r NUMBER Repeatedly run all tests NUMBER times"); + UNITY_PRINT_EOL(); + UnityPrint(" -h, --help Display this help message"); + UNITY_PRINT_EOL(); + UNITY_PRINT_EOL(); +#ifdef UNITY_CUSTOM_HELP_MSG + /* User-defined help message, e.g. to point to project-specific documentation */ + UnityPrint(UNITY_CUSTOM_HELP_MSG); + UNITY_PRINT_EOL(); +#else + /* Default help suffix if a custom one is not defined */ + UnityPrint("More information about Unity: https://www.throwtheswitch.org/unity"); + UNITY_PRINT_EOL(); +#endif + return 1; /* Exit without running the tests */ + } + else if (strcmp(argv[i], "-v") == 0) { UnityFixture.Verbose = 1; i++; From f39c856a370859fca81394c2c09b3d860e9026ae Mon Sep 17 00:00:00 2001 From: John Lindgren Date: Tue, 10 Dec 2019 13:24:14 -0500 Subject: [PATCH 205/454] auto: Only create run_test() function if it's needed. Also fix some whitespace consistency issues. Use 2 newlines (not 1 or 3) before /*====Heading====*/ comments. --- auto/generate_test_runner.rb | 8 ++++---- auto/run_test.erb | 5 +++-- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/auto/generate_test_runner.rb b/auto/generate_test_runner.rb index 4944e0be..98142701 100644 --- a/auto/generate_test_runner.rb +++ b/auto/generate_test_runner.rb @@ -92,7 +92,7 @@ def generate(input_file, output_file, tests, used_mocks, testfile_includes) create_suite_setup(output) create_suite_teardown(output) create_reset(output) - create_run_test(output) + create_run_test(output) unless tests.empty? create_args_wrappers(output, tests) create_main(output, input_file, tests, used_mocks) end @@ -325,8 +325,8 @@ def create_reset(output) def create_run_test(output) require 'erb' - template = ERB.new(File.read(File.join(__dir__, 'run_test.erb'))) - output.puts(template.result(binding)) + template = ERB.new(File.read(File.join(__dir__, 'run_test.erb')), nil, '<>') + output.puts("\n" + template.result(binding)) end def create_args_wrappers(output, tests) @@ -346,7 +346,7 @@ def create_args_wrappers(output, tests) end def create_main(output, filename, tests, used_mocks) - output.puts("\n\n/*=======MAIN=====*/") + output.puts("\n/*=======MAIN=====*/") main_name = @options[:main_name].to_sym == :auto ? "main_#{filename.gsub('.c', '')}" : (@options[:main_name]).to_s if @options[:cmdline_args] if main_name != 'main' diff --git a/auto/run_test.erb b/auto/run_test.erb index 3d3b6d1e..cb7f2b50 100644 --- a/auto/run_test.erb +++ b/auto/run_test.erb @@ -16,13 +16,14 @@ static void run_test(UnityTestFunction func, const char* name, int line_num) <% if @options[:plugins].include?(:cexception) %> CEXCEPTION_T e; Try { -<% end %> <%= @options[:setup_name] %>(); func(); -<% if @options[:plugins].include?(:cexception) %> } Catch(e) { TEST_ASSERT_EQUAL_HEX32_MESSAGE(CEXCEPTION_NONE, e, "Unhandled Exception!"); } +<% else %> + <%= @options[:setup_name] %>(); + func(); <% end %> } if (TEST_PROTECT()) From 3f71d10b2ecdc6b8ca57816a592b2bde05076d04 Mon Sep 17 00:00:00 2001 From: mvandervoord Date: Fri, 13 Dec 2019 20:38:42 -0500 Subject: [PATCH 206/454] Refactor all yaml files for self-tests to fit Ceedling format for wider reuse. Fix mistake in unity selftest without output spy running. Namespace self-tests for consistency across ThrowTheSwitch projects (like being able to test:all) Reduce clutter of NAMED self-tests in task list. --- test/rakefile | 46 ++--- test/rakefile_helper.rb | 158 +++++++-------- test/targets/ansi.yml | 85 ++++---- test/targets/clang_file.yml | 142 +++++++------ test/targets/clang_strict.yml | 141 +++++++------ test/targets/gcc_32.yml | 88 ++++---- test/targets/gcc_64.yml | 90 ++++----- test/targets/gcc_auto_limits.yml | 84 ++++---- test/targets/gcc_auto_stdint.yml | 108 +++++----- test/targets/gcc_manual_math.yml | 84 ++++---- test/targets/hitech_picc18.yml | 172 ++++++++-------- test/targets/iar_arm_v4.yml | 182 +++++++++-------- test/targets/iar_arm_v5.yml | 166 ++++++++------- test/targets/iar_arm_v5_3.yml | 166 ++++++++------- test/targets/iar_armcortex_LM3S9B92_v5_4.yml | 178 ++++++++-------- test/targets/iar_cortexm3_v5.yml | 172 ++++++++-------- test/targets/iar_msp430.yml | 201 ++++++++++--------- test/targets/iar_sh2a_v6.yml | 179 +++++++++-------- test/tests/test_generate_test_runner.rb | 12 +- test/tests/testunity.c | 6 + 20 files changed, 1227 insertions(+), 1233 deletions(-) diff --git a/test/rakefile b/test/rakefile index f6cd95ce..98b165e4 100644 --- a/test/rakefile +++ b/test/rakefile @@ -29,31 +29,31 @@ include RakefileHelpers DEFAULT_CONFIG_FILE = 'gcc_auto_stdint.yml' configure_toolchain(DEFAULT_CONFIG_FILE) -desc "Test unity with its own unit tests" -task :unit => [:prepare_for_tests] do - run_tests unit_test_files -end +namespace :test do + desc "Build and test Unity" + task :all => [:clean, :prepare_for_tests, 'test:scripts', 'test:unit', :style, 'test:summary'] -desc "Test unity's helper scripts" -task :scripts => [:prepare_for_tests] do - Dir['tests/test_*.rb'].each do |scriptfile| - require "./"+scriptfile + desc "Test unity with its own unit tests" + task :unit => [:prepare_for_tests] do + run_tests unit_test_files end -end -desc "Run all rspecs" -RSpec::Core::RakeTask.new(:spec) do |t| - t.pattern = 'spec/**/*_spec.rb' -end - -desc "Generate test summary" -task :summary do - report_summary -end + desc "Test unity's helper scripts" + task :scripts => [:prepare_for_tests] do + Dir['tests/test_*.rb'].each do |scriptfile| + require "./"+scriptfile + end + end -namespace :test do - desc "Build and test Unity" - task :all => [:clean, :prepare_for_tests, :scripts, :unit, :style, :summary] + desc "Run all rspecs" + RSpec::Core::RakeTask.new(:spec) do |t| + t.pattern = 'spec/**/*_spec.rb' + end + + desc "Generate test summary" + task :summary do + report_summary + end end # Shorthand for many common tasks @@ -86,7 +86,7 @@ namespace :style do namespace :check do Dir['../**/*.rb'].each do |f| filename = File.basename(f, '.rb') - desc "Check Style of #{filename}" + #desc "Check Style of #{filename}" task filename.to_sym => ['style:clean'] do report execute("rubocop #{f} --color --config .rubocop.yml", true) report "Style Checked for #{f}" @@ -102,7 +102,7 @@ namespace :style do namespace :c do Dir['../{src,extras/**}/*.{c,h}'].each do |f| filename = File.basename(f)[0..-3] - desc "Check Style of #{filename}" + #desc "Check Style of #{filename}" task filename.to_sym do run_astyle f end diff --git a/test/rakefile_helper.rb b/test/rakefile_helper.rb index 56f6dcc0..ff8fc923 100644 --- a/test/rakefile_helper.rb +++ b/test/rakefile_helper.rb @@ -22,7 +22,7 @@ def load_configuration(config_file) end def configure_clean - CLEAN.include($cfg['compiler']['build_path'] + '*.*') unless $cfg['compiler']['build_path'].nil? + CLEAN.include('build/*.*') end def configure_toolchain(config_file = DEFAULT_CONFIG_FILE) @@ -33,13 +33,16 @@ def configure_toolchain(config_file = DEFAULT_CONFIG_FILE) end def unit_test_files - path = $cfg['compiler']['unit_tests_path'] + 'test*' + C_EXTENSION + path = 'tests/test*' + C_EXTENSION path.tr!('\\', '/') FileList.new(path) end def local_include_dirs - include_dirs = $cfg['compiler']['includes']['items'].dup + include_dirs = $cfg[:paths][:includes].dup || [] + include_dirs += $cfg[:paths][:source].dup || [] + include_dirs += $cfg[:paths][:test].dup || [] + include_dirs += $cfg[:paths][:support].dup || [] include_dirs.delete_if { |dir| dir.is_a?(Array) } include_dirs end @@ -86,75 +89,71 @@ def should(behave, &block) end end - def build_compiler_fields(inject_defines) - command = tackit($cfg['compiler']['path']) - defines = if $cfg['compiler']['defines']['items'].nil? - '' - else - squash($cfg['compiler']['defines']['prefix'], $cfg['compiler']['defines']['items'] + ['UNITY_OUTPUT_CHAR=putcharSpy'] + ['UNITY_OUTPUT_CHAR_HEADER_DECLARATION="putcharSpy(int)"'] + inject_defines) - end - options = squash('', $cfg['compiler']['options']) - includes = squash($cfg['compiler']['includes']['prefix'], $cfg['compiler']['includes']['items']) - includes = includes.gsub(/\\ /, ' ').gsub(/\\\"/, '"').gsub(/\\$/, '') # Remove trailing slashes (for IAR) - - { :command => command, :defines => defines, :options => options, :includes => includes } - end + def build_command_string(hash, values, defines = nil) + + # Replace named and numbered slots + args = [] + hash[:arguments].each do |arg| + if arg.include? '$' + if arg.include? ': COLLECTION_PATHS_TEST_TOOLCHAIN_INCLUDE' + pattern = arg.gsub(': COLLECTION_PATHS_TEST_TOOLCHAIN_INCLUDE','') + [ File.join('..','src') ].each do |f| + args << pattern.gsub(/\$/,f) + end + + elsif arg.include? ': COLLECTION_PATHS_TEST_SUPPORT_SOURCE_INCLUDE_VENDOR' + pattern = arg.gsub(': COLLECTION_PATHS_TEST_SUPPORT_SOURCE_INCLUDE_VENDOR','') + [ 'src', File.join('tests'), File.join('testdata'), $cfg[:paths][:support] ].flatten.uniq.compact.each do |f| + args << pattern.gsub(/\$/,f) + end + + elsif arg.include? ': COLLECTION_DEFINES_TEST_AND_VENDOR' + pattern = arg.gsub(': COLLECTION_DEFINES_TEST_AND_VENDOR','') + [ 'TEST', $cfg[:defines][:test], defines ].flatten.uniq.compact.each do |f| + args << pattern.gsub(/\$/,f) + end + + elsif arg =~ /\$\{(\d+)\}/ + i = $1.to_i - 1 + if (values[i].is_a?(Array)) + values[i].each {|v| args << arg.gsub(/\$\{\d+\}/, v)} + else + args << arg.gsub(/\$\{(\d)+\}/, values[i] || '') + end + + else + args << arg - def compile(file, defines = []) - compiler = build_compiler_fields(defines) - cmd_str = "#{compiler[:command]}#{compiler[:defines]}#{compiler[:options]}#{compiler[:includes]} #{file} " \ - "#{$cfg['compiler']['object_files']['prefix']}#{$cfg['compiler']['object_files']['destination']}" - obj_file = "#{File.basename(file, C_EXTENSION)}#{$cfg['compiler']['object_files']['extension']}" - execute(cmd_str + obj_file) + end + else + args << arg + end + end - obj_file + # Build Command + return tackit(hash[:executable]) + squash('', args) end - def build_linker_fields - command = tackit($cfg['linker']['path']) - options = if $cfg['linker']['options'].nil? - '' - else - squash('', $cfg['linker']['options']) - end - includes = if $cfg['linker']['includes'].nil? || $cfg['linker']['includes']['items'].nil? - '' - else - squash($cfg['linker']['includes']['prefix'], $cfg['linker']['includes']['items']) - end.gsub(/\\ /, ' ').gsub(/\\\"/, '"').gsub(/\\$/, '') # Remove trailing slashes (for IAR) - - { :command => command, :options => options, :includes => includes } + def compile(file, defines = []) + out_file = File.basename(file, C_EXTENSION) + $cfg[:extension][:object] + cmd_str = build_command_string( $cfg[:tools][:test_compiler], [ file, out_file ], defines ) + execute(cmd_str) + out_file end def link_it(exe_name, obj_list) - linker = build_linker_fields - cmd_str = "#{linker[:command]}#{linker[:options]}#{linker[:includes]} " + - (obj_list.map { |obj| "#{$cfg['linker']['object_files']['path']}#{obj} " }).join + - $cfg['linker']['bin_files']['prefix'] + ' ' + - $cfg['linker']['bin_files']['destination'] + - exe_name + $cfg['linker']['bin_files']['extension'] + cmd_str = build_command_string( $cfg[:tools][:test_linker], [ obj_list, exe_name ] ) execute(cmd_str) end - def build_simulator_fields - return nil if $cfg['simulator'].nil? - command = if $cfg['simulator']['path'].nil? - '' - else - (tackit($cfg['simulator']['path']) + ' ') - end - pre_support = if $cfg['simulator']['pre_support'].nil? - '' - else - squash('', $cfg['simulator']['pre_support']) - end - post_support = if $cfg['simulator']['post_support'].nil? - '' - else - squash('', $cfg['simulator']['post_support']) - end - - { :command => command, :pre_support => pre_support, :post_support => post_support } + def runtest(bin_name, ok_to_fail = false, extra_args = nil) + extra_args = extra_args.nil? ? "" : " " + extra_args + if $cfg[:tools][:test_fixture] + cmd_str = build_command_string( $cfg[:tools][:test_fixture], [ bin_name, extra_args ] ) + else + cmd_str = bin_name + extra_args + end + execute(cmd_str, ok_to_fail) end def run_astyle(style_what) @@ -180,7 +179,7 @@ def execute(command_string, ok_to_fail = false) def report_summary summary = UnityTestSummary.new summary.root = __dir__ - results_glob = "#{$cfg['compiler']['build_path']}*.test*" + results_glob = "build/*.test*" results_glob.tr!('\\', '/') results = Dir[results_glob] summary.targets = results @@ -190,16 +189,11 @@ def report_summary def run_tests(test_files) report 'Running Unity system tests...' - # Tack on TEST define for compiling unit tests - load_configuration($cfg_file) - test_defines = ['TEST'] - $cfg['compiler']['defines']['items'] ||= [] - $cfg['compiler']['defines']['items'] << 'TEST' - include_dirs = local_include_dirs # Build and execute each unit test test_files.each do |test| + puts "DEBUG: " + test # Drop Out if we're skipping this type of test if $cfg[:skip_tests] @@ -210,12 +204,7 @@ def run_tests(test_files) end obj_list = [] - - unless $cfg['compiler']['aux_sources'].nil? - $cfg['compiler']['aux_sources'].each do |aux| - obj_list << compile(aux, test_defines) - end - end + test_defines = [] # Detect dependencies and build required modules extract_headers(test).each do |header| @@ -227,14 +216,8 @@ def run_tests(test_files) # Build the test runner (generate if configured to do so) test_base = File.basename(test, C_EXTENSION) - runner_name = test_base + '_Runner.c' - - runner_path = if $cfg['compiler']['runner_path'].nil? - $cfg['compiler']['build_path'] + runner_name - else - $cfg['compiler']['runner_path'] + runner_name - end + runner_path = 'build/' + runner_name options = $cfg[:unity] options[:use_param_tests] = test =~ /parameterized/ ? true : false @@ -248,15 +231,8 @@ def run_tests(test_files) link_it(test_base, obj_list) # Execute unit test and generate results file - simulator = build_simulator_fields - executable = $cfg['linker']['bin_files']['destination'] + test_base + $cfg['linker']['bin_files']['extension'] - cmd_str = if simulator.nil? - executable - else - "#{simulator[:command]} #{simulator[:pre_support]} #{executable} #{simulator[:post_support]}" - end - output = execute(cmd_str) - test_results = $cfg['compiler']['build_path'] + test_base + output = runtest(test_base) + test_results = 'build/' + test_base if output.match(/OK$/m).nil? test_results += '.testfail' else diff --git a/test/targets/ansi.yml b/test/targets/ansi.yml index 182071ad..81af4c7f 100644 --- a/test/targets/ansi.yml +++ b/test/targets/ansi.yml @@ -1,49 +1,44 @@ -compiler: - path: gcc - source_path: '../src/' - unit_tests_path: &unit_tests_path 'tests/' - build_path: &build_path 'build/' - options: - - '-c' - - '-m64' - - '-Wall' - - '-Wno-address' - - '-ansi' - #- '-pedantic' - includes: - prefix: '-I' - items: - - 'src/' - - '../src/' - - 'testdata/' - - *unit_tests_path - defines: - prefix: '-D' - items: - - UNITY_INCLUDE_DOUBLE - - UNITY_SUPPORT_TEST_CASES - - UNITY_EXCLUDE_TESTING_NEW_COMMENTS - - UNITY_SUPPORT_64 - object_files: - prefix: '-o' - extension: '.o' - destination: *build_path -linker: - path: gcc - options: - - -lm - - '-m64' - includes: - prefix: '-I' - object_files: - path: *build_path - extension: '.o' - bin_files: - prefix: '-o' - extension: '.exe' - destination: *build_path +--- colour: true :unity: :plugins: [] :skip_tests: - - :parameterized \ No newline at end of file +- :parameterized +:tools: + :test_compiler: + :name: compiler + :executable: gcc + :arguments: + - "-c" + - "-m64" + - "-Wall" + - "-Wno-address" + - "-ansi" + - '-I"$": COLLECTION_PATHS_TEST_TOOLCHAIN_INCLUDE' + - '-I"$": COLLECTION_PATHS_TEST_SUPPORT_SOURCE_INCLUDE_VENDOR' + - "-D$: COLLECTION_DEFINES_TEST_AND_VENDOR" + - "${1}" + - "-o ${2}" + :test_linker: + :name: linker + :executable: gcc + :arguments: + - "${1}" + - "-lm" + - "-m64" + - "-o ${2}" +:extension: + :object: ".o" + :executable: ".exe" +:paths: + :test: + - src/ + - "../src/" + - testdata/ + - tests/ +:defines: + :test: + - UNITY_INCLUDE_DOUBLE + - UNITY_SUPPORT_TEST_CASES + - UNITY_EXCLUDE_TESTING_NEW_COMMENTS + - UNITY_SUPPORT_64 diff --git a/test/targets/clang_file.yml b/test/targets/clang_file.yml index df1bd24e..964e8145 100644 --- a/test/targets/clang_file.yml +++ b/test/targets/clang_file.yml @@ -1,78 +1,72 @@ --- -compiler: - path: clang - source_path: '../src/' - unit_tests_path: &unit_tests_path 'tests/' - build_path: &build_path 'build/' - options: - - '-c' - - '-Wall' - - '-Wextra' - - '-Werror' - - '-Wcast-qual' - - '-Wconversion' - - '-Wdisabled-optimization' - - '-Wformat=2' - - '-Winit-self' - - '-Winline' - - '-Winvalid-pch' - - '-Wmissing-include-dirs' - - '-Wnonnull' - - '-Wpacked' - - '-Wpointer-arith' - - '-Wswitch-default' - - '-Wstrict-aliasing' - - '-Wstrict-overflow=5' - - '-Wuninitialized' - - '-Wunused' -# - '-Wunreachable-code' - - '-Wreturn-type' - - '-Wshadow' - - '-Wundef' - - '-Wwrite-strings' - - '-Wno-nested-externs' - - '-Wno-unused-parameter' - - '-Wno-variadic-macros' - - '-Wbad-function-cast' - - '-fms-extensions' - - '-fno-omit-frame-pointer' - - '-ffloat-store' - - '-fno-common' - - '-fstrict-aliasing' - - '-std=gnu99' - - '-pedantic' - - '-O0' - includes: - prefix: '-I' - items: - - 'src/' - - '../src/' - - 'testdata/' - - *unit_tests_path - defines: - prefix: '-D' - items: - - UNITY_INCLUDE_DOUBLE - - UNITY_SUPPORT_64 - - UNITY_OUTPUT_RESULTS_FILE - object_files: - prefix: '-o' - extension: '.o' - destination: *build_path -linker: - path: clang - options: - - -lm - - '-m64' - includes: - prefix: '-I' - object_files: - path: *build_path - extension: '.o' - bin_files: - prefix: '-o' - extension: '.exe' - destination: *build_path colour: true :unity: :plugins: [] +:tools: + :test_compiler: + :name: compiler + :executable: clang + :arguments: + - "-c" + - "-Wall" + - "-Wextra" + - "-Werror" + - "-Wcast-qual" + - "-Wconversion" + - "-Wdisabled-optimization" + - "-Wformat=2" + - "-Winit-self" + - "-Winline" + - "-Winvalid-pch" + - "-Wmissing-include-dirs" + - "-Wnonnull" + - "-Wpacked" + - "-Wpointer-arith" + - "-Wswitch-default" + - "-Wstrict-aliasing" + - "-Wstrict-overflow=5" + - "-Wuninitialized" + - "-Wunused" + - "-Wreturn-type" + - "-Wshadow" + - "-Wundef" + - "-Wwrite-strings" + - "-Wno-nested-externs" + - "-Wno-unused-parameter" + - "-Wno-variadic-macros" + - "-Wbad-function-cast" + - "-fms-extensions" + - "-fno-omit-frame-pointer" + - "-ffloat-store" + - "-fno-common" + - "-fstrict-aliasing" + - "-std=gnu99" + - "-pedantic" + - "-O0" + - '-I"$": COLLECTION_PATHS_TEST_TOOLCHAIN_INCLUDE' + - '-I"$": COLLECTION_PATHS_TEST_SUPPORT_SOURCE_INCLUDE_VENDOR' + - "-D$: COLLECTION_DEFINES_TEST_AND_VENDOR" + - "${1}" + - "-o ${2}" + :test_linker: + :name: linker + :executable: clang + :arguments: + - "${1}" + - "-lm" + - "-m64" + - "-o ${2}" +:extension: + :object: ".o" + :executable: ".exe" +:paths: + :test: + - src/ + - "../src/" + - testdata/ + - tests/ +:defines: + :test: + - UNITY_INCLUDE_DOUBLE + - UNITY_SUPPORT_64 + - UNITY_OUTPUT_RESULTS_FILE diff --git a/test/targets/clang_strict.yml b/test/targets/clang_strict.yml index ee05b2a9..04d56806 100644 --- a/test/targets/clang_strict.yml +++ b/test/targets/clang_strict.yml @@ -1,78 +1,71 @@ --- -compiler: - path: clang - source_path: '../src/' - unit_tests_path: &unit_tests_path 'tests/' - build_path: &build_path 'build/' - options: - - '-c' - - '-Wall' - - '-Wextra' - - '-Werror' - - '-Wcast-qual' - - '-Wconversion' - - '-Wdisabled-optimization' - - '-Wformat=2' - - '-Winit-self' - - '-Winline' - - '-Winvalid-pch' - - '-Wmissing-include-dirs' - - '-Wnonnull' - - '-Wpacked' - - '-Wpointer-arith' - - '-Wswitch-default' - - '-Wstrict-aliasing' - - '-Wstrict-overflow=5' - - '-Wuninitialized' - - '-Wunused' -# - '-Wunreachable-code' - - '-Wreturn-type' - - '-Wshadow' - - '-Wundef' - - '-Wwrite-strings' - - '-Wno-nested-externs' - - '-Wno-unused-parameter' - - '-Wno-variadic-macros' - - '-Wbad-function-cast' - - '-fms-extensions' - - '-fno-omit-frame-pointer' - #- '-ffloat-store' - - '-fno-common' - - '-fstrict-aliasing' - - '-std=gnu99' - - '-pedantic' - - '-O0' - includes: - prefix: '-I' - items: - - 'src/' - - '../src/' - - 'testdata/' - - *unit_tests_path - defines: - prefix: '-D' - items: - - UNITY_INCLUDE_DOUBLE - - UNITY_SUPPORT_TEST_CASES - - UNITY_SUPPORT_64 - object_files: - prefix: '-o' - extension: '.o' - destination: *build_path -linker: - path: clang - options: - - -lm - - '-m64' - includes: - prefix: '-I' - object_files: - path: *build_path - extension: '.o' - bin_files: - prefix: '-o' - extension: '.exe' - destination: *build_path colour: true :unity: :plugins: [] +:tools: + :test_compiler: + :name: compiler + :executable: clang + :arguments: + - "-c" + - "-Wall" + - "-Wextra" + - "-Werror" + - "-Wcast-qual" + - "-Wconversion" + - "-Wdisabled-optimization" + - "-Wformat=2" + - "-Winit-self" + - "-Winline" + - "-Winvalid-pch" + - "-Wmissing-include-dirs" + - "-Wnonnull" + - "-Wpacked" + - "-Wpointer-arith" + - "-Wswitch-default" + - "-Wstrict-aliasing" + - "-Wstrict-overflow=5" + - "-Wuninitialized" + - "-Wunused" + - "-Wreturn-type" + - "-Wshadow" + - "-Wundef" + - "-Wwrite-strings" + - "-Wno-nested-externs" + - "-Wno-unused-parameter" + - "-Wno-variadic-macros" + - "-Wbad-function-cast" + - "-fms-extensions" + - "-fno-omit-frame-pointer" + - "-fno-common" + - "-fstrict-aliasing" + - "-std=gnu99" + - "-pedantic" + - "-O0" + - '-I"$": COLLECTION_PATHS_TEST_TOOLCHAIN_INCLUDE' + - '-I"$": COLLECTION_PATHS_TEST_SUPPORT_SOURCE_INCLUDE_VENDOR' + - "-D$: COLLECTION_DEFINES_TEST_AND_VENDOR" + - "${1}" + - "-o ${2}" + :test_linker: + :name: linker + :executable: clang + :arguments: + - "${1}" + - "-lm" + - "-m64" + - "-o ${2}" +:extension: + :object: ".o" + :executable: ".exe" +:paths: + :test: + - src/ + - "../src/" + - testdata/ + - tests/ +:defines: + :test: + - UNITY_INCLUDE_DOUBLE + - UNITY_SUPPORT_TEST_CASES + - UNITY_SUPPORT_64 diff --git a/test/targets/gcc_32.yml b/test/targets/gcc_32.yml index ec1165da..ba388cf7 100644 --- a/test/targets/gcc_32.yml +++ b/test/targets/gcc_32.yml @@ -1,49 +1,45 @@ -compiler: - path: gcc - source_path: '../src/' - unit_tests_path: &unit_tests_path 'tests/' - build_path: &build_path 'build/' - options: - - '-c' - - '-m32' - - '-Wall' - - '-Wno-address' - - '-std=c99' - - '-pedantic' - includes: - prefix: '-I' - items: - - 'src/' - - '../src/' - - 'testdata/' - - *unit_tests_path - defines: - prefix: '-D' - items: - - UNITY_EXCLUDE_STDINT_H - - UNITY_EXCLUDE_LIMITS_H - - UNITY_INCLUDE_DOUBLE - - UNITY_SUPPORT_TEST_CASES - - UNITY_INT_WIDTH=32 - - UNITY_LONG_WIDTH=32 - object_files: - prefix: '-o' - extension: '.o' - destination: *build_path -linker: - path: gcc - options: - - -lm - - '-m32' - includes: - prefix: '-I' - object_files: - path: *build_path - extension: '.o' - bin_files: - prefix: '-o' - extension: '.exe' - destination: *build_path +--- colour: true :unity: :plugins: [] +:tools: + :test_compiler: + :name: compiler + :executable: gcc + :arguments: + - "-c" + - "-m32" + - "-Wall" + - "-Wno-address" + - "-std=c99" + - "-pedantic" + - '-I"$": COLLECTION_PATHS_TEST_TOOLCHAIN_INCLUDE' + - '-I"$": COLLECTION_PATHS_TEST_SUPPORT_SOURCE_INCLUDE_VENDOR' + - "-D$: COLLECTION_DEFINES_TEST_AND_VENDOR" + - "${1}" + - "-o ${2}" + :test_linker: + :name: linker + :executable: gcc + :arguments: + - "${1}" + - "-lm" + - "-m32" + - "-o ${2}" +:extension: + :object: ".o" + :executable: ".exe" +:paths: + :test: + - src/ + - "../src/" + - testdata/ + - tests/ +:defines: + :test: + - UNITY_EXCLUDE_STDINT_H + - UNITY_EXCLUDE_LIMITS_H + - UNITY_INCLUDE_DOUBLE + - UNITY_SUPPORT_TEST_CASES + - UNITY_INT_WIDTH=32 + - UNITY_LONG_WIDTH=32 diff --git a/test/targets/gcc_64.yml b/test/targets/gcc_64.yml index 0e273de8..ed9eb4a8 100644 --- a/test/targets/gcc_64.yml +++ b/test/targets/gcc_64.yml @@ -1,50 +1,46 @@ -compiler: - path: gcc - source_path: '../src/' - unit_tests_path: &unit_tests_path 'tests/' - build_path: &build_path 'build/' - options: - - '-c' - - '-m64' - - '-Wall' - - '-Wno-address' - - '-std=c99' - - '-pedantic' - includes: - prefix: '-I' - items: - - 'src/' - - '../src/' - - 'testdata/' - - *unit_tests_path - defines: - prefix: '-D' - items: - - UNITY_EXCLUDE_STDINT_H - - UNITY_EXCLUDE_LIMITS_H - - UNITY_INCLUDE_DOUBLE - - UNITY_SUPPORT_TEST_CASES - - UNITY_SUPPORT_64 - - UNITY_INT_WIDTH=32 - - UNITY_LONG_WIDTH=64 - object_files: - prefix: '-o' - extension: '.o' - destination: *build_path -linker: - path: gcc - options: - - -lm - - '-m64' - includes: - prefix: '-I' - object_files: - path: *build_path - extension: '.o' - bin_files: - prefix: '-o' - extension: '.exe' - destination: *build_path +--- colour: true :unity: :plugins: [] +:tools: + :test_compiler: + :name: compiler + :executable: gcc + :arguments: + - "-c" + - "-m64" + - "-Wall" + - "-Wno-address" + - "-std=c99" + - "-pedantic" + - '-I"$": COLLECTION_PATHS_TEST_TOOLCHAIN_INCLUDE' + - '-I"$": COLLECTION_PATHS_TEST_SUPPORT_SOURCE_INCLUDE_VENDOR' + - "-D$: COLLECTION_DEFINES_TEST_AND_VENDOR" + - "${1}" + - "-o ${2}" + :test_linker: + :name: linker + :executable: gcc + :arguments: + - "${1}" + - "-lm" + - "-m64" + - "-o ${2}" +:extension: + :object: ".o" + :executable: ".exe" +:paths: + :test: + - src/ + - "../src/" + - testdata/ + - tests/ +:defines: + :test: + - UNITY_EXCLUDE_STDINT_H + - UNITY_EXCLUDE_LIMITS_H + - UNITY_INCLUDE_DOUBLE + - UNITY_SUPPORT_TEST_CASES + - UNITY_SUPPORT_64 + - UNITY_INT_WIDTH=32 + - UNITY_LONG_WIDTH=64 diff --git a/test/targets/gcc_auto_limits.yml b/test/targets/gcc_auto_limits.yml index 40088ac4..9cfda8d4 100644 --- a/test/targets/gcc_auto_limits.yml +++ b/test/targets/gcc_auto_limits.yml @@ -1,47 +1,43 @@ -compiler: - path: gcc - source_path: '../src/' - unit_tests_path: &unit_tests_path 'tests/' - build_path: &build_path 'build/' - options: - - '-c' - - '-m64' - - '-Wall' - - '-Wno-address' - - '-std=c99' - - '-pedantic' - includes: - prefix: '-I' - items: - - 'src/' - - '../src/' - - 'testdata/' - - *unit_tests_path - defines: - prefix: '-D' - items: - - UNITY_EXCLUDE_STDINT_H - - UNITY_INCLUDE_DOUBLE - - UNITY_SUPPORT_TEST_CASES - - UNITY_SUPPORT_64 - object_files: - prefix: '-o' - extension: '.o' - destination: *build_path -linker: - path: gcc - options: - - -lm - - '-m64' - includes: - prefix: '-I' - object_files: - path: *build_path - extension: '.o' - bin_files: - prefix: '-o' - extension: '.exe' - destination: *build_path +--- colour: true :unity: :plugins: [] +:tools: + :test_compiler: + :name: compiler + :executable: gcc + :arguments: + - "-c" + - "-m64" + - "-Wall" + - "-Wno-address" + - "-std=c99" + - "-pedantic" + - '-I"$": COLLECTION_PATHS_TEST_TOOLCHAIN_INCLUDE' + - '-I"$": COLLECTION_PATHS_TEST_SUPPORT_SOURCE_INCLUDE_VENDOR' + - "-D$: COLLECTION_DEFINES_TEST_AND_VENDOR" + - "${1}" + - "-o ${2}" + :test_linker: + :name: linker + :executable: gcc + :arguments: + - "${1}" + - "-lm" + - "-m64" + - "-o ${2}" +:extension: + :object: ".o" + :executable: ".exe" +:paths: + :test: + - src/ + - "../src/" + - testdata/ + - tests/ +:defines: + :test: + - UNITY_EXCLUDE_STDINT_H + - UNITY_INCLUDE_DOUBLE + - UNITY_SUPPORT_TEST_CASES + - UNITY_SUPPORT_64 diff --git a/test/targets/gcc_auto_stdint.yml b/test/targets/gcc_auto_stdint.yml index f12165cd..66602ef7 100644 --- a/test/targets/gcc_auto_stdint.yml +++ b/test/targets/gcc_auto_stdint.yml @@ -1,59 +1,55 @@ -compiler: - path: gcc - source_path: '../src/' - unit_tests_path: &unit_tests_path 'tests/' - build_path: &build_path 'build/' - options: - - '-c' - - '-m64' - - '-Wall' - - '-Wno-address' - - '-std=c99' - - '-pedantic' - - '-Wextra' - - '-Werror' - - '-Wpointer-arith' - - '-Wcast-align' - - '-Wwrite-strings' - - '-Wswitch-default' - - '-Wunreachable-code' - - '-Winit-self' - - '-Wmissing-field-initializers' - - '-Wno-unknown-pragmas' - - '-Wstrict-prototypes' - - '-Wundef' - - '-Wold-style-definition' - includes: - prefix: '-I' - items: - - 'src/' - - '../src/' - - 'testdata/' - - *unit_tests_path - defines: - prefix: '-D' - items: - - UNITY_INCLUDE_DOUBLE - - UNITY_SUPPORT_TEST_CASES - - UNITY_SUPPORT_64 - object_files: - prefix: '-o' - extension: '.o' - destination: *build_path -linker: - path: gcc - options: - - -lm - - '-m64' - includes: - prefix: '-I' - object_files: - path: *build_path - extension: '.o' - bin_files: - prefix: '-o' - extension: '.exe' - destination: *build_path +--- colour: true :unity: :plugins: [] +:tools: + :test_compiler: + :name: compiler + :executable: gcc + :arguments: + - "-c" + - "-m64" + - "-Wall" + - "-Wno-address" + - "-std=c99" + - "-pedantic" + - "-Wextra" + - "-Werror" + - "-Wpointer-arith" + - "-Wcast-align" + - "-Wwrite-strings" + - "-Wswitch-default" + - "-Wunreachable-code" + - "-Winit-self" + - "-Wmissing-field-initializers" + - "-Wno-unknown-pragmas" + - "-Wstrict-prototypes" + - "-Wundef" + - "-Wold-style-definition" + - '-I"$": COLLECTION_PATHS_TEST_TOOLCHAIN_INCLUDE' + - '-I"$": COLLECTION_PATHS_TEST_SUPPORT_SOURCE_INCLUDE_VENDOR' + - "-D$: COLLECTION_DEFINES_TEST_AND_VENDOR" + - "${1}" + - "-o ${2}" + :test_linker: + :name: linker + :executable: gcc + :arguments: + - "${1}" + - "-lm" + - "-m64" + - "-o ${2}" +:extension: + :object: ".o" + :executable: ".exe" +:paths: + :test: + - src/ + - "../src/" + - testdata/ + - tests/ +:defines: + :test: + - UNITY_INCLUDE_DOUBLE + - UNITY_SUPPORT_TEST_CASES + - UNITY_SUPPORT_64 diff --git a/test/targets/gcc_manual_math.yml b/test/targets/gcc_manual_math.yml index b379e3fc..b1b5b82e 100644 --- a/test/targets/gcc_manual_math.yml +++ b/test/targets/gcc_manual_math.yml @@ -1,47 +1,43 @@ -compiler: - path: gcc - source_path: '../src/' - unit_tests_path: &unit_tests_path 'tests/' - build_path: &build_path 'build/' - options: - - '-c' - - '-m64' - - '-Wall' - - '-Wno-address' - - '-std=c99' - - '-pedantic' - includes: - prefix: '-I' - items: - - 'src/' - - '../src/' - - 'testdata/' - - *unit_tests_path - defines: - prefix: '-D' - items: - - UNITY_EXCLUDE_MATH_H - - UNITY_INCLUDE_DOUBLE - - UNITY_SUPPORT_TEST_CASES - - UNITY_SUPPORT_64 - object_files: - prefix: '-o' - extension: '.o' - destination: *build_path -linker: - path: gcc - options: - - -lm - - '-m64' - includes: - prefix: '-I' - object_files: - path: *build_path - extension: '.o' - bin_files: - prefix: '-o' - extension: '.exe' - destination: *build_path +--- colour: true :unity: :plugins: [] +:tools: + :test_compiler: + :name: compiler + :executable: gcc + :arguments: + - "-c" + - "-m64" + - "-Wall" + - "-Wno-address" + - "-std=c99" + - "-pedantic" + - '-I"$": COLLECTION_PATHS_TEST_TOOLCHAIN_INCLUDE' + - '-I"$": COLLECTION_PATHS_TEST_SUPPORT_SOURCE_INCLUDE_VENDOR' + - "-D$: COLLECTION_DEFINES_TEST_AND_VENDOR" + - "${1}" + - "-o ${2}" + :test_linker: + :name: linker + :executable: gcc + :arguments: + - "${1}" + - "-lm" + - "-m64" + - "-o ${2}" +:extension: + :object: ".o" + :executable: ".exe" +:paths: + :test: + - src/ + - "../src/" + - testdata/ + - tests/ +:defines: + :test: + - UNITY_EXCLUDE_MATH_H + - UNITY_INCLUDE_DOUBLE + - UNITY_SUPPORT_TEST_CASES + - UNITY_SUPPORT_64 diff --git a/test/targets/hitech_picc18.yml b/test/targets/hitech_picc18.yml index 2fd4aa36..b984edbd 100644 --- a/test/targets/hitech_picc18.yml +++ b/test/targets/hitech_picc18.yml @@ -1,101 +1,91 @@ -# rumor has it that this yaml file works for the standard edition of the -# hitech PICC18 compiler, but not the pro version. -# -compiler: - path: cd build && picc18 - source_path: '..\src\' - unit_tests_path: &unit_tests_path 'tests\' - build_path: &build_path 'build\' - options: - - --chip=18F87J10 - - --ide=hitide - - --q #quiet please - - --asmlist - - --codeoffset=0 - - --emi=wordwrite # External memory interface protocol - - --warn=0 # allow all normal warning messages - - --errors=10 # Number of errors before aborting compile - - --char=unsigned - - -Bl # Large memory model - - -G # generate symbol file - - --cp=16 # 16-bit pointers - - --double=24 - - -N255 # 255-char symbol names - - --opt=none # Do not use any compiler optimziations - - -c # compile only - - -M - includes: - prefix: '-I' - items: - - 'c:/Projects/NexGen/Prototypes/CMockTest/src/' - - 'c:/Projects/NexGen/Prototypes/CMockTest/mocks/' - - 'c:/CMock/src/' - - 'c:/CMock/examples/src/' - - 'c:/CMock/vendor/unity/src/' - - 'c:/CMock/vendor/unity/examples/helper/' - - *unit_tests_path - defines: - prefix: '-D' - items: - - UNITY_INT_WIDTH=16 - - UNITY_POINTER_WIDTH=16 - - CMOCK_MEM_STATIC - - CMOCK_MEM_SIZE=3000 - - UNITY_SUPPORT_TEST_CASES - - _PICC18 - object_files: - # prefix: '-O' # Hi-Tech doesn't want a prefix. They key off of filename .extensions, instead - extension: '.obj' - destination: *build_path - -linker: - path: cd build && picc18 - options: - - --chip=18F87J10 - - --ide=hitide - - --cp=24 # 24-bit pointers. Is this needed for linker?? - - --double=24 # Is this needed for linker?? - - -Lw # Scan the pic87*w.lib in the lib/ of the compiler installation directory - - --summary=mem,file # info listing - - --summary=+psect - - --summary=+hex - - --output=+intel - - --output=+mcof - - --runtime=+init # Directs startup code to copy idata, ibigdata and ifardata psects from ROM to RAM. - - --runtime=+clear # Directs startup code to clear bss, bigbss, rbss and farbss psects - - --runtime=+clib # link in the c-runtime - - --runtime=+keep # Keep the generated startup src after its obj is linked - - -G # Generate src-level symbol file - - -MIWasTheLastToBuild.map - - --warn=0 # allow all normal warning messages - - -Bl # Large memory model (probably not needed for linking) - includes: - prefix: '-I' - object_files: - path: *build_path - extension: '.obj' - bin_files: - prefix: '-O' - extension: '.hex' - destination: *build_path - -simulator: - path: - pre_support: - - 'java -client -jar ' # note space - - ['C:\Program Files\HI-TECH Software\HI-TIDE\3.15\lib\', 'simpic18.jar'] - - 18F87J10 - post_support: - +--- :cmock: :plugins: [] :includes: - - Types.h + - Types.h :suite_teardown: | if (num_failures) _FAILED_TEST(); else _PASSED_TESTS(); return 0; - colour: true +:tools: + :test_compiler: + :name: compiler + :executable: cd build && picc18 + :arguments: + - "--chip=18F87J10" + - "--ide=hitide" + - "--q" + - "--asmlist" + - "--codeoffset=0" + - "--emi=wordwrite" + - "--warn=0" + - "--errors=10" + - "--char=unsigned" + - "-Bl" + - "-G" + - "--cp=16" + - "--double=24" + - "-N255" + - "--opt=none" + - "-c" + - "-M" + - '-I"$": COLLECTION_PATHS_TEST_TOOLCHAIN_INCLUDE' + - '-I"$": COLLECTION_PATHS_TEST_SUPPORT_SOURCE_INCLUDE_VENDOR' + - "-D$: COLLECTION_DEFINES_TEST_AND_VENDOR" + - "${1}" + - " ${2}" + :test_linker: + :name: linker + :executable: cd build && picc18 + :arguments: + - "${1}" + - "--chip=18F87J10" + - "--ide=hitide" + - "--cp=24" + - "--double=24" + - "-Lw" + - "--summary=mem,file" + - "--summary=+psect" + - "--summary=+hex" + - "--output=+intel" + - "--output=+mcof" + - "--runtime=+init" + - "--runtime=+clear" + - "--runtime=+clib" + - "--runtime=+keep" + - "-G" + - "-MIWasTheLastToBuild.map" + - "--warn=0" + - "-Bl" + - "-O ${2}" + :test_fixture: + :name: simulator + :executable: 'java -client -jar ' + :arguments: + - - C:\Program Files\HI-TECH Software\HI-TIDE\3.15\lib\ + - simpic18.jar + - 18F87J10 + - "${1}" +:extension: + :object: ".obj" + :executable: ".hex" +:paths: + :test: + - c:/Projects/NexGen/Prototypes/CMockTest/src/ + - c:/Projects/NexGen/Prototypes/CMockTest/mocks/ + - c:/CMock/src/ + - c:/CMock/examples/src/ + - c:/CMock/vendor/unity/src/ + - c:/CMock/vendor/unity/examples/helper/ + - tests\ +:defines: + :test: + - UNITY_INT_WIDTH=16 + - UNITY_POINTER_WIDTH=16 + - CMOCK_MEM_STATIC + - CMOCK_MEM_SIZE=3000 + - UNITY_SUPPORT_TEST_CASES + - _PICC18 diff --git a/test/targets/iar_arm_v4.yml b/test/targets/iar_arm_v4.yml index 2f9f881e..9a1a2761 100644 --- a/test/targets/iar_arm_v4.yml +++ b/test/targets/iar_arm_v4.yml @@ -1,90 +1,98 @@ -tools_root: &tools_root 'C:\Program Files\IAR Systems\Embedded Workbench 4.0 Kickstart\' -compiler: - path: [*tools_root, 'arm\bin\iccarm.exe'] - source_path: '..\src\' - unit_tests_path: &unit_tests_path 'tests\' - build_path: &build_path 'build\' - options: - - --dlib_config - - [*tools_root, 'arm\lib\dl4tptinl8n.h'] - - -z3 - - --no_cse - - --no_unroll - - --no_inline - - --no_code_motion - - --no_tbaa - - --no_clustering - - --no_scheduling - - --debug - - --cpu_mode thumb - - --endian little - - --cpu ARM7TDMI - - --stack_align 4 - - --interwork - - -e - - --silent - - --warnings_are_errors - - --fpu None - - --diag_suppress Pa050 - includes: - prefix: '-I' - items: - - [*tools_root, 'arm\inc\'] - - 'src\' - - '..\src\' - - 'testdata/' - - *unit_tests_path - - 'vendor\unity\src\' - defines: - prefix: '-D' - items: - - UNITY_SUPPORT_64 - - 'UNITY_SUPPORT_TEST_CASES' - object_files: - prefix: '-o' - extension: '.r79' - destination: *build_path -linker: - path: [*tools_root, 'common\bin\xlink.exe'] - options: - - -rt - - [*tools_root, 'arm\lib\dl4tptinl8n.r79'] - - -D_L_EXTMEM_START=0 - - -D_L_EXTMEM_SIZE=0 - - -D_L_HEAP_SIZE=120 - - -D_L_STACK_SIZE=32 - - -e_small_write=_formatted_write - - -s - - __program_start - - -f - - [*tools_root, '\arm\config\lnkarm.xcl'] - includes: - prefix: '-I' - items: - - [*tools_root, 'arm\config\'] - - [*tools_root, 'arm\lib\'] - object_files: - path: *build_path - extension: '.r79' - bin_files: - prefix: '-o' - extension: '.d79' - destination: *build_path -simulator: - path: [*tools_root, 'common\bin\CSpyBat.exe'] - pre_support: - - --silent - - [*tools_root, 'arm\bin\armproc.dll'] - - [*tools_root, 'arm\bin\armsim.dll'] - post_support: - - --plugin - - [*tools_root, 'arm\bin\armbat.dll'] - - --backend - - -B - - -p - - [*tools_root, 'arm\config\ioat91sam7X256.ddf'] - - -d - - sim +--- +tools_root: C:\Program Files\IAR Systems\Embedded Workbench 4.0 Kickstart\ colour: true :unity: :plugins: [] +:tools: + :test_compiler: + :name: compiler + :executable: + - C:\Program Files\IAR Systems\Embedded Workbench 4.0 Kickstart\ + - arm\bin\iccarm.exe + :arguments: + - "--dlib_config" + - - C:\Program Files\IAR Systems\Embedded Workbench 4.0 Kickstart\ + - arm\lib\dl4tptinl8n.h + - "-z3" + - "--no_cse" + - "--no_unroll" + - "--no_inline" + - "--no_code_motion" + - "--no_tbaa" + - "--no_clustering" + - "--no_scheduling" + - "--debug" + - "--cpu_mode thumb" + - "--endian little" + - "--cpu ARM7TDMI" + - "--stack_align 4" + - "--interwork" + - "-e" + - "--silent" + - "--warnings_are_errors" + - "--fpu None" + - "--diag_suppress Pa050" + - '-I"$": COLLECTION_PATHS_TEST_TOOLCHAIN_INCLUDE' + - '-I"$": COLLECTION_PATHS_TEST_SUPPORT_SOURCE_INCLUDE_VENDOR' + - "-D$: COLLECTION_DEFINES_TEST_AND_VENDOR" + - "${1}" + - "-o ${2}" + :test_linker: + :name: linker + :executable: + - C:\Program Files\IAR Systems\Embedded Workbench 4.0 Kickstart\ + - common\bin\xlink.exe + :arguments: + - "${1}" + - "-rt" + - - C:\Program Files\IAR Systems\Embedded Workbench 4.0 Kickstart\ + - arm\lib\dl4tptinl8n.r79 + - "-D_L_EXTMEM_START=0" + - "-D_L_EXTMEM_SIZE=0" + - "-D_L_HEAP_SIZE=120" + - "-D_L_STACK_SIZE=32" + - "-e_small_write=_formatted_write" + - "-s" + - __program_start + - "-f" + - - C:\Program Files\IAR Systems\Embedded Workbench 4.0 Kickstart\ + - "\\arm\\config\\lnkarm.xcl" + - "-o ${2}" + :test_fixture: + :name: simulator + :executable: + - C:\Program Files\IAR Systems\Embedded Workbench 4.0 Kickstart\ + - common\bin\CSpyBat.exe + :arguments: + - "--silent" + - - C:\Program Files\IAR Systems\Embedded Workbench 4.0 Kickstart\ + - arm\bin\armproc.dll + - - C:\Program Files\IAR Systems\Embedded Workbench 4.0 Kickstart\ + - arm\bin\armsim.dll + - "${1}" + - "--plugin" + - - C:\Program Files\IAR Systems\Embedded Workbench 4.0 Kickstart\ + - arm\bin\armbat.dll + - "--backend" + - "-B" + - "-p" + - - C:\Program Files\IAR Systems\Embedded Workbench 4.0 Kickstart\ + - arm\config\ioat91sam7X256.ddf + - "-d" + - sim +:extension: + :object: ".r79" + :executable: ".d79" +:paths: + :test: + - - C:\Program Files\IAR Systems\Embedded Workbench 4.0 Kickstart\ + - arm\inc\ + - src\ + - "..\\src\\" + - testdata/ + - tests\ + - vendor\unity\src\ +:defines: + :test: + - UNITY_SUPPORT_64 + - UNITY_SUPPORT_TEST_CASES diff --git a/test/targets/iar_arm_v5.yml b/test/targets/iar_arm_v5.yml index 223f1a65..d4b115f1 100644 --- a/test/targets/iar_arm_v5.yml +++ b/test/targets/iar_arm_v5.yml @@ -1,80 +1,92 @@ -tools_root: &tools_root 'C:\Program Files\IAR Systems\Embedded Workbench 5.3\' -compiler: - path: [*tools_root, 'arm\bin\iccarm.exe'] - source_path: '..\src\' - unit_tests_path: &unit_tests_path 'tests\' - build_path: &build_path 'build\' - options: - - --dlib_config - - [*tools_root, 'arm\inc\DLib_Config_Normal.h'] - - --no_cse - - --no_unroll - - --no_inline - - --no_code_motion - - --no_tbaa - - --no_clustering - - --no_scheduling - - --debug - - --cpu_mode thumb - - --endian=little - - --cpu=ARM7TDMI - - --interwork - - --warnings_are_errors - - --fpu=None - - --diag_suppress=Pa050 - - --diag_suppress=Pe111 - - -e - - -On - includes: - prefix: '-I' - items: - - [*tools_root, 'arm\inc\'] - - 'src\' - - '..\src\' - - 'testdata/' - - *unit_tests_path - - 'vendor\unity\src\' - - 'iar\iar_v5\incIAR\' - defines: - prefix: '-D' - items: - - UNITY_SUPPORT_64 - - 'UNITY_SUPPORT_TEST_CASES' - object_files: - prefix: '-o' - extension: '.r79' - destination: *build_path -linker: - path: [*tools_root, 'arm\bin\ilinkarm.exe'] - options: - - --redirect _Printf=_PrintfLarge - - --redirect _Scanf=_ScanfSmall - - --semihosting - - --entry __iar_program_start - - --config - - [*tools_root, 'arm\config\generic.icf'] - object_files: - path: *build_path - extension: '.o' - bin_files: - prefix: '-o' - extension: '.out' - destination: *build_path -simulator: - path: [*tools_root, 'common\bin\CSpyBat.exe'] - pre_support: - - --silent - - [*tools_root, 'arm\bin\armproc.dll'] - - [*tools_root, 'arm\bin\armsim.dll'] - post_support: - - --plugin - - [*tools_root, 'arm\bin\armbat.dll'] - - --backend - - -B - - -p - - [*tools_root, 'arm\config\debugger\atmel\ioat91sam7X256.ddf'] - - -d - - sim +--- +tools_root: C:\Program Files\IAR Systems\Embedded Workbench 5.3\ colour: true :unity: :plugins: [] +:tools: + :test_compiler: + :name: compiler + :executable: + - C:\Program Files\IAR Systems\Embedded Workbench 5.3\ + - arm\bin\iccarm.exe + :arguments: + - "--dlib_config" + - - C:\Program Files\IAR Systems\Embedded Workbench 5.3\ + - arm\inc\DLib_Config_Normal.h + - "--no_cse" + - "--no_unroll" + - "--no_inline" + - "--no_code_motion" + - "--no_tbaa" + - "--no_clustering" + - "--no_scheduling" + - "--debug" + - "--cpu_mode thumb" + - "--endian=little" + - "--cpu=ARM7TDMI" + - "--interwork" + - "--warnings_are_errors" + - "--fpu=None" + - "--diag_suppress=Pa050" + - "--diag_suppress=Pe111" + - "-e" + - "-On" + - '-I"$": COLLECTION_PATHS_TEST_TOOLCHAIN_INCLUDE' + - '-I"$": COLLECTION_PATHS_TEST_SUPPORT_SOURCE_INCLUDE_VENDOR' + - "-D$: COLLECTION_DEFINES_TEST_AND_VENDOR" + - "${1}" + - "-o ${2}" + :test_linker: + :name: linker + :executable: + - C:\Program Files\IAR Systems\Embedded Workbench 5.3\ + - arm\bin\ilinkarm.exe + :arguments: + - "${1}" + - "--redirect _Printf=_PrintfLarge" + - "--redirect _Scanf=_ScanfSmall" + - "--semihosting" + - "--entry __iar_program_start" + - "--config" + - - C:\Program Files\IAR Systems\Embedded Workbench 5.3\ + - arm\config\generic.icf + - "-o ${2}" + :test_fixture: + :name: simulator + :executable: + - C:\Program Files\IAR Systems\Embedded Workbench 5.3\ + - common\bin\CSpyBat.exe + :arguments: + - "--silent" + - - C:\Program Files\IAR Systems\Embedded Workbench 5.3\ + - arm\bin\armproc.dll + - - C:\Program Files\IAR Systems\Embedded Workbench 5.3\ + - arm\bin\armsim.dll + - "${1}" + - "--plugin" + - - C:\Program Files\IAR Systems\Embedded Workbench 5.3\ + - arm\bin\armbat.dll + - "--backend" + - "-B" + - "-p" + - - C:\Program Files\IAR Systems\Embedded Workbench 5.3\ + - arm\config\debugger\atmel\ioat91sam7X256.ddf + - "-d" + - sim +:extension: + :object: ".r79" + :executable: ".out" +:paths: + :test: + - - C:\Program Files\IAR Systems\Embedded Workbench 5.3\ + - arm\inc\ + - src\ + - "..\\src\\" + - testdata/ + - tests\ + - vendor\unity\src\ + - iar\iar_v5\incIAR\ +:defines: + :test: + - UNITY_SUPPORT_64 + - UNITY_SUPPORT_TEST_CASES diff --git a/test/targets/iar_arm_v5_3.yml b/test/targets/iar_arm_v5_3.yml index 223f1a65..d4b115f1 100644 --- a/test/targets/iar_arm_v5_3.yml +++ b/test/targets/iar_arm_v5_3.yml @@ -1,80 +1,92 @@ -tools_root: &tools_root 'C:\Program Files\IAR Systems\Embedded Workbench 5.3\' -compiler: - path: [*tools_root, 'arm\bin\iccarm.exe'] - source_path: '..\src\' - unit_tests_path: &unit_tests_path 'tests\' - build_path: &build_path 'build\' - options: - - --dlib_config - - [*tools_root, 'arm\inc\DLib_Config_Normal.h'] - - --no_cse - - --no_unroll - - --no_inline - - --no_code_motion - - --no_tbaa - - --no_clustering - - --no_scheduling - - --debug - - --cpu_mode thumb - - --endian=little - - --cpu=ARM7TDMI - - --interwork - - --warnings_are_errors - - --fpu=None - - --diag_suppress=Pa050 - - --diag_suppress=Pe111 - - -e - - -On - includes: - prefix: '-I' - items: - - [*tools_root, 'arm\inc\'] - - 'src\' - - '..\src\' - - 'testdata/' - - *unit_tests_path - - 'vendor\unity\src\' - - 'iar\iar_v5\incIAR\' - defines: - prefix: '-D' - items: - - UNITY_SUPPORT_64 - - 'UNITY_SUPPORT_TEST_CASES' - object_files: - prefix: '-o' - extension: '.r79' - destination: *build_path -linker: - path: [*tools_root, 'arm\bin\ilinkarm.exe'] - options: - - --redirect _Printf=_PrintfLarge - - --redirect _Scanf=_ScanfSmall - - --semihosting - - --entry __iar_program_start - - --config - - [*tools_root, 'arm\config\generic.icf'] - object_files: - path: *build_path - extension: '.o' - bin_files: - prefix: '-o' - extension: '.out' - destination: *build_path -simulator: - path: [*tools_root, 'common\bin\CSpyBat.exe'] - pre_support: - - --silent - - [*tools_root, 'arm\bin\armproc.dll'] - - [*tools_root, 'arm\bin\armsim.dll'] - post_support: - - --plugin - - [*tools_root, 'arm\bin\armbat.dll'] - - --backend - - -B - - -p - - [*tools_root, 'arm\config\debugger\atmel\ioat91sam7X256.ddf'] - - -d - - sim +--- +tools_root: C:\Program Files\IAR Systems\Embedded Workbench 5.3\ colour: true :unity: :plugins: [] +:tools: + :test_compiler: + :name: compiler + :executable: + - C:\Program Files\IAR Systems\Embedded Workbench 5.3\ + - arm\bin\iccarm.exe + :arguments: + - "--dlib_config" + - - C:\Program Files\IAR Systems\Embedded Workbench 5.3\ + - arm\inc\DLib_Config_Normal.h + - "--no_cse" + - "--no_unroll" + - "--no_inline" + - "--no_code_motion" + - "--no_tbaa" + - "--no_clustering" + - "--no_scheduling" + - "--debug" + - "--cpu_mode thumb" + - "--endian=little" + - "--cpu=ARM7TDMI" + - "--interwork" + - "--warnings_are_errors" + - "--fpu=None" + - "--diag_suppress=Pa050" + - "--diag_suppress=Pe111" + - "-e" + - "-On" + - '-I"$": COLLECTION_PATHS_TEST_TOOLCHAIN_INCLUDE' + - '-I"$": COLLECTION_PATHS_TEST_SUPPORT_SOURCE_INCLUDE_VENDOR' + - "-D$: COLLECTION_DEFINES_TEST_AND_VENDOR" + - "${1}" + - "-o ${2}" + :test_linker: + :name: linker + :executable: + - C:\Program Files\IAR Systems\Embedded Workbench 5.3\ + - arm\bin\ilinkarm.exe + :arguments: + - "${1}" + - "--redirect _Printf=_PrintfLarge" + - "--redirect _Scanf=_ScanfSmall" + - "--semihosting" + - "--entry __iar_program_start" + - "--config" + - - C:\Program Files\IAR Systems\Embedded Workbench 5.3\ + - arm\config\generic.icf + - "-o ${2}" + :test_fixture: + :name: simulator + :executable: + - C:\Program Files\IAR Systems\Embedded Workbench 5.3\ + - common\bin\CSpyBat.exe + :arguments: + - "--silent" + - - C:\Program Files\IAR Systems\Embedded Workbench 5.3\ + - arm\bin\armproc.dll + - - C:\Program Files\IAR Systems\Embedded Workbench 5.3\ + - arm\bin\armsim.dll + - "${1}" + - "--plugin" + - - C:\Program Files\IAR Systems\Embedded Workbench 5.3\ + - arm\bin\armbat.dll + - "--backend" + - "-B" + - "-p" + - - C:\Program Files\IAR Systems\Embedded Workbench 5.3\ + - arm\config\debugger\atmel\ioat91sam7X256.ddf + - "-d" + - sim +:extension: + :object: ".r79" + :executable: ".out" +:paths: + :test: + - - C:\Program Files\IAR Systems\Embedded Workbench 5.3\ + - arm\inc\ + - src\ + - "..\\src\\" + - testdata/ + - tests\ + - vendor\unity\src\ + - iar\iar_v5\incIAR\ +:defines: + :test: + - UNITY_SUPPORT_64 + - UNITY_SUPPORT_TEST_CASES diff --git a/test/targets/iar_armcortex_LM3S9B92_v5_4.yml b/test/targets/iar_armcortex_LM3S9B92_v5_4.yml index c79bacf9..1703fe27 100644 --- a/test/targets/iar_armcortex_LM3S9B92_v5_4.yml +++ b/test/targets/iar_armcortex_LM3S9B92_v5_4.yml @@ -1,94 +1,90 @@ -#Default tool path for IAR 5.4 on Windows XP 64bit -tools_root: &tools_root 'C:\Program Files (x86)\IAR Systems\Embedded Workbench 5.4 Kickstart\' -compiler: - path: [*tools_root, 'arm\bin\iccarm.exe'] - source_path: '..\src\' - unit_tests_path: &unit_tests_path 'tests\' - build_path: &build_path 'build\' - options: - - --diag_suppress=Pa050 - #- --diag_suppress=Pe111 - - --debug - - --endian=little - - --cpu=Cortex-M3 - - --no_path_in_file_macros - - -e - - --fpu=None - - --dlib_config - - [*tools_root, 'arm\inc\DLib_Config_Normal.h'] - #- --preinclude --preinclude C:\Vss\T2 Working\common\system.h - - --interwork - - --warnings_are_errors -# - Ohz - - -Oh -# - --no_cse -# - --no_unroll -# - --no_inline -# - --no_code_motion -# - --no_tbaa -# - --no_clustering -# - --no_scheduling - - includes: - prefix: '-I' - items: - - [*tools_root, 'arm\inc\'] - - 'src\' - - '..\src\' - - 'testdata/' - - *unit_tests_path - - 'vendor\unity\src\' - - 'iar\iar_v5\incIAR\' - defines: - prefix: '-D' - items: - - ewarm - - PART_LM3S9B92 - - TARGET_IS_TEMPEST_RB1 - - USE_ROM_DRIVERS - - UART_BUFFERED - - UNITY_SUPPORT_64 - object_files: - prefix: '-o' - extension: '.r79' - destination: *build_path -linker: - path: [*tools_root, 'arm\bin\ilinkarm.exe'] - options: - - --redirect _Printf=_PrintfLarge - - --redirect _Scanf=_ScanfSmall - - --semihosting - - --entry __iar_program_start - - --config - - [*tools_root, 'arm\config\generic.icf'] -# - ['C:\Temp\lm3s9b92.icf'] - object_files: - path: *build_path - extension: '.o' - bin_files: - prefix: '-o' - extension: '.out' - destination: *build_path -simulator: - path: [*tools_root, 'common\bin\CSpyBat.exe'] - pre_support: - #- --silent - - [*tools_root, 'arm\bin\armproc.dll'] - - [*tools_root, 'arm\bin\armsim2.dll'] - post_support: - - --plugin - - [*tools_root, 'arm\bin\armbat.dll'] - - --backend - - -B - - --endian=little - - --cpu=Cortex-M3 - - --fpu=None - - -p - - [*tools_root, 'arm\config\debugger\TexasInstruments\iolm3sxxxx.ddf'] - - --semihosting - - --device=LM3SxBxx - #- -d - #- sim +--- +tools_root: C:\Program Files (x86)\IAR Systems\Embedded Workbench 5.4 Kickstart\ colour: true :unity: :plugins: [] +:tools: + :test_compiler: + :name: compiler + :executable: + - C:\Program Files (x86)\IAR Systems\Embedded Workbench 5.4 Kickstart\ + - arm\bin\iccarm.exe + :arguments: + - "--diag_suppress=Pa050" + - "--debug" + - "--endian=little" + - "--cpu=Cortex-M3" + - "--no_path_in_file_macros" + - "-e" + - "--fpu=None" + - "--dlib_config" + - - C:\Program Files (x86)\IAR Systems\Embedded Workbench 5.4 Kickstart\ + - arm\inc\DLib_Config_Normal.h + - "--interwork" + - "--warnings_are_errors" + - "-Oh" + - '-I"$": COLLECTION_PATHS_TEST_TOOLCHAIN_INCLUDE' + - '-I"$": COLLECTION_PATHS_TEST_SUPPORT_SOURCE_INCLUDE_VENDOR' + - "-D$: COLLECTION_DEFINES_TEST_AND_VENDOR" + - "${1}" + - "-o ${2}" + :test_linker: + :name: linker + :executable: + - C:\Program Files (x86)\IAR Systems\Embedded Workbench 5.4 Kickstart\ + - arm\bin\ilinkarm.exe + :arguments: + - "${1}" + - "--redirect _Printf=_PrintfLarge" + - "--redirect _Scanf=_ScanfSmall" + - "--semihosting" + - "--entry __iar_program_start" + - "--config" + - - C:\Program Files (x86)\IAR Systems\Embedded Workbench 5.4 Kickstart\ + - arm\config\generic.icf + - "-o ${2}" + :test_fixture: + :name: simulator + :executable: + - C:\Program Files (x86)\IAR Systems\Embedded Workbench 5.4 Kickstart\ + - common\bin\CSpyBat.exe + :arguments: + - - C:\Program Files (x86)\IAR Systems\Embedded Workbench 5.4 Kickstart\ + - arm\bin\armproc.dll + - - C:\Program Files (x86)\IAR Systems\Embedded Workbench 5.4 Kickstart\ + - arm\bin\armsim2.dll + - "${1}" + - "--plugin" + - - C:\Program Files (x86)\IAR Systems\Embedded Workbench 5.4 Kickstart\ + - arm\bin\armbat.dll + - "--backend" + - "-B" + - "--endian=little" + - "--cpu=Cortex-M3" + - "--fpu=None" + - "-p" + - - C:\Program Files (x86)\IAR Systems\Embedded Workbench 5.4 Kickstart\ + - arm\config\debugger\TexasInstruments\iolm3sxxxx.ddf + - "--semihosting" + - "--device=LM3SxBxx" +:extension: + :object: ".r79" + :executable: ".out" +:paths: + :test: + - - C:\Program Files (x86)\IAR Systems\Embedded Workbench 5.4 Kickstart\ + - arm\inc\ + - src\ + - "..\\src\\" + - testdata/ + - tests\ + - vendor\unity\src\ + - iar\iar_v5\incIAR\ +:defines: + :test: + - ewarm + - PART_LM3S9B92 + - TARGET_IS_TEMPEST_RB1 + - USE_ROM_DRIVERS + - UART_BUFFERED + - UNITY_SUPPORT_64 diff --git a/test/targets/iar_cortexm3_v5.yml b/test/targets/iar_cortexm3_v5.yml index 973de947..8b0978ff 100644 --- a/test/targets/iar_cortexm3_v5.yml +++ b/test/targets/iar_cortexm3_v5.yml @@ -1,84 +1,94 @@ -# unit testing under iar compiler / simulator for STM32 Cortex-M3 - -tools_root: &tools_root 'C:\Program Files\IAR Systems\Embedded Workbench 5.4\' -compiler: - path: [*tools_root, 'arm\bin\iccarm.exe'] - source_path: '..\src\' - unit_tests_path: &unit_tests_path 'tests\' - build_path: &build_path 'build\' - options: - - --dlib_config - - [*tools_root, 'arm\inc\DLib_Config_Normal.h'] - - --no_cse - - --no_unroll - - --no_inline - - --no_code_motion - - --no_tbaa - - --no_clustering - - --no_scheduling - - --debug - - --cpu_mode thumb - - --endian=little - - --cpu=Cortex-M3 - - --interwork - - --warnings_are_errors - - --fpu=None - - --diag_suppress=Pa050 - - --diag_suppress=Pe111 - - -e - - -On - includes: - prefix: '-I' - items: - - [*tools_root, 'arm\inc\'] - - 'src\' - - '..\src\' - - 'testdata/' - - *unit_tests_path - - 'vendor\unity\src\' - - 'iar\iar_v5\incIAR\' - defines: - prefix: '-D' - items: - - 'IAR' - - 'UNITY_SUPPORT_64' - - 'UNITY_SUPPORT_TEST_CASES' - object_files: - prefix: '-o' - extension: '.r79' - destination: *build_path -linker: - path: [*tools_root, 'arm\bin\ilinkarm.exe'] - options: - - --redirect _Printf=_PrintfLarge - - --redirect _Scanf=_ScanfSmall - - --semihosting - - --entry __iar_program_start - - --config - - [*tools_root, 'arm\config\generic_cortex.icf'] - object_files: - path: *build_path - extension: '.o' - bin_files: - prefix: '-o' - extension: '.out' - destination: *build_path -simulator: - path: [*tools_root, 'common\bin\CSpyBat.exe'] - pre_support: - - --silent - - [*tools_root, 'arm\bin\armproc.dll'] - - [*tools_root, 'arm\bin\armsim.dll'] - post_support: - - --plugin - - [*tools_root, 'arm\bin\armbat.dll'] - - --backend - - -B - - -p - - [*tools_root, 'arm\config\debugger\ST\iostm32f107xx.ddf'] - - --cpu=Cortex-M3 - - -d - - sim +--- +tools_root: C:\Program Files\IAR Systems\Embedded Workbench 5.4\ colour: true :unity: :plugins: [] +:tools: + :test_compiler: + :name: compiler + :executable: + - C:\Program Files\IAR Systems\Embedded Workbench 5.4\ + - arm\bin\iccarm.exe + :arguments: + - "--dlib_config" + - - C:\Program Files\IAR Systems\Embedded Workbench 5.4\ + - arm\inc\DLib_Config_Normal.h + - "--no_cse" + - "--no_unroll" + - "--no_inline" + - "--no_code_motion" + - "--no_tbaa" + - "--no_clustering" + - "--no_scheduling" + - "--debug" + - "--cpu_mode thumb" + - "--endian=little" + - "--cpu=Cortex-M3" + - "--interwork" + - "--warnings_are_errors" + - "--fpu=None" + - "--diag_suppress=Pa050" + - "--diag_suppress=Pe111" + - "-e" + - "-On" + - '-I"$": COLLECTION_PATHS_TEST_TOOLCHAIN_INCLUDE' + - '-I"$": COLLECTION_PATHS_TEST_SUPPORT_SOURCE_INCLUDE_VENDOR' + - "-D$: COLLECTION_DEFINES_TEST_AND_VENDOR" + - "${1}" + - "-o ${2}" + :test_linker: + :name: linker + :executable: + - C:\Program Files\IAR Systems\Embedded Workbench 5.4\ + - arm\bin\ilinkarm.exe + :arguments: + - "${1}" + - "--redirect _Printf=_PrintfLarge" + - "--redirect _Scanf=_ScanfSmall" + - "--semihosting" + - "--entry __iar_program_start" + - "--config" + - - C:\Program Files\IAR Systems\Embedded Workbench 5.4\ + - arm\config\generic_cortex.icf + - "-o ${2}" + :test_fixture: + :name: simulator + :executable: + - C:\Program Files\IAR Systems\Embedded Workbench 5.4\ + - common\bin\CSpyBat.exe + :arguments: + - "--silent" + - - C:\Program Files\IAR Systems\Embedded Workbench 5.4\ + - arm\bin\armproc.dll + - - C:\Program Files\IAR Systems\Embedded Workbench 5.4\ + - arm\bin\armsim.dll + - "${1}" + - "--plugin" + - - C:\Program Files\IAR Systems\Embedded Workbench 5.4\ + - arm\bin\armbat.dll + - "--backend" + - "-B" + - "-p" + - - C:\Program Files\IAR Systems\Embedded Workbench 5.4\ + - arm\config\debugger\ST\iostm32f107xx.ddf + - "--cpu=Cortex-M3" + - "-d" + - sim +:extension: + :object: ".r79" + :executable: ".out" +:paths: + :test: + - - C:\Program Files\IAR Systems\Embedded Workbench 5.4\ + - arm\inc\ + - src\ + - "..\\src\\" + - testdata/ + - tests\ + - vendor\unity\src\ + - iar\iar_v5\incIAR\ +:defines: + :test: + - IAR + - UNITY_SUPPORT_64 + - UNITY_SUPPORT_TEST_CASES diff --git a/test/targets/iar_msp430.yml b/test/targets/iar_msp430.yml index 4563af92..65872535 100644 --- a/test/targets/iar_msp430.yml +++ b/test/targets/iar_msp430.yml @@ -1,95 +1,112 @@ -tools_root: &tools_root 'C:\Program Files\IAR Systems\Embedded Workbench 5.3 MSP430\' -core_root: &core_root [*tools_root, '430\'] -core_bin: &core_bin [*core_root, 'bin\'] -core_config: &core_config [*core_root, 'config\'] -core_lib: &core_lib [*core_root, 'lib\'] -core_inc: &core_inc [*core_root, 'inc\'] -core_config: &core_config [*core_root, 'config\'] - -compiler: - path: [*core_bin, 'icc430.exe'] - source_path: '..\src\' - unit_tests_path: &unit_tests_path 'tests\' - build_path: &build_path 'build\' - options: - - --dlib_config - - [*core_lib, 'dlib\dl430fn.h'] - - --no_cse - - --no_unroll - - --no_inline - - --no_code_motion - - --no_tbaa - - --debug - - -e - - -Ol - - --multiplier=16 - - --double=32 - - --diag_suppress Pa050 - - --diag_suppress Pe111 - includes: - prefix: '-I' - items: - - *core_inc - - [*core_inc, 'dlib'] - - [*core_lib, 'dlib'] - - 'src\' - - '../src/' - - 'testdata/' - - *unit_tests_path - - 'vendor\unity\src' - defines: - prefix: '-D' - items: - - '__MSP430F149__' - - 'INT_WIDTH=16' - - 'UNITY_EXCLUDE_FLOAT' - - 'UNITY_SUPPORT_TEST_CASES' - object_files: - prefix: '-o' - extension: '.r43' - destination: *build_path -linker: - path: [*core_bin, 'xlink.exe'] - options: - - -rt - - [*core_lib, 'dlib\dl430fn.r43'] - - -e_PrintfTiny=_Printf - - -e_ScanfSmall=_Scanf - - -s __program_start - - -D_STACK_SIZE=50 - - -D_DATA16_HEAP_SIZE=50 - - -D_DATA20_HEAP_SIZE=50 - - -f - - [*core_config, 'lnk430f5438.xcl'] - - -f - - [*core_config, 'multiplier.xcl'] - includes: - prefix: '-I' - items: - - *core_config - - *core_lib - - [*core_lib, 'dlib'] - object_files: - path: *build_path - extension: '.r79' - bin_files: - prefix: '-o' - extension: '.d79' - destination: *build_path -simulator: - path: [*tools_root, 'common\bin\CSpyBat.exe'] - pre_support: - - --silent - - [*core_bin, '430proc.dll'] - - [*core_bin, '430sim.dll'] - post_support: - - --plugin - - [*core_bin, '430bat.dll'] - - --backend -B - - --cpu MSP430F5438 - - -p - - [*core_config, 'MSP430F5438.ddf'] - - -d sim +--- +tools_root: C:\Program Files\IAR Systems\Embedded Workbench 5.3 MSP430\ +core_root: &1 +- C:\Program Files\IAR Systems\Embedded Workbench 5.3 MSP430\ +- 430\ +core_bin: &2 +- *1 +- bin\ +core_config: &4 +- *1 +- config\ +core_lib: &3 +- *1 +- lib\ +core_inc: &5 +- *1 +- inc\ colour: true :unity: :plugins: [] +:tools: + :test_compiler: + :name: compiler + :executable: + - *2 + - icc430.exe + :arguments: + - "--dlib_config" + - - *3 + - dlib\dl430fn.h + - "--no_cse" + - "--no_unroll" + - "--no_inline" + - "--no_code_motion" + - "--no_tbaa" + - "--debug" + - "-e" + - "-Ol" + - "--multiplier=16" + - "--double=32" + - "--diag_suppress Pa050" + - "--diag_suppress Pe111" + - '-I"$": COLLECTION_PATHS_TEST_TOOLCHAIN_INCLUDE' + - '-I"$": COLLECTION_PATHS_TEST_SUPPORT_SOURCE_INCLUDE_VENDOR' + - "-D$: COLLECTION_DEFINES_TEST_AND_VENDOR" + - "${1}" + - "-o ${2}" + :test_linker: + :name: linker + :executable: + - *2 + - xlink.exe + :arguments: + - "${1}" + - "-rt" + - - *3 + - dlib\dl430fn.r43 + - "-e_PrintfTiny=_Printf" + - "-e_ScanfSmall=_Scanf" + - "-s __program_start" + - "-D_STACK_SIZE=50" + - "-D_DATA16_HEAP_SIZE=50" + - "-D_DATA20_HEAP_SIZE=50" + - "-f" + - - *4 + - lnk430f5438.xcl + - "-f" + - - *4 + - multiplier.xcl + - "-o ${2}" + :test_fixture: + :name: simulator + :executable: + - C:\Program Files\IAR Systems\Embedded Workbench 5.3 MSP430\ + - common\bin\CSpyBat.exe + :arguments: + - "--silent" + - - *2 + - 430proc.dll + - - *2 + - 430sim.dll + - "${1}" + - "--plugin" + - - *2 + - 430bat.dll + - "--backend -B" + - "--cpu MSP430F5438" + - "-p" + - - *4 + - MSP430F5438.ddf + - "-d sim" +:extension: + :object: ".r43" + :executable: ".d79" +:paths: + :test: + - *5 + - - *5 + - dlib + - - *3 + - dlib + - src\ + - "../src/" + - testdata/ + - tests\ + - vendor\unity\src +:defines: + :test: + - __MSP430F149__ + - INT_WIDTH=16 + - UNITY_EXCLUDE_FLOAT + - UNITY_SUPPORT_TEST_CASES diff --git a/test/targets/iar_sh2a_v6.yml b/test/targets/iar_sh2a_v6.yml index 27e6bee4..b4371cd0 100644 --- a/test/targets/iar_sh2a_v6.yml +++ b/test/targets/iar_sh2a_v6.yml @@ -1,86 +1,99 @@ -tools_root: &tools_root 'C:\Program Files\IAR Systems\Embedded Workbench 6.0\' -compiler: - path: [*tools_root, 'sh\bin\iccsh.exe'] - source_path: '..\src\' - unit_tests_path: &unit_tests_path 'tests\' - build_path: &build_path 'build\' - options: - - -e - - --char_is_signed - - -Ol - - --no_cse - - --no_unroll - - --no_inline - - --no_code_motion - - --no_tbaa - - --no_scheduling - - --no_clustering - - --debug - - --dlib_config - - [*tools_root, 'sh\inc\DLib_Product.h'] - - --double=32 - - --code_model=huge - - --data_model=huge - - --core=sh2afpu - - --warnings_affect_exit_code - - --warnings_are_errors - - --mfc - - --use_unix_directory_separators - - --diag_suppress=Pe161 - includes: - prefix: '-I' - items: - - [*tools_root, 'sh\inc\'] - - [*tools_root, 'sh\inc\c'] - - 'src\' - - '..\src\' - - 'testdata/' - - *unit_tests_path - - 'vendor\unity\src\' - defines: - prefix: '-D' - items: - - UNITY_SUPPORT_64 - - 'UNITY_SUPPORT_TEST_CASES' - object_files: - prefix: '-o' - extension: '.o' - destination: *build_path -linker: - path: [*tools_root, 'sh\bin\ilinksh.exe'] - options: - - --redirect __Printf=__PrintfSmall - - --redirect __Scanf=__ScanfSmall - - --config - - [*tools_root, 'sh\config\generic.icf'] - - --config_def _CSTACK_SIZE=0x800 - - --config_def _HEAP_SIZE=0x800 - - --config_def _INT_TABLE=0x10 - - --entry __iar_program_start - - --debug_lib - object_files: - path: *build_path - extension: '.o' - bin_files: - prefix: '-o' - extension: '.out' - destination: *build_path -simulator: - path: [*tools_root, 'common\bin\CSpyBat.exe'] - pre_support: - - --silent - - [*tools_root, 'sh\bin\shproc.dll'] - - [*tools_root, 'sh\bin\shsim.dll'] - post_support: - - --plugin - - [*tools_root, 'sh\bin\shbat.dll'] - - --backend - - -B - - --core sh2afpu - - -p - - [*tools_root, 'sh\config\debugger\io7264.ddf'] - - -d - - sim +--- +tools_root: C:\Program Files\IAR Systems\Embedded Workbench 6.0\ colour: true :unity: :plugins: [] +:tools: + :test_compiler: + :name: compiler + :executable: + - C:\Program Files\IAR Systems\Embedded Workbench 6.0\ + - sh\bin\iccsh.exe + :arguments: + - "-e" + - "--char_is_signed" + - "-Ol" + - "--no_cse" + - "--no_unroll" + - "--no_inline" + - "--no_code_motion" + - "--no_tbaa" + - "--no_scheduling" + - "--no_clustering" + - "--debug" + - "--dlib_config" + - - C:\Program Files\IAR Systems\Embedded Workbench 6.0\ + - sh\inc\DLib_Product.h + - "--double=32" + - "--code_model=huge" + - "--data_model=huge" + - "--core=sh2afpu" + - "--warnings_affect_exit_code" + - "--warnings_are_errors" + - "--mfc" + - "--use_unix_directory_separators" + - "--diag_suppress=Pe161" + - '-I"$": COLLECTION_PATHS_TEST_TOOLCHAIN_INCLUDE' + - '-I"$": COLLECTION_PATHS_TEST_SUPPORT_SOURCE_INCLUDE_VENDOR' + - "-D$: COLLECTION_DEFINES_TEST_AND_VENDOR" + - "${1}" + - "-o ${2}" + :test_linker: + :name: linker + :executable: + - C:\Program Files\IAR Systems\Embedded Workbench 6.0\ + - sh\bin\ilinksh.exe + :arguments: + - "${1}" + - "--redirect __Printf=__PrintfSmall" + - "--redirect __Scanf=__ScanfSmall" + - "--config" + - - C:\Program Files\IAR Systems\Embedded Workbench 6.0\ + - sh\config\generic.icf + - "--config_def _CSTACK_SIZE=0x800" + - "--config_def _HEAP_SIZE=0x800" + - "--config_def _INT_TABLE=0x10" + - "--entry __iar_program_start" + - "--debug_lib" + - "-o ${2}" + :test_fixture: + :name: simulator + :executable: + - C:\Program Files\IAR Systems\Embedded Workbench 6.0\ + - common\bin\CSpyBat.exe + :arguments: + - "--silent" + - - C:\Program Files\IAR Systems\Embedded Workbench 6.0\ + - sh\bin\shproc.dll + - - C:\Program Files\IAR Systems\Embedded Workbench 6.0\ + - sh\bin\shsim.dll + - "${1}" + - "--plugin" + - - C:\Program Files\IAR Systems\Embedded Workbench 6.0\ + - sh\bin\shbat.dll + - "--backend" + - "-B" + - "--core sh2afpu" + - "-p" + - - C:\Program Files\IAR Systems\Embedded Workbench 6.0\ + - sh\config\debugger\io7264.ddf + - "-d" + - sim +:extension: + :object: ".o" + :executable: ".out" +:paths: + :test: + - - C:\Program Files\IAR Systems\Embedded Workbench 6.0\ + - sh\inc\ + - - C:\Program Files\IAR Systems\Embedded Workbench 6.0\ + - sh\inc\c + - src\ + - "..\\src\\" + - testdata/ + - tests\ + - vendor\unity\src\ +:defines: + :test: + - UNITY_SUPPORT_64 + - UNITY_SUPPORT_TEST_CASES diff --git a/test/tests/test_generate_test_runner.rb b/test/tests/test_generate_test_runner.rb index ebf011dc..809b4494 100644 --- a/test/tests/test_generate_test_runner.rb +++ b/test/tests/test_generate_test_runner.rb @@ -786,7 +786,7 @@ :options => { :cmdline_args => true, }, - :cmdline_args => "-n testRunnerGeneratorSma*", + :cmdline_args => "-n=testRunnerGeneratorSma*", :expected => { :to_pass => [ 'test_ThisTestAlwaysPasses', 'spec_ThisTestPassesWhenNormalSetupRan', @@ -1183,15 +1183,7 @@ def runner_test(test, runner, expected, test_defines, cmdline_args, features) link_it(test_base, obj_list) # Execute unit test and generate results file - simulator = build_simulator_fields - cmdline_args ||= "" - executable = $cfg['linker']['bin_files']['destination'] + test_base + $cfg['linker']['bin_files']['extension'] + " #{cmdline_args}" - cmd_str = if simulator.nil? - executable - else - "#{simulator[:command]} #{simulator[:pre_support]} #{executable} #{simulator[:post_support]}" - end - output = execute(cmd_str, true) + output = runtest(test_base, true, cmdline_args) #compare to the expected pass/fail allgood = expected[:to_pass].inject(true) {|s,v| s && verify_match(/#{v}:PASS/, output) } diff --git a/test/tests/testunity.c b/test/tests/testunity.c index 13b6c251..08754465 100644 --- a/test/tests/testunity.c +++ b/test/tests/testunity.c @@ -6029,6 +6029,8 @@ void putcharSpy(int c) putcharSpyBuffer[indexSpyBuffer++] = (char)c; } else putchar((char)c); +#else + (void)c; #endif } @@ -6047,6 +6049,9 @@ void flushSpy(void) void testFailureCountIncrementsAndIsReturnedAtEnd(void) { +#ifndef USING_OUTPUT_SPY + TEST_IGNORE(); +#else UNITY_UINT savedFailures = Unity.TestFailures; Unity.CurrentTestFailed = 1; startPutcharSpy(); /* Suppress output */ @@ -6067,6 +6072,7 @@ void testFailureCountIncrementsAndIsReturnedAtEnd(void) Unity.TestFailures--; endPutcharSpy(); TEST_ASSERT_EQUAL(savedFailures + 1, failures); +#endif } void testCstringsEscapeSequence(void) From 461c6b397837511d13fa9c4acfe47cb2219debd4 Mon Sep 17 00:00:00 2001 From: mvandervoord Date: Sat, 14 Dec 2019 05:18:46 -0500 Subject: [PATCH 207/454] Clean up ci tasks. Get the files to use the build directory again. --- test/rakefile | 4 ++-- test/rakefile_helper.rb | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/test/rakefile b/test/rakefile index 98b165e4..90d824c6 100644 --- a/test/rakefile +++ b/test/rakefile @@ -49,7 +49,7 @@ namespace :test do RSpec::Core::RakeTask.new(:spec) do |t| t.pattern = 'spec/**/*_spec.rb' end - + desc "Generate test summary" task :summary do report_summary @@ -57,7 +57,7 @@ namespace :test do end # Shorthand for many common tasks -task :all => [:clean, :prepare_for_tests, :scripts, :unit, :style, :summary] +task :all => ['test:all'] task :default => [:clobber, :all] task :ci => [:no_color, :default] task :cruise => [:no_color, :default] diff --git a/test/rakefile_helper.rb b/test/rakefile_helper.rb index ff8fc923..e3423ec7 100644 --- a/test/rakefile_helper.rb +++ b/test/rakefile_helper.rb @@ -135,18 +135,20 @@ def build_command_string(hash, values, defines = nil) end def compile(file, defines = []) - out_file = File.basename(file, C_EXTENSION) + $cfg[:extension][:object] + out_file = File.join('build', File.basename(file, C_EXTENSION)) + $cfg[:extension][:object] cmd_str = build_command_string( $cfg[:tools][:test_compiler], [ file, out_file ], defines ) execute(cmd_str) out_file end def link_it(exe_name, obj_list) + exe_name = File.join('build', File.basename(exe_name)) cmd_str = build_command_string( $cfg[:tools][:test_linker], [ obj_list, exe_name ] ) execute(cmd_str) end def runtest(bin_name, ok_to_fail = false, extra_args = nil) + bin_name = File.join('build', File.basename(bin_name)) extra_args = extra_args.nil? ? "" : " " + extra_args if $cfg[:tools][:test_fixture] cmd_str = build_command_string( $cfg[:tools][:test_fixture], [ bin_name, extra_args ] ) @@ -193,7 +195,6 @@ def run_tests(test_files) # Build and execute each unit test test_files.each do |test| - puts "DEBUG: " + test # Drop Out if we're skipping this type of test if $cfg[:skip_tests] From ef0cf704d9f7240e565049181aef1aa6eb421b59 Mon Sep 17 00:00:00 2001 From: mvandervoord Date: Sat, 14 Dec 2019 22:24:30 -0500 Subject: [PATCH 208/454] Centralize all testing to the test folder instead of each subproject. Trigger ALL tests when calling `rake test:all` instead of that being just the core tests. --- .travis.yml | 13 --- extras/fixture/rakefile.rb | 44 ------- extras/fixture/rakefile_helper.rb | 183 ----------------------------- extras/memory/rakefile.rb | 45 ------- extras/memory/rakefile_helper.rb | 187 ------------------------------ src/unity.c | 2 +- src/unity_internals.h | 3 +- test/Makefile | 3 +- test/rakefile | 30 ++++- test/rakefile_helper.rb | 94 ++++++++++++--- 10 files changed, 113 insertions(+), 491 deletions(-) delete mode 100644 extras/fixture/rakefile.rb delete mode 100644 extras/fixture/rakefile_helper.rb delete mode 100644 extras/memory/rakefile.rb delete mode 100644 extras/memory/rakefile_helper.rb diff --git a/.travis.yml b/.travis.yml index 718fe16d..f8bbd556 100644 --- a/.travis.yml +++ b/.travis.yml @@ -17,16 +17,3 @@ install: - gem install rubocop -v 0.57.2 script: - cd test && rake ci - - make -s - - make -s DEBUG=-m32 #32-bit architecture with 64-bit support - - make -s DEBUG=-m32 UNITY_SUPPORT_64= #32-bit build without 64-bit types - - make -s UNITY_INCLUDE_DOUBLE= # without double - - cd ../extras/fixture/test && rake ci - - make -s default noStdlibMalloc - - make -s C89 - - cd ../../../extras/memory/test && rake ci - - make -s default noStdlibMalloc - - make -s C89 - - cd ../../../examples/example_1 && make -s ci - - cd ../example_2 && make -s ci - - cd ../example_3 && rake diff --git a/extras/fixture/rakefile.rb b/extras/fixture/rakefile.rb deleted file mode 100644 index f7465601..00000000 --- a/extras/fixture/rakefile.rb +++ /dev/null @@ -1,44 +0,0 @@ -# ========================================== -# Unity Project - A Test Framework for C -# Copyright (c) 2007 Mike Karlesky, Mark VanderVoord, Greg Williams -# [Released under MIT License. Please refer to license.txt for details] -# ========================================== - -require 'rake' -require 'rake/clean' -require 'rake/testtask' -require_relative 'rakefile_helper' - -TEMP_DIRS = [ - File.join(__dir__, 'build') -].freeze - -TEMP_DIRS.each do |dir| - directory(dir) - CLOBBER.include(dir) -end - -task prepare_for_tests: TEMP_DIRS - -# Load default configuration, for now -DEFAULT_CONFIG_FILE = 'gcc_auto_stdint.yml'.freeze -configure_toolchain(DEFAULT_CONFIG_FILE) - -task unit: [:prepare_for_tests] do - run_tests -end - -desc 'Build and test Unity Framework' -task all: %i[clean unit] -task default: %i[clobber all] -task ci: %i[no_color default] -task cruise: %i[no_color default] - -desc 'Load configuration' -task :config, :config_file do |_t, args| - configure_toolchain(args[:config_file]) -end - -task :no_color do - $colour_output = false -end diff --git a/extras/fixture/rakefile_helper.rb b/extras/fixture/rakefile_helper.rb deleted file mode 100644 index 4de82462..00000000 --- a/extras/fixture/rakefile_helper.rb +++ /dev/null @@ -1,183 +0,0 @@ -# ========================================== -# Unity Project - A Test Framework for C -# Copyright (c) 2007 Mike Karlesky, Mark VanderVoord, Greg Williams -# [Released under MIT License. Please refer to license.txt for details] -# ========================================== - -require 'yaml' -require 'fileutils' -require 'rbconfig' -require_relative '../../auto/unity_test_summary' -require_relative '../../auto/generate_test_runner' -require_relative '../../auto/colour_reporter' - -$is_windows = (RbConfig::CONFIG['host_os'] =~ /mswin|mingw|cygwin/) - -C_EXTENSION = '.c'.freeze - -def load_configuration(config_file) - return if $configured - - $cfg_file = "#{__dir__}/../../test/targets/#{config_file}" unless config_file =~ /[\\|\/]/ - $cfg = YAML.load(File.read($cfg_file)) - $colour_output = false unless $cfg['colour'] - $configured = true if config_file != DEFAULT_CONFIG_FILE -end - -def configure_clean - CLEAN.include($cfg['compiler']['build_path'] + '*.*') unless $cfg['compiler']['build_path'].nil? -end - -def configure_toolchain(config_file = DEFAULT_CONFIG_FILE) - config_file += '.yml' unless config_file =~ /\.yml$/ - config_file = config_file unless config_file =~ /[\\|\/]/ - load_configuration(config_file) - configure_clean -end - -def tackit(strings) - result = if strings.is_a?(Array) - "\"#{strings.join}\"" - else - strings - end - result -end - -def squash(prefix, items) - result = '' - items.each { |item| result += " #{prefix}#{tackit(item)}" } - result -end - -def build_compiler_fields - command = tackit($cfg['compiler']['path']) - defines = if $cfg['compiler']['defines']['items'].nil? - '' - else - squash($cfg['compiler']['defines']['prefix'], $cfg['compiler']['defines']['items']) - end - options = squash('', $cfg['compiler']['options']) - includes = squash($cfg['compiler']['includes']['prefix'], $cfg['compiler']['includes']['items']) - includes = includes.gsub(/\\ /, ' ').gsub(/\\\"/, '"').gsub(/\\$/, '') # Remove trailing slashes (for IAR) - - { command: command, defines: defines, options: options, includes: includes } -end - -def compile(file, _defines = []) - compiler = build_compiler_fields - unity_include = $cfg['compiler']['includes']['prefix'] + '../../src' - cmd_str = "#{compiler[:command]}#{compiler[:defines]}#{compiler[:options]}#{compiler[:includes]} #{unity_include} #{file} " \ - "#{$cfg['compiler']['object_files']['prefix']}#{$cfg['compiler']['object_files']['destination']}" \ - "#{File.basename(file, C_EXTENSION)}#{$cfg['compiler']['object_files']['extension']}" - - execute(cmd_str) -end - -def build_linker_fields - command = tackit($cfg['linker']['path']) - options = if $cfg['linker']['options'].nil? - '' - else - squash('', $cfg['linker']['options']) - end - includes = if $cfg['linker']['includes'].nil? || $cfg['linker']['includes']['items'].nil? - '' - else - squash($cfg['linker']['includes']['prefix'], $cfg['linker']['includes']['items']) - end.gsub(/\\ /, ' ').gsub(/\\\"/, '"').gsub(/\\$/, '') # Remove trailing slashes (for IAR) - - { command: command, options: options, includes: includes } -end - -def link_it(exe_name, obj_list) - linker = build_linker_fields - cmd_str = "#{linker[:command]}#{linker[:options]}#{linker[:includes]} " + - (obj_list.map { |obj| "#{$cfg['linker']['object_files']['path']}#{obj} " }).join + - $cfg['linker']['bin_files']['prefix'] + ' ' + - $cfg['linker']['bin_files']['destination'] + - exe_name + $cfg['linker']['bin_files']['extension'] - execute(cmd_str) -end - -def build_simulator_fields - return nil if $cfg['simulator'].nil? - - command = if $cfg['simulator']['path'].nil? - '' - else - (tackit($cfg['simulator']['path']) + ' ') - end - pre_support = if $cfg['simulator']['pre_support'].nil? - '' - else - squash('', $cfg['simulator']['pre_support']) - end - post_support = if $cfg['simulator']['post_support'].nil? - '' - else - squash('', $cfg['simulator']['post_support']) - end - { command: command, pre_support: pre_support, post_support: post_support } -end - -def execute(command_string, verbose = true) - report command_string - output = `#{command_string}`.chomp - report(output) if verbose && !output.nil? && !output.empty? - - raise "Command failed. (Returned #{$?.exitstatus})" if $?.exitstatus != 0 - - output -end - -def report_summary - summary = UnityTestSummary.new - summary.root = __dir__ - results_glob = "#{$cfg['compiler']['build_path']}*.test*" - results_glob.tr!('\\', '/') - results = Dir[results_glob] - summary.targets = results - summary.run -end - -def run_tests - report 'Running Unity system tests...' - - # Tack on TEST define for compiling unit tests - load_configuration($cfg_file) - test_defines = ['TEST'] - $cfg['compiler']['defines']['items'] = [] if $cfg['compiler']['defines']['items'].nil? - $cfg['compiler']['defines']['items'] << 'UNITY_FIXTURE_NO_EXTRAS' - - # Get a list of all source files needed - src_files = Dir["#{__dir__}/src/*.c"] - src_files += Dir["#{__dir__}/test/*.c"] - src_files += Dir["#{__dir__}/test/main/*.c"] - src_files << '../../src/unity.c' - - # Build object files - src_files.each { |f| compile(f, test_defines) } - obj_list = src_files.map { |f| File.basename(f.ext($cfg['compiler']['object_files']['extension'])) } - - # Link the test executable - test_base = 'framework_test' - link_it(test_base, obj_list) - - # Execute unit test and generate results file - simulator = build_simulator_fields - executable = $cfg['linker']['bin_files']['destination'] + test_base + $cfg['linker']['bin_files']['extension'] - cmd_str = if simulator.nil? - executable + ' -v -r' - else - "#{simulator[:command]} #{simulator[:pre_support]} #{executable} #{simulator[:post_support]}" - end - output = execute(cmd_str) - test_results = $cfg['compiler']['build_path'] + test_base - test_results += if output.match(/OK$/m).nil? - '.testfail' - else - '.testpass' - end - File.open(test_results, 'w') { |f| f.print output } -end diff --git a/extras/memory/rakefile.rb b/extras/memory/rakefile.rb deleted file mode 100644 index 328f3c68..00000000 --- a/extras/memory/rakefile.rb +++ /dev/null @@ -1,45 +0,0 @@ -# ========================================== -# Unity Project - A Test Framework for C -# Copyright (c) 2007 Mike Karlesky, Mark VanderVoord, Greg Williams -# [Released under MIT License. Please refer to license.txt for details] -# ========================================== - -require 'rake' -require 'rake/clean' -require 'rake/testtask' -require_relative 'rakefile_helper' - -TEMP_DIRS = [ - File.join(__dir__, 'build') -].freeze - -TEMP_DIRS.each do |dir| - directory(dir) - CLOBBER.include(dir) -end - -task prepare_for_tests: TEMP_DIRS - -# Load default configuration, for now -DEFAULT_CONFIG_FILE = 'gcc_auto_stdint.yml'.freeze -configure_toolchain(DEFAULT_CONFIG_FILE) - -task unit: [:prepare_for_tests] do - run_tests(false) - run_tests(true) -end - -desc 'Build and test Unity Framework' -task all: %i[clean unit] -task default: %i[clobber all] -task ci: %i[no_color default] -task cruise: %i[no_color default] - -desc 'Load configuration' -task :config, :config_file do |_t, args| - configure_toolchain(args[:config_file]) -end - -task :no_color do - $colour_output = false -end diff --git a/extras/memory/rakefile_helper.rb b/extras/memory/rakefile_helper.rb deleted file mode 100644 index 26ce71d8..00000000 --- a/extras/memory/rakefile_helper.rb +++ /dev/null @@ -1,187 +0,0 @@ -# ========================================== -# Unity Project - A Test Framework for C -# Copyright (c) 2007 Mike Karlesky, Mark VanderVoord, Greg Williams -# [Released under MIT License. Please refer to license.txt for details] -# ========================================== - -require 'yaml' -require 'fileutils' -require 'rbconfig' -require_relative '../../auto/unity_test_summary' -require_relative '../../auto/generate_test_runner' -require_relative '../../auto/colour_reporter' - -$is_windows = (RbConfig::CONFIG['host_os'] =~ /mswin|mingw|cygwin/) - -C_EXTENSION = '.c'.freeze - -def load_configuration(config_file) - return if $configured - - $cfg_file = "#{__dir__}/../../test/targets/#{config_file}" unless config_file =~ /[\\|\/]/ - $cfg = YAML.load(File.read($cfg_file)) - $colour_output = false unless $cfg['colour'] - $configured = true if config_file != DEFAULT_CONFIG_FILE -end - -def configure_clean - CLEAN.include($cfg['compiler']['build_path'] + '*.*') unless $cfg['compiler']['build_path'].nil? -end - -def configure_toolchain(config_file = DEFAULT_CONFIG_FILE) - config_file += '.yml' unless config_file =~ /\.yml$/ - config_file = config_file unless config_file =~ /[\\|\/]/ - load_configuration(config_file) - configure_clean -end - -def tackit(strings) - result = if strings.is_a?(Array) - "\"#{strings.join}\"" - else - strings - end - result -end - -def squash(prefix, items) - result = '' - items.each { |item| result += " #{prefix}#{tackit(item)}" } - result -end - -def build_compiler_fields - command = tackit($cfg['compiler']['path']) - defines = if $cfg['compiler']['defines']['items'].nil? - '' - else - decl = if $is_windows - 'UNITY_OUTPUT_CHAR_HEADER_DECLARATION=UnityOutputCharSpy_OutputChar(int)' - else - 'UNITY_OUTPUT_CHAR_HEADER_DECLARATION=UnityOutputCharSpy_OutputChar\(int\)' - end - squash($cfg['compiler']['defines']['prefix'], $cfg['compiler']['defines']['items'] + ['UNITY_OUTPUT_CHAR=UnityOutputCharSpy_OutputChar'] + [decl]) - end - options = squash('', $cfg['compiler']['options']) - includes = squash($cfg['compiler']['includes']['prefix'], $cfg['compiler']['includes']['items']) - includes = includes.gsub(/\\ /, ' ').gsub(/\\\"/, '"').gsub(/\\$/, '') # Remove trailing slashes (for IAR) - - { command: command, defines: defines, options: options, includes: includes } -end - -def compile(file, _defines = []) - compiler = build_compiler_fields - unity_include = $cfg['compiler']['includes']['prefix'] + '../../src' - cmd_str = "#{compiler[:command]}#{compiler[:defines]}#{compiler[:options]}#{compiler[:includes]} #{unity_include} #{file} " \ - "#{$cfg['compiler']['object_files']['prefix']}#{$cfg['compiler']['object_files']['destination']}" \ - "#{File.basename(file, C_EXTENSION)}#{$cfg['compiler']['object_files']['extension']}" - - execute(cmd_str) -end - -def build_linker_fields - command = tackit($cfg['linker']['path']) - options = if $cfg['linker']['options'].nil? - '' - else - squash('', $cfg['linker']['options']) - end - includes = if $cfg['linker']['includes'].nil? || $cfg['linker']['includes']['items'].nil? - '' - else - squash($cfg['linker']['includes']['prefix'], $cfg['linker']['includes']['items']) - end.gsub(/\\ /, ' ').gsub(/\\\"/, '"').gsub(/\\$/, '') # Remove trailing slashes (for IAR) - - { command: command, options: options, includes: includes } -end - -def link_it(exe_name, obj_list) - linker = build_linker_fields - cmd_str = "#{linker[:command]}#{linker[:options]}#{linker[:includes]} " + - (obj_list.map { |obj| "#{$cfg['linker']['object_files']['path']}#{obj} " }).join + - $cfg['linker']['bin_files']['prefix'] + ' ' + - $cfg['linker']['bin_files']['destination'] + - exe_name + $cfg['linker']['bin_files']['extension'] - execute(cmd_str) -end - -def build_simulator_fields - return nil if $cfg['simulator'].nil? - - command = if $cfg['simulator']['path'].nil? - '' - else - (tackit($cfg['simulator']['path']) + ' ') - end - pre_support = if $cfg['simulator']['pre_support'].nil? - '' - else - squash('', $cfg['simulator']['pre_support']) - end - post_support = if $cfg['simulator']['post_support'].nil? - '' - else - squash('', $cfg['simulator']['post_support']) - end - { command: command, pre_support: pre_support, post_support: post_support } -end - -def execute(command_string, verbose = true) - report command_string - output = `#{command_string}`.chomp - report(output) if verbose && !output.nil? && !output.empty? - - raise "Command failed. (Returned #{$?.exitstatus})" if $?.exitstatus != 0 - - output -end - -def report_summary - summary = UnityTestSummary.new - summary.root = __dir__ - results_glob = "#{$cfg['compiler']['build_path']}*.test*" - results_glob.tr!('\\', '/') - results = Dir[results_glob] - summary.targets = results - summary.run -end - -def run_tests(exclude_stdlib = false) - report 'Running Unity system tests...' - - # Tack on TEST define for compiling unit tests - load_configuration($cfg_file) - test_defines = ['TEST'] - $cfg['compiler']['defines']['items'] = [] if $cfg['compiler']['defines']['items'].nil? - $cfg['compiler']['defines']['items'] << 'UNITY_EXCLUDE_STDLIB_MALLOC' if exclude_stdlib - - # Get a list of all source files needed - src_files = Dir["#{__dir__}/src/*.c"] - src_files += Dir["#{__dir__}/test/*.c"] - src_files << '../../src/unity.c' - - # Build object files - src_files.each { |f| compile(f, test_defines) } - obj_list = src_files.map { |f| File.basename(f.ext($cfg['compiler']['object_files']['extension'])) } - - # Link the test executable - test_base = 'framework_test' - link_it(test_base, obj_list) - - # Execute unit test and generate results file - simulator = build_simulator_fields - executable = $cfg['linker']['bin_files']['destination'] + test_base + $cfg['linker']['bin_files']['extension'] - cmd_str = if simulator.nil? - executable + ' -v -r' - else - "#{simulator[:command]} #{simulator[:pre_support]} #{executable} #{simulator[:post_support]}" - end - output = execute(cmd_str) - test_results = $cfg['compiler']['build_path'] + test_base - test_results += if output.match(/OK$/m).nil? - '.testfail' - else - '.testpass' - end - File.open(test_results, 'w') { |f| f.print output } -end diff --git a/src/unity.c b/src/unity.c index 55af324c..253c2cf4 100644 --- a/src/unity.c +++ b/src/unity.c @@ -1801,7 +1801,7 @@ void UnityMessage(const char* msg, const UNITY_LINE_TYPE line) /*-----------------------------------------------*/ /* If we have not defined our own test runner, then include our default test runner to make life easier */ -#ifdef UNITY_SKIP_DEFAULT_RUNNER +#ifndef UNITY_SKIP_DEFAULT_RUNNER void UnityDefaultTestRun(UnityTestFunction Func, const char* FuncName, const int FuncLineNum) { Unity.CurrentTestName = FuncName; diff --git a/src/unity_internals.h b/src/unity_internals.h index fae40184..f61cd33d 100644 --- a/src/unity_internals.h +++ b/src/unity_internals.h @@ -481,8 +481,9 @@ void UnitySetTestFile(const char* filename); void UnityConcludeTest(void); #ifndef RUN_TEST -#define UNITY_SKIP_DEFAULT_RUNNER void UnityDefaultTestRun(UnityTestFunction Func, const char* FuncName, const int FuncLineNum); +#else +#define UNITY_SKIP_DEFAULT_RUNNER #endif /*------------------------------------------------------- diff --git a/test/Makefile b/test/Makefile index 7803f386..e6ca9e0a 100644 --- a/test/Makefile +++ b/test/Makefile @@ -7,7 +7,8 @@ E = -Weverything CFLAGS += $E -Wno-unknown-warning-option -Wno-missing-prototypes CFLAGS += -Wno-unused-macros -Wno-padded -Wno-missing-noreturn endif -CFLAGS += -std=c99 -pedantic -Wall -Wextra -Wconversion -Werror +CFLAGS += -std=c99 -pedantic -Wall -Wextra -Werror +#CFLAGS += -Wconversion #disabled because if falsely complains about the isinf and isnan macros CFLAGS += -Wno-switch-enum -Wno-double-promotion CFLAGS += -Wbad-function-cast -Wcast-qual -Wold-style-definition -Wshadow -Wstrict-overflow \ -Wstrict-prototypes -Wswitch-default -Wundef diff --git a/test/rakefile b/test/rakefile index 90d824c6..92399575 100644 --- a/test/rakefile +++ b/test/rakefile @@ -5,6 +5,7 @@ # ========================================== $verbose = false +$extra_paths = [] require 'rake' require 'rake/clean' @@ -29,9 +30,10 @@ include RakefileHelpers DEFAULT_CONFIG_FILE = 'gcc_auto_stdint.yml' configure_toolchain(DEFAULT_CONFIG_FILE) +############# ALL THE SELF-TESTS WE CAN PERFORM namespace :test do desc "Build and test Unity" - task :all => [:clean, :prepare_for_tests, 'test:scripts', 'test:unit', :style, 'test:summary'] + task :all => [:clean, :prepare_for_tests, 'test:scripts', 'test:unit', :style, 'test:make', 'test:fixture', 'test:memory', 'test:summary'] desc "Test unity with its own unit tests" task :unit => [:prepare_for_tests] do @@ -45,6 +47,28 @@ namespace :test do end end + desc "Test unity triggered from make" + task :make => [:prepare_for_tests] do + run_make_tests() + end + + desc "Test unity fixture addon" + task :fixture => [:prepare_for_tests] do + test_fixtures() + end + + desc "Test unity memory addon" + task :memory => [:prepare_for_tests] do + test_memory() + end + + desc "Test unity examples" + task :examples => [:prepare_for_tests] do + execute("cd ../examples/example_1 && make -s ci", false) + execute("cd ../examples/example_2 && make -s ci", false) + execute("cd ../examples/example_3 && rake", false) + end + desc "Run all rspecs" RSpec::Core::RakeTask.new(:spec) do |t| t.pattern = 'spec/**/*_spec.rb' @@ -56,11 +80,10 @@ namespace :test do end end -# Shorthand for many common tasks +###################### Shorthand for many common tasks task :all => ['test:all'] task :default => [:clobber, :all] task :ci => [:no_color, :default] -task :cruise => [:no_color, :default] desc "Load configuration" task :config, :config_file do |t, args| @@ -75,6 +98,7 @@ task :verbose do $verbose = true end +################### CODING STYLE VALIDATION namespace :style do desc "Check style" task :check do diff --git a/test/rakefile_helper.rb b/test/rakefile_helper.rb index e3423ec7..2e6b13ef 100644 --- a/test/rakefile_helper.rb +++ b/test/rakefile_helper.rb @@ -103,13 +103,13 @@ def build_command_string(hash, values, defines = nil) elsif arg.include? ': COLLECTION_PATHS_TEST_SUPPORT_SOURCE_INCLUDE_VENDOR' pattern = arg.gsub(': COLLECTION_PATHS_TEST_SUPPORT_SOURCE_INCLUDE_VENDOR','') - [ 'src', File.join('tests'), File.join('testdata'), $cfg[:paths][:support] ].flatten.uniq.compact.each do |f| + [ $extra_paths, 'src', File.join('tests'), File.join('testdata'), $cfg[:paths][:support] ].flatten.uniq.compact.each do |f| args << pattern.gsub(/\$/,f) end elsif arg.include? ': COLLECTION_DEFINES_TEST_AND_VENDOR' pattern = arg.gsub(': COLLECTION_DEFINES_TEST_AND_VENDOR','') - [ 'TEST', $cfg[:defines][:test], defines ].flatten.uniq.compact.each do |f| + [ $cfg[:defines][:test], defines ].flatten.uniq.compact.each do |f| args << pattern.gsub(/\$/,f) end @@ -181,15 +181,75 @@ def execute(command_string, ok_to_fail = false) def report_summary summary = UnityTestSummary.new summary.root = __dir__ - results_glob = "build/*.test*" + results_glob = File.join('build','*.test*') results_glob.tr!('\\', '/') results = Dir[results_glob] summary.targets = results report summary.run end + def save_test_results(test_base, output) + test_results = File.join('build',test_base) + if output.match(/OK$/m).nil? + test_results += '.testfail' + else + report output unless $verbose # Verbose already prints this line, as does a failure + test_results += '.testpass' + end + File.open(test_results, 'w') { |f| f.print output } + end + + def test_fixtures() + report "\nRunning Fixture Addon" + + # Get a list of all source files needed + src_files = Dir[File.join('..','extras','fixture','src','*.c')] + src_files += Dir[File.join('..','extras','fixture','test','*.c')] + src_files += Dir[File.join('..','extras','fixture','test','main','*.c')] + src_files += Dir[File.join('..','extras','memory','src','*.c')] + src_files << File.join('..','src','unity.c') + + # Build object files + $extra_paths = [File.join('..','extras','fixture','src'), File.join('..','extras','memory','src')] + obj_list = src_files.map { |f| compile(f, ['UNITY_SKIP_DEFAULT_RUNNER', 'UNITY_FIXTURE_NO_EXTRAS']) } + + # Link the test executable + test_base = File.basename('framework_test', C_EXTENSION) + link_it(test_base, obj_list) + + # Run and collect output + output = runtest(test_base + " -v -r") + save_test_results(test_base, output) + end + + def test_memory() + { 'w_malloc' => [], + 'wo_malloc' => ['UNITY_EXCLUDE_STDLIB_MALLOC'] + }.each_pair do |name, defs| + report "\nRunning Memory Addon #{name}" + + # Get a list of all source files needed + src_files = Dir[File.join('..','extras','memory','src','*.c')] + src_files += Dir[File.join('..','extras','memory','test','*.c')] + src_files += Dir[File.join('..','extras','memory','test','main','*.c')] + src_files << File.join('..','src','unity.c') + + # Build object files + $extra_paths = [File.join('..','extras','memory','src')] + obj_list = src_files.map { |f| compile(f, defs) } + + # Link the test executable + test_base = File.basename("memory_test_#{name}", C_EXTENSION) + link_it(test_base, obj_list) + + # Run and collect output + output = runtest(test_base) + save_test_results(test_base, output) + end + end + def run_tests(test_files) - report 'Running Unity system tests...' + report "\nRunning Unity system tests" include_dirs = local_include_dirs @@ -218,7 +278,7 @@ def run_tests(test_files) # Build the test runner (generate if configured to do so) test_base = File.basename(test, C_EXTENSION) runner_name = test_base + '_Runner.c' - runner_path = 'build/' + runner_name + runner_path = File.join('build',runner_name) options = $cfg[:unity] options[:use_param_tests] = test =~ /parameterized/ ? true : false @@ -233,14 +293,22 @@ def run_tests(test_files) # Execute unit test and generate results file output = runtest(test_base) - test_results = 'build/' + test_base - if output.match(/OK$/m).nil? - test_results += '.testfail' - else - report output unless $verbose # Verbose already prints this line, as does a failure - test_results += '.testpass' - end - File.open(test_results, 'w') { |f| f.print output } + save_test_results(test_base, output) + end + end + + def run_make_tests() + [ "make -s", # test with all defaults + "make -s DEBUG=-m32", # test 32-bit architecture with 64-bit support + "make -s DEBUG=-m32 UNITY_SUPPORT_64=", # test 32-bit build without 64-bit types + "make -s UNITY_INCLUDE_DOUBLE= ", # test without double + "cd #{File.join("..","extras","fixture")} && make -s default noStdlibMalloc", + "cd #{File.join("..","extras","fixture")} && make -s C89", + "cd #{File.join("..","extras","memory")} && make -s default noStdlibMalloc", + "cd #{File.join("..","extras","memory")} && make -s C89", + ].each do |cmd| + report "Testing '#{cmd}'" + execute(cmd, false) end end end From fb45e3010bbe3e529314dd7da93394e9749aa056 Mon Sep 17 00:00:00 2001 From: mvandervoord Date: Sat, 14 Dec 2019 22:38:52 -0500 Subject: [PATCH 209/454] the makefiles in the extras are in the test dirs. --- test/rakefile_helper.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/rakefile_helper.rb b/test/rakefile_helper.rb index 2e6b13ef..f3cbd5c9 100644 --- a/test/rakefile_helper.rb +++ b/test/rakefile_helper.rb @@ -302,10 +302,10 @@ def run_make_tests() "make -s DEBUG=-m32", # test 32-bit architecture with 64-bit support "make -s DEBUG=-m32 UNITY_SUPPORT_64=", # test 32-bit build without 64-bit types "make -s UNITY_INCLUDE_DOUBLE= ", # test without double - "cd #{File.join("..","extras","fixture")} && make -s default noStdlibMalloc", - "cd #{File.join("..","extras","fixture")} && make -s C89", - "cd #{File.join("..","extras","memory")} && make -s default noStdlibMalloc", - "cd #{File.join("..","extras","memory")} && make -s C89", + "cd #{File.join("..","extras","fixture",'test')} && make -s default noStdlibMalloc", + "cd #{File.join("..","extras","fixture",'test')} && make -s C89", + "cd #{File.join("..","extras","memory",'test')} && make -s default noStdlibMalloc", + "cd #{File.join("..","extras","memory",'test')} && make -s C89", ].each do |cmd| report "Testing '#{cmd}'" execute(cmd, false) From 47b630391d30e12d47e0cde3d1abd45aa281c847 Mon Sep 17 00:00:00 2001 From: mvandervoord Date: Sun, 15 Dec 2019 10:07:05 -0500 Subject: [PATCH 210/454] Minor tweak to the way we load includes --- test/rakefile_helper.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/rakefile_helper.rb b/test/rakefile_helper.rb index f3cbd5c9..519e728d 100644 --- a/test/rakefile_helper.rb +++ b/test/rakefile_helper.rb @@ -39,10 +39,10 @@ def unit_test_files end def local_include_dirs - include_dirs = $cfg[:paths][:includes].dup || [] - include_dirs += $cfg[:paths][:source].dup || [] - include_dirs += $cfg[:paths][:test].dup || [] - include_dirs += $cfg[:paths][:support].dup || [] + include_dirs = $cfg[:paths][:includes] || [] + include_dirs += $cfg[:paths][:source] || [] + include_dirs += $cfg[:paths][:test] || [] + include_dirs += $cfg[:paths][:support] || [] include_dirs.delete_if { |dir| dir.is_a?(Array) } include_dirs end From e276e1a4580f60d78d3819ea4ee43a49cffa14ab Mon Sep 17 00:00:00 2001 From: mvandervoord Date: Sun, 15 Dec 2019 10:30:26 -0500 Subject: [PATCH 211/454] Swap order so that CI runs all the makefile tests... but local test:all skips them as mostly redundant and very platform specific. --- test/rakefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/rakefile b/test/rakefile index 92399575..af67fba3 100644 --- a/test/rakefile +++ b/test/rakefile @@ -33,7 +33,7 @@ configure_toolchain(DEFAULT_CONFIG_FILE) ############# ALL THE SELF-TESTS WE CAN PERFORM namespace :test do desc "Build and test Unity" - task :all => [:clean, :prepare_for_tests, 'test:scripts', 'test:unit', :style, 'test:make', 'test:fixture', 'test:memory', 'test:summary'] + task :all => [:clean, :prepare_for_tests, 'test:scripts', 'test:unit', :style, 'test:fixture', 'test:memory', 'test:summary'] desc "Test unity with its own unit tests" task :unit => [:prepare_for_tests] do @@ -83,7 +83,7 @@ end ###################### Shorthand for many common tasks task :all => ['test:all'] task :default => [:clobber, :all] -task :ci => [:no_color, :default] +task :ci => [:no_color, 'test:make', :default] desc "Load configuration" task :config, :config_file do |t, args| From f3b87bb91c8d1b8c1999bc96e718e31d18f43881 Mon Sep 17 00:00:00 2001 From: mvandervoord Date: Sun, 15 Dec 2019 14:36:59 -0500 Subject: [PATCH 212/454] another tweak to how we handle the ci vs local testing. --- test/rakefile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/rakefile b/test/rakefile index af67fba3..09e4e581 100644 --- a/test/rakefile +++ b/test/rakefile @@ -34,6 +34,7 @@ configure_toolchain(DEFAULT_CONFIG_FILE) namespace :test do desc "Build and test Unity" task :all => [:clean, :prepare_for_tests, 'test:scripts', 'test:unit', :style, 'test:fixture', 'test:memory', 'test:summary'] + task :ci => [:clean, :prepare_for_tests, 'test:scripts', 'test:unit', :style, 'test:make', 'test:fixture', 'test:memory', 'test:summary'] desc "Test unity with its own unit tests" task :unit => [:prepare_for_tests] do @@ -81,9 +82,9 @@ namespace :test do end ###################### Shorthand for many common tasks +task :ci => ['test:ci'] task :all => ['test:all'] task :default => [:clobber, :all] -task :ci => [:no_color, 'test:make', :default] desc "Load configuration" task :config, :config_file do |t, args| From 3b5b491860cc747aba1e514c33bf9c35df321882 Mon Sep 17 00:00:00 2001 From: Dom Postorivo Date: Wed, 11 Dec 2019 21:30:18 -0500 Subject: [PATCH 213/454] sub in '_' for '-' in define and test name in module generator --- auto/generate_module.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/auto/generate_module.rb b/auto/generate_module.rb index eb2cebd4..d0477709 100644 --- a/auto/generate_module.rb +++ b/auto/generate_module.rb @@ -25,7 +25,7 @@ { } -void test_%1$s_NeedToImplement(void) +void test_%4$s_NeedToImplement(void) { TEST_IGNORE_MESSAGE("Need to Implement %1$s"); } @@ -208,7 +208,8 @@ def generate(module_name, pattern = nil) f.write("#{file[:boilerplate]}\n" % [file[:name]]) unless file[:boilerplate].nil? f.write(file[:template] % [file[:name], file[:includes].map { |ff| "#include \"#{ff}\"\n" }.join, - file[:name].upcase]) + file[:name].upcase.gsub(/-/, '_'), + file[:name].gsub(/-/, '_')]) end if @options[:update_svn] `svn add \"#{file[:path]}\"` From 04858be38f11c456e838ca656c9e517f3532a92d Mon Sep 17 00:00:00 2001 From: mr-bat Date: Sun, 26 Jan 2020 11:22:07 -0800 Subject: [PATCH 214/454] update copyright message --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index e32fafff..e6e7ea2d 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ Unity Test API ============== [![Unity Build Status](https://api.travis-ci.org/ThrowTheSwitch/Unity.png?branch=master)](https://travis-ci.org/ThrowTheSwitch/Unity) -__Copyright (c) 2007 - 2019 Unity Project by Mike Karlesky, Mark VanderVoord, and Greg Williams__ +__Copyright (c) 2007 - 2020 Unity Project by Mike Karlesky, Mark VanderVoord, and Greg Williams__ Getting Started =============== From 218fa2cbe8a2fe859a5248b8c9933163ab4569af Mon Sep 17 00:00:00 2001 From: Andrei Korigodskii Date: Sun, 2 Feb 2020 22:00:27 +0300 Subject: [PATCH 215/454] Add TEST_RANGE to specify arg ranges in parameterized tests TEST_RANGE([start, stop, step]) generates following runs of the test function: test(start), test(start + step), ..., test(start + n * step), where start + n * step <= stop. The step must be positive. If the test function takes several arguments, the following syntax must be used: TEST_RANGE([arg1_start, arg1_stop, arg1_step], ..., [argN_start, argN_stop, argN_step]) This addresses issues #53 and #144. Reported-by: Alex Rodriguez Reported-by: Hiroaki Yamazoe --- auto/generate_test_runner.rb | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/auto/generate_test_runner.rb b/auto/generate_test_runner.rb index 4944e0be..a6e25cb9 100644 --- a/auto/generate_test_runner.rb +++ b/auto/generate_test_runner.rb @@ -128,7 +128,7 @@ def find_tests(source) lines.each_with_index do |line, _index| # find tests - next unless line =~ /^((?:\s*TEST_CASE\s*\(.*?\)\s*)*)\s*void\s+((?:#{@options[:test_prefix]}).*)\s*\(\s*(.*)\s*\)/m + next unless line =~ /^((?:\s*(?:TEST_CASE|TEST_RANGE)\s*\(.*?\)\s*)*)\s*void\s+((?:#{@options[:test_prefix]}).*)\s*\(\s*(.*)\s*\)/m arguments = Regexp.last_match(1) name = Regexp.last_match(2) @@ -139,6 +139,21 @@ def find_tests(source) if @options[:use_param_tests] && !arguments.empty? args = [] arguments.scan(/\s*TEST_CASE\s*\((.*)\)\s*$/) { |a| args << a[0] } + + arguments.scan(/\s*TEST_RANGE\s*\((.*)\)\s*$/).flatten.each do |range_str| + args += range_str.scan(/\[(-?\d+.?\d*), *(-?\d+.?\d*), *(-?\d+.?\d*)\]/) + .map { |arg_values_str| + arg_values_str.map { |arg_value_str| + (arg_value_str.include? ".") ? arg_value_str.to_f : arg_value_str.to_i + } + }.map { |arg_values| + (arg_values[0]..arg_values[1]).step(arg_values[2]).to_a + }.reduce { |result, arg_range_expanded| + result.product(arg_range_expanded) + }.map { |arg_combinations| + arg_combinations.flatten.join(", ") + } + end end tests_and_line_numbers << { test: name, args: args, call: call, params: params, line_number: 0 } From 8a3a31f7b3d831df75a912902e00cea65849a9f1 Mon Sep 17 00:00:00 2001 From: Michael Date: Sat, 8 Feb 2020 10:30:43 -0800 Subject: [PATCH 216/454] clean up meson support --- examples/example_4/meson.build | 17 ++---- examples/example_4/src/meson.build | 17 ++---- examples/example_4/test/meson.build | 17 ++---- .../example_4/test/test_runners/meson.build | 23 ++++---- meson.build | 56 +++++++------------ src/meson.build | 17 ++---- 6 files changed, 53 insertions(+), 94 deletions(-) diff --git a/examples/example_4/meson.build b/examples/example_4/meson.build index 4bf968cb..f06c3fe3 100644 --- a/examples/example_4/meson.build +++ b/examples/example_4/meson.build @@ -1,14 +1,9 @@ -################################################################################### -# # -# NAME: meson.build # -# # -# AUTHOR: Mike Karlesky, Mark VanderVoord, Greg Williams. # -# WRITTEN BY: Michael Brockus. # -# # -# License: MIT # -# # -################################################################################### - +# +# build script written by : Michael Brockus. +# github repo author: Mike Karlesky, Mark VanderVoord, Greg Williams. +# +# license: MIT +# project('example-4', 'c') unity_dep = dependency('unity', fallback : ['unity', 'unity_dep']) diff --git a/examples/example_4/src/meson.build b/examples/example_4/src/meson.build index 8fac6c4a..10c5735b 100644 --- a/examples/example_4/src/meson.build +++ b/examples/example_4/src/meson.build @@ -1,14 +1,9 @@ -################################################################################### -# # -# NAME: meson.build # -# # -# AUTHOR: Mike Karlesky, Mark VanderVoord, Greg Williams. # -# WRITTEN BY: Michael Brockus. # -# # -# License: MIT # -# # -################################################################################### - +# +# build script written by : Michael Brockus. +# github repo author: Mike Karlesky, Mark VanderVoord, Greg Williams. +# +# license: MIT +# inc_dir = include_directories('.') lib_list = {'a': ['ProductionCode.c' ], 'b': ['ProductionCode2.c']} diff --git a/examples/example_4/test/meson.build b/examples/example_4/test/meson.build index 876a78c1..0e3c72f5 100644 --- a/examples/example_4/test/meson.build +++ b/examples/example_4/test/meson.build @@ -1,12 +1,7 @@ -################################################################################### -# # -# NAME: meson.build # -# # -# AUTHOR: Mike Karlesky, Mark VanderVoord, Greg Williams. # -# WRITTEN BY: Michael Brockus. # -# # -# License: MIT # -# # -################################################################################### - +# +# build script written by : Michael Brockus. +# github repo author: Mike Karlesky, Mark VanderVoord, Greg Williams. +# +# license: MIT +# subdir('test_runners') diff --git a/examples/example_4/test/test_runners/meson.build b/examples/example_4/test/test_runners/meson.build index 33c105f9..f2a43c1b 100644 --- a/examples/example_4/test/test_runners/meson.build +++ b/examples/example_4/test/test_runners/meson.build @@ -1,16 +1,13 @@ -################################################################################### -# # -# NAME: meson.build # -# # -# AUTHOR: Mike Karlesky, Mark VanderVoord, Greg Williams. # -# WRITTEN BY: Michael Brockus. # -# # -# License: MIT # -# # -################################################################################### - -cases = [['TestProductionCode_Runner.c', join_paths('..' ,'TestProductionCode.c')], - ['TestProductionCode2_Runner.c', join_paths('..' ,'TestProductionCode2.c')]] +# +# build script written by : Michael Brockus. +# github repo author: Mike Karlesky, Mark VanderVoord, Greg Williams. +# +# license: MIT +# +cases = [ + ['TestProductionCode_Runner.c', join_paths('..' ,'TestProductionCode.c' )], + ['TestProductionCode2_Runner.c', join_paths('..' ,'TestProductionCode2.c')] + ] test('Running: 01-test-case', executable('01-test-case', cases[0], dependencies: [ a_dep, unity_dep ])) test('Running: 02-test-case', executable('02-test-case', cases[1], dependencies: [ b_dep, unity_dep ])) diff --git a/meson.build b/meson.build index 3b4ddcc0..968e5b13 100644 --- a/meson.build +++ b/meson.build @@ -1,37 +1,29 @@ -################################################################################### -# # -# NAME: meson.build # -# # -# AUTHOR: Mike Karlesky, Mark VanderVoord, Greg Williams. # -# WRITTEN BY: Michael Brockus. # -# # -# License: MIT # -# # -################################################################################### - - - +# +# build script written by : Michael Brockus. +# github repo author: Mike Karlesky, Mark VanderVoord, Greg Williams. +# +# license: MIT +# project('unity', 'c', - license : 'MIT', - meson_version : '>=0.50.0', - default_options: ['warning_level=3', 'werror=true', 'c_std=c11'] + license: 'MIT', + meson_version: '>=0.53.0', + default_options: ['layout=flat', 'warning_level=3', 'werror=true', 'c_std=c11'] ) lang = 'c' cc = meson.get_compiler(lang) - -## # # Meson: Add compiler flags -# -## if cc.get_id() == 'clang' add_project_arguments(cc.get_supported_arguments( [ - '-Wcast-qual', '-Wshadow', '-Wcast-align', '-Wweak-vtables', - '-Wold-style-cast', '-Wpointer-arith', '-Wconversion', - '-Wexit-time-destructors', '-Wglobal-constructors', - '-Wmissing-noreturn', '-Wmissing-prototypes', '-Wno-missing-braces' + '-Wexit-time-destructors', + '-Wglobal-constructors', + '-Wmissing-prototypes', + '-Wmissing-noreturn', + '-Wno-missing-braces', + '-Wold-style-cast', '-Wpointer-arith', '-Wweak-vtables', + '-Wcast-align', '-Wconversion', '-Wcast-qual', '-Wshadow' ] ), language: lang) endif @@ -44,23 +36,13 @@ if cc.get_argument_syntax() == 'gcc' '-Wno-parentheses' , '-Wno-type-limits' , '-Wformat-security' , '-Wunreachable-code' , '-Waggregate-return' , '-Wformat-nonliteral' , - '-Wmissing-prototypes' , '-Wold-style-definition' , '-Wmissing-declarations', '-Wmissing-include-dirs' , - '-Wno-unused-parameter' , '-Wdeclaration-after-statement' - ] - ), language: lang) -endif - -if cc.get_id() == 'msvc' - add_project_arguments(cc.get_supported_arguments( - [ - '/w44265', '/w44061', '/w44062', - '/wd4018', '/wd4146', '/wd4244', - '/wd4305', '/D _CRT_SECURE_NO_WARNINGS' + '-Wno-unused-parameter' ] ), language: lang) endif +# +# Sub directory to project source code subdir('src') - unity_dep = declare_dependency(link_with: unity_lib, include_directories: unity_dir) diff --git a/src/meson.build b/src/meson.build index f5e01465..7ede15af 100644 --- a/src/meson.build +++ b/src/meson.build @@ -1,14 +1,9 @@ -################################################################################### -# # -# NAME: meson.build # -# # -# AUTHOR: Mike Karlesky, Mark VanderVoord, Greg Williams. # -# WRITTEN BY: Michael Brockus. # -# # -# License: MIT # -# # -################################################################################### - +# +# build script written by : Michael Brockus. +# github repo author: Mike Karlesky, Mark VanderVoord, Greg Williams. +# +# license: MIT +# unity_dir = include_directories('.') unity_lib = static_library(meson.project_name(), From 3b80ba73fe530f89260063ad1b3ceb5d8b46b5c0 Mon Sep 17 00:00:00 2001 From: Michael Date: Sat, 8 Feb 2020 10:39:34 -0800 Subject: [PATCH 217/454] add clang to CI file --- .travis.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.travis.yml b/.travis.yml index f8bbd556..315b3a7e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,6 +8,9 @@ matrix: - os: linux dist: trusty compiler: gcc + - os: linux + dist: trusty + compiler: clang before_install: - if [ "$TRAVIS_OS_NAME" == "osx" ]; then rvm install 2.3 && rvm use 2.3 && ruby -v; fi From 3da0b4652c7e355edbbe2a3cddf9dd9c110bc20e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rn=20Villesen=20Christensen?= Date: Fri, 14 Feb 2020 12:31:53 +0100 Subject: [PATCH 218/454] Implement macro TEST_PRINTF: Works like TEST_MESSAGE, but with a format-string. Depends on UnityPrintFormatted (define UNITY_INCLUDE_PRINT_FORMATTED). UnityPrintFormatted has been renamed to UnityPrintF due to changes below. API of UnityPrintFormatted has been changed (hence the rename), but end users (developers) can use the TEST_PRINTF as an almost-drop-in replacement TEST_PRINTF is compatible with the old UnityPrintFormatted API (see below). The behaviour of UnityPrintF has also been changed: - Now it prefixes the outout with test location information Output is marked as INFO. - It adds an EOL. Both behaviours adopted from other output functions. --- src/unity.c | 242 ++++++++++++++++++++++-------------------- src/unity.h | 3 + src/unity_internals.h | 2 +- 3 files changed, 131 insertions(+), 116 deletions(-) diff --git a/src/unity.c b/src/unity.c index 253c2cf4..5e13a720 100644 --- a/src/unity.c +++ b/src/unity.c @@ -146,121 +146,6 @@ void UnityPrint(const char* string) } } } - -/*-----------------------------------------------*/ -#ifdef UNITY_INCLUDE_PRINT_FORMATTED -void UnityPrintFormatted(const char* format, ...) -{ - const char* pch = format; - va_list va; - va_start(va, format); - - if (pch != NULL) - { - while (*pch) - { - /* format identification character */ - if (*pch == '%') - { - pch++; - - if (pch != NULL) - { - switch (*pch) - { - case 'd': - case 'i': - { - const int number = va_arg(va, int); - UnityPrintNumber((UNITY_INT)number); - break; - } -#ifndef UNITY_EXCLUDE_FLOAT_PRINT - case 'f': - case 'g': - { - const double number = va_arg(va, double); - UnityPrintFloat((UNITY_DOUBLE)number); - break; - } -#endif - case 'u': - { - const unsigned int number = va_arg(va, unsigned int); - UnityPrintNumberUnsigned((UNITY_UINT)number); - break; - } - case 'b': - { - const unsigned int number = va_arg(va, unsigned int); - const UNITY_UINT mask = (UNITY_UINT)0 - (UNITY_UINT)1; - UNITY_OUTPUT_CHAR('0'); - UNITY_OUTPUT_CHAR('b'); - UnityPrintMask(mask, (UNITY_UINT)number); - break; - } - case 'x': - case 'X': - case 'p': - { - const unsigned int number = va_arg(va, unsigned int); - UNITY_OUTPUT_CHAR('0'); - UNITY_OUTPUT_CHAR('x'); - UnityPrintNumberHex((UNITY_UINT)number, 8); - break; - } - case 'c': - { - const int ch = va_arg(va, int); - UnityPrintChar((const char *)&ch); - break; - } - case 's': - { - const char * string = va_arg(va, const char *); - UnityPrint(string); - break; - } - case '%': - { - UnityPrintChar(pch); - break; - } - default: - { - /* print the unknown format character */ - UNITY_OUTPUT_CHAR('%'); - UnityPrintChar(pch); - break; - } - } - } - } -#ifdef UNITY_OUTPUT_COLOR - /* print ANSI escape code */ - else if ((*pch == 27) && (*(pch + 1) == '[')) - { - pch += UnityPrintAnsiEscapeString(pch); - continue; - } -#endif - else if (*pch == '\n') - { - UNITY_PRINT_EOL(); - } - else - { - UnityPrintChar(pch); - } - - pch++; - } - } - - va_end(va); -} -#endif /* ! UNITY_INCLUDE_PRINT_FORMATTED */ - /*-----------------------------------------------*/ void UnityPrintLen(const char* string, const UNITY_UINT32 length) { @@ -1731,6 +1616,133 @@ UNITY_INTERNAL_PTR UnityDoubleToPtr(const double num) } #endif +/*----------------------------------------------- + * printf helper function + *-----------------------------------------------*/ +#ifdef UNITY_INCLUDE_PRINT_FORMATTED +static void UnityPrintFVA(const char* format, va_list va) +{ + const char* pch = format; + if (pch != NULL) + { + while (*pch) + { + /* format identification character */ + if (*pch == '%') + { + pch++; + + if (pch != NULL) + { + switch (*pch) + { + case 'd': + case 'i': + { + const int number = va_arg(va, int); + UnityPrintNumber((UNITY_INT)number); + break; + } +#ifndef UNITY_EXCLUDE_FLOAT_PRINT + case 'f': + case 'g': + { + const double number = va_arg(va, double); + UnityPrintFloat((UNITY_DOUBLE)number); + break; + } +#endif + case 'u': + { + const unsigned int number = va_arg(va, unsigned int); + UnityPrintNumberUnsigned((UNITY_UINT)number); + break; + } + case 'b': + { + const unsigned int number = va_arg(va, unsigned int); + const UNITY_UINT mask = (UNITY_UINT)0 - (UNITY_UINT)1; + UNITY_OUTPUT_CHAR('0'); + UNITY_OUTPUT_CHAR('b'); + UnityPrintMask(mask, (UNITY_UINT)number); + break; + } + case 'x': + case 'X': + case 'p': + { + const unsigned int number = va_arg(va, unsigned int); + UNITY_OUTPUT_CHAR('0'); + UNITY_OUTPUT_CHAR('x'); + UnityPrintNumberHex((UNITY_UINT)number, 8); + break; + } + case 'c': + { + const int ch = va_arg(va, int); + UnityPrintChar((const char *)&ch); + break; + } + case 's': + { + const char * string = va_arg(va, const char *); + UnityPrint(string); + break; + } + case '%': + { + UnityPrintChar(pch); + break; + } + default: + { + /* print the unknown format character */ + UNITY_OUTPUT_CHAR('%'); + UnityPrintChar(pch); + break; + } + } + } + } +#ifdef UNITY_OUTPUT_COLOR + /* print ANSI escape code */ + else if ((*pch == 27) && (*(pch + 1) == '[')) + { + pch += UnityPrintAnsiEscapeString(pch); + continue; + } +#endif + else if (*pch == '\n') + { + UNITY_PRINT_EOL(); + } + else + { + UnityPrintChar(pch); + } + + pch++; + } + } +} + +void UnityPrintF(const UNITY_LINE_TYPE line, const char* format, ...) +{ + UnityTestResultsBegin(Unity.TestFile, line); + UnityPrint("INFO"); + if(format != NULL) + { + UnityPrint(": "); + va_list va; + va_start(va, format); + UnityPrintFVA(format, va); + va_end(va); + } + UNITY_PRINT_EOL(); +} +#endif /* ! UNITY_INCLUDE_PRINT_FORMATTED */ + + /*----------------------------------------------- * Control Functions *-----------------------------------------------*/ diff --git a/src/unity.h b/src/unity.h index 34d7f93a..7c23e8d5 100644 --- a/src/unity.h +++ b/src/unity.h @@ -104,6 +104,9 @@ void verifyTest(void); #define TEST_IGNORE() UNITY_TEST_IGNORE(__LINE__, NULL) #define TEST_MESSAGE(message) UnityMessage((message), __LINE__) #define TEST_ONLY() +#ifdef UNITY_INCLUDE_PRINT_FORMATTED +#define TEST_PRINTF(message, ...) UnityPrintF(__LINE__, (message), __VA_ARGS__) +#endif /* It is not necessary for you to call PASS. A PASS condition is assumed if nothing fails. * This method allows you to abort a test immediately with a PASS state, ignoring the remainder of the test. */ diff --git a/src/unity_internals.h b/src/unity_internals.h index f61cd33d..6fccf8b4 100644 --- a/src/unity_internals.h +++ b/src/unity_internals.h @@ -515,7 +515,7 @@ void UnityDefaultTestRun(UnityTestFunction Func, const char* FuncName, const int void UnityPrint(const char* string); #ifdef UNITY_INCLUDE_PRINT_FORMATTED -void UnityPrintFormatted(const char* format, ...); +void UnityPrintF(const UNITY_LINE_TYPE line, const char* format, ...); #endif void UnityPrintLen(const char* string, const UNITY_UINT32 length); From 22a047ebb5a8d0c39eeab6bd599d97c1a3d04c57 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rn=20Villesen=20Christensen?= Date: Fri, 14 Feb 2020 12:35:41 +0100 Subject: [PATCH 219/454] Updated documentation and examples to reflect the TEST_PRINTF function. --- docs/UnityConfigurationGuide.md | 24 ++++++++++++------------ examples/unity_config.h | 4 ++-- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/docs/UnityConfigurationGuide.md b/docs/UnityConfigurationGuide.md index 8155a0f6..7633e0d1 100644 --- a/docs/UnityConfigurationGuide.md +++ b/docs/UnityConfigurationGuide.md @@ -282,18 +282,18 @@ _Example:_ #define UNITY_INCLUDE_PRINT_FORMATTED int a = 0xfab1; -UnityPrintFormatted("Decimal %d\n", -7); -UnityPrintFormatted("Unsigned %u\n", 987); -UnityPrintFormatted("Float %f\n", 3.1415926535897932384); -UnityPrintFormatted("Binary %b\n", 0xA); -UnityPrintFormatted("Hex %X\n", 0xFAB); -UnityPrintFormatted("Pointer %p\n", &a); -UnityPrintFormatted("Character %c\n", 'F'); -UnityPrintFormatted("String %s\n", "My string"); -UnityPrintFormatted("Percent %%\n"); -UnityPrintFormatted("Color Red \033[41mFAIL\033[00m\n"); -UnityPrintFormatted("\n"); -UnityPrintFormatted("Multiple (%d) (%i) (%u) (%x)\n", -100, 0, 200, 0x12345); +TEST_PRINTF("Decimal %d\n", -7); +TEST_PRINTF("Unsigned %u\n", 987); +TEST_PRINTF("Float %f\n", 3.1415926535897932384); +TEST_PRINTF("Binary %b\n", 0xA); +TEST_PRINTF("Hex %X\n", 0xFAB); +TEST_PRINTF("Pointer %p\n", &a); +TEST_PRINTF("Character %c\n", 'F'); +TEST_PRINTF("String %s\n", "My string"); +TEST_PRINTF("Percent %%\n"); +TEST_PRINTF("Color Red \033[41mFAIL\033[00m\n"); +TEST_PRINTF("\n"); +TEST_PRINTF("Multiple (%d) (%i) (%u) (%x)\n", -100, 0, 200, 0x12345); ``` diff --git a/examples/unity_config.h b/examples/unity_config.h index 9127bcca..fc6cdb05 100644 --- a/examples/unity_config.h +++ b/examples/unity_config.h @@ -186,8 +186,8 @@ */ /* #define UNITY_EXCLUDE_STDDEF_H */ -/* Define this to enable the unity formatted print function: - * "UnityPrintFormatted" +/* Define this to enable the unity formatted print macro: + * "TEST_PRINTF" */ /* #define UNITY_INCLUDE_PRINT_FORMATTED */ From bad429428d5adb2d10cf7fdaaee59aa99e91cf9b Mon Sep 17 00:00:00 2001 From: mvandervoord Date: Mon, 16 Mar 2020 15:04:40 -0400 Subject: [PATCH 220/454] Add assertion for checking empty null-terminated arrays. This is particularly useful for check c strings. --- docs/UnityAssertionsReference.md | 9 +++++++++ src/unity.h | 4 ++++ src/unity_internals.h | 2 ++ test/tests/testunity.c | 27 +++++++++++++++++++++++++++ 4 files changed, 42 insertions(+) diff --git a/docs/UnityAssertionsReference.md b/docs/UnityAssertionsReference.md index a395d614..1ef06b32 100644 --- a/docs/UnityAssertionsReference.md +++ b/docs/UnityAssertionsReference.md @@ -236,6 +236,15 @@ conditional statements. ##### `TEST_ASSERT_NOT_NULL (pointer)` +Verify if a pointer is or is not NULL. + +##### `TEST_ASSERT_EMPTY (pointer)` + +##### `TEST_ASSERT_NOT_EMPTY (pointer)` + +Verify if the first element dereferenced from a pointer is or is not zero. This +is particularly useful for checking for empty (or non-empty) null-terminated +C strings, but can be just as easily used for other null-terminated arrays. ### Signed and Unsigned Integers (of all sizes) diff --git a/src/unity.h b/src/unity.h index 7c23e8d5..db5815c4 100644 --- a/src/unity.h +++ b/src/unity.h @@ -128,6 +128,8 @@ void verifyTest(void); #define TEST_ASSERT_FALSE(condition) UNITY_TEST_ASSERT( !(condition), __LINE__, " Expected FALSE Was TRUE") #define TEST_ASSERT_NULL(pointer) UNITY_TEST_ASSERT_NULL( (pointer), __LINE__, " Expected NULL") #define TEST_ASSERT_NOT_NULL(pointer) UNITY_TEST_ASSERT_NOT_NULL((pointer), __LINE__, " Expected Non-NULL") +#define TEST_ASSERT_EMPTY(pointer) UNITY_TEST_ASSERT_EMPTY( (pointer), __LINE__, " Expected Empty") +#define TEST_ASSERT_NOT_EMPTY(pointer) UNITY_TEST_ASSERT_NOT_EMPTY((pointer), __LINE__, " Expected Non-Empty") /* Integers (of all sizes) */ #define TEST_ASSERT_EQUAL_INT(expected, actual) UNITY_TEST_ASSERT_EQUAL_INT((expected), (actual), __LINE__, NULL) @@ -376,6 +378,8 @@ void verifyTest(void); #define TEST_ASSERT_FALSE_MESSAGE(condition, message) UNITY_TEST_ASSERT( !(condition), __LINE__, (message)) #define TEST_ASSERT_NULL_MESSAGE(pointer, message) UNITY_TEST_ASSERT_NULL( (pointer), __LINE__, (message)) #define TEST_ASSERT_NOT_NULL_MESSAGE(pointer, message) UNITY_TEST_ASSERT_NOT_NULL((pointer), __LINE__, (message)) +#define TEST_ASSERT_EMPTY_MESSAGE(pointer, message) UNITY_TEST_ASSERT_EMPTY( (pointer), __LINE__, (message)) +#define TEST_ASSERT_NOT_EMPTY_MESSAGE(pointer, message) UNITY_TEST_ASSERT_NOT_EMPTY((pointer), __LINE__, (message)) /* Integers (of all sizes) */ #define TEST_ASSERT_EQUAL_INT_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_INT((expected), (actual), __LINE__, (message)) diff --git a/src/unity_internals.h b/src/unity_internals.h index 6fccf8b4..993e094e 100644 --- a/src/unity_internals.h +++ b/src/unity_internals.h @@ -761,6 +761,8 @@ int UnityTestMatches(void); #define UNITY_TEST_ASSERT(condition, line, message) if (condition) {} else {UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), (message));} #define UNITY_TEST_ASSERT_NULL(pointer, line, message) UNITY_TEST_ASSERT(((pointer) == NULL), (UNITY_LINE_TYPE)(line), (message)) #define UNITY_TEST_ASSERT_NOT_NULL(pointer, line, message) UNITY_TEST_ASSERT(((pointer) != NULL), (UNITY_LINE_TYPE)(line), (message)) +#define UNITY_TEST_ASSERT_EMPTY(pointer, line, message) UNITY_TEST_ASSERT(((pointer[0]) == 0), (UNITY_LINE_TYPE)(line), (message)) +#define UNITY_TEST_ASSERT_NOT_EMPTY(pointer, line, message) UNITY_TEST_ASSERT(((pointer[0]) != 0), (UNITY_LINE_TYPE)(line), (message)) #define UNITY_TEST_ASSERT_EQUAL_INT(expected, actual, line, message) UnityAssertEqualNumber((UNITY_INT)(expected), (UNITY_INT)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT) #define UNITY_TEST_ASSERT_EQUAL_INT8(expected, actual, line, message) UnityAssertEqualNumber((UNITY_INT)(UNITY_INT8 )(expected), (UNITY_INT)(UNITY_INT8 )(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT8) diff --git a/test/tests/testunity.c b/test/tests/testunity.c index 08754465..eef84e2d 100644 --- a/test/tests/testunity.c +++ b/test/tests/testunity.c @@ -258,6 +258,33 @@ void testNotNullShouldFailIfNULL(void) VERIFY_FAILS_END } +void testIsEmpty(void) +{ + const char* ptr1 = "\0"; + const char* ptr2 = "hello"; + + TEST_ASSERT_EMPTY(ptr1); + TEST_ASSERT_NOT_EMPTY(ptr2); +} + +void testIsEmptyShouldFailIfNot(void) +{ + const char* ptr1 = "hello"; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_EMPTY(ptr1); + VERIFY_FAILS_END +} + +void testNotEmptyShouldFailIfEmpty(void) +{ + const char* ptr1 = "\0"; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_NOT_EMPTY(ptr1); + VERIFY_FAILS_END +} + void testIgnore(void) { EXPECT_ABORT_BEGIN From 71e77ce6fbe0f1fcd5c1115218e3f151b80a770e Mon Sep 17 00:00:00 2001 From: mvandervoord Date: Mon, 16 Mar 2020 18:45:40 -0400 Subject: [PATCH 221/454] Added NOT-EQUAL int variants. Organized Unit Tests --- docs/UnityAssertionsReference.md | 53 +- src/unity.c | 8 +- src/unity.h | 37 + src/unity_internals.h | 17 + test/rakefile | 17 +- test/rakefile_helper.rb | 13 +- test/tests/self_assessment_utils.h | 132 + test/tests/test_unity_arrays.c | 2871 ++++++ test/tests/test_unity_core.c | 355 + test/tests/test_unity_doubles.c | 770 ++ test/tests/test_unity_floats.c | 886 ++ test/tests/test_unity_integers.c | 2854 ++++++ test/tests/test_unity_integers_64.c | 770 ++ test/tests/test_unity_memory.c | 78 + ...meterized.c => test_unity_parameterized.c} | 0 test/tests/test_unity_strings.c | 326 + test/tests/testunity.c | 8201 ----------------- 17 files changed, 9127 insertions(+), 8261 deletions(-) create mode 100644 test/tests/self_assessment_utils.h create mode 100644 test/tests/test_unity_arrays.c create mode 100644 test/tests/test_unity_core.c create mode 100644 test/tests/test_unity_doubles.c create mode 100644 test/tests/test_unity_floats.c create mode 100644 test/tests/test_unity_integers.c create mode 100644 test/tests/test_unity_integers_64.c create mode 100644 test/tests/test_unity_memory.c rename test/tests/{testparameterized.c => test_unity_parameterized.c} (100%) create mode 100644 test/tests/test_unity_strings.c delete mode 100644 test/tests/testunity.c diff --git a/docs/UnityAssertionsReference.md b/docs/UnityAssertionsReference.md index 1ef06b32..2e4e0ff4 100644 --- a/docs/UnityAssertionsReference.md +++ b/docs/UnityAssertionsReference.md @@ -336,59 +336,18 @@ Asserts the specified bit of the `actual` parameter is low. These assertions verify that the `actual` parameter is less than or greater than `threshold` (exclusive). For example, if the threshold value is 0 for the -greater than assertion will fail if it is 0 or less. - -##### `TEST_ASSERT_GREATER_THAN (threshold, actual)` - -##### `TEST_ASSERT_GREATER_THAN_INT (threshold, actual)` +greater than assertion will fail if it is 0 or less. There are assertions for +all the various sizes of ints, as for the equality assertions. Some examples: ##### `TEST_ASSERT_GREATER_THAN_INT8 (threshold, actual)` -##### `TEST_ASSERT_GREATER_THAN_INT16 (threshold, actual)` - -##### `TEST_ASSERT_GREATER_THAN_INT32 (threshold, actual)` - -##### `TEST_ASSERT_GREATER_THAN_UINT (threshold, actual)` - -##### `TEST_ASSERT_GREATER_THAN_UINT8 (threshold, actual)` - -##### `TEST_ASSERT_GREATER_THAN_UINT16 (threshold, actual)` - -##### `TEST_ASSERT_GREATER_THAN_UINT32 (threshold, actual)` - -##### `TEST_ASSERT_GREATER_THAN_HEX8 (threshold, actual)` - -##### `TEST_ASSERT_GREATER_THAN_HEX16 (threshold, actual)` - -##### `TEST_ASSERT_GREATER_THAN_HEX32 (threshold, actual)` - -##### `TEST_ASSERT_GREATER_THAN_CHAR (threshold, actual)` - -##### `TEST_ASSERT_LESS_THAN (threshold, actual)` - -##### `TEST_ASSERT_LESS_THAN_INT (threshold, actual)` - -##### `TEST_ASSERT_LESS_THAN_INT8 (threshold, actual)` - -##### `TEST_ASSERT_LESS_THAN_INT16 (threshold, actual)` - -##### `TEST_ASSERT_LESS_THAN_INT32 (threshold, actual)` - -##### `TEST_ASSERT_LESS_THAN_UINT (threshold, actual)` - -##### `TEST_ASSERT_LESS_THAN_UINT8 (threshold, actual)` - -##### `TEST_ASSERT_LESS_THAN_UINT16 (threshold, actual)` - -##### `TEST_ASSERT_LESS_THAN_UINT32 (threshold, actual)` - -##### `TEST_ASSERT_LESS_THAN_HEX8 (threshold, actual)` +##### `TEST_ASSERT_GREATER_OR_EQUAL_INT16 (threshold, actual)` -##### `TEST_ASSERT_LESS_THAN_HEX16 (threshold, actual)` +##### `TEST_ASSERT_SMALLER_THAN_INT32 (threshold, actual)` -##### `TEST_ASSERT_LESS_THAN_HEX32 (threshold, actual)` +##### `TEST_ASSERT_SMALL_OR_EQUAL_UINT (threshold, actual)` -##### `TEST_ASSERT_LESS_THAN_CHAR (threshold, actual)` +##### `TEST_ASSERT_NOT_EQUAL_UINT8 (threshold, actual)` ### Integer Ranges (of all sizes) diff --git a/src/unity.c b/src/unity.c index 5e13a720..aa8074c5 100644 --- a/src/unity.c +++ b/src/unity.c @@ -43,6 +43,7 @@ static const char PROGMEM UnityStrWas[] = " Was "; static const char PROGMEM UnityStrGt[] = " to be greater than "; static const char PROGMEM UnityStrLt[] = " to be less than "; static const char PROGMEM UnityStrOrEqual[] = "or equal to "; +static const char PROGMEM UnityStrNotEqual[] = " to be not equal to "; static const char PROGMEM UnityStrElement[] = " Element "; static const char PROGMEM UnityStrByte[] = " Byte "; static const char PROGMEM UnityStrMemory[] = " Memory Mismatch."; @@ -748,9 +749,10 @@ void UnityAssertGreaterOrLessOrEqualNumber(const UNITY_INT threshold, UnityTestResultsFailBegin(lineNumber); UnityPrint(UnityStrExpected); UnityPrintNumberByStyle(actual, style); - if (compare & UNITY_GREATER_THAN) { UnityPrint(UnityStrGt); } - if (compare & UNITY_SMALLER_THAN) { UnityPrint(UnityStrLt); } - if (compare & UNITY_EQUAL_TO) { UnityPrint(UnityStrOrEqual); } + if (compare & UNITY_GREATER_THAN) { UnityPrint(UnityStrGt); } + if (compare & UNITY_SMALLER_THAN) { UnityPrint(UnityStrLt); } + if (compare & UNITY_EQUAL_TO) { UnityPrint(UnityStrOrEqual); } + if (compare == UNITY_NOT_EQUAL) { UnityPrint(UnityStrNotEqual); } UnityPrintNumberByStyle(threshold, style); UnityAddMsgIfSpecified(msg); UNITY_FAIL_AND_BAIL; diff --git a/src/unity.h b/src/unity.h index db5815c4..925cd4d5 100644 --- a/src/unity.h +++ b/src/unity.h @@ -155,6 +155,24 @@ void verifyTest(void); #define TEST_ASSERT_BIT_HIGH(bit, actual) UNITY_TEST_ASSERT_BITS(((UNITY_UINT32)1 << (bit)), (UNITY_UINT32)(-1), (actual), __LINE__, NULL) #define TEST_ASSERT_BIT_LOW(bit, actual) UNITY_TEST_ASSERT_BITS(((UNITY_UINT32)1 << (bit)), (UNITY_UINT32)(0), (actual), __LINE__, NULL) +/* Integer Not Equal To (of all sizes) */ +#define TEST_ASSERT_NOT_EQUAL_INT(threshold, actual) UNITY_TEST_ASSERT_NOT_EQUAL_INT((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_NOT_EQUAL_INT8(threshold, actual) UNITY_TEST_ASSERT_NOT_EQUAL_INT8((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_NOT_EQUAL_INT16(threshold, actual) UNITY_TEST_ASSERT_NOT_EQUAL_INT16((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_NOT_EQUAL_INT32(threshold, actual) UNITY_TEST_ASSERT_NOT_EQUAL_INT32((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_NOT_EQUAL_INT64(threshold, actual) UNITY_TEST_ASSERT_NOT_EQUAL_INT64((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_NOT_EQUAL_UINT(threshold, actual) UNITY_TEST_ASSERT_NOT_EQUAL_UINT((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_NOT_EQUAL_UINT8(threshold, actual) UNITY_TEST_ASSERT_NOT_EQUAL_UINT8((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_NOT_EQUAL_UINT16(threshold, actual) UNITY_TEST_ASSERT_NOT_EQUAL_UINT16((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_NOT_EQUAL_UINT32(threshold, actual) UNITY_TEST_ASSERT_NOT_EQUAL_UINT32((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_NOT_EQUAL_UINT64(threshold, actual) UNITY_TEST_ASSERT_NOT_EQUAL_UINT64((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_NOT_EQUAL_size_t(threshold, actual) UNITY_TEST_ASSERT_NOT_EQUAL_UINT((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_NOT_EQUAL_HEX8(threshold, actual) UNITY_TEST_ASSERT_NOT_EQUAL_HEX8((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_NOT_EQUAL_HEX16(threshold, actual) UNITY_TEST_ASSERT_NOT_EQUAL_HEX16((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_NOT_EQUAL_HEX32(threshold, actual) UNITY_TEST_ASSERT_NOT_EQUAL_HEX32((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_NOT_EQUAL_HEX64(threshold, actual) UNITY_TEST_ASSERT_NOT_EQUAL_HEX64((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_NOT_EQUAL_CHAR(threshold, actual) UNITY_TEST_ASSERT_NOT_EQUAL_CHAR((threshold), (actual), __LINE__, NULL) + /* Integer Greater Than/ Less Than (of all sizes) */ #define TEST_ASSERT_GREATER_THAN(threshold, actual) UNITY_TEST_ASSERT_GREATER_THAN_INT((threshold), (actual), __LINE__, NULL) #define TEST_ASSERT_GREATER_THAN_INT(threshold, actual) UNITY_TEST_ASSERT_GREATER_THAN_INT((threshold), (actual), __LINE__, NULL) @@ -405,6 +423,25 @@ void verifyTest(void); #define TEST_ASSERT_BIT_LOW_MESSAGE(bit, actual, message) UNITY_TEST_ASSERT_BITS(((UNITY_UINT32)1 << (bit)), (UNITY_UINT32)(0), (actual), __LINE__, (message)) #define TEST_ASSERT_EQUAL_CHAR_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_CHAR((expected), (actual), __LINE__, (message)) +/* Integer Not Equal To (of all sizes) */ +#define TEST_ASSERT_NOT_EQUAL_INT_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_NOT_EQUAL_INT((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_NOT_EQUAL_INT8_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_NOT_EQUAL_INT8((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_NOT_EQUAL_INT16_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_NOT_EQUAL_INT16((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_NOT_EQUAL_INT32_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_NOT_EQUAL_INT32((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_NOT_EQUAL_INT64_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_NOT_EQUAL_INT64((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_NOT_EQUAL_UINT_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_NOT_EQUAL_UINT((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_NOT_EQUAL_UINT8_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_NOT_EQUAL_UINT8((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_NOT_EQUAL_UINT16_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_NOT_EQUAL_UINT16((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_NOT_EQUAL_UINT32_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_NOT_EQUAL_UINT32((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_NOT_EQUAL_UINT64_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_NOT_EQUAL_UINT64((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_NOT_EQUAL_size_t_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_NOT_EQUAL_UINT((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_NOT_EQUAL_HEX8_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_NOT_EQUAL_HEX8((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_NOT_EQUAL_HEX16_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_NOT_EQUAL_HEX16((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_NOT_EQUAL_HEX32_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_NOT_EQUAL_HEX32((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_NOT_EQUAL_HEX64_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_NOT_EQUAL_HEX64((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_NOT_EQUAL_CHAR_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_NOT_EQUAL_CHAR((threshold), (actual), __LINE__, (message)) + + /* Integer Greater Than/ Less Than (of all sizes) */ #define TEST_ASSERT_GREATER_THAN_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_THAN_INT((threshold), (actual), __LINE__, (message)) #define TEST_ASSERT_GREATER_THAN_INT_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_THAN_INT((threshold), (actual), __LINE__, (message)) diff --git a/src/unity_internals.h b/src/unity_internals.h index 993e094e..eda066ee 100644 --- a/src/unity_internals.h +++ b/src/unity_internals.h @@ -421,6 +421,7 @@ typedef enum UNITY_GREATER_OR_EQUAL = 0x2 + UNITY_EQUAL_TO, UNITY_SMALLER_THAN = 0x4, UNITY_SMALLER_OR_EQUAL = 0x4 + UNITY_EQUAL_TO, + UNITY_NOT_EQUAL = 0x0, UNITY_UNKNOWN } UNITY_COMPARISON_T; @@ -778,6 +779,19 @@ int UnityTestMatches(void); #define UNITY_TEST_ASSERT_EQUAL_CHAR(expected, actual, line, message) UnityAssertEqualNumber((UNITY_INT)(UNITY_INT8 )(expected), (UNITY_INT)(UNITY_INT8 )(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_CHAR) #define UNITY_TEST_ASSERT_BITS(mask, expected, actual, line, message) UnityAssertBits((UNITY_INT)(mask), (UNITY_INT)(expected), (UNITY_INT)(actual), (message), (UNITY_LINE_TYPE)(line)) +#define UNITY_TEST_ASSERT_NOT_EQUAL_INT(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(threshold), (UNITY_INT)(actual), UNITY_NOT_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT) +#define UNITY_TEST_ASSERT_NOT_EQUAL_INT8(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_INT8 )(threshold), (UNITY_INT)(UNITY_INT8 )(actual), UNITY_NOT_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT8) +#define UNITY_TEST_ASSERT_NOT_EQUAL_INT16(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_INT16)(threshold), (UNITY_INT)(UNITY_INT16)(actual), UNITY_NOT_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT16) +#define UNITY_TEST_ASSERT_NOT_EQUAL_INT32(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_INT32)(threshold), (UNITY_INT)(UNITY_INT32)(actual), UNITY_NOT_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT32) +#define UNITY_TEST_ASSERT_NOT_EQUAL_UINT(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(threshold), (UNITY_INT)(actual), UNITY_NOT_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT) +#define UNITY_TEST_ASSERT_NOT_EQUAL_UINT8(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_UINT8 )(threshold), (UNITY_INT)(UNITY_UINT8 )(actual), UNITY_NOT_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT8) +#define UNITY_TEST_ASSERT_NOT_EQUAL_UINT16(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_UINT16)(threshold), (UNITY_INT)(UNITY_UINT16)(actual), UNITY_NOT_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT16) +#define UNITY_TEST_ASSERT_NOT_EQUAL_UINT32(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_UINT32)(threshold), (UNITY_INT)(UNITY_UINT32)(actual), UNITY_NOT_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT32) +#define UNITY_TEST_ASSERT_NOT_EQUAL_HEX8(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_UINT8 )(threshold), (UNITY_INT)(UNITY_UINT8 )(actual), UNITY_NOT_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX8) +#define UNITY_TEST_ASSERT_NOT_EQUAL_HEX16(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_UINT16)(threshold), (UNITY_INT)(UNITY_UINT16)(actual), UNITY_NOT_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX16) +#define UNITY_TEST_ASSERT_NOT_EQUAL_HEX32(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_UINT32)(threshold), (UNITY_INT)(UNITY_UINT32)(actual), UNITY_NOT_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX32) +#define UNITY_TEST_ASSERT_NOT_EQUAL_CHAR(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_INT8 )(threshold), (UNITY_INT)(UNITY_INT8 )(actual), UNITY_NOT_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_CHAR) + #define UNITY_TEST_ASSERT_GREATER_THAN_INT(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(threshold), (UNITY_INT)(actual), UNITY_GREATER_THAN, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT) #define UNITY_TEST_ASSERT_GREATER_THAN_INT8(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_INT8 )(threshold), (UNITY_INT)(UNITY_INT8 )(actual), UNITY_GREATER_THAN, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT8) #define UNITY_TEST_ASSERT_GREATER_THAN_INT16(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_INT16)(threshold), (UNITY_INT)(UNITY_INT16)(actual), UNITY_GREATER_THAN, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT16) @@ -907,6 +921,9 @@ int UnityTestMatches(void); #define UNITY_TEST_ASSERT_INT64_WITHIN(delta, expected, actual, line, message) UnityAssertNumbersWithin((delta), (UNITY_INT)(expected), (UNITY_INT)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT64) #define UNITY_TEST_ASSERT_UINT64_WITHIN(delta, expected, actual, line, message) UnityAssertNumbersWithin((delta), (UNITY_INT)(expected), (UNITY_INT)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT64) #define UNITY_TEST_ASSERT_HEX64_WITHIN(delta, expected, actual, line, message) UnityAssertNumbersWithin((delta), (UNITY_INT)(expected), (UNITY_INT)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX64) +#define UNITY_TEST_ASSERT_NOT_EQUAL_INT64(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(threshold), (UNITY_INT)(actual), UNITY_NOT_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT64) +#define UNITY_TEST_ASSERT_NOT_EQUAL_UINT64(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(threshold), (UNITY_INT)(actual), UNITY_NOT_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT64) +#define UNITY_TEST_ASSERT_NOT_EQUAL_HEX64(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(threshold), (UNITY_INT)(actual), UNITY_NOT_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX64) #define UNITY_TEST_ASSERT_GREATER_THAN_INT64(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(threshold), (UNITY_INT)(actual), UNITY_GREATER_THAN, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT64) #define UNITY_TEST_ASSERT_GREATER_THAN_UINT64(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(threshold), (UNITY_INT)(actual), UNITY_GREATER_THAN, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT64) #define UNITY_TEST_ASSERT_GREATER_THAN_HEX64(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(threshold), (UNITY_INT)(actual), UNITY_GREATER_THAN, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX64) diff --git a/test/rakefile b/test/rakefile index 09e4e581..e5f3b748 100644 --- a/test/rakefile +++ b/test/rakefile @@ -31,7 +31,7 @@ DEFAULT_CONFIG_FILE = 'gcc_auto_stdint.yml' configure_toolchain(DEFAULT_CONFIG_FILE) ############# ALL THE SELF-TESTS WE CAN PERFORM -namespace :test do +namespace :test do desc "Build and test Unity" task :all => [:clean, :prepare_for_tests, 'test:scripts', 'test:unit', :style, 'test:fixture', 'test:memory', 'test:summary'] task :ci => [:clean, :prepare_for_tests, 'test:scripts', 'test:unit', :style, 'test:make', 'test:fixture', 'test:memory', 'test:summary'] @@ -41,6 +41,15 @@ namespace :test do run_tests unit_test_files end + namespace :unit do + unit_test_files.each do |f| + desc "test this unit only" + task File.basename(f,'.c').sub('test_unity_','') => [:prepare_for_tests] do + run_tests [f] + end + end + end + desc "Test unity's helper scripts" task :scripts => [:prepare_for_tests] do Dir['tests/test_*.rb'].each do |scriptfile| @@ -54,17 +63,17 @@ namespace :test do end desc "Test unity fixture addon" - task :fixture => [:prepare_for_tests] do + task :fixture => [:prepare_for_tests] do test_fixtures() end desc "Test unity memory addon" - task :memory => [:prepare_for_tests] do + task :memory => [:prepare_for_tests] do test_memory() end desc "Test unity examples" - task :examples => [:prepare_for_tests] do + task :examples => [:prepare_for_tests] do execute("cd ../examples/example_1 && make -s ci", false) execute("cd ../examples/example_2 && make -s ci", false) execute("cd ../examples/example_3 && rake", false) diff --git a/test/rakefile_helper.rb b/test/rakefile_helper.rb index 519e728d..e205bc67 100644 --- a/test/rakefile_helper.rb +++ b/test/rakefile_helper.rb @@ -95,13 +95,13 @@ def build_command_string(hash, values, defines = nil) args = [] hash[:arguments].each do |arg| if arg.include? '$' - if arg.include? ': COLLECTION_PATHS_TEST_TOOLCHAIN_INCLUDE' + if arg.include? ': COLLECTION_PATHS_TEST_TOOLCHAIN_INCLUDE' pattern = arg.gsub(': COLLECTION_PATHS_TEST_TOOLCHAIN_INCLUDE','') [ File.join('..','src') ].each do |f| args << pattern.gsub(/\$/,f) end - elsif arg.include? ': COLLECTION_PATHS_TEST_SUPPORT_SOURCE_INCLUDE_VENDOR' + elsif arg.include? ': COLLECTION_PATHS_TEST_SUPPORT_SOURCE_INCLUDE_VENDOR' pattern = arg.gsub(': COLLECTION_PATHS_TEST_SUPPORT_SOURCE_INCLUDE_VENDOR','') [ $extra_paths, 'src', File.join('tests'), File.join('testdata'), $cfg[:paths][:support] ].flatten.uniq.compact.each do |f| args << pattern.gsub(/\$/,f) @@ -112,7 +112,7 @@ def build_command_string(hash, values, defines = nil) [ $cfg[:defines][:test], defines ].flatten.uniq.compact.each do |f| args << pattern.gsub(/\$/,f) end - + elsif arg =~ /\$\{(\d+)\}/ i = $1.to_i - 1 if (values[i].is_a?(Array)) @@ -223,8 +223,8 @@ def test_fixtures() end def test_memory() - { 'w_malloc' => [], - 'wo_malloc' => ['UNITY_EXCLUDE_STDLIB_MALLOC'] + { 'w_malloc' => [], + 'wo_malloc' => ['UNITY_EXCLUDE_STDLIB_MALLOC'] }.each_pair do |name, defs| report "\nRunning Memory Addon #{name}" @@ -264,6 +264,7 @@ def run_tests(test_files) end end + report "\nRunning Tests in #{test}" obj_list = [] test_defines = [] @@ -297,7 +298,7 @@ def run_tests(test_files) end end - def run_make_tests() + def run_make_tests() [ "make -s", # test with all defaults "make -s DEBUG=-m32", # test 32-bit architecture with 64-bit support "make -s DEBUG=-m32 UNITY_SUPPORT_64=", # test 32-bit build without 64-bit types diff --git a/test/tests/self_assessment_utils.h b/test/tests/self_assessment_utils.h new file mode 100644 index 00000000..e7083872 --- /dev/null +++ b/test/tests/self_assessment_utils.h @@ -0,0 +1,132 @@ +#ifdef TEST_INSTANCES + +#include +#include + +/* Dividing by these constants produces +/- infinity. + * The rationale is given in UnityAssertFloatIsInf's body. + */ +#ifndef UNITY_EXCLUDE_FLOAT +static const UNITY_FLOAT f_zero = 0.0f; +#endif + +#ifndef UNITY_EXCLUDE_DOUBLE +static const UNITY_DOUBLE d_zero = 0.0; +#endif + +/* Macros for Catching An Expected Failure or Ignore */ +#define EXPECT_ABORT_BEGIN \ + startPutcharSpy(); \ + if (TEST_PROTECT()) \ + { + +#define VERIFY_FAILS_END \ + } \ + endPutcharSpy(); /* start/end Spy to suppress output of failure message */ \ + Unity.CurrentTestFailed = (Unity.CurrentTestFailed == 1) ? 0 : 1; \ + if (Unity.CurrentTestFailed == 1) { \ + SetToOneMeanWeAlreadyCheckedThisGuy = 1; \ + UnityPrintNumberUnsigned(Unity.CurrentTestLineNumber); \ + UNITY_OUTPUT_CHAR(':'); \ + UnityPrint(Unity.CurrentTestName); \ + UnityPrint(":FAIL: [[[[ Test Should Have Failed But Did Not ]]]]"); \ + UNITY_OUTPUT_CHAR('\n'); \ + } + +#define VERIFY_IGNORES_END \ + } \ + endPutcharSpy(); /* start/end Spy to suppress output of ignore message */ \ + Unity.CurrentTestFailed = (Unity.CurrentTestIgnored == 1) ? 0 : 1; \ + Unity.CurrentTestIgnored = 0; \ + if (Unity.CurrentTestFailed == 1) { \ + SetToOneMeanWeAlreadyCheckedThisGuy = 1; \ + UnityPrintNumberUnsigned(Unity.CurrentTestLineNumber); \ + UNITY_OUTPUT_CHAR(':'); \ + UnityPrint(Unity.CurrentTestName); \ + UnityPrint(":FAIL: [[[[ Test Should Have Ignored But Did Not ]]]]"); \ + UNITY_OUTPUT_CHAR('\n'); \ + } + +int SetToOneToFailInTearDown; +int SetToOneMeanWeAlreadyCheckedThisGuy; + +/* Tricky series of macros to set USING_OUTPUT_SPY */ +#define USING_SPY_AS(a) EXPAND_AND_USE_2ND(ASSIGN_VALUE(a), 0) +#define ASSIGN_VALUE(a) VAL_##a +#define VAL_putcharSpy 0, 1 +#define EXPAND_AND_USE_2ND(a, b) SECOND_PARAM(a, b, throwaway) +#define SECOND_PARAM(a, b, ...) b +#if USING_SPY_AS(UNITY_OUTPUT_CHAR) + #define USING_OUTPUT_SPY /* true only if UNITY_OUTPUT_CHAR = putcharSpy */ +#endif + +#ifdef USING_OUTPUT_SPY +#include +#define SPY_BUFFER_MAX 40 +static char putcharSpyBuffer[SPY_BUFFER_MAX]; +#endif +static int indexSpyBuffer; +static int putcharSpyEnabled; + +void startPutcharSpy(void) +{ + indexSpyBuffer = 0; + putcharSpyEnabled = 1; +} + +void endPutcharSpy(void) +{ + putcharSpyEnabled = 0; +} + +char* getBufferPutcharSpy(void) +{ +#ifdef USING_OUTPUT_SPY + putcharSpyBuffer[indexSpyBuffer] = '\0'; + return putcharSpyBuffer; +#else + return NULL; +#endif +} + +void putcharSpy(int c) +{ +#ifdef USING_OUTPUT_SPY + if (putcharSpyEnabled) + { + if (indexSpyBuffer < SPY_BUFFER_MAX - 1) + putcharSpyBuffer[indexSpyBuffer++] = (char)c; + } else + putchar((char)c); +#else + (void)c; +#endif +} + +/* This is for counting the calls to the flushSpy */ +static int flushSpyEnabled; +static int flushSpyCalls = 0; + +void startFlushSpy(void) +{ + flushSpyCalls = 0; + flushSpyEnabled = 1; +} + +void endFlushSpy(void) +{ + flushSpyCalls = 0; + flushSpyEnabled = 0; +} + +int getFlushSpyCalls(void) +{ + return flushSpyCalls; +} + +void flushSpy(void) +{ + if (flushSpyEnabled){ flushSpyCalls++; } +} + +#endif \ No newline at end of file diff --git a/test/tests/test_unity_arrays.c b/test/tests/test_unity_arrays.c new file mode 100644 index 00000000..bf1ef7a0 --- /dev/null +++ b/test/tests/test_unity_arrays.c @@ -0,0 +1,2871 @@ +/* ========================================== + Unity Project - A Test Framework for C + Copyright (c) 2007 Mike Karlesky, Mark VanderVoord, Greg Williams + [Released under MIT License. Please refer to license.txt for details] +========================================== */ + +#include "unity.h" +#define TEST_INSTANCES +#include "self_assessment_utils.h" + +void setUp(void) +{ + SetToOneToFailInTearDown = 0; + SetToOneMeanWeAlreadyCheckedThisGuy = 0; +} + +void tearDown(void) +{ + endPutcharSpy(); /* Stop suppressing test output */ + if (SetToOneToFailInTearDown == 1) + { + /* These will be skipped internally if already failed/ignored */ + TEST_FAIL_MESSAGE("<= Failed in tearDown"); + TEST_IGNORE_MESSAGE("<= Ignored in tearDown"); + } + if ((SetToOneMeanWeAlreadyCheckedThisGuy == 0) && (Unity.CurrentTestFailed > 0)) + { + UnityPrint(": [[[[ Test Should Have Passed But Did Not ]]]]"); + UNITY_OUTPUT_CHAR('\n'); + } +} + +void testInt64ArrayWithinDelta(void) +{ +#ifndef UNITY_SUPPORT_64 + TEST_IGNORE(); +#else + UNITY_INT64 expected[] = {12345000, -12344995, 12345005}; + UNITY_INT64 actualSmallDelta[] = {12345001, -12344996, 12345005}; + UNITY_INT64 actualBigDelta[] = {12345101, -12344896, 12345055}; + + TEST_ASSERT_INT64_ARRAY_WITHIN(1, expected, actualSmallDelta, 3); + TEST_ASSERT_INT64_ARRAY_WITHIN(110, expected, actualBigDelta, 3); +#endif +} + +void testInt64ArrayWithinDeltaAndMessage(void) +{ +#ifndef UNITY_SUPPORT_64 + TEST_IGNORE(); +#else + UNITY_INT64 expected[] = {12345000, -12344995, 12345005}; + UNITY_INT64 actualSmallDelta[] = {12345001, -12344996, 12345005}; + UNITY_INT64 actualBigDelta[] = {12345101, -12344896, 12345055}; + + TEST_ASSERT_INT64_ARRAY_WITHIN_MESSAGE(1, expected, actualSmallDelta, 3, "Custom Message."); + TEST_ASSERT_INT64_ARRAY_WITHIN_MESSAGE(110, expected, actualBigDelta, 3, "Custom Message."); +#endif +} + +void tesUInt64ArrayNotWithinDelta(void) +{ +#ifndef UNITY_SUPPORT_64 + TEST_IGNORE(); +#else + UNITY_INT64 expected[] = {12345000, -12344995, 12345005}; + UNITY_INT64 actualBigDelta[] = {12345101, -12344896, 12345055}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_UINT64_ARRAY_WITHIN(1, expected, actualBigDelta, 3); + VERIFY_FAILS_END +#endif +} + +void testInt64ArrayNotWithinDeltaAndMessage(void) +{ +#ifndef UNITY_SUPPORT_64 + TEST_IGNORE(); +#else + UNITY_INT64 expected[] = {12345000, -12344995, 12345005}; + UNITY_INT64 actualBigDelta[] = {12345101, -12344896, 12345055}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_INT64_ARRAY_WITHIN_MESSAGE(1, expected, actualBigDelta, 3, "Custom Message."); + VERIFY_FAILS_END +#endif +} + +void testInt64ArrayWithinDeltaPointless(void) +{ +#ifndef UNITY_SUPPORT_64 + TEST_IGNORE(); +#else + UNITY_INT64 expected[] = {12345000, -12344995, 12345005}; + UNITY_INT64 actualBigDelta[] = {12345101, -12344896, 12345055}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_INT64_ARRAY_WITHIN(110, expected, actualBigDelta, 0); + VERIFY_FAILS_END +#endif +} + +void testInt64ArrayWithinDeltaPointlessAndMessage(void) +{ +#ifndef UNITY_SUPPORT_64 + TEST_IGNORE(); +#else + UNITY_INT64 expected[] = {12345000, -12344995, 12345005}; + UNITY_INT64 actualBigDelta[] = {12345101, -12344896, 12345055}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_INT64_ARRAY_WITHIN_MESSAGE(110, expected, actualBigDelta, 0, "Custom Message."); + VERIFY_FAILS_END +#endif +} + +void testInt64ArrayWithinDeltaExpectedNull(void) +{ +#ifndef UNITY_SUPPORT_64 + TEST_IGNORE(); +#else + UNITY_INT64 actualBigDelta[] = {12345101, -12344896, 12345055}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_INT64_ARRAY_WITHIN(110, NULL, actualBigDelta, 3); + VERIFY_FAILS_END +#endif +} + +void testInt64ArrayWithinDeltaExpectedNullAndMessage(void) +{ +#ifndef UNITY_SUPPORT_64 + TEST_IGNORE(); +#else + UNITY_INT64 actualBigDelta[] = {12345101, -12344896, 12345055}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_INT64_ARRAY_WITHIN_MESSAGE(110, NULL, actualBigDelta, 3, "Custom Message."); + VERIFY_FAILS_END +#endif +} + +void testInt64ArrayWithinDeltaActualNull(void) +{ +#ifndef UNITY_SUPPORT_64 + TEST_IGNORE(); +#else + UNITY_INT64 expected[] = {12345000, -12344995, 12345005}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_INT64_ARRAY_WITHIN(110, expected, NULL, 3); + VERIFY_FAILS_END +#endif +} + +void testInt64ArrayWithinDeltaActualNullAndMessage(void) +{ +#ifndef UNITY_SUPPORT_64 + TEST_IGNORE(); +#else + UNITY_INT64 expected[] = {12345000, -12344995, 12345005}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_INT64_ARRAY_WITHIN_MESSAGE(110, expected, NULL, 3, "Custom Message."); + VERIFY_FAILS_END +#endif +} + +void testInt64ArrayWithinDeltaSamePointer(void) +{ +#ifndef UNITY_SUPPORT_64 + TEST_IGNORE(); +#else + UNITY_INT64 expected[] = {12345000, -12344995, 12345005}; + + TEST_ASSERT_UINT64_ARRAY_WITHIN(110, expected, expected, 3); +#endif +} + +void testInt64ArrayWithinDeltaSamePointerAndMessage(void) +{ +#ifndef UNITY_SUPPORT_64 + TEST_IGNORE(); +#else + UNITY_INT64 expected[] = {12345000, -12344995, 12345005}; + + TEST_ASSERT_INT64_ARRAY_WITHIN_MESSAGE(110, expected, expected, 3, "Custom Message."); +#endif +} + +void testIntArrayWithinDelta(void) +{ + UNITY_INT expected[] = {5000, -4995, 5005}; + UNITY_INT actualSmallDelta[] = {5001, -4996, 5005}; + UNITY_INT actualBigDelta[] = {5101, -4896, 5055}; + + TEST_ASSERT_INT_ARRAY_WITHIN(1, expected, actualSmallDelta, 3); + TEST_ASSERT_INT_ARRAY_WITHIN(110, expected, actualBigDelta, 3); +} + +void testIntArrayWithinDeltaAndMessage(void) +{ + UNITY_INT expected[] = {5000, -4995, 5005}; + UNITY_INT actualSmallDelta[] = {5001, -4996, 5005}; + UNITY_INT actualBigDelta[] = {5101, -4896, 5055}; + + TEST_ASSERT_INT_ARRAY_WITHIN_MESSAGE(1, expected, actualSmallDelta, 3, "Custom Message."); + TEST_ASSERT_INT_ARRAY_WITHIN_MESSAGE(110, expected, actualBigDelta, 3, "Custom Message."); +} + +void testIntArrayNotWithinDelta(void) +{ + UNITY_INT expected[] = {5000, -4995, 5005}; + UNITY_INT actualBigDelta[] = {5101, -4896, 5055}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_INT_ARRAY_WITHIN(1, expected, actualBigDelta, 3); + VERIFY_FAILS_END +} + +void testIntArrayNotWithinDeltaAndMessage(void) +{ + UNITY_INT expected[] = {5000, -4995, 5005}; + UNITY_INT actualBigDelta[] = {5101, -4896, 5055}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_INT_ARRAY_WITHIN_MESSAGE(1, expected, actualBigDelta, 3, "Custom Message."); + VERIFY_FAILS_END +} + +void testIntArrayWithinDeltaPointless(void) +{ + UNITY_INT expected[] = {5000, -4995, 5005}; + UNITY_INT actualBigDelta[] = {5101, -4896, 5055}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_INT_ARRAY_WITHIN(110, expected, actualBigDelta, 0); + VERIFY_FAILS_END +} + +void testIntArrayWithinDeltaPointlessAndMessage(void) +{ + UNITY_INT expected[] = {5000, -4995, 5005}; + UNITY_INT actualBigDelta[] = {5101, -4896, 5055}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_INT_ARRAY_WITHIN_MESSAGE(110, expected, actualBigDelta, 0, "Custom Message."); + VERIFY_FAILS_END +} + +void testIntArrayWithinDeltaExpectedNull(void) +{ + UNITY_INT actualBigDelta[] = {5101, -4896, 5055}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_INT_ARRAY_WITHIN(110, NULL, actualBigDelta, 3); + VERIFY_FAILS_END +} + +void testIntArrayWithinDeltaExpectedNullAndMessage(void) +{ + UNITY_INT actualBigDelta[] = {5101, -4896, 5055}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_INT_ARRAY_WITHIN_MESSAGE(110, NULL, actualBigDelta, 3, "Custom Message."); + VERIFY_FAILS_END +} + +void testIntArrayWithinDeltaActualNull(void) +{ + UNITY_INT expected[] = {5000, -4995, 5005}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_INT_ARRAY_WITHIN(110, expected, NULL, 3); + VERIFY_FAILS_END +} + +void testIntArrayWithinDeltaActualNullAndMessage(void) +{ + UNITY_INT expected[] = {5000, -4995, 5005}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_INT_ARRAY_WITHIN_MESSAGE(110, expected, NULL, 3, "Custom Message."); + VERIFY_FAILS_END +} + +void testIntArrayWithinDeltaSamePointer(void) +{ + UNITY_INT expected[] = {5000, -4995, 5005}; + + TEST_ASSERT_INT_ARRAY_WITHIN(110, expected, expected, 3); +} + +void testIntArrayWithinDeltaSamePointerAndMessage(void) +{ + UNITY_INT expected[] = {5000, -4995, 5005}; + + TEST_ASSERT_INT_ARRAY_WITHIN_MESSAGE(110, expected, expected, 3, "Custom Message."); +} + +void testInt16ArrayWithinDelta(void) +{ + UNITY_INT16 expected[] = {5000, -4995, 5005}; + UNITY_INT16 actualSmallDelta[] = {5001, -4996, 5005}; + UNITY_INT16 actualBigDelta[] = {5101, -4896, 5055}; + + TEST_ASSERT_INT16_ARRAY_WITHIN(1, expected, actualSmallDelta, 3); + TEST_ASSERT_INT16_ARRAY_WITHIN(110, expected, actualBigDelta, 3); +} + +void testInt16ArrayWithinDeltaAndMessage(void) +{ + UNITY_INT16 expected[] = {5000, -4995, 5005}; + UNITY_INT16 actualSmallDelta[] = {5001, -4996, 5005}; + UNITY_INT16 actualBigDelta[] = {5101, -4896, 5055}; + + TEST_ASSERT_INT16_ARRAY_WITHIN_MESSAGE(1, expected, actualSmallDelta, 3, "Custom Message."); + TEST_ASSERT_INT16_ARRAY_WITHIN_MESSAGE(110, expected, actualBigDelta, 3, "Custom Message."); +} + +void testInt16ArrayNotWithinDelta(void) +{ + UNITY_INT16 expected[] = {5000, -4995, 5005}; + UNITY_INT16 actualBigDelta[] = {5101, -4896, 5055}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_UINT16_ARRAY_WITHIN(1, expected, actualBigDelta, 3); + VERIFY_FAILS_END +} + +void testInt16ArrayNotWithinDeltaAndMessage(void) +{ + UNITY_INT16 expected[] = {5000, -4995, 5005}; + UNITY_INT16 actualBigDelta[] = {5101, -4896, 5055}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_INT16_ARRAY_WITHIN_MESSAGE(1, expected, actualBigDelta, 3, "Custom Message."); + VERIFY_FAILS_END +} + +void testInt16ArrayWithinDeltaPointless(void) +{ + UNITY_INT16 expected[] = {5000, -4995, 5005}; + UNITY_INT16 actualBigDelta[] = {5101, -4896, 5055}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_INT16_ARRAY_WITHIN(110, expected, actualBigDelta, 0); + VERIFY_FAILS_END +} + +void testInt16ArrayWithinDeltaPointlessAndMessage(void) +{ + UNITY_INT16 expected[] = {5000, -4995, 5005}; + UNITY_INT16 actualBigDelta[] = {5101, -4896, 5055}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_INT16_ARRAY_WITHIN_MESSAGE(110, expected, actualBigDelta, 0, "Custom Message."); + VERIFY_FAILS_END +} + +void testInt16ArrayWithinDeltaExpectedNull(void) +{ + UNITY_INT16 actualBigDelta[] = {5101, -4896, 5055}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_INT16_ARRAY_WITHIN(110, NULL, actualBigDelta, 3); + VERIFY_FAILS_END +} + +void testInt16ArrayWithinDeltaExpectedNullAndMessage(void) +{ + UNITY_INT16 actualBigDelta[] = {5101, -4896, 5055}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_INT16_ARRAY_WITHIN_MESSAGE(110, NULL, actualBigDelta, 3, "Custom Message."); + VERIFY_FAILS_END +} + +void testInt16ArrayWithinDeltaActualNull(void) +{ + UNITY_INT16 expected[] = {5000, -4995, 5005}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_INT16_ARRAY_WITHIN(110, expected, NULL, 3); + VERIFY_FAILS_END +} + +void testInt16ArrayWithinDeltaActualNullAndMessage(void) +{ + UNITY_INT16 expected[] = {5000, -4995, 5005}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_INT16_ARRAY_WITHIN_MESSAGE(110, expected, NULL, 3, "Custom Message."); + VERIFY_FAILS_END +} + +void testInt16ArrayWithinDeltaSamePointer(void) +{ + UNITY_INT16 expected[] = {5000, -4995, 5005}; + + TEST_ASSERT_INT16_ARRAY_WITHIN(110, expected, expected, 3); +} + +void testInt16ArrayWithinDeltaSamePointerAndMessage(void) +{ + UNITY_INT16 expected[] = {5000, -4995, 5005}; + + TEST_ASSERT_INT16_ARRAY_WITHIN_MESSAGE(110, expected, expected, 3, "Custom Message."); +} + +void testInt8ArrayWithinDelta(void) +{ + UNITY_INT8 expected[] = {20, -95, 55}; + UNITY_INT8 actualSmallDelta[] = {21, -94, 55}; + UNITY_INT8 actualBigDelta[] = {11, -86, 45}; + + TEST_ASSERT_INT8_ARRAY_WITHIN(1, expected, actualSmallDelta, 3); + TEST_ASSERT_INT8_ARRAY_WITHIN(11, expected, actualBigDelta, 3); +} + +void testInt8ArrayWithinDeltaAndMessage(void) +{ + UNITY_INT8 expected[] = {20, -95, 55}; + UNITY_INT8 actualSmallDelta[] = {21, -94, 55}; + UNITY_INT8 actualBigDelta[] = {11, -86, 45}; + + TEST_ASSERT_INT8_ARRAY_WITHIN_MESSAGE(1, expected, actualSmallDelta, 3, "Custom Message."); + TEST_ASSERT_INT8_ARRAY_WITHIN_MESSAGE(11, expected, actualBigDelta, 3, "Custom Message."); +} + +void testInt8ArrayNotWithinDelta(void) +{ + UNITY_INT8 expected[] = {20, -95, 55}; + UNITY_INT8 actualBigDelta[] = {11, -86, 45}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_INT8_ARRAY_WITHIN(1, expected, actualBigDelta, 3); + VERIFY_FAILS_END +} + +void testInt8ArrayNotWithinDeltaAndMessage(void) +{ + UNITY_INT8 expected[] = {20, -95, 55}; + UNITY_INT8 actualBigDelta[] = {11, -86, 45}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_INT8_ARRAY_WITHIN_MESSAGE(1, expected, actualBigDelta, 3, "Custom Message."); + VERIFY_FAILS_END +} + +void testInt8ArrayWithinDeltaPointless(void) +{ + UNITY_INT8 expected[] = {20, -95, 55}; + UNITY_INT8 actualBigDelta[] = {11, -86, 45}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_INT8_ARRAY_WITHIN(11, expected, actualBigDelta, 0); + VERIFY_FAILS_END +} + +void testInt8ArrayWithinDeltaPointlessAndMessage(void) +{ + UNITY_INT8 expected[] = {20, -95, 55}; + UNITY_INT8 actualBigDelta[] = {11, -86, 45}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_INT8_ARRAY_WITHIN_MESSAGE(11, expected, actualBigDelta, 0, "Custom Message."); + VERIFY_FAILS_END +} + +void testInt8ArrayWithinDeltaExpectedNull(void) +{ + UNITY_INT8 actualBigDelta[] = {11, -86, 45}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_INT8_ARRAY_WITHIN(11, NULL, actualBigDelta, 3); + VERIFY_FAILS_END +} + +void testInt8ArrayWithinDeltaExpectedNullAndMessage(void) +{ + UNITY_INT8 actualBigDelta[] = {11, -86, 45}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_INT8_ARRAY_WITHIN_MESSAGE(11, NULL, actualBigDelta, 3, "Custom Message."); + VERIFY_FAILS_END +} + +void testInt8ArrayWithinDeltaActualNull(void) +{ + UNITY_INT8 expected[] = {20, -95, 55}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_INT8_ARRAY_WITHIN(11, expected, NULL, 3); + VERIFY_FAILS_END +} + +void testInt8ArrayWithinDeltaActualNullAndMessage(void) +{ + UNITY_INT8 expected[] = {20, -95, 55}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_INT8_ARRAY_WITHIN_MESSAGE(11, expected, NULL, 3, "Custom Message."); + VERIFY_FAILS_END +} + +void testInt8ArrayWithinDeltaSamePointer(void) +{ + UNITY_INT8 expected[] = {20, -95, 55}; + + TEST_ASSERT_INT8_ARRAY_WITHIN(11, expected, expected, 3); +} + +void testInt8ArrayWithinDeltaSamePointerAndMessage(void) +{ + UNITY_INT8 expected[] = {20, -95, 55}; + + TEST_ASSERT_INT8_ARRAY_WITHIN_MESSAGE(11, expected, expected, 3, "Custom Message."); +} + +void testCHARArrayWithinDelta(void) +{ + char expected[] = {20, -95, 55}; + char actualSmallDelta[] = {21, -94, 55}; + char actualBigDelta[] = {11, -86, 45}; + + TEST_ASSERT_CHAR_ARRAY_WITHIN(1, expected, actualSmallDelta, 3); + TEST_ASSERT_CHAR_ARRAY_WITHIN(11, expected, actualBigDelta, 3); +} + +void testCHARArrayWithinDeltaAndMessage(void) +{ + char expected[] = {20, -95, 55}; + char actualSmallDelta[] = {21, -94, 55}; + char actualBigDelta[] = {11, -86, 45}; + + TEST_ASSERT_CHAR_ARRAY_WITHIN_MESSAGE(1, expected, actualSmallDelta, 3, "Custom Message."); + TEST_ASSERT_CHAR_ARRAY_WITHIN_MESSAGE(11, expected, actualBigDelta, 3, "Custom Message."); +} + +void testCHARArrayNotWithinDelta(void) +{ + char expected[] = {20, -95, 55}; + char actualBigDelta[] = {11, -86, 45}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_CHAR_ARRAY_WITHIN(1, expected, actualBigDelta, 3); + VERIFY_FAILS_END +} + +void testCHARArrayNotWithinDeltaAndMessage(void) +{ + char expected[] = {20, -95, 55}; + char actualBigDelta[] = {11, -86, 45}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_CHAR_ARRAY_WITHIN_MESSAGE(1, expected, actualBigDelta, 3, "Custom Message."); + VERIFY_FAILS_END +} + +void testCHARArrayWithinDeltaPointless(void) +{ + char expected[] = {20, -95, 55}; + char actualBigDelta[] = {11, -86, 45}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_CHAR_ARRAY_WITHIN(11, expected, actualBigDelta, 0); + VERIFY_FAILS_END +} + +void testCHARArrayWithinDeltaPointlessAndMessage(void) +{ + char expected[] = {20, -95, 55}; + char actualBigDelta[] = {11, -86, 45}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_CHAR_ARRAY_WITHIN_MESSAGE(11, expected, actualBigDelta, 0, "Custom Message."); + VERIFY_FAILS_END +} + +void testCHARArrayWithinDeltaExpectedNull(void) +{ + char actualBigDelta[] = {11, -86, 45}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_CHAR_ARRAY_WITHIN(11, NULL, actualBigDelta, 3); + VERIFY_FAILS_END +} + +void testCHARArrayWithinDeltaExpectedNullAndMessage(void) +{ + char actualBigDelta[] = {11, -86, 45}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_CHAR_ARRAY_WITHIN_MESSAGE(11, NULL, actualBigDelta, 3, "Custom Message."); + VERIFY_FAILS_END +} + +void testCHARArrayWithinDeltaActualNull(void) +{ + char expected[] = {20, -95, 55}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_CHAR_ARRAY_WITHIN(11, expected, NULL, 3); + VERIFY_FAILS_END +} + +void testCHARArrayWithinDeltaActualNullAndMessage(void) +{ + char expected[] = {20, -95, 55}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_CHAR_ARRAY_WITHIN_MESSAGE(11, expected, NULL, 3, "Custom Message."); + VERIFY_FAILS_END +} + +void testCHARArrayWithinDeltaSamePointer(void) +{ + char expected[] = {20, -95, 55}; + + TEST_ASSERT_CHAR_ARRAY_WITHIN(11, expected, expected, 3); +} + +void testCHARArrayWithinDeltaSamePointerAndMessage(void) +{ + char expected[] = {20, -95, 55}; + + TEST_ASSERT_CHAR_ARRAY_WITHIN_MESSAGE(11, expected, expected, 3, "Custom Message."); +} + +void testUInt64ArrayWithinDelta(void) +{ +#ifndef UNITY_SUPPORT_64 + TEST_IGNORE(); +#else + UNITY_UINT64 expected[] = {12345000, 12344995, 12345005}; + UNITY_UINT64 actualSmallDelta[] = {12345001, 12344996, 12345005}; + UNITY_UINT64 actualBigDelta[] = {12345101, 12344896, 12345055}; + + TEST_ASSERT_UINT64_ARRAY_WITHIN(1, expected, actualSmallDelta, 3); + TEST_ASSERT_UINT64_ARRAY_WITHIN(110, expected, actualBigDelta, 3); +#endif +} + +void testUInt64ArrayWithinDeltaAndMessage(void) +{ +#ifndef UNITY_SUPPORT_64 + TEST_IGNORE(); +#else + UNITY_UINT64 expected[] = {12345000, 12344995, 12345005}; + UNITY_UINT64 actualSmallDelta[] = {12345001, 12344996, 12345005}; + UNITY_UINT64 actualBigDelta[] = {12345101, 12344896, 12345055}; + + TEST_ASSERT_UINT64_ARRAY_WITHIN_MESSAGE(1, expected, actualSmallDelta, 3, "Custom Message."); + TEST_ASSERT_UINT64_ARRAY_WITHIN_MESSAGE(110, expected, actualBigDelta, 3, "Custom Message."); +#endif +} + +void testUInt64ArrayNotWithinDelta(void) +{ +#ifndef UNITY_SUPPORT_64 + TEST_IGNORE(); +#else + UNITY_UINT64 expected[] = {12345000, 12344995, 12345005}; + UNITY_UINT64 actualBigDelta[] = {12345101, 12344896, 12345055}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_UINT64_ARRAY_WITHIN(1, expected, actualBigDelta, 3); + VERIFY_FAILS_END +#endif +} + +void testUInt64ArrayNotWithinDeltaAndMessage(void) +{ +#ifndef UNITY_SUPPORT_64 + TEST_IGNORE(); +#else + UNITY_UINT64 expected[] = {12345000, 12344995, 12345005}; + UNITY_UINT64 actualBigDelta[] = {12345101, 12344896, 12345055}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_UINT64_ARRAY_WITHIN_MESSAGE(1, expected, actualBigDelta, 3, "Custom Message."); + VERIFY_FAILS_END +#endif +} + +void testUInt64ArrayWithinDeltaPointless(void) +{ +#ifndef UNITY_SUPPORT_64 + TEST_IGNORE(); +#else + UNITY_UINT64 expected[] = {12345000, 12344995, 12345005}; + UNITY_UINT64 actualBigDelta[] = {12345101, 12344896, 12345055}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_UINT64_ARRAY_WITHIN(110, expected, actualBigDelta, 0); + VERIFY_FAILS_END +#endif +} + +void testUInt64ArrayWithinDeltaPointlessAndMessage(void) +{ +#ifndef UNITY_SUPPORT_64 + TEST_IGNORE(); +#else + UNITY_UINT64 expected[] = {12345000, 12344995, 12345005}; + UNITY_UINT64 actualBigDelta[] = {12345101, 12344896, 12345055}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_UINT64_ARRAY_WITHIN_MESSAGE(110, expected, actualBigDelta, 0, "Custom Message."); + VERIFY_FAILS_END +#endif +} + +void testUInt64ArrayWithinDeltaExpectedNull(void) +{ +#ifndef UNITY_SUPPORT_64 + TEST_IGNORE(); +#else + UNITY_UINT64 actualBigDelta[] = {12345101, 12344896, 12345055}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_UINT64_ARRAY_WITHIN(110, NULL, actualBigDelta, 3); + VERIFY_FAILS_END +#endif +} + +void testUInt64ArrayWithinDeltaExpectedNullAndMessage(void) +{ +#ifndef UNITY_SUPPORT_64 + TEST_IGNORE(); +#else + UNITY_UINT64 actualBigDelta[] = {12345101, 12344896, 12345055}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_UINT64_ARRAY_WITHIN_MESSAGE(110, NULL, actualBigDelta, 3, "Custom Message."); + VERIFY_FAILS_END +#endif +} + +void testUInt64ArrayWithinDeltaActualNull(void) +{ +#ifndef UNITY_SUPPORT_64 + TEST_IGNORE(); +#else + UNITY_UINT64 expected[] = {12345000, 12344995, 12345005}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_UINT64_ARRAY_WITHIN(110, expected, NULL, 3); + VERIFY_FAILS_END +#endif +} + +void testUInt64ArrayWithinDeltaActualNullAndMessage(void) +{ +#ifndef UNITY_SUPPORT_64 + TEST_IGNORE(); +#else + UNITY_UINT64 expected[] = {12345000, 12344995, 12345005}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_UINT64_ARRAY_WITHIN_MESSAGE(110, expected, NULL, 3, "Custom Message."); + VERIFY_FAILS_END +#endif +} + +void testUInt64ArrayWithinDeltaSamePointer(void) +{ +#ifndef UNITY_SUPPORT_64 + TEST_IGNORE(); +#else + UNITY_UINT64 expected[] = {12345000, 12344995, 12345005}; + + TEST_ASSERT_UINT64_ARRAY_WITHIN(110, expected, expected, 3); +#endif +} + +void testUInt64ArrayWithinDeltaSamePointerAndMessage(void) +{ +#ifndef UNITY_SUPPORT_64 + TEST_IGNORE(); +#else + UNITY_UINT64 expected[] = {12345000, 12344995, 12345005}; + + TEST_ASSERT_UINT64_ARRAY_WITHIN_MESSAGE(110, expected, expected, 3, "Custom Message."); +#endif +} + +void testUIntArrayWithinDelta(void) +{ + UNITY_UINT expected[] = {125000, 124995, 125005}; + UNITY_UINT actualSmallDelta[] = {125001, 124996, 125005}; + UNITY_UINT actualBigDelta[] = {125101, 124896, 125055}; + + TEST_ASSERT_UINT_ARRAY_WITHIN(1, expected, actualSmallDelta, 3); + TEST_ASSERT_UINT_ARRAY_WITHIN(110, expected, actualBigDelta, 3); +} + +void testUIntArrayWithinDeltaAndMessage(void) +{ + UNITY_UINT expected[] = {125000, 124995, 125005}; + UNITY_UINT actualSmallDelta[] = {125001, 124996, 125005}; + UNITY_UINT actualBigDelta[] = {125101, 124896, 125055}; + + TEST_ASSERT_UINT_ARRAY_WITHIN_MESSAGE(1, expected, actualSmallDelta, 3, "Custom Message."); + TEST_ASSERT_UINT_ARRAY_WITHIN_MESSAGE(110, expected, actualBigDelta, 3, "Custom Message."); +} + +void testUIntArrayNotWithinDelta(void) +{ + UNITY_UINT expected[] = {125000, 124995, 125005}; + UNITY_UINT actualBigDelta[] = {125101, 124896, 125055}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_UINT_ARRAY_WITHIN(1, expected, actualBigDelta, 3); + VERIFY_FAILS_END +} + +void testUIntArrayNotWithinDeltaAndMessage(void) +{ + UNITY_UINT expected[] = {125000, 124995, 125005}; + UNITY_UINT actualBigDelta[] = {125101, 124896, 125055}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_UINT_ARRAY_WITHIN_MESSAGE(1, expected, actualBigDelta, 3, "Custom Message."); + VERIFY_FAILS_END +} + +void testUIntArrayWithinDeltaPointless(void) +{ + UNITY_UINT expected[] = {125000, 124995, 125005}; + UNITY_UINT actualBigDelta[] = {125101, 124896, 125055}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_UINT_ARRAY_WITHIN(110, expected, actualBigDelta, 0); + VERIFY_FAILS_END +} + +void testUIntArrayWithinDeltaPointlessAndMessage(void) +{ + UNITY_UINT expected[] = {125000, 124995, 125005}; + UNITY_UINT actualBigDelta[] = {125101, 124896, 125055}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_UINT_ARRAY_WITHIN_MESSAGE(110, expected, actualBigDelta, 0, "Custom Message."); + VERIFY_FAILS_END +} + +void testUIntArrayWithinDeltaExpectedNull(void) +{ + UNITY_UINT actualBigDelta[] = {125101, 124896, 125055}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_UINT_ARRAY_WITHIN(110, NULL, actualBigDelta, 3); + VERIFY_FAILS_END +} + +void testUIntArrayWithinDeltaExpectedNullAndMessage(void) +{ + UNITY_UINT actualBigDelta[] = {125101, 124896, 125055}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_UINT_ARRAY_WITHIN_MESSAGE(110, NULL, actualBigDelta, 3, "Custom Message."); + VERIFY_FAILS_END +} + +void testUIntArrayWithinDeltaActualNull(void) +{ + UNITY_UINT expected[] = {125000, 124995, 125005}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_UINT_ARRAY_WITHIN(110, expected, NULL, 3); + VERIFY_FAILS_END +} + +void testUIntArrayWithinDeltaActualNullAndMessage(void) +{ + UNITY_UINT expected[] = {125000, 124995, 125005}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_UINT_ARRAY_WITHIN_MESSAGE(110, expected, NULL, 3, "Custom Message."); + VERIFY_FAILS_END +} + +void testUIntArrayWithinDeltaSamePointer(void) +{ + UNITY_UINT expected[] = {125000, 124995, 125005}; + + TEST_ASSERT_UINT_ARRAY_WITHIN(110, expected, expected, 3); +} + +void testUIntArrayWithinDeltaSamePointerAndMessage(void) +{ + UNITY_UINT expected[] = {125000, 124995, 125005}; + + TEST_ASSERT_UINT_ARRAY_WITHIN_MESSAGE(110, expected, expected, 3, "Custom Message."); +} + +void testUInt16ArrayWithinDelta(void) +{ + UNITY_UINT16 expected[] = {5000, 4995, 5005}; + UNITY_UINT16 actualSmallDelta[] = {5001, 4996, 5005}; + UNITY_UINT16 actualBigDelta[] = {5101, 4896, 5055}; + + TEST_ASSERT_UINT16_ARRAY_WITHIN(1, expected, actualSmallDelta, 3); + TEST_ASSERT_UINT16_ARRAY_WITHIN(110, expected, actualBigDelta, 3); +} + +void testUInt16ArrayWithinDeltaAndMessage(void) +{ + UNITY_UINT16 expected[] = {5000, 4995, 5005}; + UNITY_UINT16 actualSmallDelta[] = {5001, 4996, 5005}; + UNITY_UINT16 actualBigDelta[] = {5101, 4896, 5055}; + + TEST_ASSERT_UINT16_ARRAY_WITHIN_MESSAGE(1, expected, actualSmallDelta, 3, "Custom Message."); + TEST_ASSERT_UINT16_ARRAY_WITHIN_MESSAGE(110, expected, actualBigDelta, 3, "Custom Message."); +} + +void testUInt16ArrayNotWithinDelta(void) +{ + UNITY_UINT16 expected[] = {5000, 4995, 5005}; + UNITY_UINT16 actualBigDelta[] = {5101, 4896, 5055}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_UINT16_ARRAY_WITHIN(1, expected, actualBigDelta, 3); + VERIFY_FAILS_END +} + +void testUInt16ArrayNotWithinDeltaAndMessage(void) +{ + UNITY_UINT16 expected[] = {5000, 4995, 5005}; + UNITY_UINT16 actualBigDelta[] = {5101, 4896, 5055}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_UINT16_ARRAY_WITHIN_MESSAGE(1, expected, actualBigDelta, 3, "Custom Message."); + VERIFY_FAILS_END +} + +void testUInt16ArrayWithinDeltaPointless(void) +{ + UNITY_UINT16 expected[] = {5000, 4995, 5005}; + UNITY_UINT16 actualBigDelta[] = {5101, 4896, 5055}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_UINT16_ARRAY_WITHIN(110, expected, actualBigDelta, 0); + VERIFY_FAILS_END +} + +void testUInt16ArrayWithinDeltaPointlessAndMessage(void) +{ + UNITY_UINT16 expected[] = {5000, 4995, 5005}; + UNITY_UINT16 actualBigDelta[] = {5101, 4896, 5055}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_UINT16_ARRAY_WITHIN_MESSAGE(110, expected, actualBigDelta, 0, "Custom Message."); + VERIFY_FAILS_END +} + +void testUInt16ArrayWithinDeltaExpectedNull(void) +{ + UNITY_UINT16 actualBigDelta[] = {5101, 4896, 5055}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_UINT16_ARRAY_WITHIN(110, NULL, actualBigDelta, 3); + VERIFY_FAILS_END +} + +void testUInt16ArrayWithinDeltaExpectedNullAndMessage(void) +{ + UNITY_UINT16 actualBigDelta[] = {5101, 4896, 5055}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_UINT16_ARRAY_WITHIN_MESSAGE(110, NULL, actualBigDelta, 3, "Custom Message."); + VERIFY_FAILS_END +} + +void testUInt16ArrayWithinDeltaActualNull(void) +{ + UNITY_UINT16 expected[] = {5000, 4995, 5005}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_UINT16_ARRAY_WITHIN(110, expected, NULL, 3); + VERIFY_FAILS_END +} + +void testUInt16ArrayWithinDeltaActualNullAndMessage(void) +{ + UNITY_UINT16 expected[] = {5000, 4995, 5005}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_UINT16_ARRAY_WITHIN_MESSAGE(110, expected, NULL, 3, "Custom Message."); + VERIFY_FAILS_END +} + +void testUInt16ArrayWithinDeltaSamePointer(void) +{ + UNITY_UINT16 expected[] = {5000, 4995, 5005}; + + TEST_ASSERT_UINT16_ARRAY_WITHIN(110, expected, expected, 3); +} + +void testUInt16ArrayWithinDeltaSamePointerAndMessage(void) +{ + UNITY_UINT16 expected[] = {5000, 4995, 5005}; + + TEST_ASSERT_UINT16_ARRAY_WITHIN_MESSAGE(110, expected, expected, 3, "Custom Message."); +} + +void testUInt8ArrayWithinDelta(void) +{ + UNITY_UINT8 expected[] = {20, 95, 55}; + UNITY_UINT8 actualSmallDelta[] = {21, 94, 55}; + UNITY_UINT8 actualBigDelta[] = {11, 86, 45}; + + TEST_ASSERT_UINT8_ARRAY_WITHIN(1, expected, actualSmallDelta, 3); + TEST_ASSERT_UINT8_ARRAY_WITHIN(11, expected, actualBigDelta, 3); +} + +void testUInt8ArrayWithinDeltaAndMessage(void) +{ + UNITY_UINT8 expected[] = {20, 95, 55}; + UNITY_UINT8 actualSmallDelta[] = {21, 94, 55}; + UNITY_UINT8 actualBigDelta[] = {11, 86, 45}; + + TEST_ASSERT_UINT8_ARRAY_WITHIN_MESSAGE(1, expected, actualSmallDelta, 3, "Custom Message."); + TEST_ASSERT_UINT8_ARRAY_WITHIN_MESSAGE(11, expected, actualBigDelta, 3, "Custom Message."); +} + +void testUInt8ArrayNotWithinDelta(void) +{ + UNITY_UINT8 expected[] = {20, 95, 55}; + UNITY_UINT8 actualBigDelta[] = {11, 86, 45}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_UINT8_ARRAY_WITHIN(1, expected, actualBigDelta, 3); + VERIFY_FAILS_END +} + +void testUInt8ArrayNotWithinDeltaAndMessage(void) +{ + UNITY_UINT8 expected[] = {20, 95, 55}; + UNITY_UINT8 actualBigDelta[] = {11, 86, 45}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_UINT8_ARRAY_WITHIN_MESSAGE(1, expected, actualBigDelta, 3, "Custom Message."); + VERIFY_FAILS_END +} + +void testUInt8ArrayWithinDeltaPointless(void) +{ + UNITY_UINT8 expected[] = {20, 95, 55}; + UNITY_UINT8 actualBigDelta[] = {11, 86, 45}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_UINT8_ARRAY_WITHIN(11, expected, actualBigDelta, 0); + VERIFY_FAILS_END +} + +void testUInt8ArrayWithinDeltaPointlessAndMessage(void) +{ + UNITY_UINT8 expected[] = {20, 95, 55}; + UNITY_UINT8 actualBigDelta[] = {11, 86, 45}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_UINT8_ARRAY_WITHIN_MESSAGE(11, expected, actualBigDelta, 0, "Custom Message."); + VERIFY_FAILS_END +} + +void testUInt8ArrayWithinDeltaExpectedNull(void) +{ + UNITY_UINT8 actualBigDelta[] = {11, 86, 45}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_UINT8_ARRAY_WITHIN(11, NULL, actualBigDelta, 3); + VERIFY_FAILS_END +} + +void testUInt8ArrayWithinDeltaExpectedNullAndMessage(void) +{ + UNITY_UINT8 actualBigDelta[] = {11, 86, 45}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_UINT8_ARRAY_WITHIN_MESSAGE(11, NULL, actualBigDelta, 3, "Custom Message."); + VERIFY_FAILS_END +} + +void testUInt8ArrayWithinDeltaActualNull(void) +{ + UNITY_UINT8 expected[] = {20, 95, 55}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_UINT8_ARRAY_WITHIN(11, expected, NULL, 3); + VERIFY_FAILS_END +} + +void testUInt8ArrayWithinDeltaActualNullAndMessage(void) +{ + UNITY_UINT8 expected[] = {20, 95, 55}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_UINT8_ARRAY_WITHIN_MESSAGE(11, expected, NULL, 3, "Custom Message."); + VERIFY_FAILS_END +} + +void testUInt8ArrayWithinDeltaSamePointer(void) +{ + UNITY_UINT8 expected[] = {20, 95, 55}; + + TEST_ASSERT_UINT8_ARRAY_WITHIN(11, expected, expected, 3); +} + +void testUInt8ArrayWithinDeltaSamePointerAndMessage(void) +{ + UNITY_UINT8 expected[] = {20, 95, 55}; + + TEST_ASSERT_UINT8_ARRAY_WITHIN_MESSAGE(11, expected, expected, 3, "Custom Message."); +} + +void testHEX64ArrayWithinDelta(void) +{ +#ifndef UNITY_SUPPORT_64 + TEST_IGNORE(); +#else + UNITY_UINT64 expected[] = {0xABCD123400000000, 0xABCD112200000000, 0xABCD127700000000}; + UNITY_UINT64 actualSmallDelta[] = {0xABCD123500000000, 0xABCD112100000000, 0xABCD127700000000}; + UNITY_UINT64 actualBigDelta[] = {0xABCD126700000000, 0xABCD118800000000, 0xABCD12AC00000000}; + + TEST_ASSERT_HEX64_ARRAY_WITHIN(0x100000000, expected, actualSmallDelta, 3); + TEST_ASSERT_HEX64_ARRAY_WITHIN(0x6E00000000, expected, actualBigDelta, 3); +#endif +} + +void testHEX64ArrayWithinDeltaAndMessage(void) +{ +#ifndef UNITY_SUPPORT_64 + TEST_IGNORE(); +#else + UNITY_UINT64 expected[] = {0xABCD123400000000, 0xABCD112200000000, 0xABCD127700000000}; + UNITY_UINT64 actualSmallDelta[] = {0xABCD123500000000, 0xABCD112100000000, 0xABCD127700000000}; + UNITY_UINT64 actualBigDelta[] = {0xABCD126700000000, 0xABCD118800000000, 0xABCD12AC00000000}; + + TEST_ASSERT_HEX64_ARRAY_WITHIN_MESSAGE(0x100000000, expected, actualSmallDelta, 3, "Custom Message."); + TEST_ASSERT_HEX64_ARRAY_WITHIN_MESSAGE(0x6E00000000, expected, actualBigDelta, 3, "Custom Message."); +#endif +} + +void testHEX64ArrayNotWithinDelta(void) +{ +#ifndef UNITY_SUPPORT_64 + TEST_IGNORE(); +#else + UNITY_UINT64 expected[] = {0xABCD123400000000, 0xABCD112200000000, 0xABCD127700000000}; + UNITY_UINT64 actualBigDelta[] = {0xABCD126700000000, 0xABCD118800000000, 0xABCD12AC00000000}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_HEX64_ARRAY_WITHIN(0x100000000, expected, actualBigDelta, 3); + VERIFY_FAILS_END +#endif +} + +void testHEX64ArrayNotWithinDeltaAndMessage(void) +{ +#ifndef UNITY_SUPPORT_64 + TEST_IGNORE(); +#else + UNITY_UINT64 expected[] = {0xABCD123400000000, 0xABCD112200000000, 0xABCD127700000000}; + UNITY_UINT64 actualBigDelta[] = {0xABCD126700000000, 0xABCD118800000000, 0xABCD12AC00000000}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_HEX64_ARRAY_WITHIN_MESSAGE(0x100000000, expected, actualBigDelta, 3, "Custom Message."); + VERIFY_FAILS_END +#endif +} + +void testHEX64ArrayWithinDeltaPointless(void) +{ +#ifndef UNITY_SUPPORT_64 + TEST_IGNORE(); +#else + UNITY_UINT64 expected[] = {0xABCD123400000000, 0xABCD112200000000, 0xABCD127700000000}; + UNITY_UINT64 actualBigDelta[] = {0xABCD126700000000, 0xABCD118800000000, 0xABCD12AC00000000}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_HEX64_ARRAY_WITHIN(0x6E00000000, expected, actualBigDelta, 0); + VERIFY_FAILS_END +#endif +} + +void testHEX64ArrayWithinDeltaPointlessAndMessage(void) +{ +#ifndef UNITY_SUPPORT_64 + TEST_IGNORE(); +#else + UNITY_UINT64 expected[] = {0xABCD123400000000, 0xABCD112200000000, 0xABCD127700000000}; + UNITY_UINT64 actualBigDelta[] = {0xABCD126700000000, 0xABCD118800000000, 0xABCD12AC00000000}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_HEX64_ARRAY_WITHIN_MESSAGE(0x6E00000000, expected, actualBigDelta, 0, "Custom Message."); + VERIFY_FAILS_END +#endif +} + +void testHEX64ArrayWithinDeltaExpectedNull(void) +{ +#ifndef UNITY_SUPPORT_64 + TEST_IGNORE(); +#else + UNITY_UINT64 actualBigDelta[] = {0xABCD126700000000, 0xABCD118800000000, 0xABCD12AC00000000}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_HEX64_ARRAY_WITHIN(0x6E00000000, NULL, actualBigDelta, 3); + VERIFY_FAILS_END +#endif +} + +void testHEX64ArrayWithinDeltaExpectedNullAndMessage(void) +{ +#ifndef UNITY_SUPPORT_64 + TEST_IGNORE(); +#else + UNITY_UINT64 actualBigDelta[] = {0xABCD126700000000, 0xABCD118800000000, 0xABCD12AC00000000}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_HEX64_ARRAY_WITHIN_MESSAGE(0x6E00000000, NULL, actualBigDelta, 3, "Custom Message."); + VERIFY_FAILS_END +#endif +} + +void testHEX64ArrayWithinDeltaActualNull(void) +{ +#ifndef UNITY_SUPPORT_64 + TEST_IGNORE(); +#else + UNITY_UINT64 expected[] = {0xABCD123400000000, 0xABCD112200000000, 0xABCD127700000000}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_HEX64_ARRAY_WITHIN(0x6E00000000, expected, NULL, 3); + VERIFY_FAILS_END +#endif +} + +void testHEX64ArrayWithinDeltaActualNullAndMessage(void) +{ +#ifndef UNITY_SUPPORT_64 + TEST_IGNORE(); +#else + UNITY_UINT64 expected[] = {0xABCD123400000000, 0xABCD112200000000, 0xABCD127700000000}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_HEX64_ARRAY_WITHIN_MESSAGE(0x6E00000000, expected, NULL, 3, "Custom Message."); + VERIFY_FAILS_END +#endif +} + +void testHEX64ArrayWithinDeltaSamePointer(void) +{ +#ifndef UNITY_SUPPORT_64 + TEST_IGNORE(); +#else + UNITY_UINT64 expected[] = {0xABCD123400000000, 0xABCD112200000000, 0xABCD127700000000}; + + TEST_ASSERT_HEX64_ARRAY_WITHIN(0x6E00000000, expected, expected, 3); +#endif +} + +void testHEX64ArrayWithinDeltaSamePointerAndMessage(void) +{ +#ifndef UNITY_SUPPORT_64 + TEST_IGNORE(); +#else + UNITY_UINT64 expected[] = {0xABCD123400000000, 0xABCD112200000000, 0xABCD127700000000}; + + TEST_ASSERT_HEX64_ARRAY_WITHIN_MESSAGE(0x6E00000000, expected, expected, 3, "Custom Message."); +#endif +} + +void testHEX32ArrayWithinDelta(void) +{ + UNITY_UINT expected[] = {0xABCD1234, 0xABCD1122, 0xABCD1277}; + UNITY_UINT actualSmallDelta[] = {0xABCD1235, 0xABCD1121, 0xABCD1277}; + UNITY_UINT actualBigDelta[] = {0xABCD1267, 0xABCD1188, 0xABCD12AC}; + + TEST_ASSERT_HEX32_ARRAY_WITHIN(1, expected, actualSmallDelta, 3); + TEST_ASSERT_HEX32_ARRAY_WITHIN(110, expected, actualBigDelta, 3); +} + +void testHEX32ArrayWithinDeltaAndMessage(void) +{ + UNITY_UINT expected[] = {0xABCD1234, 0xABCD1122, 0xABCD1277}; + UNITY_UINT actualSmallDelta[] = {0xABCD1235, 0xABCD1121, 0xABCD1277}; + UNITY_UINT actualBigDelta[] = {0xABCD1267, 0xABCD1188, 0xABCD12AC}; + + TEST_ASSERT_HEX32_ARRAY_WITHIN_MESSAGE(1, expected, actualSmallDelta, 3, "Custom Message."); + TEST_ASSERT_HEX32_ARRAY_WITHIN_MESSAGE(110, expected, actualBigDelta, 3, "Custom Message."); +} + +void testHEX32ArrayNotWithinDelta(void) +{ + UNITY_UINT expected[] = {0xABCD1234, 0xABCD1122, 0xABCD1277}; + UNITY_UINT actualBigDelta[] = {0xABCD1267, 0xABCD1188, 0xABCD12AC}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_HEX32_ARRAY_WITHIN(1, expected, actualBigDelta, 3); + VERIFY_FAILS_END +} + +void testHEX32ArrayNotWithinDeltaAndMessage(void) +{ + UNITY_UINT expected[] = {0xABCD1234, 0xABCD1122, 0xABCD1277}; + UNITY_UINT actualBigDelta[] = {0xABCD1267, 0xABCD1188, 0xABCD12AC}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_HEX32_ARRAY_WITHIN_MESSAGE(1, expected, actualBigDelta, 3, "Custom Message."); + VERIFY_FAILS_END +} + +void testHEX32ArrayWithinDeltaPointless(void) +{ + UNITY_UINT expected[] = {0xABCD1234, 0xABCD1122, 0xABCD1277}; + UNITY_UINT actualBigDelta[] = {0xABCD1267, 0xABCD1188, 0xABCD12AC}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_HEX32_ARRAY_WITHIN(110, expected, actualBigDelta, 0); + VERIFY_FAILS_END +} + +void testHEX32ArrayWithinDeltaPointlessAndMessage(void) +{ + UNITY_UINT expected[] = {0xABCD1234, 0xABCD1122, 0xABCD1277}; + UNITY_UINT actualBigDelta[] = {0xABCD1267, 0xABCD1188, 0xABCD12AC}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_HEX32_ARRAY_WITHIN_MESSAGE(110, expected, actualBigDelta, 0, "Custom Message."); + VERIFY_FAILS_END +} + +void testHEX32ArrayWithinDeltaExpectedNull(void) +{ + UNITY_UINT actualBigDelta[] = {0xABCD1267, 0xABCD1188, 0xABCD12AC}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_HEX32_ARRAY_WITHIN(110, NULL, actualBigDelta, 3); + VERIFY_FAILS_END +} + +void testHEX32ArrayWithinDeltaExpectedNullAndMessage(void) +{ + UNITY_UINT actualBigDelta[] = {0xABCD1267, 0xABCD1188, 0xABCD12AC}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_HEX32_ARRAY_WITHIN_MESSAGE(110, NULL, actualBigDelta, 3, "Custom Message."); + VERIFY_FAILS_END +} + +void testHEX32ArrayWithinDeltaActualNull(void) +{ + UNITY_UINT expected[] = {0xABCD1234, 0xABCD1122, 0xABCD1277}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_HEX32_ARRAY_WITHIN(110, expected, NULL, 3); + VERIFY_FAILS_END +} + +void testHEX32ArrayWithinDeltaActualNullAndMessage(void) +{ + UNITY_UINT expected[] = {0xABCD1234, 0xABCD1122, 0xABCD1277}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_HEX32_ARRAY_WITHIN_MESSAGE(110, expected, NULL, 3, "Custom Message."); + VERIFY_FAILS_END +} + +void testHEX32ArrayWithinDeltaSamePointer(void) +{ + UNITY_UINT expected[] = {0xABCD1234, 0xABCD1122, 0xABCD1277}; + + TEST_ASSERT_HEX32_ARRAY_WITHIN(110, expected, expected, 3); +} + +void testHEX32ArrayWithinDeltaSamePointerAndMessage(void) +{ + UNITY_UINT expected[] = {0xABCD1234, 0xABCD1122, 0xABCD1277}; + + TEST_ASSERT_HEX32_ARRAY_WITHIN_MESSAGE(110, expected, expected, 3, "Custom Message."); +} + + +void testHEX16ArrayWithinDelta(void) +{ + UNITY_UINT16 expected[] = {0x1234, 0x1122, 0x1277}; + UNITY_UINT16 actualSmallDelta[] = {0x1235, 0x1121, 0x1277}; + UNITY_UINT16 actualBigDelta[] = {0x1267, 0x1188, 0x12AC}; + + TEST_ASSERT_HEX16_ARRAY_WITHIN(1, expected, actualSmallDelta, 3); + TEST_ASSERT_HEX16_ARRAY_WITHIN(110, expected, actualBigDelta, 3); +} + +void testHEX16ArrayWithinDeltaAndMessage(void) +{ + UNITY_UINT16 expected[] = {0x1234, 0x1122, 0x1277}; + UNITY_UINT16 actualSmallDelta[] = {0x1235, 0x1121, 0x1277}; + UNITY_UINT16 actualBigDelta[] = {0x1267, 0x1188, 0x12AC}; + + TEST_ASSERT_HEX16_ARRAY_WITHIN_MESSAGE(1, expected, actualSmallDelta, 3, "Custom Message."); + TEST_ASSERT_HEX16_ARRAY_WITHIN_MESSAGE(110, expected, actualBigDelta, 3, "Custom Message."); +} + +void testHEX16ArrayNotWithinDelta(void) +{ + UNITY_UINT16 expected[] = {0x1234, 0x1122, 0x1277}; + UNITY_UINT16 actualBigDelta[] = {0x1267, 0x1188, 0x12AC}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_HEX16_ARRAY_WITHIN(1, expected, actualBigDelta, 3); + VERIFY_FAILS_END +} + +void testHEX16ArrayNotWithinDeltaAndMessage(void) +{ + UNITY_UINT16 expected[] = {0x1234, 0x1122, 0x1277}; + UNITY_UINT16 actualBigDelta[] = {0x1267, 0x1188, 0x12AC}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_HEX16_ARRAY_WITHIN_MESSAGE(1, expected, actualBigDelta, 3, "Custom Message."); + VERIFY_FAILS_END +} + +void testHEX16ArrayWithinDeltaPointless(void) +{ + UNITY_UINT16 expected[] = {0x1234, 0x1122, 0x1277}; + UNITY_UINT16 actualBigDelta[] = {0x1267, 0x1188, 0x12AC}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_HEX16_ARRAY_WITHIN(110, expected, actualBigDelta, 0); + VERIFY_FAILS_END +} + +void testHEX16ArrayWithinDeltaPointlessAndMessage(void) +{ + UNITY_UINT16 expected[] = {0x1234, 0x1122, 0x1277}; + UNITY_UINT16 actualBigDelta[] = {0x1267, 0x1188, 0x12AC}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_HEX16_ARRAY_WITHIN_MESSAGE(110, expected, actualBigDelta, 0, "Custom Message."); + VERIFY_FAILS_END +} + +void testHEX16ArrayWithinDeltaExpectedNull(void) +{ + UNITY_UINT16 actualBigDelta[] = {0x1267, 0x1188, 0x12AC}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_HEX16_ARRAY_WITHIN(110, NULL, actualBigDelta, 3); + VERIFY_FAILS_END +} + +void testHEX16ArrayWithinDeltaExpectedNullAndMessage(void) +{ + UNITY_UINT16 actualBigDelta[] = {0x1267, 0x1188, 0x12AC}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_HEX16_ARRAY_WITHIN_MESSAGE(110, NULL, actualBigDelta, 3, "Custom Message."); + VERIFY_FAILS_END +} + +void testHEX16ArrayWithinDeltaActualNull(void) +{ + UNITY_UINT16 expected[] = {0x1234, 0x1122, 0x1277}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_HEX16_ARRAY_WITHIN(110, expected, NULL, 3); + VERIFY_FAILS_END +} + +void testHEX16ArrayWithinDeltaActualNullAndMessage(void) +{ + UNITY_UINT16 expected[] = {0x1234, 0x1122, 0x1277}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_HEX16_ARRAY_WITHIN_MESSAGE(110, expected, NULL, 3, "Custom Message."); + VERIFY_FAILS_END +} + +void testHEX16ArrayWithinDeltaSamePointer(void) +{ + UNITY_UINT16 expected[] = {0x1234, 0x1122, 0x1277}; + + TEST_ASSERT_HEX16_ARRAY_WITHIN(110, expected, expected, 3); +} + +void testHEX16ArrayWithinDeltaSamePointerAndMessage(void) +{ + UNITY_UINT16 expected[] = {0x1234, 0x1122, 0x1277}; + + TEST_ASSERT_HEX16_ARRAY_WITHIN_MESSAGE(110, expected, expected, 3, "Custom Message."); +} + +void testHEX8ArrayWithinDelta(void) +{ + UNITY_UINT8 expected[] = {0x34, 0x22, 0x77}; + UNITY_UINT8 actualSmallDelta[] = {0x35, 0x21, 0x77}; + UNITY_UINT8 actualBigDelta[] = {0x47, 0x48, 0x4C}; + + TEST_ASSERT_HEX8_ARRAY_WITHIN(1, expected, actualSmallDelta, 3); + TEST_ASSERT_HEX8_ARRAY_WITHIN(60, expected, actualBigDelta, 3); +} + +void testHEX8ArrayWithinDeltaAndMessage(void) +{ + UNITY_UINT8 expected[] = {0x34, 0x22, 0x77}; + UNITY_UINT8 actualSmallDelta[] = {0x35, 0x21, 0x77}; + UNITY_UINT8 actualBigDelta[] = {0x47, 0x48, 0x4C}; + + TEST_ASSERT_HEX8_ARRAY_WITHIN_MESSAGE(1, expected, actualSmallDelta, 3, "Custom Message."); + TEST_ASSERT_HEX8_ARRAY_WITHIN_MESSAGE(60, expected, actualBigDelta, 3, "Custom Message."); +} + +void testHEX8ArrayNotWithinDelta(void) +{ + UNITY_UINT8 expected[] = {0x34, 0x22, 0x77}; + UNITY_UINT8 actualBigDelta[] = {0x67, 0x88, 0xAC}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_HEX8_ARRAY_WITHIN(1, expected, actualBigDelta, 3); + VERIFY_FAILS_END +} + +void testHEX8ArrayNotWithinDeltaAndMessage(void) +{ + UNITY_UINT8 expected[] = {0x34, 0x22, 0x77}; + UNITY_UINT8 actualBigDelta[] = {0x67, 0x88, 0xAC}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_HEX8_ARRAY_WITHIN_MESSAGE(1, expected, actualBigDelta, 3, "Custom Message."); + VERIFY_FAILS_END +} + +void testHEX8ArrayWithinDeltaPointless(void) +{ + UNITY_UINT8 expected[] = {0x34, 0x22, 0x77}; + UNITY_UINT8 actualBigDelta[] = {0x67, 0x88, 0xAC}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_HEX8_ARRAY_WITHIN(60, expected, actualBigDelta, 0); + VERIFY_FAILS_END +} + +void testHEX8ArrayWithinDeltaPointlessAndMessage(void) +{ + UNITY_UINT8 expected[] = {0x34, 0x22, 0x77}; + UNITY_UINT8 actualBigDelta[] = {0x67, 0x88, 0xAC}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_HEX8_ARRAY_WITHIN_MESSAGE(60, expected, actualBigDelta, 0, "Custom Message."); + VERIFY_FAILS_END +} + +void testHEX8ArrayWithinDeltaExpectedNull(void) +{ + UNITY_UINT8 actualBigDelta[] = {0x67, 0x88, 0xAC}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_HEX8_ARRAY_WITHIN(60, NULL, actualBigDelta, 3); + VERIFY_FAILS_END +} + +void testHEX8ArrayWithinDeltaExpectedNullAndMessage(void) +{ + UNITY_UINT8 actualBigDelta[] = {0x67, 0x88, 0xAC}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_HEX8_ARRAY_WITHIN_MESSAGE(60, NULL, actualBigDelta, 3, "Custom Message."); + VERIFY_FAILS_END +} + +void testHEX8ArrayWithinDeltaActualNull(void) +{ + UNITY_UINT8 expected[] = {0x34, 0x22, 0x77}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_HEX8_ARRAY_WITHIN(60, expected, NULL, 3); + VERIFY_FAILS_END +} + +void testHEX8ArrayWithinDeltaActualNullAndMessage(void) +{ + UNITY_UINT8 expected[] = {0x34, 0x22, 0x77}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_HEX8_ARRAY_WITHIN_MESSAGE(60, expected, NULL, 3, "Custom Message."); + VERIFY_FAILS_END +} + +void testHEX8ArrayWithinDeltaSamePointer(void) +{ + UNITY_UINT8 expected[] = {0x34, 0x22, 0x77}; + + TEST_ASSERT_HEX8_ARRAY_WITHIN(60, expected, expected, 3); +} + +void testHEX8ArrayWithinDeltaSamePointerAndMessage(void) +{ + UNITY_UINT8 expected[] = {0x34, 0x22, 0x77}; + + TEST_ASSERT_HEX8_ARRAY_WITHIN_MESSAGE(60, expected, expected, 3, "Custom Message."); +} + +void testEqualIntArrays(void) +{ + int p0[] = {1, 8, 987, -2}; + int p1[] = {1, 8, 987, -2}; + int p2[] = {1, 8, 987, 2}; + int p3[] = {1, 500, 600, 700}; + + TEST_ASSERT_EQUAL_INT_ARRAY(p0, p0, 1); + TEST_ASSERT_EQUAL_INT_ARRAY(p0, p0, 4); + TEST_ASSERT_EQUAL_INT_ARRAY(p0, p1, 4); + TEST_ASSERT_EQUAL_INT_ARRAY(p0, p2, 3); + TEST_ASSERT_EQUAL_INT_ARRAY(p0, p3, 1); + TEST_ASSERT_EQUAL_INT_ARRAY(NULL, NULL, 1); +} + +void testNotEqualIntArraysNullExpected(void) +{ + int* p0 = NULL; + int p1[] = {1, 8, 987, 2}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_EQUAL_INT_ARRAY(p0, p1, 4); + VERIFY_FAILS_END +} + +void testNotEqualIntArraysNullActual(void) +{ + int* p1 = NULL; + int p0[] = {1, 8, 987, 2}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_EQUAL_INT_ARRAY(p0, p1, 4); + VERIFY_FAILS_END +} + +void testNotEqualIntArrays1(void) +{ + int p0[] = {1, 8, 987, -2}; + int p1[] = {1, 8, 987, 2}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_EQUAL_INT_ARRAY(p0, p1, 4); + VERIFY_FAILS_END +} + +void testNotEqualIntArrays2(void) +{ + int p0[] = {1, 8, 987, -2}; + int p1[] = {2, 8, 987, -2}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_EQUAL_INT_ARRAY(p0, p1, 4); + VERIFY_FAILS_END +} + +void testNotEqualIntArrays3(void) +{ + int p0[] = {1, 8, 987, -2}; + int p1[] = {1, 8, 986, -2}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_EQUAL_INT_ARRAY(p0, p1, 4); + VERIFY_FAILS_END +} + +void testNotEqualIntArraysLengthZero(void) +{ + UNITY_UINT32 p0[1] = {1}; + UNITY_UINT32 p1[1] = {1}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_EQUAL_INT_ARRAY(p0, p1, 0); + VERIFY_FAILS_END +} + +void testEqualIntEachEqual(void) +{ + int p0[] = {1, 1, 1, 1}; + int p1[] = {987, 987, 987, 987}; + int p2[] = {-2, -2, -2, -3}; + int p3[] = {1, 5, 600, 700}; + + TEST_ASSERT_EACH_EQUAL_INT(1, p0, 1); + TEST_ASSERT_EACH_EQUAL_INT(1, p0, 4); + TEST_ASSERT_EACH_EQUAL_INT(987, p1, 4); + TEST_ASSERT_EACH_EQUAL_INT(-2, p2, 3); + TEST_ASSERT_EACH_EQUAL_INT(1, p3, 1); +} + +void testNotEqualIntEachEqualNullActual(void) +{ + int* p1 = NULL; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_EACH_EQUAL_INT(1, p1, 4); + VERIFY_FAILS_END +} + +void testNotEqualIntEachEqual1(void) +{ + int p0[] = {1, 1, 1, -2}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_EACH_EQUAL_INT(1, p0, 4); + VERIFY_FAILS_END +} + +void testNotEqualIntEachEqual2(void) +{ + int p0[] = {-5, -5, -1, -5}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_EACH_EQUAL_INT(-5, p0, 4); + VERIFY_FAILS_END +} + +void testNotEqualIntEachEqual3(void) +{ + int p0[] = {1, 88, 88, 88}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_EACH_EQUAL_INT(88, p0, 4); + VERIFY_FAILS_END +} + +void testNotEqualEachEqualLengthZero(void) +{ + UNITY_UINT32 p0[1] = {1}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_EACH_EQUAL_INT(0, p0, 0); + VERIFY_FAILS_END +} + +void testEqualPtrArrays(void) +{ + char A = 1; + char B = 2; + char C = 3; + char* p0[] = {&A, &B, &C}; + char* p1[] = {&A, &B, &C, &A}; + char* p2[] = {&A, &B}; + char* p3[] = {&A}; + + TEST_ASSERT_EQUAL_PTR_ARRAY(p0, p0, 1); + TEST_ASSERT_EQUAL_PTR_ARRAY(p0, p0, 3); + TEST_ASSERT_EQUAL_PTR_ARRAY(p0, p1, 3); + TEST_ASSERT_EQUAL_PTR_ARRAY(p1, p2, 2); + TEST_ASSERT_EQUAL_PTR_ARRAY(p3, p0, 1); +} + +void testNotEqualPtrArraysNullExpected(void) +{ + char A = 1; + char B = 2; + char** p0 = NULL; + char* p1[] = {&A, &B}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_EQUAL_PTR_ARRAY(p0, p1, 2); + VERIFY_FAILS_END +} + +void testNotEqualPtrArraysNullActual(void) +{ + char A = 1; + char B = 2; + char** p0 = NULL; + char* p1[] = {&A, &B}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_EQUAL_PTR_ARRAY(p1, p0, 2); + VERIFY_FAILS_END +} + +void testNotEqualPtrArrays1(void) +{ + char A = 1; + char B = 2; + char C = 3; + char* p0[] = {&A, &B, &C, &B}; + char* p1[] = {&A, &B, &C, &A}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_EQUAL_PTR_ARRAY(p0, p1, 4); + VERIFY_FAILS_END +} + +void testNotEqualPtrArrays2(void) +{ + char A = 1; + char B = 2; + char C = 3; + char* p0[] = {&B, &B, &C, &A}; + char* p1[] = {&A, &B, &C, &A}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_EQUAL_PTR_ARRAY(p0, p1, 4); + VERIFY_FAILS_END +} + +void testNotEqualPtrArrays3(void) +{ + char A = 1; + char B = 2; + char C = 3; + char* p0[] = {&A, &B, &B, &A}; + char* p1[] = {&A, &B, &C, &A}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_EQUAL_PTR_ARRAY(p0, p1, 4); + VERIFY_FAILS_END +} + +void testEqualPtrEachEqual(void) +{ + char A = 1; + char B = 2; + char C = 3; + char* p0[] = {&A, &A, &A}; + char* p1[] = {&A, &B, &C, &A}; + char* p2[] = {&B, &B}; + char* p3[] = {&C}; + + TEST_ASSERT_EACH_EQUAL_PTR(&A, p0, 1); + TEST_ASSERT_EACH_EQUAL_PTR(&A, p0, 3); + TEST_ASSERT_EACH_EQUAL_PTR(&A, p1, 1); + TEST_ASSERT_EACH_EQUAL_PTR(&B, p2, 2); + TEST_ASSERT_EACH_EQUAL_PTR(&C, p3, 1); +} + +void testNotEqualPtrEachEqualNullExpected(void) +{ + char A = 1; + char B = 1; + char* p0[] = {&A, &B}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_EACH_EQUAL_PTR(&A, p0, 2); + VERIFY_FAILS_END +} + +void testNotEqualPtrEachEqualNullActual(void) +{ + char A = 1; + char** p0 = NULL; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_EACH_EQUAL_PTR(&A, p0, 2); + VERIFY_FAILS_END +} + +void testNotEqualPtrEachEqual1(void) +{ + char A = 1; + char B = 1; + char* p0[] = {&A, &A, &A, &B}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_EACH_EQUAL_PTR(&A, p0, 4); + VERIFY_FAILS_END +} + +void testNotEqualPtrEachEqual2(void) +{ + char A = 1; + char B = 1; + char* p0[] = {&B, &B, &A, &B}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_EACH_EQUAL_PTR(&B, p0, 4); + VERIFY_FAILS_END +} + +void testNotEqualPtrEachEqual3(void) +{ + char A = 1; + char B = 1; + char* p0[] = {&A, &B, &B, &B}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_EACH_EQUAL_PTR(&B, p0, 4); + VERIFY_FAILS_END +} + +void testEqualInt8Arrays(void) +{ + UNITY_INT8 p0[] = {1, 8, 117, -2}; + UNITY_INT8 p1[] = {1, 8, 117, -2}; + UNITY_INT8 p2[] = {1, 8, 117, 2}; + UNITY_INT8 p3[] = {1, 50, 60, 70}; + + TEST_ASSERT_EQUAL_INT8_ARRAY(p0, p0, 1); + TEST_ASSERT_EQUAL_INT8_ARRAY(p0, p0, 4); + TEST_ASSERT_EQUAL_INT8_ARRAY(p0, p1, 4); + TEST_ASSERT_EQUAL_INT8_ARRAY(p0, p2, 3); + TEST_ASSERT_EQUAL_INT8_ARRAY(p0, p3, 1); +} + +void testNotEqualInt8Arrays(void) +{ + UNITY_INT8 p0[] = {1, 8, 36, -2}; + UNITY_INT8 p1[] = {1, 8, 36, 2}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_EQUAL_INT8_ARRAY(p0, p1, 4); + VERIFY_FAILS_END +} + +void testEqualInt8EachEqual(void) +{ + UNITY_INT8 p0[] = {1, 1, 1, 1}; + UNITY_INT8 p1[] = {117, 117, 117, -2}; + UNITY_INT8 p2[] = {-1, -1, 117, 2}; + UNITY_INT8 p3[] = {1, 50, 60, 70}; + + TEST_ASSERT_EACH_EQUAL_INT8(1, p0, 1); + TEST_ASSERT_EACH_EQUAL_INT8(1, p0, 4); + TEST_ASSERT_EACH_EQUAL_INT8(117, p1, 3); + TEST_ASSERT_EACH_EQUAL_INT8(-1, p2, 2); + TEST_ASSERT_EACH_EQUAL_INT8(1, p3, 1); +} + +void testNotEqualInt8EachEqual(void) +{ + UNITY_INT8 p0[] = {1, 8, 36, -2}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_EACH_EQUAL_INT8(1, p0, 2); + VERIFY_FAILS_END +} + +void testEqualCHARArrays(void) +{ + char p0[] = {1, 8, 117, -2}; + char p1[] = {1, 8, 117, -2}; + char p2[] = {1, 8, 117, 2}; + char p3[] = {1, 50, 60, 70}; + + TEST_ASSERT_EQUAL_CHAR_ARRAY(p0, p0, 1); + TEST_ASSERT_EQUAL_CHAR_ARRAY(p0, p0, 4); + TEST_ASSERT_EQUAL_CHAR_ARRAY(p0, p1, 4); + TEST_ASSERT_EQUAL_CHAR_ARRAY(p0, p2, 3); + TEST_ASSERT_EQUAL_CHAR_ARRAY(p0, p3, 1); +} + +void testNotEqualCHARArrays(void) +{ + char p0[] = {1, 8, 36, -2}; + char p1[] = {1, 8, 36, 2}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_EQUAL_CHAR_ARRAY(p0, p1, 4); + VERIFY_FAILS_END +} + +void testEqualCHAREachEqual(void) +{ + char p0[] = {1, 1, 1, 1}; + char p1[] = {117, 117, 117, -2}; + char p2[] = {-1, -1, 117, 2}; + char p3[] = {1, 50, 60, 70}; + + TEST_ASSERT_EACH_EQUAL_CHAR(1, p0, 1); + TEST_ASSERT_EACH_EQUAL_CHAR(1, p0, 4); + TEST_ASSERT_EACH_EQUAL_CHAR(117, p1, 3); + TEST_ASSERT_EACH_EQUAL_CHAR(-1, p2, 2); + TEST_ASSERT_EACH_EQUAL_CHAR(1, p3, 1); +} + +void testNotEqualCHAREachEqual(void) +{ + char p0[] = {1, 8, 36, -2}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_EACH_EQUAL_CHAR(1, p0, 2); + VERIFY_FAILS_END +} + +void testEqualUIntArrays(void) +{ + unsigned int p0[] = {1, 8, 987, 65132u}; + unsigned int p1[] = {1, 8, 987, 65132u}; + unsigned int p2[] = {1, 8, 987, 2}; + unsigned int p3[] = {1, 500, 600, 700}; + + TEST_ASSERT_EQUAL_UINT_ARRAY(p0, p0, 1); + TEST_ASSERT_EQUAL_UINT_ARRAY(p0, p0, 4); + TEST_ASSERT_EQUAL_UINT_ARRAY(p0, p1, 4); + TEST_ASSERT_EQUAL_UINT_ARRAY(p0, p2, 3); + TEST_ASSERT_EQUAL_UINT_ARRAY(p0, p3, 1); +} + +void testNotEqualUIntArrays1(void) +{ + unsigned int p0[] = {1, 8, 987, 65132u}; + unsigned int p1[] = {1, 8, 987, 65131u}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_EQUAL_UINT_ARRAY(p0, p1, 4); + VERIFY_FAILS_END +} + +void testNotEqualUIntArrays2(void) +{ + unsigned int p0[] = {1, 8, 987, 65132u}; + unsigned int p1[] = {2, 8, 987, 65132u}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_EQUAL_UINT_ARRAY(p0, p1, 4); + VERIFY_FAILS_END +} + +void testNotEqualUIntArrays3(void) +{ + unsigned int p0[] = {1, 8, 987, 65132u}; + unsigned int p1[] = {1, 8, 986, 65132u}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_EQUAL_UINT_ARRAY(p0, p1, 4); + VERIFY_FAILS_END +} + +void testEqualUIntEachEqual(void) +{ + unsigned int p0[] = {1, 1, 1, 1}; + unsigned int p1[] = {65132u, 65132u, 65132u, 65132u}; + unsigned int p2[] = {8, 8, 987, 2}; + unsigned int p3[] = {1, 500, 600, 700}; + + TEST_ASSERT_EACH_EQUAL_UINT(1, p0, 1); + TEST_ASSERT_EACH_EQUAL_UINT(1, p0, 4); + TEST_ASSERT_EACH_EQUAL_UINT(65132u, p1, 4); + TEST_ASSERT_EACH_EQUAL_UINT(8, p2, 2); + TEST_ASSERT_EACH_EQUAL_UINT(1, p3, 1); +} + +void testNotEqualUIntEachEqual1(void) +{ + unsigned int p0[] = {1, 65132u, 65132u, 65132u}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_EACH_EQUAL_UINT(65132u, p0, 4); + VERIFY_FAILS_END +} + +void testNotEqualUIntEachEqual2(void) +{ + unsigned int p0[] = {987, 8, 987, 987}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_EACH_EQUAL_UINT(987, p0, 4); + VERIFY_FAILS_END +} + +void testNotEqualUIntEachEqual3(void) +{ + unsigned int p0[] = {1, 1, 1, 65132u}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_EACH_EQUAL_UINT(1, p0, 4); + VERIFY_FAILS_END +} + +void testEqualInt16Arrays(void) +{ + UNITY_INT16 p0[] = {1, 8, 117, 3}; + UNITY_INT16 p1[] = {1, 8, 117, 3}; + UNITY_INT16 p2[] = {1, 8, 117, 2}; + UNITY_INT16 p3[] = {1, 50, 60, 70}; + + TEST_ASSERT_EQUAL_INT16_ARRAY(p0, p0, 1); + TEST_ASSERT_EQUAL_INT16_ARRAY(p0, p0, 4); + TEST_ASSERT_EQUAL_INT16_ARRAY(p0, p1, 4); + TEST_ASSERT_EQUAL_INT16_ARRAY(p0, p2, 3); + TEST_ASSERT_EQUAL_INT16_ARRAY(p0, p3, 1); +} + +void testNotEqualInt16Arrays(void) +{ + UNITY_INT16 p0[] = {1, 8, 127, 3}; + UNITY_INT16 p1[] = {1, 8, 127, 2}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_EQUAL_INT16_ARRAY(p0, p1, 4); + VERIFY_FAILS_END +} + +void testEqualInt16EachEqual(void) +{ + UNITY_INT16 p0[] = {1, 1, 1, 1}; + UNITY_INT16 p1[] = {32111, 32111, 32111, 3}; + UNITY_INT16 p2[] = {-1, -1, -1, 2}; + UNITY_INT16 p3[] = {1, 50, 60, 70}; + + TEST_ASSERT_EACH_EQUAL_INT16(1, p0, 1); + TEST_ASSERT_EACH_EQUAL_INT16(1, p0, 4); + TEST_ASSERT_EACH_EQUAL_INT16(32111, p1, 3); + TEST_ASSERT_EACH_EQUAL_INT16(-1, p2, 3); + TEST_ASSERT_EACH_EQUAL_INT16(1, p3, 1); +} + +void testNotEqualInt16EachEqual(void) +{ + UNITY_INT16 p0[] = {127, 127, 127, 3}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_EACH_EQUAL_INT16(127, p0, 4); + VERIFY_FAILS_END +} + +void testEqualInt32Arrays(void) +{ + UNITY_INT32 p0[] = {1, 8, 117, 3}; + UNITY_INT32 p1[] = {1, 8, 117, 3}; + UNITY_INT32 p2[] = {1, 8, 117, 2}; + UNITY_INT32 p3[] = {1, 50, 60, 70}; + + TEST_ASSERT_EQUAL_INT32_ARRAY(p0, p0, 1); + TEST_ASSERT_EQUAL_INT32_ARRAY(p0, p0, 4); + TEST_ASSERT_EQUAL_INT32_ARRAY(p0, p1, 4); + TEST_ASSERT_EQUAL_INT32_ARRAY(p0, p2, 3); + TEST_ASSERT_EQUAL_INT32_ARRAY(p0, p3, 1); +} + +void testNotEqualInt32Arrays(void) +{ + UNITY_INT32 p0[] = {1, 8, 127, 3}; + UNITY_INT32 p1[] = {1, 8, 127, 2}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_EQUAL_INT32_ARRAY(p0, p1, 4); + VERIFY_FAILS_END +} + +void testEqualInt32EachEqual(void) +{ + UNITY_INT32 p0[] = {8, 8, 8, 8}; + UNITY_INT32 p1[] = {65537, 65537, 65537, 65537}; + UNITY_INT32 p2[] = {-3, -3, -3, 2}; + UNITY_INT32 p3[] = {1, 50, 60, 70}; + + TEST_ASSERT_EACH_EQUAL_INT32(8, p0, 1); + TEST_ASSERT_EACH_EQUAL_INT32(8, p0, 4); + TEST_ASSERT_EACH_EQUAL_INT32(65537, p1, 4); + TEST_ASSERT_EACH_EQUAL_INT32(-3, p2, 3); + TEST_ASSERT_EACH_EQUAL_INT32(1, p3, 1); +} + +void testNotEqualInt32EachEqual(void) +{ + UNITY_INT32 p0[] = {127, 8, 127, 127}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_EACH_EQUAL_INT32(127, p0, 4); + VERIFY_FAILS_END +} + +void testEqualUINT8Arrays(void) +{ + UNITY_UINT8 p0[] = {1, 8, 100, 127}; + UNITY_UINT8 p1[] = {1, 8, 100, 127}; + UNITY_UINT8 p2[] = {1, 8, 100, 2}; + UNITY_UINT8 p3[] = {1, 50, 60, 70}; + + TEST_ASSERT_EQUAL_UINT8_ARRAY(p0, p0, 1); + TEST_ASSERT_EQUAL_UINT8_ARRAY(p0, p0, 4); + TEST_ASSERT_EQUAL_UINT8_ARRAY(p0, p1, 4); + TEST_ASSERT_EQUAL_UINT8_ARRAY(p0, p2, 3); + TEST_ASSERT_EQUAL_UINT8_ARRAY(p0, p3, 1); +} + +void testNotEqualUINT8Arrays1(void) +{ + unsigned char p0[] = {1, 8, 100, 127u}; + unsigned char p1[] = {1, 8, 100, 255u}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_EQUAL_UINT8_ARRAY(p0, p1, 4); + VERIFY_FAILS_END +} + +void testNotEqualUINT8Arrays2(void) +{ + unsigned char p0[] = {1, 8, 100, 127u}; + unsigned char p1[] = {1, 8, 100, 255u}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_EQUAL_UINT8_ARRAY(p0, p1, 4); + VERIFY_FAILS_END +} + +void testNotEqualUINT8Arrays3(void) +{ + unsigned char p0[] = {1, 8, 100, 127u}; + unsigned char p1[] = {1, 8, 100, 255u}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_EQUAL_UINT8_ARRAY(p0, p1, 4); + VERIFY_FAILS_END +} + + +void testEqualUINT16Arrays(void) +{ + unsigned short p0[] = {1, 8, 987, 65132u}; + unsigned short p1[] = {1, 8, 987, 65132u}; + unsigned short p2[] = {1, 8, 987, 2}; + unsigned short p3[] = {1, 500, 600, 700}; + + TEST_ASSERT_EQUAL_UINT16_ARRAY(p0, p0, 1); + TEST_ASSERT_EQUAL_UINT16_ARRAY(p0, p0, 4); + TEST_ASSERT_EQUAL_UINT16_ARRAY(p0, p1, 4); + TEST_ASSERT_EQUAL_UINT16_ARRAY(p0, p2, 3); + TEST_ASSERT_EQUAL_UINT16_ARRAY(p0, p3, 1); +} + +void testNotEqualUINT16Arrays1(void) +{ + unsigned short p0[] = {1, 8, 987, 65132u}; + unsigned short p1[] = {1, 8, 987, 65131u}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_EQUAL_UINT16_ARRAY(p0, p1, 4); + VERIFY_FAILS_END +} + +void testNotEqualUINT16Arrays2(void) +{ + unsigned short p0[] = {1, 8, 987, 65132u}; + unsigned short p1[] = {2, 8, 987, 65132u}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_EQUAL_UINT16_ARRAY(p0, p1, 4); + VERIFY_FAILS_END +} + +void testNotEqualUINT16Arrays3(void) +{ + unsigned short p0[] = {1, 8, 987, 65132u}; + unsigned short p1[] = {1, 8, 986, 65132u}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_EQUAL_UINT16_ARRAY(p0, p1, 4); + VERIFY_FAILS_END +} + +void testEqualUINT32Arrays(void) +{ + UNITY_UINT32 p0[] = {1, 8, 987, 65132u}; + UNITY_UINT32 p1[] = {1, 8, 987, 65132u}; + UNITY_UINT32 p2[] = {1, 8, 987, 2}; + UNITY_UINT32 p3[] = {1, 500, 600, 700}; + + TEST_ASSERT_EQUAL_UINT32_ARRAY(p0, p0, 1); + TEST_ASSERT_EQUAL_UINT32_ARRAY(p0, p0, 4); + TEST_ASSERT_EQUAL_UINT32_ARRAY(p0, p1, 4); + TEST_ASSERT_EQUAL_UINT32_ARRAY(p0, p2, 3); + TEST_ASSERT_EQUAL_UINT32_ARRAY(p0, p3, 1); +} + +void testNotEqualUINT32Arrays1(void) +{ + UNITY_UINT32 p0[] = {1, 8, 987, 65132u}; + UNITY_UINT32 p1[] = {1, 8, 987, 65131u}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_EQUAL_UINT32_ARRAY(p0, p1, 4); + VERIFY_FAILS_END +} + +void testNotEqualUINT32Arrays2(void) +{ + UNITY_UINT32 p0[] = {1, 8, 987, 65132u}; + UNITY_UINT32 p1[] = {2, 8, 987, 65132u}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_EQUAL_UINT32_ARRAY(p0, p1, 4); + VERIFY_FAILS_END +} + +void testNotEqualUINT32Arrays3(void) +{ + UNITY_UINT32 p0[] = {1, 8, 987, 65132u}; + UNITY_UINT32 p1[] = {1, 8, 986, 65132u}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_EQUAL_UINT32_ARRAY(p0, p1, 4); + VERIFY_FAILS_END +} + +void testEqualHEXArrays(void) +{ + UNITY_UINT32 p0[] = {1, 8, 987, 65132u}; + UNITY_UINT32 p1[] = {1, 8, 987, 65132u}; + UNITY_UINT32 p2[] = {1, 8, 987, 2}; + UNITY_UINT32 p3[] = {1, 500, 600, 700}; + + TEST_ASSERT_EQUAL_HEX_ARRAY(p0, p0, 1); + TEST_ASSERT_EQUAL_HEX_ARRAY(p0, p0, 4); + TEST_ASSERT_EQUAL_HEX_ARRAY(p0, p1, 4); + TEST_ASSERT_EQUAL_HEX32_ARRAY(p0, p2, 3); + TEST_ASSERT_EQUAL_HEX32_ARRAY(p0, p3, 1); +} + +void testNotEqualHEXArrays1(void) +{ + UNITY_UINT32 p0[] = {1, 8, 987, 65132u}; + UNITY_UINT32 p1[] = {1, 8, 987, 65131u}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_EQUAL_HEX32_ARRAY(p0, p1, 4); + VERIFY_FAILS_END +} + +void testNotEqualHEXArrays2(void) +{ + UNITY_UINT32 p0[] = {1, 8, 987, 65132u}; + UNITY_UINT32 p1[] = {2, 8, 987, 65132u}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_EQUAL_HEX32_ARRAY(p0, p1, 4); + VERIFY_FAILS_END +} + +void testNotEqualHEXArrays3(void) +{ + UNITY_UINT32 p0[] = {1, 8, 987, 65132u}; + UNITY_UINT32 p1[] = {1, 8, 986, 65132u}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_EQUAL_HEX_ARRAY(p0, p1, 4); + VERIFY_FAILS_END +} + +void testEqualHEX32Arrays(void) +{ + UNITY_UINT32 p0[] = {1, 8, 987, 65132u}; + UNITY_UINT32 p1[] = {1, 8, 987, 65132u}; + UNITY_UINT32 p2[] = {1, 8, 987, 2}; + UNITY_UINT32 p3[] = {1, 500, 600, 700}; + + TEST_ASSERT_EQUAL_HEX32_ARRAY(p0, p0, 1); + TEST_ASSERT_EQUAL_HEX32_ARRAY(p0, p0, 4); + TEST_ASSERT_EQUAL_HEX32_ARRAY(p0, p1, 4); + TEST_ASSERT_EQUAL_HEX32_ARRAY(p0, p2, 3); + TEST_ASSERT_EQUAL_HEX32_ARRAY(p0, p3, 1); +} + +void testNotEqualHEX32Arrays1(void) +{ + UNITY_UINT32 p0[] = {1, 8, 987, 65132u}; + UNITY_UINT32 p1[] = {1, 8, 987, 65131u}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_EQUAL_HEX32_ARRAY(p0, p1, 4); + VERIFY_FAILS_END +} + +void testNotEqualHEX32Arrays2(void) +{ + UNITY_UINT32 p0[] = {1, 8, 987, 65132u}; + UNITY_UINT32 p1[] = {2, 8, 987, 65132u}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_EQUAL_HEX32_ARRAY(p0, p1, 4); + VERIFY_FAILS_END +} + +void testNotEqualHEX32Arrays3(void) +{ + UNITY_UINT32 p0[] = {1, 8, 987, 65132u}; + UNITY_UINT32 p1[] = {1, 8, 986, 65132u}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_EQUAL_HEX32_ARRAY(p0, p1, 4); + VERIFY_FAILS_END +} + +void testEqualHEX16Arrays(void) +{ + unsigned short p0[] = {1, 8, 987, 65132u}; + unsigned short p1[] = {1, 8, 987, 65132u}; + unsigned short p2[] = {1, 8, 987, 2}; + unsigned short p3[] = {1, 500, 600, 700}; + + TEST_ASSERT_EQUAL_HEX16_ARRAY(p0, p0, 1); + TEST_ASSERT_EQUAL_HEX16_ARRAY(p0, p0, 4); + TEST_ASSERT_EQUAL_HEX16_ARRAY(p0, p1, 4); + TEST_ASSERT_EQUAL_HEX16_ARRAY(p0, p2, 3); + TEST_ASSERT_EQUAL_HEX16_ARRAY(p0, p3, 1); +} + +void testNotEqualHEX16Arrays1(void) +{ + unsigned short p0[] = {1, 8, 987, 65132u}; + unsigned short p1[] = {1, 8, 987, 65131u}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_EQUAL_HEX16_ARRAY(p0, p1, 4); + VERIFY_FAILS_END +} + +void testNotEqualHEX16Arrays2(void) +{ + unsigned short p0[] = {1, 8, 987, 65132u}; + unsigned short p1[] = {2, 8, 987, 65132u}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_EQUAL_HEX16_ARRAY(p0, p1, 4); + VERIFY_FAILS_END +} + +void testNotEqualHEX16Arrays3(void) +{ + unsigned short p0[] = {1, 8, 987, 65132u}; + unsigned short p1[] = {1, 8, 986, 65132u}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_EQUAL_HEX16_ARRAY(p0, p1, 4); + VERIFY_FAILS_END +} + +void testEqualHEX8Arrays(void) +{ + unsigned char p0[] = {1, 8, 254u, 123}; + unsigned char p1[] = {1, 8, 254u, 123}; + unsigned char p2[] = {1, 8, 254u, 2}; + unsigned char p3[] = {1, 23, 25, 26}; + + TEST_ASSERT_EQUAL_HEX8_ARRAY(p0, p0, 1); + TEST_ASSERT_EQUAL_HEX8_ARRAY(p0, p0, 4); + TEST_ASSERT_EQUAL_HEX8_ARRAY(p0, p1, 4); + TEST_ASSERT_EQUAL_HEX8_ARRAY(p0, p2, 3); + TEST_ASSERT_EQUAL_HEX8_ARRAY(p0, p3, 1); +} + +void testNotEqualHEX8Arrays1(void) +{ + unsigned char p0[] = {1, 8, 254u, 253u}; + unsigned char p1[] = {1, 8, 254u, 252u}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_EQUAL_HEX8_ARRAY(p0, p1, 4); + VERIFY_FAILS_END +} + +void testNotEqualHEX8Arrays2(void) +{ + unsigned char p0[] = {1, 8, 254u, 253u}; + unsigned char p1[] = {2, 8, 254u, 253u}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_EQUAL_HEX8_ARRAY(p0, p1, 4); + VERIFY_FAILS_END +} + +void testNotEqualHEX8Arrays3(void) +{ + unsigned char p0[] = {1, 8, 254u, 253u}; + unsigned char p1[] = {1, 8, 255u, 253u}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_EQUAL_HEX8_ARRAY(p0, p1, 4); + VERIFY_FAILS_END +} + +void testEqualUINT8EachEqual(void) +{ + UNITY_UINT8 p0[] = {127u, 127u, 127u, 127u}; + UNITY_UINT8 p1[] = {1u, 1u, 1u, 1u}; + UNITY_UINT8 p2[] = {128u, 128u, 128u, 2u}; + UNITY_UINT8 p3[] = {1u, 50u, 60u, 70u}; + + TEST_ASSERT_EACH_EQUAL_UINT8(127u, p0, 1); + TEST_ASSERT_EACH_EQUAL_UINT8(127u, p0, 4); + TEST_ASSERT_EACH_EQUAL_UINT8(1u, p1, 4); + TEST_ASSERT_EACH_EQUAL_UINT8(128u, p2, 3); + TEST_ASSERT_EACH_EQUAL_UINT8(1u, p3, 1); +} + +void testNotEqualUINT8EachEqual1(void) +{ + unsigned char p0[] = {127u, 127u, 128u, 127u}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_EACH_EQUAL_UINT8(127u, p0, 4); + VERIFY_FAILS_END +} + +void testNotEqualUINT8EachEqual2(void) +{ + unsigned char p0[] = {1, 1, 1, 127u}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_EACH_EQUAL_UINT8(1, p0, 4); + VERIFY_FAILS_END +} + +void testNotEqualUINT8EachEqual3(void) +{ + unsigned char p0[] = {54u, 55u, 55u, 55u}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_EACH_EQUAL_UINT8(55u, p0, 4); + VERIFY_FAILS_END +} + +void testEqualUINT16EachEqual(void) +{ + unsigned short p0[] = {65132u, 65132u, 65132u, 65132u}; + unsigned short p1[] = {987, 987, 987, 987}; + unsigned short p2[] = {1, 1, 1, 2}; + unsigned short p3[] = {1, 500, 600, 700}; + + TEST_ASSERT_EACH_EQUAL_UINT16(65132u, p0, 1); + TEST_ASSERT_EACH_EQUAL_UINT16(65132u, p0, 4); + TEST_ASSERT_EACH_EQUAL_UINT16(987, p1, 4); + TEST_ASSERT_EACH_EQUAL_UINT16(1, p2, 3); + TEST_ASSERT_EACH_EQUAL_UINT16(1, p3, 1); +} + +void testNotEqualUINT16EachEqual1(void) +{ + unsigned short p0[] = {1, 65132u, 65132u, 65132u}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_EACH_EQUAL_UINT16(65132u, p0, 4); + VERIFY_FAILS_END +} + +void testNotEqualUINT16EachEqual2(void) +{ + unsigned short p0[] = {65132u, 65132u, 987, 65132u}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_EACH_EQUAL_UINT16(65132u, p0, 4); + VERIFY_FAILS_END +} + +void testNotEqualUINT16EachEqual3(void) +{ + unsigned short p0[] = {65132u, 65132u, 65132u, 65133u}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_EACH_EQUAL_UINT16(65132u, p0, 4); + VERIFY_FAILS_END +} + +void testEqualUINT32EachEqual(void) +{ + UNITY_UINT32 p0[] = {65132u, 65132u, 65132u, 65132u}; + UNITY_UINT32 p1[] = {987, 987, 987, 987}; + UNITY_UINT32 p2[] = {8, 8, 8, 2}; + UNITY_UINT32 p3[] = {1, 500, 600, 700}; + + TEST_ASSERT_EACH_EQUAL_UINT32(65132u, p0, 1); + TEST_ASSERT_EACH_EQUAL_UINT32(65132u, p0, 4); + TEST_ASSERT_EACH_EQUAL_UINT32(987, p1, 4); + TEST_ASSERT_EACH_EQUAL_UINT32(8, p2, 3); + TEST_ASSERT_EACH_EQUAL_UINT32(1, p3, 1); +} + +void testNotEqualUINT32EachEqual1(void) +{ + UNITY_UINT32 p0[] = {65132u, 65132u, 987, 65132u}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_EACH_EQUAL_UINT32(65132u, p0, 4); + VERIFY_FAILS_END +} + +void testNotEqualUINT32EachEqual2(void) +{ + UNITY_UINT32 p0[] = {1, 987, 987, 987}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_EACH_EQUAL_UINT32(987, p0, 4); + VERIFY_FAILS_END +} + +void testNotEqualUINT32EachEqual3(void) +{ + UNITY_UINT32 p0[] = {1, 1, 1, 65132u}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_EACH_EQUAL_UINT32(1, p0, 4); + VERIFY_FAILS_END +} + +void testEqualHEXEachEqual(void) +{ + UNITY_UINT32 p0[] = {65132u, 65132u, 65132u, 65132u}; + UNITY_UINT32 p1[] = {987, 987, 987, 987}; + UNITY_UINT32 p2[] = {8, 8, 8, 2}; + UNITY_UINT32 p3[] = {1, 500, 600, 700}; + + TEST_ASSERT_EACH_EQUAL_HEX(65132u, p0, 1); + TEST_ASSERT_EACH_EQUAL_HEX(65132u, p0, 4); + TEST_ASSERT_EACH_EQUAL_HEX(987, p1, 4); + TEST_ASSERT_EACH_EQUAL_HEX(8, p2, 3); + TEST_ASSERT_EACH_EQUAL_HEX(1, p3, 1); +} + +void testNotEqualHEXEachEqual1(void) +{ + UNITY_UINT32 p0[] = {1, 65132u, 65132u, 65132u}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_EACH_EQUAL_HEX32(65132u, p0, 4); + VERIFY_FAILS_END +} + +void testNotEqualHEXEachEqual2(void) +{ + UNITY_UINT32 p0[] = {987, 987, 987, 65132u}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_EACH_EQUAL_HEX32(987, p0, 4); + VERIFY_FAILS_END +} + +void testNotEqualHEXEachEqual3(void) +{ + UNITY_UINT32 p0[] = {8, 8, 987, 8}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_EACH_EQUAL_HEX(8, p0, 4); + VERIFY_FAILS_END +} + +void testEqualHEX32EachEqual(void) +{ + UNITY_UINT32 p0[] = {65132u, 65132u, 65132u, 65132u}; + UNITY_UINT32 p1[] = {987, 987, 987, 987}; + UNITY_UINT32 p2[] = {8, 8, 8, 2}; + UNITY_UINT32 p3[] = {1, 500, 600, 700}; + + TEST_ASSERT_EACH_EQUAL_HEX32(65132u, p0, 1); + TEST_ASSERT_EACH_EQUAL_HEX32(65132u, p0, 4); + TEST_ASSERT_EACH_EQUAL_HEX32(987, p1, 4); + TEST_ASSERT_EACH_EQUAL_HEX32(8, p2, 3); + TEST_ASSERT_EACH_EQUAL_HEX32(1, p3, 1); +} + +void testNotEqualHEX32EachEqual1(void) +{ + UNITY_UINT32 p0[] = {65132u, 8, 65132u, 65132u}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_EACH_EQUAL_HEX32(65132u, p0, 4); + VERIFY_FAILS_END +} + +void testNotEqualHEX32EachEqual2(void) +{ + UNITY_UINT32 p0[] = {1, 987, 987, 987}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_EACH_EQUAL_HEX32(987, p0, 4); + VERIFY_FAILS_END +} + +void testNotEqualHEX32EachEqual3(void) +{ + UNITY_UINT32 p0[] = {8, 8, 8, 65132u}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_EACH_EQUAL_HEX32(8, p0, 4); + VERIFY_FAILS_END +} + +void testEqualHEX16EachEqual(void) +{ + UNITY_UINT16 p0[] = {65132u, 65132u, 65132u, 65132u}; + UNITY_UINT16 p1[] = {987, 987, 987, 987}; + UNITY_UINT16 p2[] = {8, 8, 8, 2}; + UNITY_UINT16 p3[] = {1, 500, 600, 700}; + + TEST_ASSERT_EACH_EQUAL_HEX16(65132u, p0, 1); + TEST_ASSERT_EACH_EQUAL_HEX16(65132u, p0, 4); + TEST_ASSERT_EACH_EQUAL_HEX16(987, p1, 4); + TEST_ASSERT_EACH_EQUAL_HEX16(8, p2, 3); + TEST_ASSERT_EACH_EQUAL_HEX16(1, p3, 1); +} + +void testNotEqualHEX16EachEqual1(void) +{ + unsigned short p0[] = {65132u, 65132u, 987, 65132u}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_EACH_EQUAL_HEX16(65132u, p0, 4); + VERIFY_FAILS_END +} + +void testNotEqualHEX16EachEqual2(void) +{ + unsigned short p0[] = {1, 987, 987, 987}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_EACH_EQUAL_HEX16(987, p0, 4); + VERIFY_FAILS_END +} + +void testNotEqualHEX16EachEqual3(void) +{ + unsigned short p0[] = {8, 8, 8, 65132u}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_EACH_EQUAL_HEX16(8, p0, 4); + VERIFY_FAILS_END +} + +void testEqualHEX8EachEqual(void) +{ + unsigned char p0[] = {254u, 254u, 254u, 254u}; + unsigned char p1[] = {123, 123, 123, 123}; + unsigned char p2[] = {8, 8, 8, 2}; + unsigned char p3[] = {1, 23, 25, 26}; + + TEST_ASSERT_EACH_EQUAL_HEX8(254u, p0, 1); + TEST_ASSERT_EACH_EQUAL_HEX8(254u, p0, 4); + TEST_ASSERT_EACH_EQUAL_HEX8(123, p1, 4); + TEST_ASSERT_EACH_EQUAL_HEX8(8, p2, 3); + TEST_ASSERT_EACH_EQUAL_HEX8(1, p3, 1); +} + +void testNotEqualHEX8EachEqual1(void) +{ + unsigned char p0[] = {253u, 253u, 254u, 253u}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_EACH_EQUAL_HEX8(253u, p0, 4); + VERIFY_FAILS_END +} + +void testNotEqualHEX8EachEqual2(void) +{ + unsigned char p0[] = {254u, 254u, 254u, 253u}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_EACH_EQUAL_HEX8(254u, p0, 4); + VERIFY_FAILS_END +} + +void testNotEqualHEX8EachEqual3(void) +{ + unsigned char p0[] = {1, 8, 8, 8}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_EACH_EQUAL_HEX8(8, p0, 4); + VERIFY_FAILS_END +} + +void testEqualHEX64Arrays(void) +{ +#ifndef UNITY_SUPPORT_64 + TEST_IGNORE(); +#else + UNITY_UINT64 p0[] = {1, 8, 987, 65132u}; + UNITY_UINT64 p1[] = {1, 8, 987, 65132u}; + UNITY_UINT64 p2[] = {1, 8, 987, 2}; + UNITY_UINT64 p3[] = {1, 500, 600, 700}; + + TEST_ASSERT_EQUAL_HEX64_ARRAY(p0, p0, 1); + TEST_ASSERT_EQUAL_HEX64_ARRAY(p0, p0, 4); + TEST_ASSERT_EQUAL_HEX64_ARRAY(p0, p1, 4); + TEST_ASSERT_EQUAL_HEX64_ARRAY(p0, p2, 3); + TEST_ASSERT_EQUAL_HEX64_ARRAY(p0, p3, 1); +#endif +} + +void testEqualUint64Arrays(void) +{ +#ifndef UNITY_SUPPORT_64 + TEST_IGNORE(); +#else + UNITY_UINT64 p0[] = {1, 8, 987, 65132u}; + UNITY_UINT64 p1[] = {1, 8, 987, 65132u}; + UNITY_UINT64 p2[] = {1, 8, 987, 2}; + UNITY_UINT64 p3[] = {1, 500, 600, 700}; + + TEST_ASSERT_EQUAL_UINT64_ARRAY(p0, p0, 1); + TEST_ASSERT_EQUAL_UINT64_ARRAY(p0, p0, 4); + TEST_ASSERT_EQUAL_UINT64_ARRAY(p0, p1, 4); + TEST_ASSERT_EQUAL_UINT64_ARRAY(p0, p2, 3); + TEST_ASSERT_EQUAL_UINT64_ARRAY(p0, p3, 1); +#endif +} + +void testEqualInt64Arrays(void) +{ +#ifndef UNITY_SUPPORT_64 + TEST_IGNORE(); +#else + UNITY_INT64 p0[] = {1, 8, 987, -65132}; + UNITY_INT64 p1[] = {1, 8, 987, -65132}; + UNITY_INT64 p2[] = {1, 8, 987, -2}; + UNITY_INT64 p3[] = {1, 500, 600, 700}; + + TEST_ASSERT_EQUAL_INT64_ARRAY(p0, p0, 1); + TEST_ASSERT_EQUAL_INT64_ARRAY(p0, p0, 4); + TEST_ASSERT_EQUAL_INT64_ARRAY(p0, p1, 4); + TEST_ASSERT_EQUAL_INT64_ARRAY(p0, p2, 3); + TEST_ASSERT_EQUAL_INT64_ARRAY(p0, p3, 1); +#endif +} + + +void testNotEqualHEX64Arrays1(void) +{ +#ifndef UNITY_SUPPORT_64 + TEST_IGNORE(); +#else + UNITY_UINT64 p0[] = {1, 8, 987, 65132u}; + UNITY_UINT64 p1[] = {1, 8, 987, 65131u}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_EQUAL_HEX64_ARRAY(p0, p1, 4); + VERIFY_FAILS_END +#endif +} + +void testNotEqualHEX64Arrays2(void) +{ +#ifndef UNITY_SUPPORT_64 + TEST_IGNORE(); +#else + UNITY_UINT64 p0[] = {1, 8, 987, 65132u}; + UNITY_UINT64 p1[] = {2, 8, 987, 65132u}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_EQUAL_HEX64_ARRAY(p0, p1, 4); + VERIFY_FAILS_END +#endif +} + +void testNotEqualUint64Arrays(void) +{ +#ifndef UNITY_SUPPORT_64 + TEST_IGNORE(); +#else + UNITY_UINT64 p0[] = {1, 8, 987, 65132u}; + UNITY_UINT64 p1[] = {1, 8, 987, 65131u}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_EQUAL_UINT64_ARRAY(p0, p1, 4); + VERIFY_FAILS_END +#endif +} + +void testNotEqualInt64Arrays(void) +{ +#ifndef UNITY_SUPPORT_64 + TEST_IGNORE(); +#else + UNITY_INT64 p0[] = {1, 8, 987, -65132}; + UNITY_INT64 p1[] = {1, 8, 987, -65131}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_EQUAL_INT64_ARRAY(p0, p1, 4); + VERIFY_FAILS_END +#endif +} diff --git a/test/tests/test_unity_core.c b/test/tests/test_unity_core.c new file mode 100644 index 00000000..eb53ba5b --- /dev/null +++ b/test/tests/test_unity_core.c @@ -0,0 +1,355 @@ +/* ========================================== + Unity Project - A Test Framework for C + Copyright (c) 2007 Mike Karlesky, Mark VanderVoord, Greg Williams + [Released under MIT License. Please refer to license.txt for details] +========================================== */ + +#include "unity.h" +#define TEST_INSTANCES +#include "self_assessment_utils.h" + +void setUp(void) +{ + SetToOneToFailInTearDown = 0; + SetToOneMeanWeAlreadyCheckedThisGuy = 0; +} + +void tearDown(void) +{ + endPutcharSpy(); /* Stop suppressing test output */ + if (SetToOneToFailInTearDown == 1) + { + /* These will be skipped internally if already failed/ignored */ + TEST_FAIL_MESSAGE("<= Failed in tearDown"); + TEST_IGNORE_MESSAGE("<= Ignored in tearDown"); + } + if ((SetToOneMeanWeAlreadyCheckedThisGuy == 0) && (Unity.CurrentTestFailed > 0)) + { + UnityPrint(": [[[[ Test Should Have Passed But Did Not ]]]]"); + UNITY_OUTPUT_CHAR('\n'); + } +} + +void testUnitySizeInitializationReminder(void) +{ + /* This test ensures that sizeof(struct UNITY_STORAGE_T) doesn't change. If this + * test breaks, go look at the initialization of the Unity global variable + * in unity.c and make sure we're filling in the proper fields. */ + const char* message = "Unexpected size for UNITY_STORAGE_T struct. Please check that " + "the initialization of the Unity symbol in unity.c is " + "still correct."; + + /* Define a structure with all the same fields as `struct UNITY_STORAGE_T`. */ +#ifdef UNITY_EXCLUDE_DETAILS + struct { + const char* TestFile; + const char* CurrentTestName; + UNITY_LINE_TYPE CurrentTestLineNumber; + UNITY_COUNTER_TYPE NumberOfTests; + UNITY_COUNTER_TYPE TestFailures; + UNITY_COUNTER_TYPE TestIgnores; + UNITY_COUNTER_TYPE CurrentTestFailed; + UNITY_COUNTER_TYPE CurrentTestIgnored; +#ifdef UNITY_INCLUDE_EXEC_TIME + UNITY_TIME_TYPE CurrentTestStartTime; + UNITY_TIME_TYPE CurrentTestStopTime; +#endif +#ifndef UNITY_EXCLUDE_SETJMP_H + jmp_buf AbortFrame; +#endif + } _Expected_Unity; +#else + struct { + const char* TestFile; + const char* CurrentTestName; + const char* CurrentDetails1; + const char* CurrentDetails2; + UNITY_LINE_TYPE CurrentTestLineNumber; + UNITY_COUNTER_TYPE NumberOfTests; + UNITY_COUNTER_TYPE TestFailures; + UNITY_COUNTER_TYPE TestIgnores; + UNITY_COUNTER_TYPE CurrentTestFailed; + UNITY_COUNTER_TYPE CurrentTestIgnored; +#ifdef UNITY_INCLUDE_EXEC_TIME + UNITY_COUNTER_TYPE CurrentTestStartTime; + UNITY_COUNTER_TYPE CurrentTestStopTime; +#endif +#ifndef UNITY_EXCLUDE_SETJMP_H + jmp_buf AbortFrame; +#endif + } _Expected_Unity; +#endif + + /* Compare our fake structure's size to the actual structure's size. They + * should be the same. + * + * This accounts for alignment, padding, and packing issues that might come + * up between different architectures. */ + TEST_ASSERT_EQUAL_MESSAGE(sizeof(_Expected_Unity), sizeof(Unity), message); +} + +void testPassShouldEndImmediatelyWithPass(void) +{ + TEST_PASS(); + TEST_FAIL_MESSAGE("We should have passed already and finished this test"); +} + +void testPassShouldEndImmediatelyWithPassAndMessage(void) +{ + TEST_PASS_MESSAGE("Woohoo! This Automatically Passes!"); + TEST_FAIL_MESSAGE("We should have passed already and finished this test"); +} + +void testMessageShouldDisplayMessageWithoutEndingAndGoOnToPass(void) +{ + TEST_MESSAGE("This is just a message"); + TEST_MESSAGE("This is another message"); + TEST_PASS(); +} + +void testMessageShouldDisplayMessageWithoutEndingAndGoOnToFail(void) +{ + TEST_MESSAGE("This is yet another message"); + + EXPECT_ABORT_BEGIN + TEST_FAIL(); + VERIFY_FAILS_END +} + +void testTrue(void) +{ + TEST_ASSERT(1); + + TEST_ASSERT_TRUE(1); +} + +void testFalse(void) +{ + TEST_ASSERT_FALSE(0); + + TEST_ASSERT_UNLESS(0); +} + +void testPreviousPass(void) +{ + TEST_ASSERT_EQUAL_INT(0U, Unity.TestFailures); +} + +void testNotVanilla(void) +{ + EXPECT_ABORT_BEGIN + TEST_ASSERT(0); + VERIFY_FAILS_END +} + +void testNotTrue(void) +{ + EXPECT_ABORT_BEGIN + TEST_ASSERT_TRUE(0); + VERIFY_FAILS_END +} + +void testNotFalse(void) +{ + EXPECT_ABORT_BEGIN + TEST_ASSERT_FALSE(1); + VERIFY_FAILS_END +} + +void testNotUnless(void) +{ + EXPECT_ABORT_BEGIN + TEST_ASSERT_UNLESS(1); + VERIFY_FAILS_END +} + +void testNotNotEqual(void) +{ + EXPECT_ABORT_BEGIN + TEST_ASSERT_NOT_EQUAL(10, 10); + VERIFY_FAILS_END +} + +void testFail(void) +{ + EXPECT_ABORT_BEGIN + TEST_FAIL_MESSAGE("Expected for testing"); + VERIFY_FAILS_END +} + +void testIsNull(void) +{ + char* ptr1 = NULL; + const char* ptr2 = "hello"; + + TEST_ASSERT_NULL(ptr1); + TEST_ASSERT_NOT_NULL(ptr2); +} + +void testIsNullShouldFailIfNot(void) +{ + const char* ptr1 = "hello"; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_NULL(ptr1); + VERIFY_FAILS_END +} + +void testNotNullShouldFailIfNULL(void) +{ + char* ptr1 = NULL; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_NOT_NULL(ptr1); + VERIFY_FAILS_END +} + +void testIsEmpty(void) +{ + const char* ptr1 = "\0"; + const char* ptr2 = "hello"; + + TEST_ASSERT_EMPTY(ptr1); + TEST_ASSERT_NOT_EMPTY(ptr2); +} + +void testIsEmptyShouldFailIfNot(void) +{ + const char* ptr1 = "hello"; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_EMPTY(ptr1); + VERIFY_FAILS_END +} + +void testNotEmptyShouldFailIfEmpty(void) +{ + const char* ptr1 = "\0"; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_NOT_EMPTY(ptr1); + VERIFY_FAILS_END +} + +void testIgnore(void) +{ + EXPECT_ABORT_BEGIN + TEST_IGNORE(); + TEST_FAIL_MESSAGE("This should not be reached"); + VERIFY_IGNORES_END +} + +void testIgnoreMessage(void) +{ + EXPECT_ABORT_BEGIN + TEST_IGNORE_MESSAGE("This is an expected TEST_IGNORE_MESSAGE string!"); + TEST_FAIL_MESSAGE("This should not be reached"); + VERIFY_IGNORES_END +} + +void testProtection(void) +{ + volatile int mask = 0; + + if (TEST_PROTECT()) + { + mask |= 1; + TEST_ABORT(); + } + else + { + Unity.CurrentTestFailed = 0; + mask |= 2; + } + + TEST_ASSERT_EQUAL(3, mask); +} + +void testIgnoredAndThenFailInTearDown(void) +{ + SetToOneToFailInTearDown = 1; + TEST_IGNORE(); +} + +void testFailureCountIncrementsAndIsReturnedAtEnd(void) +{ +#ifndef USING_OUTPUT_SPY + TEST_IGNORE(); +#else + UNITY_UINT savedFailures = Unity.TestFailures; + Unity.CurrentTestFailed = 1; + startPutcharSpy(); /* Suppress output */ + startFlushSpy(); + TEST_ASSERT_EQUAL(0, getFlushSpyCalls()); + UnityConcludeTest(); + endPutcharSpy(); + TEST_ASSERT_EQUAL(savedFailures + 1, Unity.TestFailures); +#if defined(UNITY_OUTPUT_FLUSH) && defined(UNITY_OUTPUT_FLUSH_HEADER_DECLARATION) + TEST_ASSERT_EQUAL(1, getFlushSpyCalls()); +#else + TEST_ASSERT_EQUAL(0, getFlushSpyCalls()); +#endif + endFlushSpy(); + + startPutcharSpy(); /* Suppress output */ + int failures = UnityEnd(); + Unity.TestFailures--; + endPutcharSpy(); + TEST_ASSERT_EQUAL(savedFailures + 1, failures); +#endif +} + +/* ===================== THESE TEST WILL RUN IF YOUR CONFIG INCLUDES DETAIL SUPPORT ================== */ + +void testThatDetailsCanBeHandleOneDetail(void) +{ +#ifdef UNITY_EXCLUDE_DETAILS + TEST_IGNORE(); +#else + UNITY_SET_DETAIL("Detail1"); + + EXPECT_ABORT_BEGIN + TEST_ASSERT_EQUAL_INT_MESSAGE(5, 6, "Should Fail And Say Detail1"); + VERIFY_FAILS_END +#endif +} + +void testThatDetailsCanHandleTestFail(void) +{ +#ifdef UNITY_EXCLUDE_DETAILS + TEST_IGNORE(); +#else + UNITY_SET_DETAILS("Detail1","Detail2"); + + EXPECT_ABORT_BEGIN + TEST_FAIL_MESSAGE("Should Fail And Say Detail1 and Detail2"); + VERIFY_FAILS_END +#endif +} + +void testThatDetailsCanBeHandleTwoDetails(void) +{ +#ifdef UNITY_EXCLUDE_DETAILS + TEST_IGNORE(); +#else + UNITY_SET_DETAILS("Detail1","Detail2"); + + EXPECT_ABORT_BEGIN + TEST_ASSERT_EQUAL_HEX8_MESSAGE(7, 8, "Should Fail And Say Detail1 and Detail2"); + VERIFY_FAILS_END +#endif +} + +void testThatDetailsCanBeHandleSingleDetailClearingTwoDetails(void) +{ +#ifdef UNITY_EXCLUDE_DETAILS + TEST_IGNORE(); +#else + UNITY_SET_DETAILS("Detail1","Detail2"); + UNITY_SET_DETAIL("DetailNew"); + + EXPECT_ABORT_BEGIN + TEST_ASSERT_EQUAL_STRING_MESSAGE("MEH", "GUH", "Should Fail And Say DetailNew"); + VERIFY_FAILS_END +#endif +} diff --git a/test/tests/test_unity_doubles.c b/test/tests/test_unity_doubles.c new file mode 100644 index 00000000..2757e694 --- /dev/null +++ b/test/tests/test_unity_doubles.c @@ -0,0 +1,770 @@ +/* ========================================== + Unity Project - A Test Framework for C + Copyright (c) 2007 Mike Karlesky, Mark VanderVoord, Greg Williams + [Released under MIT License. Please refer to license.txt for details] +========================================== */ + +#include "unity.h" +#define TEST_INSTANCES +#include "self_assessment_utils.h" + +void setUp(void) +{ + SetToOneToFailInTearDown = 0; + SetToOneMeanWeAlreadyCheckedThisGuy = 0; +} + +void tearDown(void) +{ + endPutcharSpy(); /* Stop suppressing test output */ + if (SetToOneToFailInTearDown == 1) + { + /* These will be skipped internally if already failed/ignored */ + TEST_FAIL_MESSAGE("<= Failed in tearDown"); + TEST_IGNORE_MESSAGE("<= Ignored in tearDown"); + } + if ((SetToOneMeanWeAlreadyCheckedThisGuy == 0) && (Unity.CurrentTestFailed > 0)) + { + UnityPrint(": [[[[ Test Should Have Passed But Did Not ]]]]"); + UNITY_OUTPUT_CHAR('\n'); + } +} + +void testDoublesWithinDelta(void) +{ +#ifdef UNITY_EXCLUDE_DOUBLE + TEST_IGNORE(); +#else + TEST_ASSERT_DOUBLE_WITHIN(0.00003, 187245.03485, 187245.03488); + TEST_ASSERT_DOUBLE_WITHIN(1.0, 187245.0, 187246.0); + TEST_ASSERT_DOUBLE_WITHIN(0.05, 9273.2549, 9273.2049); + TEST_ASSERT_DOUBLE_WITHIN(0.007, -726.93725, -726.94424); +#endif +} + +void testDoublesNotWithinDelta(void) +{ +#ifdef UNITY_EXCLUDE_DOUBLE + TEST_IGNORE(); +#else + EXPECT_ABORT_BEGIN + TEST_ASSERT_DOUBLE_WITHIN(0.05, 9273.2649, 9273.2049); + VERIFY_FAILS_END +#endif +} + + +void testDoublesEqual(void) +{ +#ifdef UNITY_EXCLUDE_DOUBLE + TEST_IGNORE(); +#else + TEST_ASSERT_EQUAL_DOUBLE(187245123456.0, 187245123456.0); + TEST_ASSERT_EQUAL_DOUBLE(187241234567.5, 187241234567.6); + TEST_ASSERT_EQUAL_DOUBLE(9273.2512345649, 9273.25123455699); + TEST_ASSERT_EQUAL_DOUBLE(-726.12345693724, -726.1234569374); +#endif +} + +void testDoublesNotEqual(void) +{ +#ifdef UNITY_EXCLUDE_DOUBLE + TEST_IGNORE(); +#else + EXPECT_ABORT_BEGIN + TEST_ASSERT_EQUAL_DOUBLE(9273.9649, 9273.0049); + VERIFY_FAILS_END +#endif +} + +void testDoublesNotEqualNegative1(void) +{ +#ifdef UNITY_EXCLUDE_DOUBLE + TEST_IGNORE(); +#else + EXPECT_ABORT_BEGIN + TEST_ASSERT_EQUAL_DOUBLE(-9273.9649, -9273.0049); + VERIFY_FAILS_END +#endif +} + +void testDoublesNotEqualNegative2(void) +{ +#ifdef UNITY_EXCLUDE_DOUBLE + TEST_IGNORE(); +#else + EXPECT_ABORT_BEGIN + TEST_ASSERT_EQUAL_DOUBLE(-9273.0049, -9273.9649); + VERIFY_FAILS_END +#endif +} + +void testDoublesNotEqualActualNaN(void) +{ +#ifdef UNITY_EXCLUDE_DOUBLE + TEST_IGNORE(); +#else + EXPECT_ABORT_BEGIN + TEST_ASSERT_EQUAL_DOUBLE(85.963, 0.0 / d_zero); + VERIFY_FAILS_END +#endif +} + +void testDoublesNotEqualExpectedNaN(void) +{ +#ifdef UNITY_EXCLUDE_DOUBLE + TEST_IGNORE(); +#else + EXPECT_ABORT_BEGIN + TEST_ASSERT_EQUAL_DOUBLE(0.0 / d_zero, 85.963); + VERIFY_FAILS_END +#endif +} + +void testDoublesEqualBothNaN(void) +{ +#ifdef UNITY_EXCLUDE_DOUBLE + TEST_IGNORE(); +#else + TEST_ASSERT_EQUAL_DOUBLE(0.0 / d_zero, 0.0 / d_zero); +#endif +} + +void testDoublesNotEqualInfNaN(void) +{ +#ifdef UNITY_EXCLUDE_DOUBLE + TEST_IGNORE(); +#else + EXPECT_ABORT_BEGIN + TEST_ASSERT_EQUAL_DOUBLE(1.0 / d_zero, 0.0 / d_zero); + VERIFY_FAILS_END +#endif +} + +void testDoublesNotEqualNaNInf(void) +{ +#ifdef UNITY_EXCLUDE_DOUBLE + TEST_IGNORE(); +#else + EXPECT_ABORT_BEGIN + TEST_ASSERT_EQUAL_DOUBLE(0.0 / d_zero, 1.0 / d_zero); + VERIFY_FAILS_END +#endif +} + +void testDoublesNotEqualActualInf(void) +{ +#ifdef UNITY_EXCLUDE_DOUBLE + TEST_IGNORE(); +#else + EXPECT_ABORT_BEGIN + TEST_ASSERT_EQUAL_DOUBLE(321.642, 1.0 / d_zero); + VERIFY_FAILS_END +#endif +} + +void testDoublesNotEqualExpectedInf(void) +{ +#ifdef UNITY_EXCLUDE_DOUBLE + TEST_IGNORE(); +#else + EXPECT_ABORT_BEGIN + TEST_ASSERT_EQUAL_DOUBLE(1.0 / d_zero, 321.642); + VERIFY_FAILS_END +#endif +} + +void testDoublesEqualBothInf(void) +{ +#ifdef UNITY_EXCLUDE_DOUBLE + TEST_IGNORE(); +#else + TEST_ASSERT_EQUAL_DOUBLE(1.0 / d_zero, 1.0 / d_zero); +#endif +} + +void testDoublesNotEqualPlusMinusInf(void) +{ +#ifdef UNITY_EXCLUDE_DOUBLE + TEST_IGNORE(); +#else + EXPECT_ABORT_BEGIN + TEST_ASSERT_EQUAL_DOUBLE(1.0 / d_zero, -1.0 / d_zero); + VERIFY_FAILS_END +#endif +} + +void testDoubleIsPosInf1(void) +{ +#ifdef UNITY_EXCLUDE_DOUBLE + TEST_IGNORE(); +#else + TEST_ASSERT_DOUBLE_IS_INF(2.0 / d_zero); +#endif +} + +void testDoubleIsPosInf2(void) +{ +#ifdef UNITY_EXCLUDE_DOUBLE + TEST_IGNORE(); +#else + EXPECT_ABORT_BEGIN + TEST_ASSERT_DOUBLE_IS_NOT_INF(2.0 / d_zero); + VERIFY_FAILS_END +#endif +} + +void testDoubleIsNegInf1(void) +{ +#ifdef UNITY_EXCLUDE_DOUBLE + TEST_IGNORE(); +#else + TEST_ASSERT_DOUBLE_IS_NEG_INF(-3.0 / d_zero); +#endif +} + +void testDoubleIsNegInf2(void) +{ +#ifdef UNITY_EXCLUDE_DOUBLE + TEST_IGNORE(); +#else + EXPECT_ABORT_BEGIN + TEST_ASSERT_DOUBLE_IS_NOT_NEG_INF(-3.0 / d_zero); + VERIFY_FAILS_END +#endif +} + +void testDoubleIsNotPosInf1(void) +{ +#ifdef UNITY_EXCLUDE_DOUBLE + TEST_IGNORE(); +#else + EXPECT_ABORT_BEGIN + TEST_ASSERT_DOUBLE_IS_INF(2.0); + VERIFY_FAILS_END +#endif +} + +void testDoubleIsNotPosInf2(void) +{ +#ifdef UNITY_EXCLUDE_DOUBLE + TEST_IGNORE(); +#else + TEST_ASSERT_DOUBLE_IS_NOT_INF(2.0); +#endif +} + +void testDoubleIsNotNegInf(void) +{ +#ifdef UNITY_EXCLUDE_DOUBLE + TEST_IGNORE(); +#else + EXPECT_ABORT_BEGIN + TEST_ASSERT_DOUBLE_IS_NEG_INF(-999.876); + VERIFY_FAILS_END +#endif +} + +void testDoubleIsNan1(void) +{ +#ifdef UNITY_EXCLUDE_DOUBLE + TEST_IGNORE(); +#else + TEST_ASSERT_DOUBLE_IS_NAN(0.0 / d_zero); +#endif +} + +void testDoubleIsNan2(void) +{ +#ifdef UNITY_EXCLUDE_DOUBLE + TEST_IGNORE(); +#else + EXPECT_ABORT_BEGIN + TEST_ASSERT_DOUBLE_IS_NOT_NAN(0.0 / d_zero); + VERIFY_FAILS_END +#endif +} + +void testDoubleIsNotNan1(void) +{ +#ifdef UNITY_EXCLUDE_DOUBLE + TEST_IGNORE(); +#else + EXPECT_ABORT_BEGIN + TEST_ASSERT_DOUBLE_IS_NAN(234.9); + VERIFY_FAILS_END +#endif +} + +void testDoubleIsNotNan2(void) +{ +#ifdef UNITY_EXCLUDE_DOUBLE + TEST_IGNORE(); +#else + TEST_ASSERT_DOUBLE_IS_NOT_NAN(234.9); +#endif +} + +void testDoubleInfIsNotNan(void) +{ +#ifdef UNITY_EXCLUDE_DOUBLE + TEST_IGNORE(); +#else + EXPECT_ABORT_BEGIN + TEST_ASSERT_DOUBLE_IS_NAN(1.0 / d_zero); + VERIFY_FAILS_END +#endif +} + +void testDoubleNanIsNotInf(void) +{ +#ifdef UNITY_EXCLUDE_DOUBLE + TEST_IGNORE(); +#else + EXPECT_ABORT_BEGIN + TEST_ASSERT_DOUBLE_IS_INF(0.0 / d_zero); + VERIFY_FAILS_END +#endif +} + +void testDoubleIsDeterminate1(void) +{ +#ifdef UNITY_EXCLUDE_DOUBLE + TEST_IGNORE(); +#else + TEST_ASSERT_DOUBLE_IS_DETERMINATE(0.0); + TEST_ASSERT_DOUBLE_IS_DETERMINATE(123.3); + TEST_ASSERT_DOUBLE_IS_DETERMINATE(-88.3); +#endif +} + +void testDoubleIsDeterminate2(void) +{ +#ifdef UNITY_EXCLUDE_DOUBLE + TEST_IGNORE(); +#else + EXPECT_ABORT_BEGIN + TEST_ASSERT_DOUBLE_IS_NOT_DETERMINATE(-88.3); + VERIFY_FAILS_END +#endif +} + +void testDoubleIsNotDeterminate1(void) +{ +#ifdef UNITY_EXCLUDE_DOUBLE + TEST_IGNORE(); +#else + TEST_ASSERT_DOUBLE_IS_NOT_DETERMINATE(1.0 / d_zero); + TEST_ASSERT_DOUBLE_IS_NOT_DETERMINATE(-1.0 / d_zero); + TEST_ASSERT_DOUBLE_IS_NOT_DETERMINATE(0.0 / d_zero); +#endif +} + +void testDoubleIsNotDeterminate2(void) +{ +#ifdef UNITY_EXCLUDE_DOUBLE + TEST_IGNORE(); +#else + EXPECT_ABORT_BEGIN + TEST_ASSERT_DOUBLE_IS_DETERMINATE(-1.0 / d_zero); + VERIFY_FAILS_END +#endif +} + +void testDoubleTraitFailsOnInvalidTrait(void) +{ +#ifdef UNITY_EXCLUDE_DOUBLE + TEST_IGNORE(); +#else + EXPECT_ABORT_BEGIN + UnityAssertDoubleSpecial(1.0, NULL, __LINE__, UNITY_FLOAT_INVALID_TRAIT); + VERIFY_FAILS_END +#endif +} + +void testEqualDoubleArrays(void) +{ +#ifdef UNITY_EXCLUDE_DOUBLE + TEST_IGNORE(); +#else + double p0[] = {1.0, -8.0, 25.4, -0.123}; + double p1[] = {1.0, -8.0, 25.4, -0.123}; + double p2[] = {1.0, -8.0, 25.4, -0.2}; + double p3[] = {1.0, -23.0, 25.0, -0.26}; + + TEST_ASSERT_EQUAL_DOUBLE_ARRAY(p0, p0, 1); + TEST_ASSERT_EQUAL_DOUBLE_ARRAY(p0, p0, 4); + TEST_ASSERT_EQUAL_DOUBLE_ARRAY(p0, p1, 4); + TEST_ASSERT_EQUAL_DOUBLE_ARRAY(p0, p2, 3); + TEST_ASSERT_EQUAL_DOUBLE_ARRAY(p0, p3, 1); + TEST_ASSERT_EQUAL_DOUBLE_ARRAY(NULL, NULL, 1); +#endif +} + +void testNotEqualDoubleArraysExpectedNull(void) +{ +#ifdef UNITY_EXCLUDE_DOUBLE + TEST_IGNORE(); +#else + double* p0 = NULL; + double p1[] = {1.0, 8.0, 25.4, 0.252}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_EQUAL_DOUBLE_ARRAY(p0, p1, 4); + VERIFY_FAILS_END +#endif +} + +void testNotEqualDoubleArraysActualNull(void) +{ +#ifdef UNITY_EXCLUDE_DOUBLE + TEST_IGNORE(); +#else + double p0[] = {1.0, 8.0, 25.4, 0.253}; + double* p1 = NULL; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_EQUAL_DOUBLE_ARRAY(p0, p1, 4); + VERIFY_FAILS_END +#endif +} + +void testNotEqualDoubleArrays1(void) +{ +#ifdef UNITY_EXCLUDE_DOUBLE + TEST_IGNORE(); +#else + double p0[] = {1.0, 8.0, 25.4, 0.25666666667}; + double p1[] = {1.0, 8.0, 25.4, 0.25666666666}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_EQUAL_DOUBLE_ARRAY(p0, p1, 4); + VERIFY_FAILS_END +#endif +} + +void testNotEqualDoubleArrays2(void) +{ +#ifdef UNITY_EXCLUDE_DOUBLE + TEST_IGNORE(); +#else + double p0[] = {1.0, 8.0, 25.4, 0.253}; + double p1[] = {2.0, 8.0, 25.4, 0.253}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_EQUAL_DOUBLE_ARRAY(p0, p1, 4); + VERIFY_FAILS_END +#endif +} + +void testNotEqualDoubleArrays3(void) +{ +#ifdef UNITY_EXCLUDE_DOUBLE + TEST_IGNORE(); +#else + double p0[] = {1.0, 8.0, 25.4, 0.253}; + double p1[] = {1.0, 8.0, 25.5, 0.253}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_EQUAL_DOUBLE_ARRAY(p0, p1, 4); + VERIFY_FAILS_END +#endif +} + +void testNotEqualDoubleArraysNegative1(void) +{ +#ifdef UNITY_EXCLUDE_DOUBLE + TEST_IGNORE(); +#else + double p0[] = {-1.0, -8.0, -25.4, -0.2566666667}; + double p1[] = {-1.0, -8.0, -25.4, -0.2566666666}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_EQUAL_DOUBLE_ARRAY(p0, p1, 4); + VERIFY_FAILS_END +#endif +} + +void testNotEqualDoubleArraysNegative2(void) +{ +#ifdef UNITY_EXCLUDE_DOUBLE + TEST_IGNORE(); +#else + double p0[] = {-1.0, -8.0, -25.4, -0.253}; + double p1[] = {-2.0, -8.0, -25.4, -0.253}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_EQUAL_DOUBLE_ARRAY(p0, p1, 4); + VERIFY_FAILS_END +#endif +} + +void testNotEqualDoubleArraysNegative3(void) +{ +#ifdef UNITY_EXCLUDE_DOUBLE + TEST_IGNORE(); +#else + double p0[] = {-1.0, -8.0, -25.4, -0.253}; + double p1[] = {-1.0, -8.0, -25.5, -0.253}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_EQUAL_DOUBLE_ARRAY(p0, p1, 4); + VERIFY_FAILS_END +#endif +} + +void testEqualDoubleArraysNaN(void) +{ +#ifdef UNITY_EXCLUDE_DOUBLE + TEST_IGNORE(); +#else + double p0[] = {1.0, 0.0 / d_zero, 25.4, 0.253}; + double p1[] = {1.0, 0.0 / d_zero, 25.4, 0.253}; + + TEST_ASSERT_EQUAL_DOUBLE_ARRAY(p0, p1, 4); +#endif +} + +void testEqualDoubleArraysInf(void) +{ +#ifdef UNITY_EXCLUDE_DOUBLE + TEST_IGNORE(); +#else + double p0[] = {1.0, 1.0 / d_zero, 25.4, 0.253}; + double p1[] = {1.0, 1.0 / d_zero, 25.4, 0.253}; + + TEST_ASSERT_EQUAL_DOUBLE_ARRAY(p0, p1, 4); +#endif +} + +void testNotEqualDoubleArraysLengthZero(void) +{ +#ifdef UNITY_EXCLUDE_DOUBLE + TEST_IGNORE(); +#else + double p0[1] = {0.0}; + double p1[1] = {0.0}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_EQUAL_DOUBLE_ARRAY(p0, p1, 0); + VERIFY_FAILS_END +#endif +} + +void testEqualDoubleEachEqual(void) +{ +#ifdef UNITY_EXCLUDE_DOUBLE + TEST_IGNORE(); +#else + double p0[] = {1.0, 1.0, 1.0, 1.0}; + double p1[] = {-0.123, -0.123, -0.123, -0.123}; + double p2[] = {25.4, 25.4, 25.4, -0.2}; + double p3[] = {1.0, -23.0, 25.0, -0.26}; + + TEST_ASSERT_EACH_EQUAL_DOUBLE(1.0, p0, 1); + TEST_ASSERT_EACH_EQUAL_DOUBLE(1.0, p0, 4); + TEST_ASSERT_EACH_EQUAL_DOUBLE(-0.123, p1, 4); + TEST_ASSERT_EACH_EQUAL_DOUBLE(25.4, p2, 3); + TEST_ASSERT_EACH_EQUAL_DOUBLE(1.0, p3, 1); +#endif +} + +void testNotEqualDoubleEachEqualActualNull(void) +{ +#ifdef UNITY_EXCLUDE_DOUBLE + TEST_IGNORE(); +#else + double* p0 = NULL; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_EACH_EQUAL_DOUBLE(5, p0, 4); + VERIFY_FAILS_END +#endif +} + +void testNotEqualDoubleEachEqual1(void) +{ +#ifdef UNITY_EXCLUDE_DOUBLE + TEST_IGNORE(); +#else + double p0[] = {0.253, 8.0, 0.253, 0.253}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_EACH_EQUAL_DOUBLE(0.253, p0, 4); + VERIFY_FAILS_END +#endif +} + +void testNotEqualDoubleEachEqual2(void) +{ +#ifdef UNITY_EXCLUDE_DOUBLE + TEST_IGNORE(); +#else + double p0[] = {8.0, 8.0, 8.0, 0.253}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_EACH_EQUAL_DOUBLE(8.0, p0, 4); + VERIFY_FAILS_END +#endif +} + +void testNotEqualDoubleEachEqual3(void) +{ +#ifdef UNITY_EXCLUDE_DOUBLE + TEST_IGNORE(); +#else + double p0[] = {1.0, 1.0, 1.0, 0.253}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_EACH_EQUAL_DOUBLE(1.0, p0, 4); + VERIFY_FAILS_END +#endif +} + +void testNotEqualDoubleEachEqualNegative1(void) +{ +#ifdef UNITY_EXCLUDE_DOUBLE + TEST_IGNORE(); +#else + double p0[] = {-1.0, -0.253, -0.253, -0.253}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_EACH_EQUAL_DOUBLE(-0.253, p0, 4); + VERIFY_FAILS_END +#endif +} + +void testNotEqualDoubleEachEqualNegative2(void) +{ +#ifdef UNITY_EXCLUDE_DOUBLE + TEST_IGNORE(); +#else + double p0[] = {-25.4, -8.0, -25.4, -25.4}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_EACH_EQUAL_DOUBLE(-25.4, p0, 4); + VERIFY_FAILS_END +#endif +} + +void testNotEqualDoubleEachEqualNegative3(void) +{ +#ifdef UNITY_EXCLUDE_DOUBLE + TEST_IGNORE(); +#else + double p0[] = {-8.0, -8.0, -8.0, -0.253}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_EACH_EQUAL_DOUBLE(-8.0, p0, 4); + VERIFY_FAILS_END +#endif +} + +void testEqualDoubleEachEqualNaN(void) +{ +#ifdef UNITY_EXCLUDE_DOUBLE + TEST_IGNORE(); +#else + double p0[] = {0.0 / d_zero, 0.0 / d_zero, 0.0 / d_zero, 0.0 / d_zero}; + + TEST_ASSERT_EACH_EQUAL_DOUBLE(0.0 / d_zero, p0, 4); +#endif +} + +void testEqualDoubleEachEqualInf(void) +{ +#ifdef UNITY_EXCLUDE_DOUBLE + TEST_IGNORE(); +#else + double p0[] = {1.0 / d_zero, 1.0 / d_zero, 25.4, 0.253}; + + TEST_ASSERT_EACH_EQUAL_DOUBLE(1.0 / d_zero, p0, 2); +#endif +} + +void testNotEqualDoubleEachEqualLengthZero(void) +{ +#ifdef UNITY_EXCLUDE_DOUBLE + TEST_IGNORE(); +#else + double p0[1] = {0.0}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_EACH_EQUAL_DOUBLE(0.0, p0, 0); + VERIFY_FAILS_END +#endif +} + +void testDoublePrinting(void) +{ +#if defined(UNITY_EXCLUDE_FLOAT_PRINT) || defined(UNITY_EXCLUDE_DOUBLE) || !defined(USING_OUTPUT_SPY) + TEST_IGNORE(); +#else + TEST_ASSERT_EQUAL_PRINT_FLOATING("0", 0.0); + TEST_ASSERT_EQUAL_PRINT_FLOATING("4.99e-07", 0.000000499); + TEST_ASSERT_EQUAL_PRINT_FLOATING("5.0000005e-07", 0.00000050000005); + TEST_ASSERT_EQUAL_PRINT_FLOATING("0.100469499", 0.100469499); + TEST_ASSERT_EQUAL_PRINT_FLOATING("1", 0.9999999995); /*Rounding to int place*/ + TEST_ASSERT_EQUAL_PRINT_FLOATING("1", 1.0); + TEST_ASSERT_EQUAL_PRINT_FLOATING("1.25", 1.25); + TEST_ASSERT_EQUAL_PRINT_FLOATING("7.99999999", 7.99999999); /*Not rounding*/ + TEST_ASSERT_EQUAL_PRINT_FLOATING("16.0000002", 16.0000002); + TEST_ASSERT_EQUAL_PRINT_FLOATING("16.0000004", 16.0000004); + TEST_ASSERT_EQUAL_PRINT_FLOATING("16.0000006", 16.0000006); + TEST_ASSERT_EQUAL_PRINT_FLOATING("999999999", 999999999.0); /*Last full print integer*/ + + TEST_ASSERT_EQUAL_PRINT_FLOATING("0", -0.0); /* -0 no supported on all targets */ + TEST_ASSERT_EQUAL_PRINT_FLOATING("-4.99e-07", -0.000000499); + TEST_ASSERT_EQUAL_PRINT_FLOATING("-5.0000005e-07", -0.00000050000005); + TEST_ASSERT_EQUAL_PRINT_FLOATING("-0.100469499", -0.100469499); + TEST_ASSERT_EQUAL_PRINT_FLOATING("-1", -0.9999999995); /*Rounding to int place*/ + TEST_ASSERT_EQUAL_PRINT_FLOATING("-1", -1.0); + TEST_ASSERT_EQUAL_PRINT_FLOATING("-1.25", -1.25); + TEST_ASSERT_EQUAL_PRINT_FLOATING("-7.99999999", -7.99999999); /*Not rounding*/ + TEST_ASSERT_EQUAL_PRINT_FLOATING("-16.0000002", -16.0000002); + TEST_ASSERT_EQUAL_PRINT_FLOATING("-16.0000004", -16.0000004); + TEST_ASSERT_EQUAL_PRINT_FLOATING("-16.0000006", -16.0000006); + TEST_ASSERT_EQUAL_PRINT_FLOATING("-999999999", -999999999.0); /*Last full print integer*/ + + TEST_ASSERT_EQUAL_PRINT_FLOATING("0.1004695", 0.10046949999999999); + TEST_ASSERT_EQUAL_PRINT_FLOATING("4.2949673e+09", 4294967295.9); + TEST_ASSERT_EQUAL_PRINT_FLOATING("4.2949673e+09", 4294967296.0); + TEST_ASSERT_EQUAL_PRINT_FLOATING("1e+10", 9999999995.0); + TEST_ASSERT_EQUAL_PRINT_FLOATING("9.00719925e+15", 9007199254740990.0); + TEST_ASSERT_EQUAL_PRINT_FLOATING("7e+100", 7.0e+100); + TEST_ASSERT_EQUAL_PRINT_FLOATING("3e+200", 3.0e+200); + TEST_ASSERT_EQUAL_PRINT_FLOATING("9.23456789e+300", 9.23456789e+300); + + TEST_ASSERT_EQUAL_PRINT_FLOATING("-0.1004695", -0.10046949999999999); + TEST_ASSERT_EQUAL_PRINT_FLOATING("-4.2949673e+09", -4294967295.9); + TEST_ASSERT_EQUAL_PRINT_FLOATING("-4.2949673e+09", -4294967296.0); + TEST_ASSERT_EQUAL_PRINT_FLOATING("-7e+100", -7.0e+100); +#endif +} + +void testDoublePrintingRoundTiesToEven(void) +{ +#if defined(UNITY_EXCLUDE_FLOAT_PRINT) || defined(UNITY_EXCLUDE_DOUBLE) || !defined(USING_OUTPUT_SPY) + TEST_IGNORE(); +#else + #ifdef UNITY_ROUND_TIES_AWAY_FROM_ZERO + TEST_ASSERT_EQUAL_PRINT_FLOATING("1.00000001e+10", 10000000050.0); + TEST_ASSERT_EQUAL_PRINT_FLOATING("9.00719925e+15", 9007199245000000.0); + #else /* Default to Round ties to even */ + TEST_ASSERT_EQUAL_PRINT_FLOATING("1e+10", 10000000050.0); + TEST_ASSERT_EQUAL_PRINT_FLOATING("9.00719924e+15", 9007199245000000.0); + #endif +#endif +} + +void testDoublePrintingInfinityAndNaN(void) +{ +#if defined(UNITY_EXCLUDE_FLOAT_PRINT) || defined(UNITY_EXCLUDE_DOUBLE) || !defined(USING_OUTPUT_SPY) + TEST_IGNORE(); +#else + TEST_ASSERT_EQUAL_PRINT_FLOATING("inf", 1.0 / d_zero); + TEST_ASSERT_EQUAL_PRINT_FLOATING("-inf", -1.0 / d_zero); + + TEST_ASSERT_EQUAL_PRINT_FLOATING("nan", 0.0 / d_zero); +#endif +} diff --git a/test/tests/test_unity_floats.c b/test/tests/test_unity_floats.c new file mode 100644 index 00000000..bbf761a7 --- /dev/null +++ b/test/tests/test_unity_floats.c @@ -0,0 +1,886 @@ +/* ========================================== + Unity Project - A Test Framework for C + Copyright (c) 2007 Mike Karlesky, Mark VanderVoord, Greg Williams + [Released under MIT License. Please refer to license.txt for details] +========================================== */ + +#include "unity.h" +#define TEST_INSTANCES +#include "self_assessment_utils.h" + +void setUp(void) +{ + SetToOneToFailInTearDown = 0; + SetToOneMeanWeAlreadyCheckedThisGuy = 0; +} + +void tearDown(void) +{ + endPutcharSpy(); /* Stop suppressing test output */ + if (SetToOneToFailInTearDown == 1) + { + /* These will be skipped internally if already failed/ignored */ + TEST_FAIL_MESSAGE("<= Failed in tearDown"); + TEST_IGNORE_MESSAGE("<= Ignored in tearDown"); + } + if ((SetToOneMeanWeAlreadyCheckedThisGuy == 0) && (Unity.CurrentTestFailed > 0)) + { + UnityPrint(": [[[[ Test Should Have Passed But Did Not ]]]]"); + UNITY_OUTPUT_CHAR('\n'); + } +} + +void testFloatsWithinDelta(void) +{ +#ifdef UNITY_EXCLUDE_FLOAT + TEST_IGNORE(); +#else + TEST_ASSERT_FLOAT_WITHIN(0.00003f, 187245.03485f, 187245.03488f); + TEST_ASSERT_FLOAT_WITHIN(1.0f, 187245.0f, 187246.0f); + TEST_ASSERT_FLOAT_WITHIN(0.05f, 9273.2549f, 9273.2049f); + TEST_ASSERT_FLOAT_WITHIN(0.007f, -726.93724f, -726.94424f); +#endif +} + +void testFloatsNotWithinDelta(void) +{ +#ifdef UNITY_EXCLUDE_FLOAT + TEST_IGNORE(); +#else + EXPECT_ABORT_BEGIN + TEST_ASSERT_FLOAT_WITHIN(0.05f, 9273.2649f, 9273.2049f); + VERIFY_FAILS_END +#endif +} + +void testFloatsEqual(void) +{ +#ifdef UNITY_EXCLUDE_FLOAT + TEST_IGNORE(); +#else + TEST_ASSERT_EQUAL_FLOAT(187245.0f, 187246.0f); + TEST_ASSERT_EQUAL_FLOAT(18724.5f, 18724.6f); + TEST_ASSERT_EQUAL_FLOAT(9273.2549f, 9273.2599f); + TEST_ASSERT_EQUAL_FLOAT(-726.93724f, -726.9374f); +#endif +} + +void testFloatsNotEqual(void) +{ +#ifdef UNITY_EXCLUDE_FLOAT + TEST_IGNORE(); +#else + EXPECT_ABORT_BEGIN + TEST_ASSERT_EQUAL_FLOAT(9273.9649f, 9273.0049f); + VERIFY_FAILS_END +#endif +} + +void testFloatsNotEqualNegative1(void) +{ +#ifdef UNITY_EXCLUDE_FLOAT + TEST_IGNORE(); +#else + EXPECT_ABORT_BEGIN + TEST_ASSERT_EQUAL_FLOAT(-9273.9649f, -9273.0049f); + VERIFY_FAILS_END +#endif +} + +void testFloatsNotEqualNegative2(void) +{ +#ifdef UNITY_EXCLUDE_FLOAT + TEST_IGNORE(); +#else + EXPECT_ABORT_BEGIN + TEST_ASSERT_EQUAL_FLOAT(-9273.0049f, -9273.9649f); + VERIFY_FAILS_END +#endif +} + +void testFloatsNotEqualActualNaN(void) +{ +#ifdef UNITY_EXCLUDE_FLOAT + TEST_IGNORE(); +#else + EXPECT_ABORT_BEGIN + TEST_ASSERT_EQUAL_FLOAT(85.963f, 0.0f / f_zero); + VERIFY_FAILS_END +#endif +} + +void testFloatsNotEqualExpectedNaN(void) +{ +#ifdef UNITY_EXCLUDE_FLOAT + TEST_IGNORE(); +#else + EXPECT_ABORT_BEGIN + TEST_ASSERT_EQUAL_FLOAT(0.0f / f_zero, 85.963f); + VERIFY_FAILS_END +#endif +} + +void testFloatsEqualBothNaN(void) +{ +#ifdef UNITY_EXCLUDE_FLOAT + TEST_IGNORE(); +#else + TEST_ASSERT_EQUAL_FLOAT(0.0f / f_zero, 0.0f / f_zero); +#endif +} + +void testFloatsNotEqualInfNaN(void) +{ +#ifdef UNITY_EXCLUDE_FLOAT + TEST_IGNORE(); +#else + EXPECT_ABORT_BEGIN + TEST_ASSERT_EQUAL_FLOAT(1.0f / f_zero, 0.0f / f_zero); + VERIFY_FAILS_END +#endif +} + +void testFloatsNotEqualNaNInf(void) +{ +#ifdef UNITY_EXCLUDE_FLOAT + TEST_IGNORE(); +#else + EXPECT_ABORT_BEGIN + TEST_ASSERT_EQUAL_FLOAT(0.0f / f_zero, 1.0f / f_zero); + VERIFY_FAILS_END +#endif +} + +void testFloatsNotEqualActualInf(void) +{ +#ifdef UNITY_EXCLUDE_FLOAT + TEST_IGNORE(); +#else + EXPECT_ABORT_BEGIN + TEST_ASSERT_EQUAL_FLOAT(321.642f, 1.0f / f_zero); + VERIFY_FAILS_END +#endif +} + +void testFloatsNotEqualExpectedInf(void) +{ +#ifdef UNITY_EXCLUDE_FLOAT + TEST_IGNORE(); +#else + EXPECT_ABORT_BEGIN + TEST_ASSERT_EQUAL_FLOAT(1.0f / f_zero, 321.642f); + VERIFY_FAILS_END +#endif +} + +void testFloatsEqualBothInf(void) +{ +#ifdef UNITY_EXCLUDE_FLOAT + TEST_IGNORE(); +#else + TEST_ASSERT_EQUAL_FLOAT(1.0f / f_zero, 1.0f / f_zero); +#endif +} + +void testFloatsNotEqualPlusMinusInf(void) +{ +#ifdef UNITY_EXCLUDE_FLOAT + TEST_IGNORE(); +#else + EXPECT_ABORT_BEGIN + TEST_ASSERT_EQUAL_FLOAT(1.0f / f_zero, -1.0f / f_zero); + VERIFY_FAILS_END +#endif +} + +void testFloatIsPosInf1(void) +{ +#ifdef UNITY_EXCLUDE_FLOAT + TEST_IGNORE(); +#else + TEST_ASSERT_FLOAT_IS_INF(2.0f / f_zero); +#endif +} + +void testFloatIsPosInf2(void) +{ +#ifdef UNITY_EXCLUDE_FLOAT + TEST_IGNORE(); +#else + EXPECT_ABORT_BEGIN + TEST_ASSERT_FLOAT_IS_NOT_INF(2.0f / f_zero); + VERIFY_FAILS_END +#endif +} + +void testFloatIsNegInf1(void) +{ +#ifdef UNITY_EXCLUDE_FLOAT + TEST_IGNORE(); +#else + TEST_ASSERT_FLOAT_IS_NEG_INF(-3.0f / f_zero); +#endif +} + +void testFloatIsNegInf2(void) +{ +#ifdef UNITY_EXCLUDE_FLOAT + TEST_IGNORE(); +#else + EXPECT_ABORT_BEGIN + TEST_ASSERT_FLOAT_IS_NOT_NEG_INF(-3.0f / f_zero); + VERIFY_FAILS_END +#endif +} + +void testFloatIsNotPosInf1(void) +{ +#ifdef UNITY_EXCLUDE_FLOAT + TEST_IGNORE(); +#else + EXPECT_ABORT_BEGIN + TEST_ASSERT_FLOAT_IS_INF(2.0f); + VERIFY_FAILS_END +#endif +} + +void testFloatIsNotPosInf2(void) +{ +#ifdef UNITY_EXCLUDE_FLOAT + TEST_IGNORE(); +#else + TEST_ASSERT_FLOAT_IS_NOT_INF(2.0f); +#endif +} + +void testFloatIsNotNegInf(void) +{ +#ifdef UNITY_EXCLUDE_FLOAT + TEST_IGNORE(); +#else + EXPECT_ABORT_BEGIN + TEST_ASSERT_FLOAT_IS_NEG_INF(-999.876f); + VERIFY_FAILS_END +#endif +} + +void testFloatIsNan1(void) +{ +#ifdef UNITY_EXCLUDE_FLOAT + TEST_IGNORE(); +#else + TEST_ASSERT_FLOAT_IS_NAN(0.0f / f_zero); +#endif +} + +void testFloatIsNan2(void) +{ +#ifdef UNITY_EXCLUDE_FLOAT + TEST_IGNORE(); +#else + EXPECT_ABORT_BEGIN + TEST_ASSERT_FLOAT_IS_NOT_NAN(0.0f / f_zero); + VERIFY_FAILS_END +#endif +} + +void testFloatIsNotNan1(void) +{ +#ifdef UNITY_EXCLUDE_FLOAT + TEST_IGNORE(); +#else + EXPECT_ABORT_BEGIN + TEST_ASSERT_FLOAT_IS_NAN(234.9f); + VERIFY_FAILS_END +#endif +} + +void testFloatIsNotNan2(void) +{ +#ifdef UNITY_EXCLUDE_FLOAT + TEST_IGNORE(); +#else + TEST_ASSERT_FLOAT_IS_NOT_NAN(234.9f); +#endif +} + +void testFloatInfIsNotNan(void) +{ +#ifdef UNITY_EXCLUDE_FLOAT + TEST_IGNORE(); +#else + EXPECT_ABORT_BEGIN + TEST_ASSERT_FLOAT_IS_NAN(1.0f / f_zero); + VERIFY_FAILS_END +#endif +} + +void testFloatNanIsNotInf(void) +{ +#ifdef UNITY_EXCLUDE_FLOAT + TEST_IGNORE(); +#else + EXPECT_ABORT_BEGIN + TEST_ASSERT_FLOAT_IS_INF(0.0f / f_zero); + VERIFY_FAILS_END +#endif +} + +void testFloatIsDeterminate1(void) +{ +#ifdef UNITY_EXCLUDE_FLOAT + TEST_IGNORE(); +#else + TEST_ASSERT_FLOAT_IS_DETERMINATE(0.0f); + TEST_ASSERT_FLOAT_IS_DETERMINATE(123.3f); + TEST_ASSERT_FLOAT_IS_DETERMINATE(-88.3f); +#endif +} + +void testFloatIsDeterminate2(void) +{ +#ifdef UNITY_EXCLUDE_FLOAT + TEST_IGNORE(); +#else + EXPECT_ABORT_BEGIN + TEST_ASSERT_FLOAT_IS_NOT_DETERMINATE(-88.3f); + VERIFY_FAILS_END +#endif +} + +void testFloatIsNotDeterminate1(void) +{ +#ifdef UNITY_EXCLUDE_FLOAT + TEST_IGNORE(); +#else + TEST_ASSERT_FLOAT_IS_NOT_DETERMINATE(1.0f / f_zero); + TEST_ASSERT_FLOAT_IS_NOT_DETERMINATE(-1.0f / f_zero); + TEST_ASSERT_FLOAT_IS_NOT_DETERMINATE(0.0f / f_zero); +#endif +} + +void testFloatIsNotDeterminate2(void) +{ +#ifdef UNITY_EXCLUDE_FLOAT + TEST_IGNORE(); +#else + EXPECT_ABORT_BEGIN + TEST_ASSERT_FLOAT_IS_DETERMINATE(-1.0f / f_zero); + VERIFY_FAILS_END +#endif +} + +void testFloatTraitFailsOnInvalidTrait(void) +{ +#ifdef UNITY_EXCLUDE_FLOAT + TEST_IGNORE(); +#else + EXPECT_ABORT_BEGIN + UnityAssertFloatSpecial(1.0f, NULL, __LINE__, UNITY_FLOAT_INVALID_TRAIT); + VERIFY_FAILS_END +#endif +} + +void testEqualFloatArrays(void) +{ +#ifdef UNITY_EXCLUDE_FLOAT + TEST_IGNORE(); +#else + float p0[] = {1.0f, -8.0f, 25.4f, -0.123f}; + float p1[] = {1.0f, -8.0f, 25.4f, -0.123f}; + float p2[] = {1.0f, -8.0f, 25.4f, -0.2f}; + float p3[] = {1.0f, -23.0f, 25.0f, -0.26f}; + + TEST_ASSERT_EQUAL_FLOAT_ARRAY(p0, p0, 1); + TEST_ASSERT_EQUAL_FLOAT_ARRAY(p0, p0, 4); + TEST_ASSERT_EQUAL_FLOAT_ARRAY(p0, p1, 4); + TEST_ASSERT_EQUAL_FLOAT_ARRAY(p0, p2, 3); + TEST_ASSERT_EQUAL_FLOAT_ARRAY(p0, p3, 1); + TEST_ASSERT_EQUAL_FLOAT_ARRAY(NULL, NULL, 1); +#endif +} + +void testNotEqualFloatArraysExpectedNull(void) +{ +#ifdef UNITY_EXCLUDE_FLOAT + TEST_IGNORE(); +#else + float* p0 = NULL; + float p1[] = {1.0f, 8.0f, 25.4f, 0.252f}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_EQUAL_FLOAT_ARRAY(p0, p1, 4); + VERIFY_FAILS_END +#endif +} + +void testNotEqualFloatArraysActualNull(void) +{ +#ifdef UNITY_EXCLUDE_FLOAT + TEST_IGNORE(); +#else + float p0[] = {1.0f, 8.0f, 25.4f, 0.253f}; + float* p1 = NULL; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_EQUAL_FLOAT_ARRAY(p0, p1, 4); + VERIFY_FAILS_END +#endif +} + +void testNotEqualFloatArrays1(void) +{ +#ifdef UNITY_EXCLUDE_FLOAT + TEST_IGNORE(); +#else + float p0[] = {1.0f, 8.0f, 25.4f, 0.253f}; + float p1[] = {1.0f, 8.0f, 25.4f, 0.252f}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_EQUAL_FLOAT_ARRAY(p0, p1, 4); + VERIFY_FAILS_END +#endif +} + +void testNotEqualFloatArrays2(void) +{ +#ifdef UNITY_EXCLUDE_FLOAT + TEST_IGNORE(); +#else + float p0[] = {1.0f, 8.0f, 25.4f, 0.253f}; + float p1[] = {2.0f, 8.0f, 25.4f, 0.253f}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_EQUAL_FLOAT_ARRAY(p0, p1, 4); + VERIFY_FAILS_END +#endif +} + +void testNotEqualFloatArrays3(void) +{ +#ifdef UNITY_EXCLUDE_FLOAT + TEST_IGNORE(); +#else + float p0[] = {1.0f, 8.0f, 25.4f, 0.253f}; + float p1[] = {1.0f, 8.0f, 25.5f, 0.253f}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_EQUAL_FLOAT_ARRAY(p0, p1, 4); + VERIFY_FAILS_END +#endif +} + +void testNotEqualFloatArraysNegative1(void) +{ +#ifdef UNITY_EXCLUDE_FLOAT + TEST_IGNORE(); +#else + float p0[] = {-1.0f, -8.0f, -25.4f, -0.253f}; + float p1[] = {-1.0f, -8.0f, -25.4f, -0.252f}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_EQUAL_FLOAT_ARRAY(p0, p1, 4); + VERIFY_FAILS_END +#endif +} + +void testNotEqualFloatArraysNegative2(void) +{ +#ifdef UNITY_EXCLUDE_FLOAT + TEST_IGNORE(); +#else + float p0[] = {-1.0f, -8.0f, -25.4f, -0.253f}; + float p1[] = {-2.0f, -8.0f, -25.4f, -0.253f}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_EQUAL_FLOAT_ARRAY(p0, p1, 4); + VERIFY_FAILS_END +#endif +} + +void testNotEqualFloatArraysNegative3(void) +{ +#ifdef UNITY_EXCLUDE_FLOAT + TEST_IGNORE(); +#else + float p0[] = {-1.0f, -8.0f, -25.4f, -0.253f}; + float p1[] = {-1.0f, -8.0f, -25.5f, -0.253f}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_EQUAL_FLOAT_ARRAY(p0, p1, 4); + VERIFY_FAILS_END +#endif +} + +void testEqualFloatArraysNaN(void) +{ +#ifdef UNITY_EXCLUDE_FLOAT + TEST_IGNORE(); +#else + float p0[] = {1.0f, 0.0f / f_zero, 25.4f, 0.253f}; + float p1[] = {1.0f, 0.0f / f_zero, 25.4f, 0.253f}; + + TEST_ASSERT_EQUAL_FLOAT_ARRAY(p0, p1, 4); +#endif +} + +void testEqualFloatArraysInf(void) +{ +#ifdef UNITY_EXCLUDE_FLOAT + TEST_IGNORE(); +#else + float p0[] = {1.0f, 1.0f / f_zero, 25.4f, 0.253f}; + float p1[] = {1.0f, 1.0f / f_zero, 25.4f, 0.253f}; + + TEST_ASSERT_EQUAL_FLOAT_ARRAY(p0, p1, 4); +#endif +} + +void testNotEqualFloatArraysLengthZero(void) +{ +#ifdef UNITY_EXCLUDE_FLOAT + TEST_IGNORE(); +#else + float p0[1] = {0.0f}; + float p1[1] = {0.0f}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_EQUAL_FLOAT_ARRAY(p0, p1, 0); + VERIFY_FAILS_END +#endif +} + +void testEqualFloatEachEqual(void) +{ +#ifdef UNITY_EXCLUDE_FLOAT + TEST_IGNORE(); +#else + float p0[] = {1.0f, 1.0f, 1.0f, 1.0f}; + float p1[] = {-0.123f, -0.123f, -0.123f, -0.123f}; + float p2[] = {25.4f, 25.4f, 25.4f, -0.2f}; + float p3[] = {1.0f, -23.0f, 25.0f, -0.26f}; + + TEST_ASSERT_EACH_EQUAL_FLOAT(1.0f, p0, 1); + TEST_ASSERT_EACH_EQUAL_FLOAT(1.0f, p0, 4); + TEST_ASSERT_EACH_EQUAL_FLOAT(-0.123f, p1, 4); + TEST_ASSERT_EACH_EQUAL_FLOAT(25.4f, p2, 3); + TEST_ASSERT_EACH_EQUAL_FLOAT(1.0f, p3, 1); +#endif +} + +void testNotEqualFloatEachEqualActualNull(void) +{ +#ifdef UNITY_EXCLUDE_FLOAT + TEST_IGNORE(); +#else + float* p0 = NULL; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_EACH_EQUAL_FLOAT(5, p0, 4); + VERIFY_FAILS_END +#endif +} + +void testNotEqualFloatEachEqual1(void) +{ +#ifdef UNITY_EXCLUDE_FLOAT + TEST_IGNORE(); +#else + float p0[] = {0.253f, 8.0f, 0.253f, 0.253f}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_EACH_EQUAL_FLOAT(0.253f, p0, 4); + VERIFY_FAILS_END +#endif +} + +void testNotEqualFloatEachEqual2(void) +{ +#ifdef UNITY_EXCLUDE_FLOAT + TEST_IGNORE(); +#else + float p0[] = {8.0f, 8.0f, 8.0f, 0.253f}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_EACH_EQUAL_FLOAT(8.0f, p0, 4); + VERIFY_FAILS_END +#endif +} + +void testNotEqualFloatEachEqual3(void) +{ +#ifdef UNITY_EXCLUDE_FLOAT + TEST_IGNORE(); +#else + float p0[] = {1.0f, 1.0f, 1.0f, 0.253f}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_EACH_EQUAL_FLOAT(1.0f, p0, 4); + VERIFY_FAILS_END +#endif +} + +void testNotEqualFloatEachEqualNegative1(void) +{ +#ifdef UNITY_EXCLUDE_FLOAT + TEST_IGNORE(); +#else + float p0[] = {-1.0f, -0.253f, -0.253f, -0.253f}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_EACH_EQUAL_FLOAT(-0.253f, p0, 4); + VERIFY_FAILS_END +#endif +} + +void testNotEqualFloatEachEqualNegative2(void) +{ +#ifdef UNITY_EXCLUDE_FLOAT + TEST_IGNORE(); +#else + float p0[] = {-25.4f, -8.0f, -25.4f, -25.4f}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_EACH_EQUAL_FLOAT(-25.4f, p0, 4); + VERIFY_FAILS_END +#endif +} + +void testNotEqualFloatEachEqualNegative3(void) +{ +#ifdef UNITY_EXCLUDE_FLOAT + TEST_IGNORE(); +#else + float p0[] = {-8.0f, -8.0f, -8.0f, -0.253f}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_EACH_EQUAL_FLOAT(-8.0f, p0, 4); + VERIFY_FAILS_END +#endif +} + +void testEqualFloatEachEqualNaN(void) +{ +#ifdef UNITY_EXCLUDE_FLOAT + TEST_IGNORE(); +#else + float p0[] = {0.0f / f_zero, 0.0f / f_zero, 0.0f / f_zero, 0.0f / f_zero}; + + TEST_ASSERT_EACH_EQUAL_FLOAT(0.0f / f_zero, p0, 4); +#endif +} + +void testEqualFloatEachEqualInf(void) +{ +#ifdef UNITY_EXCLUDE_FLOAT + TEST_IGNORE(); +#else + float p0[] = {1.0f / f_zero, 1.0f / f_zero, 25.4f, 0.253f}; + + TEST_ASSERT_EACH_EQUAL_FLOAT(1.0f / f_zero, p0, 2); +#endif +} + +void testNotEqualFloatEachEqualLengthZero(void) +{ +#ifdef UNITY_EXCLUDE_FLOAT + TEST_IGNORE(); +#else + float p0[1] = {0.0f}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_EACH_EQUAL_FLOAT(0.0f, p0, 0); + VERIFY_FAILS_END +#endif +} + +#define TEST_ASSERT_EQUAL_PRINT_FLOATING(expected, actual) { \ + startPutcharSpy(); UnityPrintFloat((actual)); endPutcharSpy(); \ + TEST_ASSERT_EQUAL_STRING((expected), getBufferPutcharSpy()); \ + } + +void testFloatPrinting(void) +{ +#if defined(UNITY_EXCLUDE_FLOAT_PRINT) || defined(UNITY_INCLUDE_DOUBLE) || !defined(USING_OUTPUT_SPY) + TEST_IGNORE(); +#else + TEST_ASSERT_EQUAL_PRINT_FLOATING("0", 0.0f); + TEST_ASSERT_EQUAL_PRINT_FLOATING("4.99e-07", 0.000000499f); + TEST_ASSERT_EQUAL_PRINT_FLOATING("0.1004695", 0.100469499f); + TEST_ASSERT_EQUAL_PRINT_FLOATING("2", 1.9999995f); /*Rounding to int place*/ + TEST_ASSERT_EQUAL_PRINT_FLOATING("1", 1.0f); + TEST_ASSERT_EQUAL_PRINT_FLOATING("1.25", 1.25f); + TEST_ASSERT_EQUAL_PRINT_FLOATING("7.999999", 7.999999f); /*Not rounding*/ + TEST_ASSERT_EQUAL_PRINT_FLOATING("16.00002", 16.00002f); + TEST_ASSERT_EQUAL_PRINT_FLOATING("16.00004", 16.00004f); + TEST_ASSERT_EQUAL_PRINT_FLOATING("16.00006", 16.00006f); + TEST_ASSERT_EQUAL_PRINT_FLOATING("9999999", 9999999.0f); /*Last full print integer*/ + + TEST_ASSERT_EQUAL_PRINT_FLOATING("-0", -0.0f); + TEST_ASSERT_EQUAL_PRINT_FLOATING("-4.99e-07", -0.000000499f); + TEST_ASSERT_EQUAL_PRINT_FLOATING("-0.1004695", -0.100469499f); + TEST_ASSERT_EQUAL_PRINT_FLOATING("-2", -1.9999995f); /*Rounding to int place*/ + TEST_ASSERT_EQUAL_PRINT_FLOATING("-1", -1.0f); + TEST_ASSERT_EQUAL_PRINT_FLOATING("-1.25", -1.25f); + TEST_ASSERT_EQUAL_PRINT_FLOATING("-7.999999", -7.999999f); /*Not rounding*/ + TEST_ASSERT_EQUAL_PRINT_FLOATING("-16.00002", -16.00002f); + TEST_ASSERT_EQUAL_PRINT_FLOATING("-16.00004", -16.00004f); + TEST_ASSERT_EQUAL_PRINT_FLOATING("-16.00006", -16.00006f); + TEST_ASSERT_EQUAL_PRINT_FLOATING("-9999999", -9999999.0f); /*Last full print integer*/ + + /* Fails, prints "4.294968e+09" due to FP math imprecision + * TEST_ASSERT_EQUAL_PRINT_FLOATING("4.294967e+09", 4294967296.0f); */ + TEST_ASSERT_EQUAL_PRINT_FLOATING("5e+09", 5000000000.0f); + TEST_ASSERT_EQUAL_PRINT_FLOATING("8e+09", 8.0e+09f); + TEST_ASSERT_EQUAL_PRINT_FLOATING("8.309999e+09", 8309999104.0f); + TEST_ASSERT_EQUAL_PRINT_FLOATING("1e+10", 1.0e+10f); + TEST_ASSERT_EQUAL_PRINT_FLOATING("1e+10", 10000000000.0f); + /* Some compilers have trouble with inexact float constants, a float cast works generally */ + TEST_ASSERT_EQUAL_PRINT_FLOATING("1.000055e+10", (float)1.000055e+10f); + TEST_ASSERT_EQUAL_PRINT_FLOATING("1.1e+38", (float)1.10000005e+38f); + TEST_ASSERT_EQUAL_PRINT_FLOATING("1.635299e+10", 1.63529943e+10f); + /* Fails, prints "3.402824e+38" due to FP math imprecision + * TEST_ASSERT_EQUAL_PRINT_FLOATING("3.402823e+38", 3.40282346638e38f); */ + + TEST_ASSERT_EQUAL_PRINT_FLOATING("-1e+10", -1.0e+10f); + /* Fails, prints "-3.402824e+38" due to FP math imprecision + * TEST_ASSERT_EQUAL_PRINT_FLOATING("-3.402823e+38", -3.40282346638e38f); */ +#endif +} + +void testFloatPrintingRoundTiesToEven(void) +{ +#if defined(UNITY_EXCLUDE_FLOAT_PRINT) || defined(UNITY_INCLUDE_DOUBLE) || !defined(USING_OUTPUT_SPY) + TEST_IGNORE(); +#else + #ifdef UNITY_ROUND_TIES_AWAY_FROM_ZERO + TEST_ASSERT_EQUAL_PRINT_FLOATING("0.0004882813", 0.00048828125f); + TEST_ASSERT_EQUAL_PRINT_FLOATING("488281.3", 488281.25f); + TEST_ASSERT_EQUAL_PRINT_FLOATING("5.000001e-07", 0.00000050000005f); + TEST_ASSERT_EQUAL_PRINT_FLOATING("-5.000001e-07", -0.00000050000005f); + #else /* Default to Round ties to even */ + TEST_ASSERT_EQUAL_PRINT_FLOATING("0.0004882812", 0.00048828125f); + TEST_ASSERT_EQUAL_PRINT_FLOATING("488281.2", 488281.25f); + TEST_ASSERT_EQUAL_PRINT_FLOATING("5e-07", 0.00000050000005f); + TEST_ASSERT_EQUAL_PRINT_FLOATING("-5e-07", -0.00000050000005f); + #endif +#endif +} + +void testFloatPrintingInfinityAndNaN(void) +{ +#if defined(UNITY_EXCLUDE_FLOAT_PRINT) || !defined(USING_OUTPUT_SPY) + TEST_IGNORE(); +#else + TEST_ASSERT_EQUAL_PRINT_FLOATING("inf", 1.0f / f_zero); + TEST_ASSERT_EQUAL_PRINT_FLOATING("-inf", -1.0f / f_zero); + + TEST_ASSERT_EQUAL_PRINT_FLOATING("nan", 0.0f / f_zero); +#endif +} + +#if defined(UNITY_TEST_ALL_FLOATS_PRINT_OK) && defined(USING_OUTPUT_SPY) +#ifdef UNITY_INCLUDE_DOUBLE +static void printFloatValue(float f) +{ + char expected[18]; + + startPutcharSpy(); + UnityPrintFloat(f); + + sprintf(expected, "%.9g", f); + /* We print all NaN's as "nan", not "-nan" */ + if (strcmp(expected, "-nan") == 0) strcpy(expected, "nan"); + + if (strcmp(expected, getBufferPutcharSpy())) + { + /* Fail with diagnostic printing */ + TEST_ASSERT_EQUAL_PRINT_FLOATING(expected, f); + } +} +#else +static void printFloatValue(float f) +{ + char expected[18]; + char expected_lower[18]; + char expected_lower2[18]; + char expected_lower3[18]; + char expected_higher[18]; + char expected_higher2[18]; + char expected_higher3[18]; + + startPutcharSpy(); + UnityPrintFloat(f); + + sprintf(expected, "%.7g", f); + /* We print all NaN's as "nan", not "-nan" */ + if (strcmp(expected, "-nan") == 0) strcpy(expected, "nan"); + + strcpy(expected_lower, expected); + strcpy(expected_lower2, expected); + strcpy(expected_lower3, expected); + strcpy(expected_higher, expected); + strcpy(expected_higher2, expected); + strcpy(expected_higher3, expected); + + /* Allow for rounding differences in the last digit */ + double lower = (double)f * 0.99999995; + double higher = (double)f * 1.00000005; + + if(isfinite(lower)) sprintf(expected_lower, "%.7g", lower); + if(isfinite(higher)) sprintf(expected_higher, "%.7g", higher); + + /* Outside [1,10000000] allow for relative error of +/-2.5e-7 */ + if (f < 1.0 || f > 10000000) + { + double lower2 = (double)f * 0.99999985; + double lower3 = (double)f * 0.99999975; + double higher2 = (double)f * 1.00000015; + double higher3 = (double)f * 1.00000025; + + if (isfinite(lower2)) sprintf(expected_lower2, "%.7g", lower2); + if (isfinite(lower3)) sprintf(expected_lower3, "%.7g", lower3); + if (isfinite(higher2)) sprintf(expected_higher2, "%.7g", higher2); + if (isfinite(higher3)) sprintf(expected_higher3, "%.7g", higher3); + } + + if (strcmp(expected, getBufferPutcharSpy()) != 0 && + strcmp(expected_lower, getBufferPutcharSpy()) != 0 && + strcmp(expected_lower2, getBufferPutcharSpy()) != 0 && + strcmp(expected_lower3, getBufferPutcharSpy()) != 0 && + strcmp(expected_higher, getBufferPutcharSpy()) != 0 && + strcmp(expected_higher2, getBufferPutcharSpy()) != 0 && + strcmp(expected_higher3, getBufferPutcharSpy()) != 0) + { + /* Fail with diagnostic printing */ + TEST_ASSERT_EQUAL_PRINT_FLOATING(expected, f); + } +} +#endif +#endif + +void testFloatPrintingRandomSamples(void) +{ +#if !defined(UNITY_TEST_ALL_FLOATS_PRINT_OK) || !defined(USING_OUTPUT_SPY) + TEST_IGNORE(); +#else + union { float f_value; uint32_t int_value; } u; + + /* These values are not covered by the MINSTD generator */ + u.int_value = 0x00000000; printFloatValue(u.f_value); + u.int_value = 0x80000000; printFloatValue(u.f_value); + u.int_value = 0x7fffffff; printFloatValue(u.f_value); + u.int_value = 0xffffffff; printFloatValue(u.f_value); + + uint32_t a = 1; + for(int num_tested = 0; num_tested < 1000000; num_tested++) + { + /* MINSTD pseudo-random number generator */ + a = (uint32_t)(((uint64_t)a * 48271u) % 2147483647u); + + /* MINSTD does not set the highest bit; test both possibilities */ + u.int_value = a; printFloatValue(u.f_value); + u.int_value = a | 0x80000000; printFloatValue(u.f_value); + } +#endif +} diff --git a/test/tests/test_unity_integers.c b/test/tests/test_unity_integers.c new file mode 100644 index 00000000..3359bc77 --- /dev/null +++ b/test/tests/test_unity_integers.c @@ -0,0 +1,2854 @@ +/* ========================================== + Unity Project - A Test Framework for C + Copyright (c) 2007 Mike Karlesky, Mark VanderVoord, Greg Williams + [Released under MIT License. Please refer to license.txt for details] +========================================== */ + +#include "unity.h" +#define TEST_INSTANCES +#include "self_assessment_utils.h" + +void setUp(void) +{ + SetToOneToFailInTearDown = 0; + SetToOneMeanWeAlreadyCheckedThisGuy = 0; +} + +void tearDown(void) +{ + endPutcharSpy(); /* Stop suppressing test output */ + if (SetToOneToFailInTearDown == 1) + { + /* These will be skipped internally if already failed/ignored */ + TEST_FAIL_MESSAGE("<= Failed in tearDown"); + TEST_IGNORE_MESSAGE("<= Ignored in tearDown"); + } + if ((SetToOneMeanWeAlreadyCheckedThisGuy == 0) && (Unity.CurrentTestFailed > 0)) + { + UnityPrint(": [[[[ Test Should Have Passed But Did Not ]]]]"); + UNITY_OUTPUT_CHAR('\n'); + } +} + +void testNotEqualInts(void) +{ + EXPECT_ABORT_BEGIN + TEST_ASSERT_EQUAL_INT(3982, 3983); + VERIFY_FAILS_END +} + +void testNotEqualInt8s(void) +{ + EXPECT_ABORT_BEGIN + TEST_ASSERT_EQUAL_INT8(-127, -126); + VERIFY_FAILS_END +} + +void testNotEqualChars(void) +{ + EXPECT_ABORT_BEGIN + TEST_ASSERT_EQUAL_CHAR('A', 'a'); + VERIFY_FAILS_END +} + +void testNotEqualInt16s(void) +{ + EXPECT_ABORT_BEGIN + TEST_ASSERT_EQUAL_INT16(-16383, -16382); + VERIFY_FAILS_END +} + +void testNotEqualInt32s(void) +{ + EXPECT_ABORT_BEGIN + /*use largest 32 bit negative to test printability*/ + /*note: (-2147483647 - 1) is used instead of -2147483648 because of C90 casting rules */ + TEST_ASSERT_EQUAL_INT32(-2147483647, (-2147483647 - 1)); + VERIFY_FAILS_END +} + +void testNotEqualBits(void) +{ + EXPECT_ABORT_BEGIN + TEST_ASSERT_BITS(0xFF00, 0x5555, 0x5A55); + VERIFY_FAILS_END +} + +void testNotEqualUInts(void) +{ + UNITY_UINT16 v0, v1; + + v0 = 9000; + v1 = 9001; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_EQUAL_UINT(v0, v1); + VERIFY_FAILS_END +} + +void testNotEqualUInt8s(void) +{ + UNITY_UINT8 v0, v1; + + v0 = 254; + v1 = 255; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_EQUAL_UINT8(v0, v1); + VERIFY_FAILS_END +} + +void testNotEqualUInt16s(void) +{ + UNITY_UINT16 v0, v1; + + v0 = 65535u; + v1 = 65534u; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_EQUAL_UINT16(v0, v1); + VERIFY_FAILS_END +} + +void testNotEqualUInt32s(void) +{ + UNITY_UINT32 v0, v1; + + v0 = 4294967295u; + v1 = 4294967294u; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_EQUAL_UINT32(v0, v1); + VERIFY_FAILS_END +} + +void testNotEqualHex8s(void) +{ + UNITY_UINT8 v0, v1; + + v0 = 0x23; + v1 = 0x22; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_EQUAL_HEX8(v0, v1); + VERIFY_FAILS_END +} + +void testNotEqualHex8sIfSigned(void) +{ + UNITY_INT8 v0, v1; + + v0 = -2; + v1 = 2; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_EQUAL_HEX8(v0, v1); + VERIFY_FAILS_END +} + +void testNotEqualHex16s(void) +{ + UNITY_UINT16 v0, v1; + + v0 = 0x1234; + v1 = 0x1235; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_EQUAL_HEX16(v0, v1); + VERIFY_FAILS_END +} + +void testNotEqualHex16sIfSigned(void) +{ + UNITY_INT16 v0, v1; + + v0 = -1024; + v1 = -1028; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_EQUAL_HEX16(v0, v1); + VERIFY_FAILS_END +} + +void testNotEqualHex32s(void) +{ + UNITY_UINT32 v0, v1; + + v0 = 900000; + v1 = 900001; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_EQUAL_HEX32(v0, v1); + VERIFY_FAILS_END +} + +void testNotEqualHex32sIfSigned(void) +{ + UNITY_INT32 v0, v1; + + v0 = -900000; + v1 = 900001; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_EQUAL_HEX32(v0, v1); + VERIFY_FAILS_END +} + +void testEqualInts(void) +{ + int v0, v1; + int *p0, *p1; + + v0 = 19467; + v1 = 19467; + p0 = &v0; + p1 = &v1; + + TEST_ASSERT_EQUAL_INT(1837, 1837); + TEST_ASSERT_EQUAL_INT(-27365, -27365); + TEST_ASSERT_EQUAL_INT(v0, v1); + TEST_ASSERT_EQUAL_INT(19467, v1); + TEST_ASSERT_EQUAL_INT(v0, 19467); + TEST_ASSERT_EQUAL_INT(*p0, v1); + TEST_ASSERT_EQUAL_INT(*p0, *p1); + TEST_ASSERT_EQUAL_INT(*p0, 19467); +} + +void testEqualInt8s(void) +{ + UNITY_INT8 v0, v1; + UNITY_INT8 *p0, *p1; + + v0 = 0x22; + v1 = 0x22; + p0 = &v0; + p1 = &v1; + + TEST_ASSERT_EQUAL_INT8(0x22, 0x22); + TEST_ASSERT_EQUAL_INT8(v0, v1); + TEST_ASSERT_EQUAL_INT8(0x22, v1); + TEST_ASSERT_EQUAL_INT8(v0, 0x22); + TEST_ASSERT_EQUAL_INT8(*p0, v1); + TEST_ASSERT_EQUAL_INT8(*p0, *p1); + TEST_ASSERT_EQUAL_INT8(*p0, 0x22); +} + +void testEqualInt8sWhenThereAreDifferencesOutside8Bits(void) +{ + TEST_ASSERT_EQUAL_INT8(0x321,0x421); + TEST_ASSERT_EQUAL_INT8(0xFF21,0x0021); +} + +void testEqualChars(void) +{ + char v0, v1; + char *p0, *p1; + + v0 = 'A'; + v1 = 'A'; + p0 = &v0; + p1 = &v1; + + TEST_ASSERT_EQUAL_CHAR('A', 'A'); + TEST_ASSERT_EQUAL_CHAR(v0, v1); + TEST_ASSERT_EQUAL_CHAR('A', v1); + TEST_ASSERT_EQUAL_CHAR(v0, 'A'); + TEST_ASSERT_EQUAL_CHAR(*p0, v1); + TEST_ASSERT_EQUAL_CHAR(*p0, *p1); + TEST_ASSERT_EQUAL_CHAR(*p0, 'A'); +} + +void testEqualCharsWhenThereAreDifferencesOutside8Bits(void) +{ + TEST_ASSERT_EQUAL_CHAR(0x321,0x421); + TEST_ASSERT_EQUAL_CHAR(0xFF21,0x0021); +} + + +void testEqualInt16s(void) +{ + UNITY_INT16 v0, v1; + UNITY_INT16 *p0, *p1; + + v0 = 0x7876; + v1 = 0x7876; + p0 = &v0; + p1 = &v1; + + TEST_ASSERT_EQUAL_INT16(0x7876, 0x7876); + TEST_ASSERT_EQUAL_INT16(v0, v1); + TEST_ASSERT_EQUAL_INT16(0x7876, v1); + TEST_ASSERT_EQUAL_INT16(v0, 0x7876); + TEST_ASSERT_EQUAL_INT16(*p0, v1); + TEST_ASSERT_EQUAL_INT16(*p0, *p1); + TEST_ASSERT_EQUAL_INT16(*p0, 0x7876); +} + +void testEqualInt16sNegatives(void) +{ + UNITY_INT16 v0, v1; + UNITY_INT16 *p0, *p1; + + v0 = -7876; + v1 = -7876; + p0 = &v0; + p1 = &v1; + + TEST_ASSERT_EQUAL_INT16(-7876, -7876); + TEST_ASSERT_EQUAL_INT16(v0, v1); + TEST_ASSERT_EQUAL_INT16(-7876, v1); + TEST_ASSERT_EQUAL_INT16(v0, -7876); + TEST_ASSERT_EQUAL_INT16(*p0, v1); + TEST_ASSERT_EQUAL_INT16(*p0, *p1); + TEST_ASSERT_EQUAL_INT16(*p0, -7876); +} + +void testEqualInt16sWhenThereAreDifferencesOutside16Bits(void) +{ + TEST_ASSERT_EQUAL_INT16(0x54321,0x64321); + TEST_ASSERT_EQUAL_INT16(0xFFFF4321,0x00004321); +} + +void testEqualInt32s(void) +{ + UNITY_INT32 v0, v1; + UNITY_INT32 *p0, *p1; + + v0 = 0x78760000; + v1 = 0x78760000; + p0 = &v0; + p1 = &v1; + + TEST_ASSERT_EQUAL_INT32(0x78760000, 0x78760000); + TEST_ASSERT_EQUAL_INT32(v0, v1); + TEST_ASSERT_EQUAL_INT32(0x78760000, v1); + TEST_ASSERT_EQUAL_INT32(v0, 0x78760000); + TEST_ASSERT_EQUAL_INT32(*p0, v1); + TEST_ASSERT_EQUAL_INT32(*p0, *p1); + TEST_ASSERT_EQUAL_INT32(*p0, 0x78760000); +} + +void testEqualInt32sNegatives(void) +{ + UNITY_INT32 v0, v1; + UNITY_INT32 *p0, *p1; + + v0 = -123456789; + v1 = -123456789; + p0 = &v0; + p1 = &v1; + + TEST_ASSERT_EQUAL_INT32(-123456789, -123456789); + TEST_ASSERT_EQUAL_INT32(v0, v1); + TEST_ASSERT_EQUAL_INT32(-123456789, v1); + TEST_ASSERT_EQUAL_INT32(v0, -123456789); + TEST_ASSERT_EQUAL_INT32(*p0, v1); + TEST_ASSERT_EQUAL_INT32(*p0, *p1); + TEST_ASSERT_EQUAL_INT32(*p0, -123456789); +} + + +void testEqualUints(void) +{ + unsigned int v0, v1; + unsigned int *p0, *p1; + + v0 = 19467; + v1 = 19467; + p0 = &v0; + p1 = &v1; + + TEST_ASSERT_EQUAL_UINT(1837, 1837); + TEST_ASSERT_EQUAL_UINT(v0, v1); + TEST_ASSERT_EQUAL_UINT(19467, v1); + TEST_ASSERT_EQUAL_UINT(v0, 19467); + TEST_ASSERT_EQUAL_UINT(*p0, v1); + TEST_ASSERT_EQUAL_UINT(*p0, *p1); + TEST_ASSERT_EQUAL_UINT(*p0, 19467); + TEST_ASSERT_EQUAL_UINT(60872u, 60872u); +} + + +void testEqualUint8s(void) +{ + UNITY_UINT8 v0, v1; + UNITY_UINT8 *p0, *p1; + + v0 = 0x22; + v1 = 0x22; + p0 = &v0; + p1 = &v1; + + TEST_ASSERT_EQUAL_UINT8(0x22, 0x22); + TEST_ASSERT_EQUAL_UINT8(v0, v1); + TEST_ASSERT_EQUAL_UINT8(0x22, v1); + TEST_ASSERT_EQUAL_UINT8(v0, 0x22); + TEST_ASSERT_EQUAL_UINT8(*p0, v1); + TEST_ASSERT_EQUAL_UINT8(*p0, *p1); + TEST_ASSERT_EQUAL_UINT8(*p0, 0x22); +} + +void testEqualUint8sWhenThereAreDifferencesOutside8Bits(void) +{ + TEST_ASSERT_EQUAL_UINT8(0x321,0x421); + TEST_ASSERT_EQUAL_UINT8(0xFF21,0x0021); +} + +void testEqualUint16s(void) +{ + UNITY_UINT16 v0, v1; + UNITY_UINT16 *p0, *p1; + + v0 = 0x9876; + v1 = 0x9876; + p0 = &v0; + p1 = &v1; + + TEST_ASSERT_EQUAL_UINT16(0x9876, 0x9876); + TEST_ASSERT_EQUAL_UINT16(v0, v1); + TEST_ASSERT_EQUAL_UINT16(0x9876, v1); + TEST_ASSERT_EQUAL_UINT16(v0, 0x9876); + TEST_ASSERT_EQUAL_UINT16(*p0, v1); + TEST_ASSERT_EQUAL_UINT16(*p0, *p1); + TEST_ASSERT_EQUAL_UINT16(*p0, 0x9876); +} + +void testEqualUint16sWhenThereAreDifferencesOutside16Bits(void) +{ + TEST_ASSERT_EQUAL_UINT16(0x54321,0x64321); + TEST_ASSERT_EQUAL_UINT16(0xFFFF4321,0x00004321); +} + +void testEqualUint32s(void) +{ + UNITY_UINT32 v0, v1; + UNITY_UINT32 *p0, *p1; + + v0 = 0x98760000; + v1 = 0x98760000; + p0 = &v0; + p1 = &v1; + + TEST_ASSERT_EQUAL_UINT32(0x98760000, 0x98760000); + TEST_ASSERT_EQUAL_UINT32(v0, v1); + TEST_ASSERT_EQUAL_UINT32(0x98760000, v1); + TEST_ASSERT_EQUAL_UINT32(v0, 0x98760000); + TEST_ASSERT_EQUAL_UINT32(*p0, v1); + TEST_ASSERT_EQUAL_UINT32(*p0, *p1); + TEST_ASSERT_EQUAL_UINT32(*p0, 0x98760000); +} + +void testNotEqual(void) +{ + TEST_ASSERT_NOT_EQUAL(0, 1); + TEST_ASSERT_NOT_EQUAL(1, 0); + TEST_ASSERT_NOT_EQUAL(100, 101); + TEST_ASSERT_NOT_EQUAL(0, -1); + TEST_ASSERT_NOT_EQUAL(65535, -65535); + TEST_ASSERT_NOT_EQUAL(75, 900); + TEST_ASSERT_NOT_EQUAL(-100, -101); +} + +void testEqualHex8s(void) +{ + UNITY_UINT8 v0, v1; + UNITY_UINT8 *p0, *p1; + + v0 = 0x22; + v1 = 0x22; + p0 = &v0; + p1 = &v1; + + TEST_ASSERT_EQUAL_HEX8(0x22, 0x22); + TEST_ASSERT_EQUAL_HEX8(v0, v1); + TEST_ASSERT_EQUAL_HEX8(0x22, v1); + TEST_ASSERT_EQUAL_HEX8(v0, 0x22); + TEST_ASSERT_EQUAL_HEX8(*p0, v1); + TEST_ASSERT_EQUAL_HEX8(*p0, *p1); + TEST_ASSERT_EQUAL_HEX8(*p0, 0x22); +} + +void testEqualHex8sWhenThereAreDifferencesOutside8Bits(void) +{ + TEST_ASSERT_EQUAL_HEX8(0x321,0x421); + TEST_ASSERT_EQUAL_HEX8(0xFF21,0x0021); +} + +void testEqualHex8sNegatives(void) +{ + UNITY_UINT8 v0, v1; + UNITY_UINT8 *p0, *p1; + + v0 = 0xDD; + v1 = 0xDD; + p0 = &v0; + p1 = &v1; + + TEST_ASSERT_EQUAL_HEX8(0xDD, 0xDD); + TEST_ASSERT_EQUAL_HEX8(v0, v1); + TEST_ASSERT_EQUAL_HEX8(0xDD, v1); + TEST_ASSERT_EQUAL_HEX8(v0, 0xDD); + TEST_ASSERT_EQUAL_HEX8(*p0, v1); + TEST_ASSERT_EQUAL_HEX8(*p0, *p1); + TEST_ASSERT_EQUAL_HEX8(*p0, 0xDD); +} + +void testEqualHex16s(void) +{ + UNITY_UINT16 v0, v1; + UNITY_UINT16 *p0, *p1; + + v0 = 0x9876; + v1 = 0x9876; + p0 = &v0; + p1 = &v1; + + TEST_ASSERT_EQUAL_HEX16(0x9876, 0x9876); + TEST_ASSERT_EQUAL_HEX16(v0, v1); + TEST_ASSERT_EQUAL_HEX16(0x9876, v1); + TEST_ASSERT_EQUAL_HEX16(v0, 0x9876); + TEST_ASSERT_EQUAL_HEX16(*p0, v1); + TEST_ASSERT_EQUAL_HEX16(*p0, *p1); + TEST_ASSERT_EQUAL_HEX16(*p0, 0x9876); +} + +void testEqualHex16sWhenThereAreDifferencesOutside16Bits(void) +{ + TEST_ASSERT_EQUAL_HEX16(0x54321,0x64321); + TEST_ASSERT_EQUAL_HEX16(0xFFFF4321,0x00004321); +} + +void testEqualHex32s(void) +{ + UNITY_UINT32 v0, v1; + UNITY_UINT32 *p0, *p1; + + v0 = 0x98765432ul; + v1 = 0x98765432ul; + p0 = &v0; + p1 = &v1; + + TEST_ASSERT_EQUAL_HEX32(0x98765432ul, 0x98765432ul); + TEST_ASSERT_EQUAL_HEX32(v0, v1); + TEST_ASSERT_EQUAL_HEX32(0x98765432ul, v1); + TEST_ASSERT_EQUAL_HEX32(v0, 0x98765432ul); + TEST_ASSERT_EQUAL_HEX32(*p0, v1); + TEST_ASSERT_EQUAL_HEX32(*p0, *p1); + TEST_ASSERT_EQUAL_HEX32(*p0, 0x98765432ul); +} + +void testEqualBits(void) +{ + UNITY_UINT32 v0 = 0xFF55AA00; + UNITY_UINT32 v1 = 0x55550000; + + TEST_ASSERT_BITS(v1, v0, 0x55550000); + TEST_ASSERT_BITS(v1, v0, 0xFF55CC00); + TEST_ASSERT_BITS(0xFFFFFFFF, v0, 0xFF55AA00); + TEST_ASSERT_BITS(0xFFFFFFFF, v0, v0); + TEST_ASSERT_BITS(0xF0F0F0F0, v0, 0xFC5DAE0F); + TEST_ASSERT_BITS_HIGH(v1, v0); + TEST_ASSERT_BITS_LOW(0x000055FF, v0); + TEST_ASSERT_BIT_HIGH(30, v0); + TEST_ASSERT_BIT_LOW(5, v0); +} + +void testNotEqualBitHigh(void) +{ + UNITY_UINT32 v0 = 0x7F55AA00; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_BIT_HIGH(31, v0); + VERIFY_FAILS_END +} + +void testNotEqualBitLow(void) +{ + UNITY_UINT32 v0 = 0xFF55AA00; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_BIT_LOW(30, v0); + VERIFY_FAILS_END +} + +void testNotEqualBitsHigh(void) +{ + UNITY_UINT32 v0 = 0xFF55AA00; + UNITY_UINT32 v1 = 0x55550000; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_BITS_HIGH(v0, v1); + VERIFY_FAILS_END + +} + +void testNotEqualBitsLow(void) +{ + UNITY_UINT32 v0 = 0xFF55AA00; + UNITY_UINT32 v1 = 0x55550000; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_BITS_LOW(v0, v1); + VERIFY_FAILS_END +} + + +void testEqualShorts(void) +{ + short v0, v1; + short *p0, *p1; + + v0 = 19467; + v1 = 19467; + p0 = &v0; + p1 = &v1; + + TEST_ASSERT_EQUAL_INT(1837, 1837); + TEST_ASSERT_EQUAL_INT(-2987, -2987); + TEST_ASSERT_EQUAL_INT(v0, v1); + TEST_ASSERT_EQUAL_INT(19467, v1); + TEST_ASSERT_EQUAL_INT(v0, 19467); + TEST_ASSERT_EQUAL_INT(*p0, v1); + TEST_ASSERT_EQUAL_INT(*p0, *p1); + TEST_ASSERT_EQUAL_INT(*p0, 19467); +} + +void testEqualUShorts(void) +{ + unsigned short v0, v1; + unsigned short *p0, *p1; + + v0 = 19467; + v1 = 19467; + p0 = &v0; + p1 = &v1; + + TEST_ASSERT_EQUAL_UINT(1837, 1837); + TEST_ASSERT_EQUAL_UINT(2987, 2987); + TEST_ASSERT_EQUAL_UINT(v0, v1); + TEST_ASSERT_EQUAL_UINT(19467, v1); + TEST_ASSERT_EQUAL_UINT(v0, 19467); + TEST_ASSERT_EQUAL_UINT(*p0, v1); + TEST_ASSERT_EQUAL_UINT(*p0, *p1); + TEST_ASSERT_EQUAL_UINT(*p0, 19467); +} + +void testEqualUInts(void) +{ + unsigned char v0, v1; + unsigned char *p0, *p1; + + v0 = 109; + v1 = 109; + p0 = &v0; + p1 = &v1; + + TEST_ASSERT_EQUAL_UINT(42, 42); + TEST_ASSERT_EQUAL_UINT(-116, -116); + TEST_ASSERT_EQUAL_UINT(v0, v1); + TEST_ASSERT_EQUAL_UINT(109, v1); + TEST_ASSERT_EQUAL_UINT(v0, 109); + TEST_ASSERT_EQUAL_UINT(*p0, v1); + TEST_ASSERT_EQUAL_UINT(*p0, *p1); + TEST_ASSERT_EQUAL_UINT(*p0, 109); +} + +void testEqualUChars(void) +{ + unsigned char v0, v1; + unsigned char *p0, *p1; + + v0 = 251; + v1 = 251; + p0 = &v0; + p1 = &v1; + + TEST_ASSERT_EQUAL_INT(42, 42); + TEST_ASSERT_EQUAL_INT(v0, v1); + TEST_ASSERT_EQUAL_INT(251, v1); + TEST_ASSERT_EQUAL_INT(v0, 251); + TEST_ASSERT_EQUAL_INT(*p0, v1); + TEST_ASSERT_EQUAL_INT(*p0, *p1); + TEST_ASSERT_EQUAL_INT(*p0, 251); +} + +void testEqualPointers(void) +{ + int v0, v1; + int *p0, *p1, *p2; + + v0 = 19467; + v1 = 18271; + p0 = &v0; + p1 = &v1; + p2 = &v1; + + TEST_ASSERT_EQUAL_PTR(p0, &v0); + TEST_ASSERT_EQUAL_PTR(&v1, p1); + TEST_ASSERT_EQUAL_PTR(p2, p1); + TEST_ASSERT_EQUAL_PTR(&v0, &v0); +} + +void testNotEqualPointers(void) +{ + EXPECT_ABORT_BEGIN + TEST_ASSERT_EQUAL_PTR(0x12345678, 0x12345677); + VERIFY_FAILS_END +} + +void testIntsWithinDelta(void) +{ + TEST_ASSERT_INT_WITHIN(1, 5000, 5001); + TEST_ASSERT_INT_WITHIN(5, 5000, 4996); + TEST_ASSERT_INT_WITHIN(5, 5000, 5005); + TEST_ASSERT_INT_WITHIN(500, 50, -440); + + TEST_ASSERT_INT_WITHIN(2, -1, -1); + TEST_ASSERT_INT_WITHIN(5, 1, -1); + TEST_ASSERT_INT_WITHIN(5, -1, 1); +} + +void testIntsWithinDeltaAndCustomMessage(void) +{ + TEST_ASSERT_INT_WITHIN_MESSAGE(1, 5000, 5001, "Custom Message."); + TEST_ASSERT_INT_WITHIN_MESSAGE(5, 5000, 4996, "Custom Message."); + TEST_ASSERT_INT_WITHIN_MESSAGE(5, 5000, 5005, "Custom Message."); + TEST_ASSERT_INT_WITHIN_MESSAGE(500, 50, -440, "Custom Message."); + + TEST_ASSERT_INT_WITHIN_MESSAGE(2, -1, -1, "Custom Message."); + TEST_ASSERT_INT_WITHIN_MESSAGE(5, 1, -1, "Custom Message."); + TEST_ASSERT_INT_WITHIN_MESSAGE(5, -1, 1, "Custom Message."); +} + +void testIntsNotWithinDelta(void) +{ + EXPECT_ABORT_BEGIN + TEST_ASSERT_INT_WITHIN(5, 5000, 5006); + VERIFY_FAILS_END +} + +void testIntsNotWithinDeltaAndCustomMessage(void) +{ + EXPECT_ABORT_BEGIN + TEST_ASSERT_INT_WITHIN_MESSAGE(5, 5000, 5006, "Custom Message."); + VERIFY_FAILS_END +} + +void testUIntsWithinDelta(void) +{ + TEST_ASSERT_UINT_WITHIN(1, 5000, 5001); + TEST_ASSERT_UINT_WITHIN(5, 5000, 4996); + TEST_ASSERT_UINT_WITHIN(5, 5000, 5005); +} + +void testUIntsWithinDeltaAndCustomMessage(void) +{ + TEST_ASSERT_UINT_WITHIN_MESSAGE(1, 5000, 5001, "Custom Message."); + TEST_ASSERT_UINT_WITHIN_MESSAGE(5, 5000, 4996, "Custom Message."); + TEST_ASSERT_UINT_WITHIN_MESSAGE(5, 5000, 5005, "Custom Message."); +} + +void testUIntsNotWithinDelta(void) +{ + EXPECT_ABORT_BEGIN + TEST_ASSERT_UINT_WITHIN(1, 2147483647u, 2147483649u); + VERIFY_FAILS_END +} + +void testUIntsNotWithinDeltaAndCustomMessage(void) +{ + EXPECT_ABORT_BEGIN + TEST_ASSERT_UINT_WITHIN_MESSAGE(1, 2147483647u, 2147483649u, "Custom Message."); + VERIFY_FAILS_END +} + +void testUIntsNotWithinDeltaEvenThoughASignedIntWouldPassSmallFirst(void) +{ + EXPECT_ABORT_BEGIN + TEST_ASSERT_UINT_WITHIN(5, 1, -1); + VERIFY_FAILS_END +} + +void testUIntsNotWithinDeltaEvenThoughASignedIntWouldPassSmallFirstAndCustomMessage(void) +{ + EXPECT_ABORT_BEGIN + TEST_ASSERT_UINT_WITHIN_MESSAGE(5, 1, -1, "Custom Message."); + VERIFY_FAILS_END +} + +void testUIntsNotWithinDeltaEvenThoughASignedIntWouldPassBigFirst(void) +{ + EXPECT_ABORT_BEGIN + TEST_ASSERT_UINT_WITHIN(5, -1, 1); + VERIFY_FAILS_END +} + +void testUIntsNotWithinDeltaEvenThoughASignedIntWouldPassBigFirstAndCustomMessage(void) +{ + EXPECT_ABORT_BEGIN + TEST_ASSERT_UINT_WITHIN_MESSAGE(5, -1, 1, "Custom Message."); + VERIFY_FAILS_END +} + +void testHEX32sWithinDelta(void) +{ + TEST_ASSERT_HEX32_WITHIN(1, 5000, 5001); + TEST_ASSERT_HEX32_WITHIN(5, 5000, 4996); + TEST_ASSERT_HEX32_WITHIN(5, 5000, 5005); +} + +void testHEX32sWithinDeltaAndCustomMessage(void) +{ + TEST_ASSERT_HEX32_WITHIN_MESSAGE(1, 5000, 5001, "Custom Message."); + TEST_ASSERT_HEX32_WITHIN_MESSAGE(5, 5000, 4996, "Custom Message."); + TEST_ASSERT_HEX32_WITHIN_MESSAGE(5, 5000, 5005, "Custom Message."); +} + +void testHEX32sNotWithinDelta(void) +{ + EXPECT_ABORT_BEGIN + TEST_ASSERT_HEX32_WITHIN(1, 2147483647u, 2147483649u); + VERIFY_FAILS_END +} + +void testHEX32sNotWithinDeltaAndCustomMessage(void) +{ + EXPECT_ABORT_BEGIN + TEST_ASSERT_HEX32_WITHIN_MESSAGE(1, 2147483647u, 2147483649u, "Custom Message."); + VERIFY_FAILS_END +} + +void testHEX32sNotWithinDeltaEvenThoughASignedIntWouldPass(void) +{ + EXPECT_ABORT_BEGIN + TEST_ASSERT_HEX32_WITHIN(5, 1, -1); + VERIFY_FAILS_END +} + +void testHEX32sNotWithinDeltaEvenThoughASignedIntWouldPassAndCustomMessage(void) +{ + EXPECT_ABORT_BEGIN + TEST_ASSERT_HEX32_WITHIN_MESSAGE(5, 1, -1, "Custom Message."); + VERIFY_FAILS_END +} + +void testHEX16sWithinDelta(void) +{ + TEST_ASSERT_HEX16_WITHIN(1, 5000, 5001); + TEST_ASSERT_HEX16_WITHIN(5, 5000, 4996); + TEST_ASSERT_HEX16_WITHIN(5, 5000, 5005); +} + +void testHEX16sWithinDeltaAndCustomMessage(void) +{ + TEST_ASSERT_HEX16_WITHIN_MESSAGE(1, 5000, 5001, "Custom Message."); + TEST_ASSERT_HEX16_WITHIN_MESSAGE(5, 5000, 4996, "Custom Message."); + TEST_ASSERT_HEX16_WITHIN_MESSAGE(5, 5000, 5005, "Custom Message."); +} + +void testHEX16sWithinDeltaWhenThereAreDifferenceOutsideOf16Bits(void) +{ + TEST_ASSERT_HEX16_WITHIN(5, 0x54321, 0x44321); +} + +void testHEX16sWithinDeltaWhenThereAreDifferenceOutsideOf16BitsAndCustomMessage(void) +{ + TEST_ASSERT_HEX16_WITHIN_MESSAGE(5, 0x54321, 0x44321, "Custom Message."); +} + +void testHEX16sNotWithinDelta(void) +{ + EXPECT_ABORT_BEGIN + TEST_ASSERT_HEX16_WITHIN(2, 65535, 0); + VERIFY_FAILS_END +} + +void testHEX16sNotWithinDeltaAndCustomMessage(void) +{ + EXPECT_ABORT_BEGIN + TEST_ASSERT_HEX16_WITHIN_MESSAGE(2, 65535, 0, "Custom Message."); + VERIFY_FAILS_END +} + +void testHEX8sWithinDelta(void) +{ + TEST_ASSERT_HEX8_WITHIN(1, 254, 255); + TEST_ASSERT_HEX8_WITHIN(5, 251, 255); + TEST_ASSERT_HEX8_WITHIN(5, 1, 4); +} + +void testHEX8sWithinDeltaAndCustomMessage(void) +{ + TEST_ASSERT_HEX8_WITHIN_MESSAGE(1, 254, 255, "Custom Message."); + TEST_ASSERT_HEX8_WITHIN_MESSAGE(5, 251, 255, "Custom Message."); + TEST_ASSERT_HEX8_WITHIN_MESSAGE(5, 1, 4, "Custom Message."); +} + +void testHEX8sWithinDeltaWhenThereAreDifferenceOutsideOf8Bits(void) +{ + TEST_ASSERT_HEX8_WITHIN(5, 0x123, 0xF23); +} + +void testHEX8sWithinDeltaWhenThereAreDifferenceOutsideOf8BitsAndCustomMessage(void) +{ + TEST_ASSERT_HEX8_WITHIN_MESSAGE(5, 0x123, 0xF23, "Custom Message."); +} + +void testHEX8sNotWithinDelta(void) +{ + EXPECT_ABORT_BEGIN + TEST_ASSERT_HEX8_WITHIN(2, 255, 0); + VERIFY_FAILS_END +} + +void testHEX8sNotWithinDeltaAndCustomMessage(void) +{ + EXPECT_ABORT_BEGIN + TEST_ASSERT_HEX8_WITHIN_MESSAGE(2, 255, 0, "Custom Message."); + VERIFY_FAILS_END +} + +/*-----------------*/ + +void testUINT32sWithinDelta(void) +{ + TEST_ASSERT_UINT32_WITHIN(1, 5000, 5001); + TEST_ASSERT_UINT32_WITHIN(5, 5000, 4996); + TEST_ASSERT_UINT32_WITHIN(5, 5000, 5005); +} + +void testUINT32sWithinDeltaAndCustomMessage(void) +{ + TEST_ASSERT_UINT32_WITHIN_MESSAGE(1, 5000, 5001, "Custom Message."); + TEST_ASSERT_UINT32_WITHIN_MESSAGE(5, 5000, 4996, "Custom Message."); + TEST_ASSERT_UINT32_WITHIN_MESSAGE(5, 5000, 5005, "Custom Message."); +} + +void testUINT32sNotWithinDelta(void) +{ + EXPECT_ABORT_BEGIN + TEST_ASSERT_UINT32_WITHIN(1, 2147483647u, 2147483649u); + VERIFY_FAILS_END +} + +void testUINT32sNotWithinDeltaAndCustomMessage(void) +{ + EXPECT_ABORT_BEGIN + TEST_ASSERT_UINT32_WITHIN_MESSAGE(1, 2147483647u, 2147483649u, "Custom Message."); + VERIFY_FAILS_END +} + +void testUINT32sNotWithinDeltaEvenThoughASignedIntWouldPass(void) +{ + EXPECT_ABORT_BEGIN + TEST_ASSERT_UINT32_WITHIN(5, 1, -1); + VERIFY_FAILS_END +} + +void testUINT32sNotWithinDeltaEvenThoughASignedIntWouldPassAndCustomMessage(void) +{ + EXPECT_ABORT_BEGIN + TEST_ASSERT_UINT32_WITHIN_MESSAGE(5, 1, -1, "Custom Message."); + VERIFY_FAILS_END +} + +void testUINT16sWithinDelta(void) +{ + TEST_ASSERT_UINT16_WITHIN(1, 5000, 5001); + TEST_ASSERT_UINT16_WITHIN(5, 5000, 4996); + TEST_ASSERT_UINT16_WITHIN(5, 5000, 5005); +} + +void testUINT16sWithinDeltaAndCustomMessage(void) +{ + TEST_ASSERT_UINT16_WITHIN_MESSAGE(1, 5000, 5001, "Custom Message."); + TEST_ASSERT_UINT16_WITHIN_MESSAGE(5, 5000, 4996, "Custom Message."); + TEST_ASSERT_UINT16_WITHIN_MESSAGE(5, 5000, 5005, "Custom Message."); +} + +void testUINT16sWithinDeltaWhenThereAreDifferenceOutsideOf16Bits(void) +{ + TEST_ASSERT_UINT16_WITHIN(5, 0x54321, 0x44321); +} + +void testUINT16sWithinDeltaWhenThereAreDifferenceOutsideOf16BitsAndCustomMessage(void) +{ + TEST_ASSERT_UINT16_WITHIN_MESSAGE(5, 0x54321, 0x44321, "Custom Message."); +} + +void testUINT16sNotWithinDelta(void) +{ + EXPECT_ABORT_BEGIN + TEST_ASSERT_UINT16_WITHIN(2, 65535, 0); + VERIFY_FAILS_END +} + +void testUINT16sNotWithinDeltaAndCustomMessage(void) +{ + EXPECT_ABORT_BEGIN + TEST_ASSERT_UINT16_WITHIN_MESSAGE(2, 65535, 0, "Custom Message."); + VERIFY_FAILS_END +} + +void testUINT8sWithinDelta(void) +{ + TEST_ASSERT_UINT8_WITHIN(1, 254, 255); + TEST_ASSERT_UINT8_WITHIN(5, 251, 255); + TEST_ASSERT_UINT8_WITHIN(5, 1, 4); +} + +void testUINT8sWithinDeltaAndCustomMessage(void) +{ + TEST_ASSERT_UINT8_WITHIN_MESSAGE(1, 254, 255, "Custom Message."); + TEST_ASSERT_UINT8_WITHIN_MESSAGE(5, 251, 255, "Custom Message."); + TEST_ASSERT_UINT8_WITHIN_MESSAGE(5, 1, 4, "Custom Message."); +} + +void testUINT8sWithinDeltaWhenThereAreDifferenceOutsideOf8Bits(void) +{ + TEST_ASSERT_UINT8_WITHIN(5, 0x123, 0xF23); +} + +void testUINT8sWithinDeltaWhenThereAreDifferenceOutsideOf8BitsAndCustomMessage(void) +{ + TEST_ASSERT_UINT8_WITHIN_MESSAGE(5, 0x123, 0xF23, "Custom Message."); +} + +void testUINT8sNotWithinDelta(void) +{ + EXPECT_ABORT_BEGIN + TEST_ASSERT_UINT8_WITHIN(2, 255, 0); + VERIFY_FAILS_END +} + +void testUINT8sNotWithinDeltaAndCustomMessage(void) +{ + EXPECT_ABORT_BEGIN + TEST_ASSERT_UINT8_WITHIN_MESSAGE(2, 255, 0, "Custom Message."); + VERIFY_FAILS_END +} + +void testINT32sWithinDelta(void) +{ + TEST_ASSERT_INT32_WITHIN(1, 5000, 5001); + TEST_ASSERT_INT32_WITHIN(5, 1, -2); + TEST_ASSERT_INT32_WITHIN(5, -2, 1); +} + +void testINT32sWithinDeltaAndCustomMessage(void) +{ + TEST_ASSERT_INT32_WITHIN_MESSAGE(1, 5000, 5001, "Custom Message."); +} + +void testINT32sNotWithinDelta(void) +{ + EXPECT_ABORT_BEGIN + TEST_ASSERT_INT32_WITHIN(1, -3, 1); + VERIFY_FAILS_END +} + +void testINT32sNotWithinDeltaAndDifferenceOverflows(void) +{ + EXPECT_ABORT_BEGIN + TEST_ASSERT_INT32_WITHIN(1, -1, 0x7FFFFFFF); + VERIFY_FAILS_END +} +void testINT32sNotWithinDeltaAndCustomMessage(void) +{ + EXPECT_ABORT_BEGIN + TEST_ASSERT_INT32_WITHIN_MESSAGE(1, -2, 1, "Custom Message."); + VERIFY_FAILS_END +} + +void testINT16sWithinDelta(void) +{ + TEST_ASSERT_INT16_WITHIN(1, 5000, 5001); + TEST_ASSERT_INT16_WITHIN(5, 2, -2); + TEST_ASSERT_INT16_WITHIN(5, -2, 2); +} + +void testINT16sWithinDeltaAndCustomMessage(void) +{ + TEST_ASSERT_INT16_WITHIN_MESSAGE(1, 5000, 5001, "Custom Message."); +} + +void testINT16sWithinDeltaWhenThereAreDifferenceOutsideOf16Bits(void) +{ + TEST_ASSERT_INT16_WITHIN(5, 0x54321, 0x44321); +} + +void testINT16sWithinDeltaWhenThereAreDifferenceOutsideOf16BitsAndCustomMessage(void) +{ + TEST_ASSERT_INT16_WITHIN_MESSAGE(5, 0x54321, 0x44321, "Custom Message."); +} + +void testINT16sNotWithinDelta(void) +{ + EXPECT_ABORT_BEGIN + TEST_ASSERT_INT16_WITHIN(2, 4, -2); + VERIFY_FAILS_END +} + +void testINT16sNotWithinDeltaAndCustomMessage(void) +{ + EXPECT_ABORT_BEGIN + TEST_ASSERT_INT16_WITHIN_MESSAGE(2, 3, 0, "Custom Message."); + VERIFY_FAILS_END +} + +void testINT8sWithinDelta(void) +{ + TEST_ASSERT_INT8_WITHIN(1, 127, 126); + TEST_ASSERT_INT8_WITHIN(5, -2, 2); + TEST_ASSERT_INT8_WITHIN(5, 2, -2); +} + +void testINT8sWithinDeltaAndCustomMessage(void) +{ + TEST_ASSERT_INT8_WITHIN_MESSAGE(5, 1, 4, "Custom Message."); +} + +void testINT8sWithinDeltaWhenThereAreDifferenceOutsideOf8Bits(void) +{ + TEST_ASSERT_INT8_WITHIN(5, 0x123, 0xF23); +} + +void testINT8sWithinDeltaWhenThereAreDifferenceOutsideOf8BitsAndCustomMessage(void) +{ + TEST_ASSERT_INT8_WITHIN_MESSAGE(5, 0x123, 0xF23, "Custom Message."); +} + +void testINT8sNotWithinDelta(void) +{ + EXPECT_ABORT_BEGIN + TEST_ASSERT_INT8_WITHIN(2, -3, 0); + VERIFY_FAILS_END +} + +void testINT8sNotWithinDeltaAndCustomMessage(void) +{ + EXPECT_ABORT_BEGIN + TEST_ASSERT_INT8_WITHIN_MESSAGE(2, -4, 0, "Custom Message."); + VERIFY_FAILS_END +} + +void testCHARsWithinDelta(void) +{ + TEST_ASSERT_CHAR_WITHIN(1, 'M', 'L'); + TEST_ASSERT_CHAR_WITHIN(5, -2, 2); + TEST_ASSERT_CHAR_WITHIN(5, 2, -2); +} + +void testCHARsWithinDeltaAndCustomMessage(void) +{ + TEST_ASSERT_CHAR_WITHIN_MESSAGE(5, 1, 4, "Custom Message."); +} + +void testCHARsWithinDeltaWhenThereAreDifferenceOutsideOf8Bits(void) +{ + TEST_ASSERT_CHAR_WITHIN(5, 0x123, 0xF23); +} + +void testCHARsWithinDeltaWhenThereAreDifferenceOutsideOf8BitsAndCustomMessage(void) +{ + TEST_ASSERT_CHAR_WITHIN_MESSAGE(5, 0x123, 0xF23, "Custom Message."); +} + +void testCHARsNotWithinDelta(void) +{ + EXPECT_ABORT_BEGIN + TEST_ASSERT_CHAR_WITHIN(2, -3, 0); + VERIFY_FAILS_END +} + +void testCHARsNotWithinDeltaAndCustomMessage(void) +{ + EXPECT_ABORT_BEGIN + TEST_ASSERT_CHAR_WITHIN_MESSAGE(2, -4, 0, "Custom Message."); + VERIFY_FAILS_END +} + +void testNotEqualINT(void) +{ + UNITY_INT v0, v1; + UNITY_INT *p0, *p1; + + v0 = 302; + v1 = 3334; + p0 = &v0; + p1 = &v1; + + TEST_ASSERT_NOT_EQUAL_INT(v0, v1); + TEST_ASSERT_NOT_EQUAL_INT(*p0, v1); + TEST_ASSERT_NOT_EQUAL_INT(v0, *p1); + TEST_ASSERT_NOT_EQUAL_INT(*p1, *p0); +} + +void testNotNotEqualINT(void) +{ + EXPECT_ABORT_BEGIN + TEST_ASSERT_NOT_EQUAL_INT(302, 302); + VERIFY_FAILS_END +} + +void testNotEqualINT8(void) +{ + UNITY_INT8 v0, v1; + UNITY_INT8 *p0, *p1; + + v0 = -128; + v1 = 127; + p0 = &v0; + p1 = &v1; + + TEST_ASSERT_NOT_EQUAL_INT8(v0, v1); + TEST_ASSERT_NOT_EQUAL_INT8(*p0, v1); + TEST_ASSERT_NOT_EQUAL_INT8(v0, *p1); + TEST_ASSERT_NOT_EQUAL_INT8(*p1, *p0); +} + +void testNotNotEqualINT8(void) +{ + EXPECT_ABORT_BEGIN + TEST_ASSERT_NOT_EQUAL_INT8(-128, -128); + VERIFY_FAILS_END +} + +void testNotEqualCHAR(void) +{ + char v0, v1; + char *p0, *p1; + + v0 = -128; + v1 = 127; + p0 = &v0; + p1 = &v1; + + TEST_ASSERT_NOT_EQUAL_CHAR(v0, v1); + TEST_ASSERT_NOT_EQUAL_CHAR(*p0, v1); + TEST_ASSERT_NOT_EQUAL_CHAR(v0, *p1); + TEST_ASSERT_NOT_EQUAL_CHAR(*p1, *p0); +} + +void testNotNotEqualCHAR(void) +{ + EXPECT_ABORT_BEGIN + TEST_ASSERT_NOT_EQUAL_CHAR(127, 127); + VERIFY_FAILS_END +} + +void testNotEqualINT16(void) +{ + UNITY_INT16 v0, v1; + UNITY_INT16 *p0, *p1; + + v0 = -32768; + v1 = 32767; + p0 = &v0; + p1 = &v1; + + TEST_ASSERT_NOT_EQUAL_INT16(v0, v1); + TEST_ASSERT_NOT_EQUAL_INT16(*p0, v1); + TEST_ASSERT_NOT_EQUAL_INT16(v0, *p1); + TEST_ASSERT_NOT_EQUAL_INT16(*p1, *p0); +} + +void testNotNotEqualINT16(void) +{ + EXPECT_ABORT_BEGIN + TEST_ASSERT_NOT_EQUAL_INT16(-32768, -32768); + VERIFY_FAILS_END +} + +void testNotEqualINT32(void) +{ + UNITY_INT32 v0, v1; + UNITY_INT32 *p0, *p1; + + v0 = -214783648; + v1 = 214783647; + p0 = &v0; + p1 = &v1; + + TEST_ASSERT_NOT_EQUAL_INT32(v0, v1); + TEST_ASSERT_NOT_EQUAL_INT32(*p0, v1); + TEST_ASSERT_NOT_EQUAL_INT32(v0, *p1); + TEST_ASSERT_NOT_EQUAL_INT32(*p1, *p0); +} + +void testNotNotEqualINT32(void) +{ + EXPECT_ABORT_BEGIN + TEST_ASSERT_NOT_EQUAL_INT32(-214783648, -214783648); + VERIFY_FAILS_END +} + +void testNotEqualUINT(void) +{ + UNITY_UINT v0, v1; + UNITY_UINT *p0, *p1; + + v0 = 0; + v1 = 1; + p0 = &v0; + p1 = &v1; + + TEST_ASSERT_NOT_EQUAL_UINT(v0, v1); + TEST_ASSERT_NOT_EQUAL_UINT(*p0, v1); + TEST_ASSERT_NOT_EQUAL_UINT(v0, *p1); + TEST_ASSERT_NOT_EQUAL_UINT(*p1, *p0); +} + +void testNotNotEqualUINT(void) +{ + EXPECT_ABORT_BEGIN + TEST_ASSERT_NOT_EQUAL_UINT(1, 1); + VERIFY_FAILS_END +} + +void testNotEqualUINT8(void) +{ + UNITY_UINT8 v0, v1; + UNITY_UINT8 *p0, *p1; + + v0 = 0; + v1 = 255; + p0 = &v0; + p1 = &v1; + + TEST_ASSERT_NOT_EQUAL_UINT8(v0, v1); + TEST_ASSERT_NOT_EQUAL_UINT8(*p0, v1); + TEST_ASSERT_NOT_EQUAL_UINT8(v0, *p1); + TEST_ASSERT_NOT_EQUAL_UINT8(*p1, *p0); +} + +void testNotNotEqualUINT8(void) +{ + EXPECT_ABORT_BEGIN + TEST_ASSERT_NOT_EQUAL_UINT8(255, 255); + VERIFY_FAILS_END +} + +void testNotEqualUINT16(void) +{ + UNITY_UINT16 v0, v1; + UNITY_UINT16 *p0, *p1; + + v0 = 0; + v1 = 65535; + p0 = &v0; + p1 = &v1; + + TEST_ASSERT_NOT_EQUAL_UINT16(v0, v1); + TEST_ASSERT_NOT_EQUAL_UINT16(*p0, v1); + TEST_ASSERT_NOT_EQUAL_UINT16(v0, *p1); + TEST_ASSERT_NOT_EQUAL_UINT16(*p1, *p0); +} + +void testNotNotEqualUINT16(void) +{ + EXPECT_ABORT_BEGIN + TEST_ASSERT_NOT_EQUAL_UINT16(65535, 65535); + VERIFY_FAILS_END +} + +void testNotEqualUINT32(void) +{ + UNITY_UINT32 v0, v1; + UNITY_UINT32 *p0, *p1; + + v0 = 0u; + v1 = 4294967295u; + p0 = &v0; + p1 = &v1; + + TEST_ASSERT_NOT_EQUAL_UINT32(v0, v1); + TEST_ASSERT_NOT_EQUAL_UINT32(*p0, v1); + TEST_ASSERT_NOT_EQUAL_UINT32(v0, *p1); + TEST_ASSERT_NOT_EQUAL_UINT32(*p1, *p0); +} + +void testNotNotEqualUINT32(void) +{ + EXPECT_ABORT_BEGIN + TEST_ASSERT_NOT_EQUAL_UINT32(4294967295u, 4294967295u); + VERIFY_FAILS_END +} + +void testNotEqualHEX8(void) +{ + UNITY_UINT8 v0, v1; + UNITY_UINT8 *p0, *p1; + + v0 = 0x00; + v1 = 0xFF; + p0 = &v0; + p1 = &v1; + + TEST_ASSERT_NOT_EQUAL_HEX8(v0, v1); + TEST_ASSERT_NOT_EQUAL_HEX8(*p0, v1); + TEST_ASSERT_NOT_EQUAL_HEX8(v0, *p1); + TEST_ASSERT_NOT_EQUAL_HEX8(*p1, *p0); +} + +void testNotNotEqualHEX8(void) +{ + EXPECT_ABORT_BEGIN + TEST_ASSERT_NOT_EQUAL_HEX8(0xFF, 0xFF); + VERIFY_FAILS_END +} + +void testNotEqualHEX16(void) +{ + UNITY_UINT16 v0, v1; + UNITY_UINT16 *p0, *p1; + + v0 = 0x0000; + v1 = 0xFFFF; + p0 = &v0; + p1 = &v1; + + TEST_ASSERT_NOT_EQUAL_HEX16(v0, v1); + TEST_ASSERT_NOT_EQUAL_HEX16(*p0, v1); + TEST_ASSERT_NOT_EQUAL_HEX16(v0, *p1); + TEST_ASSERT_NOT_EQUAL_HEX16(*p1, *p0); +} + +void testNotNotEqualHEX16(void) +{ + EXPECT_ABORT_BEGIN + TEST_ASSERT_NOT_EQUAL_HEX16(0xFFFF, 0xFFFF); + VERIFY_FAILS_END +} + +void testNotEqualHEX32(void) +{ + UNITY_UINT32 v0, v1; + UNITY_UINT32 *p0, *p1; + + v0 = 0x00000000; + v1 = 0xFFFFFFFF; + p0 = &v0; + p1 = &v1; + + TEST_ASSERT_NOT_EQUAL_HEX32(v0, v1); + TEST_ASSERT_NOT_EQUAL_HEX32(*p0, v1); + TEST_ASSERT_NOT_EQUAL_HEX32(v0, *p1); + TEST_ASSERT_NOT_EQUAL_HEX32(*p1, *p0); +} + +void testNotNotEqualHEX32(void) +{ + EXPECT_ABORT_BEGIN + TEST_ASSERT_NOT_EQUAL_HEX32(0xFFFFFFFF, 0xFFFFFFFF); + VERIFY_FAILS_END +} + +/*-----------------*/ + +void testGreaterThan(void) +{ + UNITY_INT v0, v1; + UNITY_INT *p0, *p1; + + v0 = 0; + v1 = 1; + p0 = &v0; + p1 = &v1; + + TEST_ASSERT_GREATER_THAN(v0, v1); + TEST_ASSERT_GREATER_THAN(*p0, v1); + TEST_ASSERT_GREATER_THAN(v0, *p1); + TEST_ASSERT_GREATER_THAN(*p0, *p1); +} + +void testNotGreaterThan(void) +{ + EXPECT_ABORT_BEGIN + TEST_ASSERT_GREATER_THAN(0, -1); + VERIFY_FAILS_END +} + +void testGreaterThanINT(void) +{ + UNITY_INT v0, v1; + UNITY_INT *p0, *p1; + + v0 = 302; + v1 = 3334; + p0 = &v0; + p1 = &v1; + + TEST_ASSERT_GREATER_THAN_INT(v0, v1); + TEST_ASSERT_GREATER_THAN_INT(*p0, v1); + TEST_ASSERT_GREATER_THAN_INT(v0, *p1); + TEST_ASSERT_GREATER_THAN_INT(*p0, *p1); +} + +void testNotGreaterThanINT(void) +{ + EXPECT_ABORT_BEGIN + TEST_ASSERT_GREATER_THAN_INT(3334, 302); + VERIFY_FAILS_END +} + +void testGreaterThanINT8(void) +{ + UNITY_INT8 v0, v1; + UNITY_INT8 *p0, *p1; + + v0 = -128; + v1 = 127; + p0 = &v0; + p1 = &v1; + + TEST_ASSERT_GREATER_THAN_INT8(v0, v1); + TEST_ASSERT_GREATER_THAN_INT8(*p0, v1); + TEST_ASSERT_GREATER_THAN_INT8(v0, *p1); + TEST_ASSERT_GREATER_THAN_INT8(*p0, *p1); +} + +void testNotGreaterThanINT8(void) +{ + EXPECT_ABORT_BEGIN + TEST_ASSERT_GREATER_THAN_INT8(127, -128); + VERIFY_FAILS_END +} + +void testGreaterThanCHAR(void) +{ + char v0, v1; + char *p0, *p1; + + v0 = -128; + v1 = 127; + p0 = &v0; + p1 = &v1; + + TEST_ASSERT_GREATER_THAN_CHAR(v0, v1); + TEST_ASSERT_GREATER_THAN_CHAR(*p0, v1); + TEST_ASSERT_GREATER_THAN_CHAR(v0, *p1); + TEST_ASSERT_GREATER_THAN_CHAR(*p0, *p1); +} + +void testNotGreaterThanCHAR(void) +{ + EXPECT_ABORT_BEGIN + TEST_ASSERT_GREATER_THAN_CHAR(127, -128); + VERIFY_FAILS_END +} + +void testGreaterThanINT16(void) +{ + UNITY_INT16 v0, v1; + UNITY_INT16 *p0, *p1; + + v0 = -32768; + v1 = 32767; + p0 = &v0; + p1 = &v1; + + TEST_ASSERT_GREATER_THAN_INT16(v0, v1); + TEST_ASSERT_GREATER_THAN_INT16(*p0, v1); + TEST_ASSERT_GREATER_THAN_INT16(v0, *p1); + TEST_ASSERT_GREATER_THAN_INT16(*p0, *p1); +} + +void testNotGreaterThanINT16(void) +{ + EXPECT_ABORT_BEGIN + TEST_ASSERT_GREATER_THAN_INT16(32768, -32768); + VERIFY_FAILS_END +} + +void testGreaterThanINT32(void) +{ + UNITY_INT32 v0, v1; + UNITY_INT32 *p0, *p1; + + v0 = -214783648; + v1 = 214783647; + p0 = &v0; + p1 = &v1; + + TEST_ASSERT_GREATER_THAN_INT32(v0, v1); + TEST_ASSERT_GREATER_THAN_INT32(*p0, v1); + TEST_ASSERT_GREATER_THAN_INT32(v0, *p1); + TEST_ASSERT_GREATER_THAN_INT32(*p0, *p1); +} + +void testNotGreaterThanINT32(void) +{ + EXPECT_ABORT_BEGIN + TEST_ASSERT_GREATER_THAN_INT32(214783647, -214783648); + VERIFY_FAILS_END +} + +void testGreaterThanUINT(void) +{ + UNITY_UINT v0, v1; + UNITY_UINT *p0, *p1; + + v0 = 0; + v1 = 1; + p0 = &v0; + p1 = &v1; + + TEST_ASSERT_GREATER_THAN_UINT(v0, v1); + TEST_ASSERT_GREATER_THAN_UINT(*p0, v1); + TEST_ASSERT_GREATER_THAN_UINT(v0, *p1); + TEST_ASSERT_GREATER_THAN_UINT(*p0, *p1); +} + +void testNotGreaterThanUINT(void) +{ + EXPECT_ABORT_BEGIN + TEST_ASSERT_GREATER_THAN_UINT(1, 0); + VERIFY_FAILS_END +} + +void testGreaterThanUINT8(void) +{ + UNITY_UINT8 v0, v1; + UNITY_UINT8 *p0, *p1; + + v0 = 0; + v1 = 255; + p0 = &v0; + p1 = &v1; + + TEST_ASSERT_GREATER_THAN_UINT8(v0, v1); + TEST_ASSERT_GREATER_THAN_UINT8(*p0, v1); + TEST_ASSERT_GREATER_THAN_UINT8(v0, *p1); + TEST_ASSERT_GREATER_THAN_UINT8(*p0, *p1); +} + +void testNotGreaterThanUINT8(void) +{ + EXPECT_ABORT_BEGIN + TEST_ASSERT_GREATER_THAN_UINT8(255, 0); + VERIFY_FAILS_END +} + +void testGreaterThanUINT16(void) +{ + UNITY_UINT16 v0, v1; + UNITY_UINT16 *p0, *p1; + + v0 = 0; + v1 = 65535; + p0 = &v0; + p1 = &v1; + + TEST_ASSERT_GREATER_THAN_UINT16(v0, v1); + TEST_ASSERT_GREATER_THAN_UINT16(*p0, v1); + TEST_ASSERT_GREATER_THAN_UINT16(v0, *p1); + TEST_ASSERT_GREATER_THAN_UINT16(*p0, *p1); +} + +void testNotGreaterThanUINT16(void) +{ + EXPECT_ABORT_BEGIN + TEST_ASSERT_GREATER_THAN_UINT16(65535, 0); + VERIFY_FAILS_END +} + +void testGreaterThanUINT32(void) +{ + UNITY_UINT32 v0, v1; + UNITY_UINT32 *p0, *p1; + + v0 = 0u; + v1 = 4294967295u; + p0 = &v0; + p1 = &v1; + + TEST_ASSERT_GREATER_THAN_UINT32(v0, v1); + TEST_ASSERT_GREATER_THAN_UINT32(*p0, v1); + TEST_ASSERT_GREATER_THAN_UINT32(v0, *p1); + TEST_ASSERT_GREATER_THAN_UINT32(*p0, *p1); +} + +void testNotGreaterThanUINT32(void) +{ + EXPECT_ABORT_BEGIN + TEST_ASSERT_GREATER_THAN_UINT32(4294967295u, 0); + VERIFY_FAILS_END +} + +void testGreaterThanHEX8(void) +{ + UNITY_UINT8 v0, v1; + UNITY_UINT8 *p0, *p1; + + v0 = 0x00; + v1 = 0xFF; + p0 = &v0; + p1 = &v1; + + TEST_ASSERT_GREATER_THAN_HEX8(v0, v1); + TEST_ASSERT_GREATER_THAN_HEX8(*p0, v1); + TEST_ASSERT_GREATER_THAN_HEX8(v0, *p1); + TEST_ASSERT_GREATER_THAN_HEX8(*p0, *p1); +} + +void testNotGreaterThanHEX8(void) +{ + EXPECT_ABORT_BEGIN + TEST_ASSERT_GREATER_THAN_HEX8(0xFF, 0x00); + VERIFY_FAILS_END +} + +void testGreaterThanHEX16(void) +{ + UNITY_UINT16 v0, v1; + UNITY_UINT16 *p0, *p1; + + v0 = 0x0000; + v1 = 0xFFFF; + p0 = &v0; + p1 = &v1; + + TEST_ASSERT_GREATER_THAN_HEX16(v0, v1); + TEST_ASSERT_GREATER_THAN_HEX16(*p0, v1); + TEST_ASSERT_GREATER_THAN_HEX16(v0, *p1); + TEST_ASSERT_GREATER_THAN_HEX16(*p0, *p1); +} + +void testNotGreaterThanHEX16(void) +{ + EXPECT_ABORT_BEGIN + TEST_ASSERT_GREATER_THAN_HEX16(0xFFFF, 0x00); + VERIFY_FAILS_END +} + +void testGreaterThanHEX32(void) +{ + UNITY_UINT32 v0, v1; + UNITY_UINT32 *p0, *p1; + + v0 = 0x00000000; + v1 = 0xFFFFFFFF; + p0 = &v0; + p1 = &v1; + + TEST_ASSERT_GREATER_THAN_HEX32(v0, v1); + TEST_ASSERT_GREATER_THAN_HEX32(*p0, v1); + TEST_ASSERT_GREATER_THAN_HEX32(v0, *p1); + TEST_ASSERT_GREATER_THAN_HEX32(*p0, *p1); +} + +void testNotGreaterThanHEX32(void) +{ + EXPECT_ABORT_BEGIN + TEST_ASSERT_GREATER_THAN_HEX32(0xFFFFFFFF, 0x00); + VERIFY_FAILS_END +} + +void testGreaterOrEqual(void) +{ + UNITY_INT v0, v1, v2; + UNITY_INT *p0, *p1, *p2; + + v0 = 0; + v1 = 1; + v2 = 0; + p0 = &v0; + p1 = &v1; + p2 = &v2; + + TEST_ASSERT_GREATER_OR_EQUAL(v0, v1); + TEST_ASSERT_GREATER_OR_EQUAL(*p0, v1); + TEST_ASSERT_GREATER_OR_EQUAL(v0, *p1); + TEST_ASSERT_GREATER_OR_EQUAL(*p0, *p1); + TEST_ASSERT_GREATER_OR_EQUAL(v0, v2); + TEST_ASSERT_GREATER_OR_EQUAL(*p0, v2); + TEST_ASSERT_GREATER_OR_EQUAL(v0, *p2); + TEST_ASSERT_GREATER_OR_EQUAL(*p0, *p2); +} + +void testNotGreaterOrEqual(void) +{ + EXPECT_ABORT_BEGIN + TEST_ASSERT_GREATER_OR_EQUAL(0, -1); + VERIFY_FAILS_END +} + +void testGreaterOrEqualINT(void) +{ + UNITY_INT v0, v1, v2; + UNITY_INT *p0, *p1, *p2; + + v0 = 302; + v1 = 3334; + v2 = 302; + p0 = &v0; + p1 = &v1; + p2 = &v2; + + TEST_ASSERT_GREATER_OR_EQUAL_INT(v0, v1); + TEST_ASSERT_GREATER_OR_EQUAL_INT(*p0, v1); + TEST_ASSERT_GREATER_OR_EQUAL_INT(v0, *p1); + TEST_ASSERT_GREATER_OR_EQUAL_INT(*p0, *p1); + TEST_ASSERT_GREATER_OR_EQUAL_INT(v0, v2); + TEST_ASSERT_GREATER_OR_EQUAL_INT(*p0, v2); + TEST_ASSERT_GREATER_OR_EQUAL_INT(v0, *p2); + TEST_ASSERT_GREATER_OR_EQUAL_INT(*p0, *p2); +} + +void testNotGreaterOrEqualINT(void) +{ + EXPECT_ABORT_BEGIN + TEST_ASSERT_GREATER_OR_EQUAL_INT(3334, 302); + VERIFY_FAILS_END +} + +void testGreaterOrEqualINT8(void) +{ + UNITY_INT8 v0, v1, v2; + UNITY_INT8 *p0, *p1, *p2; + + v0 = -128; + v1 = 127; + v2 = -128; + p0 = &v0; + p1 = &v1; + p2 = &v2; + + TEST_ASSERT_GREATER_OR_EQUAL_INT8(v0, v1); + TEST_ASSERT_GREATER_OR_EQUAL_INT8(*p0, v1); + TEST_ASSERT_GREATER_OR_EQUAL_INT8(v0, *p1); + TEST_ASSERT_GREATER_OR_EQUAL_INT8(*p0, *p1); + TEST_ASSERT_GREATER_OR_EQUAL_INT8(v0, v2); + TEST_ASSERT_GREATER_OR_EQUAL_INT8(*p0, v2); + TEST_ASSERT_GREATER_OR_EQUAL_INT8(v0, *p2); + TEST_ASSERT_GREATER_OR_EQUAL_INT8(*p0, *p2); +} + +void testNotGreaterOrEqualINT8(void) +{ + EXPECT_ABORT_BEGIN + TEST_ASSERT_GREATER_OR_EQUAL_INT8(127, -128); + VERIFY_FAILS_END +} + +void testGreaterOrEqualCHAR(void) +{ + char v0, v1, v2; + char *p0, *p1, *p2; + + v0 = -128; + v1 = 127; + v2 = -128; + p0 = &v0; + p1 = &v1; + p2 = &v2; + + TEST_ASSERT_GREATER_OR_EQUAL_CHAR(v0, v1); + TEST_ASSERT_GREATER_OR_EQUAL_CHAR(*p0, v1); + TEST_ASSERT_GREATER_OR_EQUAL_CHAR(v0, *p1); + TEST_ASSERT_GREATER_OR_EQUAL_CHAR(*p0, *p1); + TEST_ASSERT_GREATER_OR_EQUAL_CHAR(v0, v2); + TEST_ASSERT_GREATER_OR_EQUAL_CHAR(*p0, v2); + TEST_ASSERT_GREATER_OR_EQUAL_CHAR(v0, *p2); + TEST_ASSERT_GREATER_OR_EQUAL_CHAR(*p0, *p2); +} + +void testNotGreaterOrEqualCHAR(void) +{ + EXPECT_ABORT_BEGIN + TEST_ASSERT_GREATER_OR_EQUAL_CHAR(127, -128); + VERIFY_FAILS_END +} + +void testGreaterOrEqualINT16(void) +{ + UNITY_INT16 v0, v1, v2; + UNITY_INT16 *p0, *p1, *p2; + + v0 = -32768; + v1 = 32767; + v2 = -32768; + p0 = &v0; + p1 = &v1; + p2 = &v2; + + TEST_ASSERT_GREATER_OR_EQUAL_INT16(v0, v1); + TEST_ASSERT_GREATER_OR_EQUAL_INT16(*p0, v1); + TEST_ASSERT_GREATER_OR_EQUAL_INT16(v0, *p1); + TEST_ASSERT_GREATER_OR_EQUAL_INT16(*p0, *p1); + TEST_ASSERT_GREATER_OR_EQUAL_INT16(v0, v2); + TEST_ASSERT_GREATER_OR_EQUAL_INT16(*p0, v2); + TEST_ASSERT_GREATER_OR_EQUAL_INT16(v0, *p2); + TEST_ASSERT_GREATER_OR_EQUAL_INT16(*p0, *p2); +} + +void testNotGreaterOrEqualINT16(void) +{ + EXPECT_ABORT_BEGIN + TEST_ASSERT_GREATER_OR_EQUAL_INT16(32767, -32768); + VERIFY_FAILS_END +} + +void testGreaterOrEqualINT32(void) +{ + UNITY_INT32 v0, v1, v2; + UNITY_INT32 *p0, *p1, *p2; + + v0 = -214783648; + v1 = 214783647; + v2 = -214783648; + p0 = &v0; + p1 = &v1; + p2 = &v2; + + TEST_ASSERT_GREATER_OR_EQUAL_INT32(v0, v1); + TEST_ASSERT_GREATER_OR_EQUAL_INT32(*p0, v1); + TEST_ASSERT_GREATER_OR_EQUAL_INT32(v0, *p1); + TEST_ASSERT_GREATER_OR_EQUAL_INT32(*p0, *p1); + TEST_ASSERT_GREATER_OR_EQUAL_INT32(v0, v2); + TEST_ASSERT_GREATER_OR_EQUAL_INT32(*p0, v2); + TEST_ASSERT_GREATER_OR_EQUAL_INT32(v0, *p2); + TEST_ASSERT_GREATER_OR_EQUAL_INT32(*p0, *p2); +} + +void testNotGreaterOrEqualINT32(void) +{ + EXPECT_ABORT_BEGIN + TEST_ASSERT_GREATER_OR_EQUAL_INT32(214783647, -214783648); + VERIFY_FAILS_END +} + +void testGreaterOrEqualUINT(void) +{ + UNITY_UINT v0, v1, v2; + UNITY_UINT *p0, *p1, *p2; + + v0 = 0; + v1 = 1; + v2 = 0; + p0 = &v0; + p1 = &v1; + p2 = &v2; + + TEST_ASSERT_GREATER_OR_EQUAL_UINT(v0, v1); + TEST_ASSERT_GREATER_OR_EQUAL_UINT(*p0, v1); + TEST_ASSERT_GREATER_OR_EQUAL_UINT(v0, *p1); + TEST_ASSERT_GREATER_OR_EQUAL_UINT(*p0, *p1); + TEST_ASSERT_GREATER_OR_EQUAL_UINT(v0, v2); + TEST_ASSERT_GREATER_OR_EQUAL_UINT(*p0, v2); + TEST_ASSERT_GREATER_OR_EQUAL_UINT(v0, *p2); + TEST_ASSERT_GREATER_OR_EQUAL_UINT(*p0, *p2); +} + +void testNotGreaterOrEqualUINT(void) +{ + EXPECT_ABORT_BEGIN + TEST_ASSERT_GREATER_OR_EQUAL_UINT(1, 0); + VERIFY_FAILS_END +} + +void testGreaterOrEqualUINT8(void) +{ + UNITY_UINT8 v0, v1, v2; + UNITY_UINT8 *p0, *p1, *p2; + + v0 = 0; + v1 = 255; + v2 = 0; + p0 = &v0; + p1 = &v1; + p2 = &v2; + + TEST_ASSERT_GREATER_OR_EQUAL_UINT8(v0, v1); + TEST_ASSERT_GREATER_OR_EQUAL_UINT8(*p0, v1); + TEST_ASSERT_GREATER_OR_EQUAL_UINT8(v0, *p1); + TEST_ASSERT_GREATER_OR_EQUAL_UINT8(*p0, *p1); + TEST_ASSERT_GREATER_OR_EQUAL_UINT8(v0, v2); + TEST_ASSERT_GREATER_OR_EQUAL_UINT8(*p0, v2); + TEST_ASSERT_GREATER_OR_EQUAL_UINT8(v0, *p2); + TEST_ASSERT_GREATER_OR_EQUAL_UINT8(*p0, *p2); +} + +void testNotGreaterOrEqualUINT8(void) +{ + EXPECT_ABORT_BEGIN + TEST_ASSERT_GREATER_OR_EQUAL_UINT8(255, 0); + VERIFY_FAILS_END +} + +void testGreaterOrEqualUINT16(void) +{ + UNITY_UINT16 v0, v1, v2; + UNITY_UINT16 *p0, *p1, *p2; + + v0 = 0; + v1 = 65535; + v2 = 0; + p0 = &v0; + p1 = &v1; + p2 = &v2; + + TEST_ASSERT_GREATER_OR_EQUAL_UINT16(v0, v1); + TEST_ASSERT_GREATER_OR_EQUAL_UINT16(*p0, v1); + TEST_ASSERT_GREATER_OR_EQUAL_UINT16(v0, *p1); + TEST_ASSERT_GREATER_OR_EQUAL_UINT16(*p0, *p1); + TEST_ASSERT_GREATER_OR_EQUAL_UINT16(v0, v2); + TEST_ASSERT_GREATER_OR_EQUAL_UINT16(*p0, v2); + TEST_ASSERT_GREATER_OR_EQUAL_UINT16(v0, *p2); + TEST_ASSERT_GREATER_OR_EQUAL_UINT16(*p0, *p2); +} + +void testNotGreaterOrEqualUINT16(void) +{ + EXPECT_ABORT_BEGIN + TEST_ASSERT_GREATER_OR_EQUAL_UINT16(65535, 0); + VERIFY_FAILS_END +} + +void testGreaterOrEqualUINT32(void) +{ + UNITY_UINT32 v0, v1, v2; + UNITY_UINT32 *p0, *p1, *p2; + + v0 = 0; + v1 = 4294967295u; + v2 = 0; + p0 = &v0; + p1 = &v1; + p2 = &v2; + + TEST_ASSERT_GREATER_OR_EQUAL_UINT32(v0, v1); + TEST_ASSERT_GREATER_OR_EQUAL_UINT32(*p0, v1); + TEST_ASSERT_GREATER_OR_EQUAL_UINT32(v0, *p1); + TEST_ASSERT_GREATER_OR_EQUAL_UINT32(*p0, *p1); + TEST_ASSERT_GREATER_OR_EQUAL_UINT32(v0, v2); + TEST_ASSERT_GREATER_OR_EQUAL_UINT32(*p0, v2); + TEST_ASSERT_GREATER_OR_EQUAL_UINT32(v0, *p2); + TEST_ASSERT_GREATER_OR_EQUAL_UINT32(*p0, *p2); +} + +void testNotGreaterOrEqualUINT32(void) +{ + EXPECT_ABORT_BEGIN + TEST_ASSERT_GREATER_OR_EQUAL_UINT32(4294967295u, 0); + VERIFY_FAILS_END +} + +void testGreaterOrEqualHEX8(void) +{ + UNITY_UINT8 v0, v1, v2; + UNITY_UINT8 *p0, *p1, *p2; + + v0 = 0x00; + v1 = 0xFF; + v2 = 0x00; + p0 = &v0; + p1 = &v1; + p2 = &v2; + + TEST_ASSERT_GREATER_OR_EQUAL_HEX8(v0, v1); + TEST_ASSERT_GREATER_OR_EQUAL_HEX8(*p0, v1); + TEST_ASSERT_GREATER_OR_EQUAL_HEX8(v0, *p1); + TEST_ASSERT_GREATER_OR_EQUAL_HEX8(*p0, *p1); + TEST_ASSERT_GREATER_OR_EQUAL_HEX8(v0, v2); + TEST_ASSERT_GREATER_OR_EQUAL_HEX8(*p0, v2); + TEST_ASSERT_GREATER_OR_EQUAL_HEX8(v0, *p2); + TEST_ASSERT_GREATER_OR_EQUAL_HEX8(*p0, *p2); +} + +void testNotGreaterOrEqualHEX8(void) +{ + EXPECT_ABORT_BEGIN + TEST_ASSERT_GREATER_OR_EQUAL_HEX8(0xFF, 0x00); + VERIFY_FAILS_END +} + +void testGreaterOrEqualHEX16(void) +{ + UNITY_UINT16 v0, v1, v2; + UNITY_UINT16 *p0, *p1, *p2; + + v0 = 0x0000; + v1 = 0xFFFF; + v2 = 0x0000; + p0 = &v0; + p1 = &v1; + p2 = &v2; + + TEST_ASSERT_GREATER_OR_EQUAL_HEX16(v0, v1); + TEST_ASSERT_GREATER_OR_EQUAL_HEX16(*p0, v1); + TEST_ASSERT_GREATER_OR_EQUAL_HEX16(v0, *p1); + TEST_ASSERT_GREATER_OR_EQUAL_HEX16(*p0, *p1); + TEST_ASSERT_GREATER_OR_EQUAL_HEX16(v0, v2); + TEST_ASSERT_GREATER_OR_EQUAL_HEX16(*p0, v2); + TEST_ASSERT_GREATER_OR_EQUAL_HEX16(v0, *p2); + TEST_ASSERT_GREATER_OR_EQUAL_HEX16(*p0, *p2); +} + +void testNotGreaterOrEqualHEX16(void) +{ + EXPECT_ABORT_BEGIN + TEST_ASSERT_GREATER_OR_EQUAL_HEX16(0xFFFF, 0x00); + VERIFY_FAILS_END +} + +void testGreaterOrEqualHEX32(void) +{ + UNITY_UINT32 v0, v1, v2; + UNITY_UINT32 *p0, *p1, *p2; + + v0 = 0x00000000; + v1 = 0xFFFFFFFF; + v2 = 0x00000000; + p0 = &v0; + p1 = &v1; + p2 = &v2; + + TEST_ASSERT_GREATER_OR_EQUAL_HEX32(v0, v1); + TEST_ASSERT_GREATER_OR_EQUAL_HEX32(*p0, v1); + TEST_ASSERT_GREATER_OR_EQUAL_HEX32(v0, *p1); + TEST_ASSERT_GREATER_OR_EQUAL_HEX32(*p0, *p1); + TEST_ASSERT_GREATER_OR_EQUAL_HEX32(v0, v2); + TEST_ASSERT_GREATER_OR_EQUAL_HEX32(*p0, v2); + TEST_ASSERT_GREATER_OR_EQUAL_HEX32(v0, *p2); + TEST_ASSERT_GREATER_OR_EQUAL_HEX32(*p0, *p2); +} + +void testNotGreaterOrEqualHEX32(void) +{ + EXPECT_ABORT_BEGIN + TEST_ASSERT_GREATER_OR_EQUAL_HEX32(0xFFFFFFFF, 0x00); + VERIFY_FAILS_END +} + +/*-----------------*/ + +void testLessThan(void) +{ + UNITY_INT v0, v1; + UNITY_INT *p0, *p1; + + v0 = 0; + v1 = -1; + p0 = &v0; + p1 = &v1; + + TEST_ASSERT_LESS_THAN(v0, v1); + TEST_ASSERT_LESS_THAN(*p0, v1); + TEST_ASSERT_LESS_THAN(v0, *p1); + TEST_ASSERT_LESS_THAN(*p0, *p1); +} + +void testNotLessThan(void) +{ + EXPECT_ABORT_BEGIN + TEST_ASSERT_LESS_THAN(0, 1); + VERIFY_FAILS_END +} + +void testLessThanINT(void) +{ + UNITY_INT v0, v1; + UNITY_INT *p0, *p1; + + v0 = 3334; + v1 = 302; + p0 = &v0; + p1 = &v1; + + TEST_ASSERT_LESS_THAN_INT(v0, v1); + TEST_ASSERT_LESS_THAN_INT(*p0, v1); + TEST_ASSERT_LESS_THAN_INT(v0, *p1); + TEST_ASSERT_LESS_THAN_INT(*p0, *p1); +} + +void testNotLessThanINT(void) +{ + EXPECT_ABORT_BEGIN + TEST_ASSERT_LESS_THAN_INT(302, 3334); + VERIFY_FAILS_END +} + +void testLessThanINT8(void) +{ + UNITY_INT8 v0, v1; + UNITY_INT8 *p0, *p1; + + v0 = 127; + v1 = -128; + p0 = &v0; + p1 = &v1; + + TEST_ASSERT_LESS_THAN_INT8(v0, v1); + TEST_ASSERT_LESS_THAN_INT8(*p0, v1); + TEST_ASSERT_LESS_THAN_INT8(v0, *p1); + TEST_ASSERT_LESS_THAN_INT8(*p0, *p1); +} + +void testNotLessThanINT8(void) +{ + EXPECT_ABORT_BEGIN + TEST_ASSERT_LESS_THAN_INT8(-128, 127); + VERIFY_FAILS_END +} + +void testLessThanCHAR(void) +{ + char v0, v1; + char *p0, *p1; + + v0 = 127; + v1 = -128; + p0 = &v0; + p1 = &v1; + + TEST_ASSERT_LESS_THAN_CHAR(v0, v1); + TEST_ASSERT_LESS_THAN_CHAR(*p0, v1); + TEST_ASSERT_LESS_THAN_CHAR(v0, *p1); + TEST_ASSERT_LESS_THAN_CHAR(*p0, *p1); +} + +void testNotLessThanCHAR(void) +{ + EXPECT_ABORT_BEGIN + TEST_ASSERT_LESS_THAN_CHAR(-128, 127); + VERIFY_FAILS_END +} + +void testLessThanINT16(void) +{ + UNITY_INT16 v0, v1; + UNITY_INT16 *p0, *p1; + + v0 = 32767; + v1 = -32768; + p0 = &v0; + p1 = &v1; + + TEST_ASSERT_LESS_THAN_INT16(v0, v1); + TEST_ASSERT_LESS_THAN_INT16(*p0, v1); + TEST_ASSERT_LESS_THAN_INT16(v0, *p1); + TEST_ASSERT_LESS_THAN_INT16(*p0, *p1); +} + +void testNotLessThanINT16(void) +{ + EXPECT_ABORT_BEGIN + TEST_ASSERT_LESS_THAN_INT16(-32768, 32767); + VERIFY_FAILS_END +} + +void testLessThanINT32(void) +{ + UNITY_INT32 v0, v1; + UNITY_INT32 *p0, *p1; + + v0 = 214783647; + v1 = -214783648; + p0 = &v0; + p1 = &v1; + + TEST_ASSERT_LESS_THAN_INT32(v0, v1); + TEST_ASSERT_LESS_THAN_INT32(*p0, v1); + TEST_ASSERT_LESS_THAN_INT32(v0, *p1); + TEST_ASSERT_LESS_THAN_INT32(*p0, *p1); +} + +void testNotLessThanINT32(void) +{ + EXPECT_ABORT_BEGIN + TEST_ASSERT_LESS_THAN_INT32(-214783648, 214783647); + VERIFY_FAILS_END +} + +void testLessThanUINT(void) +{ + UNITY_UINT v0, v1; + UNITY_UINT *p0, *p1; + + v0 = 1; + v1 = 0; + p0 = &v0; + p1 = &v1; + + TEST_ASSERT_LESS_THAN_UINT(v0, v1); + TEST_ASSERT_LESS_THAN_UINT(*p0, v1); + TEST_ASSERT_LESS_THAN_UINT(v0, *p1); + TEST_ASSERT_LESS_THAN_UINT(*p0, *p1); +} + +void testNotLessThanUINT(void) +{ + EXPECT_ABORT_BEGIN + TEST_ASSERT_LESS_THAN_UINT(0, 1); + VERIFY_FAILS_END +} + +void testLessThanUINT8(void) +{ + UNITY_UINT8 v0, v1; + UNITY_UINT8 *p0, *p1; + + v0 = 255; + v1 = 0; + p0 = &v0; + p1 = &v1; + + TEST_ASSERT_LESS_THAN_UINT8(v0, v1); + TEST_ASSERT_LESS_THAN_UINT8(*p0, v1); + TEST_ASSERT_LESS_THAN_UINT8(v0, *p1); + TEST_ASSERT_LESS_THAN_UINT8(*p0, *p1); +} + +void testNotLessThanUINT8(void) +{ + EXPECT_ABORT_BEGIN + TEST_ASSERT_LESS_THAN_UINT8(0, 255); + VERIFY_FAILS_END +} + +void testLessThanUINT16(void) +{ + UNITY_UINT16 v0, v1; + UNITY_UINT16 *p0, *p1; + + v0 = 65535; + v1 = 0; + p0 = &v0; + p1 = &v1; + + TEST_ASSERT_LESS_THAN_UINT16(v0, v1); + TEST_ASSERT_LESS_THAN_UINT16(*p0, v1); + TEST_ASSERT_LESS_THAN_UINT16(v0, *p1); + TEST_ASSERT_LESS_THAN_UINT16(*p0, *p1); +} + +void testNotLessThanUINT16(void) +{ + EXPECT_ABORT_BEGIN + TEST_ASSERT_LESS_THAN_UINT16(0, 65535); + VERIFY_FAILS_END +} + +void testLessThanUINT32(void) +{ + UNITY_UINT32 v0, v1; + UNITY_UINT32 *p0, *p1; + + v0 = 4294967295u; + v1 = 0; + p0 = &v0; + p1 = &v1; + + TEST_ASSERT_LESS_THAN_UINT32(v0, v1); + TEST_ASSERT_LESS_THAN_UINT32(*p0, v1); + TEST_ASSERT_LESS_THAN_UINT32(v0, *p1); + TEST_ASSERT_LESS_THAN_UINT32(*p0, *p1); +} + +void testNotLessThanUINT32(void) +{ + EXPECT_ABORT_BEGIN + TEST_ASSERT_LESS_THAN_UINT32(0, 4294967295u); + VERIFY_FAILS_END +} + +void testLessThanHEX8(void) +{ + UNITY_UINT8 v0, v1; + UNITY_UINT8 *p0, *p1; + + v0 = 0xFF; + v1 = 0x00; + p0 = &v0; + p1 = &v1; + + TEST_ASSERT_LESS_THAN_HEX8(v0, v1); + TEST_ASSERT_LESS_THAN_HEX8(*p0, v1); + TEST_ASSERT_LESS_THAN_HEX8(v0, *p1); + TEST_ASSERT_LESS_THAN_HEX8(*p0, *p1); +} + +void testNotLessThanHEX8(void) +{ + EXPECT_ABORT_BEGIN + TEST_ASSERT_LESS_THAN_HEX8(0x00, 0xFF); + VERIFY_FAILS_END +} + +void testLessThanHEX16(void) +{ + UNITY_UINT16 v0, v1; + UNITY_UINT16 *p0, *p1; + + v0 = 0xFFFF; + v1 = 0x0000; + p0 = &v0; + p1 = &v1; + + TEST_ASSERT_LESS_THAN_HEX16(v0, v1); + TEST_ASSERT_LESS_THAN_HEX16(*p0, v1); + TEST_ASSERT_LESS_THAN_HEX16(v0, *p1); + TEST_ASSERT_LESS_THAN_HEX16(*p0, *p1); +} + +void testNotLessThanHEX16(void) +{ + EXPECT_ABORT_BEGIN + TEST_ASSERT_LESS_THAN_HEX16(0x0000, 0xFFFF); + VERIFY_FAILS_END +} + +void testLessThanHEX32(void) +{ + UNITY_UINT32 v0, v1; + UNITY_UINT32 *p0, *p1; + + v0 = 0xFFFFFFFF; + v1 = 0x00000000; + p0 = &v0; + p1 = &v1; + + TEST_ASSERT_LESS_THAN_HEX32(v0, v1); + TEST_ASSERT_LESS_THAN_HEX32(*p0, v1); + TEST_ASSERT_LESS_THAN_HEX32(v0, *p1); + TEST_ASSERT_LESS_THAN_HEX32(*p0, *p1); +} + +void testNotLessThanHEX32(void) +{ + EXPECT_ABORT_BEGIN + TEST_ASSERT_LESS_THAN_HEX32(0x00000000, 0xFFFFFFFF); + VERIFY_FAILS_END +} + +void testLessOrEqual(void) +{ + UNITY_INT v0, v1, v2; + UNITY_INT *p0, *p1, *p2; + + v0 = 0; + v1 = -1; + v2 = 0; + p0 = &v0; + p1 = &v1; + p2 = &v2; + + TEST_ASSERT_LESS_OR_EQUAL(v0, v1); + TEST_ASSERT_LESS_OR_EQUAL(*p0, v1); + TEST_ASSERT_LESS_OR_EQUAL(v0, *p1); + TEST_ASSERT_LESS_OR_EQUAL(*p0, *p1); + TEST_ASSERT_LESS_OR_EQUAL(v0, v2); + TEST_ASSERT_LESS_OR_EQUAL(*p0, v2); + TEST_ASSERT_LESS_OR_EQUAL(v0, *p2); + TEST_ASSERT_LESS_OR_EQUAL(*p0, *p2); +} + +void testNotLessOrEqual(void) +{ + EXPECT_ABORT_BEGIN + TEST_ASSERT_LESS_OR_EQUAL(0, 1); + VERIFY_FAILS_END +} + +void testLessOrEqualINT(void) +{ + UNITY_INT v0, v1, v2; + UNITY_INT *p0, *p1, *p2; + + v0 = 3334; + v1 = 302; + v2 = 3334; + p0 = &v0; + p1 = &v1; + p2 = &v2; + + TEST_ASSERT_LESS_OR_EQUAL_INT(v0, v1); + TEST_ASSERT_LESS_OR_EQUAL_INT(*p0, v1); + TEST_ASSERT_LESS_OR_EQUAL_INT(v0, *p1); + TEST_ASSERT_LESS_OR_EQUAL_INT(*p0, *p1); + TEST_ASSERT_LESS_OR_EQUAL_INT(v0, v2); + TEST_ASSERT_LESS_OR_EQUAL_INT(*p0, v2); + TEST_ASSERT_LESS_OR_EQUAL_INT(v0, *p2); + TEST_ASSERT_LESS_OR_EQUAL_INT(*p0, *p2); +} + +void testNotLessOrEqualINT(void) +{ + EXPECT_ABORT_BEGIN + TEST_ASSERT_LESS_OR_EQUAL_INT(302, 3334); + VERIFY_FAILS_END +} + +void testLessOrEqualINT8(void) +{ + UNITY_INT8 v0, v1, v2; + UNITY_INT8 *p0, *p1, *p2; + + v0 = 127; + v1 = -128; + v2 = 127; + p0 = &v0; + p1 = &v1; + p2 = &v2; + + TEST_ASSERT_LESS_OR_EQUAL_INT8(v0, v1); + TEST_ASSERT_LESS_OR_EQUAL_INT8(*p0, v1); + TEST_ASSERT_LESS_OR_EQUAL_INT8(v0, *p1); + TEST_ASSERT_LESS_OR_EQUAL_INT8(*p0, *p1); + TEST_ASSERT_LESS_OR_EQUAL_INT8(v0, v2); + TEST_ASSERT_LESS_OR_EQUAL_INT8(*p0, v2); + TEST_ASSERT_LESS_OR_EQUAL_INT8(v0, *p2); + TEST_ASSERT_LESS_OR_EQUAL_INT8(*p0, *p2); +} + +void testNotLessOrEqualINT8(void) +{ + EXPECT_ABORT_BEGIN + TEST_ASSERT_LESS_OR_EQUAL_INT8(-128, 127); + VERIFY_FAILS_END +} + +void testLessOrEqualCHAR(void) +{ + char v0, v1, v2; + char *p0, *p1, *p2; + + v0 = 127; + v1 = -128; + v2 = 127; + p0 = &v0; + p1 = &v1; + p2 = &v2; + + TEST_ASSERT_LESS_OR_EQUAL_CHAR(v0, v1); + TEST_ASSERT_LESS_OR_EQUAL_CHAR(*p0, v1); + TEST_ASSERT_LESS_OR_EQUAL_CHAR(v0, *p1); + TEST_ASSERT_LESS_OR_EQUAL_CHAR(*p0, *p1); + TEST_ASSERT_LESS_OR_EQUAL_CHAR(v0, v2); + TEST_ASSERT_LESS_OR_EQUAL_CHAR(*p0, v2); + TEST_ASSERT_LESS_OR_EQUAL_CHAR(v0, *p2); + TEST_ASSERT_LESS_OR_EQUAL_CHAR(*p0, *p2); +} + +void testNotLessOrEqualCHAR(void) +{ + EXPECT_ABORT_BEGIN + TEST_ASSERT_LESS_OR_EQUAL_CHAR(-128, 127); + VERIFY_FAILS_END +} + +void testLessOrEqualINT16(void) +{ + UNITY_INT16 v0, v1, v2; + UNITY_INT16 *p0, *p1, *p2; + + v0 = 32767; + v1 = -32768; + v2 = 32767; + p0 = &v0; + p1 = &v1; + p2 = &v2; + + TEST_ASSERT_LESS_OR_EQUAL_INT16(v0, v1); + TEST_ASSERT_LESS_OR_EQUAL_INT16(*p0, v1); + TEST_ASSERT_LESS_OR_EQUAL_INT16(v0, *p1); + TEST_ASSERT_LESS_OR_EQUAL_INT16(*p0, *p1); + TEST_ASSERT_LESS_OR_EQUAL_INT16(v0, v2); + TEST_ASSERT_LESS_OR_EQUAL_INT16(*p0, v2); + TEST_ASSERT_LESS_OR_EQUAL_INT16(v0, *p2); + TEST_ASSERT_LESS_OR_EQUAL_INT16(*p0, *p2); +} + +void testNotLessOrEqualINT16(void) +{ + EXPECT_ABORT_BEGIN + TEST_ASSERT_LESS_OR_EQUAL_INT16(-32768, 32767); + VERIFY_FAILS_END +} + +void testLessOrEqualINT32(void) +{ + UNITY_INT32 v0, v1, v2; + UNITY_INT32 *p0, *p1, *p2; + + v0 = 214783647; + v1 = -214783648; + v2 = 214783647; + p0 = &v0; + p1 = &v1; + p2 = &v2; + + TEST_ASSERT_LESS_OR_EQUAL_INT32(v0, v1); + TEST_ASSERT_LESS_OR_EQUAL_INT32(*p0, v1); + TEST_ASSERT_LESS_OR_EQUAL_INT32(v0, *p1); + TEST_ASSERT_LESS_OR_EQUAL_INT32(*p0, *p1); + TEST_ASSERT_LESS_OR_EQUAL_INT32(v0, v2); + TEST_ASSERT_LESS_OR_EQUAL_INT32(*p0, v2); + TEST_ASSERT_LESS_OR_EQUAL_INT32(v0, *p2); + TEST_ASSERT_LESS_OR_EQUAL_INT32(*p0, *p2); +} + +void testNotLessOrEqualINT32(void) +{ + EXPECT_ABORT_BEGIN + TEST_ASSERT_LESS_OR_EQUAL_INT32(-214783648, 214783647); + VERIFY_FAILS_END +} + +void testLessOrEqualUINT(void) +{ + UNITY_UINT v0, v1, v2; + UNITY_UINT *p0, *p1, *p2; + + v0 = 1; + v1 = 0; + v2 = 1; + p0 = &v0; + p1 = &v1; + p2 = &v2; + + TEST_ASSERT_LESS_OR_EQUAL_UINT(v0, v1); + TEST_ASSERT_LESS_OR_EQUAL_UINT(*p0, v1); + TEST_ASSERT_LESS_OR_EQUAL_UINT(v0, *p1); + TEST_ASSERT_LESS_OR_EQUAL_UINT(*p0, *p1); + TEST_ASSERT_LESS_OR_EQUAL_UINT(v0, v2); + TEST_ASSERT_LESS_OR_EQUAL_UINT(*p0, v2); + TEST_ASSERT_LESS_OR_EQUAL_UINT(v0, *p2); + TEST_ASSERT_LESS_OR_EQUAL_UINT(*p0, *p2); +} + +void testNotLessOrEqualUINT(void) +{ + EXPECT_ABORT_BEGIN + TEST_ASSERT_LESS_OR_EQUAL_UINT(0, 1); + VERIFY_FAILS_END +} + +void testLessOrEqualUINT8(void) +{ + UNITY_UINT8 v0, v1, v2; + UNITY_UINT8 *p0, *p1, *p2; + + v0 = 255; + v1 = 0; + v2 = 255; + p0 = &v0; + p1 = &v1; + p2 = &v2; + + TEST_ASSERT_LESS_OR_EQUAL_UINT8(v0, v1); + TEST_ASSERT_LESS_OR_EQUAL_UINT8(*p0, v1); + TEST_ASSERT_LESS_OR_EQUAL_UINT8(v0, *p1); + TEST_ASSERT_LESS_OR_EQUAL_UINT8(*p0, *p1); + TEST_ASSERT_LESS_OR_EQUAL_UINT8(v0, v2); + TEST_ASSERT_LESS_OR_EQUAL_UINT8(*p0, v2); + TEST_ASSERT_LESS_OR_EQUAL_UINT8(v0, *p2); + TEST_ASSERT_LESS_OR_EQUAL_UINT8(*p0, *p2); +} + +void testNotLessOrEqualUINT8(void) +{ + EXPECT_ABORT_BEGIN + TEST_ASSERT_LESS_OR_EQUAL_UINT8(0, 255); + VERIFY_FAILS_END +} + +void testLessOrEqualUINT16(void) +{ + UNITY_UINT16 v0, v1, v2; + UNITY_UINT16 *p0, *p1, *p2; + + v0 = 65535; + v1 = 0; + v2 = 65535; + p0 = &v0; + p1 = &v1; + p2 = &v2; + + TEST_ASSERT_LESS_OR_EQUAL_UINT16(v0, v1); + TEST_ASSERT_LESS_OR_EQUAL_UINT16(*p0, v1); + TEST_ASSERT_LESS_OR_EQUAL_UINT16(v0, *p1); + TEST_ASSERT_LESS_OR_EQUAL_UINT16(*p0, *p1); + TEST_ASSERT_LESS_OR_EQUAL_UINT16(v0, v2); + TEST_ASSERT_LESS_OR_EQUAL_UINT16(*p0, v2); + TEST_ASSERT_LESS_OR_EQUAL_UINT16(v0, *p2); + TEST_ASSERT_LESS_OR_EQUAL_UINT16(*p0, *p2); +} + +void testNotLessOrEqualUINT16(void) +{ + EXPECT_ABORT_BEGIN + TEST_ASSERT_LESS_OR_EQUAL_UINT16(0, 65535); + VERIFY_FAILS_END +} + +void testLessOrEqualUINT32(void) +{ + UNITY_UINT32 v0, v1, v2; + UNITY_UINT32 *p0, *p1, *p2; + + v0 = 4294967295u; + v1 = 0; + v2 = 4294967295u; + p0 = &v0; + p1 = &v1; + p2 = &v2; + + TEST_ASSERT_LESS_OR_EQUAL_UINT32(v0, v1); + TEST_ASSERT_LESS_OR_EQUAL_UINT32(*p0, v1); + TEST_ASSERT_LESS_OR_EQUAL_UINT32(v0, *p1); + TEST_ASSERT_LESS_OR_EQUAL_UINT32(*p0, *p1); + TEST_ASSERT_LESS_OR_EQUAL_UINT32(v0, v2); + TEST_ASSERT_LESS_OR_EQUAL_UINT32(*p0, v2); + TEST_ASSERT_LESS_OR_EQUAL_UINT32(v0, *p2); + TEST_ASSERT_LESS_OR_EQUAL_UINT32(*p0, *p2); +} + +void testNotLessOrEqualUINT32(void) +{ + EXPECT_ABORT_BEGIN + TEST_ASSERT_LESS_OR_EQUAL_UINT32(0, 4294967295u); + VERIFY_FAILS_END +} + +void testLessOrEqualHEX8(void) +{ + UNITY_UINT8 v0, v1, v2; + UNITY_UINT8 *p0, *p1, *p2; + + v0 = 0xFF; + v1 = 0x00; + v2 = 0xFF; + p0 = &v0; + p1 = &v1; + p2 = &v2; + + TEST_ASSERT_LESS_OR_EQUAL_HEX8(v0, v1); + TEST_ASSERT_LESS_OR_EQUAL_HEX8(*p0, v1); + TEST_ASSERT_LESS_OR_EQUAL_HEX8(v0, *p1); + TEST_ASSERT_LESS_OR_EQUAL_HEX8(*p0, *p1); + TEST_ASSERT_LESS_OR_EQUAL_HEX8(v0, v2); + TEST_ASSERT_LESS_OR_EQUAL_HEX8(*p0, v2); + TEST_ASSERT_LESS_OR_EQUAL_HEX8(v0, *p2); + TEST_ASSERT_LESS_OR_EQUAL_HEX8(*p0, *p2); +} + +void testNotLessOrEqualHEX8(void) +{ + EXPECT_ABORT_BEGIN + TEST_ASSERT_LESS_OR_EQUAL_HEX8(0x00, 0xFF); + VERIFY_FAILS_END +} + +void testLessOrEqualHEX16(void) +{ + UNITY_UINT16 v0, v1, v2; + UNITY_UINT16 *p0, *p1, *p2; + + v0 = 0xFFFF; + v1 = 0x0000; + v2 = 0xFFFF; + p0 = &v0; + p1 = &v1; + p2 = &v2; + + TEST_ASSERT_LESS_OR_EQUAL_HEX16(v0, v1); + TEST_ASSERT_LESS_OR_EQUAL_HEX16(*p0, v1); + TEST_ASSERT_LESS_OR_EQUAL_HEX16(v0, *p1); + TEST_ASSERT_LESS_OR_EQUAL_HEX16(*p0, *p1); + TEST_ASSERT_LESS_OR_EQUAL_HEX16(v0, v2); + TEST_ASSERT_LESS_OR_EQUAL_HEX16(*p0, v2); + TEST_ASSERT_LESS_OR_EQUAL_HEX16(v0, *p2); + TEST_ASSERT_LESS_OR_EQUAL_HEX16(*p0, *p2); +} + +void testNotLessOrEqualHEX16(void) +{ + EXPECT_ABORT_BEGIN + TEST_ASSERT_LESS_OR_EQUAL_HEX16(0x0000, 0xFFFF); + VERIFY_FAILS_END +} + +void testLessOrEqualHEX32(void) +{ + UNITY_UINT32 v0, v1, v2; + UNITY_UINT32 *p0, *p1, *p2; + + v0 = 0xFFFFFFFF; + v1 = 0x00000000; + v2 = 0xFFFFFFFF; + p0 = &v0; + p1 = &v1; + p2 = &v2; + + TEST_ASSERT_LESS_OR_EQUAL_HEX32(v0, v1); + TEST_ASSERT_LESS_OR_EQUAL_HEX32(*p0, v1); + TEST_ASSERT_LESS_OR_EQUAL_HEX32(v0, *p1); + TEST_ASSERT_LESS_OR_EQUAL_HEX32(*p0, *p1); + TEST_ASSERT_LESS_OR_EQUAL_HEX32(v0, v2); + TEST_ASSERT_LESS_OR_EQUAL_HEX32(*p0, v2); + TEST_ASSERT_LESS_OR_EQUAL_HEX32(v0, *p2); + TEST_ASSERT_LESS_OR_EQUAL_HEX32(*p0, *p2); +} + +void testNotLessOrEqualHEX32(void) +{ + EXPECT_ABORT_BEGIN + TEST_ASSERT_LESS_OR_EQUAL_HEX32(0x00000000, 0xFFFFFFFF); + VERIFY_FAILS_END +} + +void testHexPrintsUpToMaxNumberOfNibbles(void) +{ +#ifndef USING_OUTPUT_SPY + TEST_IGNORE(); +#else + startPutcharSpy(); + UnityPrintNumberHex(0xBEE, 21); + endPutcharSpy(); +#ifdef UNITY_SUPPORT_64 + TEST_ASSERT_EQUAL_INT(16, strlen(getBufferPutcharSpy())); +#else + TEST_ASSERT_EQUAL_INT( 8, strlen(getBufferPutcharSpy())); +#endif +#endif +} + +#define TEST_ASSERT_EQUAL_PRINT_NUMBERS(expected, actual) { \ + startPutcharSpy(); UnityPrintNumber((actual)); endPutcharSpy(); \ + TEST_ASSERT_EQUAL_STRING((expected), getBufferPutcharSpy()); \ + } + +#define TEST_ASSERT_EQUAL_PRINT_UNSIGNED_NUMBERS(expected, actual) { \ + startPutcharSpy(); UnityPrintNumberUnsigned((actual)); endPutcharSpy(); \ + TEST_ASSERT_EQUAL_STRING((expected), getBufferPutcharSpy()); \ + } + +void testPrintNumbers32(void) +{ +#ifndef USING_OUTPUT_SPY + TEST_IGNORE_MESSAGE("Compile with '-D UNITY_OUTPUT_CHAR=putcharSpy' to enable print testing"); +#else + TEST_ASSERT_EQUAL_PRINT_NUMBERS("0", 0); + TEST_ASSERT_EQUAL_PRINT_NUMBERS("1", 1); + TEST_ASSERT_EQUAL_PRINT_NUMBERS("-1", -1); + TEST_ASSERT_EQUAL_PRINT_NUMBERS("2000000000", 2000000000); + TEST_ASSERT_EQUAL_PRINT_NUMBERS("-2147483648", (UNITY_INT32)0x80000000); + TEST_ASSERT_EQUAL_PRINT_NUMBERS("-1", (UNITY_INT32)0xFFFFFFFF); +#endif +} + +void testPrintNumbersUnsigned32(void) +{ +#ifndef USING_OUTPUT_SPY + TEST_IGNORE(); +#else + TEST_ASSERT_EQUAL_PRINT_UNSIGNED_NUMBERS("0", 0); + TEST_ASSERT_EQUAL_PRINT_UNSIGNED_NUMBERS("1", 1); + TEST_ASSERT_EQUAL_PRINT_UNSIGNED_NUMBERS("1500000000", 1500000000); + TEST_ASSERT_EQUAL_PRINT_UNSIGNED_NUMBERS("2147483648", (UNITY_UINT32)0x80000000); + TEST_ASSERT_EQUAL_PRINT_UNSIGNED_NUMBERS("4294967295", (UNITY_UINT32)0xFFFFFFFF); +#endif +} diff --git a/test/tests/test_unity_integers_64.c b/test/tests/test_unity_integers_64.c new file mode 100644 index 00000000..e67be84d --- /dev/null +++ b/test/tests/test_unity_integers_64.c @@ -0,0 +1,770 @@ +/* ========================================== + Unity Project - A Test Framework for C + Copyright (c) 2007 Mike Karlesky, Mark VanderVoord, Greg Williams + [Released under MIT License. Please refer to license.txt for details] +========================================== */ + +#include "unity.h" +#define TEST_INSTANCES +#include "self_assessment_utils.h" + +void setUp(void) +{ + SetToOneToFailInTearDown = 0; + SetToOneMeanWeAlreadyCheckedThisGuy = 0; +} + +void tearDown(void) +{ + endPutcharSpy(); /* Stop suppressing test output */ + if (SetToOneToFailInTearDown == 1) + { + /* These will be skipped internally if already failed/ignored */ + TEST_FAIL_MESSAGE("<= Failed in tearDown"); + TEST_IGNORE_MESSAGE("<= Ignored in tearDown"); + } + if ((SetToOneMeanWeAlreadyCheckedThisGuy == 0) && (Unity.CurrentTestFailed > 0)) + { + UnityPrint(": [[[[ Test Should Have Passed But Did Not ]]]]"); + UNITY_OUTPUT_CHAR('\n'); + } +} + +void testInt64ArrayWithinDelta(void) +{ +#ifndef UNITY_SUPPORT_64 + TEST_IGNORE(); +#else + UNITY_INT64 expected[] = {12345000, -12344995, 12345005}; + UNITY_INT64 actualSmallDelta[] = {12345001, -12344996, 12345005}; + UNITY_INT64 actualBigDelta[] = {12345101, -12344896, 12345055}; + + TEST_ASSERT_INT64_ARRAY_WITHIN(1, expected, actualSmallDelta, 3); + TEST_ASSERT_INT64_ARRAY_WITHIN(110, expected, actualBigDelta, 3); +#endif +} + +void testInt64ArrayWithinDeltaAndMessage(void) +{ +#ifndef UNITY_SUPPORT_64 + TEST_IGNORE(); +#else + UNITY_INT64 expected[] = {12345000, -12344995, 12345005}; + UNITY_INT64 actualSmallDelta[] = {12345001, -12344996, 12345005}; + UNITY_INT64 actualBigDelta[] = {12345101, -12344896, 12345055}; + + TEST_ASSERT_INT64_ARRAY_WITHIN_MESSAGE(1, expected, actualSmallDelta, 3, "Custom Message."); + TEST_ASSERT_INT64_ARRAY_WITHIN_MESSAGE(110, expected, actualBigDelta, 3, "Custom Message."); +#endif +} + +void tesUInt64ArrayNotWithinDelta(void) +{ +#ifndef UNITY_SUPPORT_64 + TEST_IGNORE(); +#else + UNITY_INT64 expected[] = {12345000, -12344995, 12345005}; + UNITY_INT64 actualBigDelta[] = {12345101, -12344896, 12345055}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_UINT64_ARRAY_WITHIN(1, expected, actualBigDelta, 3); + VERIFY_FAILS_END +#endif +} + +void testInt64ArrayNotWithinDeltaAndMessage(void) +{ +#ifndef UNITY_SUPPORT_64 + TEST_IGNORE(); +#else + UNITY_INT64 expected[] = {12345000, -12344995, 12345005}; + UNITY_INT64 actualBigDelta[] = {12345101, -12344896, 12345055}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_INT64_ARRAY_WITHIN_MESSAGE(1, expected, actualBigDelta, 3, "Custom Message."); + VERIFY_FAILS_END +#endif +} + +void testInt64ArrayWithinDeltaPointless(void) +{ +#ifndef UNITY_SUPPORT_64 + TEST_IGNORE(); +#else + UNITY_INT64 expected[] = {12345000, -12344995, 12345005}; + UNITY_INT64 actualBigDelta[] = {12345101, -12344896, 12345055}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_INT64_ARRAY_WITHIN(110, expected, actualBigDelta, 0); + VERIFY_FAILS_END +#endif +} + +void testInt64ArrayWithinDeltaPointlessAndMessage(void) +{ +#ifndef UNITY_SUPPORT_64 + TEST_IGNORE(); +#else + UNITY_INT64 expected[] = {12345000, -12344995, 12345005}; + UNITY_INT64 actualBigDelta[] = {12345101, -12344896, 12345055}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_INT64_ARRAY_WITHIN_MESSAGE(110, expected, actualBigDelta, 0, "Custom Message."); + VERIFY_FAILS_END +#endif +} + +void testInt64ArrayWithinDeltaExpectedNull(void) +{ +#ifndef UNITY_SUPPORT_64 + TEST_IGNORE(); +#else + UNITY_INT64 actualBigDelta[] = {12345101, -12344896, 12345055}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_INT64_ARRAY_WITHIN(110, NULL, actualBigDelta, 3); + VERIFY_FAILS_END +#endif +} + +void testInt64ArrayWithinDeltaExpectedNullAndMessage(void) +{ +#ifndef UNITY_SUPPORT_64 + TEST_IGNORE(); +#else + UNITY_INT64 actualBigDelta[] = {12345101, -12344896, 12345055}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_INT64_ARRAY_WITHIN_MESSAGE(110, NULL, actualBigDelta, 3, "Custom Message."); + VERIFY_FAILS_END +#endif +} + +void testInt64ArrayWithinDeltaActualNull(void) +{ +#ifndef UNITY_SUPPORT_64 + TEST_IGNORE(); +#else + UNITY_INT64 expected[] = {12345000, -12344995, 12345005}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_INT64_ARRAY_WITHIN(110, expected, NULL, 3); + VERIFY_FAILS_END +#endif +} + +void testInt64ArrayWithinDeltaActualNullAndMessage(void) +{ +#ifndef UNITY_SUPPORT_64 + TEST_IGNORE(); +#else + UNITY_INT64 expected[] = {12345000, -12344995, 12345005}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_INT64_ARRAY_WITHIN_MESSAGE(110, expected, NULL, 3, "Custom Message."); + VERIFY_FAILS_END +#endif +} + +void testInt64ArrayWithinDeltaSamePointer(void) +{ +#ifndef UNITY_SUPPORT_64 + TEST_IGNORE(); +#else + UNITY_INT64 expected[] = {12345000, -12344995, 12345005}; + + TEST_ASSERT_UINT64_ARRAY_WITHIN(110, expected, expected, 3); +#endif +} + +void testInt64ArrayWithinDeltaSamePointerAndMessage(void) +{ +#ifndef UNITY_SUPPORT_64 + TEST_IGNORE(); +#else + UNITY_INT64 expected[] = {12345000, -12344995, 12345005}; + + TEST_ASSERT_INT64_ARRAY_WITHIN_MESSAGE(110, expected, expected, 3, "Custom Message."); +#endif +} + +void testUInt64ArrayWithinDelta(void) +{ +#ifndef UNITY_SUPPORT_64 + TEST_IGNORE(); +#else + UNITY_UINT64 expected[] = {12345000, 12344995, 12345005}; + UNITY_UINT64 actualSmallDelta[] = {12345001, 12344996, 12345005}; + UNITY_UINT64 actualBigDelta[] = {12345101, 12344896, 12345055}; + + TEST_ASSERT_UINT64_ARRAY_WITHIN(1, expected, actualSmallDelta, 3); + TEST_ASSERT_UINT64_ARRAY_WITHIN(110, expected, actualBigDelta, 3); +#endif +} + +void testUInt64ArrayWithinDeltaAndMessage(void) +{ +#ifndef UNITY_SUPPORT_64 + TEST_IGNORE(); +#else + UNITY_UINT64 expected[] = {12345000, 12344995, 12345005}; + UNITY_UINT64 actualSmallDelta[] = {12345001, 12344996, 12345005}; + UNITY_UINT64 actualBigDelta[] = {12345101, 12344896, 12345055}; + + TEST_ASSERT_UINT64_ARRAY_WITHIN_MESSAGE(1, expected, actualSmallDelta, 3, "Custom Message."); + TEST_ASSERT_UINT64_ARRAY_WITHIN_MESSAGE(110, expected, actualBigDelta, 3, "Custom Message."); +#endif +} + +void testUInt64ArrayNotWithinDelta(void) +{ +#ifndef UNITY_SUPPORT_64 + TEST_IGNORE(); +#else + UNITY_UINT64 expected[] = {12345000, 12344995, 12345005}; + UNITY_UINT64 actualBigDelta[] = {12345101, 12344896, 12345055}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_UINT64_ARRAY_WITHIN(1, expected, actualBigDelta, 3); + VERIFY_FAILS_END +#endif +} + +void testUInt64ArrayNotWithinDeltaAndMessage(void) +{ +#ifndef UNITY_SUPPORT_64 + TEST_IGNORE(); +#else + UNITY_UINT64 expected[] = {12345000, 12344995, 12345005}; + UNITY_UINT64 actualBigDelta[] = {12345101, 12344896, 12345055}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_UINT64_ARRAY_WITHIN_MESSAGE(1, expected, actualBigDelta, 3, "Custom Message."); + VERIFY_FAILS_END +#endif +} + +void testUInt64ArrayWithinDeltaPointless(void) +{ +#ifndef UNITY_SUPPORT_64 + TEST_IGNORE(); +#else + UNITY_UINT64 expected[] = {12345000, 12344995, 12345005}; + UNITY_UINT64 actualBigDelta[] = {12345101, 12344896, 12345055}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_UINT64_ARRAY_WITHIN(110, expected, actualBigDelta, 0); + VERIFY_FAILS_END +#endif +} + +void testUInt64ArrayWithinDeltaPointlessAndMessage(void) +{ +#ifndef UNITY_SUPPORT_64 + TEST_IGNORE(); +#else + UNITY_UINT64 expected[] = {12345000, 12344995, 12345005}; + UNITY_UINT64 actualBigDelta[] = {12345101, 12344896, 12345055}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_UINT64_ARRAY_WITHIN_MESSAGE(110, expected, actualBigDelta, 0, "Custom Message."); + VERIFY_FAILS_END +#endif +} + +void testUInt64ArrayWithinDeltaExpectedNull(void) +{ +#ifndef UNITY_SUPPORT_64 + TEST_IGNORE(); +#else + UNITY_UINT64 actualBigDelta[] = {12345101, 12344896, 12345055}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_UINT64_ARRAY_WITHIN(110, NULL, actualBigDelta, 3); + VERIFY_FAILS_END +#endif +} + +void testUInt64ArrayWithinDeltaExpectedNullAndMessage(void) +{ +#ifndef UNITY_SUPPORT_64 + TEST_IGNORE(); +#else + UNITY_UINT64 actualBigDelta[] = {12345101, 12344896, 12345055}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_UINT64_ARRAY_WITHIN_MESSAGE(110, NULL, actualBigDelta, 3, "Custom Message."); + VERIFY_FAILS_END +#endif +} + +void testUInt64ArrayWithinDeltaActualNull(void) +{ +#ifndef UNITY_SUPPORT_64 + TEST_IGNORE(); +#else + UNITY_UINT64 expected[] = {12345000, 12344995, 12345005}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_UINT64_ARRAY_WITHIN(110, expected, NULL, 3); + VERIFY_FAILS_END +#endif +} + +void testUInt64ArrayWithinDeltaActualNullAndMessage(void) +{ +#ifndef UNITY_SUPPORT_64 + TEST_IGNORE(); +#else + UNITY_UINT64 expected[] = {12345000, 12344995, 12345005}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_UINT64_ARRAY_WITHIN_MESSAGE(110, expected, NULL, 3, "Custom Message."); + VERIFY_FAILS_END +#endif +} + +void testUInt64ArrayWithinDeltaSamePointer(void) +{ +#ifndef UNITY_SUPPORT_64 + TEST_IGNORE(); +#else + UNITY_UINT64 expected[] = {12345000, 12344995, 12345005}; + + TEST_ASSERT_UINT64_ARRAY_WITHIN(110, expected, expected, 3); +#endif +} + +void testUInt64ArrayWithinDeltaSamePointerAndMessage(void) +{ +#ifndef UNITY_SUPPORT_64 + TEST_IGNORE(); +#else + UNITY_UINT64 expected[] = {12345000, 12344995, 12345005}; + + TEST_ASSERT_UINT64_ARRAY_WITHIN_MESSAGE(110, expected, expected, 3, "Custom Message."); +#endif +} + +void testHEX64ArrayWithinDelta(void) +{ +#ifndef UNITY_SUPPORT_64 + TEST_IGNORE(); +#else + UNITY_UINT64 expected[] = {0xABCD123400000000, 0xABCD112200000000, 0xABCD127700000000}; + UNITY_UINT64 actualSmallDelta[] = {0xABCD123500000000, 0xABCD112100000000, 0xABCD127700000000}; + UNITY_UINT64 actualBigDelta[] = {0xABCD126700000000, 0xABCD118800000000, 0xABCD12AC00000000}; + + TEST_ASSERT_HEX64_ARRAY_WITHIN(0x100000000, expected, actualSmallDelta, 3); + TEST_ASSERT_HEX64_ARRAY_WITHIN(0x6E00000000, expected, actualBigDelta, 3); +#endif +} + +void testHEX64ArrayWithinDeltaAndMessage(void) +{ +#ifndef UNITY_SUPPORT_64 + TEST_IGNORE(); +#else + UNITY_UINT64 expected[] = {0xABCD123400000000, 0xABCD112200000000, 0xABCD127700000000}; + UNITY_UINT64 actualSmallDelta[] = {0xABCD123500000000, 0xABCD112100000000, 0xABCD127700000000}; + UNITY_UINT64 actualBigDelta[] = {0xABCD126700000000, 0xABCD118800000000, 0xABCD12AC00000000}; + + TEST_ASSERT_HEX64_ARRAY_WITHIN_MESSAGE(0x100000000, expected, actualSmallDelta, 3, "Custom Message."); + TEST_ASSERT_HEX64_ARRAY_WITHIN_MESSAGE(0x6E00000000, expected, actualBigDelta, 3, "Custom Message."); +#endif +} + +void testHEX64ArrayNotWithinDelta(void) +{ +#ifndef UNITY_SUPPORT_64 + TEST_IGNORE(); +#else + UNITY_UINT64 expected[] = {0xABCD123400000000, 0xABCD112200000000, 0xABCD127700000000}; + UNITY_UINT64 actualBigDelta[] = {0xABCD126700000000, 0xABCD118800000000, 0xABCD12AC00000000}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_HEX64_ARRAY_WITHIN(0x100000000, expected, actualBigDelta, 3); + VERIFY_FAILS_END +#endif +} + +void testHEX64ArrayNotWithinDeltaAndMessage(void) +{ +#ifndef UNITY_SUPPORT_64 + TEST_IGNORE(); +#else + UNITY_UINT64 expected[] = {0xABCD123400000000, 0xABCD112200000000, 0xABCD127700000000}; + UNITY_UINT64 actualBigDelta[] = {0xABCD126700000000, 0xABCD118800000000, 0xABCD12AC00000000}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_HEX64_ARRAY_WITHIN_MESSAGE(0x100000000, expected, actualBigDelta, 3, "Custom Message."); + VERIFY_FAILS_END +#endif +} + +void testHEX64ArrayWithinDeltaPointless(void) +{ +#ifndef UNITY_SUPPORT_64 + TEST_IGNORE(); +#else + UNITY_UINT64 expected[] = {0xABCD123400000000, 0xABCD112200000000, 0xABCD127700000000}; + UNITY_UINT64 actualBigDelta[] = {0xABCD126700000000, 0xABCD118800000000, 0xABCD12AC00000000}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_HEX64_ARRAY_WITHIN(0x6E00000000, expected, actualBigDelta, 0); + VERIFY_FAILS_END +#endif +} + +void testHEX64ArrayWithinDeltaPointlessAndMessage(void) +{ +#ifndef UNITY_SUPPORT_64 + TEST_IGNORE(); +#else + UNITY_UINT64 expected[] = {0xABCD123400000000, 0xABCD112200000000, 0xABCD127700000000}; + UNITY_UINT64 actualBigDelta[] = {0xABCD126700000000, 0xABCD118800000000, 0xABCD12AC00000000}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_HEX64_ARRAY_WITHIN_MESSAGE(0x6E00000000, expected, actualBigDelta, 0, "Custom Message."); + VERIFY_FAILS_END +#endif +} + +void testHEX64ArrayWithinDeltaExpectedNull(void) +{ +#ifndef UNITY_SUPPORT_64 + TEST_IGNORE(); +#else + UNITY_UINT64 actualBigDelta[] = {0xABCD126700000000, 0xABCD118800000000, 0xABCD12AC00000000}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_HEX64_ARRAY_WITHIN(0x6E00000000, NULL, actualBigDelta, 3); + VERIFY_FAILS_END +#endif +} + +void testHEX64ArrayWithinDeltaExpectedNullAndMessage(void) +{ +#ifndef UNITY_SUPPORT_64 + TEST_IGNORE(); +#else + UNITY_UINT64 actualBigDelta[] = {0xABCD126700000000, 0xABCD118800000000, 0xABCD12AC00000000}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_HEX64_ARRAY_WITHIN_MESSAGE(0x6E00000000, NULL, actualBigDelta, 3, "Custom Message."); + VERIFY_FAILS_END +#endif +} + +void testHEX64ArrayWithinDeltaActualNull(void) +{ +#ifndef UNITY_SUPPORT_64 + TEST_IGNORE(); +#else + UNITY_UINT64 expected[] = {0xABCD123400000000, 0xABCD112200000000, 0xABCD127700000000}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_HEX64_ARRAY_WITHIN(0x6E00000000, expected, NULL, 3); + VERIFY_FAILS_END +#endif +} + +void testHEX64ArrayWithinDeltaActualNullAndMessage(void) +{ +#ifndef UNITY_SUPPORT_64 + TEST_IGNORE(); +#else + UNITY_UINT64 expected[] = {0xABCD123400000000, 0xABCD112200000000, 0xABCD127700000000}; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_HEX64_ARRAY_WITHIN_MESSAGE(0x6E00000000, expected, NULL, 3, "Custom Message."); + VERIFY_FAILS_END +#endif +} + +void testHEX64ArrayWithinDeltaSamePointer(void) +{ +#ifndef UNITY_SUPPORT_64 + TEST_IGNORE(); +#else + UNITY_UINT64 expected[] = {0xABCD123400000000, 0xABCD112200000000, 0xABCD127700000000}; + + TEST_ASSERT_HEX64_ARRAY_WITHIN(0x6E00000000, expected, expected, 3); +#endif +} + +void testHEX64ArrayWithinDeltaSamePointerAndMessage(void) +{ +#ifndef UNITY_SUPPORT_64 + TEST_IGNORE(); +#else + UNITY_UINT64 expected[] = {0xABCD123400000000, 0xABCD112200000000, 0xABCD127700000000}; + + TEST_ASSERT_HEX64_ARRAY_WITHIN_MESSAGE(0x6E00000000, expected, expected, 3, "Custom Message."); +#endif +} + +void testEqualHex64s(void) +{ +#ifndef UNITY_SUPPORT_64 + TEST_IGNORE(); +#else + UNITY_UINT64 v0, v1; + UNITY_UINT64 *p0, *p1; + + v0 = 0x9876543201234567; + v1 = 0x9876543201234567; + p0 = &v0; + p1 = &v1; + + TEST_ASSERT_EQUAL_HEX64(0x9876543201234567, 0x9876543201234567); + TEST_ASSERT_EQUAL_HEX64(v0, v1); + TEST_ASSERT_EQUAL_HEX64(0x9876543201234567, v1); + TEST_ASSERT_EQUAL_HEX64(v0, 0x9876543201234567); + TEST_ASSERT_EQUAL_HEX64(*p0, v1); + TEST_ASSERT_EQUAL_HEX64(*p0, *p1); + TEST_ASSERT_EQUAL_HEX64(*p0, 0x9876543201234567); +#endif +} + +void testEqualUint64s(void) +{ +#ifndef UNITY_SUPPORT_64 + TEST_IGNORE(); +#else + UNITY_UINT64 v0, v1; + UNITY_UINT64 *p0, *p1; + + v0 = 0x9876543201234567; + v1 = 0x9876543201234567; + p0 = &v0; + p1 = &v1; + + TEST_ASSERT_EQUAL_UINT64(0x9876543201234567, 0x9876543201234567); + TEST_ASSERT_EQUAL_UINT64(v0, v1); + TEST_ASSERT_EQUAL_UINT64(0x9876543201234567, v1); + TEST_ASSERT_EQUAL_UINT64(v0, 0x9876543201234567); + TEST_ASSERT_EQUAL_UINT64(*p0, v1); + TEST_ASSERT_EQUAL_UINT64(*p0, *p1); + TEST_ASSERT_EQUAL_UINT64(*p0, 0x9876543201234567); +#endif +} + +void testEqualInt64s(void) +{ +#ifndef UNITY_SUPPORT_64 + TEST_IGNORE(); +#else + UNITY_INT64 v0, v1; + UNITY_INT64 *p0, *p1; + + v0 = (UNITY_INT64)0x9876543201234567; + v1 = (UNITY_INT64)0x9876543201234567; + p0 = &v0; + p1 = &v1; + + TEST_ASSERT_EQUAL_INT64(0x9876543201234567, 0x9876543201234567); + TEST_ASSERT_EQUAL_INT64(v0, v1); + TEST_ASSERT_EQUAL_INT64(0x9876543201234567, v1); + TEST_ASSERT_EQUAL_INT64(v0, 0x9876543201234567); + TEST_ASSERT_EQUAL_INT64(*p0, v1); + TEST_ASSERT_EQUAL_INT64(*p0, *p1); + TEST_ASSERT_EQUAL_INT64(*p0, 0x9876543201234567); +#endif +} + + +void testNotEqualHex64s(void) +{ +#ifndef UNITY_SUPPORT_64 + TEST_IGNORE(); +#else + UNITY_UINT64 v0, v1; + + v0 = 9000000000; + v1 = 9100000000; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_EQUAL_HEX64(v0, v1); + VERIFY_FAILS_END +#endif +} + +void testNotEqualUint64s(void) +{ +#ifndef UNITY_SUPPORT_64 + TEST_IGNORE(); +#else + UNITY_UINT64 v0, v1; + + v0 = 9000000000; + v1 = 9100000000; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_EQUAL_UINT64(v0, v1); + VERIFY_FAILS_END +#endif +} + +void testNotEqualInt64s(void) +{ +#ifndef UNITY_SUPPORT_64 + TEST_IGNORE(); +#else + UNITY_INT64 v0, v1; + + v0 = -9000000000; + v1 = 9100000000; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_EQUAL_INT64(v0, v1); + VERIFY_FAILS_END +#endif +} + +void testNotEqualHex64sIfSigned(void) +{ +#ifndef UNITY_SUPPORT_64 + TEST_IGNORE(); +#else + UNITY_INT64 v0, v1; + + v0 = -9000000000; + v1 = 9000000000; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_EQUAL_HEX64(v0, v1); + VERIFY_FAILS_END +#endif +} + +void testHEX64sWithinDelta(void) +{ +#ifndef UNITY_SUPPORT_64 + TEST_IGNORE(); +#else + TEST_ASSERT_HEX64_WITHIN(1, 0x7FFFFFFFFFFFFFFF,0x7FFFFFFFFFFFFFFE); + TEST_ASSERT_HEX64_WITHIN(5, 5000, 4996); + TEST_ASSERT_HEX64_WITHIN(5, 5000, 5005); +#endif +} + +void testHEX64sNotWithinDelta(void) +{ +#ifndef UNITY_SUPPORT_64 + TEST_IGNORE(); +#else + EXPECT_ABORT_BEGIN + TEST_ASSERT_HEX64_WITHIN(1, 0x7FFFFFFFFFFFFFFF, 0x7FFFFFFFFFFFFFFC); + VERIFY_FAILS_END +#endif +} + +void testHEX64sNotWithinDeltaEvenThoughASignedIntWouldPass(void) +{ +#ifndef UNITY_SUPPORT_64 + TEST_IGNORE(); +#else + EXPECT_ABORT_BEGIN + TEST_ASSERT_HEX64_WITHIN(5, 1, -1); + VERIFY_FAILS_END +#endif +} + +void testUINT64sWithinDelta(void) +{ +#ifndef UNITY_SUPPORT_64 + TEST_IGNORE(); +#else + TEST_ASSERT_UINT64_WITHIN(1, 0x7FFFFFFFFFFFFFFF,0x7FFFFFFFFFFFFFFE); + TEST_ASSERT_UINT64_WITHIN(5, 5000, 4996); + TEST_ASSERT_UINT64_WITHIN(5, 5000, 5005); +#endif +} + +void testUINT64sNotWithinDelta(void) +{ +#ifndef UNITY_SUPPORT_64 + TEST_IGNORE(); +#else + EXPECT_ABORT_BEGIN + TEST_ASSERT_UINT64_WITHIN(1, 0x7FFFFFFFFFFFFFFF, 0x7FFFFFFFFFFFFFFC); + VERIFY_FAILS_END +#endif +} + +void testUINT64sNotWithinDeltaEvenThoughASignedIntWouldPass(void) +{ +#ifndef UNITY_SUPPORT_64 + TEST_IGNORE(); +#else + EXPECT_ABORT_BEGIN + TEST_ASSERT_UINT64_WITHIN(5, 1, -1); + VERIFY_FAILS_END +#endif +} + +void testINT64sWithinDelta(void) +{ +#ifndef UNITY_SUPPORT_64 + TEST_IGNORE(); +#else + TEST_ASSERT_INT64_WITHIN(1, 0x7FFFFFFFFFFFFFFF,0x7FFFFFFFFFFFFFFE); + TEST_ASSERT_INT64_WITHIN(5, 5000, 4996); + TEST_ASSERT_INT64_WITHIN(5, 5000, 5005); +#endif +} + +void testINT64sNotWithinDelta(void) +{ +#ifndef UNITY_SUPPORT_64 + TEST_IGNORE(); +#else + EXPECT_ABORT_BEGIN + TEST_ASSERT_INT64_WITHIN(1, 0x7FFFFFFFFFFFFFFF, 0x7FFFFFFFFFFFFFFC); + VERIFY_FAILS_END +#endif +} + +void testINT64sNotWithinDeltaAndDifferenceOverflows(void) +{ +#ifndef UNITY_SUPPORT_64 + TEST_IGNORE(); +#else + EXPECT_ABORT_BEGIN + TEST_ASSERT_INT64_WITHIN(1, 0x8000000000000000, 0x7FFFFFFFFFFFFFFF); + VERIFY_FAILS_END +#endif +} + +void testPrintNumbersInt64(void) +{ +#ifndef UNITY_SUPPORT_64 + TEST_IGNORE(); +#else + #ifndef USING_OUTPUT_SPY + TEST_IGNORE(); + #else + TEST_ASSERT_EQUAL_PRINT_NUMBERS("0", 0); + TEST_ASSERT_EQUAL_PRINT_NUMBERS("10000000000", 10000000000); + TEST_ASSERT_EQUAL_PRINT_NUMBERS("-9223372036854775808", (UNITY_INT)0x8000000000000000); + TEST_ASSERT_EQUAL_PRINT_NUMBERS("-1", (UNITY_INT)0xFFFFFFFFFFFFFFFF); + #endif +#endif +} + +void testPrintNumbersUInt64(void) +{ +#ifndef UNITY_SUPPORT_64 + TEST_IGNORE(); +#else + #ifndef USING_OUTPUT_SPY + TEST_IGNORE(); + #else + TEST_ASSERT_EQUAL_PRINT_UNSIGNED_NUMBERS("0", 0); + TEST_ASSERT_EQUAL_PRINT_UNSIGNED_NUMBERS("70000000000", 70000000000); + TEST_ASSERT_EQUAL_PRINT_UNSIGNED_NUMBERS("9223372036854775808", (UNITY_UINT)0x8000000000000000); + TEST_ASSERT_EQUAL_PRINT_UNSIGNED_NUMBERS("18446744073709551615", (UNITY_UINT)0xFFFFFFFFFFFFFFFF); + #endif +#endif +} diff --git a/test/tests/test_unity_memory.c b/test/tests/test_unity_memory.c new file mode 100644 index 00000000..d005dfbf --- /dev/null +++ b/test/tests/test_unity_memory.c @@ -0,0 +1,78 @@ +/* ========================================== + Unity Project - A Test Framework for C + Copyright (c) 2007 Mike Karlesky, Mark VanderVoord, Greg Williams + [Released under MIT License. Please refer to license.txt for details] +========================================== */ + +#include "unity.h" +#define TEST_INSTANCES +#include "self_assessment_utils.h" + +void setUp(void) +{ + SetToOneToFailInTearDown = 0; + SetToOneMeanWeAlreadyCheckedThisGuy = 0; +} + +void tearDown(void) +{ + endPutcharSpy(); /* Stop suppressing test output */ + if (SetToOneToFailInTearDown == 1) + { + /* These will be skipped internally if already failed/ignored */ + TEST_FAIL_MESSAGE("<= Failed in tearDown"); + TEST_IGNORE_MESSAGE("<= Ignored in tearDown"); + } + if ((SetToOneMeanWeAlreadyCheckedThisGuy == 0) && (Unity.CurrentTestFailed > 0)) + { + UnityPrint(": [[[[ Test Should Have Passed But Did Not ]]]]"); + UNITY_OUTPUT_CHAR('\n'); + } +} + +void testEqualMemory(void) +{ + const char *testString = "whatever"; + + TEST_ASSERT_EQUAL_MEMORY(testString, testString, 8); + TEST_ASSERT_EQUAL_MEMORY("whatever", "whatever", 8); + TEST_ASSERT_EQUAL_MEMORY("whatever", testString, 8); + TEST_ASSERT_EQUAL_MEMORY(testString, "whatever", 8); + TEST_ASSERT_EQUAL_MEMORY(testString, "whatever", 2); + TEST_ASSERT_EQUAL_MEMORY(NULL, NULL, 1); +} + +void testNotEqualMemory1(void) +{ + EXPECT_ABORT_BEGIN + TEST_ASSERT_EQUAL_MEMORY("foo", "bar", 3); + VERIFY_FAILS_END +} + +void testNotEqualMemory2(void) +{ + EXPECT_ABORT_BEGIN + TEST_ASSERT_EQUAL_MEMORY("fool", "food", 4); + VERIFY_FAILS_END +} + +void testNotEqualMemory3(void) +{ + EXPECT_ABORT_BEGIN + TEST_ASSERT_EQUAL_MEMORY(NULL, "food", 4); + VERIFY_FAILS_END +} + +void testNotEqualMemory4(void) +{ + EXPECT_ABORT_BEGIN + TEST_ASSERT_EQUAL_MEMORY("fool", NULL, 4); + VERIFY_FAILS_END +} + +void testNotEqualMemoryLengthZero(void) +{ + EXPECT_ABORT_BEGIN + TEST_ASSERT_EQUAL_MEMORY(NULL, NULL, 0); + VERIFY_FAILS_END +} diff --git a/test/tests/testparameterized.c b/test/tests/test_unity_parameterized.c similarity index 100% rename from test/tests/testparameterized.c rename to test/tests/test_unity_parameterized.c diff --git a/test/tests/test_unity_strings.c b/test/tests/test_unity_strings.c new file mode 100644 index 00000000..3f451516 --- /dev/null +++ b/test/tests/test_unity_strings.c @@ -0,0 +1,326 @@ +/* ========================================== + Unity Project - A Test Framework for C + Copyright (c) 2007 Mike Karlesky, Mark VanderVoord, Greg Williams + [Released under MIT License. Please refer to license.txt for details] +========================================== */ + +#include "unity.h" +#define TEST_INSTANCES +#include "self_assessment_utils.h" + +void setUp(void) +{ + SetToOneToFailInTearDown = 0; + SetToOneMeanWeAlreadyCheckedThisGuy = 0; +} + +void tearDown(void) +{ + endPutcharSpy(); /* Stop suppressing test output */ + if (SetToOneToFailInTearDown == 1) + { + /* These will be skipped internally if already failed/ignored */ + TEST_FAIL_MESSAGE("<= Failed in tearDown"); + TEST_IGNORE_MESSAGE("<= Ignored in tearDown"); + } + if ((SetToOneMeanWeAlreadyCheckedThisGuy == 0) && (Unity.CurrentTestFailed > 0)) + { + UnityPrint(": [[[[ Test Should Have Passed But Did Not ]]]]"); + UNITY_OUTPUT_CHAR('\n'); + } +} + +void testEqualStrings(void) +{ + const char *testString = "foo"; + + TEST_ASSERT_EQUAL_STRING(testString, testString); + TEST_ASSERT_EQUAL_STRING_MESSAGE("foo", "foo", "foo isn't foo"); + TEST_ASSERT_EQUAL_STRING("foo", testString); + TEST_ASSERT_EQUAL_STRING(testString, "foo"); + TEST_ASSERT_EQUAL_STRING("", ""); +} + +void testEqualStringsLen(void) +{ + const char *testString = "foobar"; + TEST_ASSERT_EQUAL_STRING_LEN(testString, testString, strlen(testString)); + TEST_ASSERT_EQUAL_STRING_LEN_MESSAGE("foobar", "foobaz", 5, "fooba isn't fooba"); + TEST_ASSERT_EQUAL_STRING_LEN("foo", testString, 3); + TEST_ASSERT_EQUAL_STRING_LEN(testString, "foo", 3); + TEST_ASSERT_EQUAL_STRING_LEN("", "", 3); +} + +void testEqualStringsWithCarriageReturnsAndLineFeeds(void) +{ + const char *testString = "foo\r\nbar"; + + TEST_ASSERT_EQUAL_STRING(testString, testString); + TEST_ASSERT_EQUAL_STRING("foo\r\nbar", "foo\r\nbar"); + TEST_ASSERT_EQUAL_STRING("foo\r\nbar", testString); + TEST_ASSERT_EQUAL_STRING(testString, "foo\r\nbar"); + TEST_ASSERT_EQUAL_STRING("", ""); +} + +void testNotEqualString1(void) +{ + EXPECT_ABORT_BEGIN + TEST_ASSERT_EQUAL_STRING("foo", "bar"); + VERIFY_FAILS_END +} + +void testNotEqualStringLen1(void) +{ + EXPECT_ABORT_BEGIN + TEST_ASSERT_EQUAL_STRING_LEN("foobar", "foobaz", 6); + VERIFY_FAILS_END +} + +void testNotEqualString2(void) +{ + EXPECT_ABORT_BEGIN + TEST_ASSERT_EQUAL_STRING("foo", ""); + VERIFY_FAILS_END +} + +void testNotEqualStringLen2(void) +{ + EXPECT_ABORT_BEGIN + TEST_ASSERT_EQUAL_STRING_LEN("foo", "", 3); + VERIFY_FAILS_END +} + +void testNotEqualString3(void) +{ + EXPECT_ABORT_BEGIN + TEST_ASSERT_EQUAL_STRING("", "bar"); + VERIFY_FAILS_END +} + +void testNotEqualStringLen3(void) +{ + EXPECT_ABORT_BEGIN + TEST_ASSERT_EQUAL_STRING_LEN("", "bar", 3); + VERIFY_FAILS_END +} + +void testNotEqualString4(void) +{ + EXPECT_ABORT_BEGIN + TEST_ASSERT_EQUAL_STRING("bar\r", "bar\n"); + VERIFY_FAILS_END +} + +void testNotEqualStringLen4(void) +{ + EXPECT_ABORT_BEGIN + TEST_ASSERT_EQUAL_STRING_LEN("ba\r\x16", "ba\r\n", 4); + VERIFY_FAILS_END +} + +void testNotEqualString5(void) +{ + const char str1[] = { 0x41, 0x42, 0x03, 0x00 }; + const char str2[] = { 0x41, 0x42, 0x04, 0x00 }; + EXPECT_ABORT_BEGIN + TEST_ASSERT_EQUAL_STRING(str1, str2); + VERIFY_FAILS_END +} + +void testNotEqualString_ExpectedStringIsNull(void) +{ + EXPECT_ABORT_BEGIN + TEST_ASSERT_EQUAL_STRING(NULL, "bar"); + VERIFY_FAILS_END +} + +void testNotEqualStringLen_ExpectedStringIsNull(void) +{ + EXPECT_ABORT_BEGIN + TEST_ASSERT_EQUAL_STRING_LEN(NULL, "bar", 1); + VERIFY_FAILS_END +} + +void testNotEqualString_ActualStringIsNull(void) +{ + EXPECT_ABORT_BEGIN + TEST_ASSERT_EQUAL_STRING("foo", NULL); + VERIFY_FAILS_END +} + +void testNotEqualStringLen_ActualStringIsNull(void) +{ + EXPECT_ABORT_BEGIN + TEST_ASSERT_EQUAL_STRING_LEN("foo", NULL, 1); + VERIFY_FAILS_END +} + +void testNotEqualString_ExpectedStringIsLonger(void) +{ + EXPECT_ABORT_BEGIN + TEST_ASSERT_EQUAL_STRING("foo2", "foo"); + VERIFY_FAILS_END +} + +void testNotEqualString_ActualStringIsLonger(void) +{ + EXPECT_ABORT_BEGIN + TEST_ASSERT_EQUAL_STRING("foo", "foo2"); + VERIFY_FAILS_END +} + +void testEqualStringArrays(void) +{ + const char *testStrings[] = { "foo", "boo", "woo", "moo" }; + const char *expStrings[] = { "foo", "boo", "woo", "zoo" }; + + TEST_ASSERT_EQUAL_STRING_ARRAY(expStrings, expStrings, 3); + TEST_ASSERT_EQUAL_STRING_ARRAY(expStrings, testStrings, 3); + TEST_ASSERT_EQUAL_STRING_ARRAY(expStrings, testStrings, 2); + TEST_ASSERT_EQUAL_STRING_ARRAY(expStrings, testStrings, 1); +} + +void testNotEqualStringArray1(void) +{ + const char *testStrings[] = { "foo", "boo", "woo", "moo" }; + const char *expStrings[] = { "foo", "boo", "woo", "zoo" }; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_EQUAL_STRING_ARRAY(expStrings, testStrings, 4); + VERIFY_FAILS_END +} + +void testNotEqualStringArray2(void) +{ + const char *testStrings[] = { "zoo", "boo", "woo", "moo" }; + const char *expStrings[] = { "foo", "boo", "woo", "moo" }; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_EQUAL_STRING_ARRAY(expStrings, testStrings, 4); + VERIFY_FAILS_END +} + +void testNotEqualStringArray3(void) +{ + const char *testStrings[] = { "foo", "boo", "woo", NULL }; + const char *expStrings[] = { "foo", "boo", "woo", "zoo" }; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_EQUAL_STRING_ARRAY(expStrings, testStrings, 4); + VERIFY_FAILS_END +} + +void testNotEqualStringArray4(void) +{ + const char *testStrings[] = { "foo", "boo", "woo", "moo" }; + const char *expStrings[] = { "foo", NULL, "woo", "moo" }; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_EQUAL_STRING_ARRAY(expStrings, testStrings, 4); + VERIFY_FAILS_END +} + +void testNotEqualStringArray5(void) +{ + const char **testStrings = NULL; + const char *expStrings[] = { "foo", "boo", "woo", "zoo" }; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_EQUAL_STRING_ARRAY(expStrings, testStrings, 4); + VERIFY_FAILS_END +} + +void testNotEqualStringArray6(void) +{ + const char *testStrings[] = { "foo", "boo", "woo", "zoo" }; + const char **expStrings = NULL; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_EQUAL_STRING_ARRAY(expStrings, testStrings, 4); + VERIFY_FAILS_END +} + +void testEqualStringArrayIfBothNulls(void) +{ + const char **testStrings = NULL; + const char **expStrings = NULL; + + TEST_ASSERT_EQUAL_STRING_ARRAY(expStrings, testStrings, 4); +} + +void testNotEqualStringArrayLengthZero(void) +{ + const char *testStrings[] = {NULL}; + const char **expStrings = NULL; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_EQUAL_STRING_ARRAY(expStrings, testStrings, 0); + VERIFY_FAILS_END +} + +void testEqualStringEachEqual(void) +{ + const char *testStrings1[] = { "foo", "foo", "foo", "foo" }; + const char *testStrings2[] = { "boo", "boo", "boo", "zoo" }; + const char *testStrings3[] = { "", "", "", "" }; + + TEST_ASSERT_EACH_EQUAL_STRING("foo", testStrings1, 4); + TEST_ASSERT_EACH_EQUAL_STRING("foo", testStrings1, 1); + TEST_ASSERT_EACH_EQUAL_STRING("boo", testStrings2, 3); + TEST_ASSERT_EACH_EQUAL_STRING("", testStrings3, 4); +} + +void testNotEqualStringEachEqual1(void) +{ + const char *testStrings[] = { "foo", "foo", "foo", "moo" }; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_EACH_EQUAL_STRING("foo", testStrings, 4); + VERIFY_FAILS_END +} + +void testNotEqualStringEachEqual2(void) +{ + const char *testStrings[] = { "boo", "foo", "foo", "foo" }; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_EACH_EQUAL_STRING("foo", testStrings, 4); + VERIFY_FAILS_END +} + +void testNotEqualStringEachEqual3(void) +{ + const char *testStrings[] = { "foo", "foo", "foo", NULL }; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_EACH_EQUAL_STRING("foo", testStrings, 4); + VERIFY_FAILS_END +} + +void testNotEqualStringEachEqual4(void) +{ + const char *testStrings[] = { "foo", "foo", "woo", "foo" }; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_EACH_EQUAL_STRING("foo", testStrings, 4); + VERIFY_FAILS_END +} + +void testNotEqualStringEachEqual5(void) +{ + EXPECT_ABORT_BEGIN + TEST_ASSERT_EACH_EQUAL_STRING("foo", NULL, 1); + VERIFY_FAILS_END +} + +void testCstringsEscapeSequence(void) +{ +#ifndef USING_OUTPUT_SPY + TEST_IGNORE(); +#else + startPutcharSpy(); + UnityPrint("\x16\x10"); + endPutcharSpy(); + TEST_ASSERT_EQUAL_STRING("\\x16\\x10", getBufferPutcharSpy()); +#endif +} diff --git a/test/tests/testunity.c b/test/tests/testunity.c deleted file mode 100644 index eef84e2d..00000000 --- a/test/tests/testunity.c +++ /dev/null @@ -1,8201 +0,0 @@ -/* ========================================== - Unity Project - A Test Framework for C - Copyright (c) 2007 Mike Karlesky, Mark VanderVoord, Greg Williams - [Released under MIT License. Please refer to license.txt for details] -========================================== */ - -#include "unity.h" -#include -#include - -/* Dividing by these constants produces +/- infinity. - * The rationale is given in UnityAssertFloatIsInf's body. - */ -#ifndef UNITY_EXCLUDE_FLOAT -static const UNITY_FLOAT f_zero = 0.0f; -#endif - -#ifndef UNITY_EXCLUDE_DOUBLE -static const UNITY_DOUBLE d_zero = 0.0; -#endif - -#define EXPECT_ABORT_BEGIN \ - startPutcharSpy(); \ - if (TEST_PROTECT()) \ - { - -#define VERIFY_FAILS_END \ - } \ - endPutcharSpy(); /* start/end Spy to suppress output of failure message */ \ - Unity.CurrentTestFailed = (Unity.CurrentTestFailed == 1) ? 0 : 1; \ - if (Unity.CurrentTestFailed == 1) { \ - SetToOneMeanWeAlreadyCheckedThisGuy = 1; \ - UnityPrintNumberUnsigned(Unity.CurrentTestLineNumber); \ - UNITY_OUTPUT_CHAR(':'); \ - UnityPrint(Unity.CurrentTestName); \ - UnityPrint(":FAIL: [[[[ Test Should Have Failed But Did Not ]]]]"); \ - UNITY_OUTPUT_CHAR('\n'); \ - } - -#define VERIFY_IGNORES_END \ - } \ - endPutcharSpy(); /* start/end Spy to suppress output of ignore message */ \ - Unity.CurrentTestFailed = (Unity.CurrentTestIgnored == 1) ? 0 : 1; \ - Unity.CurrentTestIgnored = 0; \ - if (Unity.CurrentTestFailed == 1) { \ - SetToOneMeanWeAlreadyCheckedThisGuy = 1; \ - UnityPrintNumberUnsigned(Unity.CurrentTestLineNumber); \ - UNITY_OUTPUT_CHAR(':'); \ - UnityPrint(Unity.CurrentTestName); \ - UnityPrint(":FAIL: [[[[ Test Should Have Ignored But Did Not ]]]]"); \ - UNITY_OUTPUT_CHAR('\n'); \ - } - -void startPutcharSpy(void); -void endPutcharSpy(void); -char* getBufferPutcharSpy(void); - -void startFlushSpy(void); -void endFlushSpy(void); -int getFlushSpyCalls(void); - -static int SetToOneToFailInTearDown; -static int SetToOneMeanWeAlreadyCheckedThisGuy; - -void setUp(void) -{ - SetToOneToFailInTearDown = 0; - SetToOneMeanWeAlreadyCheckedThisGuy = 0; -} - -void tearDown(void) -{ - endPutcharSpy(); /* Stop suppressing test output */ - if (SetToOneToFailInTearDown == 1) - { - /* These will be skipped internally if already failed/ignored */ - TEST_FAIL_MESSAGE("<= Failed in tearDown"); - TEST_IGNORE_MESSAGE("<= Ignored in tearDown"); - } - if ((SetToOneMeanWeAlreadyCheckedThisGuy == 0) && (Unity.CurrentTestFailed > 0)) - { - UnityPrint(": [[[[ Test Should Have Passed But Did Not ]]]]"); - UNITY_OUTPUT_CHAR('\n'); - } -} - -void testUnitySizeInitializationReminder(void) -{ - /* This test ensures that sizeof(struct UNITY_STORAGE_T) doesn't change. If this - * test breaks, go look at the initialization of the Unity global variable - * in unity.c and make sure we're filling in the proper fields. */ - const char* message = "Unexpected size for UNITY_STORAGE_T struct. Please check that " - "the initialization of the Unity symbol in unity.c is " - "still correct."; - - /* Define a structure with all the same fields as `struct UNITY_STORAGE_T`. */ -#ifdef UNITY_EXCLUDE_DETAILS - struct { - const char* TestFile; - const char* CurrentTestName; - UNITY_LINE_TYPE CurrentTestLineNumber; - UNITY_COUNTER_TYPE NumberOfTests; - UNITY_COUNTER_TYPE TestFailures; - UNITY_COUNTER_TYPE TestIgnores; - UNITY_COUNTER_TYPE CurrentTestFailed; - UNITY_COUNTER_TYPE CurrentTestIgnored; -#ifdef UNITY_INCLUDE_EXEC_TIME - UNITY_TIME_TYPE CurrentTestStartTime; - UNITY_TIME_TYPE CurrentTestStopTime; -#endif -#ifndef UNITY_EXCLUDE_SETJMP_H - jmp_buf AbortFrame; -#endif - } _Expected_Unity; -#else - struct { - const char* TestFile; - const char* CurrentTestName; - const char* CurrentDetails1; - const char* CurrentDetails2; - UNITY_LINE_TYPE CurrentTestLineNumber; - UNITY_COUNTER_TYPE NumberOfTests; - UNITY_COUNTER_TYPE TestFailures; - UNITY_COUNTER_TYPE TestIgnores; - UNITY_COUNTER_TYPE CurrentTestFailed; - UNITY_COUNTER_TYPE CurrentTestIgnored; -#ifdef UNITY_INCLUDE_EXEC_TIME - UNITY_COUNTER_TYPE CurrentTestStartTime; - UNITY_COUNTER_TYPE CurrentTestStopTime; -#endif -#ifndef UNITY_EXCLUDE_SETJMP_H - jmp_buf AbortFrame; -#endif - } _Expected_Unity; -#endif - - /* Compare our fake structure's size to the actual structure's size. They - * should be the same. - * - * This accounts for alignment, padding, and packing issues that might come - * up between different architectures. */ - TEST_ASSERT_EQUAL_MESSAGE(sizeof(_Expected_Unity), sizeof(Unity), message); -} - -void testPassShouldEndImmediatelyWithPass(void) -{ - TEST_PASS(); - TEST_FAIL_MESSAGE("We should have passed already and finished this test"); -} - -void testPassShouldEndImmediatelyWithPassAndMessage(void) -{ - TEST_PASS_MESSAGE("Woohoo! This Automatically Passes!"); - TEST_FAIL_MESSAGE("We should have passed already and finished this test"); -} - -void testMessageShouldDisplayMessageWithoutEndingAndGoOnToPass(void) -{ - TEST_MESSAGE("This is just a message"); - TEST_MESSAGE("This is another message"); - TEST_PASS(); -} - -void testMessageShouldDisplayMessageWithoutEndingAndGoOnToFail(void) -{ - TEST_MESSAGE("This is yet another message"); - - EXPECT_ABORT_BEGIN - TEST_FAIL(); - VERIFY_FAILS_END -} - -void testTrue(void) -{ - TEST_ASSERT(1); - - TEST_ASSERT_TRUE(1); -} - -void testFalse(void) -{ - TEST_ASSERT_FALSE(0); - - TEST_ASSERT_UNLESS(0); -} - -void testPreviousPass(void) -{ - TEST_ASSERT_EQUAL_INT(0U, Unity.TestFailures); -} - -void testNotVanilla(void) -{ - EXPECT_ABORT_BEGIN - TEST_ASSERT(0); - VERIFY_FAILS_END -} - -void testNotTrue(void) -{ - EXPECT_ABORT_BEGIN - TEST_ASSERT_TRUE(0); - VERIFY_FAILS_END -} - -void testNotFalse(void) -{ - EXPECT_ABORT_BEGIN - TEST_ASSERT_FALSE(1); - VERIFY_FAILS_END -} - -void testNotUnless(void) -{ - EXPECT_ABORT_BEGIN - TEST_ASSERT_UNLESS(1); - VERIFY_FAILS_END -} - -void testNotNotEqual(void) -{ - EXPECT_ABORT_BEGIN - TEST_ASSERT_NOT_EQUAL(10, 10); - VERIFY_FAILS_END -} - -void testFail(void) -{ - EXPECT_ABORT_BEGIN - TEST_FAIL_MESSAGE("Expected for testing"); - VERIFY_FAILS_END -} - -void testIsNull(void) -{ - char* ptr1 = NULL; - const char* ptr2 = "hello"; - - TEST_ASSERT_NULL(ptr1); - TEST_ASSERT_NOT_NULL(ptr2); -} - -void testIsNullShouldFailIfNot(void) -{ - const char* ptr1 = "hello"; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_NULL(ptr1); - VERIFY_FAILS_END -} - -void testNotNullShouldFailIfNULL(void) -{ - char* ptr1 = NULL; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_NOT_NULL(ptr1); - VERIFY_FAILS_END -} - -void testIsEmpty(void) -{ - const char* ptr1 = "\0"; - const char* ptr2 = "hello"; - - TEST_ASSERT_EMPTY(ptr1); - TEST_ASSERT_NOT_EMPTY(ptr2); -} - -void testIsEmptyShouldFailIfNot(void) -{ - const char* ptr1 = "hello"; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_EMPTY(ptr1); - VERIFY_FAILS_END -} - -void testNotEmptyShouldFailIfEmpty(void) -{ - const char* ptr1 = "\0"; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_NOT_EMPTY(ptr1); - VERIFY_FAILS_END -} - -void testIgnore(void) -{ - EXPECT_ABORT_BEGIN - TEST_IGNORE(); - TEST_FAIL_MESSAGE("This should not be reached"); - VERIFY_IGNORES_END -} - -void testIgnoreMessage(void) -{ - EXPECT_ABORT_BEGIN - TEST_IGNORE_MESSAGE("This is an expected TEST_IGNORE_MESSAGE string!"); - TEST_FAIL_MESSAGE("This should not be reached"); - VERIFY_IGNORES_END -} - -void testNotEqualInts(void) -{ - EXPECT_ABORT_BEGIN - TEST_ASSERT_EQUAL_INT(3982, 3983); - VERIFY_FAILS_END -} - -void testNotEqualInt8s(void) -{ - EXPECT_ABORT_BEGIN - TEST_ASSERT_EQUAL_INT8(-127, -126); - VERIFY_FAILS_END -} - -void testNotEqualChars(void) -{ - EXPECT_ABORT_BEGIN - TEST_ASSERT_EQUAL_CHAR('A', 'a'); - VERIFY_FAILS_END -} - -void testNotEqualInt16s(void) -{ - EXPECT_ABORT_BEGIN - TEST_ASSERT_EQUAL_INT16(-16383, -16382); - VERIFY_FAILS_END -} - -void testNotEqualInt32s(void) -{ - EXPECT_ABORT_BEGIN - /*use largest 32 bit negative to test printability*/ - /*note: (-2147483647 - 1) is used instead of -2147483648 because of C90 casting rules */ - TEST_ASSERT_EQUAL_INT32(-2147483647, (-2147483647 - 1)); - VERIFY_FAILS_END -} - -void testNotEqualBits(void) -{ - EXPECT_ABORT_BEGIN - TEST_ASSERT_BITS(0xFF00, 0x5555, 0x5A55); - VERIFY_FAILS_END -} - -void testNotEqualUInts(void) -{ - UNITY_UINT16 v0, v1; - - v0 = 9000; - v1 = 9001; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_EQUAL_UINT(v0, v1); - VERIFY_FAILS_END -} - -void testNotEqualUInt8s(void) -{ - UNITY_UINT8 v0, v1; - - v0 = 254; - v1 = 255; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_EQUAL_UINT8(v0, v1); - VERIFY_FAILS_END -} - -void testNotEqualUInt16s(void) -{ - UNITY_UINT16 v0, v1; - - v0 = 65535u; - v1 = 65534u; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_EQUAL_UINT16(v0, v1); - VERIFY_FAILS_END -} - -void testNotEqualUInt32s(void) -{ - UNITY_UINT32 v0, v1; - - v0 = 4294967295u; - v1 = 4294967294u; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_EQUAL_UINT32(v0, v1); - VERIFY_FAILS_END -} - -void testNotEqualHex8s(void) -{ - UNITY_UINT8 v0, v1; - - v0 = 0x23; - v1 = 0x22; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_EQUAL_HEX8(v0, v1); - VERIFY_FAILS_END -} - -void testNotEqualHex8sIfSigned(void) -{ - UNITY_INT8 v0, v1; - - v0 = -2; - v1 = 2; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_EQUAL_HEX8(v0, v1); - VERIFY_FAILS_END -} - -void testNotEqualHex16s(void) -{ - UNITY_UINT16 v0, v1; - - v0 = 0x1234; - v1 = 0x1235; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_EQUAL_HEX16(v0, v1); - VERIFY_FAILS_END -} - -void testNotEqualHex16sIfSigned(void) -{ - UNITY_INT16 v0, v1; - - v0 = -1024; - v1 = -1028; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_EQUAL_HEX16(v0, v1); - VERIFY_FAILS_END -} - -void testNotEqualHex32s(void) -{ - UNITY_UINT32 v0, v1; - - v0 = 900000; - v1 = 900001; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_EQUAL_HEX32(v0, v1); - VERIFY_FAILS_END -} - -void testNotEqualHex32sIfSigned(void) -{ - UNITY_INT32 v0, v1; - - v0 = -900000; - v1 = 900001; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_EQUAL_HEX32(v0, v1); - VERIFY_FAILS_END -} - -void testEqualInts(void) -{ - int v0, v1; - int *p0, *p1; - - v0 = 19467; - v1 = 19467; - p0 = &v0; - p1 = &v1; - - TEST_ASSERT_EQUAL_INT(1837, 1837); - TEST_ASSERT_EQUAL_INT(-27365, -27365); - TEST_ASSERT_EQUAL_INT(v0, v1); - TEST_ASSERT_EQUAL_INT(19467, v1); - TEST_ASSERT_EQUAL_INT(v0, 19467); - TEST_ASSERT_EQUAL_INT(*p0, v1); - TEST_ASSERT_EQUAL_INT(*p0, *p1); - TEST_ASSERT_EQUAL_INT(*p0, 19467); -} - -void testEqualInt8s(void) -{ - UNITY_INT8 v0, v1; - UNITY_INT8 *p0, *p1; - - v0 = 0x22; - v1 = 0x22; - p0 = &v0; - p1 = &v1; - - TEST_ASSERT_EQUAL_INT8(0x22, 0x22); - TEST_ASSERT_EQUAL_INT8(v0, v1); - TEST_ASSERT_EQUAL_INT8(0x22, v1); - TEST_ASSERT_EQUAL_INT8(v0, 0x22); - TEST_ASSERT_EQUAL_INT8(*p0, v1); - TEST_ASSERT_EQUAL_INT8(*p0, *p1); - TEST_ASSERT_EQUAL_INT8(*p0, 0x22); -} - -void testEqualInt8sWhenThereAreDifferencesOutside8Bits(void) -{ - TEST_ASSERT_EQUAL_INT8(0x321,0x421); - TEST_ASSERT_EQUAL_INT8(0xFF21,0x0021); -} - -void testEqualChars(void) -{ - char v0, v1; - char *p0, *p1; - - v0 = 'A'; - v1 = 'A'; - p0 = &v0; - p1 = &v1; - - TEST_ASSERT_EQUAL_CHAR('A', 'A'); - TEST_ASSERT_EQUAL_CHAR(v0, v1); - TEST_ASSERT_EQUAL_CHAR('A', v1); - TEST_ASSERT_EQUAL_CHAR(v0, 'A'); - TEST_ASSERT_EQUAL_CHAR(*p0, v1); - TEST_ASSERT_EQUAL_CHAR(*p0, *p1); - TEST_ASSERT_EQUAL_CHAR(*p0, 'A'); -} - -void testEqualCharsWhenThereAreDifferencesOutside8Bits(void) -{ - TEST_ASSERT_EQUAL_CHAR(0x321,0x421); - TEST_ASSERT_EQUAL_CHAR(0xFF21,0x0021); -} - - -void testEqualInt16s(void) -{ - UNITY_INT16 v0, v1; - UNITY_INT16 *p0, *p1; - - v0 = 0x7876; - v1 = 0x7876; - p0 = &v0; - p1 = &v1; - - TEST_ASSERT_EQUAL_INT16(0x7876, 0x7876); - TEST_ASSERT_EQUAL_INT16(v0, v1); - TEST_ASSERT_EQUAL_INT16(0x7876, v1); - TEST_ASSERT_EQUAL_INT16(v0, 0x7876); - TEST_ASSERT_EQUAL_INT16(*p0, v1); - TEST_ASSERT_EQUAL_INT16(*p0, *p1); - TEST_ASSERT_EQUAL_INT16(*p0, 0x7876); -} - -void testEqualInt16sNegatives(void) -{ - UNITY_INT16 v0, v1; - UNITY_INT16 *p0, *p1; - - v0 = -7876; - v1 = -7876; - p0 = &v0; - p1 = &v1; - - TEST_ASSERT_EQUAL_INT16(-7876, -7876); - TEST_ASSERT_EQUAL_INT16(v0, v1); - TEST_ASSERT_EQUAL_INT16(-7876, v1); - TEST_ASSERT_EQUAL_INT16(v0, -7876); - TEST_ASSERT_EQUAL_INT16(*p0, v1); - TEST_ASSERT_EQUAL_INT16(*p0, *p1); - TEST_ASSERT_EQUAL_INT16(*p0, -7876); -} - -void testEqualInt16sWhenThereAreDifferencesOutside16Bits(void) -{ - TEST_ASSERT_EQUAL_INT16(0x54321,0x64321); - TEST_ASSERT_EQUAL_INT16(0xFFFF4321,0x00004321); -} - -void testEqualInt32s(void) -{ - UNITY_INT32 v0, v1; - UNITY_INT32 *p0, *p1; - - v0 = 0x78760000; - v1 = 0x78760000; - p0 = &v0; - p1 = &v1; - - TEST_ASSERT_EQUAL_INT32(0x78760000, 0x78760000); - TEST_ASSERT_EQUAL_INT32(v0, v1); - TEST_ASSERT_EQUAL_INT32(0x78760000, v1); - TEST_ASSERT_EQUAL_INT32(v0, 0x78760000); - TEST_ASSERT_EQUAL_INT32(*p0, v1); - TEST_ASSERT_EQUAL_INT32(*p0, *p1); - TEST_ASSERT_EQUAL_INT32(*p0, 0x78760000); -} - -void testEqualInt32sNegatives(void) -{ - UNITY_INT32 v0, v1; - UNITY_INT32 *p0, *p1; - - v0 = -123456789; - v1 = -123456789; - p0 = &v0; - p1 = &v1; - - TEST_ASSERT_EQUAL_INT32(-123456789, -123456789); - TEST_ASSERT_EQUAL_INT32(v0, v1); - TEST_ASSERT_EQUAL_INT32(-123456789, v1); - TEST_ASSERT_EQUAL_INT32(v0, -123456789); - TEST_ASSERT_EQUAL_INT32(*p0, v1); - TEST_ASSERT_EQUAL_INT32(*p0, *p1); - TEST_ASSERT_EQUAL_INT32(*p0, -123456789); -} - - -void testEqualUints(void) -{ - unsigned int v0, v1; - unsigned int *p0, *p1; - - v0 = 19467; - v1 = 19467; - p0 = &v0; - p1 = &v1; - - TEST_ASSERT_EQUAL_UINT(1837, 1837); - TEST_ASSERT_EQUAL_UINT(v0, v1); - TEST_ASSERT_EQUAL_UINT(19467, v1); - TEST_ASSERT_EQUAL_UINT(v0, 19467); - TEST_ASSERT_EQUAL_UINT(*p0, v1); - TEST_ASSERT_EQUAL_UINT(*p0, *p1); - TEST_ASSERT_EQUAL_UINT(*p0, 19467); - TEST_ASSERT_EQUAL_UINT(60872u, 60872u); -} - - -void testEqualUint8s(void) -{ - UNITY_UINT8 v0, v1; - UNITY_UINT8 *p0, *p1; - - v0 = 0x22; - v1 = 0x22; - p0 = &v0; - p1 = &v1; - - TEST_ASSERT_EQUAL_UINT8(0x22, 0x22); - TEST_ASSERT_EQUAL_UINT8(v0, v1); - TEST_ASSERT_EQUAL_UINT8(0x22, v1); - TEST_ASSERT_EQUAL_UINT8(v0, 0x22); - TEST_ASSERT_EQUAL_UINT8(*p0, v1); - TEST_ASSERT_EQUAL_UINT8(*p0, *p1); - TEST_ASSERT_EQUAL_UINT8(*p0, 0x22); -} - -void testEqualUint8sWhenThereAreDifferencesOutside8Bits(void) -{ - TEST_ASSERT_EQUAL_UINT8(0x321,0x421); - TEST_ASSERT_EQUAL_UINT8(0xFF21,0x0021); -} - -void testEqualUint16s(void) -{ - UNITY_UINT16 v0, v1; - UNITY_UINT16 *p0, *p1; - - v0 = 0x9876; - v1 = 0x9876; - p0 = &v0; - p1 = &v1; - - TEST_ASSERT_EQUAL_UINT16(0x9876, 0x9876); - TEST_ASSERT_EQUAL_UINT16(v0, v1); - TEST_ASSERT_EQUAL_UINT16(0x9876, v1); - TEST_ASSERT_EQUAL_UINT16(v0, 0x9876); - TEST_ASSERT_EQUAL_UINT16(*p0, v1); - TEST_ASSERT_EQUAL_UINT16(*p0, *p1); - TEST_ASSERT_EQUAL_UINT16(*p0, 0x9876); -} - -void testEqualUint16sWhenThereAreDifferencesOutside16Bits(void) -{ - TEST_ASSERT_EQUAL_UINT16(0x54321,0x64321); - TEST_ASSERT_EQUAL_UINT16(0xFFFF4321,0x00004321); -} - -void testEqualUint32s(void) -{ - UNITY_UINT32 v0, v1; - UNITY_UINT32 *p0, *p1; - - v0 = 0x98760000; - v1 = 0x98760000; - p0 = &v0; - p1 = &v1; - - TEST_ASSERT_EQUAL_UINT32(0x98760000, 0x98760000); - TEST_ASSERT_EQUAL_UINT32(v0, v1); - TEST_ASSERT_EQUAL_UINT32(0x98760000, v1); - TEST_ASSERT_EQUAL_UINT32(v0, 0x98760000); - TEST_ASSERT_EQUAL_UINT32(*p0, v1); - TEST_ASSERT_EQUAL_UINT32(*p0, *p1); - TEST_ASSERT_EQUAL_UINT32(*p0, 0x98760000); -} - -void testNotEqual(void) -{ - TEST_ASSERT_NOT_EQUAL(0, 1); - TEST_ASSERT_NOT_EQUAL(1, 0); - TEST_ASSERT_NOT_EQUAL(100, 101); - TEST_ASSERT_NOT_EQUAL(0, -1); - TEST_ASSERT_NOT_EQUAL(65535, -65535); - TEST_ASSERT_NOT_EQUAL(75, 900); - TEST_ASSERT_NOT_EQUAL(-100, -101); -} - -void testEqualHex8s(void) -{ - UNITY_UINT8 v0, v1; - UNITY_UINT8 *p0, *p1; - - v0 = 0x22; - v1 = 0x22; - p0 = &v0; - p1 = &v1; - - TEST_ASSERT_EQUAL_HEX8(0x22, 0x22); - TEST_ASSERT_EQUAL_HEX8(v0, v1); - TEST_ASSERT_EQUAL_HEX8(0x22, v1); - TEST_ASSERT_EQUAL_HEX8(v0, 0x22); - TEST_ASSERT_EQUAL_HEX8(*p0, v1); - TEST_ASSERT_EQUAL_HEX8(*p0, *p1); - TEST_ASSERT_EQUAL_HEX8(*p0, 0x22); -} - -void testEqualHex8sWhenThereAreDifferencesOutside8Bits(void) -{ - TEST_ASSERT_EQUAL_HEX8(0x321,0x421); - TEST_ASSERT_EQUAL_HEX8(0xFF21,0x0021); -} - -void testEqualHex8sNegatives(void) -{ - UNITY_UINT8 v0, v1; - UNITY_UINT8 *p0, *p1; - - v0 = 0xDD; - v1 = 0xDD; - p0 = &v0; - p1 = &v1; - - TEST_ASSERT_EQUAL_HEX8(0xDD, 0xDD); - TEST_ASSERT_EQUAL_HEX8(v0, v1); - TEST_ASSERT_EQUAL_HEX8(0xDD, v1); - TEST_ASSERT_EQUAL_HEX8(v0, 0xDD); - TEST_ASSERT_EQUAL_HEX8(*p0, v1); - TEST_ASSERT_EQUAL_HEX8(*p0, *p1); - TEST_ASSERT_EQUAL_HEX8(*p0, 0xDD); -} - -void testEqualHex16s(void) -{ - UNITY_UINT16 v0, v1; - UNITY_UINT16 *p0, *p1; - - v0 = 0x9876; - v1 = 0x9876; - p0 = &v0; - p1 = &v1; - - TEST_ASSERT_EQUAL_HEX16(0x9876, 0x9876); - TEST_ASSERT_EQUAL_HEX16(v0, v1); - TEST_ASSERT_EQUAL_HEX16(0x9876, v1); - TEST_ASSERT_EQUAL_HEX16(v0, 0x9876); - TEST_ASSERT_EQUAL_HEX16(*p0, v1); - TEST_ASSERT_EQUAL_HEX16(*p0, *p1); - TEST_ASSERT_EQUAL_HEX16(*p0, 0x9876); -} - -void testEqualHex16sWhenThereAreDifferencesOutside16Bits(void) -{ - TEST_ASSERT_EQUAL_HEX16(0x54321,0x64321); - TEST_ASSERT_EQUAL_HEX16(0xFFFF4321,0x00004321); -} - -void testEqualHex32s(void) -{ - UNITY_UINT32 v0, v1; - UNITY_UINT32 *p0, *p1; - - v0 = 0x98765432ul; - v1 = 0x98765432ul; - p0 = &v0; - p1 = &v1; - - TEST_ASSERT_EQUAL_HEX32(0x98765432ul, 0x98765432ul); - TEST_ASSERT_EQUAL_HEX32(v0, v1); - TEST_ASSERT_EQUAL_HEX32(0x98765432ul, v1); - TEST_ASSERT_EQUAL_HEX32(v0, 0x98765432ul); - TEST_ASSERT_EQUAL_HEX32(*p0, v1); - TEST_ASSERT_EQUAL_HEX32(*p0, *p1); - TEST_ASSERT_EQUAL_HEX32(*p0, 0x98765432ul); -} - -void testEqualBits(void) -{ - UNITY_UINT32 v0 = 0xFF55AA00; - UNITY_UINT32 v1 = 0x55550000; - - TEST_ASSERT_BITS(v1, v0, 0x55550000); - TEST_ASSERT_BITS(v1, v0, 0xFF55CC00); - TEST_ASSERT_BITS(0xFFFFFFFF, v0, 0xFF55AA00); - TEST_ASSERT_BITS(0xFFFFFFFF, v0, v0); - TEST_ASSERT_BITS(0xF0F0F0F0, v0, 0xFC5DAE0F); - TEST_ASSERT_BITS_HIGH(v1, v0); - TEST_ASSERT_BITS_LOW(0x000055FF, v0); - TEST_ASSERT_BIT_HIGH(30, v0); - TEST_ASSERT_BIT_LOW(5, v0); -} - -void testNotEqualBitHigh(void) -{ - UNITY_UINT32 v0 = 0x7F55AA00; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_BIT_HIGH(31, v0); - VERIFY_FAILS_END -} - -void testNotEqualBitLow(void) -{ - UNITY_UINT32 v0 = 0xFF55AA00; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_BIT_LOW(30, v0); - VERIFY_FAILS_END -} - -void testNotEqualBitsHigh(void) -{ - UNITY_UINT32 v0 = 0xFF55AA00; - UNITY_UINT32 v1 = 0x55550000; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_BITS_HIGH(v0, v1); - VERIFY_FAILS_END - -} - -void testNotEqualBitsLow(void) -{ - UNITY_UINT32 v0 = 0xFF55AA00; - UNITY_UINT32 v1 = 0x55550000; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_BITS_LOW(v0, v1); - VERIFY_FAILS_END -} - - -void testEqualShorts(void) -{ - short v0, v1; - short *p0, *p1; - - v0 = 19467; - v1 = 19467; - p0 = &v0; - p1 = &v1; - - TEST_ASSERT_EQUAL_INT(1837, 1837); - TEST_ASSERT_EQUAL_INT(-2987, -2987); - TEST_ASSERT_EQUAL_INT(v0, v1); - TEST_ASSERT_EQUAL_INT(19467, v1); - TEST_ASSERT_EQUAL_INT(v0, 19467); - TEST_ASSERT_EQUAL_INT(*p0, v1); - TEST_ASSERT_EQUAL_INT(*p0, *p1); - TEST_ASSERT_EQUAL_INT(*p0, 19467); -} - -void testEqualUShorts(void) -{ - unsigned short v0, v1; - unsigned short *p0, *p1; - - v0 = 19467; - v1 = 19467; - p0 = &v0; - p1 = &v1; - - TEST_ASSERT_EQUAL_UINT(1837, 1837); - TEST_ASSERT_EQUAL_UINT(2987, 2987); - TEST_ASSERT_EQUAL_UINT(v0, v1); - TEST_ASSERT_EQUAL_UINT(19467, v1); - TEST_ASSERT_EQUAL_UINT(v0, 19467); - TEST_ASSERT_EQUAL_UINT(*p0, v1); - TEST_ASSERT_EQUAL_UINT(*p0, *p1); - TEST_ASSERT_EQUAL_UINT(*p0, 19467); -} - -void testEqualUInts(void) -{ - unsigned char v0, v1; - unsigned char *p0, *p1; - - v0 = 109; - v1 = 109; - p0 = &v0; - p1 = &v1; - - TEST_ASSERT_EQUAL_UINT(42, 42); - TEST_ASSERT_EQUAL_UINT(-116, -116); - TEST_ASSERT_EQUAL_UINT(v0, v1); - TEST_ASSERT_EQUAL_UINT(109, v1); - TEST_ASSERT_EQUAL_UINT(v0, 109); - TEST_ASSERT_EQUAL_UINT(*p0, v1); - TEST_ASSERT_EQUAL_UINT(*p0, *p1); - TEST_ASSERT_EQUAL_UINT(*p0, 109); -} - -void testEqualUChars(void) -{ - unsigned char v0, v1; - unsigned char *p0, *p1; - - v0 = 251; - v1 = 251; - p0 = &v0; - p1 = &v1; - - TEST_ASSERT_EQUAL_INT(42, 42); - TEST_ASSERT_EQUAL_INT(v0, v1); - TEST_ASSERT_EQUAL_INT(251, v1); - TEST_ASSERT_EQUAL_INT(v0, 251); - TEST_ASSERT_EQUAL_INT(*p0, v1); - TEST_ASSERT_EQUAL_INT(*p0, *p1); - TEST_ASSERT_EQUAL_INT(*p0, 251); -} - -void testEqualPointers(void) -{ - int v0, v1; - int *p0, *p1, *p2; - - v0 = 19467; - v1 = 18271; - p0 = &v0; - p1 = &v1; - p2 = &v1; - - TEST_ASSERT_EQUAL_PTR(p0, &v0); - TEST_ASSERT_EQUAL_PTR(&v1, p1); - TEST_ASSERT_EQUAL_PTR(p2, p1); - TEST_ASSERT_EQUAL_PTR(&v0, &v0); -} - -void testNotEqualPointers(void) -{ - EXPECT_ABORT_BEGIN - TEST_ASSERT_EQUAL_PTR(0x12345678, 0x12345677); - VERIFY_FAILS_END -} - -void testIntsWithinDelta(void) -{ - TEST_ASSERT_INT_WITHIN(1, 5000, 5001); - TEST_ASSERT_INT_WITHIN(5, 5000, 4996); - TEST_ASSERT_INT_WITHIN(5, 5000, 5005); - TEST_ASSERT_INT_WITHIN(500, 50, -440); - - TEST_ASSERT_INT_WITHIN(2, -1, -1); - TEST_ASSERT_INT_WITHIN(5, 1, -1); - TEST_ASSERT_INT_WITHIN(5, -1, 1); -} - -void testIntsWithinDeltaAndCustomMessage(void) -{ - TEST_ASSERT_INT_WITHIN_MESSAGE(1, 5000, 5001, "Custom Message."); - TEST_ASSERT_INT_WITHIN_MESSAGE(5, 5000, 4996, "Custom Message."); - TEST_ASSERT_INT_WITHIN_MESSAGE(5, 5000, 5005, "Custom Message."); - TEST_ASSERT_INT_WITHIN_MESSAGE(500, 50, -440, "Custom Message."); - - TEST_ASSERT_INT_WITHIN_MESSAGE(2, -1, -1, "Custom Message."); - TEST_ASSERT_INT_WITHIN_MESSAGE(5, 1, -1, "Custom Message."); - TEST_ASSERT_INT_WITHIN_MESSAGE(5, -1, 1, "Custom Message."); -} - -void testIntsNotWithinDelta(void) -{ - EXPECT_ABORT_BEGIN - TEST_ASSERT_INT_WITHIN(5, 5000, 5006); - VERIFY_FAILS_END -} - -void testIntsNotWithinDeltaAndCustomMessage(void) -{ - EXPECT_ABORT_BEGIN - TEST_ASSERT_INT_WITHIN_MESSAGE(5, 5000, 5006, "Custom Message."); - VERIFY_FAILS_END -} - -void testUIntsWithinDelta(void) -{ - TEST_ASSERT_UINT_WITHIN(1, 5000, 5001); - TEST_ASSERT_UINT_WITHIN(5, 5000, 4996); - TEST_ASSERT_UINT_WITHIN(5, 5000, 5005); -} - -void testUIntsWithinDeltaAndCustomMessage(void) -{ - TEST_ASSERT_UINT_WITHIN_MESSAGE(1, 5000, 5001, "Custom Message."); - TEST_ASSERT_UINT_WITHIN_MESSAGE(5, 5000, 4996, "Custom Message."); - TEST_ASSERT_UINT_WITHIN_MESSAGE(5, 5000, 5005, "Custom Message."); -} - -void testUIntsNotWithinDelta(void) -{ - EXPECT_ABORT_BEGIN - TEST_ASSERT_UINT_WITHIN(1, 2147483647u, 2147483649u); - VERIFY_FAILS_END -} - -void testUIntsNotWithinDeltaAndCustomMessage(void) -{ - EXPECT_ABORT_BEGIN - TEST_ASSERT_UINT_WITHIN_MESSAGE(1, 2147483647u, 2147483649u, "Custom Message."); - VERIFY_FAILS_END -} - -void testUIntsNotWithinDeltaEvenThoughASignedIntWouldPassSmallFirst(void) -{ - EXPECT_ABORT_BEGIN - TEST_ASSERT_UINT_WITHIN(5, 1, -1); - VERIFY_FAILS_END -} - -void testUIntsNotWithinDeltaEvenThoughASignedIntWouldPassSmallFirstAndCustomMessage(void) -{ - EXPECT_ABORT_BEGIN - TEST_ASSERT_UINT_WITHIN_MESSAGE(5, 1, -1, "Custom Message."); - VERIFY_FAILS_END -} - -void testUIntsNotWithinDeltaEvenThoughASignedIntWouldPassBigFirst(void) -{ - EXPECT_ABORT_BEGIN - TEST_ASSERT_UINT_WITHIN(5, -1, 1); - VERIFY_FAILS_END -} - -void testUIntsNotWithinDeltaEvenThoughASignedIntWouldPassBigFirstAndCustomMessage(void) -{ - EXPECT_ABORT_BEGIN - TEST_ASSERT_UINT_WITHIN_MESSAGE(5, -1, 1, "Custom Message."); - VERIFY_FAILS_END -} - -void testHEX32sWithinDelta(void) -{ - TEST_ASSERT_HEX32_WITHIN(1, 5000, 5001); - TEST_ASSERT_HEX32_WITHIN(5, 5000, 4996); - TEST_ASSERT_HEX32_WITHIN(5, 5000, 5005); -} - -void testHEX32sWithinDeltaAndCustomMessage(void) -{ - TEST_ASSERT_HEX32_WITHIN_MESSAGE(1, 5000, 5001, "Custom Message."); - TEST_ASSERT_HEX32_WITHIN_MESSAGE(5, 5000, 4996, "Custom Message."); - TEST_ASSERT_HEX32_WITHIN_MESSAGE(5, 5000, 5005, "Custom Message."); -} - -void testHEX32sNotWithinDelta(void) -{ - EXPECT_ABORT_BEGIN - TEST_ASSERT_HEX32_WITHIN(1, 2147483647u, 2147483649u); - VERIFY_FAILS_END -} - -void testHEX32sNotWithinDeltaAndCustomMessage(void) -{ - EXPECT_ABORT_BEGIN - TEST_ASSERT_HEX32_WITHIN_MESSAGE(1, 2147483647u, 2147483649u, "Custom Message."); - VERIFY_FAILS_END -} - -void testHEX32sNotWithinDeltaEvenThoughASignedIntWouldPass(void) -{ - EXPECT_ABORT_BEGIN - TEST_ASSERT_HEX32_WITHIN(5, 1, -1); - VERIFY_FAILS_END -} - -void testHEX32sNotWithinDeltaEvenThoughASignedIntWouldPassAndCustomMessage(void) -{ - EXPECT_ABORT_BEGIN - TEST_ASSERT_HEX32_WITHIN_MESSAGE(5, 1, -1, "Custom Message."); - VERIFY_FAILS_END -} - -void testHEX16sWithinDelta(void) -{ - TEST_ASSERT_HEX16_WITHIN(1, 5000, 5001); - TEST_ASSERT_HEX16_WITHIN(5, 5000, 4996); - TEST_ASSERT_HEX16_WITHIN(5, 5000, 5005); -} - -void testHEX16sWithinDeltaAndCustomMessage(void) -{ - TEST_ASSERT_HEX16_WITHIN_MESSAGE(1, 5000, 5001, "Custom Message."); - TEST_ASSERT_HEX16_WITHIN_MESSAGE(5, 5000, 4996, "Custom Message."); - TEST_ASSERT_HEX16_WITHIN_MESSAGE(5, 5000, 5005, "Custom Message."); -} - -void testHEX16sWithinDeltaWhenThereAreDifferenceOutsideOf16Bits(void) -{ - TEST_ASSERT_HEX16_WITHIN(5, 0x54321, 0x44321); -} - -void testHEX16sWithinDeltaWhenThereAreDifferenceOutsideOf16BitsAndCustomMessage(void) -{ - TEST_ASSERT_HEX16_WITHIN_MESSAGE(5, 0x54321, 0x44321, "Custom Message."); -} - -void testHEX16sNotWithinDelta(void) -{ - EXPECT_ABORT_BEGIN - TEST_ASSERT_HEX16_WITHIN(2, 65535, 0); - VERIFY_FAILS_END -} - -void testHEX16sNotWithinDeltaAndCustomMessage(void) -{ - EXPECT_ABORT_BEGIN - TEST_ASSERT_HEX16_WITHIN_MESSAGE(2, 65535, 0, "Custom Message."); - VERIFY_FAILS_END -} - -void testHEX8sWithinDelta(void) -{ - TEST_ASSERT_HEX8_WITHIN(1, 254, 255); - TEST_ASSERT_HEX8_WITHIN(5, 251, 255); - TEST_ASSERT_HEX8_WITHIN(5, 1, 4); -} - -void testHEX8sWithinDeltaAndCustomMessage(void) -{ - TEST_ASSERT_HEX8_WITHIN_MESSAGE(1, 254, 255, "Custom Message."); - TEST_ASSERT_HEX8_WITHIN_MESSAGE(5, 251, 255, "Custom Message."); - TEST_ASSERT_HEX8_WITHIN_MESSAGE(5, 1, 4, "Custom Message."); -} - -void testHEX8sWithinDeltaWhenThereAreDifferenceOutsideOf8Bits(void) -{ - TEST_ASSERT_HEX8_WITHIN(5, 0x123, 0xF23); -} - -void testHEX8sWithinDeltaWhenThereAreDifferenceOutsideOf8BitsAndCustomMessage(void) -{ - TEST_ASSERT_HEX8_WITHIN_MESSAGE(5, 0x123, 0xF23, "Custom Message."); -} - -void testHEX8sNotWithinDelta(void) -{ - EXPECT_ABORT_BEGIN - TEST_ASSERT_HEX8_WITHIN(2, 255, 0); - VERIFY_FAILS_END -} - -void testHEX8sNotWithinDeltaAndCustomMessage(void) -{ - EXPECT_ABORT_BEGIN - TEST_ASSERT_HEX8_WITHIN_MESSAGE(2, 255, 0, "Custom Message."); - VERIFY_FAILS_END -} - -/*-----------------*/ - -void testUINT32sWithinDelta(void) -{ - TEST_ASSERT_UINT32_WITHIN(1, 5000, 5001); - TEST_ASSERT_UINT32_WITHIN(5, 5000, 4996); - TEST_ASSERT_UINT32_WITHIN(5, 5000, 5005); -} - -void testUINT32sWithinDeltaAndCustomMessage(void) -{ - TEST_ASSERT_UINT32_WITHIN_MESSAGE(1, 5000, 5001, "Custom Message."); - TEST_ASSERT_UINT32_WITHIN_MESSAGE(5, 5000, 4996, "Custom Message."); - TEST_ASSERT_UINT32_WITHIN_MESSAGE(5, 5000, 5005, "Custom Message."); -} - -void testUINT32sNotWithinDelta(void) -{ - EXPECT_ABORT_BEGIN - TEST_ASSERT_UINT32_WITHIN(1, 2147483647u, 2147483649u); - VERIFY_FAILS_END -} - -void testUINT32sNotWithinDeltaAndCustomMessage(void) -{ - EXPECT_ABORT_BEGIN - TEST_ASSERT_UINT32_WITHIN_MESSAGE(1, 2147483647u, 2147483649u, "Custom Message."); - VERIFY_FAILS_END -} - -void testUINT32sNotWithinDeltaEvenThoughASignedIntWouldPass(void) -{ - EXPECT_ABORT_BEGIN - TEST_ASSERT_UINT32_WITHIN(5, 1, -1); - VERIFY_FAILS_END -} - -void testUINT32sNotWithinDeltaEvenThoughASignedIntWouldPassAndCustomMessage(void) -{ - EXPECT_ABORT_BEGIN - TEST_ASSERT_UINT32_WITHIN_MESSAGE(5, 1, -1, "Custom Message."); - VERIFY_FAILS_END -} - -void testUINT16sWithinDelta(void) -{ - TEST_ASSERT_UINT16_WITHIN(1, 5000, 5001); - TEST_ASSERT_UINT16_WITHIN(5, 5000, 4996); - TEST_ASSERT_UINT16_WITHIN(5, 5000, 5005); -} - -void testUINT16sWithinDeltaAndCustomMessage(void) -{ - TEST_ASSERT_UINT16_WITHIN_MESSAGE(1, 5000, 5001, "Custom Message."); - TEST_ASSERT_UINT16_WITHIN_MESSAGE(5, 5000, 4996, "Custom Message."); - TEST_ASSERT_UINT16_WITHIN_MESSAGE(5, 5000, 5005, "Custom Message."); -} - -void testUINT16sWithinDeltaWhenThereAreDifferenceOutsideOf16Bits(void) -{ - TEST_ASSERT_UINT16_WITHIN(5, 0x54321, 0x44321); -} - -void testUINT16sWithinDeltaWhenThereAreDifferenceOutsideOf16BitsAndCustomMessage(void) -{ - TEST_ASSERT_UINT16_WITHIN_MESSAGE(5, 0x54321, 0x44321, "Custom Message."); -} - -void testUINT16sNotWithinDelta(void) -{ - EXPECT_ABORT_BEGIN - TEST_ASSERT_UINT16_WITHIN(2, 65535, 0); - VERIFY_FAILS_END -} - -void testUINT16sNotWithinDeltaAndCustomMessage(void) -{ - EXPECT_ABORT_BEGIN - TEST_ASSERT_UINT16_WITHIN_MESSAGE(2, 65535, 0, "Custom Message."); - VERIFY_FAILS_END -} - -void testUINT8sWithinDelta(void) -{ - TEST_ASSERT_UINT8_WITHIN(1, 254, 255); - TEST_ASSERT_UINT8_WITHIN(5, 251, 255); - TEST_ASSERT_UINT8_WITHIN(5, 1, 4); -} - -void testUINT8sWithinDeltaAndCustomMessage(void) -{ - TEST_ASSERT_UINT8_WITHIN_MESSAGE(1, 254, 255, "Custom Message."); - TEST_ASSERT_UINT8_WITHIN_MESSAGE(5, 251, 255, "Custom Message."); - TEST_ASSERT_UINT8_WITHIN_MESSAGE(5, 1, 4, "Custom Message."); -} - -void testUINT8sWithinDeltaWhenThereAreDifferenceOutsideOf8Bits(void) -{ - TEST_ASSERT_UINT8_WITHIN(5, 0x123, 0xF23); -} - -void testUINT8sWithinDeltaWhenThereAreDifferenceOutsideOf8BitsAndCustomMessage(void) -{ - TEST_ASSERT_UINT8_WITHIN_MESSAGE(5, 0x123, 0xF23, "Custom Message."); -} - -void testUINT8sNotWithinDelta(void) -{ - EXPECT_ABORT_BEGIN - TEST_ASSERT_UINT8_WITHIN(2, 255, 0); - VERIFY_FAILS_END -} - -void testUINT8sNotWithinDeltaAndCustomMessage(void) -{ - EXPECT_ABORT_BEGIN - TEST_ASSERT_UINT8_WITHIN_MESSAGE(2, 255, 0, "Custom Message."); - VERIFY_FAILS_END -} - -void testINT32sWithinDelta(void) -{ - TEST_ASSERT_INT32_WITHIN(1, 5000, 5001); - TEST_ASSERT_INT32_WITHIN(5, 1, -2); - TEST_ASSERT_INT32_WITHIN(5, -2, 1); -} - -void testINT32sWithinDeltaAndCustomMessage(void) -{ - TEST_ASSERT_INT32_WITHIN_MESSAGE(1, 5000, 5001, "Custom Message."); -} - -void testINT32sNotWithinDelta(void) -{ - EXPECT_ABORT_BEGIN - TEST_ASSERT_INT32_WITHIN(1, -3, 1); - VERIFY_FAILS_END -} - -void testINT32sNotWithinDeltaAndDifferenceOverflows(void) -{ - EXPECT_ABORT_BEGIN - TEST_ASSERT_INT32_WITHIN(1, -1, 0x7FFFFFFF); - VERIFY_FAILS_END -} -void testINT32sNotWithinDeltaAndCustomMessage(void) -{ - EXPECT_ABORT_BEGIN - TEST_ASSERT_INT32_WITHIN_MESSAGE(1, -2, 1, "Custom Message."); - VERIFY_FAILS_END -} - -void testINT16sWithinDelta(void) -{ - TEST_ASSERT_INT16_WITHIN(1, 5000, 5001); - TEST_ASSERT_INT16_WITHIN(5, 2, -2); - TEST_ASSERT_INT16_WITHIN(5, -2, 2); -} - -void testINT16sWithinDeltaAndCustomMessage(void) -{ - TEST_ASSERT_INT16_WITHIN_MESSAGE(1, 5000, 5001, "Custom Message."); -} - -void testINT16sWithinDeltaWhenThereAreDifferenceOutsideOf16Bits(void) -{ - TEST_ASSERT_INT16_WITHIN(5, 0x54321, 0x44321); -} - -void testINT16sWithinDeltaWhenThereAreDifferenceOutsideOf16BitsAndCustomMessage(void) -{ - TEST_ASSERT_INT16_WITHIN_MESSAGE(5, 0x54321, 0x44321, "Custom Message."); -} - -void testINT16sNotWithinDelta(void) -{ - EXPECT_ABORT_BEGIN - TEST_ASSERT_INT16_WITHIN(2, 4, -2); - VERIFY_FAILS_END -} - -void testINT16sNotWithinDeltaAndCustomMessage(void) -{ - EXPECT_ABORT_BEGIN - TEST_ASSERT_INT16_WITHIN_MESSAGE(2, 3, 0, "Custom Message."); - VERIFY_FAILS_END -} - -void testINT8sWithinDelta(void) -{ - TEST_ASSERT_INT8_WITHIN(1, 127, 126); - TEST_ASSERT_INT8_WITHIN(5, -2, 2); - TEST_ASSERT_INT8_WITHIN(5, 2, -2); -} - -void testINT8sWithinDeltaAndCustomMessage(void) -{ - TEST_ASSERT_INT8_WITHIN_MESSAGE(5, 1, 4, "Custom Message."); -} - -void testINT8sWithinDeltaWhenThereAreDifferenceOutsideOf8Bits(void) -{ - TEST_ASSERT_INT8_WITHIN(5, 0x123, 0xF23); -} - -void testINT8sWithinDeltaWhenThereAreDifferenceOutsideOf8BitsAndCustomMessage(void) -{ - TEST_ASSERT_INT8_WITHIN_MESSAGE(5, 0x123, 0xF23, "Custom Message."); -} - -void testINT8sNotWithinDelta(void) -{ - EXPECT_ABORT_BEGIN - TEST_ASSERT_INT8_WITHIN(2, -3, 0); - VERIFY_FAILS_END -} - -void testINT8sNotWithinDeltaAndCustomMessage(void) -{ - EXPECT_ABORT_BEGIN - TEST_ASSERT_INT8_WITHIN_MESSAGE(2, -4, 0, "Custom Message."); - VERIFY_FAILS_END -} - -void testCHARsWithinDelta(void) -{ - TEST_ASSERT_CHAR_WITHIN(1, 'M', 'L'); - TEST_ASSERT_CHAR_WITHIN(5, -2, 2); - TEST_ASSERT_CHAR_WITHIN(5, 2, -2); -} - -void testCHARsWithinDeltaAndCustomMessage(void) -{ - TEST_ASSERT_CHAR_WITHIN_MESSAGE(5, 1, 4, "Custom Message."); -} - -void testCHARsWithinDeltaWhenThereAreDifferenceOutsideOf8Bits(void) -{ - TEST_ASSERT_CHAR_WITHIN(5, 0x123, 0xF23); -} - -void testCHARsWithinDeltaWhenThereAreDifferenceOutsideOf8BitsAndCustomMessage(void) -{ - TEST_ASSERT_CHAR_WITHIN_MESSAGE(5, 0x123, 0xF23, "Custom Message."); -} - -void testCHARsNotWithinDelta(void) -{ - EXPECT_ABORT_BEGIN - TEST_ASSERT_CHAR_WITHIN(2, -3, 0); - VERIFY_FAILS_END -} - -void testCHARsNotWithinDeltaAndCustomMessage(void) -{ - EXPECT_ABORT_BEGIN - TEST_ASSERT_CHAR_WITHIN_MESSAGE(2, -4, 0, "Custom Message."); - VERIFY_FAILS_END -} - -/*------------------------*/ - -void testInt64ArrayWithinDelta(void) -{ -#ifndef UNITY_SUPPORT_64 - TEST_IGNORE(); -#else - UNITY_INT64 expected[] = {12345000, -12344995, 12345005}; - UNITY_INT64 actualSmallDelta[] = {12345001, -12344996, 12345005}; - UNITY_INT64 actualBigDelta[] = {12345101, -12344896, 12345055}; - - TEST_ASSERT_INT64_ARRAY_WITHIN(1, expected, actualSmallDelta, 3); - TEST_ASSERT_INT64_ARRAY_WITHIN(110, expected, actualBigDelta, 3); -#endif -} - -void testInt64ArrayWithinDeltaAndMessage(void) -{ -#ifndef UNITY_SUPPORT_64 - TEST_IGNORE(); -#else - UNITY_INT64 expected[] = {12345000, -12344995, 12345005}; - UNITY_INT64 actualSmallDelta[] = {12345001, -12344996, 12345005}; - UNITY_INT64 actualBigDelta[] = {12345101, -12344896, 12345055}; - - TEST_ASSERT_INT64_ARRAY_WITHIN_MESSAGE(1, expected, actualSmallDelta, 3, "Custom Message."); - TEST_ASSERT_INT64_ARRAY_WITHIN_MESSAGE(110, expected, actualBigDelta, 3, "Custom Message."); -#endif -} - -void tesUInt64ArrayNotWithinDelta(void) -{ -#ifndef UNITY_SUPPORT_64 - TEST_IGNORE(); -#else - UNITY_INT64 expected[] = {12345000, -12344995, 12345005}; - UNITY_INT64 actualBigDelta[] = {12345101, -12344896, 12345055}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_UINT64_ARRAY_WITHIN(1, expected, actualBigDelta, 3); - VERIFY_FAILS_END -#endif -} - -void testInt64ArrayNotWithinDeltaAndMessage(void) -{ -#ifndef UNITY_SUPPORT_64 - TEST_IGNORE(); -#else - UNITY_INT64 expected[] = {12345000, -12344995, 12345005}; - UNITY_INT64 actualBigDelta[] = {12345101, -12344896, 12345055}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_INT64_ARRAY_WITHIN_MESSAGE(1, expected, actualBigDelta, 3, "Custom Message."); - VERIFY_FAILS_END -#endif -} - -void testInt64ArrayWithinDeltaPointless(void) -{ -#ifndef UNITY_SUPPORT_64 - TEST_IGNORE(); -#else - UNITY_INT64 expected[] = {12345000, -12344995, 12345005}; - UNITY_INT64 actualBigDelta[] = {12345101, -12344896, 12345055}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_INT64_ARRAY_WITHIN(110, expected, actualBigDelta, 0); - VERIFY_FAILS_END -#endif -} - -void testInt64ArrayWithinDeltaPointlessAndMessage(void) -{ -#ifndef UNITY_SUPPORT_64 - TEST_IGNORE(); -#else - UNITY_INT64 expected[] = {12345000, -12344995, 12345005}; - UNITY_INT64 actualBigDelta[] = {12345101, -12344896, 12345055}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_INT64_ARRAY_WITHIN_MESSAGE(110, expected, actualBigDelta, 0, "Custom Message."); - VERIFY_FAILS_END -#endif -} - -void testInt64ArrayWithinDeltaExpectedNull(void) -{ -#ifndef UNITY_SUPPORT_64 - TEST_IGNORE(); -#else - UNITY_INT64 actualBigDelta[] = {12345101, -12344896, 12345055}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_INT64_ARRAY_WITHIN(110, NULL, actualBigDelta, 3); - VERIFY_FAILS_END -#endif -} - -void testInt64ArrayWithinDeltaExpectedNullAndMessage(void) -{ -#ifndef UNITY_SUPPORT_64 - TEST_IGNORE(); -#else - UNITY_INT64 actualBigDelta[] = {12345101, -12344896, 12345055}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_INT64_ARRAY_WITHIN_MESSAGE(110, NULL, actualBigDelta, 3, "Custom Message."); - VERIFY_FAILS_END -#endif -} - -void testInt64ArrayWithinDeltaActualNull(void) -{ -#ifndef UNITY_SUPPORT_64 - TEST_IGNORE(); -#else - UNITY_INT64 expected[] = {12345000, -12344995, 12345005}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_INT64_ARRAY_WITHIN(110, expected, NULL, 3); - VERIFY_FAILS_END -#endif -} - -void testInt64ArrayWithinDeltaActualNullAndMessage(void) -{ -#ifndef UNITY_SUPPORT_64 - TEST_IGNORE(); -#else - UNITY_INT64 expected[] = {12345000, -12344995, 12345005}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_INT64_ARRAY_WITHIN_MESSAGE(110, expected, NULL, 3, "Custom Message."); - VERIFY_FAILS_END -#endif -} - -void testInt64ArrayWithinDeltaSamePointer(void) -{ -#ifndef UNITY_SUPPORT_64 - TEST_IGNORE(); -#else - UNITY_INT64 expected[] = {12345000, -12344995, 12345005}; - - TEST_ASSERT_UINT64_ARRAY_WITHIN(110, expected, expected, 3); -#endif -} - -void testInt64ArrayWithinDeltaSamePointerAndMessage(void) -{ -#ifndef UNITY_SUPPORT_64 - TEST_IGNORE(); -#else - UNITY_INT64 expected[] = {12345000, -12344995, 12345005}; - - TEST_ASSERT_INT64_ARRAY_WITHIN_MESSAGE(110, expected, expected, 3, "Custom Message."); -#endif -} - -void testIntArrayWithinDelta(void) -{ - UNITY_INT expected[] = {5000, -4995, 5005}; - UNITY_INT actualSmallDelta[] = {5001, -4996, 5005}; - UNITY_INT actualBigDelta[] = {5101, -4896, 5055}; - - TEST_ASSERT_INT_ARRAY_WITHIN(1, expected, actualSmallDelta, 3); - TEST_ASSERT_INT_ARRAY_WITHIN(110, expected, actualBigDelta, 3); -} - -void testIntArrayWithinDeltaAndMessage(void) -{ - UNITY_INT expected[] = {5000, -4995, 5005}; - UNITY_INT actualSmallDelta[] = {5001, -4996, 5005}; - UNITY_INT actualBigDelta[] = {5101, -4896, 5055}; - - TEST_ASSERT_INT_ARRAY_WITHIN_MESSAGE(1, expected, actualSmallDelta, 3, "Custom Message."); - TEST_ASSERT_INT_ARRAY_WITHIN_MESSAGE(110, expected, actualBigDelta, 3, "Custom Message."); -} - -void testIntArrayNotWithinDelta(void) -{ - UNITY_INT expected[] = {5000, -4995, 5005}; - UNITY_INT actualBigDelta[] = {5101, -4896, 5055}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_INT_ARRAY_WITHIN(1, expected, actualBigDelta, 3); - VERIFY_FAILS_END -} - -void testIntArrayNotWithinDeltaAndMessage(void) -{ - UNITY_INT expected[] = {5000, -4995, 5005}; - UNITY_INT actualBigDelta[] = {5101, -4896, 5055}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_INT_ARRAY_WITHIN_MESSAGE(1, expected, actualBigDelta, 3, "Custom Message."); - VERIFY_FAILS_END -} - -void testIntArrayWithinDeltaPointless(void) -{ - UNITY_INT expected[] = {5000, -4995, 5005}; - UNITY_INT actualBigDelta[] = {5101, -4896, 5055}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_INT_ARRAY_WITHIN(110, expected, actualBigDelta, 0); - VERIFY_FAILS_END -} - -void testIntArrayWithinDeltaPointlessAndMessage(void) -{ - UNITY_INT expected[] = {5000, -4995, 5005}; - UNITY_INT actualBigDelta[] = {5101, -4896, 5055}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_INT_ARRAY_WITHIN_MESSAGE(110, expected, actualBigDelta, 0, "Custom Message."); - VERIFY_FAILS_END -} - -void testIntArrayWithinDeltaExpectedNull(void) -{ - UNITY_INT actualBigDelta[] = {5101, -4896, 5055}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_INT_ARRAY_WITHIN(110, NULL, actualBigDelta, 3); - VERIFY_FAILS_END -} - -void testIntArrayWithinDeltaExpectedNullAndMessage(void) -{ - UNITY_INT actualBigDelta[] = {5101, -4896, 5055}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_INT_ARRAY_WITHIN_MESSAGE(110, NULL, actualBigDelta, 3, "Custom Message."); - VERIFY_FAILS_END -} - -void testIntArrayWithinDeltaActualNull(void) -{ - UNITY_INT expected[] = {5000, -4995, 5005}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_INT_ARRAY_WITHIN(110, expected, NULL, 3); - VERIFY_FAILS_END -} - -void testIntArrayWithinDeltaActualNullAndMessage(void) -{ - UNITY_INT expected[] = {5000, -4995, 5005}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_INT_ARRAY_WITHIN_MESSAGE(110, expected, NULL, 3, "Custom Message."); - VERIFY_FAILS_END -} - -void testIntArrayWithinDeltaSamePointer(void) -{ - UNITY_INT expected[] = {5000, -4995, 5005}; - - TEST_ASSERT_INT_ARRAY_WITHIN(110, expected, expected, 3); -} - -void testIntArrayWithinDeltaSamePointerAndMessage(void) -{ - UNITY_INT expected[] = {5000, -4995, 5005}; - - TEST_ASSERT_INT_ARRAY_WITHIN_MESSAGE(110, expected, expected, 3, "Custom Message."); -} - -void testInt16ArrayWithinDelta(void) -{ - UNITY_INT16 expected[] = {5000, -4995, 5005}; - UNITY_INT16 actualSmallDelta[] = {5001, -4996, 5005}; - UNITY_INT16 actualBigDelta[] = {5101, -4896, 5055}; - - TEST_ASSERT_INT16_ARRAY_WITHIN(1, expected, actualSmallDelta, 3); - TEST_ASSERT_INT16_ARRAY_WITHIN(110, expected, actualBigDelta, 3); -} - -void testInt16ArrayWithinDeltaAndMessage(void) -{ - UNITY_INT16 expected[] = {5000, -4995, 5005}; - UNITY_INT16 actualSmallDelta[] = {5001, -4996, 5005}; - UNITY_INT16 actualBigDelta[] = {5101, -4896, 5055}; - - TEST_ASSERT_INT16_ARRAY_WITHIN_MESSAGE(1, expected, actualSmallDelta, 3, "Custom Message."); - TEST_ASSERT_INT16_ARRAY_WITHIN_MESSAGE(110, expected, actualBigDelta, 3, "Custom Message."); -} - -void testInt16ArrayNotWithinDelta(void) -{ - UNITY_INT16 expected[] = {5000, -4995, 5005}; - UNITY_INT16 actualBigDelta[] = {5101, -4896, 5055}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_UINT16_ARRAY_WITHIN(1, expected, actualBigDelta, 3); - VERIFY_FAILS_END -} - -void testInt16ArrayNotWithinDeltaAndMessage(void) -{ - UNITY_INT16 expected[] = {5000, -4995, 5005}; - UNITY_INT16 actualBigDelta[] = {5101, -4896, 5055}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_INT16_ARRAY_WITHIN_MESSAGE(1, expected, actualBigDelta, 3, "Custom Message."); - VERIFY_FAILS_END -} - -void testInt16ArrayWithinDeltaPointless(void) -{ - UNITY_INT16 expected[] = {5000, -4995, 5005}; - UNITY_INT16 actualBigDelta[] = {5101, -4896, 5055}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_INT16_ARRAY_WITHIN(110, expected, actualBigDelta, 0); - VERIFY_FAILS_END -} - -void testInt16ArrayWithinDeltaPointlessAndMessage(void) -{ - UNITY_INT16 expected[] = {5000, -4995, 5005}; - UNITY_INT16 actualBigDelta[] = {5101, -4896, 5055}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_INT16_ARRAY_WITHIN_MESSAGE(110, expected, actualBigDelta, 0, "Custom Message."); - VERIFY_FAILS_END -} - -void testInt16ArrayWithinDeltaExpectedNull(void) -{ - UNITY_INT16 actualBigDelta[] = {5101, -4896, 5055}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_INT16_ARRAY_WITHIN(110, NULL, actualBigDelta, 3); - VERIFY_FAILS_END -} - -void testInt16ArrayWithinDeltaExpectedNullAndMessage(void) -{ - UNITY_INT16 actualBigDelta[] = {5101, -4896, 5055}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_INT16_ARRAY_WITHIN_MESSAGE(110, NULL, actualBigDelta, 3, "Custom Message."); - VERIFY_FAILS_END -} - -void testInt16ArrayWithinDeltaActualNull(void) -{ - UNITY_INT16 expected[] = {5000, -4995, 5005}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_INT16_ARRAY_WITHIN(110, expected, NULL, 3); - VERIFY_FAILS_END -} - -void testInt16ArrayWithinDeltaActualNullAndMessage(void) -{ - UNITY_INT16 expected[] = {5000, -4995, 5005}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_INT16_ARRAY_WITHIN_MESSAGE(110, expected, NULL, 3, "Custom Message."); - VERIFY_FAILS_END -} - -void testInt16ArrayWithinDeltaSamePointer(void) -{ - UNITY_INT16 expected[] = {5000, -4995, 5005}; - - TEST_ASSERT_INT16_ARRAY_WITHIN(110, expected, expected, 3); -} - -void testInt16ArrayWithinDeltaSamePointerAndMessage(void) -{ - UNITY_INT16 expected[] = {5000, -4995, 5005}; - - TEST_ASSERT_INT16_ARRAY_WITHIN_MESSAGE(110, expected, expected, 3, "Custom Message."); -} - -void testInt8ArrayWithinDelta(void) -{ - UNITY_INT8 expected[] = {20, -95, 55}; - UNITY_INT8 actualSmallDelta[] = {21, -94, 55}; - UNITY_INT8 actualBigDelta[] = {11, -86, 45}; - - TEST_ASSERT_INT8_ARRAY_WITHIN(1, expected, actualSmallDelta, 3); - TEST_ASSERT_INT8_ARRAY_WITHIN(11, expected, actualBigDelta, 3); -} - -void testInt8ArrayWithinDeltaAndMessage(void) -{ - UNITY_INT8 expected[] = {20, -95, 55}; - UNITY_INT8 actualSmallDelta[] = {21, -94, 55}; - UNITY_INT8 actualBigDelta[] = {11, -86, 45}; - - TEST_ASSERT_INT8_ARRAY_WITHIN_MESSAGE(1, expected, actualSmallDelta, 3, "Custom Message."); - TEST_ASSERT_INT8_ARRAY_WITHIN_MESSAGE(11, expected, actualBigDelta, 3, "Custom Message."); -} - -void testInt8ArrayNotWithinDelta(void) -{ - UNITY_INT8 expected[] = {20, -95, 55}; - UNITY_INT8 actualBigDelta[] = {11, -86, 45}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_INT8_ARRAY_WITHIN(1, expected, actualBigDelta, 3); - VERIFY_FAILS_END -} - -void testInt8ArrayNotWithinDeltaAndMessage(void) -{ - UNITY_INT8 expected[] = {20, -95, 55}; - UNITY_INT8 actualBigDelta[] = {11, -86, 45}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_INT8_ARRAY_WITHIN_MESSAGE(1, expected, actualBigDelta, 3, "Custom Message."); - VERIFY_FAILS_END -} - -void testInt8ArrayWithinDeltaPointless(void) -{ - UNITY_INT8 expected[] = {20, -95, 55}; - UNITY_INT8 actualBigDelta[] = {11, -86, 45}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_INT8_ARRAY_WITHIN(11, expected, actualBigDelta, 0); - VERIFY_FAILS_END -} - -void testInt8ArrayWithinDeltaPointlessAndMessage(void) -{ - UNITY_INT8 expected[] = {20, -95, 55}; - UNITY_INT8 actualBigDelta[] = {11, -86, 45}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_INT8_ARRAY_WITHIN_MESSAGE(11, expected, actualBigDelta, 0, "Custom Message."); - VERIFY_FAILS_END -} - -void testInt8ArrayWithinDeltaExpectedNull(void) -{ - UNITY_INT8 actualBigDelta[] = {11, -86, 45}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_INT8_ARRAY_WITHIN(11, NULL, actualBigDelta, 3); - VERIFY_FAILS_END -} - -void testInt8ArrayWithinDeltaExpectedNullAndMessage(void) -{ - UNITY_INT8 actualBigDelta[] = {11, -86, 45}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_INT8_ARRAY_WITHIN_MESSAGE(11, NULL, actualBigDelta, 3, "Custom Message."); - VERIFY_FAILS_END -} - -void testInt8ArrayWithinDeltaActualNull(void) -{ - UNITY_INT8 expected[] = {20, -95, 55}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_INT8_ARRAY_WITHIN(11, expected, NULL, 3); - VERIFY_FAILS_END -} - -void testInt8ArrayWithinDeltaActualNullAndMessage(void) -{ - UNITY_INT8 expected[] = {20, -95, 55}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_INT8_ARRAY_WITHIN_MESSAGE(11, expected, NULL, 3, "Custom Message."); - VERIFY_FAILS_END -} - -void testInt8ArrayWithinDeltaSamePointer(void) -{ - UNITY_INT8 expected[] = {20, -95, 55}; - - TEST_ASSERT_INT8_ARRAY_WITHIN(11, expected, expected, 3); -} - -void testInt8ArrayWithinDeltaSamePointerAndMessage(void) -{ - UNITY_INT8 expected[] = {20, -95, 55}; - - TEST_ASSERT_INT8_ARRAY_WITHIN_MESSAGE(11, expected, expected, 3, "Custom Message."); -} - - - - - -void testCHARArrayWithinDelta(void) -{ - char expected[] = {20, -95, 55}; - char actualSmallDelta[] = {21, -94, 55}; - char actualBigDelta[] = {11, -86, 45}; - - TEST_ASSERT_CHAR_ARRAY_WITHIN(1, expected, actualSmallDelta, 3); - TEST_ASSERT_CHAR_ARRAY_WITHIN(11, expected, actualBigDelta, 3); -} - -void testCHARArrayWithinDeltaAndMessage(void) -{ - char expected[] = {20, -95, 55}; - char actualSmallDelta[] = {21, -94, 55}; - char actualBigDelta[] = {11, -86, 45}; - - TEST_ASSERT_CHAR_ARRAY_WITHIN_MESSAGE(1, expected, actualSmallDelta, 3, "Custom Message."); - TEST_ASSERT_CHAR_ARRAY_WITHIN_MESSAGE(11, expected, actualBigDelta, 3, "Custom Message."); -} - -void testCHARArrayNotWithinDelta(void) -{ - char expected[] = {20, -95, 55}; - char actualBigDelta[] = {11, -86, 45}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_CHAR_ARRAY_WITHIN(1, expected, actualBigDelta, 3); - VERIFY_FAILS_END -} - -void testCHARArrayNotWithinDeltaAndMessage(void) -{ - char expected[] = {20, -95, 55}; - char actualBigDelta[] = {11, -86, 45}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_CHAR_ARRAY_WITHIN_MESSAGE(1, expected, actualBigDelta, 3, "Custom Message."); - VERIFY_FAILS_END -} - -void testCHARArrayWithinDeltaPointless(void) -{ - char expected[] = {20, -95, 55}; - char actualBigDelta[] = {11, -86, 45}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_CHAR_ARRAY_WITHIN(11, expected, actualBigDelta, 0); - VERIFY_FAILS_END -} - -void testCHARArrayWithinDeltaPointlessAndMessage(void) -{ - char expected[] = {20, -95, 55}; - char actualBigDelta[] = {11, -86, 45}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_CHAR_ARRAY_WITHIN_MESSAGE(11, expected, actualBigDelta, 0, "Custom Message."); - VERIFY_FAILS_END -} - -void testCHARArrayWithinDeltaExpectedNull(void) -{ - char actualBigDelta[] = {11, -86, 45}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_CHAR_ARRAY_WITHIN(11, NULL, actualBigDelta, 3); - VERIFY_FAILS_END -} - -void testCHARArrayWithinDeltaExpectedNullAndMessage(void) -{ - char actualBigDelta[] = {11, -86, 45}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_CHAR_ARRAY_WITHIN_MESSAGE(11, NULL, actualBigDelta, 3, "Custom Message."); - VERIFY_FAILS_END -} - -void testCHARArrayWithinDeltaActualNull(void) -{ - char expected[] = {20, -95, 55}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_CHAR_ARRAY_WITHIN(11, expected, NULL, 3); - VERIFY_FAILS_END -} - -void testCHARArrayWithinDeltaActualNullAndMessage(void) -{ - char expected[] = {20, -95, 55}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_CHAR_ARRAY_WITHIN_MESSAGE(11, expected, NULL, 3, "Custom Message."); - VERIFY_FAILS_END -} - -void testCHARArrayWithinDeltaSamePointer(void) -{ - char expected[] = {20, -95, 55}; - - TEST_ASSERT_CHAR_ARRAY_WITHIN(11, expected, expected, 3); -} - -void testCHARArrayWithinDeltaSamePointerAndMessage(void) -{ - char expected[] = {20, -95, 55}; - - TEST_ASSERT_CHAR_ARRAY_WITHIN_MESSAGE(11, expected, expected, 3, "Custom Message."); -} - -void testUInt64ArrayWithinDelta(void) -{ -#ifndef UNITY_SUPPORT_64 - TEST_IGNORE(); -#else - UNITY_UINT64 expected[] = {12345000, 12344995, 12345005}; - UNITY_UINT64 actualSmallDelta[] = {12345001, 12344996, 12345005}; - UNITY_UINT64 actualBigDelta[] = {12345101, 12344896, 12345055}; - - TEST_ASSERT_UINT64_ARRAY_WITHIN(1, expected, actualSmallDelta, 3); - TEST_ASSERT_UINT64_ARRAY_WITHIN(110, expected, actualBigDelta, 3); -#endif -} - -void testUInt64ArrayWithinDeltaAndMessage(void) -{ -#ifndef UNITY_SUPPORT_64 - TEST_IGNORE(); -#else - UNITY_UINT64 expected[] = {12345000, 12344995, 12345005}; - UNITY_UINT64 actualSmallDelta[] = {12345001, 12344996, 12345005}; - UNITY_UINT64 actualBigDelta[] = {12345101, 12344896, 12345055}; - - TEST_ASSERT_UINT64_ARRAY_WITHIN_MESSAGE(1, expected, actualSmallDelta, 3, "Custom Message."); - TEST_ASSERT_UINT64_ARRAY_WITHIN_MESSAGE(110, expected, actualBigDelta, 3, "Custom Message."); -#endif -} - -void testUInt64ArrayNotWithinDelta(void) -{ -#ifndef UNITY_SUPPORT_64 - TEST_IGNORE(); -#else - UNITY_UINT64 expected[] = {12345000, 12344995, 12345005}; - UNITY_UINT64 actualBigDelta[] = {12345101, 12344896, 12345055}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_UINT64_ARRAY_WITHIN(1, expected, actualBigDelta, 3); - VERIFY_FAILS_END -#endif -} - -void testUInt64ArrayNotWithinDeltaAndMessage(void) -{ -#ifndef UNITY_SUPPORT_64 - TEST_IGNORE(); -#else - UNITY_UINT64 expected[] = {12345000, 12344995, 12345005}; - UNITY_UINT64 actualBigDelta[] = {12345101, 12344896, 12345055}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_UINT64_ARRAY_WITHIN_MESSAGE(1, expected, actualBigDelta, 3, "Custom Message."); - VERIFY_FAILS_END -#endif -} - -void testUInt64ArrayWithinDeltaPointless(void) -{ -#ifndef UNITY_SUPPORT_64 - TEST_IGNORE(); -#else - UNITY_UINT64 expected[] = {12345000, 12344995, 12345005}; - UNITY_UINT64 actualBigDelta[] = {12345101, 12344896, 12345055}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_UINT64_ARRAY_WITHIN(110, expected, actualBigDelta, 0); - VERIFY_FAILS_END -#endif -} - -void testUInt64ArrayWithinDeltaPointlessAndMessage(void) -{ -#ifndef UNITY_SUPPORT_64 - TEST_IGNORE(); -#else - UNITY_UINT64 expected[] = {12345000, 12344995, 12345005}; - UNITY_UINT64 actualBigDelta[] = {12345101, 12344896, 12345055}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_UINT64_ARRAY_WITHIN_MESSAGE(110, expected, actualBigDelta, 0, "Custom Message."); - VERIFY_FAILS_END -#endif -} - -void testUInt64ArrayWithinDeltaExpectedNull(void) -{ -#ifndef UNITY_SUPPORT_64 - TEST_IGNORE(); -#else - UNITY_UINT64 actualBigDelta[] = {12345101, 12344896, 12345055}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_UINT64_ARRAY_WITHIN(110, NULL, actualBigDelta, 3); - VERIFY_FAILS_END -#endif -} - -void testUInt64ArrayWithinDeltaExpectedNullAndMessage(void) -{ -#ifndef UNITY_SUPPORT_64 - TEST_IGNORE(); -#else - UNITY_UINT64 actualBigDelta[] = {12345101, 12344896, 12345055}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_UINT64_ARRAY_WITHIN_MESSAGE(110, NULL, actualBigDelta, 3, "Custom Message."); - VERIFY_FAILS_END -#endif -} - -void testUInt64ArrayWithinDeltaActualNull(void) -{ -#ifndef UNITY_SUPPORT_64 - TEST_IGNORE(); -#else - UNITY_UINT64 expected[] = {12345000, 12344995, 12345005}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_UINT64_ARRAY_WITHIN(110, expected, NULL, 3); - VERIFY_FAILS_END -#endif -} - -void testUInt64ArrayWithinDeltaActualNullAndMessage(void) -{ -#ifndef UNITY_SUPPORT_64 - TEST_IGNORE(); -#else - UNITY_UINT64 expected[] = {12345000, 12344995, 12345005}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_UINT64_ARRAY_WITHIN_MESSAGE(110, expected, NULL, 3, "Custom Message."); - VERIFY_FAILS_END -#endif -} - -void testUInt64ArrayWithinDeltaSamePointer(void) -{ -#ifndef UNITY_SUPPORT_64 - TEST_IGNORE(); -#else - UNITY_UINT64 expected[] = {12345000, 12344995, 12345005}; - - TEST_ASSERT_UINT64_ARRAY_WITHIN(110, expected, expected, 3); -#endif -} - -void testUInt64ArrayWithinDeltaSamePointerAndMessage(void) -{ -#ifndef UNITY_SUPPORT_64 - TEST_IGNORE(); -#else - UNITY_UINT64 expected[] = {12345000, 12344995, 12345005}; - - TEST_ASSERT_UINT64_ARRAY_WITHIN_MESSAGE(110, expected, expected, 3, "Custom Message."); -#endif -} - -void testUIntArrayWithinDelta(void) -{ - UNITY_UINT expected[] = {125000, 124995, 125005}; - UNITY_UINT actualSmallDelta[] = {125001, 124996, 125005}; - UNITY_UINT actualBigDelta[] = {125101, 124896, 125055}; - - TEST_ASSERT_UINT_ARRAY_WITHIN(1, expected, actualSmallDelta, 3); - TEST_ASSERT_UINT_ARRAY_WITHIN(110, expected, actualBigDelta, 3); -} - -void testUIntArrayWithinDeltaAndMessage(void) -{ - UNITY_UINT expected[] = {125000, 124995, 125005}; - UNITY_UINT actualSmallDelta[] = {125001, 124996, 125005}; - UNITY_UINT actualBigDelta[] = {125101, 124896, 125055}; - - TEST_ASSERT_UINT_ARRAY_WITHIN_MESSAGE(1, expected, actualSmallDelta, 3, "Custom Message."); - TEST_ASSERT_UINT_ARRAY_WITHIN_MESSAGE(110, expected, actualBigDelta, 3, "Custom Message."); -} - -void testUIntArrayNotWithinDelta(void) -{ - UNITY_UINT expected[] = {125000, 124995, 125005}; - UNITY_UINT actualBigDelta[] = {125101, 124896, 125055}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_UINT_ARRAY_WITHIN(1, expected, actualBigDelta, 3); - VERIFY_FAILS_END -} - -void testUIntArrayNotWithinDeltaAndMessage(void) -{ - UNITY_UINT expected[] = {125000, 124995, 125005}; - UNITY_UINT actualBigDelta[] = {125101, 124896, 125055}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_UINT_ARRAY_WITHIN_MESSAGE(1, expected, actualBigDelta, 3, "Custom Message."); - VERIFY_FAILS_END -} - -void testUIntArrayWithinDeltaPointless(void) -{ - UNITY_UINT expected[] = {125000, 124995, 125005}; - UNITY_UINT actualBigDelta[] = {125101, 124896, 125055}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_UINT_ARRAY_WITHIN(110, expected, actualBigDelta, 0); - VERIFY_FAILS_END -} - -void testUIntArrayWithinDeltaPointlessAndMessage(void) -{ - UNITY_UINT expected[] = {125000, 124995, 125005}; - UNITY_UINT actualBigDelta[] = {125101, 124896, 125055}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_UINT_ARRAY_WITHIN_MESSAGE(110, expected, actualBigDelta, 0, "Custom Message."); - VERIFY_FAILS_END -} - -void testUIntArrayWithinDeltaExpectedNull(void) -{ - UNITY_UINT actualBigDelta[] = {125101, 124896, 125055}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_UINT_ARRAY_WITHIN(110, NULL, actualBigDelta, 3); - VERIFY_FAILS_END -} - -void testUIntArrayWithinDeltaExpectedNullAndMessage(void) -{ - UNITY_UINT actualBigDelta[] = {125101, 124896, 125055}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_UINT_ARRAY_WITHIN_MESSAGE(110, NULL, actualBigDelta, 3, "Custom Message."); - VERIFY_FAILS_END -} - -void testUIntArrayWithinDeltaActualNull(void) -{ - UNITY_UINT expected[] = {125000, 124995, 125005}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_UINT_ARRAY_WITHIN(110, expected, NULL, 3); - VERIFY_FAILS_END -} - -void testUIntArrayWithinDeltaActualNullAndMessage(void) -{ - UNITY_UINT expected[] = {125000, 124995, 125005}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_UINT_ARRAY_WITHIN_MESSAGE(110, expected, NULL, 3, "Custom Message."); - VERIFY_FAILS_END -} - -void testUIntArrayWithinDeltaSamePointer(void) -{ - UNITY_UINT expected[] = {125000, 124995, 125005}; - - TEST_ASSERT_UINT_ARRAY_WITHIN(110, expected, expected, 3); -} - -void testUIntArrayWithinDeltaSamePointerAndMessage(void) -{ - UNITY_UINT expected[] = {125000, 124995, 125005}; - - TEST_ASSERT_UINT_ARRAY_WITHIN_MESSAGE(110, expected, expected, 3, "Custom Message."); -} - -void testUInt16ArrayWithinDelta(void) -{ - UNITY_UINT16 expected[] = {5000, 4995, 5005}; - UNITY_UINT16 actualSmallDelta[] = {5001, 4996, 5005}; - UNITY_UINT16 actualBigDelta[] = {5101, 4896, 5055}; - - TEST_ASSERT_UINT16_ARRAY_WITHIN(1, expected, actualSmallDelta, 3); - TEST_ASSERT_UINT16_ARRAY_WITHIN(110, expected, actualBigDelta, 3); -} - -void testUInt16ArrayWithinDeltaAndMessage(void) -{ - UNITY_UINT16 expected[] = {5000, 4995, 5005}; - UNITY_UINT16 actualSmallDelta[] = {5001, 4996, 5005}; - UNITY_UINT16 actualBigDelta[] = {5101, 4896, 5055}; - - TEST_ASSERT_UINT16_ARRAY_WITHIN_MESSAGE(1, expected, actualSmallDelta, 3, "Custom Message."); - TEST_ASSERT_UINT16_ARRAY_WITHIN_MESSAGE(110, expected, actualBigDelta, 3, "Custom Message."); -} - -void testUInt16ArrayNotWithinDelta(void) -{ - UNITY_UINT16 expected[] = {5000, 4995, 5005}; - UNITY_UINT16 actualBigDelta[] = {5101, 4896, 5055}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_UINT16_ARRAY_WITHIN(1, expected, actualBigDelta, 3); - VERIFY_FAILS_END -} - -void testUInt16ArrayNotWithinDeltaAndMessage(void) -{ - UNITY_UINT16 expected[] = {5000, 4995, 5005}; - UNITY_UINT16 actualBigDelta[] = {5101, 4896, 5055}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_UINT16_ARRAY_WITHIN_MESSAGE(1, expected, actualBigDelta, 3, "Custom Message."); - VERIFY_FAILS_END -} - -void testUInt16ArrayWithinDeltaPointless(void) -{ - UNITY_UINT16 expected[] = {5000, 4995, 5005}; - UNITY_UINT16 actualBigDelta[] = {5101, 4896, 5055}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_UINT16_ARRAY_WITHIN(110, expected, actualBigDelta, 0); - VERIFY_FAILS_END -} - -void testUInt16ArrayWithinDeltaPointlessAndMessage(void) -{ - UNITY_UINT16 expected[] = {5000, 4995, 5005}; - UNITY_UINT16 actualBigDelta[] = {5101, 4896, 5055}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_UINT16_ARRAY_WITHIN_MESSAGE(110, expected, actualBigDelta, 0, "Custom Message."); - VERIFY_FAILS_END -} - -void testUInt16ArrayWithinDeltaExpectedNull(void) -{ - UNITY_UINT16 actualBigDelta[] = {5101, 4896, 5055}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_UINT16_ARRAY_WITHIN(110, NULL, actualBigDelta, 3); - VERIFY_FAILS_END -} - -void testUInt16ArrayWithinDeltaExpectedNullAndMessage(void) -{ - UNITY_UINT16 actualBigDelta[] = {5101, 4896, 5055}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_UINT16_ARRAY_WITHIN_MESSAGE(110, NULL, actualBigDelta, 3, "Custom Message."); - VERIFY_FAILS_END -} - -void testUInt16ArrayWithinDeltaActualNull(void) -{ - UNITY_UINT16 expected[] = {5000, 4995, 5005}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_UINT16_ARRAY_WITHIN(110, expected, NULL, 3); - VERIFY_FAILS_END -} - -void testUInt16ArrayWithinDeltaActualNullAndMessage(void) -{ - UNITY_UINT16 expected[] = {5000, 4995, 5005}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_UINT16_ARRAY_WITHIN_MESSAGE(110, expected, NULL, 3, "Custom Message."); - VERIFY_FAILS_END -} - -void testUInt16ArrayWithinDeltaSamePointer(void) -{ - UNITY_UINT16 expected[] = {5000, 4995, 5005}; - - TEST_ASSERT_UINT16_ARRAY_WITHIN(110, expected, expected, 3); -} - -void testUInt16ArrayWithinDeltaSamePointerAndMessage(void) -{ - UNITY_UINT16 expected[] = {5000, 4995, 5005}; - - TEST_ASSERT_UINT16_ARRAY_WITHIN_MESSAGE(110, expected, expected, 3, "Custom Message."); -} - -void testUInt8ArrayWithinDelta(void) -{ - UNITY_UINT8 expected[] = {20, 95, 55}; - UNITY_UINT8 actualSmallDelta[] = {21, 94, 55}; - UNITY_UINT8 actualBigDelta[] = {11, 86, 45}; - - TEST_ASSERT_UINT8_ARRAY_WITHIN(1, expected, actualSmallDelta, 3); - TEST_ASSERT_UINT8_ARRAY_WITHIN(11, expected, actualBigDelta, 3); -} - -void testUInt8ArrayWithinDeltaAndMessage(void) -{ - UNITY_UINT8 expected[] = {20, 95, 55}; - UNITY_UINT8 actualSmallDelta[] = {21, 94, 55}; - UNITY_UINT8 actualBigDelta[] = {11, 86, 45}; - - TEST_ASSERT_UINT8_ARRAY_WITHIN_MESSAGE(1, expected, actualSmallDelta, 3, "Custom Message."); - TEST_ASSERT_UINT8_ARRAY_WITHIN_MESSAGE(11, expected, actualBigDelta, 3, "Custom Message."); -} - -void testUInt8ArrayNotWithinDelta(void) -{ - UNITY_UINT8 expected[] = {20, 95, 55}; - UNITY_UINT8 actualBigDelta[] = {11, 86, 45}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_UINT8_ARRAY_WITHIN(1, expected, actualBigDelta, 3); - VERIFY_FAILS_END -} - -void testUInt8ArrayNotWithinDeltaAndMessage(void) -{ - UNITY_UINT8 expected[] = {20, 95, 55}; - UNITY_UINT8 actualBigDelta[] = {11, 86, 45}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_UINT8_ARRAY_WITHIN_MESSAGE(1, expected, actualBigDelta, 3, "Custom Message."); - VERIFY_FAILS_END -} - -void testUInt8ArrayWithinDeltaPointless(void) -{ - UNITY_UINT8 expected[] = {20, 95, 55}; - UNITY_UINT8 actualBigDelta[] = {11, 86, 45}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_UINT8_ARRAY_WITHIN(11, expected, actualBigDelta, 0); - VERIFY_FAILS_END -} - -void testUInt8ArrayWithinDeltaPointlessAndMessage(void) -{ - UNITY_UINT8 expected[] = {20, 95, 55}; - UNITY_UINT8 actualBigDelta[] = {11, 86, 45}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_UINT8_ARRAY_WITHIN_MESSAGE(11, expected, actualBigDelta, 0, "Custom Message."); - VERIFY_FAILS_END -} - -void testUInt8ArrayWithinDeltaExpectedNull(void) -{ - UNITY_UINT8 actualBigDelta[] = {11, 86, 45}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_UINT8_ARRAY_WITHIN(11, NULL, actualBigDelta, 3); - VERIFY_FAILS_END -} - -void testUInt8ArrayWithinDeltaExpectedNullAndMessage(void) -{ - UNITY_UINT8 actualBigDelta[] = {11, 86, 45}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_UINT8_ARRAY_WITHIN_MESSAGE(11, NULL, actualBigDelta, 3, "Custom Message."); - VERIFY_FAILS_END -} - -void testUInt8ArrayWithinDeltaActualNull(void) -{ - UNITY_UINT8 expected[] = {20, 95, 55}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_UINT8_ARRAY_WITHIN(11, expected, NULL, 3); - VERIFY_FAILS_END -} - -void testUInt8ArrayWithinDeltaActualNullAndMessage(void) -{ - UNITY_UINT8 expected[] = {20, 95, 55}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_UINT8_ARRAY_WITHIN_MESSAGE(11, expected, NULL, 3, "Custom Message."); - VERIFY_FAILS_END -} - -void testUInt8ArrayWithinDeltaSamePointer(void) -{ - UNITY_UINT8 expected[] = {20, 95, 55}; - - TEST_ASSERT_UINT8_ARRAY_WITHIN(11, expected, expected, 3); -} - -void testUInt8ArrayWithinDeltaSamePointerAndMessage(void) -{ - UNITY_UINT8 expected[] = {20, 95, 55}; - - TEST_ASSERT_UINT8_ARRAY_WITHIN_MESSAGE(11, expected, expected, 3, "Custom Message."); -} - -void testHEX64ArrayWithinDelta(void) -{ -#ifndef UNITY_SUPPORT_64 - TEST_IGNORE(); -#else - UNITY_UINT64 expected[] = {0xABCD123400000000, 0xABCD112200000000, 0xABCD127700000000}; - UNITY_UINT64 actualSmallDelta[] = {0xABCD123500000000, 0xABCD112100000000, 0xABCD127700000000}; - UNITY_UINT64 actualBigDelta[] = {0xABCD126700000000, 0xABCD118800000000, 0xABCD12AC00000000}; - - TEST_ASSERT_HEX64_ARRAY_WITHIN(0x100000000, expected, actualSmallDelta, 3); - TEST_ASSERT_HEX64_ARRAY_WITHIN(0x6E00000000, expected, actualBigDelta, 3); -#endif -} - -void testHEX64ArrayWithinDeltaAndMessage(void) -{ -#ifndef UNITY_SUPPORT_64 - TEST_IGNORE(); -#else - UNITY_UINT64 expected[] = {0xABCD123400000000, 0xABCD112200000000, 0xABCD127700000000}; - UNITY_UINT64 actualSmallDelta[] = {0xABCD123500000000, 0xABCD112100000000, 0xABCD127700000000}; - UNITY_UINT64 actualBigDelta[] = {0xABCD126700000000, 0xABCD118800000000, 0xABCD12AC00000000}; - - TEST_ASSERT_HEX64_ARRAY_WITHIN_MESSAGE(0x100000000, expected, actualSmallDelta, 3, "Custom Message."); - TEST_ASSERT_HEX64_ARRAY_WITHIN_MESSAGE(0x6E00000000, expected, actualBigDelta, 3, "Custom Message."); -#endif -} - -void testHEX64ArrayNotWithinDelta(void) -{ -#ifndef UNITY_SUPPORT_64 - TEST_IGNORE(); -#else - UNITY_UINT64 expected[] = {0xABCD123400000000, 0xABCD112200000000, 0xABCD127700000000}; - UNITY_UINT64 actualBigDelta[] = {0xABCD126700000000, 0xABCD118800000000, 0xABCD12AC00000000}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_HEX64_ARRAY_WITHIN(0x100000000, expected, actualBigDelta, 3); - VERIFY_FAILS_END -#endif -} - -void testHEX64ArrayNotWithinDeltaAndMessage(void) -{ -#ifndef UNITY_SUPPORT_64 - TEST_IGNORE(); -#else - UNITY_UINT64 expected[] = {0xABCD123400000000, 0xABCD112200000000, 0xABCD127700000000}; - UNITY_UINT64 actualBigDelta[] = {0xABCD126700000000, 0xABCD118800000000, 0xABCD12AC00000000}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_HEX64_ARRAY_WITHIN_MESSAGE(0x100000000, expected, actualBigDelta, 3, "Custom Message."); - VERIFY_FAILS_END -#endif -} - -void testHEX64ArrayWithinDeltaPointless(void) -{ -#ifndef UNITY_SUPPORT_64 - TEST_IGNORE(); -#else - UNITY_UINT64 expected[] = {0xABCD123400000000, 0xABCD112200000000, 0xABCD127700000000}; - UNITY_UINT64 actualBigDelta[] = {0xABCD126700000000, 0xABCD118800000000, 0xABCD12AC00000000}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_HEX64_ARRAY_WITHIN(0x6E00000000, expected, actualBigDelta, 0); - VERIFY_FAILS_END -#endif -} - -void testHEX64ArrayWithinDeltaPointlessAndMessage(void) -{ -#ifndef UNITY_SUPPORT_64 - TEST_IGNORE(); -#else - UNITY_UINT64 expected[] = {0xABCD123400000000, 0xABCD112200000000, 0xABCD127700000000}; - UNITY_UINT64 actualBigDelta[] = {0xABCD126700000000, 0xABCD118800000000, 0xABCD12AC00000000}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_HEX64_ARRAY_WITHIN_MESSAGE(0x6E00000000, expected, actualBigDelta, 0, "Custom Message."); - VERIFY_FAILS_END -#endif -} - -void testHEX64ArrayWithinDeltaExpectedNull(void) -{ -#ifndef UNITY_SUPPORT_64 - TEST_IGNORE(); -#else - UNITY_UINT64 actualBigDelta[] = {0xABCD126700000000, 0xABCD118800000000, 0xABCD12AC00000000}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_HEX64_ARRAY_WITHIN(0x6E00000000, NULL, actualBigDelta, 3); - VERIFY_FAILS_END -#endif -} - -void testHEX64ArrayWithinDeltaExpectedNullAndMessage(void) -{ -#ifndef UNITY_SUPPORT_64 - TEST_IGNORE(); -#else - UNITY_UINT64 actualBigDelta[] = {0xABCD126700000000, 0xABCD118800000000, 0xABCD12AC00000000}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_HEX64_ARRAY_WITHIN_MESSAGE(0x6E00000000, NULL, actualBigDelta, 3, "Custom Message."); - VERIFY_FAILS_END -#endif -} - -void testHEX64ArrayWithinDeltaActualNull(void) -{ -#ifndef UNITY_SUPPORT_64 - TEST_IGNORE(); -#else - UNITY_UINT64 expected[] = {0xABCD123400000000, 0xABCD112200000000, 0xABCD127700000000}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_HEX64_ARRAY_WITHIN(0x6E00000000, expected, NULL, 3); - VERIFY_FAILS_END -#endif -} - -void testHEX64ArrayWithinDeltaActualNullAndMessage(void) -{ -#ifndef UNITY_SUPPORT_64 - TEST_IGNORE(); -#else - UNITY_UINT64 expected[] = {0xABCD123400000000, 0xABCD112200000000, 0xABCD127700000000}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_HEX64_ARRAY_WITHIN_MESSAGE(0x6E00000000, expected, NULL, 3, "Custom Message."); - VERIFY_FAILS_END -#endif -} - -void testHEX64ArrayWithinDeltaSamePointer(void) -{ -#ifndef UNITY_SUPPORT_64 - TEST_IGNORE(); -#else - UNITY_UINT64 expected[] = {0xABCD123400000000, 0xABCD112200000000, 0xABCD127700000000}; - - TEST_ASSERT_HEX64_ARRAY_WITHIN(0x6E00000000, expected, expected, 3); -#endif -} - -void testHEX64ArrayWithinDeltaSamePointerAndMessage(void) -{ -#ifndef UNITY_SUPPORT_64 - TEST_IGNORE(); -#else - UNITY_UINT64 expected[] = {0xABCD123400000000, 0xABCD112200000000, 0xABCD127700000000}; - - TEST_ASSERT_HEX64_ARRAY_WITHIN_MESSAGE(0x6E00000000, expected, expected, 3, "Custom Message."); -#endif -} - -void testHEX32ArrayWithinDelta(void) -{ - UNITY_UINT expected[] = {0xABCD1234, 0xABCD1122, 0xABCD1277}; - UNITY_UINT actualSmallDelta[] = {0xABCD1235, 0xABCD1121, 0xABCD1277}; - UNITY_UINT actualBigDelta[] = {0xABCD1267, 0xABCD1188, 0xABCD12AC}; - - TEST_ASSERT_HEX32_ARRAY_WITHIN(1, expected, actualSmallDelta, 3); - TEST_ASSERT_HEX32_ARRAY_WITHIN(110, expected, actualBigDelta, 3); -} - -void testHEX32ArrayWithinDeltaAndMessage(void) -{ - UNITY_UINT expected[] = {0xABCD1234, 0xABCD1122, 0xABCD1277}; - UNITY_UINT actualSmallDelta[] = {0xABCD1235, 0xABCD1121, 0xABCD1277}; - UNITY_UINT actualBigDelta[] = {0xABCD1267, 0xABCD1188, 0xABCD12AC}; - - TEST_ASSERT_HEX32_ARRAY_WITHIN_MESSAGE(1, expected, actualSmallDelta, 3, "Custom Message."); - TEST_ASSERT_HEX32_ARRAY_WITHIN_MESSAGE(110, expected, actualBigDelta, 3, "Custom Message."); -} - -void testHEX32ArrayNotWithinDelta(void) -{ - UNITY_UINT expected[] = {0xABCD1234, 0xABCD1122, 0xABCD1277}; - UNITY_UINT actualBigDelta[] = {0xABCD1267, 0xABCD1188, 0xABCD12AC}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_HEX32_ARRAY_WITHIN(1, expected, actualBigDelta, 3); - VERIFY_FAILS_END -} - -void testHEX32ArrayNotWithinDeltaAndMessage(void) -{ - UNITY_UINT expected[] = {0xABCD1234, 0xABCD1122, 0xABCD1277}; - UNITY_UINT actualBigDelta[] = {0xABCD1267, 0xABCD1188, 0xABCD12AC}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_HEX32_ARRAY_WITHIN_MESSAGE(1, expected, actualBigDelta, 3, "Custom Message."); - VERIFY_FAILS_END -} - -void testHEX32ArrayWithinDeltaPointless(void) -{ - UNITY_UINT expected[] = {0xABCD1234, 0xABCD1122, 0xABCD1277}; - UNITY_UINT actualBigDelta[] = {0xABCD1267, 0xABCD1188, 0xABCD12AC}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_HEX32_ARRAY_WITHIN(110, expected, actualBigDelta, 0); - VERIFY_FAILS_END -} - -void testHEX32ArrayWithinDeltaPointlessAndMessage(void) -{ - UNITY_UINT expected[] = {0xABCD1234, 0xABCD1122, 0xABCD1277}; - UNITY_UINT actualBigDelta[] = {0xABCD1267, 0xABCD1188, 0xABCD12AC}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_HEX32_ARRAY_WITHIN_MESSAGE(110, expected, actualBigDelta, 0, "Custom Message."); - VERIFY_FAILS_END -} - -void testHEX32ArrayWithinDeltaExpectedNull(void) -{ - UNITY_UINT actualBigDelta[] = {0xABCD1267, 0xABCD1188, 0xABCD12AC}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_HEX32_ARRAY_WITHIN(110, NULL, actualBigDelta, 3); - VERIFY_FAILS_END -} - -void testHEX32ArrayWithinDeltaExpectedNullAndMessage(void) -{ - UNITY_UINT actualBigDelta[] = {0xABCD1267, 0xABCD1188, 0xABCD12AC}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_HEX32_ARRAY_WITHIN_MESSAGE(110, NULL, actualBigDelta, 3, "Custom Message."); - VERIFY_FAILS_END -} - -void testHEX32ArrayWithinDeltaActualNull(void) -{ - UNITY_UINT expected[] = {0xABCD1234, 0xABCD1122, 0xABCD1277}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_HEX32_ARRAY_WITHIN(110, expected, NULL, 3); - VERIFY_FAILS_END -} - -void testHEX32ArrayWithinDeltaActualNullAndMessage(void) -{ - UNITY_UINT expected[] = {0xABCD1234, 0xABCD1122, 0xABCD1277}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_HEX32_ARRAY_WITHIN_MESSAGE(110, expected, NULL, 3, "Custom Message."); - VERIFY_FAILS_END -} - -void testHEX32ArrayWithinDeltaSamePointer(void) -{ - UNITY_UINT expected[] = {0xABCD1234, 0xABCD1122, 0xABCD1277}; - - TEST_ASSERT_HEX32_ARRAY_WITHIN(110, expected, expected, 3); -} - -void testHEX32ArrayWithinDeltaSamePointerAndMessage(void) -{ - UNITY_UINT expected[] = {0xABCD1234, 0xABCD1122, 0xABCD1277}; - - TEST_ASSERT_HEX32_ARRAY_WITHIN_MESSAGE(110, expected, expected, 3, "Custom Message."); -} - - -void testHEX16ArrayWithinDelta(void) -{ - UNITY_UINT16 expected[] = {0x1234, 0x1122, 0x1277}; - UNITY_UINT16 actualSmallDelta[] = {0x1235, 0x1121, 0x1277}; - UNITY_UINT16 actualBigDelta[] = {0x1267, 0x1188, 0x12AC}; - - TEST_ASSERT_HEX16_ARRAY_WITHIN(1, expected, actualSmallDelta, 3); - TEST_ASSERT_HEX16_ARRAY_WITHIN(110, expected, actualBigDelta, 3); -} - -void testHEX16ArrayWithinDeltaAndMessage(void) -{ - UNITY_UINT16 expected[] = {0x1234, 0x1122, 0x1277}; - UNITY_UINT16 actualSmallDelta[] = {0x1235, 0x1121, 0x1277}; - UNITY_UINT16 actualBigDelta[] = {0x1267, 0x1188, 0x12AC}; - - TEST_ASSERT_HEX16_ARRAY_WITHIN_MESSAGE(1, expected, actualSmallDelta, 3, "Custom Message."); - TEST_ASSERT_HEX16_ARRAY_WITHIN_MESSAGE(110, expected, actualBigDelta, 3, "Custom Message."); -} - -void testHEX16ArrayNotWithinDelta(void) -{ - UNITY_UINT16 expected[] = {0x1234, 0x1122, 0x1277}; - UNITY_UINT16 actualBigDelta[] = {0x1267, 0x1188, 0x12AC}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_HEX16_ARRAY_WITHIN(1, expected, actualBigDelta, 3); - VERIFY_FAILS_END -} - -void testHEX16ArrayNotWithinDeltaAndMessage(void) -{ - UNITY_UINT16 expected[] = {0x1234, 0x1122, 0x1277}; - UNITY_UINT16 actualBigDelta[] = {0x1267, 0x1188, 0x12AC}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_HEX16_ARRAY_WITHIN_MESSAGE(1, expected, actualBigDelta, 3, "Custom Message."); - VERIFY_FAILS_END -} - -void testHEX16ArrayWithinDeltaPointless(void) -{ - UNITY_UINT16 expected[] = {0x1234, 0x1122, 0x1277}; - UNITY_UINT16 actualBigDelta[] = {0x1267, 0x1188, 0x12AC}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_HEX16_ARRAY_WITHIN(110, expected, actualBigDelta, 0); - VERIFY_FAILS_END -} - -void testHEX16ArrayWithinDeltaPointlessAndMessage(void) -{ - UNITY_UINT16 expected[] = {0x1234, 0x1122, 0x1277}; - UNITY_UINT16 actualBigDelta[] = {0x1267, 0x1188, 0x12AC}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_HEX16_ARRAY_WITHIN_MESSAGE(110, expected, actualBigDelta, 0, "Custom Message."); - VERIFY_FAILS_END -} - -void testHEX16ArrayWithinDeltaExpectedNull(void) -{ - UNITY_UINT16 actualBigDelta[] = {0x1267, 0x1188, 0x12AC}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_HEX16_ARRAY_WITHIN(110, NULL, actualBigDelta, 3); - VERIFY_FAILS_END -} - -void testHEX16ArrayWithinDeltaExpectedNullAndMessage(void) -{ - UNITY_UINT16 actualBigDelta[] = {0x1267, 0x1188, 0x12AC}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_HEX16_ARRAY_WITHIN_MESSAGE(110, NULL, actualBigDelta, 3, "Custom Message."); - VERIFY_FAILS_END -} - -void testHEX16ArrayWithinDeltaActualNull(void) -{ - UNITY_UINT16 expected[] = {0x1234, 0x1122, 0x1277}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_HEX16_ARRAY_WITHIN(110, expected, NULL, 3); - VERIFY_FAILS_END -} - -void testHEX16ArrayWithinDeltaActualNullAndMessage(void) -{ - UNITY_UINT16 expected[] = {0x1234, 0x1122, 0x1277}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_HEX16_ARRAY_WITHIN_MESSAGE(110, expected, NULL, 3, "Custom Message."); - VERIFY_FAILS_END -} - -void testHEX16ArrayWithinDeltaSamePointer(void) -{ - UNITY_UINT16 expected[] = {0x1234, 0x1122, 0x1277}; - - TEST_ASSERT_HEX16_ARRAY_WITHIN(110, expected, expected, 3); -} - -void testHEX16ArrayWithinDeltaSamePointerAndMessage(void) -{ - UNITY_UINT16 expected[] = {0x1234, 0x1122, 0x1277}; - - TEST_ASSERT_HEX16_ARRAY_WITHIN_MESSAGE(110, expected, expected, 3, "Custom Message."); -} - -void testHEX8ArrayWithinDelta(void) -{ - UNITY_UINT8 expected[] = {0x34, 0x22, 0x77}; - UNITY_UINT8 actualSmallDelta[] = {0x35, 0x21, 0x77}; - UNITY_UINT8 actualBigDelta[] = {0x47, 0x48, 0x4C}; - - TEST_ASSERT_HEX8_ARRAY_WITHIN(1, expected, actualSmallDelta, 3); - TEST_ASSERT_HEX8_ARRAY_WITHIN(60, expected, actualBigDelta, 3); -} - -void testHEX8ArrayWithinDeltaAndMessage(void) -{ - UNITY_UINT8 expected[] = {0x34, 0x22, 0x77}; - UNITY_UINT8 actualSmallDelta[] = {0x35, 0x21, 0x77}; - UNITY_UINT8 actualBigDelta[] = {0x47, 0x48, 0x4C}; - - TEST_ASSERT_HEX8_ARRAY_WITHIN_MESSAGE(1, expected, actualSmallDelta, 3, "Custom Message."); - TEST_ASSERT_HEX8_ARRAY_WITHIN_MESSAGE(60, expected, actualBigDelta, 3, "Custom Message."); -} - -void testHEX8ArrayNotWithinDelta(void) -{ - UNITY_UINT8 expected[] = {0x34, 0x22, 0x77}; - UNITY_UINT8 actualBigDelta[] = {0x67, 0x88, 0xAC}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_HEX8_ARRAY_WITHIN(1, expected, actualBigDelta, 3); - VERIFY_FAILS_END -} - -void testHEX8ArrayNotWithinDeltaAndMessage(void) -{ - UNITY_UINT8 expected[] = {0x34, 0x22, 0x77}; - UNITY_UINT8 actualBigDelta[] = {0x67, 0x88, 0xAC}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_HEX8_ARRAY_WITHIN_MESSAGE(1, expected, actualBigDelta, 3, "Custom Message."); - VERIFY_FAILS_END -} - -void testHEX8ArrayWithinDeltaPointless(void) -{ - UNITY_UINT8 expected[] = {0x34, 0x22, 0x77}; - UNITY_UINT8 actualBigDelta[] = {0x67, 0x88, 0xAC}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_HEX8_ARRAY_WITHIN(60, expected, actualBigDelta, 0); - VERIFY_FAILS_END -} - -void testHEX8ArrayWithinDeltaPointlessAndMessage(void) -{ - UNITY_UINT8 expected[] = {0x34, 0x22, 0x77}; - UNITY_UINT8 actualBigDelta[] = {0x67, 0x88, 0xAC}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_HEX8_ARRAY_WITHIN_MESSAGE(60, expected, actualBigDelta, 0, "Custom Message."); - VERIFY_FAILS_END -} - -void testHEX8ArrayWithinDeltaExpectedNull(void) -{ - UNITY_UINT8 actualBigDelta[] = {0x67, 0x88, 0xAC}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_HEX8_ARRAY_WITHIN(60, NULL, actualBigDelta, 3); - VERIFY_FAILS_END -} - -void testHEX8ArrayWithinDeltaExpectedNullAndMessage(void) -{ - UNITY_UINT8 actualBigDelta[] = {0x67, 0x88, 0xAC}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_HEX8_ARRAY_WITHIN_MESSAGE(60, NULL, actualBigDelta, 3, "Custom Message."); - VERIFY_FAILS_END -} - -void testHEX8ArrayWithinDeltaActualNull(void) -{ - UNITY_UINT8 expected[] = {0x34, 0x22, 0x77}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_HEX8_ARRAY_WITHIN(60, expected, NULL, 3); - VERIFY_FAILS_END -} - -void testHEX8ArrayWithinDeltaActualNullAndMessage(void) -{ - UNITY_UINT8 expected[] = {0x34, 0x22, 0x77}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_HEX8_ARRAY_WITHIN_MESSAGE(60, expected, NULL, 3, "Custom Message."); - VERIFY_FAILS_END -} - -void testHEX8ArrayWithinDeltaSamePointer(void) -{ - UNITY_UINT8 expected[] = {0x34, 0x22, 0x77}; - - TEST_ASSERT_HEX8_ARRAY_WITHIN(60, expected, expected, 3); -} - -void testHEX8ArrayWithinDeltaSamePointerAndMessage(void) -{ - UNITY_UINT8 expected[] = {0x34, 0x22, 0x77}; - - TEST_ASSERT_HEX8_ARRAY_WITHIN_MESSAGE(60, expected, expected, 3, "Custom Message."); -} - -/*-----------------*/ - -void testGreaterThan(void) -{ - UNITY_INT v0, v1; - UNITY_INT *p0, *p1; - - v0 = 0; - v1 = 1; - p0 = &v0; - p1 = &v1; - - TEST_ASSERT_GREATER_THAN(v0, v1); - TEST_ASSERT_GREATER_THAN(*p0, v1); - TEST_ASSERT_GREATER_THAN(v0, *p1); - TEST_ASSERT_GREATER_THAN(*p0, *p1); -} - -void testNotGreaterThan(void) -{ - EXPECT_ABORT_BEGIN - TEST_ASSERT_GREATER_THAN(0, -1); - VERIFY_FAILS_END -} - -void testGreaterThanINT(void) -{ - UNITY_INT v0, v1; - UNITY_INT *p0, *p1; - - v0 = 302; - v1 = 3334; - p0 = &v0; - p1 = &v1; - - TEST_ASSERT_GREATER_THAN_INT(v0, v1); - TEST_ASSERT_GREATER_THAN_INT(*p0, v1); - TEST_ASSERT_GREATER_THAN_INT(v0, *p1); - TEST_ASSERT_GREATER_THAN_INT(*p0, *p1); -} - -void testNotGreaterThanINT(void) -{ - EXPECT_ABORT_BEGIN - TEST_ASSERT_GREATER_THAN_INT(3334, 302); - VERIFY_FAILS_END -} - -void testGreaterThanINT8(void) -{ - UNITY_INT8 v0, v1; - UNITY_INT8 *p0, *p1; - - v0 = -128; - v1 = 127; - p0 = &v0; - p1 = &v1; - - TEST_ASSERT_GREATER_THAN_INT8(v0, v1); - TEST_ASSERT_GREATER_THAN_INT8(*p0, v1); - TEST_ASSERT_GREATER_THAN_INT8(v0, *p1); - TEST_ASSERT_GREATER_THAN_INT8(*p0, *p1); -} - -void testNotGreaterThanINT8(void) -{ - EXPECT_ABORT_BEGIN - TEST_ASSERT_GREATER_THAN_INT8(127, -128); - VERIFY_FAILS_END -} - -void testGreaterThanCHAR(void) -{ - char v0, v1; - char *p0, *p1; - - v0 = -128; - v1 = 127; - p0 = &v0; - p1 = &v1; - - TEST_ASSERT_GREATER_THAN_CHAR(v0, v1); - TEST_ASSERT_GREATER_THAN_CHAR(*p0, v1); - TEST_ASSERT_GREATER_THAN_CHAR(v0, *p1); - TEST_ASSERT_GREATER_THAN_CHAR(*p0, *p1); -} - -void testNotGreaterThanCHAR(void) -{ - EXPECT_ABORT_BEGIN - TEST_ASSERT_GREATER_THAN_CHAR(127, -128); - VERIFY_FAILS_END -} - -void testGreaterThanINT16(void) -{ - UNITY_INT16 v0, v1; - UNITY_INT16 *p0, *p1; - - v0 = -32768; - v1 = 32767; - p0 = &v0; - p1 = &v1; - - TEST_ASSERT_GREATER_THAN_INT16(v0, v1); - TEST_ASSERT_GREATER_THAN_INT16(*p0, v1); - TEST_ASSERT_GREATER_THAN_INT16(v0, *p1); - TEST_ASSERT_GREATER_THAN_INT16(*p0, *p1); -} - -void testNotGreaterThanINT16(void) -{ - EXPECT_ABORT_BEGIN - TEST_ASSERT_GREATER_THAN_INT16(32768, -32768); - VERIFY_FAILS_END -} - -void testGreaterThanINT32(void) -{ - UNITY_INT32 v0, v1; - UNITY_INT32 *p0, *p1; - - v0 = -214783648; - v1 = 214783647; - p0 = &v0; - p1 = &v1; - - TEST_ASSERT_GREATER_THAN_INT32(v0, v1); - TEST_ASSERT_GREATER_THAN_INT32(*p0, v1); - TEST_ASSERT_GREATER_THAN_INT32(v0, *p1); - TEST_ASSERT_GREATER_THAN_INT32(*p0, *p1); -} - -void testNotGreaterThanINT32(void) -{ - EXPECT_ABORT_BEGIN - TEST_ASSERT_GREATER_THAN_INT32(214783647, -214783648); - VERIFY_FAILS_END -} - -void testGreaterThanUINT(void) -{ - UNITY_UINT v0, v1; - UNITY_UINT *p0, *p1; - - v0 = 0; - v1 = 1; - p0 = &v0; - p1 = &v1; - - TEST_ASSERT_GREATER_THAN_UINT(v0, v1); - TEST_ASSERT_GREATER_THAN_UINT(*p0, v1); - TEST_ASSERT_GREATER_THAN_UINT(v0, *p1); - TEST_ASSERT_GREATER_THAN_UINT(*p0, *p1); -} - -void testNotGreaterThanUINT(void) -{ - EXPECT_ABORT_BEGIN - TEST_ASSERT_GREATER_THAN_UINT(1, 0); - VERIFY_FAILS_END -} - -void testGreaterThanUINT8(void) -{ - UNITY_UINT8 v0, v1; - UNITY_UINT8 *p0, *p1; - - v0 = 0; - v1 = 255; - p0 = &v0; - p1 = &v1; - - TEST_ASSERT_GREATER_THAN_UINT8(v0, v1); - TEST_ASSERT_GREATER_THAN_UINT8(*p0, v1); - TEST_ASSERT_GREATER_THAN_UINT8(v0, *p1); - TEST_ASSERT_GREATER_THAN_UINT8(*p0, *p1); -} - -void testNotGreaterThanUINT8(void) -{ - EXPECT_ABORT_BEGIN - TEST_ASSERT_GREATER_THAN_UINT8(255, 0); - VERIFY_FAILS_END -} - -void testGreaterThanUINT16(void) -{ - UNITY_UINT16 v0, v1; - UNITY_UINT16 *p0, *p1; - - v0 = 0; - v1 = 65535; - p0 = &v0; - p1 = &v1; - - TEST_ASSERT_GREATER_THAN_UINT16(v0, v1); - TEST_ASSERT_GREATER_THAN_UINT16(*p0, v1); - TEST_ASSERT_GREATER_THAN_UINT16(v0, *p1); - TEST_ASSERT_GREATER_THAN_UINT16(*p0, *p1); -} - -void testNotGreaterThanUINT16(void) -{ - EXPECT_ABORT_BEGIN - TEST_ASSERT_GREATER_THAN_UINT16(65535, 0); - VERIFY_FAILS_END -} - -void testGreaterThanUINT32(void) -{ - UNITY_UINT32 v0, v1; - UNITY_UINT32 *p0, *p1; - - v0 = 0u; - v1 = 4294967295u; - p0 = &v0; - p1 = &v1; - - TEST_ASSERT_GREATER_THAN_UINT32(v0, v1); - TEST_ASSERT_GREATER_THAN_UINT32(*p0, v1); - TEST_ASSERT_GREATER_THAN_UINT32(v0, *p1); - TEST_ASSERT_GREATER_THAN_UINT32(*p0, *p1); -} - -void testNotGreaterThanUINT32(void) -{ - EXPECT_ABORT_BEGIN - TEST_ASSERT_GREATER_THAN_UINT32(4294967295u, 0); - VERIFY_FAILS_END -} - -void testGreaterThanHEX8(void) -{ - UNITY_UINT8 v0, v1; - UNITY_UINT8 *p0, *p1; - - v0 = 0x00; - v1 = 0xFF; - p0 = &v0; - p1 = &v1; - - TEST_ASSERT_GREATER_THAN_HEX8(v0, v1); - TEST_ASSERT_GREATER_THAN_HEX8(*p0, v1); - TEST_ASSERT_GREATER_THAN_HEX8(v0, *p1); - TEST_ASSERT_GREATER_THAN_HEX8(*p0, *p1); -} - -void testNotGreaterThanHEX8(void) -{ - EXPECT_ABORT_BEGIN - TEST_ASSERT_GREATER_THAN_HEX8(0xFF, 0x00); - VERIFY_FAILS_END -} - -void testGreaterThanHEX16(void) -{ - UNITY_UINT16 v0, v1; - UNITY_UINT16 *p0, *p1; - - v0 = 0x0000; - v1 = 0xFFFF; - p0 = &v0; - p1 = &v1; - - TEST_ASSERT_GREATER_THAN_HEX16(v0, v1); - TEST_ASSERT_GREATER_THAN_HEX16(*p0, v1); - TEST_ASSERT_GREATER_THAN_HEX16(v0, *p1); - TEST_ASSERT_GREATER_THAN_HEX16(*p0, *p1); -} - -void testNotGreaterThanHEX16(void) -{ - EXPECT_ABORT_BEGIN - TEST_ASSERT_GREATER_THAN_HEX16(0xFFFF, 0x00); - VERIFY_FAILS_END -} - -void testGreaterThanHEX32(void) -{ - UNITY_UINT32 v0, v1; - UNITY_UINT32 *p0, *p1; - - v0 = 0x00000000; - v1 = 0xFFFFFFFF; - p0 = &v0; - p1 = &v1; - - TEST_ASSERT_GREATER_THAN_HEX32(v0, v1); - TEST_ASSERT_GREATER_THAN_HEX32(*p0, v1); - TEST_ASSERT_GREATER_THAN_HEX32(v0, *p1); - TEST_ASSERT_GREATER_THAN_HEX32(*p0, *p1); -} - -void testNotGreaterThanHEX32(void) -{ - EXPECT_ABORT_BEGIN - TEST_ASSERT_GREATER_THAN_HEX32(0xFFFFFFFF, 0x00); - VERIFY_FAILS_END -} - -void testGreaterOrEqual(void) -{ - UNITY_INT v0, v1, v2; - UNITY_INT *p0, *p1, *p2; - - v0 = 0; - v1 = 1; - v2 = 0; - p0 = &v0; - p1 = &v1; - p2 = &v2; - - TEST_ASSERT_GREATER_OR_EQUAL(v0, v1); - TEST_ASSERT_GREATER_OR_EQUAL(*p0, v1); - TEST_ASSERT_GREATER_OR_EQUAL(v0, *p1); - TEST_ASSERT_GREATER_OR_EQUAL(*p0, *p1); - TEST_ASSERT_GREATER_OR_EQUAL(v0, v2); - TEST_ASSERT_GREATER_OR_EQUAL(*p0, v2); - TEST_ASSERT_GREATER_OR_EQUAL(v0, *p2); - TEST_ASSERT_GREATER_OR_EQUAL(*p0, *p2); -} - -void testNotGreaterOrEqual(void) -{ - EXPECT_ABORT_BEGIN - TEST_ASSERT_GREATER_OR_EQUAL(0, -1); - VERIFY_FAILS_END -} - -void testGreaterOrEqualINT(void) -{ - UNITY_INT v0, v1, v2; - UNITY_INT *p0, *p1, *p2; - - v0 = 302; - v1 = 3334; - v2 = 302; - p0 = &v0; - p1 = &v1; - p2 = &v2; - - TEST_ASSERT_GREATER_OR_EQUAL_INT(v0, v1); - TEST_ASSERT_GREATER_OR_EQUAL_INT(*p0, v1); - TEST_ASSERT_GREATER_OR_EQUAL_INT(v0, *p1); - TEST_ASSERT_GREATER_OR_EQUAL_INT(*p0, *p1); - TEST_ASSERT_GREATER_OR_EQUAL_INT(v0, v2); - TEST_ASSERT_GREATER_OR_EQUAL_INT(*p0, v2); - TEST_ASSERT_GREATER_OR_EQUAL_INT(v0, *p2); - TEST_ASSERT_GREATER_OR_EQUAL_INT(*p0, *p2); -} - -void testNotGreaterOrEqualINT(void) -{ - EXPECT_ABORT_BEGIN - TEST_ASSERT_GREATER_OR_EQUAL_INT(3334, 302); - VERIFY_FAILS_END -} - -void testGreaterOrEqualINT8(void) -{ - UNITY_INT8 v0, v1, v2; - UNITY_INT8 *p0, *p1, *p2; - - v0 = -128; - v1 = 127; - v2 = -128; - p0 = &v0; - p1 = &v1; - p2 = &v2; - - TEST_ASSERT_GREATER_OR_EQUAL_INT8(v0, v1); - TEST_ASSERT_GREATER_OR_EQUAL_INT8(*p0, v1); - TEST_ASSERT_GREATER_OR_EQUAL_INT8(v0, *p1); - TEST_ASSERT_GREATER_OR_EQUAL_INT8(*p0, *p1); - TEST_ASSERT_GREATER_OR_EQUAL_INT8(v0, v2); - TEST_ASSERT_GREATER_OR_EQUAL_INT8(*p0, v2); - TEST_ASSERT_GREATER_OR_EQUAL_INT8(v0, *p2); - TEST_ASSERT_GREATER_OR_EQUAL_INT8(*p0, *p2); -} - -void testNotGreaterOrEqualINT8(void) -{ - EXPECT_ABORT_BEGIN - TEST_ASSERT_GREATER_OR_EQUAL_INT8(127, -128); - VERIFY_FAILS_END -} - -void testGreaterOrEqualCHAR(void) -{ - char v0, v1, v2; - char *p0, *p1, *p2; - - v0 = -128; - v1 = 127; - v2 = -128; - p0 = &v0; - p1 = &v1; - p2 = &v2; - - TEST_ASSERT_GREATER_OR_EQUAL_CHAR(v0, v1); - TEST_ASSERT_GREATER_OR_EQUAL_CHAR(*p0, v1); - TEST_ASSERT_GREATER_OR_EQUAL_CHAR(v0, *p1); - TEST_ASSERT_GREATER_OR_EQUAL_CHAR(*p0, *p1); - TEST_ASSERT_GREATER_OR_EQUAL_CHAR(v0, v2); - TEST_ASSERT_GREATER_OR_EQUAL_CHAR(*p0, v2); - TEST_ASSERT_GREATER_OR_EQUAL_CHAR(v0, *p2); - TEST_ASSERT_GREATER_OR_EQUAL_CHAR(*p0, *p2); -} - -void testNotGreaterOrEqualCHAR(void) -{ - EXPECT_ABORT_BEGIN - TEST_ASSERT_GREATER_OR_EQUAL_CHAR(127, -128); - VERIFY_FAILS_END -} - -void testGreaterOrEqualINT16(void) -{ - UNITY_INT16 v0, v1, v2; - UNITY_INT16 *p0, *p1, *p2; - - v0 = -32768; - v1 = 32767; - v2 = -32768; - p0 = &v0; - p1 = &v1; - p2 = &v2; - - TEST_ASSERT_GREATER_OR_EQUAL_INT16(v0, v1); - TEST_ASSERT_GREATER_OR_EQUAL_INT16(*p0, v1); - TEST_ASSERT_GREATER_OR_EQUAL_INT16(v0, *p1); - TEST_ASSERT_GREATER_OR_EQUAL_INT16(*p0, *p1); - TEST_ASSERT_GREATER_OR_EQUAL_INT16(v0, v2); - TEST_ASSERT_GREATER_OR_EQUAL_INT16(*p0, v2); - TEST_ASSERT_GREATER_OR_EQUAL_INT16(v0, *p2); - TEST_ASSERT_GREATER_OR_EQUAL_INT16(*p0, *p2); -} - -void testNotGreaterOrEqualINT16(void) -{ - EXPECT_ABORT_BEGIN - TEST_ASSERT_GREATER_OR_EQUAL_INT16(32767, -32768); - VERIFY_FAILS_END -} - -void testGreaterOrEqualINT32(void) -{ - UNITY_INT32 v0, v1, v2; - UNITY_INT32 *p0, *p1, *p2; - - v0 = -214783648; - v1 = 214783647; - v2 = -214783648; - p0 = &v0; - p1 = &v1; - p2 = &v2; - - TEST_ASSERT_GREATER_OR_EQUAL_INT32(v0, v1); - TEST_ASSERT_GREATER_OR_EQUAL_INT32(*p0, v1); - TEST_ASSERT_GREATER_OR_EQUAL_INT32(v0, *p1); - TEST_ASSERT_GREATER_OR_EQUAL_INT32(*p0, *p1); - TEST_ASSERT_GREATER_OR_EQUAL_INT32(v0, v2); - TEST_ASSERT_GREATER_OR_EQUAL_INT32(*p0, v2); - TEST_ASSERT_GREATER_OR_EQUAL_INT32(v0, *p2); - TEST_ASSERT_GREATER_OR_EQUAL_INT32(*p0, *p2); -} - -void testNotGreaterOrEqualINT32(void) -{ - EXPECT_ABORT_BEGIN - TEST_ASSERT_GREATER_OR_EQUAL_INT32(214783647, -214783648); - VERIFY_FAILS_END -} - -void testGreaterOrEqualUINT(void) -{ - UNITY_UINT v0, v1, v2; - UNITY_UINT *p0, *p1, *p2; - - v0 = 0; - v1 = 1; - v2 = 0; - p0 = &v0; - p1 = &v1; - p2 = &v2; - - TEST_ASSERT_GREATER_OR_EQUAL_UINT(v0, v1); - TEST_ASSERT_GREATER_OR_EQUAL_UINT(*p0, v1); - TEST_ASSERT_GREATER_OR_EQUAL_UINT(v0, *p1); - TEST_ASSERT_GREATER_OR_EQUAL_UINT(*p0, *p1); - TEST_ASSERT_GREATER_OR_EQUAL_UINT(v0, v2); - TEST_ASSERT_GREATER_OR_EQUAL_UINT(*p0, v2); - TEST_ASSERT_GREATER_OR_EQUAL_UINT(v0, *p2); - TEST_ASSERT_GREATER_OR_EQUAL_UINT(*p0, *p2); -} - -void testNotGreaterOrEqualUINT(void) -{ - EXPECT_ABORT_BEGIN - TEST_ASSERT_GREATER_OR_EQUAL_UINT(1, 0); - VERIFY_FAILS_END -} - -void testGreaterOrEqualUINT8(void) -{ - UNITY_UINT8 v0, v1, v2; - UNITY_UINT8 *p0, *p1, *p2; - - v0 = 0; - v1 = 255; - v2 = 0; - p0 = &v0; - p1 = &v1; - p2 = &v2; - - TEST_ASSERT_GREATER_OR_EQUAL_UINT8(v0, v1); - TEST_ASSERT_GREATER_OR_EQUAL_UINT8(*p0, v1); - TEST_ASSERT_GREATER_OR_EQUAL_UINT8(v0, *p1); - TEST_ASSERT_GREATER_OR_EQUAL_UINT8(*p0, *p1); - TEST_ASSERT_GREATER_OR_EQUAL_UINT8(v0, v2); - TEST_ASSERT_GREATER_OR_EQUAL_UINT8(*p0, v2); - TEST_ASSERT_GREATER_OR_EQUAL_UINT8(v0, *p2); - TEST_ASSERT_GREATER_OR_EQUAL_UINT8(*p0, *p2); -} - -void testNotGreaterOrEqualUINT8(void) -{ - EXPECT_ABORT_BEGIN - TEST_ASSERT_GREATER_OR_EQUAL_UINT8(255, 0); - VERIFY_FAILS_END -} - -void testGreaterOrEqualUINT16(void) -{ - UNITY_UINT16 v0, v1, v2; - UNITY_UINT16 *p0, *p1, *p2; - - v0 = 0; - v1 = 65535; - v2 = 0; - p0 = &v0; - p1 = &v1; - p2 = &v2; - - TEST_ASSERT_GREATER_OR_EQUAL_UINT16(v0, v1); - TEST_ASSERT_GREATER_OR_EQUAL_UINT16(*p0, v1); - TEST_ASSERT_GREATER_OR_EQUAL_UINT16(v0, *p1); - TEST_ASSERT_GREATER_OR_EQUAL_UINT16(*p0, *p1); - TEST_ASSERT_GREATER_OR_EQUAL_UINT16(v0, v2); - TEST_ASSERT_GREATER_OR_EQUAL_UINT16(*p0, v2); - TEST_ASSERT_GREATER_OR_EQUAL_UINT16(v0, *p2); - TEST_ASSERT_GREATER_OR_EQUAL_UINT16(*p0, *p2); -} - -void testNotGreaterOrEqualUINT16(void) -{ - EXPECT_ABORT_BEGIN - TEST_ASSERT_GREATER_OR_EQUAL_UINT16(65535, 0); - VERIFY_FAILS_END -} - -void testGreaterOrEqualUINT32(void) -{ - UNITY_UINT32 v0, v1, v2; - UNITY_UINT32 *p0, *p1, *p2; - - v0 = 0; - v1 = 4294967295u; - v2 = 0; - p0 = &v0; - p1 = &v1; - p2 = &v2; - - TEST_ASSERT_GREATER_OR_EQUAL_UINT32(v0, v1); - TEST_ASSERT_GREATER_OR_EQUAL_UINT32(*p0, v1); - TEST_ASSERT_GREATER_OR_EQUAL_UINT32(v0, *p1); - TEST_ASSERT_GREATER_OR_EQUAL_UINT32(*p0, *p1); - TEST_ASSERT_GREATER_OR_EQUAL_UINT32(v0, v2); - TEST_ASSERT_GREATER_OR_EQUAL_UINT32(*p0, v2); - TEST_ASSERT_GREATER_OR_EQUAL_UINT32(v0, *p2); - TEST_ASSERT_GREATER_OR_EQUAL_UINT32(*p0, *p2); -} - -void testNotGreaterOrEqualUINT32(void) -{ - EXPECT_ABORT_BEGIN - TEST_ASSERT_GREATER_OR_EQUAL_UINT32(4294967295u, 0); - VERIFY_FAILS_END -} - -void testGreaterOrEqualHEX8(void) -{ - UNITY_UINT8 v0, v1, v2; - UNITY_UINT8 *p0, *p1, *p2; - - v0 = 0x00; - v1 = 0xFF; - v2 = 0x00; - p0 = &v0; - p1 = &v1; - p2 = &v2; - - TEST_ASSERT_GREATER_OR_EQUAL_HEX8(v0, v1); - TEST_ASSERT_GREATER_OR_EQUAL_HEX8(*p0, v1); - TEST_ASSERT_GREATER_OR_EQUAL_HEX8(v0, *p1); - TEST_ASSERT_GREATER_OR_EQUAL_HEX8(*p0, *p1); - TEST_ASSERT_GREATER_OR_EQUAL_HEX8(v0, v2); - TEST_ASSERT_GREATER_OR_EQUAL_HEX8(*p0, v2); - TEST_ASSERT_GREATER_OR_EQUAL_HEX8(v0, *p2); - TEST_ASSERT_GREATER_OR_EQUAL_HEX8(*p0, *p2); -} - -void testNotGreaterOrEqualHEX8(void) -{ - EXPECT_ABORT_BEGIN - TEST_ASSERT_GREATER_OR_EQUAL_HEX8(0xFF, 0x00); - VERIFY_FAILS_END -} - -void testGreaterOrEqualHEX16(void) -{ - UNITY_UINT16 v0, v1, v2; - UNITY_UINT16 *p0, *p1, *p2; - - v0 = 0x0000; - v1 = 0xFFFF; - v2 = 0x0000; - p0 = &v0; - p1 = &v1; - p2 = &v2; - - TEST_ASSERT_GREATER_OR_EQUAL_HEX16(v0, v1); - TEST_ASSERT_GREATER_OR_EQUAL_HEX16(*p0, v1); - TEST_ASSERT_GREATER_OR_EQUAL_HEX16(v0, *p1); - TEST_ASSERT_GREATER_OR_EQUAL_HEX16(*p0, *p1); - TEST_ASSERT_GREATER_OR_EQUAL_HEX16(v0, v2); - TEST_ASSERT_GREATER_OR_EQUAL_HEX16(*p0, v2); - TEST_ASSERT_GREATER_OR_EQUAL_HEX16(v0, *p2); - TEST_ASSERT_GREATER_OR_EQUAL_HEX16(*p0, *p2); -} - -void testNotGreaterOrEqualHEX16(void) -{ - EXPECT_ABORT_BEGIN - TEST_ASSERT_GREATER_OR_EQUAL_HEX16(0xFFFF, 0x00); - VERIFY_FAILS_END -} - -void testGreaterOrEqualHEX32(void) -{ - UNITY_UINT32 v0, v1, v2; - UNITY_UINT32 *p0, *p1, *p2; - - v0 = 0x00000000; - v1 = 0xFFFFFFFF; - v2 = 0x00000000; - p0 = &v0; - p1 = &v1; - p2 = &v2; - - TEST_ASSERT_GREATER_OR_EQUAL_HEX32(v0, v1); - TEST_ASSERT_GREATER_OR_EQUAL_HEX32(*p0, v1); - TEST_ASSERT_GREATER_OR_EQUAL_HEX32(v0, *p1); - TEST_ASSERT_GREATER_OR_EQUAL_HEX32(*p0, *p1); - TEST_ASSERT_GREATER_OR_EQUAL_HEX32(v0, v2); - TEST_ASSERT_GREATER_OR_EQUAL_HEX32(*p0, v2); - TEST_ASSERT_GREATER_OR_EQUAL_HEX32(v0, *p2); - TEST_ASSERT_GREATER_OR_EQUAL_HEX32(*p0, *p2); -} - -void testNotGreaterOrEqualHEX32(void) -{ - EXPECT_ABORT_BEGIN - TEST_ASSERT_GREATER_OR_EQUAL_HEX32(0xFFFFFFFF, 0x00); - VERIFY_FAILS_END -} - -/*-----------------*/ - -void testLessThan(void) -{ - UNITY_INT v0, v1; - UNITY_INT *p0, *p1; - - v0 = 0; - v1 = -1; - p0 = &v0; - p1 = &v1; - - TEST_ASSERT_LESS_THAN(v0, v1); - TEST_ASSERT_LESS_THAN(*p0, v1); - TEST_ASSERT_LESS_THAN(v0, *p1); - TEST_ASSERT_LESS_THAN(*p0, *p1); -} - -void testNotLessThan(void) -{ - EXPECT_ABORT_BEGIN - TEST_ASSERT_LESS_THAN(0, 1); - VERIFY_FAILS_END -} - -void testLessThanINT(void) -{ - UNITY_INT v0, v1; - UNITY_INT *p0, *p1; - - v0 = 3334; - v1 = 302; - p0 = &v0; - p1 = &v1; - - TEST_ASSERT_LESS_THAN_INT(v0, v1); - TEST_ASSERT_LESS_THAN_INT(*p0, v1); - TEST_ASSERT_LESS_THAN_INT(v0, *p1); - TEST_ASSERT_LESS_THAN_INT(*p0, *p1); -} - -void testNotLessThanINT(void) -{ - EXPECT_ABORT_BEGIN - TEST_ASSERT_LESS_THAN_INT(302, 3334); - VERIFY_FAILS_END -} - -void testLessThanINT8(void) -{ - UNITY_INT8 v0, v1; - UNITY_INT8 *p0, *p1; - - v0 = 127; - v1 = -128; - p0 = &v0; - p1 = &v1; - - TEST_ASSERT_LESS_THAN_INT8(v0, v1); - TEST_ASSERT_LESS_THAN_INT8(*p0, v1); - TEST_ASSERT_LESS_THAN_INT8(v0, *p1); - TEST_ASSERT_LESS_THAN_INT8(*p0, *p1); -} - -void testNotLessThanINT8(void) -{ - EXPECT_ABORT_BEGIN - TEST_ASSERT_LESS_THAN_INT8(-128, 127); - VERIFY_FAILS_END -} - -void testLessThanCHAR(void) -{ - char v0, v1; - char *p0, *p1; - - v0 = 127; - v1 = -128; - p0 = &v0; - p1 = &v1; - - TEST_ASSERT_LESS_THAN_CHAR(v0, v1); - TEST_ASSERT_LESS_THAN_CHAR(*p0, v1); - TEST_ASSERT_LESS_THAN_CHAR(v0, *p1); - TEST_ASSERT_LESS_THAN_CHAR(*p0, *p1); -} - -void testNotLessThanCHAR(void) -{ - EXPECT_ABORT_BEGIN - TEST_ASSERT_LESS_THAN_CHAR(-128, 127); - VERIFY_FAILS_END -} - -void testLessThanINT16(void) -{ - UNITY_INT16 v0, v1; - UNITY_INT16 *p0, *p1; - - v0 = 32767; - v1 = -32768; - p0 = &v0; - p1 = &v1; - - TEST_ASSERT_LESS_THAN_INT16(v0, v1); - TEST_ASSERT_LESS_THAN_INT16(*p0, v1); - TEST_ASSERT_LESS_THAN_INT16(v0, *p1); - TEST_ASSERT_LESS_THAN_INT16(*p0, *p1); -} - -void testNotLessThanINT16(void) -{ - EXPECT_ABORT_BEGIN - TEST_ASSERT_LESS_THAN_INT16(-32768, 32767); - VERIFY_FAILS_END -} - -void testLessThanINT32(void) -{ - UNITY_INT32 v0, v1; - UNITY_INT32 *p0, *p1; - - v0 = 214783647; - v1 = -214783648; - p0 = &v0; - p1 = &v1; - - TEST_ASSERT_LESS_THAN_INT32(v0, v1); - TEST_ASSERT_LESS_THAN_INT32(*p0, v1); - TEST_ASSERT_LESS_THAN_INT32(v0, *p1); - TEST_ASSERT_LESS_THAN_INT32(*p0, *p1); -} - -void testNotLessThanINT32(void) -{ - EXPECT_ABORT_BEGIN - TEST_ASSERT_LESS_THAN_INT32(-214783648, 214783647); - VERIFY_FAILS_END -} - -void testLessThanUINT(void) -{ - UNITY_UINT v0, v1; - UNITY_UINT *p0, *p1; - - v0 = 1; - v1 = 0; - p0 = &v0; - p1 = &v1; - - TEST_ASSERT_LESS_THAN_UINT(v0, v1); - TEST_ASSERT_LESS_THAN_UINT(*p0, v1); - TEST_ASSERT_LESS_THAN_UINT(v0, *p1); - TEST_ASSERT_LESS_THAN_UINT(*p0, *p1); -} - -void testNotLessThanUINT(void) -{ - EXPECT_ABORT_BEGIN - TEST_ASSERT_LESS_THAN_UINT(0, 1); - VERIFY_FAILS_END -} - -void testLessThanUINT8(void) -{ - UNITY_UINT8 v0, v1; - UNITY_UINT8 *p0, *p1; - - v0 = 255; - v1 = 0; - p0 = &v0; - p1 = &v1; - - TEST_ASSERT_LESS_THAN_UINT8(v0, v1); - TEST_ASSERT_LESS_THAN_UINT8(*p0, v1); - TEST_ASSERT_LESS_THAN_UINT8(v0, *p1); - TEST_ASSERT_LESS_THAN_UINT8(*p0, *p1); -} - -void testNotLessThanUINT8(void) -{ - EXPECT_ABORT_BEGIN - TEST_ASSERT_LESS_THAN_UINT8(0, 255); - VERIFY_FAILS_END -} - -void testLessThanUINT16(void) -{ - UNITY_UINT16 v0, v1; - UNITY_UINT16 *p0, *p1; - - v0 = 65535; - v1 = 0; - p0 = &v0; - p1 = &v1; - - TEST_ASSERT_LESS_THAN_UINT16(v0, v1); - TEST_ASSERT_LESS_THAN_UINT16(*p0, v1); - TEST_ASSERT_LESS_THAN_UINT16(v0, *p1); - TEST_ASSERT_LESS_THAN_UINT16(*p0, *p1); -} - -void testNotLessThanUINT16(void) -{ - EXPECT_ABORT_BEGIN - TEST_ASSERT_LESS_THAN_UINT16(0, 65535); - VERIFY_FAILS_END -} - -void testLessThanUINT32(void) -{ - UNITY_UINT32 v0, v1; - UNITY_UINT32 *p0, *p1; - - v0 = 4294967295u; - v1 = 0; - p0 = &v0; - p1 = &v1; - - TEST_ASSERT_LESS_THAN_UINT32(v0, v1); - TEST_ASSERT_LESS_THAN_UINT32(*p0, v1); - TEST_ASSERT_LESS_THAN_UINT32(v0, *p1); - TEST_ASSERT_LESS_THAN_UINT32(*p0, *p1); -} - -void testNotLessThanUINT32(void) -{ - EXPECT_ABORT_BEGIN - TEST_ASSERT_LESS_THAN_UINT32(0, 4294967295u); - VERIFY_FAILS_END -} - -void testLessThanHEX8(void) -{ - UNITY_UINT8 v0, v1; - UNITY_UINT8 *p0, *p1; - - v0 = 0xFF; - v1 = 0x00; - p0 = &v0; - p1 = &v1; - - TEST_ASSERT_LESS_THAN_HEX8(v0, v1); - TEST_ASSERT_LESS_THAN_HEX8(*p0, v1); - TEST_ASSERT_LESS_THAN_HEX8(v0, *p1); - TEST_ASSERT_LESS_THAN_HEX8(*p0, *p1); -} - -void testNotLessThanHEX8(void) -{ - EXPECT_ABORT_BEGIN - TEST_ASSERT_LESS_THAN_HEX8(0x00, 0xFF); - VERIFY_FAILS_END -} - -void testLessThanHEX16(void) -{ - UNITY_UINT16 v0, v1; - UNITY_UINT16 *p0, *p1; - - v0 = 0xFFFF; - v1 = 0x0000; - p0 = &v0; - p1 = &v1; - - TEST_ASSERT_LESS_THAN_HEX16(v0, v1); - TEST_ASSERT_LESS_THAN_HEX16(*p0, v1); - TEST_ASSERT_LESS_THAN_HEX16(v0, *p1); - TEST_ASSERT_LESS_THAN_HEX16(*p0, *p1); -} - -void testNotLessThanHEX16(void) -{ - EXPECT_ABORT_BEGIN - TEST_ASSERT_LESS_THAN_HEX16(0x0000, 0xFFFF); - VERIFY_FAILS_END -} - -void testLessThanHEX32(void) -{ - UNITY_UINT32 v0, v1; - UNITY_UINT32 *p0, *p1; - - v0 = 0xFFFFFFFF; - v1 = 0x00000000; - p0 = &v0; - p1 = &v1; - - TEST_ASSERT_LESS_THAN_HEX32(v0, v1); - TEST_ASSERT_LESS_THAN_HEX32(*p0, v1); - TEST_ASSERT_LESS_THAN_HEX32(v0, *p1); - TEST_ASSERT_LESS_THAN_HEX32(*p0, *p1); -} - -void testNotLessThanHEX32(void) -{ - EXPECT_ABORT_BEGIN - TEST_ASSERT_LESS_THAN_HEX32(0x00000000, 0xFFFFFFFF); - VERIFY_FAILS_END -} - -void testLessOrEqual(void) -{ - UNITY_INT v0, v1, v2; - UNITY_INT *p0, *p1, *p2; - - v0 = 0; - v1 = -1; - v2 = 0; - p0 = &v0; - p1 = &v1; - p2 = &v2; - - TEST_ASSERT_LESS_OR_EQUAL(v0, v1); - TEST_ASSERT_LESS_OR_EQUAL(*p0, v1); - TEST_ASSERT_LESS_OR_EQUAL(v0, *p1); - TEST_ASSERT_LESS_OR_EQUAL(*p0, *p1); - TEST_ASSERT_LESS_OR_EQUAL(v0, v2); - TEST_ASSERT_LESS_OR_EQUAL(*p0, v2); - TEST_ASSERT_LESS_OR_EQUAL(v0, *p2); - TEST_ASSERT_LESS_OR_EQUAL(*p0, *p2); -} - -void testNotLessOrEqual(void) -{ - EXPECT_ABORT_BEGIN - TEST_ASSERT_LESS_OR_EQUAL(0, 1); - VERIFY_FAILS_END -} - -void testLessOrEqualINT(void) -{ - UNITY_INT v0, v1, v2; - UNITY_INT *p0, *p1, *p2; - - v0 = 3334; - v1 = 302; - v2 = 3334; - p0 = &v0; - p1 = &v1; - p2 = &v2; - - TEST_ASSERT_LESS_OR_EQUAL_INT(v0, v1); - TEST_ASSERT_LESS_OR_EQUAL_INT(*p0, v1); - TEST_ASSERT_LESS_OR_EQUAL_INT(v0, *p1); - TEST_ASSERT_LESS_OR_EQUAL_INT(*p0, *p1); - TEST_ASSERT_LESS_OR_EQUAL_INT(v0, v2); - TEST_ASSERT_LESS_OR_EQUAL_INT(*p0, v2); - TEST_ASSERT_LESS_OR_EQUAL_INT(v0, *p2); - TEST_ASSERT_LESS_OR_EQUAL_INT(*p0, *p2); -} - -void testNotLessOrEqualINT(void) -{ - EXPECT_ABORT_BEGIN - TEST_ASSERT_LESS_OR_EQUAL_INT(302, 3334); - VERIFY_FAILS_END -} - -void testLessOrEqualINT8(void) -{ - UNITY_INT8 v0, v1, v2; - UNITY_INT8 *p0, *p1, *p2; - - v0 = 127; - v1 = -128; - v2 = 127; - p0 = &v0; - p1 = &v1; - p2 = &v2; - - TEST_ASSERT_LESS_OR_EQUAL_INT8(v0, v1); - TEST_ASSERT_LESS_OR_EQUAL_INT8(*p0, v1); - TEST_ASSERT_LESS_OR_EQUAL_INT8(v0, *p1); - TEST_ASSERT_LESS_OR_EQUAL_INT8(*p0, *p1); - TEST_ASSERT_LESS_OR_EQUAL_INT8(v0, v2); - TEST_ASSERT_LESS_OR_EQUAL_INT8(*p0, v2); - TEST_ASSERT_LESS_OR_EQUAL_INT8(v0, *p2); - TEST_ASSERT_LESS_OR_EQUAL_INT8(*p0, *p2); -} - -void testNotLessOrEqualINT8(void) -{ - EXPECT_ABORT_BEGIN - TEST_ASSERT_LESS_OR_EQUAL_INT8(-128, 127); - VERIFY_FAILS_END -} - -void testLessOrEqualCHAR(void) -{ - char v0, v1, v2; - char *p0, *p1, *p2; - - v0 = 127; - v1 = -128; - v2 = 127; - p0 = &v0; - p1 = &v1; - p2 = &v2; - - TEST_ASSERT_LESS_OR_EQUAL_CHAR(v0, v1); - TEST_ASSERT_LESS_OR_EQUAL_CHAR(*p0, v1); - TEST_ASSERT_LESS_OR_EQUAL_CHAR(v0, *p1); - TEST_ASSERT_LESS_OR_EQUAL_CHAR(*p0, *p1); - TEST_ASSERT_LESS_OR_EQUAL_CHAR(v0, v2); - TEST_ASSERT_LESS_OR_EQUAL_CHAR(*p0, v2); - TEST_ASSERT_LESS_OR_EQUAL_CHAR(v0, *p2); - TEST_ASSERT_LESS_OR_EQUAL_CHAR(*p0, *p2); -} - -void testNotLessOrEqualCHAR(void) -{ - EXPECT_ABORT_BEGIN - TEST_ASSERT_LESS_OR_EQUAL_CHAR(-128, 127); - VERIFY_FAILS_END -} - -void testLessOrEqualINT16(void) -{ - UNITY_INT16 v0, v1, v2; - UNITY_INT16 *p0, *p1, *p2; - - v0 = 32767; - v1 = -32768; - v2 = 32767; - p0 = &v0; - p1 = &v1; - p2 = &v2; - - TEST_ASSERT_LESS_OR_EQUAL_INT16(v0, v1); - TEST_ASSERT_LESS_OR_EQUAL_INT16(*p0, v1); - TEST_ASSERT_LESS_OR_EQUAL_INT16(v0, *p1); - TEST_ASSERT_LESS_OR_EQUAL_INT16(*p0, *p1); - TEST_ASSERT_LESS_OR_EQUAL_INT16(v0, v2); - TEST_ASSERT_LESS_OR_EQUAL_INT16(*p0, v2); - TEST_ASSERT_LESS_OR_EQUAL_INT16(v0, *p2); - TEST_ASSERT_LESS_OR_EQUAL_INT16(*p0, *p2); -} - -void testNotLessOrEqualINT16(void) -{ - EXPECT_ABORT_BEGIN - TEST_ASSERT_LESS_OR_EQUAL_INT16(-32768, 32767); - VERIFY_FAILS_END -} - -void testLessOrEqualINT32(void) -{ - UNITY_INT32 v0, v1, v2; - UNITY_INT32 *p0, *p1, *p2; - - v0 = 214783647; - v1 = -214783648; - v2 = 214783647; - p0 = &v0; - p1 = &v1; - p2 = &v2; - - TEST_ASSERT_LESS_OR_EQUAL_INT32(v0, v1); - TEST_ASSERT_LESS_OR_EQUAL_INT32(*p0, v1); - TEST_ASSERT_LESS_OR_EQUAL_INT32(v0, *p1); - TEST_ASSERT_LESS_OR_EQUAL_INT32(*p0, *p1); - TEST_ASSERT_LESS_OR_EQUAL_INT32(v0, v2); - TEST_ASSERT_LESS_OR_EQUAL_INT32(*p0, v2); - TEST_ASSERT_LESS_OR_EQUAL_INT32(v0, *p2); - TEST_ASSERT_LESS_OR_EQUAL_INT32(*p0, *p2); -} - -void testNotLessOrEqualINT32(void) -{ - EXPECT_ABORT_BEGIN - TEST_ASSERT_LESS_OR_EQUAL_INT32(-214783648, 214783647); - VERIFY_FAILS_END -} - -void testLessOrEqualUINT(void) -{ - UNITY_UINT v0, v1, v2; - UNITY_UINT *p0, *p1, *p2; - - v0 = 1; - v1 = 0; - v2 = 1; - p0 = &v0; - p1 = &v1; - p2 = &v2; - - TEST_ASSERT_LESS_OR_EQUAL_UINT(v0, v1); - TEST_ASSERT_LESS_OR_EQUAL_UINT(*p0, v1); - TEST_ASSERT_LESS_OR_EQUAL_UINT(v0, *p1); - TEST_ASSERT_LESS_OR_EQUAL_UINT(*p0, *p1); - TEST_ASSERT_LESS_OR_EQUAL_UINT(v0, v2); - TEST_ASSERT_LESS_OR_EQUAL_UINT(*p0, v2); - TEST_ASSERT_LESS_OR_EQUAL_UINT(v0, *p2); - TEST_ASSERT_LESS_OR_EQUAL_UINT(*p0, *p2); -} - -void testNotLessOrEqualUINT(void) -{ - EXPECT_ABORT_BEGIN - TEST_ASSERT_LESS_OR_EQUAL_UINT(0, 1); - VERIFY_FAILS_END -} - -void testLessOrEqualUINT8(void) -{ - UNITY_UINT8 v0, v1, v2; - UNITY_UINT8 *p0, *p1, *p2; - - v0 = 255; - v1 = 0; - v2 = 255; - p0 = &v0; - p1 = &v1; - p2 = &v2; - - TEST_ASSERT_LESS_OR_EQUAL_UINT8(v0, v1); - TEST_ASSERT_LESS_OR_EQUAL_UINT8(*p0, v1); - TEST_ASSERT_LESS_OR_EQUAL_UINT8(v0, *p1); - TEST_ASSERT_LESS_OR_EQUAL_UINT8(*p0, *p1); - TEST_ASSERT_LESS_OR_EQUAL_UINT8(v0, v2); - TEST_ASSERT_LESS_OR_EQUAL_UINT8(*p0, v2); - TEST_ASSERT_LESS_OR_EQUAL_UINT8(v0, *p2); - TEST_ASSERT_LESS_OR_EQUAL_UINT8(*p0, *p2); -} - -void testNotLessOrEqualUINT8(void) -{ - EXPECT_ABORT_BEGIN - TEST_ASSERT_LESS_OR_EQUAL_UINT8(0, 255); - VERIFY_FAILS_END -} - -void testLessOrEqualUINT16(void) -{ - UNITY_UINT16 v0, v1, v2; - UNITY_UINT16 *p0, *p1, *p2; - - v0 = 65535; - v1 = 0; - v2 = 65535; - p0 = &v0; - p1 = &v1; - p2 = &v2; - - TEST_ASSERT_LESS_OR_EQUAL_UINT16(v0, v1); - TEST_ASSERT_LESS_OR_EQUAL_UINT16(*p0, v1); - TEST_ASSERT_LESS_OR_EQUAL_UINT16(v0, *p1); - TEST_ASSERT_LESS_OR_EQUAL_UINT16(*p0, *p1); - TEST_ASSERT_LESS_OR_EQUAL_UINT16(v0, v2); - TEST_ASSERT_LESS_OR_EQUAL_UINT16(*p0, v2); - TEST_ASSERT_LESS_OR_EQUAL_UINT16(v0, *p2); - TEST_ASSERT_LESS_OR_EQUAL_UINT16(*p0, *p2); -} - -void testNotLessOrEqualUINT16(void) -{ - EXPECT_ABORT_BEGIN - TEST_ASSERT_LESS_OR_EQUAL_UINT16(0, 65535); - VERIFY_FAILS_END -} - -void testLessOrEqualUINT32(void) -{ - UNITY_UINT32 v0, v1, v2; - UNITY_UINT32 *p0, *p1, *p2; - - v0 = 4294967295u; - v1 = 0; - v2 = 4294967295u; - p0 = &v0; - p1 = &v1; - p2 = &v2; - - TEST_ASSERT_LESS_OR_EQUAL_UINT32(v0, v1); - TEST_ASSERT_LESS_OR_EQUAL_UINT32(*p0, v1); - TEST_ASSERT_LESS_OR_EQUAL_UINT32(v0, *p1); - TEST_ASSERT_LESS_OR_EQUAL_UINT32(*p0, *p1); - TEST_ASSERT_LESS_OR_EQUAL_UINT32(v0, v2); - TEST_ASSERT_LESS_OR_EQUAL_UINT32(*p0, v2); - TEST_ASSERT_LESS_OR_EQUAL_UINT32(v0, *p2); - TEST_ASSERT_LESS_OR_EQUAL_UINT32(*p0, *p2); -} - -void testNotLessOrEqualUINT32(void) -{ - EXPECT_ABORT_BEGIN - TEST_ASSERT_LESS_OR_EQUAL_UINT32(0, 4294967295u); - VERIFY_FAILS_END -} - -void testLessOrEqualHEX8(void) -{ - UNITY_UINT8 v0, v1, v2; - UNITY_UINT8 *p0, *p1, *p2; - - v0 = 0xFF; - v1 = 0x00; - v2 = 0xFF; - p0 = &v0; - p1 = &v1; - p2 = &v2; - - TEST_ASSERT_LESS_OR_EQUAL_HEX8(v0, v1); - TEST_ASSERT_LESS_OR_EQUAL_HEX8(*p0, v1); - TEST_ASSERT_LESS_OR_EQUAL_HEX8(v0, *p1); - TEST_ASSERT_LESS_OR_EQUAL_HEX8(*p0, *p1); - TEST_ASSERT_LESS_OR_EQUAL_HEX8(v0, v2); - TEST_ASSERT_LESS_OR_EQUAL_HEX8(*p0, v2); - TEST_ASSERT_LESS_OR_EQUAL_HEX8(v0, *p2); - TEST_ASSERT_LESS_OR_EQUAL_HEX8(*p0, *p2); -} - -void testNotLessOrEqualHEX8(void) -{ - EXPECT_ABORT_BEGIN - TEST_ASSERT_LESS_OR_EQUAL_HEX8(0x00, 0xFF); - VERIFY_FAILS_END -} - -void testLessOrEqualHEX16(void) -{ - UNITY_UINT16 v0, v1, v2; - UNITY_UINT16 *p0, *p1, *p2; - - v0 = 0xFFFF; - v1 = 0x0000; - v2 = 0xFFFF; - p0 = &v0; - p1 = &v1; - p2 = &v2; - - TEST_ASSERT_LESS_OR_EQUAL_HEX16(v0, v1); - TEST_ASSERT_LESS_OR_EQUAL_HEX16(*p0, v1); - TEST_ASSERT_LESS_OR_EQUAL_HEX16(v0, *p1); - TEST_ASSERT_LESS_OR_EQUAL_HEX16(*p0, *p1); - TEST_ASSERT_LESS_OR_EQUAL_HEX16(v0, v2); - TEST_ASSERT_LESS_OR_EQUAL_HEX16(*p0, v2); - TEST_ASSERT_LESS_OR_EQUAL_HEX16(v0, *p2); - TEST_ASSERT_LESS_OR_EQUAL_HEX16(*p0, *p2); -} - -void testNotLessOrEqualHEX16(void) -{ - EXPECT_ABORT_BEGIN - TEST_ASSERT_LESS_OR_EQUAL_HEX16(0x0000, 0xFFFF); - VERIFY_FAILS_END -} - -void testLessOrEqualHEX32(void) -{ - UNITY_UINT32 v0, v1, v2; - UNITY_UINT32 *p0, *p1, *p2; - - v0 = 0xFFFFFFFF; - v1 = 0x00000000; - v2 = 0xFFFFFFFF; - p0 = &v0; - p1 = &v1; - p2 = &v2; - - TEST_ASSERT_LESS_OR_EQUAL_HEX32(v0, v1); - TEST_ASSERT_LESS_OR_EQUAL_HEX32(*p0, v1); - TEST_ASSERT_LESS_OR_EQUAL_HEX32(v0, *p1); - TEST_ASSERT_LESS_OR_EQUAL_HEX32(*p0, *p1); - TEST_ASSERT_LESS_OR_EQUAL_HEX32(v0, v2); - TEST_ASSERT_LESS_OR_EQUAL_HEX32(*p0, v2); - TEST_ASSERT_LESS_OR_EQUAL_HEX32(v0, *p2); - TEST_ASSERT_LESS_OR_EQUAL_HEX32(*p0, *p2); -} - -void testNotLessOrEqualHEX32(void) -{ - EXPECT_ABORT_BEGIN - TEST_ASSERT_LESS_OR_EQUAL_HEX32(0x00000000, 0xFFFFFFFF); - VERIFY_FAILS_END -} - -/*-----------------*/ - -void testEqualStrings(void) -{ - const char *testString = "foo"; - - TEST_ASSERT_EQUAL_STRING(testString, testString); - TEST_ASSERT_EQUAL_STRING_MESSAGE("foo", "foo", "foo isn't foo"); - TEST_ASSERT_EQUAL_STRING("foo", testString); - TEST_ASSERT_EQUAL_STRING(testString, "foo"); - TEST_ASSERT_EQUAL_STRING("", ""); -} - -void testEqualStringsLen(void) -{ - const char *testString = "foobar"; - TEST_ASSERT_EQUAL_STRING_LEN(testString, testString, strlen(testString)); - TEST_ASSERT_EQUAL_STRING_LEN_MESSAGE("foobar", "foobaz", 5, "fooba isn't fooba"); - TEST_ASSERT_EQUAL_STRING_LEN("foo", testString, 3); - TEST_ASSERT_EQUAL_STRING_LEN(testString, "foo", 3); - TEST_ASSERT_EQUAL_STRING_LEN("", "", 3); -} - -void testEqualStringsWithCarriageReturnsAndLineFeeds(void) -{ - const char *testString = "foo\r\nbar"; - - TEST_ASSERT_EQUAL_STRING(testString, testString); - TEST_ASSERT_EQUAL_STRING("foo\r\nbar", "foo\r\nbar"); - TEST_ASSERT_EQUAL_STRING("foo\r\nbar", testString); - TEST_ASSERT_EQUAL_STRING(testString, "foo\r\nbar"); - TEST_ASSERT_EQUAL_STRING("", ""); -} - -void testNotEqualString1(void) -{ - EXPECT_ABORT_BEGIN - TEST_ASSERT_EQUAL_STRING("foo", "bar"); - VERIFY_FAILS_END -} - -void testNotEqualStringLen1(void) -{ - EXPECT_ABORT_BEGIN - TEST_ASSERT_EQUAL_STRING_LEN("foobar", "foobaz", 6); - VERIFY_FAILS_END -} - -void testNotEqualString2(void) -{ - EXPECT_ABORT_BEGIN - TEST_ASSERT_EQUAL_STRING("foo", ""); - VERIFY_FAILS_END -} - -void testNotEqualStringLen2(void) -{ - EXPECT_ABORT_BEGIN - TEST_ASSERT_EQUAL_STRING_LEN("foo", "", 3); - VERIFY_FAILS_END -} - -void testNotEqualString3(void) -{ - EXPECT_ABORT_BEGIN - TEST_ASSERT_EQUAL_STRING("", "bar"); - VERIFY_FAILS_END -} - -void testNotEqualStringLen3(void) -{ - EXPECT_ABORT_BEGIN - TEST_ASSERT_EQUAL_STRING_LEN("", "bar", 3); - VERIFY_FAILS_END -} - -void testNotEqualString4(void) -{ - EXPECT_ABORT_BEGIN - TEST_ASSERT_EQUAL_STRING("bar\r", "bar\n"); - VERIFY_FAILS_END -} - -void testNotEqualStringLen4(void) -{ - EXPECT_ABORT_BEGIN - TEST_ASSERT_EQUAL_STRING_LEN("ba\r\x16", "ba\r\n", 4); - VERIFY_FAILS_END -} - -void testNotEqualString5(void) -{ - const char str1[] = { 0x41, 0x42, 0x03, 0x00 }; - const char str2[] = { 0x41, 0x42, 0x04, 0x00 }; - EXPECT_ABORT_BEGIN - TEST_ASSERT_EQUAL_STRING(str1, str2); - VERIFY_FAILS_END -} - -void testNotEqualString_ExpectedStringIsNull(void) -{ - EXPECT_ABORT_BEGIN - TEST_ASSERT_EQUAL_STRING(NULL, "bar"); - VERIFY_FAILS_END -} - -void testNotEqualStringLen_ExpectedStringIsNull(void) -{ - EXPECT_ABORT_BEGIN - TEST_ASSERT_EQUAL_STRING_LEN(NULL, "bar", 1); - VERIFY_FAILS_END -} - -void testNotEqualString_ActualStringIsNull(void) -{ - EXPECT_ABORT_BEGIN - TEST_ASSERT_EQUAL_STRING("foo", NULL); - VERIFY_FAILS_END -} - -void testNotEqualStringLen_ActualStringIsNull(void) -{ - EXPECT_ABORT_BEGIN - TEST_ASSERT_EQUAL_STRING_LEN("foo", NULL, 1); - VERIFY_FAILS_END -} - -void testNotEqualString_ExpectedStringIsLonger(void) -{ - EXPECT_ABORT_BEGIN - TEST_ASSERT_EQUAL_STRING("foo2", "foo"); - VERIFY_FAILS_END -} - -void testNotEqualString_ActualStringIsLonger(void) -{ - EXPECT_ABORT_BEGIN - TEST_ASSERT_EQUAL_STRING("foo", "foo2"); - VERIFY_FAILS_END -} - -void testEqualStringArrays(void) -{ - const char *testStrings[] = { "foo", "boo", "woo", "moo" }; - const char *expStrings[] = { "foo", "boo", "woo", "zoo" }; - - TEST_ASSERT_EQUAL_STRING_ARRAY(expStrings, expStrings, 3); - TEST_ASSERT_EQUAL_STRING_ARRAY(expStrings, testStrings, 3); - TEST_ASSERT_EQUAL_STRING_ARRAY(expStrings, testStrings, 2); - TEST_ASSERT_EQUAL_STRING_ARRAY(expStrings, testStrings, 1); -} - -void testNotEqualStringArray1(void) -{ - const char *testStrings[] = { "foo", "boo", "woo", "moo" }; - const char *expStrings[] = { "foo", "boo", "woo", "zoo" }; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_EQUAL_STRING_ARRAY(expStrings, testStrings, 4); - VERIFY_FAILS_END -} - -void testNotEqualStringArray2(void) -{ - const char *testStrings[] = { "zoo", "boo", "woo", "moo" }; - const char *expStrings[] = { "foo", "boo", "woo", "moo" }; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_EQUAL_STRING_ARRAY(expStrings, testStrings, 4); - VERIFY_FAILS_END -} - -void testNotEqualStringArray3(void) -{ - const char *testStrings[] = { "foo", "boo", "woo", NULL }; - const char *expStrings[] = { "foo", "boo", "woo", "zoo" }; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_EQUAL_STRING_ARRAY(expStrings, testStrings, 4); - VERIFY_FAILS_END -} - -void testNotEqualStringArray4(void) -{ - const char *testStrings[] = { "foo", "boo", "woo", "moo" }; - const char *expStrings[] = { "foo", NULL, "woo", "moo" }; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_EQUAL_STRING_ARRAY(expStrings, testStrings, 4); - VERIFY_FAILS_END -} - -void testNotEqualStringArray5(void) -{ - const char **testStrings = NULL; - const char *expStrings[] = { "foo", "boo", "woo", "zoo" }; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_EQUAL_STRING_ARRAY(expStrings, testStrings, 4); - VERIFY_FAILS_END -} - -void testNotEqualStringArray6(void) -{ - const char *testStrings[] = { "foo", "boo", "woo", "zoo" }; - const char **expStrings = NULL; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_EQUAL_STRING_ARRAY(expStrings, testStrings, 4); - VERIFY_FAILS_END -} - -void testEqualStringArrayIfBothNulls(void) -{ - const char **testStrings = NULL; - const char **expStrings = NULL; - - TEST_ASSERT_EQUAL_STRING_ARRAY(expStrings, testStrings, 4); -} - -void testNotEqualStringArrayLengthZero(void) -{ - const char *testStrings[] = {NULL}; - const char **expStrings = NULL; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_EQUAL_STRING_ARRAY(expStrings, testStrings, 0); - VERIFY_FAILS_END -} - -void testEqualStringEachEqual(void) -{ - const char *testStrings1[] = { "foo", "foo", "foo", "foo" }; - const char *testStrings2[] = { "boo", "boo", "boo", "zoo" }; - const char *testStrings3[] = { "", "", "", "" }; - - TEST_ASSERT_EACH_EQUAL_STRING("foo", testStrings1, 4); - TEST_ASSERT_EACH_EQUAL_STRING("foo", testStrings1, 1); - TEST_ASSERT_EACH_EQUAL_STRING("boo", testStrings2, 3); - TEST_ASSERT_EACH_EQUAL_STRING("", testStrings3, 4); -} - -void testNotEqualStringEachEqual1(void) -{ - const char *testStrings[] = { "foo", "foo", "foo", "moo" }; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_EACH_EQUAL_STRING("foo", testStrings, 4); - VERIFY_FAILS_END -} - -void testNotEqualStringEachEqual2(void) -{ - const char *testStrings[] = { "boo", "foo", "foo", "foo" }; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_EACH_EQUAL_STRING("foo", testStrings, 4); - VERIFY_FAILS_END -} - -void testNotEqualStringEachEqual3(void) -{ - const char *testStrings[] = { "foo", "foo", "foo", NULL }; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_EACH_EQUAL_STRING("foo", testStrings, 4); - VERIFY_FAILS_END -} - -void testNotEqualStringEachEqual4(void) -{ - const char *testStrings[] = { "foo", "foo", "woo", "foo" }; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_EACH_EQUAL_STRING("foo", testStrings, 4); - VERIFY_FAILS_END -} - -void testNotEqualStringEachEqual5(void) -{ - EXPECT_ABORT_BEGIN - TEST_ASSERT_EACH_EQUAL_STRING("foo", NULL, 1); - VERIFY_FAILS_END -} - -void testEqualMemory(void) -{ - const char *testString = "whatever"; - - TEST_ASSERT_EQUAL_MEMORY(testString, testString, 8); - TEST_ASSERT_EQUAL_MEMORY("whatever", "whatever", 8); - TEST_ASSERT_EQUAL_MEMORY("whatever", testString, 8); - TEST_ASSERT_EQUAL_MEMORY(testString, "whatever", 8); - TEST_ASSERT_EQUAL_MEMORY(testString, "whatever", 2); - TEST_ASSERT_EQUAL_MEMORY(NULL, NULL, 1); -} - -void testNotEqualMemory1(void) -{ - EXPECT_ABORT_BEGIN - TEST_ASSERT_EQUAL_MEMORY("foo", "bar", 3); - VERIFY_FAILS_END -} - -void testNotEqualMemory2(void) -{ - EXPECT_ABORT_BEGIN - TEST_ASSERT_EQUAL_MEMORY("fool", "food", 4); - VERIFY_FAILS_END -} - -void testNotEqualMemory3(void) -{ - EXPECT_ABORT_BEGIN - TEST_ASSERT_EQUAL_MEMORY(NULL, "food", 4); - VERIFY_FAILS_END -} - -void testNotEqualMemory4(void) -{ - EXPECT_ABORT_BEGIN - TEST_ASSERT_EQUAL_MEMORY("fool", NULL, 4); - VERIFY_FAILS_END -} - -void testNotEqualMemoryLengthZero(void) -{ - EXPECT_ABORT_BEGIN - TEST_ASSERT_EQUAL_MEMORY(NULL, NULL, 0); - VERIFY_FAILS_END -} - -void testEqualIntArrays(void) -{ - int p0[] = {1, 8, 987, -2}; - int p1[] = {1, 8, 987, -2}; - int p2[] = {1, 8, 987, 2}; - int p3[] = {1, 500, 600, 700}; - - TEST_ASSERT_EQUAL_INT_ARRAY(p0, p0, 1); - TEST_ASSERT_EQUAL_INT_ARRAY(p0, p0, 4); - TEST_ASSERT_EQUAL_INT_ARRAY(p0, p1, 4); - TEST_ASSERT_EQUAL_INT_ARRAY(p0, p2, 3); - TEST_ASSERT_EQUAL_INT_ARRAY(p0, p3, 1); - TEST_ASSERT_EQUAL_INT_ARRAY(NULL, NULL, 1); -} - -void testNotEqualIntArraysNullExpected(void) -{ - int* p0 = NULL; - int p1[] = {1, 8, 987, 2}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_EQUAL_INT_ARRAY(p0, p1, 4); - VERIFY_FAILS_END -} - -void testNotEqualIntArraysNullActual(void) -{ - int* p1 = NULL; - int p0[] = {1, 8, 987, 2}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_EQUAL_INT_ARRAY(p0, p1, 4); - VERIFY_FAILS_END -} - -void testNotEqualIntArrays1(void) -{ - int p0[] = {1, 8, 987, -2}; - int p1[] = {1, 8, 987, 2}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_EQUAL_INT_ARRAY(p0, p1, 4); - VERIFY_FAILS_END -} - -void testNotEqualIntArrays2(void) -{ - int p0[] = {1, 8, 987, -2}; - int p1[] = {2, 8, 987, -2}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_EQUAL_INT_ARRAY(p0, p1, 4); - VERIFY_FAILS_END -} - -void testNotEqualIntArrays3(void) -{ - int p0[] = {1, 8, 987, -2}; - int p1[] = {1, 8, 986, -2}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_EQUAL_INT_ARRAY(p0, p1, 4); - VERIFY_FAILS_END -} - -void testNotEqualIntArraysLengthZero(void) -{ - UNITY_UINT32 p0[1] = {1}; - UNITY_UINT32 p1[1] = {1}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_EQUAL_INT_ARRAY(p0, p1, 0); - VERIFY_FAILS_END -} - -void testEqualIntEachEqual(void) -{ - int p0[] = {1, 1, 1, 1}; - int p1[] = {987, 987, 987, 987}; - int p2[] = {-2, -2, -2, -3}; - int p3[] = {1, 5, 600, 700}; - - TEST_ASSERT_EACH_EQUAL_INT(1, p0, 1); - TEST_ASSERT_EACH_EQUAL_INT(1, p0, 4); - TEST_ASSERT_EACH_EQUAL_INT(987, p1, 4); - TEST_ASSERT_EACH_EQUAL_INT(-2, p2, 3); - TEST_ASSERT_EACH_EQUAL_INT(1, p3, 1); -} - -void testNotEqualIntEachEqualNullActual(void) -{ - int* p1 = NULL; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_EACH_EQUAL_INT(1, p1, 4); - VERIFY_FAILS_END -} - -void testNotEqualIntEachEqual1(void) -{ - int p0[] = {1, 1, 1, -2}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_EACH_EQUAL_INT(1, p0, 4); - VERIFY_FAILS_END -} - -void testNotEqualIntEachEqual2(void) -{ - int p0[] = {-5, -5, -1, -5}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_EACH_EQUAL_INT(-5, p0, 4); - VERIFY_FAILS_END -} - -void testNotEqualIntEachEqual3(void) -{ - int p0[] = {1, 88, 88, 88}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_EACH_EQUAL_INT(88, p0, 4); - VERIFY_FAILS_END -} - -void testNotEqualEachEqualLengthZero(void) -{ - UNITY_UINT32 p0[1] = {1}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_EACH_EQUAL_INT(0, p0, 0); - VERIFY_FAILS_END -} - -void testEqualPtrArrays(void) -{ - char A = 1; - char B = 2; - char C = 3; - char* p0[] = {&A, &B, &C}; - char* p1[] = {&A, &B, &C, &A}; - char* p2[] = {&A, &B}; - char* p3[] = {&A}; - - TEST_ASSERT_EQUAL_PTR_ARRAY(p0, p0, 1); - TEST_ASSERT_EQUAL_PTR_ARRAY(p0, p0, 3); - TEST_ASSERT_EQUAL_PTR_ARRAY(p0, p1, 3); - TEST_ASSERT_EQUAL_PTR_ARRAY(p1, p2, 2); - TEST_ASSERT_EQUAL_PTR_ARRAY(p3, p0, 1); -} - -void testNotEqualPtrArraysNullExpected(void) -{ - char A = 1; - char B = 2; - char** p0 = NULL; - char* p1[] = {&A, &B}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_EQUAL_PTR_ARRAY(p0, p1, 2); - VERIFY_FAILS_END -} - -void testNotEqualPtrArraysNullActual(void) -{ - char A = 1; - char B = 2; - char** p0 = NULL; - char* p1[] = {&A, &B}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_EQUAL_PTR_ARRAY(p1, p0, 2); - VERIFY_FAILS_END -} - -void testNotEqualPtrArrays1(void) -{ - char A = 1; - char B = 2; - char C = 3; - char* p0[] = {&A, &B, &C, &B}; - char* p1[] = {&A, &B, &C, &A}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_EQUAL_PTR_ARRAY(p0, p1, 4); - VERIFY_FAILS_END -} - -void testNotEqualPtrArrays2(void) -{ - char A = 1; - char B = 2; - char C = 3; - char* p0[] = {&B, &B, &C, &A}; - char* p1[] = {&A, &B, &C, &A}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_EQUAL_PTR_ARRAY(p0, p1, 4); - VERIFY_FAILS_END -} - -void testNotEqualPtrArrays3(void) -{ - char A = 1; - char B = 2; - char C = 3; - char* p0[] = {&A, &B, &B, &A}; - char* p1[] = {&A, &B, &C, &A}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_EQUAL_PTR_ARRAY(p0, p1, 4); - VERIFY_FAILS_END -} - -void testEqualPtrEachEqual(void) -{ - char A = 1; - char B = 2; - char C = 3; - char* p0[] = {&A, &A, &A}; - char* p1[] = {&A, &B, &C, &A}; - char* p2[] = {&B, &B}; - char* p3[] = {&C}; - - TEST_ASSERT_EACH_EQUAL_PTR(&A, p0, 1); - TEST_ASSERT_EACH_EQUAL_PTR(&A, p0, 3); - TEST_ASSERT_EACH_EQUAL_PTR(&A, p1, 1); - TEST_ASSERT_EACH_EQUAL_PTR(&B, p2, 2); - TEST_ASSERT_EACH_EQUAL_PTR(&C, p3, 1); -} - -void testNotEqualPtrEachEqualNullExpected(void) -{ - char A = 1; - char B = 1; - char* p0[] = {&A, &B}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_EACH_EQUAL_PTR(&A, p0, 2); - VERIFY_FAILS_END -} - -void testNotEqualPtrEachEqualNullActual(void) -{ - char A = 1; - char** p0 = NULL; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_EACH_EQUAL_PTR(&A, p0, 2); - VERIFY_FAILS_END -} - -void testNotEqualPtrEachEqual1(void) -{ - char A = 1; - char B = 1; - char* p0[] = {&A, &A, &A, &B}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_EACH_EQUAL_PTR(&A, p0, 4); - VERIFY_FAILS_END -} - -void testNotEqualPtrEachEqual2(void) -{ - char A = 1; - char B = 1; - char* p0[] = {&B, &B, &A, &B}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_EACH_EQUAL_PTR(&B, p0, 4); - VERIFY_FAILS_END -} - -void testNotEqualPtrEachEqual3(void) -{ - char A = 1; - char B = 1; - char* p0[] = {&A, &B, &B, &B}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_EACH_EQUAL_PTR(&B, p0, 4); - VERIFY_FAILS_END -} - -void testEqualInt8Arrays(void) -{ - UNITY_INT8 p0[] = {1, 8, 117, -2}; - UNITY_INT8 p1[] = {1, 8, 117, -2}; - UNITY_INT8 p2[] = {1, 8, 117, 2}; - UNITY_INT8 p3[] = {1, 50, 60, 70}; - - TEST_ASSERT_EQUAL_INT8_ARRAY(p0, p0, 1); - TEST_ASSERT_EQUAL_INT8_ARRAY(p0, p0, 4); - TEST_ASSERT_EQUAL_INT8_ARRAY(p0, p1, 4); - TEST_ASSERT_EQUAL_INT8_ARRAY(p0, p2, 3); - TEST_ASSERT_EQUAL_INT8_ARRAY(p0, p3, 1); -} - -void testNotEqualInt8Arrays(void) -{ - UNITY_INT8 p0[] = {1, 8, 36, -2}; - UNITY_INT8 p1[] = {1, 8, 36, 2}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_EQUAL_INT8_ARRAY(p0, p1, 4); - VERIFY_FAILS_END -} - -void testEqualInt8EachEqual(void) -{ - UNITY_INT8 p0[] = {1, 1, 1, 1}; - UNITY_INT8 p1[] = {117, 117, 117, -2}; - UNITY_INT8 p2[] = {-1, -1, 117, 2}; - UNITY_INT8 p3[] = {1, 50, 60, 70}; - - TEST_ASSERT_EACH_EQUAL_INT8(1, p0, 1); - TEST_ASSERT_EACH_EQUAL_INT8(1, p0, 4); - TEST_ASSERT_EACH_EQUAL_INT8(117, p1, 3); - TEST_ASSERT_EACH_EQUAL_INT8(-1, p2, 2); - TEST_ASSERT_EACH_EQUAL_INT8(1, p3, 1); -} - -void testNotEqualInt8EachEqual(void) -{ - UNITY_INT8 p0[] = {1, 8, 36, -2}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_EACH_EQUAL_INT8(1, p0, 2); - VERIFY_FAILS_END -} - -void testEqualCHARArrays(void) -{ - char p0[] = {1, 8, 117, -2}; - char p1[] = {1, 8, 117, -2}; - char p2[] = {1, 8, 117, 2}; - char p3[] = {1, 50, 60, 70}; - - TEST_ASSERT_EQUAL_CHAR_ARRAY(p0, p0, 1); - TEST_ASSERT_EQUAL_CHAR_ARRAY(p0, p0, 4); - TEST_ASSERT_EQUAL_CHAR_ARRAY(p0, p1, 4); - TEST_ASSERT_EQUAL_CHAR_ARRAY(p0, p2, 3); - TEST_ASSERT_EQUAL_CHAR_ARRAY(p0, p3, 1); -} - -void testNotEqualCHARArrays(void) -{ - char p0[] = {1, 8, 36, -2}; - char p1[] = {1, 8, 36, 2}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_EQUAL_CHAR_ARRAY(p0, p1, 4); - VERIFY_FAILS_END -} - -void testEqualCHAREachEqual(void) -{ - char p0[] = {1, 1, 1, 1}; - char p1[] = {117, 117, 117, -2}; - char p2[] = {-1, -1, 117, 2}; - char p3[] = {1, 50, 60, 70}; - - TEST_ASSERT_EACH_EQUAL_CHAR(1, p0, 1); - TEST_ASSERT_EACH_EQUAL_CHAR(1, p0, 4); - TEST_ASSERT_EACH_EQUAL_CHAR(117, p1, 3); - TEST_ASSERT_EACH_EQUAL_CHAR(-1, p2, 2); - TEST_ASSERT_EACH_EQUAL_CHAR(1, p3, 1); -} - -void testNotEqualCHAREachEqual(void) -{ - char p0[] = {1, 8, 36, -2}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_EACH_EQUAL_CHAR(1, p0, 2); - VERIFY_FAILS_END -} - -void testEqualUIntArrays(void) -{ - unsigned int p0[] = {1, 8, 987, 65132u}; - unsigned int p1[] = {1, 8, 987, 65132u}; - unsigned int p2[] = {1, 8, 987, 2}; - unsigned int p3[] = {1, 500, 600, 700}; - - TEST_ASSERT_EQUAL_UINT_ARRAY(p0, p0, 1); - TEST_ASSERT_EQUAL_UINT_ARRAY(p0, p0, 4); - TEST_ASSERT_EQUAL_UINT_ARRAY(p0, p1, 4); - TEST_ASSERT_EQUAL_UINT_ARRAY(p0, p2, 3); - TEST_ASSERT_EQUAL_UINT_ARRAY(p0, p3, 1); -} - -void testNotEqualUIntArrays1(void) -{ - unsigned int p0[] = {1, 8, 987, 65132u}; - unsigned int p1[] = {1, 8, 987, 65131u}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_EQUAL_UINT_ARRAY(p0, p1, 4); - VERIFY_FAILS_END -} - -void testNotEqualUIntArrays2(void) -{ - unsigned int p0[] = {1, 8, 987, 65132u}; - unsigned int p1[] = {2, 8, 987, 65132u}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_EQUAL_UINT_ARRAY(p0, p1, 4); - VERIFY_FAILS_END -} - -void testNotEqualUIntArrays3(void) -{ - unsigned int p0[] = {1, 8, 987, 65132u}; - unsigned int p1[] = {1, 8, 986, 65132u}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_EQUAL_UINT_ARRAY(p0, p1, 4); - VERIFY_FAILS_END -} - -void testEqualUIntEachEqual(void) -{ - unsigned int p0[] = {1, 1, 1, 1}; - unsigned int p1[] = {65132u, 65132u, 65132u, 65132u}; - unsigned int p2[] = {8, 8, 987, 2}; - unsigned int p3[] = {1, 500, 600, 700}; - - TEST_ASSERT_EACH_EQUAL_UINT(1, p0, 1); - TEST_ASSERT_EACH_EQUAL_UINT(1, p0, 4); - TEST_ASSERT_EACH_EQUAL_UINT(65132u, p1, 4); - TEST_ASSERT_EACH_EQUAL_UINT(8, p2, 2); - TEST_ASSERT_EACH_EQUAL_UINT(1, p3, 1); -} - -void testNotEqualUIntEachEqual1(void) -{ - unsigned int p0[] = {1, 65132u, 65132u, 65132u}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_EACH_EQUAL_UINT(65132u, p0, 4); - VERIFY_FAILS_END -} - -void testNotEqualUIntEachEqual2(void) -{ - unsigned int p0[] = {987, 8, 987, 987}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_EACH_EQUAL_UINT(987, p0, 4); - VERIFY_FAILS_END -} - -void testNotEqualUIntEachEqual3(void) -{ - unsigned int p0[] = {1, 1, 1, 65132u}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_EACH_EQUAL_UINT(1, p0, 4); - VERIFY_FAILS_END -} - -void testEqualInt16Arrays(void) -{ - UNITY_INT16 p0[] = {1, 8, 117, 3}; - UNITY_INT16 p1[] = {1, 8, 117, 3}; - UNITY_INT16 p2[] = {1, 8, 117, 2}; - UNITY_INT16 p3[] = {1, 50, 60, 70}; - - TEST_ASSERT_EQUAL_INT16_ARRAY(p0, p0, 1); - TEST_ASSERT_EQUAL_INT16_ARRAY(p0, p0, 4); - TEST_ASSERT_EQUAL_INT16_ARRAY(p0, p1, 4); - TEST_ASSERT_EQUAL_INT16_ARRAY(p0, p2, 3); - TEST_ASSERT_EQUAL_INT16_ARRAY(p0, p3, 1); -} - -void testNotEqualInt16Arrays(void) -{ - UNITY_INT16 p0[] = {1, 8, 127, 3}; - UNITY_INT16 p1[] = {1, 8, 127, 2}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_EQUAL_INT16_ARRAY(p0, p1, 4); - VERIFY_FAILS_END -} - -void testEqualInt16EachEqual(void) -{ - UNITY_INT16 p0[] = {1, 1, 1, 1}; - UNITY_INT16 p1[] = {32111, 32111, 32111, 3}; - UNITY_INT16 p2[] = {-1, -1, -1, 2}; - UNITY_INT16 p3[] = {1, 50, 60, 70}; - - TEST_ASSERT_EACH_EQUAL_INT16(1, p0, 1); - TEST_ASSERT_EACH_EQUAL_INT16(1, p0, 4); - TEST_ASSERT_EACH_EQUAL_INT16(32111, p1, 3); - TEST_ASSERT_EACH_EQUAL_INT16(-1, p2, 3); - TEST_ASSERT_EACH_EQUAL_INT16(1, p3, 1); -} - -void testNotEqualInt16EachEqual(void) -{ - UNITY_INT16 p0[] = {127, 127, 127, 3}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_EACH_EQUAL_INT16(127, p0, 4); - VERIFY_FAILS_END -} - -void testEqualInt32Arrays(void) -{ - UNITY_INT32 p0[] = {1, 8, 117, 3}; - UNITY_INT32 p1[] = {1, 8, 117, 3}; - UNITY_INT32 p2[] = {1, 8, 117, 2}; - UNITY_INT32 p3[] = {1, 50, 60, 70}; - - TEST_ASSERT_EQUAL_INT32_ARRAY(p0, p0, 1); - TEST_ASSERT_EQUAL_INT32_ARRAY(p0, p0, 4); - TEST_ASSERT_EQUAL_INT32_ARRAY(p0, p1, 4); - TEST_ASSERT_EQUAL_INT32_ARRAY(p0, p2, 3); - TEST_ASSERT_EQUAL_INT32_ARRAY(p0, p3, 1); -} - -void testNotEqualInt32Arrays(void) -{ - UNITY_INT32 p0[] = {1, 8, 127, 3}; - UNITY_INT32 p1[] = {1, 8, 127, 2}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_EQUAL_INT32_ARRAY(p0, p1, 4); - VERIFY_FAILS_END -} - -void testEqualInt32EachEqual(void) -{ - UNITY_INT32 p0[] = {8, 8, 8, 8}; - UNITY_INT32 p1[] = {65537, 65537, 65537, 65537}; - UNITY_INT32 p2[] = {-3, -3, -3, 2}; - UNITY_INT32 p3[] = {1, 50, 60, 70}; - - TEST_ASSERT_EACH_EQUAL_INT32(8, p0, 1); - TEST_ASSERT_EACH_EQUAL_INT32(8, p0, 4); - TEST_ASSERT_EACH_EQUAL_INT32(65537, p1, 4); - TEST_ASSERT_EACH_EQUAL_INT32(-3, p2, 3); - TEST_ASSERT_EACH_EQUAL_INT32(1, p3, 1); -} - -void testNotEqualInt32EachEqual(void) -{ - UNITY_INT32 p0[] = {127, 8, 127, 127}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_EACH_EQUAL_INT32(127, p0, 4); - VERIFY_FAILS_END -} - -void testEqualUINT8Arrays(void) -{ - UNITY_UINT8 p0[] = {1, 8, 100, 127}; - UNITY_UINT8 p1[] = {1, 8, 100, 127}; - UNITY_UINT8 p2[] = {1, 8, 100, 2}; - UNITY_UINT8 p3[] = {1, 50, 60, 70}; - - TEST_ASSERT_EQUAL_UINT8_ARRAY(p0, p0, 1); - TEST_ASSERT_EQUAL_UINT8_ARRAY(p0, p0, 4); - TEST_ASSERT_EQUAL_UINT8_ARRAY(p0, p1, 4); - TEST_ASSERT_EQUAL_UINT8_ARRAY(p0, p2, 3); - TEST_ASSERT_EQUAL_UINT8_ARRAY(p0, p3, 1); -} - -void testNotEqualUINT8Arrays1(void) -{ - unsigned char p0[] = {1, 8, 100, 127u}; - unsigned char p1[] = {1, 8, 100, 255u}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_EQUAL_UINT8_ARRAY(p0, p1, 4); - VERIFY_FAILS_END -} - -void testNotEqualUINT8Arrays2(void) -{ - unsigned char p0[] = {1, 8, 100, 127u}; - unsigned char p1[] = {1, 8, 100, 255u}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_EQUAL_UINT8_ARRAY(p0, p1, 4); - VERIFY_FAILS_END -} - -void testNotEqualUINT8Arrays3(void) -{ - unsigned char p0[] = {1, 8, 100, 127u}; - unsigned char p1[] = {1, 8, 100, 255u}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_EQUAL_UINT8_ARRAY(p0, p1, 4); - VERIFY_FAILS_END -} - - -void testEqualUINT16Arrays(void) -{ - unsigned short p0[] = {1, 8, 987, 65132u}; - unsigned short p1[] = {1, 8, 987, 65132u}; - unsigned short p2[] = {1, 8, 987, 2}; - unsigned short p3[] = {1, 500, 600, 700}; - - TEST_ASSERT_EQUAL_UINT16_ARRAY(p0, p0, 1); - TEST_ASSERT_EQUAL_UINT16_ARRAY(p0, p0, 4); - TEST_ASSERT_EQUAL_UINT16_ARRAY(p0, p1, 4); - TEST_ASSERT_EQUAL_UINT16_ARRAY(p0, p2, 3); - TEST_ASSERT_EQUAL_UINT16_ARRAY(p0, p3, 1); -} - -void testNotEqualUINT16Arrays1(void) -{ - unsigned short p0[] = {1, 8, 987, 65132u}; - unsigned short p1[] = {1, 8, 987, 65131u}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_EQUAL_UINT16_ARRAY(p0, p1, 4); - VERIFY_FAILS_END -} - -void testNotEqualUINT16Arrays2(void) -{ - unsigned short p0[] = {1, 8, 987, 65132u}; - unsigned short p1[] = {2, 8, 987, 65132u}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_EQUAL_UINT16_ARRAY(p0, p1, 4); - VERIFY_FAILS_END -} - -void testNotEqualUINT16Arrays3(void) -{ - unsigned short p0[] = {1, 8, 987, 65132u}; - unsigned short p1[] = {1, 8, 986, 65132u}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_EQUAL_UINT16_ARRAY(p0, p1, 4); - VERIFY_FAILS_END -} - -void testEqualUINT32Arrays(void) -{ - UNITY_UINT32 p0[] = {1, 8, 987, 65132u}; - UNITY_UINT32 p1[] = {1, 8, 987, 65132u}; - UNITY_UINT32 p2[] = {1, 8, 987, 2}; - UNITY_UINT32 p3[] = {1, 500, 600, 700}; - - TEST_ASSERT_EQUAL_UINT32_ARRAY(p0, p0, 1); - TEST_ASSERT_EQUAL_UINT32_ARRAY(p0, p0, 4); - TEST_ASSERT_EQUAL_UINT32_ARRAY(p0, p1, 4); - TEST_ASSERT_EQUAL_UINT32_ARRAY(p0, p2, 3); - TEST_ASSERT_EQUAL_UINT32_ARRAY(p0, p3, 1); -} - -void testNotEqualUINT32Arrays1(void) -{ - UNITY_UINT32 p0[] = {1, 8, 987, 65132u}; - UNITY_UINT32 p1[] = {1, 8, 987, 65131u}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_EQUAL_UINT32_ARRAY(p0, p1, 4); - VERIFY_FAILS_END -} - -void testNotEqualUINT32Arrays2(void) -{ - UNITY_UINT32 p0[] = {1, 8, 987, 65132u}; - UNITY_UINT32 p1[] = {2, 8, 987, 65132u}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_EQUAL_UINT32_ARRAY(p0, p1, 4); - VERIFY_FAILS_END -} - -void testNotEqualUINT32Arrays3(void) -{ - UNITY_UINT32 p0[] = {1, 8, 987, 65132u}; - UNITY_UINT32 p1[] = {1, 8, 986, 65132u}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_EQUAL_UINT32_ARRAY(p0, p1, 4); - VERIFY_FAILS_END -} - -void testEqualHEXArrays(void) -{ - UNITY_UINT32 p0[] = {1, 8, 987, 65132u}; - UNITY_UINT32 p1[] = {1, 8, 987, 65132u}; - UNITY_UINT32 p2[] = {1, 8, 987, 2}; - UNITY_UINT32 p3[] = {1, 500, 600, 700}; - - TEST_ASSERT_EQUAL_HEX_ARRAY(p0, p0, 1); - TEST_ASSERT_EQUAL_HEX_ARRAY(p0, p0, 4); - TEST_ASSERT_EQUAL_HEX_ARRAY(p0, p1, 4); - TEST_ASSERT_EQUAL_HEX32_ARRAY(p0, p2, 3); - TEST_ASSERT_EQUAL_HEX32_ARRAY(p0, p3, 1); -} - -void testNotEqualHEXArrays1(void) -{ - UNITY_UINT32 p0[] = {1, 8, 987, 65132u}; - UNITY_UINT32 p1[] = {1, 8, 987, 65131u}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_EQUAL_HEX32_ARRAY(p0, p1, 4); - VERIFY_FAILS_END -} - -void testNotEqualHEXArrays2(void) -{ - UNITY_UINT32 p0[] = {1, 8, 987, 65132u}; - UNITY_UINT32 p1[] = {2, 8, 987, 65132u}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_EQUAL_HEX32_ARRAY(p0, p1, 4); - VERIFY_FAILS_END -} - -void testNotEqualHEXArrays3(void) -{ - UNITY_UINT32 p0[] = {1, 8, 987, 65132u}; - UNITY_UINT32 p1[] = {1, 8, 986, 65132u}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_EQUAL_HEX_ARRAY(p0, p1, 4); - VERIFY_FAILS_END -} - -void testEqualHEX32Arrays(void) -{ - UNITY_UINT32 p0[] = {1, 8, 987, 65132u}; - UNITY_UINT32 p1[] = {1, 8, 987, 65132u}; - UNITY_UINT32 p2[] = {1, 8, 987, 2}; - UNITY_UINT32 p3[] = {1, 500, 600, 700}; - - TEST_ASSERT_EQUAL_HEX32_ARRAY(p0, p0, 1); - TEST_ASSERT_EQUAL_HEX32_ARRAY(p0, p0, 4); - TEST_ASSERT_EQUAL_HEX32_ARRAY(p0, p1, 4); - TEST_ASSERT_EQUAL_HEX32_ARRAY(p0, p2, 3); - TEST_ASSERT_EQUAL_HEX32_ARRAY(p0, p3, 1); -} - -void testNotEqualHEX32Arrays1(void) -{ - UNITY_UINT32 p0[] = {1, 8, 987, 65132u}; - UNITY_UINT32 p1[] = {1, 8, 987, 65131u}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_EQUAL_HEX32_ARRAY(p0, p1, 4); - VERIFY_FAILS_END -} - -void testNotEqualHEX32Arrays2(void) -{ - UNITY_UINT32 p0[] = {1, 8, 987, 65132u}; - UNITY_UINT32 p1[] = {2, 8, 987, 65132u}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_EQUAL_HEX32_ARRAY(p0, p1, 4); - VERIFY_FAILS_END -} - -void testNotEqualHEX32Arrays3(void) -{ - UNITY_UINT32 p0[] = {1, 8, 987, 65132u}; - UNITY_UINT32 p1[] = {1, 8, 986, 65132u}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_EQUAL_HEX32_ARRAY(p0, p1, 4); - VERIFY_FAILS_END -} - -void testEqualHEX16Arrays(void) -{ - unsigned short p0[] = {1, 8, 987, 65132u}; - unsigned short p1[] = {1, 8, 987, 65132u}; - unsigned short p2[] = {1, 8, 987, 2}; - unsigned short p3[] = {1, 500, 600, 700}; - - TEST_ASSERT_EQUAL_HEX16_ARRAY(p0, p0, 1); - TEST_ASSERT_EQUAL_HEX16_ARRAY(p0, p0, 4); - TEST_ASSERT_EQUAL_HEX16_ARRAY(p0, p1, 4); - TEST_ASSERT_EQUAL_HEX16_ARRAY(p0, p2, 3); - TEST_ASSERT_EQUAL_HEX16_ARRAY(p0, p3, 1); -} - -void testNotEqualHEX16Arrays1(void) -{ - unsigned short p0[] = {1, 8, 987, 65132u}; - unsigned short p1[] = {1, 8, 987, 65131u}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_EQUAL_HEX16_ARRAY(p0, p1, 4); - VERIFY_FAILS_END -} - -void testNotEqualHEX16Arrays2(void) -{ - unsigned short p0[] = {1, 8, 987, 65132u}; - unsigned short p1[] = {2, 8, 987, 65132u}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_EQUAL_HEX16_ARRAY(p0, p1, 4); - VERIFY_FAILS_END -} - -void testNotEqualHEX16Arrays3(void) -{ - unsigned short p0[] = {1, 8, 987, 65132u}; - unsigned short p1[] = {1, 8, 986, 65132u}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_EQUAL_HEX16_ARRAY(p0, p1, 4); - VERIFY_FAILS_END -} - -void testEqualHEX8Arrays(void) -{ - unsigned char p0[] = {1, 8, 254u, 123}; - unsigned char p1[] = {1, 8, 254u, 123}; - unsigned char p2[] = {1, 8, 254u, 2}; - unsigned char p3[] = {1, 23, 25, 26}; - - TEST_ASSERT_EQUAL_HEX8_ARRAY(p0, p0, 1); - TEST_ASSERT_EQUAL_HEX8_ARRAY(p0, p0, 4); - TEST_ASSERT_EQUAL_HEX8_ARRAY(p0, p1, 4); - TEST_ASSERT_EQUAL_HEX8_ARRAY(p0, p2, 3); - TEST_ASSERT_EQUAL_HEX8_ARRAY(p0, p3, 1); -} - -void testNotEqualHEX8Arrays1(void) -{ - unsigned char p0[] = {1, 8, 254u, 253u}; - unsigned char p1[] = {1, 8, 254u, 252u}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_EQUAL_HEX8_ARRAY(p0, p1, 4); - VERIFY_FAILS_END -} - -void testNotEqualHEX8Arrays2(void) -{ - unsigned char p0[] = {1, 8, 254u, 253u}; - unsigned char p1[] = {2, 8, 254u, 253u}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_EQUAL_HEX8_ARRAY(p0, p1, 4); - VERIFY_FAILS_END -} - -void testNotEqualHEX8Arrays3(void) -{ - unsigned char p0[] = {1, 8, 254u, 253u}; - unsigned char p1[] = {1, 8, 255u, 253u}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_EQUAL_HEX8_ARRAY(p0, p1, 4); - VERIFY_FAILS_END -} - -void testEqualUINT8EachEqual(void) -{ - UNITY_UINT8 p0[] = {127u, 127u, 127u, 127u}; - UNITY_UINT8 p1[] = {1u, 1u, 1u, 1u}; - UNITY_UINT8 p2[] = {128u, 128u, 128u, 2u}; - UNITY_UINT8 p3[] = {1u, 50u, 60u, 70u}; - - TEST_ASSERT_EACH_EQUAL_UINT8(127u, p0, 1); - TEST_ASSERT_EACH_EQUAL_UINT8(127u, p0, 4); - TEST_ASSERT_EACH_EQUAL_UINT8(1u, p1, 4); - TEST_ASSERT_EACH_EQUAL_UINT8(128u, p2, 3); - TEST_ASSERT_EACH_EQUAL_UINT8(1u, p3, 1); -} - -void testNotEqualUINT8EachEqual1(void) -{ - unsigned char p0[] = {127u, 127u, 128u, 127u}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_EACH_EQUAL_UINT8(127u, p0, 4); - VERIFY_FAILS_END -} - -void testNotEqualUINT8EachEqual2(void) -{ - unsigned char p0[] = {1, 1, 1, 127u}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_EACH_EQUAL_UINT8(1, p0, 4); - VERIFY_FAILS_END -} - -void testNotEqualUINT8EachEqual3(void) -{ - unsigned char p0[] = {54u, 55u, 55u, 55u}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_EACH_EQUAL_UINT8(55u, p0, 4); - VERIFY_FAILS_END -} - -void testEqualUINT16EachEqual(void) -{ - unsigned short p0[] = {65132u, 65132u, 65132u, 65132u}; - unsigned short p1[] = {987, 987, 987, 987}; - unsigned short p2[] = {1, 1, 1, 2}; - unsigned short p3[] = {1, 500, 600, 700}; - - TEST_ASSERT_EACH_EQUAL_UINT16(65132u, p0, 1); - TEST_ASSERT_EACH_EQUAL_UINT16(65132u, p0, 4); - TEST_ASSERT_EACH_EQUAL_UINT16(987, p1, 4); - TEST_ASSERT_EACH_EQUAL_UINT16(1, p2, 3); - TEST_ASSERT_EACH_EQUAL_UINT16(1, p3, 1); -} - -void testNotEqualUINT16EachEqual1(void) -{ - unsigned short p0[] = {1, 65132u, 65132u, 65132u}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_EACH_EQUAL_UINT16(65132u, p0, 4); - VERIFY_FAILS_END -} - -void testNotEqualUINT16EachEqual2(void) -{ - unsigned short p0[] = {65132u, 65132u, 987, 65132u}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_EACH_EQUAL_UINT16(65132u, p0, 4); - VERIFY_FAILS_END -} - -void testNotEqualUINT16EachEqual3(void) -{ - unsigned short p0[] = {65132u, 65132u, 65132u, 65133u}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_EACH_EQUAL_UINT16(65132u, p0, 4); - VERIFY_FAILS_END -} - -void testEqualUINT32EachEqual(void) -{ - UNITY_UINT32 p0[] = {65132u, 65132u, 65132u, 65132u}; - UNITY_UINT32 p1[] = {987, 987, 987, 987}; - UNITY_UINT32 p2[] = {8, 8, 8, 2}; - UNITY_UINT32 p3[] = {1, 500, 600, 700}; - - TEST_ASSERT_EACH_EQUAL_UINT32(65132u, p0, 1); - TEST_ASSERT_EACH_EQUAL_UINT32(65132u, p0, 4); - TEST_ASSERT_EACH_EQUAL_UINT32(987, p1, 4); - TEST_ASSERT_EACH_EQUAL_UINT32(8, p2, 3); - TEST_ASSERT_EACH_EQUAL_UINT32(1, p3, 1); -} - -void testNotEqualUINT32EachEqual1(void) -{ - UNITY_UINT32 p0[] = {65132u, 65132u, 987, 65132u}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_EACH_EQUAL_UINT32(65132u, p0, 4); - VERIFY_FAILS_END -} - -void testNotEqualUINT32EachEqual2(void) -{ - UNITY_UINT32 p0[] = {1, 987, 987, 987}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_EACH_EQUAL_UINT32(987, p0, 4); - VERIFY_FAILS_END -} - -void testNotEqualUINT32EachEqual3(void) -{ - UNITY_UINT32 p0[] = {1, 1, 1, 65132u}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_EACH_EQUAL_UINT32(1, p0, 4); - VERIFY_FAILS_END -} - -void testEqualHEXEachEqual(void) -{ - UNITY_UINT32 p0[] = {65132u, 65132u, 65132u, 65132u}; - UNITY_UINT32 p1[] = {987, 987, 987, 987}; - UNITY_UINT32 p2[] = {8, 8, 8, 2}; - UNITY_UINT32 p3[] = {1, 500, 600, 700}; - - TEST_ASSERT_EACH_EQUAL_HEX(65132u, p0, 1); - TEST_ASSERT_EACH_EQUAL_HEX(65132u, p0, 4); - TEST_ASSERT_EACH_EQUAL_HEX(987, p1, 4); - TEST_ASSERT_EACH_EQUAL_HEX(8, p2, 3); - TEST_ASSERT_EACH_EQUAL_HEX(1, p3, 1); -} - -void testNotEqualHEXEachEqual1(void) -{ - UNITY_UINT32 p0[] = {1, 65132u, 65132u, 65132u}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_EACH_EQUAL_HEX32(65132u, p0, 4); - VERIFY_FAILS_END -} - -void testNotEqualHEXEachEqual2(void) -{ - UNITY_UINT32 p0[] = {987, 987, 987, 65132u}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_EACH_EQUAL_HEX32(987, p0, 4); - VERIFY_FAILS_END -} - -void testNotEqualHEXEachEqual3(void) -{ - UNITY_UINT32 p0[] = {8, 8, 987, 8}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_EACH_EQUAL_HEX(8, p0, 4); - VERIFY_FAILS_END -} - -void testEqualHEX32EachEqual(void) -{ - UNITY_UINT32 p0[] = {65132u, 65132u, 65132u, 65132u}; - UNITY_UINT32 p1[] = {987, 987, 987, 987}; - UNITY_UINT32 p2[] = {8, 8, 8, 2}; - UNITY_UINT32 p3[] = {1, 500, 600, 700}; - - TEST_ASSERT_EACH_EQUAL_HEX32(65132u, p0, 1); - TEST_ASSERT_EACH_EQUAL_HEX32(65132u, p0, 4); - TEST_ASSERT_EACH_EQUAL_HEX32(987, p1, 4); - TEST_ASSERT_EACH_EQUAL_HEX32(8, p2, 3); - TEST_ASSERT_EACH_EQUAL_HEX32(1, p3, 1); -} - -void testNotEqualHEX32EachEqual1(void) -{ - UNITY_UINT32 p0[] = {65132u, 8, 65132u, 65132u}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_EACH_EQUAL_HEX32(65132u, p0, 4); - VERIFY_FAILS_END -} - -void testNotEqualHEX32EachEqual2(void) -{ - UNITY_UINT32 p0[] = {1, 987, 987, 987}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_EACH_EQUAL_HEX32(987, p0, 4); - VERIFY_FAILS_END -} - -void testNotEqualHEX32EachEqual3(void) -{ - UNITY_UINT32 p0[] = {8, 8, 8, 65132u}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_EACH_EQUAL_HEX32(8, p0, 4); - VERIFY_FAILS_END -} - -void testEqualHEX16EachEqual(void) -{ - UNITY_UINT16 p0[] = {65132u, 65132u, 65132u, 65132u}; - UNITY_UINT16 p1[] = {987, 987, 987, 987}; - UNITY_UINT16 p2[] = {8, 8, 8, 2}; - UNITY_UINT16 p3[] = {1, 500, 600, 700}; - - TEST_ASSERT_EACH_EQUAL_HEX16(65132u, p0, 1); - TEST_ASSERT_EACH_EQUAL_HEX16(65132u, p0, 4); - TEST_ASSERT_EACH_EQUAL_HEX16(987, p1, 4); - TEST_ASSERT_EACH_EQUAL_HEX16(8, p2, 3); - TEST_ASSERT_EACH_EQUAL_HEX16(1, p3, 1); -} - -void testNotEqualHEX16EachEqual1(void) -{ - unsigned short p0[] = {65132u, 65132u, 987, 65132u}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_EACH_EQUAL_HEX16(65132u, p0, 4); - VERIFY_FAILS_END -} - -void testNotEqualHEX16EachEqual2(void) -{ - unsigned short p0[] = {1, 987, 987, 987}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_EACH_EQUAL_HEX16(987, p0, 4); - VERIFY_FAILS_END -} - -void testNotEqualHEX16EachEqual3(void) -{ - unsigned short p0[] = {8, 8, 8, 65132u}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_EACH_EQUAL_HEX16(8, p0, 4); - VERIFY_FAILS_END -} - -void testEqualHEX8EachEqual(void) -{ - unsigned char p0[] = {254u, 254u, 254u, 254u}; - unsigned char p1[] = {123, 123, 123, 123}; - unsigned char p2[] = {8, 8, 8, 2}; - unsigned char p3[] = {1, 23, 25, 26}; - - TEST_ASSERT_EACH_EQUAL_HEX8(254u, p0, 1); - TEST_ASSERT_EACH_EQUAL_HEX8(254u, p0, 4); - TEST_ASSERT_EACH_EQUAL_HEX8(123, p1, 4); - TEST_ASSERT_EACH_EQUAL_HEX8(8, p2, 3); - TEST_ASSERT_EACH_EQUAL_HEX8(1, p3, 1); -} - -void testNotEqualHEX8EachEqual1(void) -{ - unsigned char p0[] = {253u, 253u, 254u, 253u}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_EACH_EQUAL_HEX8(253u, p0, 4); - VERIFY_FAILS_END -} - -void testNotEqualHEX8EachEqual2(void) -{ - unsigned char p0[] = {254u, 254u, 254u, 253u}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_EACH_EQUAL_HEX8(254u, p0, 4); - VERIFY_FAILS_END -} - -void testNotEqualHEX8EachEqual3(void) -{ - unsigned char p0[] = {1, 8, 8, 8}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_EACH_EQUAL_HEX8(8, p0, 4); - VERIFY_FAILS_END -} - -void testEqualMemoryArrays(void) -{ - int p0[] = {1, 8, 987, -2}; - int p1[] = {1, 8, 987, -2}; - int p2[] = {1, 8, 987, 2}; - int p3[] = {1, 500, 600, 700}; - - TEST_ASSERT_EQUAL_MEMORY_ARRAY(p0, p0, sizeof(int), 1); - TEST_ASSERT_EQUAL_MEMORY_ARRAY(p0, p0, sizeof(int), 4); - TEST_ASSERT_EQUAL_MEMORY_ARRAY(p0, p1, sizeof(int), 4); - TEST_ASSERT_EQUAL_MEMORY_ARRAY(p0, p2, sizeof(int), 3); - TEST_ASSERT_EQUAL_MEMORY_ARRAY(p0, p3, sizeof(int), 1); -} - -void testNotEqualMemoryArraysExpectedNull(void) -{ - int* p0 = NULL; - int p1[] = {1, 8, 987, 2}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_EQUAL_MEMORY_ARRAY(p0, p1, sizeof(int), 4); - VERIFY_FAILS_END -} - -void testNotEqualMemoryArraysActualNull(void) -{ - int p0[] = {1, 8, 987, -2}; - int* p1 = NULL; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_EQUAL_MEMORY_ARRAY(p0, p1, sizeof(int), 4); - VERIFY_FAILS_END -} - -void testNotEqualMemoryArrays1(void) -{ - int p0[] = {1, 8, 987, -2}; - int p1[] = {1, 8, 987, 2}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_EQUAL_MEMORY_ARRAY(p0, p1, sizeof(int), 4); - VERIFY_FAILS_END -} - -void testNotEqualMemoryArrays2(void) -{ - int p0[] = {1, 8, 987, -2}; - int p1[] = {2, 8, 987, -2}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_EQUAL_MEMORY_ARRAY(p0, p1, sizeof(int), 4); - VERIFY_FAILS_END -} - -void testNotEqualMemoryArrays3(void) -{ - int p0[] = {1, 8, 987, -2}; - int p1[] = {1, 8, 986, -2}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_EQUAL_MEMORY_ARRAY(p0, p1, sizeof(int), 4); - VERIFY_FAILS_END -} - -void testEqualMemoryEachEqual(void) -{ - int p0[] = {1, 8, 987, -2}; - int p1[] = {1, 8, 987, -2, 1, 8, 987, -2}; - int p2[] = {8, 8, 8, 2}; - int p3[] = {8, 500, 600, 700}; - int v = 8; - - TEST_ASSERT_EACH_EQUAL_MEMORY(p0, p0, sizeof(int)*4, 1); - TEST_ASSERT_EACH_EQUAL_MEMORY(p0, p1, sizeof(int)*4, 2); - TEST_ASSERT_EACH_EQUAL_MEMORY(p0, p1, sizeof(int)*4, 1); - TEST_ASSERT_EACH_EQUAL_MEMORY(&v, p2, sizeof(int), 3); - TEST_ASSERT_EACH_EQUAL_MEMORY(&v, p3, sizeof(int), 1); -} - -void testNotEqualMemoryEachEqualExpectedNull(void) -{ - int* p0 = NULL; - int p1[] = {1, 8, 987, 2}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_EACH_EQUAL_MEMORY(p0, p1, sizeof(int), 4); - VERIFY_FAILS_END -} - -void testNotEqualMemoryEachEqualActualNull(void) -{ - int p0[] = {1, 8, 987, -2}; - int* p1 = NULL; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_EACH_EQUAL_MEMORY(p0, p1, sizeof(int), 4); - VERIFY_FAILS_END -} - -void testNotEqualMemoryEachEqual1(void) -{ - int p0[] = {1, 8, 987, -2}; - int p1[] = {9, 8, 987, -2, 1, 8, 987, -2, 1, 8, 987, -2}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_EACH_EQUAL_MEMORY(p0, p1, sizeof(int)*4, 3); - VERIFY_FAILS_END -} - -void testNotEqualMemoryEachEqual2(void) -{ - int p0[] = {1, 8, 987, -2}; - int p1[] = {1, 8, 987, -2, 1, 8, 987, -2, 1, 8, 987, 9}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_EACH_EQUAL_MEMORY(p0, p1, sizeof(int)*4, 3); - VERIFY_FAILS_END -} - -void testNotEqualMemoryEachEqual3(void) -{ - int p0[] = {1, 8, 987, -2}; - int p1[] = {1, 8, 987, -2, 1, 9, 987, -2, 1, 8, 987, -2}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_EACH_EQUAL_MEMORY(p0, p1, sizeof(int)*4, 3); - VERIFY_FAILS_END -} - -void testProtection(void) -{ - volatile int mask = 0; - - if (TEST_PROTECT()) - { - mask |= 1; - TEST_ABORT(); - } - else - { - Unity.CurrentTestFailed = 0; - mask |= 2; - } - - TEST_ASSERT_EQUAL(3, mask); -} - -void testIgnoredAndThenFailInTearDown(void) -{ - SetToOneToFailInTearDown = 1; - TEST_IGNORE(); -} - -/* Tricky series of macros to set USING_OUTPUT_SPY */ -#define USING_SPY_AS(a) EXPAND_AND_USE_2ND(ASSIGN_VALUE(a), 0) -#define ASSIGN_VALUE(a) VAL_##a -#define VAL_putcharSpy 0, 1 -#define EXPAND_AND_USE_2ND(a, b) SECOND_PARAM(a, b, throwaway) -#define SECOND_PARAM(a, b, ...) b -#if USING_SPY_AS(UNITY_OUTPUT_CHAR) - #define USING_OUTPUT_SPY /* true only if UNITY_OUTPUT_CHAR = putcharSpy */ -#endif - -#ifdef USING_OUTPUT_SPY -#include -#define SPY_BUFFER_MAX 40 -static char putcharSpyBuffer[SPY_BUFFER_MAX]; -#endif -static int indexSpyBuffer; -static int putcharSpyEnabled; - -void startPutcharSpy(void) {indexSpyBuffer = 0; putcharSpyEnabled = 1;} - -void endPutcharSpy(void) {putcharSpyEnabled = 0;} - -char* getBufferPutcharSpy(void) -{ -#ifdef USING_OUTPUT_SPY - putcharSpyBuffer[indexSpyBuffer] = '\0'; - return putcharSpyBuffer; -#else - return NULL; -#endif -} - -void putcharSpy(int c) -{ -#ifdef USING_OUTPUT_SPY - if (putcharSpyEnabled) - { - if (indexSpyBuffer < SPY_BUFFER_MAX - 1) - putcharSpyBuffer[indexSpyBuffer++] = (char)c; - } else - putchar((char)c); -#else - (void)c; -#endif -} - -/* This is for counting the calls to the flushSpy */ -static int flushSpyEnabled; -static int flushSpyCalls = 0; - -void startFlushSpy(void) { flushSpyCalls = 0; flushSpyEnabled = 1; } -void endFlushSpy(void) { flushSpyCalls = 0; flushSpyEnabled = 0; } -int getFlushSpyCalls(void) { return flushSpyCalls; } - -void flushSpy(void) -{ - if (flushSpyEnabled){ flushSpyCalls++; } -} - -void testFailureCountIncrementsAndIsReturnedAtEnd(void) -{ -#ifndef USING_OUTPUT_SPY - TEST_IGNORE(); -#else - UNITY_UINT savedFailures = Unity.TestFailures; - Unity.CurrentTestFailed = 1; - startPutcharSpy(); /* Suppress output */ - startFlushSpy(); - TEST_ASSERT_EQUAL(0, getFlushSpyCalls()); - UnityConcludeTest(); - endPutcharSpy(); - TEST_ASSERT_EQUAL(savedFailures + 1, Unity.TestFailures); -#if defined(UNITY_OUTPUT_FLUSH) && defined(UNITY_OUTPUT_FLUSH_HEADER_DECLARATION) - TEST_ASSERT_EQUAL(1, getFlushSpyCalls()); -#else - TEST_ASSERT_EQUAL(0, getFlushSpyCalls()); -#endif - endFlushSpy(); - - startPutcharSpy(); /* Suppress output */ - int failures = UnityEnd(); - Unity.TestFailures--; - endPutcharSpy(); - TEST_ASSERT_EQUAL(savedFailures + 1, failures); -#endif -} - -void testCstringsEscapeSequence(void) -{ -#ifndef USING_OUTPUT_SPY - TEST_IGNORE(); -#else - startPutcharSpy(); - UnityPrint("\x16\x10"); - endPutcharSpy(); - TEST_ASSERT_EQUAL_STRING("\\x16\\x10", getBufferPutcharSpy()); -#endif -} - -void testHexPrintsUpToMaxNumberOfNibbles(void) -{ -#ifndef USING_OUTPUT_SPY - TEST_IGNORE(); -#else - startPutcharSpy(); - UnityPrintNumberHex(0xBEE, 21); - endPutcharSpy(); -#ifdef UNITY_SUPPORT_64 - TEST_ASSERT_EQUAL_INT(16, strlen(getBufferPutcharSpy())); -#else - TEST_ASSERT_EQUAL_INT( 8, strlen(getBufferPutcharSpy())); -#endif -#endif -} - -#define TEST_ASSERT_EQUAL_PRINT_NUMBERS(expected, actual) { \ - startPutcharSpy(); UnityPrintNumber((actual)); endPutcharSpy(); \ - TEST_ASSERT_EQUAL_STRING((expected), getBufferPutcharSpy()); \ - } - -#define TEST_ASSERT_EQUAL_PRINT_UNSIGNED_NUMBERS(expected, actual) { \ - startPutcharSpy(); UnityPrintNumberUnsigned((actual)); endPutcharSpy(); \ - TEST_ASSERT_EQUAL_STRING((expected), getBufferPutcharSpy()); \ - } - -void testPrintNumbers32(void) -{ -#ifndef USING_OUTPUT_SPY - TEST_IGNORE_MESSAGE("Compile with '-D UNITY_OUTPUT_CHAR=putcharSpy' to enable print testing"); -#else - TEST_ASSERT_EQUAL_PRINT_NUMBERS("0", 0); - TEST_ASSERT_EQUAL_PRINT_NUMBERS("1", 1); - TEST_ASSERT_EQUAL_PRINT_NUMBERS("-1", -1); - TEST_ASSERT_EQUAL_PRINT_NUMBERS("2000000000", 2000000000); - TEST_ASSERT_EQUAL_PRINT_NUMBERS("-2147483648", (UNITY_INT32)0x80000000); - TEST_ASSERT_EQUAL_PRINT_NUMBERS("-1", (UNITY_INT32)0xFFFFFFFF); -#endif -} - -void testPrintNumbersUnsigned32(void) -{ -#ifndef USING_OUTPUT_SPY - TEST_IGNORE(); -#else - TEST_ASSERT_EQUAL_PRINT_UNSIGNED_NUMBERS("0", 0); - TEST_ASSERT_EQUAL_PRINT_UNSIGNED_NUMBERS("1", 1); - TEST_ASSERT_EQUAL_PRINT_UNSIGNED_NUMBERS("1500000000", 1500000000); - TEST_ASSERT_EQUAL_PRINT_UNSIGNED_NUMBERS("2147483648", (UNITY_UINT32)0x80000000); - TEST_ASSERT_EQUAL_PRINT_UNSIGNED_NUMBERS("4294967295", (UNITY_UINT32)0xFFFFFFFF); -#endif -} - - -/* ===================== THESE TEST WILL RUN IF YOUR CONFIG INCLUDES 64 BIT SUPPORT ================== */ - -void testPrintNumbersInt64(void) -{ -#ifndef UNITY_SUPPORT_64 - TEST_IGNORE(); -#else - #ifndef USING_OUTPUT_SPY - TEST_IGNORE(); - #else - TEST_ASSERT_EQUAL_PRINT_NUMBERS("0", 0); - TEST_ASSERT_EQUAL_PRINT_NUMBERS("10000000000", 10000000000); - TEST_ASSERT_EQUAL_PRINT_NUMBERS("-9223372036854775808", (UNITY_INT)0x8000000000000000); - TEST_ASSERT_EQUAL_PRINT_NUMBERS("-1", (UNITY_INT)0xFFFFFFFFFFFFFFFF); - #endif -#endif -} - -void testPrintNumbersUInt64(void) -{ -#ifndef UNITY_SUPPORT_64 - TEST_IGNORE(); -#else - #ifndef USING_OUTPUT_SPY - TEST_IGNORE(); - #else - TEST_ASSERT_EQUAL_PRINT_UNSIGNED_NUMBERS("0", 0); - TEST_ASSERT_EQUAL_PRINT_UNSIGNED_NUMBERS("70000000000", 70000000000); - TEST_ASSERT_EQUAL_PRINT_UNSIGNED_NUMBERS("9223372036854775808", (UNITY_UINT)0x8000000000000000); - TEST_ASSERT_EQUAL_PRINT_UNSIGNED_NUMBERS("18446744073709551615", (UNITY_UINT)0xFFFFFFFFFFFFFFFF); - #endif -#endif -} - -void testEqualHex64s(void) -{ -#ifndef UNITY_SUPPORT_64 - TEST_IGNORE(); -#else - UNITY_UINT64 v0, v1; - UNITY_UINT64 *p0, *p1; - - v0 = 0x9876543201234567; - v1 = 0x9876543201234567; - p0 = &v0; - p1 = &v1; - - TEST_ASSERT_EQUAL_HEX64(0x9876543201234567, 0x9876543201234567); - TEST_ASSERT_EQUAL_HEX64(v0, v1); - TEST_ASSERT_EQUAL_HEX64(0x9876543201234567, v1); - TEST_ASSERT_EQUAL_HEX64(v0, 0x9876543201234567); - TEST_ASSERT_EQUAL_HEX64(*p0, v1); - TEST_ASSERT_EQUAL_HEX64(*p0, *p1); - TEST_ASSERT_EQUAL_HEX64(*p0, 0x9876543201234567); -#endif -} - -void testEqualUint64s(void) -{ -#ifndef UNITY_SUPPORT_64 - TEST_IGNORE(); -#else - UNITY_UINT64 v0, v1; - UNITY_UINT64 *p0, *p1; - - v0 = 0x9876543201234567; - v1 = 0x9876543201234567; - p0 = &v0; - p1 = &v1; - - TEST_ASSERT_EQUAL_UINT64(0x9876543201234567, 0x9876543201234567); - TEST_ASSERT_EQUAL_UINT64(v0, v1); - TEST_ASSERT_EQUAL_UINT64(0x9876543201234567, v1); - TEST_ASSERT_EQUAL_UINT64(v0, 0x9876543201234567); - TEST_ASSERT_EQUAL_UINT64(*p0, v1); - TEST_ASSERT_EQUAL_UINT64(*p0, *p1); - TEST_ASSERT_EQUAL_UINT64(*p0, 0x9876543201234567); -#endif -} - -void testEqualInt64s(void) -{ -#ifndef UNITY_SUPPORT_64 - TEST_IGNORE(); -#else - UNITY_INT64 v0, v1; - UNITY_INT64 *p0, *p1; - - v0 = (UNITY_INT64)0x9876543201234567; - v1 = (UNITY_INT64)0x9876543201234567; - p0 = &v0; - p1 = &v1; - - TEST_ASSERT_EQUAL_INT64(0x9876543201234567, 0x9876543201234567); - TEST_ASSERT_EQUAL_INT64(v0, v1); - TEST_ASSERT_EQUAL_INT64(0x9876543201234567, v1); - TEST_ASSERT_EQUAL_INT64(v0, 0x9876543201234567); - TEST_ASSERT_EQUAL_INT64(*p0, v1); - TEST_ASSERT_EQUAL_INT64(*p0, *p1); - TEST_ASSERT_EQUAL_INT64(*p0, 0x9876543201234567); -#endif -} - - -void testNotEqualHex64s(void) -{ -#ifndef UNITY_SUPPORT_64 - TEST_IGNORE(); -#else - UNITY_UINT64 v0, v1; - - v0 = 9000000000; - v1 = 9100000000; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_EQUAL_HEX64(v0, v1); - VERIFY_FAILS_END -#endif -} - -void testNotEqualUint64s(void) -{ -#ifndef UNITY_SUPPORT_64 - TEST_IGNORE(); -#else - UNITY_UINT64 v0, v1; - - v0 = 9000000000; - v1 = 9100000000; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_EQUAL_UINT64(v0, v1); - VERIFY_FAILS_END -#endif -} - -void testNotEqualInt64s(void) -{ -#ifndef UNITY_SUPPORT_64 - TEST_IGNORE(); -#else - UNITY_INT64 v0, v1; - - v0 = -9000000000; - v1 = 9100000000; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_EQUAL_INT64(v0, v1); - VERIFY_FAILS_END -#endif -} - -void testNotEqualHex64sIfSigned(void) -{ -#ifndef UNITY_SUPPORT_64 - TEST_IGNORE(); -#else - UNITY_INT64 v0, v1; - - v0 = -9000000000; - v1 = 9000000000; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_EQUAL_HEX64(v0, v1); - VERIFY_FAILS_END -#endif -} - -void testHEX64sWithinDelta(void) -{ -#ifndef UNITY_SUPPORT_64 - TEST_IGNORE(); -#else - TEST_ASSERT_HEX64_WITHIN(1, 0x7FFFFFFFFFFFFFFF,0x7FFFFFFFFFFFFFFE); - TEST_ASSERT_HEX64_WITHIN(5, 5000, 4996); - TEST_ASSERT_HEX64_WITHIN(5, 5000, 5005); -#endif -} - -void testHEX64sNotWithinDelta(void) -{ -#ifndef UNITY_SUPPORT_64 - TEST_IGNORE(); -#else - EXPECT_ABORT_BEGIN - TEST_ASSERT_HEX64_WITHIN(1, 0x7FFFFFFFFFFFFFFF, 0x7FFFFFFFFFFFFFFC); - VERIFY_FAILS_END -#endif -} - -void testHEX64sNotWithinDeltaEvenThoughASignedIntWouldPass(void) -{ -#ifndef UNITY_SUPPORT_64 - TEST_IGNORE(); -#else - EXPECT_ABORT_BEGIN - TEST_ASSERT_HEX64_WITHIN(5, 1, -1); - VERIFY_FAILS_END -#endif -} - -void testUINT64sWithinDelta(void) -{ -#ifndef UNITY_SUPPORT_64 - TEST_IGNORE(); -#else - TEST_ASSERT_UINT64_WITHIN(1, 0x7FFFFFFFFFFFFFFF,0x7FFFFFFFFFFFFFFE); - TEST_ASSERT_UINT64_WITHIN(5, 5000, 4996); - TEST_ASSERT_UINT64_WITHIN(5, 5000, 5005); -#endif -} - -void testUINT64sNotWithinDelta(void) -{ -#ifndef UNITY_SUPPORT_64 - TEST_IGNORE(); -#else - EXPECT_ABORT_BEGIN - TEST_ASSERT_UINT64_WITHIN(1, 0x7FFFFFFFFFFFFFFF, 0x7FFFFFFFFFFFFFFC); - VERIFY_FAILS_END -#endif -} - -void testUINT64sNotWithinDeltaEvenThoughASignedIntWouldPass(void) -{ -#ifndef UNITY_SUPPORT_64 - TEST_IGNORE(); -#else - EXPECT_ABORT_BEGIN - TEST_ASSERT_UINT64_WITHIN(5, 1, -1); - VERIFY_FAILS_END -#endif -} - -void testINT64sWithinDelta(void) -{ -#ifndef UNITY_SUPPORT_64 - TEST_IGNORE(); -#else - TEST_ASSERT_INT64_WITHIN(1, 0x7FFFFFFFFFFFFFFF,0x7FFFFFFFFFFFFFFE); - TEST_ASSERT_INT64_WITHIN(5, 5000, 4996); - TEST_ASSERT_INT64_WITHIN(5, 5000, 5005); -#endif -} - -void testINT64sNotWithinDelta(void) -{ -#ifndef UNITY_SUPPORT_64 - TEST_IGNORE(); -#else - EXPECT_ABORT_BEGIN - TEST_ASSERT_INT64_WITHIN(1, 0x7FFFFFFFFFFFFFFF, 0x7FFFFFFFFFFFFFFC); - VERIFY_FAILS_END -#endif -} - -void testINT64sNotWithinDeltaAndDifferenceOverflows(void) -{ -#ifndef UNITY_SUPPORT_64 - TEST_IGNORE(); -#else - EXPECT_ABORT_BEGIN - TEST_ASSERT_INT64_WITHIN(1, 0x8000000000000000, 0x7FFFFFFFFFFFFFFF); - VERIFY_FAILS_END -#endif -} - -void testEqualHEX64Arrays(void) -{ -#ifndef UNITY_SUPPORT_64 - TEST_IGNORE(); -#else - UNITY_UINT64 p0[] = {1, 8, 987, 65132u}; - UNITY_UINT64 p1[] = {1, 8, 987, 65132u}; - UNITY_UINT64 p2[] = {1, 8, 987, 2}; - UNITY_UINT64 p3[] = {1, 500, 600, 700}; - - TEST_ASSERT_EQUAL_HEX64_ARRAY(p0, p0, 1); - TEST_ASSERT_EQUAL_HEX64_ARRAY(p0, p0, 4); - TEST_ASSERT_EQUAL_HEX64_ARRAY(p0, p1, 4); - TEST_ASSERT_EQUAL_HEX64_ARRAY(p0, p2, 3); - TEST_ASSERT_EQUAL_HEX64_ARRAY(p0, p3, 1); -#endif -} - -void testEqualUint64Arrays(void) -{ -#ifndef UNITY_SUPPORT_64 - TEST_IGNORE(); -#else - UNITY_UINT64 p0[] = {1, 8, 987, 65132u}; - UNITY_UINT64 p1[] = {1, 8, 987, 65132u}; - UNITY_UINT64 p2[] = {1, 8, 987, 2}; - UNITY_UINT64 p3[] = {1, 500, 600, 700}; - - TEST_ASSERT_EQUAL_UINT64_ARRAY(p0, p0, 1); - TEST_ASSERT_EQUAL_UINT64_ARRAY(p0, p0, 4); - TEST_ASSERT_EQUAL_UINT64_ARRAY(p0, p1, 4); - TEST_ASSERT_EQUAL_UINT64_ARRAY(p0, p2, 3); - TEST_ASSERT_EQUAL_UINT64_ARRAY(p0, p3, 1); -#endif -} - -void testEqualInt64Arrays(void) -{ -#ifndef UNITY_SUPPORT_64 - TEST_IGNORE(); -#else - UNITY_INT64 p0[] = {1, 8, 987, -65132}; - UNITY_INT64 p1[] = {1, 8, 987, -65132}; - UNITY_INT64 p2[] = {1, 8, 987, -2}; - UNITY_INT64 p3[] = {1, 500, 600, 700}; - - TEST_ASSERT_EQUAL_INT64_ARRAY(p0, p0, 1); - TEST_ASSERT_EQUAL_INT64_ARRAY(p0, p0, 4); - TEST_ASSERT_EQUAL_INT64_ARRAY(p0, p1, 4); - TEST_ASSERT_EQUAL_INT64_ARRAY(p0, p2, 3); - TEST_ASSERT_EQUAL_INT64_ARRAY(p0, p3, 1); -#endif -} - - -void testNotEqualHEX64Arrays1(void) -{ -#ifndef UNITY_SUPPORT_64 - TEST_IGNORE(); -#else - UNITY_UINT64 p0[] = {1, 8, 987, 65132u}; - UNITY_UINT64 p1[] = {1, 8, 987, 65131u}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_EQUAL_HEX64_ARRAY(p0, p1, 4); - VERIFY_FAILS_END -#endif -} - -void testNotEqualHEX64Arrays2(void) -{ -#ifndef UNITY_SUPPORT_64 - TEST_IGNORE(); -#else - UNITY_UINT64 p0[] = {1, 8, 987, 65132u}; - UNITY_UINT64 p1[] = {2, 8, 987, 65132u}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_EQUAL_HEX64_ARRAY(p0, p1, 4); - VERIFY_FAILS_END -#endif -} - -void testNotEqualUint64Arrays(void) -{ -#ifndef UNITY_SUPPORT_64 - TEST_IGNORE(); -#else - UNITY_UINT64 p0[] = {1, 8, 987, 65132u}; - UNITY_UINT64 p1[] = {1, 8, 987, 65131u}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_EQUAL_UINT64_ARRAY(p0, p1, 4); - VERIFY_FAILS_END -#endif -} - -void testNotEqualInt64Arrays(void) -{ -#ifndef UNITY_SUPPORT_64 - TEST_IGNORE(); -#else - UNITY_INT64 p0[] = {1, 8, 987, -65132}; - UNITY_INT64 p1[] = {1, 8, 987, -65131}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_EQUAL_INT64_ARRAY(p0, p1, 4); - VERIFY_FAILS_END -#endif -} - -/* ===================== THESE TEST WILL RUN IF YOUR CONFIG INCLUDES FLOAT SUPPORT ================== */ - -void testFloatsWithinDelta(void) -{ -#ifdef UNITY_EXCLUDE_FLOAT - TEST_IGNORE(); -#else - TEST_ASSERT_FLOAT_WITHIN(0.00003f, 187245.03485f, 187245.03488f); - TEST_ASSERT_FLOAT_WITHIN(1.0f, 187245.0f, 187246.0f); - TEST_ASSERT_FLOAT_WITHIN(0.05f, 9273.2549f, 9273.2049f); - TEST_ASSERT_FLOAT_WITHIN(0.007f, -726.93724f, -726.94424f); -#endif -} - -void testFloatsNotWithinDelta(void) -{ -#ifdef UNITY_EXCLUDE_FLOAT - TEST_IGNORE(); -#else - EXPECT_ABORT_BEGIN - TEST_ASSERT_FLOAT_WITHIN(0.05f, 9273.2649f, 9273.2049f); - VERIFY_FAILS_END -#endif -} - -void testFloatsEqual(void) -{ -#ifdef UNITY_EXCLUDE_FLOAT - TEST_IGNORE(); -#else - TEST_ASSERT_EQUAL_FLOAT(187245.0f, 187246.0f); - TEST_ASSERT_EQUAL_FLOAT(18724.5f, 18724.6f); - TEST_ASSERT_EQUAL_FLOAT(9273.2549f, 9273.2599f); - TEST_ASSERT_EQUAL_FLOAT(-726.93724f, -726.9374f); -#endif -} - -void testFloatsNotEqual(void) -{ -#ifdef UNITY_EXCLUDE_FLOAT - TEST_IGNORE(); -#else - EXPECT_ABORT_BEGIN - TEST_ASSERT_EQUAL_FLOAT(9273.9649f, 9273.0049f); - VERIFY_FAILS_END -#endif -} - -void testFloatsNotEqualNegative1(void) -{ -#ifdef UNITY_EXCLUDE_FLOAT - TEST_IGNORE(); -#else - EXPECT_ABORT_BEGIN - TEST_ASSERT_EQUAL_FLOAT(-9273.9649f, -9273.0049f); - VERIFY_FAILS_END -#endif -} - -void testFloatsNotEqualNegative2(void) -{ -#ifdef UNITY_EXCLUDE_FLOAT - TEST_IGNORE(); -#else - EXPECT_ABORT_BEGIN - TEST_ASSERT_EQUAL_FLOAT(-9273.0049f, -9273.9649f); - VERIFY_FAILS_END -#endif -} - -void testFloatsNotEqualActualNaN(void) -{ -#ifdef UNITY_EXCLUDE_FLOAT - TEST_IGNORE(); -#else - EXPECT_ABORT_BEGIN - TEST_ASSERT_EQUAL_FLOAT(85.963f, 0.0f / f_zero); - VERIFY_FAILS_END -#endif -} - -void testFloatsNotEqualExpectedNaN(void) -{ -#ifdef UNITY_EXCLUDE_FLOAT - TEST_IGNORE(); -#else - EXPECT_ABORT_BEGIN - TEST_ASSERT_EQUAL_FLOAT(0.0f / f_zero, 85.963f); - VERIFY_FAILS_END -#endif -} - -void testFloatsEqualBothNaN(void) -{ -#ifdef UNITY_EXCLUDE_FLOAT - TEST_IGNORE(); -#else - TEST_ASSERT_EQUAL_FLOAT(0.0f / f_zero, 0.0f / f_zero); -#endif -} - -void testFloatsNotEqualInfNaN(void) -{ -#ifdef UNITY_EXCLUDE_FLOAT - TEST_IGNORE(); -#else - EXPECT_ABORT_BEGIN - TEST_ASSERT_EQUAL_FLOAT(1.0f / f_zero, 0.0f / f_zero); - VERIFY_FAILS_END -#endif -} - -void testFloatsNotEqualNaNInf(void) -{ -#ifdef UNITY_EXCLUDE_FLOAT - TEST_IGNORE(); -#else - EXPECT_ABORT_BEGIN - TEST_ASSERT_EQUAL_FLOAT(0.0f / f_zero, 1.0f / f_zero); - VERIFY_FAILS_END -#endif -} - -void testFloatsNotEqualActualInf(void) -{ -#ifdef UNITY_EXCLUDE_FLOAT - TEST_IGNORE(); -#else - EXPECT_ABORT_BEGIN - TEST_ASSERT_EQUAL_FLOAT(321.642f, 1.0f / f_zero); - VERIFY_FAILS_END -#endif -} - -void testFloatsNotEqualExpectedInf(void) -{ -#ifdef UNITY_EXCLUDE_FLOAT - TEST_IGNORE(); -#else - EXPECT_ABORT_BEGIN - TEST_ASSERT_EQUAL_FLOAT(1.0f / f_zero, 321.642f); - VERIFY_FAILS_END -#endif -} - -void testFloatsEqualBothInf(void) -{ -#ifdef UNITY_EXCLUDE_FLOAT - TEST_IGNORE(); -#else - TEST_ASSERT_EQUAL_FLOAT(1.0f / f_zero, 1.0f / f_zero); -#endif -} - -void testFloatsNotEqualPlusMinusInf(void) -{ -#ifdef UNITY_EXCLUDE_FLOAT - TEST_IGNORE(); -#else - EXPECT_ABORT_BEGIN - TEST_ASSERT_EQUAL_FLOAT(1.0f / f_zero, -1.0f / f_zero); - VERIFY_FAILS_END -#endif -} - -void testFloatIsPosInf1(void) -{ -#ifdef UNITY_EXCLUDE_FLOAT - TEST_IGNORE(); -#else - TEST_ASSERT_FLOAT_IS_INF(2.0f / f_zero); -#endif -} - -void testFloatIsPosInf2(void) -{ -#ifdef UNITY_EXCLUDE_FLOAT - TEST_IGNORE(); -#else - EXPECT_ABORT_BEGIN - TEST_ASSERT_FLOAT_IS_NOT_INF(2.0f / f_zero); - VERIFY_FAILS_END -#endif -} - -void testFloatIsNegInf1(void) -{ -#ifdef UNITY_EXCLUDE_FLOAT - TEST_IGNORE(); -#else - TEST_ASSERT_FLOAT_IS_NEG_INF(-3.0f / f_zero); -#endif -} - -void testFloatIsNegInf2(void) -{ -#ifdef UNITY_EXCLUDE_FLOAT - TEST_IGNORE(); -#else - EXPECT_ABORT_BEGIN - TEST_ASSERT_FLOAT_IS_NOT_NEG_INF(-3.0f / f_zero); - VERIFY_FAILS_END -#endif -} - -void testFloatIsNotPosInf1(void) -{ -#ifdef UNITY_EXCLUDE_FLOAT - TEST_IGNORE(); -#else - EXPECT_ABORT_BEGIN - TEST_ASSERT_FLOAT_IS_INF(2.0f); - VERIFY_FAILS_END -#endif -} - -void testFloatIsNotPosInf2(void) -{ -#ifdef UNITY_EXCLUDE_FLOAT - TEST_IGNORE(); -#else - TEST_ASSERT_FLOAT_IS_NOT_INF(2.0f); -#endif -} - -void testFloatIsNotNegInf(void) -{ -#ifdef UNITY_EXCLUDE_FLOAT - TEST_IGNORE(); -#else - EXPECT_ABORT_BEGIN - TEST_ASSERT_FLOAT_IS_NEG_INF(-999.876f); - VERIFY_FAILS_END -#endif -} - -void testFloatIsNan1(void) -{ -#ifdef UNITY_EXCLUDE_FLOAT - TEST_IGNORE(); -#else - TEST_ASSERT_FLOAT_IS_NAN(0.0f / f_zero); -#endif -} - -void testFloatIsNan2(void) -{ -#ifdef UNITY_EXCLUDE_FLOAT - TEST_IGNORE(); -#else - EXPECT_ABORT_BEGIN - TEST_ASSERT_FLOAT_IS_NOT_NAN(0.0f / f_zero); - VERIFY_FAILS_END -#endif -} - -void testFloatIsNotNan1(void) -{ -#ifdef UNITY_EXCLUDE_FLOAT - TEST_IGNORE(); -#else - EXPECT_ABORT_BEGIN - TEST_ASSERT_FLOAT_IS_NAN(234.9f); - VERIFY_FAILS_END -#endif -} - -void testFloatIsNotNan2(void) -{ -#ifdef UNITY_EXCLUDE_FLOAT - TEST_IGNORE(); -#else - TEST_ASSERT_FLOAT_IS_NOT_NAN(234.9f); -#endif -} - -void testFloatInfIsNotNan(void) -{ -#ifdef UNITY_EXCLUDE_FLOAT - TEST_IGNORE(); -#else - EXPECT_ABORT_BEGIN - TEST_ASSERT_FLOAT_IS_NAN(1.0f / f_zero); - VERIFY_FAILS_END -#endif -} - -void testFloatNanIsNotInf(void) -{ -#ifdef UNITY_EXCLUDE_FLOAT - TEST_IGNORE(); -#else - EXPECT_ABORT_BEGIN - TEST_ASSERT_FLOAT_IS_INF(0.0f / f_zero); - VERIFY_FAILS_END -#endif -} - -void testFloatIsDeterminate1(void) -{ -#ifdef UNITY_EXCLUDE_FLOAT - TEST_IGNORE(); -#else - TEST_ASSERT_FLOAT_IS_DETERMINATE(0.0f); - TEST_ASSERT_FLOAT_IS_DETERMINATE(123.3f); - TEST_ASSERT_FLOAT_IS_DETERMINATE(-88.3f); -#endif -} - -void testFloatIsDeterminate2(void) -{ -#ifdef UNITY_EXCLUDE_FLOAT - TEST_IGNORE(); -#else - EXPECT_ABORT_BEGIN - TEST_ASSERT_FLOAT_IS_NOT_DETERMINATE(-88.3f); - VERIFY_FAILS_END -#endif -} - -void testFloatIsNotDeterminate1(void) -{ -#ifdef UNITY_EXCLUDE_FLOAT - TEST_IGNORE(); -#else - TEST_ASSERT_FLOAT_IS_NOT_DETERMINATE(1.0f / f_zero); - TEST_ASSERT_FLOAT_IS_NOT_DETERMINATE(-1.0f / f_zero); - TEST_ASSERT_FLOAT_IS_NOT_DETERMINATE(0.0f / f_zero); -#endif -} - -void testFloatIsNotDeterminate2(void) -{ -#ifdef UNITY_EXCLUDE_FLOAT - TEST_IGNORE(); -#else - EXPECT_ABORT_BEGIN - TEST_ASSERT_FLOAT_IS_DETERMINATE(-1.0f / f_zero); - VERIFY_FAILS_END -#endif -} - -void testFloatTraitFailsOnInvalidTrait(void) -{ -#ifdef UNITY_EXCLUDE_FLOAT - TEST_IGNORE(); -#else - EXPECT_ABORT_BEGIN - UnityAssertFloatSpecial(1.0f, NULL, __LINE__, UNITY_FLOAT_INVALID_TRAIT); - VERIFY_FAILS_END -#endif -} - - -void testEqualFloatArrays(void) -{ -#ifdef UNITY_EXCLUDE_FLOAT - TEST_IGNORE(); -#else - float p0[] = {1.0f, -8.0f, 25.4f, -0.123f}; - float p1[] = {1.0f, -8.0f, 25.4f, -0.123f}; - float p2[] = {1.0f, -8.0f, 25.4f, -0.2f}; - float p3[] = {1.0f, -23.0f, 25.0f, -0.26f}; - - TEST_ASSERT_EQUAL_FLOAT_ARRAY(p0, p0, 1); - TEST_ASSERT_EQUAL_FLOAT_ARRAY(p0, p0, 4); - TEST_ASSERT_EQUAL_FLOAT_ARRAY(p0, p1, 4); - TEST_ASSERT_EQUAL_FLOAT_ARRAY(p0, p2, 3); - TEST_ASSERT_EQUAL_FLOAT_ARRAY(p0, p3, 1); - TEST_ASSERT_EQUAL_FLOAT_ARRAY(NULL, NULL, 1); -#endif -} - -void testNotEqualFloatArraysExpectedNull(void) -{ -#ifdef UNITY_EXCLUDE_FLOAT - TEST_IGNORE(); -#else - float* p0 = NULL; - float p1[] = {1.0f, 8.0f, 25.4f, 0.252f}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_EQUAL_FLOAT_ARRAY(p0, p1, 4); - VERIFY_FAILS_END -#endif -} - -void testNotEqualFloatArraysActualNull(void) -{ -#ifdef UNITY_EXCLUDE_FLOAT - TEST_IGNORE(); -#else - float p0[] = {1.0f, 8.0f, 25.4f, 0.253f}; - float* p1 = NULL; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_EQUAL_FLOAT_ARRAY(p0, p1, 4); - VERIFY_FAILS_END -#endif -} - -void testNotEqualFloatArrays1(void) -{ -#ifdef UNITY_EXCLUDE_FLOAT - TEST_IGNORE(); -#else - float p0[] = {1.0f, 8.0f, 25.4f, 0.253f}; - float p1[] = {1.0f, 8.0f, 25.4f, 0.252f}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_EQUAL_FLOAT_ARRAY(p0, p1, 4); - VERIFY_FAILS_END -#endif -} - -void testNotEqualFloatArrays2(void) -{ -#ifdef UNITY_EXCLUDE_FLOAT - TEST_IGNORE(); -#else - float p0[] = {1.0f, 8.0f, 25.4f, 0.253f}; - float p1[] = {2.0f, 8.0f, 25.4f, 0.253f}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_EQUAL_FLOAT_ARRAY(p0, p1, 4); - VERIFY_FAILS_END -#endif -} - -void testNotEqualFloatArrays3(void) -{ -#ifdef UNITY_EXCLUDE_FLOAT - TEST_IGNORE(); -#else - float p0[] = {1.0f, 8.0f, 25.4f, 0.253f}; - float p1[] = {1.0f, 8.0f, 25.5f, 0.253f}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_EQUAL_FLOAT_ARRAY(p0, p1, 4); - VERIFY_FAILS_END -#endif -} - -void testNotEqualFloatArraysNegative1(void) -{ -#ifdef UNITY_EXCLUDE_FLOAT - TEST_IGNORE(); -#else - float p0[] = {-1.0f, -8.0f, -25.4f, -0.253f}; - float p1[] = {-1.0f, -8.0f, -25.4f, -0.252f}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_EQUAL_FLOAT_ARRAY(p0, p1, 4); - VERIFY_FAILS_END -#endif -} - -void testNotEqualFloatArraysNegative2(void) -{ -#ifdef UNITY_EXCLUDE_FLOAT - TEST_IGNORE(); -#else - float p0[] = {-1.0f, -8.0f, -25.4f, -0.253f}; - float p1[] = {-2.0f, -8.0f, -25.4f, -0.253f}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_EQUAL_FLOAT_ARRAY(p0, p1, 4); - VERIFY_FAILS_END -#endif -} - -void testNotEqualFloatArraysNegative3(void) -{ -#ifdef UNITY_EXCLUDE_FLOAT - TEST_IGNORE(); -#else - float p0[] = {-1.0f, -8.0f, -25.4f, -0.253f}; - float p1[] = {-1.0f, -8.0f, -25.5f, -0.253f}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_EQUAL_FLOAT_ARRAY(p0, p1, 4); - VERIFY_FAILS_END -#endif -} - -void testEqualFloatArraysNaN(void) -{ -#ifdef UNITY_EXCLUDE_FLOAT - TEST_IGNORE(); -#else - float p0[] = {1.0f, 0.0f / f_zero, 25.4f, 0.253f}; - float p1[] = {1.0f, 0.0f / f_zero, 25.4f, 0.253f}; - - TEST_ASSERT_EQUAL_FLOAT_ARRAY(p0, p1, 4); -#endif -} - -void testEqualFloatArraysInf(void) -{ -#ifdef UNITY_EXCLUDE_FLOAT - TEST_IGNORE(); -#else - float p0[] = {1.0f, 1.0f / f_zero, 25.4f, 0.253f}; - float p1[] = {1.0f, 1.0f / f_zero, 25.4f, 0.253f}; - - TEST_ASSERT_EQUAL_FLOAT_ARRAY(p0, p1, 4); -#endif -} - -void testNotEqualFloatArraysLengthZero(void) -{ -#ifdef UNITY_EXCLUDE_FLOAT - TEST_IGNORE(); -#else - float p0[1] = {0.0f}; - float p1[1] = {0.0f}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_EQUAL_FLOAT_ARRAY(p0, p1, 0); - VERIFY_FAILS_END -#endif -} - -void testEqualFloatEachEqual(void) -{ -#ifdef UNITY_EXCLUDE_FLOAT - TEST_IGNORE(); -#else - float p0[] = {1.0f, 1.0f, 1.0f, 1.0f}; - float p1[] = {-0.123f, -0.123f, -0.123f, -0.123f}; - float p2[] = {25.4f, 25.4f, 25.4f, -0.2f}; - float p3[] = {1.0f, -23.0f, 25.0f, -0.26f}; - - TEST_ASSERT_EACH_EQUAL_FLOAT(1.0f, p0, 1); - TEST_ASSERT_EACH_EQUAL_FLOAT(1.0f, p0, 4); - TEST_ASSERT_EACH_EQUAL_FLOAT(-0.123f, p1, 4); - TEST_ASSERT_EACH_EQUAL_FLOAT(25.4f, p2, 3); - TEST_ASSERT_EACH_EQUAL_FLOAT(1.0f, p3, 1); -#endif -} - -void testNotEqualFloatEachEqualActualNull(void) -{ -#ifdef UNITY_EXCLUDE_FLOAT - TEST_IGNORE(); -#else - float* p0 = NULL; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_EACH_EQUAL_FLOAT(5, p0, 4); - VERIFY_FAILS_END -#endif -} - -void testNotEqualFloatEachEqual1(void) -{ -#ifdef UNITY_EXCLUDE_FLOAT - TEST_IGNORE(); -#else - float p0[] = {0.253f, 8.0f, 0.253f, 0.253f}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_EACH_EQUAL_FLOAT(0.253f, p0, 4); - VERIFY_FAILS_END -#endif -} - -void testNotEqualFloatEachEqual2(void) -{ -#ifdef UNITY_EXCLUDE_FLOAT - TEST_IGNORE(); -#else - float p0[] = {8.0f, 8.0f, 8.0f, 0.253f}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_EACH_EQUAL_FLOAT(8.0f, p0, 4); - VERIFY_FAILS_END -#endif -} - -void testNotEqualFloatEachEqual3(void) -{ -#ifdef UNITY_EXCLUDE_FLOAT - TEST_IGNORE(); -#else - float p0[] = {1.0f, 1.0f, 1.0f, 0.253f}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_EACH_EQUAL_FLOAT(1.0f, p0, 4); - VERIFY_FAILS_END -#endif -} - -void testNotEqualFloatEachEqualNegative1(void) -{ -#ifdef UNITY_EXCLUDE_FLOAT - TEST_IGNORE(); -#else - float p0[] = {-1.0f, -0.253f, -0.253f, -0.253f}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_EACH_EQUAL_FLOAT(-0.253f, p0, 4); - VERIFY_FAILS_END -#endif -} - -void testNotEqualFloatEachEqualNegative2(void) -{ -#ifdef UNITY_EXCLUDE_FLOAT - TEST_IGNORE(); -#else - float p0[] = {-25.4f, -8.0f, -25.4f, -25.4f}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_EACH_EQUAL_FLOAT(-25.4f, p0, 4); - VERIFY_FAILS_END -#endif -} - -void testNotEqualFloatEachEqualNegative3(void) -{ -#ifdef UNITY_EXCLUDE_FLOAT - TEST_IGNORE(); -#else - float p0[] = {-8.0f, -8.0f, -8.0f, -0.253f}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_EACH_EQUAL_FLOAT(-8.0f, p0, 4); - VERIFY_FAILS_END -#endif -} - -void testEqualFloatEachEqualNaN(void) -{ -#ifdef UNITY_EXCLUDE_FLOAT - TEST_IGNORE(); -#else - float p0[] = {0.0f / f_zero, 0.0f / f_zero, 0.0f / f_zero, 0.0f / f_zero}; - - TEST_ASSERT_EACH_EQUAL_FLOAT(0.0f / f_zero, p0, 4); -#endif -} - -void testEqualFloatEachEqualInf(void) -{ -#ifdef UNITY_EXCLUDE_FLOAT - TEST_IGNORE(); -#else - float p0[] = {1.0f / f_zero, 1.0f / f_zero, 25.4f, 0.253f}; - - TEST_ASSERT_EACH_EQUAL_FLOAT(1.0f / f_zero, p0, 2); -#endif -} - -void testNotEqualFloatEachEqualLengthZero(void) -{ -#ifdef UNITY_EXCLUDE_FLOAT - TEST_IGNORE(); -#else - float p0[1] = {0.0f}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_EACH_EQUAL_FLOAT(0.0f, p0, 0); - VERIFY_FAILS_END -#endif -} - -#define TEST_ASSERT_EQUAL_PRINT_FLOATING(expected, actual) { \ - startPutcharSpy(); UnityPrintFloat((actual)); endPutcharSpy(); \ - TEST_ASSERT_EQUAL_STRING((expected), getBufferPutcharSpy()); \ - } - -void testFloatPrinting(void) -{ -#if defined(UNITY_EXCLUDE_FLOAT_PRINT) || defined(UNITY_INCLUDE_DOUBLE) || !defined(USING_OUTPUT_SPY) - TEST_IGNORE(); -#else - TEST_ASSERT_EQUAL_PRINT_FLOATING("0", 0.0f); - TEST_ASSERT_EQUAL_PRINT_FLOATING("4.99e-07", 0.000000499f); - TEST_ASSERT_EQUAL_PRINT_FLOATING("0.1004695", 0.100469499f); - TEST_ASSERT_EQUAL_PRINT_FLOATING("2", 1.9999995f); /*Rounding to int place*/ - TEST_ASSERT_EQUAL_PRINT_FLOATING("1", 1.0f); - TEST_ASSERT_EQUAL_PRINT_FLOATING("1.25", 1.25f); - TEST_ASSERT_EQUAL_PRINT_FLOATING("7.999999", 7.999999f); /*Not rounding*/ - TEST_ASSERT_EQUAL_PRINT_FLOATING("16.00002", 16.00002f); - TEST_ASSERT_EQUAL_PRINT_FLOATING("16.00004", 16.00004f); - TEST_ASSERT_EQUAL_PRINT_FLOATING("16.00006", 16.00006f); - TEST_ASSERT_EQUAL_PRINT_FLOATING("9999999", 9999999.0f); /*Last full print integer*/ - - TEST_ASSERT_EQUAL_PRINT_FLOATING("-0", -0.0f); - TEST_ASSERT_EQUAL_PRINT_FLOATING("-4.99e-07", -0.000000499f); - TEST_ASSERT_EQUAL_PRINT_FLOATING("-0.1004695", -0.100469499f); - TEST_ASSERT_EQUAL_PRINT_FLOATING("-2", -1.9999995f); /*Rounding to int place*/ - TEST_ASSERT_EQUAL_PRINT_FLOATING("-1", -1.0f); - TEST_ASSERT_EQUAL_PRINT_FLOATING("-1.25", -1.25f); - TEST_ASSERT_EQUAL_PRINT_FLOATING("-7.999999", -7.999999f); /*Not rounding*/ - TEST_ASSERT_EQUAL_PRINT_FLOATING("-16.00002", -16.00002f); - TEST_ASSERT_EQUAL_PRINT_FLOATING("-16.00004", -16.00004f); - TEST_ASSERT_EQUAL_PRINT_FLOATING("-16.00006", -16.00006f); - TEST_ASSERT_EQUAL_PRINT_FLOATING("-9999999", -9999999.0f); /*Last full print integer*/ - - /* Fails, prints "4.294968e+09" due to FP math imprecision - * TEST_ASSERT_EQUAL_PRINT_FLOATING("4.294967e+09", 4294967296.0f); */ - TEST_ASSERT_EQUAL_PRINT_FLOATING("5e+09", 5000000000.0f); - TEST_ASSERT_EQUAL_PRINT_FLOATING("8e+09", 8.0e+09f); - TEST_ASSERT_EQUAL_PRINT_FLOATING("8.309999e+09", 8309999104.0f); - TEST_ASSERT_EQUAL_PRINT_FLOATING("1e+10", 1.0e+10f); - TEST_ASSERT_EQUAL_PRINT_FLOATING("1e+10", 10000000000.0f); - /* Some compilers have trouble with inexact float constants, a float cast works generally */ - TEST_ASSERT_EQUAL_PRINT_FLOATING("1.000055e+10", (float)1.000055e+10f); - TEST_ASSERT_EQUAL_PRINT_FLOATING("1.1e+38", (float)1.10000005e+38f); - TEST_ASSERT_EQUAL_PRINT_FLOATING("1.635299e+10", 1.63529943e+10f); - /* Fails, prints "3.402824e+38" due to FP math imprecision - * TEST_ASSERT_EQUAL_PRINT_FLOATING("3.402823e+38", 3.40282346638e38f); */ - - TEST_ASSERT_EQUAL_PRINT_FLOATING("-1e+10", -1.0e+10f); - /* Fails, prints "-3.402824e+38" due to FP math imprecision - * TEST_ASSERT_EQUAL_PRINT_FLOATING("-3.402823e+38", -3.40282346638e38f); */ -#endif -} - -void testFloatPrintingRoundTiesToEven(void) -{ -#if defined(UNITY_EXCLUDE_FLOAT_PRINT) || defined(UNITY_INCLUDE_DOUBLE) || !defined(USING_OUTPUT_SPY) - TEST_IGNORE(); -#else - #ifdef UNITY_ROUND_TIES_AWAY_FROM_ZERO - TEST_ASSERT_EQUAL_PRINT_FLOATING("0.0004882813", 0.00048828125f); - TEST_ASSERT_EQUAL_PRINT_FLOATING("488281.3", 488281.25f); - TEST_ASSERT_EQUAL_PRINT_FLOATING("5.000001e-07", 0.00000050000005f); - TEST_ASSERT_EQUAL_PRINT_FLOATING("-5.000001e-07", -0.00000050000005f); - #else /* Default to Round ties to even */ - TEST_ASSERT_EQUAL_PRINT_FLOATING("0.0004882812", 0.00048828125f); - TEST_ASSERT_EQUAL_PRINT_FLOATING("488281.2", 488281.25f); - TEST_ASSERT_EQUAL_PRINT_FLOATING("5e-07", 0.00000050000005f); - TEST_ASSERT_EQUAL_PRINT_FLOATING("-5e-07", -0.00000050000005f); - #endif -#endif -} - -void testFloatPrintingInfinityAndNaN(void) -{ -#if defined(UNITY_EXCLUDE_FLOAT_PRINT) || !defined(USING_OUTPUT_SPY) - TEST_IGNORE(); -#else - TEST_ASSERT_EQUAL_PRINT_FLOATING("inf", 1.0f / f_zero); - TEST_ASSERT_EQUAL_PRINT_FLOATING("-inf", -1.0f / f_zero); - - TEST_ASSERT_EQUAL_PRINT_FLOATING("nan", 0.0f / f_zero); -#endif -} - -#if defined(UNITY_TEST_ALL_FLOATS_PRINT_OK) && defined(USING_OUTPUT_SPY) -#ifdef UNITY_INCLUDE_DOUBLE -static void printFloatValue(float f) -{ - char expected[18]; - - startPutcharSpy(); - UnityPrintFloat(f); - - sprintf(expected, "%.9g", f); - /* We print all NaN's as "nan", not "-nan" */ - if (strcmp(expected, "-nan") == 0) strcpy(expected, "nan"); - - if (strcmp(expected, getBufferPutcharSpy())) - { - /* Fail with diagnostic printing */ - TEST_ASSERT_EQUAL_PRINT_FLOATING(expected, f); - } -} -#else -static void printFloatValue(float f) -{ - char expected[18]; - char expected_lower[18]; - char expected_lower2[18]; - char expected_lower3[18]; - char expected_higher[18]; - char expected_higher2[18]; - char expected_higher3[18]; - - startPutcharSpy(); - UnityPrintFloat(f); - - sprintf(expected, "%.7g", f); - /* We print all NaN's as "nan", not "-nan" */ - if (strcmp(expected, "-nan") == 0) strcpy(expected, "nan"); - - strcpy(expected_lower, expected); - strcpy(expected_lower2, expected); - strcpy(expected_lower3, expected); - strcpy(expected_higher, expected); - strcpy(expected_higher2, expected); - strcpy(expected_higher3, expected); - - /* Allow for rounding differences in the last digit */ - double lower = (double)f * 0.99999995; - double higher = (double)f * 1.00000005; - - if(isfinite(lower)) sprintf(expected_lower, "%.7g", lower); - if(isfinite(higher)) sprintf(expected_higher, "%.7g", higher); - - /* Outside [1,10000000] allow for relative error of +/-2.5e-7 */ - if (f < 1.0 || f > 10000000) - { - double lower2 = (double)f * 0.99999985; - double lower3 = (double)f * 0.99999975; - double higher2 = (double)f * 1.00000015; - double higher3 = (double)f * 1.00000025; - - if (isfinite(lower2)) sprintf(expected_lower2, "%.7g", lower2); - if (isfinite(lower3)) sprintf(expected_lower3, "%.7g", lower3); - if (isfinite(higher2)) sprintf(expected_higher2, "%.7g", higher2); - if (isfinite(higher3)) sprintf(expected_higher3, "%.7g", higher3); - } - - if (strcmp(expected, getBufferPutcharSpy()) != 0 && - strcmp(expected_lower, getBufferPutcharSpy()) != 0 && - strcmp(expected_lower2, getBufferPutcharSpy()) != 0 && - strcmp(expected_lower3, getBufferPutcharSpy()) != 0 && - strcmp(expected_higher, getBufferPutcharSpy()) != 0 && - strcmp(expected_higher2, getBufferPutcharSpy()) != 0 && - strcmp(expected_higher3, getBufferPutcharSpy()) != 0) - { - /* Fail with diagnostic printing */ - TEST_ASSERT_EQUAL_PRINT_FLOATING(expected, f); - } -} -#endif -#endif - -void testFloatPrintingRandomSamples(void) -{ -#if !defined(UNITY_TEST_ALL_FLOATS_PRINT_OK) || !defined(USING_OUTPUT_SPY) - TEST_IGNORE(); -#else - union { float f_value; uint32_t int_value; } u; - - /* These values are not covered by the MINSTD generator */ - u.int_value = 0x00000000; printFloatValue(u.f_value); - u.int_value = 0x80000000; printFloatValue(u.f_value); - u.int_value = 0x7fffffff; printFloatValue(u.f_value); - u.int_value = 0xffffffff; printFloatValue(u.f_value); - - uint32_t a = 1; - for(int num_tested = 0; num_tested < 1000000; num_tested++) - { - /* MINSTD pseudo-random number generator */ - a = (uint32_t)(((uint64_t)a * 48271u) % 2147483647u); - - /* MINSTD does not set the highest bit; test both possibilities */ - u.int_value = a; printFloatValue(u.f_value); - u.int_value = a | 0x80000000; printFloatValue(u.f_value); - } -#endif -} - -/* ===================== THESE TEST WILL RUN IF YOUR CONFIG INCLUDES DOUBLE SUPPORT ================== */ - -void testDoublesWithinDelta(void) -{ -#ifdef UNITY_EXCLUDE_DOUBLE - TEST_IGNORE(); -#else - TEST_ASSERT_DOUBLE_WITHIN(0.00003, 187245.03485, 187245.03488); - TEST_ASSERT_DOUBLE_WITHIN(1.0, 187245.0, 187246.0); - TEST_ASSERT_DOUBLE_WITHIN(0.05, 9273.2549, 9273.2049); - TEST_ASSERT_DOUBLE_WITHIN(0.007, -726.93725, -726.94424); -#endif -} - -void testDoublesNotWithinDelta(void) -{ -#ifdef UNITY_EXCLUDE_DOUBLE - TEST_IGNORE(); -#else - EXPECT_ABORT_BEGIN - TEST_ASSERT_DOUBLE_WITHIN(0.05, 9273.2649, 9273.2049); - VERIFY_FAILS_END -#endif -} - - -void testDoublesEqual(void) -{ -#ifdef UNITY_EXCLUDE_DOUBLE - TEST_IGNORE(); -#else - TEST_ASSERT_EQUAL_DOUBLE(187245123456.0, 187245123456.0); - TEST_ASSERT_EQUAL_DOUBLE(187241234567.5, 187241234567.6); - TEST_ASSERT_EQUAL_DOUBLE(9273.2512345649, 9273.25123455699); - TEST_ASSERT_EQUAL_DOUBLE(-726.12345693724, -726.1234569374); -#endif -} - -void testDoublesNotEqual(void) -{ -#ifdef UNITY_EXCLUDE_DOUBLE - TEST_IGNORE(); -#else - EXPECT_ABORT_BEGIN - TEST_ASSERT_EQUAL_DOUBLE(9273.9649, 9273.0049); - VERIFY_FAILS_END -#endif -} - -void testDoublesNotEqualNegative1(void) -{ -#ifdef UNITY_EXCLUDE_DOUBLE - TEST_IGNORE(); -#else - EXPECT_ABORT_BEGIN - TEST_ASSERT_EQUAL_DOUBLE(-9273.9649, -9273.0049); - VERIFY_FAILS_END -#endif -} - -void testDoublesNotEqualNegative2(void) -{ -#ifdef UNITY_EXCLUDE_DOUBLE - TEST_IGNORE(); -#else - EXPECT_ABORT_BEGIN - TEST_ASSERT_EQUAL_DOUBLE(-9273.0049, -9273.9649); - VERIFY_FAILS_END -#endif -} - -void testDoublesNotEqualActualNaN(void) -{ -#ifdef UNITY_EXCLUDE_DOUBLE - TEST_IGNORE(); -#else - EXPECT_ABORT_BEGIN - TEST_ASSERT_EQUAL_DOUBLE(85.963, 0.0 / d_zero); - VERIFY_FAILS_END -#endif -} - -void testDoublesNotEqualExpectedNaN(void) -{ -#ifdef UNITY_EXCLUDE_DOUBLE - TEST_IGNORE(); -#else - EXPECT_ABORT_BEGIN - TEST_ASSERT_EQUAL_DOUBLE(0.0 / d_zero, 85.963); - VERIFY_FAILS_END -#endif -} - -void testDoublesEqualBothNaN(void) -{ -#ifdef UNITY_EXCLUDE_DOUBLE - TEST_IGNORE(); -#else - TEST_ASSERT_EQUAL_DOUBLE(0.0 / d_zero, 0.0 / d_zero); -#endif -} - -void testDoublesNotEqualInfNaN(void) -{ -#ifdef UNITY_EXCLUDE_DOUBLE - TEST_IGNORE(); -#else - EXPECT_ABORT_BEGIN - TEST_ASSERT_EQUAL_DOUBLE(1.0 / d_zero, 0.0 / d_zero); - VERIFY_FAILS_END -#endif -} - -void testDoublesNotEqualNaNInf(void) -{ -#ifdef UNITY_EXCLUDE_DOUBLE - TEST_IGNORE(); -#else - EXPECT_ABORT_BEGIN - TEST_ASSERT_EQUAL_DOUBLE(0.0 / d_zero, 1.0 / d_zero); - VERIFY_FAILS_END -#endif -} - -void testDoublesNotEqualActualInf(void) -{ -#ifdef UNITY_EXCLUDE_DOUBLE - TEST_IGNORE(); -#else - EXPECT_ABORT_BEGIN - TEST_ASSERT_EQUAL_DOUBLE(321.642, 1.0 / d_zero); - VERIFY_FAILS_END -#endif -} - -void testDoublesNotEqualExpectedInf(void) -{ -#ifdef UNITY_EXCLUDE_DOUBLE - TEST_IGNORE(); -#else - EXPECT_ABORT_BEGIN - TEST_ASSERT_EQUAL_DOUBLE(1.0 / d_zero, 321.642); - VERIFY_FAILS_END -#endif -} - -void testDoublesEqualBothInf(void) -{ -#ifdef UNITY_EXCLUDE_DOUBLE - TEST_IGNORE(); -#else - TEST_ASSERT_EQUAL_DOUBLE(1.0 / d_zero, 1.0 / d_zero); -#endif -} - -void testDoublesNotEqualPlusMinusInf(void) -{ -#ifdef UNITY_EXCLUDE_DOUBLE - TEST_IGNORE(); -#else - EXPECT_ABORT_BEGIN - TEST_ASSERT_EQUAL_DOUBLE(1.0 / d_zero, -1.0 / d_zero); - VERIFY_FAILS_END -#endif -} - -void testDoubleIsPosInf1(void) -{ -#ifdef UNITY_EXCLUDE_DOUBLE - TEST_IGNORE(); -#else - TEST_ASSERT_DOUBLE_IS_INF(2.0 / d_zero); -#endif -} - -void testDoubleIsPosInf2(void) -{ -#ifdef UNITY_EXCLUDE_DOUBLE - TEST_IGNORE(); -#else - EXPECT_ABORT_BEGIN - TEST_ASSERT_DOUBLE_IS_NOT_INF(2.0 / d_zero); - VERIFY_FAILS_END -#endif -} - -void testDoubleIsNegInf1(void) -{ -#ifdef UNITY_EXCLUDE_DOUBLE - TEST_IGNORE(); -#else - TEST_ASSERT_DOUBLE_IS_NEG_INF(-3.0 / d_zero); -#endif -} - -void testDoubleIsNegInf2(void) -{ -#ifdef UNITY_EXCLUDE_DOUBLE - TEST_IGNORE(); -#else - EXPECT_ABORT_BEGIN - TEST_ASSERT_DOUBLE_IS_NOT_NEG_INF(-3.0 / d_zero); - VERIFY_FAILS_END -#endif -} - -void testDoubleIsNotPosInf1(void) -{ -#ifdef UNITY_EXCLUDE_DOUBLE - TEST_IGNORE(); -#else - EXPECT_ABORT_BEGIN - TEST_ASSERT_DOUBLE_IS_INF(2.0); - VERIFY_FAILS_END -#endif -} - -void testDoubleIsNotPosInf2(void) -{ -#ifdef UNITY_EXCLUDE_DOUBLE - TEST_IGNORE(); -#else - TEST_ASSERT_DOUBLE_IS_NOT_INF(2.0); -#endif -} - -void testDoubleIsNotNegInf(void) -{ -#ifdef UNITY_EXCLUDE_DOUBLE - TEST_IGNORE(); -#else - EXPECT_ABORT_BEGIN - TEST_ASSERT_DOUBLE_IS_NEG_INF(-999.876); - VERIFY_FAILS_END -#endif -} - -void testDoubleIsNan1(void) -{ -#ifdef UNITY_EXCLUDE_DOUBLE - TEST_IGNORE(); -#else - TEST_ASSERT_DOUBLE_IS_NAN(0.0 / d_zero); -#endif -} - -void testDoubleIsNan2(void) -{ -#ifdef UNITY_EXCLUDE_DOUBLE - TEST_IGNORE(); -#else - EXPECT_ABORT_BEGIN - TEST_ASSERT_DOUBLE_IS_NOT_NAN(0.0 / d_zero); - VERIFY_FAILS_END -#endif -} - -void testDoubleIsNotNan1(void) -{ -#ifdef UNITY_EXCLUDE_DOUBLE - TEST_IGNORE(); -#else - EXPECT_ABORT_BEGIN - TEST_ASSERT_DOUBLE_IS_NAN(234.9); - VERIFY_FAILS_END -#endif -} - -void testDoubleIsNotNan2(void) -{ -#ifdef UNITY_EXCLUDE_DOUBLE - TEST_IGNORE(); -#else - TEST_ASSERT_DOUBLE_IS_NOT_NAN(234.9); -#endif -} - -void testDoubleInfIsNotNan(void) -{ -#ifdef UNITY_EXCLUDE_DOUBLE - TEST_IGNORE(); -#else - EXPECT_ABORT_BEGIN - TEST_ASSERT_DOUBLE_IS_NAN(1.0 / d_zero); - VERIFY_FAILS_END -#endif -} - -void testDoubleNanIsNotInf(void) -{ -#ifdef UNITY_EXCLUDE_DOUBLE - TEST_IGNORE(); -#else - EXPECT_ABORT_BEGIN - TEST_ASSERT_DOUBLE_IS_INF(0.0 / d_zero); - VERIFY_FAILS_END -#endif -} - -void testDoubleIsDeterminate1(void) -{ -#ifdef UNITY_EXCLUDE_DOUBLE - TEST_IGNORE(); -#else - TEST_ASSERT_DOUBLE_IS_DETERMINATE(0.0); - TEST_ASSERT_DOUBLE_IS_DETERMINATE(123.3); - TEST_ASSERT_DOUBLE_IS_DETERMINATE(-88.3); -#endif -} - -void testDoubleIsDeterminate2(void) -{ -#ifdef UNITY_EXCLUDE_DOUBLE - TEST_IGNORE(); -#else - EXPECT_ABORT_BEGIN - TEST_ASSERT_DOUBLE_IS_NOT_DETERMINATE(-88.3); - VERIFY_FAILS_END -#endif -} - -void testDoubleIsNotDeterminate1(void) -{ -#ifdef UNITY_EXCLUDE_DOUBLE - TEST_IGNORE(); -#else - TEST_ASSERT_DOUBLE_IS_NOT_DETERMINATE(1.0 / d_zero); - TEST_ASSERT_DOUBLE_IS_NOT_DETERMINATE(-1.0 / d_zero); - TEST_ASSERT_DOUBLE_IS_NOT_DETERMINATE(0.0 / d_zero); -#endif -} - -void testDoubleIsNotDeterminate2(void) -{ -#ifdef UNITY_EXCLUDE_DOUBLE - TEST_IGNORE(); -#else - EXPECT_ABORT_BEGIN - TEST_ASSERT_DOUBLE_IS_DETERMINATE(-1.0 / d_zero); - VERIFY_FAILS_END -#endif -} - -void testDoubleTraitFailsOnInvalidTrait(void) -{ -#ifdef UNITY_EXCLUDE_DOUBLE - TEST_IGNORE(); -#else - EXPECT_ABORT_BEGIN - UnityAssertDoubleSpecial(1.0, NULL, __LINE__, UNITY_FLOAT_INVALID_TRAIT); - VERIFY_FAILS_END -#endif -} - -void testEqualDoubleArrays(void) -{ -#ifdef UNITY_EXCLUDE_DOUBLE - TEST_IGNORE(); -#else - double p0[] = {1.0, -8.0, 25.4, -0.123}; - double p1[] = {1.0, -8.0, 25.4, -0.123}; - double p2[] = {1.0, -8.0, 25.4, -0.2}; - double p3[] = {1.0, -23.0, 25.0, -0.26}; - - TEST_ASSERT_EQUAL_DOUBLE_ARRAY(p0, p0, 1); - TEST_ASSERT_EQUAL_DOUBLE_ARRAY(p0, p0, 4); - TEST_ASSERT_EQUAL_DOUBLE_ARRAY(p0, p1, 4); - TEST_ASSERT_EQUAL_DOUBLE_ARRAY(p0, p2, 3); - TEST_ASSERT_EQUAL_DOUBLE_ARRAY(p0, p3, 1); - TEST_ASSERT_EQUAL_DOUBLE_ARRAY(NULL, NULL, 1); -#endif -} - -void testNotEqualDoubleArraysExpectedNull(void) -{ -#ifdef UNITY_EXCLUDE_DOUBLE - TEST_IGNORE(); -#else - double* p0 = NULL; - double p1[] = {1.0, 8.0, 25.4, 0.252}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_EQUAL_DOUBLE_ARRAY(p0, p1, 4); - VERIFY_FAILS_END -#endif -} - -void testNotEqualDoubleArraysActualNull(void) -{ -#ifdef UNITY_EXCLUDE_DOUBLE - TEST_IGNORE(); -#else - double p0[] = {1.0, 8.0, 25.4, 0.253}; - double* p1 = NULL; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_EQUAL_DOUBLE_ARRAY(p0, p1, 4); - VERIFY_FAILS_END -#endif -} - -void testNotEqualDoubleArrays1(void) -{ -#ifdef UNITY_EXCLUDE_DOUBLE - TEST_IGNORE(); -#else - double p0[] = {1.0, 8.0, 25.4, 0.25666666667}; - double p1[] = {1.0, 8.0, 25.4, 0.25666666666}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_EQUAL_DOUBLE_ARRAY(p0, p1, 4); - VERIFY_FAILS_END -#endif -} - -void testNotEqualDoubleArrays2(void) -{ -#ifdef UNITY_EXCLUDE_DOUBLE - TEST_IGNORE(); -#else - double p0[] = {1.0, 8.0, 25.4, 0.253}; - double p1[] = {2.0, 8.0, 25.4, 0.253}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_EQUAL_DOUBLE_ARRAY(p0, p1, 4); - VERIFY_FAILS_END -#endif -} - -void testNotEqualDoubleArrays3(void) -{ -#ifdef UNITY_EXCLUDE_DOUBLE - TEST_IGNORE(); -#else - double p0[] = {1.0, 8.0, 25.4, 0.253}; - double p1[] = {1.0, 8.0, 25.5, 0.253}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_EQUAL_DOUBLE_ARRAY(p0, p1, 4); - VERIFY_FAILS_END -#endif -} - -void testNotEqualDoubleArraysNegative1(void) -{ -#ifdef UNITY_EXCLUDE_DOUBLE - TEST_IGNORE(); -#else - double p0[] = {-1.0, -8.0, -25.4, -0.2566666667}; - double p1[] = {-1.0, -8.0, -25.4, -0.2566666666}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_EQUAL_DOUBLE_ARRAY(p0, p1, 4); - VERIFY_FAILS_END -#endif -} - -void testNotEqualDoubleArraysNegative2(void) -{ -#ifdef UNITY_EXCLUDE_DOUBLE - TEST_IGNORE(); -#else - double p0[] = {-1.0, -8.0, -25.4, -0.253}; - double p1[] = {-2.0, -8.0, -25.4, -0.253}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_EQUAL_DOUBLE_ARRAY(p0, p1, 4); - VERIFY_FAILS_END -#endif -} - -void testNotEqualDoubleArraysNegative3(void) -{ -#ifdef UNITY_EXCLUDE_DOUBLE - TEST_IGNORE(); -#else - double p0[] = {-1.0, -8.0, -25.4, -0.253}; - double p1[] = {-1.0, -8.0, -25.5, -0.253}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_EQUAL_DOUBLE_ARRAY(p0, p1, 4); - VERIFY_FAILS_END -#endif -} - -void testEqualDoubleArraysNaN(void) -{ -#ifdef UNITY_EXCLUDE_DOUBLE - TEST_IGNORE(); -#else - double p0[] = {1.0, 0.0 / d_zero, 25.4, 0.253}; - double p1[] = {1.0, 0.0 / d_zero, 25.4, 0.253}; - - TEST_ASSERT_EQUAL_DOUBLE_ARRAY(p0, p1, 4); -#endif -} - -void testEqualDoubleArraysInf(void) -{ -#ifdef UNITY_EXCLUDE_DOUBLE - TEST_IGNORE(); -#else - double p0[] = {1.0, 1.0 / d_zero, 25.4, 0.253}; - double p1[] = {1.0, 1.0 / d_zero, 25.4, 0.253}; - - TEST_ASSERT_EQUAL_DOUBLE_ARRAY(p0, p1, 4); -#endif -} - -void testNotEqualDoubleArraysLengthZero(void) -{ -#ifdef UNITY_EXCLUDE_DOUBLE - TEST_IGNORE(); -#else - double p0[1] = {0.0}; - double p1[1] = {0.0}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_EQUAL_DOUBLE_ARRAY(p0, p1, 0); - VERIFY_FAILS_END -#endif -} - -void testEqualDoubleEachEqual(void) -{ -#ifdef UNITY_EXCLUDE_DOUBLE - TEST_IGNORE(); -#else - double p0[] = {1.0, 1.0, 1.0, 1.0}; - double p1[] = {-0.123, -0.123, -0.123, -0.123}; - double p2[] = {25.4, 25.4, 25.4, -0.2}; - double p3[] = {1.0, -23.0, 25.0, -0.26}; - - TEST_ASSERT_EACH_EQUAL_DOUBLE(1.0, p0, 1); - TEST_ASSERT_EACH_EQUAL_DOUBLE(1.0, p0, 4); - TEST_ASSERT_EACH_EQUAL_DOUBLE(-0.123, p1, 4); - TEST_ASSERT_EACH_EQUAL_DOUBLE(25.4, p2, 3); - TEST_ASSERT_EACH_EQUAL_DOUBLE(1.0, p3, 1); -#endif -} - -void testNotEqualDoubleEachEqualActualNull(void) -{ -#ifdef UNITY_EXCLUDE_DOUBLE - TEST_IGNORE(); -#else - double* p0 = NULL; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_EACH_EQUAL_DOUBLE(5, p0, 4); - VERIFY_FAILS_END -#endif -} - -void testNotEqualDoubleEachEqual1(void) -{ -#ifdef UNITY_EXCLUDE_DOUBLE - TEST_IGNORE(); -#else - double p0[] = {0.253, 8.0, 0.253, 0.253}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_EACH_EQUAL_DOUBLE(0.253, p0, 4); - VERIFY_FAILS_END -#endif -} - -void testNotEqualDoubleEachEqual2(void) -{ -#ifdef UNITY_EXCLUDE_DOUBLE - TEST_IGNORE(); -#else - double p0[] = {8.0, 8.0, 8.0, 0.253}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_EACH_EQUAL_DOUBLE(8.0, p0, 4); - VERIFY_FAILS_END -#endif -} - -void testNotEqualDoubleEachEqual3(void) -{ -#ifdef UNITY_EXCLUDE_DOUBLE - TEST_IGNORE(); -#else - double p0[] = {1.0, 1.0, 1.0, 0.253}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_EACH_EQUAL_DOUBLE(1.0, p0, 4); - VERIFY_FAILS_END -#endif -} - -void testNotEqualDoubleEachEqualNegative1(void) -{ -#ifdef UNITY_EXCLUDE_DOUBLE - TEST_IGNORE(); -#else - double p0[] = {-1.0, -0.253, -0.253, -0.253}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_EACH_EQUAL_DOUBLE(-0.253, p0, 4); - VERIFY_FAILS_END -#endif -} - -void testNotEqualDoubleEachEqualNegative2(void) -{ -#ifdef UNITY_EXCLUDE_DOUBLE - TEST_IGNORE(); -#else - double p0[] = {-25.4, -8.0, -25.4, -25.4}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_EACH_EQUAL_DOUBLE(-25.4, p0, 4); - VERIFY_FAILS_END -#endif -} - -void testNotEqualDoubleEachEqualNegative3(void) -{ -#ifdef UNITY_EXCLUDE_DOUBLE - TEST_IGNORE(); -#else - double p0[] = {-8.0, -8.0, -8.0, -0.253}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_EACH_EQUAL_DOUBLE(-8.0, p0, 4); - VERIFY_FAILS_END -#endif -} - -void testEqualDoubleEachEqualNaN(void) -{ -#ifdef UNITY_EXCLUDE_DOUBLE - TEST_IGNORE(); -#else - double p0[] = {0.0 / d_zero, 0.0 / d_zero, 0.0 / d_zero, 0.0 / d_zero}; - - TEST_ASSERT_EACH_EQUAL_DOUBLE(0.0 / d_zero, p0, 4); -#endif -} - -void testEqualDoubleEachEqualInf(void) -{ -#ifdef UNITY_EXCLUDE_DOUBLE - TEST_IGNORE(); -#else - double p0[] = {1.0 / d_zero, 1.0 / d_zero, 25.4, 0.253}; - - TEST_ASSERT_EACH_EQUAL_DOUBLE(1.0 / d_zero, p0, 2); -#endif -} - -void testNotEqualDoubleEachEqualLengthZero(void) -{ -#ifdef UNITY_EXCLUDE_DOUBLE - TEST_IGNORE(); -#else - double p0[1] = {0.0}; - - EXPECT_ABORT_BEGIN - TEST_ASSERT_EACH_EQUAL_DOUBLE(0.0, p0, 0); - VERIFY_FAILS_END -#endif -} - -void testDoublePrinting(void) -{ -#if defined(UNITY_EXCLUDE_FLOAT_PRINT) || defined(UNITY_EXCLUDE_DOUBLE) || !defined(USING_OUTPUT_SPY) - TEST_IGNORE(); -#else - TEST_ASSERT_EQUAL_PRINT_FLOATING("0", 0.0); - TEST_ASSERT_EQUAL_PRINT_FLOATING("4.99e-07", 0.000000499); - TEST_ASSERT_EQUAL_PRINT_FLOATING("5.0000005e-07", 0.00000050000005); - TEST_ASSERT_EQUAL_PRINT_FLOATING("0.100469499", 0.100469499); - TEST_ASSERT_EQUAL_PRINT_FLOATING("1", 0.9999999995); /*Rounding to int place*/ - TEST_ASSERT_EQUAL_PRINT_FLOATING("1", 1.0); - TEST_ASSERT_EQUAL_PRINT_FLOATING("1.25", 1.25); - TEST_ASSERT_EQUAL_PRINT_FLOATING("7.99999999", 7.99999999); /*Not rounding*/ - TEST_ASSERT_EQUAL_PRINT_FLOATING("16.0000002", 16.0000002); - TEST_ASSERT_EQUAL_PRINT_FLOATING("16.0000004", 16.0000004); - TEST_ASSERT_EQUAL_PRINT_FLOATING("16.0000006", 16.0000006); - TEST_ASSERT_EQUAL_PRINT_FLOATING("999999999", 999999999.0); /*Last full print integer*/ - - TEST_ASSERT_EQUAL_PRINT_FLOATING("0", -0.0); /* -0 no supported on all targets */ - TEST_ASSERT_EQUAL_PRINT_FLOATING("-4.99e-07", -0.000000499); - TEST_ASSERT_EQUAL_PRINT_FLOATING("-5.0000005e-07", -0.00000050000005); - TEST_ASSERT_EQUAL_PRINT_FLOATING("-0.100469499", -0.100469499); - TEST_ASSERT_EQUAL_PRINT_FLOATING("-1", -0.9999999995); /*Rounding to int place*/ - TEST_ASSERT_EQUAL_PRINT_FLOATING("-1", -1.0); - TEST_ASSERT_EQUAL_PRINT_FLOATING("-1.25", -1.25); - TEST_ASSERT_EQUAL_PRINT_FLOATING("-7.99999999", -7.99999999); /*Not rounding*/ - TEST_ASSERT_EQUAL_PRINT_FLOATING("-16.0000002", -16.0000002); - TEST_ASSERT_EQUAL_PRINT_FLOATING("-16.0000004", -16.0000004); - TEST_ASSERT_EQUAL_PRINT_FLOATING("-16.0000006", -16.0000006); - TEST_ASSERT_EQUAL_PRINT_FLOATING("-999999999", -999999999.0); /*Last full print integer*/ - - TEST_ASSERT_EQUAL_PRINT_FLOATING("0.1004695", 0.10046949999999999); - TEST_ASSERT_EQUAL_PRINT_FLOATING("4.2949673e+09", 4294967295.9); - TEST_ASSERT_EQUAL_PRINT_FLOATING("4.2949673e+09", 4294967296.0); - TEST_ASSERT_EQUAL_PRINT_FLOATING("1e+10", 9999999995.0); - TEST_ASSERT_EQUAL_PRINT_FLOATING("9.00719925e+15", 9007199254740990.0); - TEST_ASSERT_EQUAL_PRINT_FLOATING("7e+100", 7.0e+100); - TEST_ASSERT_EQUAL_PRINT_FLOATING("3e+200", 3.0e+200); - TEST_ASSERT_EQUAL_PRINT_FLOATING("9.23456789e+300", 9.23456789e+300); - - TEST_ASSERT_EQUAL_PRINT_FLOATING("-0.1004695", -0.10046949999999999); - TEST_ASSERT_EQUAL_PRINT_FLOATING("-4.2949673e+09", -4294967295.9); - TEST_ASSERT_EQUAL_PRINT_FLOATING("-4.2949673e+09", -4294967296.0); - TEST_ASSERT_EQUAL_PRINT_FLOATING("-7e+100", -7.0e+100); -#endif -} - -void testDoublePrintingRoundTiesToEven(void) -{ -#if defined(UNITY_EXCLUDE_FLOAT_PRINT) || defined(UNITY_EXCLUDE_DOUBLE) || !defined(USING_OUTPUT_SPY) - TEST_IGNORE(); -#else - #ifdef UNITY_ROUND_TIES_AWAY_FROM_ZERO - TEST_ASSERT_EQUAL_PRINT_FLOATING("1.00000001e+10", 10000000050.0); - TEST_ASSERT_EQUAL_PRINT_FLOATING("9.00719925e+15", 9007199245000000.0); - #else /* Default to Round ties to even */ - TEST_ASSERT_EQUAL_PRINT_FLOATING("1e+10", 10000000050.0); - TEST_ASSERT_EQUAL_PRINT_FLOATING("9.00719924e+15", 9007199245000000.0); - #endif -#endif -} - -void testDoublePrintingInfinityAndNaN(void) -{ -#if defined(UNITY_EXCLUDE_FLOAT_PRINT) || defined(UNITY_EXCLUDE_DOUBLE) || !defined(USING_OUTPUT_SPY) - TEST_IGNORE(); -#else - TEST_ASSERT_EQUAL_PRINT_FLOATING("inf", 1.0 / d_zero); - TEST_ASSERT_EQUAL_PRINT_FLOATING("-inf", -1.0 / d_zero); - - TEST_ASSERT_EQUAL_PRINT_FLOATING("nan", 0.0 / d_zero); -#endif -} - -/* ===================== THESE TEST WILL RUN IF YOUR CONFIG INCLUDES DETAIL SUPPORT ================== */ - -void testThatDetailsCanBeHandleOneDetail(void) -{ -#ifdef UNITY_EXCLUDE_DETAILS - TEST_IGNORE(); -#else - UNITY_SET_DETAIL("Detail1"); - - EXPECT_ABORT_BEGIN - TEST_ASSERT_EQUAL_INT_MESSAGE(5, 6, "Should Fail And Say Detail1"); - VERIFY_FAILS_END -#endif -} - -void testThatDetailsCanHandleTestFail(void) -{ -#ifdef UNITY_EXCLUDE_DETAILS - TEST_IGNORE(); -#else - UNITY_SET_DETAILS("Detail1","Detail2"); - - EXPECT_ABORT_BEGIN - TEST_FAIL_MESSAGE("Should Fail And Say Detail1 and Detail2"); - VERIFY_FAILS_END -#endif -} - -void testThatDetailsCanBeHandleTwoDetails(void) -{ -#ifdef UNITY_EXCLUDE_DETAILS - TEST_IGNORE(); -#else - UNITY_SET_DETAILS("Detail1","Detail2"); - - EXPECT_ABORT_BEGIN - TEST_ASSERT_EQUAL_HEX8_MESSAGE(7, 8, "Should Fail And Say Detail1 and Detail2"); - VERIFY_FAILS_END -#endif -} - -void testThatDetailsCanBeHandleSingleDetailClearingTwoDetails(void) -{ -#ifdef UNITY_EXCLUDE_DETAILS - TEST_IGNORE(); -#else - UNITY_SET_DETAILS("Detail1","Detail2"); - UNITY_SET_DETAIL("DetailNew"); - - EXPECT_ABORT_BEGIN - TEST_ASSERT_EQUAL_STRING_MESSAGE("MEH", "GUH", "Should Fail And Say DetailNew"); - VERIFY_FAILS_END -#endif -} From a58054b0137c46f826cee86e145e427389a21884 Mon Sep 17 00:00:00 2001 From: mvandervoord Date: Mon, 16 Mar 2020 19:33:51 -0400 Subject: [PATCH 222/454] Update makefile to run tests. tweak broken tests. --- test/Makefile | 107 ++++++++++++++++++++++++++--- test/tests/self_assessment_utils.h | 15 ++++ test/tests/test_unity_floats.c | 5 -- test/tests/test_unity_integers.c | 10 --- 4 files changed, 114 insertions(+), 23 deletions(-) diff --git a/test/Makefile b/test/Makefile index e6ca9e0a..d8d10d22 100644 --- a/test/Makefile +++ b/test/Makefile @@ -21,7 +21,14 @@ DEFINES += -D UNITY_OUTPUT_CHAR_HEADER_DECLARATION=putcharSpy\(int\) DEFINES += -D UNITY_OUTPUT_FLUSH=flushSpy DEFINES += -D UNITY_OUTPUT_FLUSH_HEADER_DECLARATION=flushSpy\(void\) DEFINES += $(UNITY_SUPPORT_64) $(UNITY_INCLUDE_DOUBLE) -SRC = ../src/unity.c tests/testunity.c build/testunityRunner.c +SRC1 = ../src/unity.c tests/test_unity_arrays.c build/test_unity_arraysRunner.c +SRC2 = ../src/unity.c tests/test_unity_core.c build/test_unity_coreRunner.c +SRC3 = ../src/unity.c tests/test_unity_doubles.c build/test_unity_doublesRunner.c +SRC4 = ../src/unity.c tests/test_unity_floats.c build/test_unity_floatsRunner.c +SRC5 = ../src/unity.c tests/test_unity_integers.c build/test_unity_integersRunner.c +SRC6 = ../src/unity.c tests/test_unity_integers_64.c build/test_unity_integers_64Runner.c +SRC7 = ../src/unity.c tests/test_unity_memory.c build/test_unity_memoryRunner.c +SRC8 = ../src/unity.c tests/test_unity_strings.c build/test_unity_stringsRunner.c INC_DIR = -I ../src COV_FLAGS = -fprofile-arcs -ftest-coverage -I ../../src BUILD_DIR = build @@ -31,17 +38,80 @@ TARGET = build/testunity-cov.exe # For verbose output of all the tests, run 'make test'. default: coverage .PHONY: default coverage test clean -coverage: $(BUILD_DIR)/testunityRunner.c +coverage: $(SRC1) $(SRC2) $(SRC3) $(SRC4) $(SRC5) $(SRC6) $(SRC7) $(SRC8) cd $(BUILD_DIR) && \ - $(CC) $(CFLAGS) $(DEFINES) $(foreach i,$(SRC), ../$i) $(COV_FLAGS) -o ../$(TARGET) + $(CC) $(CFLAGS) $(DEFINES) $(foreach i,$(SRC1), ../$i) $(COV_FLAGS) -o ../$(TARGET) + rm -f $(BUILD_DIR)/*.gcda + ./$(TARGET) | grep 'Tests\|]]]' -A1 + cd $(BUILD_DIR) && \ + gcov unity.c | head -3 + grep '###' $(BUILD_DIR)/unity.c.gcov -C2 || true + cd $(BUILD_DIR) && \ + $(CC) $(CFLAGS) $(DEFINES) $(foreach i,$(SRC2), ../$i) $(COV_FLAGS) -o ../$(TARGET) + rm -f $(BUILD_DIR)/*.gcda + ./$(TARGET) | grep 'Tests\|]]]' -A1 + cd $(BUILD_DIR) && \ + gcov unity.c | head -3 + grep '###' $(BUILD_DIR)/unity.c.gcov -C2 || true + cd $(BUILD_DIR) && \ + $(CC) $(CFLAGS) $(DEFINES) $(foreach i,$(SRC3), ../$i) $(COV_FLAGS) -o ../$(TARGET) + rm -f $(BUILD_DIR)/*.gcda + ./$(TARGET) | grep 'Tests\|]]]' -A1 + cd $(BUILD_DIR) && \ + gcov unity.c | head -3 + grep '###' $(BUILD_DIR)/unity.c.gcov -C2 || true + cd $(BUILD_DIR) && \ + $(CC) $(CFLAGS) $(DEFINES) $(foreach i,$(SRC4), ../$i) $(COV_FLAGS) -o ../$(TARGET) + rm -f $(BUILD_DIR)/*.gcda + ./$(TARGET) | grep 'Tests\|]]]' -A1 + cd $(BUILD_DIR) && \ + gcov unity.c | head -3 + grep '###' $(BUILD_DIR)/unity.c.gcov -C2 || true + cd $(BUILD_DIR) && \ + $(CC) $(CFLAGS) $(DEFINES) $(foreach i,$(SRC5), ../$i) $(COV_FLAGS) -o ../$(TARGET) + rm -f $(BUILD_DIR)/*.gcda + ./$(TARGET) | grep 'Tests\|]]]' -A1 + cd $(BUILD_DIR) && \ + gcov unity.c | head -3 + grep '###' $(BUILD_DIR)/unity.c.gcov -C2 || true + cd $(BUILD_DIR) && \ + $(CC) $(CFLAGS) $(DEFINES) $(foreach i,$(SRC6), ../$i) $(COV_FLAGS) -o ../$(TARGET) + rm -f $(BUILD_DIR)/*.gcda + ./$(TARGET) | grep 'Tests\|]]]' -A1 + cd $(BUILD_DIR) && \ + gcov unity.c | head -3 + grep '###' $(BUILD_DIR)/unity.c.gcov -C2 || true + cd $(BUILD_DIR) && \ + $(CC) $(CFLAGS) $(DEFINES) $(foreach i,$(SRC7), ../$i) $(COV_FLAGS) -o ../$(TARGET) + rm -f $(BUILD_DIR)/*.gcda + ./$(TARGET) | grep 'Tests\|]]]' -A1 + cd $(BUILD_DIR) && \ + gcov unity.c | head -3 + grep '###' $(BUILD_DIR)/unity.c.gcov -C2 || true + cd $(BUILD_DIR) && \ + $(CC) $(CFLAGS) $(DEFINES) $(foreach i,$(SRC8), ../$i) $(COV_FLAGS) -o ../$(TARGET) rm -f $(BUILD_DIR)/*.gcda ./$(TARGET) | grep 'Tests\|]]]' -A1 cd $(BUILD_DIR) && \ gcov unity.c | head -3 grep '###' $(BUILD_DIR)/unity.c.gcov -C2 || true -test: $(BUILD_DIR)/testunityRunner.c - $(CC) $(CFLAGS) $(DEFINES) $(INC_DIR) $(SRC) -o $(TARGET) +test: $(SRC1) $(SRC2) $(SRC3) $(SRC4) $(SRC5) $(SRC6) $(SRC7) $(SRC8) + $(CC) $(CFLAGS) $(DEFINES) $(INC_DIR) $(SRC1) -o $(TARGET) + ./$(TARGET) + $(CC) $(CFLAGS) $(DEFINES) $(INC_DIR) $(SRC2) -o $(TARGET) + ./$(TARGET) + $(CC) $(CFLAGS) $(DEFINES) $(INC_DIR) $(SRC3) -o $(TARGET) + ./$(TARGET) + $(CC) $(CFLAGS) $(DEFINES) $(INC_DIR) $(SRC4) -o $(TARGET) + ./$(TARGET) + $(CC) $(CFLAGS) $(DEFINES) $(INC_DIR) $(SRC5) -o $(TARGET) + ./$(TARGET) + $(CC) $(CFLAGS) $(DEFINES) $(INC_DIR) $(SRC6) -o $(TARGET) + ./$(TARGET) + $(CC) $(CFLAGS) $(DEFINES) $(INC_DIR) $(SRC7) -o $(TARGET) + ./$(TARGET) + $(CC) $(CFLAGS) $(DEFINES) $(INC_DIR) $(SRC8) -o $(TARGET) ./$(TARGET) # Compile only, for testing that preprocessor detection works @@ -50,8 +120,29 @@ intDetection: $(CC) $(CFLAGS) $(INC_DIR) $(UNITY_C_ONLY) -D UNITY_EXCLUDE_STDINT_H $(CC) $(CFLAGS) $(INC_DIR) $(UNITY_C_ONLY) -D UNITY_EXCLUDE_LIMITS_H -$(BUILD_DIR)/testunityRunner.c: tests/testunity.c | $(BUILD_DIR) - awk $(AWK_SCRIPT) tests/testunity.c > $@ +$(BUILD_DIR)/test_unity_arraysRunner.c: tests/test_unity_arrays.c | $(BUILD_DIR) + awk $(AWK_SCRIPT) tests/test_unity_arrays.c > $@ + +$(BUILD_DIR)/test_unity_coreRunner.c: tests/test_unity_core.c | $(BUILD_DIR) + awk $(AWK_SCRIPT) tests/test_unity_core.c > $@ + +$(BUILD_DIR)/test_unity_doublesRunner.c: tests/test_unity_doubles.c | $(BUILD_DIR) + awk $(AWK_SCRIPT) tests/test_unity_doubles.c > $@ + +$(BUILD_DIR)/test_unity_floatsRunner.c: tests/test_unity_floats.c | $(BUILD_DIR) + awk $(AWK_SCRIPT) tests/test_unity_floats.c > $@ + +$(BUILD_DIR)/test_unity_integersRunner.c: tests/test_unity_integers.c | $(BUILD_DIR) + awk $(AWK_SCRIPT) tests/test_unity_integers.c > $@ + +$(BUILD_DIR)/test_unity_integers_64Runner.c: tests/test_unity_integers_64.c | $(BUILD_DIR) + awk $(AWK_SCRIPT) tests/test_unity_integers_64.c > $@ + +$(BUILD_DIR)/test_unity_memoryRunner.c: tests/test_unity_memory.c | $(BUILD_DIR) + awk $(AWK_SCRIPT) tests/test_unity_memory.c > $@ + +$(BUILD_DIR)/test_unity_stringsRunner.c: tests/test_unity_strings.c | $(BUILD_DIR) + awk $(AWK_SCRIPT) tests/test_unity_strings.c > $@ AWK_SCRIPT=\ '/^void test/{ declarations[d++]=$$0; gsub(/\(?void\)? ?/,""); tests[t++]=$$0; line[u++]=NR } \ @@ -65,4 +156,4 @@ $(BUILD_DIR): mkdir -p $(BUILD_DIR) clean: - rm -f $(TARGET) $(BUILD_DIR)/*.gc* $(BUILD_DIR)/testunityRunner.c + rm -f $(TARGET) $(BUILD_DIR)/*.gc* $(BUILD_DIR)/test_unity_*Runner.c diff --git a/test/tests/self_assessment_utils.h b/test/tests/self_assessment_utils.h index e7083872..14ee4024 100644 --- a/test/tests/self_assessment_utils.h +++ b/test/tests/self_assessment_utils.h @@ -129,4 +129,19 @@ void flushSpy(void) if (flushSpyEnabled){ flushSpyCalls++; } } +#define TEST_ASSERT_EQUAL_PRINT_NUMBERS(expected, actual) { \ + startPutcharSpy(); UnityPrintNumber((actual)); endPutcharSpy(); \ + TEST_ASSERT_EQUAL_STRING((expected), getBufferPutcharSpy()); \ + } + +#define TEST_ASSERT_EQUAL_PRINT_UNSIGNED_NUMBERS(expected, actual) { \ + startPutcharSpy(); UnityPrintNumberUnsigned((actual)); endPutcharSpy(); \ + TEST_ASSERT_EQUAL_STRING((expected), getBufferPutcharSpy()); \ + } + +#define TEST_ASSERT_EQUAL_PRINT_FLOATING(expected, actual) { \ + startPutcharSpy(); UnityPrintFloat((actual)); endPutcharSpy(); \ + TEST_ASSERT_EQUAL_STRING((expected), getBufferPutcharSpy()); \ + } + #endif \ No newline at end of file diff --git a/test/tests/test_unity_floats.c b/test/tests/test_unity_floats.c index bbf761a7..0444ee3d 100644 --- a/test/tests/test_unity_floats.c +++ b/test/tests/test_unity_floats.c @@ -694,11 +694,6 @@ void testNotEqualFloatEachEqualLengthZero(void) #endif } -#define TEST_ASSERT_EQUAL_PRINT_FLOATING(expected, actual) { \ - startPutcharSpy(); UnityPrintFloat((actual)); endPutcharSpy(); \ - TEST_ASSERT_EQUAL_STRING((expected), getBufferPutcharSpy()); \ - } - void testFloatPrinting(void) { #if defined(UNITY_EXCLUDE_FLOAT_PRINT) || defined(UNITY_INCLUDE_DOUBLE) || !defined(USING_OUTPUT_SPY) diff --git a/test/tests/test_unity_integers.c b/test/tests/test_unity_integers.c index 3359bc77..ce8bdb04 100644 --- a/test/tests/test_unity_integers.c +++ b/test/tests/test_unity_integers.c @@ -2816,16 +2816,6 @@ void testHexPrintsUpToMaxNumberOfNibbles(void) #endif } -#define TEST_ASSERT_EQUAL_PRINT_NUMBERS(expected, actual) { \ - startPutcharSpy(); UnityPrintNumber((actual)); endPutcharSpy(); \ - TEST_ASSERT_EQUAL_STRING((expected), getBufferPutcharSpy()); \ - } - -#define TEST_ASSERT_EQUAL_PRINT_UNSIGNED_NUMBERS(expected, actual) { \ - startPutcharSpy(); UnityPrintNumberUnsigned((actual)); endPutcharSpy(); \ - TEST_ASSERT_EQUAL_STRING((expected), getBufferPutcharSpy()); \ - } - void testPrintNumbers32(void) { #ifndef USING_OUTPUT_SPY From 3ee46e3da3362c7949f0a0b0b82e0004e937993a Mon Sep 17 00:00:00 2001 From: mvandervoord Date: Mon, 16 Mar 2020 19:51:05 -0400 Subject: [PATCH 223/454] Forgot EOL --- test/tests/self_assessment_utils.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/tests/self_assessment_utils.h b/test/tests/self_assessment_utils.h index 14ee4024..92b08f00 100644 --- a/test/tests/self_assessment_utils.h +++ b/test/tests/self_assessment_utils.h @@ -144,4 +144,4 @@ void flushSpy(void) TEST_ASSERT_EQUAL_STRING((expected), getBufferPutcharSpy()); \ } -#endif \ No newline at end of file +#endif From d7a05a56df2ff79eeb8ff6fb528bd84ca9dd3348 Mon Sep 17 00:00:00 2001 From: mvandervoord Date: Mon, 16 Mar 2020 20:14:02 -0400 Subject: [PATCH 224/454] Working with very picky compilers. :) --- test/tests/self_assessment_utils.h | 3 --- test/tests/test_unity_arrays.c | 3 +++ test/tests/test_unity_core.c | 3 +++ test/tests/test_unity_doubles.c | 3 +++ test/tests/test_unity_floats.c | 3 +++ test/tests/test_unity_integers.c | 3 +++ test/tests/test_unity_integers_64.c | 3 +++ test/tests/test_unity_memory.c | 3 +++ test/tests/test_unity_strings.c | 3 +++ 9 files changed, 24 insertions(+), 3 deletions(-) diff --git a/test/tests/self_assessment_utils.h b/test/tests/self_assessment_utils.h index 92b08f00..c8cb595d 100644 --- a/test/tests/self_assessment_utils.h +++ b/test/tests/self_assessment_utils.h @@ -47,9 +47,6 @@ static const UNITY_DOUBLE d_zero = 0.0; UNITY_OUTPUT_CHAR('\n'); \ } -int SetToOneToFailInTearDown; -int SetToOneMeanWeAlreadyCheckedThisGuy; - /* Tricky series of macros to set USING_OUTPUT_SPY */ #define USING_SPY_AS(a) EXPAND_AND_USE_2ND(ASSIGN_VALUE(a), 0) #define ASSIGN_VALUE(a) VAL_##a diff --git a/test/tests/test_unity_arrays.c b/test/tests/test_unity_arrays.c index bf1ef7a0..496dda03 100644 --- a/test/tests/test_unity_arrays.c +++ b/test/tests/test_unity_arrays.c @@ -8,6 +8,9 @@ #define TEST_INSTANCES #include "self_assessment_utils.h" +int SetToOneToFailInTearDown; +int SetToOneMeanWeAlreadyCheckedThisGuy; + void setUp(void) { SetToOneToFailInTearDown = 0; diff --git a/test/tests/test_unity_core.c b/test/tests/test_unity_core.c index eb53ba5b..a2193bca 100644 --- a/test/tests/test_unity_core.c +++ b/test/tests/test_unity_core.c @@ -8,6 +8,9 @@ #define TEST_INSTANCES #include "self_assessment_utils.h" +int SetToOneToFailInTearDown; +int SetToOneMeanWeAlreadyCheckedThisGuy; + void setUp(void) { SetToOneToFailInTearDown = 0; diff --git a/test/tests/test_unity_doubles.c b/test/tests/test_unity_doubles.c index 2757e694..ec93baed 100644 --- a/test/tests/test_unity_doubles.c +++ b/test/tests/test_unity_doubles.c @@ -8,6 +8,9 @@ #define TEST_INSTANCES #include "self_assessment_utils.h" +int SetToOneToFailInTearDown; +int SetToOneMeanWeAlreadyCheckedThisGuy; + void setUp(void) { SetToOneToFailInTearDown = 0; diff --git a/test/tests/test_unity_floats.c b/test/tests/test_unity_floats.c index 0444ee3d..e183384b 100644 --- a/test/tests/test_unity_floats.c +++ b/test/tests/test_unity_floats.c @@ -8,6 +8,9 @@ #define TEST_INSTANCES #include "self_assessment_utils.h" +int SetToOneToFailInTearDown; +int SetToOneMeanWeAlreadyCheckedThisGuy; + void setUp(void) { SetToOneToFailInTearDown = 0; diff --git a/test/tests/test_unity_integers.c b/test/tests/test_unity_integers.c index ce8bdb04..38ce5660 100644 --- a/test/tests/test_unity_integers.c +++ b/test/tests/test_unity_integers.c @@ -8,6 +8,9 @@ #define TEST_INSTANCES #include "self_assessment_utils.h" +int SetToOneToFailInTearDown; +int SetToOneMeanWeAlreadyCheckedThisGuy; + void setUp(void) { SetToOneToFailInTearDown = 0; diff --git a/test/tests/test_unity_integers_64.c b/test/tests/test_unity_integers_64.c index e67be84d..cfc97744 100644 --- a/test/tests/test_unity_integers_64.c +++ b/test/tests/test_unity_integers_64.c @@ -8,6 +8,9 @@ #define TEST_INSTANCES #include "self_assessment_utils.h" +int SetToOneToFailInTearDown; +int SetToOneMeanWeAlreadyCheckedThisGuy; + void setUp(void) { SetToOneToFailInTearDown = 0; diff --git a/test/tests/test_unity_memory.c b/test/tests/test_unity_memory.c index d005dfbf..684ef9b4 100644 --- a/test/tests/test_unity_memory.c +++ b/test/tests/test_unity_memory.c @@ -8,6 +8,9 @@ #define TEST_INSTANCES #include "self_assessment_utils.h" +int SetToOneToFailInTearDown; +int SetToOneMeanWeAlreadyCheckedThisGuy; + void setUp(void) { SetToOneToFailInTearDown = 0; diff --git a/test/tests/test_unity_strings.c b/test/tests/test_unity_strings.c index 3f451516..6c25d503 100644 --- a/test/tests/test_unity_strings.c +++ b/test/tests/test_unity_strings.c @@ -8,6 +8,9 @@ #define TEST_INSTANCES #include "self_assessment_utils.h" +int SetToOneToFailInTearDown; +int SetToOneMeanWeAlreadyCheckedThisGuy; + void setUp(void) { SetToOneToFailInTearDown = 0; From 6e3ecbf92be5144e5770d3a4f295fc9af67d98bd Mon Sep 17 00:00:00 2001 From: mvandervoord Date: Mon, 16 Mar 2020 20:26:10 -0400 Subject: [PATCH 225/454] Declare the test variable static --- test/tests/test_unity_arrays.c | 4 ++-- test/tests/test_unity_doubles.c | 4 ++-- test/tests/test_unity_floats.c | 4 ++-- test/tests/test_unity_integers.c | 4 ++-- test/tests/test_unity_integers_64.c | 4 ++-- test/tests/test_unity_memory.c | 4 ++-- test/tests/test_unity_strings.c | 4 ++-- 7 files changed, 14 insertions(+), 14 deletions(-) diff --git a/test/tests/test_unity_arrays.c b/test/tests/test_unity_arrays.c index 496dda03..ff90a6c4 100644 --- a/test/tests/test_unity_arrays.c +++ b/test/tests/test_unity_arrays.c @@ -8,8 +8,8 @@ #define TEST_INSTANCES #include "self_assessment_utils.h" -int SetToOneToFailInTearDown; -int SetToOneMeanWeAlreadyCheckedThisGuy; +static int SetToOneToFailInTearDown; +static int SetToOneMeanWeAlreadyCheckedThisGuy; void setUp(void) { diff --git a/test/tests/test_unity_doubles.c b/test/tests/test_unity_doubles.c index ec93baed..1bdedbc3 100644 --- a/test/tests/test_unity_doubles.c +++ b/test/tests/test_unity_doubles.c @@ -8,8 +8,8 @@ #define TEST_INSTANCES #include "self_assessment_utils.h" -int SetToOneToFailInTearDown; -int SetToOneMeanWeAlreadyCheckedThisGuy; +static int SetToOneToFailInTearDown; +static int SetToOneMeanWeAlreadyCheckedThisGuy; void setUp(void) { diff --git a/test/tests/test_unity_floats.c b/test/tests/test_unity_floats.c index e183384b..e89bec20 100644 --- a/test/tests/test_unity_floats.c +++ b/test/tests/test_unity_floats.c @@ -8,8 +8,8 @@ #define TEST_INSTANCES #include "self_assessment_utils.h" -int SetToOneToFailInTearDown; -int SetToOneMeanWeAlreadyCheckedThisGuy; +static int SetToOneToFailInTearDown; +static int SetToOneMeanWeAlreadyCheckedThisGuy; void setUp(void) { diff --git a/test/tests/test_unity_integers.c b/test/tests/test_unity_integers.c index 38ce5660..7bdfa144 100644 --- a/test/tests/test_unity_integers.c +++ b/test/tests/test_unity_integers.c @@ -8,8 +8,8 @@ #define TEST_INSTANCES #include "self_assessment_utils.h" -int SetToOneToFailInTearDown; -int SetToOneMeanWeAlreadyCheckedThisGuy; +static int SetToOneToFailInTearDown; +static int SetToOneMeanWeAlreadyCheckedThisGuy; void setUp(void) { diff --git a/test/tests/test_unity_integers_64.c b/test/tests/test_unity_integers_64.c index cfc97744..e12566e8 100644 --- a/test/tests/test_unity_integers_64.c +++ b/test/tests/test_unity_integers_64.c @@ -8,8 +8,8 @@ #define TEST_INSTANCES #include "self_assessment_utils.h" -int SetToOneToFailInTearDown; -int SetToOneMeanWeAlreadyCheckedThisGuy; +static int SetToOneToFailInTearDown; +static int SetToOneMeanWeAlreadyCheckedThisGuy; void setUp(void) { diff --git a/test/tests/test_unity_memory.c b/test/tests/test_unity_memory.c index 684ef9b4..b3cff131 100644 --- a/test/tests/test_unity_memory.c +++ b/test/tests/test_unity_memory.c @@ -8,8 +8,8 @@ #define TEST_INSTANCES #include "self_assessment_utils.h" -int SetToOneToFailInTearDown; -int SetToOneMeanWeAlreadyCheckedThisGuy; +static int SetToOneToFailInTearDown; +static int SetToOneMeanWeAlreadyCheckedThisGuy; void setUp(void) { diff --git a/test/tests/test_unity_strings.c b/test/tests/test_unity_strings.c index 6c25d503..964c5536 100644 --- a/test/tests/test_unity_strings.c +++ b/test/tests/test_unity_strings.c @@ -8,8 +8,8 @@ #define TEST_INSTANCES #include "self_assessment_utils.h" -int SetToOneToFailInTearDown; -int SetToOneMeanWeAlreadyCheckedThisGuy; +static int SetToOneToFailInTearDown; +static int SetToOneMeanWeAlreadyCheckedThisGuy; void setUp(void) { From 75754de04e4f02b5ef392a31c7579c4dc2c5f9f6 Mon Sep 17 00:00:00 2001 From: mvandervoord Date: Mon, 16 Mar 2020 20:38:54 -0400 Subject: [PATCH 226/454] more of the same. --- test/tests/test_unity_core.c | 4 ++-- test/tests/test_unity_parameterized.c | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/test/tests/test_unity_core.c b/test/tests/test_unity_core.c index a2193bca..ba1e3d3d 100644 --- a/test/tests/test_unity_core.c +++ b/test/tests/test_unity_core.c @@ -8,8 +8,8 @@ #define TEST_INSTANCES #include "self_assessment_utils.h" -int SetToOneToFailInTearDown; -int SetToOneMeanWeAlreadyCheckedThisGuy; +static int SetToOneToFailInTearDown; +static int SetToOneMeanWeAlreadyCheckedThisGuy; void setUp(void) { diff --git a/test/tests/test_unity_parameterized.c b/test/tests/test_unity_parameterized.c index 0583cb74..3129817e 100644 --- a/test/tests/test_unity_parameterized.c +++ b/test/tests/test_unity_parameterized.c @@ -44,8 +44,8 @@ void flushSpy(void) {} UNITY_OUTPUT_CHAR('\n'); \ } -int SetToOneToFailInTearDown; -int SetToOneMeanWeAlreadyCheckedThisGuy; +static int SetToOneToFailInTearDown; +static int SetToOneMeanWeAlreadyCheckedThisGuy; static unsigned NextExpectedStringIndex; static unsigned NextExpectedCharIndex; @@ -127,7 +127,7 @@ TEST_CASE(3, ";") TEST_CASE(4, "\"quoted\"") void test_StringsArePreserved(unsigned index, const char * str) { - static const char * const expected[] = + static const char * const expected[] = { "abc", "{", From 3e4dfec1470b3672f962b3e37a0ecea00e13aa08 Mon Sep 17 00:00:00 2001 From: mvandervoord Date: Tue, 17 Mar 2020 14:02:54 -0400 Subject: [PATCH 227/454] Add support for alternate forms of header and source files to test runner generator. This borrows heavily from #477 (Thanks @Tuc-an) but maintains the ability to sort files that don't need to be relinked. --- auto/generate_test_runner.rb | 43 ++++++++++++++++++------------------ test/.rubocop.yml | 2 ++ 2 files changed, 24 insertions(+), 21 deletions(-) diff --git a/auto/generate_test_runner.rb b/auto/generate_test_runner.rb index a6e25cb9..d951b238 100644 --- a/auto/generate_test_runner.rb +++ b/auto/generate_test_runner.rb @@ -42,7 +42,9 @@ def self.default_options main_export_decl: '', cmdline_args: false, omit_begin_end: false, - use_param_tests: false + use_param_tests: false, + include_extensions: '(?:hpp|hh|H|h)', + source_extensions: '(?:cpp|cc|ino|C|c)' } end @@ -141,18 +143,17 @@ def find_tests(source) arguments.scan(/\s*TEST_CASE\s*\((.*)\)\s*$/) { |a| args << a[0] } arguments.scan(/\s*TEST_RANGE\s*\((.*)\)\s*$/).flatten.each do |range_str| - args += range_str.scan(/\[(-?\d+.?\d*), *(-?\d+.?\d*), *(-?\d+.?\d*)\]/) - .map { |arg_values_str| - arg_values_str.map { |arg_value_str| - (arg_value_str.include? ".") ? arg_value_str.to_f : arg_value_str.to_i - } - }.map { |arg_values| - (arg_values[0]..arg_values[1]).step(arg_values[2]).to_a - }.reduce { |result, arg_range_expanded| - result.product(arg_range_expanded) - }.map { |arg_combinations| - arg_combinations.flatten.join(", ") - } + args += range_str.scan(/\[(-?\d+.?\d*), *(-?\d+.?\d*), *(-?\d+.?\d*)\]/).map do |arg_values_str| + arg_values_str.map do |arg_value_str| + arg_value_str.include?('.') ? arg_value_str.to_f : arg_value_str.to_i + end + end.map do |arg_values| + (arg_values[0]..arg_values[1]).step(arg_values[2]).to_a + end.reduce do |result, arg_range_expanded| + result.product(arg_range_expanded) + end.map do |arg_combinations| + arg_combinations.flatten.join(', ') + end end end @@ -185,9 +186,9 @@ def find_includes(source) # parse out includes includes = { - local: source.scan(/^\s*#include\s+\"\s*(.+)\.[hH]\s*\"/).flatten, + local: source.scan(/^\s*#include\s+\"\s*(.+\.#{@options[:include_extensions]})\s*\"/).flatten, system: source.scan(/^\s*#include\s+<\s*(.+)\s*>/).flatten.map { |inc| "<#{inc}>" }, - linkonly: source.scan(/^TEST_FILE\(\s*\"\s*(.+)\.[cC]\w*\s*\"/).flatten + linkonly: source.scan(/^TEST_FILE\(\s*\"\s*(.+\.#{@options[:source_extensions]})\s*\"/).flatten } includes end @@ -220,14 +221,14 @@ def create_header(output, mocks, testfile_includes = []) output.puts("#include \"#{File.basename(@options[:header_file])}\"") else @options[:includes].flatten.uniq.compact.each do |inc| - output.puts("#include #{inc.include?('<') ? inc : "\"#{inc.gsub('.h', '')}.h\""}") + output.puts("#include #{inc.include?('<') ? inc : "\"#{inc}\""}") end testfile_includes.each do |inc| - output.puts("#include #{inc.include?('<') ? inc : "\"#{inc.gsub('.h', '')}.h\""}") + output.puts("#include #{inc.include?('<') ? inc : "\"#{inc}\""}") end end mocks.each do |mock| - output.puts("#include \"#{mock.gsub('.h', '')}.h\"") + output.puts("#include \"#{mock}\"") end output.puts('#include "CException.h"') if @options[:plugins].include?(:cexception) @@ -262,7 +263,7 @@ def create_mock_management(output, mock_headers) output.puts(' GlobalOrderError = NULL;') end - mocks = mock_headers.map { |mock| File.basename(mock) } + mocks = mock_headers.map { |mock| File.basename(mock, '.*') } mocks.each do |mock| mock_clean = TypeSanitizer.sanitize_c_identifier(mock) output.puts(" #{mock_clean}_Init();") @@ -438,10 +439,10 @@ def create_h_file(output, filename, tests, testfile_includes, used_mocks) output.puts("#include \"#{@options[:framework]}.h\"") output.puts('#include "cmock.h"') unless used_mocks.empty? @options[:includes].flatten.uniq.compact.each do |inc| - output.puts("#include #{inc.include?('<') ? inc : "\"#{inc.gsub('.h', '')}.h\""}") + output.puts("#include #{inc.include?('<') ? inc : "\"#{inc}\""}") end testfile_includes.each do |inc| - output.puts("#include #{inc.include?('<') ? inc : "\"#{inc.gsub('.h', '')}.h\""}") + output.puts("#include #{inc.include?('<') ? inc : "\"#{inc}\""}") end output.puts "\n" tests.each do |test| diff --git a/test/.rubocop.yml b/test/.rubocop.yml index 7c130767..bedab006 100644 --- a/test/.rubocop.yml +++ b/test/.rubocop.yml @@ -20,6 +20,8 @@ Style/HashSyntax: EnforcedStyle: no_mixed_keys Style/NumericPredicate: Enabled: false +Style/MultilineBlockChain: + Enabled: false # These are also places we diverge... but we will likely comply down the road Style/IfUnlessModifier: From 99199515fddd2e791bffc69839cdfeeaede32536 Mon Sep 17 00:00:00 2001 From: mvandervoord Date: Tue, 17 Mar 2020 15:01:46 -0400 Subject: [PATCH 228/454] Update documentation. Add UNITY_PRINT_TEST_CONTEXT (thanks @jlindgren90 !) Replaces PR #473 --- docs/UnityAssertionsReference.md | 69 +++++++++++++++++++------------- docs/UnityConfigurationGuide.md | 26 ++++++++++-- docs/UnityHelperScriptsGuide.md | 14 ++++++- src/unity.c | 7 ++++ src/unity_internals.h | 4 ++ 5 files changed, 87 insertions(+), 33 deletions(-) diff --git a/docs/UnityAssertionsReference.md b/docs/UnityAssertionsReference.md index 2e4e0ff4..58ceb6fa 100644 --- a/docs/UnityAssertionsReference.md +++ b/docs/UnityAssertionsReference.md @@ -67,18 +67,20 @@ to be well designed code. The convention of assertion parameters generally follows this order: - TEST_ASSERT_X( {modifiers}, {expected}, actual, {size/count} ) +``` +TEST_ASSERT_X( {modifiers}, {expected}, actual, {size/count} ) +``` -The very simplest assertion possible uses only a single "actual" parameter (e.g. +The very simplest assertion possible uses only a single `actual` parameter (e.g. a simple null check). -"Actual" is the value being tested and unlike the other parameters in an -assertion construction is the only parameter present in all assertion variants. -"Modifiers" are masks, ranges, bit flag specifiers, floating point deltas. -"Expected" is your expected value (duh) to compare to an "actual" value; it's -marked as an optional parameter because some assertions only need a single -"actual" parameter (e.g. null check). -"Size/count" refers to string lengths, number of array elements, etc. + - `Actual` is the value being tested and unlike the other parameters in an + assertion construction is the only parameter present in all assertion variants. + - `Modifiers` are masks, ranges, bit flag specifiers, floating point deltas. + - `Expected` is your expected value (duh) to compare to an `actual` value; it's + marked as an optional parameter because some assertions only need a single + `actual` parameter (e.g. null check). + - `Size/count` refers to string lengths, number of array elements, etc. Many of Unity's assertions are clear duplications in that the same data type is handled by several assertions. The differences among these are in how failure @@ -98,11 +100,15 @@ the reference list below and add a string as the final parameter. _Example:_ - TEST_ASSERT_X( {modifiers}, {expected}, actual, {size/count} ) +``` +TEST_ASSERT_X( {modifiers}, {expected}, actual, {size/count} ) +``` becomes messageified like thus... - TEST_ASSERT_X_MESSAGE( {modifiers}, {expected}, actual, {size/count}, message ) +``` +TEST_ASSERT_X_MESSAGE( {modifiers}, {expected}, actual, {size/count}, message ) +``` Notes: - The `_MESSAGE` variants intentionally do not support `printf` style formatting @@ -122,18 +128,21 @@ with the `_MESSAGE`variants of Unity's Asserts in that for pretty much any Unity type assertion you can tack on `_ARRAY` and run assertions on an entire block of memory. +``` TEST_ASSERT_EQUAL_TYPEX_ARRAY( expected, actual, {size/count} ) +``` -"Expected" is an array itself. -"Size/count" is one or two parameters necessary to establish the number of array -elements and perhaps the length of elements within the array. + - `Expected` is an array itself. + - `Size/count` is one or two parameters necessary to establish the number of array + elements and perhaps the length of elements within the array. Notes: -- The `_MESSAGE` variant convention still applies here to array assertions. The -`_MESSAGE` variants of the `_ARRAY` assertions have names ending with -`_ARRAY_MESSAGE`. -- Assertions for handling arrays of floating point values are grouped with float -and double assertions (see immediately following section). + + - The `_MESSAGE` variant convention still applies here to array assertions. The + `_MESSAGE` variants of the `_ARRAY` assertions have names ending with + `_ARRAY_MESSAGE`. + - Assertions for handling arrays of floating point values are grouped with float + and double assertions (see immediately following section). ### TEST_ASSERT_EACH_EQUAL_X Variants @@ -142,19 +151,22 @@ Unity provides a collection of assertions for arrays containing a variety of types which can be compared to a single value as well. These are documented in the Each Equal section below. these are almost on par with the `_MESSAGE` variants of Unity's Asserts in that for pretty much any Unity type assertion you -can inject _EACH_EQUAL and run assertions on an entire block of memory. +can inject `_EACH_EQUAL` and run assertions on an entire block of memory. - TEST_ASSERT_EACH_EQUAL_TYPEX( expected, actual, {size/count} ) +``` +TEST_ASSERT_EACH_EQUAL_TYPEX( expected, actual, {size/count} ) +``` -"Expected" is a single value to compare to. -"Actual" is an array where each element will be compared to the expected value. -"Size/count" is one of two parameters necessary to establish the number of array -elements and perhaps the length of elements within the array. + - `Expected` is a single value to compare to. + - `Actual` is an array where each element will be compared to the expected value. + - `Size/count` is one of two parameters necessary to establish the number of array + elements and perhaps the length of elements within the array. Notes: -- The `_MESSAGE` variant convention still applies here to Each Equal assertions. -- Assertions for handling Each Equal of floating point values are grouped with -float and double assertions (see immediately following section). + + - The `_MESSAGE` variant convention still applies here to Each Equal assertions. + - Assertions for handling Each Equal of floating point values are grouped with + float and double assertions (see immediately following section). ### Configuration @@ -189,6 +201,7 @@ performing logic beyond a simple assertion. That is, in practice, `TEST_FAIL()` will always be found inside a conditional code block. _Examples:_ + - Executing a state machine multiple times that increments a counter your test code then verifies as a final step. - Triggering an exception and verifying it (as in Try / Catch / Throw - see the diff --git a/docs/UnityConfigurationGuide.md b/docs/UnityConfigurationGuide.md index 7633e0d1..e96db03a 100644 --- a/docs/UnityConfigurationGuide.md +++ b/docs/UnityConfigurationGuide.md @@ -350,7 +350,7 @@ specifying `UNITY_USE_FLUSH_STDOUT`. No other defines are required. ##### `UNITY_OUTPUT_FOR_QT_CREATOR` When managing your own builds, it is often handy to have messages output in a format which is -recognized by your IDE. These are some standard formats which can be supported. If you're using +recognized by your IDE. These are some standard formats which can be supported. If you're using Ceedling to manage your builds, it is better to stick with the standard format (leaving these all undefined) and allow Ceedling to use its own decorators. @@ -392,6 +392,24 @@ _Example:_ #define UNITY_EXCLUDE_DETAILS ``` +##### `UNITY_PRINT_TEST_CONTEXT` + +This option allows you to specify your own function to print additional context +as part of the error message when a test has failed. It can be useful if you +want to output some specific information about the state of the test at the point +of failure, and `UNITY_SET_DETAILS` isn't flexible enough for your needs. + +_Example:_ +```C +#define UNITY_PRINT_TEST_CONTEXT PrintIterationCount + +extern int iteration_count; + +void PrintIterationCount(void) +{ + UnityPrintFormatted("At iteration #%d: ", iteration_count); +} +``` ##### `UNITY_EXCLUDE_SETJMP` @@ -441,12 +459,12 @@ will allow you to specify how Unity will treat these assertions. #### `UNITY_SUPPORT_VARIADIC_MACROS` -This will force Unity to support variadic macros when using its own built-in +This will force Unity to support variadic macros when using its own built-in RUN_TEST macro. This will rarely be necessary. Most often, Unity will automatically detect if the compiler supports variadic macros by checking to see if it's C99+ compatible. In the event that the compiler supports variadic macros, but is primarily -C89 (ANSI), defining this option will allow you to use them. This option is also not -necessary when using Ceedling or the test runner generator script. +C89 (ANSI), defining this option will allow you to use them. This option is also not +necessary when using Ceedling or the test runner generator script. ## Getting Into The Guts diff --git a/docs/UnityHelperScriptsGuide.md b/docs/UnityHelperScriptsGuide.md index da56db2e..46c9d74d 100644 --- a/docs/UnityHelperScriptsGuide.md +++ b/docs/UnityHelperScriptsGuide.md @@ -48,7 +48,7 @@ ruby generate_test_runner.rb TestFile.c NameOfRunner.c ``` Alternatively, if you include only the test file parameter, the script will copy -the name of the test file and automatically append "_Runner" to the name of the +the name of the test file and automatically append `_Runner` to the name of the generated file. The example immediately below will create TestFile_Runner.c. ```Shell @@ -194,6 +194,18 @@ If you are using CMock, it is very likely that you are already passing an array of plugins to CMock. You can just use the same array here. This script will just ignore the plugins that don't require additional support. +##### `:include_extensions` + +This option specifies the pattern for matching acceptable header file extensions. +By default it will accept hpp, hh, H, and h files. If you need a different combination +of files to search, update this from the default `'(?:hpp|hh|H|h)'`. + +##### `:source_extensions` + +This option specifies the pattern for matching acceptable source file extensions. +By default it will accept cpp, cc, C, c, and ino files. If you need a different combination +of files to search, update this from the default `'(?:cpp|cc|ino|C|c)'`. + ### `unity_test_summary.rb` diff --git a/src/unity.c b/src/unity.c index aa8074c5..90ea672d 100644 --- a/src/unity.c +++ b/src/unity.c @@ -566,6 +566,10 @@ static void UnityAddMsgIfSpecified(const char* msg) if (msg) { UnityPrint(UnityStrSpacer); + +#ifdef UNITY_PRINT_TEST_CONTEXT + UNITY_PRINT_TEST_CONTEXT(); +#endif #ifndef UNITY_EXCLUDE_DETAILS if (Unity.CurrentDetail1) { @@ -1760,6 +1764,9 @@ void UnityFail(const char* msg, const UNITY_LINE_TYPE line) { UNITY_OUTPUT_CHAR(':'); +#ifdef UNITY_PRINT_TEST_CONTEXT + UNITY_PRINT_TEST_CONTEXT(); +#endif #ifndef UNITY_EXCLUDE_DETAILS if (Unity.CurrentDetail1) { diff --git a/src/unity_internals.h b/src/unity_internals.h index eda066ee..cdf1374d 100644 --- a/src/unity_internals.h +++ b/src/unity_internals.h @@ -509,6 +509,10 @@ void UnityDefaultTestRun(UnityTestFunction Func, const char* FuncName, const int #endif #endif +#ifdef UNITY_PRINT_TEST_CONTEXT +void UNITY_PRINT_TEST_CONTEXT(void); +#endif + /*------------------------------------------------------- * Test Output *-------------------------------------------------------*/ From f61a7ea8e41d43e419beacad82074ff1ecea2a2d Mon Sep 17 00:00:00 2001 From: mvandervoord Date: Tue, 17 Mar 2020 16:12:08 -0400 Subject: [PATCH 229/454] Fix Issue #479 (Thanks @cy18) --- src/unity.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/unity.c b/src/unity.c index 90ea672d..ffa5cf0d 100644 --- a/src/unity.c +++ b/src/unity.c @@ -21,7 +21,7 @@ void UNITY_OUTPUT_CHAR(int); /* Helpful macros for us to use here in Assert functions */ #define UNITY_FAIL_AND_BAIL { Unity.CurrentTestFailed = 1; UNITY_OUTPUT_FLUSH(); TEST_ABORT(); } #define UNITY_IGNORE_AND_BAIL { Unity.CurrentTestIgnored = 1; UNITY_OUTPUT_FLUSH(); TEST_ABORT(); } -#define RETURN_IF_FAIL_OR_IGNORE if (Unity.CurrentTestFailed || Unity.CurrentTestIgnored) return +#define RETURN_IF_FAIL_OR_IGNORE if (Unity.CurrentTestFailed || Unity.CurrentTestIgnored) TEST_ABORT() struct UNITY_STORAGE_T Unity; From 371e062555f27dda008966185285353484aea96e Mon Sep 17 00:00:00 2001 From: mvandervoord Date: Tue, 17 Mar 2020 16:24:25 -0400 Subject: [PATCH 230/454] Fixed issue #480 - better protection against bad pattern matching. --- auto/generate_test_runner.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/auto/generate_test_runner.rb b/auto/generate_test_runner.rb index 672d17c9..41941a04 100644 --- a/auto/generate_test_runner.rb +++ b/auto/generate_test_runner.rb @@ -465,13 +465,13 @@ def create_h_file(output, filename, tests, testfile_includes, used_mocks) when '-cexception' options[:plugins] = [:cexception] true - when /\.*\.ya?ml/ + when /\.*\.ya?ml$/ options = UnityTestRunnerGenerator.grab_config(arg) true when /--(\w+)=\"?(.*)\"?/ options[Regexp.last_match(1).to_sym] = Regexp.last_match(2) true - when /\.*\.h/ + when /\.*\.(?:hpp|hh|H|h)$/ options[:includes] << arg true else false From 2c3e75e859b020c3ca065f4eecd5fb1f7c546ccf Mon Sep 17 00:00:00 2001 From: mvandervoord Date: Tue, 17 Mar 2020 20:38:11 -0400 Subject: [PATCH 231/454] Fixed issue #486 --- auto/generate_module.rb | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/auto/generate_module.rb b/auto/generate_module.rb index d0477709..3d9ee8d6 100644 --- a/auto/generate_module.rb +++ b/auto/generate_module.rb @@ -164,23 +164,25 @@ def files_to_operate_on(module_name, pattern = nil) end ############################ - def create_filename(part1, part2 = '') - if part2.empty? - case (@options[:naming]) - when 'bumpy' then part1 - when 'camel' then part1 - when 'snake' then part1.downcase - when 'caps' then part1.upcase - else part1 - end + def neutralize_filename(name, start_cap=true) + return name if name.empty? + name = name.split(/(?:\s+|_|(?=[A-Z][a-z]))|(?<=[a-z])(?=[A-Z])/).map{|v|v.capitalize}.join('_') + if start_cap + return name else - case (@options[:naming]) - when 'bumpy' then part1 + part2 - when 'camel' then part1 + part2 - when 'snake' then part1.downcase + '_' + part2.downcase - when 'caps' then part1.upcase + '_' + part2.upcase - else part1 + '_' + part2 - end + return name[0].downcase + name[1..-1] + end + end + + ############################ + def create_filename(part1, part2 = '') + name = part2.empty? ? part1 : part1 + '_' + part2 + case (@options[:naming]) + when 'bumpy' then neutralize_filename(name,false).gsub('_','') + when 'camel' then neutralize_filename(name).gsub('_','') + when 'snake' then neutralize_filename(name).downcase + when 'caps' then neutralize_filename(name).upcase + else name end end From 8c4ae7aacd18a1abb35b42fc644972052c99d555 Mon Sep 17 00:00:00 2001 From: mvandervoord Date: Wed, 18 Mar 2020 15:19:35 -0400 Subject: [PATCH 232/454] clarification in docs (#468) --- docs/UnityConfigurationGuide.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docs/UnityConfigurationGuide.md b/docs/UnityConfigurationGuide.md index e96db03a..de691fdf 100644 --- a/docs/UnityConfigurationGuide.md +++ b/docs/UnityConfigurationGuide.md @@ -39,6 +39,10 @@ toolchain's search paths). In this file, you will list definitions and macros specific to your target. All you must do is define `UNITY_INCLUDE_CONFIG_H` and Unity will rely on `unity_config.h` for any further definitions it may need. +Unfortunately, it doesn't usually work well to just #define these things in the +test itself. These defines need to take effect where ever unity.h is included. +This would be test test, the test runner (if you're generating one), and from +unity.c when it's compiled. ## The Options From 615cf2349e700aa2aae7d166c33d340a82cc1d41 Mon Sep 17 00:00:00 2001 From: mvandervoord Date: Thu, 19 Mar 2020 09:48:40 -0400 Subject: [PATCH 233/454] Update self-test parameters --- .travis.yml | 10 +++++++--- test/.rubocop.yml | 6 ++++++ 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 315b3a7e..253a3968 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,4 +1,5 @@ -language: c +sudo: required +language: ruby c matrix: include: @@ -7,16 +8,19 @@ matrix: osx_image: xcode7.3 - os: linux dist: trusty + rvm: "2.4" compiler: gcc - os: linux - dist: trusty + dist: xenial + rvm: "2.7" compiler: clang before_install: - - if [ "$TRAVIS_OS_NAME" == "osx" ]; then rvm install 2.3 && rvm use 2.3 && ruby -v; fi - if [ "$TRAVIS_OS_NAME" == "linux" ]; then sudo apt-get install --assume-yes --quiet gcc-multilib; fi + install: - gem install rspec - gem install rubocop -v 0.57.2 + script: - cd test && rake ci diff --git a/test/.rubocop.yml b/test/.rubocop.yml index bedab006..6c9542f5 100644 --- a/test/.rubocop.yml +++ b/test/.rubocop.yml @@ -22,6 +22,12 @@ Style/NumericPredicate: Enabled: false Style/MultilineBlockChain: Enabled: false +Style/Alias: + Enabled: false +Style/EvalWithLocation: + Enabled: false +Style/MixinUsage: + Enabled: false # These are also places we diverge... but we will likely comply down the road Style/IfUnlessModifier: From 87d8de6d55e760e0433cf004f1a4f3745392257a Mon Sep 17 00:00:00 2001 From: mvandervoord Date: Thu, 19 Mar 2020 10:02:38 -0400 Subject: [PATCH 234/454] Disable osx tests because (1) they are slow and (2) the toolchain is old and crusty --- .travis.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 253a3968..d3b9a18e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,9 +3,9 @@ language: ruby c matrix: include: - - os: osx - compiler: clang - osx_image: xcode7.3 + #- os: osx + # compiler: clang + # osx_image: xcode7.3 - os: linux dist: trusty rvm: "2.4" From ff479e9aa03087a14ae8806e109f09c2870b769d Mon Sep 17 00:00:00 2001 From: Gavriil Pascalau Date: Sat, 28 Mar 2020 18:31:43 +0100 Subject: [PATCH 235/454] Fix small typo --- auto/generate_test_runner.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/auto/generate_test_runner.rb b/auto/generate_test_runner.rb index 41941a04..def615df 100644 --- a/auto/generate_test_runner.rb +++ b/auto/generate_test_runner.rb @@ -110,7 +110,7 @@ def find_tests(source) tests_and_line_numbers = [] # contains characters which will be substituted from within strings, doing - # this prevents these characters from interferring with scrubbers + # this prevents these characters from interfering with scrubbers # @ is not a valid C character, so there should be no clashes with files genuinely containing these markers substring_subs = { '{' => '@co@', '}' => '@cc@', ';' => '@ss@', '/' => '@fs@' } substring_re = Regexp.union(substring_subs.keys) From d603ccdc3b67501ef3375d347864f04e682d6547 Mon Sep 17 00:00:00 2001 From: Vitalii Shylienkov Date: Thu, 9 Apr 2020 13:58:45 +0200 Subject: [PATCH 236/454] cmake: update CMake --- CMakeLists.txt | 110 +++++++++++++++++++++++++---- cmake/templates/unity_version.h.in | 12 ++++ src/CMakeLists.txt | 22 ------ src/unity.h | 5 +- unityConfig.cmake | 1 + 5 files changed, 111 insertions(+), 39 deletions(-) create mode 100644 cmake/templates/unity_version.h.in delete mode 100644 src/CMakeLists.txt create mode 100644 unityConfig.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 08fafd9d..ecfb539f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,24 +8,108 @@ # License: MIT # # # ################################################################################### -cmake_minimum_required(VERSION 3.0 FATAL_ERROR) +cmake_minimum_required(VERSION 3.12) +project(unity + VERSION 2.5.0 + LANGUAGES C + DESCRIPTION "C Unit testing framework." +) + +# Main target ------------------------------------------------------------------ +add_library(${PROJECT_NAME} STATIC) +add_library(${PROJECT_NAME}::framework ALIAS ${PROJECT_NAME}) + +# Includes --------------------------------------------------------------------- +include(GNUInstallDirs) +include(CMakePackageConfigHelpers) + +# Configuration ---------------------------------------------------------------- +configure_file(cmake/templates/${PROJECT_NAME}_version.h.in + ${PROJECT_NAME}_version.h + @ONLY +) + +target_sources(${PROJECT_NAME} + PRIVATE + src/unity.c +) + +target_include_directories(${PROJECT_NAME} + PUBLIC + $ + $ + $ +) + +set(${PROJECT_NAME}_PUBLIC_HEADERS src/unity.h + src/unity_internals.h + ${CMAKE_CURRENT_BINARY_DIR}/unity_version.h +) -project(unity LANGUAGES C DESCRIPTION "C Unit testing framework.") +set_target_properties(${PROJECT_NAME} + PROPERTIES + C_STANDARD 11 + C_STANDARD_REQUIRED ON + C_EXTENSIONS OFF + PUBLIC_HEADER "${${PROJECT_NAME}_PUBLIC_HEADERS}" + EXPORT_NAME framework +) -add_subdirectory(src) -target_include_directories(unity - PUBLIC - "$" - "$" +target_compile_options(${PROJECT_NAME} + PRIVATE + $<$:-Wcast-align> + $<$:-Wcast-qual> + $<$:-Wconversion> + $<$:-Wexit-time-destructors> + $<$:-Wglobal-constructors> + $<$:-Wmissing-noreturn> + $<$:-Wmissing-prototypes> + $<$:-Wno-missing-braces> + $<$:-Wold-style-cast> + $<$:-Wshadow> + $<$:-Wweak-vtables> + $<$:-Waddress> + $<$:-Waggregate-return> + $<$:-Wformat-nonliteral> + $<$:-Wformat-security> + $<$:-Wformat> + $<$:-Winit-self> + $<$:-Wmissing-declarations> + $<$:-Wmissing-include-dirs> + $<$:-Wno-multichar> + $<$:-Wno-parentheses> + $<$:-Wno-type-limits> + $<$:-Wno-unused-parameter> + $<$:-Wunreachable-code> + $<$:-Wwrite-strings> + -Wpointer-arith + -Wall + -Werror +) - PRIVATE "src" +write_basic_package_version_file(${PROJECT_NAME}ConfigVersion.cmake + VERSION ${PROJECT_VERSION} + COMPATIBILITY SameMajorVersion ) -add_library(unity::framework ALIAS unity) +## Target installation +install(TARGETS ${PROJECT_NAME} + EXPORT ${PROJECT_NAME}Targets + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME} + COMPONENT library +) -install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/src/ DESTINATION src) -install(EXPORT unityConfig DESTINATION share/unityConfig/cmake) +## Target's cmake files: targets export +install(EXPORT ${PROJECT_NAME}Targets + NAMESPACE ${PROJECT_NAME}:: + DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME} +) -# This makes the project importable from the build directory -export(TARGETS unity FILE unityConfig.cmake) +## Target's cmake files: config and version config for find_package() +install(FILES ${PROJECT_NAME}Config.cmake + ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake + DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME} +) diff --git a/cmake/templates/unity_version.h.in b/cmake/templates/unity_version.h.in new file mode 100644 index 00000000..7c89e773 --- /dev/null +++ b/cmake/templates/unity_version.h.in @@ -0,0 +1,12 @@ +#ifndef UNITY_CONFIG_H +#define UNITY_CONFIG_H + +#define UNITY_VERSION_STRING "@PROJECT_VERSION@" +#define UNITY_VERSION_MAJOR @PROJECT_VERSION_MAJOR@ +#define UNITY_VERSION_MINOR @PROJECT_VERSION_MINOR@ +#define UNITY_VERSION_BUILD @PROJECT_VERSION_PATCH@ +#define UNITY_VERSION ((UNITY_VERSION_MAJOR << 16) | \ + (UNITY_VERSION_MINOR << 8) | \ + UNITY_VERSION_BUILD) + +#endif /* UNITY_CONFIG_H */ diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt deleted file mode 100644 index c747cb0a..00000000 --- a/src/CMakeLists.txt +++ /dev/null @@ -1,22 +0,0 @@ -################################################################################### -# # -# NAME: CMakeLists.txt # -# # -# AUTHOR: Mike Karlesky, Mark VanderVoord, Greg Williams. # -# WRITTEN BY: Michael Brockus. # -# # -# License: MIT # -# # -################################################################################### -cmake_minimum_required(VERSION 3.0 FATAL_ERROR) - - -add_library(unity STATIC "unity.c") - -install(TARGETS unity EXPORT unityConfig - ARCHIVE DESTINATION "${CMAKE_CURRENT_SOURCE_DIR}/${CMAKE_INSTALL_LIBDIR}" - LIBRARY DESTINATION "${CMAKE_CURRENT_SOURCE_DIR}/${CMAKE_INSTALL_LIBDIR}" - RUNTIME DESTINATION "${CMAKE_CURRENT_SOURCE_DIR}/${CMAKE_INSTALL_BINDIR}" - INCLUDES DESTINATION "${CMAKE_INSTALL_LIBDIR}") - - diff --git a/src/unity.h b/src/unity.h index 925cd4d5..6eceb8da 100644 --- a/src/unity.h +++ b/src/unity.h @@ -8,10 +8,7 @@ #define UNITY_FRAMEWORK_H #define UNITY -#define UNITY_VERSION_MAJOR 2 -#define UNITY_VERSION_MINOR 5 -#define UNITY_VERSION_BUILD 0 -#define UNITY_VERSION ((UNITY_VERSION_MAJOR << 16) | (UNITY_VERSION_MINOR << 8) | UNITY_VERSION_BUILD) +#include "unity_version.h" #ifdef __cplusplus extern "C" diff --git a/unityConfig.cmake b/unityConfig.cmake new file mode 100644 index 00000000..55410ccc --- /dev/null +++ b/unityConfig.cmake @@ -0,0 +1 @@ +include(${CMAKE_CURRENT_LIST_DIR}/unityTargets.cmake) \ No newline at end of file From 2485d49d13c0dff8f691b0a150eaad5e2c2be13c Mon Sep 17 00:00:00 2001 From: John Lindgren Date: Thu, 9 Apr 2020 13:03:16 -0400 Subject: [PATCH 237/454] Wrap UNITY_TEST_ASSERT in a do ... while(0) block This ensures that constructions like the following work correctly: if(condition) TEST_ASSERT(a); else TEST_ASSERT(b); --- src/unity_internals.h | 2 +- test/tests/test_unity_core.c | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/unity_internals.h b/src/unity_internals.h index cdf1374d..d7c2116c 100644 --- a/src/unity_internals.h +++ b/src/unity_internals.h @@ -763,7 +763,7 @@ int UnityTestMatches(void); * Test Asserts *-------------------------------------------------------*/ -#define UNITY_TEST_ASSERT(condition, line, message) if (condition) {} else {UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), (message));} +#define UNITY_TEST_ASSERT(condition, line, message) do {if (condition) {} else {UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), (message));}} while(0) #define UNITY_TEST_ASSERT_NULL(pointer, line, message) UNITY_TEST_ASSERT(((pointer) == NULL), (UNITY_LINE_TYPE)(line), (message)) #define UNITY_TEST_ASSERT_NOT_NULL(pointer, line, message) UNITY_TEST_ASSERT(((pointer) != NULL), (UNITY_LINE_TYPE)(line), (message)) #define UNITY_TEST_ASSERT_EMPTY(pointer, line, message) UNITY_TEST_ASSERT(((pointer[0]) == 0), (UNITY_LINE_TYPE)(line), (message)) diff --git a/test/tests/test_unity_core.c b/test/tests/test_unity_core.c index ba1e3d3d..d324e861 100644 --- a/test/tests/test_unity_core.c +++ b/test/tests/test_unity_core.c @@ -133,6 +133,19 @@ void testFalse(void) TEST_ASSERT_UNLESS(0); } +void testSingleStatement(void) +{ + for(int i = 0; i < 2; i++) + { + /* TEST_ASSERT_TRUE should expand to a single C statement, minus + * the semicolon. This if-else will fail to compile otherwise. */ + if(i > 0) + TEST_ASSERT_TRUE(i); + else + TEST_ASSERT_FALSE(i); + } +} + void testPreviousPass(void) { TEST_ASSERT_EQUAL_INT(0U, Unity.TestFailures); From 2a2a4d19c545aed85dfb541e8b0a5ccbe4b1deb7 Mon Sep 17 00:00:00 2001 From: Vitalii Shylienkov Date: Mon, 13 Apr 2020 12:47:07 +0200 Subject: [PATCH 238/454] meson: supports version - generate version header --- meson.build | 3 ++- src/meson.build | 9 +++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/meson.build b/meson.build index 968e5b13..33d58875 100644 --- a/meson.build +++ b/meson.build @@ -7,7 +7,8 @@ project('unity', 'c', license: 'MIT', meson_version: '>=0.53.0', - default_options: ['layout=flat', 'warning_level=3', 'werror=true', 'c_std=c11'] + default_options: ['layout=flat', 'warning_level=3', 'werror=true', 'c_std=c11'], + version: '2.5.0' ) lang = 'c' cc = meson.get_compiler(lang) diff --git a/src/meson.build b/src/meson.build index 7ede15af..19e7bd8e 100644 --- a/src/meson.build +++ b/src/meson.build @@ -4,6 +4,15 @@ # # license: MIT # +conf_data = configuration_data() +conf_data.set('PROJECT_VERSION', meson.project_version()) +conf_data.set('PROJECT_VERSION_MAJOR',meson.project_version().split('.')[0]) +conf_data.set('PROJECT_VERSION_MINOR',meson.project_version().split('.')[1]) +conf_data.set('PROJECT_VERSION_PATCH',meson.project_version().split('.')[2]) +unity_version_template = join_paths(meson.source_root(), 'cmake/templates/unity_version.h.in') +unity_version_file =configure_file(input : unity_version_template, + output : 'unity_version.h', + configuration : conf_data) unity_dir = include_directories('.') unity_lib = static_library(meson.project_name(), From b397a72e897a55bb34eaebfcf27ec65eef85dd00 Mon Sep 17 00:00:00 2001 From: Vitalii Shylienkov Date: Mon, 13 Apr 2020 13:08:18 +0200 Subject: [PATCH 239/454] cmake: get version from meson --- CMakeLists.txt | 64 +++++++++++++++++++++++++++++--------------------- 1 file changed, 37 insertions(+), 27 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ecfb539f..70de467c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,8 +10,18 @@ ################################################################################### cmake_minimum_required(VERSION 3.12) + +# Read root meson.build file and get project version from it +set(ROOT_MESON_BUILD_FILE "meson.build") +file(READ "${ROOT_MESON_BUILD_FILE}" ROOT_MESON_BUILD_CONTENT) +string(REGEX MATCH " *version: '[.0-9]+'" UNITY_VERSION "${ROOT_MESON_BUILD_CONTENT}") +if(NOT UNITY_VERSION) + message(FATAL_ERROR "Cannot define version from meson build file") +endif() +string(REGEX REPLACE " *version: '([.0-9]+)'" "\\1" UNITY_VERSION "${UNITY_VERSION}") + project(unity - VERSION 2.5.0 + VERSION ${UNITY_VERSION} LANGUAGES C DESCRIPTION "C Unit testing framework." ) @@ -58,32 +68,32 @@ set_target_properties(${PROJECT_NAME} target_compile_options(${PROJECT_NAME} PRIVATE - $<$:-Wcast-align> - $<$:-Wcast-qual> - $<$:-Wconversion> - $<$:-Wexit-time-destructors> - $<$:-Wglobal-constructors> - $<$:-Wmissing-noreturn> - $<$:-Wmissing-prototypes> - $<$:-Wno-missing-braces> - $<$:-Wold-style-cast> - $<$:-Wshadow> - $<$:-Wweak-vtables> - $<$:-Waddress> - $<$:-Waggregate-return> - $<$:-Wformat-nonliteral> - $<$:-Wformat-security> - $<$:-Wformat> - $<$:-Winit-self> - $<$:-Wmissing-declarations> - $<$:-Wmissing-include-dirs> - $<$:-Wno-multichar> - $<$:-Wno-parentheses> - $<$:-Wno-type-limits> - $<$:-Wno-unused-parameter> - $<$:-Wunreachable-code> - $<$:-Wwrite-strings> - -Wpointer-arith + $<$:-Wcast-align + -Wcast-qual + -Wconversion + -Wexit-time-destructors + -Wglobal-constructors + -Wmissing-noreturn + -Wmissing-prototypes + -Wno-missing-braces + -Wold-style-cast + -Wshadow + -Wweak-vtables> + $<$:-Waddress + -Waggregate-return + -Wformat-nonliteral + -Wformat-security + -Wformat + -Winit-self + -Wmissing-declarations + -Wmissing-include-dirs + -Wno-multichar + -Wno-parentheses + -Wno-type-limits + -Wno-unused-parameter + -Wunreachable-code + -Wwrite-strings + -Wpointer-arith> -Wall -Werror ) From a2af08c773803755e90614615fe9b649f5b242e6 Mon Sep 17 00:00:00 2001 From: Vitalii Shylienkov Date: Tue, 14 Apr 2020 11:02:24 +0200 Subject: [PATCH 240/454] project: revert UNITY_VERSION_* to unity.h --- CMakeLists.txt | 40 ++++++++++++++++++------------ cmake/templates/unity_version.h.in | 12 --------- meson.build | 3 +-- src/meson.build | 9 ------- src/unity.h | 5 +++- 5 files changed, 29 insertions(+), 40 deletions(-) delete mode 100644 cmake/templates/unity_version.h.in diff --git a/CMakeLists.txt b/CMakeLists.txt index 70de467c..3a9d8a94 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -11,17 +11,32 @@ cmake_minimum_required(VERSION 3.12) -# Read root meson.build file and get project version from it -set(ROOT_MESON_BUILD_FILE "meson.build") -file(READ "${ROOT_MESON_BUILD_FILE}" ROOT_MESON_BUILD_CONTENT) -string(REGEX MATCH " *version: '[.0-9]+'" UNITY_VERSION "${ROOT_MESON_BUILD_CONTENT}") -if(NOT UNITY_VERSION) - message(FATAL_ERROR "Cannot define version from meson build file") -endif() -string(REGEX REPLACE " *version: '([.0-9]+)'" "\\1" UNITY_VERSION "${UNITY_VERSION}") +# Read src/unity.h file and get project version from it +set(UNITY_HEADER "src/unity.h") + +file(STRINGS "${UNITY_HEADER}" UNITY_HEADER_CONTENT + REGEX "^#define UNITY_VERSION_(MAJOR|MINOR|BUILD) +[0-9]+$" +) + +set(UNITY_HEADER_VERSION_MAJOR 0) +set(UNITY_HEADER_VERSION_MINOR 0) +set(UNITY_HEADER_VERSION_BUILD 0) + +foreach(VERSION_LINE IN LISTS UNITY_HEADER_CONTENT) + foreach(VERSION_PART MAJOR MINOR BUILD) + string(CONCAT REGEX_STRING "#define UNITY_VERSION_" + "${VERSION_PART}" + " +([0-9]+)" + ) + + if(VERSION_LINE MATCHES "${REGEX_STRING}") + set(UNITY_HEADER_VERSION_${VERSION_PART} "${CMAKE_MATCH_1}") + endif() + endforeach() +endforeach() project(unity - VERSION ${UNITY_VERSION} + VERSION ${UNITY_HEADER_VERSION_MAJOR}.${UNITY_HEADER_VERSION_MINOR}.${UNITY_HEADER_VERSION_BUILD} LANGUAGES C DESCRIPTION "C Unit testing framework." ) @@ -34,12 +49,6 @@ add_library(${PROJECT_NAME}::framework ALIAS ${PROJECT_NAME}) include(GNUInstallDirs) include(CMakePackageConfigHelpers) -# Configuration ---------------------------------------------------------------- -configure_file(cmake/templates/${PROJECT_NAME}_version.h.in - ${PROJECT_NAME}_version.h - @ONLY -) - target_sources(${PROJECT_NAME} PRIVATE src/unity.c @@ -54,7 +63,6 @@ target_include_directories(${PROJECT_NAME} set(${PROJECT_NAME}_PUBLIC_HEADERS src/unity.h src/unity_internals.h - ${CMAKE_CURRENT_BINARY_DIR}/unity_version.h ) set_target_properties(${PROJECT_NAME} diff --git a/cmake/templates/unity_version.h.in b/cmake/templates/unity_version.h.in deleted file mode 100644 index 7c89e773..00000000 --- a/cmake/templates/unity_version.h.in +++ /dev/null @@ -1,12 +0,0 @@ -#ifndef UNITY_CONFIG_H -#define UNITY_CONFIG_H - -#define UNITY_VERSION_STRING "@PROJECT_VERSION@" -#define UNITY_VERSION_MAJOR @PROJECT_VERSION_MAJOR@ -#define UNITY_VERSION_MINOR @PROJECT_VERSION_MINOR@ -#define UNITY_VERSION_BUILD @PROJECT_VERSION_PATCH@ -#define UNITY_VERSION ((UNITY_VERSION_MAJOR << 16) | \ - (UNITY_VERSION_MINOR << 8) | \ - UNITY_VERSION_BUILD) - -#endif /* UNITY_CONFIG_H */ diff --git a/meson.build b/meson.build index 33d58875..968e5b13 100644 --- a/meson.build +++ b/meson.build @@ -7,8 +7,7 @@ project('unity', 'c', license: 'MIT', meson_version: '>=0.53.0', - default_options: ['layout=flat', 'warning_level=3', 'werror=true', 'c_std=c11'], - version: '2.5.0' + default_options: ['layout=flat', 'warning_level=3', 'werror=true', 'c_std=c11'] ) lang = 'c' cc = meson.get_compiler(lang) diff --git a/src/meson.build b/src/meson.build index 19e7bd8e..7ede15af 100644 --- a/src/meson.build +++ b/src/meson.build @@ -4,15 +4,6 @@ # # license: MIT # -conf_data = configuration_data() -conf_data.set('PROJECT_VERSION', meson.project_version()) -conf_data.set('PROJECT_VERSION_MAJOR',meson.project_version().split('.')[0]) -conf_data.set('PROJECT_VERSION_MINOR',meson.project_version().split('.')[1]) -conf_data.set('PROJECT_VERSION_PATCH',meson.project_version().split('.')[2]) -unity_version_template = join_paths(meson.source_root(), 'cmake/templates/unity_version.h.in') -unity_version_file =configure_file(input : unity_version_template, - output : 'unity_version.h', - configuration : conf_data) unity_dir = include_directories('.') unity_lib = static_library(meson.project_name(), diff --git a/src/unity.h b/src/unity.h index 6eceb8da..925cd4d5 100644 --- a/src/unity.h +++ b/src/unity.h @@ -8,7 +8,10 @@ #define UNITY_FRAMEWORK_H #define UNITY -#include "unity_version.h" +#define UNITY_VERSION_MAJOR 2 +#define UNITY_VERSION_MINOR 5 +#define UNITY_VERSION_BUILD 0 +#define UNITY_VERSION ((UNITY_VERSION_MAJOR << 16) | (UNITY_VERSION_MINOR << 8) | UNITY_VERSION_BUILD) #ifdef __cplusplus extern "C" From ec31dfacad352fdbc57ce998994ba136ee2ba5bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alari=20=C3=95is?= Date: Sat, 25 Apr 2020 07:14:21 +0300 Subject: [PATCH 241/454] Fixed typos in documentation --- docs/UnityAssertionsReference.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/UnityAssertionsReference.md b/docs/UnityAssertionsReference.md index 58ceb6fa..0957bcf6 100644 --- a/docs/UnityAssertionsReference.md +++ b/docs/UnityAssertionsReference.md @@ -356,9 +356,9 @@ all the various sizes of ints, as for the equality assertions. Some examples: ##### `TEST_ASSERT_GREATER_OR_EQUAL_INT16 (threshold, actual)` -##### `TEST_ASSERT_SMALLER_THAN_INT32 (threshold, actual)` +##### `TEST_ASSERT_LESS_THAN_INT32 (threshold, actual)` -##### `TEST_ASSERT_SMALL_OR_EQUAL_UINT (threshold, actual)` +##### `TEST_ASSERT_LESS_OR_EQUAL_UINT (threshold, actual)` ##### `TEST_ASSERT_NOT_EQUAL_UINT8 (threshold, actual)` From cdfb7e092ccb3cb1080486dd0d78bc713b7317da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alari=20=C3=95is?= Date: Fri, 1 May 2020 08:18:09 +0300 Subject: [PATCH 242/454] More elegant RUN_TEST macro --- src/unity_internals.h | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/unity_internals.h b/src/unity_internals.h index d7c2116c..3ba153b4 100644 --- a/src/unity_internals.h +++ b/src/unity_internals.h @@ -701,11 +701,8 @@ extern const char UnityStrErrShorthand[]; #endif #endif #ifdef UNITY_SUPPORT_VARIADIC_MACROS -#define RUN_TEST(...) UnityDefaultTestRun(RUN_TEST_FIRST(__VA_ARGS__), RUN_TEST_SECOND(__VA_ARGS__)) -#define RUN_TEST_FIRST(...) RUN_TEST_FIRST_HELPER(__VA_ARGS__, throwaway) -#define RUN_TEST_FIRST_HELPER(first, ...) (first), #first -#define RUN_TEST_SECOND(...) RUN_TEST_SECOND_HELPER(__VA_ARGS__, __LINE__, throwaway) -#define RUN_TEST_SECOND_HELPER(first, second, ...) (second) +#define RUN_TEST(...) RUN_TEST_AT_LINE(__VA_ARGS__, __LINE__) +#define RUN_TEST_AT_LINE(func, line, ...) UnityDefaultTestRun(func, #func, line) #endif #endif From fd80d514ee6b17a54bee29eaa5225ca25eef5ea9 Mon Sep 17 00:00:00 2001 From: Mark VanderVoord Date: Sun, 3 May 2020 08:57:21 -0400 Subject: [PATCH 243/454] Revert "More elegant RUN_TEST macro" This reverts commit cdfb7e092ccb3cb1080486dd0d78bc713b7317da. --- src/unity_internals.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/unity_internals.h b/src/unity_internals.h index 3ba153b4..d7c2116c 100644 --- a/src/unity_internals.h +++ b/src/unity_internals.h @@ -701,8 +701,11 @@ extern const char UnityStrErrShorthand[]; #endif #endif #ifdef UNITY_SUPPORT_VARIADIC_MACROS -#define RUN_TEST(...) RUN_TEST_AT_LINE(__VA_ARGS__, __LINE__) -#define RUN_TEST_AT_LINE(func, line, ...) UnityDefaultTestRun(func, #func, line) +#define RUN_TEST(...) UnityDefaultTestRun(RUN_TEST_FIRST(__VA_ARGS__), RUN_TEST_SECOND(__VA_ARGS__)) +#define RUN_TEST_FIRST(...) RUN_TEST_FIRST_HELPER(__VA_ARGS__, throwaway) +#define RUN_TEST_FIRST_HELPER(first, ...) (first), #first +#define RUN_TEST_SECOND(...) RUN_TEST_SECOND_HELPER(__VA_ARGS__, __LINE__, throwaway) +#define RUN_TEST_SECOND_HELPER(first, second, ...) (second) #endif #endif From cf949f45ca6d172a177b00da21310607b97bc7a7 Mon Sep 17 00:00:00 2001 From: Mark VanderVoord Date: Sun, 3 May 2020 16:03:07 -0400 Subject: [PATCH 244/454] Bump Version --- src/unity.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/unity.h b/src/unity.h index 925cd4d5..8caa7852 100644 --- a/src/unity.h +++ b/src/unity.h @@ -10,7 +10,7 @@ #define UNITY_VERSION_MAJOR 2 #define UNITY_VERSION_MINOR 5 -#define UNITY_VERSION_BUILD 0 +#define UNITY_VERSION_BUILD 1 #define UNITY_VERSION ((UNITY_VERSION_MAJOR << 16) | (UNITY_VERSION_MINOR << 8) | UNITY_VERSION_BUILD) #ifdef __cplusplus From 97f6d5525654ecddd97c12f1881ac17c4db39ebc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alari=20=C3=95is?= Date: Mon, 4 May 2020 08:20:19 +0300 Subject: [PATCH 245/454] c99 support for new RUN_TEST macro --- src/unity_internals.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/unity_internals.h b/src/unity_internals.h index 3ba153b4..705c6121 100644 --- a/src/unity_internals.h +++ b/src/unity_internals.h @@ -701,7 +701,7 @@ extern const char UnityStrErrShorthand[]; #endif #endif #ifdef UNITY_SUPPORT_VARIADIC_MACROS -#define RUN_TEST(...) RUN_TEST_AT_LINE(__VA_ARGS__, __LINE__) +#define RUN_TEST(...) RUN_TEST_AT_LINE(__VA_ARGS__, __LINE__, throwaway) #define RUN_TEST_AT_LINE(func, line, ...) UnityDefaultTestRun(func, #func, line) #endif #endif From dcb30731f878499241f37f586e3da20265f01a6b Mon Sep 17 00:00:00 2001 From: Jakob Olesen Date: Mon, 4 May 2020 20:34:45 +0200 Subject: [PATCH 246/454] Fixed suiteTearDown not matching prototype Fixed suiteTearDown to match prototype in unity.h --- auto/generate_test_runner.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/auto/generate_test_runner.rb b/auto/generate_test_runner.rb index def615df..faa8f042 100644 --- a/auto/generate_test_runner.rb +++ b/auto/generate_test_runner.rb @@ -206,7 +206,7 @@ def find_setup_and_teardown(source) @options[:has_setup] = source =~ /void\s+#{@options[:setup_name]}\s*\(/ @options[:has_teardown] = source =~ /void\s+#{@options[:teardown_name]}\s*\(/ @options[:has_suite_setup] ||= (source =~ /void\s+suiteSetUp\s*\(/) - @options[:has_suite_teardown] ||= (source =~ /void\s+suiteTearDown\s*\(/) + @options[:has_suite_teardown] ||= (source =~ /int\s+suiteTearDown\s*\(int\s+([a-zA-Z0-9_])+\s*\)/) end def create_header(output, mocks, testfile_includes = []) From f5ff3504b50ca524e9b431ba45fd36ae2735fac6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Draszik?= Date: Mon, 25 May 2020 07:14:14 +0100 Subject: [PATCH 247/454] auto/run_test: fix Wsign-compare warning MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Compiling a source base / test with Wsign-compare enabled, gives the following warning: build/test/runners/test_system_runner.c: In function ‘run_test’: build/test/runners/test_system_runner.c:62:35: warning: conversion to ‘UNITY_UINT’ {aka ‘long unsigned int’} from ‘int’ may change the sign of the result [-Wsign-conversion] 62 | Unity.CurrentTestLineNumber = line_num; | ^~~~~~~~ Fix by updating the type in the function declaration. Signed-off-by: André Draszik --- auto/run_test.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/auto/run_test.erb b/auto/run_test.erb index cb7f2b50..f91b5669 100644 --- a/auto/run_test.erb +++ b/auto/run_test.erb @@ -1,5 +1,5 @@ /*=======Test Runner Used To Run Each Test=====*/ -static void run_test(UnityTestFunction func, const char* name, int line_num) +static void run_test(UnityTestFunction func, const char* name, UNITY_LINE_TYPE line_num) { Unity.CurrentTestName = name; Unity.CurrentTestLineNumber = line_num; From 9760c4f14fdf4b0089991cccc30b414c12480a57 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Draszik?= Date: Mon, 25 May 2020 07:48:16 +0100 Subject: [PATCH 248/454] unity: fix Wswitch-enum warning MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Compiling a source base / test with Wswitch-enum enabled, gives the following warning: ../src/unity.c: In function ‘UnityAssertFloatSpecial’: ../src/unity.c:1092:5: warning: enumeration value ‘UNITY_FLOAT_INVALID_TRAIT’ not handled in switch [-Wswitch-enum] 1092 | switch (style) | ^~~~~~ Fix by adding the missing value to the default (unhandled) case. Signed-off-by: André Draszik --- src/unity.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/unity.c b/src/unity.c index ffa5cf0d..be6eaf72 100644 --- a/src/unity.c +++ b/src/unity.c @@ -1001,6 +1001,7 @@ void UnityAssertFloatSpecial(const UNITY_FLOAT actual, is_trait = !isinf(actual) && !isnan(actual); break; + case UNITY_FLOAT_INVALID_TRAIT: default: trait_index = 0; trait_names[0] = UnityStrInvalidFloatTrait; @@ -1141,6 +1142,7 @@ void UnityAssertDoubleSpecial(const UNITY_DOUBLE actual, is_trait = !isinf(actual) && !isnan(actual); break; + case UNITY_FLOAT_INVALID_TRAIT: default: trait_index = 0; trait_names[0] = UnityStrInvalidFloatTrait; From a6a4e9766dad5d35a9a03cf508a92b11616f1112 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Draszik?= Date: Mon, 25 May 2020 15:32:16 +0100 Subject: [PATCH 249/454] unity: annotate noreturn APIs (fix Wsuggest-attribute=noreturn warnings) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit GCC (& Clang) have the notion of pure and const functions [1], where those attributes are intended to help the optimiser. Annotate a few APIs here with the appropriate key words, which also fixes Wsuggest-attribute=noreturn warning, which a source base might have enabled: Compiling unity.c... .../src/unity.c: In function ‘UnityFail’: .../src/unity.c:1759:6: warning: function might be candidate for attribute ‘noreturn’ [-Wsuggest-attribute=noreturn] 1759 | void UnityFail(const char* msg, const UNITY_LINE_TYPE line) | ^~~~~~~~~ .../src/unity.c: In function ‘UnityIgnore’: .../src/unity.c:1796:6: warning: function might be candidate for attribute ‘noreturn’ [-Wsuggest-attribute=noreturn] 1796 | void UnityIgnore(const char* msg, const UNITY_LINE_TYPE line) | ^~~~~~~~~~~ [1] https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html Signed-off-by: André Draszik --- src/unity_internals.h | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/unity_internals.h b/src/unity_internals.h index 705c6121..09b7eda4 100644 --- a/src/unity_internals.h +++ b/src/unity_internals.h @@ -40,6 +40,12 @@ #include #endif +#if defined __GNUC__ +# define UNITY_FUNCTION_ATTR(a) __attribute__((a)) +#else +# define UNITY_FUNCTION_ATTR(a) /* ignore */ +#endif + /*------------------------------------------------------- * Guess Widths If Not Specified *-------------------------------------------------------*/ @@ -611,8 +617,8 @@ void UnityAssertNumbersArrayWithin(const UNITY_UINT delta, const UNITY_DISPLAY_STYLE_T style, const UNITY_FLAGS_T flags); -void UnityFail(const char* message, const UNITY_LINE_TYPE line); -void UnityIgnore(const char* message, const UNITY_LINE_TYPE line); +void UnityFail(const char* message, const UNITY_LINE_TYPE line) UNITY_FUNCTION_ATTR(noreturn); +void UnityIgnore(const char* message, const UNITY_LINE_TYPE line) UNITY_FUNCTION_ATTR(noreturn); void UnityMessage(const char* message, const UNITY_LINE_TYPE line); #ifndef UNITY_EXCLUDE_FLOAT From b4b1994bd74f7ed9aaeb0233906294b7ba601fb3 Mon Sep 17 00:00:00 2001 From: Connor Newton Date: Tue, 26 May 2020 12:52:02 +0100 Subject: [PATCH 250/454] Fix TEST_ASSERT_BIT(S)_HIGH testing only lower 32-bits The high/low bits masks for TEST_ASSERT_BIT(S)_HIGH/LOW are created by casting 0/-1 to UNITY_UINT32. This isn't OK on 64-bit platforms as it results in a high bits mask of 0x00000000ffffffff instead of 0xffffffffffffffff. Cast 0/-1 to UNITY_UINT instead. --- src/unity.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/unity.h b/src/unity.h index 8caa7852..7d8c7116 100644 --- a/src/unity.h +++ b/src/unity.h @@ -150,10 +150,10 @@ void verifyTest(void); #define TEST_ASSERT_EQUAL_HEX64(expected, actual) UNITY_TEST_ASSERT_EQUAL_HEX64((expected), (actual), __LINE__, NULL) #define TEST_ASSERT_EQUAL_CHAR(expected, actual) UNITY_TEST_ASSERT_EQUAL_CHAR((expected), (actual), __LINE__, NULL) #define TEST_ASSERT_BITS(mask, expected, actual) UNITY_TEST_ASSERT_BITS((mask), (expected), (actual), __LINE__, NULL) -#define TEST_ASSERT_BITS_HIGH(mask, actual) UNITY_TEST_ASSERT_BITS((mask), (UNITY_UINT32)(-1), (actual), __LINE__, NULL) -#define TEST_ASSERT_BITS_LOW(mask, actual) UNITY_TEST_ASSERT_BITS((mask), (UNITY_UINT32)(0), (actual), __LINE__, NULL) -#define TEST_ASSERT_BIT_HIGH(bit, actual) UNITY_TEST_ASSERT_BITS(((UNITY_UINT32)1 << (bit)), (UNITY_UINT32)(-1), (actual), __LINE__, NULL) -#define TEST_ASSERT_BIT_LOW(bit, actual) UNITY_TEST_ASSERT_BITS(((UNITY_UINT32)1 << (bit)), (UNITY_UINT32)(0), (actual), __LINE__, NULL) +#define TEST_ASSERT_BITS_HIGH(mask, actual) UNITY_TEST_ASSERT_BITS((mask), (UNITY_UINT)(-1), (actual), __LINE__, NULL) +#define TEST_ASSERT_BITS_LOW(mask, actual) UNITY_TEST_ASSERT_BITS((mask), (UNITY_UINT)(0), (actual), __LINE__, NULL) +#define TEST_ASSERT_BIT_HIGH(bit, actual) UNITY_TEST_ASSERT_BITS(((UNITY_UINT)1 << (bit)), (UNITY_UINT)(-1), (actual), __LINE__, NULL) +#define TEST_ASSERT_BIT_LOW(bit, actual) UNITY_TEST_ASSERT_BITS(((UNITY_UINT)1 << (bit)), (UNITY_UINT)(0), (actual), __LINE__, NULL) /* Integer Not Equal To (of all sizes) */ #define TEST_ASSERT_NOT_EQUAL_INT(threshold, actual) UNITY_TEST_ASSERT_NOT_EQUAL_INT((threshold), (actual), __LINE__, NULL) From 8bbfe1f5ac4aa3d2333e0fbacb3cbbd2f9f9a5fc Mon Sep 17 00:00:00 2001 From: Alessio Centazzo Date: Sat, 6 Jun 2020 08:07:57 -0700 Subject: [PATCH 251/454] Fix warning from issue #507 UnityFail() and UnityIgnore had the noreturn attribute with long jumps disabled --- src/unity_internals.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/unity_internals.h b/src/unity_internals.h index 09b7eda4..ffb69a9e 100644 --- a/src/unity_internals.h +++ b/src/unity_internals.h @@ -617,8 +617,14 @@ void UnityAssertNumbersArrayWithin(const UNITY_UINT delta, const UNITY_DISPLAY_STYLE_T style, const UNITY_FLAGS_T flags); +#ifndef UNITY_EXCLUDE_SETJMP_H void UnityFail(const char* message, const UNITY_LINE_TYPE line) UNITY_FUNCTION_ATTR(noreturn); void UnityIgnore(const char* message, const UNITY_LINE_TYPE line) UNITY_FUNCTION_ATTR(noreturn); +#else +void UnityFail(const char* message, const UNITY_LINE_TYPE line); +void UnityIgnore(const char* message, const UNITY_LINE_TYPE line); +#endif + void UnityMessage(const char* message, const UNITY_LINE_TYPE line); #ifndef UNITY_EXCLUDE_FLOAT From 777ad17420378609fcf686c5fb0b5d939cf048b1 Mon Sep 17 00:00:00 2001 From: Carson Holloway Date: Sat, 18 Jul 2020 21:52:00 +1000 Subject: [PATCH 252/454] Added MSVC options to CMakeLists.txt. --- CMakeLists.txt | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3a9d8a94..7105ad6f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -38,8 +38,7 @@ endforeach() project(unity VERSION ${UNITY_HEADER_VERSION_MAJOR}.${UNITY_HEADER_VERSION_MINOR}.${UNITY_HEADER_VERSION_BUILD} LANGUAGES C - DESCRIPTION "C Unit testing framework." -) + DESCRIPTION "C Unit testing framework.") # Main target ------------------------------------------------------------------ add_library(${PROJECT_NAME} STATIC) @@ -86,7 +85,9 @@ target_compile_options(${PROJECT_NAME} -Wno-missing-braces -Wold-style-cast -Wshadow - -Wweak-vtables> + -Wweak-vtables + -Werror + -Wall> $<$:-Waddress -Waggregate-return -Wformat-nonliteral @@ -101,9 +102,10 @@ target_compile_options(${PROJECT_NAME} -Wno-unused-parameter -Wunreachable-code -Wwrite-strings - -Wpointer-arith> - -Wall - -Werror + -Wpointer-arith + -Werror + -Wall> + $<$:/Wall> ) write_basic_package_version_file(${PROJECT_NAME}ConfigVersion.cmake From 6fecc8eb38ebcd2a8ecd42f2988b97a7957e1945 Mon Sep 17 00:00:00 2001 From: Carson Holloway Date: Sat, 18 Jul 2020 21:52:00 +1000 Subject: [PATCH 253/454] Added MSVC options to CMakeLists.txt. --- CMakeLists.txt | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3a9d8a94..4af2b381 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -86,7 +86,9 @@ target_compile_options(${PROJECT_NAME} -Wno-missing-braces -Wold-style-cast -Wshadow - -Wweak-vtables> + -Wweak-vtables + -Werror + -Wall> $<$:-Waddress -Waggregate-return -Wformat-nonliteral @@ -101,9 +103,10 @@ target_compile_options(${PROJECT_NAME} -Wno-unused-parameter -Wunreachable-code -Wwrite-strings - -Wpointer-arith> - -Wall - -Werror + -Wpointer-arith + -Werror + -Wall> + $<$:/Wall> ) write_basic_package_version_file(${PROJECT_NAME}ConfigVersion.cmake From 52d5f59b72219ca61e0fbcc9c237a745edc1dd0d Mon Sep 17 00:00:00 2001 From: Michael Brockus <55331536+michaelbrockus@users.noreply.github.com> Date: Wed, 5 Aug 2020 21:13:06 -0700 Subject: [PATCH 254/454] Update meson.build --- meson.build | 36 +----------------------------------- 1 file changed, 1 insertion(+), 35 deletions(-) diff --git a/meson.build b/meson.build index 968e5b13..f5c5cfaa 100644 --- a/meson.build +++ b/meson.build @@ -7,42 +7,8 @@ project('unity', 'c', license: 'MIT', meson_version: '>=0.53.0', - default_options: ['layout=flat', 'warning_level=3', 'werror=true', 'c_std=c11'] + default_options: ['werror=true', 'c_std=c11'] ) -lang = 'c' -cc = meson.get_compiler(lang) -# -# Meson: Add compiler flags -if cc.get_id() == 'clang' - add_project_arguments(cc.get_supported_arguments( - [ - '-Wexit-time-destructors', - '-Wglobal-constructors', - '-Wmissing-prototypes', - '-Wmissing-noreturn', - '-Wno-missing-braces', - '-Wold-style-cast', '-Wpointer-arith', '-Wweak-vtables', - '-Wcast-align', '-Wconversion', '-Wcast-qual', '-Wshadow' - ] - ), language: lang) -endif - -if cc.get_argument_syntax() == 'gcc' - add_project_arguments(cc.get_supported_arguments( - [ - '-Wformat', '-Waddress', '-Winit-self', '-Wno-multichar', - '-Wpointer-arith' , '-Wwrite-strings' , - '-Wno-parentheses' , '-Wno-type-limits' , - '-Wformat-security' , '-Wunreachable-code' , - '-Waggregate-return' , '-Wformat-nonliteral' , - '-Wmissing-declarations', '-Wmissing-include-dirs' , - '-Wno-unused-parameter' - ] - ), language: lang) -endif - -# -# Sub directory to project source code subdir('src') unity_dep = declare_dependency(link_with: unity_lib, include_directories: unity_dir) From 62d0e7d68ebe51240371c06b503d5d983ec0cd1a Mon Sep 17 00:00:00 2001 From: Michael Brockus <55331536+michaelbrockus@users.noreply.github.com> Date: Wed, 5 Aug 2020 21:15:37 -0700 Subject: [PATCH 255/454] Update meson.build --- src/meson.build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/meson.build b/src/meson.build index 7ede15af..1c7b426f 100644 --- a/src/meson.build +++ b/src/meson.build @@ -7,5 +7,5 @@ unity_dir = include_directories('.') unity_lib = static_library(meson.project_name(), - sources: ['unity.c'], + files('unity.c'), include_directories: unity_dir) From c3afe99a77b3ccd865f2768b18c038ec9600b56a Mon Sep 17 00:00:00 2001 From: Fabian Weik Date: Thu, 27 Aug 2020 13:21:45 +0200 Subject: [PATCH 256/454] parse mock files correctly --- auto/generate_test_runner.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/auto/generate_test_runner.rb b/auto/generate_test_runner.rb index faa8f042..ea0b2c4a 100644 --- a/auto/generate_test_runner.rb +++ b/auto/generate_test_runner.rb @@ -197,7 +197,7 @@ def find_mocks(includes) mock_headers = [] includes.each do |include_path| include_file = File.basename(include_path) - mock_headers << include_path if include_file =~ /^#{@options[:mock_prefix]}.*#{@options[:mock_suffix]}$/i + mock_headers << include_path if include_file =~ /^#{@options[:mock_prefix]}.*#{@options[:mock_suffix]}\.h$/i end mock_headers end From 76c3755fe37c84fd60f0478a4cf6c6f4e0468519 Mon Sep 17 00:00:00 2001 From: Julien PEYREGNE Date: Mon, 7 Sep 2020 10:37:26 +0200 Subject: [PATCH 257/454] Add guard TEST on test module template With a test file guarded we can include this file on IDE project (MPLAB X in my case) and compile without excluding test files. Excluding test files on MPLAB X disable autocompletion and function navigation. --- auto/generate_module.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/auto/generate_module.rb b/auto/generate_module.rb index 3d9ee8d6..f7e1598f 100644 --- a/auto/generate_module.rb +++ b/auto/generate_module.rb @@ -13,7 +13,9 @@ require 'pathname' # TEMPLATE_TST -TEMPLATE_TST ||= '#include "unity.h" +TEMPLATE_TST ||= '#ifdef TEST + +#include "unity.h" %2$s#include "%1$s.h" @@ -29,6 +31,8 @@ { TEST_IGNORE_MESSAGE("Need to Implement %1$s"); } + +#endif // TEST '.freeze # TEMPLATE_SRC From 723b9fee53772fa2f820f2915d8feadc5d277a02 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20S=C5=82awomir=20K=C5=91m=C5=B1ves?= <43279628+sardior@users.noreply.github.com> Date: Thu, 8 Oct 2020 00:55:47 +0200 Subject: [PATCH 258/454] Update unity.c UNITY_EXCLUDE_DETAILS caused a compile error here due to UNITY_DETAIL{1,2}_NAME declaration already being skipped. --- src/unity.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/unity.c b/src/unity.c index be6eaf72..fef1d57c 100644 --- a/src/unity.c +++ b/src/unity.c @@ -67,9 +67,10 @@ static const char PROGMEM UnityStrBreaker[] = "------------------ static const char PROGMEM UnityStrResultsTests[] = " Tests "; static const char PROGMEM UnityStrResultsFailures[] = " Failures "; static const char PROGMEM UnityStrResultsIgnored[] = " Ignored "; +#ifndef UNITY_EXCLUDE_DETAILS static const char PROGMEM UnityStrDetail1Name[] = UNITY_DETAIL1_NAME " "; static const char PROGMEM UnityStrDetail2Name[] = " " UNITY_DETAIL2_NAME " "; - +#endif /*----------------------------------------------- * Pretty Printers & Test Result Output Handlers *-----------------------------------------------*/ From 418c1635f2f1bcd353b6fce23a16594c914047b8 Mon Sep 17 00:00:00 2001 From: Carson Holloway Date: Sun, 20 Dec 2020 12:58:11 +1100 Subject: [PATCH 259/454] Added option to compile fixture and memory extensions in CMakeLists.txt --- CMakeLists.txt | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4af2b381..55d795cb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -41,6 +41,22 @@ project(unity DESCRIPTION "C Unit testing framework." ) +# Options to Build With Extras ------------------------------------------------- +option(UNITY_EXTENSION_FIXTURE "Compiles Unity with the \"fixture\" extension." OFF) +option(UNITY_EXTENSION_MEMORY "Compiles Unity with the \"memory\" extension." OFF) + +# Fixture is a dependant of memory +set(UNITY_EXTENSION_FIXTURE_ENABLED ${UNITY_EXTENSION_FIXTURE}) +set(UNITY_EXTENSION_MEMORY_ENABLED $,$>) + +if(${UNITY_EXTENSION_FIXTURE}) + message(STATUS "Unity: Bulding with the fixture extension.") +endif() + +if(${UNITY_EXTENSION_MEMORY}) + message(STATUS "Unity: Bulding with the memory extension.") +endif() + # Main target ------------------------------------------------------------------ add_library(${PROJECT_NAME} STATIC) add_library(${PROJECT_NAME}::framework ALIAS ${PROJECT_NAME}) @@ -52,6 +68,8 @@ include(CMakePackageConfigHelpers) target_sources(${PROJECT_NAME} PRIVATE src/unity.c + $<$:extras/fixture/src/unity_fixture.c> + $<$:extras/memory/src/unity_memory.c> ) target_include_directories(${PROJECT_NAME} @@ -59,10 +77,17 @@ target_include_directories(${PROJECT_NAME} $ $ $ + $:${CMAKE_CURRENT_SOURCE_DIR}/extras/memory/src>> + $:${CMAKE_CURRENT_SOURCE_DIR}/extras/fixture/src>> ) -set(${PROJECT_NAME}_PUBLIC_HEADERS src/unity.h - src/unity_internals.h +set(${PROJECT_NAME}_PUBLIC_HEADERS + src/unity.h + src/unity_internals.h + $<$:extras/fixture/src/unity_fixture.h + extras/fixture/src/unity_fixture_internals.h> + $<$:extras/memory/src/unity_memory.h + extras/memory/src/unity_memory_internals.h> ) set_target_properties(${PROJECT_NAME} From 53e1449f898e255a09ee8400de2573d9b4fe1d06 Mon Sep 17 00:00:00 2001 From: Carson Holloway Date: Fri, 8 Jan 2021 10:18:37 +1000 Subject: [PATCH 260/454] Fixed CMake install when compiled with extensions This is a fix from the change I made in `commit 418c1635f2f1bcd353b6fce23a16594c914047b8` where I added options to compile unity with the `fixture` and `memory` extensions: In that version, Unity had been able to build, but there were some issues when trying to install it. Namely, the CMake generator expressions were not evaluated correctly, and it would try to install with a path that had un-expanded generator commands in it, which would obviously fail and throw an error. I've got a feeling that this is a bug with CMake, but for now the workaround that worked in [this stackoverflow post](https://stackoverflow.com/questions/51541678/nested-cmake-generator-expressions-are-only-partially-evaluated) seemed to work here, as well. Another issue with that commit was that it tried to include a `unity_memory_internals.h` file, which did not exist. This has also been resolved. --- CMakeLists.txt | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 55d795cb..3a16cdcc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -45,9 +45,8 @@ project(unity option(UNITY_EXTENSION_FIXTURE "Compiles Unity with the \"fixture\" extension." OFF) option(UNITY_EXTENSION_MEMORY "Compiles Unity with the \"memory\" extension." OFF) -# Fixture is a dependant of memory -set(UNITY_EXTENSION_FIXTURE_ENABLED ${UNITY_EXTENSION_FIXTURE}) -set(UNITY_EXTENSION_MEMORY_ENABLED $,$>) +set(UNITY_EXTENSION_FIXTURE_ENABLED $) +set(UNITY_EXTENSION_MEMORY_ENABLED $>) if(${UNITY_EXTENSION_FIXTURE}) message(STATUS "Unity: Bulding with the fixture extension.") @@ -84,10 +83,9 @@ target_include_directories(${PROJECT_NAME} set(${PROJECT_NAME}_PUBLIC_HEADERS src/unity.h src/unity_internals.h - $<$:extras/fixture/src/unity_fixture.h - extras/fixture/src/unity_fixture_internals.h> - $<$:extras/memory/src/unity_memory.h - extras/memory/src/unity_memory_internals.h> + $<$:${CMAKE_CURRENT_SOURCE_DIR}/extras/fixture/src/unity_fixture.h> + $<$:${CMAKE_CURRENT_SOURCE_DIR}/extras/fixture/src/unity_fixture_internals.h> + $<$:${CMAKE_CURRENT_SOURCE_DIR}/extras/memory/src/unity_memory.h> ) set_target_properties(${PROJECT_NAME} From ffb51ecb7e30c62a8439ef893fb40ed63d51b664 Mon Sep 17 00:00:00 2001 From: Mark VanderVoord Date: Sat, 16 Jan 2021 20:05:20 -0500 Subject: [PATCH 261/454] Switch from Travis to Github Actions. Update year in docs. --- .github/workflows/main.yml | 41 ++++++++++++++++++++++++++++++++++++++ .travis.yml | 26 ------------------------ LICENSE.txt | 2 +- README.md | 17 ++++++++++++---- src/unity.c | 2 +- src/unity.h | 2 +- src/unity_internals.h | 2 +- 7 files changed, 58 insertions(+), 34 deletions(-) create mode 100644 .github/workflows/main.yml delete mode 100644 .travis.yml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 00000000..9807cbba --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,41 @@ +--- +# Continuous Integration Workflow: Test case suite run + validation build check +name: CI + +# Controls when the action will run. +# Triggers the workflow on push or pull request events but only for the master branch +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +jobs: + # Job: Unit test suite + unit-tests: + name: "Unit Tests" + runs-on: ubuntu-latest + steps: + # Install Ruby Testing Tools + - name: Setup Ruby Testing Tools + run: | + gem install rspec + gem install rubocop -v 0.57.2 + + # Run Tests + - name: Run All Unit Tests + run: | + cd test && rake ci + + # Slack notification + - uses: 8398a7/action-slack@v3 + with: + icon_emoji: ':octocat:' + status: ${{ job.status }} + # Github Actions limit visibility into renamed jobs; explicit job names here solve this limitation + job_name: "Unit Tests" + fields: repo,author,eventName,workflow,job + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_CI_CHANNEL_WEBHOOK }} + if: always() # Pick up events even if the job fails or is canceled. diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index d3b9a18e..00000000 --- a/.travis.yml +++ /dev/null @@ -1,26 +0,0 @@ -sudo: required -language: ruby c - -matrix: - include: - #- os: osx - # compiler: clang - # osx_image: xcode7.3 - - os: linux - dist: trusty - rvm: "2.4" - compiler: gcc - - os: linux - dist: xenial - rvm: "2.7" - compiler: clang - -before_install: - - if [ "$TRAVIS_OS_NAME" == "linux" ]; then sudo apt-get install --assume-yes --quiet gcc-multilib; fi - -install: - - gem install rspec - - gem install rubocop -v 0.57.2 - -script: - - cd test && rake ci diff --git a/LICENSE.txt b/LICENSE.txt index d66fba53..b9a329dd 100644 --- a/LICENSE.txt +++ b/LICENSE.txt @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2007-14 Mike Karlesky, Mark VanderVoord, Greg Williams +Copyright (c) 2007-21 Mike Karlesky, Mark VanderVoord, Greg Williams Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md index e6e7ea2d..cab2de39 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,17 @@ -Unity Test API -============== +Unity Test ![CI](https://github.com/ThrowTheSwitch/Unity/workflows/CI/badge.svg) +========== +__Copyright (c) 2007 - 2021 Unity Project by Mike Karlesky, Mark VanderVoord, and Greg Williams__ -[![Unity Build Status](https://api.travis-ci.org/ThrowTheSwitch/Unity.png?branch=master)](https://travis-ci.org/ThrowTheSwitch/Unity) -__Copyright (c) 2007 - 2020 Unity Project by Mike Karlesky, Mark VanderVoord, and Greg Williams__ +Welcome to the Unity Test Project, one of the main projects of ThrowTheSwitch.org. Unity Test is a +unit testing framework built for C, with a focus on working with embedded toolchains. + +This project is made to test code targetting microcontrollers big and small. The core project is a +single C file and a pair of headers, allowing it to the added to your existing build setup without +too much headache. You may use any compiler you wish, and may use most existing build systems +including make, cmake, etc. If you'd like to leave the hard work to us, you might be interested +in Ceedling, a build tool also by ThrowTheSwitch.org. + +If you're new to Unity, we encourage you to tour the [getting started guide](docs/UnityGettingStartedGuide.md) Getting Started =============== diff --git a/src/unity.c b/src/unity.c index fef1d57c..0426d037 100644 --- a/src/unity.c +++ b/src/unity.c @@ -1,6 +1,6 @@ /* ========================================================================= Unity Project - A Test Framework for C - Copyright (c) 2007-19 Mike Karlesky, Mark VanderVoord, Greg Williams + Copyright (c) 2007-21 Mike Karlesky, Mark VanderVoord, Greg Williams [Released under MIT License. Please refer to license.txt for details] ============================================================================ */ diff --git a/src/unity.h b/src/unity.h index 7d8c7116..08c6a4ef 100644 --- a/src/unity.h +++ b/src/unity.h @@ -1,6 +1,6 @@ /* ========================================== Unity Project - A Test Framework for C - Copyright (c) 2007-19 Mike Karlesky, Mark VanderVoord, Greg Williams + Copyright (c) 2007-21 Mike Karlesky, Mark VanderVoord, Greg Williams [Released under MIT License. Please refer to license.txt for details] ========================================== */ diff --git a/src/unity_internals.h b/src/unity_internals.h index ffb69a9e..79c305e9 100644 --- a/src/unity_internals.h +++ b/src/unity_internals.h @@ -1,6 +1,6 @@ /* ========================================== Unity Project - A Test Framework for C - Copyright (c) 2007-19 Mike Karlesky, Mark VanderVoord, Greg Williams + Copyright (c) 2007-21 Mike Karlesky, Mark VanderVoord, Greg Williams [Released under MIT License. Please refer to license.txt for details] ========================================== */ From 9e7c259822d0f4dc3ac00537995b96b231f671b5 Mon Sep 17 00:00:00 2001 From: Mark VanderVoord Date: Sat, 16 Jan 2021 20:19:29 -0500 Subject: [PATCH 262/454] Do we need to be admin to install gems? --- .github/workflows/main.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 9807cbba..96e7e19d 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -19,8 +19,8 @@ jobs: # Install Ruby Testing Tools - name: Setup Ruby Testing Tools run: | - gem install rspec - gem install rubocop -v 0.57.2 + sudo gem install rspec + sudo gem install rubocop -v 0.57.2 # Run Tests - name: Run All Unit Tests From 3c1c5338af388ee45eb347b0955c16de5b644c7e Mon Sep 17 00:00:00 2001 From: Mark VanderVoord Date: Sat, 16 Jan 2021 20:27:49 -0500 Subject: [PATCH 263/454] Need to checkout. Drop Slack support --- .github/workflows/main.yml | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 96e7e19d..fcae2ad6 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -22,20 +22,11 @@ jobs: sudo gem install rspec sudo gem install rubocop -v 0.57.2 + # Checks out repository under $GITHUB_WORKSPACE + - name: Checkout Latest Repo + uses: actions/checkout@v2 + # Run Tests - name: Run All Unit Tests run: | cd test && rake ci - - # Slack notification - - uses: 8398a7/action-slack@v3 - with: - icon_emoji: ':octocat:' - status: ${{ job.status }} - # Github Actions limit visibility into renamed jobs; explicit job names here solve this limitation - job_name: "Unit Tests" - fields: repo,author,eventName,workflow,job - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - SLACK_WEBHOOK_URL: ${{ secrets.SLACK_CI_CHANNEL_WEBHOOK }} - if: always() # Pick up events even if the job fails or is canceled. From fcab680286c60c199f793a49a93019c76b8f8a21 Mon Sep 17 00:00:00 2001 From: Mark VanderVoord Date: Sat, 16 Jan 2021 21:03:18 -0500 Subject: [PATCH 264/454] Ruby script cleanup. Fix warnings. Remove 32-bit tests from standard suite because they're not running on most platforms. --- auto/generate_module.rb | 14 +++++++------- src/unity.c | 6 ++---- test/Makefile | 1 + test/rakefile_helper.rb | 4 ++-- 4 files changed, 12 insertions(+), 13 deletions(-) diff --git a/auto/generate_module.rb b/auto/generate_module.rb index f7e1598f..119234c7 100644 --- a/auto/generate_module.rb +++ b/auto/generate_module.rb @@ -168,13 +168,13 @@ def files_to_operate_on(module_name, pattern = nil) end ############################ - def neutralize_filename(name, start_cap=true) + def neutralize_filename(name, start_cap = true) return name if name.empty? - name = name.split(/(?:\s+|_|(?=[A-Z][a-z]))|(?<=[a-z])(?=[A-Z])/).map{|v|v.capitalize}.join('_') - if start_cap - return name + name = name.split(/(?:\s+|_|(?=[A-Z][a-z]))|(?<=[a-z])(?=[A-Z])/).map { |v| v.capitalize }.join('_') + return if start_cap + name else - return name[0].downcase + name[1..-1] + name[0].downcase + name[1..-1] end end @@ -182,8 +182,8 @@ def neutralize_filename(name, start_cap=true) def create_filename(part1, part2 = '') name = part2.empty? ? part1 : part1 + '_' + part2 case (@options[:naming]) - when 'bumpy' then neutralize_filename(name,false).gsub('_','') - when 'camel' then neutralize_filename(name).gsub('_','') + when 'bumpy' then neutralize_filename(name,false).delete('_') + when 'camel' then neutralize_filename(name).delete('_') when 'snake' then neutralize_filename(name).downcase when 'caps' then neutralize_filename(name).upcase else name diff --git a/src/unity.c b/src/unity.c index 0426d037..be3528fa 100644 --- a/src/unity.c +++ b/src/unity.c @@ -1002,8 +1002,7 @@ void UnityAssertFloatSpecial(const UNITY_FLOAT actual, is_trait = !isinf(actual) && !isnan(actual); break; - case UNITY_FLOAT_INVALID_TRAIT: - default: + default: /* including UNITY_FLOAT_INVALID_TRAIT */ trait_index = 0; trait_names[0] = UnityStrInvalidFloatTrait; break; @@ -1143,8 +1142,7 @@ void UnityAssertDoubleSpecial(const UNITY_DOUBLE actual, is_trait = !isinf(actual) && !isnan(actual); break; - case UNITY_FLOAT_INVALID_TRAIT: - default: + default: /* including UNITY_FLOAT_INVALID_TRAIT */ trait_index = 0; trait_names[0] = UnityStrInvalidFloatTrait; break; diff --git a/test/Makefile b/test/Makefile index d8d10d22..5be0488f 100644 --- a/test/Makefile +++ b/test/Makefile @@ -10,6 +10,7 @@ endif CFLAGS += -std=c99 -pedantic -Wall -Wextra -Werror #CFLAGS += -Wconversion #disabled because if falsely complains about the isinf and isnan macros CFLAGS += -Wno-switch-enum -Wno-double-promotion +CFLAGS += -Wno-poison-system-directories CFLAGS += -Wbad-function-cast -Wcast-qual -Wold-style-definition -Wshadow -Wstrict-overflow \ -Wstrict-prototypes -Wswitch-default -Wundef #DEBUG = -O0 -g diff --git a/test/rakefile_helper.rb b/test/rakefile_helper.rb index e205bc67..86789445 100644 --- a/test/rakefile_helper.rb +++ b/test/rakefile_helper.rb @@ -300,8 +300,8 @@ def run_tests(test_files) def run_make_tests() [ "make -s", # test with all defaults - "make -s DEBUG=-m32", # test 32-bit architecture with 64-bit support - "make -s DEBUG=-m32 UNITY_SUPPORT_64=", # test 32-bit build without 64-bit types + #"make -s DEBUG=-m32", # test 32-bit architecture with 64-bit support + #"make -s DEBUG=-m32 UNITY_SUPPORT_64=", # test 32-bit build without 64-bit types "make -s UNITY_INCLUDE_DOUBLE= ", # test without double "cd #{File.join("..","extras","fixture",'test')} && make -s default noStdlibMalloc", "cd #{File.join("..","extras","fixture",'test')} && make -s C89", From d8eb8414f4f4f42350389c6ebdd63e57adce8787 Mon Sep 17 00:00:00 2001 From: Mark VanderVoord Date: Sat, 16 Jan 2021 21:20:09 -0500 Subject: [PATCH 265/454] Stop noticing my sublime files. ;) --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index 083b4f89..e4bb017b 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,5 @@ examples/example_1/test1.out examples/example_1/test2.out examples/example_2/all_tests.out examples/example_4/builddir +*.sublime-project +*.sublime-workspace From 0b899aec14d3a9abb2bf260ac355f0f28630a6a3 Mon Sep 17 00:00:00 2001 From: Mark VanderVoord Date: Tue, 26 Jan 2021 08:59:27 -0500 Subject: [PATCH 266/454] Fix conditional issue in generator script. Bump version. --- auto/generate_module.rb | 7 ++----- src/unity.h | 2 +- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/auto/generate_module.rb b/auto/generate_module.rb index 119234c7..0a88becc 100644 --- a/auto/generate_module.rb +++ b/auto/generate_module.rb @@ -171,11 +171,8 @@ def files_to_operate_on(module_name, pattern = nil) def neutralize_filename(name, start_cap = true) return name if name.empty? name = name.split(/(?:\s+|_|(?=[A-Z][a-z]))|(?<=[a-z])(?=[A-Z])/).map { |v| v.capitalize }.join('_') - return if start_cap - name - else - name[0].downcase + name[1..-1] - end + name = name[0].downcase + name[1..-1] unless start_cap + return name end ############################ diff --git a/src/unity.h b/src/unity.h index 08c6a4ef..ab986c4b 100644 --- a/src/unity.h +++ b/src/unity.h @@ -10,7 +10,7 @@ #define UNITY_VERSION_MAJOR 2 #define UNITY_VERSION_MINOR 5 -#define UNITY_VERSION_BUILD 1 +#define UNITY_VERSION_BUILD 2 #define UNITY_VERSION ((UNITY_VERSION_MAJOR << 16) | (UNITY_VERSION_MINOR << 8) | UNITY_VERSION_BUILD) #ifdef __cplusplus From 563b93e5ec4549cfa6896976937be12cfa7c63ad Mon Sep 17 00:00:00 2001 From: throwaway47912 Date: Wed, 10 Feb 2021 15:20:03 +0100 Subject: [PATCH 267/454] Fix typo in doc --- docs/UnityGettingStartedGuide.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/UnityGettingStartedGuide.md b/docs/UnityGettingStartedGuide.md index c054b361..a0fb035e 100644 --- a/docs/UnityGettingStartedGuide.md +++ b/docs/UnityGettingStartedGuide.md @@ -96,7 +96,7 @@ Both functions accept no arguments and return nothing. You may leave either or both of these blank if you have no need for them. If you're using Ceedling or the test runner generator script, you may leave these off -completely. Not sure? Give it a try. If you compiler complains that it can't +completely. Not sure? Give it a try. If your compiler complains that it can't find setUp or tearDown when it links, you'll know you need to at least include an empty function for these. From 63fef7dd102689d54fe39e930edfdcac4596a018 Mon Sep 17 00:00:00 2001 From: Kin Numaru Date: Fri, 12 Feb 2021 20:25:34 +0100 Subject: [PATCH 268/454] Enlarge the TEST_RANGE() regex to accept more spaces This commit change the regex to accept more spaces inside the brackets of the TEST_RANGE(). I use clang-format through vscode "editor.formatOnSave": true feature and it produce padding spaces inside the array brackets by default. ```c int a[] = [1, 2]; ``` is changed into ```c int a[] = [ 1, 2 ]; ``` Also, every time I save a file containing a TEST_RANGE() with ctrl + s, it breaks it. --- auto/generate_test_runner.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/auto/generate_test_runner.rb b/auto/generate_test_runner.rb index ea0b2c4a..d1d8f91a 100644 --- a/auto/generate_test_runner.rb +++ b/auto/generate_test_runner.rb @@ -143,7 +143,7 @@ def find_tests(source) arguments.scan(/\s*TEST_CASE\s*\((.*)\)\s*$/) { |a| args << a[0] } arguments.scan(/\s*TEST_RANGE\s*\((.*)\)\s*$/).flatten.each do |range_str| - args += range_str.scan(/\[(-?\d+.?\d*), *(-?\d+.?\d*), *(-?\d+.?\d*)\]/).map do |arg_values_str| + args += range_str.scan(/\[\s*(-?\d+.?\d*),\s*(-?\d+.?\d*),\s*(-?\d+.?\d*)\s*\]/).map do |arg_values_str| arg_values_str.map do |arg_value_str| arg_value_str.include?('.') ? arg_value_str.to_f : arg_value_str.to_i end From 66cec22838e2b163c75b691fbf3e396fe3e4e5c9 Mon Sep 17 00:00:00 2001 From: Fabian Zahn - 0xFAB Date: Fri, 26 Feb 2021 07:51:57 +0100 Subject: [PATCH 269/454] Update UnityConfigurationGuide.md Add semi-colon to configuration :) --- docs/UnityConfigurationGuide.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/UnityConfigurationGuide.md b/docs/UnityConfigurationGuide.md index de691fdf..b4386d92 100644 --- a/docs/UnityConfigurationGuide.md +++ b/docs/UnityConfigurationGuide.md @@ -379,7 +379,7 @@ system. Feel free to override this and to make it whatever you wish. _Example:_ ```C -#define UNITY_PRINT_EOL { UNITY_OUTPUT_CHAR('\r'); UNITY_OUTPUT_CHAR('\n') } +#define UNITY_PRINT_EOL { UNITY_OUTPUT_CHAR('\r'); UNITY_OUTPUT_CHAR('\n'); } ``` From 0168ea1541128188a4515c85c92df6936071dbfd Mon Sep 17 00:00:00 2001 From: Fabian Zahn Date: Fri, 26 Feb 2021 18:46:27 +0100 Subject: [PATCH 270/454] Enable __attribute__ when __clang__ is definedgit --- src/unity_internals.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/unity_internals.h b/src/unity_internals.h index 79c305e9..b86fefa3 100644 --- a/src/unity_internals.h +++ b/src/unity_internals.h @@ -40,10 +40,10 @@ #include #endif -#if defined __GNUC__ -# define UNITY_FUNCTION_ATTR(a) __attribute__((a)) +#if defined(__GNUC__) || defined(__clang__) + #define UNITY_FUNCTION_ATTR(a) __attribute__((a)) #else -# define UNITY_FUNCTION_ATTR(a) /* ignore */ + #define UNITY_FUNCTION_ATTR(a) /* ignore */ #endif /*------------------------------------------------------- From 7edf9d9ac538785deb9f469a6f60dbd567f52435 Mon Sep 17 00:00:00 2001 From: Fabian Zahn Date: Sat, 27 Feb 2021 08:53:53 +0100 Subject: [PATCH 271/454] Fix #510 (-Wextra-semi-stmt with clang compiler) --- CMakeLists.txt | 1 + src/unity.c | 16 +++++++++------- src/unity.h | 2 +- src/unity_internals.h | 24 ++++++++++++------------ 4 files changed, 23 insertions(+), 20 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3a16cdcc..59b2ab29 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -103,6 +103,7 @@ target_compile_options(${PROJECT_NAME} -Wcast-qual -Wconversion -Wexit-time-destructors + -Wextra-semi-stmt -Wglobal-constructors -Wmissing-noreturn -Wmissing-prototypes diff --git a/src/unity.c b/src/unity.c index be3528fa..2d328531 100644 --- a/src/unity.c +++ b/src/unity.c @@ -19,9 +19,9 @@ void UNITY_OUTPUT_CHAR(int); #endif /* Helpful macros for us to use here in Assert functions */ -#define UNITY_FAIL_AND_BAIL { Unity.CurrentTestFailed = 1; UNITY_OUTPUT_FLUSH(); TEST_ABORT(); } -#define UNITY_IGNORE_AND_BAIL { Unity.CurrentTestIgnored = 1; UNITY_OUTPUT_FLUSH(); TEST_ABORT(); } -#define RETURN_IF_FAIL_OR_IGNORE if (Unity.CurrentTestFailed || Unity.CurrentTestIgnored) TEST_ABORT() +#define UNITY_FAIL_AND_BAIL do { Unity.CurrentTestFailed = 1; UNITY_OUTPUT_FLUSH(); TEST_ABORT(); } while (0) +#define UNITY_IGNORE_AND_BAIL do { Unity.CurrentTestIgnored = 1; UNITY_OUTPUT_FLUSH(); TEST_ABORT(); } while (0) +#define RETURN_IF_FAIL_OR_IGNORE do { if (Unity.CurrentTestFailed || Unity.CurrentTestIgnored) { TEST_ABORT(); } } while (0) struct UNITY_STORAGE_T Unity; @@ -765,11 +765,12 @@ void UnityAssertGreaterOrLessOrEqualNumber(const UNITY_INT threshold, } #define UnityPrintPointlessAndBail() \ -{ \ +do { \ UnityTestResultsFailBegin(lineNumber); \ UnityPrint(UnityStrPointless); \ UnityAddMsgIfSpecified(msg); \ - UNITY_FAIL_AND_BAIL; } + UNITY_FAIL_AND_BAIL; \ +} while (0) /*-----------------------------------------------*/ void UnityAssertEqualIntArray(UNITY_INTERNAL_PTR expected, @@ -884,11 +885,12 @@ void UnityAssertEqualIntArray(UNITY_INTERNAL_PTR expected, #ifndef UNITY_EXCLUDE_FLOAT_PRINT #define UNITY_PRINT_EXPECTED_AND_ACTUAL_FLOAT(expected, actual) \ - { \ + do { \ UnityPrint(UnityStrExpected); \ UnityPrintFloat(expected); \ UnityPrint(UnityStrWas); \ - UnityPrintFloat(actual); } + UnityPrintFloat(actual); \ + } while (0) #else #define UNITY_PRINT_EXPECTED_AND_ACTUAL_FLOAT(expected, actual) \ UnityPrint(UnityStrDelta) diff --git a/src/unity.h b/src/unity.h index ab986c4b..7f3db26e 100644 --- a/src/unity.h +++ b/src/unity.h @@ -111,7 +111,7 @@ void verifyTest(void); /* It is not necessary for you to call PASS. A PASS condition is assumed if nothing fails. * This method allows you to abort a test immediately with a PASS state, ignoring the remainder of the test. */ #define TEST_PASS() TEST_ABORT() -#define TEST_PASS_MESSAGE(message) do { UnityMessage((message), __LINE__); TEST_ABORT(); } while(0) +#define TEST_PASS_MESSAGE(message) do { UnityMessage((message), __LINE__); TEST_ABORT(); } while (0) /* This macro does nothing, but it is useful for build tools (like Ceedling) to make use of this to figure out * which files should be linked to in order to perform a test. Use it like TEST_FILE("sandwiches.c") */ diff --git a/src/unity_internals.h b/src/unity_internals.h index b86fefa3..08c876f1 100644 --- a/src/unity_internals.h +++ b/src/unity_internals.h @@ -273,10 +273,10 @@ typedef UNITY_FLOAT_TYPE UNITY_FLOAT; #ifdef UNITY_USE_FLUSH_STDOUT /* We want to use the stdout flush utility */ #include - #define UNITY_OUTPUT_FLUSH() (void)fflush(stdout) + #define UNITY_OUTPUT_FLUSH() (void)fflush(stdout) #else /* We've specified nothing, therefore flush should just be ignored */ - #define UNITY_OUTPUT_FLUSH() + #define UNITY_OUTPUT_FLUSH() (void)0 #endif #else /* If defined as something else, make sure we declare it here so it's ready for use */ @@ -288,11 +288,11 @@ typedef UNITY_FLOAT_TYPE UNITY_FLOAT; #ifndef UNITY_OUTPUT_FLUSH #define UNITY_FLUSH_CALL() #else -#define UNITY_FLUSH_CALL() UNITY_OUTPUT_FLUSH() +#define UNITY_FLUSH_CALL() UNITY_OUTPUT_FLUSH() #endif #ifndef UNITY_PRINT_EOL -#define UNITY_PRINT_EOL() UNITY_OUTPUT_CHAR('\n') +#define UNITY_PRINT_EOL() UNITY_OUTPUT_CHAR('\n') #endif #ifndef UNITY_OUTPUT_START @@ -351,19 +351,19 @@ typedef UNITY_FLOAT_TYPE UNITY_FLOAT; #endif #ifndef UNITY_EXEC_TIME_START -#define UNITY_EXEC_TIME_START() do{}while(0) +#define UNITY_EXEC_TIME_START() do { /* nothing*/ } while (0) #endif #ifndef UNITY_EXEC_TIME_STOP -#define UNITY_EXEC_TIME_STOP() do{}while(0) +#define UNITY_EXEC_TIME_STOP() do { /* nothing*/ } while (0) #endif #ifndef UNITY_TIME_TYPE -#define UNITY_TIME_TYPE UNITY_UINT +#define UNITY_TIME_TYPE UNITY_UINT #endif #ifndef UNITY_PRINT_EXEC_TIME -#define UNITY_PRINT_EXEC_TIME() do{}while(0) +#define UNITY_PRINT_EXEC_TIME() do { /* nothing*/ } while (0) #endif /*------------------------------------------------------- @@ -502,9 +502,9 @@ void UnityDefaultTestRun(UnityTestFunction Func, const char* FuncName, const int #define UNITY_SET_DETAIL(d1) #define UNITY_SET_DETAILS(d1,d2) #else -#define UNITY_CLR_DETAILS() { Unity.CurrentDetail1 = 0; Unity.CurrentDetail2 = 0; } -#define UNITY_SET_DETAIL(d1) { Unity.CurrentDetail1 = (d1); Unity.CurrentDetail2 = 0; } -#define UNITY_SET_DETAILS(d1,d2) { Unity.CurrentDetail1 = (d1); Unity.CurrentDetail2 = (d2); } +#define UNITY_CLR_DETAILS() do { Unity.CurrentDetail1 = 0; Unity.CurrentDetail2 = 0; } while (0) +#define UNITY_SET_DETAIL(d1) do { Unity.CurrentDetail1 = (d1); Unity.CurrentDetail2 = 0; } while (0) +#define UNITY_SET_DETAILS(d1,d2) do { Unity.CurrentDetail1 = (d1); Unity.CurrentDetail2 = (d2); } while (0) #ifndef UNITY_DETAIL1_NAME #define UNITY_DETAIL1_NAME "Function" @@ -772,7 +772,7 @@ int UnityTestMatches(void); * Test Asserts *-------------------------------------------------------*/ -#define UNITY_TEST_ASSERT(condition, line, message) do {if (condition) {} else {UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), (message));}} while(0) +#define UNITY_TEST_ASSERT(condition, line, message) do { if (condition) { /* nothing*/ } else { UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), (message)); } } while (0) #define UNITY_TEST_ASSERT_NULL(pointer, line, message) UNITY_TEST_ASSERT(((pointer) == NULL), (UNITY_LINE_TYPE)(line), (message)) #define UNITY_TEST_ASSERT_NOT_NULL(pointer, line, message) UNITY_TEST_ASSERT(((pointer) != NULL), (UNITY_LINE_TYPE)(line), (message)) #define UNITY_TEST_ASSERT_EMPTY(pointer, line, message) UNITY_TEST_ASSERT(((pointer[0]) == 0), (UNITY_LINE_TYPE)(line), (message)) From fa32e530ba1aecc37113067714d29459d12bbdec Mon Sep 17 00:00:00 2001 From: Fabian Zahn Date: Sat, 27 Feb 2021 10:49:34 +0100 Subject: [PATCH 272/454] Remove "error: assuming signed overflow does not occur when reducing constant in comparison [-Werror=strict-overflow]" --- src/unity.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/src/unity.c b/src/unity.c index 2d328531..b8802487 100644 --- a/src/unity.c +++ b/src/unity.c @@ -369,10 +369,12 @@ void UnityPrintFloat(const UNITY_DOUBLE input_number) } else { - UNITY_INT32 n_int = 0, n; - int exponent = 0; - int decimals, digits; - char buf[16] = {0}; + UNITY_INT32 n_int = 0; + UNITY_INT32 n; + int exponent = 0; + int decimals; + int digits; + char buf[16] = {0}; /* * Scale up or down by powers of 10. To minimize rounding error, @@ -445,14 +447,19 @@ void UnityPrintFloat(const UNITY_DOUBLE input_number) /* build up buffer in reverse order */ digits = 0; - while ((n != 0) || (digits < (decimals + 1))) + while ((n != 0) || (digits <= decimals)) { buf[digits++] = (char)('0' + n % 10); n /= 10; } + + /* print out buffer (backwards) */ while (digits > 0) { - if (digits == decimals) { UNITY_OUTPUT_CHAR('.'); } + if (digits == decimals) + { + UNITY_OUTPUT_CHAR('.'); + } UNITY_OUTPUT_CHAR(buf[--digits]); } From 4cfb39290ad8e9f81ddc9da6abe5bb65aef4d641 Mon Sep 17 00:00:00 2001 From: Fabian Zahn Date: Sat, 27 Feb 2021 11:14:43 +0100 Subject: [PATCH 273/454] Refactor generator expressions for CMake --- CMakeLists.txt | 75 +++++++++++++++++++++++++++++--------------------- 1 file changed, 43 insertions(+), 32 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 59b2ab29..766a5bdf 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -99,38 +99,49 @@ set_target_properties(${PROJECT_NAME} target_compile_options(${PROJECT_NAME} PRIVATE - $<$:-Wcast-align - -Wcast-qual - -Wconversion - -Wexit-time-destructors - -Wextra-semi-stmt - -Wglobal-constructors - -Wmissing-noreturn - -Wmissing-prototypes - -Wno-missing-braces - -Wold-style-cast - -Wshadow - -Wweak-vtables - -Werror - -Wall> - $<$:-Waddress - -Waggregate-return - -Wformat-nonliteral - -Wformat-security - -Wformat - -Winit-self - -Wmissing-declarations - -Wmissing-include-dirs - -Wno-multichar - -Wno-parentheses - -Wno-type-limits - -Wno-unused-parameter - -Wunreachable-code - -Wwrite-strings - -Wpointer-arith - -Werror - -Wall> - $<$:/Wall> + # Clang + $<$: + -Wcast-align + -Wcast-qual + -Wconversion + -Wexit-time-destructors + -Wglobal-constructors + -Wmissing-noreturn + -Wmissing-prototypes + -Wno-missing-braces + -Wold-style-cast + -Wshadow + -Wweak-vtables + -Werror + -Wall + $<$,8.0.0>:-Wextra-semi-stmt> + > + + # GCC + $<$: + -Waddress + -Waggregate-return + -Wformat-nonliteral + -Wformat-security + -Wformat + -Winit-self + -Wmissing-declarations + -Wmissing-include-dirs + -Wno-multichar + -Wno-parentheses + -Wno-type-limits + -Wno-unused-parameter + -Wunreachable-code + -Wwrite-strings + -Wpointer-arith + -Werror + -Wall + > + + # MSVC + $<$: + /Wall + > ) write_basic_package_version_file(${PROJECT_NAME}ConfigVersion.cmake From b51303a65b93fc5f4d8598d280f414d0535fb2ce Mon Sep 17 00:00:00 2001 From: Jannis Baudisch Date: Thu, 1 Apr 2021 10:29:22 +0200 Subject: [PATCH 274/454] Improve regex for test parameterization to support function pointers The regex to match function names for the test parameterization used the wildcard '.*'. This lead to an error when you try to add a function pointer as arguement. The regex will now only match the word characters a-z A-Z 0-9 and underscore (which are all characers that are accepted by the C standard) --- auto/generate_test_runner.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/auto/generate_test_runner.rb b/auto/generate_test_runner.rb index d1d8f91a..7497c6de 100644 --- a/auto/generate_test_runner.rb +++ b/auto/generate_test_runner.rb @@ -131,6 +131,7 @@ def find_tests(source) lines.each_with_index do |line, _index| # find tests next unless line =~ /^((?:\s*(?:TEST_CASE|TEST_RANGE)\s*\(.*?\)\s*)*)\s*void\s+((?:#{@options[:test_prefix]}).*)\s*\(\s*(.*)\s*\)/m + next unless line =~ /^((?:\s*(?:TEST_CASE|TEST_RANGE)\s*\(.*?\)\s*)*)\s*void\s+((?:#{@options[:test_prefix]})\w*)\s*\(\s*(.*)\s*\)/m arguments = Regexp.last_match(1) name = Regexp.last_match(2) From 77bd4f994334d6cd36ecd92bf227e9b2561a3678 Mon Sep 17 00:00:00 2001 From: Jannis Baudisch Date: Thu, 1 Apr 2021 10:29:22 +0200 Subject: [PATCH 275/454] Add test for function pointers in parameterized tests --- test/testdata/Defs.h | 1 + test/testdata/testRunnerGenerator.c | 11 +++++++++++ test/tests/test_generate_test_runner.rb | 6 +++++- 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/test/testdata/Defs.h b/test/testdata/Defs.h index b1dc83e9..58678c12 100644 --- a/test/testdata/Defs.h +++ b/test/testdata/Defs.h @@ -4,5 +4,6 @@ #define EXTERN_DECL extern int CounterSuiteSetup; +extern int isArgumentOne(int i); #endif diff --git a/test/testdata/testRunnerGenerator.c b/test/testdata/testRunnerGenerator.c index b5dd97f5..46fc3b4c 100644 --- a/test/testdata/testRunnerGenerator.c +++ b/test/testdata/testRunnerGenerator.c @@ -167,6 +167,17 @@ void paratest_ShouldHandleParameterizedTestsThatFail(int Num) TEST_ASSERT_EQUAL_MESSAGE(3, Num, "This call should fail"); } +int isArgumentOne(int i) +{ + return i == 1; +} + +TEST_CASE(isArgumentOne) +void paratest_WorksWithFunctionPointers(int function(int)) +{ + TEST_ASSERT_TRUE_MESSAGE(function(1), "Function should return True"); +} + #ifdef USE_CEXCEPTION void extest_ShouldHandleCExceptionInTest(void) { diff --git a/test/tests/test_generate_test_runner.rb b/test/tests/test_generate_test_runner.rb index 809b4494..658b6e2e 100644 --- a/test/tests/test_generate_test_runner.rb +++ b/test/tests/test_generate_test_runner.rb @@ -151,6 +151,7 @@ 'paratest_ShouldHandleParameterizedTests\(5\)', 'paratest_ShouldHandleParameterizedTests2\(7\)', 'paratest_ShouldHandleNonParameterizedTestsWhenParameterizationValid', + 'paratest_WorksWithFunctionPointers\(isArgumentOne\)', ], :to_fail => [ 'paratest_ShouldHandleParameterizedTestsThatFail\(17\)' ], :to_ignore => [ ], @@ -168,6 +169,7 @@ 'paratest_ShouldHandleParameterizedTests\(5\)', 'paratest_ShouldHandleParameterizedTests2\(7\)', 'paratest_ShouldHandleNonParameterizedTestsWhenParameterizationValid', + 'paratest_WorksWithFunctionPointers\(isArgumentOne\)', ], :to_fail => [ 'paratest_ShouldHandleParameterizedTestsThatFail\(17\)' ], :to_ignore => [ ], @@ -188,6 +190,7 @@ 'paratest_ShouldHandleParameterizedTests\(5\)', 'paratest_ShouldHandleParameterizedTests2\(7\)', 'paratest_ShouldHandleNonParameterizedTestsWhenParameterizationValid', + 'paratest_WorksWithFunctionPointers\(isArgumentOne\)', ], :to_fail => [ 'paratest_ShouldHandleParameterizedTestsThatFail\(17\)' ], :to_ignore => [ ], @@ -1108,7 +1111,8 @@ 'paratest_ShouldHandleParameterizedTests\(5\)', 'paratest_ShouldHandleParameterizedTests2\(7\)', 'paratest_ShouldHandleNonParameterizedTestsWhenParameterizationValid', - 'paratest_ShouldHandleParameterizedTestsThatFail\(17\)' + 'paratest_ShouldHandleParameterizedTestsThatFail\(17\)', + 'paratest_WorksWithFunctionPointers\(isArgumentOne\)', ], } }, From 31f5b47fc5d6e70a79d87fded0d8b8add6052dc1 Mon Sep 17 00:00:00 2001 From: Peter Membrey Date: Sun, 4 Apr 2021 01:54:43 +0800 Subject: [PATCH 276/454] Add generator code to build file and make script executable --- auto/generate_test_runner.rb | 2 ++ meson.build | 12 ++++++++++++ 2 files changed, 14 insertions(+) mode change 100644 => 100755 auto/generate_test_runner.rb diff --git a/auto/generate_test_runner.rb b/auto/generate_test_runner.rb old mode 100644 new mode 100755 index d1d8f91a..ab376fa5 --- a/auto/generate_test_runner.rb +++ b/auto/generate_test_runner.rb @@ -1,3 +1,5 @@ +#!/usr/bin/ruby + # ========================================== # Unity Project - A Test Framework for C # Copyright (c) 2007 Mike Karlesky, Mark VanderVoord, Greg Williams diff --git a/meson.build b/meson.build index f5c5cfaa..d424f62f 100644 --- a/meson.build +++ b/meson.build @@ -12,3 +12,15 @@ project('unity', 'c', subdir('src') unity_dep = declare_dependency(link_with: unity_lib, include_directories: unity_dir) + + +# Get the generate_test_runner script relative to itself or the parent project if it is being used as a subproject +# NOTE: This could be (and probably is) a complete hack - but I haven't yet been able to find a better way.... +if meson.is_subproject() +gen_test_runner_path = find_program(meson.source_root() / 'subprojects/unity/auto/generate_test_runner.rb') +else +gen_test_runner_path = find_program('subprojects/unity/auto/generate_test_runner.rb') +endif + +# Create a generator that we can access from the parent project +gen_test_runner = generator(gen_test_runner_path, output: '@BASENAME@_Runner.c', arguments: ['@INPUT@', '@OUTPUT@'] ) From 63ea077a29759f8a6396ed80db60f54fefe83997 Mon Sep 17 00:00:00 2001 From: Peter Membrey Date: Sun, 4 Apr 2021 22:14:28 +0800 Subject: [PATCH 277/454] Add some docs for the Meson generator --- docs/MesonGeneratorRunner.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 docs/MesonGeneratorRunner.md diff --git a/docs/MesonGeneratorRunner.md b/docs/MesonGeneratorRunner.md new file mode 100644 index 00000000..3b81e378 --- /dev/null +++ b/docs/MesonGeneratorRunner.md @@ -0,0 +1,18 @@ +# Meson Generator - Test Runner + +One of the really nice things about using Unity with Ceedling is that Ceedling takes care of generating all of the test runners automatically. If you're not using Ceedling though, you'll need to do this yourself. + +The way this is done in Unity is via a Ruby script called `generate_test_runner.rb`. When given a test file such as `test_example.c`, the script will generate `test_example_Runner.c`, which provides the `main` method and some other useful plumbing. + +So that you don't have to run this by hand, a Meson generator is provided to generate the runner automatically for you. Generally with Meson, you would use Unity as a subproject and you'd want to access the generator from the parent. + +For example, to get the generator you can use: + + unity_proj = subproject('unity') + runner_gen = unity_proj.get_variable('gen_test_runner') + +Once you have the generator you need to pass it the absolute path of your test file. This seems to be a bug in how the paths work with subprojects in Meson. You can get the full path with `meson.source_root()`, so you could do: + + test_runner = meson.source_root() / 'test/test_example.c' + +You can then include `test_runner` as a normal dependency to your builds. Meson will create the test runner in a private directory for each build target. It's only meant to be used as part of the build, so if you need to refer to the runner after the build, you won't be able to use the generator. \ No newline at end of file From 8e1e9c18ab3067a001eb2c5196103ad7bdde5cf1 Mon Sep 17 00:00:00 2001 From: Erik Flodin Date: Thu, 15 Apr 2021 22:22:33 +0200 Subject: [PATCH 278/454] Fix ruby style warnings as reported by rubocop --- auto/generate_module.rb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/auto/generate_module.rb b/auto/generate_module.rb index 0a88becc..8e33d95e 100644 --- a/auto/generate_module.rb +++ b/auto/generate_module.rb @@ -170,16 +170,16 @@ def files_to_operate_on(module_name, pattern = nil) ############################ def neutralize_filename(name, start_cap = true) return name if name.empty? - name = name.split(/(?:\s+|_|(?=[A-Z][a-z]))|(?<=[a-z])(?=[A-Z])/).map { |v| v.capitalize }.join('_') + name = name.split(/(?:\s+|_|(?=[A-Z][a-z]))|(?<=[a-z])(?=[A-Z])/).map(&:capitalize).join('_') name = name[0].downcase + name[1..-1] unless start_cap - return name + name end ############################ def create_filename(part1, part2 = '') name = part2.empty? ? part1 : part1 + '_' + part2 case (@options[:naming]) - when 'bumpy' then neutralize_filename(name,false).delete('_') + when 'bumpy' then neutralize_filename(name, false).delete('_') when 'camel' then neutralize_filename(name).delete('_') when 'snake' then neutralize_filename(name).downcase when 'caps' then neutralize_filename(name).upcase @@ -211,8 +211,8 @@ def generate(module_name, pattern = nil) f.write("#{file[:boilerplate]}\n" % [file[:name]]) unless file[:boilerplate].nil? f.write(file[:template] % [file[:name], file[:includes].map { |ff| "#include \"#{ff}\"\n" }.join, - file[:name].upcase.gsub(/-/, '_'), - file[:name].gsub(/-/, '_')]) + file[:name].upcase.tr('-', '_'), + file[:name].tr('-', '_')]) end if @options[:update_svn] `svn add \"#{file[:path]}\"` From dc96c3e6ddda456d6ed3bbf097213b5aad7f402b Mon Sep 17 00:00:00 2001 From: Erik Flodin Date: Sat, 17 Apr 2021 19:00:06 +0200 Subject: [PATCH 279/454] Fix strict-overflow compiler warning By replacing "x < y + 1" with "x <= y" the compiler doesn't have to do it and the warning "assuming signed overflow does not occur when reducing constant in comparison [-Werror=strict-overflow]" is avoided. --- src/unity.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/unity.c b/src/unity.c index be3528fa..764a42b1 100644 --- a/src/unity.c +++ b/src/unity.c @@ -445,7 +445,7 @@ void UnityPrintFloat(const UNITY_DOUBLE input_number) /* build up buffer in reverse order */ digits = 0; - while ((n != 0) || (digits < (decimals + 1))) + while ((n != 0) || (digits <= decimals)) { buf[digits++] = (char)('0' + n % 10); n /= 10; From 27ef0eb44e8b921d1a68ef7eafeff6b6271b05db Mon Sep 17 00:00:00 2001 From: Jonathan Reichelt Gjertsen Date: Mon, 24 May 2021 14:52:24 +0200 Subject: [PATCH 280/454] Fix some formatting errors in the assertions reference --- docs/UnityAssertionsReference.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/docs/UnityAssertionsReference.md b/docs/UnityAssertionsReference.md index 0957bcf6..1c3d063f 100644 --- a/docs/UnityAssertionsReference.md +++ b/docs/UnityAssertionsReference.md @@ -580,7 +580,7 @@ equality are not guaranteed. ##### `TEST_ASSERT_EQUAL_FLOAT (expected, actual)` -Asserts that the ?actual?value is "close enough to be considered equal" to the +Asserts that the `actual` value is "close enough to be considered equal" to the `expected` value. If you are curious about the details, refer to the Advanced Asserting section for more details on this. Omitting a user-specified delta in a floating point assertion is both a shorthand convenience and a requirement of @@ -590,7 +590,7 @@ code generation conventions for CMock. ##### `TEST_ASSERT_EQUAL_FLOAT_ARRAY (expected, actual, num_elements)` See Array assertion section for details. Note that individual array element -float comparisons are executed using T?EST_ASSERT_EQUAL_FLOAT?.That is, user +float comparisons are executed using `TEST_ASSERT_EQUAL_FLOAT`.That is, user specified delta comparison values requires a custom-implemented floating point array assertion. @@ -614,7 +614,7 @@ Asserts that `actual` parameter is a Not A Number floating point representation. ##### `TEST_ASSERT_FLOAT_IS_DETERMINATE (actual)` -Asserts that ?actual?parameter is a floating point representation usable for +Asserts that `actual` parameter is a floating point representation usable for mathematical operations. That is, the `actual` parameter is neither positive infinity nor negative infinity nor Not A Number floating point representations. @@ -690,7 +690,7 @@ Asserts that `actual` parameter is a Not A Number floating point representation. ##### `TEST_ASSERT_DOUBLE_IS_DETERMINATE (actual)` Asserts that `actual` parameter is a floating point representation usable for -mathematical operations. That is, the ?actual?parameter is neither positive +mathematical operations. That is, the `actual` parameter is neither positive infinity nor negative infinity nor Not A Number floating point representations. @@ -821,11 +821,11 @@ What about the times where you suddenly need to deal with something odd, like a affect you: 1. When Unity displays errors for you, it's going to pad the upper unused bits -with zeros. + with zeros. 2. You're going to have to be careful of assertions that perform signed -operations, particularly `TEST_ASSERT_INT_WITHIN`.Such assertions might wrap -your `int` in the wrong place, and you could experience false failures. You can -always back down to a simple `TEST_ASSERT` and do the operations yourself. + operations, particularly `TEST_ASSERT_INT_WITHIN`. Such assertions might wrap + your `int` in the wrong place, and you could experience false failures. You can + always back down to a simple `TEST_ASSERT` and do the operations yourself. *Find The Latest of This And More at [ThrowTheSwitch.org](https://throwtheswitch.org)* From 410de1a02b0b45e542ff6afab18fabf5fef24bac Mon Sep 17 00:00:00 2001 From: Jonathan Reichelt Gjertsen Date: Mon, 24 May 2021 14:53:29 +0200 Subject: [PATCH 281/454] Add macros for testing inequalities between floats, doubles --- README.md | 7 + docs/UnityAssertionsReference.md | 28 ++++ src/unity.c | 56 ++++++++ src/unity.h | 8 ++ src/unity_internals.h | 20 +++ test/tests/test_unity_doubles.c | 220 +++++++++++++++++++++++++++++++ test/tests/test_unity_floats.c | 220 +++++++++++++++++++++++++++++++ 7 files changed, 559 insertions(+) diff --git a/README.md b/README.md index cab2de39..563bcebc 100644 --- a/README.md +++ b/README.md @@ -151,6 +151,13 @@ Asserts that the actual value is within plus or minus delta of the expected valu Asserts that two floating point values are "equal" within a small % delta of the expected value. + TEST_ASSERT_LESS_THAN_FLOAT(threshold, actual) + TEST_ASSERT_LESS_THAN_DOUBLE(threshold, actual) + TEST_ASSERT_GREATER_THAN_FLOAT(threshold, actual) + TEST_ASSERT_GREATER_THAN_DOUBLE(threshold, actual) + +Asserts that the actual value is less than or greater than the threshold. + String Assertions ----------------- diff --git a/docs/UnityAssertionsReference.md b/docs/UnityAssertionsReference.md index 1c3d063f..068a768e 100644 --- a/docs/UnityAssertionsReference.md +++ b/docs/UnityAssertionsReference.md @@ -595,6 +595,20 @@ specified delta comparison values requires a custom-implemented floating point array assertion. +##### `TEST_ASSERT_LESS_THAN_FLOAT (threshold, actual)` + +Asserts that the `actual` parameter is less than `threshold` (exclusive). +For example, if the threshold value is 1.0f, the assertion will fail if it is +greater than 1.0f. + + +##### `TEST_ASSERT_GREATER_THAN_FLOAT (threshold, actual)` + +Asserts that the `actual` parameter is greater than `threshold` (exclusive). +For example, if the threshold value is 1.0f, the assertion will fail if it is +less than 1.0f. + + ##### `TEST_ASSERT_FLOAT_IS_INF (actual)` Asserts that `actual` parameter is equivalent to positive infinity floating @@ -670,6 +684,20 @@ specified delta comparison values requires a custom implemented double array assertion. +##### `TEST_ASSERT_LESS_THAN_DOUBLE (threshold, actual)` + +Asserts that the `actual` parameter is less than `threshold` (exclusive). +For example, if the threshold value is 1.0, the assertion will fail if it is +greater than 1.0. + + +##### `TEST_ASSERT_GREATER_THAN_DOUBLE (threshold, actual)` + +Asserts that the `actual` parameter is greater than `threshold` (exclusive). +For example, if the threshold value is 1.0, the assertion will fail if it is +less than 1.0. + + ##### `TEST_ASSERT_DOUBLE_IS_INF (actual)` Asserts that `actual` parameter is equivalent to positive infinity floating diff --git a/src/unity.c b/src/unity.c index be3528fa..adeea673 100644 --- a/src/unity.c +++ b/src/unity.c @@ -968,6 +968,34 @@ void UnityAssertFloatsWithin(const UNITY_FLOAT delta, } } +/*-----------------------------------------------*/ +void UnityAssertGreaterOrLessFloat(const UNITY_FLOAT threshold, + const UNITY_FLOAT actual, + const UNITY_COMPARISON_T compare, + const char* msg, + const UNITY_LINE_TYPE lineNumber) +{ + RETURN_IF_FAIL_OR_IGNORE; + + int failed = 0; + + // Checking for "not success" rather than failure to get the right result for NaN + if (!(actual < threshold) && (compare & UNITY_SMALLER_THAN)) { failed = 1; } + if (!(actual > threshold) && (compare & UNITY_GREATER_THAN)) { failed = 1; } + + if (failed) + { + UnityTestResultsFailBegin(lineNumber); + UnityPrint(UnityStrExpected); + UnityPrintFloat(actual); + if (compare & UNITY_GREATER_THAN) { UnityPrint(UnityStrGt); } + if (compare & UNITY_SMALLER_THAN) { UnityPrint(UnityStrLt); } + UnityPrintFloat(threshold); + UnityAddMsgIfSpecified(msg); + UNITY_FAIL_AND_BAIL; + } +} + /*-----------------------------------------------*/ void UnityAssertFloatSpecial(const UNITY_FLOAT actual, const char* msg, @@ -1108,6 +1136,34 @@ void UnityAssertDoublesWithin(const UNITY_DOUBLE delta, } } +/*-----------------------------------------------*/ +void UnityAssertGreaterOrLessDouble(const UNITY_DOUBLE threshold, + const UNITY_DOUBLE actual, + const UNITY_COMPARISON_T compare, + const char* msg, + const UNITY_LINE_TYPE lineNumber) +{ + RETURN_IF_FAIL_OR_IGNORE; + + int failed = 0; + + // Checking for "not success" rather than failure to get the right result for NaN + if (!(actual < threshold) && (compare & UNITY_SMALLER_THAN)) { failed = 1; } + if (!(actual > threshold) && (compare & UNITY_GREATER_THAN)) { failed = 1; } + + if (failed) + { + UnityTestResultsFailBegin(lineNumber); + UnityPrint(UnityStrExpected); + UnityPrintFloat(actual); + if (compare & UNITY_GREATER_THAN) { UnityPrint(UnityStrGt); } + if (compare & UNITY_SMALLER_THAN) { UnityPrint(UnityStrLt); } + UnityPrintFloat(threshold); + UnityAddMsgIfSpecified(msg); + UNITY_FAIL_AND_BAIL; + } +} + /*-----------------------------------------------*/ void UnityAssertDoubleSpecial(const UNITY_DOUBLE actual, const char* msg, diff --git a/src/unity.h b/src/unity.h index ab986c4b..dc89666d 100644 --- a/src/unity.h +++ b/src/unity.h @@ -340,6 +340,8 @@ void verifyTest(void); #define TEST_ASSERT_EQUAL_FLOAT(expected, actual) UNITY_TEST_ASSERT_EQUAL_FLOAT((expected), (actual), __LINE__, NULL) #define TEST_ASSERT_EQUAL_FLOAT_ARRAY(expected, actual, num_elements) UNITY_TEST_ASSERT_EQUAL_FLOAT_ARRAY((expected), (actual), (num_elements), __LINE__, NULL) #define TEST_ASSERT_EACH_EQUAL_FLOAT(expected, actual, num_elements) UNITY_TEST_ASSERT_EACH_EQUAL_FLOAT((expected), (actual), (num_elements), __LINE__, NULL) +#define TEST_ASSERT_GREATER_THAN_FLOAT(threshold, actual) UNITY_TEST_ASSERT_GREATER_THAN_FLOAT((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_LESS_THAN_FLOAT(threshold, actual) UNITY_TEST_ASSERT_LESS_THAN_FLOAT((threshold), (actual), __LINE__, NULL) #define TEST_ASSERT_FLOAT_IS_INF(actual) UNITY_TEST_ASSERT_FLOAT_IS_INF((actual), __LINE__, NULL) #define TEST_ASSERT_FLOAT_IS_NEG_INF(actual) UNITY_TEST_ASSERT_FLOAT_IS_NEG_INF((actual), __LINE__, NULL) #define TEST_ASSERT_FLOAT_IS_NAN(actual) UNITY_TEST_ASSERT_FLOAT_IS_NAN((actual), __LINE__, NULL) @@ -354,6 +356,8 @@ void verifyTest(void); #define TEST_ASSERT_EQUAL_DOUBLE(expected, actual) UNITY_TEST_ASSERT_EQUAL_DOUBLE((expected), (actual), __LINE__, NULL) #define TEST_ASSERT_EQUAL_DOUBLE_ARRAY(expected, actual, num_elements) UNITY_TEST_ASSERT_EQUAL_DOUBLE_ARRAY((expected), (actual), (num_elements), __LINE__, NULL) #define TEST_ASSERT_EACH_EQUAL_DOUBLE(expected, actual, num_elements) UNITY_TEST_ASSERT_EACH_EQUAL_DOUBLE((expected), (actual), (num_elements), __LINE__, NULL) +#define TEST_ASSERT_GREATER_THAN_DOUBLE(threshold, actual) UNITY_TEST_ASSERT_GREATER_THAN_DOUBLE((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_LESS_THAN_DOUBLE(threshold, actual) UNITY_TEST_ASSERT_LESS_THAN_DOUBLE((threshold), (actual), __LINE__, NULL) #define TEST_ASSERT_DOUBLE_IS_INF(actual) UNITY_TEST_ASSERT_DOUBLE_IS_INF((actual), __LINE__, NULL) #define TEST_ASSERT_DOUBLE_IS_NEG_INF(actual) UNITY_TEST_ASSERT_DOUBLE_IS_NEG_INF((actual), __LINE__, NULL) #define TEST_ASSERT_DOUBLE_IS_NAN(actual) UNITY_TEST_ASSERT_DOUBLE_IS_NAN((actual), __LINE__, NULL) @@ -609,6 +613,8 @@ void verifyTest(void); #define TEST_ASSERT_EQUAL_FLOAT_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_FLOAT((expected), (actual), __LINE__, (message)) #define TEST_ASSERT_EQUAL_FLOAT_ARRAY_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EQUAL_FLOAT_ARRAY((expected), (actual), (num_elements), __LINE__, (message)) #define TEST_ASSERT_EACH_EQUAL_FLOAT_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EACH_EQUAL_FLOAT((expected), (actual), (num_elements), __LINE__, (message)) +#define TEST_ASSERT_GREATER_THAN_FLOAT_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_THAN_FLOAT((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_LESS_THAN_FLOAT_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_LESS_THAN_FLOAT((threshold), (actual), __LINE__, (message)) #define TEST_ASSERT_FLOAT_IS_INF_MESSAGE(actual, message) UNITY_TEST_ASSERT_FLOAT_IS_INF((actual), __LINE__, (message)) #define TEST_ASSERT_FLOAT_IS_NEG_INF_MESSAGE(actual, message) UNITY_TEST_ASSERT_FLOAT_IS_NEG_INF((actual), __LINE__, (message)) #define TEST_ASSERT_FLOAT_IS_NAN_MESSAGE(actual, message) UNITY_TEST_ASSERT_FLOAT_IS_NAN((actual), __LINE__, (message)) @@ -623,6 +629,8 @@ void verifyTest(void); #define TEST_ASSERT_EQUAL_DOUBLE_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_DOUBLE((expected), (actual), __LINE__, (message)) #define TEST_ASSERT_EQUAL_DOUBLE_ARRAY_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EQUAL_DOUBLE_ARRAY((expected), (actual), (num_elements), __LINE__, (message)) #define TEST_ASSERT_EACH_EQUAL_DOUBLE_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EACH_EQUAL_DOUBLE((expected), (actual), (num_elements), __LINE__, (message)) +#define TEST_ASSERT_GREATER_THAN_DOUBLE_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_THAN_DOUBLE((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_LESS_THAN_DOUBLE_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_LESS_THAN_DOUBLE((threshold), (actual), __LINE__, (message)) #define TEST_ASSERT_DOUBLE_IS_INF_MESSAGE(actual, message) UNITY_TEST_ASSERT_DOUBLE_IS_INF((actual), __LINE__, (message)) #define TEST_ASSERT_DOUBLE_IS_NEG_INF_MESSAGE(actual, message) UNITY_TEST_ASSERT_DOUBLE_IS_NEG_INF((actual), __LINE__, (message)) #define TEST_ASSERT_DOUBLE_IS_NAN_MESSAGE(actual, message) UNITY_TEST_ASSERT_DOUBLE_IS_NAN((actual), __LINE__, (message)) diff --git a/src/unity_internals.h b/src/unity_internals.h index b86fefa3..e7d2ba59 100644 --- a/src/unity_internals.h +++ b/src/unity_internals.h @@ -634,6 +634,12 @@ void UnityAssertFloatsWithin(const UNITY_FLOAT delta, const char* msg, const UNITY_LINE_TYPE lineNumber); +void UnityAssertGreaterOrLessFloat(const UNITY_FLOAT threshold, + const UNITY_FLOAT actual, + const UNITY_COMPARISON_T compare, + const char* msg, + const UNITY_LINE_TYPE linenumber); + void UnityAssertEqualFloatArray(UNITY_PTR_ATTRIBUTE const UNITY_FLOAT* expected, UNITY_PTR_ATTRIBUTE const UNITY_FLOAT* actual, const UNITY_UINT32 num_elements, @@ -654,6 +660,12 @@ void UnityAssertDoublesWithin(const UNITY_DOUBLE delta, const char* msg, const UNITY_LINE_TYPE lineNumber); +void UnityAssertGreaterOrLessDouble(const UNITY_DOUBLE threshold, + const UNITY_DOUBLE actual, + const UNITY_COMPARISON_T compare, + const char* msg, + const UNITY_LINE_TYPE linenumber); + void UnityAssertEqualDoubleArray(UNITY_PTR_ATTRIBUTE const UNITY_DOUBLE* expected, UNITY_PTR_ATTRIBUTE const UNITY_DOUBLE* actual, const UNITY_UINT32 num_elements, @@ -984,6 +996,8 @@ int UnityTestMatches(void); #define UNITY_TEST_ASSERT_EQUAL_FLOAT(expected, actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErrFloat) #define UNITY_TEST_ASSERT_EQUAL_FLOAT_ARRAY(expected, actual, num_elements, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErrFloat) #define UNITY_TEST_ASSERT_EACH_EQUAL_FLOAT(expected, actual, num_elements, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErrFloat) +#define UNITY_TEST_ASSERT_GREATER_THAN_FLOAT(threshold, actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErrFloat) +#define UNITY_TEST_ASSERT_LESS_THAN_FLOAT(threshold, actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErrFloat) #define UNITY_TEST_ASSERT_FLOAT_IS_INF(actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErrFloat) #define UNITY_TEST_ASSERT_FLOAT_IS_NEG_INF(actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErrFloat) #define UNITY_TEST_ASSERT_FLOAT_IS_NAN(actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErrFloat) @@ -997,6 +1011,8 @@ int UnityTestMatches(void); #define UNITY_TEST_ASSERT_EQUAL_FLOAT(expected, actual, line, message) UNITY_TEST_ASSERT_FLOAT_WITHIN((UNITY_FLOAT)(expected) * (UNITY_FLOAT)UNITY_FLOAT_PRECISION, (UNITY_FLOAT)(expected), (UNITY_FLOAT)(actual), (UNITY_LINE_TYPE)(line), (message)) #define UNITY_TEST_ASSERT_EQUAL_FLOAT_ARRAY(expected, actual, num_elements, line, message) UnityAssertEqualFloatArray((UNITY_FLOAT*)(expected), (UNITY_FLOAT*)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_ARRAY_TO_ARRAY) #define UNITY_TEST_ASSERT_EACH_EQUAL_FLOAT(expected, actual, num_elements, line, message) UnityAssertEqualFloatArray(UnityFloatToPtr(expected), (UNITY_FLOAT*)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_ARRAY_TO_VAL) +#define UNITY_TEST_ASSERT_GREATER_THAN_FLOAT(threshold, actual, line, message) UnityAssertGreaterOrLessFloat((UNITY_FLOAT)(threshold), (UNITY_FLOAT)(actual), UNITY_GREATER_THAN, (message), (UNITY_LINE_TYPE)(line)) +#define UNITY_TEST_ASSERT_LESS_THAN_FLOAT(threshold, actual, line, message) UnityAssertGreaterOrLessFloat((UNITY_FLOAT)(threshold), (UNITY_FLOAT)(actual), UNITY_SMALLER_THAN, (message), (UNITY_LINE_TYPE)(line)) #define UNITY_TEST_ASSERT_FLOAT_IS_INF(actual, line, message) UnityAssertFloatSpecial((UNITY_FLOAT)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_FLOAT_IS_INF) #define UNITY_TEST_ASSERT_FLOAT_IS_NEG_INF(actual, line, message) UnityAssertFloatSpecial((UNITY_FLOAT)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_FLOAT_IS_NEG_INF) #define UNITY_TEST_ASSERT_FLOAT_IS_NAN(actual, line, message) UnityAssertFloatSpecial((UNITY_FLOAT)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_FLOAT_IS_NAN) @@ -1012,6 +1028,8 @@ int UnityTestMatches(void); #define UNITY_TEST_ASSERT_EQUAL_DOUBLE(expected, actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErrDouble) #define UNITY_TEST_ASSERT_EQUAL_DOUBLE_ARRAY(expected, actual, num_elements, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErrDouble) #define UNITY_TEST_ASSERT_EACH_EQUAL_DOUBLE(expected, actual, num_elements, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErrDouble) +#define UNITY_TEST_ASSERT_GREATER_THAN_DOUBLE(threshold, actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErrDouble) +#define UNITY_TEST_ASSERT_LESS_THAN_DOUBLE(threshold, actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErrDouble) #define UNITY_TEST_ASSERT_DOUBLE_IS_INF(actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErrDouble) #define UNITY_TEST_ASSERT_DOUBLE_IS_NEG_INF(actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErrDouble) #define UNITY_TEST_ASSERT_DOUBLE_IS_NAN(actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErrDouble) @@ -1025,6 +1043,8 @@ int UnityTestMatches(void); #define UNITY_TEST_ASSERT_EQUAL_DOUBLE(expected, actual, line, message) UNITY_TEST_ASSERT_DOUBLE_WITHIN((UNITY_DOUBLE)(expected) * (UNITY_DOUBLE)UNITY_DOUBLE_PRECISION, (UNITY_DOUBLE)(expected), (UNITY_DOUBLE)(actual), (UNITY_LINE_TYPE)(line), (message)) #define UNITY_TEST_ASSERT_EQUAL_DOUBLE_ARRAY(expected, actual, num_elements, line, message) UnityAssertEqualDoubleArray((UNITY_DOUBLE*)(expected), (UNITY_DOUBLE*)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_ARRAY_TO_ARRAY) #define UNITY_TEST_ASSERT_EACH_EQUAL_DOUBLE(expected, actual, num_elements, line, message) UnityAssertEqualDoubleArray(UnityDoubleToPtr(expected), (UNITY_DOUBLE*)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_ARRAY_TO_VAL) +#define UNITY_TEST_ASSERT_GREATER_THAN_DOUBLE(threshold, actual, line, message) UnityAssertGreaterOrLessDouble((UNITY_DOUBLE)(threshold), (UNITY_DOUBLE)(actual), UNITY_GREATER_THAN, (message), (UNITY_LINE_TYPE)(line)) +#define UNITY_TEST_ASSERT_LESS_THAN_DOUBLE(threshold, actual, line, message) UnityAssertGreaterOrLessDouble((UNITY_DOUBLE)(threshold), (UNITY_DOUBLE)(actual), UNITY_SMALLER_THAN, (message), (UNITY_LINE_TYPE)(line)) #define UNITY_TEST_ASSERT_DOUBLE_IS_INF(actual, line, message) UnityAssertDoubleSpecial((UNITY_DOUBLE)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_FLOAT_IS_INF) #define UNITY_TEST_ASSERT_DOUBLE_IS_NEG_INF(actual, line, message) UnityAssertDoubleSpecial((UNITY_DOUBLE)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_FLOAT_IS_NEG_INF) #define UNITY_TEST_ASSERT_DOUBLE_IS_NAN(actual, line, message) UnityAssertDoubleSpecial((UNITY_DOUBLE)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_FLOAT_IS_NAN) diff --git a/test/tests/test_unity_doubles.c b/test/tests/test_unity_doubles.c index 1bdedbc3..32020710 100644 --- a/test/tests/test_unity_doubles.c +++ b/test/tests/test_unity_doubles.c @@ -197,6 +197,226 @@ void testDoublesNotEqualPlusMinusInf(void) #endif } +void testDoublesGreaterThan(void) +{ +#ifdef UNITY_EXCLUDE_DOUBLE + TEST_IGNORE(); +#else + TEST_ASSERT_GREATER_THAN_DOUBLE(1.0, 2.0); + TEST_ASSERT_GREATER_THAN_DOUBLE(-1.0, 1.0); + TEST_ASSERT_GREATER_THAN_DOUBLE(-2.0, -1.0); +#endif +} + +void testDoublesGreaterThanInf(void) +{ +#ifdef UNITY_EXCLUDE_DOUBLE + TEST_IGNORE(); +#else + TEST_ASSERT_GREATER_THAN_DOUBLE(1.0, 1.0 / d_zero); + TEST_ASSERT_GREATER_THAN_DOUBLE(-1.0 / d_zero, 1.0 / d_zero); + TEST_ASSERT_GREATER_THAN_DOUBLE(-1.0 / d_zero, 1.0); +#endif +} + +void testDoublesNotGreaterThan(void) +{ +#ifdef UNITY_EXCLUDE_DOUBLE + TEST_IGNORE(); +#else + EXPECT_ABORT_BEGIN + TEST_ASSERT_GREATER_THAN_DOUBLE(2.0, 1.0); + VERIFY_FAILS_END +#endif +} + +void testDoublesNotGreaterThanNanActual(void) +{ +#ifdef UNITY_EXCLUDE_DOUBLE + TEST_IGNORE(); +#else + EXPECT_ABORT_BEGIN + TEST_ASSERT_GREATER_THAN_DOUBLE(1.0, 0.0 / d_zero); + VERIFY_FAILS_END +#endif +} + +void testDoublesNotGreaterThanNanThreshold(void) +{ +#ifdef UNITY_EXCLUDE_DOUBLE + TEST_IGNORE(); +#else + EXPECT_ABORT_BEGIN + TEST_ASSERT_GREATER_THAN_DOUBLE(0.0 / d_zero, 1.0); + VERIFY_FAILS_END +#endif +} + +void testDoublesNotGreaterThanNanBoth(void) +{ +#ifdef UNITY_EXCLUDE_DOUBLE + TEST_IGNORE(); +#else + EXPECT_ABORT_BEGIN + TEST_ASSERT_GREATER_THAN_DOUBLE(0.0 / d_zero, 0.0 / d_zero); + VERIFY_FAILS_END +#endif +} + +void testDoublesNotGreaterThanInfActual(void) +{ +#ifdef UNITY_EXCLUDE_DOUBLE + TEST_IGNORE(); +#else + EXPECT_ABORT_BEGIN + TEST_ASSERT_GREATER_THAN_DOUBLE(1.0 / d_zero, 1.0); + VERIFY_FAILS_END +#endif +} + +void testDoublesNotGreaterThanNegInf(void) +{ +#ifdef UNITY_EXCLUDE_DOUBLE + TEST_IGNORE(); +#else + EXPECT_ABORT_BEGIN + TEST_ASSERT_GREATER_THAN_DOUBLE(1.0, -1.0 / d_zero); + VERIFY_FAILS_END +#endif +} + +void testDoublesNotGreaterThanBothInf(void) +{ +#ifdef UNITY_EXCLUDE_DOUBLE + TEST_IGNORE(); +#else + EXPECT_ABORT_BEGIN + TEST_ASSERT_GREATER_THAN_DOUBLE(1.0 / d_zero, 1.0 / d_zero); + VERIFY_FAILS_END +#endif +} + +void testDoublesNotGreaterThanBothNegInf(void) +{ +#ifdef UNITY_EXCLUDE_DOUBLE + TEST_IGNORE(); +#else + EXPECT_ABORT_BEGIN + TEST_ASSERT_GREATER_THAN_DOUBLE(-1.0 / d_zero, -1.0 / d_zero); + VERIFY_FAILS_END +#endif +} + +void testDoublesLessThan(void) +{ +#ifdef UNITY_EXCLUDE_DOUBLE + TEST_IGNORE(); +#else + TEST_ASSERT_LESS_THAN_DOUBLE(2.0, 1.0); + TEST_ASSERT_LESS_THAN_DOUBLE(1.0, -1.0); + TEST_ASSERT_LESS_THAN_DOUBLE(-1.0, -2.0); +#endif +} + +void testDoublesLessThanInf(void) +{ +#ifdef UNITY_EXCLUDE_DOUBLE + TEST_IGNORE(); +#else + TEST_ASSERT_LESS_THAN_DOUBLE(1.0 / d_zero, 1.0); + TEST_ASSERT_LESS_THAN_DOUBLE(1.0 / d_zero, -1.0 / d_zero); + TEST_ASSERT_LESS_THAN_DOUBLE(1.0, -1.0 / d_zero); +#endif +} + +void testDoublesNotLessThan(void) +{ +#ifdef UNITY_EXCLUDE_DOUBLE + TEST_IGNORE(); +#else + EXPECT_ABORT_BEGIN + TEST_ASSERT_LESS_THAN_DOUBLE(1.0, 2.0); + VERIFY_FAILS_END +#endif +} + +void testDoublesNotLessThanNanActual(void) +{ +#ifdef UNITY_EXCLUDE_DOUBLE + TEST_IGNORE(); +#else + EXPECT_ABORT_BEGIN + TEST_ASSERT_LESS_THAN_DOUBLE(1.0, 0.0 / d_zero); + VERIFY_FAILS_END +#endif +} + +void testDoublesNotLessThanNanThreshold(void) +{ +#ifdef UNITY_EXCLUDE_DOUBLE + TEST_IGNORE(); +#else + EXPECT_ABORT_BEGIN + TEST_ASSERT_LESS_THAN_DOUBLE(0.0 / d_zero, 1.0); + VERIFY_FAILS_END +#endif +} + +void testDoublesNotLessThanNanBoth(void) +{ +#ifdef UNITY_EXCLUDE_DOUBLE + TEST_IGNORE(); +#else + EXPECT_ABORT_BEGIN + TEST_ASSERT_LESS_THAN_DOUBLE(0.0 / d_zero, 0.0 / d_zero); + VERIFY_FAILS_END +#endif +} + +void testDoublesNotLessThanInf(void) +{ +#ifdef UNITY_EXCLUDE_DOUBLE + TEST_IGNORE(); +#else + EXPECT_ABORT_BEGIN + TEST_ASSERT_LESS_THAN_DOUBLE(1.0, 1.0 / d_zero); + VERIFY_FAILS_END +#endif +} + +void testDoublesNotLessThanNegInf(void) +{ +#ifdef UNITY_EXCLUDE_DOUBLE + TEST_IGNORE(); +#else + EXPECT_ABORT_BEGIN + TEST_ASSERT_LESS_THAN_DOUBLE(-1.0 / d_zero, 1.0); + VERIFY_FAILS_END +#endif +} + +void testDoublesNotLessThanBothInf(void) +{ +#ifdef UNITY_EXCLUDE_DOUBLE + TEST_IGNORE(); +#else + EXPECT_ABORT_BEGIN + TEST_ASSERT_LESS_THAN_DOUBLE(1.0 / d_zero, 1.0 / d_zero); + VERIFY_FAILS_END +#endif +} + +void testDoublesNotLessThanBothNegInf(void) +{ +#ifdef UNITY_EXCLUDE_DOUBLE + TEST_IGNORE(); +#else + EXPECT_ABORT_BEGIN + TEST_ASSERT_LESS_THAN_DOUBLE(-1.0 / d_zero, -1.0 / d_zero); + VERIFY_FAILS_END +#endif +} + void testDoubleIsPosInf1(void) { #ifdef UNITY_EXCLUDE_DOUBLE diff --git a/test/tests/test_unity_floats.c b/test/tests/test_unity_floats.c index e89bec20..2f15c1a5 100644 --- a/test/tests/test_unity_floats.c +++ b/test/tests/test_unity_floats.c @@ -196,6 +196,226 @@ void testFloatsNotEqualPlusMinusInf(void) #endif } +void testFloatsGreaterThan(void) +{ +#ifdef UNITY_EXCLUDE_FLOAT + TEST_IGNORE(); +#else + TEST_ASSERT_GREATER_THAN_FLOAT(1.0f, 2.0f); + TEST_ASSERT_GREATER_THAN_FLOAT(-1.0f, 1.0f); + TEST_ASSERT_GREATER_THAN_FLOAT(-2.0f, -1.0f); +#endif +} + +void testFloatsGreaterThanInf(void) +{ +#ifdef UNITY_EXCLUDE_FLOAT + TEST_IGNORE(); +#else + TEST_ASSERT_GREATER_THAN_FLOAT(1.0f, 1.0f / f_zero); + TEST_ASSERT_GREATER_THAN_FLOAT(-1.0f / f_zero, 1.0f / f_zero); + TEST_ASSERT_GREATER_THAN_FLOAT(-1.0f / f_zero, 1.0f); +#endif +} + +void testFloatsNotGreaterThan(void) +{ +#ifdef UNITY_EXCLUDE_FLOAT + TEST_IGNORE(); +#else + EXPECT_ABORT_BEGIN + TEST_ASSERT_GREATER_THAN_FLOAT(2.0f, 1.0f); + VERIFY_FAILS_END +#endif +} + +void testFloatsNotGreaterThanNanActual(void) +{ +#ifdef UNITY_EXCLUDE_FLOAT + TEST_IGNORE(); +#else + EXPECT_ABORT_BEGIN + TEST_ASSERT_GREATER_THAN_FLOAT(1.0f, 0.0f / f_zero); + VERIFY_FAILS_END +#endif +} + +void testFloatsNotGreaterThanNanThreshold(void) +{ +#ifdef UNITY_EXCLUDE_FLOAT + TEST_IGNORE(); +#else + EXPECT_ABORT_BEGIN + TEST_ASSERT_GREATER_THAN_FLOAT(0.0f / f_zero, 1.0f); + VERIFY_FAILS_END +#endif +} + +void testFloatsNotGreaterThanNanBoth(void) +{ +#ifdef UNITY_EXCLUDE_FLOAT + TEST_IGNORE(); +#else + EXPECT_ABORT_BEGIN + TEST_ASSERT_GREATER_THAN_FLOAT(0.0f / f_zero, 0.0f / f_zero); + VERIFY_FAILS_END +#endif +} + +void testFloatsNotGreaterThanInfActual(void) +{ +#ifdef UNITY_EXCLUDE_FLOAT + TEST_IGNORE(); +#else + EXPECT_ABORT_BEGIN + TEST_ASSERT_GREATER_THAN_FLOAT(1.0f / f_zero, 1.0f); + VERIFY_FAILS_END +#endif +} + +void testFloatsNotGreaterThanNegInf(void) +{ +#ifdef UNITY_EXCLUDE_FLOAT + TEST_IGNORE(); +#else + EXPECT_ABORT_BEGIN + TEST_ASSERT_GREATER_THAN_FLOAT(1.0f, -1.0f / f_zero); + VERIFY_FAILS_END +#endif +} + +void testFloatsNotGreaterThanBothInf(void) +{ +#ifdef UNITY_EXCLUDE_FLOAT + TEST_IGNORE(); +#else + EXPECT_ABORT_BEGIN + TEST_ASSERT_GREATER_THAN_FLOAT(1.0f / f_zero, 1.0f / f_zero); + VERIFY_FAILS_END +#endif +} + +void testFloatsNotGreaterThanBothNegInf(void) +{ +#ifdef UNITY_EXCLUDE_FLOAT + TEST_IGNORE(); +#else + EXPECT_ABORT_BEGIN + TEST_ASSERT_GREATER_THAN_FLOAT(-1.0f / f_zero, -1.0f / f_zero); + VERIFY_FAILS_END +#endif +} + +void testFloatsLessThan(void) +{ +#ifdef UNITY_EXCLUDE_FLOAT + TEST_IGNORE(); +#else + TEST_ASSERT_LESS_THAN_FLOAT(2.0f, 1.0f); + TEST_ASSERT_LESS_THAN_FLOAT(1.0f, -1.0f); + TEST_ASSERT_LESS_THAN_FLOAT(-1.0f, -2.0f); +#endif +} + +void testFloatsLessThanInf(void) +{ +#ifdef UNITY_EXCLUDE_FLOAT + TEST_IGNORE(); +#else + TEST_ASSERT_LESS_THAN_FLOAT(1.0f / f_zero, 1.0f); + TEST_ASSERT_LESS_THAN_FLOAT(1.0f / f_zero, -1.0f / f_zero); + TEST_ASSERT_LESS_THAN_FLOAT(1.0f, -1.0f / f_zero); +#endif +} + +void testFloatsNotLessThan(void) +{ +#ifdef UNITY_EXCLUDE_FLOAT + TEST_IGNORE(); +#else + EXPECT_ABORT_BEGIN + TEST_ASSERT_LESS_THAN_FLOAT(1.0f, 2.0f); + VERIFY_FAILS_END +#endif +} + +void testFloatsNotLessThanNanActual(void) +{ +#ifdef UNITY_EXCLUDE_FLOAT + TEST_IGNORE(); +#else + EXPECT_ABORT_BEGIN + TEST_ASSERT_LESS_THAN_FLOAT(1.0f, 0.0f / f_zero); + VERIFY_FAILS_END +#endif +} + +void testFloatsNotLessThanNanThreshold(void) +{ +#ifdef UNITY_EXCLUDE_FLOAT + TEST_IGNORE(); +#else + EXPECT_ABORT_BEGIN + TEST_ASSERT_LESS_THAN_FLOAT(0.0f / f_zero, 1.0f); + VERIFY_FAILS_END +#endif +} + +void testFloatsNotLessThanNanBoth(void) +{ +#ifdef UNITY_EXCLUDE_FLOAT + TEST_IGNORE(); +#else + EXPECT_ABORT_BEGIN + TEST_ASSERT_LESS_THAN_FLOAT(0.0f / f_zero, 0.0f / f_zero); + VERIFY_FAILS_END +#endif +} + +void testFloatsNotLessThanInf(void) +{ +#ifdef UNITY_EXCLUDE_FLOAT + TEST_IGNORE(); +#else + EXPECT_ABORT_BEGIN + TEST_ASSERT_LESS_THAN_FLOAT(1.0f, 1.0f / f_zero); + VERIFY_FAILS_END +#endif +} + +void testFloatsNotLessThanNegInf(void) +{ +#ifdef UNITY_EXCLUDE_FLOAT + TEST_IGNORE(); +#else + EXPECT_ABORT_BEGIN + TEST_ASSERT_LESS_THAN_FLOAT(-1.0f / f_zero, 1.0f); + VERIFY_FAILS_END +#endif +} + +void testFloatsNotLessThanBothInf(void) +{ +#ifdef UNITY_EXCLUDE_FLOAT + TEST_IGNORE(); +#else + EXPECT_ABORT_BEGIN + TEST_ASSERT_LESS_THAN_FLOAT(1.0f / f_zero, 1.0f / f_zero); + VERIFY_FAILS_END +#endif +} + +void testFloatsNotLessThanBothNegInf(void) +{ +#ifdef UNITY_EXCLUDE_FLOAT + TEST_IGNORE(); +#else + EXPECT_ABORT_BEGIN + TEST_ASSERT_LESS_THAN_FLOAT(-1.0f / f_zero, -1.0f / f_zero); + VERIFY_FAILS_END +#endif +} + void testFloatIsPosInf1(void) { #ifdef UNITY_EXCLUDE_FLOAT From edfc5ae355687cdc10d49b566bd6a6d4277acdb2 Mon Sep 17 00:00:00 2001 From: druckdev Date: Mon, 31 May 2021 12:55:37 +0200 Subject: [PATCH 282/454] Support UNITY_INCLUDE_EXEC_TIME under Apples OSX The unix way of getting the time works under OSX as well and can be used. --- src/unity_internals.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/unity_internals.h b/src/unity_internals.h index b86fefa3..75c2df6f 100644 --- a/src/unity_internals.h +++ b/src/unity_internals.h @@ -333,7 +333,7 @@ typedef UNITY_FLOAT_TYPE UNITY_FLOAT; UnityPrintNumberUnsigned(execTimeMs); \ UnityPrint(" ms)"); \ } - #elif defined(__unix__) + #elif defined(__unix__) || defined(__APPLE__) #include #define UNITY_TIME_TYPE struct timespec #define UNITY_GET_TIME(t) clock_gettime(CLOCK_MONOTONIC, &t) From fa5644bd07690fcfe4cc5803d7aa368e9a5d1452 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Wed, 2 Jun 2021 15:38:27 +0200 Subject: [PATCH 283/454] Fix typo in UnityHelperScriptsGuide.md An `e` is missing in`suit_setup` in the `my_config.yml`. --- docs/UnityHelperScriptsGuide.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/UnityHelperScriptsGuide.md b/docs/UnityHelperScriptsGuide.md index 46c9d74d..0c173e61 100644 --- a/docs/UnityHelperScriptsGuide.md +++ b/docs/UnityHelperScriptsGuide.md @@ -74,7 +74,7 @@ to love the next section of this document. - stdio.h - microdefs.h :cexception: 1 - :suit_setup: "blah = malloc(1024);" + :suite_setup: "blah = malloc(1024);" :suite_teardown: "free(blah);" ``` From f944b08878ba07ffb71bdd6e3dde273d82b4bf16 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bernhard=20Breu=C3=9F?= Date: Wed, 2 Jun 2021 16:56:14 +0200 Subject: [PATCH 284/454] Use stdnoreturn.h for c11 and [[ noreturn ]] for c++11. ThrowTheSwitch#563 --- src/unity_internals.h | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/unity_internals.h b/src/unity_internals.h index 75c2df6f..4e5629bb 100644 --- a/src/unity_internals.h +++ b/src/unity_internals.h @@ -46,6 +46,20 @@ #define UNITY_FUNCTION_ATTR(a) /* ignore */ #endif +#ifndef UNITY_NORETURN + #if defined(__cplusplus) + #if __cplusplus >= 201103L + #define UNITY_NORETURN [[ noreturn ]] + #endif + #elif defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L + #include + #define UNITY_NORETURN noreturn + #endif +#endif +#ifndef UNITY_NORETURN + #define UNITY_NORETURN UNITY_FUNCTION_ATTR(noreturn) +#endif + /*------------------------------------------------------- * Guess Widths If Not Specified *-------------------------------------------------------*/ @@ -618,8 +632,8 @@ void UnityAssertNumbersArrayWithin(const UNITY_UINT delta, const UNITY_FLAGS_T flags); #ifndef UNITY_EXCLUDE_SETJMP_H -void UnityFail(const char* message, const UNITY_LINE_TYPE line) UNITY_FUNCTION_ATTR(noreturn); -void UnityIgnore(const char* message, const UNITY_LINE_TYPE line) UNITY_FUNCTION_ATTR(noreturn); +UNITY_NORETURN void UnityFail(const char* message, const UNITY_LINE_TYPE line); +UNITY_NORETURN void UnityIgnore(const char* message, const UNITY_LINE_TYPE line); #else void UnityFail(const char* message, const UNITY_LINE_TYPE line); void UnityIgnore(const char* message, const UNITY_LINE_TYPE line); From d0b5a920bb150cc885df7c4dcd9fca9f653030af Mon Sep 17 00:00:00 2001 From: wolf99 <281700+wolf99@users.noreply.github.com> Date: Wed, 2 Jun 2021 22:06:45 +0100 Subject: [PATCH 285/454] markdown conformance --- README.md | 59 ++--- docs/ThrowTheSwitchCodingStandard.md | 40 +--- docs/UnityAssertionsReference.md | 337 ++++++++++++--------------- docs/UnityConfigurationGuide.md | 135 ++++++----- docs/UnityGettingStartedGuide.md | 28 ++- docs/UnityHelperScriptsGuide.md | 10 +- extras/fixture/readme.md | 8 +- extras/memory/readme.md | 26 +-- 8 files changed, 281 insertions(+), 362 deletions(-) diff --git a/README.md b/README.md index cab2de39..ea775c2c 100644 --- a/README.md +++ b/README.md @@ -1,29 +1,28 @@ -Unity Test ![CI](https://github.com/ThrowTheSwitch/Unity/workflows/CI/badge.svg) -========== +# Unity Test ![CI](https://github.com/ThrowTheSwitch/Unity/workflows/CI/badge.svg) + __Copyright (c) 2007 - 2021 Unity Project by Mike Karlesky, Mark VanderVoord, and Greg Williams__ -Welcome to the Unity Test Project, one of the main projects of ThrowTheSwitch.org. Unity Test is a -unit testing framework built for C, with a focus on working with embedded toolchains. +Welcome to the Unity Test Project, one of the main projects of ThrowTheSwitch.org. Unity Test is a +unit testing framework built for C, with a focus on working with embedded toolchains. -This project is made to test code targetting microcontrollers big and small. The core project is a -single C file and a pair of headers, allowing it to the added to your existing build setup without +This project is made to test code targetting microcontrollers big and small. The core project is a +single C file and a pair of headers, allowing it to the added to your existing build setup without too much headache. You may use any compiler you wish, and may use most existing build systems -including make, cmake, etc. If you'd like to leave the hard work to us, you might be interested -in Ceedling, a build tool also by ThrowTheSwitch.org. +including Make, CMake, etc. If you'd like to leave the hard work to us, you might be interested +in Ceedling, a build tool also by ThrowTheSwitch.org. If you're new to Unity, we encourage you to tour the [getting started guide](docs/UnityGettingStartedGuide.md) -Getting Started -=============== +## Getting Started + The [docs](docs/) folder contains a [getting started guide](docs/UnityGettingStartedGuide.md) -and much more tips about using Unity. +and much more tips about using Unity. + +## Unity Assertion Summary -Unity Assertion Summary -======================= For the full list, see [UnityAssertionsReference.md](docs/UnityAssertionsReference.md). -Basic Validity Tests --------------------- +### Basic Validity Tests TEST_ASSERT_TRUE(condition) @@ -46,8 +45,7 @@ Another way of calling `TEST_ASSERT_FALSE` This test is automatically marked as a failure. The message is output stating why. -Numerical Assertions: Integers ------------------------------- +### Numerical Assertions: Integers TEST_ASSERT_EQUAL_INT(expected, actual) TEST_ASSERT_EQUAL_INT8(expected, actual) @@ -87,19 +85,15 @@ Another way of calling TEST_ASSERT_EQUAL_INT Asserts that the actual value is within plus or minus delta of the expected value. This also comes in size specific variants. - TEST_ASSERT_GREATER_THAN(threshold, actual) Asserts that the actual value is greater than the threshold. This also comes in size specific variants. - TEST_ASSERT_LESS_THAN(threshold, actual) Asserts that the actual value is less than the threshold. This also comes in size specific variants. - -Arrays ------- +### Arrays _ARRAY @@ -116,8 +110,7 @@ value. You do this by specifying the EACH_EQUAL macro. For example: TEST_ASSERT_EACH_EQUAL_INT32(expected, actual, elements) -Numerical Assertions: Bitwise ------------------------------ +### Numerical Assertions: Bitwise TEST_ASSERT_BITS(mask, expected, actual) @@ -139,8 +132,7 @@ Test a single bit and verify that it is high. The bit is specified 0-31 for a 3 Test a single bit and verify that it is low. The bit is specified 0-31 for a 32-bit integer. -Numerical Assertions: Floats ----------------------------- +### Numerical Assertions: Floats TEST_ASSERT_FLOAT_WITHIN(delta, expected, actual) @@ -151,8 +143,7 @@ Asserts that the actual value is within plus or minus delta of the expected valu Asserts that two floating point values are "equal" within a small % delta of the expected value. -String Assertions ------------------ +### String Assertions TEST_ASSERT_EQUAL_STRING(expected, actual) @@ -170,8 +161,7 @@ Compare two null-terminate strings. Fail if any character is different or if th Compare two strings. Fail if any character is different, stop comparing after len characters. Output a custom message on failure. -Pointer Assertions ------------------- +### Pointer Assertions Most pointer operations can be performed by simply using the integer comparisons above. However, a couple of special cases are added for clarity. @@ -183,18 +173,15 @@ Fails if the pointer is not equal to NULL Fails if the pointer is equal to NULL -Memory Assertions ------------------ +### Memory Assertions TEST_ASSERT_EQUAL_MEMORY(expected, actual, len) Compare two blocks of memory. This is a good generic assertion for types that can't be coerced into acting like standard types... but since it's a memory compare, you have to be careful that your data types are packed. -\_MESSAGE ---------- +### \_MESSAGE -you can append \_MESSAGE to any of the macros to make them take an additional argument. This argument +you can append `\_MESSAGE` to any of the macros to make them take an additional argument. This argument is a string that will be printed at the end of the failure strings. This is useful for specifying more information about the problem. - diff --git a/docs/ThrowTheSwitchCodingStandard.md b/docs/ThrowTheSwitchCodingStandard.md index bf4c099b..29787c87 100644 --- a/docs/ThrowTheSwitchCodingStandard.md +++ b/docs/ThrowTheSwitchCodingStandard.md @@ -8,14 +8,12 @@ and we'll try to be polite when we notice yours. ;) - ## Why Have A Coding Standard? Being consistent makes code easier to understand. We've tried to keep our standard simple because we also believe that we can only expect someone to follow something that is understandable. Please do your best. - ## Our Philosophy Before we get into details on syntax, let's take a moment to talk about our @@ -46,7 +44,6 @@ default. We believe that if you're working with a simple compiler and target, you shouldn't need to configure very much... we try to make the tools guess as much as they can, but give the user the power to override it when it's wrong. - ## Naming Things Let's talk about naming things. Programming is all about naming things. We name @@ -56,20 +53,19 @@ finding *What Something WANTS to be Called*™. When naming things, we follow this hierarchy, the first being the most important to us (but we do all four when possible): + 1. Readable 2. Descriptive 3. Consistent 4. Memorable - -#### Readable +### Readable We want to read our code. This means we like names and flow that are more naturally read. We try to avoid double negatives. We try to avoid cryptic abbreviations (sticking to ones we feel are common). - -#### Descriptive +### Descriptive We like descriptive names for things, especially functions and variables. Finding the right name for something is an important endeavor. You might notice @@ -90,16 +86,14 @@ naming. We find i, j, and k are better loop counters than loopCounterVar or whatnot. We only break this rule when we see that more description could improve understanding of an algorithm. - -#### Consistent +### Consistent We like consistency, but we're not really obsessed with it. We try to name our configuration macros in a consistent fashion... you'll notice a repeated use of UNITY_EXCLUDE_BLAH or UNITY_USES_BLAH macros. This helps users avoid having to remember each macro's details. - -#### Memorable +### Memorable Where ever it doesn't violate the above principles, we try to apply memorable names. Sometimes this means using something that is simply descriptive, but @@ -108,10 +102,9 @@ out in our memory and are easier to search for. Take a look through the file names in Ceedling and you'll get a good idea of what we are talking about here. Why use preprocess when you can use preprocessinator? Or what better describes a module in charge of invoking tasks during releases than release_invoker? Don't -get carried away. The names are still descriptive and fulfill the above +get carried away. The names are still descriptive and fulfil the above requirements, but they don't feel stale. - ## C and C++ Details We don't really want to add to the style battles out there. Tabs or spaces? @@ -123,8 +116,7 @@ We've decided on our own style preferences. If you'd like to contribute to these projects (and we hope that you do), then we ask if you do your best to follow the same. It will only hurt a little. We promise. - -#### Whitespace +### Whitespace in C/C++ Our C-style is to use spaces and to use 4 of them per indent level. It's a nice power-of-2 number that looks decent on a wide-screen. We have no more reason @@ -139,8 +131,7 @@ things up in nice tidy columns. } ``` - -#### Case +### Case in C/C++ - Files - all lower case with underscores. - Variables - all lower case with underscores @@ -149,8 +140,7 @@ things up in nice tidy columns. - Functions - camel cased. Usually named ModuleName_FuncName - Constants and Globals - camel cased. - -#### Braces +### Braces in C/C++ The left brace is on the next line after the declaration. The right brace is directly below that. Everything in between in indented one level. If you're @@ -163,8 +153,7 @@ catching an error and you have a one-line, go ahead and to it on the same line. } ``` - -#### Comments +### Comments in C/C++ Do you know what we hate? Old-school C block comments. BUT, we're using them anyway. As we mentioned, our goal is to support every compiler we can, @@ -172,23 +161,20 @@ especially embedded compilers. There are STILL C compilers out there that only support old-school block comments. So that is what we're using. We apologize. We think they are ugly too. - ## Ruby Details Is there really such thing as a Ruby coding standard? Ruby is such a free form language, it seems almost sacrilegious to suggest that people should comply to one method! We'll keep it really brief! - -#### Whitespace +### Whitespace in Ruby Our Ruby style is to use spaces and to use 2 of them per indent level. It's a nice power-of-2 number that really grooves with Ruby's compact style. We have no more reason than that. We break that rule when we have lines that wrap. When that happens, we like to indent further to line things up in nice tidy columns. - -#### Case +### Case in Ruby - Files - all lower case with underscores. - Variables - all lower case with underscores @@ -196,11 +182,9 @@ that happens, we like to indent further to line things up in nice tidy columns. - Functions - all lower case with underscores - Constants - all upper case with underscores - ## Documentation Egad. Really? We use mark down and we like pdf files because they can be made to look nice while still being portable. Good enough? - *Find The Latest of This And More at [ThrowTheSwitch.org](https://throwtheswitch.org)* diff --git a/docs/UnityAssertionsReference.md b/docs/UnityAssertionsReference.md index 0957bcf6..09e251f6 100644 --- a/docs/UnityAssertionsReference.md +++ b/docs/UnityAssertionsReference.md @@ -16,7 +16,6 @@ source code in, well, test code. - Document types, expected values, and basic behavior in your source code for free. - ### Unity Is Several Things But Mainly It's Assertions One way to think of Unity is simply as a rich collection of assertions you can @@ -24,7 +23,6 @@ use to establish whether your source code behaves the way you think it does. Unity provides a framework to easily organize and execute those assertions in test code separate from your source code. - ### What's an Assertion? At their core, assertions are an establishment of truth - boolean truth. Was this @@ -44,7 +42,6 @@ support, it's far too tempting to litter source code with C's `assert()`'s. It's generally much cleaner, manageable, and more useful to separate test and source code in the way Unity facilitates. - ### Unity's Assertions: Helpful Messages _and_ Free Source Code Documentation Asserting a simple truth condition is valuable, but using the context of the @@ -60,34 +57,32 @@ tests pass, you have a detailed, up-to-date view of the intent and mechanisms in your source code. And due to a wondrous mystery, well-tested code usually tends to be well designed code. - ## Assertion Conventions and Configurations ### Naming and Parameter Conventions The convention of assertion parameters generally follows this order: -``` +```c TEST_ASSERT_X( {modifiers}, {expected}, actual, {size/count} ) ``` The very simplest assertion possible uses only a single `actual` parameter (e.g. a simple null check). - - `Actual` is the value being tested and unlike the other parameters in an - assertion construction is the only parameter present in all assertion variants. - - `Modifiers` are masks, ranges, bit flag specifiers, floating point deltas. - - `Expected` is your expected value (duh) to compare to an `actual` value; it's - marked as an optional parameter because some assertions only need a single - `actual` parameter (e.g. null check). - - `Size/count` refers to string lengths, number of array elements, etc. +- `Actual` is the value being tested and unlike the other parameters in an + assertion construction is the only parameter present in all assertion variants. +- `Modifiers` are masks, ranges, bit flag specifiers, floating point deltas. +- `Expected` is your expected value (duh) to compare to an `actual` value; it's + marked as an optional parameter because some assertions only need a single + `actual` parameter (e.g. null check). +- `Size/count` refers to string lengths, number of array elements, etc. Many of Unity's assertions are clear duplications in that the same data type is handled by several assertions. The differences among these are in how failure messages are presented. For instance, a `_HEX` variant of an assertion prints the expected and actual values of that assertion formatted as hexadecimal. - #### TEST_ASSERT_X_MESSAGE Variants _All_ assertions are complemented with a variant that includes a simple string @@ -100,17 +95,18 @@ the reference list below and add a string as the final parameter. _Example:_ -``` +```c TEST_ASSERT_X( {modifiers}, {expected}, actual, {size/count} ) ``` becomes messageified like thus... -``` +```c TEST_ASSERT_X_MESSAGE( {modifiers}, {expected}, actual, {size/count}, message ) ``` Notes: + - The `_MESSAGE` variants intentionally do not support `printf` style formatting since many embedded projects don't support or avoid `printf` for various reasons. It is possible to use `sprintf` before the assertion to assemble a complex fail @@ -119,7 +115,6 @@ Notes: a loop) , building up an array of results and then using one of the `_ARRAY` assertions (see below) might be a handy alternative to `sprintf`. - #### TEST_ASSERT_X_ARRAY Variants Unity provides a collection of assertions for arrays containing a variety of @@ -128,22 +123,21 @@ with the `_MESSAGE`variants of Unity's Asserts in that for pretty much any Unity type assertion you can tack on `_ARRAY` and run assertions on an entire block of memory. -``` +```c TEST_ASSERT_EQUAL_TYPEX_ARRAY( expected, actual, {size/count} ) ``` - - `Expected` is an array itself. - - `Size/count` is one or two parameters necessary to establish the number of array - elements and perhaps the length of elements within the array. +- `Expected` is an array itself. +- `Size/count` is one or two parameters necessary to establish the number of array + elements and perhaps the length of elements within the array. Notes: - - The `_MESSAGE` variant convention still applies here to array assertions. The - `_MESSAGE` variants of the `_ARRAY` assertions have names ending with - `_ARRAY_MESSAGE`. - - Assertions for handling arrays of floating point values are grouped with float - and double assertions (see immediately following section). - +- The `_MESSAGE` variant convention still applies here to array assertions. The + `_MESSAGE` variants of the `_ARRAY` assertions have names ending with + `_ARRAY_MESSAGE`. +- Assertions for handling arrays of floating point values are grouped with float + and double assertions (see immediately following section). ### TEST_ASSERT_EACH_EQUAL_X Variants @@ -153,21 +147,20 @@ the Each Equal section below. these are almost on par with the `_MESSAGE` variants of Unity's Asserts in that for pretty much any Unity type assertion you can inject `_EACH_EQUAL` and run assertions on an entire block of memory. -``` +```c TEST_ASSERT_EACH_EQUAL_TYPEX( expected, actual, {size/count} ) ``` - - `Expected` is a single value to compare to. - - `Actual` is an array where each element will be compared to the expected value. - - `Size/count` is one of two parameters necessary to establish the number of array - elements and perhaps the length of elements within the array. +- `Expected` is a single value to compare to. +- `Actual` is an array where each element will be compared to the expected value. +- `Size/count` is one of two parameters necessary to establish the number of array + elements and perhaps the length of elements within the array. Notes: - - The `_MESSAGE` variant convention still applies here to Each Equal assertions. - - Assertions for handling Each Equal of floating point values are grouped with - float and double assertions (see immediately following section). - +- The `_MESSAGE` variant convention still applies here to Each Equal assertions. +- Assertions for handling Each Equal of floating point values are grouped with + float and double assertions (see immediately following section). ### Configuration @@ -179,7 +172,6 @@ or disabled in Unity code. This is useful for embedded targets with no floating point math support (i.e. Unity compiles free of errors for fixed point only platforms). See Unity documentation for specifics. - #### Maximum Data Type Width Is Configurable Not all targets support 64 bit wide types or even 32 bit wide types. Define the @@ -187,14 +179,13 @@ appropriate preprocessor symbols and Unity will omit all operations from compilation that exceed the maximum width of your target. See Unity documentation for specifics. - ## The Assertions in All Their Blessed Glory ### Basic Fail, Pass and Ignore -##### `TEST_FAIL()` +#### `TEST_FAIL()` -##### `TEST_FAIL_MESSAGE("message")` +#### `TEST_FAIL_MESSAGE("message")` This fella is most often used in special conditions where your test code is performing logic beyond a simple assertion. That is, in practice, `TEST_FAIL()` @@ -207,25 +198,25 @@ code then verifies as a final step. - Triggering an exception and verifying it (as in Try / Catch / Throw - see the [CException](https://github.com/ThrowTheSwitch/CException) project). -##### `TEST_PASS()` +#### `TEST_PASS()` -##### `TEST_PASS_MESSAGE("message")` +#### `TEST_PASS_MESSAGE("message")` This will abort the remainder of the test, but count the test as a pass. Under normal circumstances, it is not necessary to include this macro in your tests... a lack of failure will automatically be counted as a `PASS`. It is occasionally useful for tests with `#ifdef`s and such. -##### `TEST_IGNORE()` +#### `TEST_IGNORE()` -##### `TEST_IGNORE_MESSAGE("message")` +#### `TEST_IGNORE_MESSAGE("message")` Marks a test case (i.e. function meant to contain test assertions) as ignored. Usually this is employed as a breadcrumb to come back and implement a test case. An ignored test case has effects if other assertions are in the enclosing test case (see Unity documentation for more). -##### `TEST_MESSAGE(message)` +#### `TEST_MESSAGE(message)` This can be useful for outputting `INFO` messages into the Unity output stream without actually ending the test. Like pass and fail messages, it will be output @@ -233,27 +224,27 @@ with the filename and line number. ### Boolean -##### `TEST_ASSERT (condition)` +#### `TEST_ASSERT (condition)` -##### `TEST_ASSERT_TRUE (condition)` +#### `TEST_ASSERT_TRUE (condition)` -##### `TEST_ASSERT_FALSE (condition)` +#### `TEST_ASSERT_FALSE (condition)` -##### `TEST_ASSERT_UNLESS (condition)` +#### `TEST_ASSERT_UNLESS (condition)` A simple wording variation on `TEST_ASSERT_FALSE`.The semantics of `TEST_ASSERT_UNLESS` aid readability in certain test constructions or conditional statements. -##### `TEST_ASSERT_NULL (pointer)` +#### `TEST_ASSERT_NULL (pointer)` -##### `TEST_ASSERT_NOT_NULL (pointer)` +#### `TEST_ASSERT_NOT_NULL (pointer)` Verify if a pointer is or is not NULL. -##### `TEST_ASSERT_EMPTY (pointer)` +#### `TEST_ASSERT_EMPTY (pointer)` -##### `TEST_ASSERT_NOT_EMPTY (pointer)` +#### `TEST_ASSERT_NOT_EMPTY (pointer)` Verify if the first element dereferenced from a pointer is or is not zero. This is particularly useful for checking for empty (or non-empty) null-terminated @@ -268,26 +259,25 @@ that would break compilation (see Unity documentation for more). Refer to Advanced Asserting later in this document for advice on dealing with other word sizes. -##### `TEST_ASSERT_EQUAL_INT (expected, actual)` +#### `TEST_ASSERT_EQUAL_INT (expected, actual)` -##### `TEST_ASSERT_EQUAL_INT8 (expected, actual)` +#### `TEST_ASSERT_EQUAL_INT8 (expected, actual)` -##### `TEST_ASSERT_EQUAL_INT16 (expected, actual)` +#### `TEST_ASSERT_EQUAL_INT16 (expected, actual)` -##### `TEST_ASSERT_EQUAL_INT32 (expected, actual)` +#### `TEST_ASSERT_EQUAL_INT32 (expected, actual)` -##### `TEST_ASSERT_EQUAL_INT64 (expected, actual)` +#### `TEST_ASSERT_EQUAL_INT64 (expected, actual)` -##### `TEST_ASSERT_EQUAL_UINT (expected, actual)` +#### `TEST_ASSERT_EQUAL_UINT (expected, actual)` -##### `TEST_ASSERT_EQUAL_UINT8 (expected, actual)` +#### `TEST_ASSERT_EQUAL_UINT8 (expected, actual)` -##### `TEST_ASSERT_EQUAL_UINT16 (expected, actual)` +#### `TEST_ASSERT_EQUAL_UINT16 (expected, actual)` -##### `TEST_ASSERT_EQUAL_UINT32 (expected, actual)` - -##### `TEST_ASSERT_EQUAL_UINT64 (expected, actual)` +#### `TEST_ASSERT_EQUAL_UINT32 (expected, actual)` +#### `TEST_ASSERT_EQUAL_UINT64 (expected, actual)` ### Unsigned Integers (of all sizes) in Hexadecimal @@ -295,16 +285,15 @@ All `_HEX` assertions are identical in function to unsigned integer assertions but produce failure messages with the `expected` and `actual` values formatted in hexadecimal. Unity output is big endian. -##### `TEST_ASSERT_EQUAL_HEX (expected, actual)` - -##### `TEST_ASSERT_EQUAL_HEX8 (expected, actual)` +#### `TEST_ASSERT_EQUAL_HEX (expected, actual)` -##### `TEST_ASSERT_EQUAL_HEX16 (expected, actual)` +#### `TEST_ASSERT_EQUAL_HEX8 (expected, actual)` -##### `TEST_ASSERT_EQUAL_HEX32 (expected, actual)` +#### `TEST_ASSERT_EQUAL_HEX16 (expected, actual)` -##### `TEST_ASSERT_EQUAL_HEX64 (expected, actual)` +#### `TEST_ASSERT_EQUAL_HEX32 (expected, actual)` +#### `TEST_ASSERT_EQUAL_HEX64 (expected, actual)` ### Characters @@ -312,36 +301,30 @@ While you can use the 8-bit integer assertions to compare `char`, another option to use this specialized assertion which will show printable characters as printables, otherwise showing the HEX escape code for the characters. -##### `TEST_ASSERT_EQUAL_CHAR (expected, actual)` - +#### `TEST_ASSERT_EQUAL_CHAR (expected, actual)` ### Masked and Bit-level Assertions Masked and bit-level assertions produce output formatted in hexadecimal. Unity output is big endian. - -##### `TEST_ASSERT_BITS (mask, expected, actual)` +#### `TEST_ASSERT_BITS (mask, expected, actual)` Only compares the masked (i.e. high) bits of `expected` and `actual` parameters. - -##### `TEST_ASSERT_BITS_HIGH (mask, actual)` +#### `TEST_ASSERT_BITS_HIGH (mask, actual)` Asserts the masked bits of the `actual` parameter are high. - -##### `TEST_ASSERT_BITS_LOW (mask, actual)` +#### `TEST_ASSERT_BITS_LOW (mask, actual)` Asserts the masked bits of the `actual` parameter are low. - -##### `TEST_ASSERT_BIT_HIGH (bit, actual)` +#### `TEST_ASSERT_BIT_HIGH (bit, actual)` Asserts the specified bit of the `actual` parameter is high. - -##### `TEST_ASSERT_BIT_LOW (bit, actual)` +#### `TEST_ASSERT_BIT_LOW (bit, actual)` Asserts the specified bit of the `actual` parameter is low. @@ -352,16 +335,15 @@ than `threshold` (exclusive). For example, if the threshold value is 0 for the greater than assertion will fail if it is 0 or less. There are assertions for all the various sizes of ints, as for the equality assertions. Some examples: -##### `TEST_ASSERT_GREATER_THAN_INT8 (threshold, actual)` +#### `TEST_ASSERT_GREATER_THAN_INT8 (threshold, actual)` -##### `TEST_ASSERT_GREATER_OR_EQUAL_INT16 (threshold, actual)` +#### `TEST_ASSERT_GREATER_OR_EQUAL_INT16 (threshold, actual)` -##### `TEST_ASSERT_LESS_THAN_INT32 (threshold, actual)` +#### `TEST_ASSERT_LESS_THAN_INT32 (threshold, actual)` -##### `TEST_ASSERT_LESS_OR_EQUAL_UINT (threshold, actual)` - -##### `TEST_ASSERT_NOT_EQUAL_UINT8 (threshold, actual)` +#### `TEST_ASSERT_LESS_OR_EQUAL_UINT (threshold, actual)` +#### `TEST_ASSERT_NOT_EQUAL_UINT8 (threshold, actual)` ### Integer Ranges (of all sizes) @@ -370,60 +352,57 @@ These assertions verify that the `expected` parameter is within +/- `delta` and the delta is 3 then the assertion will fail for any value outside the range of 7 - 13. -##### `TEST_ASSERT_INT_WITHIN (delta, expected, actual)` +#### `TEST_ASSERT_INT_WITHIN (delta, expected, actual)` -##### `TEST_ASSERT_INT8_WITHIN (delta, expected, actual)` +#### `TEST_ASSERT_INT8_WITHIN (delta, expected, actual)` -##### `TEST_ASSERT_INT16_WITHIN (delta, expected, actual)` +#### `TEST_ASSERT_INT16_WITHIN (delta, expected, actual)` -##### `TEST_ASSERT_INT32_WITHIN (delta, expected, actual)` +#### `TEST_ASSERT_INT32_WITHIN (delta, expected, actual)` -##### `TEST_ASSERT_INT64_WITHIN (delta, expected, actual)` +#### `TEST_ASSERT_INT64_WITHIN (delta, expected, actual)` -##### `TEST_ASSERT_UINT_WITHIN (delta, expected, actual)` +#### `TEST_ASSERT_UINT_WITHIN (delta, expected, actual)` -##### `TEST_ASSERT_UINT8_WITHIN (delta, expected, actual)` +#### `TEST_ASSERT_UINT8_WITHIN (delta, expected, actual)` -##### `TEST_ASSERT_UINT16_WITHIN (delta, expected, actual)` +#### `TEST_ASSERT_UINT16_WITHIN (delta, expected, actual)` -##### `TEST_ASSERT_UINT32_WITHIN (delta, expected, actual)` +#### `TEST_ASSERT_UINT32_WITHIN (delta, expected, actual)` -##### `TEST_ASSERT_UINT64_WITHIN (delta, expected, actual)` +#### `TEST_ASSERT_UINT64_WITHIN (delta, expected, actual)` -##### `TEST_ASSERT_HEX_WITHIN (delta, expected, actual)` +#### `TEST_ASSERT_HEX_WITHIN (delta, expected, actual)` -##### `TEST_ASSERT_HEX8_WITHIN (delta, expected, actual)` +#### `TEST_ASSERT_HEX8_WITHIN (delta, expected, actual)` -##### `TEST_ASSERT_HEX16_WITHIN (delta, expected, actual)` +#### `TEST_ASSERT_HEX16_WITHIN (delta, expected, actual)` -##### `TEST_ASSERT_HEX32_WITHIN (delta, expected, actual)` +#### `TEST_ASSERT_HEX32_WITHIN (delta, expected, actual)` -##### `TEST_ASSERT_HEX64_WITHIN (delta, expected, actual)` +#### `TEST_ASSERT_HEX64_WITHIN (delta, expected, actual)` -##### `TEST_ASSERT_CHAR_WITHIN (delta, expected, actual)` +#### `TEST_ASSERT_CHAR_WITHIN (delta, expected, actual)` ### Structs and Strings -##### `TEST_ASSERT_EQUAL_PTR (expected, actual)` +#### `TEST_ASSERT_EQUAL_PTR (expected, actual)` Asserts that the pointers point to the same memory location. - -##### `TEST_ASSERT_EQUAL_STRING (expected, actual)` +#### `TEST_ASSERT_EQUAL_STRING (expected, actual)` Asserts that the null terminated (`'\0'`)strings are identical. If strings are of different lengths or any portion of the strings before their terminators differ, the assertion fails. Two NULL strings (i.e. zero length) are considered equivalent. - -##### `TEST_ASSERT_EQUAL_MEMORY (expected, actual, len)` +#### `TEST_ASSERT_EQUAL_MEMORY (expected, actual, len)` Asserts that the contents of the memory specified by the `expected` and `actual` pointers is identical. The size of the memory blocks in bytes is specified by the `len` parameter. - ### Arrays `expected` and `actual` parameters are both arrays. `num_elements` specifies the @@ -438,43 +417,43 @@ For array of strings comparison behavior, see comments for Assertions fail upon the first element in the compared arrays found not to match. Failure messages specify the array index of the failed comparison. -##### `TEST_ASSERT_EQUAL_INT_ARRAY (expected, actual, num_elements)` +#### `TEST_ASSERT_EQUAL_INT_ARRAY (expected, actual, num_elements)` -##### `TEST_ASSERT_EQUAL_INT8_ARRAY (expected, actual, num_elements)` +#### `TEST_ASSERT_EQUAL_INT8_ARRAY (expected, actual, num_elements)` -##### `TEST_ASSERT_EQUAL_INT16_ARRAY (expected, actual, num_elements)` +#### `TEST_ASSERT_EQUAL_INT16_ARRAY (expected, actual, num_elements)` -##### `TEST_ASSERT_EQUAL_INT32_ARRAY (expected, actual, num_elements)` +#### `TEST_ASSERT_EQUAL_INT32_ARRAY (expected, actual, num_elements)` -##### `TEST_ASSERT_EQUAL_INT64_ARRAY (expected, actual, num_elements)` +#### `TEST_ASSERT_EQUAL_INT64_ARRAY (expected, actual, num_elements)` -##### `TEST_ASSERT_EQUAL_UINT_ARRAY (expected, actual, num_elements)` +#### `TEST_ASSERT_EQUAL_UINT_ARRAY (expected, actual, num_elements)` -##### `TEST_ASSERT_EQUAL_UINT8_ARRAY (expected, actual, num_elements)` +#### `TEST_ASSERT_EQUAL_UINT8_ARRAY (expected, actual, num_elements)` -##### `TEST_ASSERT_EQUAL_UINT16_ARRAY (expected, actual, num_elements)` +#### `TEST_ASSERT_EQUAL_UINT16_ARRAY (expected, actual, num_elements)` -##### `TEST_ASSERT_EQUAL_UINT32_ARRAY (expected, actual, num_elements)` +#### `TEST_ASSERT_EQUAL_UINT32_ARRAY (expected, actual, num_elements)` -##### `TEST_ASSERT_EQUAL_UINT64_ARRAY (expected, actual, num_elements)` +#### `TEST_ASSERT_EQUAL_UINT64_ARRAY (expected, actual, num_elements)` -##### `TEST_ASSERT_EQUAL_HEX_ARRAY (expected, actual, num_elements)` +#### `TEST_ASSERT_EQUAL_HEX_ARRAY (expected, actual, num_elements)` -##### `TEST_ASSERT_EQUAL_HEX8_ARRAY (expected, actual, num_elements)` +#### `TEST_ASSERT_EQUAL_HEX8_ARRAY (expected, actual, num_elements)` -##### `TEST_ASSERT_EQUAL_HEX16_ARRAY (expected, actual, num_elements)` +#### `TEST_ASSERT_EQUAL_HEX16_ARRAY (expected, actual, num_elements)` -##### `TEST_ASSERT_EQUAL_HEX32_ARRAY (expected, actual, num_elements)` +#### `TEST_ASSERT_EQUAL_HEX32_ARRAY (expected, actual, num_elements)` -##### `TEST_ASSERT_EQUAL_HEX64_ARRAY (expected, actual, num_elements)` +#### `TEST_ASSERT_EQUAL_HEX64_ARRAY (expected, actual, num_elements)` -##### `TEST_ASSERT_EQUAL_CHAR_ARRAY (expected, actual, num_elements)` +#### `TEST_ASSERT_EQUAL_CHAR_ARRAY (expected, actual, num_elements)` -##### `TEST_ASSERT_EQUAL_PTR_ARRAY (expected, actual, num_elements)` +#### `TEST_ASSERT_EQUAL_PTR_ARRAY (expected, actual, num_elements)` -##### `TEST_ASSERT_EQUAL_STRING_ARRAY (expected, actual, num_elements)` +#### `TEST_ASSERT_EQUAL_STRING_ARRAY (expected, actual, num_elements)` -##### `TEST_ASSERT_EQUAL_MEMORY_ARRAY (expected, actual, len, num_elements)` +#### `TEST_ASSERT_EQUAL_MEMORY_ARRAY (expected, actual, len, num_elements)` `len` is the memory in bytes to be compared at each array element. @@ -485,37 +464,37 @@ These assertions verify that the `expected` array parameter is within +/- `delta \[10, 12\] and the delta is 3 then the assertion will fail for any value outside the range of \[7 - 13, 9 - 15\]. -##### `TEST_ASSERT_INT_ARRAY_WITHIN (delta, expected, actual, num_elements)` +#### `TEST_ASSERT_INT_ARRAY_WITHIN (delta, expected, actual, num_elements)` -##### `TEST_ASSERT_INT8_ARRAY_WITHIN (delta, expected, actual, num_elements)` +#### `TEST_ASSERT_INT8_ARRAY_WITHIN (delta, expected, actual, num_elements)` -##### `TEST_ASSERT_INT16_ARRAY_WITHIN (delta, expected, actual, num_elements)` +#### `TEST_ASSERT_INT16_ARRAY_WITHIN (delta, expected, actual, num_elements)` -##### `TEST_ASSERT_INT32_ARRAY_WITHIN (delta, expected, actual, num_elements)` +#### `TEST_ASSERT_INT32_ARRAY_WITHIN (delta, expected, actual, num_elements)` -##### `TEST_ASSERT_INT64_ARRAY_WITHIN (delta, expected, actual, num_elements)` +#### `TEST_ASSERT_INT64_ARRAY_WITHIN (delta, expected, actual, num_elements)` -##### `TEST_ASSERT_UINT_ARRAY_WITHIN (delta, expected, actual, num_elements)` +#### `TEST_ASSERT_UINT_ARRAY_WITHIN (delta, expected, actual, num_elements)` -##### `TEST_ASSERT_UINT8_ARRAY_WITHIN (delta, expected, actual, num_elements)` +#### `TEST_ASSERT_UINT8_ARRAY_WITHIN (delta, expected, actual, num_elements)` -##### `TEST_ASSERT_UINT16_ARRAY_WITHIN (delta, expected, actual, num_elements)` +#### `TEST_ASSERT_UINT16_ARRAY_WITHIN (delta, expected, actual, num_elements)` -##### `TEST_ASSERT_UINT32_ARRAY_WITHIN (delta, expected, actual, num_elements)` +#### `TEST_ASSERT_UINT32_ARRAY_WITHIN (delta, expected, actual, num_elements)` -##### `TEST_ASSERT_UINT64_ARRAY_WITHIN (delta, expected, actual, num_elements)` +#### `TEST_ASSERT_UINT64_ARRAY_WITHIN (delta, expected, actual, num_elements)` -##### `TEST_ASSERT_HEX_ARRAY_WITHIN (delta, expected, actual, num_elements)` +#### `TEST_ASSERT_HEX_ARRAY_WITHIN (delta, expected, actual, num_elements)` -##### `TEST_ASSERT_HEX8_ARRAY_WITHIN (delta, expected, actual, num_elements)` +#### `TEST_ASSERT_HEX8_ARRAY_WITHIN (delta, expected, actual, num_elements)` -##### `TEST_ASSERT_HEX16_ARRAY_WITHIN (delta, expected, actual, num_elements)` +#### `TEST_ASSERT_HEX16_ARRAY_WITHIN (delta, expected, actual, num_elements)` -##### `TEST_ASSERT_HEX32_ARRAY_WITHIN (delta, expected, actual, num_elements)` +#### `TEST_ASSERT_HEX32_ARRAY_WITHIN (delta, expected, actual, num_elements)` -##### `TEST_ASSERT_HEX64_ARRAY_WITHIN (delta, expected, actual, num_elements)` +#### `TEST_ASSERT_HEX64_ARRAY_WITHIN (delta, expected, actual, num_elements)` -##### `TEST_ASSERT_CHAR_ARRAY_WITHIN (delta, expected, actual, num_elements)` +#### `TEST_ASSERT_CHAR_ARRAY_WITHIN (delta, expected, actual, num_elements)` ### Each Equal (Arrays to Single Value) @@ -568,17 +547,15 @@ match. Failure messages specify the array index of the failed comparison. `len` is the memory in bytes to be compared at each array element. - ### Floating Point (If enabled) -##### `TEST_ASSERT_FLOAT_WITHIN (delta, expected, actual)` +#### `TEST_ASSERT_FLOAT_WITHIN (delta, expected, actual)` Asserts that the `actual` value is within +/- `delta` of the `expected` value. The nature of floating point representation is such that exact evaluations of equality are not guaranteed. - -##### `TEST_ASSERT_EQUAL_FLOAT (expected, actual)` +#### `TEST_ASSERT_EQUAL_FLOAT (expected, actual)` Asserts that the ?actual?value is "close enough to be considered equal" to the `expected` value. If you are curious about the details, refer to the Advanced @@ -586,74 +563,63 @@ Asserting section for more details on this. Omitting a user-specified delta in a floating point assertion is both a shorthand convenience and a requirement of code generation conventions for CMock. - -##### `TEST_ASSERT_EQUAL_FLOAT_ARRAY (expected, actual, num_elements)` +#### `TEST_ASSERT_EQUAL_FLOAT_ARRAY (expected, actual, num_elements)` See Array assertion section for details. Note that individual array element float comparisons are executed using T?EST_ASSERT_EQUAL_FLOAT?.That is, user specified delta comparison values requires a custom-implemented floating point array assertion. - -##### `TEST_ASSERT_FLOAT_IS_INF (actual)` +#### `TEST_ASSERT_FLOAT_IS_INF (actual)` Asserts that `actual` parameter is equivalent to positive infinity floating point representation. - -##### `TEST_ASSERT_FLOAT_IS_NEG_INF (actual)` +#### `TEST_ASSERT_FLOAT_IS_NEG_INF (actual)` Asserts that `actual` parameter is equivalent to negative infinity floating point representation. - -##### `TEST_ASSERT_FLOAT_IS_NAN (actual)` +#### `TEST_ASSERT_FLOAT_IS_NAN (actual)` Asserts that `actual` parameter is a Not A Number floating point representation. - -##### `TEST_ASSERT_FLOAT_IS_DETERMINATE (actual)` +#### `TEST_ASSERT_FLOAT_IS_DETERMINATE (actual)` Asserts that ?actual?parameter is a floating point representation usable for mathematical operations. That is, the `actual` parameter is neither positive infinity nor negative infinity nor Not A Number floating point representations. - -##### `TEST_ASSERT_FLOAT_IS_NOT_INF (actual)` +#### `TEST_ASSERT_FLOAT_IS_NOT_INF (actual)` Asserts that `actual` parameter is a value other than positive infinity floating point representation. - -##### `TEST_ASSERT_FLOAT_IS_NOT_NEG_INF (actual)` +#### `TEST_ASSERT_FLOAT_IS_NOT_NEG_INF (actual)` Asserts that `actual` parameter is a value other than negative infinity floating point representation. - -##### `TEST_ASSERT_FLOAT_IS_NOT_NAN (actual)` +#### `TEST_ASSERT_FLOAT_IS_NOT_NAN (actual)` Asserts that `actual` parameter is a value other than Not A Number floating point representation. - -##### `TEST_ASSERT_FLOAT_IS_NOT_DETERMINATE (actual)` +#### `TEST_ASSERT_FLOAT_IS_NOT_DETERMINATE (actual)` Asserts that `actual` parameter is not usable for mathematical operations. That is, the `actual` parameter is either positive infinity or negative infinity or Not A Number floating point representations. - ### Double (If enabled) -##### `TEST_ASSERT_DOUBLE_WITHIN (delta, expected, actual)` +#### `TEST_ASSERT_DOUBLE_WITHIN (delta, expected, actual)` Asserts that the `actual` value is within +/- `delta` of the `expected` value. The nature of floating point representation is such that exact evaluations of equality are not guaranteed. - -##### `TEST_ASSERT_EQUAL_DOUBLE (expected, actual)` +#### `TEST_ASSERT_EQUAL_DOUBLE (expected, actual)` Asserts that the `actual` value is "close enough to be considered equal" to the `expected` value. If you are curious about the details, refer to the Advanced @@ -661,64 +627,54 @@ Asserting section for more details. Omitting a user-specified delta in a floating point assertion is both a shorthand convenience and a requirement of code generation conventions for CMock. - -##### `TEST_ASSERT_EQUAL_DOUBLE_ARRAY (expected, actual, num_elements)` +#### `TEST_ASSERT_EQUAL_DOUBLE_ARRAY (expected, actual, num_elements)` See Array assertion section for details. Note that individual array element double comparisons are executed using `TEST_ASSERT_EQUAL_DOUBLE`.That is, user specified delta comparison values requires a custom implemented double array assertion. - -##### `TEST_ASSERT_DOUBLE_IS_INF (actual)` +#### `TEST_ASSERT_DOUBLE_IS_INF (actual)` Asserts that `actual` parameter is equivalent to positive infinity floating point representation. - -##### `TEST_ASSERT_DOUBLE_IS_NEG_INF (actual)` +#### `TEST_ASSERT_DOUBLE_IS_NEG_INF (actual)` Asserts that `actual` parameter is equivalent to negative infinity floating point representation. - -##### `TEST_ASSERT_DOUBLE_IS_NAN (actual)` +#### `TEST_ASSERT_DOUBLE_IS_NAN (actual)` Asserts that `actual` parameter is a Not A Number floating point representation. - -##### `TEST_ASSERT_DOUBLE_IS_DETERMINATE (actual)` +#### `TEST_ASSERT_DOUBLE_IS_DETERMINATE (actual)` Asserts that `actual` parameter is a floating point representation usable for mathematical operations. That is, the ?actual?parameter is neither positive infinity nor negative infinity nor Not A Number floating point representations. - -##### `TEST_ASSERT_DOUBLE_IS_NOT_INF (actual)` +#### `TEST_ASSERT_DOUBLE_IS_NOT_INF (actual)` Asserts that `actual` parameter is a value other than positive infinity floating point representation. - -##### `TEST_ASSERT_DOUBLE_IS_NOT_NEG_INF (actual)` +#### `TEST_ASSERT_DOUBLE_IS_NOT_NEG_INF (actual)` Asserts that `actual` parameter is a value other than negative infinity floating point representation. - -##### `TEST_ASSERT_DOUBLE_IS_NOT_NAN (actual)` +#### `TEST_ASSERT_DOUBLE_IS_NOT_NAN (actual)` Asserts that `actual` parameter is a value other than Not A Number floating point representation. - -##### `TEST_ASSERT_DOUBLE_IS_NOT_DETERMINATE (actual)` +#### `TEST_ASSERT_DOUBLE_IS_NOT_DETERMINATE (actual)` Asserts that `actual` parameter is not usable for mathematical operations. That is, the `actual` parameter is either positive infinity or negative infinity or Not A Number floating point representations. - ## Advanced Asserting: Details On Tricky Assertions This section helps you understand how to deal with some of the trickier @@ -727,7 +683,6 @@ the under-the-hood details of Unity's assertion mechanisms. If you're one of those people who likes to know what is going on in the background, read on. If not, feel free to ignore the rest of this document until you need it. - ### How do the EQUAL assertions work for FLOAT and DOUBLE? As you may know, directly checking for equality between a pair of floats or a @@ -768,7 +723,6 @@ assertions less strict, you can change these multipliers to whatever you like by defining UNITY_FLOAT_PRECISION and UNITY_DOUBLE_PRECISION. See Unity documentation for more. - ### How do we deal with targets with non-standard int sizes? It's "fun" that C is a standard where something as fundamental as an integer @@ -827,5 +781,4 @@ operations, particularly `TEST_ASSERT_INT_WITHIN`.Such assertions might wrap your `int` in the wrong place, and you could experience false failures. You can always back down to a simple `TEST_ASSERT` and do the operations yourself. - *Find The Latest of This And More at [ThrowTheSwitch.org](https://throwtheswitch.org)* diff --git a/docs/UnityConfigurationGuide.md b/docs/UnityConfigurationGuide.md index b4386d92..e2e3d8e5 100644 --- a/docs/UnityConfigurationGuide.md +++ b/docs/UnityConfigurationGuide.md @@ -22,7 +22,6 @@ challenging to build. From a more positive perspective, it is also proof that a great deal of complexity can be centralized primarily to one place to provide a more consistent and simple experience elsewhere. - ### Using These Options It doesn't matter if you're using a target-specific compiler and a simulator or @@ -58,8 +57,7 @@ certainly not every compiler you are likely to encounter. Therefore, Unity has a number of features for helping to adjust itself to match your required integer sizes. It starts off by trying to do it automatically. - -##### `UNITY_EXCLUDE_STDINT_H` +#### `UNITY_EXCLUDE_STDINT_H` The first thing that Unity does to guess your types is check `stdint.h`. This file includes defines like `UINT_MAX` that Unity can use to @@ -70,18 +68,19 @@ That way, Unity will know to skip the inclusion of this file and you won't be left with a compiler error. _Example:_ + ```C #define UNITY_EXCLUDE_STDINT_H ``` - -##### `UNITY_EXCLUDE_LIMITS_H` +#### `UNITY_EXCLUDE_LIMITS_H` The second attempt to guess your types is to check `limits.h`. Some compilers that don't support `stdint.h` could include `limits.h` instead. If you don't want Unity to check this file either, define this to make it skip the inclusion. _Example:_ + ```C #define UNITY_EXCLUDE_LIMITS_H ``` @@ -91,19 +90,18 @@ do the configuration yourself. Don't worry. Even this isn't too bad... there are just a handful of defines that you are going to specify if you don't like the defaults. - -##### `UNITY_INT_WIDTH` +#### `UNITY_INT_WIDTH` Define this to be the number of bits an `int` takes up on your system. The default, if not autodetected, is 32 bits. _Example:_ + ```C #define UNITY_INT_WIDTH 16 ``` - -##### `UNITY_LONG_WIDTH` +#### `UNITY_LONG_WIDTH` Define this to be the number of bits a `long` takes up on your system. The default, if not autodetected, is 32 bits. This is used to figure out what kind @@ -112,12 +110,12 @@ of 64-bit support your system can handle. Does it need to specify a `long` or a ignored. _Example:_ + ```C #define UNITY_LONG_WIDTH 16 ``` - -##### `UNITY_POINTER_WIDTH` +#### `UNITY_POINTER_WIDTH` Define this to be the number of bits a pointer takes up on your system. The default, if not autodetected, is 32-bits. If you're getting ugly compiler @@ -129,6 +127,7 @@ width of 23-bit), choose the next power of two (in this case 32-bit). _Supported values:_ 16, 32 and 64 _Example:_ + ```C // Choose on of these #defines to set your pointer width (if not autodetected) //#define UNITY_POINTER_WIDTH 16 @@ -136,8 +135,7 @@ _Example:_ #define UNITY_POINTER_WIDTH 64 // Set UNITY_POINTER_WIDTH to 64-bit ``` - -##### `UNITY_SUPPORT_64` +#### `UNITY_SUPPORT_64` Unity will automatically include 64-bit support if it auto-detects it, or if your `int`, `long`, or pointer widths are greater than 32-bits. Define this to @@ -146,11 +144,11 @@ can be a significant size and speed impact to enabling 64-bit support on small targets, so don't define it if you don't need it. _Example:_ + ```C #define UNITY_SUPPORT_64 ``` - ### Floating Point Types In the embedded world, it's not uncommon for targets to have no support for @@ -160,14 +158,13 @@ are always available in at least one size. Floating point, on the other hand, is sometimes not available at all. Trying to include `float.h` on these platforms would result in an error. This leaves manual configuration as the only option. +#### `UNITY_INCLUDE_FLOAT` -##### `UNITY_INCLUDE_FLOAT` - -##### `UNITY_EXCLUDE_FLOAT` +#### `UNITY_EXCLUDE_FLOAT` -##### `UNITY_INCLUDE_DOUBLE` +#### `UNITY_INCLUDE_DOUBLE` -##### `UNITY_EXCLUDE_DOUBLE` +#### `UNITY_EXCLUDE_DOUBLE` By default, Unity guesses that you will want single precision floating point support, but not double precision. It's easy to change either of these using the @@ -176,14 +173,14 @@ suits your needs. For features that are enabled, the following floating point options also become available. _Example:_ + ```C //what manner of strange processor is this? #define UNITY_EXCLUDE_FLOAT #define UNITY_INCLUDE_DOUBLE ``` - -##### `UNITY_EXCLUDE_FLOAT_PRINT` +#### `UNITY_EXCLUDE_FLOAT_PRINT` Unity aims for as small of a footprint as possible and avoids most standard library calls (some embedded platforms don’t have a standard library!). Because @@ -196,24 +193,24 @@ can use this define to instead respond to a failed assertion with a message like point assertions, use these options to give more explicit failure messages. _Example:_ + ```C #define UNITY_EXCLUDE_FLOAT_PRINT ``` - -##### `UNITY_FLOAT_TYPE` +#### `UNITY_FLOAT_TYPE` If enabled, Unity assumes you want your `FLOAT` asserts to compare standard C floats. If your compiler supports a specialty floating point type, you can always override this behavior by using this definition. _Example:_ + ```C #define UNITY_FLOAT_TYPE float16_t ``` - -##### `UNITY_DOUBLE_TYPE` +#### `UNITY_DOUBLE_TYPE` If enabled, Unity assumes you want your `DOUBLE` asserts to compare standard C doubles. If you would like to change this, you can specify something else by @@ -222,14 +219,14 @@ could enable gargantuan floating point types on your 64-bit processor instead of the standard `double`. _Example:_ + ```C #define UNITY_DOUBLE_TYPE long double ``` +#### `UNITY_FLOAT_PRECISION` -##### `UNITY_FLOAT_PRECISION` - -##### `UNITY_DOUBLE_PRECISION` +#### `UNITY_DOUBLE_PRECISION` If you look up `UNITY_ASSERT_EQUAL_FLOAT` and `UNITY_ASSERT_EQUAL_DOUBLE` as documented in the big daddy Unity Assertion Guide, you will learn that they are @@ -243,14 +240,14 @@ For further details on how this works, see the appendix of the Unity Assertion Guide. _Example:_ + ```C #define UNITY_FLOAT_PRECISION 0.001f ``` - ### Miscellaneous -##### `UNITY_EXCLUDE_STDDEF_H` +#### `UNITY_EXCLUDE_STDDEF_H` Unity uses the `NULL` macro, which defines the value of a null pointer constant, defined in `stddef.h` by default. If you want to provide @@ -258,11 +255,11 @@ your own macro for this, you should exclude the `stddef.h` header file by adding define to your configuration. _Example:_ + ```C #define UNITY_EXCLUDE_STDDEF_H ``` - #### `UNITY_INCLUDE_PRINT_FORMATTED` Unity provides a simple (and very basic) printf-like string output implementation, @@ -282,6 +279,7 @@ which is able to print a string modified by the following format string modifier - __%%__ - The "%" symbol (escaped) _Example:_ + ```C #define UNITY_INCLUDE_PRINT_FORMATTED @@ -300,7 +298,6 @@ TEST_PRINTF("\n"); TEST_PRINTF("Multiple (%d) (%i) (%u) (%x)\n", -100, 0, 200, 0x12345); ``` - ### Toolset Customization In addition to the options listed above, there are a number of other options @@ -310,14 +307,13 @@ certain platforms, particularly those running in simulators, may need to jump through extra hoops to run properly. These macros will help in those situations. +#### `UNITY_OUTPUT_CHAR(a)` -##### `UNITY_OUTPUT_CHAR(a)` - -##### `UNITY_OUTPUT_FLUSH()` +#### `UNITY_OUTPUT_FLUSH()` -##### `UNITY_OUTPUT_START()` +#### `UNITY_OUTPUT_START()` -##### `UNITY_OUTPUT_COMPLETE()` +#### `UNITY_OUTPUT_COMPLETE()` By default, Unity prints its results to `stdout` as it runs. This works perfectly fine in most situations where you are using a native compiler for @@ -333,6 +329,7 @@ _Example:_ Say you are forced to run your test suite on an embedded processor with no `stdout` option. You decide to route your test result output to a custom serial `RS232_putc()` function you wrote like thus: + ```C #include "RS232_header.h" ... @@ -346,44 +343,43 @@ _Note:_ `UNITY_OUTPUT_FLUSH()` can be set to the standard out flush function simply by specifying `UNITY_USE_FLUSH_STDOUT`. No other defines are required. +#### `UNITY_OUTPUT_FOR_ECLIPSE` -##### `UNITY_OUTPUT_FOR_ECLIPSE` - -##### `UNITY_OUTPUT_FOR_IAR_WORKBENCH` +#### `UNITY_OUTPUT_FOR_IAR_WORKBENCH` -##### `UNITY_OUTPUT_FOR_QT_CREATOR` +#### `UNITY_OUTPUT_FOR_QT_CREATOR` When managing your own builds, it is often handy to have messages output in a format which is recognized by your IDE. These are some standard formats which can be supported. If you're using Ceedling to manage your builds, it is better to stick with the standard format (leaving these all undefined) and allow Ceedling to use its own decorators. - -##### `UNITY_PTR_ATTRIBUTE` +#### `UNITY_PTR_ATTRIBUTE` Some compilers require a custom attribute to be assigned to pointers, like `near` or `far`. In these cases, you can give Unity a safe default for these by defining this option with the attribute you would like. _Example:_ + ```C #define UNITY_PTR_ATTRIBUTE __attribute__((far)) #define UNITY_PTR_ATTRIBUTE near ``` -##### `UNITY_PRINT_EOL` +#### `UNITY_PRINT_EOL` By default, Unity outputs \n at the end of each line of output. This is easy to parse by the scripts, by Ceedling, etc, but it might not be ideal for YOUR system. Feel free to override this and to make it whatever you wish. _Example:_ + ```C #define UNITY_PRINT_EOL { UNITY_OUTPUT_CHAR('\r'); UNITY_OUTPUT_CHAR('\n'); } ``` - -##### `UNITY_EXCLUDE_DETAILS` +#### `UNITY_EXCLUDE_DETAILS` This is an option for if you absolutely must squeeze every byte of memory out of your system. Unity stores a set of internal scratchpads which are used to pass @@ -392,11 +388,12 @@ report which function or argument flagged an error. If you're not using CMock an you're not using these details for other things, then you can exclude them. _Example:_ + ```C #define UNITY_EXCLUDE_DETAILS ``` -##### `UNITY_PRINT_TEST_CONTEXT` +#### `UNITY_PRINT_TEST_CONTEXT` This option allows you to specify your own function to print additional context as part of the error message when a test has failed. It can be useful if you @@ -404,6 +401,7 @@ want to output some specific information about the state of the test at the poin of failure, and `UNITY_SET_DETAILS` isn't flexible enough for your needs. _Example:_ + ```C #define UNITY_PRINT_TEST_CONTEXT PrintIterationCount @@ -415,7 +413,7 @@ void PrintIterationCount(void) } ``` -##### `UNITY_EXCLUDE_SETJMP` +#### `UNITY_EXCLUDE_SETJMP` If your embedded system doesn't support the standard library setjmp, you can exclude Unity's reliance on this by using this define. This dropped dependence @@ -425,23 +423,28 @@ compiler doesn't support setjmp, you wouldn't have had the memory space for thos things anyway, though... so this option exists for those situations. _Example:_ + ```C #define UNITY_EXCLUDE_SETJMP ``` -##### `UNITY_OUTPUT_COLOR` +#### `UNITY_OUTPUT_COLOR` If you want to add color using ANSI escape codes you can use this define. _Example:_ + ```C #define UNITY_OUTPUT_COLOR ``` -##### `UNITY_SHORTHAND_AS_INT` -##### `UNITY_SHORTHAND_AS_MEM` -##### `UNITY_SHORTHAND_AS_RAW` -##### `UNITY_SHORTHAND_AS_NONE` +#### `UNITY_SHORTHAND_AS_INT` + +#### `UNITY_SHORTHAND_AS_MEM` + +#### `UNITY_SHORTHAND_AS_RAW` + +#### `UNITY_SHORTHAND_AS_NONE` These options give you control of the `TEST_ASSERT_EQUAL` and the `TEST_ASSERT_NOT_EQUAL` shorthand assertions. Historically, Unity treated the @@ -450,15 +453,15 @@ comparison using `!=`. This assymetry was confusing, but there was much disagreement as to how best to treat this pair of assertions. These four options will allow you to specify how Unity will treat these assertions. - - AS INT - the values will be cast to integers and directly compared. Arguments - that don't cast easily to integers will cause compiler errors. - - AS MEM - the address of both values will be taken and the entire object's - memory footprint will be compared byte by byte. Directly placing - constant numbers like `456` as expected values will cause errors. - - AS_RAW - Unity assumes that you can compare the two values using `==` and `!=` - and will do so. No details are given about mismatches, because it - doesn't really know what type it's dealing with. - - AS_NONE - Unity will disallow the use of these shorthand macros altogether, +- AS INT - the values will be cast to integers and directly compared. Arguments + that don't cast easily to integers will cause compiler errors. +- AS MEM - the address of both values will be taken and the entire object's + memory footprint will be compared byte by byte. Directly placing + constant numbers like `456` as expected values will cause errors. +- AS_RAW - Unity assumes that you can compare the two values using `==` and `!=` + and will do so. No details are given about mismatches, because it + doesn't really know what type it's dealing with. +- AS_NONE - Unity will disallow the use of these shorthand macros altogether, insisting that developers choose a more descriptive option. #### `UNITY_SUPPORT_VARIADIC_MACROS` @@ -482,8 +485,7 @@ require special help. This special help will usually reside in one of two places: the `main()` function or the `RUN_TEST` macro. Let's look at how these work. - -##### `main()` +### `main()` Each test module is compiled and run on its own, separate from the other test files in your project. Each test file, therefore, has a `main` function. This @@ -515,8 +517,7 @@ after all the test cases have completed. This allows you to do any needed system-wide setup or teardown that might be required for your special circumstances. - -##### `RUN_TEST` +#### `RUN_TEST` The `RUN_TEST` macro is called with each test case function. Its job is to perform whatever setup and teardown is necessary for executing a single test @@ -552,12 +553,10 @@ each result set. Again, you could do this by adding lines to this macro. Updates to this macro are for the occasions when you need an action before or after every single test case throughout your entire suite of tests. - ## Happy Porting The defines and macros in this guide should help you port Unity to just about any C target we can imagine. If you run into a snag or two, don't be afraid of asking for help on the forums. We love a good challenge! - *Find The Latest of This And More at [ThrowTheSwitch.org](https://throwtheswitch.org)* diff --git a/docs/UnityGettingStartedGuide.md b/docs/UnityGettingStartedGuide.md index a0fb035e..85f8d4df 100644 --- a/docs/UnityGettingStartedGuide.md +++ b/docs/UnityGettingStartedGuide.md @@ -17,7 +17,6 @@ rules. Unity has been used with many compilers, including GCC, IAR, Clang, Green Hills, Microchip, and MS Visual Studio. It's not much work to get it to work with a new target. - ### Overview of the Documents #### Unity Assertions reference @@ -26,21 +25,18 @@ This document will guide you through all the assertion options provided by Unity. This is going to be your unit testing bread and butter. You'll spend more time with assertions than any other part of Unity. - #### Unity Assertions Cheat Sheet This document contains an abridged summary of the assertions described in the previous document. It's perfect for printing and referencing while you familiarize yourself with Unity's options. - #### Unity Configuration Guide This document is the one to reference when you are going to use Unity with a new target or compiler. It'll guide you through the configuration options and will help you customize your testing experience to meet your needs. - #### Unity Helper Scripts This document describes the helper scripts that are available for simplifying @@ -49,7 +45,6 @@ included in the auto directory of your Unity installation. Neither Ruby nor these scripts are necessary for using Unity. They are provided as a convenience for those who wish to use them. - #### Unity License What's an open source project without a license file? This brief document @@ -57,7 +52,6 @@ describes the terms you're agreeing to when you use this software. Basically, we want it to be useful to you in whatever context you want to use it, but please don't blame us if you run into problems. - ### Overview of the Folders If you have obtained Unity through Github or something similar, you might be @@ -82,7 +76,6 @@ everything is configured properly. - `auto` - Here you will find helpful Ruby scripts for simplifying your test workflow. They are purely optional and are not required to make use of Unity. - ## How to Create A Test File Test files are C files. Most often you will create a single test file for each C @@ -156,21 +149,27 @@ For that sort of thing, you're going to want to look at the configuration guide. This should be enough to get you going, though. ### Running Test Functions + When writing your own `main()` functions, for a test-runner. There are two ways to execute the test. The classic variant + ``` c RUN_TEST(func, linenum) ``` + or its simpler replacement that starts at the beginning of the function. + ``` c RUN_TEST(func) ``` + These macros perform the necessary setup before the test is called and -handles cleanup and result tabulation afterwards. +handles clean-up and result tabulation afterwards. ### Ignoring Test Functions + There are times when a test is incomplete or not valid for some reason. At these times, TEST_IGNORE can be called. Control will immediately be returned to the caller of the test, and no failures will be returned. @@ -182,25 +181,31 @@ TEST_IGNORE() Ignore this test and return immediately -``` c +```c TEST_IGNORE_MESSAGE (message) ``` Ignore this test and return immediately. Output a message stating why the test was ignored. ### Aborting Tests + There are times when a test will contain an infinite loop on error conditions, or there may be reason to escape from the test early without executing the rest of the test. A pair of macros support this functionality in Unity. The first `TEST_PROTECT` sets up the feature, and handles emergency abort cases. `TEST_ABORT` can then be used at any time within the tests to return to the last `TEST_PROTECT` call. +```c TEST_PROTECT() +``` Setup and Catch macro +```c TEST_ABORT() +``` Abort Test macro Example: +```c main() { if (TEST_PROTECT()) @@ -208,11 +213,10 @@ Example: MyTest(); } } +``` If MyTest calls `TEST_ABORT`, program control will immediately return to `TEST_PROTECT` with a return value of zero. - - ## How to Build and Run A Test File This is the single biggest challenge to picking up a new unit testing framework, @@ -225,6 +229,7 @@ You have two really good options for toolchains. Depending on where you're coming from, it might surprise you that neither of these options is running the unit tests on your hardware. There are many reasons for this, but here's a short version: + - On hardware, you have too many constraints (processing power, memory, etc), - On hardware, you don't have complete control over all registers, - On hardware, unit testing is more challenging, @@ -247,5 +252,4 @@ This flexibility of separating tests into individual executables allows us to much more thoroughly unit test our system and it keeps all the test code out of our final release! - *Find The Latest of This And More at [ThrowTheSwitch.org](https://throwtheswitch.org)* diff --git a/docs/UnityHelperScriptsGuide.md b/docs/UnityHelperScriptsGuide.md index 0c173e61..a95e9efd 100644 --- a/docs/UnityHelperScriptsGuide.md +++ b/docs/UnityHelperScriptsGuide.md @@ -8,7 +8,6 @@ easier. They are completely optional. If you choose to use them, you'll need a copy of Ruby, of course. Just install whatever the latest version is, and it is likely to work. You can find Ruby at [ruby-lang.org](https://ruby-labg.org/). - ### `generate_test_runner.rb` Are you tired of creating your own `main` function in your test file? Do you @@ -114,21 +113,19 @@ test_files.each do |f| end ``` -#### Options accepted by generate_test_runner.rb: +#### Options accepted by generate_test_runner.rb The following options are available when executing `generate_test_runner`. You may pass these as a Ruby hash directly or specify them in a YAML file, both of which are described above. In the `examples` directory, Example 3's Rakefile demonstrates using a Ruby hash. - ##### `:includes` This option specifies an array of file names to be `#include`'d at the top of your runner C file. You might use it to reference custom types or anything else universally needed in your generated runners. - ##### `:suite_setup` Define this option with C code to be executed _before any_ test cases are run. @@ -138,7 +135,6 @@ option unset and instead provide a `void suiteSetUp(void)` function in your test suite. The linker will look for this symbol and fall back to a Unity-provided stub if it is not found. - ##### `:suite_teardown` Define this option with C code to be executed _after all_ test cases have @@ -151,7 +147,6 @@ option unset and instead provide a `int suiteTearDown(int num_failures)` function in your test suite. The linker will look for this symbol and fall back to a Unity-provided stub if it is not found. - ##### `:enforce_strict_ordering` This option should be defined if you have the strict order feature enabled in @@ -159,7 +154,6 @@ CMock (see CMock documentation). This generates extra variables required for everything to run smoothly. If you provide the same YAML to the generator as used in CMock's configuration, you've already configured the generator properly. - ##### `:externc` This option should be defined if you are mixing C and CPP and want your test @@ -206,7 +200,6 @@ This option specifies the pattern for matching acceptable source file extensions By default it will accept cpp, cc, C, c, and ino files. If you need a different combination of files to search, update this from the default `'(?:cpp|cc|ino|C|c)'`. - ### `unity_test_summary.rb` A Unity test file contains one or more test case functions. Each test case can @@ -274,5 +267,4 @@ OVERALL UNITY TEST SUMMARY How convenient is that? - *Find The Latest of This And More at [ThrowTheSwitch.org](https://throwtheswitch.org)* diff --git a/extras/fixture/readme.md b/extras/fixture/readme.md index 2e0c2f06..d36e46ef 100644 --- a/extras/fixture/readme.md +++ b/extras/fixture/readme.md @@ -1,7 +1,7 @@ # Unity Fixtures This Framework is an optional add-on to Unity. By including unity_framework.h in place of unity.h, -you may now work with Unity in a manner similar to CppUTest. This framework adds the concepts of +you may now work with Unity in a manner similar to CppUTest. This framework adds the concepts of test groups and gives finer control of your tests over the command line. This framework is primarily supplied for those working through James Grenning's book on Embedded @@ -9,14 +9,14 @@ Test Driven Development, or those coming to Unity from CppUTest. We should note framework glosses over some of the features of Unity, and makes it more difficult to integrate with other testing tools like Ceedling and CMock. -# Dependency Notification +## Dependency Notification Fixtures, by default, uses the Memory addon as well. This is to make it simple for those trying to -follow along with James' book. Using them together is completely optional. You may choose to use +follow along with James' book. Using them together is completely optional. You may choose to use Fixtures without Memory handling by defining `UNITY_FIXTURE_NO_EXTRAS`. It will then stop automatically pulling in extras and leave you to do it as desired. -# Usage information +## Usage information By default the test executables produced by Unity Fixtures run all tests once, but the behavior can be configured with command-line flags. Run the test executable with the `--help` flag for more diff --git a/extras/memory/readme.md b/extras/memory/readme.md index 37769825..0c56d418 100644 --- a/extras/memory/readme.md +++ b/extras/memory/readme.md @@ -1,49 +1,49 @@ # Unity Memory This Framework is an optional add-on to Unity. By including unity.h and then -unity_memory.h, you have the added ability to track malloc and free calls. This +unity_memory.h, you have the added ability to track malloc and free calls. This addon requires that the stdlib functions be overridden by its own defines. These defines will still malloc / realloc / free etc, but will also track the calls in order to ensure that you don't have any memory leaks in your programs. Note that this is only useful in situations where a unit is in charge of both -the allocation and deallocation of memory. When it is not symmetric, unit testing +the allocation and deallocation of memory. When it is not symmetric, unit testing can report a number of false failures. A more advanced runtime tool is required to track complete system memory handling. -# Module API +## Module API -## `UnityMalloc_StartTest` and `UnityMalloc_EndTest` +### `UnityMalloc_StartTest` and `UnityMalloc_EndTest` These must be called at the beginning and end of each test. For simplicity, they can be added to `setUp` and `tearDown` in order to do their job. When using the test runner generator scripts, these will be automatically added to the runner whenever unity_memory.h is included. -## `UnityMalloc_MakeMallocFailAfterCount` +### `UnityMalloc_MakeMallocFailAfterCount` This can be called from the tests themselves. Passing this function a number will force the reference counter to start keeping track of malloc calls. During that test, -if the number of malloc calls exceeds the number given, malloc will immediately -start returning `NULL`. This allows you to test error conditions. Think of it as a +if the number of malloc calls exceeds the number given, malloc will immediately +start returning `NULL`. This allows you to test error conditions. Think of it as a simplified mock. -# Configuration +## Configuration -## `UNITY_MALLOC` and `UNITY_FREE` +### `UNITY_MALLOC` and `UNITY_FREE` -By default, this module tries to use the real stdlib `malloc` and `free` internally. -If you would prefer it to use something else, like FreeRTOS's `pvPortMalloc` and +By default, this module tries to use the real stdlib `malloc` and `free` internally. +If you would prefer it to use something else, like FreeRTOS's `pvPortMalloc` and `pvPortFree`, then you can use these defines to make it so. -## `UNITY_EXCLUDE_STDLIB_MALLOC` +### `UNITY_EXCLUDE_STDLIB_MALLOC` If you would like this library to ignore stdlib or other heap engines completely, and manage the memory on its own, then define this. All memory will be handled internally (and at likely lower overhead). Note that this is not a very featureful memory manager, but is sufficient for most testing purposes. -## `UNITY_INTERNAL_HEAP_SIZE_BYTES` +### `UNITY_INTERNAL_HEAP_SIZE_BYTES` When using the built-in memory manager (see `UNITY_EXCLUDE_STDLIB_MALLOC`) this define allows you to set the heap size this library will use to manage the memory. From 8b90b51c683764d96b1cebd596d8ff42bd82c042 Mon Sep 17 00:00:00 2001 From: wolf99 <281700+wolf99@users.noreply.github.com> Date: Wed, 2 Jun 2021 22:10:19 +0100 Subject: [PATCH 286/454] Reference style URLs --- README.md | 13 +++++++++---- docs/ThrowTheSwitchCodingStandard.md | 4 +++- docs/UnityAssertionsReference.md | 7 +++++-- docs/UnityConfigurationGuide.md | 4 +++- docs/UnityGettingStartedGuide.md | 7 +++++-- docs/UnityHelperScriptsGuide.md | 15 ++++++++++----- 6 files changed, 35 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index ea775c2c..0bd68129 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Unity Test ![CI](https://github.com/ThrowTheSwitch/Unity/workflows/CI/badge.svg) +# Unity Test ![CI][] __Copyright (c) 2007 - 2021 Unity Project by Mike Karlesky, Mark VanderVoord, and Greg Williams__ @@ -11,16 +11,16 @@ too much headache. You may use any compiler you wish, and may use most existing including Make, CMake, etc. If you'd like to leave the hard work to us, you might be interested in Ceedling, a build tool also by ThrowTheSwitch.org. -If you're new to Unity, we encourage you to tour the [getting started guide](docs/UnityGettingStartedGuide.md) +If you're new to Unity, we encourage you to tour the [getting started guide][]. ## Getting Started -The [docs](docs/) folder contains a [getting started guide](docs/UnityGettingStartedGuide.md) +The [docs][] folder contains a [getting started guide][] and much more tips about using Unity. ## Unity Assertion Summary -For the full list, see [UnityAssertionsReference.md](docs/UnityAssertionsReference.md). +For the full list, see [UnityAssertionsReference.md][]. ### Basic Validity Tests @@ -185,3 +185,8 @@ standard types... but since it's a memory compare, you have to be careful that y you can append `\_MESSAGE` to any of the macros to make them take an additional argument. This argument is a string that will be printed at the end of the failure strings. This is useful for specifying more information about the problem. + +[CI]: https://github.com/ThrowTheSwitch/Unity/workflows/CI/badge.svg +[getting started guide]: docs/UnityGettingStartedGuide.md +[docs]: docs/ +[UnityAssertionsReference.md]: docs/UnityAssertionsReference.md diff --git a/docs/ThrowTheSwitchCodingStandard.md b/docs/ThrowTheSwitchCodingStandard.md index 29787c87..bb977f09 100644 --- a/docs/ThrowTheSwitchCodingStandard.md +++ b/docs/ThrowTheSwitchCodingStandard.md @@ -187,4 +187,6 @@ that happens, we like to indent further to line things up in nice tidy columns. Egad. Really? We use mark down and we like pdf files because they can be made to look nice while still being portable. Good enough? -*Find The Latest of This And More at [ThrowTheSwitch.org](https://throwtheswitch.org)* +*Find The Latest of This And More at [ThrowTheSwitch.org][]* + +[ThrowTheSwitch.org]: https://throwtheswitch.org \ No newline at end of file diff --git a/docs/UnityAssertionsReference.md b/docs/UnityAssertionsReference.md index 09e251f6..f618c727 100644 --- a/docs/UnityAssertionsReference.md +++ b/docs/UnityAssertionsReference.md @@ -34,7 +34,7 @@ execution and reports an error through some appropriate I/O channel (e.g. stdout, GUI, file, blinky light). Fundamentally, for dynamic verification all you need is a single assertion -mechanism. In fact, that's what the [assert() macro in C's standard library](http://en.wikipedia.org/en/wiki/Assert.h) +mechanism. In fact, that's what the [assert() macro][] in C's standard library is for. So why not just use it? Well, we can do far better in the reporting department. C's `assert()` is pretty dumb as-is and is particularly poor for handling common data types like arrays, structs, etc. And, without some other @@ -781,4 +781,7 @@ operations, particularly `TEST_ASSERT_INT_WITHIN`.Such assertions might wrap your `int` in the wrong place, and you could experience false failures. You can always back down to a simple `TEST_ASSERT` and do the operations yourself. -*Find The Latest of This And More at [ThrowTheSwitch.org](https://throwtheswitch.org)* +*Find The Latest of This And More at [ThrowTheSwitch.org][]* + +[assert() macro]: http://en.wikipedia.org/en/wiki/Assert.h +[ThrowTheSwitch.org]: https://throwtheswitch.org diff --git a/docs/UnityConfigurationGuide.md b/docs/UnityConfigurationGuide.md index e2e3d8e5..eddc79cf 100644 --- a/docs/UnityConfigurationGuide.md +++ b/docs/UnityConfigurationGuide.md @@ -559,4 +559,6 @@ The defines and macros in this guide should help you port Unity to just about any C target we can imagine. If you run into a snag or two, don't be afraid of asking for help on the forums. We love a good challenge! -*Find The Latest of This And More at [ThrowTheSwitch.org](https://throwtheswitch.org)* +*Find The Latest of This And More at [ThrowTheSwitch.org][]* + +[ThrowTheSwitch.org]: https://throwtheswitch.org diff --git a/docs/UnityGettingStartedGuide.md b/docs/UnityGettingStartedGuide.md index 85f8d4df..039364f6 100644 --- a/docs/UnityGettingStartedGuide.md +++ b/docs/UnityGettingStartedGuide.md @@ -108,7 +108,7 @@ call. Remembering to add each test to the main function can get to be tedious. If you enjoy using helper scripts in your build process, you might consider making use -of our handy [generate_test_runner.rb](../auto/generate_test_runner.rb) script. +of our handy [generate_test_runner.rb][] script. This will create the main function and all the calls for you, assuming that you have followed the suggested naming conventions. In this case, there is no need for you to include the main function in your test file at all. @@ -252,4 +252,7 @@ This flexibility of separating tests into individual executables allows us to much more thoroughly unit test our system and it keeps all the test code out of our final release! -*Find The Latest of This And More at [ThrowTheSwitch.org](https://throwtheswitch.org)* +*Find The Latest of This And More at [ThrowTheSwitch.org][]* + +[generate_test_runner.rb]: ../auto/generate_test_runner.rb +[ThrowTheSwitch.org]: https://throwtheswitch.org diff --git a/docs/UnityHelperScriptsGuide.md b/docs/UnityHelperScriptsGuide.md index a95e9efd..c2e91fe8 100644 --- a/docs/UnityHelperScriptsGuide.md +++ b/docs/UnityHelperScriptsGuide.md @@ -6,7 +6,7 @@ Sometimes what it takes to be a really efficient C programmer is a little non-C. The Unity project includes a couple of Ruby scripts for making your life just a tad easier. They are completely optional. If you choose to use them, you'll need a copy of Ruby, of course. Just install whatever the latest version is, and it is -likely to work. You can find Ruby at [ruby-lang.org](https://ruby-labg.org/). +likely to work. You can find Ruby at [ruby-lang.org][]. ### `generate_test_runner.rb` @@ -54,7 +54,7 @@ generated file. The example immediately below will create TestFile_Runner.c. ruby generate_test_runner.rb TestFile.c ``` -You can also add a [YAML](http://www.yaml.org/) file to configure extra options. +You can also add a [YAML][] file to configure extra options. Conveniently, this YAML file is of the same format as that used by Unity and CMock. So if you are using YAML files already, you can simply pass the very same file into the generator script. @@ -216,8 +216,8 @@ ignored and failing tests in this project generate corresponding entries in the summary report. If you're interested in other (prettier?) output formats, check into the -Ceedling build tool project (ceedling.sourceforge.net) that works with Unity and -CMock and supports xunit-style xml as well as other goodies. +[Ceedling][] build tool project that works with Unity and CMock and supports +xunit-style xml as well as other goodies. This script assumes the existence of files ending with the extensions `.testpass` and `.testfail`.The contents of these files includes the test @@ -267,4 +267,9 @@ OVERALL UNITY TEST SUMMARY How convenient is that? -*Find The Latest of This And More at [ThrowTheSwitch.org](https://throwtheswitch.org)* +*Find The Latest of This And More at [ThrowTheSwitch.org][]* + +[ruby-lang.org]: https://ruby-labg.org/ +[YAML]: http://www.yaml.org/ +[Ceedling]: http://www.throwtheswitch.org/ceedling +[ThrowTheSwitch.org]: https://throwtheswitch.org From 00a1d02835f77e7fed630904e02aba94f511f2c5 Mon Sep 17 00:00:00 2001 From: wolf99 <281700+wolf99@users.noreply.github.com> Date: Wed, 2 Jun 2021 22:19:43 +0100 Subject: [PATCH 287/454] Break on sentences instead of column --- README.md | 98 ++++--- docs/ThrowTheSwitchCodingStandard.md | 195 +++++++------ docs/UnityConfigurationGuide.md | 409 ++++++++++++--------------- docs/UnityGettingStartedGuide.md | 208 +++++++------- docs/UnityHelperScriptsGuide.md | 178 +++++------- extras/fixture/readme.md | 31 +- extras/memory/readme.md | 45 ++- 7 files changed, 529 insertions(+), 635 deletions(-) diff --git a/README.md b/README.md index 0bd68129..20ccb3c0 100644 --- a/README.md +++ b/README.md @@ -2,21 +2,19 @@ __Copyright (c) 2007 - 2021 Unity Project by Mike Karlesky, Mark VanderVoord, and Greg Williams__ -Welcome to the Unity Test Project, one of the main projects of ThrowTheSwitch.org. Unity Test is a -unit testing framework built for C, with a focus on working with embedded toolchains. +Welcome to the Unity Test Project, one of the main projects of ThrowTheSwitch.org. +Unity Test is a unit testing framework built for C, with a focus on working with embedded toolchains. -This project is made to test code targetting microcontrollers big and small. The core project is a -single C file and a pair of headers, allowing it to the added to your existing build setup without -too much headache. You may use any compiler you wish, and may use most existing build systems -including Make, CMake, etc. If you'd like to leave the hard work to us, you might be interested -in Ceedling, a build tool also by ThrowTheSwitch.org. +This project is made to test code targetting microcontrollers big and small. +The core project is a single C file and a pair of headers, allowing it to the added to your existing build setup without too much headache. +You may use any compiler you wish, and may use most existing build systems including Make, CMake, etc. +If you'd like to leave the hard work to us, you might be interested in Ceedling, a build tool also by ThrowTheSwitch.org. If you're new to Unity, we encourage you to tour the [getting started guide][]. ## Getting Started -The [docs][] folder contains a [getting started guide][] -and much more tips about using Unity. +The [docs][] folder contains a [getting started guide][] and much more tips about using Unity. ## Unity Assertion Summary @@ -43,7 +41,8 @@ Another way of calling `TEST_ASSERT_FALSE` TEST_FAIL() TEST_FAIL_MESSAGE(message) -This test is automatically marked as a failure. The message is output stating why. +This test is automatically marked as a failure. +The message is output stating why. ### Numerical Assertions: Integers @@ -53,9 +52,9 @@ This test is automatically marked as a failure. The message is output stating wh TEST_ASSERT_EQUAL_INT32(expected, actual) TEST_ASSERT_EQUAL_INT64(expected, actual) -Compare two integers for equality and display errors as signed integers. A cast will be performed -to your natural integer size so often this can just be used. When you need to specify the exact size, -like when comparing arrays, you can use a specific version: +Compare two integers for equality and display errors as signed integers. +A cast will be performed to your natural integer size so often this can just be used. +When you need to specify the exact size, like when comparing arrays, you can use a specific version: TEST_ASSERT_EQUAL_UINT(expected, actual) TEST_ASSERT_EQUAL_UINT8(expected, actual) @@ -63,8 +62,8 @@ like when comparing arrays, you can use a specific version: TEST_ASSERT_EQUAL_UINT32(expected, actual) TEST_ASSERT_EQUAL_UINT64(expected, actual) -Compare two integers for equality and display errors as unsigned integers. Like INT, there are -variants for different sizes also. +Compare two integers for equality and display errors as unsigned integers. +Like INT, there are variants for different sizes also. TEST_ASSERT_EQUAL_HEX(expected, actual) TEST_ASSERT_EQUAL_HEX8(expected, actual) @@ -72,9 +71,8 @@ variants for different sizes also. TEST_ASSERT_EQUAL_HEX32(expected, actual) TEST_ASSERT_EQUAL_HEX64(expected, actual) -Compares two integers for equality and display errors as hexadecimal. Like the other integer comparisons, -you can specify the size... here the size will also effect how many nibbles are shown (for example, `HEX16` -will show 4 nibbles). +Compares two integers for equality and display errors as hexadecimal. +Like the other integer comparisons, you can specify the size... here the size will also effect how many nibbles are shown (for example, `HEX16` will show 4 nibbles). TEST_ASSERT_EQUAL(expected, actual) @@ -82,31 +80,35 @@ Another way of calling TEST_ASSERT_EQUAL_INT TEST_ASSERT_INT_WITHIN(delta, expected, actual) -Asserts that the actual value is within plus or minus delta of the expected value. This also comes in -size specific variants. +Asserts that the actual value is within plus or minus delta of the expected value. +This also comes in size specific variants. TEST_ASSERT_GREATER_THAN(threshold, actual) -Asserts that the actual value is greater than the threshold. This also comes in size specific variants. +Asserts that the actual value is greater than the threshold. +This also comes in size specific variants. TEST_ASSERT_LESS_THAN(threshold, actual) -Asserts that the actual value is less than the threshold. This also comes in size specific variants. +Asserts that the actual value is less than the threshold. +This also comes in size specific variants. ### Arrays _ARRAY -You can append `_ARRAY` to any of these macros to make an array comparison of that type. Here you will -need to care a bit more about the actual size of the value being checked. You will also specify an -additional argument which is the number of elements to compare. For example: +You can append `_ARRAY` to any of these macros to make an array comparison of that type. +Here you will need to care a bit more about the actual size of the value being checked. +You will also specify an additional argument which is the number of elements to compare. +For example: TEST_ASSERT_EQUAL_HEX8_ARRAY(expected, actual, elements) _EACH_EQUAL -Another array comparison option is to check that EVERY element of an array is equal to a single expected -value. You do this by specifying the EACH_EQUAL macro. For example: +Another array comparison option is to check that EVERY element of an array is equal to a single expected value. +You do this by specifying the EACH_EQUAL macro. +For example: TEST_ASSERT_EACH_EQUAL_INT32(expected, actual, elements) @@ -114,23 +116,28 @@ value. You do this by specifying the EACH_EQUAL macro. For example: TEST_ASSERT_BITS(mask, expected, actual) -Use an integer mask to specify which bits should be compared between two other integers. High bits in the mask are compared, low bits ignored. +Use an integer mask to specify which bits should be compared between two other integers. +High bits in the mask are compared, low bits ignored. TEST_ASSERT_BITS_HIGH(mask, actual) -Use an integer mask to specify which bits should be inspected to determine if they are all set high. High bits in the mask are compared, low bits ignored. +Use an integer mask to specify which bits should be inspected to determine if they are all set high. +High bits in the mask are compared, low bits ignored. TEST_ASSERT_BITS_LOW(mask, actual) -Use an integer mask to specify which bits should be inspected to determine if they are all set low. High bits in the mask are compared, low bits ignored. +Use an integer mask to specify which bits should be inspected to determine if they are all set low. +High bits in the mask are compared, low bits ignored. TEST_ASSERT_BIT_HIGH(bit, actual) -Test a single bit and verify that it is high. The bit is specified 0-31 for a 32-bit integer. +Test a single bit and verify that it is high. +The bit is specified 0-31 for a 32-bit integer. TEST_ASSERT_BIT_LOW(bit, actual) -Test a single bit and verify that it is low. The bit is specified 0-31 for a 32-bit integer. +Test a single bit and verify that it is low. +The bit is specified 0-31 for a 32-bit integer. ### Numerical Assertions: Floats @@ -147,23 +154,30 @@ Asserts that two floating point values are "equal" within a small % delta of the TEST_ASSERT_EQUAL_STRING(expected, actual) -Compare two null-terminate strings. Fail if any character is different or if the lengths are different. +Compare two null-terminate strings. +Fail if any character is different or if the lengths are different. TEST_ASSERT_EQUAL_STRING_LEN(expected, actual, len) -Compare two strings. Fail if any character is different, stop comparing after len characters. +Compare two strings. +Fail if any character is different, stop comparing after len characters. TEST_ASSERT_EQUAL_STRING_MESSAGE(expected, actual, message) -Compare two null-terminate strings. Fail if any character is different or if the lengths are different. Output a custom message on failure. +Compare two null-terminate strings. +Fail if any character is different or if the lengths are different. +Output a custom message on failure. TEST_ASSERT_EQUAL_STRING_LEN_MESSAGE(expected, actual, len, message) -Compare two strings. Fail if any character is different, stop comparing after len characters. Output a custom message on failure. +Compare two strings. +Fail if any character is different, stop comparing after len characters. +Output a custom message on failure. ### Pointer Assertions -Most pointer operations can be performed by simply using the integer comparisons above. However, a couple of special cases are added for clarity. +Most pointer operations can be performed by simply using the integer comparisons above. +However, a couple of special cases are added for clarity. TEST_ASSERT_NULL(pointer) @@ -177,14 +191,14 @@ Fails if the pointer is equal to NULL TEST_ASSERT_EQUAL_MEMORY(expected, actual, len) -Compare two blocks of memory. This is a good generic assertion for types that can't be coerced into acting like -standard types... but since it's a memory compare, you have to be careful that your data types are packed. +Compare two blocks of memory. +This is a good generic assertion for types that can't be coerced into acting like standard types... but since it's a memory compare, you have to be careful that your data types are packed. ### \_MESSAGE -you can append `\_MESSAGE` to any of the macros to make them take an additional argument. This argument -is a string that will be printed at the end of the failure strings. This is useful for specifying more -information about the problem. +You can append `\_MESSAGE` to any of the macros to make them take an additional argument. +This argument is a string that will be printed at the end of the failure strings. +This is useful for specifying more information about the problem. [CI]: https://github.com/ThrowTheSwitch/Unity/workflows/CI/badge.svg [getting started guide]: docs/UnityGettingStartedGuide.md diff --git a/docs/ThrowTheSwitchCodingStandard.md b/docs/ThrowTheSwitchCodingStandard.md index bb977f09..517b8fb6 100644 --- a/docs/ThrowTheSwitchCodingStandard.md +++ b/docs/ThrowTheSwitchCodingStandard.md @@ -1,58 +1,51 @@ # ThrowTheSwitch.org Coding Standard -Hi. Welcome to the coding standard for ThrowTheSwitch.org. For the most part, -we try to follow these standards to unify our contributors' code into a cohesive -unit (puns intended). You might find places where these standards aren't -followed. We're not perfect. Please be polite where you notice these discrepancies -and we'll try to be polite when we notice yours. +Hi. +Welcome to the coding standard for ThrowTheSwitch.org. +For the most part, we try to follow these standards to unify our contributors' code into a cohesive unit (puns intended). +You might find places where these standards aren't followed. +We're not perfect. Please be polite where you notice these discrepancies and we'll try to be polite when we notice yours. ;) ## Why Have A Coding Standard? -Being consistent makes code easier to understand. We've tried to keep -our standard simple because we also believe that we can only expect someone to -follow something that is understandable. Please do your best. +Being consistent makes code easier to understand. +We've tried to keep our standard simple because we also believe that we can only expect someone to follow something that is understandable. +Please do your best. ## Our Philosophy -Before we get into details on syntax, let's take a moment to talk about our -vision for these tools. We're C developers and embedded software developers. -These tools are great to test any C code, but catering to embedded software has -made us more tolerant of compiler quirks. There are a LOT of quirky compilers -out there. By quirky I mean "doesn't follow standards because they feel like -they have a license to do as they wish." - -Our philosophy is "support every compiler we can". Most often, this means that -we aim for writing C code that is standards compliant (often C89... that seems -to be a sweet spot that is almost always compatible). But it also means these -tools are tolerant of things that aren't common. Some that aren't even -compliant. There are configuration options to override the size of standard -types. There are configuration options to force Unity to not use certain -standard library functions. A lot of Unity is configurable and we have worked -hard to make it not TOO ugly in the process. - -Similarly, our tools that parse C do their best. They aren't full C parsers -(yet) and, even if they were, they would still have to accept non-standard -additions like gcc extensions or specifying `@0x1000` to force a variable to -compile to a particular location. It's just what we do, because we like -everything to Just Work™. - -Speaking of having things Just Work™, that's our second philosophy. By that, we -mean that we do our best to have EVERY configuration option have a logical -default. We believe that if you're working with a simple compiler and target, -you shouldn't need to configure very much... we try to make the tools guess as -much as they can, but give the user the power to override it when it's wrong. +Before we get into details on syntax, let's take a moment to talk about our vision for these tools. +We're C developers and embedded software developers. +These tools are great to test any C code, but catering to embedded software made us more tolerant of compiler quirks. +There are a LOT of quirky compilers out there. +By quirky I mean "doesn't follow standards because they feel like they have a license to do as they wish." + +Our philosophy is "support every compiler we can". +Most often, this means that we aim for writing C code that is standards compliant (often C89... that seems to be a sweet spot that is almost always compatible). +But it also means these tools are tolerant of things that aren't common. +Some that aren't even compliant. +There are configuration options to override the size of standard types. +There are configuration options to force Unity to not use certain standard library functions. +A lot of Unity is configurable and we have worked hard to make it not TOO ugly in the process. + +Similarly, our tools that parse C do their best. +They aren't full C parsers (yet) and, even if they were, they would still have to accept non-standard additions like gcc extensions or specifying `@0x1000` to force a variable to compile to a particular location. +It's just what we do, because we like everything to Just Work™. + +Speaking of having things Just Work™, that's our second philosophy. +By that, we mean that we do our best to have EVERY configuration option have a logical default. +We believe that if you're working with a simple compiler and target, you shouldn't need to configure very much... we try to make the tools guess as much as they can, but give the user the power to override it when it's wrong. ## Naming Things -Let's talk about naming things. Programming is all about naming things. We name -files, functions, variables, and so much more. While we're not always going to -find the best name for something, we actually put a bit of effort into -finding *What Something WANTS to be Called*™. +Let's talk about naming things. +Programming is all about naming things. +We name files, functions, variables, and so much more. +While we're not always going to find the best name for something, we actually put a bit of effort into finding *What Something WANTS to be Called*™. -When naming things, we follow this hierarchy, the first being the -most important to us (but we do all four when possible): +When naming things, we follow this hierarchy, the first being the most important to us (but we do all four when possible): 1. Readable 2. Descriptive @@ -61,68 +54,63 @@ most important to us (but we do all four when possible): ### Readable -We want to read our code. This means we like names and flow that are more -naturally read. We try to avoid double negatives. We try to avoid cryptic -abbreviations (sticking to ones we feel are common). +We want to read our code. +This means we like names and flow that are more naturally read. +We try to avoid double negatives. +We try to avoid cryptic abbreviations (sticking to ones we feel are common). ### Descriptive We like descriptive names for things, especially functions and variables. -Finding the right name for something is an important endeavor. You might notice -from poking around our code that this often results in names that are a little -longer than the average. Guilty. We're okay with a bit more typing if it -means our code is easier to understand. +Finding the right name for something is an important endeavour. +You might notice from poking around our code that this often results in names that are a little longer than the average. +Guilty. +We're okay with a bit more typing if it means our code is easier to understand. -There are two exceptions to this rule that we also stick to as religiously as -possible: +There are two exceptions to this rule that we also stick to as religiously as possible: -First, while we realize hungarian notation (and similar systems for encoding -type information into variable names) is providing a more descriptive name, we -feel that (for the average developer) it takes away from readability and is to be avoided. +First, while we realize hungarian notation (and similar systems for encoding type information into variable names) is providing a more descriptive name, we feel that (for the average developer) it takes away from readability and is to be avoided. -Second, loop counters and other local throw-away variables often have a purpose -which is obvious. There's no need, therefore, to get carried away with complex -naming. We find i, j, and k are better loop counters than loopCounterVar or -whatnot. We only break this rule when we see that more description could improve -understanding of an algorithm. +Second, loop counters and other local throw-away variables often have a purpose which is obvious. +There's no need, therefore, to get carried away with complex naming. +We find i, j, and k are better loop counters than loopCounterVar or whatnot. +We only break this rule when we see that more description could improve understanding of an algorithm. ### Consistent -We like consistency, but we're not really obsessed with it. We try to name our -configuration macros in a consistent fashion... you'll notice a repeated use of -UNITY_EXCLUDE_BLAH or UNITY_USES_BLAH macros. This helps users avoid having to -remember each macro's details. +We like consistency, but we're not really obsessed with it. +We try to name our configuration macros in a consistent fashion... you'll notice a repeated use of UNITY_EXCLUDE_BLAH or UNITY_USES_BLAH macros. +This helps users avoid having to remember each macro's details. ### Memorable -Where ever it doesn't violate the above principles, we try to apply memorable -names. Sometimes this means using something that is simply descriptive, but -often we strive for descriptive AND unique... we like quirky names that stand -out in our memory and are easier to search for. Take a look through the file -names in Ceedling and you'll get a good idea of what we are talking about here. -Why use preprocess when you can use preprocessinator? Or what better describes a -module in charge of invoking tasks during releases than release_invoker? Don't -get carried away. The names are still descriptive and fulfil the above -requirements, but they don't feel stale. +Where ever it doesn't violate the above principles, we try to apply memorable names. +Sometimes this means using something that is simply descriptive, but often we strive for descriptive AND unique... we like quirky names that stand out in our memory and are easier to search for. +Take a look through the file names in Ceedling and you'll get a good idea of what we are talking about here. +Why use preprocess when you can use preprocessinator? +Or what better describes a module in charge of invoking tasks during releases than release_invoker? +Don't get carried away. +The names are still descriptive and fulfil the above requirements, but they don't feel stale. ## C and C++ Details -We don't really want to add to the style battles out there. Tabs or spaces? -How many spaces? Where do the braces go? These are age-old questions that will -never be answered... or at least not answered in a way that will make everyone -happy. +We don't really want to add to the style battles out there. +Tabs or spaces? +How many spaces? +Where do the braces go? +These are age-old questions that will never be answered... or at least not answered in a way that will make everyone happy. -We've decided on our own style preferences. If you'd like to contribute to these -projects (and we hope that you do), then we ask if you do your best to follow -the same. It will only hurt a little. We promise. +We've decided on our own style preferences. +If you'd like to contribute to these projects (and we hope that you do), then we ask if you do your best to follow the same. +It will only hurt a little. We promise. ### Whitespace in C/C++ -Our C-style is to use spaces and to use 4 of them per indent level. It's a nice -power-of-2 number that looks decent on a wide-screen. We have no more reason -than that. We break that rule when we have lines that wrap (macros or function -arguments or whatnot). When that happens, we like to indent further to line -things up in nice tidy columns. +Our C-style is to use spaces and to use 4 of them per indent level. +It's a nice power-of-2 number that looks decent on a wide-screen. +We have no more reason than that. +We break that rule when we have lines that wrap (macros or function arguments or whatnot). +When that happens, we like to indent further to line things up in nice tidy columns. ```C if (stuff_happened) @@ -142,9 +130,10 @@ things up in nice tidy columns. ### Braces in C/C++ -The left brace is on the next line after the declaration. The right brace is -directly below that. Everything in between in indented one level. If you're -catching an error and you have a one-line, go ahead and to it on the same line. +The left brace is on the next line after the declaration. +The right brace is directly below that. +Everything in between in indented one level. +If you're catching an error and you have a one-line, go ahead and to it on the same line. ```C while (blah) @@ -155,24 +144,28 @@ catching an error and you have a one-line, go ahead and to it on the same line. ### Comments in C/C++ -Do you know what we hate? Old-school C block comments. BUT, we're using them -anyway. As we mentioned, our goal is to support every compiler we can, -especially embedded compilers. There are STILL C compilers out there that only -support old-school block comments. So that is what we're using. We apologize. We -think they are ugly too. +Do you know what we hate? +Old-school C block comments. +BUT, we're using them anyway. +As we mentioned, our goal is to support every compiler we can, especially embedded compilers. +There are STILL C compilers out there that only support old-school block comments. +So that is what we're using. +We apologize. +We think they are ugly too. ## Ruby Details -Is there really such thing as a Ruby coding standard? Ruby is such a free form -language, it seems almost sacrilegious to suggest that people should comply to -one method! We'll keep it really brief! +Is there really such thing as a Ruby coding standard? +Ruby is such a free form language, it seems almost sacrilegious to suggest that people should comply to one method! +We'll keep it really brief! ### Whitespace in Ruby -Our Ruby style is to use spaces and to use 2 of them per indent level. It's a -nice power-of-2 number that really grooves with Ruby's compact style. We have no -more reason than that. We break that rule when we have lines that wrap. When -that happens, we like to indent further to line things up in nice tidy columns. +Our Ruby style is to use spaces and to use 2 of them per indent level. +It's a nice power-of-2 number that really grooves with Ruby's compact style. +We have no more reason than that. +We break that rule when we have lines that wrap. +When that happens, we like to indent further to line things up in nice tidy columns. ### Case in Ruby @@ -184,8 +177,10 @@ that happens, we like to indent further to line things up in nice tidy columns. ## Documentation -Egad. Really? We use mark down and we like pdf files because they can be made to -look nice while still being portable. Good enough? +Egad. +Really? +We use markdown and we like PDF files because they can be made to look nice while still being portable. +Good enough? *Find The Latest of This And More at [ThrowTheSwitch.org][]* diff --git a/docs/UnityConfigurationGuide.md b/docs/UnityConfigurationGuide.md index eddc79cf..493b1421 100644 --- a/docs/UnityConfigurationGuide.md +++ b/docs/UnityConfigurationGuide.md @@ -2,70 +2,58 @@ ## C Standards, Compilers and Microcontrollers -The embedded software world contains its challenges. Compilers support different -revisions of the C Standard. They ignore requirements in places, sometimes to -make the language more usable in some special regard. Sometimes it's to simplify -their support. Sometimes it's due to specific quirks of the microcontroller they -are targeting. Simulators add another dimension to this menagerie. - -Unity is designed to run on almost anything that is targeted by a C compiler. It -would be awesome if this could be done with zero configuration. While there are -some targets that come close to this dream, it is sadly not universal. It is -likely that you are going to need at least a couple of the configuration options -described in this document. - -All of Unity's configuration options are `#defines`. Most of these are simple -definitions. A couple are macros with arguments. They live inside the -unity_internals.h header file. We don't necessarily recommend opening that file -unless you really need to. That file is proof that a cross-platform library is -challenging to build. From a more positive perspective, it is also proof that a -great deal of complexity can be centralized primarily to one place to -provide a more consistent and simple experience elsewhere. +The embedded software world contains its challenges. +Compilers support different revisions of the C Standard. +They ignore requirements in places, sometimes to make the language more usable in some special regard. +Sometimes it's to simplify their support. +Sometimes it's due to specific quirks of the microcontroller they are targeting. +Simulators add another dimension to this menagerie. + +Unity is designed to run on almost anything that is targeted by a C compiler. +It would be awesome if this could be done with zero configuration. +While there are some targets that come close to this dream, it is sadly not universal. +It is likely that you are going to need at least a couple of the configuration options described in this document. + +All of Unity's configuration options are `#defines`. +Most of these are simple definitions. +A couple are macros with arguments. +They live inside the unity_internals.h header file. +We don't necessarily recommend opening that file unless you really need to. +That file is proof that a cross-platform library is challenging to build. +From a more positive perspective, it is also proof that a great deal of complexity can be centralized primarily to one place to provide a more consistent and simple experience elsewhere. ### Using These Options -It doesn't matter if you're using a target-specific compiler and a simulator or -a native compiler. In either case, you've got a couple choices for configuring -these options: - -1. Because these options are specified via C defines, you can pass most of these -options to your compiler through command line compiler flags. Even if you're -using an embedded target that forces you to use their overbearing IDE for all -configuration, there will be a place somewhere in your project to configure -defines for your compiler. -2. You can create a custom `unity_config.h` configuration file (present in your -toolchain's search paths). In this file, you will list definitions and macros -specific to your target. All you must do is define `UNITY_INCLUDE_CONFIG_H` and -Unity will rely on `unity_config.h` for any further definitions it may need. - -Unfortunately, it doesn't usually work well to just #define these things in the -test itself. These defines need to take effect where ever unity.h is included. -This would be test test, the test runner (if you're generating one), and from -unity.c when it's compiled. +It doesn't matter if you're using a target-specific compiler and a simulator or a native compiler. +In either case, you've got a couple choices for configuring these options: + +1. Because these options are specified via C defines, you can pass most of these options to your compiler through command line compiler flags. Even if you're using an embedded target that forces you to use their overbearing IDE for all configuration, there will be a place somewhere in your project to configure defines for your compiler. +2. You can create a custom `unity_config.h` configuration file (present in your toolchain's search paths). + In this file, you will list definitions and macros specific to your target. All you must do is define `UNITY_INCLUDE_CONFIG_H` and Unity will rely on `unity_config.h` for any further definitions it may need. + +Unfortunately, it doesn't usually work well to just #define these things in the test itself. +These defines need to take effect where ever unity.h is included. +This would be test test, the test runner (if you're generating one), and from unity.c when it's compiled. ## The Options ### Integer Types -If you've been a C developer for long, you probably already know that C's -concept of an integer varies from target to target. The C Standard has rules -about the `int` matching the register size of the target microprocessor. It has -rules about the `int` and how its size relates to other integer types. An `int` -on one target might be 16 bits while on another target it might be 64. There are -more specific types in compilers compliant with C99 or later, but that's -certainly not every compiler you are likely to encounter. Therefore, Unity has a -number of features for helping to adjust itself to match your required integer -sizes. It starts off by trying to do it automatically. +If you've been a C developer for long, you probably already know that C's concept of an integer varies from target to target. +The C Standard has rules about the `int` matching the register size of the target microprocessor. +It has rules about the `int` and how its size relates to other integer types. +An `int` on one target might be 16 bits while on another target it might be 64. +There are more specific types in compilers compliant with C99 or later, but that's certainly not every compiler you are likely to encounter. +Therefore, Unity has a number of features for helping to adjust itself to match your required integer sizes. +It starts off by trying to do it automatically. #### `UNITY_EXCLUDE_STDINT_H` The first thing that Unity does to guess your types is check `stdint.h`. -This file includes defines like `UINT_MAX` that Unity can use to -learn a lot about your system. It's possible you don't want it to do this -(um. why not?) or (more likely) it's possible that your system doesn't -support `stdint.h`. If that's the case, you're going to want to define this. -That way, Unity will know to skip the inclusion of this file and you won't -be left with a compiler error. +This file includes defines like `UINT_MAX` that Unity can use to learn a lot about your system. +It's possible you don't want it to do this (um. why not?) or (more likely) it's possible that your system doesn't support `stdint.h`. +If that's the case, you're going to want to define this. +That way, Unity will know to skip the inclusion of this file and you won't be left with a compiler error. _Example:_ @@ -75,9 +63,9 @@ _Example:_ #### `UNITY_EXCLUDE_LIMITS_H` -The second attempt to guess your types is to check `limits.h`. Some compilers -that don't support `stdint.h` could include `limits.h` instead. If you don't -want Unity to check this file either, define this to make it skip the inclusion. +The second attempt to guess your types is to check `limits.h`. +Some compilers that don't support `stdint.h` could include `limits.h` instead. +If you don't want Unity to check this file either, define this to make it skip the inclusion. _Example:_ @@ -85,15 +73,14 @@ _Example:_ #define UNITY_EXCLUDE_LIMITS_H ``` -If you've disabled both of the automatic options above, you're going to have to -do the configuration yourself. Don't worry. Even this isn't too bad... there are -just a handful of defines that you are going to specify if you don't like the -defaults. +If you've disabled both of the automatic options above, you're going to have to do the configuration yourself. +Don't worry. +Even this isn't too bad... there are just a handful of defines that you are going to specify if you don't like the defaults. #### `UNITY_INT_WIDTH` -Define this to be the number of bits an `int` takes up on your system. The -default, if not autodetected, is 32 bits. +Define this to be the number of bits an `int` takes up on your system. +The default, if not autodetected, is 32 bits. _Example:_ @@ -103,11 +90,11 @@ _Example:_ #### `UNITY_LONG_WIDTH` -Define this to be the number of bits a `long` takes up on your system. The -default, if not autodetected, is 32 bits. This is used to figure out what kind -of 64-bit support your system can handle. Does it need to specify a `long` or a -`long long` to get a 64-bit value. On 16-bit systems, this option is going to be -ignored. +Define this to be the number of bits a `long` takes up on your system. +The default, if not autodetected, is 32 bits. +This is used to figure out what kind of 64-bit support your system can handle. +Does it need to specify a `long` or a `long long` to get a 64-bit value. +On 16-bit systems, this option is going to be ignored. _Example:_ @@ -117,12 +104,11 @@ _Example:_ #### `UNITY_POINTER_WIDTH` -Define this to be the number of bits a pointer takes up on your system. The -default, if not autodetected, is 32-bits. If you're getting ugly compiler -warnings about casting from pointers, this is the one to look at. +Define this to be the number of bits a pointer takes up on your system. +The default, if not autodetected, is 32-bits. +If you're getting ugly compiler warnings about casting from pointers, this is the one to look at. -_Hint:_ In order to support exotic processors (for example TI C55x with a pointer -width of 23-bit), choose the next power of two (in this case 32-bit). +_Hint:_ In order to support exotic processors (for example TI C55x with a pointer width of 23-bit), choose the next power of two (in this case 32-bit). _Supported values:_ 16, 32 and 64 @@ -137,11 +123,9 @@ _Example:_ #### `UNITY_SUPPORT_64` -Unity will automatically include 64-bit support if it auto-detects it, or if -your `int`, `long`, or pointer widths are greater than 32-bits. Define this to -enable 64-bit support if none of the other options already did it for you. There -can be a significant size and speed impact to enabling 64-bit support on small -targets, so don't define it if you don't need it. +Unity will automatically include 64-bit support if it auto-detects it, or if your `int`, `long`, or pointer widths are greater than 32-bits. +Define this to enable 64-bit support if none of the other options already did it for you. +There can be a significant size and speed impact to enabling 64-bit support on small targets, so don't define it if you don't need it. _Example:_ @@ -151,12 +135,10 @@ _Example:_ ### Floating Point Types -In the embedded world, it's not uncommon for targets to have no support for -floating point operations at all or to have support that is limited to only -single precision. We are able to guess integer sizes on the fly because integers -are always available in at least one size. Floating point, on the other hand, is -sometimes not available at all. Trying to include `float.h` on these platforms -would result in an error. This leaves manual configuration as the only option. +In the embedded world, it's not uncommon for targets to have no support for floating point operations at all or to have support that is limited to only single precision. +We are able to guess integer sizes on the fly because integers are always available in at least one size. +Floating point, on the other hand, is sometimes not available at all. +Trying to include `float.h` on these platforms would result in an error. This leaves manual configuration as the only option. #### `UNITY_INCLUDE_FLOAT` @@ -166,11 +148,10 @@ would result in an error. This leaves manual configuration as the only option. #### `UNITY_EXCLUDE_DOUBLE` -By default, Unity guesses that you will want single precision floating point -support, but not double precision. It's easy to change either of these using the -include and exclude options here. You may include neither, either, or both, as -suits your needs. For features that are enabled, the following floating point -options also become available. +By default, Unity guesses that you will want single precision floating point support, but not double precision. +It's easy to change either of these using the include and exclude options here. +You may include neither, either, or both, as suits your needs. +For features that are enabled, the following floating point options also become available. _Example:_ @@ -182,15 +163,12 @@ _Example:_ #### `UNITY_EXCLUDE_FLOAT_PRINT` -Unity aims for as small of a footprint as possible and avoids most standard -library calls (some embedded platforms don’t have a standard library!). Because -of this, its routines for printing integer values are minimalist and hand-coded. +Unity aims for as small of a footprint as possible and avoids most standard library calls (some embedded platforms don’t have a standard library!). +Because of this, its routines for printing integer values are minimalist and hand-coded. Therefore, the display of floating point values during a failure are optional. -By default, Unity will print the actual results of floating point assertion -failure (e.g. ”Expected 4.56 Was 4.68”). To not include this extra support, you -can use this define to instead respond to a failed assertion with a message like -”Values Not Within Delta”. If you would like verbose failure messages for floating -point assertions, use these options to give more explicit failure messages. +By default, Unity will print the actual results of floating point assertion failure (e.g. ”Expected 4.56 Was 4.68”). +To not include this extra support, you can use this define to instead respond to a failed assertion with a message like ”Values Not Within Delta”. +If you would like verbose failure messages for floating point assertions, use these options to give more explicit failure messages. _Example:_ @@ -200,9 +178,8 @@ _Example:_ #### `UNITY_FLOAT_TYPE` -If enabled, Unity assumes you want your `FLOAT` asserts to compare standard C -floats. If your compiler supports a specialty floating point type, you can -always override this behavior by using this definition. +If enabled, Unity assumes you want your `FLOAT` asserts to compare standard C floats. +If your compiler supports a specialty floating point type, you can always override this behavior by using this definition. _Example:_ @@ -212,11 +189,9 @@ _Example:_ #### `UNITY_DOUBLE_TYPE` -If enabled, Unity assumes you want your `DOUBLE` asserts to compare standard C -doubles. If you would like to change this, you can specify something else by -using this option. For example, defining `UNITY_DOUBLE_TYPE` to `long double` -could enable gargantuan floating point types on your 64-bit processor instead of -the standard `double`. +If enabled, Unity assumes you want your `DOUBLE` asserts to compare standard C doubles. +If you would like to change this, you can specify something else by using this option. +For example, defining `UNITY_DOUBLE_TYPE` to `long double` could enable gargantuan floating point types on your 64-bit processor instead of the standard `double`. _Example:_ @@ -228,16 +203,12 @@ _Example:_ #### `UNITY_DOUBLE_PRECISION` -If you look up `UNITY_ASSERT_EQUAL_FLOAT` and `UNITY_ASSERT_EQUAL_DOUBLE` as -documented in the big daddy Unity Assertion Guide, you will learn that they are -not really asserting that two values are equal but rather that two values are -"close enough" to equal. "Close enough" is controlled by these precision -configuration options. If you are working with 32-bit floats and/or 64-bit -doubles (the normal on most processors), you should have no need to change these -options. They are both set to give you approximately 1 significant bit in either -direction. The float precision is 0.00001 while the double is 10-12. -For further details on how this works, see the appendix of the Unity Assertion -Guide. +If you look up `UNITY_ASSERT_EQUAL_FLOAT` and `UNITY_ASSERT_EQUAL_DOUBLE` as documented in the big daddy Unity Assertion Guide, you will learn that they are not really asserting that two values are equal but rather that two values are "close enough" to equal. +"Close enough" is controlled by these precision configuration options. +If you are working with 32-bit floats and/or 64-bit doubles (the normal on most processors), you should have no need to change these options. +They are both set to give you approximately 1 significant bit in either direction. +The float precision is 0.00001 while the double is 10-12. +For further details on how this works, see the appendix of the Unity Assertion Guide. _Example:_ @@ -249,10 +220,8 @@ _Example:_ #### `UNITY_EXCLUDE_STDDEF_H` -Unity uses the `NULL` macro, which defines the value of a null pointer constant, -defined in `stddef.h` by default. If you want to provide -your own macro for this, you should exclude the `stddef.h` header file by adding this -define to your configuration. +Unity uses the `NULL` macro, which defines the value of a null pointer constant, defined in `stddef.h` by default. +If you want to provide your own macro for this, you should exclude the `stddef.h` header file by adding this define to your configuration. _Example:_ @@ -262,8 +231,7 @@ _Example:_ #### `UNITY_INCLUDE_PRINT_FORMATTED` -Unity provides a simple (and very basic) printf-like string output implementation, -which is able to print a string modified by the following format string modifiers: +Unity provides a simple (and very basic) printf-like string output implementation, which is able to print a string modified by the following format string modifiers: - __%d__ - signed value (decimal) - __%i__ - same as __%i__ @@ -300,12 +268,9 @@ TEST_PRINTF("Multiple (%d) (%i) (%u) (%x)\n", -100, 0, 200, 0x12345); ### Toolset Customization -In addition to the options listed above, there are a number of other options -which will come in handy to customize Unity's behavior for your specific -toolchain. It is possible that you may not need to touch any of these... but -certain platforms, particularly those running in simulators, may need to jump -through extra hoops to run properly. These macros will help in those -situations. +In addition to the options listed above, there are a number of other options which will come in handy to customize Unity's behavior for your specific toolchain. +It is possible that you may not need to touch any of these... but certain platforms, particularly those running in simulators, may need to jump through extra hoops to run properly. +These macros will help in those situations. #### `UNITY_OUTPUT_CHAR(a)` @@ -315,20 +280,17 @@ situations. #### `UNITY_OUTPUT_COMPLETE()` -By default, Unity prints its results to `stdout` as it runs. This works -perfectly fine in most situations where you are using a native compiler for -testing. It works on some simulators as well so long as they have `stdout` -routed back to the command line. There are times, however, where the simulator -will lack support for dumping results or you will want to route results -elsewhere for other reasons. In these cases, you should define the -`UNITY_OUTPUT_CHAR` macro. This macro accepts a single character at a time (as -an `int`, since this is the parameter type of the standard C `putchar` function -most commonly used). You may replace this with whatever function call you like. +By default, Unity prints its results to `stdout` as it runs. +This works perfectly fine in most situations where you are using a native compiler for testing. +It works on some simulators as well so long as they have `stdout` routed back to the command line. +There are times, however, where the simulator will lack support for dumping results or you will want to route results elsewhere for other reasons. +In these cases, you should define the `UNITY_OUTPUT_CHAR` macro. +This macro accepts a single character at a time (as an `int`, since this is the parameter type of the standard C `putchar` function most commonly used). +You may replace this with whatever function call you like. _Example:_ -Say you are forced to run your test suite on an embedded processor with no -`stdout` option. You decide to route your test result output to a custom serial -`RS232_putc()` function you wrote like thus: +Say you are forced to run your test suite on an embedded processor with no `stdout` option. +You decide to route your test result output to a custom serial `RS232_putc()` function you wrote like thus: ```C #include "RS232_header.h" @@ -340,8 +302,8 @@ Say you are forced to run your test suite on an embedded processor with no ``` _Note:_ -`UNITY_OUTPUT_FLUSH()` can be set to the standard out flush function simply by -specifying `UNITY_USE_FLUSH_STDOUT`. No other defines are required. +`UNITY_OUTPUT_FLUSH()` can be set to the standard out flush function simply by specifying `UNITY_USE_FLUSH_STDOUT`. +No other defines are required. #### `UNITY_OUTPUT_FOR_ECLIPSE` @@ -349,16 +311,14 @@ specifying `UNITY_USE_FLUSH_STDOUT`. No other defines are required. #### `UNITY_OUTPUT_FOR_QT_CREATOR` -When managing your own builds, it is often handy to have messages output in a format which is -recognized by your IDE. These are some standard formats which can be supported. If you're using -Ceedling to manage your builds, it is better to stick with the standard format (leaving these -all undefined) and allow Ceedling to use its own decorators. +When managing your own builds, it is often handy to have messages output in a format which is recognized by your IDE. +These are some standard formats which can be supported. +If you're using Ceedling to manage your builds, it is better to stick with the standard format (leaving these all undefined) and allow Ceedling to use its own decorators. #### `UNITY_PTR_ATTRIBUTE` -Some compilers require a custom attribute to be assigned to pointers, like -`near` or `far`. In these cases, you can give Unity a safe default for these by -defining this option with the attribute you would like. +Some compilers require a custom attribute to be assigned to pointers, like `near` or `far`. +In these cases, you can give Unity a safe default for these by defining this option with the attribute you would like. _Example:_ @@ -369,9 +329,9 @@ _Example:_ #### `UNITY_PRINT_EOL` -By default, Unity outputs \n at the end of each line of output. This is easy -to parse by the scripts, by Ceedling, etc, but it might not be ideal for YOUR -system. Feel free to override this and to make it whatever you wish. +By default, Unity outputs \n at the end of each line of output. +This is easy to parse by the scripts, by Ceedling, etc, but it might not be ideal for YOUR system. +Feel free to override this and to make it whatever you wish. _Example:_ @@ -381,11 +341,10 @@ _Example:_ #### `UNITY_EXCLUDE_DETAILS` -This is an option for if you absolutely must squeeze every byte of memory out of -your system. Unity stores a set of internal scratchpads which are used to pass -extra detail information around. It's used by systems like CMock in order to -report which function or argument flagged an error. If you're not using CMock and -you're not using these details for other things, then you can exclude them. +This is an option for if you absolutely must squeeze every byte of memory out of your system. +Unity stores a set of internal scratchpads which are used to pass extra detail information around. +It's used by systems like CMock in order to report which function or argument flagged an error. +If you're not using CMock and you're not using these details for other things, then you can exclude them. _Example:_ @@ -395,10 +354,8 @@ _Example:_ #### `UNITY_PRINT_TEST_CONTEXT` -This option allows you to specify your own function to print additional context -as part of the error message when a test has failed. It can be useful if you -want to output some specific information about the state of the test at the point -of failure, and `UNITY_SET_DETAILS` isn't flexible enough for your needs. +This option allows you to specify your own function to print additional context as part of the error message when a test has failed. +It can be useful if you want to output some specific information about the state of the test at the point of failure, and `UNITY_SET_DETAILS` isn't flexible enough for your needs. _Example:_ @@ -415,12 +372,10 @@ void PrintIterationCount(void) #### `UNITY_EXCLUDE_SETJMP` -If your embedded system doesn't support the standard library setjmp, you can -exclude Unity's reliance on this by using this define. This dropped dependence -comes at a price, though. You will be unable to use custom helper functions for -your tests, and you will be unable to use tools like CMock. Very likely, if your -compiler doesn't support setjmp, you wouldn't have had the memory space for those -things anyway, though... so this option exists for those situations. +If your embedded system doesn't support the standard library setjmp, you can exclude Unity's reliance on this by using this define. +This dropped dependence comes at a price, though. +You will be unable to use custom helper functions for your tests, and you will be unable to use tools like CMock. +Very likely, if your compiler doesn't support setjmp, you wouldn't have had the memory space for those things anyway, though... so this option exists for those situations. _Example:_ @@ -446,53 +401,43 @@ _Example:_ #### `UNITY_SHORTHAND_AS_NONE` -These options give you control of the `TEST_ASSERT_EQUAL` and the -`TEST_ASSERT_NOT_EQUAL` shorthand assertions. Historically, Unity treated the -former as an alias for an integer comparison. It treated the latter as a direct -comparison using `!=`. This assymetry was confusing, but there was much -disagreement as to how best to treat this pair of assertions. These four options -will allow you to specify how Unity will treat these assertions. - -- AS INT - the values will be cast to integers and directly compared. Arguments - that don't cast easily to integers will cause compiler errors. -- AS MEM - the address of both values will be taken and the entire object's - memory footprint will be compared byte by byte. Directly placing - constant numbers like `456` as expected values will cause errors. -- AS_RAW - Unity assumes that you can compare the two values using `==` and `!=` - and will do so. No details are given about mismatches, because it - doesn't really know what type it's dealing with. -- AS_NONE - Unity will disallow the use of these shorthand macros altogether, - insisting that developers choose a more descriptive option. +These options give you control of the `TEST_ASSERT_EQUAL` and the `TEST_ASSERT_NOT_EQUAL` shorthand assertions. +Historically, Unity treated the former as an alias for an integer comparison. +It treated the latter as a direct comparison using `!=`. +This asymmetry was confusing, but there was much disagreement as to how best to treat this pair of assertions. +These four options will allow you to specify how Unity will treat these assertions. + +- AS INT - the values will be cast to integers and directly compared. + Arguments that don't cast easily to integers will cause compiler errors. +- AS MEM - the address of both values will be taken and the entire object's memory footprint will be compared byte by byte. + Directly placing constant numbers like `456` as expected values will cause errors. +- AS_RAW - Unity assumes that you can compare the two values using `==` and `!=` and will do so. + No details are given about mismatches, because it doesn't really know what type it's dealing with. +- AS_NONE - Unity will disallow the use of these shorthand macros altogether, insisting that developers choose a more descriptive option. #### `UNITY_SUPPORT_VARIADIC_MACROS` -This will force Unity to support variadic macros when using its own built-in -RUN_TEST macro. This will rarely be necessary. Most often, Unity will automatically -detect if the compiler supports variadic macros by checking to see if it's C99+ -compatible. In the event that the compiler supports variadic macros, but is primarily -C89 (ANSI), defining this option will allow you to use them. This option is also not -necessary when using Ceedling or the test runner generator script. +This will force Unity to support variadic macros when using its own built-in RUN_TEST macro. +This will rarely be necessary. Most often, Unity will automatically detect if the compiler supports variadic macros by checking to see if it's C99+ compatible. +In the event that the compiler supports variadic macros, but is primarily C89 (ANSI), defining this option will allow you to use them. +This option is also not necessary when using Ceedling or the test runner generator script. ## Getting Into The Guts -There will be cases where the options above aren't quite going to get everything -perfect. They are likely sufficient for any situation where you are compiling -and executing your tests with a native toolchain (e.g. clang on Mac). These -options may even get you through the majority of cases encountered in working -with a target simulator run from your local command line. But especially if you -must run your test suite on your target hardware, your Unity configuration will -require special help. This special help will usually reside in one of two -places: the `main()` function or the `RUN_TEST` macro. Let's look at how these -work. +There will be cases where the options above aren't quite going to get everything perfect. +They are likely sufficient for any situation where you are compiling and executing your tests with a native toolchain (e.g. clang on Mac). +These options may even get you through the majority of cases encountered in working with a target simulator run from your local command line. +But especially if you must run your test suite on your target hardware, your Unity configuration will +require special help. +This special help will usually reside in one of two places: the `main()` function or the `RUN_TEST` macro. +Let's look at how these work. ### `main()` -Each test module is compiled and run on its own, separate from the other test -files in your project. Each test file, therefore, has a `main` function. This -`main` function will need to contain whatever code is necessary to initialize -your system to a workable state. This is particularly true for situations where -you must set up a memory map or initialize a communication channel for the -output of your test results. +Each test module is compiled and run on its own, separate from the other test files in your project. +Each test file, therefore, has a `main` function. +This `main` function will need to contain whatever code is necessary to initialize your system to a workable state. +This is particularly true for situations where you must set up a memory map or initialize a communication channel for the output of your test results. A simple main function looks something like this: @@ -506,25 +451,22 @@ int main(void) { } ``` -You can see that our main function doesn't bother taking any arguments. For our -most barebones case, we'll never have arguments because we just run all the -tests each time. Instead, we start by calling `UNITY_BEGIN`. We run each test -(in whatever order we wish). Finally, we call `UNITY_END`, returning its return -value (which is the total number of failures). +You can see that our main function doesn't bother taking any arguments. +For our most barebones case, we'll never have arguments because we just run all the tests each time. +Instead, we start by calling `UNITY_BEGIN`. +We run each test (in whatever order we wish). +Finally, we call `UNITY_END`, returning its return value (which is the total number of failures). -It should be easy to see that you can add code before any test cases are run or -after all the test cases have completed. This allows you to do any needed -system-wide setup or teardown that might be required for your special -circumstances. +It should be easy to see that you can add code before any test cases are run or after all the test cases have completed. +This allows you to do any needed system-wide setup or teardown that might be required for your special circumstances. #### `RUN_TEST` -The `RUN_TEST` macro is called with each test case function. Its job is to -perform whatever setup and teardown is necessary for executing a single test -case function. This includes catching failures, calling the test module's -`setUp()` and `tearDown()` functions, and calling `UnityConcludeTest()`. If -using CMock or test coverage, there will be additional stubs in use here. A -simple minimalist RUN_TEST macro looks something like this: +The `RUN_TEST` macro is called with each test case function. +Its job is to perform whatever setup and teardown is necessary for executing a single test case function. +This includes catching failures, calling the test module's `setUp()` and `tearDown()` functions, and calling `UnityConcludeTest()`. +If using CMock or test coverage, there will be additional stubs in use here. +A simple minimalist RUN_TEST macro looks something like this: ```C #define RUN_TEST(testfunc) \ @@ -538,26 +480,25 @@ simple minimalist RUN_TEST macro looks something like this: UnityConcludeTest(); ``` -So that's quite a macro, huh? It gives you a glimpse of what kind of stuff Unity -has to deal with for every single test case. For each test case, we declare that -it is a new test. Then we run `setUp` and our test function. These are run -within a `TEST_PROTECT` block, the function of which is to handle failures that -occur during the test. Then, assuming our test is still running and hasn't been -ignored, we run `tearDown`. No matter what, our last step is to conclude this -test before moving on to the next. - -Let's say you need to add a call to `fsync` to force all of your output data to -flush to a file after each test. You could easily insert this after your -`UnityConcludeTest` call. Maybe you want to write an xml tag before and after -each result set. Again, you could do this by adding lines to this macro. Updates -to this macro are for the occasions when you need an action before or after -every single test case throughout your entire suite of tests. +So that's quite a macro, huh? +It gives you a glimpse of what kind of stuff Unity has to deal with for every single test case. +For each test case, we declare that it is a new test. +Then we run `setUp` and our test function. +These are run within a `TEST_PROTECT` block, the function of which is to handle failures that occur during the test. +Then, assuming our test is still running and hasn't been ignored, we run `tearDown`. +No matter what, our last step is to conclude this test before moving on to the next. + +Let's say you need to add a call to `fsync` to force all of your output data to flush to a file after each test. +You could easily insert this after your `UnityConcludeTest` call. +Maybe you want to write an xml tag before and after each result set. +Again, you could do this by adding lines to this macro. +Updates to this macro are for the occasions when you need an action before or after every single test case throughout your entire suite of tests. ## Happy Porting -The defines and macros in this guide should help you port Unity to just about -any C target we can imagine. If you run into a snag or two, don't be afraid of -asking for help on the forums. We love a good challenge! +The defines and macros in this guide should help you port Unity to just about any C target we can imagine. +If you run into a snag or two, don't be afraid of asking for help on the forums. +We love a good challenge! *Find The Latest of This And More at [ThrowTheSwitch.org][]* diff --git a/docs/UnityGettingStartedGuide.md b/docs/UnityGettingStartedGuide.md index 039364f6..b951c60c 100644 --- a/docs/UnityGettingStartedGuide.md +++ b/docs/UnityGettingStartedGuide.md @@ -2,116 +2,104 @@ ## Welcome -Congratulations. You're now the proud owner of your very own pile of bits! What -are you going to do with all these ones and zeros? This document should be able -to help you decide just that. +Congratulations. +You're now the proud owner of your very own pile of bits! +What are you going to do with all these ones and zeros? +This document should be able to help you decide just that. -Unity is a unit test framework. The goal has been to keep it small and -functional. The core Unity test framework is three files: a single C file and a -couple header files. These team up to provide functions and macros to make -testing easier. +Unity is a unit test framework. +The goal has been to keep it small and functional. +The core Unity test framework is three files: a single C file and a couple header files. +These team up to provide functions and macros to make testing easier. -Unity was designed to be cross-platform. It works hard to stick with C standards -while still providing support for the many embedded C compilers that bend the -rules. Unity has been used with many compilers, including GCC, IAR, Clang, -Green Hills, Microchip, and MS Visual Studio. It's not much work to get it to -work with a new target. +Unity was designed to be cross-platform. +It works hard to stick with C standards while still providing support for the many embedded C compilers that bend the rules. +Unity has been used with many compilers, including GCC, IAR, Clang, Green Hills, Microchip, and MS Visual Studio. +It's not much work to get it to work with a new target. ### Overview of the Documents #### Unity Assertions reference -This document will guide you through all the assertion options provided by -Unity. This is going to be your unit testing bread and butter. You'll spend more -time with assertions than any other part of Unity. +This document will guide you through all the assertion options provided by Unity. +This is going to be your unit testing bread and butter. +You'll spend more time with assertions than any other part of Unity. #### Unity Assertions Cheat Sheet -This document contains an abridged summary of the assertions described in the -previous document. It's perfect for printing and referencing while you -familiarize yourself with Unity's options. +This document contains an abridged summary of the assertions described in the previous document. +It's perfect for printing and referencing while you familiarize yourself with Unity's options. #### Unity Configuration Guide -This document is the one to reference when you are going to use Unity with a new -target or compiler. It'll guide you through the configuration options and will -help you customize your testing experience to meet your needs. +This document is the one to reference when you are going to use Unity with a new target or compiler. +It'll guide you through the configuration options and will help you customize your testing experience to meet your needs. #### Unity Helper Scripts -This document describes the helper scripts that are available for simplifying -your testing workflow. It describes the collection of optional Ruby scripts -included in the auto directory of your Unity installation. Neither Ruby nor -these scripts are necessary for using Unity. They are provided as a convenience -for those who wish to use them. +This document describes the helper scripts that are available for simplifying your testing workflow. +It describes the collection of optional Ruby scripts included in the auto directory of your Unity installation. +Neither Ruby nor these scripts are necessary for using Unity. +They are provided as a convenience for those who wish to use them. #### Unity License -What's an open source project without a license file? This brief document -describes the terms you're agreeing to when you use this software. Basically, we -want it to be useful to you in whatever context you want to use it, but please -don't blame us if you run into problems. +What's an open source project without a license file? +This brief document describes the terms you're agreeing to when you use this software. +Basically, we want it to be useful to you in whatever context you want to use it, but please don't blame us if you run into problems. ### Overview of the Folders -If you have obtained Unity through Github or something similar, you might be -surprised by just how much stuff you suddenly have staring you in the face. -Don't worry, Unity itself is very small. The rest of it is just there to make -your life easier. You can ignore it or use it at your convenience. Here's an -overview of everything in the project. - -- `src` - This is the code you care about! This folder contains a C file and two -header files. These three files _are_ Unity. -- `docs` - You're reading this document, so it's possible you have found your way -into this folder already. This is where all the handy documentation can be -found. +If you have obtained Unity through Github or something similar, you might be surprised by just how much stuff you suddenly have staring you in the face. +Don't worry, Unity itself is very small. +The rest of it is just there to make your life easier. +You can ignore it or use it at your convenience. +Here's an overview of everything in the project. + +- `src` - This is the code you care about! This folder contains a C file and two header files. + These three files _are_ Unity. +- `docs` - You're reading this document, so it's possible you have found your way into this folder already. + This is where all the handy documentation can be found. - `examples` - This contains a few examples of using Unity. -- `extras` - These are optional add ons to Unity that are not part of the core -project. If you've reached us through James Grenning's book, you're going to -want to look here. -- `test` - This is how Unity and its scripts are all tested. If you're just using -Unity, you'll likely never need to go in here. If you are the lucky team member -who gets to port Unity to a new toolchain, this is a good place to verify -everything is configured properly. -- `auto` - Here you will find helpful Ruby scripts for simplifying your test -workflow. They are purely optional and are not required to make use of Unity. +- `extras` - These are optional add ons to Unity that are not part of the core project. + If you've reached us through James Grenning's book, you're going to want to look here. +- `test` - This is how Unity and its scripts are all tested. + If you're just using Unity, you'll likely never need to go in here. + If you are the lucky team member who gets to port Unity to a new toolchain, this is a good place to verify everything is configured properly. +- `auto` - Here you will find helpful Ruby scripts for simplifying your test workflow. + They are purely optional and are not required to make use of Unity. ## How to Create A Test File -Test files are C files. Most often you will create a single test file for each C -module that you want to test. The test file should include unity.h and the -header for your C module to be tested. +Test files are C files. +Most often you will create a single test file for each C module that you want to test. +The test file should include unity.h and the header for your C module to be tested. -Next, a test file will include a `setUp()` and `tearDown()` function. The setUp -function can contain anything you would like to run before each test. The -tearDown function can contain anything you would like to run after each test. -Both functions accept no arguments and return nothing. You may leave either or -both of these blank if you have no need for them. +Next, a test file will include a `setUp()` and `tearDown()` function. +The setUp function can contain anything you would like to run before each test. +The tearDown function can contain anything you would like to run after each test. +Both functions accept no arguments and return nothing. +You may leave either or both of these blank if you have no need for them. -If you're using Ceedling or the test runner generator script, you may leave these off -completely. Not sure? Give it a try. If your compiler complains that it can't -find setUp or tearDown when it links, you'll know you need to at least include -an empty function for these. +If you're using Ceedling or the test runner generator script, you may leave these off completely. +Not sure? +Give it a try. +If your compiler complains that it can't find setUp or tearDown when it links, you'll know you need to at least include an empty function for these. -The majority of the file will be a series of test functions. Test functions -follow the convention of starting with the word "test_" or "spec_". You don't HAVE -to name them this way, but it makes it clear what functions are tests for other -developers. Also, the automated scripts that come with Unity or Ceedling will default -to looking for test functions to be prefixed this way. Test functions take no arguments -and return nothing. All test accounting is handled internally in Unity. +The majority of the file will be a series of test functions. +Test functions follow the convention of starting with the word "test_" or "spec_". +You don't HAVE to name them this way, but it makes it clear what functions are tests for other developers. +Also, the automated scripts that come with Unity or Ceedling will default to looking for test functions to be prefixed this way. +Test functions take no arguments and return nothing. All test accounting is handled internally in Unity. Finally, at the bottom of your test file, you will write a `main()` function. -This function will call `UNITY_BEGIN()`, then `RUN_TEST` for each test, and -finally `UNITY_END()`.This is what will actually trigger each of those test -functions to run, so it is important that each function gets its own `RUN_TEST` -call. - -Remembering to add each test to the main function can get to be tedious. If you -enjoy using helper scripts in your build process, you might consider making use -of our handy [generate_test_runner.rb][] script. -This will create the main function and all the calls for you, assuming that you -have followed the suggested naming conventions. In this case, there is no need -for you to include the main function in your test file at all. +This function will call `UNITY_BEGIN()`, then `RUN_TEST` for each test, and finally `UNITY_END()`. +This is what will actually trigger each of those test functions to run, so it is important that each function gets its own `RUN_TEST` call. + +Remembering to add each test to the main function can get to be tedious. +If you enjoy using helper scripts in your build process, you might consider making use of our handy [generate_test_runner.rb][] script. +This will create the main function and all the calls for you, assuming that you have followed the suggested naming conventions. +In this case, there is no need for you to include the main function in your test file at all. When you're done, your test file will look something like this: @@ -150,8 +138,8 @@ This should be enough to get you going, though. ### Running Test Functions -When writing your own `main()` functions, for a test-runner. There are two ways -to execute the test. +When writing your own `main()` functions, for a test-runner. +There are two ways to execute the test. The classic variant @@ -159,20 +147,19 @@ The classic variant RUN_TEST(func, linenum) ``` -or its simpler replacement that starts at the beginning of the function. +Or its simpler replacement that starts at the beginning of the function. ``` c RUN_TEST(func) ``` -These macros perform the necessary setup before the test is called and -handles clean-up and result tabulation afterwards. +These macros perform the necessary setup before the test is called and handles clean-up and result tabulation afterwards. ### Ignoring Test Functions There are times when a test is incomplete or not valid for some reason. -At these times, TEST_IGNORE can be called. Control will immediately be -returned to the caller of the test, and no failures will be returned. +At these times, TEST_IGNORE can be called. +Control will immediately be returned to the caller of the test, and no failures will be returned. This is useful when your test runners are automatically generated. ``` c @@ -185,11 +172,15 @@ Ignore this test and return immediately TEST_IGNORE_MESSAGE (message) ``` -Ignore this test and return immediately. Output a message stating why the test was ignored. +Ignore this test and return immediately. +Output a message stating why the test was ignored. ### Aborting Tests -There are times when a test will contain an infinite loop on error conditions, or there may be reason to escape from the test early without executing the rest of the test. A pair of macros support this functionality in Unity. The first `TEST_PROTECT` sets up the feature, and handles emergency abort cases. `TEST_ABORT` can then be used at any time within the tests to return to the last `TEST_PROTECT` call. +There are times when a test will contain an infinite loop on error conditions, or there may be reason to escape from the test early without executing the rest of the test. +A pair of macros support this functionality in Unity. +The first `TEST_PROTECT` sets up the feature, and handles emergency abort cases. +`TEST_ABORT` can then be used at any time within the tests to return to the last `TEST_PROTECT` call. ```c TEST_PROTECT() @@ -219,15 +210,12 @@ If MyTest calls `TEST_ABORT`, program control will immediately return to `TEST_P ## How to Build and Run A Test File -This is the single biggest challenge to picking up a new unit testing framework, -at least in a language like C or C++. These languages are REALLY good at getting -you "close to the metal" (why is the phrase metal? Wouldn't it be more accurate -to say "close to the silicon"?). While this feature is usually a good thing, it -can make testing more challenging. +This is the single biggest challenge to picking up a new unit testing framework, at least in a language like C or C++. +These languages are REALLY good at getting you "close to the metal" (why is the phrase metal? Wouldn't it be more accurate to say "close to the silicon"?). +While this feature is usually a good thing, it can make testing more challenging. -You have two really good options for toolchains. Depending on where you're -coming from, it might surprise you that neither of these options is running the -unit tests on your hardware. +You have two really good options for toolchains. +Depending on where you're coming from, it might surprise you that neither of these options is running the unit tests on your hardware. There are many reasons for this, but here's a short version: - On hardware, you have too many constraints (processing power, memory, etc), @@ -235,22 +223,18 @@ There are many reasons for this, but here's a short version: - On hardware, unit testing is more challenging, - Unit testing isn't System testing. Keep them separate. -Instead of running your tests on your actual hardware, most developers choose to -develop them as native applications (using gcc or MSVC for example) or as -applications running on a simulator. Either is a good option. Native apps have -the advantages of being faster and easier to set up. Simulator apps have the -advantage of working with the same compiler as your target application. The -options for configuring these are discussed in the configuration guide. - -To get either to work, you might need to make a few changes to the file -containing your register set (discussed later). - -In either case, a test is built by linking unity, the test file, and the C -file(s) being tested. These files create an executable which can be run as the -test set for that module. Then, this process is repeated for the next test file. -This flexibility of separating tests into individual executables allows us to -much more thoroughly unit test our system and it keeps all the test code out of -our final release! +Instead of running your tests on your actual hardware, most developers choose to develop them as native applications (using gcc or MSVC for example) or as applications running on a simulator. +Either is a good option. +Native apps have the advantages of being faster and easier to set up. +Simulator apps have the advantage of working with the same compiler as your target application. +The options for configuring these are discussed in the configuration guide. + +To get either to work, you might need to make a few changes to the file containing your register set (discussed later). + +In either case, a test is built by linking unity, the test file, and the C file(s) being tested. +These files create an executable which can be run as the test set for that module. +Then, this process is repeated for the next test file. +This flexibility of separating tests into individual executables allows us to much more thoroughly unit test our system and it keeps all the test code out of our final release! *Find The Latest of This And More at [ThrowTheSwitch.org][]* diff --git a/docs/UnityHelperScriptsGuide.md b/docs/UnityHelperScriptsGuide.md index c2e91fe8..ecbf55e1 100644 --- a/docs/UnityHelperScriptsGuide.md +++ b/docs/UnityHelperScriptsGuide.md @@ -3,29 +3,25 @@ ## With a Little Help From Our Friends Sometimes what it takes to be a really efficient C programmer is a little non-C. -The Unity project includes a couple of Ruby scripts for making your life just a tad -easier. They are completely optional. If you choose to use them, you'll need a -copy of Ruby, of course. Just install whatever the latest version is, and it is -likely to work. You can find Ruby at [ruby-lang.org][]. +The Unity project includes a couple of Ruby scripts for making your life just a tad easier. +They are completely optional. +If you choose to use them, you'll need a copy of Ruby, of course. +Just install whatever the latest version is, and it is likely to work. You can find Ruby at [ruby-lang.org][]. ### `generate_test_runner.rb` -Are you tired of creating your own `main` function in your test file? Do you -keep forgetting to add a `RUN_TEST` call when you add a new test case to your -suite? Do you want to use CMock or other fancy add-ons but don't want to figure -out how to create your own `RUN_TEST` macro? +Are you tired of creating your own `main` function in your test file? +Do you keep forgetting to add a `RUN_TEST` call when you add a new test case to your suite? +Do you want to use CMock or other fancy add-ons but don't want to figure out how to create your own `RUN_TEST` macro? Well then we have the perfect script for you! -The `generate_test_runner` script processes a given test file and automatically -creates a separate test runner file that includes ?main?to execute the test -cases within the scanned test file. All you do then is add the generated runner -to your list of files to be compiled and linked, and presto you're done! +The `generate_test_runner` script processes a given test file and automatically creates a separate test runner file that includes ?main?to execute the test cases within the scanned test file. +All you do then is add the generated runner to your list of files to be compiled and linked, and presto you're done! -This script searches your test file for void function signatures having a -function name beginning with "test" or "spec". It treats each of these -functions as a test case and builds up a test suite of them. For example, the -following includes three test cases: +This script searches your test file for void function signatures having a function name beginning with "test" or "spec". +It treats each of these functions as a test case and builds up a test suite of them. +For example, the following includes three test cases: ```C void testVerifyThatUnityIsAwesomeAndWillMakeYourLifeEasier(void) @@ -40,32 +36,30 @@ void spec_Function_should_DoWhatItIsSupposedToDo(void) { } ``` -You can run this script a couple of ways. The first is from the command line: +You can run this script a couple of ways. +The first is from the command line: ```Shell ruby generate_test_runner.rb TestFile.c NameOfRunner.c ``` -Alternatively, if you include only the test file parameter, the script will copy -the name of the test file and automatically append `_Runner` to the name of the -generated file. The example immediately below will create TestFile_Runner.c. +Alternatively, if you include only the test file parameter, the script will copy the name of the test file and automatically append `_Runner` to the name of the generated file. +The example immediately below will create TestFile_Runner.c. ```Shell ruby generate_test_runner.rb TestFile.c ``` You can also add a [YAML][] file to configure extra options. -Conveniently, this YAML file is of the same format as that used by Unity and -CMock. So if you are using YAML files already, you can simply pass the very same -file into the generator script. +Conveniently, this YAML file is of the same format as that used by Unity and CMock. +So if you are using YAML files already, you can simply pass the very same file into the generator script. ```Shell ruby generate_test_runner.rb TestFile.c my_config.yml ``` -The contents of the YAML file `my_config.yml` could look something like the -example below. If you're wondering what some of these options do, you're going -to love the next section of this document. +The contents of the YAML file `my_config.yml` could look something like the example below. +If you're wondering what some of these options do, you're going to love the next section of this document. ```YAML :unity: @@ -77,19 +71,16 @@ to love the next section of this document. :suite_teardown: "free(blah);" ``` -If you would like to force your generated test runner to include one or more -header files, you can just include those at the command line too. Just make sure -these are _after_ the YAML file, if you are using one: +If you would like to force your generated test runner to include one or more header files, you can just include those at the command line too. +Just make sure these are _after_ the YAML file, if you are using one: ```Shell ruby generate_test_runner.rb TestFile.c my_config.yml extras.h ``` -Another option, particularly if you are already using Ruby to orchestrate your -builds - or more likely the Ruby-based build tool Rake - is requiring this -script directly. Anything that you would have specified in a YAML file can be -passed to the script as part of a hash. Let's push the exact same requirement -set as we did above but this time through Ruby code directly: +Another option, particularly if you are already using Ruby to orchestrate your builds - or more likely the Ruby-based build tool Rake - is requiring this script directly. +Anything that you would have specified in a YAML file can be passed to the script as part of a hash. +Let's push the exact same requirement set as we did above but this time through Ruby code directly: ```Ruby require "generate_test_runner.rb" @@ -102,9 +93,8 @@ options = { UnityTestRunnerGenerator.new.run(testfile, runner_name, options) ``` -If you have multiple files to generate in a build script (such as a Rakefile), -you might want to instantiate a generator object with your options and call it -to generate each runner afterwards. Like thus: +If you have multiple files to generate in a build script (such as a Rakefile), you might want to instantiate a generator object with your options and call it to generate each runner afterwards. +Like thus: ```Ruby gen = UnityTestRunnerGenerator.new(options) @@ -115,63 +105,52 @@ end #### Options accepted by generate_test_runner.rb -The following options are available when executing `generate_test_runner`. You -may pass these as a Ruby hash directly or specify them in a YAML file, both of -which are described above. In the `examples` directory, Example 3's Rakefile -demonstrates using a Ruby hash. +The following options are available when executing `generate_test_runner`. +You may pass these as a Ruby hash directly or specify them in a YAML file, both of which are described above. +In the `examples` directory, Example 3's Rakefile demonstrates using a Ruby hash. ##### `:includes` -This option specifies an array of file names to be `#include`'d at the top of -your runner C file. You might use it to reference custom types or anything else -universally needed in your generated runners. +This option specifies an array of file names to be `#include`'d at the top of your runner C file. +You might use it to reference custom types or anything else universally needed in your generated runners. ##### `:suite_setup` Define this option with C code to be executed _before any_ test cases are run. -Alternatively, if your C compiler supports weak symbols, you can leave this -option unset and instead provide a `void suiteSetUp(void)` function in your test -suite. The linker will look for this symbol and fall back to a Unity-provided -stub if it is not found. +Alternatively, if your C compiler supports weak symbols, you can leave this option unset and instead provide a `void suiteSetUp(void)` function in your test suite. +The linker will look for this symbol and fall back to a Unity-provided stub if it is not found. ##### `:suite_teardown` -Define this option with C code to be executed _after all_ test cases have -finished. An integer variable `num_failures` is available for diagnostics. -The code should end with a `return` statement; the value returned will become -the exit code of `main`. You can normally just return `num_failures`. +Define this option with C code to be executed _after all_ test cases have finished. +An integer variable `num_failures` is available for diagnostics. +The code should end with a `return` statement; the value returned will become the exit code of `main`. +You can normally just return `num_failures`. -Alternatively, if your C compiler supports weak symbols, you can leave this -option unset and instead provide a `int suiteTearDown(int num_failures)` -function in your test suite. The linker will look for this symbol and fall -back to a Unity-provided stub if it is not found. +Alternatively, if your C compiler supports weak symbols, you can leave this option unset and instead provide a `int suiteTearDown(int num_failures)` function in your test suite. +The linker will look for this symbol and fall back to a Unity-provided stub if it is not found. ##### `:enforce_strict_ordering` -This option should be defined if you have the strict order feature enabled in -CMock (see CMock documentation). This generates extra variables required for -everything to run smoothly. If you provide the same YAML to the generator as -used in CMock's configuration, you've already configured the generator properly. +This option should be defined if you have the strict order feature enabled in CMock (see CMock documentation). +This generates extra variables required for everything to run smoothly. +If you provide the same YAML to the generator as used in CMock's configuration, you've already configured the generator properly. ##### `:externc` -This option should be defined if you are mixing C and CPP and want your test -runners to automatically include extern "C" support when they are generated. +This option should be defined if you are mixing C and CPP and want your test runners to automatically include extern "C" support when they are generated. ##### `:mock_prefix` and `:mock_suffix` -Unity automatically generates calls to Init, Verify and Destroy for every file -included in the main test file that starts with the given mock prefix and ends -with the given mock suffix, file extension not included. By default, Unity -assumes a `Mock` prefix and no suffix. +Unity automatically generates calls to Init, Verify and Destroy for every file included in the main test file that starts with the given mock prefix and ends with the given mock suffix, file extension not included. +By default, Unity assumes a `Mock` prefix and no suffix. ##### `:plugins` -This option specifies an array of plugins to be used (of course, the array can -contain only a single plugin). This is your opportunity to enable support for -CException support, which will add a check for unhandled exceptions in each -test, reporting a failure if one is detected. To enable this feature using Ruby: +This option specifies an array of plugins to be used (of course, the array can contain only a single plugin). +This is your opportunity to enable support for CException support, which will add a check for unhandled exceptions in each test, reporting a failure if one is detected. +To enable this feature using Ruby: ```Ruby :plugins => [ :cexception ] @@ -184,56 +163,47 @@ Or as a yaml file: -:cexception ``` -If you are using CMock, it is very likely that you are already passing an array -of plugins to CMock. You can just use the same array here. This script will just -ignore the plugins that don't require additional support. +If you are using CMock, it is very likely that you are already passing an array of plugins to CMock. +You can just use the same array here. +This script will just ignore the plugins that don't require additional support. ##### `:include_extensions` This option specifies the pattern for matching acceptable header file extensions. -By default it will accept hpp, hh, H, and h files. If you need a different combination -of files to search, update this from the default `'(?:hpp|hh|H|h)'`. +By default it will accept hpp, hh, H, and h files. +If you need a different combination of files to search, update this from the default `'(?:hpp|hh|H|h)'`. ##### `:source_extensions` This option specifies the pattern for matching acceptable source file extensions. -By default it will accept cpp, cc, C, c, and ino files. If you need a different combination -of files to search, update this from the default `'(?:cpp|cc|ino|C|c)'`. +By default it will accept cpp, cc, C, c, and ino files. +If you need a different combination of files to search, update this from the default `'(?:cpp|cc|ino|C|c)'`. ### `unity_test_summary.rb` -A Unity test file contains one or more test case functions. Each test case can -pass, fail, or be ignored. Each test file is run individually producing results -for its collection of test cases. A given project will almost certainly be -composed of multiple test files. Therefore, the suite of tests is comprised of -one or more test cases spread across one or more test files. This script -aggregates individual test file results to generate a summary of all executed -test cases. The output includes how many tests were run, how many were ignored, -and how many failed. In addition, the output includes a listing of which -specific tests were ignored and failed. A good example of the breadth and -details of these results can be found in the `examples` directory. Intentionally -ignored and failing tests in this project generate corresponding entries in the -summary report. - -If you're interested in other (prettier?) output formats, check into the -[Ceedling][] build tool project that works with Unity and CMock and supports -xunit-style xml as well as other goodies. - -This script assumes the existence of files ending with the extensions -`.testpass` and `.testfail`.The contents of these files includes the test -results summary corresponding to each test file executed with the extension set -according to the presence or absence of failures for that test file. The script -searches a specified path for these files, opens each one it finds, parses the -results, and aggregates and prints a summary. Calling it from the command line -looks like this: +A Unity test file contains one or more test case functions. +Each test case can pass, fail, or be ignored. +Each test file is run individually producing results for its collection of test cases. +A given project will almost certainly be composed of multiple test files. +Therefore, the suite of tests is comprised of one or more test cases spread across one or more test files. +This script aggregates individual test file results to generate a summary of all executed test cases. +The output includes how many tests were run, how many were ignored, and how many failed. In addition, the output includes a listing of which specific tests were ignored and failed. +A good example of the breadth and details of these results can be found in the `examples` directory. +Intentionally ignored and failing tests in this project generate corresponding entries in the summary report. + +If you're interested in other (prettier?) output formats, check into the [Ceedling][] build tool project that works with Unity and CMock and supports xunit-style xml as well as other goodies. + +This script assumes the existence of files ending with the extensions `.testpass` and `.testfail`. +The contents of these files includes the test results summary corresponding to each test file executed with the extension set according to the presence or absence of failures for that test file. +The script searches a specified path for these files, opens each one it finds, parses the results, and aggregates and prints a summary. +Calling it from the command line looks like this: ```Shell ruby unity_test_summary.rb build/test/ ``` -You can optionally specify a root path as well. This is really helpful when you -are using relative paths in your tools' setup, but you want to pull the summary -into an IDE like Eclipse for clickable shortcuts. +You can optionally specify a root path as well. +This is really helpful when you are using relative paths in your tools' setup, but you want to pull the summary into an IDE like Eclipse for clickable shortcuts. ```Shell ruby unity_test_summary.rb build/test/ ~/projects/myproject/ diff --git a/extras/fixture/readme.md b/extras/fixture/readme.md index d36e46ef..5791bcb9 100644 --- a/extras/fixture/readme.md +++ b/extras/fixture/readme.md @@ -1,29 +1,26 @@ # Unity Fixtures -This Framework is an optional add-on to Unity. By including unity_framework.h in place of unity.h, -you may now work with Unity in a manner similar to CppUTest. This framework adds the concepts of -test groups and gives finer control of your tests over the command line. +This Framework is an optional add-on to Unity. +By including unity_framework.h in place of unity.h, you may now work with Unity in a manner similar to CppUTest. +This framework adds the concepts of test groups and gives finer control of your tests over the command line. -This framework is primarily supplied for those working through James Grenning's book on Embedded -Test Driven Development, or those coming to Unity from CppUTest. We should note that using this -framework glosses over some of the features of Unity, and makes it more difficult -to integrate with other testing tools like Ceedling and CMock. +This framework is primarily supplied for those working through James Grenning's book on Embedded Test Driven Development, or those coming to Unity from CppUTest. +We should note that using this framework glosses over some of the features of Unity, and makes it more difficult to integrate with other testing tools like Ceedling and CMock. ## Dependency Notification -Fixtures, by default, uses the Memory addon as well. This is to make it simple for those trying to -follow along with James' book. Using them together is completely optional. You may choose to use -Fixtures without Memory handling by defining `UNITY_FIXTURE_NO_EXTRAS`. It will then stop automatically -pulling in extras and leave you to do it as desired. +Fixtures, by default, uses the Memory addon as well. +This is to make it simple for those trying to follow along with James' book. +Using them together is completely optional. +You may choose to use Fixtures without Memory handling by defining `UNITY_FIXTURE_NO_EXTRAS`. +It will then stop automatically pulling in extras and leave you to do it as desired. ## Usage information -By default the test executables produced by Unity Fixtures run all tests once, but the behavior can -be configured with command-line flags. Run the test executable with the `--help` flag for more -information. +By default the test executables produced by Unity Fixtures run all tests once, but the behavior can be configured with command-line flags. +Run the test executable with the `--help` flag for more information. -It's possible to add a custom line at the end of the help message, typically to point to -project-specific or company-specific unit test documentation. Define `UNITY_CUSTOM_HELP_MSG` to -provide a custom message, e.g.: +It's possible to add a custom line at the end of the help message, typically to point to project-specific or company-specific unit test documentation. +Define `UNITY_CUSTOM_HELP_MSG` to provide a custom message, e.g.: #define UNITY_CUSTOM_HELP_MSG "If any test fails see https://example.com/troubleshooting" diff --git a/extras/memory/readme.md b/extras/memory/readme.md index 0c56d418..ea8b9cf7 100644 --- a/extras/memory/readme.md +++ b/extras/memory/readme.md @@ -1,49 +1,42 @@ # Unity Memory -This Framework is an optional add-on to Unity. By including unity.h and then -unity_memory.h, you have the added ability to track malloc and free calls. This -addon requires that the stdlib functions be overridden by its own defines. These -defines will still malloc / realloc / free etc, but will also track the calls -in order to ensure that you don't have any memory leaks in your programs. +This Framework is an optional add-on to Unity. +By including unity.h and then unity_memory.h, you have the added ability to track malloc and free calls. +This addon requires that the stdlib functions be overridden by its own defines. +These defines will still malloc / realloc / free etc, but will also track the calls in order to ensure that you don't have any memory leaks in your programs. -Note that this is only useful in situations where a unit is in charge of both -the allocation and deallocation of memory. When it is not symmetric, unit testing -can report a number of false failures. A more advanced runtime tool is required to -track complete system memory handling. +Note that this is only useful in situations where a unit is in charge of both the allocation and deallocation of memory. +When it is not symmetric, unit testing can report a number of false failures. +A more advanced runtime tool is required to track complete system memory handling. ## Module API ### `UnityMalloc_StartTest` and `UnityMalloc_EndTest` -These must be called at the beginning and end of each test. For simplicity, they can -be added to `setUp` and `tearDown` in order to do their job. When using the test -runner generator scripts, these will be automatically added to the runner whenever -unity_memory.h is included. +These must be called at the beginning and end of each test. +For simplicity, they can be added to `setUp` and `tearDown` in order to do their job. +When using the test runner generator scripts, these will be automatically added to the runner whenever unity_memory.h is included. ### `UnityMalloc_MakeMallocFailAfterCount` -This can be called from the tests themselves. Passing this function a number will -force the reference counter to start keeping track of malloc calls. During that test, -if the number of malloc calls exceeds the number given, malloc will immediately -start returning `NULL`. This allows you to test error conditions. Think of it as a -simplified mock. +This can be called from the tests themselves. +Passing this function a number will force the reference counter to start keeping track of malloc calls. +During that test, if the number of malloc calls exceeds the number given, malloc will immediately start returning `NULL`. +This allows you to test error conditions. +Think of it as a simplified mock. ## Configuration ### `UNITY_MALLOC` and `UNITY_FREE` By default, this module tries to use the real stdlib `malloc` and `free` internally. -If you would prefer it to use something else, like FreeRTOS's `pvPortMalloc` and -`pvPortFree`, then you can use these defines to make it so. +If you would prefer it to use something else, like FreeRTOS's `pvPortMalloc` and `pvPortFree`, then you can use these defines to make it so. ### `UNITY_EXCLUDE_STDLIB_MALLOC` -If you would like this library to ignore stdlib or other heap engines completely, and -manage the memory on its own, then define this. All memory will be handled internally -(and at likely lower overhead). Note that this is not a very featureful memory manager, -but is sufficient for most testing purposes. +If you would like this library to ignore stdlib or other heap engines completely, and manage the memory on its own, then define this. All memory will be handled internally (and at likely lower overhead). +Note that this is not a very featureful memory manager, but is sufficient for most testing purposes. ### `UNITY_INTERNAL_HEAP_SIZE_BYTES` -When using the built-in memory manager (see `UNITY_EXCLUDE_STDLIB_MALLOC`) this define -allows you to set the heap size this library will use to manage the memory. +When using the built-in memory manager (see `UNITY_EXCLUDE_STDLIB_MALLOC`) this define allows you to set the heap size this library will use to manage the memory. From e44c3b56f7f278c9edfd99e2930063b5133740ce Mon Sep 17 00:00:00 2001 From: Mark VanderVoord Date: Thu, 3 Jun 2021 08:51:24 -0400 Subject: [PATCH 288/454] Adjust how decimal tracking handles to avoid warnings. --- src/unity.c | 2 +- src/unity.h | 2 +- src/unity_internals.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/unity.c b/src/unity.c index be3528fa..764a42b1 100644 --- a/src/unity.c +++ b/src/unity.c @@ -445,7 +445,7 @@ void UnityPrintFloat(const UNITY_DOUBLE input_number) /* build up buffer in reverse order */ digits = 0; - while ((n != 0) || (digits < (decimals + 1))) + while ((n != 0) || (digits <= decimals)) { buf[digits++] = (char)('0' + n % 10); n /= 10; diff --git a/src/unity.h b/src/unity.h index ab986c4b..74a6088e 100644 --- a/src/unity.h +++ b/src/unity.h @@ -10,7 +10,7 @@ #define UNITY_VERSION_MAJOR 2 #define UNITY_VERSION_MINOR 5 -#define UNITY_VERSION_BUILD 2 +#define UNITY_VERSION_BUILD 3 #define UNITY_VERSION ((UNITY_VERSION_MAJOR << 16) | (UNITY_VERSION_MINOR << 8) | UNITY_VERSION_BUILD) #ifdef __cplusplus diff --git a/src/unity_internals.h b/src/unity_internals.h index 4e5629bb..2c91b6db 100644 --- a/src/unity_internals.h +++ b/src/unity_internals.h @@ -889,7 +889,7 @@ int UnityTestMatches(void); #define UNITY_TEST_ASSERT_INT16_ARRAY_WITHIN(delta, expected, actual, num_elements, line, message) UnityAssertNumbersArrayWithin((UNITY_UINT16)(delta), (UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), ((UNITY_UINT32)(num_elements)), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT16, UNITY_ARRAY_TO_ARRAY) #define UNITY_TEST_ASSERT_INT32_ARRAY_WITHIN(delta, expected, actual, num_elements, line, message) UnityAssertNumbersArrayWithin((UNITY_UINT32)(delta), (UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), ((UNITY_UINT32)(num_elements)), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT32, UNITY_ARRAY_TO_ARRAY) #define UNITY_TEST_ASSERT_UINT_ARRAY_WITHIN(delta, expected, actual, num_elements, line, message) UnityAssertNumbersArrayWithin( (delta), (UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), ((UNITY_UINT32)(num_elements)), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT, UNITY_ARRAY_TO_ARRAY) -#define UNITY_TEST_ASSERT_UINT8_ARRAY_WITHIN(delta, expected, actual, num_elements, line, message) UnityAssertNumbersArrayWithin( (UNITY_UINT16)(delta), (UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), ((UNITY_UINT32)(num_elements)), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT8, UNITY_ARRAY_TO_ARRAY) +#define UNITY_TEST_ASSERT_UINT8_ARRAY_WITHIN(delta, expected, actual, num_elements, line, message) UnityAssertNumbersArrayWithin((UNITY_UINT16)(delta), (UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), ((UNITY_UINT32)(num_elements)), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT8, UNITY_ARRAY_TO_ARRAY) #define UNITY_TEST_ASSERT_UINT16_ARRAY_WITHIN(delta, expected, actual, num_elements, line, message) UnityAssertNumbersArrayWithin((UNITY_UINT16)(delta), (UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), ((UNITY_UINT32)(num_elements)), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT16, UNITY_ARRAY_TO_ARRAY) #define UNITY_TEST_ASSERT_UINT32_ARRAY_WITHIN(delta, expected, actual, num_elements, line, message) UnityAssertNumbersArrayWithin((UNITY_UINT32)(delta), (UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), ((UNITY_UINT32)(num_elements)), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT32, UNITY_ARRAY_TO_ARRAY) #define UNITY_TEST_ASSERT_HEX8_ARRAY_WITHIN(delta, expected, actual, num_elements, line, message) UnityAssertNumbersArrayWithin((UNITY_UINT8 )(delta), (UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), ((UNITY_UINT32)(num_elements)), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX8, UNITY_ARRAY_TO_ARRAY) From 2f7406572e6f11212536c99a839e1bf512fe3fb6 Mon Sep 17 00:00:00 2001 From: Mark VanderVoord Date: Fri, 18 Jun 2021 14:32:54 -0400 Subject: [PATCH 289/454] Bump Version --- src/unity.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/unity.h b/src/unity.h index 74a6088e..338df0b5 100644 --- a/src/unity.h +++ b/src/unity.h @@ -10,7 +10,7 @@ #define UNITY_VERSION_MAJOR 2 #define UNITY_VERSION_MINOR 5 -#define UNITY_VERSION_BUILD 3 +#define UNITY_VERSION_BUILD 4 #define UNITY_VERSION ((UNITY_VERSION_MAJOR << 16) | (UNITY_VERSION_MINOR << 8) | UNITY_VERSION_BUILD) #ifdef __cplusplus From 29617c7ecd505407d5e4b96c6e85762e1252c207 Mon Sep 17 00:00:00 2001 From: Daniele Nardi Date: Thu, 15 Jul 2021 13:10:07 +0200 Subject: [PATCH 290/454] Added -externcincludes option in order to build unit test executable in mixed C/C++ environment --- auto/generate_test_runner.rb | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/auto/generate_test_runner.rb b/auto/generate_test_runner.rb index d1d8f91a..9401ad88 100644 --- a/auto/generate_test_runner.rb +++ b/auto/generate_test_runner.rb @@ -212,8 +212,10 @@ def find_setup_and_teardown(source) def create_header(output, mocks, testfile_includes = []) output.puts('/* AUTOGENERATED FILE. DO NOT EDIT. */') output.puts("\n/*=======Automagically Detected Files To Include=====*/") + output.puts('extern "C" {') if @options[:externcincludes] output.puts("#include \"#{@options[:framework]}.h\"") output.puts('#include "cmock.h"') unless mocks.empty? + output.puts('}') if @options[:externcincludes] if @options[:defines] && !@options[:defines].empty? @options[:defines].each { |d| output.puts("#ifndef #{d}\n#define #{d}\n#endif /* #{d} */") } end @@ -227,9 +229,11 @@ def create_header(output, mocks, testfile_includes = []) output.puts("#include #{inc.include?('<') ? inc : "\"#{inc}\""}") end end + output.puts('extern "C" {') if @options[:externcincludes] mocks.each do |mock| output.puts("#include \"#{mock}\"") end + output.puts('}') if @options[:externcincludes] output.puts('#include "CException.h"') if @options[:plugins].include?(:cexception) return unless @options[:enforce_strict_ordering] @@ -465,6 +469,9 @@ def create_h_file(output, filename, tests, testfile_includes, used_mocks) when '-cexception' options[:plugins] = [:cexception] true + when '-externcincludes' + options[:externcincludes] = true + true when /\.*\.ya?ml$/ options = UnityTestRunnerGenerator.grab_config(arg) true From f98e2c868fa3a6eca5504e62fae6495d7d337b61 Mon Sep 17 00:00:00 2001 From: "Andres O. Vela" Date: Mon, 20 Sep 2021 10:49:08 +0200 Subject: [PATCH 291/454] Fix typo in CMakeLists.txt --- CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3a16cdcc..55417a56 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -49,11 +49,11 @@ set(UNITY_EXTENSION_FIXTURE_ENABLED $) set(UNITY_EXTENSION_MEMORY_ENABLED $>) if(${UNITY_EXTENSION_FIXTURE}) - message(STATUS "Unity: Bulding with the fixture extension.") + message(STATUS "Unity: Building with the fixture extension.") endif() if(${UNITY_EXTENSION_MEMORY}) - message(STATUS "Unity: Bulding with the memory extension.") + message(STATUS "Unity: Building with the memory extension.") endif() # Main target ------------------------------------------------------------------ From 13e40e84eec7fe513b7b5eab9c7f36d315286588 Mon Sep 17 00:00:00 2001 From: Ivan Grokhotkov Date: Fri, 3 Dec 2021 11:43:50 +0100 Subject: [PATCH 292/454] extras/fixture: add missing C++ include guards This fixes linking errors when test cases based on Unity fixture are defined in a .cpp file. unity_internals.h doesn't have C++ guards, and is included from unity.h from within C++ header guard block. Same approach is taken in this commit --- extras/fixture/src/unity_fixture.h | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/extras/fixture/src/unity_fixture.h b/extras/fixture/src/unity_fixture.h index 4cc403ef..65750662 100644 --- a/extras/fixture/src/unity_fixture.h +++ b/extras/fixture/src/unity_fixture.h @@ -9,13 +9,20 @@ #define UNITY_FIXTURE_H_ #include "unity.h" -#include "unity_internals.h" #include "unity_fixture_internals.h" #ifndef UNITY_FIXTURE_NO_EXTRAS #include "unity_memory.h" #endif +#ifdef __cplusplus +extern "C" +{ +#endif + +#include "unity_internals.h" + + int UnityMain(int argc, const char* argv[], void (*runAllTests)(void)); @@ -80,4 +87,8 @@ int UnityMain(int argc, const char* argv[], void (*runAllTests)(void)); #define DOUBLES_EQUAL(expected, actual, delta) TEST_ASSERT_DOUBLE_WITHIN((delta), (expected), (actual)) #endif +#ifdef __cplusplus +} +#endif + #endif /* UNITY_FIXTURE_H_ */ From 72ffe691cd444e40dd36e507b13a793dba7dc444 Mon Sep 17 00:00:00 2001 From: Erik Flodin Date: Thu, 15 Apr 2021 21:28:07 +0200 Subject: [PATCH 293/454] Make TEST_RANGE handle a single range Before this change a single range such as TEST_RANGE([5, 100, 5]) would generate the following error: undefined method `flatten' for 5:Integer (NoMethodError) The problem is that reduce called on an array with a single element returns that element which isn't an array of arrays as expected by the following block. --- auto/generate_test_runner.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/auto/generate_test_runner.rb b/auto/generate_test_runner.rb index 9401ad88..7a60f2ef 100644 --- a/auto/generate_test_runner.rb +++ b/auto/generate_test_runner.rb @@ -149,8 +149,8 @@ def find_tests(source) end end.map do |arg_values| (arg_values[0]..arg_values[1]).step(arg_values[2]).to_a - end.reduce do |result, arg_range_expanded| - result.product(arg_range_expanded) + end.reduce(nil) do |result, arg_range_expanded| + result.nil? ? arg_range_expanded.map { |a| [a] } : result.product(arg_range_expanded) end.map do |arg_combinations| arg_combinations.flatten.join(', ') end From 285bb6e282f440ba49c30d4e13980f9c74ec2154 Mon Sep 17 00:00:00 2001 From: Erik Flodin Date: Fri, 16 Apr 2021 12:00:34 +0200 Subject: [PATCH 294/454] Ignore space around parameter in TEST_CASE() This makes it possible to use defines that expand to something that includes space, e.g. TEST_CASE(true). --- auto/generate_test_runner.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/auto/generate_test_runner.rb b/auto/generate_test_runner.rb index 9401ad88..9604ef7f 100644 --- a/auto/generate_test_runner.rb +++ b/auto/generate_test_runner.rb @@ -140,7 +140,7 @@ def find_tests(source) if @options[:use_param_tests] && !arguments.empty? args = [] - arguments.scan(/\s*TEST_CASE\s*\((.*)\)\s*$/) { |a| args << a[0] } + arguments.scan(/\s*TEST_CASE\s*\(\s*(.*)\s*\)\s*$/) { |a| args << a[0] } arguments.scan(/\s*TEST_RANGE\s*\((.*)\)\s*$/).flatten.each do |range_str| args += range_str.scan(/\[\s*(-?\d+.?\d*),\s*(-?\d+.?\d*),\s*(-?\d+.?\d*)\s*\]/).map do |arg_values_str| From 244edf6c1692515936cdb94c68c865299a896e09 Mon Sep 17 00:00:00 2001 From: Jonathan Reichelt Gjertsen Date: Fri, 3 Dec 2021 19:29:30 +0100 Subject: [PATCH 295/454] Add NOT_EQUAL* and NOT_WITHIN* checks for floats and doubles --- README.md | 11 +++++++++ docs/UnityAssertionsReference.md | 18 ++++++++++++++ src/unity.c | 42 ++++++++++++++++++++++++++++++++ src/unity.h | 4 +++ src/unity_internals.h | 17 +++++++++++++ test/tests/test_unity_doubles.c | 38 +++++++++++++++++++++++++++++ test/tests/test_unity_floats.c | 38 +++++++++++++++++++++++++++++ 7 files changed, 168 insertions(+) diff --git a/README.md b/README.md index 0fbdc52c..0cd5a436 100644 --- a/README.md +++ b/README.md @@ -142,14 +142,25 @@ The bit is specified 0-31 for a 32-bit integer. ### Numerical Assertions: Floats TEST_ASSERT_FLOAT_WITHIN(delta, expected, actual) + TEST_ASSERT_DOUBLE_WITHIN(delta, expected, actual) Asserts that the actual value is within plus or minus delta of the expected value. + TEST_ASSERT_FLOAT_NOT_WITHIN(delta, expected, actual) + TEST_ASSERT_DOUBLE_NOT_WITHIN(delta, expected, actual) + +Asserts that the actual value is NOT within plus or minus delta of the expected value. + TEST_ASSERT_EQUAL_FLOAT(expected, actual) TEST_ASSERT_EQUAL_DOUBLE(expected, actual) Asserts that two floating point values are "equal" within a small % delta of the expected value. + TEST_ASSERT_NOT_EQUAL_FLOAT(expected, actual) + TEST_ASSERT_NOT_EQUAL_DOUBLE(expected, actual) + +Asserts that two floating point values are NOT "equal" within a small % delta of the expected value. + TEST_ASSERT_LESS_THAN_FLOAT(threshold, actual) TEST_ASSERT_LESS_THAN_DOUBLE(threshold, actual) TEST_ASSERT_GREATER_THAN_FLOAT(threshold, actual) diff --git a/docs/UnityAssertionsReference.md b/docs/UnityAssertionsReference.md index c2acf1fe..02d35ab7 100644 --- a/docs/UnityAssertionsReference.md +++ b/docs/UnityAssertionsReference.md @@ -555,6 +555,10 @@ Asserts that the `actual` value is within +/- `delta` of the `expected` value. The nature of floating point representation is such that exact evaluations of equality are not guaranteed. +#### `TEST_ASSERT_FLOAT_WITHIN (delta, expected, actual)` + +Asserts that the `actual` value is NOT within +/- `delta` of the `expected` value. + #### `TEST_ASSERT_EQUAL_FLOAT (expected, actual)` Asserts that the `actual` value is "close enough to be considered equal" to the @@ -563,6 +567,11 @@ Asserting section for more details on this. Omitting a user-specified delta in a floating point assertion is both a shorthand convenience and a requirement of code generation conventions for CMock. +#### `TEST_ASSERT_NOT_EQUAL_FLOAT (expected, actual)` + +Asserts that the `actual` value is NOT "close enough to be considered equal" to the +`expected` value. + #### `TEST_ASSERT_EQUAL_FLOAT_ARRAY (expected, actual, num_elements)` See Array assertion section for details. Note that individual array element @@ -631,6 +640,10 @@ Asserts that the `actual` value is within +/- `delta` of the `expected` value. The nature of floating point representation is such that exact evaluations of equality are not guaranteed. +#### `TEST_ASSERT_DOUBLE_NOT_WITHIN (delta, expected, actual)` + +Asserts that the `actual` value is NOT within +/- `delta` of the `expected` value. + #### `TEST_ASSERT_EQUAL_DOUBLE (expected, actual)` Asserts that the `actual` value is "close enough to be considered equal" to the @@ -639,6 +652,11 @@ Asserting section for more details. Omitting a user-specified delta in a floating point assertion is both a shorthand convenience and a requirement of code generation conventions for CMock. +#### `TEST_ASSERT_NOT_EQUAL_DOUBLE (expected, actual)` + +Asserts that the `actual` value is NOT "close enough to be considered equal" to the +`expected` value. + #### `TEST_ASSERT_EQUAL_DOUBLE_ARRAY (expected, actual, num_elements)` See Array assertion section for details. Note that individual array element diff --git a/src/unity.c b/src/unity.c index 71f3db5d..fab13a0b 100644 --- a/src/unity.c +++ b/src/unity.c @@ -977,6 +977,27 @@ void UnityAssertFloatsWithin(const UNITY_FLOAT delta, } } +/*-----------------------------------------------*/ +void UnityAssertFloatsNotWithin(const UNITY_FLOAT delta, + const UNITY_FLOAT expected, + const UNITY_FLOAT actual, + const char* msg, + const UNITY_LINE_TYPE lineNumber) +{ + RETURN_IF_FAIL_OR_IGNORE; + + if (UnityFloatsWithin(delta, expected, actual)) + { + UnityTestResultsFailBegin(lineNumber); + UnityPrint(UnityStrExpected); + UnityPrintFloat((UNITY_DOUBLE)expected); + UnityPrint(UnityStrNotEqual); + UnityPrintFloat((UNITY_DOUBLE)actual); + UnityAddMsgIfSpecified(msg); + UNITY_FAIL_AND_BAIL; + } +} + /*-----------------------------------------------*/ void UnityAssertGreaterOrLessFloat(const UNITY_FLOAT threshold, const UNITY_FLOAT actual, @@ -1145,6 +1166,27 @@ void UnityAssertDoublesWithin(const UNITY_DOUBLE delta, } } +/*-----------------------------------------------*/ +void UnityAssertDoublesNotWithin(const UNITY_DOUBLE delta, + const UNITY_DOUBLE expected, + const UNITY_DOUBLE actual, + const char* msg, + const UNITY_LINE_TYPE lineNumber) +{ + RETURN_IF_FAIL_OR_IGNORE; + + if (UnityDoublesWithin(delta, expected, actual)) + { + UnityTestResultsFailBegin(lineNumber); + UnityPrint(UnityStrExpected); + UnityPrintFloat((UNITY_DOUBLE)expected); + UnityPrint(UnityStrNotEqual); + UnityPrintFloat((UNITY_DOUBLE)actual); + UnityAddMsgIfSpecified(msg); + UNITY_FAIL_AND_BAIL; + } +} + /*-----------------------------------------------*/ void UnityAssertGreaterOrLessDouble(const UNITY_DOUBLE threshold, const UNITY_DOUBLE actual, diff --git a/src/unity.h b/src/unity.h index 3e53961e..01256246 100644 --- a/src/unity.h +++ b/src/unity.h @@ -337,7 +337,9 @@ void verifyTest(void); /* Floating Point (If Enabled) */ #define TEST_ASSERT_FLOAT_WITHIN(delta, expected, actual) UNITY_TEST_ASSERT_FLOAT_WITHIN((delta), (expected), (actual), __LINE__, NULL) +#define TEST_ASSERT_FLOAT_NOT_WITHIN(delta, expected, actual) UNITY_TEST_ASSERT_FLOAT_NOT_WITHIN((delta), (expected), (actual), __LINE__, NULL) #define TEST_ASSERT_EQUAL_FLOAT(expected, actual) UNITY_TEST_ASSERT_EQUAL_FLOAT((expected), (actual), __LINE__, NULL) +#define TEST_ASSERT_NOT_EQUAL_FLOAT(expected, actual) UNITY_TEST_ASSERT_NOT_EQUAL_FLOAT((expected), (actual), __LINE__, NULL) #define TEST_ASSERT_EQUAL_FLOAT_ARRAY(expected, actual, num_elements) UNITY_TEST_ASSERT_EQUAL_FLOAT_ARRAY((expected), (actual), (num_elements), __LINE__, NULL) #define TEST_ASSERT_EACH_EQUAL_FLOAT(expected, actual, num_elements) UNITY_TEST_ASSERT_EACH_EQUAL_FLOAT((expected), (actual), (num_elements), __LINE__, NULL) #define TEST_ASSERT_GREATER_THAN_FLOAT(threshold, actual) UNITY_TEST_ASSERT_GREATER_THAN_FLOAT((threshold), (actual), __LINE__, NULL) @@ -353,7 +355,9 @@ void verifyTest(void); /* Double (If Enabled) */ #define TEST_ASSERT_DOUBLE_WITHIN(delta, expected, actual) UNITY_TEST_ASSERT_DOUBLE_WITHIN((delta), (expected), (actual), __LINE__, NULL) +#define TEST_ASSERT_DOUBLE_NOT_WITHIN(delta, expected, actual) UNITY_TEST_ASSERT_DOUBLE_NOT_WITHIN((delta), (expected), (actual), __LINE__, NULL) #define TEST_ASSERT_EQUAL_DOUBLE(expected, actual) UNITY_TEST_ASSERT_EQUAL_DOUBLE((expected), (actual), __LINE__, NULL) +#define TEST_ASSERT_NOT_EQUAL_DOUBLE(expected, actual) UNITY_TEST_ASSERT_NOT_EQUAL_DOUBLE((expected), (actual), __LINE__, NULL) #define TEST_ASSERT_EQUAL_DOUBLE_ARRAY(expected, actual, num_elements) UNITY_TEST_ASSERT_EQUAL_DOUBLE_ARRAY((expected), (actual), (num_elements), __LINE__, NULL) #define TEST_ASSERT_EACH_EQUAL_DOUBLE(expected, actual, num_elements) UNITY_TEST_ASSERT_EACH_EQUAL_DOUBLE((expected), (actual), (num_elements), __LINE__, NULL) #define TEST_ASSERT_GREATER_THAN_DOUBLE(threshold, actual) UNITY_TEST_ASSERT_GREATER_THAN_DOUBLE((threshold), (actual), __LINE__, NULL) diff --git a/src/unity_internals.h b/src/unity_internals.h index 44921192..24508689 100644 --- a/src/unity_internals.h +++ b/src/unity_internals.h @@ -648,6 +648,12 @@ void UnityAssertFloatsWithin(const UNITY_FLOAT delta, const char* msg, const UNITY_LINE_TYPE lineNumber); +void UnityAssertFloatsNotWithin(const UNITY_FLOAT delta, + const UNITY_FLOAT expected, + const UNITY_FLOAT actual, + const char* msg, + const UNITY_LINE_TYPE lineNumber); + void UnityAssertGreaterOrLessFloat(const UNITY_FLOAT threshold, const UNITY_FLOAT actual, const UNITY_COMPARISON_T compare, @@ -674,6 +680,12 @@ void UnityAssertDoublesWithin(const UNITY_DOUBLE delta, const char* msg, const UNITY_LINE_TYPE lineNumber); +void UnityAssertDoublesNotWithin(const UNITY_DOUBLE delta, + const UNITY_DOUBLE expected, + const UNITY_DOUBLE actual, + const char* msg, + const UNITY_LINE_TYPE lineNumber); + void UnityAssertGreaterOrLessDouble(const UNITY_DOUBLE threshold, const UNITY_DOUBLE actual, const UNITY_COMPARISON_T compare, @@ -1007,6 +1019,7 @@ int UnityTestMatches(void); #ifdef UNITY_EXCLUDE_FLOAT #define UNITY_TEST_ASSERT_FLOAT_WITHIN(delta, expected, actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErrFloat) +#define UNITY_TEST_ASSERT_FLOAT_NOT_WITHIN(delta, expected, actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErrFloat) #define UNITY_TEST_ASSERT_EQUAL_FLOAT(expected, actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErrFloat) #define UNITY_TEST_ASSERT_EQUAL_FLOAT_ARRAY(expected, actual, num_elements, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErrFloat) #define UNITY_TEST_ASSERT_EACH_EQUAL_FLOAT(expected, actual, num_elements, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErrFloat) @@ -1022,7 +1035,9 @@ int UnityTestMatches(void); #define UNITY_TEST_ASSERT_FLOAT_IS_NOT_DETERMINATE(actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErrFloat) #else #define UNITY_TEST_ASSERT_FLOAT_WITHIN(delta, expected, actual, line, message) UnityAssertFloatsWithin((UNITY_FLOAT)(delta), (UNITY_FLOAT)(expected), (UNITY_FLOAT)(actual), (message), (UNITY_LINE_TYPE)(line)) +#define UNITY_TEST_ASSERT_FLOAT_NOT_WITHIN(delta, expected, actual, line, message) UnityAssertFloatsNotWithin((UNITY_FLOAT)(delta), (UNITY_FLOAT)(expected), (UNITY_FLOAT)(actual), (message), (UNITY_LINE_TYPE)(line)) #define UNITY_TEST_ASSERT_EQUAL_FLOAT(expected, actual, line, message) UNITY_TEST_ASSERT_FLOAT_WITHIN((UNITY_FLOAT)(expected) * (UNITY_FLOAT)UNITY_FLOAT_PRECISION, (UNITY_FLOAT)(expected), (UNITY_FLOAT)(actual), (UNITY_LINE_TYPE)(line), (message)) +#define UNITY_TEST_ASSERT_NOT_EQUAL_FLOAT(expected, actual, line, message) UNITY_TEST_ASSERT_FLOAT_NOT_WITHIN((UNITY_FLOAT)(expected) * (UNITY_FLOAT)UNITY_FLOAT_PRECISION, (UNITY_FLOAT)(expected), (UNITY_FLOAT)(actual), (UNITY_LINE_TYPE)(line), (message)) #define UNITY_TEST_ASSERT_EQUAL_FLOAT_ARRAY(expected, actual, num_elements, line, message) UnityAssertEqualFloatArray((UNITY_FLOAT*)(expected), (UNITY_FLOAT*)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_ARRAY_TO_ARRAY) #define UNITY_TEST_ASSERT_EACH_EQUAL_FLOAT(expected, actual, num_elements, line, message) UnityAssertEqualFloatArray(UnityFloatToPtr(expected), (UNITY_FLOAT*)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_ARRAY_TO_VAL) #define UNITY_TEST_ASSERT_GREATER_THAN_FLOAT(threshold, actual, line, message) UnityAssertGreaterOrLessFloat((UNITY_FLOAT)(threshold), (UNITY_FLOAT)(actual), UNITY_GREATER_THAN, (message), (UNITY_LINE_TYPE)(line)) @@ -1054,7 +1069,9 @@ int UnityTestMatches(void); #define UNITY_TEST_ASSERT_DOUBLE_IS_NOT_DETERMINATE(actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErrDouble) #else #define UNITY_TEST_ASSERT_DOUBLE_WITHIN(delta, expected, actual, line, message) UnityAssertDoublesWithin((UNITY_DOUBLE)(delta), (UNITY_DOUBLE)(expected), (UNITY_DOUBLE)(actual), (message), (UNITY_LINE_TYPE)(line)) +#define UNITY_TEST_ASSERT_DOUBLE_NOT_WITHIN(delta, expected, actual, line, message) UnityAssertDoublesNotWithin((UNITY_DOUBLE)(delta), (UNITY_DOUBLE)(expected), (UNITY_DOUBLE)(actual), (message), (UNITY_LINE_TYPE)(line)) #define UNITY_TEST_ASSERT_EQUAL_DOUBLE(expected, actual, line, message) UNITY_TEST_ASSERT_DOUBLE_WITHIN((UNITY_DOUBLE)(expected) * (UNITY_DOUBLE)UNITY_DOUBLE_PRECISION, (UNITY_DOUBLE)(expected), (UNITY_DOUBLE)(actual), (UNITY_LINE_TYPE)(line), (message)) +#define UNITY_TEST_ASSERT_NOT_EQUAL_DOUBLE(expected, actual, line, message) UNITY_TEST_ASSERT_DOUBLE_NOT_WITHIN((UNITY_DOUBLE)(expected) * (UNITY_DOUBLE)UNITY_DOUBLE_PRECISION, (UNITY_DOUBLE)(expected), (UNITY_DOUBLE)(actual), (UNITY_LINE_TYPE)(line), (message)) #define UNITY_TEST_ASSERT_EQUAL_DOUBLE_ARRAY(expected, actual, num_elements, line, message) UnityAssertEqualDoubleArray((UNITY_DOUBLE*)(expected), (UNITY_DOUBLE*)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_ARRAY_TO_ARRAY) #define UNITY_TEST_ASSERT_EACH_EQUAL_DOUBLE(expected, actual, num_elements, line, message) UnityAssertEqualDoubleArray(UnityDoubleToPtr(expected), (UNITY_DOUBLE*)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_ARRAY_TO_VAL) #define UNITY_TEST_ASSERT_GREATER_THAN_DOUBLE(threshold, actual, line, message) UnityAssertGreaterOrLessDouble((UNITY_DOUBLE)(threshold), (UNITY_DOUBLE)(actual), UNITY_GREATER_THAN, (message), (UNITY_LINE_TYPE)(line)) diff --git a/test/tests/test_unity_doubles.c b/test/tests/test_unity_doubles.c index 32020710..b188bac7 100644 --- a/test/tests/test_unity_doubles.c +++ b/test/tests/test_unity_doubles.c @@ -42,6 +42,10 @@ void testDoublesWithinDelta(void) TEST_ASSERT_DOUBLE_WITHIN(1.0, 187245.0, 187246.0); TEST_ASSERT_DOUBLE_WITHIN(0.05, 9273.2549, 9273.2049); TEST_ASSERT_DOUBLE_WITHIN(0.007, -726.93725, -726.94424); + + EXPECT_ABORT_BEGIN + TEST_ASSERT_DOUBLE_NOT_WITHIN(0.05, 9273.2549, 9273.2049); + VERIFY_FAILS_END #endif } @@ -50,6 +54,8 @@ void testDoublesNotWithinDelta(void) #ifdef UNITY_EXCLUDE_DOUBLE TEST_IGNORE(); #else + TEST_ASSERT_DOUBLE_NOT_WITHIN(0.05, 9273.2649, 9273.2049); + EXPECT_ABORT_BEGIN TEST_ASSERT_DOUBLE_WITHIN(0.05, 9273.2649, 9273.2049); VERIFY_FAILS_END @@ -66,6 +72,10 @@ void testDoublesEqual(void) TEST_ASSERT_EQUAL_DOUBLE(187241234567.5, 187241234567.6); TEST_ASSERT_EQUAL_DOUBLE(9273.2512345649, 9273.25123455699); TEST_ASSERT_EQUAL_DOUBLE(-726.12345693724, -726.1234569374); + + EXPECT_ABORT_BEGIN + TEST_ASSERT_NOT_EQUAL_DOUBLE(-726.12345693724, -726.1234569374); + VERIFY_FAILS_END #endif } @@ -74,6 +84,8 @@ void testDoublesNotEqual(void) #ifdef UNITY_EXCLUDE_DOUBLE TEST_IGNORE(); #else + TEST_ASSERT_NOT_EQUAL_DOUBLE(9273.9649, 9273.0049); + EXPECT_ABORT_BEGIN TEST_ASSERT_EQUAL_DOUBLE(9273.9649, 9273.0049); VERIFY_FAILS_END @@ -85,6 +97,8 @@ void testDoublesNotEqualNegative1(void) #ifdef UNITY_EXCLUDE_DOUBLE TEST_IGNORE(); #else + TEST_ASSERT_NOT_EQUAL_DOUBLE(-9273.9649, -9273.0049); + EXPECT_ABORT_BEGIN TEST_ASSERT_EQUAL_DOUBLE(-9273.9649, -9273.0049); VERIFY_FAILS_END @@ -96,6 +110,8 @@ void testDoublesNotEqualNegative2(void) #ifdef UNITY_EXCLUDE_DOUBLE TEST_IGNORE(); #else + TEST_ASSERT_NOT_EQUAL_DOUBLE(-9273.0049, -9273.9649); + EXPECT_ABORT_BEGIN TEST_ASSERT_EQUAL_DOUBLE(-9273.0049, -9273.9649); VERIFY_FAILS_END @@ -107,6 +123,8 @@ void testDoublesNotEqualActualNaN(void) #ifdef UNITY_EXCLUDE_DOUBLE TEST_IGNORE(); #else + TEST_ASSERT_NOT_EQUAL_DOUBLE(85.963, 0.0 / d_zero); + EXPECT_ABORT_BEGIN TEST_ASSERT_EQUAL_DOUBLE(85.963, 0.0 / d_zero); VERIFY_FAILS_END @@ -118,6 +136,8 @@ void testDoublesNotEqualExpectedNaN(void) #ifdef UNITY_EXCLUDE_DOUBLE TEST_IGNORE(); #else + TEST_ASSERT_NOT_EQUAL_DOUBLE(0.0 / d_zero, 85.963); + EXPECT_ABORT_BEGIN TEST_ASSERT_EQUAL_DOUBLE(0.0 / d_zero, 85.963); VERIFY_FAILS_END @@ -130,6 +150,10 @@ void testDoublesEqualBothNaN(void) TEST_IGNORE(); #else TEST_ASSERT_EQUAL_DOUBLE(0.0 / d_zero, 0.0 / d_zero); + + EXPECT_ABORT_BEGIN + TEST_ASSERT_NOT_EQUAL_DOUBLE(0.0 / d_zero, 0.0 / d_zero); + VERIFY_FAILS_END #endif } @@ -138,6 +162,8 @@ void testDoublesNotEqualInfNaN(void) #ifdef UNITY_EXCLUDE_DOUBLE TEST_IGNORE(); #else + TEST_ASSERT_NOT_EQUAL_DOUBLE(1.0 / d_zero, 0.0 / d_zero); + EXPECT_ABORT_BEGIN TEST_ASSERT_EQUAL_DOUBLE(1.0 / d_zero, 0.0 / d_zero); VERIFY_FAILS_END @@ -149,6 +175,8 @@ void testDoublesNotEqualNaNInf(void) #ifdef UNITY_EXCLUDE_DOUBLE TEST_IGNORE(); #else + TEST_ASSERT_NOT_EQUAL_DOUBLE(0.0 / d_zero, 1.0 / d_zero); + EXPECT_ABORT_BEGIN TEST_ASSERT_EQUAL_DOUBLE(0.0 / d_zero, 1.0 / d_zero); VERIFY_FAILS_END @@ -160,6 +188,8 @@ void testDoublesNotEqualActualInf(void) #ifdef UNITY_EXCLUDE_DOUBLE TEST_IGNORE(); #else + TEST_ASSERT_NOT_EQUAL_DOUBLE(321.642, 1.0 / d_zero); + EXPECT_ABORT_BEGIN TEST_ASSERT_EQUAL_DOUBLE(321.642, 1.0 / d_zero); VERIFY_FAILS_END @@ -171,6 +201,8 @@ void testDoublesNotEqualExpectedInf(void) #ifdef UNITY_EXCLUDE_DOUBLE TEST_IGNORE(); #else + TEST_ASSERT_NOT_EQUAL_DOUBLE(1.0 / d_zero, 321.642); + EXPECT_ABORT_BEGIN TEST_ASSERT_EQUAL_DOUBLE(1.0 / d_zero, 321.642); VERIFY_FAILS_END @@ -183,6 +215,10 @@ void testDoublesEqualBothInf(void) TEST_IGNORE(); #else TEST_ASSERT_EQUAL_DOUBLE(1.0 / d_zero, 1.0 / d_zero); + + EXPECT_ABORT_BEGIN + TEST_ASSERT_NOT_EQUAL_DOUBLE(1.0 / d_zero, 1.0 / d_zero); + VERIFY_FAILS_END #endif } @@ -191,6 +227,8 @@ void testDoublesNotEqualPlusMinusInf(void) #ifdef UNITY_EXCLUDE_DOUBLE TEST_IGNORE(); #else + TEST_ASSERT_NOT_EQUAL_DOUBLE(1.0 / d_zero, -1.0 / d_zero); + EXPECT_ABORT_BEGIN TEST_ASSERT_EQUAL_DOUBLE(1.0 / d_zero, -1.0 / d_zero); VERIFY_FAILS_END diff --git a/test/tests/test_unity_floats.c b/test/tests/test_unity_floats.c index 2f15c1a5..4e0ac65c 100644 --- a/test/tests/test_unity_floats.c +++ b/test/tests/test_unity_floats.c @@ -42,6 +42,10 @@ void testFloatsWithinDelta(void) TEST_ASSERT_FLOAT_WITHIN(1.0f, 187245.0f, 187246.0f); TEST_ASSERT_FLOAT_WITHIN(0.05f, 9273.2549f, 9273.2049f); TEST_ASSERT_FLOAT_WITHIN(0.007f, -726.93724f, -726.94424f); + + EXPECT_ABORT_BEGIN + TEST_ASSERT_FLOAT_NOT_WITHIN(0.05f, 9273.2549f, 9273.2049f); + VERIFY_FAILS_END #endif } @@ -50,6 +54,8 @@ void testFloatsNotWithinDelta(void) #ifdef UNITY_EXCLUDE_FLOAT TEST_IGNORE(); #else + TEST_ASSERT_FLOAT_NOT_WITHIN(0.05f, 9273.2649f, 9273.2049f); + EXPECT_ABORT_BEGIN TEST_ASSERT_FLOAT_WITHIN(0.05f, 9273.2649f, 9273.2049f); VERIFY_FAILS_END @@ -65,6 +71,10 @@ void testFloatsEqual(void) TEST_ASSERT_EQUAL_FLOAT(18724.5f, 18724.6f); TEST_ASSERT_EQUAL_FLOAT(9273.2549f, 9273.2599f); TEST_ASSERT_EQUAL_FLOAT(-726.93724f, -726.9374f); + + EXPECT_ABORT_BEGIN + TEST_ASSERT_NOT_EQUAL_FLOAT(-726.93724f, -726.9374f); + VERIFY_FAILS_END #endif } @@ -73,6 +83,8 @@ void testFloatsNotEqual(void) #ifdef UNITY_EXCLUDE_FLOAT TEST_IGNORE(); #else + TEST_ASSERT_NOT_EQUAL_FLOAT(9273.9649f, 9273.0049f); + EXPECT_ABORT_BEGIN TEST_ASSERT_EQUAL_FLOAT(9273.9649f, 9273.0049f); VERIFY_FAILS_END @@ -84,6 +96,8 @@ void testFloatsNotEqualNegative1(void) #ifdef UNITY_EXCLUDE_FLOAT TEST_IGNORE(); #else + TEST_ASSERT_NOT_EQUAL_FLOAT(-9273.9649f, -9273.0049f); + EXPECT_ABORT_BEGIN TEST_ASSERT_EQUAL_FLOAT(-9273.9649f, -9273.0049f); VERIFY_FAILS_END @@ -95,6 +109,8 @@ void testFloatsNotEqualNegative2(void) #ifdef UNITY_EXCLUDE_FLOAT TEST_IGNORE(); #else + TEST_ASSERT_NOT_EQUAL_FLOAT(-9273.0049f, -9273.9649f); + EXPECT_ABORT_BEGIN TEST_ASSERT_EQUAL_FLOAT(-9273.0049f, -9273.9649f); VERIFY_FAILS_END @@ -106,6 +122,8 @@ void testFloatsNotEqualActualNaN(void) #ifdef UNITY_EXCLUDE_FLOAT TEST_IGNORE(); #else + TEST_ASSERT_NOT_EQUAL_FLOAT(85.963f, 0.0f / f_zero); + EXPECT_ABORT_BEGIN TEST_ASSERT_EQUAL_FLOAT(85.963f, 0.0f / f_zero); VERIFY_FAILS_END @@ -117,6 +135,8 @@ void testFloatsNotEqualExpectedNaN(void) #ifdef UNITY_EXCLUDE_FLOAT TEST_IGNORE(); #else + TEST_ASSERT_NOT_EQUAL_FLOAT(0.0f / f_zero, 85.963f); + EXPECT_ABORT_BEGIN TEST_ASSERT_EQUAL_FLOAT(0.0f / f_zero, 85.963f); VERIFY_FAILS_END @@ -129,6 +149,10 @@ void testFloatsEqualBothNaN(void) TEST_IGNORE(); #else TEST_ASSERT_EQUAL_FLOAT(0.0f / f_zero, 0.0f / f_zero); + + EXPECT_ABORT_BEGIN + TEST_ASSERT_NOT_EQUAL_FLOAT(0.0f / f_zero, 0.0f / f_zero); + VERIFY_FAILS_END #endif } @@ -137,6 +161,8 @@ void testFloatsNotEqualInfNaN(void) #ifdef UNITY_EXCLUDE_FLOAT TEST_IGNORE(); #else + TEST_ASSERT_NOT_EQUAL_FLOAT(1.0f / f_zero, 0.0f / f_zero); + EXPECT_ABORT_BEGIN TEST_ASSERT_EQUAL_FLOAT(1.0f / f_zero, 0.0f / f_zero); VERIFY_FAILS_END @@ -148,6 +174,8 @@ void testFloatsNotEqualNaNInf(void) #ifdef UNITY_EXCLUDE_FLOAT TEST_IGNORE(); #else + TEST_ASSERT_NOT_EQUAL_FLOAT(0.0f / f_zero, 1.0f / f_zero); + EXPECT_ABORT_BEGIN TEST_ASSERT_EQUAL_FLOAT(0.0f / f_zero, 1.0f / f_zero); VERIFY_FAILS_END @@ -159,6 +187,8 @@ void testFloatsNotEqualActualInf(void) #ifdef UNITY_EXCLUDE_FLOAT TEST_IGNORE(); #else + TEST_ASSERT_NOT_EQUAL_FLOAT(321.642f, 1.0f / f_zero); + EXPECT_ABORT_BEGIN TEST_ASSERT_EQUAL_FLOAT(321.642f, 1.0f / f_zero); VERIFY_FAILS_END @@ -170,6 +200,8 @@ void testFloatsNotEqualExpectedInf(void) #ifdef UNITY_EXCLUDE_FLOAT TEST_IGNORE(); #else + TEST_ASSERT_NOT_EQUAL_FLOAT(1.0f / f_zero, 321.642f); + EXPECT_ABORT_BEGIN TEST_ASSERT_EQUAL_FLOAT(1.0f / f_zero, 321.642f); VERIFY_FAILS_END @@ -182,6 +214,10 @@ void testFloatsEqualBothInf(void) TEST_IGNORE(); #else TEST_ASSERT_EQUAL_FLOAT(1.0f / f_zero, 1.0f / f_zero); + + EXPECT_ABORT_BEGIN + TEST_ASSERT_NOT_EQUAL_FLOAT(1.0f / f_zero, 1.0f / f_zero); + VERIFY_FAILS_END #endif } @@ -190,6 +226,8 @@ void testFloatsNotEqualPlusMinusInf(void) #ifdef UNITY_EXCLUDE_FLOAT TEST_IGNORE(); #else + TEST_ASSERT_NOT_EQUAL_FLOAT(1.0f / f_zero, -1.0f / f_zero); + EXPECT_ABORT_BEGIN TEST_ASSERT_EQUAL_FLOAT(1.0f / f_zero, -1.0f / f_zero); VERIFY_FAILS_END From 2a8f3fe65a06b59681811370d9e20ecb7f9876fc Mon Sep 17 00:00:00 2001 From: Jonathan Reichelt Gjertsen Date: Fri, 3 Dec 2021 19:32:33 +0100 Subject: [PATCH 296/454] Try to fix C89 incompatibilities in UnityAssertGreaterOrLess(Double|Float) --- src/unity.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/unity.c b/src/unity.c index fab13a0b..d9de692a 100644 --- a/src/unity.c +++ b/src/unity.c @@ -1005,11 +1005,13 @@ void UnityAssertGreaterOrLessFloat(const UNITY_FLOAT threshold, const char* msg, const UNITY_LINE_TYPE lineNumber) { + int failed; + RETURN_IF_FAIL_OR_IGNORE; - int failed = 0; + failed = 0; - // Checking for "not success" rather than failure to get the right result for NaN + /* Checking for "not success" rather than failure to get the right result for NaN */ if (!(actual < threshold) && (compare & UNITY_SMALLER_THAN)) { failed = 1; } if (!(actual > threshold) && (compare & UNITY_GREATER_THAN)) { failed = 1; } @@ -1194,11 +1196,13 @@ void UnityAssertGreaterOrLessDouble(const UNITY_DOUBLE threshold, const char* msg, const UNITY_LINE_TYPE lineNumber) { + int failed; + RETURN_IF_FAIL_OR_IGNORE; - int failed = 0; + failed = 0; - // Checking for "not success" rather than failure to get the right result for NaN + /* Checking for "not success" rather than failure to get the right result for NaN */ if (!(actual < threshold) && (compare & UNITY_SMALLER_THAN)) { failed = 1; } if (!(actual > threshold) && (compare & UNITY_GREATER_THAN)) { failed = 1; } From b732fbf1cabeadca3531500e303a88a00b42c9cb Mon Sep 17 00:00:00 2001 From: Jonathan Reichelt Gjertsen Date: Fri, 3 Dec 2021 20:38:09 +0100 Subject: [PATCH 297/454] Add LESS_OR_EQUAL and GREATER_OR_EQUAL assertions for doubles and floats --- README.md | 4 + docs/UnityAssertionsReference.md | 20 +++ src/unity.c | 6 + src/unity.h | 10 ++ src/unity_internals.h | 8 ++ test/tests/test_unity_doubles.c | 212 +++++++++++++++++++++++++++++++ test/tests/test_unity_floats.c | 211 ++++++++++++++++++++++++++++++ 7 files changed, 471 insertions(+) diff --git a/README.md b/README.md index 0cd5a436..e71527b2 100644 --- a/README.md +++ b/README.md @@ -168,6 +168,10 @@ Asserts that two floating point values are NOT "equal" within a small % delta of Asserts that the actual value is less than or greater than the threshold. +There are also `LESS_OR_EQUAL` and `GREATER_OR_EQUAL` variations. +These obey the same rules for equality as do `TEST_ASSERT_EQUAL_FLOAT` and `TEST_ASSERT_EQUAL_DOUBLE`: +If the two values are within a small % delta of the expected value, the assertion will pass. + ### String Assertions TEST_ASSERT_EQUAL_STRING(expected, actual) diff --git a/docs/UnityAssertionsReference.md b/docs/UnityAssertionsReference.md index 02d35ab7..f1ef63df 100644 --- a/docs/UnityAssertionsReference.md +++ b/docs/UnityAssertionsReference.md @@ -591,6 +591,16 @@ Asserts that the `actual` parameter is greater than `threshold` (exclusive). For example, if the threshold value is 1.0f, the assertion will fail if it is less than 1.0f. +#### `TEST_ASSERT_LESS_OR_EQUAL_FLOAT (threshold, actual)` + +Asserts that the `actual` parameter is less than or equal to `threshold`. +The rules for equality are the same as for `TEST_ASSERT_EQUAL_FLOAT`. + +#### `TEST_ASSERT_GREATER_OR_EQUAL_FLOAT (threshold, actual)` + +Asserts that the `actual` parameter is greater than `threshold`. +The rules for equality are the same as for `TEST_ASSERT_EQUAL_FLOAT`. + #### `TEST_ASSERT_FLOAT_IS_INF (actual)` Asserts that `actual` parameter is equivalent to positive infinity floating @@ -670,12 +680,22 @@ Asserts that the `actual` parameter is less than `threshold` (exclusive). For example, if the threshold value is 1.0, the assertion will fail if it is greater than 1.0. +#### `TEST_ASSERT_LESS_OR_EQUAL_DOUBLE (threshold, actual)` + +Asserts that the `actual` parameter is less than or equal to `threshold`. +The rules for equality are the same as for `TEST_ASSERT_EQUAL_DOUBLE`. + #### `TEST_ASSERT_GREATER_THAN_DOUBLE (threshold, actual)` Asserts that the `actual` parameter is greater than `threshold` (exclusive). For example, if the threshold value is 1.0, the assertion will fail if it is less than 1.0. +#### `TEST_ASSERT_GREATER_OR_EQUAL_DOUBLE (threshold, actual)` + +Asserts that the `actual` parameter is greater than or equal to `threshold`. +The rules for equality are the same as for `TEST_ASSERT_EQUAL_DOUBLE`. + #### `TEST_ASSERT_DOUBLE_IS_INF (actual)` Asserts that `actual` parameter is equivalent to positive infinity floating diff --git a/src/unity.c b/src/unity.c index d9de692a..e7cbafaf 100644 --- a/src/unity.c +++ b/src/unity.c @@ -1015,6 +1015,8 @@ void UnityAssertGreaterOrLessFloat(const UNITY_FLOAT threshold, if (!(actual < threshold) && (compare & UNITY_SMALLER_THAN)) { failed = 1; } if (!(actual > threshold) && (compare & UNITY_GREATER_THAN)) { failed = 1; } + if ((compare & UNITY_EQUAL_TO) && UnityFloatsWithin(threshold * UNITY_FLOAT_PRECISION, threshold, actual)) { failed = 0; } + if (failed) { UnityTestResultsFailBegin(lineNumber); @@ -1022,6 +1024,7 @@ void UnityAssertGreaterOrLessFloat(const UNITY_FLOAT threshold, UnityPrintFloat(actual); if (compare & UNITY_GREATER_THAN) { UnityPrint(UnityStrGt); } if (compare & UNITY_SMALLER_THAN) { UnityPrint(UnityStrLt); } + if (compare & UNITY_EQUAL_TO) { UnityPrint(UnityStrOrEqual); } UnityPrintFloat(threshold); UnityAddMsgIfSpecified(msg); UNITY_FAIL_AND_BAIL; @@ -1206,6 +1209,8 @@ void UnityAssertGreaterOrLessDouble(const UNITY_DOUBLE threshold, if (!(actual < threshold) && (compare & UNITY_SMALLER_THAN)) { failed = 1; } if (!(actual > threshold) && (compare & UNITY_GREATER_THAN)) { failed = 1; } + if ((compare & UNITY_EQUAL_TO) && UnityFloatsWithin(threshold * UNITY_DOUBLE_PRECISION, threshold, actual)) { failed = 0; } + if (failed) { UnityTestResultsFailBegin(lineNumber); @@ -1213,6 +1218,7 @@ void UnityAssertGreaterOrLessDouble(const UNITY_DOUBLE threshold, UnityPrintFloat(actual); if (compare & UNITY_GREATER_THAN) { UnityPrint(UnityStrGt); } if (compare & UNITY_SMALLER_THAN) { UnityPrint(UnityStrLt); } + if (compare & UNITY_EQUAL_TO) { UnityPrint(UnityStrOrEqual); } UnityPrintFloat(threshold); UnityAddMsgIfSpecified(msg); UNITY_FAIL_AND_BAIL; diff --git a/src/unity.h b/src/unity.h index 01256246..f33448a1 100644 --- a/src/unity.h +++ b/src/unity.h @@ -343,7 +343,9 @@ void verifyTest(void); #define TEST_ASSERT_EQUAL_FLOAT_ARRAY(expected, actual, num_elements) UNITY_TEST_ASSERT_EQUAL_FLOAT_ARRAY((expected), (actual), (num_elements), __LINE__, NULL) #define TEST_ASSERT_EACH_EQUAL_FLOAT(expected, actual, num_elements) UNITY_TEST_ASSERT_EACH_EQUAL_FLOAT((expected), (actual), (num_elements), __LINE__, NULL) #define TEST_ASSERT_GREATER_THAN_FLOAT(threshold, actual) UNITY_TEST_ASSERT_GREATER_THAN_FLOAT((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_GREATER_OR_EQUAL_FLOAT(threshold, actual) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_FLOAT((threshold), (actual), __LINE__, NULL) #define TEST_ASSERT_LESS_THAN_FLOAT(threshold, actual) UNITY_TEST_ASSERT_LESS_THAN_FLOAT((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_LESS_OR_EQUAL_FLOAT(threshold, actual) UNITY_TEST_ASSERT_LESS_OR_EQUAL_FLOAT((threshold), (actual), __LINE__, NULL) #define TEST_ASSERT_FLOAT_IS_INF(actual) UNITY_TEST_ASSERT_FLOAT_IS_INF((actual), __LINE__, NULL) #define TEST_ASSERT_FLOAT_IS_NEG_INF(actual) UNITY_TEST_ASSERT_FLOAT_IS_NEG_INF((actual), __LINE__, NULL) #define TEST_ASSERT_FLOAT_IS_NAN(actual) UNITY_TEST_ASSERT_FLOAT_IS_NAN((actual), __LINE__, NULL) @@ -361,7 +363,9 @@ void verifyTest(void); #define TEST_ASSERT_EQUAL_DOUBLE_ARRAY(expected, actual, num_elements) UNITY_TEST_ASSERT_EQUAL_DOUBLE_ARRAY((expected), (actual), (num_elements), __LINE__, NULL) #define TEST_ASSERT_EACH_EQUAL_DOUBLE(expected, actual, num_elements) UNITY_TEST_ASSERT_EACH_EQUAL_DOUBLE((expected), (actual), (num_elements), __LINE__, NULL) #define TEST_ASSERT_GREATER_THAN_DOUBLE(threshold, actual) UNITY_TEST_ASSERT_GREATER_THAN_DOUBLE((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_GREATER_OR_EQUAL_DOUBLE(threshold, actual) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_DOUBLE((threshold), (actual), __LINE__, NULL) #define TEST_ASSERT_LESS_THAN_DOUBLE(threshold, actual) UNITY_TEST_ASSERT_LESS_THAN_DOUBLE((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_LESS_OR_EQUAL_DOUBLE(threshold, actual) UNITY_TEST_ASSERT_LESS_OR_EQUAL_DOUBLE((threshold), (actual), __LINE__, NULL) #define TEST_ASSERT_DOUBLE_IS_INF(actual) UNITY_TEST_ASSERT_DOUBLE_IS_INF((actual), __LINE__, NULL) #define TEST_ASSERT_DOUBLE_IS_NEG_INF(actual) UNITY_TEST_ASSERT_DOUBLE_IS_NEG_INF((actual), __LINE__, NULL) #define TEST_ASSERT_DOUBLE_IS_NAN(actual) UNITY_TEST_ASSERT_DOUBLE_IS_NAN((actual), __LINE__, NULL) @@ -615,10 +619,13 @@ void verifyTest(void); /* Floating Point (If Enabled) */ #define TEST_ASSERT_FLOAT_WITHIN_MESSAGE(delta, expected, actual, message) UNITY_TEST_ASSERT_FLOAT_WITHIN((delta), (expected), (actual), __LINE__, (message)) #define TEST_ASSERT_EQUAL_FLOAT_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_FLOAT((expected), (actual), __LINE__, (message)) +#define TEST_ASSERT_NOT_EQUAL_FLOAT_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_NOT_EQUAL_FLOAT((expected), (actual), __LINE__, (message)) #define TEST_ASSERT_EQUAL_FLOAT_ARRAY_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EQUAL_FLOAT_ARRAY((expected), (actual), (num_elements), __LINE__, (message)) #define TEST_ASSERT_EACH_EQUAL_FLOAT_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EACH_EQUAL_FLOAT((expected), (actual), (num_elements), __LINE__, (message)) #define TEST_ASSERT_GREATER_THAN_FLOAT_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_THAN_FLOAT((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_GREATER_OR_EQUAL_FLOAT_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_FLOAT((threshold), (actual), __LINE__, (message)) #define TEST_ASSERT_LESS_THAN_FLOAT_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_LESS_THAN_FLOAT((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_LESS_OR_EQUAL_FLOAT_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_LESS_OR_EQUAL_FLOAT((threshold), (actual), __LINE__, (message)) #define TEST_ASSERT_FLOAT_IS_INF_MESSAGE(actual, message) UNITY_TEST_ASSERT_FLOAT_IS_INF((actual), __LINE__, (message)) #define TEST_ASSERT_FLOAT_IS_NEG_INF_MESSAGE(actual, message) UNITY_TEST_ASSERT_FLOAT_IS_NEG_INF((actual), __LINE__, (message)) #define TEST_ASSERT_FLOAT_IS_NAN_MESSAGE(actual, message) UNITY_TEST_ASSERT_FLOAT_IS_NAN((actual), __LINE__, (message)) @@ -631,10 +638,13 @@ void verifyTest(void); /* Double (If Enabled) */ #define TEST_ASSERT_DOUBLE_WITHIN_MESSAGE(delta, expected, actual, message) UNITY_TEST_ASSERT_DOUBLE_WITHIN((delta), (expected), (actual), __LINE__, (message)) #define TEST_ASSERT_EQUAL_DOUBLE_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_DOUBLE((expected), (actual), __LINE__, (message)) +#define TEST_ASSERT_NOT_EQUAL_DOUBLE_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_NOT_EQUAL_DOUBLE((expected), (actual), __LINE__, (message)) #define TEST_ASSERT_EQUAL_DOUBLE_ARRAY_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EQUAL_DOUBLE_ARRAY((expected), (actual), (num_elements), __LINE__, (message)) #define TEST_ASSERT_EACH_EQUAL_DOUBLE_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EACH_EQUAL_DOUBLE((expected), (actual), (num_elements), __LINE__, (message)) #define TEST_ASSERT_GREATER_THAN_DOUBLE_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_THAN_DOUBLE((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_GREATER_OR_EQUAL_DOUBLE_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_DOUBLE((threshold), (actual), __LINE__, (message)) #define TEST_ASSERT_LESS_THAN_DOUBLE_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_LESS_THAN_DOUBLE((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_LESS_OR_EQUAL_DOUBLE_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_LESS_OR_EQUAL_DOUBLE((threshold), (actual), __LINE__, (message)) #define TEST_ASSERT_DOUBLE_IS_INF_MESSAGE(actual, message) UNITY_TEST_ASSERT_DOUBLE_IS_INF((actual), __LINE__, (message)) #define TEST_ASSERT_DOUBLE_IS_NEG_INF_MESSAGE(actual, message) UNITY_TEST_ASSERT_DOUBLE_IS_NEG_INF((actual), __LINE__, (message)) #define TEST_ASSERT_DOUBLE_IS_NAN_MESSAGE(actual, message) UNITY_TEST_ASSERT_DOUBLE_IS_NAN((actual), __LINE__, (message)) diff --git a/src/unity_internals.h b/src/unity_internals.h index 24508689..91a95b5d 100644 --- a/src/unity_internals.h +++ b/src/unity_internals.h @@ -1024,7 +1024,9 @@ int UnityTestMatches(void); #define UNITY_TEST_ASSERT_EQUAL_FLOAT_ARRAY(expected, actual, num_elements, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErrFloat) #define UNITY_TEST_ASSERT_EACH_EQUAL_FLOAT(expected, actual, num_elements, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErrFloat) #define UNITY_TEST_ASSERT_GREATER_THAN_FLOAT(threshold, actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErrFloat) +#define UNITY_TEST_ASSERT_GREATER_OR_EQUAL_FLOAT(threshold, actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErrFloat) #define UNITY_TEST_ASSERT_LESS_THAN_FLOAT(threshold, actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErrFloat) +#define UNITY_TEST_ASSERT_LESS_OR_EQUAL_FLOAT(threshold, actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErrFloat) #define UNITY_TEST_ASSERT_FLOAT_IS_INF(actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErrFloat) #define UNITY_TEST_ASSERT_FLOAT_IS_NEG_INF(actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErrFloat) #define UNITY_TEST_ASSERT_FLOAT_IS_NAN(actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErrFloat) @@ -1041,7 +1043,9 @@ int UnityTestMatches(void); #define UNITY_TEST_ASSERT_EQUAL_FLOAT_ARRAY(expected, actual, num_elements, line, message) UnityAssertEqualFloatArray((UNITY_FLOAT*)(expected), (UNITY_FLOAT*)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_ARRAY_TO_ARRAY) #define UNITY_TEST_ASSERT_EACH_EQUAL_FLOAT(expected, actual, num_elements, line, message) UnityAssertEqualFloatArray(UnityFloatToPtr(expected), (UNITY_FLOAT*)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_ARRAY_TO_VAL) #define UNITY_TEST_ASSERT_GREATER_THAN_FLOAT(threshold, actual, line, message) UnityAssertGreaterOrLessFloat((UNITY_FLOAT)(threshold), (UNITY_FLOAT)(actual), UNITY_GREATER_THAN, (message), (UNITY_LINE_TYPE)(line)) +#define UNITY_TEST_ASSERT_GREATER_OR_EQUAL_FLOAT(threshold, actual, line, message) UnityAssertGreaterOrLessFloat((UNITY_FLOAT)(threshold), (UNITY_FLOAT)(actual), UNITY_GREATER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line)) #define UNITY_TEST_ASSERT_LESS_THAN_FLOAT(threshold, actual, line, message) UnityAssertGreaterOrLessFloat((UNITY_FLOAT)(threshold), (UNITY_FLOAT)(actual), UNITY_SMALLER_THAN, (message), (UNITY_LINE_TYPE)(line)) +#define UNITY_TEST_ASSERT_LESS_OR_EQUAL_FLOAT(threshold, actual, line, message) UnityAssertGreaterOrLessFloat((UNITY_FLOAT)(threshold), (UNITY_FLOAT)(actual), UNITY_SMALLER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line)) #define UNITY_TEST_ASSERT_FLOAT_IS_INF(actual, line, message) UnityAssertFloatSpecial((UNITY_FLOAT)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_FLOAT_IS_INF) #define UNITY_TEST_ASSERT_FLOAT_IS_NEG_INF(actual, line, message) UnityAssertFloatSpecial((UNITY_FLOAT)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_FLOAT_IS_NEG_INF) #define UNITY_TEST_ASSERT_FLOAT_IS_NAN(actual, line, message) UnityAssertFloatSpecial((UNITY_FLOAT)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_FLOAT_IS_NAN) @@ -1058,7 +1062,9 @@ int UnityTestMatches(void); #define UNITY_TEST_ASSERT_EQUAL_DOUBLE_ARRAY(expected, actual, num_elements, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErrDouble) #define UNITY_TEST_ASSERT_EACH_EQUAL_DOUBLE(expected, actual, num_elements, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErrDouble) #define UNITY_TEST_ASSERT_GREATER_THAN_DOUBLE(threshold, actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErrDouble) +#define UNITY_TEST_ASSERT_GREATER_OR_EQUAL_DOUBLE(threshold, actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErrDouble) #define UNITY_TEST_ASSERT_LESS_THAN_DOUBLE(threshold, actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErrDouble) +#define UNITY_TEST_ASSERT_LESS_OR_EQUAL_DOUBLE(threshold, actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErrDouble) #define UNITY_TEST_ASSERT_DOUBLE_IS_INF(actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErrDouble) #define UNITY_TEST_ASSERT_DOUBLE_IS_NEG_INF(actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErrDouble) #define UNITY_TEST_ASSERT_DOUBLE_IS_NAN(actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErrDouble) @@ -1075,7 +1081,9 @@ int UnityTestMatches(void); #define UNITY_TEST_ASSERT_EQUAL_DOUBLE_ARRAY(expected, actual, num_elements, line, message) UnityAssertEqualDoubleArray((UNITY_DOUBLE*)(expected), (UNITY_DOUBLE*)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_ARRAY_TO_ARRAY) #define UNITY_TEST_ASSERT_EACH_EQUAL_DOUBLE(expected, actual, num_elements, line, message) UnityAssertEqualDoubleArray(UnityDoubleToPtr(expected), (UNITY_DOUBLE*)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_ARRAY_TO_VAL) #define UNITY_TEST_ASSERT_GREATER_THAN_DOUBLE(threshold, actual, line, message) UnityAssertGreaterOrLessDouble((UNITY_DOUBLE)(threshold), (UNITY_DOUBLE)(actual), UNITY_GREATER_THAN, (message), (UNITY_LINE_TYPE)(line)) +#define UNITY_TEST_ASSERT_GREATER_OR_EQUAL_DOUBLE(threshold, actual, line, message) UnityAssertGreaterOrLessDouble((UNITY_DOUBLE)(threshold), (UNITY_DOUBLE)(actual), UNITY_GREATER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line)) #define UNITY_TEST_ASSERT_LESS_THAN_DOUBLE(threshold, actual, line, message) UnityAssertGreaterOrLessDouble((UNITY_DOUBLE)(threshold), (UNITY_DOUBLE)(actual), UNITY_SMALLER_THAN, (message), (UNITY_LINE_TYPE)(line)) +#define UNITY_TEST_ASSERT_LESS_OR_EQUAL_DOUBLE(threshold, actual, line, message) UnityAssertGreaterOrLessDouble((UNITY_DOUBLE)(threshold), (UNITY_DOUBLE)(actual), UNITY_SMALLER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line)) #define UNITY_TEST_ASSERT_DOUBLE_IS_INF(actual, line, message) UnityAssertDoubleSpecial((UNITY_DOUBLE)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_FLOAT_IS_INF) #define UNITY_TEST_ASSERT_DOUBLE_IS_NEG_INF(actual, line, message) UnityAssertDoubleSpecial((UNITY_DOUBLE)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_FLOAT_IS_NEG_INF) #define UNITY_TEST_ASSERT_DOUBLE_IS_NAN(actual, line, message) UnityAssertDoubleSpecial((UNITY_DOUBLE)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_FLOAT_IS_NAN) diff --git a/test/tests/test_unity_doubles.c b/test/tests/test_unity_doubles.c index b188bac7..1a54c0dd 100644 --- a/test/tests/test_unity_doubles.c +++ b/test/tests/test_unity_doubles.c @@ -345,6 +345,112 @@ void testDoublesNotGreaterThanBothNegInf(void) #endif } +void testDoublesGreaterOrEqual(void) +{ +#ifdef UNITY_EXCLUDE_DOUBLE + TEST_IGNORE(); +#else + TEST_ASSERT_GREATER_OR_EQUAL_DOUBLE(1.0, 2.0); + TEST_ASSERT_GREATER_OR_EQUAL_DOUBLE(2.0, 2.0); + TEST_ASSERT_GREATER_OR_EQUAL_DOUBLE(-1.0, 1.0); + TEST_ASSERT_GREATER_OR_EQUAL_DOUBLE(-2.0, -1.0); + TEST_ASSERT_GREATER_OR_EQUAL_DOUBLE(-2.0, -2.0); +#endif +} + +void testDoublesGreaterOrEqualInf(void) +{ +#ifdef UNITY_EXCLUDE_DOUBLE + TEST_IGNORE(); +#else + TEST_ASSERT_GREATER_OR_EQUAL_DOUBLE(1.0, 1.0 / d_zero); + TEST_ASSERT_GREATER_OR_EQUAL_DOUBLE(-1.0 / d_zero, 1.0 / d_zero); + TEST_ASSERT_GREATER_OR_EQUAL_DOUBLE(-1.0 / d_zero, 1.0); +#endif +} + +void testDoublesNotGreaterOrEqual(void) +{ +#ifdef UNITY_EXCLUDE_DOUBLE + TEST_IGNORE(); +#else + EXPECT_ABORT_BEGIN + TEST_ASSERT_GREATER_OR_EQUAL_DOUBLE(2.0, 1.0); + VERIFY_FAILS_END +#endif +} + +void testDoublesNotGreaterOrEqualNanActual(void) +{ +#ifdef UNITY_EXCLUDE_DOUBLE + TEST_IGNORE(); +#else + EXPECT_ABORT_BEGIN + TEST_ASSERT_GREATER_OR_EQUAL_DOUBLE(1.0, 0.0 / d_zero); + VERIFY_FAILS_END +#endif +} + +void testDoublesNotGreaterOrEqualNanThreshold(void) +{ +#ifdef UNITY_EXCLUDE_DOUBLE + TEST_IGNORE(); +#else + EXPECT_ABORT_BEGIN + TEST_ASSERT_GREATER_OR_EQUAL_DOUBLE(0.0 / d_zero, 1.0); + VERIFY_FAILS_END +#endif +} + +void testDoublesGreaterOrEqualNanBoth(void) +{ +#ifdef UNITY_EXCLUDE_DOUBLE + TEST_IGNORE(); +#else + TEST_ASSERT_GREATER_OR_EQUAL_DOUBLE(0.0 / d_zero, 0.0 / d_zero); +#endif +} + +void testDoublesNotGreaterOrEqualInfActual(void) +{ +#ifdef UNITY_EXCLUDE_DOUBLE + TEST_IGNORE(); +#else + EXPECT_ABORT_BEGIN + TEST_ASSERT_GREATER_OR_EQUAL_DOUBLE(1.0 / d_zero, 1.0); + VERIFY_FAILS_END +#endif +} + +void testDoublesNotGreaterOrEqualNegInf(void) +{ +#ifdef UNITY_EXCLUDE_DOUBLE + TEST_IGNORE(); +#else + EXPECT_ABORT_BEGIN + TEST_ASSERT_GREATER_OR_EQUAL_DOUBLE(1.0, -1.0 / d_zero); + VERIFY_FAILS_END +#endif +} + +void testDoublesGreaterOrEqualBothInf(void) +{ +#ifdef UNITY_EXCLUDE_DOUBLE + TEST_IGNORE(); +#else + TEST_ASSERT_GREATER_OR_EQUAL_DOUBLE(1.0 / d_zero, 1.0 / d_zero); +#endif +} + +void testDoublesGreaterOrEqualBothNegInf(void) +{ +#ifdef UNITY_EXCLUDE_DOUBLE + TEST_IGNORE(); +#else + TEST_ASSERT_GREATER_OR_EQUAL_DOUBLE(-1.0 / d_zero, -1.0 / d_zero); +#endif +} + void testDoublesLessThan(void) { #ifdef UNITY_EXCLUDE_DOUBLE @@ -455,6 +561,112 @@ void testDoublesNotLessThanBothNegInf(void) #endif } +void testDoublesLessOrEqual(void) +{ +#ifdef UNITY_EXCLUDE_DOUBLE + TEST_IGNORE(); +#else + TEST_ASSERT_LESS_OR_EQUAL_DOUBLE(2.0, 1.0); + TEST_ASSERT_LESS_OR_EQUAL_DOUBLE(2.0, 2.0); + TEST_ASSERT_LESS_OR_EQUAL_DOUBLE(1.0, -1.0); + TEST_ASSERT_LESS_OR_EQUAL_DOUBLE(-1.0, -2.0); + TEST_ASSERT_LESS_OR_EQUAL_DOUBLE(-2.0, -2.0); +#endif +} + +void testDoublesLessOrEqualInf(void) +{ +#ifdef UNITY_EXCLUDE_DOUBLE + TEST_IGNORE(); +#else + TEST_ASSERT_LESS_OR_EQUAL_DOUBLE(1.0 / d_zero, 1.0); + TEST_ASSERT_LESS_OR_EQUAL_DOUBLE(1.0 / d_zero, -1.0 / d_zero); + TEST_ASSERT_LESS_OR_EQUAL_DOUBLE(1.0, -1.0 / d_zero); +#endif +} + +void testDoublesNotLessOrEqual(void) +{ +#ifdef UNITY_EXCLUDE_DOUBLE + TEST_IGNORE(); +#else + EXPECT_ABORT_BEGIN + TEST_ASSERT_LESS_OR_EQUAL_DOUBLE(1.0, 2.0); + VERIFY_FAILS_END +#endif +} + +void testDoublesNotLessOrEqualNanActual(void) +{ +#ifdef UNITY_EXCLUDE_DOUBLE + TEST_IGNORE(); +#else + EXPECT_ABORT_BEGIN + TEST_ASSERT_LESS_OR_EQUAL_DOUBLE(1.0, 0.0 / d_zero); + VERIFY_FAILS_END +#endif +} + +void testDoublesNotLessOrEqualNanThreshold(void) +{ +#ifdef UNITY_EXCLUDE_DOUBLE + TEST_IGNORE(); +#else + EXPECT_ABORT_BEGIN + TEST_ASSERT_LESS_OR_EQUAL_DOUBLE(0.0 / d_zero, 1.0); + VERIFY_FAILS_END +#endif +} + +void testDoublesLessOrEqualNanBoth(void) +{ +#ifdef UNITY_EXCLUDE_DOUBLE + TEST_IGNORE(); +#else + TEST_ASSERT_LESS_OR_EQUAL_DOUBLE(0.0 / d_zero, 0.0 / d_zero); +#endif +} + +void testDoublesNotLessOrEqualInf(void) +{ +#ifdef UNITY_EXCLUDE_DOUBLE + TEST_IGNORE(); +#else + EXPECT_ABORT_BEGIN + TEST_ASSERT_LESS_OR_EQUAL_DOUBLE(1.0, 1.0 / d_zero); + VERIFY_FAILS_END +#endif +} + +void testDoublesNotLessOrEqualNegInf(void) +{ +#ifdef UNITY_EXCLUDE_DOUBLE + TEST_IGNORE(); +#else + EXPECT_ABORT_BEGIN + TEST_ASSERT_LESS_OR_EQUAL_DOUBLE(-1.0 / d_zero, 1.0); + VERIFY_FAILS_END +#endif +} + +void testDoublesLessOrEqualBothInf(void) +{ +#ifdef UNITY_EXCLUDE_DOUBLE + TEST_IGNORE(); +#else + TEST_ASSERT_LESS_OR_EQUAL_DOUBLE(1.0 / d_zero, 1.0 / d_zero); +#endif +} + +void testDoublesLessOrEqualBothNegInf(void) +{ +#ifdef UNITY_EXCLUDE_DOUBLE + TEST_IGNORE(); +#else + TEST_ASSERT_LESS_OR_EQUAL_DOUBLE(-1.0 / d_zero, -1.0 / d_zero); +#endif +} + void testDoubleIsPosInf1(void) { #ifdef UNITY_EXCLUDE_DOUBLE diff --git a/test/tests/test_unity_floats.c b/test/tests/test_unity_floats.c index 4e0ac65c..5a746bb9 100644 --- a/test/tests/test_unity_floats.c +++ b/test/tests/test_unity_floats.c @@ -344,6 +344,112 @@ void testFloatsNotGreaterThanBothNegInf(void) #endif } +void testFloatsGreaterOrEqual(void) +{ +#ifdef UNITY_EXCLUDE_FLOAT + TEST_IGNORE(); +#else + TEST_ASSERT_GREATER_OR_EQUAL_FLOAT(1.0f, 2.0f); + TEST_ASSERT_GREATER_OR_EQUAL_FLOAT(2.0f, 2.0f); + TEST_ASSERT_GREATER_OR_EQUAL_FLOAT(-1.0f, 1.0f); + TEST_ASSERT_GREATER_OR_EQUAL_FLOAT(-2.0f, -1.0f); + TEST_ASSERT_GREATER_OR_EQUAL_FLOAT(-2.0f, -2.0f); +#endif +} + +void testFloatsGreaterOrEqualInf(void) +{ +#ifdef UNITY_EXCLUDE_FLOAT + TEST_IGNORE(); +#else + TEST_ASSERT_GREATER_OR_EQUAL_FLOAT(1.0f, 1.0f / f_zero); + TEST_ASSERT_GREATER_OR_EQUAL_FLOAT(-1.0f / f_zero, 1.0f / f_zero); + TEST_ASSERT_GREATER_OR_EQUAL_FLOAT(-1.0f / f_zero, 1.0f); +#endif +} + +void testFloatsNotGreaterOrEqual(void) +{ +#ifdef UNITY_EXCLUDE_FLOAT + TEST_IGNORE(); +#else + EXPECT_ABORT_BEGIN + TEST_ASSERT_GREATER_OR_EQUAL_FLOAT(2.0f, 1.0f); + VERIFY_FAILS_END +#endif +} + +void testFloatsNotGreaterOrEqualNanActual(void) +{ +#ifdef UNITY_EXCLUDE_FLOAT + TEST_IGNORE(); +#else + EXPECT_ABORT_BEGIN + TEST_ASSERT_GREATER_OR_EQUAL_FLOAT(1.0f, 0.0f / f_zero); + VERIFY_FAILS_END +#endif +} + +void testFloatsNotGreaterOrEqualNanThreshold(void) +{ +#ifdef UNITY_EXCLUDE_FLOAT + TEST_IGNORE(); +#else + EXPECT_ABORT_BEGIN + TEST_ASSERT_GREATER_OR_EQUAL_FLOAT(0.0f / f_zero, 1.0f); + VERIFY_FAILS_END +#endif +} + +void testFloatsGreaterOrEqualNanBoth(void) +{ +#ifdef UNITY_EXCLUDE_FLOAT + TEST_IGNORE(); +#else + TEST_ASSERT_GREATER_OR_EQUAL_FLOAT(0.0f / f_zero, 0.0f / f_zero); +#endif +} + +void testFloatsNotGreaterOrEqualInfActual(void) +{ +#ifdef UNITY_EXCLUDE_FLOAT + TEST_IGNORE(); +#else + EXPECT_ABORT_BEGIN + TEST_ASSERT_GREATER_OR_EQUAL_FLOAT(1.0f / f_zero, 1.0f); + VERIFY_FAILS_END +#endif +} + +void testFloatsNotGreaterOrEqualNegInf(void) +{ +#ifdef UNITY_EXCLUDE_FLOAT + TEST_IGNORE(); +#else + EXPECT_ABORT_BEGIN + TEST_ASSERT_GREATER_OR_EQUAL_FLOAT(1.0f, -1.0f / f_zero); + VERIFY_FAILS_END +#endif +} + +void testFloatsGreaterOrEqualBothInf(void) +{ +#ifdef UNITY_EXCLUDE_FLOAT + TEST_IGNORE(); +#else + TEST_ASSERT_GREATER_OR_EQUAL_FLOAT(1.0f / f_zero, 1.0f / f_zero); +#endif +} + +void testFloatsGreaterOrEqualBothNegInf(void) +{ +#ifdef UNITY_EXCLUDE_FLOAT + TEST_IGNORE(); +#else + TEST_ASSERT_GREATER_OR_EQUAL_FLOAT(-1.0f / f_zero, -1.0f / f_zero); +#endif +} + void testFloatsLessThan(void) { #ifdef UNITY_EXCLUDE_FLOAT @@ -453,6 +559,111 @@ void testFloatsNotLessThanBothNegInf(void) VERIFY_FAILS_END #endif } +void testFloatsLessOrEqual(void) +{ +#ifdef UNITY_EXCLUDE_FLOAT + TEST_IGNORE(); +#else + TEST_ASSERT_LESS_OR_EQUAL_FLOAT(2.0f, 1.0f); + TEST_ASSERT_LESS_OR_EQUAL_FLOAT(2.0f, 2.0f); + TEST_ASSERT_LESS_OR_EQUAL_FLOAT(1.0f, -1.0f); + TEST_ASSERT_LESS_OR_EQUAL_FLOAT(-1.0f, -2.0f); + TEST_ASSERT_LESS_OR_EQUAL_FLOAT(-2.0f, -2.0f); +#endif +} + +void testFloatsLessOrEqualInf(void) +{ +#ifdef UNITY_EXCLUDE_FLOAT + TEST_IGNORE(); +#else + TEST_ASSERT_LESS_OR_EQUAL_FLOAT(1.0f / f_zero, 1.0f); + TEST_ASSERT_LESS_OR_EQUAL_FLOAT(1.0f / f_zero, -1.0f / f_zero); + TEST_ASSERT_LESS_OR_EQUAL_FLOAT(1.0f, -1.0f / f_zero); +#endif +} + +void testFloatsNotLessOrEqual(void) +{ +#ifdef UNITY_EXCLUDE_FLOAT + TEST_IGNORE(); +#else + EXPECT_ABORT_BEGIN + TEST_ASSERT_LESS_OR_EQUAL_FLOAT(1.0f, 2.0f); + VERIFY_FAILS_END +#endif +} + +void testFloatsNotLessOrEqualNanActual(void) +{ +#ifdef UNITY_EXCLUDE_FLOAT + TEST_IGNORE(); +#else + EXPECT_ABORT_BEGIN + TEST_ASSERT_LESS_OR_EQUAL_FLOAT(1.0f, 0.0f / f_zero); + VERIFY_FAILS_END +#endif +} + +void testFloatsNotLessOrEqualNanThreshold(void) +{ +#ifdef UNITY_EXCLUDE_FLOAT + TEST_IGNORE(); +#else + EXPECT_ABORT_BEGIN + TEST_ASSERT_LESS_OR_EQUAL_FLOAT(0.0f / f_zero, 1.0f); + VERIFY_FAILS_END +#endif +} + +void testFloatsLessOrEqualNanBoth(void) +{ +#ifdef UNITY_EXCLUDE_FLOAT + TEST_IGNORE(); +#else + TEST_ASSERT_LESS_OR_EQUAL_FLOAT(0.0f / f_zero, 0.0f / f_zero); +#endif +} + +void testFloatsNotLessOrEqualInf(void) +{ +#ifdef UNITY_EXCLUDE_FLOAT + TEST_IGNORE(); +#else + EXPECT_ABORT_BEGIN + TEST_ASSERT_LESS_OR_EQUAL_FLOAT(1.0f, 1.0f / f_zero); + VERIFY_FAILS_END +#endif +} + +void testFloatsNotLessOrEqualNegInf(void) +{ +#ifdef UNITY_EXCLUDE_FLOAT + TEST_IGNORE(); +#else + EXPECT_ABORT_BEGIN + TEST_ASSERT_LESS_OR_EQUAL_FLOAT(-1.0f / f_zero, 1.0f); + VERIFY_FAILS_END +#endif +} + +void testFloatsLessOrEqualBothInf(void) +{ +#ifdef UNITY_EXCLUDE_FLOAT + TEST_IGNORE(); +#else + TEST_ASSERT_LESS_OR_EQUAL_FLOAT(1.0f / f_zero, 1.0f / f_zero); +#endif +} + +void testFloatsLessOrEqualBothNegInf(void) +{ +#ifdef UNITY_EXCLUDE_FLOAT + TEST_IGNORE(); +#else + TEST_ASSERT_LESS_OR_EQUAL_FLOAT(-1.0f / f_zero, -1.0f / f_zero); +#endif +} void testFloatIsPosInf1(void) { From c0e9a4c18537cdc4de3e16f3fe28447303afd3a6 Mon Sep 17 00:00:00 2001 From: Maurizio Bonesi <51166992+mbonesi@users.noreply.github.com> Date: Fri, 10 Dec 2021 10:16:45 +0100 Subject: [PATCH 298/454] fixed hyperlink text to obtain Ruby the text was correct but the hyperlink had a problem. --- docs/UnityHelperScriptsGuide.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/UnityHelperScriptsGuide.md b/docs/UnityHelperScriptsGuide.md index ecbf55e1..b430c415 100644 --- a/docs/UnityHelperScriptsGuide.md +++ b/docs/UnityHelperScriptsGuide.md @@ -239,7 +239,7 @@ How convenient is that? *Find The Latest of This And More at [ThrowTheSwitch.org][]* -[ruby-lang.org]: https://ruby-labg.org/ +[ruby-lang.org]: https://ruby-lang.org/ [YAML]: http://www.yaml.org/ [Ceedling]: http://www.throwtheswitch.org/ceedling [ThrowTheSwitch.org]: https://throwtheswitch.org From 2ad5d74dc76d51488138835d879f9944d294e766 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9o=20SEBAL?= Date: Wed, 19 Jan 2022 18:50:54 +0100 Subject: [PATCH 299/454] Fixes and features on the JUnit Python conversion script * Added python3 shebang * Renamed the script `unity_to_junit.py` as `stylize_as_junit.py` to match the Ruby file * Fixed a bug on where the script failed if the first entry slot of each result line is empty. Now falls back to the result file name * Rewrote the argument parsing to use argparse * Added a `--output` / `-o` option, to match the Ruby file --- ...{unity_to_junit.py => stylize_as_junit.py} | 93 +++++++++++-------- 1 file changed, 54 insertions(+), 39 deletions(-) rename auto/{unity_to_junit.py => stylize_as_junit.py} (60%) diff --git a/auto/unity_to_junit.py b/auto/stylize_as_junit.py similarity index 60% rename from auto/unity_to_junit.py rename to auto/stylize_as_junit.py index 71dd5688..06c86596 100644 --- a/auto/unity_to_junit.py +++ b/auto/stylize_as_junit.py @@ -1,6 +1,15 @@ +#! python3 +# ========================================== +# Fork from Unity Project - A Test Framework for C +# Pull request on Gerrit in progress, the objective of this file is to be deleted when official Unity deliveries +# include that modification +# Copyright (c) 2015 Alexander Mueller / XelaRellum@web.de +# [Released under MIT License. Please refer to license.txt for details] +# ========================================== import sys import os from glob import glob +import argparse from pyparsing import * from junit_xml import TestSuite, TestCase @@ -14,6 +23,7 @@ def __init__(self): self.ignored = 0 self.targets = 0 self.root = None + self.output = None self.test_suites = dict() def run(self): @@ -37,15 +47,18 @@ def run(self): entry = entry_one | entry_two delimiter = Literal(':').suppress() - tc_result_line = Group(entry.setResultsName('tc_file_name') + delimiter + entry.setResultsName( - 'tc_line_nr') + delimiter + entry.setResultsName('tc_name') + delimiter + entry.setResultsName( - 'tc_status') + Optional( - delimiter + entry.setResultsName('tc_msg'))).setResultsName("tc_line") + # Format of a result line is `[file_name]:line:test_name:RESULT[:msg]` + tc_result_line = Group(ZeroOrMore(entry.setResultsName('tc_file_name')) + + delimiter + entry.setResultsName('tc_line_nr') + + delimiter + entry.setResultsName('tc_name') + + delimiter + entry.setResultsName('tc_status') + + Optional(delimiter + entry.setResultsName('tc_msg'))).setResultsName("tc_line") eol = LineEnd().suppress() sol = LineStart().suppress() blank_line = sol + eol + # Format of the summary line is `# Tests # Failures # Ignored` tc_summary_line = Group(Word(nums).setResultsName("num_of_tests") + "Tests" + Word(nums).setResultsName( "num_of_fail") + "Failures" + Word(nums).setResultsName("num_of_ignore") + "Ignored").setResultsName( "tc_summary") @@ -67,7 +80,10 @@ def run(self): tmp_tc_line = r['tc_line'] # get only the file name which will be used as the classname - file_name = tmp_tc_line['tc_file_name'].split('\\').pop().split('/').pop().rsplit('.', 1)[0] + if 'tc_file_name' in tmp_tc_line: + file_name = tmp_tc_line['tc_file_name'].split('\\').pop().split('/').pop().rsplit('.', 1)[0] + else: + file_name = result_file.strip("./") tmp_tc = TestCase(name=tmp_tc_line['tc_name'], classname=file_name) if 'tc_status' in tmp_tc_line: if str(tmp_tc_line['tc_status']) == 'IGNORE': @@ -96,7 +112,7 @@ def run(self): for suite_name in self.test_suites: ts.append(TestSuite(suite_name, self.test_suites[suite_name])) - with open('result.xml', 'w') as f: + with open(self.output, 'w') as f: TestSuite.to_file(f, ts, prettyprint='True', encoding='utf-8') return self.report @@ -107,40 +123,39 @@ def set_targets(self, target_array): def set_root_path(self, path): self.root = path - @staticmethod - def usage(err_msg=None): - print("\nERROR: ") - if err_msg: - print(err_msg) - print("\nUsage: unity_test_summary.py result_file_directory/ root_path/") - print(" result_file_directory - The location of your results files.") - print(" Defaults to current directory if not specified.") - print(" Should end in / if specified.") - print(" root_path - Helpful for producing more verbose output if using relative paths.") - sys.exit(1) + def set_output(self, output): + self.output = output if __name__ == '__main__': uts = UnityTestSummary() - try: - # look in the specified or current directory for result files - if len(sys.argv) > 1: - targets_dir = sys.argv[1] - else: - targets_dir = './' - targets = list(map(lambda x: x.replace('\\', '/'), glob(targets_dir + '*.test*'))) - if len(targets) == 0: - raise Exception("No *.testpass or *.testfail files found in '%s'" % targets_dir) - uts.set_targets(targets) - - # set the root path - if len(sys.argv) > 2: - root_path = sys.argv[2] - else: - root_path = os.path.split(__file__)[0] - uts.set_root_path(root_path) - - # run the summarizer - print(uts.run()) - except Exception as e: - UnityTestSummary.usage(e) + parser = argparse.ArgumentParser(description= + """Takes as input the collection of *.testpass and *.testfail result + files, and converts them to a JUnit formatted XML.""") + parser.add_argument('targets_dir', metavar='result_file_directory', + type=str, nargs='?', default='./', + help="""The location of your results files. + Defaults to current directory if not specified.""") + parser.add_argument('root_path', nargs='?', + default='os.path.split(__file__)[0]', + help="""Helpful for producing more verbose output if + using relative paths.""") + parser.add_argument('--output', '-o', type=str, default="result.xml", + help="""The name of the JUnit-formatted file (XML).""") + args = parser.parse_args() + + if args.targets_dir[-1] != '/': + args.targets_dir+='/' + targets = list(map(lambda x: x.replace('\\', '/'), glob(args.targets_dir + '*.test*'))) + if len(targets) == 0: + raise Exception("No *.testpass or *.testfail files found in '%s'" % args.targets_dir) + uts.set_targets(targets) + + # set the root path + uts.set_root_path(args.root_path) + + # set output + uts.set_output(args.output) + + # run the summarizer + print(uts.run()) From db3398a5dd26e295949c1858230b23f4a93a6aa8 Mon Sep 17 00:00:00 2001 From: Alex Overchenko Date: Wed, 16 Feb 2022 14:56:00 +0300 Subject: [PATCH 300/454] Unity color resetting was fixed for Gitlab CI. Based on escape codes: https://en.wikipedia.org/wiki/ANSI_escape_code#3-bit_and_4-bit --- docs/UnityConfigurationGuide.md | 2 +- src/unity.c | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/docs/UnityConfigurationGuide.md b/docs/UnityConfigurationGuide.md index 493b1421..71305c3c 100644 --- a/docs/UnityConfigurationGuide.md +++ b/docs/UnityConfigurationGuide.md @@ -261,7 +261,7 @@ TEST_PRINTF("Pointer %p\n", &a); TEST_PRINTF("Character %c\n", 'F'); TEST_PRINTF("String %s\n", "My string"); TEST_PRINTF("Percent %%\n"); -TEST_PRINTF("Color Red \033[41mFAIL\033[00m\n"); +TEST_PRINTF("Color Red \033[41mFAIL\033[0m\n"); TEST_PRINTF("\n"); TEST_PRINTF("Multiple (%d) (%i) (%u) (%x)\n", -100, 0, 200, 0x12345); ``` diff --git a/src/unity.c b/src/unity.c index b8802487..9add9674 100644 --- a/src/unity.c +++ b/src/unity.c @@ -26,10 +26,10 @@ void UNITY_OUTPUT_CHAR(int); struct UNITY_STORAGE_T Unity; #ifdef UNITY_OUTPUT_COLOR -const char PROGMEM UnityStrOk[] = "\033[42mOK\033[00m"; -const char PROGMEM UnityStrPass[] = "\033[42mPASS\033[00m"; -const char PROGMEM UnityStrFail[] = "\033[41mFAIL\033[00m"; -const char PROGMEM UnityStrIgnore[] = "\033[43mIGNORE\033[00m"; +const char PROGMEM UnityStrOk[] = "\033[42mOK\033[0m"; +const char PROGMEM UnityStrPass[] = "\033[42mPASS\033[0m"; +const char PROGMEM UnityStrFail[] = "\033[41mFAIL\033[0m"; +const char PROGMEM UnityStrIgnore[] = "\033[43mIGNORE\033[0m"; #else const char PROGMEM UnityStrOk[] = "OK"; const char PROGMEM UnityStrPass[] = "PASS"; From 2b725883f7b43660f0f5b36046ed628cf61b9999 Mon Sep 17 00:00:00 2001 From: Alex Overchenko Date: Fri, 27 Nov 2020 10:10:01 +0300 Subject: [PATCH 301/454] parse_output should parse color output now --- auto/parse_output.rb | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/auto/parse_output.rb b/auto/parse_output.rb index d72c6e8b..d5515d54 100644 --- a/auto/parse_output.rb +++ b/auto/parse_output.rb @@ -288,6 +288,17 @@ def process(file_name) line_array.push('No reason given') test_ignored(line_array) @test_ignored += 1 + elsif line_array.size >= 4 + if line_array[3].include? 'PASS' + test_passed(line_array) + @test_passed += 1 + elsif line_array[3].include? 'FAIL' + test_failed(line_array) + @test_failed += 1 + elsif line_array[3].include? 'IGNORE:' + test_ignored(line_array) + @test_ignored += 1 + end end @total_tests = @test_passed + @test_failed + @test_ignored end From 10d593d4138af9b841e715b3535bf31550411b51 Mon Sep 17 00:00:00 2001 From: Alex Overchenko Date: Fri, 27 Nov 2020 10:23:54 +0300 Subject: [PATCH 302/454] parse_output test_suite tag can be passed as arg now --- auto/parse_output.rb | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/auto/parse_output.rb b/auto/parse_output.rb index d5515d54..f0c062b9 100644 --- a/auto/parse_output.rb +++ b/auto/parse_output.rb @@ -18,6 +18,9 @@ # To use this parser use the following command # ruby parseOutput.rb [options] [file] # options: -xml : produce a JUnit compatible XML file +# -suiteRequiredSuiteName +# : replace default test suite name to +# "RequiredSuiteName" (can be any name) # file: file to scan for results #============================================================ @@ -33,6 +36,9 @@ def initialize @array_list = false # current suite name and statistics + ## testsuite name + @real_test_suite_name = 'Unity' + ## classname for testcase @test_suite = nil @total_tests = 0 @test_passed = 0 @@ -45,6 +51,12 @@ def set_xml_output @xml_out = true end + # Set the flag to indicate if there will be an XML output file or not + def set_test_suite_name(cli_arg) + @real_test_suite_name = cli_arg['-suite'.length..-1] + puts 'Real test suite name will be \'' + @real_test_suite_name + '\'' + end + # If write our output to XML def write_xml_output output = File.open('report.xml', 'w') @@ -57,7 +69,7 @@ def write_xml_output # Pushes the suite info as xml to the array list, which will be written later def push_xml_output_suite_info # Insert opening tag at front - heading = '' + heading = '' @array_list.insert(0, heading) # Push back the closing tag @array_list.push '' @@ -325,6 +337,8 @@ def process(file_name) ARGV.each do |arg| if arg == '-xml' parse_my_file.set_xml_output + elsif arg.start_with?('-suite') + parse_my_file.set_test_suite_name(arg) else parse_my_file.process(arg) break From 474d2018007b28abc41900f3606592c308b5443a Mon Sep 17 00:00:00 2001 From: Alex Overchenko Date: Fri, 27 Nov 2020 11:40:47 +0300 Subject: [PATCH 303/454] parse_output: test names can contain double-quoted string now --- auto/parse_output.rb | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/auto/parse_output.rb b/auto/parse_output.rb index f0c062b9..6d9b17ca 100644 --- a/auto/parse_output.rb +++ b/auto/parse_output.rb @@ -57,6 +57,10 @@ def set_test_suite_name(cli_arg) puts 'Real test suite name will be \'' + @real_test_suite_name + '\'' end + def xml_encode_s(s) + return s.encode(:xml => :attr) + end + # If write our output to XML def write_xml_output output = File.open('report.xml', 'w') @@ -69,7 +73,7 @@ def write_xml_output # Pushes the suite info as xml to the array list, which will be written later def push_xml_output_suite_info # Insert opening tag at front - heading = '' + heading = '' @array_list.insert(0, heading) # Push back the closing tag @array_list.push '' @@ -77,19 +81,19 @@ def push_xml_output_suite_info # Pushes xml output data to the array list, which will be written later def push_xml_output_passed(test_name) - @array_list.push ' ' + @array_list.push ' ' end # Pushes xml output data to the array list, which will be written later def push_xml_output_failed(test_name, reason) - @array_list.push ' ' + @array_list.push ' ' @array_list.push ' ' + reason + '' @array_list.push ' ' end # Pushes xml output data to the array list, which will be written later def push_xml_output_ignored(test_name, reason) - @array_list.push ' ' + @array_list.push ' ' @array_list.push ' ' + reason + '' @array_list.push ' ' end From e32809c529b8dc81f5b41bf6165dc3325df8ff30 Mon Sep 17 00:00:00 2001 From: Alex Overchenko Date: Fri, 27 Nov 2020 16:10:26 +0300 Subject: [PATCH 304/454] Trying to fix errors of non-ASCII characters while parsing --- auto/parse_output.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/auto/parse_output.rb b/auto/parse_output.rb index 6d9b17ca..afdd9933 100644 --- a/auto/parse_output.rb +++ b/auto/parse_output.rb @@ -250,7 +250,7 @@ def process(file_name) puts '' puts '=================== RESULTS =====================' puts '' - File.open(file_name).each do |line| + File.open(file_name, :encoding => "UTF-8").each do |line| # Typical test lines look like these: # ---------------------------------------------------- # 1. normal output: From 5089be60e0030fd08948ce145db439973e62e3df Mon Sep 17 00:00:00 2001 From: Alex Overchenko Date: Fri, 27 Nov 2020 23:02:55 +0300 Subject: [PATCH 305/454] parse_output accepting all symbols now Methods with their args can contain colons (':') now --- auto/parse_output.rb | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/auto/parse_output.rb b/auto/parse_output.rb index afdd9933..314a33ff 100644 --- a/auto/parse_output.rb +++ b/auto/parse_output.rb @@ -29,6 +29,7 @@ class ParseOutput def initialize # internal data @class_name_idx = 0 + @result_usual_idx = 3 @path_delim = nil # xml output related @@ -250,7 +251,8 @@ def process(file_name) puts '' puts '=================== RESULTS =====================' puts '' - File.open(file_name, :encoding => "UTF-8").each do |line| + # Apply binary encoding. Bad symbols will be unchanged + File.open(file_name, "rb").each do |line| # Typical test lines look like these: # ---------------------------------------------------- # 1. normal output: @@ -305,13 +307,18 @@ def process(file_name) test_ignored(line_array) @test_ignored += 1 elsif line_array.size >= 4 - if line_array[3].include? 'PASS' + # ':' symbol will be valid in function args now + real_method_name = line_array[@result_usual_idx - 1..-2].join(':') + line_array = line_array[0..@result_usual_idx - 2] + [real_method_name] + [line_array[-1]] + + # We will check output from color compilation + if line_array[@result_usual_idx].include? 'PASS' test_passed(line_array) @test_passed += 1 - elsif line_array[3].include? 'FAIL' + elsif line_array[@result_usual_idx].include? 'FAIL' test_failed(line_array) @test_failed += 1 - elsif line_array[3].include? 'IGNORE:' + elsif line_array[@result_usual_idx].include? 'IGNORE' test_ignored(line_array) @test_ignored += 1 end From cc36e0d82b99d2a457a5599bebc68c1616dbf5a8 Mon Sep 17 00:00:00 2001 From: Alex Overchenko Date: Mon, 30 Nov 2020 12:14:52 +0300 Subject: [PATCH 306/454] Fix failed & ignored tests color parsing --- auto/parse_output.rb | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/auto/parse_output.rb b/auto/parse_output.rb index 314a33ff..7d8a4c22 100644 --- a/auto/parse_output.rb +++ b/auto/parse_output.rb @@ -169,6 +169,10 @@ def test_ignored_unity_fixture(array) # Test was flagged as having passed so format the output def test_passed(array) + # ':' symbol will be valid in function args now + real_method_name = array[@result_usual_idx - 1..-2].join(':') + array = array[0..@result_usual_idx - 2] + [real_method_name] + [array[-1]] + last_item = array.length - 1 test_name = array[last_item - 1] test_suite_verify(array[@class_name_idx]) @@ -181,6 +185,10 @@ def test_passed(array) # Test was flagged as having failed so format the line def test_failed(array) + # ':' symbol will be valid in function args now + real_method_name = array[@result_usual_idx - 1..-3].join(':') + array = array[0..@result_usual_idx - 3] + [real_method_name] + array[-2..-1] + last_item = array.length - 1 test_name = array[last_item - 2] reason = array[last_item].chomp.lstrip + ' at line: ' + array[last_item - 3] @@ -204,6 +212,10 @@ def test_failed(array) # Test was flagged as being ignored so format the output def test_ignored(array) + # ':' symbol will be valid in function args now + real_method_name = array[@result_usual_idx - 1..-3].join(':') + array = array[0..@result_usual_idx - 3] + [real_method_name] + array[-2..-1] + last_item = array.length - 1 test_name = array[last_item - 2] reason = array[last_item].chomp.lstrip @@ -307,18 +319,18 @@ def process(file_name) test_ignored(line_array) @test_ignored += 1 elsif line_array.size >= 4 - # ':' symbol will be valid in function args now - real_method_name = line_array[@result_usual_idx - 1..-2].join(':') - line_array = line_array[0..@result_usual_idx - 2] + [real_method_name] + [line_array[-1]] - # We will check output from color compilation - if line_array[@result_usual_idx].include? 'PASS' + if line_array[@result_usual_idx..-1].any? {|l| l.include? 'PASS'} test_passed(line_array) @test_passed += 1 - elsif line_array[@result_usual_idx].include? 'FAIL' + elsif line_array[@result_usual_idx..-1].any? {|l| l.include? 'FAIL'} test_failed(line_array) @test_failed += 1 - elsif line_array[@result_usual_idx].include? 'IGNORE' + elsif line_array[@result_usual_idx..-2].any? {|l| l.include? 'IGNORE'} + test_ignored(line_array) + @test_ignored += 1 + elsif line_array[@result_usual_idx..-1].any? {|l| l.include? 'IGNORE'} + line_array.push('No reason given') test_ignored(line_array) @test_ignored += 1 end From 72f30d82e44e98855c62aca4ad18326d97520075 Mon Sep 17 00:00:00 2001 From: 6arms1leg Date: Mon, 21 Feb 2022 14:10:10 +0100 Subject: [PATCH 307/454] Add missing `volatile` type qualifier ... to fix "clobbered variable" compiler warning (`-Wclobbered`). --- auto/run_test.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/auto/run_test.erb b/auto/run_test.erb index f91b5669..68b33730 100644 --- a/auto/run_test.erb +++ b/auto/run_test.erb @@ -14,7 +14,7 @@ static void run_test(UnityTestFunction func, const char* name, UNITY_LINE_TYPE l if (TEST_PROTECT()) { <% if @options[:plugins].include?(:cexception) %> - CEXCEPTION_T e; + volatile CEXCEPTION_T e; Try { <%= @options[:setup_name] %>(); func(); From edf6a52bfdb58267a345df124e0294af156e0c5d Mon Sep 17 00:00:00 2001 From: Alex Overchenko Date: Thu, 3 Dec 2020 16:26:20 +0300 Subject: [PATCH 308/454] Test time parsing was added (cherry picked from commit f2fe9fd4ad78c574af08afaa91d402b37464b131) --- auto/parse_output.rb | 37 ++++++++++++++++++++++++------------- 1 file changed, 24 insertions(+), 13 deletions(-) diff --git a/auto/parse_output.rb b/auto/parse_output.rb index 7d8a4c22..92d62d9a 100644 --- a/auto/parse_output.rb +++ b/auto/parse_output.rb @@ -81,20 +81,20 @@ def push_xml_output_suite_info end # Pushes xml output data to the array list, which will be written later - def push_xml_output_passed(test_name) - @array_list.push ' ' + def push_xml_output_passed(test_name, execution_time = 0) + @array_list.push ' ' end # Pushes xml output data to the array list, which will be written later - def push_xml_output_failed(test_name, reason) - @array_list.push ' ' + def push_xml_output_failed(test_name, reason, execution_time = 0) + @array_list.push ' ' @array_list.push ' ' + reason + '' @array_list.push ' ' end # Pushes xml output data to the array list, which will be written later - def push_xml_output_ignored(test_name, reason) - @array_list.push ' ' + def push_xml_output_ignored(test_name, reason, execution_time = 0) + @array_list.push ' ' @array_list.push ' ' + reason + '' @array_list.push ' ' end @@ -174,13 +174,14 @@ def test_passed(array) array = array[0..@result_usual_idx - 2] + [real_method_name] + [array[-1]] last_item = array.length - 1 + test_time = get_test_time(array[last_item]) test_name = array[last_item - 1] test_suite_verify(array[@class_name_idx]) - printf "%-40s PASS\n", test_name + printf "%-40s PASS %10d ms\n", test_name, test_time return unless @xml_out - push_xml_output_passed(test_name) if @xml_out + push_xml_output_passed(test_name, test_time) if @xml_out end # Test was flagged as having failed so format the line @@ -190,6 +191,7 @@ def test_failed(array) array = array[0..@result_usual_idx - 3] + [real_method_name] + array[-2..-1] last_item = array.length - 1 + test_time = get_test_time(array[last_item]) test_name = array[last_item - 2] reason = array[last_item].chomp.lstrip + ' at line: ' + array[last_item - 3] class_name = array[@class_name_idx] @@ -205,9 +207,9 @@ def test_failed(array) end test_suite_verify(class_name) - printf "%-40s FAILED\n", test_name + printf "%-40s FAILED %10d ms\n", test_name, test_time - push_xml_output_failed(test_name, reason) if @xml_out + push_xml_output_failed(test_name, reason, test_time) if @xml_out end # Test was flagged as being ignored so format the output @@ -217,6 +219,7 @@ def test_ignored(array) array = array[0..@result_usual_idx - 3] + [real_method_name] + array[-2..-1] last_item = array.length - 1 + test_time = get_test_time(array[last_item]) test_name = array[last_item - 2] reason = array[last_item].chomp.lstrip class_name = array[@class_name_idx] @@ -232,9 +235,17 @@ def test_ignored(array) end test_suite_verify(class_name) - printf "%-40s IGNORED\n", test_name + printf "%-40s IGNORED %10d ms\n", test_name, test_time - push_xml_output_ignored(test_name, reason) if @xml_out + push_xml_output_ignored(test_name, reason, test_time) if @xml_out + end + + def get_test_time(value_with_time) + test_time_array = value_with_time.scan(/\((-?\d+.?\d*) ms\)\s*$/).flatten.map do |arg_value_str| + arg_value_str.include?('.') ? arg_value_str.to_f : arg_value_str.to_i + end + + test_time_array.any? ? test_time_array[0] : 0 end # Adjusts the os specific members according to the current path style @@ -330,7 +341,7 @@ def process(file_name) test_ignored(line_array) @test_ignored += 1 elsif line_array[@result_usual_idx..-1].any? {|l| l.include? 'IGNORE'} - line_array.push('No reason given') + line_array.push('No reason given (' + get_test_time(line_array[@result_usual_idx..-1]).to_s + ' ms)') test_ignored(line_array) @test_ignored += 1 end From 32608af4f50eb36f52fa5bd5cf34b4c9dea40c0b Mon Sep 17 00:00:00 2001 From: Alex Overchenko Date: Thu, 3 Dec 2020 16:49:49 +0300 Subject: [PATCH 309/454] Test passing time will be in seconds now (for xml output) (cherry picked from commit 39d54e2913b0c3a18106a13705fed2fb8ab7f4b0) --- auto/parse_output.rb | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/auto/parse_output.rb b/auto/parse_output.rb index 92d62d9a..8d541f19 100644 --- a/auto/parse_output.rb +++ b/auto/parse_output.rb @@ -82,19 +82,19 @@ def push_xml_output_suite_info # Pushes xml output data to the array list, which will be written later def push_xml_output_passed(test_name, execution_time = 0) - @array_list.push ' ' + @array_list.push ' ' end # Pushes xml output data to the array list, which will be written later def push_xml_output_failed(test_name, reason, execution_time = 0) - @array_list.push ' ' + @array_list.push ' ' @array_list.push ' ' + reason + '' @array_list.push ' ' end # Pushes xml output data to the array list, which will be written later def push_xml_output_ignored(test_name, reason, execution_time = 0) - @array_list.push ' ' + @array_list.push ' ' @array_list.push ' ' + reason + '' @array_list.push ' ' end @@ -240,6 +240,7 @@ def test_ignored(array) push_xml_output_ignored(test_name, reason, test_time) if @xml_out end + # Test time will be in ms def get_test_time(value_with_time) test_time_array = value_with_time.scan(/\((-?\d+.?\d*) ms\)\s*$/).flatten.map do |arg_value_str| arg_value_str.include?('.') ? arg_value_str.to_f : arg_value_str.to_i From 42503b3343cbbc45c19967cbccb40b3409fb5065 Mon Sep 17 00:00:00 2001 From: Alex Overchenko Date: Mon, 28 Feb 2022 14:12:57 +0300 Subject: [PATCH 310/454] unity_to_junit.py can be imported as Python module now --- auto/__init__.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 auto/__init__.py diff --git a/auto/__init__.py b/auto/__init__.py new file mode 100644 index 00000000..e69de29b From 2dbfd0594c575688fe4d81aeb4cadd58dbc396f4 Mon Sep 17 00:00:00 2001 From: Alex Overchenko Date: Mon, 28 Feb 2022 16:11:32 +0300 Subject: [PATCH 311/454] Adding time feature description --- auto/parse_output.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/auto/parse_output.rb b/auto/parse_output.rb index 8d541f19..ea9fa0b3 100644 --- a/auto/parse_output.rb +++ b/auto/parse_output.rb @@ -14,6 +14,7 @@ # - normal output (raw unity) # - fixture output (unity_fixture.h/.c) # - fixture output with verbose flag set ("-v") +# - time output flag set (UNITY_INCLUDE_EXEC_TIME define enabled with milliseconds output) # # To use this parser use the following command # ruby parseOutput.rb [options] [file] From 824eb5f5c54c1288437e34e5d002f9e80dbafbbb Mon Sep 17 00:00:00 2001 From: Alex Overchenko Date: Mon, 28 Feb 2022 16:59:52 +0300 Subject: [PATCH 312/454] Fixing Rubocop code style --- auto/parse_output.rb | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/auto/parse_output.rb b/auto/parse_output.rb index ea9fa0b3..864104be 100644 --- a/auto/parse_output.rb +++ b/auto/parse_output.rb @@ -54,13 +54,13 @@ def set_xml_output end # Set the flag to indicate if there will be an XML output file or not - def set_test_suite_name(cli_arg) - @real_test_suite_name = cli_arg['-suite'.length..-1] + def test_suite_name=(cli_arg) + @real_test_suite_name = cli_arg puts 'Real test suite name will be \'' + @real_test_suite_name + '\'' end - def xml_encode_s(s) - return s.encode(:xml => :attr) + def xml_encode_s(str) + str.encode(:xml => :attr) end # If write our output to XML @@ -277,7 +277,7 @@ def process(file_name) puts '=================== RESULTS =====================' puts '' # Apply binary encoding. Bad symbols will be unchanged - File.open(file_name, "rb").each do |line| + File.open(file_name, 'rb').each do |line| # Typical test lines look like these: # ---------------------------------------------------- # 1. normal output: @@ -333,16 +333,16 @@ def process(file_name) @test_ignored += 1 elsif line_array.size >= 4 # We will check output from color compilation - if line_array[@result_usual_idx..-1].any? {|l| l.include? 'PASS'} + if line_array[@result_usual_idx..-1].any? { |l| l.include? 'PASS' } test_passed(line_array) @test_passed += 1 - elsif line_array[@result_usual_idx..-1].any? {|l| l.include? 'FAIL'} + elsif line_array[@result_usual_idx..-1].any? { |l| l.include? 'FAIL' } test_failed(line_array) @test_failed += 1 - elsif line_array[@result_usual_idx..-2].any? {|l| l.include? 'IGNORE'} + elsif line_array[@result_usual_idx..-2].any? { |l| l.include? 'IGNORE' } test_ignored(line_array) @test_ignored += 1 - elsif line_array[@result_usual_idx..-1].any? {|l| l.include? 'IGNORE'} + elsif line_array[@result_usual_idx..-1].any? { |l| l.include? 'IGNORE' } line_array.push('No reason given (' + get_test_time(line_array[@result_usual_idx..-1]).to_s + ' ms)') test_ignored(line_array) @test_ignored += 1 @@ -374,7 +374,7 @@ def process(file_name) if arg == '-xml' parse_my_file.set_xml_output elsif arg.start_with?('-suite') - parse_my_file.set_test_suite_name(arg) + parse_my_file.test_suite_name = arg.delete_prefix('-suite') else parse_my_file.process(arg) break From b770a519a018edcd8ddca354e1cb23a68580b271 Mon Sep 17 00:00:00 2001 From: Alex Overchenko Date: Fri, 4 Mar 2022 14:45:47 +0300 Subject: [PATCH 313/454] Fixing overflow false error detection on 32, 16 & 8 bit arrays withins --- src/unity.c | 64 +++++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 52 insertions(+), 12 deletions(-) diff --git a/src/unity.c b/src/unity.c index 9add9674..29cbe9c9 100644 --- a/src/unity.c +++ b/src/unity.c @@ -1269,30 +1269,70 @@ void UnityAssertNumbersArrayWithin(const UNITY_UINT delta, switch (length) { case 1: - expect_val = *(UNITY_PTR_ATTRIBUTE const UNITY_INT8*)expected; - actual_val = *(UNITY_PTR_ATTRIBUTE const UNITY_INT8*)actual; - increment = sizeof(UNITY_INT8); + // fixing problems with signed overflow on unsigned numbers + if ((style & UNITY_DISPLAY_RANGE_INT) == UNITY_DISPLAY_RANGE_INT) + { + expect_val = *(UNITY_PTR_ATTRIBUTE const UNITY_INT8*)expected; + actual_val = *(UNITY_PTR_ATTRIBUTE const UNITY_INT8*)actual; + increment = sizeof(UNITY_INT8); + } + else + { + expect_val = (UNITY_INT)*(UNITY_PTR_ATTRIBUTE const UNITY_UINT8*)expected; + actual_val = (UNITY_INT)*(UNITY_PTR_ATTRIBUTE const UNITY_UINT8*)actual; + increment = sizeof(UNITY_UINT8); + } break; case 2: - expect_val = *(UNITY_PTR_ATTRIBUTE const UNITY_INT16*)expected; - actual_val = *(UNITY_PTR_ATTRIBUTE const UNITY_INT16*)actual; - increment = sizeof(UNITY_INT16); + // fixing problems with signed overflow on unsigned numbers + if ((style & UNITY_DISPLAY_RANGE_INT) == UNITY_DISPLAY_RANGE_INT) + { + expect_val = *(UNITY_PTR_ATTRIBUTE const UNITY_INT16*)expected; + actual_val = *(UNITY_PTR_ATTRIBUTE const UNITY_INT16*)actual; + increment = sizeof(UNITY_INT16); + } + else + { + expect_val = (UNITY_INT)*(UNITY_PTR_ATTRIBUTE const UNITY_UINT16*)expected; + actual_val = (UNITY_INT)*(UNITY_PTR_ATTRIBUTE const UNITY_UINT16*)actual; + increment = sizeof(UNITY_UINT16); + } break; #ifdef UNITY_SUPPORT_64 case 8: - expect_val = *(UNITY_PTR_ATTRIBUTE const UNITY_INT64*)expected; - actual_val = *(UNITY_PTR_ATTRIBUTE const UNITY_INT64*)actual; - increment = sizeof(UNITY_INT64); + // fixing problems with signed overflow on unsigned numbers + if ((style & UNITY_DISPLAY_RANGE_INT) == UNITY_DISPLAY_RANGE_INT) + { + expect_val = *(UNITY_PTR_ATTRIBUTE const UNITY_INT64*)expected; + actual_val = *(UNITY_PTR_ATTRIBUTE const UNITY_INT64*)actual; + increment = sizeof(UNITY_INT64); + } + else + { + expect_val = (UNITY_INT)*(UNITY_PTR_ATTRIBUTE const UNITY_UINT64*)expected; + actual_val = (UNITY_INT)*(UNITY_PTR_ATTRIBUTE const UNITY_UINT64*)actual; + increment = sizeof(UNITY_UINT64); + } break; #endif default: /* default is length 4 bytes */ case 4: - expect_val = *(UNITY_PTR_ATTRIBUTE const UNITY_INT32*)expected; - actual_val = *(UNITY_PTR_ATTRIBUTE const UNITY_INT32*)actual; - increment = sizeof(UNITY_INT32); + // fixing problems with signed overflow on unsigned numbers + if ((style & UNITY_DISPLAY_RANGE_INT) == UNITY_DISPLAY_RANGE_INT) + { + expect_val = *(UNITY_PTR_ATTRIBUTE const UNITY_INT32*)expected; + actual_val = *(UNITY_PTR_ATTRIBUTE const UNITY_INT32*)actual; + increment = sizeof(UNITY_INT32); + } + else + { + expect_val = (UNITY_INT)*(UNITY_PTR_ATTRIBUTE const UNITY_UINT32*)expected; + actual_val = (UNITY_INT)*(UNITY_PTR_ATTRIBUTE const UNITY_UINT32*)actual; + increment = sizeof(UNITY_UINT32); + } length = 4; break; } From 9db619d6dce1d6146da7afa346fa439c9d7fa462 Mon Sep 17 00:00:00 2001 From: Alex Overchenko Date: Fri, 4 Mar 2022 14:49:29 +0300 Subject: [PATCH 314/454] Using C90 style comments --- src/unity.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/unity.c b/src/unity.c index 29cbe9c9..87c7aec9 100644 --- a/src/unity.c +++ b/src/unity.c @@ -1269,7 +1269,7 @@ void UnityAssertNumbersArrayWithin(const UNITY_UINT delta, switch (length) { case 1: - // fixing problems with signed overflow on unsigned numbers + /* fixing problems with signed overflow on unsigned numbers */ if ((style & UNITY_DISPLAY_RANGE_INT) == UNITY_DISPLAY_RANGE_INT) { expect_val = *(UNITY_PTR_ATTRIBUTE const UNITY_INT8*)expected; @@ -1285,7 +1285,7 @@ void UnityAssertNumbersArrayWithin(const UNITY_UINT delta, break; case 2: - // fixing problems with signed overflow on unsigned numbers + /* fixing problems with signed overflow on unsigned numbers */ if ((style & UNITY_DISPLAY_RANGE_INT) == UNITY_DISPLAY_RANGE_INT) { expect_val = *(UNITY_PTR_ATTRIBUTE const UNITY_INT16*)expected; @@ -1302,7 +1302,7 @@ void UnityAssertNumbersArrayWithin(const UNITY_UINT delta, #ifdef UNITY_SUPPORT_64 case 8: - // fixing problems with signed overflow on unsigned numbers + /* fixing problems with signed overflow on unsigned numbers */ if ((style & UNITY_DISPLAY_RANGE_INT) == UNITY_DISPLAY_RANGE_INT) { expect_val = *(UNITY_PTR_ATTRIBUTE const UNITY_INT64*)expected; @@ -1320,7 +1320,7 @@ void UnityAssertNumbersArrayWithin(const UNITY_UINT delta, default: /* default is length 4 bytes */ case 4: - // fixing problems with signed overflow on unsigned numbers + /* fixing problems with signed overflow on unsigned numbers */ if ((style & UNITY_DISPLAY_RANGE_INT) == UNITY_DISPLAY_RANGE_INT) { expect_val = *(UNITY_PTR_ATTRIBUTE const UNITY_INT32*)expected; From 79644b62422e776392647e177dac96c76ba483ee Mon Sep 17 00:00:00 2001 From: Alex Overchenko Date: Fri, 4 Mar 2022 16:20:55 +0300 Subject: [PATCH 315/454] Fixing noreturn usage on old Windows SDKs with new MSVC --- src/unity_internals.h | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/src/unity_internals.h b/src/unity_internals.h index d303e8fe..819164e7 100644 --- a/src/unity_internals.h +++ b/src/unity_internals.h @@ -52,8 +52,28 @@ #define UNITY_NORETURN [[ noreturn ]] #endif #elif defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L - #include - #define UNITY_NORETURN noreturn + #if defined(_WIN32) && defined(_MSC_VER) + /* We are using MSVC compiler on Windows platform. */ + /* Not all Windows SDKs supports , but compiler can support C11: */ + /* https://devblogs.microsoft.com/cppblog/c11-and-c17-standard-support-arriving-in-msvc/ */ + /* Not sure, that Mingw compilers has Windows SDK headers at all. */ + #include + #endif + + /* Using Windows SDK predefined macro for detecting supported SDK with MSVC compiler. */ + /* Mingw GCC should work without that fixes. */ + /* Based on: */ + /* https://docs.microsoft.com/en-us/cpp/porting/modifying-winver-and-win32-winnt?view=msvc-170 */ + /* NTDDI_WIN10_FE is equal to Windows 10 SDK 2104 */ + #if defined(_MSC_VER) && ((!defined(NTDDI_WIN10_FE)) || WDK_NTDDI_VERSION < NTDDI_WIN10_FE) + /* Based on tests and: */ + /* https://docs.microsoft.com/en-us/cpp/c-language/noreturn?view=msvc-170 */ + /* https://en.cppreference.com/w/c/language/_Noreturn */ + #define UNITY_NORETURN _Noreturn + #else /* Using newer Windows SDK or not MSVC compiler */ + #include + #define UNITY_NORETURN noreturn + #endif #endif #endif #ifndef UNITY_NORETURN From 0df1d442cb529ce7a8611429c149908f8b5b7a94 Mon Sep 17 00:00:00 2001 From: Mark VanderVoord Date: Tue, 19 Apr 2022 16:21:04 -0400 Subject: [PATCH 316/454] Rearrange details to always print if given, no matter if another msg added or not. Print output on failures no matter if verbose or not. Enforce that HEX comparisons are unsigned comparisons. --- src/unity.c | 49 +++++++++++++++++++---------- test/rakefile_helper.rb | 2 +- test/tests/test_unity_arrays.c | 36 +++++++++++++++++++++ test/tests/test_unity_integers.c | 15 +++++++++ test/tests/test_unity_integers_64.c | 9 ++++++ 5 files changed, 94 insertions(+), 17 deletions(-) diff --git a/src/unity.c b/src/unity.c index 87c7aec9..398da66e 100644 --- a/src/unity.c +++ b/src/unity.c @@ -571,26 +571,26 @@ void UnityConcludeTest(void) /*-----------------------------------------------*/ static void UnityAddMsgIfSpecified(const char* msg) { - if (msg) - { - UnityPrint(UnityStrSpacer); - #ifdef UNITY_PRINT_TEST_CONTEXT - UNITY_PRINT_TEST_CONTEXT(); + UnityPrint(UnityStrSpacer); + UNITY_PRINT_TEST_CONTEXT(); #endif #ifndef UNITY_EXCLUDE_DETAILS - if (Unity.CurrentDetail1) + if (Unity.CurrentDetail1) + { + UnityPrint(UnityStrSpacer); + UnityPrint(UnityStrDetail1Name); + UnityPrint(Unity.CurrentDetail1); + if (Unity.CurrentDetail2) { - UnityPrint(UnityStrDetail1Name); - UnityPrint(Unity.CurrentDetail1); - if (Unity.CurrentDetail2) - { - UnityPrint(UnityStrDetail2Name); - UnityPrint(Unity.CurrentDetail2); - } - UnityPrint(UnityStrSpacer); + UnityPrint(UnityStrDetail2Name); + UnityPrint(Unity.CurrentDetail2); } -#endif + } +#endif + if (msg) + { + UnityPrint(UnityStrSpacer); UnityPrint(msg); } } @@ -819,12 +819,22 @@ void UnityAssertEqualIntArray(UNITY_INTERNAL_PTR expected, case 1: expect_val = *(UNITY_PTR_ATTRIBUTE const UNITY_INT8*)expected; actual_val = *(UNITY_PTR_ATTRIBUTE const UNITY_INT8*)actual; + if (style & (UNITY_DISPLAY_RANGE_UINT | UNITY_DISPLAY_RANGE_HEX)) + { + expect_val &= 0x000000FF; + actual_val &= 0x000000FF; + } increment = sizeof(UNITY_INT8); break; case 2: expect_val = *(UNITY_PTR_ATTRIBUTE const UNITY_INT16*)expected; actual_val = *(UNITY_PTR_ATTRIBUTE const UNITY_INT16*)actual; + if (style & (UNITY_DISPLAY_RANGE_UINT | UNITY_DISPLAY_RANGE_HEX)) + { + expect_val &= 0x0000FFFF; + actual_val &= 0x0000FFFF; + } increment = sizeof(UNITY_INT16); break; @@ -839,7 +849,14 @@ void UnityAssertEqualIntArray(UNITY_INTERNAL_PTR expected, default: /* default is length 4 bytes */ case 4: expect_val = *(UNITY_PTR_ATTRIBUTE const UNITY_INT32*)expected; - actual_val = *(UNITY_PTR_ATTRIBUTE const UNITY_INT32*)actual; + actual_val = *(UNITY_PTR_ATTRIBUTE const UNITY_INT32*)actual; +#ifdef UNITY_SUPPORT_64 + if (style & (UNITY_DISPLAY_RANGE_UINT | UNITY_DISPLAY_RANGE_HEX)) + { + expect_val &= 0x00000000FFFFFFFF; + actual_val &= 0x00000000FFFFFFFF; + } +#endif increment = sizeof(UNITY_INT32); length = 4; break; diff --git a/test/rakefile_helper.rb b/test/rakefile_helper.rb index 86789445..4487a28c 100644 --- a/test/rakefile_helper.rb +++ b/test/rakefile_helper.rb @@ -173,7 +173,7 @@ def run_astyle(style_what) def execute(command_string, ok_to_fail = false) report command_string if $verbose output = `#{command_string}`.chomp - report(output) if $verbose && !output.nil? && !output.empty? + report(output) if ($verbose && !output.nil? && !output.empty?) || (!$?.nil? && !$?.exitstatus.zero? && !ok_to_fail) raise "Command failed. (Returned #{$?.exitstatus})" if !$?.nil? && !$?.exitstatus.zero? && !ok_to_fail output end diff --git a/test/tests/test_unity_arrays.c b/test/tests/test_unity_arrays.c index ff90a6c4..8d5bb471 100644 --- a/test/tests/test_unity_arrays.c +++ b/test/tests/test_unity_arrays.c @@ -1133,6 +1133,18 @@ void testHEX64ArrayWithinDelta(void) #endif } +void testHEX64ArrayWithinDeltaShouldNotHaveSignIssues(void) +{ +#ifndef UNITY_SUPPORT_64 + TEST_IGNORE(); +#else + UNITY_UINT64 expected[] = {0x7FFFFFFFFFFFFFFF, 0x8000000000000000}; + UNITY_UINT64 actualBigDelta[] = {0x8000000000000000, 0x7FFFFFFFFFFFFFFF}; + + TEST_ASSERT_HEX64_ARRAY_WITHIN(1, expected, actualBigDelta, 2); +#endif +} + void testHEX64ArrayWithinDeltaAndMessage(void) { #ifndef UNITY_SUPPORT_64 @@ -1287,6 +1299,14 @@ void testHEX32ArrayWithinDelta(void) TEST_ASSERT_HEX32_ARRAY_WITHIN(110, expected, actualBigDelta, 3); } +void testHEX32ArrayWithinDeltaShouldNotHaveSignIssues(void) +{ + UNITY_UINT32 expected[] = {0x7FFFFFFF, 0x80000000}; + UNITY_UINT32 actualBigDelta[] = {0x80000000, 0x7FFFFFFF}; + + TEST_ASSERT_HEX32_ARRAY_WITHIN(1, expected, actualBigDelta, 2); +} + void testHEX32ArrayWithinDeltaAndMessage(void) { UNITY_UINT expected[] = {0xABCD1234, 0xABCD1122, 0xABCD1277}; @@ -1398,6 +1418,14 @@ void testHEX16ArrayWithinDelta(void) TEST_ASSERT_HEX16_ARRAY_WITHIN(110, expected, actualBigDelta, 3); } +void testHEX16ArrayWithinDeltaShouldNotHaveSignIssues(void) +{ + UNITY_UINT16 expected[] = {0x7FFF, 0x8000}; + UNITY_UINT16 actualBigDelta[] = {0x8000, 0x7FFF}; + + TEST_ASSERT_HEX16_ARRAY_WITHIN(1, expected, actualBigDelta, 2); +} + void testHEX16ArrayWithinDeltaAndMessage(void) { UNITY_UINT16 expected[] = {0x1234, 0x1122, 0x1277}; @@ -1528,6 +1556,14 @@ void testHEX8ArrayNotWithinDelta(void) VERIFY_FAILS_END } +void testHEX8ArrayWithinDeltaShouldNotHaveSignIssues(void) +{ + UNITY_UINT8 expected[] = {0x7F, 0x80}; + UNITY_UINT8 actualBigDelta[] = {0x80, 0x7F}; + + TEST_ASSERT_HEX8_ARRAY_WITHIN(1, expected, actualBigDelta, 2); +} + void testHEX8ArrayNotWithinDeltaAndMessage(void) { UNITY_UINT8 expected[] = {0x34, 0x22, 0x77}; diff --git a/test/tests/test_unity_integers.c b/test/tests/test_unity_integers.c index 7bdfa144..d615e5f0 100644 --- a/test/tests/test_unity_integers.c +++ b/test/tests/test_unity_integers.c @@ -800,6 +800,11 @@ void testHEX32sWithinDelta(void) TEST_ASSERT_HEX32_WITHIN(5, 5000, 5005); } +void testHEX32sWithinDeltaShouldIgnoreSign(void) +{ + TEST_ASSERT_HEX32_WITHIN(1, 0x7FFFFFFF, 0x80000000); +} + void testHEX32sWithinDeltaAndCustomMessage(void) { TEST_ASSERT_HEX32_WITHIN_MESSAGE(1, 5000, 5001, "Custom Message."); @@ -842,6 +847,11 @@ void testHEX16sWithinDelta(void) TEST_ASSERT_HEX16_WITHIN(5, 5000, 5005); } +void testHEX16sWithinDeltaShouldIgnoreSign(void) +{ + TEST_ASSERT_HEX16_WITHIN(1, 0x7FFF, 0x8000); +} + void testHEX16sWithinDeltaAndCustomMessage(void) { TEST_ASSERT_HEX16_WITHIN_MESSAGE(1, 5000, 5001, "Custom Message."); @@ -880,6 +890,11 @@ void testHEX8sWithinDelta(void) TEST_ASSERT_HEX8_WITHIN(5, 1, 4); } +void testHEX8sWithinDeltaShouldIgnoreSign(void) +{ + TEST_ASSERT_HEX8_WITHIN(1, 0x7F, 0x80); +} + void testHEX8sWithinDeltaAndCustomMessage(void) { TEST_ASSERT_HEX8_WITHIN_MESSAGE(1, 254, 255, "Custom Message."); diff --git a/test/tests/test_unity_integers_64.c b/test/tests/test_unity_integers_64.c index e12566e8..867d1e79 100644 --- a/test/tests/test_unity_integers_64.c +++ b/test/tests/test_unity_integers_64.c @@ -652,6 +652,15 @@ void testHEX64sWithinDelta(void) #endif } +void testHEX32sWithinDeltaShouldIgnoreSign(void) +{ +#ifndef UNITY_SUPPORT_64 + TEST_IGNORE(); +#else + TEST_ASSERT_HEX64_WITHIN(1, 0x7FFFFFFFFFFFFFFF,0x8000000000000000); +#endif +} + void testHEX64sNotWithinDelta(void) { #ifndef UNITY_SUPPORT_64 From 4389bab82ee8a4b4631a03be2e07dd5c67dab2d4 Mon Sep 17 00:00:00 2001 From: Mark VanderVoord Date: Tue, 19 Apr 2022 17:27:31 -0400 Subject: [PATCH 317/454] Support option to specify array length of zero to force pointer comparison. --- docs/UnityConfigurationGuide.md | 6 ++++++ src/unity.c | 30 +++++++++++++++++++++++++++++- src/unity_internals.h | 2 ++ test/targets/clang_strict.yml | 1 + test/tests/test_unity_arrays.c | 30 ++++++++++++++++++++++++++++++ 5 files changed, 68 insertions(+), 1 deletion(-) diff --git a/docs/UnityConfigurationGuide.md b/docs/UnityConfigurationGuide.md index 71305c3c..9ac0cdd6 100644 --- a/docs/UnityConfigurationGuide.md +++ b/docs/UnityConfigurationGuide.md @@ -121,6 +121,12 @@ _Example:_ #define UNITY_POINTER_WIDTH 64 // Set UNITY_POINTER_WIDTH to 64-bit ``` +#### `UNITY_COMPARE_PTRS_ON_ZERO_ARRAY` + +Define this to make all array assertions compare pointers instead of contents when a length of zero is specified. When not enabled, +defining a length of zero will always result in a failure and a message warning the user that they have tried to compare empty +arrays. + #### `UNITY_SUPPORT_64` Unity will automatically include 64-bit support if it auto-detects it, or if your `int`, `long`, or pointer widths are greater than 32-bits. diff --git a/src/unity.c b/src/unity.c index 398da66e..951ed1c4 100644 --- a/src/unity.c +++ b/src/unity.c @@ -796,7 +796,11 @@ void UnityAssertEqualIntArray(UNITY_INTERNAL_PTR expected, if (num_elements == 0) { +#ifdef UNITY_COMPARE_PTRS_ON_ZERO_ARRAY + UNITY_TEST_ASSERT_EQUAL_PTR(expected, actual, lineNumber, msg); +#else UnityPrintPointlessAndBail(); +#endif } if (expected == actual) @@ -943,7 +947,11 @@ void UnityAssertEqualFloatArray(UNITY_PTR_ATTRIBUTE const UNITY_FLOAT* expected, if (elements == 0) { +#ifdef UNITY_COMPARE_PTRS_ON_ZERO_ARRAY + UNITY_TEST_ASSERT_EQUAL_PTR(expected, actual, lineNumber, msg); +#else UnityPrintPointlessAndBail(); +#endif } if (expected == actual) @@ -1084,7 +1092,11 @@ void UnityAssertEqualDoubleArray(UNITY_PTR_ATTRIBUTE const UNITY_DOUBLE* expecte if (elements == 0) { +#ifdef UNITY_COMPARE_PTRS_ON_ZERO_ARRAY + UNITY_TEST_ASSERT_EQUAL_PTR(expected, actual, lineNumber, msg); +#else UnityPrintPointlessAndBail(); +#endif } if (expected == actual) @@ -1265,7 +1277,11 @@ void UnityAssertNumbersArrayWithin(const UNITY_UINT delta, if (num_elements == 0) { +#ifdef UNITY_COMPARE_PTRS_ON_ZERO_ARRAY + UNITY_TEST_ASSERT_EQUAL_PTR(expected, actual, lineNumber, msg); +#else UnityPrintPointlessAndBail(); +#endif } if (expected == actual) @@ -1504,7 +1520,11 @@ void UnityAssertEqualStringArray(UNITY_INTERNAL_PTR expected, /* if no elements, it's an error */ if (num_elements == 0) { +#ifdef UNITY_COMPARE_PTRS_ON_ZERO_ARRAY + UNITY_TEST_ASSERT_EQUAL_PTR(expected, actual, lineNumber, msg); +#else UnityPrintPointlessAndBail(); +#endif } if ((const void*)expected == (const void*)actual) @@ -1581,7 +1601,15 @@ void UnityAssertEqualMemory(UNITY_INTERNAL_PTR expected, RETURN_IF_FAIL_OR_IGNORE; - if ((elements == 0) || (length == 0)) + if (elements == 0) + { +#ifdef UNITY_COMPARE_PTRS_ON_ZERO_ARRAY + UNITY_TEST_ASSERT_EQUAL_PTR(expected, actual, lineNumber, msg); +#else + UnityPrintPointlessAndBail(); +#endif + } + if (length == 0) { UnityPrintPointlessAndBail(); } diff --git a/src/unity_internals.h b/src/unity_internals.h index 819164e7..8bc783b9 100644 --- a/src/unity_internals.h +++ b/src/unity_internals.h @@ -214,6 +214,8 @@ #define UNITY_INTERNAL_PTR UNITY_PTR_ATTRIBUTE const void* #endif +/* optionally define UNITY_COMPARE_PTRS_ON_ZERO_ARRAY */ + /*------------------------------------------------------- * Float Support *-------------------------------------------------------*/ diff --git a/test/targets/clang_strict.yml b/test/targets/clang_strict.yml index 04d56806..f124e8fd 100644 --- a/test/targets/clang_strict.yml +++ b/test/targets/clang_strict.yml @@ -69,3 +69,4 @@ colour: true - UNITY_INCLUDE_DOUBLE - UNITY_SUPPORT_TEST_CASES - UNITY_SUPPORT_64 + - UNITY_COMPARE_PTRS_ON_ZERO_ARRAY diff --git a/test/tests/test_unity_arrays.c b/test/tests/test_unity_arrays.c index 8d5bb471..59848836 100644 --- a/test/tests/test_unity_arrays.c +++ b/test/tests/test_unity_arrays.c @@ -2908,3 +2908,33 @@ void testNotEqualInt64Arrays(void) VERIFY_FAILS_END #endif } + +void testVerifyIntPassingPointerComparisonOnZeroLengthArray(void) +{ + int a[] = { 1 }; + +#ifndef UNITY_COMPARE_PTRS_ON_ZERO_ARRAY + EXPECT_ABORT_BEGIN + TEST_ASSERT_EQUAL_INT_ARRAY(a, a, 0); + VERIFY_FAILS_END +#else + + TEST_ASSERT_EQUAL_INT_ARRAY(a, a, 0); +#endif +} + +void testVerifyIntFailingPointerComparisonOnZeroLengthArray(void) +{ + int a[] = { 1 }; + int b[] = { 1 }; + +#ifndef UNITY_COMPARE_PTRS_ON_ZERO_ARRAY + EXPECT_ABORT_BEGIN + TEST_ASSERT_EQUAL_INT_ARRAY(a, b, 0); + VERIFY_FAILS_END +#else + EXPECT_ABORT_BEGIN + TEST_ASSERT_EQUAL_INT_ARRAY(a, b, 0); + VERIFY_FAILS_END +#endif +} From be657105e5d751d3d95538e36b6a1e84a37aad26 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Fri, 22 Apr 2022 13:31:07 +0300 Subject: [PATCH 318/454] Make PROGMEM configurable // Resolve #606, Resolve #482 --- src/unity.c | 90 ++++++++++++++++++++++++++--------------------------- 1 file changed, 44 insertions(+), 46 deletions(-) diff --git a/src/unity.c b/src/unity.c index 951ed1c4..cf9f8cf8 100644 --- a/src/unity.c +++ b/src/unity.c @@ -7,10 +7,8 @@ #include "unity.h" #include -#ifdef AVR -#include -#else -#define PROGMEM +#ifndef UNITY_PROGMEM +#define UNITY_PROGMEM #endif /* If omitted from header, declare overrideable prototypes here so they're ready for use */ @@ -26,50 +24,50 @@ void UNITY_OUTPUT_CHAR(int); struct UNITY_STORAGE_T Unity; #ifdef UNITY_OUTPUT_COLOR -const char PROGMEM UnityStrOk[] = "\033[42mOK\033[0m"; -const char PROGMEM UnityStrPass[] = "\033[42mPASS\033[0m"; -const char PROGMEM UnityStrFail[] = "\033[41mFAIL\033[0m"; -const char PROGMEM UnityStrIgnore[] = "\033[43mIGNORE\033[0m"; +const char UNITY_PROGMEM UnityStrOk[] = "\033[42mOK\033[0m"; +const char UNITY_PROGMEM UnityStrPass[] = "\033[42mPASS\033[0m"; +const char UNITY_PROGMEM UnityStrFail[] = "\033[41mFAIL\033[0m"; +const char UNITY_PROGMEM UnityStrIgnore[] = "\033[43mIGNORE\033[0m"; #else -const char PROGMEM UnityStrOk[] = "OK"; -const char PROGMEM UnityStrPass[] = "PASS"; -const char PROGMEM UnityStrFail[] = "FAIL"; -const char PROGMEM UnityStrIgnore[] = "IGNORE"; +const char UNITY_PROGMEM UnityStrOk[] = "OK"; +const char UNITY_PROGMEM UnityStrPass[] = "PASS"; +const char UNITY_PROGMEM UnityStrFail[] = "FAIL"; +const char UNITY_PROGMEM UnityStrIgnore[] = "IGNORE"; #endif -static const char PROGMEM UnityStrNull[] = "NULL"; -static const char PROGMEM UnityStrSpacer[] = ". "; -static const char PROGMEM UnityStrExpected[] = " Expected "; -static const char PROGMEM UnityStrWas[] = " Was "; -static const char PROGMEM UnityStrGt[] = " to be greater than "; -static const char PROGMEM UnityStrLt[] = " to be less than "; -static const char PROGMEM UnityStrOrEqual[] = "or equal to "; -static const char PROGMEM UnityStrNotEqual[] = " to be not equal to "; -static const char PROGMEM UnityStrElement[] = " Element "; -static const char PROGMEM UnityStrByte[] = " Byte "; -static const char PROGMEM UnityStrMemory[] = " Memory Mismatch."; -static const char PROGMEM UnityStrDelta[] = " Values Not Within Delta "; -static const char PROGMEM UnityStrPointless[] = " You Asked Me To Compare Nothing, Which Was Pointless."; -static const char PROGMEM UnityStrNullPointerForExpected[] = " Expected pointer to be NULL"; -static const char PROGMEM UnityStrNullPointerForActual[] = " Actual pointer was NULL"; +static const char UNITY_PROGMEM UnityStrNull[] = "NULL"; +static const char UNITY_PROGMEM UnityStrSpacer[] = ". "; +static const char UNITY_PROGMEM UnityStrExpected[] = " Expected "; +static const char UNITY_PROGMEM UnityStrWas[] = " Was "; +static const char UNITY_PROGMEM UnityStrGt[] = " to be greater than "; +static const char UNITY_PROGMEM UnityStrLt[] = " to be less than "; +static const char UNITY_PROGMEM UnityStrOrEqual[] = "or equal to "; +static const char UNITY_PROGMEM UnityStrNotEqual[] = " to be not equal to "; +static const char UNITY_PROGMEM UnityStrElement[] = " Element "; +static const char UNITY_PROGMEM UnityStrByte[] = " Byte "; +static const char UNITY_PROGMEM UnityStrMemory[] = " Memory Mismatch."; +static const char UNITY_PROGMEM UnityStrDelta[] = " Values Not Within Delta "; +static const char UNITY_PROGMEM UnityStrPointless[] = " You Asked Me To Compare Nothing, Which Was Pointless."; +static const char UNITY_PROGMEM UnityStrNullPointerForExpected[] = " Expected pointer to be NULL"; +static const char UNITY_PROGMEM UnityStrNullPointerForActual[] = " Actual pointer was NULL"; #ifndef UNITY_EXCLUDE_FLOAT -static const char PROGMEM UnityStrNot[] = "Not "; -static const char PROGMEM UnityStrInf[] = "Infinity"; -static const char PROGMEM UnityStrNegInf[] = "Negative Infinity"; -static const char PROGMEM UnityStrNaN[] = "NaN"; -static const char PROGMEM UnityStrDet[] = "Determinate"; -static const char PROGMEM UnityStrInvalidFloatTrait[] = "Invalid Float Trait"; +static const char UNITY_PROGMEM UnityStrNot[] = "Not "; +static const char UNITY_PROGMEM UnityStrInf[] = "Infinity"; +static const char UNITY_PROGMEM UnityStrNegInf[] = "Negative Infinity"; +static const char UNITY_PROGMEM UnityStrNaN[] = "NaN"; +static const char UNITY_PROGMEM UnityStrDet[] = "Determinate"; +static const char UNITY_PROGMEM UnityStrInvalidFloatTrait[] = "Invalid Float Trait"; #endif -const char PROGMEM UnityStrErrShorthand[] = "Unity Shorthand Support Disabled"; -const char PROGMEM UnityStrErrFloat[] = "Unity Floating Point Disabled"; -const char PROGMEM UnityStrErrDouble[] = "Unity Double Precision Disabled"; -const char PROGMEM UnityStrErr64[] = "Unity 64-bit Support Disabled"; -static const char PROGMEM UnityStrBreaker[] = "-----------------------"; -static const char PROGMEM UnityStrResultsTests[] = " Tests "; -static const char PROGMEM UnityStrResultsFailures[] = " Failures "; -static const char PROGMEM UnityStrResultsIgnored[] = " Ignored "; +const char UNITY_PROGMEM UnityStrErrShorthand[] = "Unity Shorthand Support Disabled"; +const char UNITY_PROGMEM UnityStrErrFloat[] = "Unity Floating Point Disabled"; +const char UNITY_PROGMEM UnityStrErrDouble[] = "Unity Double Precision Disabled"; +const char UNITY_PROGMEM UnityStrErr64[] = "Unity 64-bit Support Disabled"; +static const char UNITY_PROGMEM UnityStrBreaker[] = "-----------------------"; +static const char UNITY_PROGMEM UnityStrResultsTests[] = " Tests "; +static const char UNITY_PROGMEM UnityStrResultsFailures[] = " Failures "; +static const char UNITY_PROGMEM UnityStrResultsIgnored[] = " Ignored "; #ifndef UNITY_EXCLUDE_DETAILS -static const char PROGMEM UnityStrDetail1Name[] = UNITY_DETAIL1_NAME " "; -static const char PROGMEM UnityStrDetail2Name[] = " " UNITY_DETAIL2_NAME " "; +static const char UNITY_PROGMEM UnityStrDetail1Name[] = UNITY_DETAIL1_NAME " "; +static const char UNITY_PROGMEM UnityStrDetail2Name[] = " " UNITY_DETAIL2_NAME " "; #endif /*----------------------------------------------- * Pretty Printers & Test Result Output Handlers @@ -587,9 +585,9 @@ static void UnityAddMsgIfSpecified(const char* msg) UnityPrint(Unity.CurrentDetail2); } } -#endif +#endif if (msg) - { + { UnityPrint(UnityStrSpacer); UnityPrint(msg); } @@ -853,7 +851,7 @@ void UnityAssertEqualIntArray(UNITY_INTERNAL_PTR expected, default: /* default is length 4 bytes */ case 4: expect_val = *(UNITY_PTR_ATTRIBUTE const UNITY_INT32*)expected; - actual_val = *(UNITY_PTR_ATTRIBUTE const UNITY_INT32*)actual; + actual_val = *(UNITY_PTR_ATTRIBUTE const UNITY_INT32*)actual; #ifdef UNITY_SUPPORT_64 if (style & (UNITY_DISPLAY_RANGE_UINT | UNITY_DISPLAY_RANGE_HEX)) { From e85f439c9859b81e0866b191553d9a88f2d4edc9 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Fri, 22 Apr 2022 13:43:32 +0300 Subject: [PATCH 319/454] List Unity framework in PlatformIO Registry --- library.json | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 library.json diff --git a/library.json b/library.json new file mode 100644 index 00000000..3522f1e9 --- /dev/null +++ b/library.json @@ -0,0 +1,15 @@ +{ + "name": "Unity", + "version": "2.5.2", + "keywords": "unittest, tdd, unit, test", + "description": "Simple Unit Testing for C", + "homepage": "http://www.throwtheswitch.org/unity", + "license": "MIT", + "repository": { + "type": "git", + "url": "https://github.com/ThrowTheSwitch/Unity.git" + }, + "frameworks": "*", + "platforms": "*", + "headers": "unity.h" +} From a260ba1e4edd4305c4c51ffadd10e795791e5cbe Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Fri, 22 Apr 2022 17:48:58 +0300 Subject: [PATCH 320/454] Improve keywrods list --- library.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library.json b/library.json index 3522f1e9..26a1e813 100644 --- a/library.json +++ b/library.json @@ -1,7 +1,7 @@ { "name": "Unity", "version": "2.5.2", - "keywords": "unittest, tdd, unit, test", + "keywords": "unit-testing, testing, tdd, testing-framework", "description": "Simple Unit Testing for C", "homepage": "http://www.throwtheswitch.org/unity", "license": "MIT", From b44c2dd0955dc7730fdaed4e2a75992d5061d432 Mon Sep 17 00:00:00 2001 From: Martyn Jago Date: Fri, 27 May 2022 15:08:11 +0100 Subject: [PATCH 321/454] Fix broken YAML parsing on later Rubies with Psych >=4.0 YAML.load is now interpreted as YAML.safe_load, which breaks where the YAML file contains aliases. If we can assume our yaml files are trusted (since this a development tool), we can check for the presence of YAML.unsafe_load and use it instead if it exists. --- auto/generate_module.rb | 4 ++-- auto/generate_test_runner.rb | 4 ++-- auto/test_file_filter.rb | 7 ++++--- auto/yaml_helper.rb | 19 +++++++++++++++++++ examples/example_3/rakefile_helper.rb | 11 ++++++++--- test/rakefile_helper.rb | 4 ++-- 6 files changed, 37 insertions(+), 12 deletions(-) create mode 100644 auto/yaml_helper.rb diff --git a/auto/generate_module.rb b/auto/generate_module.rb index 8e33d95e..7151586b 100644 --- a/auto/generate_module.rb +++ b/auto/generate_module.rb @@ -116,8 +116,8 @@ def self.default_options def self.grab_config(config_file) options = default_options unless config_file.nil? || config_file.empty? - require 'yaml' - yaml_guts = YAML.load_file(config_file) + require_relative 'yaml_helper' + yaml_guts = YamlHelper.load_file(config_file) options.merge!(yaml_guts[:unity] || yaml_guts[:cmock]) raise "No :unity or :cmock section found in #{config_file}" unless options end diff --git a/auto/generate_test_runner.rb b/auto/generate_test_runner.rb index 9401ad88..b4deb2bd 100644 --- a/auto/generate_test_runner.rb +++ b/auto/generate_test_runner.rb @@ -51,8 +51,8 @@ def self.default_options def self.grab_config(config_file) options = default_options unless config_file.nil? || config_file.empty? - require 'yaml' - yaml_guts = YAML.load_file(config_file) + require_relative 'yaml_helper' + yaml_guts = YamlHelper.load_file(config_file) options.merge!(yaml_guts[:unity] || yaml_guts[:cmock]) raise "No :unity or :cmock section found in #{config_file}" unless options end diff --git a/auto/test_file_filter.rb b/auto/test_file_filter.rb index 5c3a79fc..3cc32de8 100644 --- a/auto/test_file_filter.rb +++ b/auto/test_file_filter.rb @@ -4,7 +4,7 @@ # [Released under MIT License. Please refer to license.txt for details] # ========================================== -require'yaml' +require_relative 'yaml_helper' module RakefileHelpers class TestFileFilter @@ -12,9 +12,10 @@ def initialize(all_files = false) @all_files = all_files return unless @all_files - return unless File.exist?('test_file_filter.yml') - filters = YAML.load_file('test_file_filter.yml') + file = 'test_file_filter.yml' + return unless File.exist?(file) + filters = YamlHelper.load_file(file) @all_files = filters[:all_files] @only_files = filters[:only_files] @exclude_files = filters[:exclude_files] diff --git a/auto/yaml_helper.rb b/auto/yaml_helper.rb new file mode 100644 index 00000000..e5a08657 --- /dev/null +++ b/auto/yaml_helper.rb @@ -0,0 +1,19 @@ +# ========================================== +# Unity Project - A Test Framework for C +# Copyright (c) 2007 Mike Karlesky, Mark VanderVoord, Greg Williams +# [Released under MIT License. Please refer to license.txt for details] +# ========================================== + +require 'yaml' + +module YamlHelper + def self.load(body) + YAML.respond_to?(:unsafe_load) ? + YAML.unsafe_load(body) : YAML.load(body) + end + + def self.load_file(file) + body = File.read(file) + self.load(body) + end +end diff --git a/examples/example_3/rakefile_helper.rb b/examples/example_3/rakefile_helper.rb index 64d20c95..49060750 100644 --- a/examples/example_3/rakefile_helper.rb +++ b/examples/example_3/rakefile_helper.rb @@ -1,14 +1,19 @@ -require 'yaml' +# ========================================== +# Unity Project - A Test Framework for C +# Copyright (c) 2007 Mike Karlesky, Mark VanderVoord, Greg Williams +# [Released under MIT License. Please refer to license.txt for details] +# ========================================== + require 'fileutils' require_relative '../../auto/unity_test_summary' require_relative '../../auto/generate_test_runner' require_relative '../../auto/colour_reporter' - +require_relative '../../auto/yaml_helper' C_EXTENSION = '.c'.freeze def load_configuration(config_file) $cfg_file = config_file - $cfg = YAML.load(File.read($cfg_file)) + $cfg = YamlHelper.load_file($cfg_file) end def configure_clean diff --git a/test/rakefile_helper.rb b/test/rakefile_helper.rb index 4487a28c..1a9fc334 100644 --- a/test/rakefile_helper.rb +++ b/test/rakefile_helper.rb @@ -4,11 +4,11 @@ # [Released under MIT License. Please refer to license.txt for details] # ========================================== -require 'yaml' require 'fileutils' require_relative '../auto/unity_test_summary' require_relative '../auto/generate_test_runner' require_relative '../auto/colour_reporter' +require_relative '../auto/yaml_helper' module RakefileHelpers C_EXTENSION = '.c'.freeze @@ -16,7 +16,7 @@ def load_configuration(config_file) return if $configured $cfg_file = "targets/#{config_file}" unless config_file =~ /[\\|\/]/ - $cfg = YAML.load(File.read($cfg_file)) + $cfg = YamlHelper.load_file($cfg_file) $colour_output = false unless $cfg['colour'] $configured = true if config_file != DEFAULT_CONFIG_FILE end From 5dd3aa40dc16ac664198f89b72076c9eb4c5051d Mon Sep 17 00:00:00 2001 From: Martyn Jago Date: Sat, 28 May 2022 12:35:22 +0100 Subject: [PATCH 322/454] Fix call to ERB.new to avoid deprecation warnings. On later Rubies calling create_run_test() causes the generation of warnings of the following form: warning: Passing safe_level with the 2nd argument of ERB.new is deprecated... warning: Passing trim_mode with the 3rd argument of ERB.new is deprecated... This patch removes the noise. --- auto/generate_test_runner.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/auto/generate_test_runner.rb b/auto/generate_test_runner.rb index b4deb2bd..3b35a69f 100644 --- a/auto/generate_test_runner.rb +++ b/auto/generate_test_runner.rb @@ -345,7 +345,8 @@ def create_reset(output) def create_run_test(output) require 'erb' - template = ERB.new(File.read(File.join(__dir__, 'run_test.erb')), nil, '<>') + file = File.read(File.join(__dir__, 'run_test.erb')) + template = ERB.new(file, trim_mode: '<>') output.puts("\n" + template.result(binding)) end From 02e0bd5382b592ef9f5bc92de73e3da43e9c8cb4 Mon Sep 17 00:00:00 2001 From: Can Caglar Date: Sun, 5 Jun 2022 14:01:48 +0100 Subject: [PATCH 323/454] fix wrong filename mentioned in readme for fixtures --- extras/fixture/readme.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extras/fixture/readme.md b/extras/fixture/readme.md index 5791bcb9..e0c9e1b7 100644 --- a/extras/fixture/readme.md +++ b/extras/fixture/readme.md @@ -1,7 +1,7 @@ # Unity Fixtures This Framework is an optional add-on to Unity. -By including unity_framework.h in place of unity.h, you may now work with Unity in a manner similar to CppUTest. +By including unity_fixture.h in place of unity.h, you may now work with Unity in a manner similar to CppUTest. This framework adds the concepts of test groups and gives finer control of your tests over the command line. This framework is primarily supplied for those working through James Grenning's book on Embedded Test Driven Development, or those coming to Unity from CppUTest. From df2ea08157f709f5c3fb1ad24c08b9f1794dcb79 Mon Sep 17 00:00:00 2001 From: Michael Gene Brockus <55331536+troglobyte-coder@users.noreply.github.com> Date: Sun, 19 Jun 2022 06:33:19 -0700 Subject: [PATCH 324/454] Update meson.build --- meson.build | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/meson.build b/meson.build index f5c5cfaa..4b9f6e77 100644 --- a/meson.build +++ b/meson.build @@ -1,14 +1,12 @@ # -# build script written by : Michael Brockus. +# build script written by : Michael Gene Brockus. # github repo author: Mike Karlesky, Mark VanderVoord, Greg Williams. # # license: MIT # project('unity', 'c', - license: 'MIT', - meson_version: '>=0.53.0', - default_options: ['werror=true', 'c_std=c11'] -) + meson_version: '>=0.62.0', + default_options: ['werror=true', 'c_std=c11']) subdir('src') unity_dep = declare_dependency(link_with: unity_lib, include_directories: unity_dir) From 91d16179b537023bd766ed45a2ecee13adc08bfa Mon Sep 17 00:00:00 2001 From: Michael Gene Brockus <55331536+troglobyte-coder@users.noreply.github.com> Date: Sun, 19 Jun 2022 06:34:23 -0700 Subject: [PATCH 325/454] Update meson.build --- src/meson.build | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/meson.build b/src/meson.build index 1c7b426f..c165afed 100644 --- a/src/meson.build +++ b/src/meson.build @@ -1,11 +1,11 @@ # -# build script written by : Michael Brockus. +# build script written by : Michael Gene Brockus. # github repo author: Mike Karlesky, Mark VanderVoord, Greg Williams. # # license: MIT # unity_dir = include_directories('.') -unity_lib = static_library(meson.project_name(), - files('unity.c'), +unity_lib = static_library(meson.project_name(), + 'unity.c', include_directories: unity_dir) From b7b65737e8dcc5a94f3def87d3b01a6bd019184f Mon Sep 17 00:00:00 2001 From: Michael Gene Brockus <55331536+troglobyte-coder@users.noreply.github.com> Date: Sun, 19 Jun 2022 06:35:43 -0700 Subject: [PATCH 326/454] Update meson.build --- examples/example_4/meson.build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/example_4/meson.build b/examples/example_4/meson.build index f06c3fe3..862e2319 100644 --- a/examples/example_4/meson.build +++ b/examples/example_4/meson.build @@ -6,7 +6,7 @@ # project('example-4', 'c') -unity_dep = dependency('unity', fallback : ['unity', 'unity_dep']) +unity_dep = dependency('unity') subdir('src') subdir('test') From 193f130aedefcd51a974da96e26bd7fea7ecd5d4 Mon Sep 17 00:00:00 2001 From: Michael Gene Brockus <55331536+troglobyte-coder@users.noreply.github.com> Date: Sun, 19 Jun 2022 06:36:25 -0700 Subject: [PATCH 327/454] Update unity.wrap --- examples/example_4/subprojects/unity.wrap | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/examples/example_4/subprojects/unity.wrap b/examples/example_4/subprojects/unity.wrap index f2e54c84..8688475d 100755 --- a/examples/example_4/subprojects/unity.wrap +++ b/examples/example_4/subprojects/unity.wrap @@ -1,4 +1,6 @@ [wrap-git] -directory = unity url = https://github.com/ThrowTheSwitch/Unity.git revision = head + +[provide] +unity = unity_dep From ae10bd1268e20e6b12860780e164d452939a900f Mon Sep 17 00:00:00 2001 From: Eli Schwartz Date: Sun, 19 Jun 2022 13:40:24 -0400 Subject: [PATCH 328/454] examples: meson: do not use deprecated test naming style Tests cannot contain a ":", and configuring the example produced the following warning: test/test_runners/meson.build:12: DEPRECATION: ":" is not allowed in test name "Running: 01-test-case", it has been replaced with "_" test/test_runners/meson.build:13: DEPRECATION: ":" is not allowed in test name "Running: 02-test-case", it has been replaced with "_" In this case, the "running" part is redundant, so remove it. --- examples/example_4/test/test_runners/meson.build | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/example_4/test/test_runners/meson.build b/examples/example_4/test/test_runners/meson.build index f2a43c1b..1503c5f3 100644 --- a/examples/example_4/test/test_runners/meson.build +++ b/examples/example_4/test/test_runners/meson.build @@ -5,9 +5,9 @@ # license: MIT # cases = [ - ['TestProductionCode_Runner.c', join_paths('..' ,'TestProductionCode.c' )], + ['TestProductionCode_Runner.c', join_paths('..' ,'TestProductionCode.c' )], ['TestProductionCode2_Runner.c', join_paths('..' ,'TestProductionCode2.c')] ] -test('Running: 01-test-case', executable('01-test-case', cases[0], dependencies: [ a_dep, unity_dep ])) -test('Running: 02-test-case', executable('02-test-case', cases[1], dependencies: [ b_dep, unity_dep ])) +test('01-test-case', executable('01-test-case', cases[0], dependencies: [ a_dep, unity_dep ])) +test('02-test-case', executable('02-test-case', cases[1], dependencies: [ b_dep, unity_dep ])) From 0129cf5b11c111f389f59677aec01766086856ee Mon Sep 17 00:00:00 2001 From: Eli Schwartz Date: Sun, 19 Jun 2022 13:41:58 -0400 Subject: [PATCH 329/454] meson: specify correct minimum versions of Meson The main project doesn't really have any specific version requirement. Specify a very low one just in case -- 0.37.0 is old enough to cover probably any existing use of Meson anywhere in the wild, and coincidentally is also the version that Meson started adding feature warnings for, to notify you if you use too-new features. The example *does* depend on a specific version. It needs 0.55.0 in order to use subproject wrap dependency fallback instead of the legacy style of specifying the name of the variable as a fallback. Ensure that is used. --- examples/example_4/meson.build | 2 +- meson.build | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/example_4/meson.build b/examples/example_4/meson.build index 862e2319..b1c4e852 100644 --- a/examples/example_4/meson.build +++ b/examples/example_4/meson.build @@ -4,7 +4,7 @@ # # license: MIT # -project('example-4', 'c') +project('example-4', 'c', meson_version: '>= 0.55.0') unity_dep = dependency('unity') diff --git a/meson.build b/meson.build index 4b9f6e77..f5affb4b 100644 --- a/meson.build +++ b/meson.build @@ -5,7 +5,7 @@ # license: MIT # project('unity', 'c', - meson_version: '>=0.62.0', + meson_version: '>=0.37.0', default_options: ['werror=true', 'c_std=c11']) subdir('src') From 1b131552445e9eabcabc07c600fe7a3749ff7108 Mon Sep 17 00:00:00 2001 From: Eli Schwartz Date: Sun, 19 Jun 2022 13:49:52 -0400 Subject: [PATCH 330/454] meson: include the license info in the project definition This is useful to help convey the usage rights and e.g. generate a Software Bill of Materials. --- meson.build | 1 + 1 file changed, 1 insertion(+) diff --git a/meson.build b/meson.build index f5affb4b..ce99ae30 100644 --- a/meson.build +++ b/meson.build @@ -5,6 +5,7 @@ # license: MIT # project('unity', 'c', + license: 'MIT', meson_version: '>=0.37.0', default_options: ['werror=true', 'c_std=c11']) From ca7a1707c935513d98f18ed18f8fbb189cf9a9a7 Mon Sep 17 00:00:00 2001 From: trbenton Date: Tue, 21 Jun 2022 23:38:03 -0400 Subject: [PATCH 331/454] Formatting: Replace a stray tab with spaces --- src/unity.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/unity.c b/src/unity.c index b9a5ed71..14d5cdab 100644 --- a/src/unity.c +++ b/src/unity.c @@ -2048,7 +2048,7 @@ void UnityDefaultTestRun(UnityTestFunction Func, const char* FuncName, const int /*-----------------------------------------------*/ void UnitySetTestFile(const char* filename) { - Unity.TestFile = filename; + Unity.TestFile = filename; } /*-----------------------------------------------*/ From 062e44ebc5ee1e7a8b2ff3a53fc999f165c88ea5 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Mon, 27 Jun 2022 17:20:22 +0000 Subject: [PATCH 332/454] Provide custom build configuration for the PlatformIO --- library.json | 5 ++++- platformio-build.py | 17 +++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 platformio-build.py diff --git a/library.json b/library.json index 26a1e813..b5712943 100644 --- a/library.json +++ b/library.json @@ -11,5 +11,8 @@ }, "frameworks": "*", "platforms": "*", - "headers": "unity.h" + "headers": "unity.h", + "build": { + "extraScript": "platformio-build.py" + } } diff --git a/platformio-build.py b/platformio-build.py new file mode 100644 index 00000000..66fea42f --- /dev/null +++ b/platformio-build.py @@ -0,0 +1,17 @@ +import os + +Import("env") + +env.Append(CPPDEFINES=["UNITY_INCLUDE_CONFIG_H"]) + +# import "unity_config.h" folder to the library builder +try: + Import("projenv") + + projenv.Append(CPPDEFINES=["UNITY_INCLUDE_CONFIG_H"]) + for p in projenv["CPPPATH"]: + p = projenv.subst(p) + if os.path.isfile(os.path.join(p, "unity_config.h")): + env.Prepend(CPPPATH=[p]) +except: + pass From 612aec09e8896810e4ec7ae94b289262817447d5 Mon Sep 17 00:00:00 2001 From: "jonath.re@gmail.com" Date: Wed, 27 Jul 2022 02:39:14 +0200 Subject: [PATCH 333/454] Support long and long long types in TEST_PRINTF This change helps Unity parse and print correctly in cases where a long or long long type is passed to TEST_PRINTF. Example situations: ```C // With %u: TEST_PRINTF("%u %d\n", ((1ULL << 63) - 1), 5); // --> prints 11982546 -1 (both arguments incorrect because only 4 of the 8 bytes were read out of the va_list) // With %llu, UNITY_SUPPORT_64=0 TEST_PRINTF("%llu %d\n", ((1ULL << 63) - 1), 5); // --> prints 4294967295 5 (first argument wrapped, second argument intact) // With %llu, UNITY_SUPPORT_64=1 TEST_PRINTF("%llu %d\n", ((1ULL << 63) - 1), 5); // --> prints 9223372036854775807 5 (both arguments correct) ``` --- docs/UnityConfigurationGuide.md | 12 +++- src/unity.c | 113 ++++++++++++++++++++++++++++++-- 2 files changed, 118 insertions(+), 7 deletions(-) diff --git a/docs/UnityConfigurationGuide.md b/docs/UnityConfigurationGuide.md index 9ac0cdd6..7a0fa4c5 100644 --- a/docs/UnityConfigurationGuide.md +++ b/docs/UnityConfigurationGuide.md @@ -240,7 +240,7 @@ _Example:_ Unity provides a simple (and very basic) printf-like string output implementation, which is able to print a string modified by the following format string modifiers: - __%d__ - signed value (decimal) -- __%i__ - same as __%i__ +- __%i__ - same as __%d__ - __%u__ - unsigned value (decimal) - __%f__ - float/Double (if float support is activated) - __%g__ - same as __%f__ @@ -252,6 +252,15 @@ Unity provides a simple (and very basic) printf-like string output implementatio - __%s__ - a string (e.g. "string") - __%%__ - The "%" symbol (escaped) +Length specifiers are also supported. If you are using long long types, make sure UNITY_SUPPORT_64 is true to ensure they are printed correctly. + +- __%ld__ - signed long value (decimal) +- __%lld__ - signed long long value (decimal) +- __%lu__ - unsigned long value (decimal) +- __%llu__ - unsigned long long value (decimal) +- __%lx__ - unsigned long value (hexadecimal) +- __%llx__ - unsigned long long value (hexadecimal) + _Example:_ ```C @@ -267,6 +276,7 @@ TEST_PRINTF("Pointer %p\n", &a); TEST_PRINTF("Character %c\n", 'F'); TEST_PRINTF("String %s\n", "My string"); TEST_PRINTF("Percent %%\n"); +TEST_PRINTF("Unsigned long long %llu\n", 922337203685477580); TEST_PRINTF("Color Red \033[41mFAIL\033[0m\n"); TEST_PRINTF("\n"); TEST_PRINTF("Multiple (%d) (%i) (%u) (%x)\n", -100, 0, 200, 0x12345); diff --git a/src/unity.c b/src/unity.c index 14d5cdab..dfab4b40 100644 --- a/src/unity.c +++ b/src/unity.c @@ -1823,10 +1823,96 @@ UNITY_INTERNAL_PTR UnityDoubleToPtr(const double num) } #endif +#ifdef UNITY_INCLUDE_PRINT_FORMATTED + +/*----------------------------------------------- + * printf length modifier helpers + *-----------------------------------------------*/ + +enum UnityLengthModifier { + UNITY_LENGTH_MODIFIER_NONE, + UNITY_LENGTH_MODIFIER_LONG_LONG, + UNITY_LENGTH_MODIFIER_LONG, +}; + +#define UNITY_EXTRACT_ARG(NUMBER_T, NUMBER, LENGTH_MOD, VA, ARG_T) \ +do { \ + switch (LENGTH_MOD) \ + { \ + case UNITY_LENGTH_MODIFIER_LONG_LONG: \ + { \ + NUMBER = (NUMBER_T)va_arg(VA, long long ARG_T); \ + break; \ + } \ + case UNITY_LENGTH_MODIFIER_LONG: \ + { \ + NUMBER = (NUMBER_T)va_arg(VA, long ARG_T); \ + break; \ + } \ + case UNITY_LENGTH_MODIFIER_NONE: \ + default: \ + { \ + NUMBER = (NUMBER_T)va_arg(VA, ARG_T); \ + break; \ + } \ + } \ +} while (0) + +static enum UnityLengthModifier UnityLengthModifierGet(const char *pch, int *length) +{ + enum UnityLengthModifier length_mod; + switch (pch[0]) + { + case 'l': + { + if (pch[1] == 'l') + { + *length = 2; + length_mod = UNITY_LENGTH_MODIFIER_LONG_LONG; + } + else + { + *length = 1; + length_mod = UNITY_LENGTH_MODIFIER_LONG; + } + break; + } + case 'h': + { + // short and char are converted to int + length_mod = UNITY_LENGTH_MODIFIER_NONE; + if (pch[1] == 'h') + { + *length = 2; + } + else + { + *length = 1; + } + break; + } + case 'j': + case 'z': + case 't': + case 'L': + { + // Not supported, but should gobble up the length specifier anyway + length_mod = UNITY_LENGTH_MODIFIER_NONE; + *length = 1; + break; + } + default: + { + length_mod = UNITY_LENGTH_MODIFIER_NONE; + *length = 0; + } + } + return length_mod; +} + /*----------------------------------------------- * printf helper function *-----------------------------------------------*/ -#ifdef UNITY_INCLUDE_PRINT_FORMATTED static void UnityPrintFVA(const char* format, va_list va) { const char* pch = format; @@ -1841,12 +1927,17 @@ static void UnityPrintFVA(const char* format, va_list va) if (pch != NULL) { + int length_mod_size; + enum UnityLengthModifier length_mod = UnityLengthModifierGet(pch, &length_mod_size); + pch += length_mod_size; + switch (*pch) { case 'd': case 'i': { - const int number = va_arg(va, int); + UNITY_INT number; + UNITY_EXTRACT_ARG(UNITY_INT, number, length_mod, va, int); UnityPrintNumber((UNITY_INT)number); break; } @@ -1861,21 +1952,31 @@ static void UnityPrintFVA(const char* format, va_list va) #endif case 'u': { - const unsigned int number = va_arg(va, unsigned int); - UnityPrintNumberUnsigned((UNITY_UINT)number); + UNITY_UINT number; + UNITY_EXTRACT_ARG(UNITY_UINT, number, length_mod, va, unsigned int); + UnityPrintNumberUnsigned(number); break; } case 'b': { - const unsigned int number = va_arg(va, unsigned int); + UNITY_UINT number; + UNITY_EXTRACT_ARG(UNITY_UINT, number, length_mod, va, unsigned int); const UNITY_UINT mask = (UNITY_UINT)0 - (UNITY_UINT)1; UNITY_OUTPUT_CHAR('0'); UNITY_OUTPUT_CHAR('b'); - UnityPrintMask(mask, (UNITY_UINT)number); + UnityPrintMask(mask, number); break; } case 'x': case 'X': + { + UNITY_UINT number; + UNITY_EXTRACT_ARG(UNITY_UINT, number, length_mod, va, unsigned int); + UNITY_OUTPUT_CHAR('0'); + UNITY_OUTPUT_CHAR('x'); + UnityPrintNumberHex(number, 8); + break; + } case 'p': { const unsigned int number = va_arg(va, unsigned int); From f62ff65f9b6f6eeb9aec89b1fdd21e43f8bcc185 Mon Sep 17 00:00:00 2001 From: RodrigoDornelles Date: Fri, 2 Sep 2022 15:28:40 -0300 Subject: [PATCH 334/454] fix: add cmake outputs in .gitignore --- .gitignore | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.gitignore b/.gitignore index e4bb017b..c2febeb6 100644 --- a/.gitignore +++ b/.gitignore @@ -11,3 +11,7 @@ examples/example_2/all_tests.out examples/example_4/builddir *.sublime-project *.sublime-workspace +*.cmake +Makefile +CMakeFiles +CMakeCache.txt From 30046e664e5c2c57bdeba8e67f2c1edce1fbf6b5 Mon Sep 17 00:00:00 2001 From: RodrigoDornelles Date: Fri, 2 Sep 2022 16:03:55 -0300 Subject: [PATCH 335/454] remove unityConfig.cmake from .gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index c2febeb6..7500c746 100644 --- a/.gitignore +++ b/.gitignore @@ -15,3 +15,4 @@ examples/example_4/builddir Makefile CMakeFiles CMakeCache.txt +!unityConfig.cmake From fc5b33ce7103402ad6e2b8b9230f1f430a6679aa Mon Sep 17 00:00:00 2001 From: Noah Knegt Date: Thu, 13 Oct 2022 15:36:10 +0200 Subject: [PATCH 336/454] Fix compiling native when main project is cross-compiling --- src/meson.build | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/meson.build b/src/meson.build index c165afed..fbe4b5bb 100644 --- a/src/meson.build +++ b/src/meson.build @@ -8,4 +8,6 @@ unity_dir = include_directories('.') unity_lib = static_library(meson.project_name(), 'unity.c', - include_directories: unity_dir) + include_directories: unity_dir, + native: true +) From 76b7e359ccaeca0ee62a93a589c0cddb7d3c8ad0 Mon Sep 17 00:00:00 2001 From: Erik Flodin Date: Thu, 13 Oct 2022 22:13:03 +0200 Subject: [PATCH 337/454] Improve handling of space in TEST_CASE/RANGE The fix in 285bb6e282 didn't completly fix the issue. --- auto/generate_test_runner.rb | 11 ++++++++--- test/tests/test_unity_parameterized.c | 25 +++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 3 deletions(-) diff --git a/auto/generate_test_runner.rb b/auto/generate_test_runner.rb index e63f0a2a..3af827a8 100644 --- a/auto/generate_test_runner.rb +++ b/auto/generate_test_runner.rb @@ -140,10 +140,15 @@ def find_tests(source) if @options[:use_param_tests] && !arguments.empty? args = [] - arguments.scan(/\s*TEST_CASE\s*\(\s*(.*)\s*\)\s*$/) { |a| args << a[0] } + type_and_args = arguments.split(/TEST_(CASE|RANGE)/) + for i in (1...type_and_args.length).step(2) + if type_and_args[i] == "CASE" + args << type_and_args[i + 1].sub(/^\s*\(\s*(.*?)\s*\)\s*$/m, '\1') + next + end - arguments.scan(/\s*TEST_RANGE\s*\((.*)\)\s*$/).flatten.each do |range_str| - args += range_str.scan(/\[\s*(-?\d+.?\d*),\s*(-?\d+.?\d*),\s*(-?\d+.?\d*)\s*\]/).map do |arg_values_str| + # RANGE + args += type_and_args[i + 1].scan(/\[\s*(-?\d+.?\d*)\s*,\s*(-?\d+.?\d*)\s*,\s*(-?\d+.?\d*)\s*\]/m).map do |arg_values_str| arg_values_str.map do |arg_value_str| arg_value_str.include?('.') ? arg_value_str.to_f : arg_value_str.to_i end diff --git a/test/tests/test_unity_parameterized.c b/test/tests/test_unity_parameterized.c index 3129817e..0b95cfc9 100644 --- a/test/tests/test_unity_parameterized.c +++ b/test/tests/test_unity_parameterized.c @@ -10,6 +10,7 @@ /* Support for Meta Test Rig */ #define TEST_CASE(...) +#define TEST_RANGE(...) /* Include Passthroughs for Linking Tests */ void putcharSpy(int c) { (void)putchar(c);} @@ -48,11 +49,13 @@ static int SetToOneToFailInTearDown; static int SetToOneMeanWeAlreadyCheckedThisGuy; static unsigned NextExpectedStringIndex; static unsigned NextExpectedCharIndex; +static unsigned NextExpectedSpaceIndex; void suiteSetUp(void) { NextExpectedStringIndex = 0; NextExpectedCharIndex = 0; + NextExpectedSpaceIndex = 0; } void setUp(void) @@ -169,3 +172,25 @@ void test_CharsArePreserved(unsigned index, char c) NextExpectedCharIndex++; } + +TEST_CASE(0, + + 1) +TEST_CASE(1, + + 2 + + ) +TEST_RANGE([2, + 5 , + 1], [6, 6, 1]) +TEST_CASE( + + 6 , 7) +void test_SpaceInTestCase(unsigned index, unsigned bigger) +{ + TEST_ASSERT_EQUAL_UINT32(NextExpectedSpaceIndex, index); + TEST_ASSERT_LESS_THAN(bigger, index); + + NextExpectedSpaceIndex++; +} From 563786f97c6825c23924f8b971fe0fe5aafb47fb Mon Sep 17 00:00:00 2001 From: Erik Flodin Date: Fri, 16 Apr 2021 12:02:15 +0200 Subject: [PATCH 338/454] Add support for TEST_RANGE with exclusive end If the range is instead of [start, end, step], the end value will not be included in the range. This can be useful if you have a define that defines e.g. the size of something and you want to use this define as the end value. As the pre-processor doesn't evalutate expressions (unless you do some macro magic) you can't specify the range as [0, MY_SIZE - 1, 1]. With this change you can then instead give the range <0, MY_SIZE, 1>. --- auto/generate_test_runner.rb | 9 +++++---- src/unity.h | 2 +- test/tests/test_unity_parameterized.c | 26 ++++++++++++++++++++++++++ 3 files changed, 32 insertions(+), 5 deletions(-) diff --git a/auto/generate_test_runner.rb b/auto/generate_test_runner.rb index 3af827a8..cd22be38 100644 --- a/auto/generate_test_runner.rb +++ b/auto/generate_test_runner.rb @@ -148,12 +148,13 @@ def find_tests(source) end # RANGE - args += type_and_args[i + 1].scan(/\[\s*(-?\d+.?\d*)\s*,\s*(-?\d+.?\d*)\s*,\s*(-?\d+.?\d*)\s*\]/m).map do |arg_values_str| - arg_values_str.map do |arg_value_str| + args += type_and_args[i + 1].scan(/(\[|<)\s*(-?\d+.?\d*)\s*,\s*(-?\d+.?\d*)\s*,\s*(-?\d+.?\d*)\s*(\]|>)/m).map do |arg_values_str| + exclude_end = arg_values_str[0] == '<' && arg_values_str[-1] == '>' + arg_values_str[1...-1].map do |arg_value_str| arg_value_str.include?('.') ? arg_value_str.to_f : arg_value_str.to_i - end + end.push(exclude_end) end.map do |arg_values| - (arg_values[0]..arg_values[1]).step(arg_values[2]).to_a + Range.new(arg_values[0], arg_values[1], arg_values[3]).step(arg_values[2]).to_a end.reduce(nil) do |result, arg_range_expanded| result.nil? ? arg_range_expanded.map { |a| [a] } : result.product(arg_range_expanded) end.map do |arg_combinations| diff --git a/src/unity.h b/src/unity.h index f33448a1..868dc237 100644 --- a/src/unity.h +++ b/src/unity.h @@ -89,7 +89,7 @@ void verifyTest(void); * - define UNITY_SUPPORT_TEST_CASES to include the TEST_CASE macro, though really it's mostly about the runner generator script * Parameterized Tests - * - you'll want to create a define of TEST_CASE(...) which basically evaluates to nothing + * - you'll want to create a define of TEST_CASE(...) and/or TEST_RANGE(...) which basically evaluates to nothing * Tests with Arguments * - you'll want to define UNITY_USE_COMMAND_LINE_ARGS if you have the test runner passing arguments to Unity diff --git a/test/tests/test_unity_parameterized.c b/test/tests/test_unity_parameterized.c index 0b95cfc9..5d20826e 100644 --- a/test/tests/test_unity_parameterized.c +++ b/test/tests/test_unity_parameterized.c @@ -173,6 +173,32 @@ void test_CharsArePreserved(unsigned index, char c) NextExpectedCharIndex++; } +TEST_RANGE([0, 10, 2]) +void test_SingleRange(unsigned value) +{ + TEST_ASSERT_EQUAL(0, value % 2); + TEST_ASSERT_LESS_OR_EQUAL(10, value); +} + +TEST_RANGE([1, 2, 1], [2, 1, -1]) +void test_TwoRanges(unsigned first, unsigned second) +{ + TEST_ASSERT_LESS_OR_EQUAL(4, first * second); +} + +TEST_RANGE(<0, 10, 2>) +void test_SingleExclusiveRange(unsigned value) +{ + TEST_ASSERT_EQUAL(0, value % 2); + TEST_ASSERT_LESS_THAN(10, value); +} + +TEST_RANGE([2, 4, 1], <1, 2, 1>) +void test_BothInclusiveAndExclusiveRange(unsigned first, unsigned second) +{ + TEST_ASSERT_LESS_THAN(first, second); +} + TEST_CASE(0, 1) From 4d5ed3d68b0971689ba3ff045aacdadb4a42345e Mon Sep 17 00:00:00 2001 From: Alex Overchenko Date: Sun, 27 Nov 2022 13:05:13 +0300 Subject: [PATCH 339/454] Adding possibility for automatically defining TEST_CASE & TEST_RANGE macros --- docs/UnityConfigurationGuide.md | 24 ++++++++++++++++++++++++ src/unity_internals.h | 26 +++++++++++++++++++++----- test/tests/test_unity_parameterized.c | 6 ++---- 3 files changed, 47 insertions(+), 9 deletions(-) diff --git a/docs/UnityConfigurationGuide.md b/docs/UnityConfigurationGuide.md index 7a0fa4c5..f24e6a02 100644 --- a/docs/UnityConfigurationGuide.md +++ b/docs/UnityConfigurationGuide.md @@ -438,6 +438,30 @@ This will rarely be necessary. Most often, Unity will automatically detect if th In the event that the compiler supports variadic macros, but is primarily C89 (ANSI), defining this option will allow you to use them. This option is also not necessary when using Ceedling or the test runner generator script. +#### `UNITY_INCLUDE_PARAM_TESTING_MACRO` + +Unity can automatically define all supported parameterized tests macros. +To enable that feature, use the following example: + +```C +#define UNITY_INCLUDE_PARAM_TESTING_MACRO +``` + +You can manually provide required `TEST_CASE` or `TEST_RANGE` macro definitions +before including `unity.h`, and they won't be redefined. +If you provide one of the following macros, some of default definitions will not be +defined: +| User defines macro | Unity will __not__ define following macro | +|---|---| +| `UNITY_NOT_DEFINE_TEST_CASE` | `TEST_CASE` | +| `UNITY_NOT_DEFINE_TEST_RANGE` | `TEST_RANGE` | +| `TEST_CASE` | `TEST_CASE` | +| `TEST_RANGE` | `TEST_RANGE` | + +_Note:_ +That feature requires variadic macro support by compiler. If required feature +is not detected, it will not be enabled, even though preprocessor macro is defined. + ## Getting Into The Guts There will be cases where the options above aren't quite going to get everything perfect. diff --git a/src/unity_internals.h b/src/unity_internals.h index f2c312c2..bae842ed 100644 --- a/src/unity_internals.h +++ b/src/unity_internals.h @@ -765,19 +765,35 @@ extern const char UnityStrErrShorthand[]; #define TEST_ABORT() return #endif +/* Automatically enable variadic macros support, if it not enabled before */ +#ifndef UNITY_SUPPORT_VARIADIC_MACROS + #ifdef __STDC_VERSION__ + #if __STDC_VERSION__ >= 199901L + #define UNITY_SUPPORT_VARIADIC_MACROS + #endif + #endif +#endif + /* This tricky series of macros gives us an optional line argument to treat it as RUN_TEST(func, num=__LINE__) */ #ifndef RUN_TEST -#ifdef __STDC_VERSION__ -#if __STDC_VERSION__ >= 199901L -#define UNITY_SUPPORT_VARIADIC_MACROS -#endif -#endif #ifdef UNITY_SUPPORT_VARIADIC_MACROS #define RUN_TEST(...) RUN_TEST_AT_LINE(__VA_ARGS__, __LINE__, throwaway) #define RUN_TEST_AT_LINE(func, line, ...) UnityDefaultTestRun(func, #func, line) #endif #endif +/* Enable default macros for masking param tests test cases */ +#ifdef UNITY_INCLUDE_PARAM_TESTING_MACRO + #ifdef UNITY_SUPPORT_VARIADIC_MACROS + #if !defined(TEST_CASE) && !defined(UNITY_NOT_DEFINE_TEST_CASE) + #define TEST_CASE(...) + #endif + #if !defined(TEST_RANGE) && !defined(UNITY_NOT_DEFINE_TEST_RANGE) + #define TEST_RANGE(...) + #endif + #endif +#endif + /* If we can't do the tricky version, we'll just have to require them to always include the line number */ #ifndef RUN_TEST #ifdef CMOCK diff --git a/test/tests/test_unity_parameterized.c b/test/tests/test_unity_parameterized.c index 5d20826e..a393a0a7 100644 --- a/test/tests/test_unity_parameterized.c +++ b/test/tests/test_unity_parameterized.c @@ -4,14 +4,12 @@ [Released under MIT License. Please refer to license.txt for details] ========================================== */ +#define UNITY_INCLUDE_PARAM_TESTING_MACRO + #include #include #include "unity.h" -/* Support for Meta Test Rig */ -#define TEST_CASE(...) -#define TEST_RANGE(...) - /* Include Passthroughs for Linking Tests */ void putcharSpy(int c) { (void)putchar(c);} void flushSpy(void) {} From cef22753c410b940016e779cf7a625d678b24136 Mon Sep 17 00:00:00 2001 From: Alex Overchenko Date: Sun, 27 Nov 2022 14:20:03 +0300 Subject: [PATCH 340/454] Adding param tests documentation. Describe TEST_CASE logic. --- docs/UnityHelperScriptsGuide.md | 60 +++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) diff --git a/docs/UnityHelperScriptsGuide.md b/docs/UnityHelperScriptsGuide.md index b430c415..c31baa40 100644 --- a/docs/UnityHelperScriptsGuide.md +++ b/docs/UnityHelperScriptsGuide.md @@ -179,6 +179,66 @@ This option specifies the pattern for matching acceptable source file extensions By default it will accept cpp, cc, C, c, and ino files. If you need a different combination of files to search, update this from the default `'(?:cpp|cc|ino|C|c)'`. +##### `:use_param_tests` + +This option enables parameterized test usage. +That tests accepts arguments from `TEST_CASE` and `TEST_RANGE` macros, +that are located above current test definition. +By default, Unity assumes, that parameterized tests are disabled. + +Few usage examples can be found in `/test/tests/test_unity_parameterized.c` file. + +You should define `UNITY_SUPPORT_TEST_CASES` macro for tests success compiling, +if you enable current option. + +You can see list of supported macros list in the next section. + +#### Parameterized tests provided macros + +Unity provides support for few param tests generators, that can be combined +with each other. You must define test function as usual C function with usual +C arguments, and test generator will pass what you tell as a list of arguments. + +Let's show how all of them works on the following test function definitions: + +```C +/* Place your test generators here, usually one generator per one or few lines */ +void test_demoParamFunction(int a, int b, int c) +{ + TEST_ASSERT_GREATER_THAN_INT(a + b, c); +} +``` + +##### `TEST_CASE` + +Test case is a basic generator, that can be used for param testing. +One call of that macro will generate only one call for test function. +It can be used with different args, such as numbers, enums, strings, +global variables, another preprocessor defines. + +If we use replace comment before test function with the following code: + +```C +TEST_CASE(1, 2, 5) +TEST_CASE(3, 7, 20) +``` + +script will generate 2 test calls: + +```C +test_demoParamFunction(1, 2, 5); +test_demoParamFunction(3, 7, 20); +``` + +That calls will be wrapped with `setUp`, `tearDown` and other +usual Unity calls, as an independent unit tests. +The following output can be generated after test executable startup: + +```Log +tests/test_unity_parameterized.c:9:test_demoParamFunction(1, 2, 5):PASS +tests/test_unity_parameterized.c:9:test_demoParamFunction(3, 7, 20):PASS +``` + ### `unity_test_summary.rb` A Unity test file contains one or more test case functions. From e4085eb8e669e227e8d1e8a4700830e2052df599 Mon Sep 17 00:00:00 2001 From: Alex Overchenko Date: Sun, 27 Nov 2022 14:36:22 +0300 Subject: [PATCH 341/454] Using default macro for TEST_CASEs define. Improving docs about manual definition. --- docs/UnityConfigurationGuide.md | 18 ++++++++++++------ src/unity_internals.h | 6 +++--- test/tests/test_unity_parameterized.c | 2 -- 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/docs/UnityConfigurationGuide.md b/docs/UnityConfigurationGuide.md index f24e6a02..d5e4098f 100644 --- a/docs/UnityConfigurationGuide.md +++ b/docs/UnityConfigurationGuide.md @@ -438,26 +438,32 @@ This will rarely be necessary. Most often, Unity will automatically detect if th In the event that the compiler supports variadic macros, but is primarily C89 (ANSI), defining this option will allow you to use them. This option is also not necessary when using Ceedling or the test runner generator script. -#### `UNITY_INCLUDE_PARAM_TESTING_MACRO` +#### `UNITY_SUPPORT_TEST_CASES` Unity can automatically define all supported parameterized tests macros. -To enable that feature, use the following example: +That feature is disabled by default. +To enable it, use the following example: ```C -#define UNITY_INCLUDE_PARAM_TESTING_MACRO +#define UNITY_SUPPORT_TEST_CASES ``` You can manually provide required `TEST_CASE` or `TEST_RANGE` macro definitions before including `unity.h`, and they won't be redefined. If you provide one of the following macros, some of default definitions will not be defined: -| User defines macro | Unity will __not__ define following macro | +| User defines macro | Unity will _not_ define following macro | |---|---| -| `UNITY_NOT_DEFINE_TEST_CASE` | `TEST_CASE` | -| `UNITY_NOT_DEFINE_TEST_RANGE` | `TEST_RANGE` | +| `UNITY_EXCLUDE_TEST_CASE` | `TEST_CASE` | +| `UNITY_EXCLUDE_TEST_RANGE` | `TEST_RANGE` | | `TEST_CASE` | `TEST_CASE` | | `TEST_RANGE` | `TEST_RANGE` | +`UNITY_EXCLUDE_TEST_*` defines is not processed by test runner generator script. +If you exclude one of them from definition, you should provide your own definition +for them or avoid using undefined `TEST_*` macro as a test generator. +Otherwise, compiler cannot build source code file with provided call. + _Note:_ That feature requires variadic macro support by compiler. If required feature is not detected, it will not be enabled, even though preprocessor macro is defined. diff --git a/src/unity_internals.h b/src/unity_internals.h index bae842ed..641c1b3b 100644 --- a/src/unity_internals.h +++ b/src/unity_internals.h @@ -783,12 +783,12 @@ extern const char UnityStrErrShorthand[]; #endif /* Enable default macros for masking param tests test cases */ -#ifdef UNITY_INCLUDE_PARAM_TESTING_MACRO +#ifdef UNITY_SUPPORT_TEST_CASES #ifdef UNITY_SUPPORT_VARIADIC_MACROS - #if !defined(TEST_CASE) && !defined(UNITY_NOT_DEFINE_TEST_CASE) + #if !defined(TEST_CASE) && !defined(UNITY_EXCLUDE_TEST_CASE) #define TEST_CASE(...) #endif - #if !defined(TEST_RANGE) && !defined(UNITY_NOT_DEFINE_TEST_RANGE) + #if !defined(TEST_RANGE) && !defined(UNITY_EXCLUDE_TEST_RANGE) #define TEST_RANGE(...) #endif #endif diff --git a/test/tests/test_unity_parameterized.c b/test/tests/test_unity_parameterized.c index a393a0a7..6b8aeb79 100644 --- a/test/tests/test_unity_parameterized.c +++ b/test/tests/test_unity_parameterized.c @@ -4,8 +4,6 @@ [Released under MIT License. Please refer to license.txt for details] ========================================== */ -#define UNITY_INCLUDE_PARAM_TESTING_MACRO - #include #include #include "unity.h" From 48d7210644842b4e25b735dedd4927e2de26a924 Mon Sep 17 00:00:00 2001 From: Alex Overchenko Date: Sun, 27 Nov 2022 14:46:34 +0300 Subject: [PATCH 342/454] Fixing CI tests passing --- test/testdata/testRunnerGenerator.c | 3 --- test/testdata/testRunnerGeneratorSmall.c | 4 ---- test/testdata/testRunnerGeneratorWithMocks.c | 4 ---- 3 files changed, 11 deletions(-) diff --git a/test/testdata/testRunnerGenerator.c b/test/testdata/testRunnerGenerator.c index b5dd97f5..3ea01a17 100644 --- a/test/testdata/testRunnerGenerator.c +++ b/test/testdata/testRunnerGenerator.c @@ -19,9 +19,6 @@ suitetest- custom prefix for when we want to use custom suite setup/teardown */ -/* Support for Meta Test Rig */ -#define TEST_CASE(a) - /* Include Passthroughs for Linking Tests */ void putcharSpy(int c) { (void)putchar(c);} void flushSpy(void) {} diff --git a/test/testdata/testRunnerGeneratorSmall.c b/test/testdata/testRunnerGeneratorSmall.c index c8aaf747..dc687ba2 100644 --- a/test/testdata/testRunnerGeneratorSmall.c +++ b/test/testdata/testRunnerGeneratorSmall.c @@ -11,9 +11,6 @@ TEST_FILE("some_file.c") spec - normal default prefix. required to run default setup/teardown calls. */ -/* Support for Meta Test Rig */ -#define TEST_CASE(a) - /* Include Passthroughs for Linking Tests */ void putcharSpy(int c) { (void)putchar(c);} void flushSpy(void) {} @@ -67,4 +64,3 @@ void spec_ThisTestPassesWhenNormalTeardownRan(void) { TEST_ASSERT_EQUAL_MESSAGE(1, CounterTeardown, "Normal Teardown Wasn't Run"); } - diff --git a/test/testdata/testRunnerGeneratorWithMocks.c b/test/testdata/testRunnerGeneratorWithMocks.c index aaceda44..d48692ed 100644 --- a/test/testdata/testRunnerGeneratorWithMocks.c +++ b/test/testdata/testRunnerGeneratorWithMocks.c @@ -20,9 +20,6 @@ suitetest- custom prefix for when we want to use custom suite setup/teardown */ -/* Support for Meta Test Rig */ -#define TEST_CASE(a) - /* Include Passthroughs for Linking Tests */ void putcharSpy(int c) { (void)putchar(c);} void flushSpy(void) {} @@ -194,4 +191,3 @@ void test_ShouldCallMockInitAndVerifyFunctionsForEachTest(void) TEST_ASSERT_EQUAL_MESSAGE(Unity.NumberOfTests - 1, mockMock_Destroy_Counter, "Mock Destroy Should Be Called Once Per Test Completed"); TEST_ASSERT_EQUAL_MESSAGE(0, CMockMemFreeFinalCounter, "Mock MemFreeFinal Should Not Be Called Until End"); } - From ad86e15ca5e448628df2bf01ae30398857640c08 Mon Sep 17 00:00:00 2001 From: Alex Overchenko Date: Sun, 27 Nov 2022 16:09:22 +0300 Subject: [PATCH 343/454] Adding docs to TEST_RANGE formats. Adding parameterizedDemo tests as an independent file --- docs/UnityHelperScriptsGuide.md | 65 +++++++++++++++++++++-- test/tests/test_unity_parameterizedDemo.c | 17 ++++++ 2 files changed, 78 insertions(+), 4 deletions(-) create mode 100644 test/tests/test_unity_parameterizedDemo.c diff --git a/docs/UnityHelperScriptsGuide.md b/docs/UnityHelperScriptsGuide.md index c31baa40..06c34ea6 100644 --- a/docs/UnityHelperScriptsGuide.md +++ b/docs/UnityHelperScriptsGuide.md @@ -227,16 +227,73 @@ script will generate 2 test calls: ```C test_demoParamFunction(1, 2, 5); -test_demoParamFunction(3, 7, 20); +test_demoParamFunction(10, 7, 20); ``` That calls will be wrapped with `setUp`, `tearDown` and other -usual Unity calls, as an independent unit tests. +usual Unity calls, as for independent unit tests. The following output can be generated after test executable startup: ```Log -tests/test_unity_parameterized.c:9:test_demoParamFunction(1, 2, 5):PASS -tests/test_unity_parameterized.c:9:test_demoParamFunction(3, 7, 20):PASS +tests/test_unity_parameterizedDemo.c:14:test_demoParamFunction(1, 2, 5):PASS +tests/test_unity_parameterizedDemo.c:14:test_demoParamFunction(10, 7, 20):PASS +``` + +##### `TEST_RANGE` + +Test range is an advanced generator. It single call can be converted to zero, +one or few `TEST_CASE` equivalent commands. + +That generator can be used for creating numeric ranges in decimal representation +only: integers & floating point numbers. It uses few formats for every parameter: + +1. `[start, stop, step]` is stop-inclusive format +2. `` is stop-exclusive formats + +Format providers 1 and 2 accept only three arguments: + +* `start` is start number +* `stop` is end number (can or cannot exists in result sequence for format 1, +will be always skipped for format 2) +* `step` is incrementing step: can be either positive or negative value. + +Let's use our `test_demoParamFunction` test for checking, what ranges +will be generated for our single `TEST_RANGE` row: + +```C +TEST_RANGE([3, 4, 1], [10, 5, -2], <30, 31, 1>) +``` + +Tests execution output will be similar to that text: + +```Log +tests/test_unity_parameterizedDemo.c:14:test_demoParamFunction(3, 10, 30):PASS +tests/test_unity_parameterizedDemo.c:14:test_demoParamFunction(3, 8, 30):PASS +tests/test_unity_parameterizedDemo.c:14:test_demoParamFunction(3, 6, 30):PASS +tests/test_unity_parameterizedDemo.c:14:test_demoParamFunction(4, 10, 30):PASS +tests/test_unity_parameterizedDemo.c:14:test_demoParamFunction(4, 8, 30):PASS +tests/test_unity_parameterizedDemo.c:14:test_demoParamFunction(4, 6, 30):PASS +``` + +As we can see: + +| Parameter | Format | Possible values | Total of values | Format number | +|---|---|---|---|---| +| `a` | `[3, 4, 1]` | `3`, `4` | 2 | Format 1 | +| `b` | `[10, 5, -2]` | `10`, `8`, `6` | 3 | Format 1, negative step, end number is not included | +| `c` | `<30, 31, 1>` | `30` | 1 | Format 2 | + +_Note_, that format 2 also supports negative step. + +We totally have 2 * 3 * 1 = 6 equal test cases, that can be written as following: + +```C +TEST_CASE(3, 10, 30) +TEST_CASE(3, 8, 30) +TEST_CASE(3, 6, 30) +TEST_CASE(4, 10, 30) +TEST_CASE(4, 8, 30) +TEST_CASE(4, 6, 30) ``` ### `unity_test_summary.rb` diff --git a/test/tests/test_unity_parameterizedDemo.c b/test/tests/test_unity_parameterizedDemo.c new file mode 100644 index 00000000..2e2efc8f --- /dev/null +++ b/test/tests/test_unity_parameterizedDemo.c @@ -0,0 +1,17 @@ +#include "unity.h" + +/* Support for Meta Test Rig */ +#ifndef TEST_CASE +#define TEST_CASE(...) +#endif +#ifndef TEST_RANGE +#define TEST_RANGE(...) +#endif + +TEST_CASE(1, 2, 5) +TEST_CASE(10, 7, 20) +TEST_RANGE([3, 4, 1], [10, 5, -2], <30, 31, 1>) +void test_demoParamFunction(int a, int b, int c) +{ + TEST_ASSERT_GREATER_THAN_INT(a + b, c); +} From e15b9f7a28e62d32e1c4cf09cf24a9c9e6391817 Mon Sep 17 00:00:00 2001 From: Alex Overchenko Date: Mon, 28 Nov 2022 13:22:40 +0300 Subject: [PATCH 344/454] Fixing typo in assertion reference --- docs/UnityAssertionsReference.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/UnityAssertionsReference.md b/docs/UnityAssertionsReference.md index f1ef63df..ff3b5309 100644 --- a/docs/UnityAssertionsReference.md +++ b/docs/UnityAssertionsReference.md @@ -555,7 +555,7 @@ Asserts that the `actual` value is within +/- `delta` of the `expected` value. The nature of floating point representation is such that exact evaluations of equality are not guaranteed. -#### `TEST_ASSERT_FLOAT_WITHIN (delta, expected, actual)` +#### `TEST_ASSERT_FLOAT_NOT_WITHIN (delta, expected, actual)` Asserts that the `actual` value is NOT within +/- `delta` of the `expected` value. From 50146afb46b730a629ec4b1937177478c42a6cb9 Mon Sep 17 00:00:00 2001 From: Jeppe Pihl Date: Mon, 28 Nov 2022 13:15:55 +0100 Subject: [PATCH 345/454] Update unity.c --- src/unity.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/unity.c b/src/unity.c index dfab4b40..5786318c 100644 --- a/src/unity.c +++ b/src/unity.c @@ -5,7 +5,6 @@ ============================================================================ */ #include "unity.h" -#include #ifndef UNITY_PROGMEM #define UNITY_PROGMEM From 6567f07f477b844a357eb24d1845c95b4caca74e Mon Sep 17 00:00:00 2001 From: AJIOB Date: Mon, 28 Nov 2022 17:47:08 +0300 Subject: [PATCH 346/454] Adding possibility for setting relative & absolute floating difference --- src/unity.c | 57 +++++++++++++++++++++++-------------------- src/unity_internals.h | 34 ++++++++++++++------------ 2 files changed, 48 insertions(+), 43 deletions(-) diff --git a/src/unity.c b/src/unity.c index 5786318c..ff331d21 100644 --- a/src/unity.c +++ b/src/unity.c @@ -894,13 +894,14 @@ void UnityAssertEqualIntArray(UNITY_INTERNAL_PTR expected, /*-----------------------------------------------*/ #ifndef UNITY_EXCLUDE_FLOAT /* Wrap this define in a function with variable types as float or double */ -#define UNITY_FLOAT_OR_DOUBLE_WITHIN(delta, expected, actual, diff) \ +#define UNITY_FLOAT_OR_DOUBLE_WITHIN(delta0, delta1, expected, actual, diff) \ if (isinf(expected) && isinf(actual) && (((expected) < 0) == ((actual) < 0))) return 1; \ if (UNITY_NAN_CHECK) return 1; \ (diff) = (actual) - (expected); \ if ((diff) < 0) (diff) = -(diff); \ - if ((delta) < 0) (delta) = -(delta); \ - return !(isnan(diff) || isinf(diff) || ((diff) > (delta))) + if ((delta0) < 0) (delta0) = -(delta0); \ + if ((delta1) < 0) (delta1) = -(delta1); \ + return !(isnan(diff) || isinf(diff) || ((diff) > ((delta0) + (delta1)))) /* This first part of this condition will catch any NaN or Infinite values */ #ifndef UNITY_NAN_NOT_EQUAL_NAN #define UNITY_NAN_CHECK isnan(expected) && isnan(actual) @@ -922,19 +923,20 @@ void UnityAssertEqualIntArray(UNITY_INTERNAL_PTR expected, #endif /* UNITY_EXCLUDE_FLOAT_PRINT */ /*-----------------------------------------------*/ -static int UnityFloatsWithin(UNITY_FLOAT delta, UNITY_FLOAT expected, UNITY_FLOAT actual) +static int UnityFloatsWithin(UNITY_FLOAT delta0, UNITY_FLOAT delta1, UNITY_FLOAT expected, UNITY_FLOAT actual) { UNITY_FLOAT diff; - UNITY_FLOAT_OR_DOUBLE_WITHIN(delta, expected, actual, diff); + UNITY_FLOAT_OR_DOUBLE_WITHIN(delta0, delta1, expected, actual, diff); } /*-----------------------------------------------*/ -void UnityAssertEqualFloatArray(UNITY_PTR_ATTRIBUTE const UNITY_FLOAT* expected, - UNITY_PTR_ATTRIBUTE const UNITY_FLOAT* actual, - const UNITY_UINT32 num_elements, - const char* msg, - const UNITY_LINE_TYPE lineNumber, - const UNITY_FLAGS_T flags) +void UnityAssertWithinFloatArray(const UNITY_FLOAT delta, + UNITY_PTR_ATTRIBUTE const UNITY_FLOAT* expected, + UNITY_PTR_ATTRIBUTE const UNITY_FLOAT* actual, + const UNITY_UINT32 num_elements, + const char* msg, + const UNITY_LINE_TYPE lineNumber, + const UNITY_FLAGS_T flags) { UNITY_UINT32 elements = num_elements; UNITY_PTR_ATTRIBUTE const UNITY_FLOAT* ptr_expected = expected; @@ -963,7 +965,7 @@ void UnityAssertEqualFloatArray(UNITY_PTR_ATTRIBUTE const UNITY_FLOAT* expected, while (elements--) { - if (!UnityFloatsWithin(*ptr_expected * UNITY_FLOAT_PRECISION, *ptr_expected, *ptr_actual)) + if (!UnityFloatsWithin(delta, *ptr_expected * UNITY_FLOAT_PRECISION, *ptr_expected, *ptr_actual)) { UnityTestResultsFailBegin(lineNumber); UnityPrint(UnityStrElement); @@ -990,7 +992,7 @@ void UnityAssertFloatsWithin(const UNITY_FLOAT delta, RETURN_IF_FAIL_OR_IGNORE; - if (!UnityFloatsWithin(delta, expected, actual)) + if (!UnityFloatsWithin(delta, (UNITY_FLOAT)0, expected, actual)) { UnityTestResultsFailBegin(lineNumber); UNITY_PRINT_EXPECTED_AND_ACTUAL_FLOAT((UNITY_DOUBLE)expected, (UNITY_DOUBLE)actual); @@ -1008,7 +1010,7 @@ void UnityAssertFloatsNotWithin(const UNITY_FLOAT delta, { RETURN_IF_FAIL_OR_IGNORE; - if (UnityFloatsWithin(delta, expected, actual)) + if (UnityFloatsWithin(delta, (UNITY_FLOAT)0, expected, actual)) { UnityTestResultsFailBegin(lineNumber); UnityPrint(UnityStrExpected); @@ -1037,7 +1039,7 @@ void UnityAssertGreaterOrLessFloat(const UNITY_FLOAT threshold, if (!(actual < threshold) && (compare & UNITY_SMALLER_THAN)) { failed = 1; } if (!(actual > threshold) && (compare & UNITY_GREATER_THAN)) { failed = 1; } - if ((compare & UNITY_EQUAL_TO) && UnityFloatsWithin(threshold * UNITY_FLOAT_PRECISION, threshold, actual)) { failed = 0; } + if ((compare & UNITY_EQUAL_TO) && UnityFloatsWithin((UNITY_FLOAT)0, threshold * UNITY_FLOAT_PRECISION, threshold, actual)) { failed = 0; } if (failed) { @@ -1121,19 +1123,20 @@ void UnityAssertFloatSpecial(const UNITY_FLOAT actual, /*-----------------------------------------------*/ #ifndef UNITY_EXCLUDE_DOUBLE -static int UnityDoublesWithin(UNITY_DOUBLE delta, UNITY_DOUBLE expected, UNITY_DOUBLE actual) +static int UnityDoublesWithin(UNITY_DOUBLE delta0, UNITY_DOUBLE delta1, UNITY_DOUBLE expected, UNITY_DOUBLE actual) { UNITY_DOUBLE diff; - UNITY_FLOAT_OR_DOUBLE_WITHIN(delta, expected, actual, diff); + UNITY_FLOAT_OR_DOUBLE_WITHIN(delta0, delta1, expected, actual, diff); } /*-----------------------------------------------*/ -void UnityAssertEqualDoubleArray(UNITY_PTR_ATTRIBUTE const UNITY_DOUBLE* expected, - UNITY_PTR_ATTRIBUTE const UNITY_DOUBLE* actual, - const UNITY_UINT32 num_elements, - const char* msg, - const UNITY_LINE_TYPE lineNumber, - const UNITY_FLAGS_T flags) +void UnityAssertWithinDoubleArray(const UNITY_DOUBLE delta, + UNITY_PTR_ATTRIBUTE const UNITY_DOUBLE* expected, + UNITY_PTR_ATTRIBUTE const UNITY_DOUBLE* actual, + const UNITY_UINT32 num_elements, + const char* msg, + const UNITY_LINE_TYPE lineNumber, + const UNITY_FLAGS_T flags) { UNITY_UINT32 elements = num_elements; UNITY_PTR_ATTRIBUTE const UNITY_DOUBLE* ptr_expected = expected; @@ -1162,7 +1165,7 @@ void UnityAssertEqualDoubleArray(UNITY_PTR_ATTRIBUTE const UNITY_DOUBLE* expecte while (elements--) { - if (!UnityDoublesWithin(*ptr_expected * UNITY_DOUBLE_PRECISION, *ptr_expected, *ptr_actual)) + if (!UnityDoublesWithin(delta, *ptr_expected * UNITY_DOUBLE_PRECISION, *ptr_expected, *ptr_actual)) { UnityTestResultsFailBegin(lineNumber); UnityPrint(UnityStrElement); @@ -1188,7 +1191,7 @@ void UnityAssertDoublesWithin(const UNITY_DOUBLE delta, { RETURN_IF_FAIL_OR_IGNORE; - if (!UnityDoublesWithin(delta, expected, actual)) + if (!UnityDoublesWithin(delta, 0, expected, actual)) { UnityTestResultsFailBegin(lineNumber); UNITY_PRINT_EXPECTED_AND_ACTUAL_FLOAT(expected, actual); @@ -1206,7 +1209,7 @@ void UnityAssertDoublesNotWithin(const UNITY_DOUBLE delta, { RETURN_IF_FAIL_OR_IGNORE; - if (UnityDoublesWithin(delta, expected, actual)) + if (UnityDoublesWithin(delta, 0, expected, actual)) { UnityTestResultsFailBegin(lineNumber); UnityPrint(UnityStrExpected); @@ -1235,7 +1238,7 @@ void UnityAssertGreaterOrLessDouble(const UNITY_DOUBLE threshold, if (!(actual < threshold) && (compare & UNITY_SMALLER_THAN)) { failed = 1; } if (!(actual > threshold) && (compare & UNITY_GREATER_THAN)) { failed = 1; } - if ((compare & UNITY_EQUAL_TO) && UnityFloatsWithin(threshold * UNITY_DOUBLE_PRECISION, threshold, actual)) { failed = 0; } + if ((compare & UNITY_EQUAL_TO) && UnityDoublesWithin((UNITY_FLOAT)0, threshold * UNITY_DOUBLE_PRECISION, threshold, actual)) { failed = 0; } if (failed) { diff --git a/src/unity_internals.h b/src/unity_internals.h index f2c312c2..c2a6f661 100644 --- a/src/unity_internals.h +++ b/src/unity_internals.h @@ -682,12 +682,13 @@ void UnityAssertGreaterOrLessFloat(const UNITY_FLOAT threshold, const char* msg, const UNITY_LINE_TYPE linenumber); -void UnityAssertEqualFloatArray(UNITY_PTR_ATTRIBUTE const UNITY_FLOAT* expected, - UNITY_PTR_ATTRIBUTE const UNITY_FLOAT* actual, - const UNITY_UINT32 num_elements, - const char* msg, - const UNITY_LINE_TYPE lineNumber, - const UNITY_FLAGS_T flags); +void UnityAssertWithinFloatArray(const UNITY_FLOAT delta, + UNITY_PTR_ATTRIBUTE const UNITY_FLOAT* expected, + UNITY_PTR_ATTRIBUTE const UNITY_FLOAT* actual, + const UNITY_UINT32 num_elements, + const char* msg, + const UNITY_LINE_TYPE lineNumber, + const UNITY_FLAGS_T flags); void UnityAssertFloatSpecial(const UNITY_FLOAT actual, const char* msg, @@ -714,12 +715,13 @@ void UnityAssertGreaterOrLessDouble(const UNITY_DOUBLE threshold, const char* msg, const UNITY_LINE_TYPE linenumber); -void UnityAssertEqualDoubleArray(UNITY_PTR_ATTRIBUTE const UNITY_DOUBLE* expected, - UNITY_PTR_ATTRIBUTE const UNITY_DOUBLE* actual, - const UNITY_UINT32 num_elements, - const char* msg, - const UNITY_LINE_TYPE lineNumber, - const UNITY_FLAGS_T flags); +void UnityAssertWithinDoubleArray(const UNITY_DOUBLE delta, + UNITY_PTR_ATTRIBUTE const UNITY_DOUBLE* expected, + UNITY_PTR_ATTRIBUTE const UNITY_DOUBLE* actual, + const UNITY_UINT32 num_elements, + const char* msg, + const UNITY_LINE_TYPE lineNumber, + const UNITY_FLAGS_T flags); void UnityAssertDoubleSpecial(const UNITY_DOUBLE actual, const char* msg, @@ -1062,8 +1064,8 @@ int UnityTestMatches(void); #define UNITY_TEST_ASSERT_FLOAT_NOT_WITHIN(delta, expected, actual, line, message) UnityAssertFloatsNotWithin((UNITY_FLOAT)(delta), (UNITY_FLOAT)(expected), (UNITY_FLOAT)(actual), (message), (UNITY_LINE_TYPE)(line)) #define UNITY_TEST_ASSERT_EQUAL_FLOAT(expected, actual, line, message) UNITY_TEST_ASSERT_FLOAT_WITHIN((UNITY_FLOAT)(expected) * (UNITY_FLOAT)UNITY_FLOAT_PRECISION, (UNITY_FLOAT)(expected), (UNITY_FLOAT)(actual), (UNITY_LINE_TYPE)(line), (message)) #define UNITY_TEST_ASSERT_NOT_EQUAL_FLOAT(expected, actual, line, message) UNITY_TEST_ASSERT_FLOAT_NOT_WITHIN((UNITY_FLOAT)(expected) * (UNITY_FLOAT)UNITY_FLOAT_PRECISION, (UNITY_FLOAT)(expected), (UNITY_FLOAT)(actual), (UNITY_LINE_TYPE)(line), (message)) -#define UNITY_TEST_ASSERT_EQUAL_FLOAT_ARRAY(expected, actual, num_elements, line, message) UnityAssertEqualFloatArray((UNITY_FLOAT*)(expected), (UNITY_FLOAT*)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_ARRAY_TO_ARRAY) -#define UNITY_TEST_ASSERT_EACH_EQUAL_FLOAT(expected, actual, num_elements, line, message) UnityAssertEqualFloatArray(UnityFloatToPtr(expected), (UNITY_FLOAT*)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_ARRAY_TO_VAL) +#define UNITY_TEST_ASSERT_EQUAL_FLOAT_ARRAY(expected, actual, num_elements, line, message) UnityAssertWithinFloatArray((UNITY_FLOAT)0, (UNITY_FLOAT*)(expected), (UNITY_FLOAT*)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_ARRAY_TO_ARRAY) +#define UNITY_TEST_ASSERT_EACH_EQUAL_FLOAT(expected, actual, num_elements, line, message) UnityAssertWithinFloatArray((UNITY_FLOAT)0, UnityFloatToPtr(expected), (UNITY_FLOAT*)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_ARRAY_TO_VAL) #define UNITY_TEST_ASSERT_GREATER_THAN_FLOAT(threshold, actual, line, message) UnityAssertGreaterOrLessFloat((UNITY_FLOAT)(threshold), (UNITY_FLOAT)(actual), UNITY_GREATER_THAN, (message), (UNITY_LINE_TYPE)(line)) #define UNITY_TEST_ASSERT_GREATER_OR_EQUAL_FLOAT(threshold, actual, line, message) UnityAssertGreaterOrLessFloat((UNITY_FLOAT)(threshold), (UNITY_FLOAT)(actual), UNITY_GREATER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line)) #define UNITY_TEST_ASSERT_LESS_THAN_FLOAT(threshold, actual, line, message) UnityAssertGreaterOrLessFloat((UNITY_FLOAT)(threshold), (UNITY_FLOAT)(actual), UNITY_SMALLER_THAN, (message), (UNITY_LINE_TYPE)(line)) @@ -1100,8 +1102,8 @@ int UnityTestMatches(void); #define UNITY_TEST_ASSERT_DOUBLE_NOT_WITHIN(delta, expected, actual, line, message) UnityAssertDoublesNotWithin((UNITY_DOUBLE)(delta), (UNITY_DOUBLE)(expected), (UNITY_DOUBLE)(actual), (message), (UNITY_LINE_TYPE)(line)) #define UNITY_TEST_ASSERT_EQUAL_DOUBLE(expected, actual, line, message) UNITY_TEST_ASSERT_DOUBLE_WITHIN((UNITY_DOUBLE)(expected) * (UNITY_DOUBLE)UNITY_DOUBLE_PRECISION, (UNITY_DOUBLE)(expected), (UNITY_DOUBLE)(actual), (UNITY_LINE_TYPE)(line), (message)) #define UNITY_TEST_ASSERT_NOT_EQUAL_DOUBLE(expected, actual, line, message) UNITY_TEST_ASSERT_DOUBLE_NOT_WITHIN((UNITY_DOUBLE)(expected) * (UNITY_DOUBLE)UNITY_DOUBLE_PRECISION, (UNITY_DOUBLE)(expected), (UNITY_DOUBLE)(actual), (UNITY_LINE_TYPE)(line), (message)) -#define UNITY_TEST_ASSERT_EQUAL_DOUBLE_ARRAY(expected, actual, num_elements, line, message) UnityAssertEqualDoubleArray((UNITY_DOUBLE*)(expected), (UNITY_DOUBLE*)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_ARRAY_TO_ARRAY) -#define UNITY_TEST_ASSERT_EACH_EQUAL_DOUBLE(expected, actual, num_elements, line, message) UnityAssertEqualDoubleArray(UnityDoubleToPtr(expected), (UNITY_DOUBLE*)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_ARRAY_TO_VAL) +#define UNITY_TEST_ASSERT_EQUAL_DOUBLE_ARRAY(expected, actual, num_elements, line, message) UnityAssertWithinDoubleArray((UNITY_DOUBLE)0, (UNITY_DOUBLE*)(expected), (UNITY_DOUBLE*)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_ARRAY_TO_ARRAY) +#define UNITY_TEST_ASSERT_EACH_EQUAL_DOUBLE(expected, actual, num_elements, line, message) UnityAssertWithinDoubleArray((UNITY_DOUBLE)0, UnityDoubleToPtr(expected), (UNITY_DOUBLE*)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_ARRAY_TO_VAL) #define UNITY_TEST_ASSERT_GREATER_THAN_DOUBLE(threshold, actual, line, message) UnityAssertGreaterOrLessDouble((UNITY_DOUBLE)(threshold), (UNITY_DOUBLE)(actual), UNITY_GREATER_THAN, (message), (UNITY_LINE_TYPE)(line)) #define UNITY_TEST_ASSERT_GREATER_OR_EQUAL_DOUBLE(threshold, actual, line, message) UnityAssertGreaterOrLessDouble((UNITY_DOUBLE)(threshold), (UNITY_DOUBLE)(actual), UNITY_GREATER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line)) #define UNITY_TEST_ASSERT_LESS_THAN_DOUBLE(threshold, actual, line, message) UnityAssertGreaterOrLessDouble((UNITY_DOUBLE)(threshold), (UNITY_DOUBLE)(actual), UNITY_SMALLER_THAN, (message), (UNITY_LINE_TYPE)(line)) From 9c45c7861b6a5c62d3dfe8a5a521407bad5a1d08 Mon Sep 17 00:00:00 2001 From: AJIOB Date: Mon, 28 Nov 2022 18:28:31 +0300 Subject: [PATCH 347/454] Adding support for floating point arrays within. Testing newly created API. --- src/unity.h | 4 ++++ src/unity_internals.h | 4 ++++ test/tests/test_unity_doubles.c | 25 +++++++++++++++++++++++++ test/tests/test_unity_floats.c | 25 +++++++++++++++++++++++++ 4 files changed, 58 insertions(+) diff --git a/src/unity.h b/src/unity.h index 868dc237..e321a1da 100644 --- a/src/unity.h +++ b/src/unity.h @@ -340,6 +340,7 @@ void verifyTest(void); #define TEST_ASSERT_FLOAT_NOT_WITHIN(delta, expected, actual) UNITY_TEST_ASSERT_FLOAT_NOT_WITHIN((delta), (expected), (actual), __LINE__, NULL) #define TEST_ASSERT_EQUAL_FLOAT(expected, actual) UNITY_TEST_ASSERT_EQUAL_FLOAT((expected), (actual), __LINE__, NULL) #define TEST_ASSERT_NOT_EQUAL_FLOAT(expected, actual) UNITY_TEST_ASSERT_NOT_EQUAL_FLOAT((expected), (actual), __LINE__, NULL) +#define TEST_ASSERT_FLOAT_ARRAY_WITHIN(delta, expected, actual, num_elements) UNITY_TEST_ASSERT_FLOAT_ARRAY_WITHIN((delta), (expected), (actual), (num_elements), __LINE__, NULL) #define TEST_ASSERT_EQUAL_FLOAT_ARRAY(expected, actual, num_elements) UNITY_TEST_ASSERT_EQUAL_FLOAT_ARRAY((expected), (actual), (num_elements), __LINE__, NULL) #define TEST_ASSERT_EACH_EQUAL_FLOAT(expected, actual, num_elements) UNITY_TEST_ASSERT_EACH_EQUAL_FLOAT((expected), (actual), (num_elements), __LINE__, NULL) #define TEST_ASSERT_GREATER_THAN_FLOAT(threshold, actual) UNITY_TEST_ASSERT_GREATER_THAN_FLOAT((threshold), (actual), __LINE__, NULL) @@ -360,6 +361,7 @@ void verifyTest(void); #define TEST_ASSERT_DOUBLE_NOT_WITHIN(delta, expected, actual) UNITY_TEST_ASSERT_DOUBLE_NOT_WITHIN((delta), (expected), (actual), __LINE__, NULL) #define TEST_ASSERT_EQUAL_DOUBLE(expected, actual) UNITY_TEST_ASSERT_EQUAL_DOUBLE((expected), (actual), __LINE__, NULL) #define TEST_ASSERT_NOT_EQUAL_DOUBLE(expected, actual) UNITY_TEST_ASSERT_NOT_EQUAL_DOUBLE((expected), (actual), __LINE__, NULL) +#define TEST_ASSERT_DOUBLE_ARRAY_WITHIN(delta, expected, actual, num_elements) UNITY_TEST_ASSERT_DOUBLE_ARRAY_WITHIN((delta), (expected), (actual), (num_elements), __LINE__, NULL) #define TEST_ASSERT_EQUAL_DOUBLE_ARRAY(expected, actual, num_elements) UNITY_TEST_ASSERT_EQUAL_DOUBLE_ARRAY((expected), (actual), (num_elements), __LINE__, NULL) #define TEST_ASSERT_EACH_EQUAL_DOUBLE(expected, actual, num_elements) UNITY_TEST_ASSERT_EACH_EQUAL_DOUBLE((expected), (actual), (num_elements), __LINE__, NULL) #define TEST_ASSERT_GREATER_THAN_DOUBLE(threshold, actual) UNITY_TEST_ASSERT_GREATER_THAN_DOUBLE((threshold), (actual), __LINE__, NULL) @@ -620,6 +622,7 @@ void verifyTest(void); #define TEST_ASSERT_FLOAT_WITHIN_MESSAGE(delta, expected, actual, message) UNITY_TEST_ASSERT_FLOAT_WITHIN((delta), (expected), (actual), __LINE__, (message)) #define TEST_ASSERT_EQUAL_FLOAT_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_FLOAT((expected), (actual), __LINE__, (message)) #define TEST_ASSERT_NOT_EQUAL_FLOAT_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_NOT_EQUAL_FLOAT((expected), (actual), __LINE__, (message)) +#define TEST_ASSERT_FLOAT_ARRAY_WITHIN_MESSAGE(delta, expected, actual, num_elements, message) UNITY_TEST_ASSERT_FLOAT_ARRAY_WITHIN((delta), (expected), (actual), (num_elements), __LINE__, (message)) #define TEST_ASSERT_EQUAL_FLOAT_ARRAY_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EQUAL_FLOAT_ARRAY((expected), (actual), (num_elements), __LINE__, (message)) #define TEST_ASSERT_EACH_EQUAL_FLOAT_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EACH_EQUAL_FLOAT((expected), (actual), (num_elements), __LINE__, (message)) #define TEST_ASSERT_GREATER_THAN_FLOAT_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_THAN_FLOAT((threshold), (actual), __LINE__, (message)) @@ -639,6 +642,7 @@ void verifyTest(void); #define TEST_ASSERT_DOUBLE_WITHIN_MESSAGE(delta, expected, actual, message) UNITY_TEST_ASSERT_DOUBLE_WITHIN((delta), (expected), (actual), __LINE__, (message)) #define TEST_ASSERT_EQUAL_DOUBLE_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_DOUBLE((expected), (actual), __LINE__, (message)) #define TEST_ASSERT_NOT_EQUAL_DOUBLE_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_NOT_EQUAL_DOUBLE((expected), (actual), __LINE__, (message)) +#define TEST_ASSERT_DOUBLE_ARRAY_WITHIN_MESSAGE(delta, expected, actual, num_elements, message) UNITY_TEST_ASSERT_DOUBLE_ARRAY_WITHIN((delta), (expected), (actual), (num_elements), __LINE__, (message)) #define TEST_ASSERT_EQUAL_DOUBLE_ARRAY_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EQUAL_DOUBLE_ARRAY((expected), (actual), (num_elements), __LINE__, (message)) #define TEST_ASSERT_EACH_EQUAL_DOUBLE_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EACH_EQUAL_DOUBLE((expected), (actual), (num_elements), __LINE__, (message)) #define TEST_ASSERT_GREATER_THAN_DOUBLE_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_THAN_DOUBLE((threshold), (actual), __LINE__, (message)) diff --git a/src/unity_internals.h b/src/unity_internals.h index c2a6f661..6a86ce99 100644 --- a/src/unity_internals.h +++ b/src/unity_internals.h @@ -1045,6 +1045,7 @@ int UnityTestMatches(void); #define UNITY_TEST_ASSERT_FLOAT_WITHIN(delta, expected, actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErrFloat) #define UNITY_TEST_ASSERT_FLOAT_NOT_WITHIN(delta, expected, actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErrFloat) #define UNITY_TEST_ASSERT_EQUAL_FLOAT(expected, actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErrFloat) +#define UNITY_TEST_ASSERT_FLOAT_ARRAY_WITHIN(delta, expected, actual, num_elements, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErrFloat) #define UNITY_TEST_ASSERT_EQUAL_FLOAT_ARRAY(expected, actual, num_elements, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErrFloat) #define UNITY_TEST_ASSERT_EACH_EQUAL_FLOAT(expected, actual, num_elements, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErrFloat) #define UNITY_TEST_ASSERT_GREATER_THAN_FLOAT(threshold, actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErrFloat) @@ -1064,6 +1065,7 @@ int UnityTestMatches(void); #define UNITY_TEST_ASSERT_FLOAT_NOT_WITHIN(delta, expected, actual, line, message) UnityAssertFloatsNotWithin((UNITY_FLOAT)(delta), (UNITY_FLOAT)(expected), (UNITY_FLOAT)(actual), (message), (UNITY_LINE_TYPE)(line)) #define UNITY_TEST_ASSERT_EQUAL_FLOAT(expected, actual, line, message) UNITY_TEST_ASSERT_FLOAT_WITHIN((UNITY_FLOAT)(expected) * (UNITY_FLOAT)UNITY_FLOAT_PRECISION, (UNITY_FLOAT)(expected), (UNITY_FLOAT)(actual), (UNITY_LINE_TYPE)(line), (message)) #define UNITY_TEST_ASSERT_NOT_EQUAL_FLOAT(expected, actual, line, message) UNITY_TEST_ASSERT_FLOAT_NOT_WITHIN((UNITY_FLOAT)(expected) * (UNITY_FLOAT)UNITY_FLOAT_PRECISION, (UNITY_FLOAT)(expected), (UNITY_FLOAT)(actual), (UNITY_LINE_TYPE)(line), (message)) +#define UNITY_TEST_ASSERT_FLOAT_ARRAY_WITHIN(delta, expected, actual, num_elements, line, message) UnityAssertWithinFloatArray((UNITY_FLOAT)(delta), (UNITY_FLOAT*)(expected), (UNITY_FLOAT*)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_ARRAY_TO_ARRAY) #define UNITY_TEST_ASSERT_EQUAL_FLOAT_ARRAY(expected, actual, num_elements, line, message) UnityAssertWithinFloatArray((UNITY_FLOAT)0, (UNITY_FLOAT*)(expected), (UNITY_FLOAT*)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_ARRAY_TO_ARRAY) #define UNITY_TEST_ASSERT_EACH_EQUAL_FLOAT(expected, actual, num_elements, line, message) UnityAssertWithinFloatArray((UNITY_FLOAT)0, UnityFloatToPtr(expected), (UNITY_FLOAT*)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_ARRAY_TO_VAL) #define UNITY_TEST_ASSERT_GREATER_THAN_FLOAT(threshold, actual, line, message) UnityAssertGreaterOrLessFloat((UNITY_FLOAT)(threshold), (UNITY_FLOAT)(actual), UNITY_GREATER_THAN, (message), (UNITY_LINE_TYPE)(line)) @@ -1083,6 +1085,7 @@ int UnityTestMatches(void); #ifdef UNITY_EXCLUDE_DOUBLE #define UNITY_TEST_ASSERT_DOUBLE_WITHIN(delta, expected, actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErrDouble) #define UNITY_TEST_ASSERT_EQUAL_DOUBLE(expected, actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErrDouble) +#define UNITY_TEST_ASSERT_DOUBLE_ARRAY_WITHIN(delta, expected, actual, num_elements, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErrDouble) #define UNITY_TEST_ASSERT_EQUAL_DOUBLE_ARRAY(expected, actual, num_elements, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErrDouble) #define UNITY_TEST_ASSERT_EACH_EQUAL_DOUBLE(expected, actual, num_elements, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErrDouble) #define UNITY_TEST_ASSERT_GREATER_THAN_DOUBLE(threshold, actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErrDouble) @@ -1102,6 +1105,7 @@ int UnityTestMatches(void); #define UNITY_TEST_ASSERT_DOUBLE_NOT_WITHIN(delta, expected, actual, line, message) UnityAssertDoublesNotWithin((UNITY_DOUBLE)(delta), (UNITY_DOUBLE)(expected), (UNITY_DOUBLE)(actual), (message), (UNITY_LINE_TYPE)(line)) #define UNITY_TEST_ASSERT_EQUAL_DOUBLE(expected, actual, line, message) UNITY_TEST_ASSERT_DOUBLE_WITHIN((UNITY_DOUBLE)(expected) * (UNITY_DOUBLE)UNITY_DOUBLE_PRECISION, (UNITY_DOUBLE)(expected), (UNITY_DOUBLE)(actual), (UNITY_LINE_TYPE)(line), (message)) #define UNITY_TEST_ASSERT_NOT_EQUAL_DOUBLE(expected, actual, line, message) UNITY_TEST_ASSERT_DOUBLE_NOT_WITHIN((UNITY_DOUBLE)(expected) * (UNITY_DOUBLE)UNITY_DOUBLE_PRECISION, (UNITY_DOUBLE)(expected), (UNITY_DOUBLE)(actual), (UNITY_LINE_TYPE)(line), (message)) +#define UNITY_TEST_ASSERT_DOUBLE_ARRAY_WITHIN(delta, expected, actual, num_elements, line, message) UnityAssertWithinDoubleArray((UNITY_DOUBLE)(delta), (UNITY_DOUBLE*)(expected), (UNITY_DOUBLE*)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_ARRAY_TO_ARRAY) #define UNITY_TEST_ASSERT_EQUAL_DOUBLE_ARRAY(expected, actual, num_elements, line, message) UnityAssertWithinDoubleArray((UNITY_DOUBLE)0, (UNITY_DOUBLE*)(expected), (UNITY_DOUBLE*)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_ARRAY_TO_ARRAY) #define UNITY_TEST_ASSERT_EACH_EQUAL_DOUBLE(expected, actual, num_elements, line, message) UnityAssertWithinDoubleArray((UNITY_DOUBLE)0, UnityDoubleToPtr(expected), (UNITY_DOUBLE*)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_ARRAY_TO_VAL) #define UNITY_TEST_ASSERT_GREATER_THAN_DOUBLE(threshold, actual, line, message) UnityAssertGreaterOrLessDouble((UNITY_DOUBLE)(threshold), (UNITY_DOUBLE)(actual), UNITY_GREATER_THAN, (message), (UNITY_LINE_TYPE)(line)) diff --git a/test/tests/test_unity_doubles.c b/test/tests/test_unity_doubles.c index 1a54c0dd..174f7339 100644 --- a/test/tests/test_unity_doubles.c +++ b/test/tests/test_unity_doubles.c @@ -1024,6 +1024,31 @@ void testNotEqualDoubleArraysLengthZero(void) #endif } +void testDoubleArraysWithin(void) +{ +#ifdef UNITY_EXCLUDE_DOUBLE + TEST_IGNORE(); +#else + double p0[] = {1.0, -8.0, 25.4, -0.123}; + double p1[] = {1.0, -8.0, 25.4, -0.123}; + double p2[] = {1.0, -8.0, 25.4, -0.2}; + double p3[] = {1.0, -23.0, 25.0, -0.26}; + double p4[] = {2.0, -9.0, 26.2, 0.26}; + double p5[] = {-1.0, -7.0, 29.0, 2.6}; + + TEST_ASSERT_DOUBLE_ARRAY_WITHIN(1.0, p0, p0, 1); + TEST_ASSERT_DOUBLE_ARRAY_WITHIN(1.0, p0, p0, 4); + TEST_ASSERT_DOUBLE_ARRAY_WITHIN(1.0, p0, p1, 4); + TEST_ASSERT_DOUBLE_ARRAY_WITHIN(1.0, p0, p2, 3); + TEST_ASSERT_DOUBLE_ARRAY_WITHIN(1.0, p0, p3, 1); + TEST_ASSERT_DOUBLE_ARRAY_WITHIN(1.0, p0, p4, 1); + TEST_ASSERT_DOUBLE_ARRAY_WITHIN(1.0, p0, p4, 4); + TEST_ASSERT_DOUBLE_ARRAY_WITHIN(2.0, p0, p5, 1); + TEST_ASSERT_DOUBLE_ARRAY_WITHIN(2.0, p0, p5, 2); + TEST_ASSERT_DOUBLE_ARRAY_WITHIN(1.0, NULL, NULL, 1); +#endif +} + void testEqualDoubleEachEqual(void) { #ifdef UNITY_EXCLUDE_DOUBLE diff --git a/test/tests/test_unity_floats.c b/test/tests/test_unity_floats.c index 5a746bb9..b86f4803 100644 --- a/test/tests/test_unity_floats.c +++ b/test/tests/test_unity_floats.c @@ -1022,6 +1022,31 @@ void testNotEqualFloatArraysLengthZero(void) #endif } +void testFloatArraysWithin(void) +{ +#ifdef UNITY_EXCLUDE_FLOAT + TEST_IGNORE(); +#else + float p0[] = {1.0f, -8.0f, 25.4f, -0.123f}; + float p1[] = {1.0f, -8.0f, 25.4f, -0.123f}; + float p2[] = {1.0f, -8.0f, 25.4f, -0.2f}; + float p3[] = {1.0f, -23.0f, 25.0f, -0.26f}; + float p4[] = {2.0f, -9.0f, 26.2f, 0.26f}; + float p5[] = {-1.0f, -7.0f, 29.0f, 2.6f}; + + TEST_ASSERT_FLOAT_ARRAY_WITHIN(1.0f, p0, p0, 1); + TEST_ASSERT_FLOAT_ARRAY_WITHIN(1.0f, p0, p0, 4); + TEST_ASSERT_FLOAT_ARRAY_WITHIN(1.0f, p0, p1, 4); + TEST_ASSERT_FLOAT_ARRAY_WITHIN(1.0f, p0, p2, 3); + TEST_ASSERT_FLOAT_ARRAY_WITHIN(1.0f, p0, p3, 1); + TEST_ASSERT_FLOAT_ARRAY_WITHIN(1.0f, p0, p4, 1); + TEST_ASSERT_FLOAT_ARRAY_WITHIN(1.0f, p0, p4, 4); + TEST_ASSERT_FLOAT_ARRAY_WITHIN(2.0f, p0, p5, 1); + TEST_ASSERT_FLOAT_ARRAY_WITHIN(2.0f, p0, p5, 2); + TEST_ASSERT_FLOAT_ARRAY_WITHIN(1.0f, NULL, NULL, 1); +#endif +} + void testEqualFloatEachEqual(void) { #ifdef UNITY_EXCLUDE_FLOAT From aed2e62142256c33d664b4df3b9fb07f898b91c6 Mon Sep 17 00:00:00 2001 From: AJIOB Date: Mon, 28 Nov 2022 18:30:46 +0300 Subject: [PATCH 348/454] Float-double types typo was fixed --- src/unity.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/unity.c b/src/unity.c index ff331d21..9d5a6cf6 100644 --- a/src/unity.c +++ b/src/unity.c @@ -1191,7 +1191,7 @@ void UnityAssertDoublesWithin(const UNITY_DOUBLE delta, { RETURN_IF_FAIL_OR_IGNORE; - if (!UnityDoublesWithin(delta, 0, expected, actual)) + if (!UnityDoublesWithin(delta, (UNITY_DOUBLE)0, expected, actual)) { UnityTestResultsFailBegin(lineNumber); UNITY_PRINT_EXPECTED_AND_ACTUAL_FLOAT(expected, actual); @@ -1209,7 +1209,7 @@ void UnityAssertDoublesNotWithin(const UNITY_DOUBLE delta, { RETURN_IF_FAIL_OR_IGNORE; - if (UnityDoublesWithin(delta, 0, expected, actual)) + if (UnityDoublesWithin(delta, (UNITY_DOUBLE)0, expected, actual)) { UnityTestResultsFailBegin(lineNumber); UnityPrint(UnityStrExpected); @@ -1238,7 +1238,7 @@ void UnityAssertGreaterOrLessDouble(const UNITY_DOUBLE threshold, if (!(actual < threshold) && (compare & UNITY_SMALLER_THAN)) { failed = 1; } if (!(actual > threshold) && (compare & UNITY_GREATER_THAN)) { failed = 1; } - if ((compare & UNITY_EQUAL_TO) && UnityDoublesWithin((UNITY_FLOAT)0, threshold * UNITY_DOUBLE_PRECISION, threshold, actual)) { failed = 0; } + if ((compare & UNITY_EQUAL_TO) && UnityDoublesWithin((UNITY_DOUBLE)0, threshold * UNITY_DOUBLE_PRECISION, threshold, actual)) { failed = 0; } if (failed) { From 7d2a92708206cb6f65c35fb6b9ad84b9b5529ac9 Mon Sep 17 00:00:00 2001 From: AJIOB Date: Mon, 28 Nov 2022 18:45:58 +0300 Subject: [PATCH 349/454] Adding lost float & double assert entries when they were previously disabled --- src/unity_internals.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/unity_internals.h b/src/unity_internals.h index 6a86ce99..a7f72be8 100644 --- a/src/unity_internals.h +++ b/src/unity_internals.h @@ -1045,6 +1045,7 @@ int UnityTestMatches(void); #define UNITY_TEST_ASSERT_FLOAT_WITHIN(delta, expected, actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErrFloat) #define UNITY_TEST_ASSERT_FLOAT_NOT_WITHIN(delta, expected, actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErrFloat) #define UNITY_TEST_ASSERT_EQUAL_FLOAT(expected, actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErrFloat) +#define UNITY_TEST_ASSERT_NOT_EQUAL_FLOAT(expected, actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErrFloat) #define UNITY_TEST_ASSERT_FLOAT_ARRAY_WITHIN(delta, expected, actual, num_elements, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErrFloat) #define UNITY_TEST_ASSERT_EQUAL_FLOAT_ARRAY(expected, actual, num_elements, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErrFloat) #define UNITY_TEST_ASSERT_EACH_EQUAL_FLOAT(expected, actual, num_elements, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErrFloat) @@ -1084,7 +1085,9 @@ int UnityTestMatches(void); #ifdef UNITY_EXCLUDE_DOUBLE #define UNITY_TEST_ASSERT_DOUBLE_WITHIN(delta, expected, actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErrDouble) +#define UNITY_TEST_ASSERT_DOUBLE_NOT_WITHIN(delta, expected, actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErrDouble) #define UNITY_TEST_ASSERT_EQUAL_DOUBLE(expected, actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErrDouble) +#define UNITY_TEST_ASSERT_NOT_EQUAL_DOUBLE(expected, actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErrDouble) #define UNITY_TEST_ASSERT_DOUBLE_ARRAY_WITHIN(delta, expected, actual, num_elements, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErrDouble) #define UNITY_TEST_ASSERT_EQUAL_DOUBLE_ARRAY(expected, actual, num_elements, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErrDouble) #define UNITY_TEST_ASSERT_EACH_EQUAL_DOUBLE(expected, actual, num_elements, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErrDouble) From 0963e20d0b45b4317c05cb2c22bfc5c5f47a44d2 Mon Sep 17 00:00:00 2001 From: AJIOB Date: Mon, 28 Nov 2022 20:09:06 +0300 Subject: [PATCH 350/454] Force moving double delta logic to local function --- src/unity.c | 63 +++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 47 insertions(+), 16 deletions(-) diff --git a/src/unity.c b/src/unity.c index 9d5a6cf6..432c2971 100644 --- a/src/unity.c +++ b/src/unity.c @@ -894,14 +894,13 @@ void UnityAssertEqualIntArray(UNITY_INTERNAL_PTR expected, /*-----------------------------------------------*/ #ifndef UNITY_EXCLUDE_FLOAT /* Wrap this define in a function with variable types as float or double */ -#define UNITY_FLOAT_OR_DOUBLE_WITHIN(delta0, delta1, expected, actual, diff) \ +#define UNITY_FLOAT_OR_DOUBLE_WITHIN(delta, expected, actual, diff) \ if (isinf(expected) && isinf(actual) && (((expected) < 0) == ((actual) < 0))) return 1; \ if (UNITY_NAN_CHECK) return 1; \ (diff) = (actual) - (expected); \ if ((diff) < 0) (diff) = -(diff); \ - if ((delta0) < 0) (delta0) = -(delta0); \ - if ((delta1) < 0) (delta1) = -(delta1); \ - return !(isnan(diff) || isinf(diff) || ((diff) > ((delta0) + (delta1)))) + if ((delta) < 0) (delta) = -(delta); \ + return !(isnan(diff) || isinf(diff) || ((diff) > (delta))) /* This first part of this condition will catch any NaN or Infinite values */ #ifndef UNITY_NAN_NOT_EQUAL_NAN #define UNITY_NAN_CHECK isnan(expected) && isnan(actual) @@ -923,10 +922,10 @@ void UnityAssertEqualIntArray(UNITY_INTERNAL_PTR expected, #endif /* UNITY_EXCLUDE_FLOAT_PRINT */ /*-----------------------------------------------*/ -static int UnityFloatsWithin(UNITY_FLOAT delta0, UNITY_FLOAT delta1, UNITY_FLOAT expected, UNITY_FLOAT actual) +static int UnityFloatsWithin(UNITY_FLOAT delta, UNITY_FLOAT expected, UNITY_FLOAT actual) { UNITY_FLOAT diff; - UNITY_FLOAT_OR_DOUBLE_WITHIN(delta0, delta1, expected, actual, diff); + UNITY_FLOAT_OR_DOUBLE_WITHIN(delta, expected, actual, diff); } /*-----------------------------------------------*/ @@ -941,6 +940,8 @@ void UnityAssertWithinFloatArray(const UNITY_FLOAT delta, UNITY_UINT32 elements = num_elements; UNITY_PTR_ATTRIBUTE const UNITY_FLOAT* ptr_expected = expected; UNITY_PTR_ATTRIBUTE const UNITY_FLOAT* ptr_actual = actual; + UNITY_FLOAT in_delta = delta; + UNITY_FLOAT current_element_delta = delta; RETURN_IF_FAIL_OR_IGNORE; @@ -963,9 +964,23 @@ void UnityAssertWithinFloatArray(const UNITY_FLOAT delta, UNITY_FAIL_AND_BAIL; } + /* fix delta sign if need */ + if (in_delta < 0) + { + in_delta = -in_delta; + } + while (elements--) { - if (!UnityFloatsWithin(delta, *ptr_expected * UNITY_FLOAT_PRECISION, *ptr_expected, *ptr_actual)) + current_element_delta = *ptr_expected * UNITY_FLOAT_PRECISION; + + if (current_element_delta < 0) + { + /* fix delta sign for correct calculations */ + current_element_delta = -current_element_delta; + } + + if (!UnityFloatsWithin(in_delta + current_element_delta, *ptr_expected, *ptr_actual)) { UnityTestResultsFailBegin(lineNumber); UnityPrint(UnityStrElement); @@ -992,7 +1007,7 @@ void UnityAssertFloatsWithin(const UNITY_FLOAT delta, RETURN_IF_FAIL_OR_IGNORE; - if (!UnityFloatsWithin(delta, (UNITY_FLOAT)0, expected, actual)) + if (!UnityFloatsWithin(delta, expected, actual)) { UnityTestResultsFailBegin(lineNumber); UNITY_PRINT_EXPECTED_AND_ACTUAL_FLOAT((UNITY_DOUBLE)expected, (UNITY_DOUBLE)actual); @@ -1010,7 +1025,7 @@ void UnityAssertFloatsNotWithin(const UNITY_FLOAT delta, { RETURN_IF_FAIL_OR_IGNORE; - if (UnityFloatsWithin(delta, (UNITY_FLOAT)0, expected, actual)) + if (UnityFloatsWithin(delta, expected, actual)) { UnityTestResultsFailBegin(lineNumber); UnityPrint(UnityStrExpected); @@ -1039,7 +1054,7 @@ void UnityAssertGreaterOrLessFloat(const UNITY_FLOAT threshold, if (!(actual < threshold) && (compare & UNITY_SMALLER_THAN)) { failed = 1; } if (!(actual > threshold) && (compare & UNITY_GREATER_THAN)) { failed = 1; } - if ((compare & UNITY_EQUAL_TO) && UnityFloatsWithin((UNITY_FLOAT)0, threshold * UNITY_FLOAT_PRECISION, threshold, actual)) { failed = 0; } + if ((compare & UNITY_EQUAL_TO) && UnityFloatsWithin(threshold * UNITY_FLOAT_PRECISION, threshold, actual)) { failed = 0; } if (failed) { @@ -1123,10 +1138,10 @@ void UnityAssertFloatSpecial(const UNITY_FLOAT actual, /*-----------------------------------------------*/ #ifndef UNITY_EXCLUDE_DOUBLE -static int UnityDoublesWithin(UNITY_DOUBLE delta0, UNITY_DOUBLE delta1, UNITY_DOUBLE expected, UNITY_DOUBLE actual) +static int UnityDoublesWithin(UNITY_DOUBLE delta, UNITY_DOUBLE expected, UNITY_DOUBLE actual) { UNITY_DOUBLE diff; - UNITY_FLOAT_OR_DOUBLE_WITHIN(delta0, delta1, expected, actual, diff); + UNITY_FLOAT_OR_DOUBLE_WITHIN(delta, expected, actual, diff); } /*-----------------------------------------------*/ @@ -1141,6 +1156,8 @@ void UnityAssertWithinDoubleArray(const UNITY_DOUBLE delta, UNITY_UINT32 elements = num_elements; UNITY_PTR_ATTRIBUTE const UNITY_DOUBLE* ptr_expected = expected; UNITY_PTR_ATTRIBUTE const UNITY_DOUBLE* ptr_actual = actual; + UNITY_DOUBLE in_delta = delta; + UNITY_DOUBLE current_element_delta = delta; RETURN_IF_FAIL_OR_IGNORE; @@ -1163,9 +1180,23 @@ void UnityAssertWithinDoubleArray(const UNITY_DOUBLE delta, UNITY_FAIL_AND_BAIL; } + /* fix delta sign if need */ + if (in_delta < 0) + { + in_delta = -in_delta; + } + while (elements--) { - if (!UnityDoublesWithin(delta, *ptr_expected * UNITY_DOUBLE_PRECISION, *ptr_expected, *ptr_actual)) + current_element_delta = *ptr_expected * UNITY_DOUBLE_PRECISION; + + if (current_element_delta < 0) + { + /* fix delta sign for correct calculations */ + current_element_delta = -current_element_delta; + } + + if (!UnityDoublesWithin(in_delta + current_element_delta, *ptr_expected, *ptr_actual)) { UnityTestResultsFailBegin(lineNumber); UnityPrint(UnityStrElement); @@ -1191,7 +1222,7 @@ void UnityAssertDoublesWithin(const UNITY_DOUBLE delta, { RETURN_IF_FAIL_OR_IGNORE; - if (!UnityDoublesWithin(delta, (UNITY_DOUBLE)0, expected, actual)) + if (!UnityDoublesWithin(delta, expected, actual)) { UnityTestResultsFailBegin(lineNumber); UNITY_PRINT_EXPECTED_AND_ACTUAL_FLOAT(expected, actual); @@ -1209,7 +1240,7 @@ void UnityAssertDoublesNotWithin(const UNITY_DOUBLE delta, { RETURN_IF_FAIL_OR_IGNORE; - if (UnityDoublesWithin(delta, (UNITY_DOUBLE)0, expected, actual)) + if (UnityDoublesWithin(delta, expected, actual)) { UnityTestResultsFailBegin(lineNumber); UnityPrint(UnityStrExpected); @@ -1238,7 +1269,7 @@ void UnityAssertGreaterOrLessDouble(const UNITY_DOUBLE threshold, if (!(actual < threshold) && (compare & UNITY_SMALLER_THAN)) { failed = 1; } if (!(actual > threshold) && (compare & UNITY_GREATER_THAN)) { failed = 1; } - if ((compare & UNITY_EQUAL_TO) && UnityDoublesWithin((UNITY_DOUBLE)0, threshold * UNITY_DOUBLE_PRECISION, threshold, actual)) { failed = 0; } + if ((compare & UNITY_EQUAL_TO) && UnityDoublesWithin(threshold * UNITY_DOUBLE_PRECISION, threshold, actual)) { failed = 0; } if (failed) { From b2360fa7ca9a9e2b00bd507ed05ac12fba40a1ef Mon Sep 17 00:00:00 2001 From: AJIOB Date: Mon, 28 Nov 2022 20:23:36 +0300 Subject: [PATCH 351/454] Adding delta infinity & nan checks & tests --- src/unity.c | 22 ++++++++++++++++++++++ test/tests/test_unity_doubles.c | 16 ++++++++++++++++ test/tests/test_unity_floats.c | 16 ++++++++++++++++ 3 files changed, 54 insertions(+) diff --git a/src/unity.c b/src/unity.c index 432c2971..be3daaf2 100644 --- a/src/unity.c +++ b/src/unity.c @@ -954,6 +954,17 @@ void UnityAssertWithinFloatArray(const UNITY_FLOAT delta, #endif } + if (isinf(in_delta)) + { + return; /* Arrays will be force equal with infinite delta */ + } + + if (isnan(in_delta)) + { + /* Delta must be correct number */ + UnityPrintPointlessAndBail(); + } + if (expected == actual) { return; /* Both are NULL or same pointer */ @@ -1170,6 +1181,17 @@ void UnityAssertWithinDoubleArray(const UNITY_DOUBLE delta, #endif } + if (isinf(in_delta)) + { + return; /* Arrays will be force equal with infinite delta */ + } + + if (isnan(in_delta)) + { + /* Delta must be correct number */ + UnityPrintPointlessAndBail(); + } + if (expected == actual) { return; /* Both are NULL or same pointer */ diff --git a/test/tests/test_unity_doubles.c b/test/tests/test_unity_doubles.c index 174f7339..0ad9494d 100644 --- a/test/tests/test_unity_doubles.c +++ b/test/tests/test_unity_doubles.c @@ -1049,6 +1049,22 @@ void testDoubleArraysWithin(void) #endif } +void testDoubleArraysWithinUnusualDelta(void) +{ +#ifdef UNITY_EXCLUDE_DOUBLE + TEST_IGNORE(); +#else + double p0[] = {-INFINITY, -8.0, 25.4, -0.123}; + double p1[] = {INFINITY, 10.1}; + + TEST_ASSERT_DOUBLE_ARRAY_WITHIN(INFINITY, p0, p1, 2); + + EXPECT_ABORT_BEGIN + TEST_ASSERT_DOUBLE_ARRAY_WITHIN(NAN, p0, p0, 4); + VERIFY_FAILS_END +#endif +} + void testEqualDoubleEachEqual(void) { #ifdef UNITY_EXCLUDE_DOUBLE diff --git a/test/tests/test_unity_floats.c b/test/tests/test_unity_floats.c index b86f4803..9e92f96a 100644 --- a/test/tests/test_unity_floats.c +++ b/test/tests/test_unity_floats.c @@ -1047,6 +1047,22 @@ void testFloatArraysWithin(void) #endif } +void testFloatArraysWithinUnusualDelta(void) +{ +#ifdef UNITY_EXCLUDE_FLOAT + TEST_IGNORE(); +#else + float p0[] = {(float)-INFINITY, -8.0f, 25.4f, -0.123f}; + float p1[] = {(float)INFINITY, 10.1f}; + + TEST_ASSERT_FLOAT_ARRAY_WITHIN(INFINITY, p0, p1, 2); + + EXPECT_ABORT_BEGIN + TEST_ASSERT_FLOAT_ARRAY_WITHIN(NAN, p0, p0, 4); + VERIFY_FAILS_END +#endif +} + void testEqualFloatEachEqual(void) { #ifdef UNITY_EXCLUDE_FLOAT From a9959df958a4b4c8e2a60da155ef82d7f5f2d2ee Mon Sep 17 00:00:00 2001 From: AJIOB Date: Mon, 28 Nov 2022 20:27:56 +0300 Subject: [PATCH 352/454] Returning lost spaces --- src/unity.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/unity.c b/src/unity.c index be3daaf2..3e4bc04d 100644 --- a/src/unity.c +++ b/src/unity.c @@ -894,12 +894,12 @@ void UnityAssertEqualIntArray(UNITY_INTERNAL_PTR expected, /*-----------------------------------------------*/ #ifndef UNITY_EXCLUDE_FLOAT /* Wrap this define in a function with variable types as float or double */ -#define UNITY_FLOAT_OR_DOUBLE_WITHIN(delta, expected, actual, diff) \ +#define UNITY_FLOAT_OR_DOUBLE_WITHIN(delta, expected, actual, diff) \ if (isinf(expected) && isinf(actual) && (((expected) < 0) == ((actual) < 0))) return 1; \ if (UNITY_NAN_CHECK) return 1; \ (diff) = (actual) - (expected); \ if ((diff) < 0) (diff) = -(diff); \ - if ((delta) < 0) (delta) = -(delta); \ + if ((delta) < 0) (delta) = -(delta); \ return !(isnan(diff) || isinf(diff) || ((diff) > (delta))) /* This first part of this condition will catch any NaN or Infinite values */ #ifndef UNITY_NAN_NOT_EQUAL_NAN From a35af14a273a36387bb6e7f7b81559b5136a1203 Mon Sep 17 00:00:00 2001 From: AJIOB Date: Tue, 29 Nov 2022 09:26:29 +0300 Subject: [PATCH 353/454] Actualizing docs --- docs/UnityAssertionsReference.md | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/docs/UnityAssertionsReference.md b/docs/UnityAssertionsReference.md index ff3b5309..86e78435 100644 --- a/docs/UnityAssertionsReference.md +++ b/docs/UnityAssertionsReference.md @@ -572,10 +572,16 @@ code generation conventions for CMock. Asserts that the `actual` value is NOT "close enough to be considered equal" to the `expected` value. +#### `TEST_ASSERT_FLOAT_ARRAY_WITHIN (delta, expected, actual, num_elements)` + +See Array assertion section for details. Note that individual array element +uses user-provided delta plus default comparison delta for checking +and is based on `TEST_ASSERT_FLOAT_WITHIN` comparison. + #### `TEST_ASSERT_EQUAL_FLOAT_ARRAY (expected, actual, num_elements)` See Array assertion section for details. Note that individual array element -float comparisons are executed using `TEST_ASSERT_EQUAL_FLOAT`.That is, user +float comparisons are executed using `TEST_ASSERT_EQUAL_FLOAT`. That is, user specified delta comparison values requires a custom-implemented floating point array assertion. @@ -667,10 +673,16 @@ code generation conventions for CMock. Asserts that the `actual` value is NOT "close enough to be considered equal" to the `expected` value. +#### `TEST_ASSERT_DOUBLE_ARRAY_WITHIN (delta, expected, actual, num_elements)` + +See Array assertion section for details. Note that individual array element +uses user-provided delta plus default comparison delta for checking +and is based on `TEST_ASSERT_DOUBLE_WITHIN` comparison. + #### `TEST_ASSERT_EQUAL_DOUBLE_ARRAY (expected, actual, num_elements)` See Array assertion section for details. Note that individual array element -double comparisons are executed using `TEST_ASSERT_EQUAL_DOUBLE`.That is, user +double comparisons are executed using `TEST_ASSERT_EQUAL_DOUBLE`. That is, user specified delta comparison values requires a custom implemented double array assertion. From 7298f3771cf033cd120d20947dbaf252689617ed Mon Sep 17 00:00:00 2001 From: Crt Mori Date: Mon, 12 Dec 2022 14:49:53 +0100 Subject: [PATCH 354/454] Change link to wikipedia Assert header file Closes #647 --- docs/UnityAssertionsReference.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/UnityAssertionsReference.md b/docs/UnityAssertionsReference.md index ff3b5309..bc2aff14 100644 --- a/docs/UnityAssertionsReference.md +++ b/docs/UnityAssertionsReference.md @@ -845,5 +845,5 @@ affect you: *Find The Latest of This And More at [ThrowTheSwitch.org][]* -[assert() macro]: http://en.wikipedia.org/en/wiki/Assert.h +[assert() macro]: http://en.wikipedia.org/wiki/Assert.h [ThrowTheSwitch.org]: https://throwtheswitch.org From 43a32567476a5775fa1e4bcd68f68e3c6ddf79eb Mon Sep 17 00:00:00 2001 From: Mark VanderVoord Date: Mon, 16 Jan 2023 16:41:21 -0500 Subject: [PATCH 355/454] Test across multiple versions of Ruby --- .github/workflows/main.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index fcae2ad6..ce948bd3 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -15,6 +15,9 @@ jobs: unit-tests: name: "Unit Tests" runs-on: ubuntu-latest + strategy: + matrix: + ruby: ['2.7', '3.0', '3.1', '3.2'] steps: # Install Ruby Testing Tools - name: Setup Ruby Testing Tools From 3fe84580c837348f58a5d60119b17e8a1066890d Mon Sep 17 00:00:00 2001 From: Henrik Nilsson Date: Wed, 1 Feb 2023 08:02:50 +0100 Subject: [PATCH 356/454] Avoid cast-qual warnings with const float and double arrays --- src/unity_internals.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/unity_internals.h b/src/unity_internals.h index 47bd370d..30e09668 100644 --- a/src/unity_internals.h +++ b/src/unity_internals.h @@ -1082,9 +1082,9 @@ int UnityTestMatches(void); #define UNITY_TEST_ASSERT_FLOAT_NOT_WITHIN(delta, expected, actual, line, message) UnityAssertFloatsNotWithin((UNITY_FLOAT)(delta), (UNITY_FLOAT)(expected), (UNITY_FLOAT)(actual), (message), (UNITY_LINE_TYPE)(line)) #define UNITY_TEST_ASSERT_EQUAL_FLOAT(expected, actual, line, message) UNITY_TEST_ASSERT_FLOAT_WITHIN((UNITY_FLOAT)(expected) * (UNITY_FLOAT)UNITY_FLOAT_PRECISION, (UNITY_FLOAT)(expected), (UNITY_FLOAT)(actual), (UNITY_LINE_TYPE)(line), (message)) #define UNITY_TEST_ASSERT_NOT_EQUAL_FLOAT(expected, actual, line, message) UNITY_TEST_ASSERT_FLOAT_NOT_WITHIN((UNITY_FLOAT)(expected) * (UNITY_FLOAT)UNITY_FLOAT_PRECISION, (UNITY_FLOAT)(expected), (UNITY_FLOAT)(actual), (UNITY_LINE_TYPE)(line), (message)) -#define UNITY_TEST_ASSERT_FLOAT_ARRAY_WITHIN(delta, expected, actual, num_elements, line, message) UnityAssertWithinFloatArray((UNITY_FLOAT)(delta), (UNITY_FLOAT*)(expected), (UNITY_FLOAT*)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_ARRAY_TO_ARRAY) -#define UNITY_TEST_ASSERT_EQUAL_FLOAT_ARRAY(expected, actual, num_elements, line, message) UnityAssertWithinFloatArray((UNITY_FLOAT)0, (UNITY_FLOAT*)(expected), (UNITY_FLOAT*)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_ARRAY_TO_ARRAY) -#define UNITY_TEST_ASSERT_EACH_EQUAL_FLOAT(expected, actual, num_elements, line, message) UnityAssertWithinFloatArray((UNITY_FLOAT)0, UnityFloatToPtr(expected), (UNITY_FLOAT*)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_ARRAY_TO_VAL) +#define UNITY_TEST_ASSERT_FLOAT_ARRAY_WITHIN(delta, expected, actual, num_elements, line, message) UnityAssertWithinFloatArray((UNITY_FLOAT)(delta), (const UNITY_FLOAT*)(expected), (const UNITY_FLOAT*)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_ARRAY_TO_ARRAY) +#define UNITY_TEST_ASSERT_EQUAL_FLOAT_ARRAY(expected, actual, num_elements, line, message) UnityAssertWithinFloatArray((UNITY_FLOAT)0, (const UNITY_FLOAT*)(expected), (const UNITY_FLOAT*)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_ARRAY_TO_ARRAY) +#define UNITY_TEST_ASSERT_EACH_EQUAL_FLOAT(expected, actual, num_elements, line, message) UnityAssertWithinFloatArray((UNITY_FLOAT)0, UnityFloatToPtr(expected), (const UNITY_FLOAT*)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_ARRAY_TO_VAL) #define UNITY_TEST_ASSERT_GREATER_THAN_FLOAT(threshold, actual, line, message) UnityAssertGreaterOrLessFloat((UNITY_FLOAT)(threshold), (UNITY_FLOAT)(actual), UNITY_GREATER_THAN, (message), (UNITY_LINE_TYPE)(line)) #define UNITY_TEST_ASSERT_GREATER_OR_EQUAL_FLOAT(threshold, actual, line, message) UnityAssertGreaterOrLessFloat((UNITY_FLOAT)(threshold), (UNITY_FLOAT)(actual), UNITY_GREATER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line)) #define UNITY_TEST_ASSERT_LESS_THAN_FLOAT(threshold, actual, line, message) UnityAssertGreaterOrLessFloat((UNITY_FLOAT)(threshold), (UNITY_FLOAT)(actual), UNITY_SMALLER_THAN, (message), (UNITY_LINE_TYPE)(line)) @@ -1124,9 +1124,9 @@ int UnityTestMatches(void); #define UNITY_TEST_ASSERT_DOUBLE_NOT_WITHIN(delta, expected, actual, line, message) UnityAssertDoublesNotWithin((UNITY_DOUBLE)(delta), (UNITY_DOUBLE)(expected), (UNITY_DOUBLE)(actual), (message), (UNITY_LINE_TYPE)(line)) #define UNITY_TEST_ASSERT_EQUAL_DOUBLE(expected, actual, line, message) UNITY_TEST_ASSERT_DOUBLE_WITHIN((UNITY_DOUBLE)(expected) * (UNITY_DOUBLE)UNITY_DOUBLE_PRECISION, (UNITY_DOUBLE)(expected), (UNITY_DOUBLE)(actual), (UNITY_LINE_TYPE)(line), (message)) #define UNITY_TEST_ASSERT_NOT_EQUAL_DOUBLE(expected, actual, line, message) UNITY_TEST_ASSERT_DOUBLE_NOT_WITHIN((UNITY_DOUBLE)(expected) * (UNITY_DOUBLE)UNITY_DOUBLE_PRECISION, (UNITY_DOUBLE)(expected), (UNITY_DOUBLE)(actual), (UNITY_LINE_TYPE)(line), (message)) -#define UNITY_TEST_ASSERT_DOUBLE_ARRAY_WITHIN(delta, expected, actual, num_elements, line, message) UnityAssertWithinDoubleArray((UNITY_DOUBLE)(delta), (UNITY_DOUBLE*)(expected), (UNITY_DOUBLE*)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_ARRAY_TO_ARRAY) -#define UNITY_TEST_ASSERT_EQUAL_DOUBLE_ARRAY(expected, actual, num_elements, line, message) UnityAssertWithinDoubleArray((UNITY_DOUBLE)0, (UNITY_DOUBLE*)(expected), (UNITY_DOUBLE*)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_ARRAY_TO_ARRAY) -#define UNITY_TEST_ASSERT_EACH_EQUAL_DOUBLE(expected, actual, num_elements, line, message) UnityAssertWithinDoubleArray((UNITY_DOUBLE)0, UnityDoubleToPtr(expected), (UNITY_DOUBLE*)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_ARRAY_TO_VAL) +#define UNITY_TEST_ASSERT_DOUBLE_ARRAY_WITHIN(delta, expected, actual, num_elements, line, message) UnityAssertWithinDoubleArray((UNITY_DOUBLE)(delta), (const UNITY_DOUBLE*)(expected), (const UNITY_DOUBLE*)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_ARRAY_TO_ARRAY) +#define UNITY_TEST_ASSERT_EQUAL_DOUBLE_ARRAY(expected, actual, num_elements, line, message) UnityAssertWithinDoubleArray((UNITY_DOUBLE)0, (const UNITY_DOUBLE*)(expected), (const UNITY_DOUBLE*)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_ARRAY_TO_ARRAY) +#define UNITY_TEST_ASSERT_EACH_EQUAL_DOUBLE(expected, actual, num_elements, line, message) UnityAssertWithinDoubleArray((UNITY_DOUBLE)0, UnityDoubleToPtr(expected), (const UNITY_DOUBLE*)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_ARRAY_TO_VAL) #define UNITY_TEST_ASSERT_GREATER_THAN_DOUBLE(threshold, actual, line, message) UnityAssertGreaterOrLessDouble((UNITY_DOUBLE)(threshold), (UNITY_DOUBLE)(actual), UNITY_GREATER_THAN, (message), (UNITY_LINE_TYPE)(line)) #define UNITY_TEST_ASSERT_GREATER_OR_EQUAL_DOUBLE(threshold, actual, line, message) UnityAssertGreaterOrLessDouble((UNITY_DOUBLE)(threshold), (UNITY_DOUBLE)(actual), UNITY_GREATER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line)) #define UNITY_TEST_ASSERT_LESS_THAN_DOUBLE(threshold, actual, line, message) UnityAssertGreaterOrLessDouble((UNITY_DOUBLE)(threshold), (UNITY_DOUBLE)(actual), UNITY_SMALLER_THAN, (message), (UNITY_LINE_TYPE)(line)) From 278b8dd3e205e78e611f1bc7f8525a4068878be2 Mon Sep 17 00:00:00 2001 From: Mark VanderVoord Date: Mon, 6 Feb 2023 14:49:29 -0500 Subject: [PATCH 357/454] Pull in PR #553. Bump release. --- auto/unity_test_summary.rb | 5 ++++- src/unity.h | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/auto/unity_test_summary.rb b/auto/unity_test_summary.rb index b3fe8a69..c31b1d5f 100644 --- a/auto/unity_test_summary.rb +++ b/auto/unity_test_summary.rb @@ -86,7 +86,10 @@ def usage(err_msg = nil) def get_details(_result_file, lines) results = { failures: [], ignores: [], successes: [] } lines.each do |line| - _src_file, _src_line, _test_name, status, _msg = line.split(/:/) + status_match = line.match(/^[^:]+:[^:]+:\w+(?:\([^\)]*\))?:([^:]+):?/) + next unless status_match + status = status_match.captures[0] + line_out = (@root && (@root != 0) ? "#{@root}#{line}" : line).gsub(/\//, '\\') case status when 'IGNORE' then results[:ignores] << line_out diff --git a/src/unity.h b/src/unity.h index e321a1da..d199f4b2 100644 --- a/src/unity.h +++ b/src/unity.h @@ -9,8 +9,8 @@ #define UNITY #define UNITY_VERSION_MAJOR 2 -#define UNITY_VERSION_MINOR 5 -#define UNITY_VERSION_BUILD 4 +#define UNITY_VERSION_MINOR 6 +#define UNITY_VERSION_BUILD 0 #define UNITY_VERSION ((UNITY_VERSION_MAJOR << 16) | (UNITY_VERSION_MINOR << 8) | UNITY_VERSION_BUILD) #ifdef __cplusplus From 36259d46b6d3aadac7db96ae94fc0e0ea676dc07 Mon Sep 17 00:00:00 2001 From: Mark VanderVoord Date: Mon, 6 Feb 2023 15:15:43 -0500 Subject: [PATCH 358/454] Merge PR #545 --- auto/generate_module.rb | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/auto/generate_module.rb b/auto/generate_module.rb index 7151586b..2f044c4f 100644 --- a/auto/generate_module.rb +++ b/auto/generate_module.rb @@ -13,7 +13,7 @@ require 'pathname' # TEMPLATE_TST -TEMPLATE_TST ||= '#ifdef TEST +TEMPLATE_TST ||= '#ifdef %5$s #include "unity.h" @@ -32,7 +32,7 @@ TEST_IGNORE_MESSAGE("Need to Implement %1$s"); } -#endif // TEST +#endif // %5$s '.freeze # TEMPLATE_SRC @@ -108,7 +108,8 @@ def self.default_options update_svn: false, boilerplates: {}, test_prefix: 'Test', - mock_prefix: 'Mock' + mock_prefix: 'Mock', + test_define: 'TEST' } end @@ -134,7 +135,7 @@ def files_to_operate_on(module_name, pattern = nil) prefix = @options[:test_prefix] || 'Test' triad = [{ ext: '.c', path: @options[:path_src], prefix: '', template: TEMPLATE_SRC, inc: :src, boilerplate: @options[:boilerplates][:src] }, { ext: '.h', path: @options[:path_inc], prefix: '', template: TEMPLATE_INC, inc: :inc, boilerplate: @options[:boilerplates][:inc] }, - { ext: '.c', path: @options[:path_tst], prefix: prefix, template: TEMPLATE_TST, inc: :tst, boilerplate: @options[:boilerplates][:tst] }] + { ext: '.c', path: @options[:path_tst], prefix: prefix, template: TEMPLATE_TST, inc: :tst, boilerplate: @options[:boilerplates][:tst], test_define: @options[:test_define] }] # prepare the pattern for use pattern = (pattern || @options[:pattern] || 'src').downcase @@ -154,6 +155,7 @@ def files_to_operate_on(module_name, pattern = nil) path: (Pathname.new("#{cfg[:path]}#{subfolder}") + filename).cleanpath, name: submodule_name, template: cfg[:template], + test_define: cfg[:test_define] boilerplate: cfg[:boilerplate], includes: case (cfg[:inc]) when :src then (@options[:includes][:src] || []) | (pattern_traits[:inc].map { |f| format(f, module_name) }) @@ -212,7 +214,8 @@ def generate(module_name, pattern = nil) f.write(file[:template] % [file[:name], file[:includes].map { |ff| "#include \"#{ff}\"\n" }.join, file[:name].upcase.tr('-', '_'), - file[:name].tr('-', '_')]) + file[:name].tr('-', '_'), + file[:test_define]]) end if @options[:update_svn] `svn add \"#{file[:path]}\"` From 7a31075b77b998c3a1e992d0516ba0aa00dfea4a Mon Sep 17 00:00:00 2001 From: Mark VanderVoord Date: Mon, 6 Feb 2023 16:26:36 -0500 Subject: [PATCH 359/454] Bump years. --- LICENSE.txt | 2 +- README.md | 2 +- library.json | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/LICENSE.txt b/LICENSE.txt index b9a329dd..a541b843 100644 --- a/LICENSE.txt +++ b/LICENSE.txt @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2007-21 Mike Karlesky, Mark VanderVoord, Greg Williams +Copyright (c) 2007-23 Mike Karlesky, Mark VanderVoord, Greg Williams Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md index e71527b2..1fc220c0 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Unity Test ![CI][] -__Copyright (c) 2007 - 2021 Unity Project by Mike Karlesky, Mark VanderVoord, and Greg Williams__ +__Copyright (c) 2007 - 2023 Unity Project by Mike Karlesky, Mark VanderVoord, and Greg Williams__ Welcome to the Unity Test Project, one of the main projects of ThrowTheSwitch.org. Unity Test is a unit testing framework built for C, with a focus on working with embedded toolchains. diff --git a/library.json b/library.json index b5712943..914f5f68 100644 --- a/library.json +++ b/library.json @@ -1,6 +1,6 @@ { "name": "Unity", - "version": "2.5.2", + "version": "2.6.0", "keywords": "unit-testing, testing, tdd, testing-framework", "description": "Simple Unit Testing for C", "homepage": "http://www.throwtheswitch.org/unity", From 699a391c7859f5d76db20a33af5aa3191a0409af Mon Sep 17 00:00:00 2001 From: Andrew McNulty Date: Mon, 13 Feb 2023 15:55:47 +0100 Subject: [PATCH 360/454] Updates to Meson build system: 1. Use cross-platform `/` operator for path construction. 2. Use `meson.project_source_root()` for correct path resolution of generate_test_runner.rb path when used as a subproject. 3. Bump the minimum required Meson version to '0.56.0' as this is needed for the above changes. --- meson.build | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/meson.build b/meson.build index fbb9444f..94138f55 100644 --- a/meson.build +++ b/meson.build @@ -5,21 +5,22 @@ # license: MIT # project('unity', 'c', - license: 'MIT', - meson_version: '>=0.37.0', - default_options: ['werror=true', 'c_std=c11']) + license: 'MIT', + # `meson.project_source_root()` introduced in 0.56.0 + meson_version: '>=0.56.0', + default_options: [ + 'werror=true', + 'c_std=c11' + ] +) subdir('src') unity_dep = declare_dependency(link_with: unity_lib, include_directories: unity_dir) - -# Get the generate_test_runner script relative to itself or the parent project if it is being used as a subproject -# NOTE: This could be (and probably is) a complete hack - but I haven't yet been able to find a better way.... -if meson.is_subproject() -gen_test_runner_path = find_program(meson.source_root() / 'subprojects/unity/auto/generate_test_runner.rb') -else -gen_test_runner_path = find_program('subprojects/unity/auto/generate_test_runner.rb') -endif - -# Create a generator that we can access from the parent project -gen_test_runner = generator(gen_test_runner_path, output: '@BASENAME@_Runner.c', arguments: ['@INPUT@', '@OUTPUT@'] ) +# Create a generator that can be used by consumers of our build system to generate +# test runners. +gen_test_runner = generator( + find_program(meson.project_source_root() / 'auto' / 'generate_test_runner.rb'), + output: '@BASENAME@_Runner.c', + arguments: ['@INPUT@', '@OUTPUT@'] +) From cd80a79db525d3456ae7a80c3252b314119536fd Mon Sep 17 00:00:00 2001 From: Andrew McNulty Date: Mon, 13 Feb 2023 16:19:39 +0100 Subject: [PATCH 361/454] Add Meson example based on Owen Torres' example. --- .gitignore | 1 + examples/example_1/meson.build | 48 +++++++++++++++++++++++ examples/example_1/readme.txt | 9 ++++- examples/example_1/subprojects/unity.wrap | 3 ++ 4 files changed, 60 insertions(+), 1 deletion(-) create mode 100644 examples/example_1/meson.build create mode 100644 examples/example_1/subprojects/unity.wrap diff --git a/.gitignore b/.gitignore index 7500c746..211683a8 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,7 @@ build/ builddir/ test/sandbox .DS_Store +examples/example_1/subprojects/unity examples/example_1/test1.exe examples/example_1/test2.exe examples/example_2/all_tests.exe diff --git a/examples/example_1/meson.build b/examples/example_1/meson.build new file mode 100644 index 00000000..645eeb99 --- /dev/null +++ b/examples/example_1/meson.build @@ -0,0 +1,48 @@ +project('Unity example', 'c', + license: 'MIT', + default_options: [ + 'c_std=c99', + 'warning_level=3', + ], + meson_version: '>= 0.49.0' +) + +unity_subproject = subproject('unity') +unity_dependency = unity_subproject.get_variable('unity_dep') +unity_gen_runner = unity_subproject.get_variable('gen_test_runner') + +src1 = files([ + 'src' / 'ProductionCode.c', + 'test' / 'TestProductionCode.c', +]) + +src2 = files([ + 'src' / 'ProductionCode2.c', + 'test' / 'TestProductionCode2.c', +]) + +inc = include_directories('src') + +test1 = executable('test1', + sources: [ + src1, + unity_gen_runner.process('test' / 'TestProductionCode.c') + ], + include_directories: [ inc ], + dependencies: [ unity_dependency ], +) + +test('test1', test1, + should_fail: true) + +test2 = executable('test2', + sources: [ + src2, + unity_gen_runner.process('test' / 'TestProductionCode2.c') + ], + include_directories: [ inc ], + dependencies: [ unity_dependency ], +) + +test('test2', test2) + diff --git a/examples/example_1/readme.txt b/examples/example_1/readme.txt index dfed8150..ddddd369 100644 --- a/examples/example_1/readme.txt +++ b/examples/example_1/readme.txt @@ -2,4 +2,11 @@ Example 1 ========= Close to the simplest possible example of Unity, using only basic features. -Run make to build & run the example tests. \ No newline at end of file + +Build and run with Make +--- +Just run `make`. + +Build and run with Meson +--- +Run `meson setup build` to create the build directory, and then `meson test -C build` to build and run the tests. diff --git a/examples/example_1/subprojects/unity.wrap b/examples/example_1/subprojects/unity.wrap new file mode 100644 index 00000000..6df241bd --- /dev/null +++ b/examples/example_1/subprojects/unity.wrap @@ -0,0 +1,3 @@ +[wrap-git] +url = https://github.com/ThrowTheSwitch/Unity.git +revision = head From 44bc9e6dbe40e92b0e9f44cc00c65938f23984b1 Mon Sep 17 00:00:00 2001 From: Andrew McNulty Date: Mon, 13 Feb 2023 17:22:52 +0100 Subject: [PATCH 362/454] Update Meson build system The following features from the CMake build have been implemented: * Library version retrieved from unity.h. * Extension support. * Library, header, and package configuration file installation. This commit is entirely based on existing work by Owen Torres. --- auto/extract_version.py | 15 +++++++++ extras/fixture/src/meson.build | 8 +++++ extras/memory/src/meson.build | 7 +++++ meson.build | 56 +++++++++++++++++++++++++++++++++- meson_options.txt | 2 ++ src/meson.build | 12 +++++--- 6 files changed, 94 insertions(+), 6 deletions(-) create mode 100755 auto/extract_version.py create mode 100644 extras/fixture/src/meson.build create mode 100644 extras/memory/src/meson.build create mode 100644 meson_options.txt diff --git a/auto/extract_version.py b/auto/extract_version.py new file mode 100755 index 00000000..1d137e5b --- /dev/null +++ b/auto/extract_version.py @@ -0,0 +1,15 @@ +#!/usr/bin/env python3 +import re +import sys + +ver_re = re.compile(r"^#define\s+UNITY_VERSION_(?:MAJOR|MINOR|BUILD)\s+(\d+)$") +version = [] + +with open(sys.argv[1], "r") as f: + for line in f: + m = ver_re.match(line) + if m: + version.append(m.group(1)) + +print(".".join(version)) + diff --git a/extras/fixture/src/meson.build b/extras/fixture/src/meson.build new file mode 100644 index 00000000..5d114708 --- /dev/null +++ b/extras/fixture/src/meson.build @@ -0,0 +1,8 @@ +unity_inc += include_directories('.') +unity_src += files('unity_fixture.c') + +install_headers( + 'unity_fixture.h', + 'unity_fixture_internals.h', + subdir: meson.project_name() +) diff --git a/extras/memory/src/meson.build b/extras/memory/src/meson.build new file mode 100644 index 00000000..53a66ca0 --- /dev/null +++ b/extras/memory/src/meson.build @@ -0,0 +1,7 @@ +unity_inc += include_directories('.') +unity_src += files('unity_memory.c') + +install_headers( + 'unity_memory.h', + subdir: meson.project_name() +) diff --git a/meson.build b/meson.build index 94138f55..1a56f275 100644 --- a/meson.build +++ b/meson.build @@ -6,6 +6,17 @@ # project('unity', 'c', license: 'MIT', + + # Set project version to value extracted from unity.h header + version: run_command( + [ + find_program('python', 'python3'), + 'auto' / 'extract_version.py', + 'src' / 'unity.h' + ], + check: true + ).stdout().strip(), + # `meson.project_source_root()` introduced in 0.56.0 meson_version: '>=0.56.0', default_options: [ @@ -14,8 +25,41 @@ project('unity', 'c', ] ) +build_fixture = get_option('extension_fixture').enabled() +build_memory = get_option('extension_memory').enabled() + +unity_src = [] +unity_inc = [] + subdir('src') -unity_dep = declare_dependency(link_with: unity_lib, include_directories: unity_dir) + +if build_fixture + # Building the fixture extension implies building the memory + # extension. + build_memory = true + subdir('extras/fixture/src') +endif + +if build_memory + subdir('extras/memory/src') +endif + +unity_lib = static_library(meson.project_name(), + sources: unity_src, + include_directories: unity_inc, + install: true +) + +unity_dep = declare_dependency( + link_with: unity_lib, + include_directories: unity_inc +) + +# Generate pkg-config file. +pkg = import('pkgconfig') +pkg.generate(unity_lib, + description: 'C Unit testing framework.' +) # Create a generator that can be used by consumers of our build system to generate # test runners. @@ -24,3 +68,13 @@ gen_test_runner = generator( output: '@BASENAME@_Runner.c', arguments: ['@INPUT@', '@OUTPUT@'] ) + +# Summarize. +summary( + { + 'Fixture extension': build_fixture, + 'Memory extension': build_memory, + }, + section: 'Extensions', + bool_yn: true +) diff --git a/meson_options.txt b/meson_options.txt new file mode 100644 index 00000000..10b136f7 --- /dev/null +++ b/meson_options.txt @@ -0,0 +1,2 @@ +option('extension_fixture', type: 'feature', value: 'disabled', description: 'Whether to use the fixture extension.') +option('extension_memory', type: 'feature', value: 'disabled', description: 'Whether to use the memory extension.') diff --git a/src/meson.build b/src/meson.build index fbe4b5bb..4d7751f3 100644 --- a/src/meson.build +++ b/src/meson.build @@ -4,10 +4,12 @@ # # license: MIT # -unity_dir = include_directories('.') -unity_lib = static_library(meson.project_name(), - 'unity.c', - include_directories: unity_dir, - native: true +unity_inc += include_directories('.') +unity_src += files('unity.c') + +install_headers( + 'unity.h', + 'unity_internals.h', + subdir: meson.project_name() ) From 43378c4262a83572615ad241d0c2af0c47c0d844 Mon Sep 17 00:00:00 2001 From: Andrew McNulty Date: Tue, 14 Feb 2023 09:18:13 +0100 Subject: [PATCH 363/454] Implement review feedback for Meson updates. 1. Call the version extraction script directly instead of through a Python returned from `find_program()`. 2. We don't need to use `meson.project_source_root()` as `find_program()` will search relative to the current meson.build script. 3. Lower the required version back to `>= 0.37.0`, and modify some things to get rid of warnings with this version selected. The use of `summary()`, `dict`, and positional arguments in `pkgconfig.generate()` generate warnings with this version so remove `summary()` and dict()`, also pass keyword arguments to `pkgconfig.generate()`. --- meson.build | 29 ++++++++++------------------- meson_options.txt | 4 ++-- 2 files changed, 12 insertions(+), 21 deletions(-) diff --git a/meson.build b/meson.build index 1a56f275..312c4e34 100644 --- a/meson.build +++ b/meson.build @@ -10,23 +10,21 @@ project('unity', 'c', # Set project version to value extracted from unity.h header version: run_command( [ - find_program('python', 'python3'), - 'auto' / 'extract_version.py', - 'src' / 'unity.h' + 'auto/extract_version.py', + 'src/unity.h' ], check: true ).stdout().strip(), - # `meson.project_source_root()` introduced in 0.56.0 - meson_version: '>=0.56.0', + meson_version: '>=0.37.0', default_options: [ 'werror=true', 'c_std=c11' ] ) -build_fixture = get_option('extension_fixture').enabled() -build_memory = get_option('extension_memory').enabled() +build_fixture = get_option('extension_fixture') +build_memory = get_option('extension_memory') unity_src = [] unity_inc = [] @@ -57,24 +55,17 @@ unity_dep = declare_dependency( # Generate pkg-config file. pkg = import('pkgconfig') -pkg.generate(unity_lib, +pkg.generate( + name: meson.project_name(), + version: meson.project_version(), + libraries: [ unity_lib ], description: 'C Unit testing framework.' ) # Create a generator that can be used by consumers of our build system to generate # test runners. gen_test_runner = generator( - find_program(meson.project_source_root() / 'auto' / 'generate_test_runner.rb'), + find_program('auto/generate_test_runner.rb'), output: '@BASENAME@_Runner.c', arguments: ['@INPUT@', '@OUTPUT@'] ) - -# Summarize. -summary( - { - 'Fixture extension': build_fixture, - 'Memory extension': build_memory, - }, - section: 'Extensions', - bool_yn: true -) diff --git a/meson_options.txt b/meson_options.txt index 10b136f7..fbb66d7e 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -1,2 +1,2 @@ -option('extension_fixture', type: 'feature', value: 'disabled', description: 'Whether to use the fixture extension.') -option('extension_memory', type: 'feature', value: 'disabled', description: 'Whether to use the memory extension.') +option('extension_fixture', type: 'boolean', value: 'false', description: 'Whether to enable the fixture extension.') +option('extension_memory', type: 'boolean', value: 'false', description: 'Whether to enable the memory extension.') From fba6be17c744faa71718b4abd675b42f11b471c6 Mon Sep 17 00:00:00 2001 From: Andrew McNulty Date: Tue, 14 Feb 2023 17:53:03 +0100 Subject: [PATCH 364/454] Bump meson_version to '0.47.0' The use of the check kwarg in run_command() was introduced in meson version 0.47.0 --- meson.build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/meson.build b/meson.build index 312c4e34..708b295d 100644 --- a/meson.build +++ b/meson.build @@ -16,7 +16,7 @@ project('unity', 'c', check: true ).stdout().strip(), - meson_version: '>=0.37.0', + meson_version: '>=0.47.0', default_options: [ 'werror=true', 'c_std=c11' From a7639eeb54f532b57859a85f6de1e41df66d61cc Mon Sep 17 00:00:00 2001 From: Mark VanderVoord Date: Thu, 16 Feb 2023 16:40:23 -0500 Subject: [PATCH 365/454] Bump rubocop up to newer ruby versions (in progress) --- auto/colour_reporter.rb | 2 +- auto/generate_module.rb | 2 +- auto/generate_test_runner.rb | 15 +++++++-------- auto/test_file_filter.rb | 1 + auto/type_sanitizer.rb | 2 +- auto/unity_test_summary.rb | 3 ++- auto/yaml_helper.rb | 7 +++++-- examples/example_3/rakefile_helper.rb | 17 ++++++++--------- test/.rubocop.yml | 8 ++++---- 9 files changed, 30 insertions(+), 27 deletions(-) diff --git a/auto/colour_reporter.rb b/auto/colour_reporter.rb index 1c3bc216..b86b76c5 100644 --- a/auto/colour_reporter.rb +++ b/auto/colour_reporter.rb @@ -12,7 +12,7 @@ def report(message) if !$colour_output $stdout.puts(message) else - message = message.join('\n') if message.class == Array + message = message.join('\n') if message.instance_of?(Array) message.each_line do |line| line.chomp! colour = case line diff --git a/auto/generate_module.rb b/auto/generate_module.rb index 2f044c4f..40586f9c 100644 --- a/auto/generate_module.rb +++ b/auto/generate_module.rb @@ -133,7 +133,7 @@ def files_to_operate_on(module_name, pattern = nil) # create triad definition prefix = @options[:test_prefix] || 'Test' - triad = [{ ext: '.c', path: @options[:path_src], prefix: '', template: TEMPLATE_SRC, inc: :src, boilerplate: @options[:boilerplates][:src] }, + triad = [{ ext: '.c', path: @options[:path_src], prefix: '', template: TEMPLATE_SRC, inc: :src, boilerplate: @options[:boilerplates][:src] }, { ext: '.h', path: @options[:path_inc], prefix: '', template: TEMPLATE_INC, inc: :inc, boilerplate: @options[:boilerplates][:inc] }, { ext: '.c', path: @options[:path_tst], prefix: prefix, template: TEMPLATE_TST, inc: :tst, boilerplate: @options[:boilerplates][:tst], test_define: @options[:test_define] }] diff --git a/auto/generate_test_runner.rb b/auto/generate_test_runner.rb index aa0f351d..3d64d486 100755 --- a/auto/generate_test_runner.rb +++ b/auto/generate_test_runner.rb @@ -144,8 +144,8 @@ def find_tests(source) if @options[:use_param_tests] && !arguments.empty? args = [] type_and_args = arguments.split(/TEST_(CASE|RANGE)/) - for i in (1...type_and_args.length).step(2) - if type_and_args[i] == "CASE" + (1...type_and_args.length).step(2).each do |i| + if type_and_args[i] == 'CASE' args << type_and_args[i + 1].sub(/^\s*\(\s*(.*?)\s*\)\s*$/m, '\1') next end @@ -194,12 +194,11 @@ def find_includes(source) source.gsub!(/\/\/.*$/, '') # remove line comments (all that remain) # parse out includes - includes = { - local: source.scan(/^\s*#include\s+\"\s*(.+\.#{@options[:include_extensions]})\s*\"/).flatten, + { + local: source.scan(/^\s*#include\s+"\s*(.+\.#{@options[:include_extensions]})\s*"/).flatten, system: source.scan(/^\s*#include\s+<\s*(.+)\s*>/).flatten.map { |inc| "<#{inc}>" }, - linkonly: source.scan(/^TEST_FILE\(\s*\"\s*(.+\.#{@options[:source_extensions]})\s*\"/).flatten + linkonly: source.scan(/^TEST_FILE\(\s*"\s*(.+\.#{@options[:source_extensions]})\s*"/).flatten } - includes end def find_mocks(includes) @@ -446,7 +445,7 @@ def create_main(output, filename, tests, used_mocks) end def create_h_file(output, filename, tests, testfile_includes, used_mocks) - filename = File.basename(filename).gsub(/[-\/\\\.\,\s]/, '_').upcase + filename = File.basename(filename).gsub(/[-\/\\.,\s]/, '_').upcase output.puts('/* AUTOGENERATED FILE. DO NOT EDIT. */') output.puts("#ifndef _#{filename}") output.puts("#define _#{filename}\n\n") @@ -485,7 +484,7 @@ def create_h_file(output, filename, tests, testfile_includes, used_mocks) when /\.*\.ya?ml$/ options = UnityTestRunnerGenerator.grab_config(arg) true - when /--(\w+)=\"?(.*)\"?/ + when /--(\w+)="?(.*)"?/ options[Regexp.last_match(1).to_sym] = Regexp.last_match(2) true when /\.*\.(?:hpp|hh|H|h)$/ diff --git a/auto/test_file_filter.rb b/auto/test_file_filter.rb index 3cc32de8..f4834a12 100644 --- a/auto/test_file_filter.rb +++ b/auto/test_file_filter.rb @@ -15,6 +15,7 @@ def initialize(all_files = false) file = 'test_file_filter.yml' return unless File.exist?(file) + filters = YamlHelper.load_file(file) @all_files = filters[:all_files] @only_files = filters[:only_files] diff --git a/auto/type_sanitizer.rb b/auto/type_sanitizer.rb index dafb8826..3d1db09f 100644 --- a/auto/type_sanitizer.rb +++ b/auto/type_sanitizer.rb @@ -1,6 +1,6 @@ module TypeSanitizer def self.sanitize_c_identifier(unsanitized) # convert filename to valid C identifier by replacing invalid chars with '_' - unsanitized.gsub(/[-\/\\\.\,\s]/, '_') + unsanitized.gsub(/[-\/\\.,\s]/, '_') end end diff --git a/auto/unity_test_summary.rb b/auto/unity_test_summary.rb index c31b1d5f..0253b5d7 100644 --- a/auto/unity_test_summary.rb +++ b/auto/unity_test_summary.rb @@ -86,8 +86,9 @@ def usage(err_msg = nil) def get_details(_result_file, lines) results = { failures: [], ignores: [], successes: [] } lines.each do |line| - status_match = line.match(/^[^:]+:[^:]+:\w+(?:\([^\)]*\))?:([^:]+):?/) + status_match = line.match(/^[^:]+:[^:]+:\w+(?:\([^)]*\))?:([^:]+):?/) next unless status_match + status = status_match.captures[0] line_out = (@root && (@root != 0) ? "#{@root}#{line}" : line).gsub(/\//, '\\') diff --git a/auto/yaml_helper.rb b/auto/yaml_helper.rb index e5a08657..3296ba0e 100644 --- a/auto/yaml_helper.rb +++ b/auto/yaml_helper.rb @@ -8,8 +8,11 @@ module YamlHelper def self.load(body) - YAML.respond_to?(:unsafe_load) ? - YAML.unsafe_load(body) : YAML.load(body) + if YAML.respond_to?(:unsafe_load) + YAML.unsafe_load(body) + else + YAML.load(body) + end end def self.load_file(file) diff --git a/examples/example_3/rakefile_helper.rb b/examples/example_3/rakefile_helper.rb index 49060750..d88df584 100644 --- a/examples/example_3/rakefile_helper.rb +++ b/examples/example_3/rakefile_helper.rb @@ -42,7 +42,7 @@ def extract_headers(filename) includes = [] lines = File.readlines(filename) lines.each do |line| - m = line.match(/^\s*#include\s+\"\s*(.+\.[hH])\s*\"/) + m = line.match(/^\s*#include\s+"\s*(.+\.[hH])\s*"/) includes << m[1] unless m.nil? end includes @@ -57,12 +57,11 @@ def find_source_file(header, paths) end def tackit(strings) - result = if strings.is_a?(Array) - "\"#{strings.join}\"" - else - strings - end - result + if strings.is_a?(Array) + "\"#{strings.join}\"" + else + strings + end end def squash(prefix, items) @@ -80,7 +79,7 @@ def build_compiler_fields end options = squash('', $cfg['compiler']['options']) includes = squash($cfg['compiler']['includes']['prefix'], $cfg['compiler']['includes']['items']) - includes = includes.gsub(/\\ /, ' ').gsub(/\\\"/, '"').gsub(/\\$/, '') # Remove trailing slashes (for IAR) + includes = includes.gsub(/\\ /, ' ').gsub(/\\"/, '"').gsub(/\\$/, '') # Remove trailing slashes (for IAR) { command: command, defines: defines, options: options, includes: includes } end @@ -105,7 +104,7 @@ def build_linker_fields '' else squash($cfg['linker']['includes']['prefix'], $cfg['linker']['includes']['items']) - end.gsub(/\\ /, ' ').gsub(/\\\"/, '"').gsub(/\\$/, '') # Remove trailing slashes (for IAR) + end.gsub(/\\ /, ' ').gsub(/\\"/, '"').gsub(/\\$/, '') # Remove trailing slashes (for IAR) { command: command, options: options, includes: includes } end diff --git a/test/.rubocop.yml b/test/.rubocop.yml index 6c9542f5..44b01605 100644 --- a/test/.rubocop.yml +++ b/test/.rubocop.yml @@ -3,7 +3,7 @@ #inherit_from: .rubocop_todo.yml AllCops: - TargetRubyVersion: 2.3 + TargetRubyVersion: 3.0 # These are areas where ThrowTheSwitch's coding style diverges from the Ruby standard Style/SpecialGlobalVars: @@ -36,10 +36,12 @@ Style/FormatStringToken: Enabled: false # This is disabled because it seems to get confused over nested hashes -Layout/AlignHash: +Layout/HashAlignment: Enabled: false EnforcedHashRocketStyle: table EnforcedColonStyle: table +Layout/LineLength: + Enabled: false # We purposefully use these insecure features because they're what makes Ruby awesome Security/Eval: @@ -64,8 +66,6 @@ Metrics/ClassLength: Enabled: false Metrics/CyclomaticComplexity: Enabled: false -Metrics/LineLength: - Enabled: false Metrics/MethodLength: Enabled: false Metrics/ModuleLength: From 18482abd9ee11b7bf1e6aef0e4b81eda33a372f7 Mon Sep 17 00:00:00 2001 From: Nir Soffer Date: Tue, 21 Feb 2023 01:26:54 +0200 Subject: [PATCH 366/454] Don't install anything when building as subproject When a project is consuming unity as as subproject, unity headers, static library and pkg config files are installed by `meson install`. This can be fixed by using `meson install --skip-subprojects`, but this must be repeated in all the distros packaging a project. Fixed by disabling install when building as a subproject. Fixes: #661 --- extras/fixture/src/meson.build | 12 +++++++----- extras/memory/src/meson.build | 10 ++++++---- meson.build | 18 ++++++++++-------- src/meson.build | 12 +++++++----- 4 files changed, 30 insertions(+), 22 deletions(-) diff --git a/extras/fixture/src/meson.build b/extras/fixture/src/meson.build index 5d114708..224911de 100644 --- a/extras/fixture/src/meson.build +++ b/extras/fixture/src/meson.build @@ -1,8 +1,10 @@ unity_inc += include_directories('.') unity_src += files('unity_fixture.c') -install_headers( - 'unity_fixture.h', - 'unity_fixture_internals.h', - subdir: meson.project_name() -) +if not meson.is_subproject() + install_headers( + 'unity_fixture.h', + 'unity_fixture_internals.h', + subdir: meson.project_name() + ) +endif diff --git a/extras/memory/src/meson.build b/extras/memory/src/meson.build index 53a66ca0..650ba32d 100644 --- a/extras/memory/src/meson.build +++ b/extras/memory/src/meson.build @@ -1,7 +1,9 @@ unity_inc += include_directories('.') unity_src += files('unity_memory.c') -install_headers( - 'unity_memory.h', - subdir: meson.project_name() -) +if not meson.is_subproject() + install_headers( + 'unity_memory.h', + subdir: meson.project_name() + ) +endif diff --git a/meson.build b/meson.build index 708b295d..c5cf9711 100644 --- a/meson.build +++ b/meson.build @@ -45,7 +45,7 @@ endif unity_lib = static_library(meson.project_name(), sources: unity_src, include_directories: unity_inc, - install: true + install: not meson.is_subproject(), ) unity_dep = declare_dependency( @@ -54,13 +54,15 @@ unity_dep = declare_dependency( ) # Generate pkg-config file. -pkg = import('pkgconfig') -pkg.generate( - name: meson.project_name(), - version: meson.project_version(), - libraries: [ unity_lib ], - description: 'C Unit testing framework.' -) +if not meson.is_subproject() + pkg = import('pkgconfig') + pkg.generate( + name: meson.project_name(), + version: meson.project_version(), + libraries: [ unity_lib ], + description: 'C Unit testing framework.' + ) +endif # Create a generator that can be used by consumers of our build system to generate # test runners. diff --git a/src/meson.build b/src/meson.build index 4d7751f3..5365227f 100644 --- a/src/meson.build +++ b/src/meson.build @@ -8,8 +8,10 @@ unity_inc += include_directories('.') unity_src += files('unity.c') -install_headers( - 'unity.h', - 'unity_internals.h', - subdir: meson.project_name() -) +if not meson.is_subproject() + install_headers( + 'unity.h', + 'unity_internals.h', + subdir: meson.project_name() + ) +endif From 40b573a7846267fe6173287ef7ea5a5aa53487b2 Mon Sep 17 00:00:00 2001 From: Dave Hart Date: Wed, 15 Mar 2023 09:11:08 -0400 Subject: [PATCH 367/454] Use __attribute__((__noreturn__)) instead of __attribute__((noreturn)) to avoid issue with FreeBSD #define noreturn _Noreturn --- src/unity_internals.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/unity_internals.h b/src/unity_internals.h index 30e09668..54c6853d 100644 --- a/src/unity_internals.h +++ b/src/unity_internals.h @@ -77,7 +77,7 @@ #endif #endif #ifndef UNITY_NORETURN - #define UNITY_NORETURN UNITY_FUNCTION_ATTR(noreturn) + #define UNITY_NORETURN UNITY_FUNCTION_ATTR(__noreturn__) #endif /*------------------------------------------------------- From 91ff8c3ee8f48421a1e6c8704960d57f3dea16f8 Mon Sep 17 00:00:00 2001 From: Torgny Lyon Date: Wed, 15 Mar 2023 19:29:58 +0100 Subject: [PATCH 368/454] Fix delta cast for UINT8_ARRAY_WITHIN --- src/unity_internals.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/unity_internals.h b/src/unity_internals.h index 54c6853d..98e298fc 100644 --- a/src/unity_internals.h +++ b/src/unity_internals.h @@ -953,7 +953,7 @@ int UnityTestMatches(void); #define UNITY_TEST_ASSERT_INT16_ARRAY_WITHIN(delta, expected, actual, num_elements, line, message) UnityAssertNumbersArrayWithin((UNITY_UINT16)(delta), (UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), ((UNITY_UINT32)(num_elements)), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT16, UNITY_ARRAY_TO_ARRAY) #define UNITY_TEST_ASSERT_INT32_ARRAY_WITHIN(delta, expected, actual, num_elements, line, message) UnityAssertNumbersArrayWithin((UNITY_UINT32)(delta), (UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), ((UNITY_UINT32)(num_elements)), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT32, UNITY_ARRAY_TO_ARRAY) #define UNITY_TEST_ASSERT_UINT_ARRAY_WITHIN(delta, expected, actual, num_elements, line, message) UnityAssertNumbersArrayWithin( (delta), (UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), ((UNITY_UINT32)(num_elements)), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT, UNITY_ARRAY_TO_ARRAY) -#define UNITY_TEST_ASSERT_UINT8_ARRAY_WITHIN(delta, expected, actual, num_elements, line, message) UnityAssertNumbersArrayWithin((UNITY_UINT16)(delta), (UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), ((UNITY_UINT32)(num_elements)), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT8, UNITY_ARRAY_TO_ARRAY) +#define UNITY_TEST_ASSERT_UINT8_ARRAY_WITHIN(delta, expected, actual, num_elements, line, message) UnityAssertNumbersArrayWithin((UNITY_UINT8 )(delta), (UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), ((UNITY_UINT32)(num_elements)), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT8, UNITY_ARRAY_TO_ARRAY) #define UNITY_TEST_ASSERT_UINT16_ARRAY_WITHIN(delta, expected, actual, num_elements, line, message) UnityAssertNumbersArrayWithin((UNITY_UINT16)(delta), (UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), ((UNITY_UINT32)(num_elements)), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT16, UNITY_ARRAY_TO_ARRAY) #define UNITY_TEST_ASSERT_UINT32_ARRAY_WITHIN(delta, expected, actual, num_elements, line, message) UnityAssertNumbersArrayWithin((UNITY_UINT32)(delta), (UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), ((UNITY_UINT32)(num_elements)), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT32, UNITY_ARRAY_TO_ARRAY) #define UNITY_TEST_ASSERT_HEX8_ARRAY_WITHIN(delta, expected, actual, num_elements, line, message) UnityAssertNumbersArrayWithin((UNITY_UINT8 )(delta), (UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), ((UNITY_UINT32)(num_elements)), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX8, UNITY_ARRAY_TO_ARRAY) From 6a8e03b5a9bfbc442729701f57d8dbbdb1715e53 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jon=20Hangh=C3=B8j=20Henneberg?= Date: Mon, 17 Apr 2023 18:19:51 +0200 Subject: [PATCH 369/454] Fix filename sanitization with command line option When enabling the command line option the file name added to the runner did not escape the slashes on windows in the same way other paths where sanitized. Copied the sanitization from the other filename uses. --- auto/generate_test_runner.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/auto/generate_test_runner.rb b/auto/generate_test_runner.rb index aa0f351d..ace59303 100755 --- a/auto/generate_test_runner.rb +++ b/auto/generate_test_runner.rb @@ -389,7 +389,7 @@ def create_main(output, filename, tests, used_mocks) output.puts(' {') output.puts(' if (parse_status < 0)') output.puts(' {') - output.puts(" UnityPrint(\"#{filename.gsub('.c', '')}.\");") + output.puts(" UnityPrint(\"#{filename.gsub('.c', '').gsub(/\\/, '\\\\\\')}.\");") output.puts(' UNITY_PRINT_EOL();') tests.each do |test| if (!@options[:use_param_tests]) || test[:args].nil? || test[:args].empty? From b35f6b0851d1c5086dc61b0eb382d634ba7aeb2c Mon Sep 17 00:00:00 2001 From: nfarid <54642193+nfarid@users.noreply.github.com> Date: Tue, 30 May 2023 11:40:39 +0100 Subject: [PATCH 370/454] Add CMAKE_INSTALL_INCLUDEDIR to INSTALL_INTERFACE's include directory This allows one to #include --- CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 348266d5..f7062199 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -76,6 +76,7 @@ target_include_directories(${PROJECT_NAME} $ $ $ + $ $:${CMAKE_CURRENT_SOURCE_DIR}/extras/memory/src>> $:${CMAKE_CURRENT_SOURCE_DIR}/extras/fixture/src>> ) From 9e6e6fcb4434c4b468c8b81c7b4348909822813b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?0xHiro=20/=20=E3=83=92=E3=83=AD?= <90010840+0xhiro@users.noreply.github.com> Date: Sun, 4 Jun 2023 12:24:18 +0900 Subject: [PATCH 371/454] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index e71527b2..b5b723b2 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Welcome to the Unity Test Project, one of the main projects of ThrowTheSwitch.or Unity Test is a unit testing framework built for C, with a focus on working with embedded toolchains. This project is made to test code targetting microcontrollers big and small. -The core project is a single C file and a pair of headers, allowing it to the added to your existing build setup without too much headache. +The core project is a single C file and a pair of headers, allowing it to be added to your existing build setup without too much headache. You may use any compiler you wish, and may use most existing build systems including Make, CMake, etc. If you'd like to leave the hard work to us, you might be interested in Ceedling, a build tool also by ThrowTheSwitch.org. From 4d64a170278d4238b75c2022a776430ede773d6a Mon Sep 17 00:00:00 2001 From: Mike Karlesky Date: Mon, 12 Jun 2023 09:58:19 -0400 Subject: [PATCH 372/454] Documentation improvements * Fixed a broken markdown bulleted list * Replaced a missing document link (from the original source of this documentation) with a full sentence explaining the relation of `assert()` to static analysis. * Typographic fixes * Replaced single and double straight quotes with smart quotes where appropriate * Replaced three periods with ellipses where appropriate --- docs/UnityAssertionsReference.md | 105 +++++++++++++++---------------- 1 file changed, 52 insertions(+), 53 deletions(-) diff --git a/docs/UnityAssertionsReference.md b/docs/UnityAssertionsReference.md index 99880d84..0a0e51b6 100644 --- a/docs/UnityAssertionsReference.md +++ b/docs/UnityAssertionsReference.md @@ -10,46 +10,46 @@ Upon boolean False, an assertion stops execution and reports the failure. and easily execute those assertions. - The structure of Unity allows you to easily separate test assertions from source code in, well, test code. -- Unity's assertions: -- Come in many, many flavors to handle different C types and assertion cases. -- Use context to provide detailed and helpful failure messages. -- Document types, expected values, and basic behavior in your source code for +- Unity’s assertions: + - Come in many, many flavors to handle different C types and assertion cases. + - Use context to provide detailed and helpful failure messages. + - Document types, expected values, and basic behavior in your source code for free. -### Unity Is Several Things But Mainly It's Assertions +### Unity Is Several Things But Mainly It’s Assertions One way to think of Unity is simply as a rich collection of assertions you can use to establish whether your source code behaves the way you think it does. Unity provides a framework to easily organize and execute those assertions in test code separate from your source code. -### What's an Assertion? +### What’s an Assertion? At their core, assertions are an establishment of truth - boolean truth. Was this thing equal to that thing? Does that code doohickey have such-and-such property -or not? You get the idea. Assertions are executable code (to appreciate the big -picture on this read up on the difference between -[link:Dynamic Verification and Static Analysis]). A failing assertion stops -execution and reports an error through some appropriate I/O channel (e.g. -stdout, GUI, file, blinky light). +or not? You get the idea. Assertions are executable code. Static analysis is a +valuable approach to improving code quality, but it is not executing your code +in the way an assertion can. A failing assertion stops execution and reports an +error through some appropriate I/O channel (e.g. stdout, GUI, output file, +blinky light). Fundamentally, for dynamic verification all you need is a single assertion -mechanism. In fact, that's what the [assert() macro][] in C's standard library +mechanism. In fact, that’s what the [assert() macro][] in C’s standard library is for. So why not just use it? Well, we can do far better in the reporting -department. C's `assert()` is pretty dumb as-is and is particularly poor for +department. C’s `assert()` is pretty dumb as-is and is particularly poor for handling common data types like arrays, structs, etc. And, without some other -support, it's far too tempting to litter source code with C's `assert()`'s. It's +support, it’s far too tempting to litter source code with C’s `assert()`’s. It’s generally much cleaner, manageable, and more useful to separate test and source code in the way Unity facilitates. -### Unity's Assertions: Helpful Messages _and_ Free Source Code Documentation +### Unity’s Assertions: Helpful Messages _and_ Free Source Code Documentation Asserting a simple truth condition is valuable, but using the context of the -assertion is even more valuable. For instance, if you know you're comparing bit +assertion is even more valuable. For instance, if you know you’re comparing bit flags and not just integers, then why not use that context to give explicit, readable, bit-level feedback when an assertion fails? -That's what Unity's collection of assertions do - capture context to give you +That’s what Unity’s collection of assertions do - capture context to give you helpful, meaningful assertion failure messages. In fact, the assertions themselves also serve as executable documentation about types and values in your source code. So long as your tests remain current with your source and all those @@ -73,12 +73,12 @@ a simple null check). - `Actual` is the value being tested and unlike the other parameters in an assertion construction is the only parameter present in all assertion variants. - `Modifiers` are masks, ranges, bit flag specifiers, floating point deltas. -- `Expected` is your expected value (duh) to compare to an `actual` value; it's +- `Expected` is your expected value (duh) to compare to an `actual` value; it’s marked as an optional parameter because some assertions only need a single `actual` parameter (e.g. null check). - `Size/count` refers to string lengths, number of array elements, etc. -Many of Unity's assertions are clear duplications in that the same data type +Many of Unity’s assertions are clear duplications in that the same data type is handled by several assertions. The differences among these are in how failure messages are presented. For instance, a `_HEX` variant of an assertion prints the expected and actual values of that assertion formatted as hexadecimal. @@ -99,7 +99,7 @@ _Example:_ TEST_ASSERT_X( {modifiers}, {expected}, actual, {size/count} ) ``` -becomes messageified like thus... +becomes messageified like thus… ```c TEST_ASSERT_X_MESSAGE( {modifiers}, {expected}, actual, {size/count}, message ) @@ -108,7 +108,7 @@ TEST_ASSERT_X_MESSAGE( {modifiers}, {expected}, actual, {size/count}, message ) Notes: - The `_MESSAGE` variants intentionally do not support `printf` style formatting - since many embedded projects don't support or avoid `printf` for various reasons. + since many embedded projects don’t support or avoid `printf` for various reasons. It is possible to use `sprintf` before the assertion to assemble a complex fail message, if necessary. - If you want to output a counter value within an assertion fail message (e.g. from @@ -119,7 +119,7 @@ Notes: Unity provides a collection of assertions for arrays containing a variety of types. These are documented in the Array section below. These are almost on par -with the `_MESSAGE`variants of Unity's Asserts in that for pretty much any Unity +with the `_MESSAGE`variants of Unity’s Asserts in that for pretty much any Unity type assertion you can tack on `_ARRAY` and run assertions on an entire block of memory. @@ -144,7 +144,7 @@ Notes: Unity provides a collection of assertions for arrays containing a variety of types which can be compared to a single value as well. These are documented in the Each Equal section below. these are almost on par with the `_MESSAGE` -variants of Unity's Asserts in that for pretty much any Unity type assertion you +variants of Unity’s Asserts in that for pretty much any Unity type assertion you can inject `_EACH_EQUAL` and run assertions on an entire block of memory. ```c @@ -203,7 +203,7 @@ code then verifies as a final step. #### `TEST_PASS_MESSAGE("message")` This will abort the remainder of the test, but count the test as a pass. Under -normal circumstances, it is not necessary to include this macro in your tests... +normal circumstances, it is not necessary to include this macro in your tests… a lack of failure will automatically be counted as a `PASS`. It is occasionally useful for tests with `#ifdef`s and such. @@ -392,7 +392,7 @@ Asserts that the pointers point to the same memory location. #### `TEST_ASSERT_EQUAL_STRING (expected, actual)` -Asserts that the null terminated (`'\0'`)strings are identical. If strings are +Asserts that the null terminated (`’\0’`)strings are identical. If strings are of different lengths or any portion of the strings before their terminators differ, the assertion fails. Two NULL strings (i.e. zero length) are considered equivalent. @@ -561,7 +561,7 @@ Asserts that the `actual` value is NOT within +/- `delta` of the `expected` valu #### `TEST_ASSERT_EQUAL_FLOAT (expected, actual)` -Asserts that the `actual` value is "close enough to be considered equal" to the +Asserts that the `actual` value is “close enough to be considered equal” to the `expected` value. If you are curious about the details, refer to the Advanced Asserting section for more details on this. Omitting a user-specified delta in a floating point assertion is both a shorthand convenience and a requirement of @@ -569,7 +569,7 @@ code generation conventions for CMock. #### `TEST_ASSERT_NOT_EQUAL_FLOAT (expected, actual)` -Asserts that the `actual` value is NOT "close enough to be considered equal" to the +Asserts that the `actual` value is NOT “close enough to be considered equal” to the `expected` value. #### `TEST_ASSERT_FLOAT_ARRAY_WITHIN (delta, expected, actual, num_elements)` @@ -662,7 +662,7 @@ Asserts that the `actual` value is NOT within +/- `delta` of the `expected` valu #### `TEST_ASSERT_EQUAL_DOUBLE (expected, actual)` -Asserts that the `actual` value is "close enough to be considered equal" to the +Asserts that the `actual` value is “close enough to be considered equal” to the `expected` value. If you are curious about the details, refer to the Advanced Asserting section for more details. Omitting a user-specified delta in a floating point assertion is both a shorthand convenience and a requirement of @@ -670,7 +670,7 @@ code generation conventions for CMock. #### `TEST_ASSERT_NOT_EQUAL_DOUBLE (expected, actual)` -Asserts that the `actual` value is NOT "close enough to be considered equal" to the +Asserts that the `actual` value is NOT “close enough to be considered equal” to the `expected` value. #### `TEST_ASSERT_DOUBLE_ARRAY_WITHIN (delta, expected, actual, num_elements)` @@ -753,7 +753,7 @@ Not A Number floating point representations. This section helps you understand how to deal with some of the trickier assertion situations you may run into. It will give you a glimpse into some of -the under-the-hood details of Unity's assertion mechanisms. If you're one of +the under-the-hood details of Unity’s assertion mechanisms. If you’re one of those people who likes to know what is going on in the background, read on. If not, feel free to ignore the rest of this document until you need it. @@ -768,9 +768,9 @@ mathematical operations might result in a representation of 8 x 2-2 that also evaluates to a value of 2. At some point repeated operations cause equality checks to fail. -So Unity doesn't do direct floating point comparisons for equality. Instead, it -checks if two floating point values are "really close." If you leave Unity -running with defaults, "really close" means "within a significant bit or two." +So Unity doesn’t do direct floating point comparisons for equality. Instead, it +checks if two floating point values are “really close.” If you leave Unity +running with defaults, “really close” means “within a significant bit or two.” Under the hood, `TEST_ASSERT_EQUAL_FLOAT` is really `TEST_ASSERT_FLOAT_WITHIN` with the `delta` parameter calculated on the fly. For single precision, delta is the expected value multiplied by 0.00001, producing a very small proportional @@ -779,28 +779,27 @@ range around the expected value. If you are expecting a value of 20,000.0 the delta is calculated to be 0.2. So any value between 19,999.8 and 20,000.2 will satisfy the equality check. This works out to be roughly a single bit of range for a single-precision number, and -that's just about as tight a tolerance as you can reasonably get from a floating +that’s just about as tight a tolerance as you can reasonably get from a floating point value. -So what happens when it's zero? Zero - even more than other floating point -values - can be represented many different ways. It doesn't matter if you have -0 x 20 or 0 x 263.It's still zero, right? Luckily, if you -subtract these values from each other, they will always produce a difference of -zero, which will still fall between 0 plus or minus a delta of 0. So it still -works! +So what happens when it’s zero? Zero - even more than other floating point +values - can be represented many different ways. It doesn’t matter if you have +0x20 or 0x263. It’s still zero, right? Luckily, if you subtract these +values from each other, they will always produce a difference of zero, which +will still fall between 0 plus or minus a delta of 0. So it still works! Double precision floating point numbers use a much smaller multiplier, again approximating a single bit of error. -If you don't like these ranges and you want to make your floating point equality +If you don’t like these ranges and you want to make your floating point equality assertions less strict, you can change these multipliers to whatever you like by defining UNITY_FLOAT_PRECISION and UNITY_DOUBLE_PRECISION. See Unity documentation for more. ### How do we deal with targets with non-standard int sizes? -It's "fun" that C is a standard where something as fundamental as an integer -varies by target. According to the C standard, an `int` is to be the target's +It’s “fun” that C is a standard where something as fundamental as an integer +varies by target. According to the C standard, an `int` is to be the target’s natural register size, and it should be at least 16-bits and a multiple of a byte. It also guarantees an order of sizes: @@ -814,7 +813,7 @@ and this remains perfectly standard C. To make things even more interesting, there are compilers and targets out there that have a hard choice to make. What if their natural register size is 10-bits -or 12-bits? Clearly they can't fulfill _both_ the requirement to be at least +or 12-bits? Clearly they can’t fulfill _both_ the requirement to be at least 16-bits AND the requirement to match the natural register size. In these situations, they often choose the natural register size, leaving us with something like this: @@ -823,24 +822,24 @@ something like this: char (8 bit) <= short (12 bit) <= int (12 bit) <= long (16 bit) ``` -Um... yikes. It's obviously breaking a rule or two... but they had to break SOME +Um… yikes. It’s obviously breaking a rule or two… but they had to break SOME rules, so they made a choice. When the C99 standard rolled around, it introduced alternate standard-size types. It also introduced macros for pulling in MIN/MAX values for your integer types. -It's glorious! Unfortunately, many embedded compilers can't be relied upon to +It’s glorious! Unfortunately, many embedded compilers can’t be relied upon to use the C99 types (Sometimes because they have weird register sizes as described -above. Sometimes because they don't feel like it?). +above. Sometimes because they don’t feel like it?). A goal of Unity from the beginning was to support every combination of -microcontroller or microprocessor and C compiler. Over time, we've gotten really +microcontroller or microprocessor and C compiler. Over time, we’ve gotten really close to this. There are a few tricks that you should be aware of, though, if -you're going to do this effectively on some of these more idiosyncratic targets. +you’re going to do this effectively on some of these more idiosyncratic targets. -First, when setting up Unity for a new target, you're going to want to pay +First, when setting up Unity for a new target, you’re going to want to pay special attention to the macros for automatically detecting types (where available) or manually configuring them yourself. You can get information -on both of these in Unity's documentation. +on both of these in Unity’s documentation. What about the times where you suddenly need to deal with something odd, like a 24-bit `int`? The simplest solution is to use the next size up. If you have a @@ -848,9 +847,9 @@ What about the times where you suddenly need to deal with something odd, like a `int`, configure Unity to use 16 bits. There are two ways this is going to affect you: -1. When Unity displays errors for you, it's going to pad the upper unused bits +1. When Unity displays errors for you, it’s going to pad the upper unused bits with zeros. -2. You're going to have to be careful of assertions that perform signed +2. You’re going to have to be careful of assertions that perform signed operations, particularly `TEST_ASSERT_INT_WITHIN`. Such assertions might wrap your `int` in the wrong place, and you could experience false failures. You can always back down to a simple `TEST_ASSERT` and do the operations yourself. From e271a76a11df631702af5b2e3e4e5a27a08388cd Mon Sep 17 00:00:00 2001 From: James Browning Date: Tue, 4 Jul 2023 15:16:47 -0700 Subject: [PATCH 373/454] Squash warnings about unhandled enumeration. --- src/unity.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/unity.c b/src/unity.c index 3e4bc04d..8c946ebe 100644 --- a/src/unity.c +++ b/src/unity.c @@ -1115,6 +1115,7 @@ void UnityAssertFloatSpecial(const UNITY_FLOAT actual, is_trait = !isinf(actual) && !isnan(actual); break; + case UNITY_FLOAT_INVALID_TRAIT: /* Supress warning */ default: /* including UNITY_FLOAT_INVALID_TRAIT */ trait_index = 0; trait_names[0] = UnityStrInvalidFloatTrait; @@ -1341,6 +1342,7 @@ void UnityAssertDoubleSpecial(const UNITY_DOUBLE actual, is_trait = !isinf(actual) && !isnan(actual); break; + case UNITY_FLOAT_INVALID_TRAIT: /* Supress warning */ default: /* including UNITY_FLOAT_INVALID_TRAIT */ trait_index = 0; trait_names[0] = UnityStrInvalidFloatTrait; From 30b1a05c33cda2489ea2ff1259d3c12f05c2b93c Mon Sep 17 00:00:00 2001 From: Alex Overchenko Date: Sat, 8 Jul 2023 23:15:15 +0300 Subject: [PATCH 374/454] Fix TEST_CASE description typo --- docs/UnityHelperScriptsGuide.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/UnityHelperScriptsGuide.md b/docs/UnityHelperScriptsGuide.md index 06c34ea6..8b1e6372 100644 --- a/docs/UnityHelperScriptsGuide.md +++ b/docs/UnityHelperScriptsGuide.md @@ -220,7 +220,7 @@ If we use replace comment before test function with the following code: ```C TEST_CASE(1, 2, 5) -TEST_CASE(3, 7, 20) +TEST_CASE(10, 7, 20) ``` script will generate 2 test calls: From 8a5918b81d313fc902c7b51fdf7070f7d09435d0 Mon Sep 17 00:00:00 2001 From: Jason Heeris Date: Thu, 13 Jul 2023 14:53:21 +0800 Subject: [PATCH 375/454] Expose double support as an option. --- meson.build | 7 +++++++ meson_options.txt | 1 + 2 files changed, 8 insertions(+) diff --git a/meson.build b/meson.build index c5cf9711..6585129c 100644 --- a/meson.build +++ b/meson.build @@ -25,7 +25,9 @@ project('unity', 'c', build_fixture = get_option('extension_fixture') build_memory = get_option('extension_memory') +support_double = get_option('support_double') +unity_args = [] unity_src = [] unity_inc = [] @@ -42,8 +44,13 @@ if build_memory subdir('extras/memory/src') endif +if support_double + unity_args += '-DUNITY_INCLUDE_DOUBLE' +endif + unity_lib = static_library(meson.project_name(), sources: unity_src, + c_args: unity_args, include_directories: unity_inc, install: not meson.is_subproject(), ) diff --git a/meson_options.txt b/meson_options.txt index fbb66d7e..8e66784b 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -1,2 +1,3 @@ option('extension_fixture', type: 'boolean', value: 'false', description: 'Whether to enable the fixture extension.') option('extension_memory', type: 'boolean', value: 'false', description: 'Whether to enable the memory extension.') +option('support_double', type: 'boolean', value: 'false', description: 'Whether to enable double precision floating point assertions.') From d59381763041ba09ac2387793275477d2f86b387 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jon=20Hangh=C3=B8j=20Henneberg?= Date: Thu, 13 Jul 2023 22:35:53 +0200 Subject: [PATCH 376/454] Add TEST_MATIX option for parameterization Added matrix option for parameterization that generates cases based on the product of the given arguments. --- auto/generate_test_runner.rb | 49 +++++++++++++++++++++++------------- src/unity.h | 2 +- src/unity_internals.h | 3 +++ 3 files changed, 35 insertions(+), 19 deletions(-) diff --git a/auto/generate_test_runner.rb b/auto/generate_test_runner.rb index ace59303..4fc83f68 100755 --- a/auto/generate_test_runner.rb +++ b/auto/generate_test_runner.rb @@ -132,8 +132,8 @@ def find_tests(source) lines.each_with_index do |line, _index| # find tests - next unless line =~ /^((?:\s*(?:TEST_CASE|TEST_RANGE)\s*\(.*?\)\s*)*)\s*void\s+((?:#{@options[:test_prefix]}).*)\s*\(\s*(.*)\s*\)/m - next unless line =~ /^((?:\s*(?:TEST_CASE|TEST_RANGE)\s*\(.*?\)\s*)*)\s*void\s+((?:#{@options[:test_prefix]})\w*)\s*\(\s*(.*)\s*\)/m + next unless line =~ /^((?:\s*(?:TEST_(?:CASE|RANGE|MATRIX))\s*\(.*?\)\s*)*)\s*void\s+((?:#{@options[:test_prefix]}).*)\s*\(\s*(.*)\s*\)/m + next unless line =~ /^((?:\s*(?:TEST_(?:CASE|RANGE|MATRIX))\s*\(.*?\)\s*)*)\s*void\s+((?:#{@options[:test_prefix]})\w*)\s*\(\s*(.*)\s*\)/m arguments = Regexp.last_match(1) name = Regexp.last_match(2) @@ -143,25 +143,38 @@ def find_tests(source) if @options[:use_param_tests] && !arguments.empty? args = [] - type_and_args = arguments.split(/TEST_(CASE|RANGE)/) + type_and_args = arguments.split(/TEST_(CASE|RANGE|MATRIX)/) for i in (1...type_and_args.length).step(2) - if type_and_args[i] == "CASE" + case type_and_args[i] + when "CASE" args << type_and_args[i + 1].sub(/^\s*\(\s*(.*?)\s*\)\s*$/m, '\1') - next - end - # RANGE - args += type_and_args[i + 1].scan(/(\[|<)\s*(-?\d+.?\d*)\s*,\s*(-?\d+.?\d*)\s*,\s*(-?\d+.?\d*)\s*(\]|>)/m).map do |arg_values_str| - exclude_end = arg_values_str[0] == '<' && arg_values_str[-1] == '>' - arg_values_str[1...-1].map do |arg_value_str| - arg_value_str.include?('.') ? arg_value_str.to_f : arg_value_str.to_i - end.push(exclude_end) - end.map do |arg_values| - Range.new(arg_values[0], arg_values[1], arg_values[3]).step(arg_values[2]).to_a - end.reduce(nil) do |result, arg_range_expanded| - result.nil? ? arg_range_expanded.map { |a| [a] } : result.product(arg_range_expanded) - end.map do |arg_combinations| - arg_combinations.flatten.join(', ') + when "RANGE" + args += type_and_args[i + 1].scan(/(\[|<)\s*(-?\d+.?\d*)\s*,\s*(-?\d+.?\d*)\s*,\s*(-?\d+.?\d*)\s*(\]|>)/m).map do |arg_values_str| + exclude_end = arg_values_str[0] == '<' && arg_values_str[-1] == '>' + arg_values_str[1...-1].map do |arg_value_str| + arg_value_str.include?('.') ? arg_value_str.to_f : arg_value_str.to_i + end.push(exclude_end) + end.map do |arg_values| + Range.new(arg_values[0], arg_values[1], arg_values[3]).step(arg_values[2]).to_a + end.reduce(nil) do |result, arg_range_expanded| + result.nil? ? arg_range_expanded.map { |a| [a] } : result.product(arg_range_expanded) + end.map do |arg_combinations| + arg_combinations.flatten.join(', ') + end + + when "MATRIX" + single_arg_regex_string = /(?:(?:"(?:\\"|[^\\])*?")+|(?:'\\?.')+|(?:[^\s\]\["'\,]|\[[\d\S_-]+\])+)/.source + args_regex = /\[((?:\s*#{single_arg_regex_string}\s*,?)*(?:\s*#{single_arg_regex_string})?\s*)\]/m + arg_elements_regex = /\s*(#{single_arg_regex_string})\s*,\s*/m + + args += type_and_args[i + 1].scan(args_regex).flatten.map do |arg_values_str| + (arg_values_str + ',').scan(arg_elements_regex) + end.reduce do |result, arg_range_expanded| + result.product(arg_range_expanded) + end.map do |arg_combinations| + arg_combinations.flatten.join(', ') + end end end end diff --git a/src/unity.h b/src/unity.h index e321a1da..e4db3147 100644 --- a/src/unity.h +++ b/src/unity.h @@ -89,7 +89,7 @@ void verifyTest(void); * - define UNITY_SUPPORT_TEST_CASES to include the TEST_CASE macro, though really it's mostly about the runner generator script * Parameterized Tests - * - you'll want to create a define of TEST_CASE(...) and/or TEST_RANGE(...) which basically evaluates to nothing + * - you'll want to create a define of TEST_CASE(...), TEST_RANGE(...) and/or TEST_MATRIX(...) which basically evaluates to nothing * Tests with Arguments * - you'll want to define UNITY_USE_COMMAND_LINE_ARGS if you have the test runner passing arguments to Unity diff --git a/src/unity_internals.h b/src/unity_internals.h index 98e298fc..9f89eda9 100644 --- a/src/unity_internals.h +++ b/src/unity_internals.h @@ -793,6 +793,9 @@ extern const char UnityStrErrShorthand[]; #if !defined(TEST_RANGE) && !defined(UNITY_EXCLUDE_TEST_RANGE) #define TEST_RANGE(...) #endif + #if !defined(TEST_MATRIX) && !defined(UNITY_EXCLUDE_TEST_MATRIX) + #define TEST_MATRIX(...) + #endif #endif #endif From 5dd2be96fa64d2c09cc040f531ce9c384690746c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jon=20Hangh=C3=B8j=20Henneberg?= Date: Thu, 13 Jul 2023 23:01:13 +0200 Subject: [PATCH 377/454] Add TEST_MATRIX to docs --- docs/UnityConfigurationGuide.md | 4 +- docs/UnityHelperScriptsGuide.md | 87 +++++++++++++++++++++++++++++++++ 2 files changed, 90 insertions(+), 1 deletion(-) diff --git a/docs/UnityConfigurationGuide.md b/docs/UnityConfigurationGuide.md index d5e4098f..88603fc8 100644 --- a/docs/UnityConfigurationGuide.md +++ b/docs/UnityConfigurationGuide.md @@ -448,7 +448,7 @@ To enable it, use the following example: #define UNITY_SUPPORT_TEST_CASES ``` -You can manually provide required `TEST_CASE` or `TEST_RANGE` macro definitions +You can manually provide required `TEST_CASE`, `TEST_RANGE` or `TEST_MATRIX` macro definitions before including `unity.h`, and they won't be redefined. If you provide one of the following macros, some of default definitions will not be defined: @@ -456,8 +456,10 @@ defined: |---|---| | `UNITY_EXCLUDE_TEST_CASE` | `TEST_CASE` | | `UNITY_EXCLUDE_TEST_RANGE` | `TEST_RANGE` | +| `UNITY_EXCLUDE_TEST_MATRIX` | `TEST_MATRIX` | | `TEST_CASE` | `TEST_CASE` | | `TEST_RANGE` | `TEST_RANGE` | +| `TEST_MATRIX` | `TEST_MATRIX` | `UNITY_EXCLUDE_TEST_*` defines is not processed by test runner generator script. If you exclude one of them from definition, you should provide your own definition diff --git a/docs/UnityHelperScriptsGuide.md b/docs/UnityHelperScriptsGuide.md index 8b1e6372..3c321336 100644 --- a/docs/UnityHelperScriptsGuide.md +++ b/docs/UnityHelperScriptsGuide.md @@ -296,6 +296,93 @@ TEST_CASE(4, 8, 30) TEST_CASE(4, 6, 30) ``` +##### `TEST_MATRIX` + +Test matix is an advanced generator. It single call can be converted to zero, +one or few `TEST_CASE` equivalent commands. + +That generator will create tests for all cobinations of the provided list. Each argument has to be given as a list of one or more elements in the format `[, , ..., , ]`. + +All parameters supported by the `TEST_CASE` is supported as arguments: +- Numbers incl type specifiers e.g. `<1>`, `<1u>`, `<1l>`, `<2.3>`, or `<2.3f>` +- Strings incl string concatianion e.g. `<"string">`, or `<"partial" "string">` +- Chars e.g. `<'c'>` +- Enums e.g. `` +- Elements of arrays e.g. `` + +Let's use our `test_demoParamFunction` test for checking, what ranges +will be generated for our single `TEST_RANGE` row: + +```C +TEST_MATRIX([3, 4, 7], [10, 8, 2, 1],[30u, 20.0f]) +``` + +Tests execution output will be similar to that text: + +```Log +tests/test_unity_parameterizedDemo.c:18:test_demoParamFunction(3, 10, 30u):PASS +tests/test_unity_parameterizedDemo.c:18:test_demoParamFunction(3, 10, 20.0f):PASS +tests/test_unity_parameterizedDemo.c:18:test_demoParamFunction(3, 8, 30u):PASS +tests/test_unity_parameterizedDemo.c:18:test_demoParamFunction(3, 8, 20.0f):PASS +tests/test_unity_parameterizedDemo.c:18:test_demoParamFunction(3, 2, 30u):PASS +tests/test_unity_parameterizedDemo.c:18:test_demoParamFunction(3, 2, 20.0f):PASS +tests/test_unity_parameterizedDemo.c:18:test_demoParamFunction(3, 1, 30u):PASS +tests/test_unity_parameterizedDemo.c:18:test_demoParamFunction(3, 1, 20.0f):PASS +tests/test_unity_parameterizedDemo.c:18:test_demoParamFunction(4, 10, 30u):PASS +tests/test_unity_parameterizedDemo.c:18:test_demoParamFunction(4, 10, 20.0f):PASS +tests/test_unity_parameterizedDemo.c:18:test_demoParamFunction(4, 8, 30u):PASS +tests/test_unity_parameterizedDemo.c:18:test_demoParamFunction(4, 8, 20.0f):PASS +tests/test_unity_parameterizedDemo.c:18:test_demoParamFunction(4, 2, 30u):PASS +tests/test_unity_parameterizedDemo.c:18:test_demoParamFunction(4, 2, 20.0f):PASS +tests/test_unity_parameterizedDemo.c:18:test_demoParamFunction(4, 1, 30u):PASS +tests/test_unity_parameterizedDemo.c:18:test_demoParamFunction(4, 1, 20.0f):PASS +tests/test_unity_parameterizedDemo.c:18:test_demoParamFunction(7, 10, 30u):PASS +tests/test_unity_parameterizedDemo.c:18:test_demoParamFunction(7, 10, 20.0f):PASS +tests/test_unity_parameterizedDemo.c:18:test_demoParamFunction(7, 8, 30u):PASS +tests/test_unity_parameterizedDemo.c:18:test_demoParamFunction(7, 8, 20.0f):PASS +tests/test_unity_parameterizedDemo.c:18:test_demoParamFunction(7, 2, 30u):PASS +tests/test_unity_parameterizedDemo.c:18:test_demoParamFunction(7, 2, 20.0f):PASS +tests/test_unity_parameterizedDemo.c:18:test_demoParamFunction(7, 1, 30u):PASS +tests/test_unity_parameterizedDemo.c:18:test_demoParamFunction(7, 1, 20.0f):PASS +``` + +As we can see: + +| Parameter | Format | Count of values | +|---|---|---| +| `a` | `[3, 4, 7]` | 2 | +| `b` | `[10, 8, 2, 1]` | 4 | +| `c` | `[30u, 20.0f]` | 2 | + +We totally have 2 * 4 * 2 = 16 equal test cases, that can be written as following: + +```C +TEST_CASE(3, 10, 30u) +TEST_CASE(3, 10, 20.0f) +TEST_CASE(3, 8, 30u) +TEST_CASE(3, 8, 20.0f) +TEST_CASE(3, 2, 30u) +TEST_CASE(3, 2, 20.0f) +TEST_CASE(3, 1, 30u) +TEST_CASE(3, 1, 20.0f) +TEST_CASE(4, 10, 30u) +TEST_CASE(4, 10, 20.0f) +TEST_CASE(4, 8, 30u) +TEST_CASE(4, 8, 20.0f) +TEST_CASE(4, 2, 30u) +TEST_CASE(4, 2, 20.0f) +TEST_CASE(4, 1, 30u) +TEST_CASE(4, 1, 20.0f) +TEST_CASE(7, 10, 30u) +TEST_CASE(7, 10, 20.0f) +TEST_CASE(7, 8, 30u) +TEST_CASE(7, 8, 20.0f) +TEST_CASE(7, 2, 30u) +TEST_CASE(7, 2, 20.0f) +TEST_CASE(7, 1, 30u) +TEST_CASE(7, 1, 20.0f) +``` + ### `unity_test_summary.rb` A Unity test file contains one or more test case functions. From c97a2705b36a23f4a09228daddaae9d94d41fc1e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jon=20Hangh=C3=B8j=20Henneberg?= Date: Thu, 13 Jul 2023 22:36:23 +0200 Subject: [PATCH 378/454] Add tests for TEST_MATRIX --- test/tests/test_unity_parameterized.c | 90 +++++++++++++++++++++++ test/tests/test_unity_parameterizedDemo.c | 4 + test/tests/types_for_test.h | 14 ++++ 3 files changed, 108 insertions(+) create mode 100644 test/tests/types_for_test.h diff --git a/test/tests/test_unity_parameterized.c b/test/tests/test_unity_parameterized.c index 6b8aeb79..24e1f9cd 100644 --- a/test/tests/test_unity_parameterized.c +++ b/test/tests/test_unity_parameterized.c @@ -7,6 +7,7 @@ #include #include #include "unity.h" +#include "types_for_test.h" /* Include Passthroughs for Linking Tests */ void putcharSpy(int c) { (void)putchar(c);} @@ -209,6 +210,14 @@ TEST_RANGE([2, TEST_CASE( 6 , 7) +TEST_MATRIX([7, + 8 , + + 9, 10], + [ + 11] + + ) void test_SpaceInTestCase(unsigned index, unsigned bigger) { TEST_ASSERT_EQUAL_UINT32(NextExpectedSpaceIndex, index); @@ -216,3 +225,84 @@ void test_SpaceInTestCase(unsigned index, unsigned bigger) NextExpectedSpaceIndex++; } + +TEST_MATRIX([1, 5, (2*2)+1, 4]) +void test_SingleMatix(unsigned value) +{ + TEST_ASSERT_LESS_OR_EQUAL(10, value); +} + +TEST_MATRIX([2, 5l, 4u+3, 4ul], [-2, 3]) +void test_TwoMatrices(unsigned first, signed second) +{ + static unsigned idx = 0; + static const unsigned expected[] = + { + // -2 3 + -4, 6, // 2 + -10, 15, // 5 + -14, 21, // 7 + -8, 12, // 4 + }; + TEST_ASSERT_EQUAL_INT(expected[idx++], first * second); +} + +TEST_MATRIX(["String1", "String,2", "Stri" "ng3", "String[4]", "String\"5\""], [-5, 12.5f]) +void test_StringsAndNumbersMatrices(const char* str, float number) +{ + static unsigned idx = 0; + static const char* expected[] = + { + "String1_-05.00", + "String1_+12.50", + "String,2_-05.00", + "String,2_+12.50", + "String3_-05.00", + "String3_+12.50", + "String[4]_-05.00", + "String[4]_+12.50", + "String\"5\"_-05.00", + "String\"5\"_+12.50", + }; + char buf[200] = {0}; + snprintf(buf, sizeof(buf), "%s_%+06.2f", str, number); + TEST_ASSERT_EQUAL_STRING(expected[idx++], buf); +} + +TEST_MATRIX( + [ENUM_A, ENUM_4, ENUM_C], + [test_arr[0], 7.8f, test_arr[2]], + ['a', 'f', '[', ']', '\'', '"'], +) +void test_EnumCharAndArrayMatrices(test_enum_t e, float n, char c) +{ + static unsigned enum_idx = 0; + static const test_enum_t exp_enum[3] = { + ENUM_A, ENUM_4, ENUM_C, + }; + + static unsigned float_idx = 0; + float exp_float[3] = {0}; + exp_float[0] = test_arr[0]; + exp_float[1] = 7.8f; + exp_float[2] = test_arr[2]; + + static unsigned char_idx = 0; + static const test_enum_t exp_char[] = { + 'a', 'f', '[', ']', '\'', '"' + }; + + TEST_ASSERT_EQUAL_INT(exp_enum[enum_idx], e); + TEST_ASSERT_EQUAL_FLOAT(exp_float[float_idx], n); + TEST_ASSERT_EQUAL_CHAR(exp_char[char_idx], c); + + char_idx = (char_idx + 1) % 6; + if (char_idx == 0.0f) + { + float_idx = (float_idx + 1) % 3; + if (float_idx == 0.0f) + { + enum_idx = (enum_idx + 1) % 3; + } + } +} \ No newline at end of file diff --git a/test/tests/test_unity_parameterizedDemo.c b/test/tests/test_unity_parameterizedDemo.c index 2e2efc8f..83dfad66 100644 --- a/test/tests/test_unity_parameterizedDemo.c +++ b/test/tests/test_unity_parameterizedDemo.c @@ -7,10 +7,14 @@ #ifndef TEST_RANGE #define TEST_RANGE(...) #endif +#ifndef TEST_MATRIX +#define TEST_MATRIX(...) +#endif TEST_CASE(1, 2, 5) TEST_CASE(10, 7, 20) TEST_RANGE([3, 4, 1], [10, 5, -2], <30, 31, 1>) +TEST_MATRIX([3, 4, 7], [10, 8, 2, 1],[30u, 20.0f]) void test_demoParamFunction(int a, int b, int c) { TEST_ASSERT_GREATER_THAN_INT(a + b, c); diff --git a/test/tests/types_for_test.h b/test/tests/types_for_test.h new file mode 100644 index 00000000..8bae1eca --- /dev/null +++ b/test/tests/types_for_test.h @@ -0,0 +1,14 @@ +#pragma once + +typedef enum { + ENUM_A, + ENUM_2, + ENUM_C, + ENUM_4, +} test_enum_t; + +static const float test_arr[] = { + 1.2f, + 2.3f, + 3.4f, +}; \ No newline at end of file From 5baa4580eebdbebc7eba4797cb46a5df17016470 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jon=20Hangh=C3=B8j=20Henneberg?= Date: Sat, 15 Jul 2023 22:19:46 +0200 Subject: [PATCH 379/454] Fix file endings --- test/tests/test_unity_parameterized.c | 2 +- test/tests/types_for_test.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/test/tests/test_unity_parameterized.c b/test/tests/test_unity_parameterized.c index 24e1f9cd..aa9f9c16 100644 --- a/test/tests/test_unity_parameterized.c +++ b/test/tests/test_unity_parameterized.c @@ -305,4 +305,4 @@ void test_EnumCharAndArrayMatrices(test_enum_t e, float n, char c) enum_idx = (enum_idx + 1) % 3; } } -} \ No newline at end of file +} diff --git a/test/tests/types_for_test.h b/test/tests/types_for_test.h index 8bae1eca..6da4e515 100644 --- a/test/tests/types_for_test.h +++ b/test/tests/types_for_test.h @@ -11,4 +11,4 @@ static const float test_arr[] = { 1.2f, 2.3f, 3.4f, -}; \ No newline at end of file +}; From aa3ca2d5728ed91a9f20581533f749b8b2e470df Mon Sep 17 00:00:00 2001 From: Michael Karlesky Date: Sat, 29 Jul 2023 20:20:33 -0400 Subject: [PATCH 380/454] Add/update build directives * Renamed macro `TEST_FILE()` to `TEST_SOURCE_FILE()` * Added macro `TEST_INCLUDE_PATH()` * Added full comment block for documentation --- src/unity.h | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/unity.h b/src/unity.h index e321a1da..d849a3f7 100644 --- a/src/unity.h +++ b/src/unity.h @@ -113,9 +113,19 @@ void verifyTest(void); #define TEST_PASS() TEST_ABORT() #define TEST_PASS_MESSAGE(message) do { UnityMessage((message), __LINE__); TEST_ABORT(); } while (0) -/* This macro does nothing, but it is useful for build tools (like Ceedling) to make use of this to figure out - * which files should be linked to in order to perform a test. Use it like TEST_FILE("sandwiches.c") */ -#define TEST_FILE(a) +/*------------------------------------------------------- + * Build Directives + *------------------------------------------------------- + + * These macros do nothing, but they are useful for additional build context. + * Tools (like Ceedling) can scan for these directives and make use of them for + * per-test-executable #include search paths and linking. */ + +/* Add source files to a test executable's compilation and linking. Ex: TEST_SOURCE_FILE("sandwiches.c") */ +#define TEST_SOURCE_FILE(a) + +/* Customize #include search paths for a test executable's compilation. Ex: TEST_INCLUDE_PATH("src/module_a/inc") */ +#define TEST_INCLUDE_PATH(a) /*------------------------------------------------------- * Test Asserts (simple) From 7a9e25b445ecc3d744bc46a97b4f05f87dcc614e Mon Sep 17 00:00:00 2001 From: epsilonrt Date: Tue, 8 Aug 2023 22:15:56 +0200 Subject: [PATCH 381/454] fix: fixes TEST_PRINTF() expansion error #691 fixes TEST_PRINTF() expansion error when no variadic arguments are passed --- src/unity.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/unity.h b/src/unity.h index e321a1da..77dfc127 100644 --- a/src/unity.h +++ b/src/unity.h @@ -105,7 +105,7 @@ void verifyTest(void); #define TEST_MESSAGE(message) UnityMessage((message), __LINE__) #define TEST_ONLY() #ifdef UNITY_INCLUDE_PRINT_FORMATTED -#define TEST_PRINTF(message, ...) UnityPrintF(__LINE__, (message), __VA_ARGS__) +#define TEST_PRINTF(message, ...) UnityPrintF(__LINE__, (message), ##__VA_ARGS__) #endif /* It is not necessary for you to call PASS. A PASS condition is assumed if nothing fails. From 5109be3881f5f2304e801b1df06a99157167cca7 Mon Sep 17 00:00:00 2001 From: Mike Karlesky Date: Tue, 15 Aug 2023 21:16:02 -0400 Subject: [PATCH 382/454] Missed renames of TEST_FILE() directive --- auto/generate_test_runner.rb | 2 +- test/testdata/testRunnerGeneratorSmall.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/auto/generate_test_runner.rb b/auto/generate_test_runner.rb index ace59303..30d4107b 100755 --- a/auto/generate_test_runner.rb +++ b/auto/generate_test_runner.rb @@ -197,7 +197,7 @@ def find_includes(source) includes = { local: source.scan(/^\s*#include\s+\"\s*(.+\.#{@options[:include_extensions]})\s*\"/).flatten, system: source.scan(/^\s*#include\s+<\s*(.+)\s*>/).flatten.map { |inc| "<#{inc}>" }, - linkonly: source.scan(/^TEST_FILE\(\s*\"\s*(.+\.#{@options[:source_extensions]})\s*\"/).flatten + linkonly: source.scan(/^TEST_SOURCE_FILE\(\s*\"\s*(.+\.#{@options[:source_extensions]})\s*\"/).flatten } includes end diff --git a/test/testdata/testRunnerGeneratorSmall.c b/test/testdata/testRunnerGeneratorSmall.c index dc687ba2..58bc65c0 100644 --- a/test/testdata/testRunnerGeneratorSmall.c +++ b/test/testdata/testRunnerGeneratorSmall.c @@ -4,7 +4,7 @@ #include "unity.h" #include "Defs.h" -TEST_FILE("some_file.c") +TEST_SOURCE_FILE("some_file.c") /* Notes about prefixes: test - normal default prefix. these are "always run" tests for this procedure From f3b2de4da260b67e36a515844ecc34a131ae86ff Mon Sep 17 00:00:00 2001 From: cmachida Date: Fri, 25 Aug 2023 17:14:55 +0000 Subject: [PATCH 383/454] fix: TEST_PRINTF(): printing 64-bit hex numbers or pointers --- src/unity.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/src/unity.c b/src/unity.c index 8c946ebe..b6c08b70 100644 --- a/src/unity.c +++ b/src/unity.c @@ -2031,15 +2031,29 @@ static void UnityPrintFVA(const char* format, va_list va) UNITY_EXTRACT_ARG(UNITY_UINT, number, length_mod, va, unsigned int); UNITY_OUTPUT_CHAR('0'); UNITY_OUTPUT_CHAR('x'); - UnityPrintNumberHex(number, 8); + if (length_mod == UNITY_LENGTH_MODIFIER_LONG_LONG) + { + UnityPrintNumberHex(number, 16); + } + else + { + UnityPrintNumberHex(number, 8); + } break; } case 'p': { - const unsigned int number = va_arg(va, unsigned int); + UNITY_UINT number; + char nibbles_to_print = 8; + if (UNITY_POINTER_WIDTH == 64) + { + length_mod = UNITY_LENGTH_MODIFIER_LONG_LONG; + nibbles_to_print = 16; + } + UNITY_EXTRACT_ARG(UNITY_UINT, number, length_mod, va, unsigned int); UNITY_OUTPUT_CHAR('0'); UNITY_OUTPUT_CHAR('x'); - UnityPrintNumberHex((UNITY_UINT)number, 8); + UnityPrintNumberHex((UNITY_UINT)number, nibbles_to_print); break; } case 'c': From 710bb58c6a91dfbd605973e0c38c4f624cd13776 Mon Sep 17 00:00:00 2001 From: Filip Jagodzinski Date: Tue, 29 Aug 2023 13:46:18 +0200 Subject: [PATCH 384/454] Allow user-defined TEST_PROTECT & TEST_ABORT macros However rare, this update covers real-world use cases where: - Unity is used to provide the assertion macros only, and an external test harness/runner is used for test orchestration/reporting. - Calling longjmp on a given platform is possible, but has a platform-specific (or implementation-specific) set of prerequisites, e.g. privileged access level. Enable project-specific customisation of TEST_PROTECT and TEST_ABORT macros. - Use the user-defined UNITY_TEST_ABORT if available; fall back to default behaviour otherwise. - Use the user-defined UNITY_TEST_PROTECT if available; fall back to default behaviour otherwise. - These may be defined independently. --- docs/UnityConfigurationGuide.md | 62 +++++++++++++++++++++++++++++++++ src/unity_internals.h | 14 +++++++- 2 files changed, 75 insertions(+), 1 deletion(-) diff --git a/docs/UnityConfigurationGuide.md b/docs/UnityConfigurationGuide.md index 88603fc8..e56b4a40 100644 --- a/docs/UnityConfigurationGuide.md +++ b/docs/UnityConfigurationGuide.md @@ -399,6 +399,68 @@ _Example:_ #define UNITY_EXCLUDE_SETJMP ``` +#### `UNITY_TEST_PROTECT` + +#### `UNITY_TEST_ABORT` + +Unity handles test failures via `setjmp`/`longjmp` pair by default. As mentioned above, you can disable this with `UNITY_EXCLUDE_SETJMP`. You can also customise what happens on every `TEST_PROTECT` and `TEST_ABORT` call. This can be accomplished by providing user-defined `UNITY_TEST_PROTECT` and `UNITY_TEST_ABORT` macros (and these may be defined independently). + +`UNITY_TEST_PROTECT` is used as an `if` statement expression, and has to evaluate to `true` on the first call (when saving stack environment with `setjmp`), and to `false` when it returns as a result of a `TEST_ABORT` (when restoring the stack environment with `longjmp`). + +Whenever an assert macro fails, `TEST_ABORT` is used to restore the stack environment previously set by `TEST_PROTECT`. This part may be overriden with `UNITY_TEST_ABORT`, e.g. if custom failure handling is needed. + +_Example 1:_ + +Calling `longjmp` on your target is possible, but has a platform-specific (or implementation-specific) set of prerequisites, e.g. privileged access level. You can extend the default behaviour of `TEST_PROTECT` and `TEST_ABORT` as: + +`unity_config.h`: + +```C +#include "my_custom_test_handlers.h" + +#define UNITY_TEST_PROTECT() custom_test_protect() +#define UNITY_TEST_ABORT() custom_test_abort() +``` + +`my_custom_test_handlers.c`: + +```C +int custom_test_protect(void) { + platform_specific_code(); + return setjmp(Unity.AbortFrame) == 0; +} + +UNITY_NORETURN void custom_test_abort(void) { + more_platform_specific_code(); + longjmp(Unity.AbortFrame, 1); +} +``` + +_Example 2:_ + +Unity is used to provide the assertion macros only, and an external test harness/runner is used for test orchestration/reporting. In this case you can easily plug your code by overriding `TEST_ABORT` as: + +`unity_config.h`: + +```C +#include "my_custom_test_handlers.h" + +#define UNITY_TEST_PROTECT() 1 +#define UNITY_TEST_ABORT() custom_test_abort() +``` + +`my_custom_test_handlers.c`: + +```C +void custom_test_abort(void) { + if (Unity.CurrentTestFailed == 1) { + custom_failed_test_handler(); + } else if (Unity.CurrentTestIgnored == 1) { + custom_ignored_test_handler(); + } +} +``` + #### `UNITY_OUTPUT_COLOR` If you want to add color using ANSI escape codes you can use this define. diff --git a/src/unity_internals.h b/src/unity_internals.h index 9f89eda9..11d9abb4 100644 --- a/src/unity_internals.h +++ b/src/unity_internals.h @@ -759,13 +759,25 @@ extern const char UnityStrErrShorthand[]; * Test Running Macros *-------------------------------------------------------*/ +#ifdef UNITY_TEST_PROTECT +#define TEST_PROTECT() UNITY_TEST_PROTECT() +#else #ifndef UNITY_EXCLUDE_SETJMP_H #define TEST_PROTECT() (setjmp(Unity.AbortFrame) == 0) -#define TEST_ABORT() longjmp(Unity.AbortFrame, 1) #else #define TEST_PROTECT() 1 +#endif +#endif + +#ifdef UNITY_TEST_ABORT +#define TEST_ABORT() UNITY_TEST_ABORT() +#else +#ifndef UNITY_EXCLUDE_SETJMP_H +#define TEST_ABORT() longjmp(Unity.AbortFrame, 1) +#else #define TEST_ABORT() return #endif +#endif /* Automatically enable variadic macros support, if it not enabled before */ #ifndef UNITY_SUPPORT_VARIADIC_MACROS From 955809048c3a7fbe04481abbfd9d0deeee2b7784 Mon Sep 17 00:00:00 2001 From: "Michael Gene Brockus (Dreamer)" <55331536+dreamer-coding-555@users.noreply.github.com> Date: Fri, 15 Sep 2023 09:53:34 -0600 Subject: [PATCH 385/454] Create bdd.h --- extras/bdd/src/bdd.h | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 extras/bdd/src/bdd.h diff --git a/extras/bdd/src/bdd.h b/extras/bdd/src/bdd.h new file mode 100644 index 00000000..35f177d9 --- /dev/null +++ b/extras/bdd/src/bdd.h @@ -0,0 +1,42 @@ +/* Copyright (c) 2023 Michael Gene Brockus (Dreamer) and Contributed to Unity Project + * ========================================== + * Unity Project - A Test Framework for C + * Copyright (c) 2007 Mike Karlesky, Mark VanderVoord, Greg Williams + * [Released under MIT License. Please refer to license.txt for details] + * ========================================== */ + +#ifndef UNITY_BDD_TEST_H_ +#define UNITY_BDD_TEST_H_ + +#ifdef __cplusplus +extern "C" +{ +#endif + +/** + * @brief Macros for defining a Behavior-Driven Development (BDD) structure with descriptions. + * + * These macros provide a way to structure and describe different phases (Given, When, Then) of a + * test scenario in a BDD-style format. However, they don't have functional behavior by themselves + * and are used for descriptive purposes. + */ +#define GIVEN(description) \ + if (0) { \ + printf("Given %s\n", description); \ + } else + +#define WHEN(description) \ + if (0) { \ + printf("When %s\n", description); \ + } else + +#define THEN(description) \ + if (0) { \ + printf("Then %s\n", description); \ + } else + +#ifdef __cplusplus +} +#endif + +#endif From cf13244043603803a8fefc84162e8efd06dfc471 Mon Sep 17 00:00:00 2001 From: "Michael Gene Brockus (Dreamer)" <55331536+dreamer-coding-555@users.noreply.github.com> Date: Fri, 15 Sep 2023 09:54:32 -0600 Subject: [PATCH 386/454] adding stdio --- extras/bdd/src/bdd.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/extras/bdd/src/bdd.h b/extras/bdd/src/bdd.h index 35f177d9..d91b3f13 100644 --- a/extras/bdd/src/bdd.h +++ b/extras/bdd/src/bdd.h @@ -13,6 +13,8 @@ extern "C" { #endif +#include + /** * @brief Macros for defining a Behavior-Driven Development (BDD) structure with descriptions. * From de387ef0731219dd50119f008e0f9e99810bb220 Mon Sep 17 00:00:00 2001 From: "Michael Gene Brockus (Dreamer)" <55331536+dreamer-coding-555@users.noreply.github.com> Date: Fri, 15 Sep 2023 10:12:34 -0600 Subject: [PATCH 387/454] Create test_bdd.c --- extras/bdd/test/test_bdd.c | 128 +++++++++++++++++++++++++++++++++++++ 1 file changed, 128 insertions(+) create mode 100644 extras/bdd/test/test_bdd.c diff --git a/extras/bdd/test/test_bdd.c b/extras/bdd/test/test_bdd.c new file mode 100644 index 00000000..4f415858 --- /dev/null +++ b/extras/bdd/test/test_bdd.c @@ -0,0 +1,128 @@ +/* ========================================== + * Unity Project - A Test Framework for C + * Copyright (c) 2007 Mike Karlesky, Mark VanderVoord, Greg Williams + * [Released under MIT License. Please refer to license.txt for details] + * ========================================== */ + +#include "unity.h" +#include "unity_bdd.h" + +void test_bdd_logic_test(void) { + GIVEN("a valid statement is passed") + { + // Set up the context + bool givenExecuted = true; + + WHEN("a statement is true") + { + // Perform the login action + bool whenExecuted = true; + + THEN("we validate everything was worked") + { + // Check the expected outcome + bool thenExecuted = true; + + TEST_ASSERT_TRUE(givenExecuted); + TEST_ASSERT_TRUE(whenExecuted); + TEST_ASSERT_TRUE(thenExecuted); + } + } + } +} // end of case + +void test_bdd_user_account(void) { + GIVEN("a user's account with sufficient balance") + { + // Set up the context + float accountBalance = 500.0; + float withdrawalAmount = 200.0; + + WHEN("the user requests a withdrawal of $200") + { + // Perform the withdrawal action + if (accountBalance >= withdrawalAmount) + { + accountBalance -= withdrawalAmount; + } // end if + THEN("the withdrawal amount should be deducted from the account balance") + { + // Check the expected outcome + + // Simulate the scenario + float compareBalance = 500.0; + TEST_ASSERT_LESS_THAN_FLOAT(accountBalance, compareBalance); + } + } + } +} // end of case + +void test_bdd_empty_cart(void) { + GIVEN("a user with an empty shopping cart") + { + // Set up the context + int cartItemCount = 0; + + WHEN("the user adds a product to the cart") + { + // Perform the action of adding a product + + THEN("the cart item count should increase by 1") + { + // Check the expected outcome + cartItemCount++; + + TEST_ASSERT_EQUAL_INT(cartItemCount, 1); + } + } + } +} // end of case + +void test_bdd_valid_login(void) { + GIVEN("a registered user with valid credentials") + { + // Set up the context + const char* validUsername = "user123"; + const char* validPassword = "pass456"; + + WHEN("the user provides correct username and password") + { + // Perform the action of user login + const char* inputUsername = "user123"; + const char* inputPassword = "pass456"; + + THEN("the login should be successful") + { + // Check the expected outcome + // Simulate login validation + TEST_ASSERT_EQUAL_STRING(inputUsername, validUsername); + TEST_ASSERT_EQUAL_STRING(inputPassword, validPassword); + } + } + + WHEN("the user provides incorrect password") + { + // Perform the action of user login + const char* inputUsername = "user123"; + const char* inputPassword = "wrongpass"; + + THEN("the login should fail with an error message") + { + // Check the expected outcome + // Simulate login validation + TEST_ASSERT_EQUAL_STRING(inputUsername, validUsername); + // TEST_ASSERT_NOT_EQUAL_STRING(inputPassword, validPassword); + } + } + } +} // end of case + +int main(void) +{ + UnityBegin("test_bdd.c"); + RUN_TEST(test_bdd_logic_test); + RUN_TEST(test_bdd_user_account); + RUN_TEST(test_bdd_empty_cart); + RUN_TEST(test_bdd_valid_login); + return UnityEnd(); +} From a4d0150758aa8bcd25563c727fe04d845e3399a3 Mon Sep 17 00:00:00 2001 From: "Michael Gene Brockus (Dreamer)" <55331536+dreamer-coding-555@users.noreply.github.com> Date: Fri, 15 Sep 2023 10:13:06 -0600 Subject: [PATCH 388/454] Rename bdd.h to unity_bdd.h --- extras/bdd/src/{bdd.h => unity_bdd.h} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename extras/bdd/src/{bdd.h => unity_bdd.h} (100%) diff --git a/extras/bdd/src/bdd.h b/extras/bdd/src/unity_bdd.h similarity index 100% rename from extras/bdd/src/bdd.h rename to extras/bdd/src/unity_bdd.h From 24c175f64f31a6b2d5fcc25de1e5f32897f6118d Mon Sep 17 00:00:00 2001 From: "Michael Gene Brockus (Dreamer)" <55331536+dreamer-coding-555@users.noreply.github.com> Date: Fri, 15 Sep 2023 10:20:26 -0600 Subject: [PATCH 389/454] Create readme.md --- extras/bdd/readme.md | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 extras/bdd/readme.md diff --git a/extras/bdd/readme.md b/extras/bdd/readme.md new file mode 100644 index 00000000..e7035885 --- /dev/null +++ b/extras/bdd/readme.md @@ -0,0 +1,40 @@ +# Unity Project - BDD Feature + +Unity's Behavior-Driven Development (BDD) test feature. It allows developers to structure and describe various phases (Given, When, Then) of a test scenario in a BDD-style format. + +## Introduction + +This project is based on the Unity framework originally created by Mike Karlesky, Mark VanderVoord, and Greg Williams in 2007. The project extends Unity by providing macros to define BDD structures with descriptive elements. Feature added by Michael Gene Brockus (Dreamer). + +## License + +This project is distributed under the MIT License. See the [license.txt](license.txt) file for more information. + +## Usage + +### BDD Macros + +The provided BDD macros allow you to structure your test scenarios in a descriptive manner. These macros are for descriptive purposes only and do not have functional behavior. + +- `GIVEN(description)`: Describes the "Given" phase of a test scenario. +- `WHEN(description)`: Describes the "When" phase of a test scenario. +- `THEN(description)`: Describes the "Then" phase of a test scenario. + +Example usage: + +```c +GIVEN("a valid input") { + // Test setup and context + // ... + + WHEN("the input is processed") { + // Perform the action + // ... + + THEN("the expected outcome occurs") { + // Assert the outcome + // ... + } + } +} +``` From 4403d97d1420d0638150486ea1cfde3130d6b097 Mon Sep 17 00:00:00 2001 From: "Michael Gene Brockus (Dreamer)" <55331536+dreamer-coding-555@users.noreply.github.com> Date: Fri, 15 Sep 2023 10:22:26 -0600 Subject: [PATCH 390/454] Create meson.build --- extras/bdd/test/meson.build | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 extras/bdd/test/meson.build diff --git a/extras/bdd/test/meson.build b/extras/bdd/test/meson.build new file mode 100644 index 00000000..fcdaffff --- /dev/null +++ b/extras/bdd/test/meson.build @@ -0,0 +1,9 @@ +project('BDD Tester', 'c') + +# Add Unity as a dependency +unity_dep = dependency('unity') + +# Define your source files +sources = files('test_bdd.c') + +executable('tester', sources, dependencies : unity_dep) From 7d0bcc892ec8517c4d97c605711e9a5cd43c23d8 Mon Sep 17 00:00:00 2001 From: SteveBroshar Date: Sun, 8 Oct 2023 15:47:22 -0500 Subject: [PATCH 391/454] use null check instead of pointer compar --- src/unity.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/unity.c b/src/unity.c index b6c08b70..e455f57a 100644 --- a/src/unity.c +++ b/src/unity.c @@ -1609,8 +1609,8 @@ void UnityAssertEqualString(const char* expected, } } else - { /* handle case of one pointers being null (if both null, test should pass) */ - if (expected != actual) + { /* fail if either null but not if both */ + if (expected || actual) { Unity.CurrentTestFailed = 1; } @@ -1649,8 +1649,8 @@ void UnityAssertEqualStringLen(const char* expected, } } else - { /* handle case of one pointers being null (if both null, test should pass) */ - if (expected != actual) + { /* fail if either null but not if both */ + if (expected || actual) { Unity.CurrentTestFailed = 1; } From 88069f045cdf7d9f2a9d202a9560ac18ee848994 Mon Sep 17 00:00:00 2001 From: Mark VanderVoord Date: Tue, 7 Nov 2023 23:48:48 -0500 Subject: [PATCH 392/454] Fix docs issues. Update scripts to match latest rubocop. Fix hex length of unity printf feature. --- README.md | 8 +++++--- auto/generate_module.rb | 23 ++++++++++++----------- src/unity.c | 4 ++-- 3 files changed, 19 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index 1fc220c0..942ad9d7 100644 --- a/README.md +++ b/README.md @@ -54,7 +54,7 @@ The message is output stating why. Compare two integers for equality and display errors as signed integers. A cast will be performed to your natural integer size so often this can just be used. -When you need to specify the exact size, like when comparing arrays, you can use a specific version: +When you need to specify the exact size, you can use a specific version. TEST_ASSERT_EQUAL_UINT(expected, actual) TEST_ASSERT_EQUAL_UINT8(expected, actual) @@ -72,7 +72,8 @@ Like INT, there are variants for different sizes also. TEST_ASSERT_EQUAL_HEX64(expected, actual) Compares two integers for equality and display errors as hexadecimal. -Like the other integer comparisons, you can specify the size... here the size will also effect how many nibbles are shown (for example, `HEX16` will show 4 nibbles). +Like the other integer comparisons, you can specify the size... +here the size will also effect how many nibbles are shown (for example, `HEX16` will show 4 nibbles). TEST_ASSERT_EQUAL(expected, actual) @@ -214,7 +215,8 @@ Fails if the pointer is equal to NULL TEST_ASSERT_EQUAL_MEMORY(expected, actual, len) Compare two blocks of memory. -This is a good generic assertion for types that can't be coerced into acting like standard types... but since it's a memory compare, you have to be careful that your data types are packed. +This is a good generic assertion for types that can't be coerced into acting like standard types... +but since it's a memory compare, you have to be careful that your data types are packed. ### \_MESSAGE diff --git a/auto/generate_module.rb b/auto/generate_module.rb index 40586f9c..7b33c727 100644 --- a/auto/generate_module.rb +++ b/auto/generate_module.rb @@ -155,7 +155,7 @@ def files_to_operate_on(module_name, pattern = nil) path: (Pathname.new("#{cfg[:path]}#{subfolder}") + filename).cleanpath, name: submodule_name, template: cfg[:template], - test_define: cfg[:test_define] + test_define: cfg[:test_define], boilerplate: cfg[:boilerplate], includes: case (cfg[:inc]) when :src then (@options[:includes][:src] || []) | (pattern_traits[:inc].map { |f| format(f, module_name) }) @@ -170,18 +170,19 @@ def files_to_operate_on(module_name, pattern = nil) end ############################ - def neutralize_filename(name, start_cap = true) + def neutralize_filename(name, start_cap: true) return name if name.empty? + name = name.split(/(?:\s+|_|(?=[A-Z][a-z]))|(?<=[a-z])(?=[A-Z])/).map(&:capitalize).join('_') - name = name[0].downcase + name[1..-1] unless start_cap + name = name[0].downcase + name[1..] unless start_cap name end ############################ def create_filename(part1, part2 = '') - name = part2.empty? ? part1 : part1 + '_' + part2 + name = part2.empty? ? part1 : "#{part1}_#{part2}" case (@options[:naming]) - when 'bumpy' then neutralize_filename(name, false).delete('_') + when 'bumpy' then neutralize_filename(name, start_cap: false).delete('_') when 'camel' then neutralize_filename(name).delete('_') when 'snake' then neutralize_filename(name).downcase when 'caps' then neutralize_filename(name).upcase @@ -263,12 +264,12 @@ def destroy(module_name, pattern = nil) case arg when /^-d/ then destroy = true when /^-u/ then options[:update_svn] = true - when /^-p\"?(\w+)\"?/ then options[:pattern] = Regexp.last_match(1) - when /^-s\"?(.+)\"?/ then options[:path_src] = Regexp.last_match(1) - when /^-i\"?(.+)\"?/ then options[:path_inc] = Regexp.last_match(1) - when /^-t\"?(.+)\"?/ then options[:path_tst] = Regexp.last_match(1) - when /^-n\"?(.+)\"?/ then options[:naming] = Regexp.last_match(1) - when /^-y\"?(.+)\"?/ then options = UnityModuleGenerator.grab_config(Regexp.last_match(1)) + when /^-p"?(\w+)"?/ then options[:pattern] = Regexp.last_match(1) + when /^-s"?(.+)"?/ then options[:path_src] = Regexp.last_match(1) + when /^-i"?(.+)"?/ then options[:path_inc] = Regexp.last_match(1) + when /^-t"?(.+)"?/ then options[:path_tst] = Regexp.last_match(1) + when /^-n"?(.+)"?/ then options[:naming] = Regexp.last_match(1) + when /^-y"?(.+)"?/ then options = UnityModuleGenerator.grab_config(Regexp.last_match(1)) when /^(\w+)/ raise "ERROR: You can't have more than one Module name specified!" unless module_name.nil? diff --git a/src/unity.c b/src/unity.c index 3e4bc04d..74071555 100644 --- a/src/unity.c +++ b/src/unity.c @@ -2029,7 +2029,7 @@ static void UnityPrintFVA(const char* format, va_list va) UNITY_EXTRACT_ARG(UNITY_UINT, number, length_mod, va, unsigned int); UNITY_OUTPUT_CHAR('0'); UNITY_OUTPUT_CHAR('x'); - UnityPrintNumberHex(number, 8); + UnityPrintNumberHex(number, UNITY_MAX_NIBBLES); break; } case 'p': @@ -2037,7 +2037,7 @@ static void UnityPrintFVA(const char* format, va_list va) const unsigned int number = va_arg(va, unsigned int); UNITY_OUTPUT_CHAR('0'); UNITY_OUTPUT_CHAR('x'); - UnityPrintNumberHex((UNITY_UINT)number, 8); + UnityPrintNumberHex((UNITY_UINT)number, UNITY_MAX_NIBBLES); break; } case 'c': From 3f7564ea3b86ec25c45a240b38a26aea521d1482 Mon Sep 17 00:00:00 2001 From: Mark VanderVoord Date: Sun, 12 Nov 2023 19:07:32 -0500 Subject: [PATCH 393/454] Catch up on Ruby style and formatting changes. --- auto/generate_test_runner.rb | 23 ++++++++-------- auto/parse_output.rb | 38 +++++++++++++-------------- auto/stylize_as_junit.rb | 2 +- auto/unity_test_summary.rb | 4 +-- examples/example_3/rakefile_helper.rb | 18 ++++++------- test/.rubocop.yml | 2 ++ 6 files changed, 45 insertions(+), 42 deletions(-) diff --git a/auto/generate_test_runner.rb b/auto/generate_test_runner.rb index 483739b7..057c02fb 100755 --- a/auto/generate_test_runner.rb +++ b/auto/generate_test_runner.rb @@ -45,6 +45,7 @@ def self.default_options cmdline_args: false, omit_begin_end: false, use_param_tests: false, + use_system_files: true, include_extensions: '(?:hpp|hh|H|h)', source_extensions: '(?:cpp|cc|ino|C|c)' } @@ -69,7 +70,7 @@ def run(input_file, output_file, options = nil) source = source.force_encoding('ISO-8859-1').encode('utf-8', replace: nil) tests = find_tests(source) headers = find_includes(source) - testfile_includes = (headers[:local] + headers[:system]) + testfile_includes = @options[:use_system_files] ? (headers[:local] + headers[:system]) : (headers[:local]) used_mocks = find_mocks(testfile_includes) testfile_includes = (testfile_includes - used_mocks) testfile_includes.delete_if { |inc| inc =~ /(unity|cmock)/ } @@ -80,7 +81,7 @@ def run(input_file, output_file, options = nil) # determine which files were used to return them all_files_used = [input_file, output_file] - all_files_used += testfile_includes.map { |filename| filename + '.c' } unless testfile_includes.empty? + all_files_used += testfile_includes.map { |filename| "#{filename}.c" } unless testfile_includes.empty? all_files_used += @options[:includes] unless @options[:includes].empty? all_files_used += headers[:linkonly] unless headers[:linkonly].empty? all_files_used.uniq @@ -144,12 +145,12 @@ def find_tests(source) if @options[:use_param_tests] && !arguments.empty? args = [] type_and_args = arguments.split(/TEST_(CASE|RANGE|MATRIX)/) - for i in (1...type_and_args.length).step(2) + (1...type_and_args.length).step(2).each do |i| case type_and_args[i] - when "CASE" + when 'CASE' args << type_and_args[i + 1].sub(/^\s*\(\s*(.*?)\s*\)\s*$/m, '\1') - when "RANGE" + when 'RANGE' args += type_and_args[i + 1].scan(/(\[|<)\s*(-?\d+.?\d*)\s*,\s*(-?\d+.?\d*)\s*,\s*(-?\d+.?\d*)\s*(\]|>)/m).map do |arg_values_str| exclude_end = arg_values_str[0] == '<' && arg_values_str[-1] == '>' arg_values_str[1...-1].map do |arg_value_str| @@ -163,13 +164,13 @@ def find_tests(source) arg_combinations.flatten.join(', ') end - when "MATRIX" - single_arg_regex_string = /(?:(?:"(?:\\"|[^\\])*?")+|(?:'\\?.')+|(?:[^\s\]\["'\,]|\[[\d\S_-]+\])+)/.source + when 'MATRIX' + single_arg_regex_string = /(?:(?:"(?:\\"|[^\\])*?")+|(?:'\\?.')+|(?:[^\s\]\["',]|\[[\d\S_-]+\])+)/.source args_regex = /\[((?:\s*#{single_arg_regex_string}\s*,?)*(?:\s*#{single_arg_regex_string})?\s*)\]/m arg_elements_regex = /\s*(#{single_arg_regex_string})\s*,\s*/m args += type_and_args[i + 1].scan(args_regex).flatten.map do |arg_values_str| - (arg_values_str + ',').scan(arg_elements_regex) + ("#{arg_values_str},").scan(arg_elements_regex) end.reduce do |result, arg_range_expanded| result.product(arg_range_expanded) end.map do |arg_combinations| @@ -188,7 +189,7 @@ def find_tests(source) source_lines = source.split("\n") source_index = 0 tests_and_line_numbers.size.times do |i| - source_lines[source_index..-1].each_with_index do |line, index| + source_lines[source_index..].each_with_index do |line, index| next unless line =~ /\s+#{tests_and_line_numbers[i][:test]}(?:\s|\()/ source_index += index @@ -210,7 +211,7 @@ def find_includes(source) { local: source.scan(/^\s*#include\s+"\s*(.+\.#{@options[:include_extensions]})\s*"/).flatten, system: source.scan(/^\s*#include\s+<\s*(.+)\s*>/).flatten.map { |inc| "<#{inc}>" }, - linkonly: source.scan(/^TEST_SOURCE_FILE\(\s*\"\s*(.+\.#{@options[:source_extensions]})\s*\"/).flatten + linkonly: source.scan(/^TEST_SOURCE_FILE\(\s*"\s*(.+\.#{@options[:source_extensions]})\s*"/).flatten } end @@ -368,7 +369,7 @@ def create_run_test(output) require 'erb' file = File.read(File.join(__dir__, 'run_test.erb')) template = ERB.new(file, trim_mode: '<>') - output.puts("\n" + template.result(binding)) + output.puts("\n#{template.result(binding)}") end def create_args_wrappers(output, tests) diff --git a/auto/parse_output.rb b/auto/parse_output.rb index 864104be..aa306e2c 100644 --- a/auto/parse_output.rb +++ b/auto/parse_output.rb @@ -56,7 +56,7 @@ def set_xml_output # Set the flag to indicate if there will be an XML output file or not def test_suite_name=(cli_arg) @real_test_suite_name = cli_arg - puts 'Real test suite name will be \'' + @real_test_suite_name + '\'' + puts "Real test suite name will be '#{@real_test_suite_name}'" end def xml_encode_s(str) @@ -75,7 +75,7 @@ def write_xml_output # Pushes the suite info as xml to the array list, which will be written later def push_xml_output_suite_info # Insert opening tag at front - heading = '' + heading = "" @array_list.insert(0, heading) # Push back the closing tag @array_list.push '' @@ -83,20 +83,20 @@ def push_xml_output_suite_info # Pushes xml output data to the array list, which will be written later def push_xml_output_passed(test_name, execution_time = 0) - @array_list.push ' ' + @array_list.push " " end # Pushes xml output data to the array list, which will be written later def push_xml_output_failed(test_name, reason, execution_time = 0) - @array_list.push ' ' - @array_list.push ' ' + reason + '' + @array_list.push " " + @array_list.push " #{reason}" @array_list.push ' ' end # Pushes xml output data to the array list, which will be written later def push_xml_output_ignored(test_name, reason, execution_time = 0) - @array_list.push ' ' - @array_list.push ' ' + reason + '' + @array_list.push " " + @array_list.push " #{reason}" @array_list.push ' ' end @@ -144,7 +144,7 @@ def test_failed_unity_fixture(array) test_name = array[1] test_suite_verify(class_name) reason_array = array[2].split(':') - reason = reason_array[-1].lstrip.chomp + ' at line: ' + reason_array[-4] + reason = "#{reason_array[-1].lstrip.chomp} at line: #{reason_array[-4]}" printf "%-40s FAILED\n", test_name @@ -189,12 +189,12 @@ def test_passed(array) def test_failed(array) # ':' symbol will be valid in function args now real_method_name = array[@result_usual_idx - 1..-3].join(':') - array = array[0..@result_usual_idx - 3] + [real_method_name] + array[-2..-1] + array = array[0..@result_usual_idx - 3] + [real_method_name] + array[-2..] last_item = array.length - 1 test_time = get_test_time(array[last_item]) test_name = array[last_item - 2] - reason = array[last_item].chomp.lstrip + ' at line: ' + array[last_item - 3] + reason = "#{array[last_item].chomp.lstrip} at line: #{array[last_item - 3]}" class_name = array[@class_name_idx] if test_name.start_with? 'TEST(' @@ -217,7 +217,7 @@ def test_failed(array) def test_ignored(array) # ':' symbol will be valid in function args now real_method_name = array[@result_usual_idx - 1..-3].join(':') - array = array[0..@result_usual_idx - 3] + [real_method_name] + array[-2..-1] + array = array[0..@result_usual_idx - 3] + [real_method_name] + array[-2..] last_item = array.length - 1 test_time = get_test_time(array[last_item]) @@ -268,7 +268,7 @@ def detect_os_specifics(line) def process(file_name) @array_list = [] - puts 'Parsing file: ' + file_name + puts "Parsing file: #{file_name}" @test_passed = 0 @test_failed = 0 @@ -333,17 +333,17 @@ def process(file_name) @test_ignored += 1 elsif line_array.size >= 4 # We will check output from color compilation - if line_array[@result_usual_idx..-1].any? { |l| l.include? 'PASS' } + if line_array[@result_usual_idx..].any? { |l| l.include? 'PASS' } test_passed(line_array) @test_passed += 1 - elsif line_array[@result_usual_idx..-1].any? { |l| l.include? 'FAIL' } + elsif line_array[@result_usual_idx..].any? { |l| l.include? 'FAIL' } test_failed(line_array) @test_failed += 1 elsif line_array[@result_usual_idx..-2].any? { |l| l.include? 'IGNORE' } test_ignored(line_array) @test_ignored += 1 - elsif line_array[@result_usual_idx..-1].any? { |l| l.include? 'IGNORE' } - line_array.push('No reason given (' + get_test_time(line_array[@result_usual_idx..-1]).to_s + ' ms)') + elsif line_array[@result_usual_idx..].any? { |l| l.include? 'IGNORE' } + line_array.push("No reason given (#{get_test_time(line_array[@result_usual_idx..])} ms)") test_ignored(line_array) @test_ignored += 1 end @@ -353,9 +353,9 @@ def process(file_name) puts '' puts '=================== SUMMARY =====================' puts '' - puts 'Tests Passed : ' + @test_passed.to_s - puts 'Tests Failed : ' + @test_failed.to_s - puts 'Tests Ignored : ' + @test_ignored.to_s + puts "Tests Passed : #{@test_passed}" + puts "Tests Failed : #{@test_failed}" + puts "Tests Ignored : #{@test_ignored}" return unless @xml_out diff --git a/auto/stylize_as_junit.rb b/auto/stylize_as_junit.rb index e01f7912..e4b911eb 100755 --- a/auto/stylize_as_junit.rb +++ b/auto/stylize_as_junit.rb @@ -99,7 +99,7 @@ def run test_file = if test_file_str.length < 2 result_file else - test_file_str[0] + ':' + test_file_str[1] + "#{test_file_str[0]}:#{test_file_str[1]}" end result_output[:source][:path] = File.dirname(test_file) result_output[:source][:file] = File.basename(test_file) diff --git a/auto/unity_test_summary.rb b/auto/unity_test_summary.rb index 0253b5d7..03d67a68 100644 --- a/auto/unity_test_summary.rb +++ b/auto/unity_test_summary.rb @@ -112,7 +112,7 @@ def parse_test_summary(summary) # parse out the command options opts, args = ARGV.partition { |v| v =~ /^--\w+/ } - opts.map! { |v| v[2..-1].to_sym } + opts.map! { |v| v[2..].to_sym } # create an instance to work with uts = UnityTestSummary.new(opts) @@ -128,7 +128,7 @@ def parse_test_summary(summary) uts.targets = results # set the root path - args[1] ||= Dir.pwd + '/' + args[1] ||= "#{Dir.pwd}/" uts.root = ARGV[1] # run the summarizer diff --git a/examples/example_3/rakefile_helper.rb b/examples/example_3/rakefile_helper.rb index d88df584..cbc4549f 100644 --- a/examples/example_3/rakefile_helper.rb +++ b/examples/example_3/rakefile_helper.rb @@ -17,7 +17,7 @@ def load_configuration(config_file) end def configure_clean - CLEAN.include($cfg['compiler']['build_path'] + '*.*') unless $cfg['compiler']['build_path'].nil? + CLEAN.include("#{$cfg['compiler']['build_path']}*.*") unless $cfg['compiler']['build_path'].nil? end def configure_toolchain(config_file = DEFAULT_CONFIG_FILE) @@ -27,7 +27,7 @@ def configure_toolchain(config_file = DEFAULT_CONFIG_FILE) end def unit_test_files - path = $cfg['compiler']['unit_tests_path'] + 'Test*' + C_EXTENSION + path = "#{$cfg['compiler']['unit_tests_path']}Test*#{C_EXTENSION}" path.tr!('\\', '/') FileList.new(path) end @@ -111,11 +111,11 @@ def build_linker_fields def link_it(exe_name, obj_list) linker = build_linker_fields - cmd_str = "#{linker[:command]}#{linker[:options]}#{linker[:includes]} " + - (obj_list.map { |obj| "#{$cfg['linker']['object_files']['path']}#{obj} " }).join + - $cfg['linker']['bin_files']['prefix'] + ' ' + - $cfg['linker']['bin_files']['destination'] + - exe_name + $cfg['linker']['bin_files']['extension'] + cmd_str = "#{linker[:command]}#{linker[:options]}#{linker[:includes]}" + cmd_str += " #{(obj_list.map { |obj| "#{$cfg['linker']['object_files']['path']}#{obj}" }).join(' ')}" + cmd_str += " #{$cfg['linker']['bin_files']['prefix']} " + cmd_str += $cfg['linker']['bin_files']['destination'] + cmd_str += exe_name + $cfg['linker']['bin_files']['extension'] execute(cmd_str) end @@ -125,7 +125,7 @@ def build_simulator_fields command = if $cfg['simulator']['path'].nil? '' else - (tackit($cfg['simulator']['path']) + ' ') + "#{tackit($cfg['simulator']['path'])} " end pre_support = if $cfg['simulator']['pre_support'].nil? '' @@ -188,7 +188,7 @@ def run_tests(test_files) # Build the test runner (generate if configured to do so) test_base = File.basename(test, C_EXTENSION) - runner_name = test_base + '_Runner.c' + runner_name = "#{test_base}_Runner.c" if $cfg['compiler']['runner_path'].nil? runner_path = $cfg['compiler']['build_path'] + runner_name test_gen = UnityTestRunnerGenerator.new($cfg_file) diff --git a/test/.rubocop.yml b/test/.rubocop.yml index 44b01605..a3b811bd 100644 --- a/test/.rubocop.yml +++ b/test/.rubocop.yml @@ -28,6 +28,8 @@ Style/EvalWithLocation: Enabled: false Style/MixinUsage: Enabled: false +Style/OptionalBooleanParameter: + Enabled: false # These are also places we diverge... but we will likely comply down the road Style/IfUnlessModifier: From a1b1600e4361cdf98bdb57e7d32a1cafa6eb90bf Mon Sep 17 00:00:00 2001 From: Mark VanderVoord Date: Mon, 13 Nov 2023 17:03:07 -0500 Subject: [PATCH 394/454] Update change log and known issues. Fix bug with infinity and NaN handling. --- README.md | 4 ++ docs/UnityChangeLog.md | 93 +++++++++++++++++++++++++++++++++ docs/UnityConfigurationGuide.md | 11 ++++ docs/UnityKnownIssues.md | 13 +++++ src/unity.c | 34 ++++++------ src/unity_internals.h | 23 +++++--- 6 files changed, 154 insertions(+), 24 deletions(-) create mode 100644 docs/UnityChangeLog.md create mode 100644 docs/UnityKnownIssues.md diff --git a/README.md b/README.md index 8a020f6f..71488b3e 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,8 @@ If you'd like to leave the hard work to us, you might be interested in Ceedling, If you're new to Unity, we encourage you to tour the [getting started guide][]. +You can also find the [change log][] and [known issues][] in our documentation. + ## Getting Started The [docs][] folder contains a [getting started guide][] and much more tips about using Unity. @@ -226,5 +228,7 @@ This is useful for specifying more information about the problem. [CI]: https://github.com/ThrowTheSwitch/Unity/workflows/CI/badge.svg [getting started guide]: docs/UnityGettingStartedGuide.md +[change log]: docs/UnityChangeLog.md +[known issues]: docs/UnityKnownIssues.md [docs]: docs/ [UnityAssertionsReference.md]: docs/UnityAssertionsReference.md diff --git a/docs/UnityChangeLog.md b/docs/UnityChangeLog.md new file mode 100644 index 00000000..9c3bb7bf --- /dev/null +++ b/docs/UnityChangeLog.md @@ -0,0 +1,93 @@ +# Unity Test - Change Log + +## A Note + +This document captures significant features and fixes to the Unity project core source files +and scripts. More detail can be found in the history on Github. + +This project is now tracking changes in more detail. Previous releases get less detailed as +we move back in histroy. + +Prior to 2012, the project was hosted on SourceForge.net +Prior to 2008, the project was an internal project and not released to the public. + +## Log + +### Unity 2.6.0 () + +New Features: + + - Fill out missing variations of arrays, within, etc. + - Add `TEST_PRINTF()` + - Add `TEST_MATRIX()` and `TEST_RANGE()` options and documentation + - Add support for searching `TEST_SOURCE_FILE()` for determining test dependencies + - Add Unity BDD plugin + - Add `UNITY_INCLUDE_EXEC_TIME` option to report test times + - Allow user to override test abort underlying mechanism + +Significant Bugfixes: + + - More portable validation of NaN and Infinity. Added `UNITY_IS_NAN` and `UNITY_IS_INF` options + - Add `UNITY_PROGMEM` configuration option + - Fix overflow detection of hex values when using arrays + - Fix scripts broken by Ruby standard changes + +Other: + + - Avoid pointer comparison when one is null to avoid compiler warnings + - Significant improvements to documentation + - Updates to match latest Ruby style specification + - Meson, CMake, PlatformIO builds + +### Unity 2.5.2 (January 2021) + + - improvements to RUN_TEST macro and generated RUN_TEST + - Fix `UNITY_TEST_ASSERT_BIT(S)_HIGH` + - Cleaner handling of details tracking by CMock + +### Unity 2.5.1 (May 2020) + +Mostly a bugfix and stability release. +Bonus Features: + + - Optional TEST_PRINTF macro + - Improve self-testing procedures. + +### Unity 2.5.0 (October 2019) + +It's been a LONG time since the last release of Unity. Finally, here it is! +There are too many updates to list here, so some highlights: + + - more standards compliant (without giving up on supporting ALL compilers, no matter how quirky) + - many more specialized assertions for better test feedback + - more examples for integrating into your world + - many many bugfixes and tweaks + +### Unity 2.4.3 (November 2017) + + - Allow suiteSetUp() and suiteTearDown() to be povided as normal C functions + - Fix & Expand Greater Than / Less Than assertions for integers + - Built-in option to colorize test results + - Documentation updates + +### Unity 2.4.2 (September 2017) + + - Fixed bug in UNTY_TEST_ASSERT_EACH_EQUAL_* + - Added TEST_ASSERT_GREATER_THAN and TEST_ASSERT_LESS_THAN + - Updated Module Generator to stop changing names when no style given + - Cleanup to custom float printing for accuracy + - Cleanup incorrect line numbers are partial name matching + - Reduce warnings from using popular function names as variable names + +### Unity 2.4.1 (April 2017) + + - test runner generator can inject defines as well as headers + - added a built-in floating point print routine instead of relying on printf + - updated to new coding and naming standard + - updated documentation to be markdown instead of pdf + - fixed many many little bugs, most of which were supplied by the community (you people are awesome!) + - coding standard actually enforced in CI + +### Unity 2.4.0 (October, 2016) + + - port from SourceForge and numerous bugfixes diff --git a/docs/UnityConfigurationGuide.md b/docs/UnityConfigurationGuide.md index e56b4a40..953851fd 100644 --- a/docs/UnityConfigurationGuide.md +++ b/docs/UnityConfigurationGuide.md @@ -222,6 +222,17 @@ _Example:_ #define UNITY_FLOAT_PRECISION 0.001f ``` +#### `UNITY_IS_NAN` and `UNITY_IS_INF` + +If your toolchain defines `isnan` and `isinf` in `math.h` as macros, nothing needs to be done. If your toolchain doesn't define these, Unity +will create these macros itself. You may override either or both of these defines to specify how you want to evaluate if a number is NaN or Infinity. + +_Example:_ + +```C +#define UNITY_IS_NAN(n) ((n != n) ? 1 : 0) +``` + ### Miscellaneous #### `UNITY_EXCLUDE_STDDEF_H` diff --git a/docs/UnityKnownIssues.md b/docs/UnityKnownIssues.md new file mode 100644 index 00000000..34493197 --- /dev/null +++ b/docs/UnityKnownIssues.md @@ -0,0 +1,13 @@ +# Unity Test - Known Issues + +## A Note + +This project will do its best to keep track of significant bugs that might effect your usage of this +project and its supporting scripts. A more detailed and up-to-date list for cutting edge Unity can +be found on our Github repository. + +## Issues + + - No built-in validation of no-return functions + - Incomplete support for Printf-style formatting + - Incomplete support for VarArgs diff --git a/src/unity.c b/src/unity.c index e049e3ae..cc2e5ce1 100644 --- a/src/unity.c +++ b/src/unity.c @@ -356,11 +356,11 @@ void UnityPrintFloat(const UNITY_DOUBLE input_number) { UnityPrint("0"); } - else if (isnan(number)) + else if (UNITY_IS_NAN(number)) { UnityPrint("nan"); } - else if (isinf(number)) + else if (UNITY_IS_INF(number)) { UnityPrint("inf"); } @@ -895,15 +895,15 @@ void UnityAssertEqualIntArray(UNITY_INTERNAL_PTR expected, #ifndef UNITY_EXCLUDE_FLOAT /* Wrap this define in a function with variable types as float or double */ #define UNITY_FLOAT_OR_DOUBLE_WITHIN(delta, expected, actual, diff) \ - if (isinf(expected) && isinf(actual) && (((expected) < 0) == ((actual) < 0))) return 1; \ + if (UNITY_IS_INF(expected) && UNITY_IS_INF(actual) && (((expected) < 0) == ((actual) < 0))) return 1; \ if (UNITY_NAN_CHECK) return 1; \ (diff) = (actual) - (expected); \ if ((diff) < 0) (diff) = -(diff); \ if ((delta) < 0) (delta) = -(delta); \ - return !(isnan(diff) || isinf(diff) || ((diff) > (delta))) + return !(UNITY_IS_NAN(diff) || UNITY_IS_INF(diff) || ((diff) > (delta))) /* This first part of this condition will catch any NaN or Infinite values */ #ifndef UNITY_NAN_NOT_EQUAL_NAN - #define UNITY_NAN_CHECK isnan(expected) && isnan(actual) + #define UNITY_NAN_CHECK UNITY_IS_NAN(expected) && UNITY_IS_NAN(actual) #else #define UNITY_NAN_CHECK 0 #endif @@ -954,12 +954,12 @@ void UnityAssertWithinFloatArray(const UNITY_FLOAT delta, #endif } - if (isinf(in_delta)) + if (UNITY_IS_INF(in_delta)) { return; /* Arrays will be force equal with infinite delta */ } - if (isnan(in_delta)) + if (UNITY_IS_NAN(in_delta)) { /* Delta must be correct number */ UnityPrintPointlessAndBail(); @@ -1098,21 +1098,21 @@ void UnityAssertFloatSpecial(const UNITY_FLOAT actual, { case UNITY_FLOAT_IS_INF: case UNITY_FLOAT_IS_NOT_INF: - is_trait = isinf(actual) && (actual > 0); + is_trait = UNITY_IS_INF(actual) && (actual > 0); break; case UNITY_FLOAT_IS_NEG_INF: case UNITY_FLOAT_IS_NOT_NEG_INF: - is_trait = isinf(actual) && (actual < 0); + is_trait = UNITY_IS_INF(actual) && (actual < 0); break; case UNITY_FLOAT_IS_NAN: case UNITY_FLOAT_IS_NOT_NAN: - is_trait = isnan(actual) ? 1 : 0; + is_trait = UNITY_IS_NAN(actual) ? 1 : 0; break; case UNITY_FLOAT_IS_DET: /* A determinate number is non infinite and not NaN. */ case UNITY_FLOAT_IS_NOT_DET: - is_trait = !isinf(actual) && !isnan(actual); + is_trait = !UNITY_IS_INF(actual) && !UNITY_IS_NAN(actual); break; case UNITY_FLOAT_INVALID_TRAIT: /* Supress warning */ @@ -1182,12 +1182,12 @@ void UnityAssertWithinDoubleArray(const UNITY_DOUBLE delta, #endif } - if (isinf(in_delta)) + if (UNITY_IS_INF(in_delta)) { return; /* Arrays will be force equal with infinite delta */ } - if (isnan(in_delta)) + if (UNITY_IS_NAN(in_delta)) { /* Delta must be correct number */ UnityPrintPointlessAndBail(); @@ -1325,21 +1325,21 @@ void UnityAssertDoubleSpecial(const UNITY_DOUBLE actual, { case UNITY_FLOAT_IS_INF: case UNITY_FLOAT_IS_NOT_INF: - is_trait = isinf(actual) && (actual > 0); + is_trait = UNITY_IS_INF(actual) && (actual > 0); break; case UNITY_FLOAT_IS_NEG_INF: case UNITY_FLOAT_IS_NOT_NEG_INF: - is_trait = isinf(actual) && (actual < 0); + is_trait = UNITY_IS_INF(actual) && (actual < 0); break; case UNITY_FLOAT_IS_NAN: case UNITY_FLOAT_IS_NOT_NAN: - is_trait = isnan(actual) ? 1 : 0; + is_trait = UNITY_IS_NAN(actual) ? 1 : 0; break; case UNITY_FLOAT_IS_DET: /* A determinate number is non infinite and not NaN. */ case UNITY_FLOAT_IS_NOT_DET: - is_trait = !isinf(actual) && !isnan(actual); + is_trait = !UNITY_IS_INF(actual) && !UNITY_IS_NAN(actual); break; case UNITY_FLOAT_INVALID_TRAIT: /* Supress warning */ diff --git a/src/unity_internals.h b/src/unity_internals.h index 11d9abb4..65938ff7 100644 --- a/src/unity_internals.h +++ b/src/unity_internals.h @@ -241,16 +241,25 @@ #endif typedef UNITY_FLOAT_TYPE UNITY_FLOAT; -/* isinf & isnan macros should be provided by math.h */ -#ifndef isinf -/* The value of Inf - Inf is NaN */ -#define isinf(n) (isnan((n) - (n)) && !isnan(n)) -#endif - +/* isnan macro should be provided by math.h. Override if not macro */ +#ifndef UNITY_IS_NAN #ifndef isnan /* NaN is the only floating point value that does NOT equal itself. * Therefore if n != n, then it is NaN. */ -#define isnan(n) ((n != n) ? 1 : 0) +#define UNITY_IS_NAN(n) ((n != n) ? 1 : 0) +#else +#define UNITY_IS_NAN(n) isnan(n) +#endif +#endif + +/* isinf macro should be provided by math.h. Override if not macro */ +#ifndef UNITY_IS_INF +#ifndef isinf +/* The value of Inf - Inf is NaN */ +#define UNITY_IS_INF(n) (UNITY_IS_NAN((n) - (n)) && !UNITY_IS_NAN(n)) +#else +#define UNITY_IS_INF(n) isinf(n) +#endif #endif #endif From 3911b01d8166f3bc3778e81737711d241f642c2a Mon Sep 17 00:00:00 2001 From: "Lei, Andre" Date: Thu, 16 Nov 2023 19:40:45 +0000 Subject: [PATCH 395/454] Update generate test runner to leverage custom UNITY_END() --- auto/generate_test_runner.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/auto/generate_test_runner.rb b/auto/generate_test_runner.rb index 057c02fb..4b34c8b7 100755 --- a/auto/generate_test_runner.rb +++ b/auto/generate_test_runner.rb @@ -450,10 +450,10 @@ def create_main(output, filename, tests, used_mocks) if @options[:omit_begin_end] output.puts(' (void) suite_teardown(0);') else - output.puts(' return suiteTearDown(UnityEnd());') + output.puts(' return suiteTearDown(UNITY_END());') end else - output.puts(' return UnityEnd();') unless @options[:omit_begin_end] + output.puts(' return UNITY_END();') unless @options[:omit_begin_end] end output.puts('}') end @@ -529,7 +529,7 @@ def create_h_file(output, filename, tests, testfile_includes, used_mocks) ' --suite_setup="" - code to execute for setup of entire suite', ' --suite_teardown="" - code to execute for teardown of entire suite', ' --use_param_tests=1 - enable parameterized tests (disabled by default)', - ' --omit_begin_end=1 - omit calls to UnityBegin and UnityEnd (disabled by default)', + ' --omit_begin_end=1 - omit calls to UnityBegin and UNITY_END (disabled by default)', ' --header_file="" - path/name of test header file to generate too'].join("\n") exit 1 end From 985f6e019472a2165cbae2320eac04f90eb8d226 Mon Sep 17 00:00:00 2001 From: Dennis Skinner Date: Sat, 2 Dec 2023 03:05:32 -0500 Subject: [PATCH 396/454] Add help option to test command line args When test binaries are run with unknown options or with the standard -h option, a help menu will print all available options. This is much more convenient than having to dig through unity.c to find every option. --- src/unity.c | 11 ++++++++ test/tests/test_generate_test_runner.rb | 36 ++++++++++++++++++++++++- 2 files changed, 46 insertions(+), 1 deletion(-) diff --git a/src/unity.c b/src/unity.c index cc2e5ce1..284f0dce 100644 --- a/src/unity.c +++ b/src/unity.c @@ -2329,6 +2329,17 @@ int UnityParseOptions(int argc, char** argv) UnityPrint("ERROR: Unknown Option "); UNITY_OUTPUT_CHAR(argv[i][1]); UNITY_PRINT_EOL(); + /* fall-through to display help */ + case 'h': + UnityPrint("Options: "); UNITY_PRINT_EOL(); + UnityPrint("-l List all tests"); UNITY_PRINT_EOL(); + UnityPrint("-f TEST Only run tests with TEST in the name"); UNITY_PRINT_EOL(); + UnityPrint("-n TEST Only run tests with TEST in the name"); UNITY_PRINT_EOL(); + UnityPrint("-h Show this help menu"); UNITY_PRINT_EOL(); + UnityPrint("-q Quiet/Decrease verbosity"); UNITY_PRINT_EOL(); + UnityPrint("-v Increase verbosity"); UNITY_PRINT_EOL(); + UnityPrint("-x TEST Exclude tests with TEST in the name"); UNITY_PRINT_EOL(); + UNITY_OUTPUT_FLUSH(); return 1; } } diff --git a/test/tests/test_generate_test_runner.rb b/test/tests/test_generate_test_runner.rb index 658b6e2e..1d73bf81 100644 --- a/test/tests/test_generate_test_runner.rb +++ b/test/tests/test_generate_test_runner.rb @@ -1158,9 +1158,43 @@ :to_pass => [ ], :to_fail => [ ], :to_ignore => [ ], - :text => [ "ERROR: Unknown Option z" ], + :text => [ + "ERROR: Unknown Option z", + "Options:", + "-l List all tests", + "-f TEST Only run tests with TEST in the name", + "-n TEST Only run tests with TEST in the name", + "-h Show this help menu", + "-q Quiet/Decrease verbosity", + "-v Increase verbosity", + "-x TEST Exclude tests with TEST in the name", + ], } }, + + { :name => 'ArgsHelp', + :testfile => 'testdata/testRunnerGenerator.c', + :testdefines => ['TEST', 'UNITY_USE_COMMAND_LINE_ARGS'], + :options => { + :cmdline_args => true, + }, + :cmdline_args => "-h", + :expected => { + :to_pass => [ ], + :to_fail => [ ], + :to_ignore => [ ], + :text => [ + "Options:", + "-l List all tests", + "-f TEST Only run tests with TEST in the name", + "-n TEST Only run tests with TEST in the name", + "-h Show this help menu", + "-q Quiet/Decrease verbosity", + "-v Increase verbosity", + "-x TEST Exclude tests with TEST in the name", + ], + } + }, ] def runner_test(test, runner, expected, test_defines, cmdline_args, features) From fcb4e53c367b8df1053810ed8ed6192ee322e27d Mon Sep 17 00:00:00 2001 From: Dennis Skinner <1518323+Skinner927@users.noreply.github.com> Date: Sun, 3 Dec 2023 22:07:15 -0500 Subject: [PATCH 397/454] Update help menu to use mnemonics --- src/unity.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/unity.c b/src/unity.c index 284f0dce..8b858c98 100644 --- a/src/unity.c +++ b/src/unity.c @@ -2332,13 +2332,13 @@ int UnityParseOptions(int argc, char** argv) /* fall-through to display help */ case 'h': UnityPrint("Options: "); UNITY_PRINT_EOL(); - UnityPrint("-l List all tests"); UNITY_PRINT_EOL(); - UnityPrint("-f TEST Only run tests with TEST in the name"); UNITY_PRINT_EOL(); - UnityPrint("-n TEST Only run tests with TEST in the name"); UNITY_PRINT_EOL(); - UnityPrint("-h Show this help menu"); UNITY_PRINT_EOL(); - UnityPrint("-q Quiet/Decrease verbosity"); UNITY_PRINT_EOL(); - UnityPrint("-v Increase verbosity"); UNITY_PRINT_EOL(); - UnityPrint("-x TEST Exclude tests with TEST in the name"); UNITY_PRINT_EOL(); + UnityPrint("-l List all tests and exit"); UNITY_PRINT_EOL(); + UnityPrint("-f NAME Filter to run only tests whose name includes NAME"); UNITY_PRINT_EOL(); + UnityPrint("-n NAME (deprecated) alias of -f"); UNITY_PRINT_EOL(); + UnityPrint("-h show this Help menu"); UNITY_PRINT_EOL(); + UnityPrint("-q Quiet/decrease verbosity"); UNITY_PRINT_EOL(); + UnityPrint("-v increase Verbosity"); UNITY_PRINT_EOL(); + UnityPrint("-x NAME eXclude tests whose name includes NAME"); UNITY_PRINT_EOL(); UNITY_OUTPUT_FLUSH(); return 1; } From 049ddda6156ec4889748805e85328876e322cac4 Mon Sep 17 00:00:00 2001 From: Dennis Skinner <1518323+Skinner927@users.noreply.github.com> Date: Sun, 3 Dec 2023 23:02:09 -0500 Subject: [PATCH 398/454] Fix tests for new help verbiage --- test/tests/test_generate_test_runner.rb | 56 ++++++++++++------------- 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/test/tests/test_generate_test_runner.rb b/test/tests/test_generate_test_runner.rb index 1d73bf81..0f92a3af 100644 --- a/test/tests/test_generate_test_runner.rb +++ b/test/tests/test_generate_test_runner.rb @@ -1161,40 +1161,40 @@ :text => [ "ERROR: Unknown Option z", "Options:", - "-l List all tests", - "-f TEST Only run tests with TEST in the name", - "-n TEST Only run tests with TEST in the name", - "-h Show this help menu", - "-q Quiet/Decrease verbosity", - "-v Increase verbosity", - "-x TEST Exclude tests with TEST in the name", + "-l List all tests and exit", + "-f NAME Filter to run only tests whose name includes NAME", + "-n NAME (deprecated) alias of -f", + "-h show this Help menu", + "-q Quiet/decrease verbosity", + "-v increase Verbosity", + "-x NAME eXclude tests whose name includes NAME", ], } }, { :name => 'ArgsHelp', - :testfile => 'testdata/testRunnerGenerator.c', - :testdefines => ['TEST', 'UNITY_USE_COMMAND_LINE_ARGS'], - :options => { - :cmdline_args => true, - }, - :cmdline_args => "-h", - :expected => { - :to_pass => [ ], - :to_fail => [ ], - :to_ignore => [ ], - :text => [ - "Options:", - "-l List all tests", - "-f TEST Only run tests with TEST in the name", - "-n TEST Only run tests with TEST in the name", - "-h Show this help menu", - "-q Quiet/Decrease verbosity", - "-v Increase verbosity", - "-x TEST Exclude tests with TEST in the name", - ], - } + :testfile => 'testdata/testRunnerGenerator.c', + :testdefines => ['TEST', 'UNITY_USE_COMMAND_LINE_ARGS'], + :options => { + :cmdline_args => true, }, + :cmdline_args => "-h", + :expected => { + :to_pass => [ ], + :to_fail => [ ], + :to_ignore => [ ], + :text => [ + "Options:", + "-l List all tests and exit", + "-f NAME Filter to run only tests whose name includes NAME", + "-n NAME (deprecated) alias of -f", + "-h show this Help menu", + "-q Quiet/decrease verbosity", + "-v increase Verbosity", + "-x NAME eXclude tests whose name includes NAME", + ], + } + }, ] def runner_test(test, runner, expected, test_defines, cmdline_args, features) From 4a606dc2cd47e1fcd8391c45ae6be7fc648346e9 Mon Sep 17 00:00:00 2001 From: Dennis Skinner <1518323+Skinner927@users.noreply.github.com> Date: Sun, 3 Dec 2023 22:58:39 -0500 Subject: [PATCH 399/454] Add missing `generate_test_runner.rb` options to docs --- docs/UnityHelperScriptsGuide.md | 63 ++++++++++++++++++++++++++++++++- 1 file changed, 62 insertions(+), 1 deletion(-) diff --git a/docs/UnityHelperScriptsGuide.md b/docs/UnityHelperScriptsGuide.md index 3c321336..68382808 100644 --- a/docs/UnityHelperScriptsGuide.md +++ b/docs/UnityHelperScriptsGuide.md @@ -114,6 +114,11 @@ In the `examples` directory, Example 3's Rakefile demonstrates using a Ruby hash This option specifies an array of file names to be `#include`'d at the top of your runner C file. You might use it to reference custom types or anything else universally needed in your generated runners. +##### `:defines` + +This option specifies an array of definitions to be `#define`'d at the top of your runner C file. +Each definition will be wrapped in an `#ifndef`. + ##### `:suite_setup` Define this option with C code to be executed _before any_ test cases are run. @@ -191,7 +196,63 @@ Few usage examples can be found in `/test/tests/test_unity_parameterized.c` file You should define `UNITY_SUPPORT_TEST_CASES` macro for tests success compiling, if you enable current option. -You can see list of supported macros list in the next section. +You can see list of supported macros list in the +[Parameterized tests provided macros](#parameterized-tests-provided-macros) +section that follows. + +##### `:cmdline_args` + +When set to `true`, the generated test runner can accept a number of +options to modify how the test(s) are run. + +Ensure Unity is compiled with `UNITY_USE_COMMAND_LINE_ARGS` defined or else +the required functions will not exist. + +These are the available options: + +| Option | Description | +| --------- | ------------------------------------------------- | +| `-l` | List all tests and exit | +| `-f NAME` | Filter to run only tests whose name includes NAME | +| `-n NAME` | (deprecated) alias of -f | +| `-h` | show the Help menu that lists these options | +| `-q` | Quiet/decrease verbosity | +| `-v` | increase Verbosity | +| `-x NAME` | eXclude tests whose name includes NAME | + +##### `:setup_name` + +Override the default test `setUp` function name. + +##### `:teardown_name` + +Override the default test `tearDown` function name. + +##### `:test_reset_name` + +Override the default test `resetTest` function name. + +##### `:test_verify_name` + +Override the default test `verifyTest` function name. + +##### `:main_name` + +Override the test's `main()` function name (from `main` to whatever is specified). +The sentinel value `:auto` will use the test's filename with the `.c` extension removed prefixed +with `main_` as the "main" function. + +To clarify, if `:main_name == :auto` and the test filename is "test_my_project.c", then the +generated function name will be `main_test_my_project(int argc, char** argv)`. + +##### `main_export_decl` + +Provide any `cdecl` for the `main()` test function. Is empty by default. + +##### `:omit_begin_end` + +If `true`, the `UnityBegin` and `UnityEnd` function will not be called for +Unity test state setup and cleanup. #### Parameterized tests provided macros From 3adb5dd7b92bab98ed079f2a4729a6b281b3dbde Mon Sep 17 00:00:00 2001 From: Dennis Skinner <1518323+Skinner927@users.noreply.github.com> Date: Mon, 4 Dec 2023 13:38:50 -0500 Subject: [PATCH 400/454] Add FALLTHRU --- src/unity.c | 3 ++- test/tests/test_generate_test_runner.rb | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/unity.c b/src/unity.c index 8b858c98..b105fa27 100644 --- a/src/unity.c +++ b/src/unity.c @@ -2329,7 +2329,8 @@ int UnityParseOptions(int argc, char** argv) UnityPrint("ERROR: Unknown Option "); UNITY_OUTPUT_CHAR(argv[i][1]); UNITY_PRINT_EOL(); - /* fall-through to display help */ + /* Now display help */ + /* FALLTHRU */ case 'h': UnityPrint("Options: "); UNITY_PRINT_EOL(); UnityPrint("-l List all tests and exit"); UNITY_PRINT_EOL(); diff --git a/test/tests/test_generate_test_runner.rb b/test/tests/test_generate_test_runner.rb index 0f92a3af..229b6abb 100644 --- a/test/tests/test_generate_test_runner.rb +++ b/test/tests/test_generate_test_runner.rb @@ -1163,7 +1163,7 @@ "Options:", "-l List all tests and exit", "-f NAME Filter to run only tests whose name includes NAME", - "-n NAME (deprecated) alias of -f", + "-n NAME \\(deprecated\\) alias of -f", "-h show this Help menu", "-q Quiet/decrease verbosity", "-v increase Verbosity", @@ -1187,7 +1187,7 @@ "Options:", "-l List all tests and exit", "-f NAME Filter to run only tests whose name includes NAME", - "-n NAME (deprecated) alias of -f", + "-n NAME \\(deprecated\\) alias of -f", "-h show this Help menu", "-q Quiet/decrease verbosity", "-v increase Verbosity", From b4f65573f75564d4b5d33e1812a31946191620d1 Mon Sep 17 00:00:00 2001 From: Mark VanderVoord Date: Thu, 4 Jan 2024 16:57:45 -0500 Subject: [PATCH 401/454] Bump rubocop version --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index ce948bd3..339bd23a 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -23,7 +23,7 @@ jobs: - name: Setup Ruby Testing Tools run: | sudo gem install rspec - sudo gem install rubocop -v 0.57.2 + sudo gem install rubocop -v 1.57.2 # Checks out repository under $GITHUB_WORKSPACE - name: Checkout Latest Repo From 64939db64e3271808fdfcfa348120b36790a23cf Mon Sep 17 00:00:00 2001 From: Mark VanderVoord Date: Fri, 19 Jan 2024 11:44:48 -0500 Subject: [PATCH 402/454] generate test runner: clean injected defines so the ifndef doesn't use the assignment when it exists. --- auto/generate_test_runner.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/auto/generate_test_runner.rb b/auto/generate_test_runner.rb index 057c02fb..102f6f30 100755 --- a/auto/generate_test_runner.rb +++ b/auto/generate_test_runner.rb @@ -239,7 +239,11 @@ def create_header(output, mocks, testfile_includes = []) output.puts('#include "cmock.h"') unless mocks.empty? output.puts('}') if @options[:externcincludes] if @options[:defines] && !@options[:defines].empty? - @options[:defines].each { |d| output.puts("#ifndef #{d}\n#define #{d}\n#endif /* #{d} */") } + output.puts("/* injected defines for unity settings, etc */") + @options[:defines].each do |d| + def_only = d.match(/(\w+).*/)[1] + output.puts("#ifndef #{def_only}\n#define #{d}\n#endif /* #{def_only} */") + end end if @options[:header_file] && !@options[:header_file].empty? output.puts("#include \"#{File.basename(@options[:header_file])}\"") From 2777955d3a3275447ebcfca01b844ea6430c9fbb Mon Sep 17 00:00:00 2001 From: Mark VanderVoord Date: Sat, 9 Mar 2024 18:28:42 -0500 Subject: [PATCH 403/454] Document unity exec time options. --- LICENSE.txt | 2 +- docs/UnityConfigurationGuide.md | 28 ++++++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/LICENSE.txt b/LICENSE.txt index a541b843..e12b59e6 100644 --- a/LICENSE.txt +++ b/LICENSE.txt @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2007-23 Mike Karlesky, Mark VanderVoord, Greg Williams +Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, Greg Williams Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/docs/UnityConfigurationGuide.md b/docs/UnityConfigurationGuide.md index 953851fd..0b735f7a 100644 --- a/docs/UnityConfigurationGuide.md +++ b/docs/UnityConfigurationGuide.md @@ -482,6 +482,34 @@ _Example:_ #define UNITY_OUTPUT_COLOR ``` +#### `UNITY_INCLUDE_EXEC_TIME` + +Define this to measure and report execution time for each test in the suite. When enabled, Unity will do +it's best to automatically find a way to determine the time in milliseconds. On most Windows, macos, or +Linux environments, this is automatic. If not, you can give Unity more information. + +#### `UNITY_CLOCK_MS` + +If you're working on a system (embedded or otherwise) which has an accessible millisecond timer. You can +define `UNITY_CLOCK_MS` to be the name of the function which returns the millisecond timer. It will then +attempt to use that function for timing purposes. + +#### `UNITY_EXEC_TIME_START` + +Define this hook to start a millisecond timer if necessary. + +#### `UNITY_EXEC_TIME_STOP` + +Define this hook to stop a millisecond timer if necessary. + +#### `UNITY_PRINT_EXEC_TIME` + +Define this hook to print the current execution time. Used to report the milliseconds elapsed. + +#### `UNITY_TIME_TYPE` + +Finally, this can be set to the type which holds the millisecond timer. + #### `UNITY_SHORTHAND_AS_INT` #### `UNITY_SHORTHAND_AS_MEM` From b512a1c184f61861f0e1e43a80fb770cffd720d3 Mon Sep 17 00:00:00 2001 From: Mark VanderVoord Date: Sat, 9 Mar 2024 18:50:25 -0500 Subject: [PATCH 404/454] Flesh out documentation for command line options for runner generator. --- docs/UnityHelperScriptsGuide.md | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/docs/UnityHelperScriptsGuide.md b/docs/UnityHelperScriptsGuide.md index 68382808..01db2752 100644 --- a/docs/UnityHelperScriptsGuide.md +++ b/docs/UnityHelperScriptsGuide.md @@ -126,6 +126,8 @@ Define this option with C code to be executed _before any_ test cases are run. Alternatively, if your C compiler supports weak symbols, you can leave this option unset and instead provide a `void suiteSetUp(void)` function in your test suite. The linker will look for this symbol and fall back to a Unity-provided stub if it is not found. +This option can also be specified at the command prompt as `--suite_setup=""` + ##### `:suite_teardown` Define this option with C code to be executed _after all_ test cases have finished. @@ -136,6 +138,8 @@ You can normally just return `num_failures`. Alternatively, if your C compiler supports weak symbols, you can leave this option unset and instead provide a `int suiteTearDown(int num_failures)` function in your test suite. The linker will look for this symbol and fall back to a Unity-provided stub if it is not found. +This option can also be specified at the command prompt as `--suite_teardown=""` + ##### `:enforce_strict_ordering` This option should be defined if you have the strict order feature enabled in CMock (see CMock documentation). @@ -146,6 +150,8 @@ If you provide the same YAML to the generator as used in CMock's configuration, This option should be defined if you are mixing C and CPP and want your test runners to automatically include extern "C" support when they are generated. +This option can also be specified at the command prompt as `--externc` + ##### `:mock_prefix` and `:mock_suffix` Unity automatically generates calls to Init, Verify and Destroy for every file included in the main test file that starts with the given mock prefix and ends with the given mock suffix, file extension not included. @@ -170,8 +176,11 @@ Or as a yaml file: If you are using CMock, it is very likely that you are already passing an array of plugins to CMock. You can just use the same array here. + This script will just ignore the plugins that don't require additional support. +This option can also be specified at the command prompt as `--cexception` + ##### `:include_extensions` This option specifies the pattern for matching acceptable header file extensions. @@ -200,6 +209,8 @@ You can see list of supported macros list in the [Parameterized tests provided macros](#parameterized-tests-provided-macros) section that follows. +This option can also be specified at the command prompt as `--use_param_tests=1` + ##### `:cmdline_args` When set to `true`, the generated test runner can accept a number of @@ -224,18 +235,26 @@ These are the available options: Override the default test `setUp` function name. +This option can also be specified at the command prompt as `--setup_name=""` + ##### `:teardown_name` Override the default test `tearDown` function name. +This option can also be specified at the command prompt as `--teardown_name=""` + ##### `:test_reset_name` Override the default test `resetTest` function name. +This option can also be specified at the command prompt as `--test_reset_name=""` + ##### `:test_verify_name` Override the default test `verifyTest` function name. +This option can also be specified at the command prompt as `--test_verify_name=""` + ##### `:main_name` Override the test's `main()` function name (from `main` to whatever is specified). @@ -245,6 +264,8 @@ with `main_` as the "main" function. To clarify, if `:main_name == :auto` and the test filename is "test_my_project.c", then the generated function name will be `main_test_my_project(int argc, char** argv)`. +This option can also be specified at the command prompt as `--main_name=""` + ##### `main_export_decl` Provide any `cdecl` for the `main()` test function. Is empty by default. @@ -254,6 +275,8 @@ Provide any `cdecl` for the `main()` test function. Is empty by default. If `true`, the `UnityBegin` and `UnityEnd` function will not be called for Unity test state setup and cleanup. +This option can also be specified at the command prompt as `--omit_begin_end` + #### Parameterized tests provided macros Unity provides support for few param tests generators, that can be combined From e3457a85f4738bdcb4359b6a8abef2d7bc716ade Mon Sep 17 00:00:00 2001 From: Mark VanderVoord Date: Sat, 9 Mar 2024 19:26:38 -0500 Subject: [PATCH 405/454] Fix temperamental test in core test suite. --- test/tests/test_unity_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/tests/test_unity_core.c b/test/tests/test_unity_core.c index d324e861..c6ac8128 100644 --- a/test/tests/test_unity_core.c +++ b/test/tests/test_unity_core.c @@ -296,9 +296,9 @@ void testFailureCountIncrementsAndIsReturnedAtEnd(void) Unity.CurrentTestFailed = 1; startPutcharSpy(); /* Suppress output */ startFlushSpy(); - TEST_ASSERT_EQUAL(0, getFlushSpyCalls()); UnityConcludeTest(); endPutcharSpy(); + TEST_ASSERT_EQUAL(0, getFlushSpyCalls()); TEST_ASSERT_EQUAL(savedFailures + 1, Unity.TestFailures); #if defined(UNITY_OUTPUT_FLUSH) && defined(UNITY_OUTPUT_FLUSH_HEADER_DECLARATION) TEST_ASSERT_EQUAL(1, getFlushSpyCalls()); From 860062d51b2e8a75d150337b63ca2a472840d13c Mon Sep 17 00:00:00 2001 From: Mark VanderVoord Date: Sat, 9 Mar 2024 19:36:15 -0500 Subject: [PATCH 406/454] Fixed issue #715 (typo that disabled two tests) --- test/tests/test_unity_arrays.c | 2 +- test/tests/test_unity_integers_64.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/test/tests/test_unity_arrays.c b/test/tests/test_unity_arrays.c index 59848836..2151eef9 100644 --- a/test/tests/test_unity_arrays.c +++ b/test/tests/test_unity_arrays.c @@ -61,7 +61,7 @@ void testInt64ArrayWithinDeltaAndMessage(void) #endif } -void tesUInt64ArrayNotWithinDelta(void) +void testInt64ArrayNotWithinDelta(void) { #ifndef UNITY_SUPPORT_64 TEST_IGNORE(); diff --git a/test/tests/test_unity_integers_64.c b/test/tests/test_unity_integers_64.c index 867d1e79..6e83329e 100644 --- a/test/tests/test_unity_integers_64.c +++ b/test/tests/test_unity_integers_64.c @@ -61,7 +61,7 @@ void testInt64ArrayWithinDeltaAndMessage(void) #endif } -void tesUInt64ArrayNotWithinDelta(void) +void testInt64ArrayNotWithinDelta(void) { #ifndef UNITY_SUPPORT_64 TEST_IGNORE(); From 85452ad1544f77d752a2444eb8859f73346bfb97 Mon Sep 17 00:00:00 2001 From: Mark VanderVoord Date: Wed, 13 Mar 2024 15:07:30 -0400 Subject: [PATCH 407/454] :memo: Add Code of Conduct and Contributing docs --- docs/CODE_OF_CONDUCT.md | 138 +++++++++++++++++++++++ docs/CONTRIBUTING.md | 238 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 376 insertions(+) create mode 100644 docs/CODE_OF_CONDUCT.md create mode 100644 docs/CONTRIBUTING.md diff --git a/docs/CODE_OF_CONDUCT.md b/docs/CODE_OF_CONDUCT.md new file mode 100644 index 00000000..84e34806 --- /dev/null +++ b/docs/CODE_OF_CONDUCT.md @@ -0,0 +1,138 @@ + +# ThrowTheSwitch.org Code of Conduct + +Thank you for participating in a ThrowTheSwitch.org community project! We want +this to continue to be a warm and inviting place for everyone to share ideas +and get help. To accomplish this goal, we've developed this Code of Conduct. + +## Our Pledge + +We as members, contributors, and leaders pledge to make participation in our +community a harassment-free experience for everyone, regardless of age, body +size, visible or invisible disability, ethnicity, sex characteristics, gender +identity and expression, level of experience, education, socio-economic status, +nationality, personal appearance, race, caste, color, religion, or sexual +identity and orientation. + +We pledge to act and interact in ways that contribute to an open, welcoming, +diverse, inclusive, and healthy community. + +## Our Standards + +Examples of behavior that contributes to a positive environment for our +community include: + +* Demonstrating empathy and kindness toward other people +* Being respectful of differing opinions, viewpoints, and experiences +* Giving and gracefully accepting constructive feedback +* Accepting responsibility and apologizing to those affected by our mistakes, + and learning from the experience +* Focusing on what is best not just for us as individuals, but for the overall + community + +Examples of unacceptable behavior include: + +* The use of sexualized language or imagery, and sexual attention or advances of + any kind +* Trolling, insulting or derogatory comments, and personal or political attacks +* Public or private harassment +* Publishing others' private information, such as a physical or email address, + without their explicit permission +* Other conduct which could reasonably be considered inappropriate in a + professional setting + +## Enforcement Responsibilities + +Community leaders are responsible for clarifying and enforcing our standards of +acceptable behavior and will take appropriate and fair corrective action in +response to any behavior that they deem inappropriate, threatening, offensive, +or harmful. + +Community leaders have the right and responsibility to remove, edit, or reject +comments, commits, code, wiki edits, issues, and other contributions that are +not aligned to this Code of Conduct, and will communicate reasons for moderation +decisions when appropriate. + +## Scope + +This Code of Conduct applies within all community spaces, and also applies when +an individual is officially representing the community in public spaces. +Examples of representing our community include using an official email address, +posting via an official social media account, or acting as an appointed +representative at an online or offline event. + +## Enforcement + +Instances of abusive, harassing, or otherwise unacceptable behavior may be +reported to the community leaders responsible for enforcement at +hello@thingamabyte.com. + +All complaints will be reviewed and investigated promptly and fairly. + +All community leaders are obligated to respect the privacy and security of the +reporter of any incident. + +## Enforcement Guidelines + +Community leaders will follow these Community Impact Guidelines in determining +the consequences for any action they deem in violation of this Code of Conduct: + +### 1. Correction + +**Community Impact**: Use of inappropriate language or other behavior deemed +unprofessional or unwelcome in the community. + +**Consequence**: A private, written warning from community leaders, providing +clarity around the nature of the violation and an explanation of why the +behavior was inappropriate. A public apology may be requested. + +### 2. Warning + +**Community Impact**: A violation through a single incident or series of +actions. + +**Consequence**: A warning with consequences for continued behavior. No +interaction with the people involved, including unsolicited interaction with +those enforcing the Code of Conduct, for a specified period of time. This +includes avoiding interactions in community spaces as well as external channels +like social media. Violating these terms may lead to a temporary or permanent +ban. + +### 3. Temporary Ban + +**Community Impact**: A serious violation of community standards, including +sustained inappropriate behavior. + +**Consequence**: A temporary ban from any sort of interaction or public +communication with the community for a specified period of time. No public or +private interaction with the people involved, including unsolicited interaction +with those enforcing the Code of Conduct, is allowed during this period. +Violating these terms may lead to a permanent ban. + +### 4. Permanent Ban + +**Community Impact**: Demonstrating a pattern of violation of community +standards, including sustained inappropriate behavior, harassment of an +individual, or aggression toward or disparagement of classes of individuals. + +**Consequence**: A permanent ban from any sort of public interaction within the +community. + +## Attribution + +This Code of Conduct is adapted from the [Contributor Covenant][homepage], +version 2.1, available at +[https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1]. + +Community Impact Guidelines were inspired by +[Mozilla's code of conduct enforcement ladder][Mozilla CoC]. + +For answers to common questions about this code of conduct, see the FAQ at +[https://www.contributor-covenant.org/faq][FAQ]. Translations are available at +[https://www.contributor-covenant.org/translations][translations]. + +[homepage]: https://www.contributor-covenant.org +[v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html +[Mozilla CoC]: https://github.com/mozilla/diversity +[FAQ]: https://www.contributor-covenant.org/faq +[translations]: https://www.contributor-covenant.org/translations diff --git a/docs/CONTRIBUTING.md b/docs/CONTRIBUTING.md new file mode 100644 index 00000000..e64a285a --- /dev/null +++ b/docs/CONTRIBUTING.md @@ -0,0 +1,238 @@ +# Contributing to a ThrowTheSwitch.org Project + +👍🎉 _First off, thanks for taking the time to contribute!_ 🎉👍 + +The following is a set of guidelines for contributing to any of ThrowTheSwitch.org's projects or the website itself, hosted at throwtheswitch.org or ThrowTheSwitch's organization on GitHub. These are mostly guidelines, not rules. Use your best judgment, and feel free to propose changes to this document in a pull request. + +### Table Of Contents + +- [Code of Conduct](#book-code-of-conduct) +- [Asking Questions](#bulb-asking-questions) +- [Opening an Issue](#inbox_tray-opening-an-issue) +- [Feature Requests](#love_letter-feature-requests) +- [Triaging Issues](#mag-triaging-issues) +- [Submitting Pull Requests](#repeat-submitting-pull-requests) +- [Writing Commit Messages](#memo-writing-commit-messages) +- [Code Review](#white_check_mark-code-review) +- [Coding Style](#nail_care-coding-style) +- [Certificate of Origin](#medal_sports-certificate-of-origin) +- [Credits](#pray-credits) + +## :book: Code of Conduct + +Please review our [Code of Conduct](CODE_OF_CONDUCT.md). It is in effect at all times. We expect it to be honored by everyone who contributes to this project. Be a Good Human! + +## :bulb: Asking Questions + +> **Note:** Please don't file an issue to ask a question. We have an official forum where the community chimes in with helpful advice if you have questions. + +* [ThrowTheSwitch Forums](https://throwtheswitch.org/forums) + +### What should I know before I get started? + +ThrowTheSwitch hosts a number of open source projects — Ceedling is the entrypoint for many users. Ceedling is actually built upon the foundation of Unity Test (a flexible C testing framework) and CMock (a mocking tool for C) and it coordinates many other open source and proprietary tools. Please do your best to focus your ideas and questions at the correct tool. We'll do our best to help you find your way, but there will be times where we'll have to direct your attention to another subtool. + +Here are some of the main projects hosted by ThrowTheSwitch.org: + + - [Ceedling](https://www.github.com/throwtheswitch/ceedling) -- Build coordinator for testing C applications, especially embedded C (and optionally your release build too!) + - [CMock](https://www.github.com/throwtheswitch/cmock) -- Mocking tool for automatically creating stubs, mocks, and skeletons in C + - [Unity](https://www.github.com/throwtheswitch/unity) -- Unit Testing framework for C, specially embedded C. + - [MadScienceLabDocker](https://www.github.com/throwtheswitch/madsciencelabdocker) -- Docker image giving you a shortcut to getting running with Ceedling + - [CException](https://www.github.com/throwtheswitch/cexception) -- An exception framework for using simple exceptions in C. + +There are many more, but this list should be a good starting point. + +## :inbox_tray: Opening an Issue + +Before [creating an issue](https://help.github.com/en/github/managing-your-work-on-github/creating-an-issue), check if you are using the latest version of the project. If you are not up-to-date, see if updating fixes your issue first. + +### :beetle: Bug Reports and Other Issues + +A great way to contribute to the project is to send a detailed issue when you encounter a problem. We always appreciate a well-written, thorough bug report. :v: + +In short, since you are most likely a developer, **provide a ticket that you would like to receive**. + +- **Review the documentation** before opening a new issue. + +- **Do not open a duplicate issue!** Search through existing issues to see if your issue has previously been reported. If your issue exists, comment with any additional information you have. You may simply note "I have this problem too", which helps prioritize the most common problems and requests. + +- **Prefer using [reactions](https://github.blog/2016-03-10-add-reactions-to-pull-requests-issues-and-comments/)**, not comments, if you simply want to "+1" an existing issue. + +- **Fully complete the provided issue template.** The bug report template requests all the information we need to quickly and efficiently address your issue. Be clear, concise, and descriptive. Provide as much information as you can, including steps to reproduce, stack traces, compiler errors, library versions, OS versions, and screenshots (if applicable). + +- **Use [GitHub-flavored Markdown](https://help.github.com/en/github/writing-on-github/basic-writing-and-formatting-syntax).** Especially put code blocks and console outputs in backticks (```). This improves readability. + +## :seedling: Feature Requests + +Feature requests are welcome! We don't have all the answers and we truly love the collaborative experience of building software together! That being said, we cannot guarantee your request will be accepted. We want to avoid [feature creep](https://en.wikipedia.org/wiki/Feature_creep). Your idea may be great, but also out-of-scope for the project. If accepted, we'll do our best to tackle it in a timely manner, but cannot make any commitments regarding the timeline for implementation and release. However, you are welcome to submit a pull request to help! + +- **Please don't open a duplicate feature request.** Search for existing feature requests first. If you find your feature (or one very similar) previously requested, comment on that issue. + +- **Fully complete the provided issue template.** The feature request template asks for all necessary information for us to begin a productive conversation. + +- Be precise about the proposed outcome of the feature and how it relates to existing features. Include implementation details if possible. + +## :mag: Triaging Issues + +You can triage issues which may include reproducing bug reports or asking for additional information, such as version numbers or reproduction instructions. Any help you can provide to quickly resolve an issue is very much appreciated! + +## :repeat: Submitting Pull Requests + +We **love** pull requests! Before [forking the repo](https://help.github.com/en/github/getting-started-with-github/fork-a-repo) and [creating a pull request](https://help.github.com/en/github/collaborating-with-issues-and-pull-requests/proposing-changes-to-your-work-with-pull-requests) for non-trivial changes, it is usually best to first open an issue to discuss the changes, or discuss your intended approach for solving the problem in the comments for an existing issue. + +For most contributions, after your first pull request is accepted and merged, you will be [invited to the project](https://help.github.com/en/github/setting-up-and-managing-your-github-user-account/inviting-collaborators-to-a-personal-repository) and given **push access**. :tada: + +*Note: All contributions will be licensed under the project's license.* + +- **Smaller is better.** Submit **one** pull request per bug fix or feature. A pull request should contain isolated changes pertaining to a single bug fix or feature implementation. **Do not** refactor or reformat code that is unrelated to your change. It is better to **submit many small pull requests** rather than a single large one. Enormous pull requests will take enormous amounts of time to review, or may be rejected altogether. + +- **Coordinate bigger changes.** For large and non-trivial changes, open an issue to discuss a strategy with the maintainers. Otherwise, you risk doing a lot of work for nothing! + +- **Prioritize understanding over cleverness.** Write code clearly and concisely. Remember that source code usually gets written once and read often. Ensure the code is clear to the reader. The purpose and logic should be obvious to a reasonably skilled developer, otherwise you should add a comment that explains it. + +- **Follow existing coding style and conventions.** Keep your code consistent with the style, formatting, and conventions in the rest of the code base. When possible, these will be enforced with a linter. Consistency makes it easier to review and modify in the future. + +- **Include test coverage.** Add unit tests when possible. Follow existing patterns for implementing tests. + +- **Update the example project** if one exists to exercise any new functionality you have added. + +- **Add documentation.** Document your changes with code doc comments or in existing guides. + +- **Update the CHANGELOG** for all enhancements and bug fixes. Include the corresponding issue number if one exists, and your GitHub username. (example: "- Fixed crash in profile view. #123 @jessesquires") + +- **Use the repo's default branch.** Branch from and [submit your pull request](https://help.github.com/en/github/collaborating-with-issues-and-pull-requests/creating-a-pull-request-from-a-fork) to the repo's default branch. Usually this is `main`, but it could be `dev`, `develop`, or `master`. + +- **[Resolve any merge conflicts](https://help.github.com/en/github/collaborating-with-issues-and-pull-requests/resolving-a-merge-conflict-on-github)** that occur. + +- **Promptly address any CI failures**. If your pull request fails to build or pass tests, please push another commit to fix it. + +- When writing comments, use properly constructed sentences, including punctuation. + +- Use spaces, not tabs. + +## :memo: Writing Commit Messages + +Please [write a great commit message](https://chris.beams.io/posts/git-commit/). + +1. Separate subject from body with a blank line +1. Limit the subject line to 50 characters +1. Capitalize the subject line +1. Do not end the subject line with a period +1. Wrap the body at _about_ 72 characters +1. Use the body to explain **why**, *not what and how* (the code shows that!) +1. If applicable, prefix the title with the relevant component name or emoji (see below. examples: "[Docs] Fix typo", "[Profile] Fix missing avatar") + +``` +:palm_tree: Summary of Amazing Feature Here + +Add a more detailed explanation here, if necessary. Possibly give +some background about the issue being fixed, etc. The body of the +commit message can be several paragraphs. Further paragraphs come +after blank lines and please do proper word-wrap. + +Wrap it to about 72 characters or so. In some contexts, +the first line is treated as the subject of the commit and the +rest of the text as the body. The blank line separating the summary +from the body is critical (unless you omit the body entirely); +various tools like `log`, `shortlog` and `rebase` can get confused +if you run the two together. + +Explain the problem that this commit is solving. Focus on why you +are making this change as opposed to how or what. The code explains +how or what. Reviewers and your future self can read the patch, +but might not understand why a particular solution was implemented. +Are there side effects or other unintuitive consequences of this +change? Here's the place to explain them. + + - Bullet points are awesome, too + + - A hyphen should be used for the bullet, preceded + by a single space, with blank lines in between + +Note the fixed or relevant GitHub issues at the end: + +Resolves: #123 +See also: #456, #789 +``` + +## :heart: Who Loves Emoji? + +Commit comments, Issues, Feature Requests... they can all use a little sprucing up, right? Consider using the following emoji for a mix of function and :sparkles: dazzle! + + - actions + - :seedling: `:seedling:` (or other plants) when growing new features. Choose your fav! :cactus: :herb: :evergreen_tree: :palm_tree: :deciduous_tree: :blossom: + - :art: `:art:` when improving the format/structure of the code + - :racehorse: `:racehorse:` when improving performance + - :non-potable_water: `:non-potable_water:` when plugging memory leaks + - :memo: `:memo:` when writing docs + - :bug: `:bug:` (or other insects) when fixing a bug. Maybe :beetle: :ant: or :honeybee: ? + - :fire: `:fire:` when removing code or files + - :green_heart: `:green_heart:` when fixing the CI build + - :white_check_mark: `:white_check_mark:` when adding tests + - :lock: `:lock:` when dealing with security + - :arrow_up: `:arrow_up:` when upgrading dependencies + - :arrow_down: `:arrow_down:` when downgrading dependencies + - :shirt: `:shirt:` when removing linter warnings + + - platforms + - :penguin: `:penguin:` when fixing something on Linux + - :apple: `:apple:` when fixing something on macOS + - :checkered_flag: `:checkered_flag:` when fixing something on Windows + +## :white_check_mark: Code Review + +- **Review the code, not the author.** Look for and suggest improvements without disparaging or insulting the author. Provide actionable feedback and explain your reasoning. + +- **You are not your code.** When your code is critiqued, questioned, or constructively criticized, remember that you are not your code. Do not take code review personally. + +- **Always do your best.** No one writes bugs on purpose. Do your best, and learn from your mistakes. + +- Kindly note any violations to the guidelines specified in this document. + +## :violin: Coding Style + +Consistency is the most important. Following the existing style, formatting, and naming conventions of the file you are modifying and of the overall project. Failure to do so will result in a prolonged review process that has to focus on updating the superficial aspects of your code, rather than improving its functionality and performance. + +For example, if all private properties are prefixed with an underscore `_`, then new ones you add should be prefixed in the same way. Or, if methods are named using camelcase, like `thisIsMyNewMethod`, then do not diverge from that by writing `this_is_my_new_method`. You get the idea. If in doubt, please ask or search the codebase for something similar. + +When possible, style and format will be enforced with a linter. + +### C Styleguide + +C code is linted with [AStyle](https://astyle.sourceforge.net/). + +### Ruby Styleguide + +Ruby code is linted with [Rubocop](https://github.com/rubocop/rubocop) + +## :medal_sports: Certificate of Origin + +*Developer's Certificate of Origin 1.1* + +By making a contribution to this project, I certify that: + +> 1. The contribution was created in whole or in part by me and I have the right to submit it under the open source license indicated in the file; or +> 1. The contribution is based upon previous work that, to the best of my knowledge, is covered under an appropriate open source license and I have the right under that license to submit that work with modifications, whether created in whole or in part by me, under the same open source license (unless I am permitted to submit under a different license), as indicated in the file; or +> 1. The contribution was provided directly to me by some other person who certified (1), (2) or (3) and I have not modified it. +> 1. I understand and agree that this project and the contribution are public and that a record of the contribution (including all personal information I submit with it, including my sign-off) is maintained indefinitely and may be redistributed consistent with this project or the open source license(s) involved. + +## [No Brown M&M's](https://en.wikipedia.org/wiki/Van_Halen#Contract_riders) + +If you are reading this, bravo dear user and (hopefully) contributor for making it this far! You are awesome. :100: + +To confirm that you have read this guide and are following it as best as possible, **include this emoji at the top** of your issue or pull request: :pineapple: `:pineapple:` + +## :pray: Credits + +Written by [@jessesquires](https://github.com/jessesquires). Lovingly adapted to ThrowTheSwitch.org by [@mvandervoord](https://github.com/mvandervoord). + +**Please feel free to adopt this guide in your own projects. Fork it wholesale or remix it for your needs.** + +*Many of the ideas and prose for the statements in this document were based on or inspired by work from the following communities:* + +- [Alamofire](https://github.com/Alamofire/Alamofire/blob/master/CONTRIBUTING.md) +- [CocoaPods](https://github.com/CocoaPods/CocoaPods/blob/master/CONTRIBUTING.md) +- [Docker](https://github.com/moby/moby/blob/master/CONTRIBUTING.md) +- [Linux](https://elinux.org/Developer_Certificate_Of_Origin) + +*We commend them for their efforts to facilitate collaboration in their projects.* From 671f8d25f19527a17d15475b038a16e5ba249bdf Mon Sep 17 00:00:00 2001 From: Mark VanderVoord Date: Sat, 16 Mar 2024 23:15:00 -0400 Subject: [PATCH 408/454] Update all the boilerplates --- LICENSE.txt | 2 +- auto/__init__.py | 7 +++++++ auto/colour_prompt.rb | 11 ++++++----- auto/colour_reporter.rb | 11 ++++++----- auto/extract_version.py | 7 +++++++ auto/generate_config.yml | 7 +++++++ auto/generate_module.rb | 11 ++++++----- auto/generate_test_runner.rb | 11 ++++++----- auto/parse_output.rb | 6 ++++++ auto/stylize_as_junit.py | 13 ++++++------- auto/stylize_as_junit.rb | 7 +++++++ auto/test_file_filter.rb | 11 ++++++----- auto/type_sanitizer.rb | 7 +++++++ auto/unity_test_summary.py | 12 ++++++------ auto/unity_test_summary.rb | 11 ++++++----- auto/yaml_helper.rb | 11 ++++++----- examples/example_1/makefile | 11 ++++++----- examples/example_1/src/ProductionCode.c | 7 +++++++ examples/example_1/src/ProductionCode.h | 7 +++++++ examples/example_1/src/ProductionCode2.c | 7 +++++++ examples/example_1/src/ProductionCode2.h | 7 +++++++ examples/example_1/test/TestProductionCode.c | 7 +++++++ examples/example_1/test/TestProductionCode2.c | 7 +++++++ examples/example_2/makefile | 11 ++++++----- examples/example_2/src/ProductionCode.c | 7 +++++++ examples/example_2/src/ProductionCode.h | 7 +++++++ examples/example_2/src/ProductionCode2.c | 7 +++++++ examples/example_2/src/ProductionCode2.h | 7 +++++++ examples/example_2/test/TestProductionCode.c | 7 +++++++ examples/example_2/test/TestProductionCode2.c | 7 +++++++ .../test_runners/TestProductionCode2_Runner.c | 7 +++++++ .../test/test_runners/TestProductionCode_Runner.c | 7 +++++++ examples/example_2/test/test_runners/all_tests.c | 7 +++++++ examples/example_3/helper/UnityHelper.c | 7 +++++++ examples/example_3/helper/UnityHelper.h | 7 +++++++ examples/example_3/rakefile.rb | 7 +++++++ examples/example_3/rakefile_helper.rb | 11 ++++++----- examples/example_3/src/ProductionCode.c | 7 +++++++ examples/example_3/src/ProductionCode.h | 7 +++++++ examples/example_3/src/ProductionCode2.c | 7 +++++++ examples/example_3/src/ProductionCode2.h | 7 +++++++ examples/example_3/target_gcc_32.yml | 7 +++++++ examples/example_3/test/TestProductionCode.c | 7 +++++++ examples/example_3/test/TestProductionCode2.c | 7 +++++++ examples/example_4/src/ProductionCode.c | 7 +++++++ examples/example_4/src/ProductionCode.h | 7 +++++++ examples/example_4/src/ProductionCode2.c | 7 +++++++ examples/example_4/src/ProductionCode2.h | 7 +++++++ examples/example_4/test/TestProductionCode.c | 7 +++++++ examples/example_4/test/TestProductionCode2.c | 7 +++++++ examples/unity_config.h | 7 +++++++ extras/bdd/src/unity_bdd.h | 12 ++++++------ extras/bdd/test/test_bdd.c | 11 ++++++----- extras/fixture/src/unity_fixture.c | 12 ++++++------ extras/fixture/src/unity_fixture.h | 13 +++++++------ extras/fixture/src/unity_fixture_internals.h | 13 +++++++------ extras/fixture/test/main/AllTests.c | 12 ++++++------ extras/fixture/test/template_fixture_tests.c | 13 +++++++------ extras/fixture/test/unity_fixture_Test.c | 13 +++++++------ extras/fixture/test/unity_fixture_TestRunner.c | 13 +++++++------ extras/memory/src/unity_memory.c | 11 ++++++----- extras/memory/src/unity_memory.h | 11 ++++++----- extras/memory/test/Makefile | 7 +++++++ extras/memory/test/unity_memory_Test.c | 11 ++++++----- extras/memory/test/unity_memory_TestRunner.c | 11 ++++++----- extras/memory/test/unity_output_Spy.c | 11 ++++++----- extras/memory/test/unity_output_Spy.h | 11 ++++++----- library.json | 7 +++++++ platformio-build.py | 7 +++++++ src/unity.c | 9 +++++---- src/unity.h | 11 ++++++----- src/unity_internals.h | 11 ++++++----- test/.rubocop.yml | 7 ++++++- test/Makefile | 6 ++++++ test/rakefile | 11 ++++++----- test/rakefile_helper.rb | 11 ++++++----- test/spec/generate_module_existing_file_spec.rb | 7 +++++++ test/targets/ansi.yml | 7 +++++++ test/targets/clang_file.yml | 7 +++++++ test/targets/clang_strict.yml | 7 +++++++ test/targets/gcc_32.yml | 7 +++++++ test/targets/gcc_64.yml | 7 +++++++ test/targets/gcc_auto_limits.yml | 7 +++++++ test/targets/gcc_auto_stdint.yml | 7 +++++++ test/targets/gcc_manual_math.yml | 7 +++++++ test/targets/hitech_picc18.yml | 7 +++++++ test/targets/iar_arm_v4.yml | 7 +++++++ test/targets/iar_arm_v5.yml | 7 +++++++ test/targets/iar_arm_v5_3.yml | 7 +++++++ test/targets/iar_armcortex_LM3S9B92_v5_4.yml | 7 +++++++ test/targets/iar_cortexm3_v5.yml | 7 +++++++ test/targets/iar_msp430.yml | 7 +++++++ test/targets/iar_sh2a_v6.yml | 7 +++++++ test/testdata/CException.h | 7 +++++++ test/testdata/Defs.h | 7 +++++++ test/testdata/cmock.h | 7 +++++++ test/testdata/mockMock.h | 7 +++++++ test/testdata/testRunnerGenerator.c | 7 +++++++ test/testdata/testRunnerGeneratorSmall.c | 7 +++++++ test/testdata/testRunnerGeneratorWithMocks.c | 7 +++++++ test/tests/self_assessment_utils.h | 7 +++++++ test/tests/test_generate_test_runner.rb | 11 ++++++----- test/tests/test_unity_arrays.c | 11 ++++++----- test/tests/test_unity_core.c | 15 +++++++++------ test/tests/test_unity_doubles.c | 11 ++++++----- test/tests/test_unity_floats.c | 11 ++++++----- test/tests/test_unity_integers.c | 11 ++++++----- test/tests/test_unity_integers_64.c | 11 ++++++----- test/tests/test_unity_memory.c | 11 ++++++----- test/tests/test_unity_parameterized.c | 11 ++++++----- test/tests/test_unity_parameterizedDemo.c | 7 +++++++ test/tests/test_unity_strings.c | 11 ++++++----- test/tests/types_for_test.h | 7 +++++++ 113 files changed, 747 insertions(+), 223 deletions(-) diff --git a/LICENSE.txt b/LICENSE.txt index e12b59e6..ecca34ce 100644 --- a/LICENSE.txt +++ b/LICENSE.txt @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, Greg Williams +Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, Greg Williams Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/auto/__init__.py b/auto/__init__.py index e69de29b..793090f9 100644 --- a/auto/__init__.py +++ b/auto/__init__.py @@ -0,0 +1,7 @@ +# ========================================================================= +# Unity - A Test Framework for C +# ThrowTheSwitch.org +# Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams +# SPDX-License-Identifier: MIT +# ========================================================================= + diff --git a/auto/colour_prompt.rb b/auto/colour_prompt.rb index 85cbfd80..57b495a0 100644 --- a/auto/colour_prompt.rb +++ b/auto/colour_prompt.rb @@ -1,8 +1,9 @@ -# ========================================== -# Unity Project - A Test Framework for C -# Copyright (c) 2007 Mike Karlesky, Mark VanderVoord, Greg Williams -# [Released under MIT License. Please refer to license.txt for details] -# ========================================== +# ========================================================================= +# Unity - A Test Framework for C +# ThrowTheSwitch.org +# Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams +# SPDX-License-Identifier: MIT +# ========================================================================= if RUBY_PLATFORM =~ /(win|w)32$/ begin diff --git a/auto/colour_reporter.rb b/auto/colour_reporter.rb index b86b76c5..273ea3b6 100644 --- a/auto/colour_reporter.rb +++ b/auto/colour_reporter.rb @@ -1,8 +1,9 @@ -# ========================================== -# Unity Project - A Test Framework for C -# Copyright (c) 2007 Mike Karlesky, Mark VanderVoord, Greg Williams -# [Released under MIT License. Please refer to license.txt for details] -# ========================================== +# ========================================================================= +# Unity - A Test Framework for C +# ThrowTheSwitch.org +# Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams +# SPDX-License-Identifier: MIT +# ========================================================================= require_relative 'colour_prompt' diff --git a/auto/extract_version.py b/auto/extract_version.py index 1d137e5b..44cb3b41 100755 --- a/auto/extract_version.py +++ b/auto/extract_version.py @@ -1,3 +1,10 @@ +# ========================================================================= +# Unity - A Test Framework for C +# ThrowTheSwitch.org +# Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams +# SPDX-License-Identifier: MIT +# ========================================================================= + #!/usr/bin/env python3 import re import sys diff --git a/auto/generate_config.yml b/auto/generate_config.yml index 4a5e4742..d0fccec7 100644 --- a/auto/generate_config.yml +++ b/auto/generate_config.yml @@ -1,3 +1,10 @@ +# ========================================================================= +# Unity - A Test Framework for C +# ThrowTheSwitch.org +# Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams +# SPDX-License-Identifier: MIT +# ========================================================================= + #this is a sample configuration file for generate_module #you would use it by calling generate_module with the -ygenerate_config.yml option #files like this are useful for customizing generate_module to your environment diff --git a/auto/generate_module.rb b/auto/generate_module.rb index 7b33c727..4c91a131 100644 --- a/auto/generate_module.rb +++ b/auto/generate_module.rb @@ -1,8 +1,9 @@ -# ========================================== -# Unity Project - A Test Framework for C -# Copyright (c) 2007 Mike Karlesky, Mark VanderVoord, Greg Williams -# [Released under MIT License. Please refer to license.txt for details] -# ========================================== +# ========================================================================= +# Unity - A Test Framework for C +# ThrowTheSwitch.org +# Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams +# SPDX-License-Identifier: MIT +# ========================================================================= # This script creates all the files with start code necessary for a new module. # A simple module only requires a source file, header file, and test file. diff --git a/auto/generate_test_runner.rb b/auto/generate_test_runner.rb index 102f6f30..1a90564d 100755 --- a/auto/generate_test_runner.rb +++ b/auto/generate_test_runner.rb @@ -1,10 +1,11 @@ #!/usr/bin/ruby -# ========================================== -# Unity Project - A Test Framework for C -# Copyright (c) 2007 Mike Karlesky, Mark VanderVoord, Greg Williams -# [Released under MIT License. Please refer to license.txt for details] -# ========================================== +# ========================================================================= +# Unity - A Test Framework for C +# ThrowTheSwitch.org +# Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams +# SPDX-License-Identifier: MIT +# ========================================================================= class UnityTestRunnerGenerator def initialize(options = nil) diff --git a/auto/parse_output.rb b/auto/parse_output.rb index aa306e2c..7a5b7a5e 100644 --- a/auto/parse_output.rb +++ b/auto/parse_output.rb @@ -1,3 +1,9 @@ +# ========================================================================= +# Unity - A Test Framework for C +# ThrowTheSwitch.org +# Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams +# SPDX-License-Identifier: MIT +# ========================================================================= #============================================================ # Author: John Theofanopoulos # A simple parser. Takes the output files generated during the diff --git a/auto/stylize_as_junit.py b/auto/stylize_as_junit.py index 06c86596..a60c472e 100644 --- a/auto/stylize_as_junit.py +++ b/auto/stylize_as_junit.py @@ -1,11 +1,10 @@ #! python3 -# ========================================== -# Fork from Unity Project - A Test Framework for C -# Pull request on Gerrit in progress, the objective of this file is to be deleted when official Unity deliveries -# include that modification -# Copyright (c) 2015 Alexander Mueller / XelaRellum@web.de -# [Released under MIT License. Please refer to license.txt for details] -# ========================================== +# ========================================================================= +# Unity - A Test Framework for C +# ThrowTheSwitch.org +# Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams +# SPDX-License-Identifier: MIT +# ========================================================================= import sys import os from glob import glob diff --git a/auto/stylize_as_junit.rb b/auto/stylize_as_junit.rb index e4b911eb..b44979e2 100755 --- a/auto/stylize_as_junit.rb +++ b/auto/stylize_as_junit.rb @@ -1,3 +1,10 @@ +# ========================================================================= +# Unity - A Test Framework for C +# ThrowTheSwitch.org +# Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams +# SPDX-License-Identifier: MIT +# ========================================================================= + #!/usr/bin/ruby # # unity_to_junit.rb diff --git a/auto/test_file_filter.rb b/auto/test_file_filter.rb index f4834a12..c922cdd2 100644 --- a/auto/test_file_filter.rb +++ b/auto/test_file_filter.rb @@ -1,8 +1,9 @@ -# ========================================== -# Unity Project - A Test Framework for C -# Copyright (c) 2007 Mike Karlesky, Mark VanderVoord, Greg Williams -# [Released under MIT License. Please refer to license.txt for details] -# ========================================== +# ========================================================================= +# Unity - A Test Framework for C +# ThrowTheSwitch.org +# Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams +# SPDX-License-Identifier: MIT +# ========================================================================= require_relative 'yaml_helper' diff --git a/auto/type_sanitizer.rb b/auto/type_sanitizer.rb index 3d1db09f..0cf9563c 100644 --- a/auto/type_sanitizer.rb +++ b/auto/type_sanitizer.rb @@ -1,3 +1,10 @@ +# ========================================================================= +# Unity - A Test Framework for C +# ThrowTheSwitch.org +# Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams +# SPDX-License-Identifier: MIT +# ========================================================================= + module TypeSanitizer def self.sanitize_c_identifier(unsanitized) # convert filename to valid C identifier by replacing invalid chars with '_' diff --git a/auto/unity_test_summary.py b/auto/unity_test_summary.py index 00c0da8c..a7d24bad 100644 --- a/auto/unity_test_summary.py +++ b/auto/unity_test_summary.py @@ -1,10 +1,10 @@ #! python3 -# ========================================== -# Unity Project - A Test Framework for C -# Copyright (c) 2015 Alexander Mueller / XelaRellum@web.de -# [Released under MIT License. Please refer to license.txt for details] -# Based on the ruby script by Mike Karlesky, Mark VanderVoord, Greg Williams -# ========================================== +# ========================================================================= +# Unity - A Test Framework for C +# ThrowTheSwitch.org +# Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams +# SPDX-License-Identifier: MIT +# ========================================================================= import sys import os import re diff --git a/auto/unity_test_summary.rb b/auto/unity_test_summary.rb index 03d67a68..0d7f1838 100644 --- a/auto/unity_test_summary.rb +++ b/auto/unity_test_summary.rb @@ -1,8 +1,9 @@ -# ========================================== -# Unity Project - A Test Framework for C -# Copyright (c) 2007 Mike Karlesky, Mark VanderVoord, Greg Williams -# [Released under MIT License. Please refer to license.txt for details] -# ========================================== +# ========================================================================= +# Unity - A Test Framework for C +# ThrowTheSwitch.org +# Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams +# SPDX-License-Identifier: MIT +# ========================================================================= # !/usr/bin/ruby # diff --git a/auto/yaml_helper.rb b/auto/yaml_helper.rb index 3296ba0e..32746db7 100644 --- a/auto/yaml_helper.rb +++ b/auto/yaml_helper.rb @@ -1,8 +1,9 @@ -# ========================================== -# Unity Project - A Test Framework for C -# Copyright (c) 2007 Mike Karlesky, Mark VanderVoord, Greg Williams -# [Released under MIT License. Please refer to license.txt for details] -# ========================================== +# ========================================================================= +# Unity - A Test Framework for C +# ThrowTheSwitch.org +# Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams +# SPDX-License-Identifier: MIT +# ========================================================================= require 'yaml' diff --git a/examples/example_1/makefile b/examples/example_1/makefile index 28409c10..9c97687e 100644 --- a/examples/example_1/makefile +++ b/examples/example_1/makefile @@ -1,8 +1,9 @@ -# ========================================== -# Unity Project - A Test Framework for C -# Copyright (c) 2007 Mike Karlesky, Mark VanderVoord, Greg Williams -# [Released under MIT License. Please refer to license.txt for details] -# ========================================== +# ========================================================================= +# Unity - A Test Framework for C +# ThrowTheSwitch.org +# Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams +# SPDX-License-Identifier: MIT +# ========================================================================= #We try to detect the OS we are running on, and adjust commands as needed ifeq ($(OS),Windows_NT) diff --git a/examples/example_1/src/ProductionCode.c b/examples/example_1/src/ProductionCode.c index db128e5b..6be26aca 100644 --- a/examples/example_1/src/ProductionCode.c +++ b/examples/example_1/src/ProductionCode.c @@ -1,3 +1,10 @@ +/* ========================================================================= + Unity - A Test Framework for C + ThrowTheSwitch.org + Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams + SPDX-License-Identifier: MIT +========================================================================= */ + #include "ProductionCode.h" diff --git a/examples/example_1/src/ProductionCode.h b/examples/example_1/src/ProductionCode.h index 250ca0dc..5aaa8bbc 100644 --- a/examples/example_1/src/ProductionCode.h +++ b/examples/example_1/src/ProductionCode.h @@ -1,3 +1,10 @@ +/* ========================================================================= + Unity - A Test Framework for C + ThrowTheSwitch.org + Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams + SPDX-License-Identifier: MIT +========================================================================= */ + int FindFunction_WhichIsBroken(int NumberToFind); int FunctionWhichReturnsLocalVariable(void); diff --git a/examples/example_1/src/ProductionCode2.c b/examples/example_1/src/ProductionCode2.c index 98ee7eeb..ea12cd71 100644 --- a/examples/example_1/src/ProductionCode2.c +++ b/examples/example_1/src/ProductionCode2.c @@ -1,3 +1,10 @@ +/* ========================================================================= + Unity - A Test Framework for C + ThrowTheSwitch.org + Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams + SPDX-License-Identifier: MIT +========================================================================= */ + #include "ProductionCode2.h" diff --git a/examples/example_1/src/ProductionCode2.h b/examples/example_1/src/ProductionCode2.h index 34ae980d..63f8b0f5 100644 --- a/examples/example_1/src/ProductionCode2.h +++ b/examples/example_1/src/ProductionCode2.h @@ -1,2 +1,9 @@ +/* ========================================================================= + Unity - A Test Framework for C + ThrowTheSwitch.org + Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams + SPDX-License-Identifier: MIT +========================================================================= */ + char* ThisFunctionHasNotBeenTested(int Poor, char* LittleFunction); diff --git a/examples/example_1/test/TestProductionCode.c b/examples/example_1/test/TestProductionCode.c index 404c3718..44441fd1 100644 --- a/examples/example_1/test/TestProductionCode.c +++ b/examples/example_1/test/TestProductionCode.c @@ -1,3 +1,10 @@ +/* ========================================================================= + Unity - A Test Framework for C + ThrowTheSwitch.org + Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams + SPDX-License-Identifier: MIT +========================================================================= */ + #include "ProductionCode.h" #include "unity.h" diff --git a/examples/example_1/test/TestProductionCode2.c b/examples/example_1/test/TestProductionCode2.c index 7d940c17..cb6e4444 100644 --- a/examples/example_1/test/TestProductionCode2.c +++ b/examples/example_1/test/TestProductionCode2.c @@ -1,3 +1,10 @@ +/* ========================================================================= + Unity - A Test Framework for C + ThrowTheSwitch.org + Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams + SPDX-License-Identifier: MIT +========================================================================= */ + #include "ProductionCode2.h" #include "unity.h" diff --git a/examples/example_2/makefile b/examples/example_2/makefile index e2832173..c0b41852 100644 --- a/examples/example_2/makefile +++ b/examples/example_2/makefile @@ -1,8 +1,9 @@ -# ========================================== -# Unity Project - A Test Framework for C -# Copyright (c) 2007 Mike Karlesky, Mark VanderVoord, Greg Williams -# [Released under MIT License. Please refer to license.txt for details] -# ========================================== +# ========================================================================= +# Unity - A Test Framework for C +# ThrowTheSwitch.org +# Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams +# SPDX-License-Identifier: MIT +# ========================================================================= #We try to detect the OS we are running on, and adjust commands as needed ifeq ($(OS),Windows_NT) diff --git a/examples/example_2/src/ProductionCode.c b/examples/example_2/src/ProductionCode.c index 3bafe205..e30851a7 100644 --- a/examples/example_2/src/ProductionCode.c +++ b/examples/example_2/src/ProductionCode.c @@ -1,3 +1,10 @@ +/* ========================================================================= + Unity - A Test Framework for C + ThrowTheSwitch.org + Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams + SPDX-License-Identifier: MIT +========================================================================= */ + #include "ProductionCode.h" diff --git a/examples/example_2/src/ProductionCode.h b/examples/example_2/src/ProductionCode.h index 250ca0dc..5aaa8bbc 100644 --- a/examples/example_2/src/ProductionCode.h +++ b/examples/example_2/src/ProductionCode.h @@ -1,3 +1,10 @@ +/* ========================================================================= + Unity - A Test Framework for C + ThrowTheSwitch.org + Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams + SPDX-License-Identifier: MIT +========================================================================= */ + int FindFunction_WhichIsBroken(int NumberToFind); int FunctionWhichReturnsLocalVariable(void); diff --git a/examples/example_2/src/ProductionCode2.c b/examples/example_2/src/ProductionCode2.c index 77c969f1..bd6f4ce8 100644 --- a/examples/example_2/src/ProductionCode2.c +++ b/examples/example_2/src/ProductionCode2.c @@ -1,3 +1,10 @@ +/* ========================================================================= + Unity - A Test Framework for C + ThrowTheSwitch.org + Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams + SPDX-License-Identifier: MIT +========================================================================= */ + #include "ProductionCode2.h" diff --git a/examples/example_2/src/ProductionCode2.h b/examples/example_2/src/ProductionCode2.h index 34ae980d..63f8b0f5 100644 --- a/examples/example_2/src/ProductionCode2.h +++ b/examples/example_2/src/ProductionCode2.h @@ -1,2 +1,9 @@ +/* ========================================================================= + Unity - A Test Framework for C + ThrowTheSwitch.org + Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams + SPDX-License-Identifier: MIT +========================================================================= */ + char* ThisFunctionHasNotBeenTested(int Poor, char* LittleFunction); diff --git a/examples/example_2/test/TestProductionCode.c b/examples/example_2/test/TestProductionCode.c index b8fb95c0..0e05a0db 100644 --- a/examples/example_2/test/TestProductionCode.c +++ b/examples/example_2/test/TestProductionCode.c @@ -1,3 +1,10 @@ +/* ========================================================================= + Unity - A Test Framework for C + ThrowTheSwitch.org + Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams + SPDX-License-Identifier: MIT +========================================================================= */ + #include "ProductionCode.h" #include "unity.h" #include "unity_fixture.h" diff --git a/examples/example_2/test/TestProductionCode2.c b/examples/example_2/test/TestProductionCode2.c index d9f4efe3..de6c3242 100644 --- a/examples/example_2/test/TestProductionCode2.c +++ b/examples/example_2/test/TestProductionCode2.c @@ -1,3 +1,10 @@ +/* ========================================================================= + Unity - A Test Framework for C + ThrowTheSwitch.org + Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams + SPDX-License-Identifier: MIT +========================================================================= */ + #include "ProductionCode2.h" #include "unity.h" #include "unity_fixture.h" diff --git a/examples/example_2/test/test_runners/TestProductionCode2_Runner.c b/examples/example_2/test/test_runners/TestProductionCode2_Runner.c index 6fcc3b12..c528c80f 100644 --- a/examples/example_2/test/test_runners/TestProductionCode2_Runner.c +++ b/examples/example_2/test/test_runners/TestProductionCode2_Runner.c @@ -1,3 +1,10 @@ +/* ========================================================================= + Unity - A Test Framework for C + ThrowTheSwitch.org + Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams + SPDX-License-Identifier: MIT +========================================================================= */ + #include "unity.h" #include "unity_fixture.h" diff --git a/examples/example_2/test/test_runners/TestProductionCode_Runner.c b/examples/example_2/test/test_runners/TestProductionCode_Runner.c index 41a416a6..b65e6695 100644 --- a/examples/example_2/test/test_runners/TestProductionCode_Runner.c +++ b/examples/example_2/test/test_runners/TestProductionCode_Runner.c @@ -1,3 +1,10 @@ +/* ========================================================================= + Unity - A Test Framework for C + ThrowTheSwitch.org + Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams + SPDX-License-Identifier: MIT +========================================================================= */ + #include "unity.h" #include "unity_fixture.h" diff --git a/examples/example_2/test/test_runners/all_tests.c b/examples/example_2/test/test_runners/all_tests.c index e706ece7..6cd4ef95 100644 --- a/examples/example_2/test/test_runners/all_tests.c +++ b/examples/example_2/test/test_runners/all_tests.c @@ -1,3 +1,10 @@ +/* ========================================================================= + Unity - A Test Framework for C + ThrowTheSwitch.org + Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams + SPDX-License-Identifier: MIT +========================================================================= */ + #include "unity_fixture.h" static void RunAllTests(void) diff --git a/examples/example_3/helper/UnityHelper.c b/examples/example_3/helper/UnityHelper.c index 9cf42c67..12110176 100644 --- a/examples/example_3/helper/UnityHelper.c +++ b/examples/example_3/helper/UnityHelper.c @@ -1,3 +1,10 @@ +/* ========================================================================= + Unity - A Test Framework for C + ThrowTheSwitch.org + Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams + SPDX-License-Identifier: MIT +========================================================================= */ + #include "unity.h" #include "UnityHelper.h" #include diff --git a/examples/example_3/helper/UnityHelper.h b/examples/example_3/helper/UnityHelper.h index 15161115..573f26c9 100644 --- a/examples/example_3/helper/UnityHelper.h +++ b/examples/example_3/helper/UnityHelper.h @@ -1,3 +1,10 @@ +/* ========================================================================= + Unity - A Test Framework for C + ThrowTheSwitch.org + Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams + SPDX-License-Identifier: MIT +========================================================================= */ + #ifndef _TESTHELPER_H #define _TESTHELPER_H diff --git a/examples/example_3/rakefile.rb b/examples/example_3/rakefile.rb index c095af38..48de0d05 100644 --- a/examples/example_3/rakefile.rb +++ b/examples/example_3/rakefile.rb @@ -1,3 +1,10 @@ +# ========================================================================= +# Unity - A Test Framework for C +# ThrowTheSwitch.org +# Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams +# SPDX-License-Identifier: MIT +# ========================================================================= + require 'rake' require 'rake/clean' require_relative 'rakefile_helper' diff --git a/examples/example_3/rakefile_helper.rb b/examples/example_3/rakefile_helper.rb index cbc4549f..9b57e814 100644 --- a/examples/example_3/rakefile_helper.rb +++ b/examples/example_3/rakefile_helper.rb @@ -1,8 +1,9 @@ -# ========================================== -# Unity Project - A Test Framework for C -# Copyright (c) 2007 Mike Karlesky, Mark VanderVoord, Greg Williams -# [Released under MIT License. Please refer to license.txt for details] -# ========================================== +# ========================================================================= +# Unity - A Test Framework for C +# ThrowTheSwitch.org +# Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams +# SPDX-License-Identifier: MIT +# ========================================================================= require 'fileutils' require_relative '../../auto/unity_test_summary' diff --git a/examples/example_3/src/ProductionCode.c b/examples/example_3/src/ProductionCode.c index 3bafe205..e30851a7 100644 --- a/examples/example_3/src/ProductionCode.c +++ b/examples/example_3/src/ProductionCode.c @@ -1,3 +1,10 @@ +/* ========================================================================= + Unity - A Test Framework for C + ThrowTheSwitch.org + Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams + SPDX-License-Identifier: MIT +========================================================================= */ + #include "ProductionCode.h" diff --git a/examples/example_3/src/ProductionCode.h b/examples/example_3/src/ProductionCode.h index 250ca0dc..5aaa8bbc 100644 --- a/examples/example_3/src/ProductionCode.h +++ b/examples/example_3/src/ProductionCode.h @@ -1,3 +1,10 @@ +/* ========================================================================= + Unity - A Test Framework for C + ThrowTheSwitch.org + Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams + SPDX-License-Identifier: MIT +========================================================================= */ + int FindFunction_WhichIsBroken(int NumberToFind); int FunctionWhichReturnsLocalVariable(void); diff --git a/examples/example_3/src/ProductionCode2.c b/examples/example_3/src/ProductionCode2.c index 77c969f1..bd6f4ce8 100644 --- a/examples/example_3/src/ProductionCode2.c +++ b/examples/example_3/src/ProductionCode2.c @@ -1,3 +1,10 @@ +/* ========================================================================= + Unity - A Test Framework for C + ThrowTheSwitch.org + Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams + SPDX-License-Identifier: MIT +========================================================================= */ + #include "ProductionCode2.h" diff --git a/examples/example_3/src/ProductionCode2.h b/examples/example_3/src/ProductionCode2.h index 34ae980d..63f8b0f5 100644 --- a/examples/example_3/src/ProductionCode2.h +++ b/examples/example_3/src/ProductionCode2.h @@ -1,2 +1,9 @@ +/* ========================================================================= + Unity - A Test Framework for C + ThrowTheSwitch.org + Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams + SPDX-License-Identifier: MIT +========================================================================= */ + char* ThisFunctionHasNotBeenTested(int Poor, char* LittleFunction); diff --git a/examples/example_3/target_gcc_32.yml b/examples/example_3/target_gcc_32.yml index d7568ab8..3fa10040 100644 --- a/examples/example_3/target_gcc_32.yml +++ b/examples/example_3/target_gcc_32.yml @@ -1,3 +1,10 @@ +# ========================================================================= +# Unity - A Test Framework for C +# ThrowTheSwitch.org +# Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams +# SPDX-License-Identifier: MIT +# ========================================================================= + # Copied from ~Unity/targets/gcc_32.yml unity_root: &unity_root '../..' unity_source: &unity_source '../../src/' diff --git a/examples/example_3/test/TestProductionCode.c b/examples/example_3/test/TestProductionCode.c index 28a55812..a74e9eab 100644 --- a/examples/example_3/test/TestProductionCode.c +++ b/examples/example_3/test/TestProductionCode.c @@ -1,3 +1,10 @@ +/* ========================================================================= + Unity - A Test Framework for C + ThrowTheSwitch.org + Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams + SPDX-License-Identifier: MIT +========================================================================= */ + #include "ProductionCode.h" #include "unity.h" diff --git a/examples/example_3/test/TestProductionCode2.c b/examples/example_3/test/TestProductionCode2.c index e2119cc3..43907d4f 100644 --- a/examples/example_3/test/TestProductionCode2.c +++ b/examples/example_3/test/TestProductionCode2.c @@ -1,3 +1,10 @@ +/* ========================================================================= + Unity - A Test Framework for C + ThrowTheSwitch.org + Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams + SPDX-License-Identifier: MIT +========================================================================= */ + #include "ProductionCode2.h" #include "unity.h" diff --git a/examples/example_4/src/ProductionCode.c b/examples/example_4/src/ProductionCode.c index db128e5b..6be26aca 100644 --- a/examples/example_4/src/ProductionCode.c +++ b/examples/example_4/src/ProductionCode.c @@ -1,3 +1,10 @@ +/* ========================================================================= + Unity - A Test Framework for C + ThrowTheSwitch.org + Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams + SPDX-License-Identifier: MIT +========================================================================= */ + #include "ProductionCode.h" diff --git a/examples/example_4/src/ProductionCode.h b/examples/example_4/src/ProductionCode.h index 250ca0dc..5aaa8bbc 100644 --- a/examples/example_4/src/ProductionCode.h +++ b/examples/example_4/src/ProductionCode.h @@ -1,3 +1,10 @@ +/* ========================================================================= + Unity - A Test Framework for C + ThrowTheSwitch.org + Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams + SPDX-License-Identifier: MIT +========================================================================= */ + int FindFunction_WhichIsBroken(int NumberToFind); int FunctionWhichReturnsLocalVariable(void); diff --git a/examples/example_4/src/ProductionCode2.c b/examples/example_4/src/ProductionCode2.c index 98ee7eeb..ea12cd71 100644 --- a/examples/example_4/src/ProductionCode2.c +++ b/examples/example_4/src/ProductionCode2.c @@ -1,3 +1,10 @@ +/* ========================================================================= + Unity - A Test Framework for C + ThrowTheSwitch.org + Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams + SPDX-License-Identifier: MIT +========================================================================= */ + #include "ProductionCode2.h" diff --git a/examples/example_4/src/ProductionCode2.h b/examples/example_4/src/ProductionCode2.h index 34ae980d..63f8b0f5 100644 --- a/examples/example_4/src/ProductionCode2.h +++ b/examples/example_4/src/ProductionCode2.h @@ -1,2 +1,9 @@ +/* ========================================================================= + Unity - A Test Framework for C + ThrowTheSwitch.org + Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams + SPDX-License-Identifier: MIT +========================================================================= */ + char* ThisFunctionHasNotBeenTested(int Poor, char* LittleFunction); diff --git a/examples/example_4/test/TestProductionCode.c b/examples/example_4/test/TestProductionCode.c index 526a84eb..15a19fcd 100644 --- a/examples/example_4/test/TestProductionCode.c +++ b/examples/example_4/test/TestProductionCode.c @@ -1,3 +1,10 @@ +/* ========================================================================= + Unity - A Test Framework for C + ThrowTheSwitch.org + Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams + SPDX-License-Identifier: MIT +========================================================================= */ + #include "ProductionCode.h" #include "unity.h" diff --git a/examples/example_4/test/TestProductionCode2.c b/examples/example_4/test/TestProductionCode2.c index 2578ca94..479a1a67 100644 --- a/examples/example_4/test/TestProductionCode2.c +++ b/examples/example_4/test/TestProductionCode2.c @@ -1,3 +1,10 @@ +/* ========================================================================= + Unity - A Test Framework for C + ThrowTheSwitch.org + Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams + SPDX-License-Identifier: MIT +========================================================================= */ + #include "ProductionCode2.h" #include "unity.h" diff --git a/examples/unity_config.h b/examples/unity_config.h index fc6cdb05..98931aba 100644 --- a/examples/unity_config.h +++ b/examples/unity_config.h @@ -1,3 +1,10 @@ +/* ========================================================================= + Unity - A Test Framework for C + ThrowTheSwitch.org + Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams + SPDX-License-Identifier: MIT +========================================================================= */ + /* Unity Configuration * As of May 11th, 2016 at ThrowTheSwitch/Unity commit 837c529 * Update: December 29th, 2016 diff --git a/extras/bdd/src/unity_bdd.h b/extras/bdd/src/unity_bdd.h index d91b3f13..129b7bc3 100644 --- a/extras/bdd/src/unity_bdd.h +++ b/extras/bdd/src/unity_bdd.h @@ -1,9 +1,9 @@ -/* Copyright (c) 2023 Michael Gene Brockus (Dreamer) and Contributed to Unity Project - * ========================================== - * Unity Project - A Test Framework for C - * Copyright (c) 2007 Mike Karlesky, Mark VanderVoord, Greg Williams - * [Released under MIT License. Please refer to license.txt for details] - * ========================================== */ +/* ========================================================================= + Unity - A Test Framework for C + ThrowTheSwitch.org + Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams + SPDX-License-Identifier: MIT +========================================================================= */ #ifndef UNITY_BDD_TEST_H_ #define UNITY_BDD_TEST_H_ diff --git a/extras/bdd/test/test_bdd.c b/extras/bdd/test/test_bdd.c index 4f415858..548ba97c 100644 --- a/extras/bdd/test/test_bdd.c +++ b/extras/bdd/test/test_bdd.c @@ -1,8 +1,9 @@ -/* ========================================== - * Unity Project - A Test Framework for C - * Copyright (c) 2007 Mike Karlesky, Mark VanderVoord, Greg Williams - * [Released under MIT License. Please refer to license.txt for details] - * ========================================== */ +/* ========================================================================= + Unity - A Test Framework for C + ThrowTheSwitch.org + Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams + SPDX-License-Identifier: MIT +========================================================================= */ #include "unity.h" #include "unity_bdd.h" diff --git a/extras/fixture/src/unity_fixture.c b/extras/fixture/src/unity_fixture.c index c3dda796..0047bd36 100644 --- a/extras/fixture/src/unity_fixture.c +++ b/extras/fixture/src/unity_fixture.c @@ -1,9 +1,9 @@ -/* Copyright (c) 2010 James Grenning and Contributed to Unity Project - * ========================================== - * Unity Project - A Test Framework for C - * Copyright (c) 2007 Mike Karlesky, Mark VanderVoord, Greg Williams - * [Released under MIT License. Please refer to license.txt for details] - * ========================================== */ +/* ========================================================================= + Unity - A Test Framework for C + ThrowTheSwitch.org + Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams + SPDX-License-Identifier: MIT +========================================================================= */ #include "unity_fixture.h" #include "unity_internals.h" diff --git a/extras/fixture/src/unity_fixture.h b/extras/fixture/src/unity_fixture.h index 65750662..0eb471e3 100644 --- a/extras/fixture/src/unity_fixture.h +++ b/extras/fixture/src/unity_fixture.h @@ -1,9 +1,10 @@ -/* Copyright (c) 2010 James Grenning and Contributed to Unity Project - * ========================================== - * Unity Project - A Test Framework for C - * Copyright (c) 2007 Mike Karlesky, Mark VanderVoord, Greg Williams - * [Released under MIT License. Please refer to license.txt for details] - * ========================================== */ +/* ========================================================================= + Unity - A Test Framework for C + ThrowTheSwitch.org + Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams + SPDX-License-Identifier: MIT +========================================================================= */ + #ifndef UNITY_FIXTURE_H_ #define UNITY_FIXTURE_H_ diff --git a/extras/fixture/src/unity_fixture_internals.h b/extras/fixture/src/unity_fixture_internals.h index 1c51aa98..9e6f8b7c 100644 --- a/extras/fixture/src/unity_fixture_internals.h +++ b/extras/fixture/src/unity_fixture_internals.h @@ -1,9 +1,10 @@ -/* Copyright (c) 2010 James Grenning and Contributed to Unity Project - * ========================================== - * Unity Project - A Test Framework for C - * Copyright (c) 2007 Mike Karlesky, Mark VanderVoord, Greg Williams - * [Released under MIT License. Please refer to license.txt for details] - * ========================================== */ +/* ========================================================================= + Unity - A Test Framework for C + ThrowTheSwitch.org + Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams + SPDX-License-Identifier: MIT +========================================================================= */ + #ifndef UNITY_FIXTURE_INTERNALS_H_ #define UNITY_FIXTURE_INTERNALS_H_ diff --git a/extras/fixture/test/main/AllTests.c b/extras/fixture/test/main/AllTests.c index 30242cb3..8b8e16ba 100644 --- a/extras/fixture/test/main/AllTests.c +++ b/extras/fixture/test/main/AllTests.c @@ -1,9 +1,9 @@ -/* Copyright (c) 2010 James Grenning and Contributed to Unity Project - * ========================================== - * Unity Project - A Test Framework for C - * Copyright (c) 2007 Mike Karlesky, Mark VanderVoord, Greg Williams - * [Released under MIT License. Please refer to license.txt for details] - * ========================================== */ +/* ========================================================================= + Unity - A Test Framework for C + ThrowTheSwitch.org + Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams + SPDX-License-Identifier: MIT +========================================================================= */ #include "unity_fixture.h" diff --git a/extras/fixture/test/template_fixture_tests.c b/extras/fixture/test/template_fixture_tests.c index 18bbb89e..ad7f0823 100644 --- a/extras/fixture/test/template_fixture_tests.c +++ b/extras/fixture/test/template_fixture_tests.c @@ -1,9 +1,10 @@ -/* Copyright (c) 2010 James Grenning and Contributed to Unity Project - * ========================================== - * Unity Project - A Test Framework for C - * Copyright (c) 2007 Mike Karlesky, Mark VanderVoord, Greg Williams - * [Released under MIT License. Please refer to license.txt for details] - * ========================================== */ +/* ========================================================================= + Unity - A Test Framework for C + ThrowTheSwitch.org + Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams + SPDX-License-Identifier: MIT +========================================================================= */ + #include "unity_fixture.h" diff --git a/extras/fixture/test/unity_fixture_Test.c b/extras/fixture/test/unity_fixture_Test.c index 1422b489..e258fbaf 100644 --- a/extras/fixture/test/unity_fixture_Test.c +++ b/extras/fixture/test/unity_fixture_Test.c @@ -1,9 +1,10 @@ -/* Copyright (c) 2010 James Grenning and Contributed to Unity Project - * ========================================== - * Unity Project - A Test Framework for C - * Copyright (c) 2007 Mike Karlesky, Mark VanderVoord, Greg Williams - * [Released under MIT License. Please refer to license.txt for details] - * ========================================== */ +/* ========================================================================= + Unity - A Test Framework for C + ThrowTheSwitch.org + Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams + SPDX-License-Identifier: MIT +========================================================================= */ + #include "unity_fixture.h" #include diff --git a/extras/fixture/test/unity_fixture_TestRunner.c b/extras/fixture/test/unity_fixture_TestRunner.c index 7b78c49c..0eb2bdb1 100644 --- a/extras/fixture/test/unity_fixture_TestRunner.c +++ b/extras/fixture/test/unity_fixture_TestRunner.c @@ -1,9 +1,10 @@ -/* Copyright (c) 2010 James Grenning and Contributed to Unity Project - * ========================================== - * Unity Project - A Test Framework for C - * Copyright (c) 2007 Mike Karlesky, Mark VanderVoord, Greg Williams - * [Released under MIT License. Please refer to license.txt for details] - * ========================================== */ +/* ========================================================================= + Unity - A Test Framework for C + ThrowTheSwitch.org + Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams + SPDX-License-Identifier: MIT +========================================================================= */ + #include "unity_fixture.h" diff --git a/extras/memory/src/unity_memory.c b/extras/memory/src/unity_memory.c index e4dc6654..85abbc9f 100644 --- a/extras/memory/src/unity_memory.c +++ b/extras/memory/src/unity_memory.c @@ -1,8 +1,9 @@ -/* ========================================== - * Unity Project - A Test Framework for C - * Copyright (c) 2007 Mike Karlesky, Mark VanderVoord, Greg Williams - * [Released under MIT License. Please refer to license.txt for details] - * ========================================== */ +/* ========================================================================= + Unity - A Test Framework for C + ThrowTheSwitch.org + Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams + SPDX-License-Identifier: MIT +========================================================================= */ #include "unity.h" #include "unity_memory.h" diff --git a/extras/memory/src/unity_memory.h b/extras/memory/src/unity_memory.h index ccdb826f..ace96a5a 100644 --- a/extras/memory/src/unity_memory.h +++ b/extras/memory/src/unity_memory.h @@ -1,8 +1,9 @@ -/* ========================================== - * Unity Project - A Test Framework for C - * Copyright (c) 2007 Mike Karlesky, Mark VanderVoord, Greg Williams - * [Released under MIT License. Please refer to license.txt for details] - * ========================================== */ +/* ========================================================================= + Unity - A Test Framework for C + ThrowTheSwitch.org + Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams + SPDX-License-Identifier: MIT +========================================================================= */ #ifndef UNITY_MEMORY_OVERRIDES_H_ #define UNITY_MEMORY_OVERRIDES_H_ diff --git a/extras/memory/test/Makefile b/extras/memory/test/Makefile index f3f86ce6..790ab393 100644 --- a/extras/memory/test/Makefile +++ b/extras/memory/test/Makefile @@ -1,3 +1,10 @@ +# ========================================================================= +# Unity - A Test Framework for C +# ThrowTheSwitch.org +# Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams +# SPDX-License-Identifier: MIT +# ========================================================================= + CC = gcc ifeq ($(shell uname -s), Darwin) CC = clang diff --git a/extras/memory/test/unity_memory_Test.c b/extras/memory/test/unity_memory_Test.c index 6f832e27..163d24c0 100644 --- a/extras/memory/test/unity_memory_Test.c +++ b/extras/memory/test/unity_memory_Test.c @@ -1,8 +1,9 @@ -/* ========================================== - * Unity Project - A Test Framework for C - * Copyright (c) 2007 Mike Karlesky, Mark VanderVoord, Greg Williams - * [Released under MIT License. Please refer to license.txt for details] - * ========================================== */ +/* ========================================================================= + Unity - A Test Framework for C + ThrowTheSwitch.org + Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams + SPDX-License-Identifier: MIT +========================================================================= */ #include "unity.h" #include "unity_memory.h" diff --git a/extras/memory/test/unity_memory_TestRunner.c b/extras/memory/test/unity_memory_TestRunner.c index 4c91a599..92e98ff8 100644 --- a/extras/memory/test/unity_memory_TestRunner.c +++ b/extras/memory/test/unity_memory_TestRunner.c @@ -1,8 +1,9 @@ -/* ========================================== - * Unity Project - A Test Framework for C - * Copyright (c) 2007 Mike Karlesky, Mark VanderVoord, Greg Williams - * [Released under MIT License. Please refer to license.txt for details] - * ========================================== */ +/* ========================================================================= + Unity - A Test Framework for C + ThrowTheSwitch.org + Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams + SPDX-License-Identifier: MIT +========================================================================= */ #include "unity.h" #include "unity_memory.h" diff --git a/extras/memory/test/unity_output_Spy.c b/extras/memory/test/unity_output_Spy.c index 772fe0bd..69fcacc7 100644 --- a/extras/memory/test/unity_output_Spy.c +++ b/extras/memory/test/unity_output_Spy.c @@ -1,8 +1,9 @@ -/* ========================================== - * Unity Project - A Test Framework for C - * Copyright (c) 2007 Mike Karlesky, Mark VanderVoord, Greg Williams - * [Released under MIT License. Please refer to license.txt for details] - * ========================================== */ +/* ========================================================================= + Unity - A Test Framework for C + ThrowTheSwitch.org + Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams + SPDX-License-Identifier: MIT +========================================================================= */ #include "unity.h" #include "unity_output_Spy.h" diff --git a/extras/memory/test/unity_output_Spy.h b/extras/memory/test/unity_output_Spy.h index e2e401c4..739263cd 100644 --- a/extras/memory/test/unity_output_Spy.h +++ b/extras/memory/test/unity_output_Spy.h @@ -1,8 +1,9 @@ -/* ========================================== - * Unity Project - A Test Framework for C - * Copyright (c) 2007 Mike Karlesky, Mark VanderVoord, Greg Williams - * [Released under MIT License. Please refer to license.txt for details] - * ========================================== */ +/* ========================================================================= + Unity - A Test Framework for C + ThrowTheSwitch.org + Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams + SPDX-License-Identifier: MIT +========================================================================= */ #ifndef UNITY_OUTPUT_SPY_H #define UNITY_OUTPUT_SPY_H diff --git a/library.json b/library.json index 914f5f68..839b5abd 100644 --- a/library.json +++ b/library.json @@ -1,3 +1,10 @@ +# ========================================================================= +# Unity - A Test Framework for C +# ThrowTheSwitch.org +# Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams +# SPDX-License-Identifier: MIT +# ========================================================================= + { "name": "Unity", "version": "2.6.0", diff --git a/platformio-build.py b/platformio-build.py index 66fea42f..51251ddd 100644 --- a/platformio-build.py +++ b/platformio-build.py @@ -1,3 +1,10 @@ +# ========================================================================= +# Unity - A Test Framework for C +# ThrowTheSwitch.org +# Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams +# SPDX-License-Identifier: MIT +# ========================================================================= + import os Import("env") diff --git a/src/unity.c b/src/unity.c index b105fa27..7fd703ab 100644 --- a/src/unity.c +++ b/src/unity.c @@ -1,8 +1,9 @@ /* ========================================================================= - Unity Project - A Test Framework for C - Copyright (c) 2007-21 Mike Karlesky, Mark VanderVoord, Greg Williams - [Released under MIT License. Please refer to license.txt for details] -============================================================================ */ + Unity - A Test Framework for C + ThrowTheSwitch.org + Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams + SPDX-License-Identifier: MIT +========================================================================= */ #include "unity.h" diff --git a/src/unity.h b/src/unity.h index 265e548d..8337c8c6 100644 --- a/src/unity.h +++ b/src/unity.h @@ -1,8 +1,9 @@ -/* ========================================== - Unity Project - A Test Framework for C - Copyright (c) 2007-21 Mike Karlesky, Mark VanderVoord, Greg Williams - [Released under MIT License. Please refer to license.txt for details] -========================================== */ +/* ========================================================================= + Unity - A Test Framework for C + ThrowTheSwitch.org + Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams + SPDX-License-Identifier: MIT +========================================================================= */ #ifndef UNITY_FRAMEWORK_H #define UNITY_FRAMEWORK_H diff --git a/src/unity_internals.h b/src/unity_internals.h index 65938ff7..1214bf07 100644 --- a/src/unity_internals.h +++ b/src/unity_internals.h @@ -1,8 +1,9 @@ -/* ========================================== - Unity Project - A Test Framework for C - Copyright (c) 2007-21 Mike Karlesky, Mark VanderVoord, Greg Williams - [Released under MIT License. Please refer to license.txt for details] -========================================== */ +/* ========================================================================= + Unity - A Test Framework for C + ThrowTheSwitch.org + Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams + SPDX-License-Identifier: MIT +========================================================================= */ #ifndef UNITY_INTERNALS_H #define UNITY_INTERNALS_H diff --git a/test/.rubocop.yml b/test/.rubocop.yml index a3b811bd..a11c2461 100644 --- a/test/.rubocop.yml +++ b/test/.rubocop.yml @@ -1,4 +1,9 @@ -# This is the configuration used to check the rubocop source code. +# ========================================================================= +# Unity - A Test Framework for C +# ThrowTheSwitch.org +# Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams +# SPDX-License-Identifier: MIT +# ========================================================================= #inherit_from: .rubocop_todo.yml diff --git a/test/Makefile b/test/Makefile index 5be0488f..917a8749 100644 --- a/test/Makefile +++ b/test/Makefile @@ -1,3 +1,9 @@ +# ========================================================================= +# Unity - A Test Framework for C +# ThrowTheSwitch.org +# Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams +# SPDX-License-Identifier: MIT +# ========================================================================= CC = gcc ifeq ($(shell uname -s), Darwin) CC = clang diff --git a/test/rakefile b/test/rakefile index e5f3b748..7747f305 100644 --- a/test/rakefile +++ b/test/rakefile @@ -1,8 +1,9 @@ -# ========================================== -# Unity Project - A Test Framework for C -# Copyright (c) 2007 Mike Karlesky, Mark VanderVoord, Greg Williams -# [Released under MIT License. Please refer to license.txt for details] -# ========================================== +# ========================================================================= +# Unity - A Test Framework for C +# ThrowTheSwitch.org +# Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams +# SPDX-License-Identifier: MIT +# ========================================================================= $verbose = false $extra_paths = [] diff --git a/test/rakefile_helper.rb b/test/rakefile_helper.rb index 1a9fc334..61ce874e 100644 --- a/test/rakefile_helper.rb +++ b/test/rakefile_helper.rb @@ -1,8 +1,9 @@ -# ========================================== -# Unity Project - A Test Framework for C -# Copyright (c) 2007 Mike Karlesky, Mark VanderVoord, Greg Williams -# [Released under MIT License. Please refer to license.txt for details] -# ========================================== +# ========================================================================= +# Unity - A Test Framework for C +# ThrowTheSwitch.org +# Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams +# SPDX-License-Identifier: MIT +# ========================================================================= require 'fileutils' require_relative '../auto/unity_test_summary' diff --git a/test/spec/generate_module_existing_file_spec.rb b/test/spec/generate_module_existing_file_spec.rb index 74e7fc84..0d5eb1b3 100644 --- a/test/spec/generate_module_existing_file_spec.rb +++ b/test/spec/generate_module_existing_file_spec.rb @@ -1,3 +1,10 @@ +# ========================================================================= +# Unity - A Test Framework for C +# ThrowTheSwitch.org +# Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams +# SPDX-License-Identifier: MIT +# ========================================================================= + require '../auto/generate_module.rb' require 'fileutils' diff --git a/test/targets/ansi.yml b/test/targets/ansi.yml index 81af4c7f..960a5bd8 100644 --- a/test/targets/ansi.yml +++ b/test/targets/ansi.yml @@ -1,3 +1,10 @@ +# ========================================================================= +# Unity - A Test Framework for C +# ThrowTheSwitch.org +# Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams +# SPDX-License-Identifier: MIT +# ========================================================================= + --- colour: true :unity: diff --git a/test/targets/clang_file.yml b/test/targets/clang_file.yml index 964e8145..00617331 100644 --- a/test/targets/clang_file.yml +++ b/test/targets/clang_file.yml @@ -1,3 +1,10 @@ +# ========================================================================= +# Unity - A Test Framework for C +# ThrowTheSwitch.org +# Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams +# SPDX-License-Identifier: MIT +# ========================================================================= + --- colour: true :unity: diff --git a/test/targets/clang_strict.yml b/test/targets/clang_strict.yml index f124e8fd..6ae19356 100644 --- a/test/targets/clang_strict.yml +++ b/test/targets/clang_strict.yml @@ -1,3 +1,10 @@ +# ========================================================================= +# Unity - A Test Framework for C +# ThrowTheSwitch.org +# Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams +# SPDX-License-Identifier: MIT +# ========================================================================= + --- colour: true :unity: diff --git a/test/targets/gcc_32.yml b/test/targets/gcc_32.yml index ba388cf7..60deb062 100644 --- a/test/targets/gcc_32.yml +++ b/test/targets/gcc_32.yml @@ -1,3 +1,10 @@ +# ========================================================================= +# Unity - A Test Framework for C +# ThrowTheSwitch.org +# Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams +# SPDX-License-Identifier: MIT +# ========================================================================= + --- colour: true :unity: diff --git a/test/targets/gcc_64.yml b/test/targets/gcc_64.yml index ed9eb4a8..b6f10f82 100644 --- a/test/targets/gcc_64.yml +++ b/test/targets/gcc_64.yml @@ -1,3 +1,10 @@ +# ========================================================================= +# Unity - A Test Framework for C +# ThrowTheSwitch.org +# Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams +# SPDX-License-Identifier: MIT +# ========================================================================= + --- colour: true :unity: diff --git a/test/targets/gcc_auto_limits.yml b/test/targets/gcc_auto_limits.yml index 9cfda8d4..12a11fe0 100644 --- a/test/targets/gcc_auto_limits.yml +++ b/test/targets/gcc_auto_limits.yml @@ -1,3 +1,10 @@ +# ========================================================================= +# Unity - A Test Framework for C +# ThrowTheSwitch.org +# Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams +# SPDX-License-Identifier: MIT +# ========================================================================= + --- colour: true :unity: diff --git a/test/targets/gcc_auto_stdint.yml b/test/targets/gcc_auto_stdint.yml index 66602ef7..94066139 100644 --- a/test/targets/gcc_auto_stdint.yml +++ b/test/targets/gcc_auto_stdint.yml @@ -1,3 +1,10 @@ +# ========================================================================= +# Unity - A Test Framework for C +# ThrowTheSwitch.org +# Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams +# SPDX-License-Identifier: MIT +# ========================================================================= + --- colour: true :unity: diff --git a/test/targets/gcc_manual_math.yml b/test/targets/gcc_manual_math.yml index b1b5b82e..76fc9921 100644 --- a/test/targets/gcc_manual_math.yml +++ b/test/targets/gcc_manual_math.yml @@ -1,3 +1,10 @@ +# ========================================================================= +# Unity - A Test Framework for C +# ThrowTheSwitch.org +# Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams +# SPDX-License-Identifier: MIT +# ========================================================================= + --- colour: true :unity: diff --git a/test/targets/hitech_picc18.yml b/test/targets/hitech_picc18.yml index b984edbd..493705be 100644 --- a/test/targets/hitech_picc18.yml +++ b/test/targets/hitech_picc18.yml @@ -1,3 +1,10 @@ +# ========================================================================= +# Unity - A Test Framework for C +# ThrowTheSwitch.org +# Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams +# SPDX-License-Identifier: MIT +# ========================================================================= + --- :cmock: :plugins: [] diff --git a/test/targets/iar_arm_v4.yml b/test/targets/iar_arm_v4.yml index 9a1a2761..36b1a0c8 100644 --- a/test/targets/iar_arm_v4.yml +++ b/test/targets/iar_arm_v4.yml @@ -1,3 +1,10 @@ +# ========================================================================= +# Unity - A Test Framework for C +# ThrowTheSwitch.org +# Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams +# SPDX-License-Identifier: MIT +# ========================================================================= + --- tools_root: C:\Program Files\IAR Systems\Embedded Workbench 4.0 Kickstart\ colour: true diff --git a/test/targets/iar_arm_v5.yml b/test/targets/iar_arm_v5.yml index d4b115f1..17b6b10d 100644 --- a/test/targets/iar_arm_v5.yml +++ b/test/targets/iar_arm_v5.yml @@ -1,3 +1,10 @@ +# ========================================================================= +# Unity - A Test Framework for C +# ThrowTheSwitch.org +# Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams +# SPDX-License-Identifier: MIT +# ========================================================================= + --- tools_root: C:\Program Files\IAR Systems\Embedded Workbench 5.3\ colour: true diff --git a/test/targets/iar_arm_v5_3.yml b/test/targets/iar_arm_v5_3.yml index d4b115f1..17b6b10d 100644 --- a/test/targets/iar_arm_v5_3.yml +++ b/test/targets/iar_arm_v5_3.yml @@ -1,3 +1,10 @@ +# ========================================================================= +# Unity - A Test Framework for C +# ThrowTheSwitch.org +# Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams +# SPDX-License-Identifier: MIT +# ========================================================================= + --- tools_root: C:\Program Files\IAR Systems\Embedded Workbench 5.3\ colour: true diff --git a/test/targets/iar_armcortex_LM3S9B92_v5_4.yml b/test/targets/iar_armcortex_LM3S9B92_v5_4.yml index 1703fe27..7bf92871 100644 --- a/test/targets/iar_armcortex_LM3S9B92_v5_4.yml +++ b/test/targets/iar_armcortex_LM3S9B92_v5_4.yml @@ -1,3 +1,10 @@ +# ========================================================================= +# Unity - A Test Framework for C +# ThrowTheSwitch.org +# Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams +# SPDX-License-Identifier: MIT +# ========================================================================= + --- tools_root: C:\Program Files (x86)\IAR Systems\Embedded Workbench 5.4 Kickstart\ colour: true diff --git a/test/targets/iar_cortexm3_v5.yml b/test/targets/iar_cortexm3_v5.yml index 8b0978ff..e56286a4 100644 --- a/test/targets/iar_cortexm3_v5.yml +++ b/test/targets/iar_cortexm3_v5.yml @@ -1,3 +1,10 @@ +# ========================================================================= +# Unity - A Test Framework for C +# ThrowTheSwitch.org +# Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams +# SPDX-License-Identifier: MIT +# ========================================================================= + --- tools_root: C:\Program Files\IAR Systems\Embedded Workbench 5.4\ colour: true diff --git a/test/targets/iar_msp430.yml b/test/targets/iar_msp430.yml index 65872535..a1bd3ee4 100644 --- a/test/targets/iar_msp430.yml +++ b/test/targets/iar_msp430.yml @@ -1,3 +1,10 @@ +# ========================================================================= +# Unity - A Test Framework for C +# ThrowTheSwitch.org +# Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams +# SPDX-License-Identifier: MIT +# ========================================================================= + --- tools_root: C:\Program Files\IAR Systems\Embedded Workbench 5.3 MSP430\ core_root: &1 diff --git a/test/targets/iar_sh2a_v6.yml b/test/targets/iar_sh2a_v6.yml index b4371cd0..c4469d62 100644 --- a/test/targets/iar_sh2a_v6.yml +++ b/test/targets/iar_sh2a_v6.yml @@ -1,3 +1,10 @@ +# ========================================================================= +# Unity - A Test Framework for C +# ThrowTheSwitch.org +# Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams +# SPDX-License-Identifier: MIT +# ========================================================================= + --- tools_root: C:\Program Files\IAR Systems\Embedded Workbench 6.0\ colour: true diff --git a/test/testdata/CException.h b/test/testdata/CException.h index 3872fa75..4f82afa1 100644 --- a/test/testdata/CException.h +++ b/test/testdata/CException.h @@ -1,3 +1,10 @@ +/* ========================================================================= + Unity - A Test Framework for C + ThrowTheSwitch.org + Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams + SPDX-License-Identifier: MIT +========================================================================= */ + #ifndef CEXCEPTION_H #define CEXCEPTION_H diff --git a/test/testdata/Defs.h b/test/testdata/Defs.h index 58678c12..470f8877 100644 --- a/test/testdata/Defs.h +++ b/test/testdata/Defs.h @@ -1,3 +1,10 @@ +/* ========================================================================= + Unity - A Test Framework for C + ThrowTheSwitch.org + Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams + SPDX-License-Identifier: MIT +========================================================================= */ + #ifndef DEF_H #define DEF_H diff --git a/test/testdata/cmock.h b/test/testdata/cmock.h index 33ddbfc5..af739308 100644 --- a/test/testdata/cmock.h +++ b/test/testdata/cmock.h @@ -1,3 +1,10 @@ +/* ========================================================================= + Unity - A Test Framework for C + ThrowTheSwitch.org + Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams + SPDX-License-Identifier: MIT +========================================================================= */ + #ifndef CMOCK_H #define CMOCK_H diff --git a/test/testdata/mockMock.h b/test/testdata/mockMock.h index 5c6829d7..3d728e4a 100644 --- a/test/testdata/mockMock.h +++ b/test/testdata/mockMock.h @@ -1,3 +1,10 @@ +/* ========================================================================= + Unity - A Test Framework for C + ThrowTheSwitch.org + Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams + SPDX-License-Identifier: MIT +========================================================================= */ + #ifndef MOCK_MOCK_H #define MOCK_MOCK_H diff --git a/test/testdata/testRunnerGenerator.c b/test/testdata/testRunnerGenerator.c index 475e2435..ab14c0e8 100644 --- a/test/testdata/testRunnerGenerator.c +++ b/test/testdata/testRunnerGenerator.c @@ -1,3 +1,10 @@ +/* ========================================================================= + Unity - A Test Framework for C + ThrowTheSwitch.org + Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams + SPDX-License-Identifier: MIT +========================================================================= */ + /* This Test File Is Used To Verify Many Combinations Of Using the Generate Test Runner Script */ #include diff --git a/test/testdata/testRunnerGeneratorSmall.c b/test/testdata/testRunnerGeneratorSmall.c index 58bc65c0..15893d53 100644 --- a/test/testdata/testRunnerGeneratorSmall.c +++ b/test/testdata/testRunnerGeneratorSmall.c @@ -1,3 +1,10 @@ +/* ========================================================================= + Unity - A Test Framework for C + ThrowTheSwitch.org + Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams + SPDX-License-Identifier: MIT +========================================================================= */ + /* This Test File Is Used To Verify Many Combinations Of Using the Generate Test Runner Script */ #include diff --git a/test/testdata/testRunnerGeneratorWithMocks.c b/test/testdata/testRunnerGeneratorWithMocks.c index d48692ed..a5b37b8c 100644 --- a/test/testdata/testRunnerGeneratorWithMocks.c +++ b/test/testdata/testRunnerGeneratorWithMocks.c @@ -1,3 +1,10 @@ +/* ========================================================================= + Unity - A Test Framework for C + ThrowTheSwitch.org + Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams + SPDX-License-Identifier: MIT +========================================================================= */ + /* This Test File Is Used To Verify Many Combinations Of Using the Generate Test Runner Script */ #include diff --git a/test/tests/self_assessment_utils.h b/test/tests/self_assessment_utils.h index c8cb595d..670dddc8 100644 --- a/test/tests/self_assessment_utils.h +++ b/test/tests/self_assessment_utils.h @@ -1,3 +1,10 @@ +/* ========================================================================= + Unity - A Test Framework for C + ThrowTheSwitch.org + Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams + SPDX-License-Identifier: MIT +========================================================================= */ + #ifdef TEST_INSTANCES #include diff --git a/test/tests/test_generate_test_runner.rb b/test/tests/test_generate_test_runner.rb index 229b6abb..6766f5b6 100644 --- a/test/tests/test_generate_test_runner.rb +++ b/test/tests/test_generate_test_runner.rb @@ -1,8 +1,9 @@ -# ========================================== -# CMock Project - Automatic Mock Generation for C -# Copyright (c) 2007 Mike Karlesky, Mark VanderVoord, Greg Williams -# [Released under MIT License. Please refer to license.txt for details] -# ========================================== +# ========================================================================= +# Unity - A Test Framework for C +# ThrowTheSwitch.org +# Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams +# SPDX-License-Identifier: MIT +# ========================================================================= require '../auto/generate_test_runner.rb' diff --git a/test/tests/test_unity_arrays.c b/test/tests/test_unity_arrays.c index 2151eef9..e61e43d5 100644 --- a/test/tests/test_unity_arrays.c +++ b/test/tests/test_unity_arrays.c @@ -1,8 +1,9 @@ -/* ========================================== - Unity Project - A Test Framework for C - Copyright (c) 2007 Mike Karlesky, Mark VanderVoord, Greg Williams - [Released under MIT License. Please refer to license.txt for details] -========================================== */ +/* ========================================================================= + Unity - A Test Framework for C + ThrowTheSwitch.org + Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams + SPDX-License-Identifier: MIT +========================================================================= */ #include "unity.h" #define TEST_INSTANCES diff --git a/test/tests/test_unity_core.c b/test/tests/test_unity_core.c index c6ac8128..094d48a5 100644 --- a/test/tests/test_unity_core.c +++ b/test/tests/test_unity_core.c @@ -1,8 +1,9 @@ -/* ========================================== - Unity Project - A Test Framework for C - Copyright (c) 2007 Mike Karlesky, Mark VanderVoord, Greg Williams - [Released under MIT License. Please refer to license.txt for details] -========================================== */ +/* ========================================================================= + Unity - A Test Framework for C + ThrowTheSwitch.org + Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams + SPDX-License-Identifier: MIT +========================================================================= */ #include "unity.h" #define TEST_INSTANCES @@ -292,13 +293,15 @@ void testFailureCountIncrementsAndIsReturnedAtEnd(void) #ifndef USING_OUTPUT_SPY TEST_IGNORE(); #else + UNITY_UINT savedGetFlushSpyCalls = 0; UNITY_UINT savedFailures = Unity.TestFailures; Unity.CurrentTestFailed = 1; startPutcharSpy(); /* Suppress output */ startFlushSpy(); + savedGetFlushSpyCalls = getFlushSpyCalls(); UnityConcludeTest(); + TEST_ASSERT_EQUAL(0, savedGetFlushSpyCalls); endPutcharSpy(); - TEST_ASSERT_EQUAL(0, getFlushSpyCalls()); TEST_ASSERT_EQUAL(savedFailures + 1, Unity.TestFailures); #if defined(UNITY_OUTPUT_FLUSH) && defined(UNITY_OUTPUT_FLUSH_HEADER_DECLARATION) TEST_ASSERT_EQUAL(1, getFlushSpyCalls()); diff --git a/test/tests/test_unity_doubles.c b/test/tests/test_unity_doubles.c index 0ad9494d..64d59070 100644 --- a/test/tests/test_unity_doubles.c +++ b/test/tests/test_unity_doubles.c @@ -1,8 +1,9 @@ -/* ========================================== - Unity Project - A Test Framework for C - Copyright (c) 2007 Mike Karlesky, Mark VanderVoord, Greg Williams - [Released under MIT License. Please refer to license.txt for details] -========================================== */ +/* ========================================================================= + Unity - A Test Framework for C + ThrowTheSwitch.org + Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams + SPDX-License-Identifier: MIT +========================================================================= */ #include "unity.h" #define TEST_INSTANCES diff --git a/test/tests/test_unity_floats.c b/test/tests/test_unity_floats.c index 9e92f96a..4a2c2131 100644 --- a/test/tests/test_unity_floats.c +++ b/test/tests/test_unity_floats.c @@ -1,8 +1,9 @@ -/* ========================================== - Unity Project - A Test Framework for C - Copyright (c) 2007 Mike Karlesky, Mark VanderVoord, Greg Williams - [Released under MIT License. Please refer to license.txt for details] -========================================== */ +/* ========================================================================= + Unity - A Test Framework for C + ThrowTheSwitch.org + Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams + SPDX-License-Identifier: MIT +========================================================================= */ #include "unity.h" #define TEST_INSTANCES diff --git a/test/tests/test_unity_integers.c b/test/tests/test_unity_integers.c index d615e5f0..2a923a8d 100644 --- a/test/tests/test_unity_integers.c +++ b/test/tests/test_unity_integers.c @@ -1,8 +1,9 @@ -/* ========================================== - Unity Project - A Test Framework for C - Copyright (c) 2007 Mike Karlesky, Mark VanderVoord, Greg Williams - [Released under MIT License. Please refer to license.txt for details] -========================================== */ +/* ========================================================================= + Unity - A Test Framework for C + ThrowTheSwitch.org + Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams + SPDX-License-Identifier: MIT +========================================================================= */ #include "unity.h" #define TEST_INSTANCES diff --git a/test/tests/test_unity_integers_64.c b/test/tests/test_unity_integers_64.c index 6e83329e..2a1d3769 100644 --- a/test/tests/test_unity_integers_64.c +++ b/test/tests/test_unity_integers_64.c @@ -1,8 +1,9 @@ -/* ========================================== - Unity Project - A Test Framework for C - Copyright (c) 2007 Mike Karlesky, Mark VanderVoord, Greg Williams - [Released under MIT License. Please refer to license.txt for details] -========================================== */ +/* ========================================================================= + Unity - A Test Framework for C + ThrowTheSwitch.org + Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams + SPDX-License-Identifier: MIT +========================================================================= */ #include "unity.h" #define TEST_INSTANCES diff --git a/test/tests/test_unity_memory.c b/test/tests/test_unity_memory.c index b3cff131..4d0513a5 100644 --- a/test/tests/test_unity_memory.c +++ b/test/tests/test_unity_memory.c @@ -1,8 +1,9 @@ -/* ========================================== - Unity Project - A Test Framework for C - Copyright (c) 2007 Mike Karlesky, Mark VanderVoord, Greg Williams - [Released under MIT License. Please refer to license.txt for details] -========================================== */ +/* ========================================================================= + Unity - A Test Framework for C + ThrowTheSwitch.org + Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams + SPDX-License-Identifier: MIT +========================================================================= */ #include "unity.h" #define TEST_INSTANCES diff --git a/test/tests/test_unity_parameterized.c b/test/tests/test_unity_parameterized.c index aa9f9c16..a473a921 100644 --- a/test/tests/test_unity_parameterized.c +++ b/test/tests/test_unity_parameterized.c @@ -1,8 +1,9 @@ -/* ========================================== - Unity Project - A Test Framework for C - Copyright (c) 2007 Mike Karlesky, Mark VanderVoord, Greg Williams - [Released under MIT License. Please refer to license.txt for details] -========================================== */ +/* ========================================================================= + Unity - A Test Framework for C + ThrowTheSwitch.org + Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams + SPDX-License-Identifier: MIT +========================================================================= */ #include #include diff --git a/test/tests/test_unity_parameterizedDemo.c b/test/tests/test_unity_parameterizedDemo.c index 83dfad66..6ee42c54 100644 --- a/test/tests/test_unity_parameterizedDemo.c +++ b/test/tests/test_unity_parameterizedDemo.c @@ -1,3 +1,10 @@ +/* ========================================================================= + Unity - A Test Framework for C + ThrowTheSwitch.org + Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams + SPDX-License-Identifier: MIT +========================================================================= */ + #include "unity.h" /* Support for Meta Test Rig */ diff --git a/test/tests/test_unity_strings.c b/test/tests/test_unity_strings.c index 964c5536..99ba4d53 100644 --- a/test/tests/test_unity_strings.c +++ b/test/tests/test_unity_strings.c @@ -1,8 +1,9 @@ -/* ========================================== - Unity Project - A Test Framework for C - Copyright (c) 2007 Mike Karlesky, Mark VanderVoord, Greg Williams - [Released under MIT License. Please refer to license.txt for details] -========================================== */ +/* ========================================================================= + Unity - A Test Framework for C + ThrowTheSwitch.org + Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams + SPDX-License-Identifier: MIT +========================================================================= */ #include "unity.h" #define TEST_INSTANCES diff --git a/test/tests/types_for_test.h b/test/tests/types_for_test.h index 6da4e515..176926cf 100644 --- a/test/tests/types_for_test.h +++ b/test/tests/types_for_test.h @@ -1,3 +1,10 @@ +/* ========================================================================= + Unity - A Test Framework for C + ThrowTheSwitch.org + Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams + SPDX-License-Identifier: MIT +========================================================================= */ + #pragma once typedef enum { From f1d953a651835acbd7b68c47d70db3935747d129 Mon Sep 17 00:00:00 2001 From: Fredrik Ellertsen Date: Wed, 20 Mar 2024 12:47:02 +0100 Subject: [PATCH 409/454] Fix shebang placement 671f8d2 introduced a license header to auto/extract_version.py before the shebang, causing builds to fail like this: ../subprojects/unity/meson.build:7:0: ERROR: Failed running '/path/to/extract_version.py', binary or interpreter not executable. --- auto/extract_version.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/auto/extract_version.py b/auto/extract_version.py index 44cb3b41..ff7a6982 100755 --- a/auto/extract_version.py +++ b/auto/extract_version.py @@ -1,3 +1,4 @@ +#!/usr/bin/env python3 # ========================================================================= # Unity - A Test Framework for C # ThrowTheSwitch.org @@ -5,7 +6,6 @@ # SPDX-License-Identifier: MIT # ========================================================================= -#!/usr/bin/env python3 import re import sys From 3cbe49900a6f0b061be4b9d992632c3cdab7b23a Mon Sep 17 00:00:00 2001 From: Mark VanderVoord Date: Sun, 31 Mar 2024 18:12:31 -0400 Subject: [PATCH 410/454] Don't call assertions until after we've concluded test framework tinkering in core test (#718) --- test/tests/test_unity_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/tests/test_unity_core.c b/test/tests/test_unity_core.c index 094d48a5..6638fb94 100644 --- a/test/tests/test_unity_core.c +++ b/test/tests/test_unity_core.c @@ -300,8 +300,8 @@ void testFailureCountIncrementsAndIsReturnedAtEnd(void) startFlushSpy(); savedGetFlushSpyCalls = getFlushSpyCalls(); UnityConcludeTest(); - TEST_ASSERT_EQUAL(0, savedGetFlushSpyCalls); endPutcharSpy(); + TEST_ASSERT_EQUAL(0, savedGetFlushSpyCalls); TEST_ASSERT_EQUAL(savedFailures + 1, Unity.TestFailures); #if defined(UNITY_OUTPUT_FLUSH) && defined(UNITY_OUTPUT_FLUSH_HEADER_DECLARATION) TEST_ASSERT_EQUAL(1, getFlushSpyCalls()); From 0ace9d8273bb99b229a8e76bfab157896dee913c Mon Sep 17 00:00:00 2001 From: sdimovv <36302090+sdimovv@users.noreply.github.com> Date: Sun, 7 Apr 2024 02:57:16 +0100 Subject: [PATCH 411/454] Cast line_num to allow compilation with `-WConversion` --- auto/run_test.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/auto/run_test.erb b/auto/run_test.erb index 68b33730..e334d657 100644 --- a/auto/run_test.erb +++ b/auto/run_test.erb @@ -2,7 +2,7 @@ static void run_test(UnityTestFunction func, const char* name, UNITY_LINE_TYPE line_num) { Unity.CurrentTestName = name; - Unity.CurrentTestLineNumber = line_num; + Unity.CurrentTestLineNumber = (UNITY_UINT) line_num; #ifdef UNITY_USE_COMMAND_LINE_ARGS if (!UnityTestMatches()) return; From 9b77170349e8ab025dac23dd37f0925bfe15e184 Mon Sep 17 00:00:00 2001 From: sdimovv <36302090+sdimovv@users.noreply.github.com> Date: Thu, 18 Apr 2024 14:25:55 +0100 Subject: [PATCH 412/454] Remove redundant line casts from `UNITY_TEST_ASSERT_*` macros --- src/unity_internals.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/unity_internals.h b/src/unity_internals.h index 1214bf07..ca962af1 100644 --- a/src/unity_internals.h +++ b/src/unity_internals.h @@ -875,11 +875,11 @@ int UnityTestMatches(void); * Test Asserts *-------------------------------------------------------*/ -#define UNITY_TEST_ASSERT(condition, line, message) do { if (condition) { /* nothing*/ } else { UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), (message)); } } while (0) -#define UNITY_TEST_ASSERT_NULL(pointer, line, message) UNITY_TEST_ASSERT(((pointer) == NULL), (UNITY_LINE_TYPE)(line), (message)) -#define UNITY_TEST_ASSERT_NOT_NULL(pointer, line, message) UNITY_TEST_ASSERT(((pointer) != NULL), (UNITY_LINE_TYPE)(line), (message)) -#define UNITY_TEST_ASSERT_EMPTY(pointer, line, message) UNITY_TEST_ASSERT(((pointer[0]) == 0), (UNITY_LINE_TYPE)(line), (message)) -#define UNITY_TEST_ASSERT_NOT_EMPTY(pointer, line, message) UNITY_TEST_ASSERT(((pointer[0]) != 0), (UNITY_LINE_TYPE)(line), (message)) +#define UNITY_TEST_ASSERT(condition, line, message) do { if (condition) { /* nothing*/ } else { UNITY_TEST_FAIL((line), (message)); } } while (0) +#define UNITY_TEST_ASSERT_NULL(pointer, line, message) UNITY_TEST_ASSERT(((pointer) == NULL), (line), (message)) +#define UNITY_TEST_ASSERT_NOT_NULL(pointer, line, message) UNITY_TEST_ASSERT(((pointer) != NULL), (line), (message)) +#define UNITY_TEST_ASSERT_EMPTY(pointer, line, message) UNITY_TEST_ASSERT(((pointer[0]) == 0), (line), (message)) +#define UNITY_TEST_ASSERT_NOT_EMPTY(pointer, line, message) UNITY_TEST_ASSERT(((pointer[0]) != 0), (line), (message)) #define UNITY_TEST_ASSERT_EQUAL_INT(expected, actual, line, message) UnityAssertEqualNumber((UNITY_INT)(expected), (UNITY_INT)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT) #define UNITY_TEST_ASSERT_EQUAL_INT8(expected, actual, line, message) UnityAssertEqualNumber((UNITY_INT)(UNITY_INT8 )(expected), (UNITY_INT)(UNITY_INT8 )(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT8) From e6f73b6ad0d7d42c7b60b2b9dd9317eb9dd54080 Mon Sep 17 00:00:00 2001 From: "Mr.UNIX" <99476714+mrunix00@users.noreply.github.com> Date: Fri, 26 Apr 2024 16:59:59 +0100 Subject: [PATCH 413/454] Update the year in README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 71488b3e..2ebf988e 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Unity Test ![CI][] -__Copyright (c) 2007 - 2023 Unity Project by Mike Karlesky, Mark VanderVoord, and Greg Williams__ +__Copyright (c) 2007 - 2024 Unity Project by Mike Karlesky, Mark VanderVoord, and Greg Williams__ Welcome to the Unity Test Project, one of the main projects of ThrowTheSwitch.org. Unity Test is a unit testing framework built for C, with a focus on working with embedded toolchains. From 5ff17d6542684c146fbffd0d0509f925b34a17dc Mon Sep 17 00:00:00 2001 From: mchernosky Date: Fri, 26 Apr 2024 12:46:49 -0600 Subject: [PATCH 414/454] Label as static internal functions enabled by UNITY_USE_COMMAND_LINE_ARGS to prevent -Werror=missing-declarations --- src/unity.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/unity.c b/src/unity.c index 7fd703ab..c91c3853 100644 --- a/src/unity.c +++ b/src/unity.c @@ -2351,7 +2351,7 @@ int UnityParseOptions(int argc, char** argv) } /*-----------------------------------------------*/ -int IsStringInBiggerString(const char* longstring, const char* shortstring) +static int IsStringInBiggerString(const char* longstring, const char* shortstring) { const char* lptr = longstring; const char* sptr = shortstring; @@ -2396,7 +2396,7 @@ int IsStringInBiggerString(const char* longstring, const char* shortstring) } /*-----------------------------------------------*/ -int UnityStringArgumentMatches(const char* str) +static int UnityStringArgumentMatches(const char* str) { int retval; const char* ptr1; From 8e4c9b94cb334cc9c20217eb0d36f5ee8805a442 Mon Sep 17 00:00:00 2001 From: "Michael Gene Brockus (Dreamer)" <55331536+dreamer-coding-555@users.noreply.github.com> Date: Tue, 30 Apr 2024 14:24:34 -0600 Subject: [PATCH 415/454] Update main.yml --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 339bd23a..f0b6d930 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -27,7 +27,7 @@ jobs: # Checks out repository under $GITHUB_WORKSPACE - name: Checkout Latest Repo - uses: actions/checkout@v2 + uses: actions/checkout@v4 # Run Tests - name: Run All Unit Tests From 18fb33921f1bb973c81a9ce740c52b92a152333d Mon Sep 17 00:00:00 2001 From: Mark VanderVoord Date: Wed, 12 Jun 2024 22:59:08 -0400 Subject: [PATCH 416/454] add strict match option as '-n' again. fix style while I'm at it. --- auto/generate_module.rb | 2 +- auto/generate_test_runner.rb | 6 +- auto/stylize_as_junit.rb | 7 +-- docs/UnityHelperScriptsGuide.md | 2 +- src/unity.c | 43 ++++++++----- test/tests/test_generate_test_runner.rb | 84 ++++++++++++++++++------- 6 files changed, 97 insertions(+), 47 deletions(-) diff --git a/auto/generate_module.rb b/auto/generate_module.rb index 4c91a131..27bdf820 100644 --- a/auto/generate_module.rb +++ b/auto/generate_module.rb @@ -160,7 +160,7 @@ def files_to_operate_on(module_name, pattern = nil) boilerplate: cfg[:boilerplate], includes: case (cfg[:inc]) when :src then (@options[:includes][:src] || []) | (pattern_traits[:inc].map { |f| format(f, module_name) }) - when :inc then (@options[:includes][:inc] || []) + when :inc then @options[:includes][:inc] || [] when :tst then (@options[:includes][:tst] || []) | (pattern_traits[:inc].map { |f| format("#{@options[:mock_prefix]}#{f}", module_name) }) end } diff --git a/auto/generate_test_runner.rb b/auto/generate_test_runner.rb index 33cbff96..2f95fd2b 100755 --- a/auto/generate_test_runner.rb +++ b/auto/generate_test_runner.rb @@ -171,7 +171,7 @@ def find_tests(source) arg_elements_regex = /\s*(#{single_arg_regex_string})\s*,\s*/m args += type_and_args[i + 1].scan(args_regex).flatten.map do |arg_values_str| - ("#{arg_values_str},").scan(arg_elements_regex) + "#{arg_values_str},".scan(arg_elements_regex) end.reduce do |result, arg_range_expanded| result.product(arg_range_expanded) end.map do |arg_combinations| @@ -240,8 +240,8 @@ def create_header(output, mocks, testfile_includes = []) output.puts('#include "cmock.h"') unless mocks.empty? output.puts('}') if @options[:externcincludes] if @options[:defines] && !@options[:defines].empty? - output.puts("/* injected defines for unity settings, etc */") - @options[:defines].each do |d| + output.puts('/* injected defines for unity settings, etc */') + @options[:defines].each do |d| def_only = d.match(/(\w+).*/)[1] output.puts("#ifndef #{def_only}\n#define #{d}\n#endif /* #{def_only} */") end diff --git a/auto/stylize_as_junit.rb b/auto/stylize_as_junit.rb index b44979e2..9f3b91a6 100755 --- a/auto/stylize_as_junit.rb +++ b/auto/stylize_as_junit.rb @@ -1,3 +1,4 @@ +#!/usr/bin/ruby # ========================================================================= # Unity - A Test Framework for C # ThrowTheSwitch.org @@ -5,17 +6,11 @@ # SPDX-License-Identifier: MIT # ========================================================================= -#!/usr/bin/ruby -# -# unity_to_junit.rb -# require 'fileutils' require 'optparse' require 'ostruct' require 'set' -require 'pp' - VERSION = 1.0 class ArgvParser diff --git a/docs/UnityHelperScriptsGuide.md b/docs/UnityHelperScriptsGuide.md index 01db2752..90e21939 100644 --- a/docs/UnityHelperScriptsGuide.md +++ b/docs/UnityHelperScriptsGuide.md @@ -225,7 +225,7 @@ These are the available options: | --------- | ------------------------------------------------- | | `-l` | List all tests and exit | | `-f NAME` | Filter to run only tests whose name includes NAME | -| `-n NAME` | (deprecated) alias of -f | +| `-n NAME` | Run only the test named NAME | | `-h` | show the Help menu that lists these options | | `-q` | Quiet/decrease verbosity | | `-v` | increase Verbosity | diff --git a/src/unity.c b/src/unity.c index c91c3853..04d716d7 100644 --- a/src/unity.c +++ b/src/unity.c @@ -2271,6 +2271,7 @@ int UnityEnd(void) char* UnityOptionIncludeNamed = NULL; char* UnityOptionExcludeNamed = NULL; int UnityVerbosity = 1; +int UnityStrictMatch = 0; /*-----------------------------------------------*/ int UnityParseOptions(int argc, char** argv) @@ -2278,6 +2279,7 @@ int UnityParseOptions(int argc, char** argv) int i; UnityOptionIncludeNamed = NULL; UnityOptionExcludeNamed = NULL; + UnityStrictMatch = 0; for (i = 1; i < argc; i++) { @@ -2289,6 +2291,7 @@ int UnityParseOptions(int argc, char** argv) return -1; case 'n': /* include tests with name including this string */ case 'f': /* an alias for -n */ + UnityStrictMatch = (argv[i][1] == 'n'); /* strictly match this string if -n */ if (argv[i][2] == '=') { UnityOptionIncludeNamed = &argv[i][3]; @@ -2336,7 +2339,7 @@ int UnityParseOptions(int argc, char** argv) UnityPrint("Options: "); UNITY_PRINT_EOL(); UnityPrint("-l List all tests and exit"); UNITY_PRINT_EOL(); UnityPrint("-f NAME Filter to run only tests whose name includes NAME"); UNITY_PRINT_EOL(); - UnityPrint("-n NAME (deprecated) alias of -f"); UNITY_PRINT_EOL(); + UnityPrint("-n NAME Run only the test named NAME"); UNITY_PRINT_EOL(); UnityPrint("-h show this Help menu"); UNITY_PRINT_EOL(); UnityPrint("-q Quiet/decrease verbosity"); UNITY_PRINT_EOL(); UnityPrint("-v increase Verbosity"); UNITY_PRINT_EOL(); @@ -2359,7 +2362,7 @@ static int IsStringInBiggerString(const char* longstring, const char* shortstrin if (*sptr == '*') { - return 1; + return UnityStrictMatch ? 0 : 1; } while (*lptr) @@ -2372,19 +2375,29 @@ static int IsStringInBiggerString(const char* longstring, const char* shortstrin lptr++; sptr++; - /* We're done if we match the entire string or up to a wildcard */ - if (*sptr == '*') - return 1; - if (*sptr == ',') - return 1; - if (*sptr == '"') - return 1; - if (*sptr == '\'') - return 1; - if (*sptr == ':') - return 2; - if (*sptr == 0) - return 1; + switch (*sptr) + { + case '*': /* we encountered a wild-card */ + return UnityStrictMatch ? 0 : 1; + + case ',': /* we encountered the end of match string */ + case '"': + case '\'': + case 0: + return (!UnityStrictMatch || (*lptr == 0)) ? 1 : 0; + + case ':': /* we encountered the end of a partial match */ + return 2; + + default: + break; + } + } + + // If we didn't match and we're on strict matching, we already know we failed + if (UnityStrictMatch) + { + return 0; } /* Otherwise we start in the long pointer 1 character further and try again */ diff --git a/test/tests/test_generate_test_runner.rb b/test/tests/test_generate_test_runner.rb index 6766f5b6..dd1c4c8e 100644 --- a/test/tests/test_generate_test_runner.rb +++ b/test/tests/test_generate_test_runner.rb @@ -740,7 +740,7 @@ :options => { :cmdline_args => true, }, - :cmdline_args => "-n test_", + :cmdline_args => "-f test_", :expected => { :to_pass => [ 'test_ThisTestAlwaysPasses', 'test_NotBeConfusedByLongComplicatedStrings', @@ -758,7 +758,7 @@ :options => { :cmdline_args => true, }, - :cmdline_args => "-n should_", + :cmdline_args => "-f should_", :expected => { :to_pass => [ 'should_RunTestsStartingWithShouldByDefault' ], :to_fail => [ ], @@ -772,7 +772,7 @@ :options => { :cmdline_args => true, }, - :cmdline_args => "-n should_,test_", + :cmdline_args => "-f should_,test_", :expected => { :to_pass => [ 'test_ThisTestAlwaysPasses', 'test_NotBeConfusedByLongComplicatedStrings', @@ -790,7 +790,7 @@ :options => { :cmdline_args => true, }, - :cmdline_args => "-n=testRunnerGeneratorSma*", + :cmdline_args => "-f=testRunnerGeneratorSma*", :expected => { :to_pass => [ 'test_ThisTestAlwaysPasses', 'spec_ThisTestPassesWhenNormalSetupRan', @@ -806,7 +806,7 @@ :options => { :cmdline_args => true, }, - :cmdline_args => "-n testRunnerGeneratorSmall:*", + :cmdline_args => "-f testRunnerGeneratorSmall:*", :expected => { :to_pass => [ 'test_ThisTestAlwaysPasses', 'spec_ThisTestPassesWhenNormalSetupRan', @@ -822,7 +822,7 @@ :options => { :cmdline_args => true, }, - :cmdline_args => "-n testRunnerGeneratorSmall:test_*", + :cmdline_args => "-f testRunnerGeneratorSmall:test_*", :expected => { :to_pass => [ 'test_ThisTestAlwaysPasses' ], :to_fail => [ 'test_ThisTestAlwaysFails' ], @@ -836,7 +836,7 @@ :options => { :cmdline_args => true, }, - :cmdline_args => "-n testRunnerGeneratorSmall:te*", + :cmdline_args => "-f testRunnerGeneratorSmall:te*", :expected => { :to_pass => [ 'test_ThisTestAlwaysPasses' ], :to_fail => [ 'test_ThisTestAlwaysFails' ], @@ -850,7 +850,7 @@ :options => { :cmdline_args => true, }, - :cmdline_args => "-n testRunnerGeneratorSm*:*", + :cmdline_args => "-f testRunnerGeneratorSm*:*", :expected => { :to_pass => [ 'test_ThisTestAlwaysPasses', 'spec_ThisTestPassesWhenNormalSetupRan', @@ -885,7 +885,7 @@ :cmdline_args => true, :includes => ['Defs.h'], }, - :cmdline_args => "-n test_ -x Ignored", + :cmdline_args => "-f test_ -x Ignored", :expected => { :to_pass => [ 'test_ThisTestAlwaysPasses', 'test_NotBeConfusedByLongComplicatedStrings', @@ -903,7 +903,7 @@ :options => { :cmdline_args => true, }, - :cmdline_args => "-n ThisTestAlwaysPasses", + :cmdline_args => "-f ThisTestAlwaysPasses", :expected => { :to_pass => [ 'test_ThisTestAlwaysPasses' ], :to_fail => [ ], @@ -917,7 +917,7 @@ :options => { :cmdline_args => true, }, - :cmdline_args => "-n testRunnerGenerator:ThisTestAlwaysPasses", + :cmdline_args => "-f testRunnerGenerator:ThisTestAlwaysPasses", :expected => { :to_pass => [ 'test_ThisTestAlwaysPasses' ], :to_fail => [ ], @@ -931,7 +931,7 @@ :options => { :cmdline_args => true, }, - :cmdline_args => "-n testRunnerGenerator.c:ThisTestAlwaysPasses", + :cmdline_args => "-f testRunnerGenerator.c:ThisTestAlwaysPasses", :expected => { :to_pass => [ 'test_ThisTestAlwaysPasses' ], :to_fail => [ ], @@ -945,7 +945,7 @@ :options => { :cmdline_args => true, }, - :cmdline_args => "-n \"testRunnerGenerator:ThisTestAlwaysPasses,test_ThisTestAlwaysFails\"", + :cmdline_args => "-f \"testRunnerGenerator:ThisTestAlwaysPasses,test_ThisTestAlwaysFails\"", :expected => { :to_pass => [ 'test_ThisTestAlwaysPasses' ], :to_fail => [ 'test_ThisTestAlwaysFails' ], @@ -959,7 +959,7 @@ :options => { :cmdline_args => true, }, - :cmdline_args => "-n 'testRunnerGenerator:ThisTestAlwaysPasses,test_ThisTestAlwaysFails'", + :cmdline_args => "-f 'testRunnerGenerator:ThisTestAlwaysPasses,test_ThisTestAlwaysFails'", :expected => { :to_pass => [ 'test_ThisTestAlwaysPasses' ], :to_fail => [ 'test_ThisTestAlwaysFails' ], @@ -967,13 +967,55 @@ } }, + { :name => 'ArgsHandlePreciseMatch', + :testfile => 'testdata/testRunnerGenerator.c', + :testdefines => ['TEST', 'UNITY_USE_COMMAND_LINE_ARGS'], + :options => { + :cmdline_args => true, + }, + :cmdline_args => "-n 'test_ThisTestAlwaysPasses'", + :expected => { + :to_pass => [ 'test_ThisTestAlwaysPasses' ], + :to_fail => [ ], + :to_ignore => [ ], + } + }, + + { :name => 'ArgsHandlePreciseMatches', + :testfile => 'testdata/testRunnerGenerator.c', + :testdefines => ['TEST', 'UNITY_USE_COMMAND_LINE_ARGS'], + :options => { + :cmdline_args => true, + }, + :cmdline_args => "-n 'test_ThisTestAlwaysPasses,test_ThisTestAlwaysFails'", + :expected => { + :to_pass => [ 'test_ThisTestAlwaysPasses' ], + :to_fail => [ 'test_ThisTestAlwaysFails' ], + :to_ignore => [ ], + } + }, + + { :name => 'ArgsRequiresPreciseMatchNotPartial', + :testfile => 'testdata/testRunnerGenerator.c', + :testdefines => ['TEST', 'UNITY_USE_COMMAND_LINE_ARGS'], + :options => { + :cmdline_args => true, + }, + :cmdline_args => "-n ThisTestAlwaysPass", + :expected => { + :to_pass => [ ], + :to_fail => [ ], + :to_ignore => [ ], + } + }, + { :name => 'ArgsIncludeAValidTestForADifferentFile', :testfile => 'testdata/testRunnerGenerator.c', :testdefines => ['TEST', 'UNITY_USE_COMMAND_LINE_ARGS'], :options => { :cmdline_args => true, }, - :cmdline_args => "-n AnotherFile:ThisTestDoesNotExist", + :cmdline_args => "-f AnotherFile:ThisTestDoesNotExist", :expected => { :to_pass => [ ], :to_fail => [ ], @@ -987,7 +1029,7 @@ :options => { :cmdline_args => true, }, - :cmdline_args => "-n ThisTestDoesNotExist", + :cmdline_args => "-f ThisTestDoesNotExist", :expected => { :to_pass => [ ], :to_fail => [ ], @@ -1015,7 +1057,7 @@ :options => { :cmdline_args => true, }, - :cmdline_args => "-n testRunnerGenerator", + :cmdline_args => "-f testRunnerGenerator", :expected => { :to_pass => [ 'test_ThisTestAlwaysPasses', 'spec_ThisTestPassesWhenNormalSetupRan', @@ -1053,7 +1095,7 @@ :cmdline_args => true, :test_prefix => "paratest" }, - :cmdline_args => "-n ShouldHandleParameterizedTests", + :cmdline_args => "-f ShouldHandleParameterizedTests", :features => [ :parameterized ], :expected => { :to_pass => [ 'paratest_ShouldHandleParameterizedTests\(25\)', @@ -1124,7 +1166,7 @@ :options => { :cmdline_args => true, }, - :cmdline_args => "-n", + :cmdline_args => "-f", :expected => { :to_pass => [ ], :to_fail => [ ], @@ -1164,7 +1206,7 @@ "Options:", "-l List all tests and exit", "-f NAME Filter to run only tests whose name includes NAME", - "-n NAME \\(deprecated\\) alias of -f", + "-n NAME Run only the test named NAME", "-h show this Help menu", "-q Quiet/decrease verbosity", "-v increase Verbosity", @@ -1188,7 +1230,7 @@ "Options:", "-l List all tests and exit", "-f NAME Filter to run only tests whose name includes NAME", - "-n NAME \\(deprecated\\) alias of -f", + "-n NAME Run only the test named NAME", "-h show this Help menu", "-q Quiet/decrease verbosity", "-v increase Verbosity", From c546414657673c9e0bef646ee33e7005d180a85b Mon Sep 17 00:00:00 2001 From: Mark VanderVoord Date: Thu, 1 Aug 2024 16:01:09 -0400 Subject: [PATCH 417/454] - Protect against people not defining UNITY_USE_COMMAND)LINES_ARGS but enabling cmd_lines in test runner generator. (Cherry-pick PR 739) - Fix UNITY_NORETURN usage (Cherry-pick PR 742) - Other standards and formatting tweaks. --- auto/generate_test_runner.rb | 2 + src/unity_internals.h | 71 ++++++++++++++++++------------ test/Makefile | 1 + test/tests/self_assessment_utils.h | 10 ++--- test/tests/test_unity_core.c | 7 +-- 5 files changed, 54 insertions(+), 37 deletions(-) diff --git a/auto/generate_test_runner.rb b/auto/generate_test_runner.rb index 2f95fd2b..45f0425a 100755 --- a/auto/generate_test_runner.rb +++ b/auto/generate_test_runner.rb @@ -402,6 +402,7 @@ def create_main(output, filename, tests, used_mocks) end output.puts("#{@options[:main_export_decl]} int #{main_name}(int argc, char** argv)") output.puts('{') + output.puts('#ifdef UNITY_USE_COMMAND_LINE_ARGS') output.puts(' int parse_status = UnityParseOptions(argc, argv);') output.puts(' if (parse_status != 0)') output.puts(' {') @@ -424,6 +425,7 @@ def create_main(output, filename, tests, used_mocks) output.puts(' }') output.puts(' return parse_status;') output.puts(' }') + output.puts('#endif') else main_return = @options[:omit_begin_end] ? 'void' : 'int' if main_name != 'main' diff --git a/src/unity_internals.h b/src/unity_internals.h index ca962af1..192f7ffa 100644 --- a/src/unity_internals.h +++ b/src/unity_internals.h @@ -47,38 +47,51 @@ #define UNITY_FUNCTION_ATTR(a) /* ignore */ #endif -#ifndef UNITY_NORETURN - #if defined(__cplusplus) - #if __cplusplus >= 201103L +/* UNITY_NORETURN is only required if we have setjmp.h. */ +#ifndef UNITY_EXCLUDE_SETJMP_H + #ifndef UNITY_NORETURN + #if defined(__cplusplus) + #if __cplusplus >= 201103L + #define UNITY_NORETURN [[ noreturn ]] + #endif + #elif defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L && __STDC_VERSION__ < 202311L + /* _Noreturn keyword is used from C11 but deprecated in C23. */ + #if defined(_WIN32) && defined(_MSC_VER) + /* We are using MSVC compiler on Windows platform. */ + /* Not all Windows SDKs supports , but compiler can support C11: */ + /* https://devblogs.microsoft.com/cppblog/c11-and-c17-standard-support-arriving-in-msvc/ */ + /* Not sure, that Mingw compilers has Windows SDK headers at all. */ + #include + #endif + + /* Using Windows SDK predefined macro for detecting supported SDK with MSVC compiler. */ + /* Mingw GCC should work without that fixes. */ + /* Based on: */ + /* https://docs.microsoft.com/en-us/cpp/porting/modifying-winver-and-win32-winnt?view=msvc-170 */ + /* NTDDI_WIN10_FE is equal to Windows 10 SDK 2104 */ + #if defined(_MSC_VER) && ((!defined(NTDDI_WIN10_FE)) || WDK_NTDDI_VERSION < NTDDI_WIN10_FE) + /* Based on tests and: */ + /* https://docs.microsoft.com/en-us/cpp/c-language/noreturn?view=msvc-170 */ + /* https://en.cppreference.com/w/c/language/_Noreturn */ + #define UNITY_NORETURN _Noreturn + #else /* Using newer Windows SDK or not MSVC compiler */ + #if defined(__GNUC__) + /* The header collides with __attribute(noreturn)__ from GCC. */ + #define UNITY_NORETURN _Noreturn + #else + #include + #define UNITY_NORETURN noreturn + #endif + #endif + #elif defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L + /* Since C23, the keyword _Noreturn has been replaced by the attribute noreturn, based on: */ + /* https://en.cppreference.com/w/c/language/attributes/noreturn */ #define UNITY_NORETURN [[ noreturn ]] #endif - #elif defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L - #if defined(_WIN32) && defined(_MSC_VER) - /* We are using MSVC compiler on Windows platform. */ - /* Not all Windows SDKs supports , but compiler can support C11: */ - /* https://devblogs.microsoft.com/cppblog/c11-and-c17-standard-support-arriving-in-msvc/ */ - /* Not sure, that Mingw compilers has Windows SDK headers at all. */ - #include - #endif - - /* Using Windows SDK predefined macro for detecting supported SDK with MSVC compiler. */ - /* Mingw GCC should work without that fixes. */ - /* Based on: */ - /* https://docs.microsoft.com/en-us/cpp/porting/modifying-winver-and-win32-winnt?view=msvc-170 */ - /* NTDDI_WIN10_FE is equal to Windows 10 SDK 2104 */ - #if defined(_MSC_VER) && ((!defined(NTDDI_WIN10_FE)) || WDK_NTDDI_VERSION < NTDDI_WIN10_FE) - /* Based on tests and: */ - /* https://docs.microsoft.com/en-us/cpp/c-language/noreturn?view=msvc-170 */ - /* https://en.cppreference.com/w/c/language/_Noreturn */ - #define UNITY_NORETURN _Noreturn - #else /* Using newer Windows SDK or not MSVC compiler */ - #include - #define UNITY_NORETURN noreturn - #endif #endif -#endif -#ifndef UNITY_NORETURN - #define UNITY_NORETURN UNITY_FUNCTION_ATTR(__noreturn__) + #ifndef UNITY_NORETURN + #define UNITY_NORETURN UNITY_FUNCTION_ATTR(__noreturn__) + #endif #endif /*------------------------------------------------------- diff --git a/test/Makefile b/test/Makefile index 917a8749..82b61af9 100644 --- a/test/Makefile +++ b/test/Makefile @@ -17,6 +17,7 @@ CFLAGS += -std=c99 -pedantic -Wall -Wextra -Werror #CFLAGS += -Wconversion #disabled because if falsely complains about the isinf and isnan macros CFLAGS += -Wno-switch-enum -Wno-double-promotion CFLAGS += -Wno-poison-system-directories +CFLAGS += -Wno-covered-switch-default CFLAGS += -Wbad-function-cast -Wcast-qual -Wold-style-definition -Wshadow -Wstrict-overflow \ -Wstrict-prototypes -Wswitch-default -Wundef #DEBUG = -O0 -g diff --git a/test/tests/self_assessment_utils.h b/test/tests/self_assessment_utils.h index 670dddc8..39953e36 100644 --- a/test/tests/self_assessment_utils.h +++ b/test/tests/self_assessment_utils.h @@ -69,8 +69,8 @@ static const UNITY_DOUBLE d_zero = 0.0; #define SPY_BUFFER_MAX 40 static char putcharSpyBuffer[SPY_BUFFER_MAX]; #endif -static int indexSpyBuffer; -static int putcharSpyEnabled; +static UNITY_COUNTER_TYPE indexSpyBuffer; +static UNITY_COUNTER_TYPE putcharSpyEnabled; void startPutcharSpy(void) { @@ -108,8 +108,8 @@ void putcharSpy(int c) } /* This is for counting the calls to the flushSpy */ -static int flushSpyEnabled; -static int flushSpyCalls = 0; +static UNITY_COUNTER_TYPE flushSpyEnabled; +static UNITY_COUNTER_TYPE flushSpyCalls = 0; void startFlushSpy(void) { @@ -123,7 +123,7 @@ void endFlushSpy(void) flushSpyEnabled = 0; } -int getFlushSpyCalls(void) +UNITY_COUNTER_TYPE getFlushSpyCalls(void) { return flushSpyCalls; } diff --git a/test/tests/test_unity_core.c b/test/tests/test_unity_core.c index 6638fb94..e4a3fdd9 100644 --- a/test/tests/test_unity_core.c +++ b/test/tests/test_unity_core.c @@ -293,8 +293,9 @@ void testFailureCountIncrementsAndIsReturnedAtEnd(void) #ifndef USING_OUTPUT_SPY TEST_IGNORE(); #else - UNITY_UINT savedGetFlushSpyCalls = 0; - UNITY_UINT savedFailures = Unity.TestFailures; + int failures = 0; + UNITY_COUNTER_TYPE savedGetFlushSpyCalls = 0; + UNITY_COUNTER_TYPE savedFailures = Unity.TestFailures; Unity.CurrentTestFailed = 1; startPutcharSpy(); /* Suppress output */ startFlushSpy(); @@ -311,7 +312,7 @@ void testFailureCountIncrementsAndIsReturnedAtEnd(void) endFlushSpy(); startPutcharSpy(); /* Suppress output */ - int failures = UnityEnd(); + failures = UnityEnd(); Unity.TestFailures--; endPutcharSpy(); TEST_ASSERT_EQUAL(savedFailures + 1, failures); From f8be3a5eba649dded41ee54dc66a2247787919ea Mon Sep 17 00:00:00 2001 From: Franz-Josef Grosch <8401442+schorg@users.noreply.github.com> Date: Wed, 14 Aug 2024 16:40:05 +0200 Subject: [PATCH 418/454] Update unity_config.h Corrected the #define for 64-bit support in example unity_config.h file --- examples/unity_config.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/unity_config.h b/examples/unity_config.h index 98931aba..a9845f88 100644 --- a/examples/unity_config.h +++ b/examples/unity_config.h @@ -109,7 +109,7 @@ * There can be a significant size and speed impact to enabling 64-bit support * on small targets, so don't define it if you don't need it. */ -/* #define UNITY_INCLUDE_64 */ +/* #define UNITY_SUPPORT_64 */ /* *************************** FLOATING POINT TYPES **************************** From 6ebcd6065cf1b24f46d130a6fb62105e735d4b7a Mon Sep 17 00:00:00 2001 From: David Beitey Date: Fri, 23 Aug 2024 10:46:32 +1000 Subject: [PATCH 419/454] Add changelog entry for NOT float/double tests This is from https://github.com/ThrowTheSwitch/Unity/commit/244edf6c1692515936cdb94c68c865299a896e09, an addition in v2.6.0. --- docs/UnityChangeLog.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/UnityChangeLog.md b/docs/UnityChangeLog.md index 9c3bb7bf..f93f9ec6 100644 --- a/docs/UnityChangeLog.md +++ b/docs/UnityChangeLog.md @@ -24,6 +24,7 @@ New Features: - Add Unity BDD plugin - Add `UNITY_INCLUDE_EXEC_TIME` option to report test times - Allow user to override test abort underlying mechanism + - Add `NOT_EQUAL*` and `NOT_WITHIN*` checks for floats and doubles Significant Bugfixes: From 1a29024cc7ca8193864684d70c5646f7ba4614ae Mon Sep 17 00:00:00 2001 From: Mark VanderVoord Date: Wed, 1 Jan 2025 11:46:30 -0500 Subject: [PATCH 420/454] It's a New Year --- LICENSE.txt | 2 +- auto/__init__.py | 2 +- auto/colour_prompt.rb | 2 +- auto/colour_reporter.rb | 2 +- auto/extract_version.py | 2 +- auto/generate_config.yml | 2 +- auto/generate_module.rb | 2 +- auto/generate_test_runner.rb | 3 +-- auto/parse_output.rb | 3 ++- auto/stylize_as_junit.py | 3 ++- auto/stylize_as_junit.rb | 2 +- auto/test_file_filter.rb | 2 +- auto/type_sanitizer.rb | 2 +- auto/unity_test_summary.py | 3 ++- auto/unity_test_summary.rb | 2 +- auto/yaml_helper.rb | 2 +- examples/example_1/src/ProductionCode.c | 3 +-- examples/example_1/src/ProductionCode.h | 3 +-- examples/example_1/src/ProductionCode2.c | 3 +-- examples/example_1/src/ProductionCode2.h | 3 +-- examples/example_1/test/TestProductionCode.c | 3 +-- examples/example_1/test/TestProductionCode2.c | 3 +-- examples/example_2/src/ProductionCode.c | 3 +-- examples/example_2/src/ProductionCode.h | 3 +-- examples/example_2/src/ProductionCode2.c | 3 +-- examples/example_2/src/ProductionCode2.h | 3 +-- examples/example_2/test/TestProductionCode.c | 2 +- examples/example_2/test/TestProductionCode2.c | 2 +- .../example_2/test/test_runners/TestProductionCode2_Runner.c | 2 +- .../example_2/test/test_runners/TestProductionCode_Runner.c | 2 +- examples/example_2/test/test_runners/all_tests.c | 2 +- examples/example_3/helper/UnityHelper.c | 2 +- examples/example_3/helper/UnityHelper.h | 2 +- examples/example_3/rakefile.rb | 2 +- examples/example_3/rakefile_helper.rb | 2 +- examples/example_3/src/ProductionCode.c | 3 +-- examples/example_3/src/ProductionCode.h | 3 +-- examples/example_3/src/ProductionCode2.c | 3 +-- examples/example_3/src/ProductionCode2.h | 3 +-- examples/example_3/target_gcc_32.yml | 2 +- examples/example_3/test/TestProductionCode.c | 3 +-- examples/example_3/test/TestProductionCode2.c | 3 +-- examples/example_4/src/ProductionCode.c | 3 +-- examples/example_4/src/ProductionCode.h | 3 +-- examples/example_4/src/ProductionCode2.c | 3 +-- examples/example_4/src/ProductionCode2.h | 3 +-- examples/example_4/test/TestProductionCode.c | 3 +-- examples/example_4/test/TestProductionCode2.c | 3 +-- examples/unity_config.h | 2 +- extras/bdd/src/unity_bdd.h | 2 +- extras/bdd/test/test_bdd.c | 2 +- extras/fixture/src/unity_fixture.c | 2 +- extras/fixture/src/unity_fixture.h | 3 +-- extras/fixture/src/unity_fixture_internals.h | 3 +-- extras/fixture/test/main/AllTests.c | 2 +- extras/fixture/test/template_fixture_tests.c | 3 +-- extras/fixture/test/unity_fixture_Test.c | 3 +-- extras/fixture/test/unity_fixture_TestRunner.c | 3 +-- extras/memory/src/unity_memory.c | 2 +- extras/memory/src/unity_memory.h | 2 +- extras/memory/test/unity_memory_Test.c | 2 +- extras/memory/test/unity_memory_TestRunner.c | 2 +- extras/memory/test/unity_output_Spy.c | 2 +- extras/memory/test/unity_output_Spy.h | 2 +- src/unity.c | 2 +- src/unity.h | 2 +- src/unity_internals.h | 2 +- test/rakefile_helper.rb | 2 +- test/spec/generate_module_existing_file_spec.rb | 3 +-- test/targets/ansi.yml | 2 +- test/targets/clang_file.yml | 2 +- test/targets/clang_strict.yml | 2 +- test/targets/gcc_32.yml | 2 +- test/targets/gcc_64.yml | 2 +- test/targets/gcc_auto_limits.yml | 2 +- test/targets/gcc_auto_stdint.yml | 2 +- test/targets/gcc_manual_math.yml | 2 +- test/targets/hitech_picc18.yml | 2 +- test/targets/iar_arm_v4.yml | 2 +- test/targets/iar_arm_v5.yml | 2 +- test/targets/iar_arm_v5_3.yml | 2 +- test/targets/iar_armcortex_LM3S9B92_v5_4.yml | 2 +- test/targets/iar_cortexm3_v5.yml | 2 +- test/targets/iar_msp430.yml | 2 +- test/targets/iar_sh2a_v6.yml | 2 +- test/testdata/CException.h | 2 +- test/testdata/Defs.h | 2 +- test/testdata/cmock.h | 2 +- test/testdata/mockMock.h | 2 +- test/testdata/testRunnerGenerator.c | 2 +- test/testdata/testRunnerGeneratorSmall.c | 2 +- test/testdata/testRunnerGeneratorWithMocks.c | 2 +- test/tests/self_assessment_utils.h | 2 +- test/tests/test_generate_test_runner.rb | 2 +- test/tests/test_unity_arrays.c | 2 +- test/tests/test_unity_core.c | 2 +- test/tests/test_unity_doubles.c | 2 +- test/tests/test_unity_floats.c | 2 +- test/tests/test_unity_integers.c | 2 +- test/tests/test_unity_integers_64.c | 2 +- test/tests/test_unity_memory.c | 2 +- test/tests/test_unity_parameterized.c | 2 +- test/tests/test_unity_parameterizedDemo.c | 2 +- test/tests/test_unity_strings.c | 2 +- test/tests/types_for_test.h | 2 +- 105 files changed, 108 insertions(+), 134 deletions(-) diff --git a/LICENSE.txt b/LICENSE.txt index ecca34ce..3e3aad5b 100644 --- a/LICENSE.txt +++ b/LICENSE.txt @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, Greg Williams +Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/auto/__init__.py b/auto/__init__.py index 793090f9..15f87c39 100644 --- a/auto/__init__.py +++ b/auto/__init__.py @@ -1,7 +1,7 @@ # ========================================================================= # Unity - A Test Framework for C # ThrowTheSwitch.org -# Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams +# Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams # SPDX-License-Identifier: MIT # ========================================================================= diff --git a/auto/colour_prompt.rb b/auto/colour_prompt.rb index 57b495a0..566efe9e 100644 --- a/auto/colour_prompt.rb +++ b/auto/colour_prompt.rb @@ -1,7 +1,7 @@ # ========================================================================= # Unity - A Test Framework for C # ThrowTheSwitch.org -# Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams +# Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams # SPDX-License-Identifier: MIT # ========================================================================= diff --git a/auto/colour_reporter.rb b/auto/colour_reporter.rb index 273ea3b6..cac748f8 100644 --- a/auto/colour_reporter.rb +++ b/auto/colour_reporter.rb @@ -1,7 +1,7 @@ # ========================================================================= # Unity - A Test Framework for C # ThrowTheSwitch.org -# Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams +# Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams # SPDX-License-Identifier: MIT # ========================================================================= diff --git a/auto/extract_version.py b/auto/extract_version.py index ff7a6982..7c2f3d30 100755 --- a/auto/extract_version.py +++ b/auto/extract_version.py @@ -2,7 +2,7 @@ # ========================================================================= # Unity - A Test Framework for C # ThrowTheSwitch.org -# Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams +# Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams # SPDX-License-Identifier: MIT # ========================================================================= diff --git a/auto/generate_config.yml b/auto/generate_config.yml index d0fccec7..d1cd9b20 100644 --- a/auto/generate_config.yml +++ b/auto/generate_config.yml @@ -1,7 +1,7 @@ # ========================================================================= # Unity - A Test Framework for C # ThrowTheSwitch.org -# Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams +# Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams # SPDX-License-Identifier: MIT # ========================================================================= diff --git a/auto/generate_module.rb b/auto/generate_module.rb index 27bdf820..d335cab2 100644 --- a/auto/generate_module.rb +++ b/auto/generate_module.rb @@ -1,7 +1,7 @@ # ========================================================================= # Unity - A Test Framework for C # ThrowTheSwitch.org -# Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams +# Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams # SPDX-License-Identifier: MIT # ========================================================================= diff --git a/auto/generate_test_runner.rb b/auto/generate_test_runner.rb index 45f0425a..2c2d5956 100755 --- a/auto/generate_test_runner.rb +++ b/auto/generate_test_runner.rb @@ -1,9 +1,8 @@ #!/usr/bin/ruby - # ========================================================================= # Unity - A Test Framework for C # ThrowTheSwitch.org -# Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams +# Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams # SPDX-License-Identifier: MIT # ========================================================================= diff --git a/auto/parse_output.rb b/auto/parse_output.rb index 7a5b7a5e..1711337a 100644 --- a/auto/parse_output.rb +++ b/auto/parse_output.rb @@ -1,9 +1,10 @@ # ========================================================================= # Unity - A Test Framework for C # ThrowTheSwitch.org -# Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams +# Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams # SPDX-License-Identifier: MIT # ========================================================================= + #============================================================ # Author: John Theofanopoulos # A simple parser. Takes the output files generated during the diff --git a/auto/stylize_as_junit.py b/auto/stylize_as_junit.py index a60c472e..020ec440 100644 --- a/auto/stylize_as_junit.py +++ b/auto/stylize_as_junit.py @@ -2,9 +2,10 @@ # ========================================================================= # Unity - A Test Framework for C # ThrowTheSwitch.org -# Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams +# Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams # SPDX-License-Identifier: MIT # ========================================================================= + import sys import os from glob import glob diff --git a/auto/stylize_as_junit.rb b/auto/stylize_as_junit.rb index 9f3b91a6..23d89a65 100755 --- a/auto/stylize_as_junit.rb +++ b/auto/stylize_as_junit.rb @@ -2,7 +2,7 @@ # ========================================================================= # Unity - A Test Framework for C # ThrowTheSwitch.org -# Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams +# Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams # SPDX-License-Identifier: MIT # ========================================================================= diff --git a/auto/test_file_filter.rb b/auto/test_file_filter.rb index c922cdd2..f9c8d904 100644 --- a/auto/test_file_filter.rb +++ b/auto/test_file_filter.rb @@ -1,7 +1,7 @@ # ========================================================================= # Unity - A Test Framework for C # ThrowTheSwitch.org -# Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams +# Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams # SPDX-License-Identifier: MIT # ========================================================================= diff --git a/auto/type_sanitizer.rb b/auto/type_sanitizer.rb index 0cf9563c..cfadb0dc 100644 --- a/auto/type_sanitizer.rb +++ b/auto/type_sanitizer.rb @@ -1,7 +1,7 @@ # ========================================================================= # Unity - A Test Framework for C # ThrowTheSwitch.org -# Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams +# Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams # SPDX-License-Identifier: MIT # ========================================================================= diff --git a/auto/unity_test_summary.py b/auto/unity_test_summary.py index a7d24bad..43e5af7c 100644 --- a/auto/unity_test_summary.py +++ b/auto/unity_test_summary.py @@ -2,9 +2,10 @@ # ========================================================================= # Unity - A Test Framework for C # ThrowTheSwitch.org -# Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams +# Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams # SPDX-License-Identifier: MIT # ========================================================================= + import sys import os import re diff --git a/auto/unity_test_summary.rb b/auto/unity_test_summary.rb index 0d7f1838..33c8d7a3 100644 --- a/auto/unity_test_summary.rb +++ b/auto/unity_test_summary.rb @@ -1,7 +1,7 @@ # ========================================================================= # Unity - A Test Framework for C # ThrowTheSwitch.org -# Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams +# Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams # SPDX-License-Identifier: MIT # ========================================================================= diff --git a/auto/yaml_helper.rb b/auto/yaml_helper.rb index 32746db7..6d1bf7ae 100644 --- a/auto/yaml_helper.rb +++ b/auto/yaml_helper.rb @@ -1,7 +1,7 @@ # ========================================================================= # Unity - A Test Framework for C # ThrowTheSwitch.org -# Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams +# Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams # SPDX-License-Identifier: MIT # ========================================================================= diff --git a/examples/example_1/src/ProductionCode.c b/examples/example_1/src/ProductionCode.c index 6be26aca..8a52aff0 100644 --- a/examples/example_1/src/ProductionCode.c +++ b/examples/example_1/src/ProductionCode.c @@ -1,11 +1,10 @@ /* ========================================================================= Unity - A Test Framework for C ThrowTheSwitch.org - Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams + Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams SPDX-License-Identifier: MIT ========================================================================= */ - #include "ProductionCode.h" int Counter = 0; diff --git a/examples/example_1/src/ProductionCode.h b/examples/example_1/src/ProductionCode.h index 5aaa8bbc..d8929bfb 100644 --- a/examples/example_1/src/ProductionCode.h +++ b/examples/example_1/src/ProductionCode.h @@ -1,10 +1,9 @@ /* ========================================================================= Unity - A Test Framework for C ThrowTheSwitch.org - Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams + Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams SPDX-License-Identifier: MIT ========================================================================= */ - int FindFunction_WhichIsBroken(int NumberToFind); int FunctionWhichReturnsLocalVariable(void); diff --git a/examples/example_1/src/ProductionCode2.c b/examples/example_1/src/ProductionCode2.c index ea12cd71..ff8a537f 100644 --- a/examples/example_1/src/ProductionCode2.c +++ b/examples/example_1/src/ProductionCode2.c @@ -1,11 +1,10 @@ /* ========================================================================= Unity - A Test Framework for C ThrowTheSwitch.org - Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams + Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams SPDX-License-Identifier: MIT ========================================================================= */ - #include "ProductionCode2.h" char* ThisFunctionHasNotBeenTested(int Poor, char* LittleFunction) diff --git a/examples/example_1/src/ProductionCode2.h b/examples/example_1/src/ProductionCode2.h index 63f8b0f5..5204543f 100644 --- a/examples/example_1/src/ProductionCode2.h +++ b/examples/example_1/src/ProductionCode2.h @@ -1,9 +1,8 @@ /* ========================================================================= Unity - A Test Framework for C ThrowTheSwitch.org - Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams + Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams SPDX-License-Identifier: MIT ========================================================================= */ - char* ThisFunctionHasNotBeenTested(int Poor, char* LittleFunction); diff --git a/examples/example_1/test/TestProductionCode.c b/examples/example_1/test/TestProductionCode.c index 44441fd1..ceb6d8b5 100644 --- a/examples/example_1/test/TestProductionCode.c +++ b/examples/example_1/test/TestProductionCode.c @@ -1,11 +1,10 @@ /* ========================================================================= Unity - A Test Framework for C ThrowTheSwitch.org - Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams + Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams SPDX-License-Identifier: MIT ========================================================================= */ - #include "ProductionCode.h" #include "unity.h" diff --git a/examples/example_1/test/TestProductionCode2.c b/examples/example_1/test/TestProductionCode2.c index cb6e4444..32bbfdf0 100644 --- a/examples/example_1/test/TestProductionCode2.c +++ b/examples/example_1/test/TestProductionCode2.c @@ -1,11 +1,10 @@ /* ========================================================================= Unity - A Test Framework for C ThrowTheSwitch.org - Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams + Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams SPDX-License-Identifier: MIT ========================================================================= */ - #include "ProductionCode2.h" #include "unity.h" diff --git a/examples/example_2/src/ProductionCode.c b/examples/example_2/src/ProductionCode.c index e30851a7..b84c4276 100644 --- a/examples/example_2/src/ProductionCode.c +++ b/examples/example_2/src/ProductionCode.c @@ -1,11 +1,10 @@ /* ========================================================================= Unity - A Test Framework for C ThrowTheSwitch.org - Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams + Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams SPDX-License-Identifier: MIT ========================================================================= */ - #include "ProductionCode.h" int Counter = 0; diff --git a/examples/example_2/src/ProductionCode.h b/examples/example_2/src/ProductionCode.h index 5aaa8bbc..d8929bfb 100644 --- a/examples/example_2/src/ProductionCode.h +++ b/examples/example_2/src/ProductionCode.h @@ -1,10 +1,9 @@ /* ========================================================================= Unity - A Test Framework for C ThrowTheSwitch.org - Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams + Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams SPDX-License-Identifier: MIT ========================================================================= */ - int FindFunction_WhichIsBroken(int NumberToFind); int FunctionWhichReturnsLocalVariable(void); diff --git a/examples/example_2/src/ProductionCode2.c b/examples/example_2/src/ProductionCode2.c index bd6f4ce8..80040187 100644 --- a/examples/example_2/src/ProductionCode2.c +++ b/examples/example_2/src/ProductionCode2.c @@ -1,11 +1,10 @@ /* ========================================================================= Unity - A Test Framework for C ThrowTheSwitch.org - Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams + Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams SPDX-License-Identifier: MIT ========================================================================= */ - #include "ProductionCode2.h" char* ThisFunctionHasNotBeenTested(int Poor, char* LittleFunction) diff --git a/examples/example_2/src/ProductionCode2.h b/examples/example_2/src/ProductionCode2.h index 63f8b0f5..5204543f 100644 --- a/examples/example_2/src/ProductionCode2.h +++ b/examples/example_2/src/ProductionCode2.h @@ -1,9 +1,8 @@ /* ========================================================================= Unity - A Test Framework for C ThrowTheSwitch.org - Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams + Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams SPDX-License-Identifier: MIT ========================================================================= */ - char* ThisFunctionHasNotBeenTested(int Poor, char* LittleFunction); diff --git a/examples/example_2/test/TestProductionCode.c b/examples/example_2/test/TestProductionCode.c index 0e05a0db..9635f32a 100644 --- a/examples/example_2/test/TestProductionCode.c +++ b/examples/example_2/test/TestProductionCode.c @@ -1,7 +1,7 @@ /* ========================================================================= Unity - A Test Framework for C ThrowTheSwitch.org - Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams + Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams SPDX-License-Identifier: MIT ========================================================================= */ diff --git a/examples/example_2/test/TestProductionCode2.c b/examples/example_2/test/TestProductionCode2.c index de6c3242..d0233c0a 100644 --- a/examples/example_2/test/TestProductionCode2.c +++ b/examples/example_2/test/TestProductionCode2.c @@ -1,7 +1,7 @@ /* ========================================================================= Unity - A Test Framework for C ThrowTheSwitch.org - Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams + Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams SPDX-License-Identifier: MIT ========================================================================= */ diff --git a/examples/example_2/test/test_runners/TestProductionCode2_Runner.c b/examples/example_2/test/test_runners/TestProductionCode2_Runner.c index c528c80f..eaa057fd 100644 --- a/examples/example_2/test/test_runners/TestProductionCode2_Runner.c +++ b/examples/example_2/test/test_runners/TestProductionCode2_Runner.c @@ -1,7 +1,7 @@ /* ========================================================================= Unity - A Test Framework for C ThrowTheSwitch.org - Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams + Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams SPDX-License-Identifier: MIT ========================================================================= */ diff --git a/examples/example_2/test/test_runners/TestProductionCode_Runner.c b/examples/example_2/test/test_runners/TestProductionCode_Runner.c index b65e6695..f0acf24f 100644 --- a/examples/example_2/test/test_runners/TestProductionCode_Runner.c +++ b/examples/example_2/test/test_runners/TestProductionCode_Runner.c @@ -1,7 +1,7 @@ /* ========================================================================= Unity - A Test Framework for C ThrowTheSwitch.org - Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams + Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams SPDX-License-Identifier: MIT ========================================================================= */ diff --git a/examples/example_2/test/test_runners/all_tests.c b/examples/example_2/test/test_runners/all_tests.c index 6cd4ef95..5376dbe2 100644 --- a/examples/example_2/test/test_runners/all_tests.c +++ b/examples/example_2/test/test_runners/all_tests.c @@ -1,7 +1,7 @@ /* ========================================================================= Unity - A Test Framework for C ThrowTheSwitch.org - Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams + Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams SPDX-License-Identifier: MIT ========================================================================= */ diff --git a/examples/example_3/helper/UnityHelper.c b/examples/example_3/helper/UnityHelper.c index 12110176..17830959 100644 --- a/examples/example_3/helper/UnityHelper.c +++ b/examples/example_3/helper/UnityHelper.c @@ -1,7 +1,7 @@ /* ========================================================================= Unity - A Test Framework for C ThrowTheSwitch.org - Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams + Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams SPDX-License-Identifier: MIT ========================================================================= */ diff --git a/examples/example_3/helper/UnityHelper.h b/examples/example_3/helper/UnityHelper.h index 573f26c9..6ebf8604 100644 --- a/examples/example_3/helper/UnityHelper.h +++ b/examples/example_3/helper/UnityHelper.h @@ -1,7 +1,7 @@ /* ========================================================================= Unity - A Test Framework for C ThrowTheSwitch.org - Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams + Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams SPDX-License-Identifier: MIT ========================================================================= */ diff --git a/examples/example_3/rakefile.rb b/examples/example_3/rakefile.rb index 48de0d05..a1eb35a4 100644 --- a/examples/example_3/rakefile.rb +++ b/examples/example_3/rakefile.rb @@ -1,7 +1,7 @@ # ========================================================================= # Unity - A Test Framework for C # ThrowTheSwitch.org -# Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams +# Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams # SPDX-License-Identifier: MIT # ========================================================================= diff --git a/examples/example_3/rakefile_helper.rb b/examples/example_3/rakefile_helper.rb index 9b57e814..55885741 100644 --- a/examples/example_3/rakefile_helper.rb +++ b/examples/example_3/rakefile_helper.rb @@ -1,7 +1,7 @@ # ========================================================================= # Unity - A Test Framework for C # ThrowTheSwitch.org -# Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams +# Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams # SPDX-License-Identifier: MIT # ========================================================================= diff --git a/examples/example_3/src/ProductionCode.c b/examples/example_3/src/ProductionCode.c index e30851a7..b84c4276 100644 --- a/examples/example_3/src/ProductionCode.c +++ b/examples/example_3/src/ProductionCode.c @@ -1,11 +1,10 @@ /* ========================================================================= Unity - A Test Framework for C ThrowTheSwitch.org - Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams + Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams SPDX-License-Identifier: MIT ========================================================================= */ - #include "ProductionCode.h" int Counter = 0; diff --git a/examples/example_3/src/ProductionCode.h b/examples/example_3/src/ProductionCode.h index 5aaa8bbc..d8929bfb 100644 --- a/examples/example_3/src/ProductionCode.h +++ b/examples/example_3/src/ProductionCode.h @@ -1,10 +1,9 @@ /* ========================================================================= Unity - A Test Framework for C ThrowTheSwitch.org - Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams + Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams SPDX-License-Identifier: MIT ========================================================================= */ - int FindFunction_WhichIsBroken(int NumberToFind); int FunctionWhichReturnsLocalVariable(void); diff --git a/examples/example_3/src/ProductionCode2.c b/examples/example_3/src/ProductionCode2.c index bd6f4ce8..80040187 100644 --- a/examples/example_3/src/ProductionCode2.c +++ b/examples/example_3/src/ProductionCode2.c @@ -1,11 +1,10 @@ /* ========================================================================= Unity - A Test Framework for C ThrowTheSwitch.org - Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams + Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams SPDX-License-Identifier: MIT ========================================================================= */ - #include "ProductionCode2.h" char* ThisFunctionHasNotBeenTested(int Poor, char* LittleFunction) diff --git a/examples/example_3/src/ProductionCode2.h b/examples/example_3/src/ProductionCode2.h index 63f8b0f5..5204543f 100644 --- a/examples/example_3/src/ProductionCode2.h +++ b/examples/example_3/src/ProductionCode2.h @@ -1,9 +1,8 @@ /* ========================================================================= Unity - A Test Framework for C ThrowTheSwitch.org - Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams + Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams SPDX-License-Identifier: MIT ========================================================================= */ - char* ThisFunctionHasNotBeenTested(int Poor, char* LittleFunction); diff --git a/examples/example_3/target_gcc_32.yml b/examples/example_3/target_gcc_32.yml index 3fa10040..a3d123d4 100644 --- a/examples/example_3/target_gcc_32.yml +++ b/examples/example_3/target_gcc_32.yml @@ -1,7 +1,7 @@ # ========================================================================= # Unity - A Test Framework for C # ThrowTheSwitch.org -# Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams +# Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams # SPDX-License-Identifier: MIT # ========================================================================= diff --git a/examples/example_3/test/TestProductionCode.c b/examples/example_3/test/TestProductionCode.c index a74e9eab..7f48ea76 100644 --- a/examples/example_3/test/TestProductionCode.c +++ b/examples/example_3/test/TestProductionCode.c @@ -1,11 +1,10 @@ /* ========================================================================= Unity - A Test Framework for C ThrowTheSwitch.org - Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams + Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams SPDX-License-Identifier: MIT ========================================================================= */ - #include "ProductionCode.h" #include "unity.h" diff --git a/examples/example_3/test/TestProductionCode2.c b/examples/example_3/test/TestProductionCode2.c index 43907d4f..7ab3926e 100644 --- a/examples/example_3/test/TestProductionCode2.c +++ b/examples/example_3/test/TestProductionCode2.c @@ -1,11 +1,10 @@ /* ========================================================================= Unity - A Test Framework for C ThrowTheSwitch.org - Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams + Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams SPDX-License-Identifier: MIT ========================================================================= */ - #include "ProductionCode2.h" #include "unity.h" diff --git a/examples/example_4/src/ProductionCode.c b/examples/example_4/src/ProductionCode.c index 6be26aca..8a52aff0 100644 --- a/examples/example_4/src/ProductionCode.c +++ b/examples/example_4/src/ProductionCode.c @@ -1,11 +1,10 @@ /* ========================================================================= Unity - A Test Framework for C ThrowTheSwitch.org - Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams + Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams SPDX-License-Identifier: MIT ========================================================================= */ - #include "ProductionCode.h" int Counter = 0; diff --git a/examples/example_4/src/ProductionCode.h b/examples/example_4/src/ProductionCode.h index 5aaa8bbc..d8929bfb 100644 --- a/examples/example_4/src/ProductionCode.h +++ b/examples/example_4/src/ProductionCode.h @@ -1,10 +1,9 @@ /* ========================================================================= Unity - A Test Framework for C ThrowTheSwitch.org - Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams + Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams SPDX-License-Identifier: MIT ========================================================================= */ - int FindFunction_WhichIsBroken(int NumberToFind); int FunctionWhichReturnsLocalVariable(void); diff --git a/examples/example_4/src/ProductionCode2.c b/examples/example_4/src/ProductionCode2.c index ea12cd71..ff8a537f 100644 --- a/examples/example_4/src/ProductionCode2.c +++ b/examples/example_4/src/ProductionCode2.c @@ -1,11 +1,10 @@ /* ========================================================================= Unity - A Test Framework for C ThrowTheSwitch.org - Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams + Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams SPDX-License-Identifier: MIT ========================================================================= */ - #include "ProductionCode2.h" char* ThisFunctionHasNotBeenTested(int Poor, char* LittleFunction) diff --git a/examples/example_4/src/ProductionCode2.h b/examples/example_4/src/ProductionCode2.h index 63f8b0f5..5204543f 100644 --- a/examples/example_4/src/ProductionCode2.h +++ b/examples/example_4/src/ProductionCode2.h @@ -1,9 +1,8 @@ /* ========================================================================= Unity - A Test Framework for C ThrowTheSwitch.org - Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams + Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams SPDX-License-Identifier: MIT ========================================================================= */ - char* ThisFunctionHasNotBeenTested(int Poor, char* LittleFunction); diff --git a/examples/example_4/test/TestProductionCode.c b/examples/example_4/test/TestProductionCode.c index 15a19fcd..a7cf1449 100644 --- a/examples/example_4/test/TestProductionCode.c +++ b/examples/example_4/test/TestProductionCode.c @@ -1,11 +1,10 @@ /* ========================================================================= Unity - A Test Framework for C ThrowTheSwitch.org - Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams + Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams SPDX-License-Identifier: MIT ========================================================================= */ - #include "ProductionCode.h" #include "unity.h" diff --git a/examples/example_4/test/TestProductionCode2.c b/examples/example_4/test/TestProductionCode2.c index 479a1a67..168564e1 100644 --- a/examples/example_4/test/TestProductionCode2.c +++ b/examples/example_4/test/TestProductionCode2.c @@ -1,11 +1,10 @@ /* ========================================================================= Unity - A Test Framework for C ThrowTheSwitch.org - Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams + Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams SPDX-License-Identifier: MIT ========================================================================= */ - #include "ProductionCode2.h" #include "unity.h" diff --git a/examples/unity_config.h b/examples/unity_config.h index a9845f88..efd91232 100644 --- a/examples/unity_config.h +++ b/examples/unity_config.h @@ -1,7 +1,7 @@ /* ========================================================================= Unity - A Test Framework for C ThrowTheSwitch.org - Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams + Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams SPDX-License-Identifier: MIT ========================================================================= */ diff --git a/extras/bdd/src/unity_bdd.h b/extras/bdd/src/unity_bdd.h index 129b7bc3..feff492c 100644 --- a/extras/bdd/src/unity_bdd.h +++ b/extras/bdd/src/unity_bdd.h @@ -1,7 +1,7 @@ /* ========================================================================= Unity - A Test Framework for C ThrowTheSwitch.org - Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams + Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams SPDX-License-Identifier: MIT ========================================================================= */ diff --git a/extras/bdd/test/test_bdd.c b/extras/bdd/test/test_bdd.c index 548ba97c..f86e5abd 100644 --- a/extras/bdd/test/test_bdd.c +++ b/extras/bdd/test/test_bdd.c @@ -1,7 +1,7 @@ /* ========================================================================= Unity - A Test Framework for C ThrowTheSwitch.org - Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams + Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams SPDX-License-Identifier: MIT ========================================================================= */ diff --git a/extras/fixture/src/unity_fixture.c b/extras/fixture/src/unity_fixture.c index 0047bd36..9b3fce27 100644 --- a/extras/fixture/src/unity_fixture.c +++ b/extras/fixture/src/unity_fixture.c @@ -1,7 +1,7 @@ /* ========================================================================= Unity - A Test Framework for C ThrowTheSwitch.org - Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams + Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams SPDX-License-Identifier: MIT ========================================================================= */ diff --git a/extras/fixture/src/unity_fixture.h b/extras/fixture/src/unity_fixture.h index 0eb471e3..ed6ff482 100644 --- a/extras/fixture/src/unity_fixture.h +++ b/extras/fixture/src/unity_fixture.h @@ -1,11 +1,10 @@ /* ========================================================================= Unity - A Test Framework for C ThrowTheSwitch.org - Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams + Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams SPDX-License-Identifier: MIT ========================================================================= */ - #ifndef UNITY_FIXTURE_H_ #define UNITY_FIXTURE_H_ diff --git a/extras/fixture/src/unity_fixture_internals.h b/extras/fixture/src/unity_fixture_internals.h index 9e6f8b7c..f8f83d2d 100644 --- a/extras/fixture/src/unity_fixture_internals.h +++ b/extras/fixture/src/unity_fixture_internals.h @@ -1,11 +1,10 @@ /* ========================================================================= Unity - A Test Framework for C ThrowTheSwitch.org - Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams + Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams SPDX-License-Identifier: MIT ========================================================================= */ - #ifndef UNITY_FIXTURE_INTERNALS_H_ #define UNITY_FIXTURE_INTERNALS_H_ diff --git a/extras/fixture/test/main/AllTests.c b/extras/fixture/test/main/AllTests.c index 8b8e16ba..d5eec4be 100644 --- a/extras/fixture/test/main/AllTests.c +++ b/extras/fixture/test/main/AllTests.c @@ -1,7 +1,7 @@ /* ========================================================================= Unity - A Test Framework for C ThrowTheSwitch.org - Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams + Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams SPDX-License-Identifier: MIT ========================================================================= */ diff --git a/extras/fixture/test/template_fixture_tests.c b/extras/fixture/test/template_fixture_tests.c index ad7f0823..2397f105 100644 --- a/extras/fixture/test/template_fixture_tests.c +++ b/extras/fixture/test/template_fixture_tests.c @@ -1,11 +1,10 @@ /* ========================================================================= Unity - A Test Framework for C ThrowTheSwitch.org - Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams + Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams SPDX-License-Identifier: MIT ========================================================================= */ - #include "unity_fixture.h" static int data = -1; diff --git a/extras/fixture/test/unity_fixture_Test.c b/extras/fixture/test/unity_fixture_Test.c index e258fbaf..d2785d3c 100644 --- a/extras/fixture/test/unity_fixture_Test.c +++ b/extras/fixture/test/unity_fixture_Test.c @@ -1,11 +1,10 @@ /* ========================================================================= Unity - A Test Framework for C ThrowTheSwitch.org - Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams + Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams SPDX-License-Identifier: MIT ========================================================================= */ - #include "unity_fixture.h" #include #include diff --git a/extras/fixture/test/unity_fixture_TestRunner.c b/extras/fixture/test/unity_fixture_TestRunner.c index 0eb2bdb1..ec92663f 100644 --- a/extras/fixture/test/unity_fixture_TestRunner.c +++ b/extras/fixture/test/unity_fixture_TestRunner.c @@ -1,11 +1,10 @@ /* ========================================================================= Unity - A Test Framework for C ThrowTheSwitch.org - Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams + Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams SPDX-License-Identifier: MIT ========================================================================= */ - #include "unity_fixture.h" TEST_GROUP_RUNNER(UnityFixture) diff --git a/extras/memory/src/unity_memory.c b/extras/memory/src/unity_memory.c index 85abbc9f..e9eaae35 100644 --- a/extras/memory/src/unity_memory.c +++ b/extras/memory/src/unity_memory.c @@ -1,7 +1,7 @@ /* ========================================================================= Unity - A Test Framework for C ThrowTheSwitch.org - Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams + Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams SPDX-License-Identifier: MIT ========================================================================= */ diff --git a/extras/memory/src/unity_memory.h b/extras/memory/src/unity_memory.h index ace96a5a..70a7f25f 100644 --- a/extras/memory/src/unity_memory.h +++ b/extras/memory/src/unity_memory.h @@ -1,7 +1,7 @@ /* ========================================================================= Unity - A Test Framework for C ThrowTheSwitch.org - Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams + Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams SPDX-License-Identifier: MIT ========================================================================= */ diff --git a/extras/memory/test/unity_memory_Test.c b/extras/memory/test/unity_memory_Test.c index 163d24c0..b66e6deb 100644 --- a/extras/memory/test/unity_memory_Test.c +++ b/extras/memory/test/unity_memory_Test.c @@ -1,7 +1,7 @@ /* ========================================================================= Unity - A Test Framework for C ThrowTheSwitch.org - Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams + Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams SPDX-License-Identifier: MIT ========================================================================= */ diff --git a/extras/memory/test/unity_memory_TestRunner.c b/extras/memory/test/unity_memory_TestRunner.c index 92e98ff8..0a8ed3da 100644 --- a/extras/memory/test/unity_memory_TestRunner.c +++ b/extras/memory/test/unity_memory_TestRunner.c @@ -1,7 +1,7 @@ /* ========================================================================= Unity - A Test Framework for C ThrowTheSwitch.org - Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams + Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams SPDX-License-Identifier: MIT ========================================================================= */ diff --git a/extras/memory/test/unity_output_Spy.c b/extras/memory/test/unity_output_Spy.c index 69fcacc7..044c5def 100644 --- a/extras/memory/test/unity_output_Spy.c +++ b/extras/memory/test/unity_output_Spy.c @@ -1,7 +1,7 @@ /* ========================================================================= Unity - A Test Framework for C ThrowTheSwitch.org - Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams + Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams SPDX-License-Identifier: MIT ========================================================================= */ diff --git a/extras/memory/test/unity_output_Spy.h b/extras/memory/test/unity_output_Spy.h index 739263cd..3c2e9b97 100644 --- a/extras/memory/test/unity_output_Spy.h +++ b/extras/memory/test/unity_output_Spy.h @@ -1,7 +1,7 @@ /* ========================================================================= Unity - A Test Framework for C ThrowTheSwitch.org - Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams + Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams SPDX-License-Identifier: MIT ========================================================================= */ diff --git a/src/unity.c b/src/unity.c index 04d716d7..7fa2dc63 100644 --- a/src/unity.c +++ b/src/unity.c @@ -1,7 +1,7 @@ /* ========================================================================= Unity - A Test Framework for C ThrowTheSwitch.org - Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams + Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams SPDX-License-Identifier: MIT ========================================================================= */ diff --git a/src/unity.h b/src/unity.h index 8337c8c6..e390ff16 100644 --- a/src/unity.h +++ b/src/unity.h @@ -1,7 +1,7 @@ /* ========================================================================= Unity - A Test Framework for C ThrowTheSwitch.org - Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams + Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams SPDX-License-Identifier: MIT ========================================================================= */ diff --git a/src/unity_internals.h b/src/unity_internals.h index 192f7ffa..562f5b6d 100644 --- a/src/unity_internals.h +++ b/src/unity_internals.h @@ -1,7 +1,7 @@ /* ========================================================================= Unity - A Test Framework for C ThrowTheSwitch.org - Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams + Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams SPDX-License-Identifier: MIT ========================================================================= */ diff --git a/test/rakefile_helper.rb b/test/rakefile_helper.rb index 61ce874e..80a4976d 100644 --- a/test/rakefile_helper.rb +++ b/test/rakefile_helper.rb @@ -1,7 +1,7 @@ # ========================================================================= # Unity - A Test Framework for C # ThrowTheSwitch.org -# Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams +# Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams # SPDX-License-Identifier: MIT # ========================================================================= diff --git a/test/spec/generate_module_existing_file_spec.rb b/test/spec/generate_module_existing_file_spec.rb index 0d5eb1b3..f4dd13e3 100644 --- a/test/spec/generate_module_existing_file_spec.rb +++ b/test/spec/generate_module_existing_file_spec.rb @@ -1,11 +1,10 @@ # ========================================================================= # Unity - A Test Framework for C # ThrowTheSwitch.org -# Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams +# Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams # SPDX-License-Identifier: MIT # ========================================================================= - require '../auto/generate_module.rb' require 'fileutils' diff --git a/test/targets/ansi.yml b/test/targets/ansi.yml index 960a5bd8..fcc24557 100644 --- a/test/targets/ansi.yml +++ b/test/targets/ansi.yml @@ -1,7 +1,7 @@ # ========================================================================= # Unity - A Test Framework for C # ThrowTheSwitch.org -# Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams +# Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams # SPDX-License-Identifier: MIT # ========================================================================= diff --git a/test/targets/clang_file.yml b/test/targets/clang_file.yml index 00617331..f962ced3 100644 --- a/test/targets/clang_file.yml +++ b/test/targets/clang_file.yml @@ -1,7 +1,7 @@ # ========================================================================= # Unity - A Test Framework for C # ThrowTheSwitch.org -# Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams +# Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams # SPDX-License-Identifier: MIT # ========================================================================= diff --git a/test/targets/clang_strict.yml b/test/targets/clang_strict.yml index 6ae19356..1c82f624 100644 --- a/test/targets/clang_strict.yml +++ b/test/targets/clang_strict.yml @@ -1,7 +1,7 @@ # ========================================================================= # Unity - A Test Framework for C # ThrowTheSwitch.org -# Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams +# Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams # SPDX-License-Identifier: MIT # ========================================================================= diff --git a/test/targets/gcc_32.yml b/test/targets/gcc_32.yml index 60deb062..3375e4ee 100644 --- a/test/targets/gcc_32.yml +++ b/test/targets/gcc_32.yml @@ -1,7 +1,7 @@ # ========================================================================= # Unity - A Test Framework for C # ThrowTheSwitch.org -# Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams +# Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams # SPDX-License-Identifier: MIT # ========================================================================= diff --git a/test/targets/gcc_64.yml b/test/targets/gcc_64.yml index b6f10f82..55223ceb 100644 --- a/test/targets/gcc_64.yml +++ b/test/targets/gcc_64.yml @@ -1,7 +1,7 @@ # ========================================================================= # Unity - A Test Framework for C # ThrowTheSwitch.org -# Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams +# Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams # SPDX-License-Identifier: MIT # ========================================================================= diff --git a/test/targets/gcc_auto_limits.yml b/test/targets/gcc_auto_limits.yml index 12a11fe0..9159b385 100644 --- a/test/targets/gcc_auto_limits.yml +++ b/test/targets/gcc_auto_limits.yml @@ -1,7 +1,7 @@ # ========================================================================= # Unity - A Test Framework for C # ThrowTheSwitch.org -# Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams +# Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams # SPDX-License-Identifier: MIT # ========================================================================= diff --git a/test/targets/gcc_auto_stdint.yml b/test/targets/gcc_auto_stdint.yml index 94066139..18221609 100644 --- a/test/targets/gcc_auto_stdint.yml +++ b/test/targets/gcc_auto_stdint.yml @@ -1,7 +1,7 @@ # ========================================================================= # Unity - A Test Framework for C # ThrowTheSwitch.org -# Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams +# Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams # SPDX-License-Identifier: MIT # ========================================================================= diff --git a/test/targets/gcc_manual_math.yml b/test/targets/gcc_manual_math.yml index 76fc9921..22e69aa6 100644 --- a/test/targets/gcc_manual_math.yml +++ b/test/targets/gcc_manual_math.yml @@ -1,7 +1,7 @@ # ========================================================================= # Unity - A Test Framework for C # ThrowTheSwitch.org -# Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams +# Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams # SPDX-License-Identifier: MIT # ========================================================================= diff --git a/test/targets/hitech_picc18.yml b/test/targets/hitech_picc18.yml index 493705be..547cb2b5 100644 --- a/test/targets/hitech_picc18.yml +++ b/test/targets/hitech_picc18.yml @@ -1,7 +1,7 @@ # ========================================================================= # Unity - A Test Framework for C # ThrowTheSwitch.org -# Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams +# Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams # SPDX-License-Identifier: MIT # ========================================================================= diff --git a/test/targets/iar_arm_v4.yml b/test/targets/iar_arm_v4.yml index 36b1a0c8..26a0f462 100644 --- a/test/targets/iar_arm_v4.yml +++ b/test/targets/iar_arm_v4.yml @@ -1,7 +1,7 @@ # ========================================================================= # Unity - A Test Framework for C # ThrowTheSwitch.org -# Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams +# Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams # SPDX-License-Identifier: MIT # ========================================================================= diff --git a/test/targets/iar_arm_v5.yml b/test/targets/iar_arm_v5.yml index 17b6b10d..afd51775 100644 --- a/test/targets/iar_arm_v5.yml +++ b/test/targets/iar_arm_v5.yml @@ -1,7 +1,7 @@ # ========================================================================= # Unity - A Test Framework for C # ThrowTheSwitch.org -# Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams +# Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams # SPDX-License-Identifier: MIT # ========================================================================= diff --git a/test/targets/iar_arm_v5_3.yml b/test/targets/iar_arm_v5_3.yml index 17b6b10d..afd51775 100644 --- a/test/targets/iar_arm_v5_3.yml +++ b/test/targets/iar_arm_v5_3.yml @@ -1,7 +1,7 @@ # ========================================================================= # Unity - A Test Framework for C # ThrowTheSwitch.org -# Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams +# Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams # SPDX-License-Identifier: MIT # ========================================================================= diff --git a/test/targets/iar_armcortex_LM3S9B92_v5_4.yml b/test/targets/iar_armcortex_LM3S9B92_v5_4.yml index 7bf92871..b4aa5d8e 100644 --- a/test/targets/iar_armcortex_LM3S9B92_v5_4.yml +++ b/test/targets/iar_armcortex_LM3S9B92_v5_4.yml @@ -1,7 +1,7 @@ # ========================================================================= # Unity - A Test Framework for C # ThrowTheSwitch.org -# Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams +# Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams # SPDX-License-Identifier: MIT # ========================================================================= diff --git a/test/targets/iar_cortexm3_v5.yml b/test/targets/iar_cortexm3_v5.yml index e56286a4..e27b0f6b 100644 --- a/test/targets/iar_cortexm3_v5.yml +++ b/test/targets/iar_cortexm3_v5.yml @@ -1,7 +1,7 @@ # ========================================================================= # Unity - A Test Framework for C # ThrowTheSwitch.org -# Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams +# Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams # SPDX-License-Identifier: MIT # ========================================================================= diff --git a/test/targets/iar_msp430.yml b/test/targets/iar_msp430.yml index a1bd3ee4..041ebdaf 100644 --- a/test/targets/iar_msp430.yml +++ b/test/targets/iar_msp430.yml @@ -1,7 +1,7 @@ # ========================================================================= # Unity - A Test Framework for C # ThrowTheSwitch.org -# Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams +# Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams # SPDX-License-Identifier: MIT # ========================================================================= diff --git a/test/targets/iar_sh2a_v6.yml b/test/targets/iar_sh2a_v6.yml index c4469d62..21761d4b 100644 --- a/test/targets/iar_sh2a_v6.yml +++ b/test/targets/iar_sh2a_v6.yml @@ -1,7 +1,7 @@ # ========================================================================= # Unity - A Test Framework for C # ThrowTheSwitch.org -# Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams +# Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams # SPDX-License-Identifier: MIT # ========================================================================= diff --git a/test/testdata/CException.h b/test/testdata/CException.h index 4f82afa1..0c11eaaa 100644 --- a/test/testdata/CException.h +++ b/test/testdata/CException.h @@ -1,7 +1,7 @@ /* ========================================================================= Unity - A Test Framework for C ThrowTheSwitch.org - Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams + Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams SPDX-License-Identifier: MIT ========================================================================= */ diff --git a/test/testdata/Defs.h b/test/testdata/Defs.h index 470f8877..aa5ed670 100644 --- a/test/testdata/Defs.h +++ b/test/testdata/Defs.h @@ -1,7 +1,7 @@ /* ========================================================================= Unity - A Test Framework for C ThrowTheSwitch.org - Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams + Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams SPDX-License-Identifier: MIT ========================================================================= */ diff --git a/test/testdata/cmock.h b/test/testdata/cmock.h index af739308..440220d0 100644 --- a/test/testdata/cmock.h +++ b/test/testdata/cmock.h @@ -1,7 +1,7 @@ /* ========================================================================= Unity - A Test Framework for C ThrowTheSwitch.org - Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams + Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams SPDX-License-Identifier: MIT ========================================================================= */ diff --git a/test/testdata/mockMock.h b/test/testdata/mockMock.h index 3d728e4a..ca65fc93 100644 --- a/test/testdata/mockMock.h +++ b/test/testdata/mockMock.h @@ -1,7 +1,7 @@ /* ========================================================================= Unity - A Test Framework for C ThrowTheSwitch.org - Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams + Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams SPDX-License-Identifier: MIT ========================================================================= */ diff --git a/test/testdata/testRunnerGenerator.c b/test/testdata/testRunnerGenerator.c index ab14c0e8..c10a96e6 100644 --- a/test/testdata/testRunnerGenerator.c +++ b/test/testdata/testRunnerGenerator.c @@ -1,7 +1,7 @@ /* ========================================================================= Unity - A Test Framework for C ThrowTheSwitch.org - Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams + Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams SPDX-License-Identifier: MIT ========================================================================= */ diff --git a/test/testdata/testRunnerGeneratorSmall.c b/test/testdata/testRunnerGeneratorSmall.c index 15893d53..bc9f7fcf 100644 --- a/test/testdata/testRunnerGeneratorSmall.c +++ b/test/testdata/testRunnerGeneratorSmall.c @@ -1,7 +1,7 @@ /* ========================================================================= Unity - A Test Framework for C ThrowTheSwitch.org - Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams + Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams SPDX-License-Identifier: MIT ========================================================================= */ diff --git a/test/testdata/testRunnerGeneratorWithMocks.c b/test/testdata/testRunnerGeneratorWithMocks.c index a5b37b8c..adc2a295 100644 --- a/test/testdata/testRunnerGeneratorWithMocks.c +++ b/test/testdata/testRunnerGeneratorWithMocks.c @@ -1,7 +1,7 @@ /* ========================================================================= Unity - A Test Framework for C ThrowTheSwitch.org - Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams + Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams SPDX-License-Identifier: MIT ========================================================================= */ diff --git a/test/tests/self_assessment_utils.h b/test/tests/self_assessment_utils.h index 39953e36..6051bda8 100644 --- a/test/tests/self_assessment_utils.h +++ b/test/tests/self_assessment_utils.h @@ -1,7 +1,7 @@ /* ========================================================================= Unity - A Test Framework for C ThrowTheSwitch.org - Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams + Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams SPDX-License-Identifier: MIT ========================================================================= */ diff --git a/test/tests/test_generate_test_runner.rb b/test/tests/test_generate_test_runner.rb index dd1c4c8e..79a2e48e 100644 --- a/test/tests/test_generate_test_runner.rb +++ b/test/tests/test_generate_test_runner.rb @@ -1,7 +1,7 @@ # ========================================================================= # Unity - A Test Framework for C # ThrowTheSwitch.org -# Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams +# Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams # SPDX-License-Identifier: MIT # ========================================================================= diff --git a/test/tests/test_unity_arrays.c b/test/tests/test_unity_arrays.c index e61e43d5..f852c269 100644 --- a/test/tests/test_unity_arrays.c +++ b/test/tests/test_unity_arrays.c @@ -1,7 +1,7 @@ /* ========================================================================= Unity - A Test Framework for C ThrowTheSwitch.org - Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams + Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams SPDX-License-Identifier: MIT ========================================================================= */ diff --git a/test/tests/test_unity_core.c b/test/tests/test_unity_core.c index e4a3fdd9..866f2ab1 100644 --- a/test/tests/test_unity_core.c +++ b/test/tests/test_unity_core.c @@ -1,7 +1,7 @@ /* ========================================================================= Unity - A Test Framework for C ThrowTheSwitch.org - Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams + Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams SPDX-License-Identifier: MIT ========================================================================= */ diff --git a/test/tests/test_unity_doubles.c b/test/tests/test_unity_doubles.c index 64d59070..b9e70cff 100644 --- a/test/tests/test_unity_doubles.c +++ b/test/tests/test_unity_doubles.c @@ -1,7 +1,7 @@ /* ========================================================================= Unity - A Test Framework for C ThrowTheSwitch.org - Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams + Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams SPDX-License-Identifier: MIT ========================================================================= */ diff --git a/test/tests/test_unity_floats.c b/test/tests/test_unity_floats.c index 4a2c2131..006c76ab 100644 --- a/test/tests/test_unity_floats.c +++ b/test/tests/test_unity_floats.c @@ -1,7 +1,7 @@ /* ========================================================================= Unity - A Test Framework for C ThrowTheSwitch.org - Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams + Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams SPDX-License-Identifier: MIT ========================================================================= */ diff --git a/test/tests/test_unity_integers.c b/test/tests/test_unity_integers.c index 2a923a8d..1b8c6e30 100644 --- a/test/tests/test_unity_integers.c +++ b/test/tests/test_unity_integers.c @@ -1,7 +1,7 @@ /* ========================================================================= Unity - A Test Framework for C ThrowTheSwitch.org - Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams + Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams SPDX-License-Identifier: MIT ========================================================================= */ diff --git a/test/tests/test_unity_integers_64.c b/test/tests/test_unity_integers_64.c index 2a1d3769..6fb0957f 100644 --- a/test/tests/test_unity_integers_64.c +++ b/test/tests/test_unity_integers_64.c @@ -1,7 +1,7 @@ /* ========================================================================= Unity - A Test Framework for C ThrowTheSwitch.org - Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams + Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams SPDX-License-Identifier: MIT ========================================================================= */ diff --git a/test/tests/test_unity_memory.c b/test/tests/test_unity_memory.c index 4d0513a5..d4897de4 100644 --- a/test/tests/test_unity_memory.c +++ b/test/tests/test_unity_memory.c @@ -1,7 +1,7 @@ /* ========================================================================= Unity - A Test Framework for C ThrowTheSwitch.org - Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams + Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams SPDX-License-Identifier: MIT ========================================================================= */ diff --git a/test/tests/test_unity_parameterized.c b/test/tests/test_unity_parameterized.c index a473a921..b9550986 100644 --- a/test/tests/test_unity_parameterized.c +++ b/test/tests/test_unity_parameterized.c @@ -1,7 +1,7 @@ /* ========================================================================= Unity - A Test Framework for C ThrowTheSwitch.org - Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams + Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams SPDX-License-Identifier: MIT ========================================================================= */ diff --git a/test/tests/test_unity_parameterizedDemo.c b/test/tests/test_unity_parameterizedDemo.c index 6ee42c54..6de6e686 100644 --- a/test/tests/test_unity_parameterizedDemo.c +++ b/test/tests/test_unity_parameterizedDemo.c @@ -1,7 +1,7 @@ /* ========================================================================= Unity - A Test Framework for C ThrowTheSwitch.org - Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams + Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams SPDX-License-Identifier: MIT ========================================================================= */ diff --git a/test/tests/test_unity_strings.c b/test/tests/test_unity_strings.c index 99ba4d53..6a421135 100644 --- a/test/tests/test_unity_strings.c +++ b/test/tests/test_unity_strings.c @@ -1,7 +1,7 @@ /* ========================================================================= Unity - A Test Framework for C ThrowTheSwitch.org - Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams + Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams SPDX-License-Identifier: MIT ========================================================================= */ diff --git a/test/tests/types_for_test.h b/test/tests/types_for_test.h index 176926cf..66828b95 100644 --- a/test/tests/types_for_test.h +++ b/test/tests/types_for_test.h @@ -1,7 +1,7 @@ /* ========================================================================= Unity - A Test Framework for C ThrowTheSwitch.org - Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams + Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams SPDX-License-Identifier: MIT ========================================================================= */ From cbcd08fa7de711053a3deec6339ee89cad5d2697 Mon Sep 17 00:00:00 2001 From: Mark VanderVoord Date: Wed, 1 Jan 2025 11:53:54 -0500 Subject: [PATCH 421/454] Add release notes and bump version. --- docs/UnityChangeLog.md | 18 +++++++++++++++++- src/unity.h | 2 +- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/docs/UnityChangeLog.md b/docs/UnityChangeLog.md index f93f9ec6..a9fec00f 100644 --- a/docs/UnityChangeLog.md +++ b/docs/UnityChangeLog.md @@ -13,7 +13,23 @@ Prior to 2008, the project was an internal project and not released to the publi ## Log -### Unity 2.6.0 () +### Unity 2.6.1 (Jan 2025) + +New Features: + + - Add `-n` comand line option as strict matcher again + +Significant Bugfixes: + + - Protect against problems when mis-matched command line options selected + +Other: + + - Protect against Conversion warnings in gcc + - Remove Redundant line-casts + - Make more internal functions static + +### Unity 2.6.0 (Mar 2024) New Features: diff --git a/src/unity.h b/src/unity.h index e390ff16..9e2a97b7 100644 --- a/src/unity.h +++ b/src/unity.h @@ -11,7 +11,7 @@ #define UNITY_VERSION_MAJOR 2 #define UNITY_VERSION_MINOR 6 -#define UNITY_VERSION_BUILD 0 +#define UNITY_VERSION_BUILD 1 #define UNITY_VERSION ((UNITY_VERSION_MAJOR << 16) | (UNITY_VERSION_MINOR << 8) | UNITY_VERSION_BUILD) #ifdef __cplusplus From 459d53a82159bbce0315b777e599cf7d179250f1 Mon Sep 17 00:00:00 2001 From: Koy Rehme Date: Wed, 8 Jan 2025 15:35:32 -0700 Subject: [PATCH 422/454] New command line options --- extras/fixture/src/unity_fixture.c | 65 +++++++++++++++----- extras/fixture/src/unity_fixture_internals.h | 3 + 2 files changed, 54 insertions(+), 14 deletions(-) diff --git a/extras/fixture/src/unity_fixture.c b/extras/fixture/src/unity_fixture.c index 9b3fce27..cd0df2ca 100644 --- a/extras/fixture/src/unity_fixture.c +++ b/extras/fixture/src/unity_fixture.c @@ -46,21 +46,25 @@ int UnityMain(int argc, const char* argv[], void (*runAllTests)(void)) return (int)Unity.TestFailures; } -static int selected(const char* filter, const char* name) +static int selected(const char* filter, const char* select, const char* name) { - if (filter == 0) + if (filter == 0 && select == 0) return 1; - return strstr(name, filter) ? 1 : 0; + if (filter && strstr(name, filter)) + return 1; + if (select && strcmp(name, select) == 0) + return 1; + return 0; } static int testSelected(const char* test) { - return selected(UnityFixture.NameFilter, test); + return selected(UnityFixture.NameFilter, UnityFixture.Name, test); } static int groupSelected(const char* group) { - return selected(UnityFixture.GroupFilter, group); + return selected(UnityFixture.GroupFilter, UnityFixture.Group, group); } void UnityTestRunner(unityfunction* setup, @@ -96,17 +100,20 @@ void UnityTestRunner(unityfunction* setup, Unity.NumberOfTests++; UnityPointer_Init(); - UNITY_EXEC_TIME_START(); + if (!UnityFixture.DryRun) { + UNITY_EXEC_TIME_START(); - if (TEST_PROTECT()) - { - setup(); - testBody(); - } - if (TEST_PROTECT()) - { - teardown(); + if (TEST_PROTECT()) + { + setup(); + testBody(); + } + if (TEST_PROTECT()) + { + teardown(); + } } + if (TEST_PROTECT()) { UnityPointer_UndoAllSets(); @@ -183,8 +190,11 @@ int UnityGetCommandLineOptions(int argc, const char* argv[]) int i; UnityFixture.Verbose = 0; UnityFixture.Silent = 0; + UnityFixture.DryRun = 0; UnityFixture.GroupFilter = 0; + UnityFixture.Group = 0; UnityFixture.NameFilter = 0; + UnityFixture.Name = 0; UnityFixture.RepeatCount = 1; if (argc == 1) @@ -207,10 +217,16 @@ int UnityGetCommandLineOptions(int argc, const char* argv[]) UNITY_PRINT_EOL(); UnityPrint(" -s Silent mode: minimal output showing only test failures"); UNITY_PRINT_EOL(); + UnityPrint(" -d Dry run all tests"); + UNITY_PRINT_EOL(); UnityPrint(" -g NAME Only run tests in groups that contain the string NAME"); UNITY_PRINT_EOL(); + UnityPrint(" -G NAME Only run tests in groups named NAME"); + UNITY_PRINT_EOL(); UnityPrint(" -n NAME Only run tests whose name contains the string NAME"); UNITY_PRINT_EOL(); + UnityPrint(" -N NAME Only run tests named NAME"); + UNITY_PRINT_EOL(); UnityPrint(" -r NUMBER Repeatedly run all tests NUMBER times"); UNITY_PRINT_EOL(); UnityPrint(" -h, --help Display this help message"); @@ -237,6 +253,11 @@ int UnityGetCommandLineOptions(int argc, const char* argv[]) UnityFixture.Silent = 1; i++; } + else if (strcmp(argv[i], "-d") == 0) + { + UnityFixture.DryRun = 1; + i++; + } else if (strcmp(argv[i], "-g") == 0) { i++; @@ -245,6 +266,14 @@ int UnityGetCommandLineOptions(int argc, const char* argv[]) UnityFixture.GroupFilter = argv[i]; i++; } + else if (strcmp(argv[i], "-G") == 0) + { + i++; + if (i >= argc) + return 1; + UnityFixture.Group= argv[i]; + i++; + } else if (strcmp(argv[i], "-n") == 0) { i++; @@ -253,6 +282,14 @@ int UnityGetCommandLineOptions(int argc, const char* argv[]) UnityFixture.NameFilter = argv[i]; i++; } + else if (strcmp(argv[i], "-N") == 0) + { + i++; + if (i >= argc) + return 1; + UnityFixture.Name = argv[i]; + i++; + } else if (strcmp(argv[i], "-r") == 0) { UnityFixture.RepeatCount = 2; diff --git a/extras/fixture/src/unity_fixture_internals.h b/extras/fixture/src/unity_fixture_internals.h index f8f83d2d..6a552c1f 100644 --- a/extras/fixture/src/unity_fixture_internals.h +++ b/extras/fixture/src/unity_fixture_internals.h @@ -17,9 +17,12 @@ struct UNITY_FIXTURE_T { int Verbose; int Silent; + int DryRun; unsigned int RepeatCount; const char* NameFilter; + const char* Name; const char* GroupFilter; + const char* Group; }; extern struct UNITY_FIXTURE_T UnityFixture; From df0b5d90b80a00a2f5b2d33670a994401cfd4973 Mon Sep 17 00:00:00 2001 From: "Rehme, Koy" Date: Sat, 18 Jan 2025 17:45:21 -0700 Subject: [PATCH 423/454] Add unit tests for new switches --- extras/fixture/test/unity_fixture_Test.c | 45 +++++++++++++++++++ .../fixture/test/unity_fixture_TestRunner.c | 3 ++ 2 files changed, 48 insertions(+) diff --git a/extras/fixture/test/unity_fixture_Test.c b/extras/fixture/test/unity_fixture_Test.c index d2785d3c..f5103ff1 100644 --- a/extras/fixture/test/unity_fixture_Test.c +++ b/extras/fixture/test/unity_fixture_Test.c @@ -90,23 +90,32 @@ TEST_GROUP(UnityCommandOptions); static int savedVerbose; static unsigned int savedRepeat; +static int savedDryRun; static const char* savedName; static const char* savedGroup; +static const char* savedNameExact; +static const char* savedGroupExact; TEST_SETUP(UnityCommandOptions) { savedVerbose = UnityFixture.Verbose; savedRepeat = UnityFixture.RepeatCount; + savedDryRun = UnityFixture.DryRun; savedName = UnityFixture.NameFilter; savedGroup = UnityFixture.GroupFilter; + savedNameExact = UnityFixture.Name; + savedGroupExact = UnityFixture.Group; } TEST_TEAR_DOWN(UnityCommandOptions) { UnityFixture.Verbose = savedVerbose; UnityFixture.RepeatCount= savedRepeat; + UnityFixture.DryRun = savedDryRun; UnityFixture.NameFilter = savedName; UnityFixture.GroupFilter = savedGroup; + UnityFixture.Name= savedNameExact; + UnityFixture.Group= savedGroup; } @@ -118,8 +127,11 @@ TEST(UnityCommandOptions, DefaultOptions) { UnityGetCommandLineOptions(1, noOptions); TEST_ASSERT_EQUAL(0, UnityFixture.Verbose); + TEST_ASSERT_EQUAL(0, UnityFixture.DryRun); TEST_ASSERT_POINTERS_EQUAL(0, UnityFixture.GroupFilter); TEST_ASSERT_POINTERS_EQUAL(0, UnityFixture.NameFilter); + TEST_ASSERT_POINTERS_EQUAL(0, UnityFixture.Group); + TEST_ASSERT_POINTERS_EQUAL(0, UnityFixture.Name); TEST_ASSERT_EQUAL(1, UnityFixture.RepeatCount); } @@ -134,6 +146,17 @@ TEST(UnityCommandOptions, OptionVerbose) TEST_ASSERT_EQUAL(1, UnityFixture.Verbose); } +static const char* dryRun[] = { + "testrunner.exe", + "-d" +}; + +TEST(UnityCommandOptions, OptionDryRun) +{ + TEST_ASSERT_EQUAL(0, UnityGetCommandLineOptions(2, dryRun)); + TEST_ASSERT_EQUAL(1, UnityFixture.DryRun); +} + static const char* group[] = { "testrunner.exe", "-g", "groupname" @@ -156,6 +179,28 @@ TEST(UnityCommandOptions, OptionSelectTestByName) STRCMP_EQUAL("testname", UnityFixture.NameFilter); } +static const char* groupExact[] = { + "testrunner.exe", + "-G", "groupname" +}; + +TEST(UnityCommandOptions, OptionSelectTestByGroupExact) +{ + TEST_ASSERT_EQUAL(0, UnityGetCommandLineOptions(3, groupExact)); + STRCMP_EQUAL("groupname", UnityFixture.Group); +} + +static const char* nameExact[] = { + "testrunner.exe", + "-N", "testname" +}; + +TEST(UnityCommandOptions, OptionSelectTestByNameExact) +{ + TEST_ASSERT_EQUAL(0, UnityGetCommandLineOptions(3, nameExact)); + STRCMP_EQUAL("testname", UnityFixture.Name); +} + static const char* repeat[] = { "testrunner.exe", "-r", "99" diff --git a/extras/fixture/test/unity_fixture_TestRunner.c b/extras/fixture/test/unity_fixture_TestRunner.c index ec92663f..07099d36 100644 --- a/extras/fixture/test/unity_fixture_TestRunner.c +++ b/extras/fixture/test/unity_fixture_TestRunner.c @@ -19,8 +19,11 @@ TEST_GROUP_RUNNER(UnityCommandOptions) { RUN_TEST_CASE(UnityCommandOptions, DefaultOptions); RUN_TEST_CASE(UnityCommandOptions, OptionVerbose); + RUN_TEST_CASE(UnityCommandOptions, OptionDryRun); RUN_TEST_CASE(UnityCommandOptions, OptionSelectTestByGroup); RUN_TEST_CASE(UnityCommandOptions, OptionSelectTestByName); + RUN_TEST_CASE(UnityCommandOptions, OptionSelectTestByGroupExact); + RUN_TEST_CASE(UnityCommandOptions, OptionSelectTestByNameExact); RUN_TEST_CASE(UnityCommandOptions, OptionSelectRepeatTestsDefaultCount); RUN_TEST_CASE(UnityCommandOptions, OptionSelectRepeatTestsSpecificCount); RUN_TEST_CASE(UnityCommandOptions, MultipleOptions); From cdf1d0297effc2736ee847e557b4275b4f02310b Mon Sep 17 00:00:00 2001 From: Mark VanderVoord Date: Mon, 17 Feb 2025 09:14:39 -0500 Subject: [PATCH 424/454] Create FUNDING.yml --- .github/FUNDING.yml | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 .github/FUNDING.yml diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 00000000..5aa51266 --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1,13 @@ +github: ThrowTheSwitch +#patreon: # Replace with a single Patreon username +#open_collective: # Replace with a single Open Collective username +#ko_fi: # Replace with a single Ko-fi username +#tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel +#community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry +#liberapay: # Replace with a single Liberapay username +#issuehunt: # Replace with a single IssueHunt username +#lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry +#polar: # Replace with a single Polar username +#buy_me_a_coffee: # Replace with a single Buy Me a Coffee username +#thanks_dev: # Replace with a single thanks.dev username +#custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] From 0921c263f4fcef5da10531db61ec6eac89137a70 Mon Sep 17 00:00:00 2001 From: Ross Smyth Date: Wed, 5 Mar 2025 16:22:40 -0500 Subject: [PATCH 425/454] Allow the memory extra and fixture extra to be enabled seperatly. --- meson.build | 7 +++---- meson_options.txt | 6 +++--- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/meson.build b/meson.build index 6585129c..e16bce09 100644 --- a/meson.build +++ b/meson.build @@ -34,14 +34,13 @@ unity_inc = [] subdir('src') if build_fixture - # Building the fixture extension implies building the memory - # extension. - build_memory = true subdir('extras/fixture/src') endif -if build_memory +if build_memory.enabled() or (build_memory.auto() and build_fixture) subdir('extras/memory/src') +else + unity_args += '-DUNITY_FIXTURE_NO_EXTRAS' endif if support_double diff --git a/meson_options.txt b/meson_options.txt index 8e66784b..069b19d1 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -1,3 +1,3 @@ -option('extension_fixture', type: 'boolean', value: 'false', description: 'Whether to enable the fixture extension.') -option('extension_memory', type: 'boolean', value: 'false', description: 'Whether to enable the memory extension.') -option('support_double', type: 'boolean', value: 'false', description: 'Whether to enable double precision floating point assertions.') +option('extension_fixture', type: 'boolean', value: false, description: 'Whether to enable the fixture extension.') +option('extension_memory', type: 'feature', value: 'auto', description: 'Whether to enable the memory extension. By default this is automatically enabled when extension_fixture is enabled.') +option('support_double', type: 'boolean', value: false, description: 'Whether to enable double precision floating point assertions.') From 8badc0e070f47f275b50885b6eacad06d917022d Mon Sep 17 00:00:00 2001 From: Ross Smyth Date: Wed, 5 Mar 2025 16:31:13 -0500 Subject: [PATCH 426/454] Add fixture help message option for UNITY_CUSTOM_HELP_MSG --- meson.build | 4 ++++ meson_options.txt | 1 + 2 files changed, 5 insertions(+) diff --git a/meson.build b/meson.build index e16bce09..419e09ea 100644 --- a/meson.build +++ b/meson.build @@ -26,6 +26,7 @@ project('unity', 'c', build_fixture = get_option('extension_fixture') build_memory = get_option('extension_memory') support_double = get_option('support_double') +fixture_help_message = get_option('fixture_help_message') unity_args = [] unity_src = [] @@ -35,6 +36,9 @@ subdir('src') if build_fixture subdir('extras/fixture/src') + if fixture_help_message != '' + unity_args += '-DUNITY_CUSTOM_HELP_MSG=' + fixture_help_message + endif endif if build_memory.enabled() or (build_memory.auto() and build_fixture) diff --git a/meson_options.txt b/meson_options.txt index 069b19d1..264480cf 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -1,3 +1,4 @@ option('extension_fixture', type: 'boolean', value: false, description: 'Whether to enable the fixture extension.') option('extension_memory', type: 'feature', value: 'auto', description: 'Whether to enable the memory extension. By default this is automatically enabled when extension_fixture is enabled.') option('support_double', type: 'boolean', value: false, description: 'Whether to enable double precision floating point assertions.') +option('fixture_help_message', type: 'string', description: 'If the fixture extension is enabled, this allows a custom help message to be defined.') From b0bcdb56c18ce8695c38742af757bbf116e649f5 Mon Sep 17 00:00:00 2001 From: James Raphael Tiovalen Date: Tue, 30 Jan 2024 17:45:53 +0800 Subject: [PATCH 427/454] Add support for randomizing test execution order This commit reintroduces the option to shuffle the test execution order into the test runner. This has been tested with the temp_sensor example project in Ceedling. Unit tests have also been successfully executed. Signed-off-by: James Raphael Tiovalen --- auto/generate_test_runner.rb | 96 ++++++++++++++++++++++++++++++--- docs/UnityHelperScriptsGuide.md | 16 ++++++ 2 files changed, 106 insertions(+), 6 deletions(-) diff --git a/auto/generate_test_runner.rb b/auto/generate_test_runner.rb index 2c2d5956..9fae0c1b 100755 --- a/auto/generate_test_runner.rb +++ b/auto/generate_test_runner.rb @@ -47,7 +47,9 @@ def self.default_options use_param_tests: false, use_system_files: true, include_extensions: '(?:hpp|hh|H|h)', - source_extensions: '(?:cpp|cc|ino|C|c)' + source_extensions: '(?:cpp|cc|ino|C|c)', + shuffle_tests: false, + rng_seed: 0 } end @@ -90,6 +92,7 @@ def run(input_file, output_file, options = nil) def generate(input_file, output_file, tests, used_mocks, testfile_includes) File.open(output_file, 'w') do |output| create_header(output, used_mocks, testfile_includes) + create_run_test_params_struct(output) create_externs(output, tests, used_mocks) create_mock_management(output, used_mocks) create_setup(output) @@ -99,6 +102,7 @@ def generate(input_file, output_file, tests, used_mocks, testfile_includes) create_reset(output) create_run_test(output) unless tests.empty? create_args_wrappers(output, tests) + create_shuffle_tests(output) if @options[:shuffle_tests] create_main(output, input_file, tests, used_mocks) end @@ -231,10 +235,34 @@ def find_setup_and_teardown(source) @options[:has_suite_teardown] ||= (source =~ /int\s+suiteTearDown\s*\(int\s+([a-zA-Z0-9_])+\s*\)/) end + def count_tests(tests) + if @options[:use_param_tests] + idx = 0 + tests.each do |test| + if (test[:args].nil? || test[:args].empty?) + idx += 1 + else + test[:args].each do |args| + idx += 1 + end + end + end + return idx + else + return tests.size + end + end + def create_header(output, mocks, testfile_includes = []) output.puts('/* AUTOGENERATED FILE. DO NOT EDIT. */') output.puts("\n/*=======Automagically Detected Files To Include=====*/") output.puts('extern "C" {') if @options[:externcincludes] + if @options[:shuffle_tests] + output.puts('#include ') + if @options[:rng_seed] == 0 + output.puts('#include ') + end + end output.puts("#include \"#{@options[:framework]}.h\"") output.puts('#include "cmock.h"') unless mocks.empty? output.puts('}') if @options[:externcincludes] @@ -270,6 +298,16 @@ def create_header(output, mocks, testfile_includes = []) output.puts('char* GlobalOrderError;') end + def create_run_test_params_struct(output) + output.puts("\n/*=======Structure Used By Test Runner=====*/") + output.puts('struct UnityRunTestParameters') + output.puts('{') + output.puts(' UnityTestFunction func;') + output.puts(' const char* name;') + output.puts(' UNITY_LINE_TYPE line_num;') + output.puts('};') + end + def create_externs(output, tests, _mocks) output.puts("\n/*=======External Functions This Runner Calls=====*/") output.puts("extern void #{@options[:setup_name]}(void);") @@ -392,6 +430,22 @@ def create_args_wrappers(output, tests) end end + def create_shuffle_tests(output) + output.puts("\n/*=======Shuffle Test Order=====*/") + output.puts('static void shuffleTests(struct UnityRunTestParameters run_test_params_arr[], int num_of_tests)') + output.puts('{') + + # Use Fisher-Yates shuffle algorithm + output.puts(' for (int i = num_of_tests - 1; i > 0; i--)') + output.puts(' {') + output.puts(' int j = rand() % (i + 1);') + output.puts(' struct UnityRunTestParameters temp = run_test_params_arr[i];') + output.puts(' run_test_params_arr[i] = run_test_params_arr[j];') + output.puts(' run_test_params_arr[j] = temp;') + output.puts(' }') + output.puts('}') + end + def create_main(output, filename, tests, used_mocks) output.puts("\n/*=======MAIN=====*/") main_name = @options[:main_name].to_sym == :auto ? "main_#{filename.gsub('.c', '')}" : (@options[:main_name]).to_s @@ -439,18 +493,46 @@ def create_main(output, filename, tests, used_mocks) else output.puts(" UnityBegin(\"#{filename.gsub(/\\/, '\\\\\\')}\");") end + if @options[:shuffle_tests] + output.puts + if @options[:rng_seed] == 0 + output.puts(' srand(time(NULL));') + else + output.puts(" srand(#{@options[:rng_seed]});") + end + end + output.puts + output.puts(" int number_of_tests = #{count_tests(tests)};") + output.puts(' struct UnityRunTestParameters run_test_params_arr[number_of_tests];') + output.puts + idx = 0 tests.each do |test| if (!@options[:use_param_tests]) || test[:args].nil? || test[:args].empty? - output.puts(" run_test(#{test[:test]}, \"#{test[:test]}\", #{test[:line_number]});") + output.puts(" run_test_params_arr[#{idx}].func = #{test[:test]};") + output.puts(" run_test_params_arr[#{idx}].name = \"#{test[:test]}\";") + output.puts(" run_test_params_arr[#{idx}].line_num = #{test[:line_number]};") + idx += 1 else - test[:args].each.with_index(1) do |args, idx| - wrapper = "runner_args#{idx}_#{test[:test]}" + test[:args].each.with_index(1) do |args, arg_idx| + wrapper = "runner_args#{arg_idx}_#{test[:test]}" testname = "#{test[:test]}(#{args})".dump - output.puts(" run_test(#{wrapper}, #{testname}, #{test[:line_number]});") + output.puts(" run_test_params_arr[#{idx}].func = #{wrapper};") + output.puts(" run_test_params_arr[#{idx}].name = #{testname};") + output.puts(" run_test_params_arr[#{idx}].line_num = #{test[:line_number]};") + idx += 1 end end end output.puts + if @options[:shuffle_tests] + output.puts(' shuffleTests(run_test_params_arr, number_of_tests);') + output.puts + end + output.puts(' for (int i = 0; i < number_of_tests; i++)') + output.puts(' {') + output.puts(' run_test(run_test_params_arr[i].func, run_test_params_arr[i].name, run_test_params_arr[i].line_num);') + output.puts(' }') + output.puts output.puts(' CMock_Guts_MemFreeFinal();') unless used_mocks.empty? if @options[:has_suite_teardown] if @options[:omit_begin_end] @@ -536,7 +618,9 @@ def create_h_file(output, filename, tests, testfile_includes, used_mocks) ' --suite_teardown="" - code to execute for teardown of entire suite', ' --use_param_tests=1 - enable parameterized tests (disabled by default)', ' --omit_begin_end=1 - omit calls to UnityBegin and UNITY_END (disabled by default)', - ' --header_file="" - path/name of test header file to generate too'].join("\n") + ' --header_file="" - path/name of test header file to generate too', + ' --shuffle_tests=1 - enable shuffling of the test execution order (disabled by default)', + ' --rng_seed=1 - seed value for randomization of test execution order'].join("\n") exit 1 end diff --git a/docs/UnityHelperScriptsGuide.md b/docs/UnityHelperScriptsGuide.md index 90e21939..9a8941c2 100644 --- a/docs/UnityHelperScriptsGuide.md +++ b/docs/UnityHelperScriptsGuide.md @@ -277,6 +277,22 @@ Unity test state setup and cleanup. This option can also be specified at the command prompt as `--omit_begin_end` +##### `:shuffle_tests` + +If `true`, the test execution order will be shuffled. Is `false` by default. + +This option can also be specified at the command prompt as `--shuffle_tests` + +##### `:rng_seed` + +If set to some positive integer value, said value will be used as the seed value passed +to the `srand` function. Otherwise, if not set to any value, `time(NULL)` will be used +as the seed value. + +Only applicable if `:shuffle_tests` is set to `true`. + +This option can also be specified at the command prompt as `--rng_seed` + #### Parameterized tests provided macros Unity provides support for few param tests generators, that can be combined From 19da6e196b41ef8a679e451f2b3143d396f896d0 Mon Sep 17 00:00:00 2001 From: Costas Akrivoulis Date: Sun, 23 Mar 2025 22:20:34 -0700 Subject: [PATCH 428/454] Fix minor typo --- docs/ThrowTheSwitchCodingStandard.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/ThrowTheSwitchCodingStandard.md b/docs/ThrowTheSwitchCodingStandard.md index 517b8fb6..607c456c 100644 --- a/docs/ThrowTheSwitchCodingStandard.md +++ b/docs/ThrowTheSwitchCodingStandard.md @@ -90,7 +90,7 @@ Take a look through the file names in Ceedling and you'll get a good idea of wha Why use preprocess when you can use preprocessinator? Or what better describes a module in charge of invoking tasks during releases than release_invoker? Don't get carried away. -The names are still descriptive and fulfil the above requirements, but they don't feel stale. +The names are still descriptive and fulfill the above requirements, but they don't feel stale. ## C and C++ Details @@ -184,4 +184,4 @@ Good enough? *Find The Latest of This And More at [ThrowTheSwitch.org][]* -[ThrowTheSwitch.org]: https://throwtheswitch.org \ No newline at end of file +[ThrowTheSwitch.org]: https://throwtheswitch.org From c359bf37b07a897e7e48c3149ff2f37e2ec27bc8 Mon Sep 17 00:00:00 2001 From: ml-physec <206103694+ml-physec@users.noreply.github.com> Date: Wed, 16 Apr 2025 19:21:33 +0200 Subject: [PATCH 429/454] Initial implementation --- src/unity.c | 106 +++++++++++++++++++++++++++++++----------- src/unity_internals.h | 70 ++++++++++++++++++++++++++-- 2 files changed, 146 insertions(+), 30 deletions(-) diff --git a/src/unity.c b/src/unity.c index 7fa2dc63..dd15222f 100644 --- a/src/unity.c +++ b/src/unity.c @@ -61,14 +61,24 @@ const char UNITY_PROGMEM UnityStrErrShorthand[] = "Unity Shorth const char UNITY_PROGMEM UnityStrErrFloat[] = "Unity Floating Point Disabled"; const char UNITY_PROGMEM UnityStrErrDouble[] = "Unity Double Precision Disabled"; const char UNITY_PROGMEM UnityStrErr64[] = "Unity 64-bit Support Disabled"; +const char UNITY_PROGMEM UnityStrErrDetailStack[] = "Unity Detail Stack Support Disabled"; static const char UNITY_PROGMEM UnityStrBreaker[] = "-----------------------"; static const char UNITY_PROGMEM UnityStrResultsTests[] = " Tests "; static const char UNITY_PROGMEM UnityStrResultsFailures[] = " Failures "; static const char UNITY_PROGMEM UnityStrResultsIgnored[] = " Ignored "; #ifndef UNITY_EXCLUDE_DETAILS +#ifdef UNITY_DETAIL_STACK_SIZE +static const char* UNITY_PROGMEM UnityStrDetailLabels[] = UNITY_DETAIL_LABEL_NAMES; +static const UNITY_COUNTER_TYPE UNITY_PROGMEM UnityStrDetailLabelsCount = sizeof(UnityStrDetailLabels) / sizeof(const char*); +static const char UNITY_PROGMEM UnityStrErrDetailStackEmpty[] = " Detail Stack Empty"; +static const char UNITY_PROGMEM UnityStrErrDetailStackFull[] = " Detail Stack Full"; +static const char UNITY_PROGMEM UnityStrErrDetailStackLabel[] = " Detail Label Outside Of UNITY_DETAIL_LABEL_NAMES: "; +static const char UNITY_PROGMEM UnityStrErrDetailStackPop[] = " Detail Pop With Unexpected Arguments"; +#else static const char UNITY_PROGMEM UnityStrDetail1Name[] = UNITY_DETAIL1_NAME " "; static const char UNITY_PROGMEM UnityStrDetail2Name[] = " " UNITY_DETAIL2_NAME " "; #endif +#endif /*----------------------------------------------- * Pretty Printers & Test Result Output Handlers *-----------------------------------------------*/ @@ -574,6 +584,28 @@ static void UnityAddMsgIfSpecified(const char* msg) UNITY_PRINT_TEST_CONTEXT(); #endif #ifndef UNITY_EXCLUDE_DETAILS +#ifdef UNITY_DETAIL_STACK_SIZE + { + UNITY_COUNTER_TYPE c; + for (c = 0; (c < Unity.CurrentDetailStackSize) && (c < UNITY_DETAIL_STACK_SIZE); c++) { + const char* label; + if ((Unity.CurrentDetailStackLabels[c] == UNITY_DETAIL_NONE) || (Unity.CurrentDetailStackLabels[c] > UnityStrDetailLabelsCount)) { + break; + } + label = UnityStrDetailLabels[Unity.CurrentDetailStackLabels[c]]; + UnityPrint(UnityStrSpacer); + if ((label[0] == '#') && (label[1] != 0)) { + UnityPrint(label + 2); + UNITY_OUTPUT_CHAR(' '); + UnityPrintNumberByStyle(Unity.CurrentDetailStackValues[c], label[1]); + } else if (Unity.CurrentDetailStackValues[c] != 0){ + UnityPrint(label); + UNITY_OUTPUT_CHAR(' '); + UnityPrint((const char*)Unity.CurrentDetailStackValues[c]); + } + } + } +#else if (Unity.CurrentDetail1) { UnityPrint(UnityStrSpacer); @@ -585,6 +617,7 @@ static void UnityAddMsgIfSpecified(const char* msg) UnityPrint(Unity.CurrentDetail2); } } +#endif #endif if (msg) { @@ -2127,32 +2160,7 @@ void UnityFail(const char* msg, const UNITY_LINE_TYPE line) UnityTestResultsBegin(Unity.TestFile, line); UnityPrint(UnityStrFail); - if (msg != NULL) - { - UNITY_OUTPUT_CHAR(':'); - -#ifdef UNITY_PRINT_TEST_CONTEXT - UNITY_PRINT_TEST_CONTEXT(); -#endif -#ifndef UNITY_EXCLUDE_DETAILS - if (Unity.CurrentDetail1) - { - UnityPrint(UnityStrDetail1Name); - UnityPrint(Unity.CurrentDetail1); - if (Unity.CurrentDetail2) - { - UnityPrint(UnityStrDetail2Name); - UnityPrint(Unity.CurrentDetail2); - } - UnityPrint(UnityStrSpacer); - } -#endif - if (msg[0] != ' ') - { - UNITY_OUTPUT_CHAR(' '); - } - UnityPrint(msg); - } + UnityAddMsgIfSpecified(msg); UNITY_FAIL_AND_BAIL; } @@ -2195,7 +2203,13 @@ void UnityDefaultTestRun(UnityTestFunction Func, const char* FuncName, const int Unity.CurrentTestName = FuncName; Unity.CurrentTestLineNumber = (UNITY_LINE_TYPE)FuncLineNum; Unity.NumberOfTests++; + #ifndef UNITY_EXCLUDE_DETAILS + #ifdef UNITY_DETAIL_STACK_SIZE + Unity.CurrentDetailStackSize = 0; + #else UNITY_CLR_DETAILS(); + #endif + #endif UNITY_EXEC_TIME_START(); if (TEST_PROTECT()) { @@ -2263,6 +2277,46 @@ int UnityEnd(void) return (int)(Unity.TestFailures); } +/*----------------------------------------------- + * Details Stack + *-----------------------------------------------*/ +#ifndef UNITY_EXCLUDE_DETAILS +#ifdef UNITY_DETAIL_STACK_SIZE +void UnityPushDetail(UNITY_DETAIL_LABEL_TYPE label, UNITY_DETAIL_VALUE_TYPE value, const UNITY_LINE_TYPE line) { + if (Unity.CurrentDetailStackSize >= UNITY_DETAIL_STACK_SIZE) { + UnityTestResultsFailBegin(line); + UnityPrint(UnityStrErrDetailStackFull); + UnityAddMsgIfSpecified(NULL); + UNITY_FAIL_AND_BAIL; + } + if (label >= UnityStrDetailLabelsCount) { + UnityTestResultsFailBegin(line); + UnityPrint(UnityStrErrDetailStackLabel); + UnityPrintNumberUnsigned(label); + UnityAddMsgIfSpecified(NULL); + UNITY_FAIL_AND_BAIL; + } + Unity.CurrentDetailStackLabels[Unity.CurrentDetailStackSize] = label; + Unity.CurrentDetailStackValues[Unity.CurrentDetailStackSize++] = value; +} +void UnityPopDetail(UNITY_DETAIL_LABEL_TYPE label, UNITY_DETAIL_VALUE_TYPE value, const UNITY_LINE_TYPE line) { + if (Unity.CurrentDetailStackSize == 0) { + UnityTestResultsFailBegin(line); + UnityPrint(UnityStrErrDetailStackEmpty); + UnityAddMsgIfSpecified(NULL); + UNITY_FAIL_AND_BAIL; + } + if ((Unity.CurrentDetailStackLabels[Unity.CurrentDetailStackSize-1] != label) || (Unity.CurrentDetailStackValues[Unity.CurrentDetailStackSize-1] != value)) { + UnityTestResultsFailBegin(line); + UnityPrint(UnityStrErrDetailStackPop); + UnityAddMsgIfSpecified(NULL); + UNITY_FAIL_AND_BAIL; + } + Unity.CurrentDetailStackSize--; +} +#endif +#endif + /*----------------------------------------------- * Command Line Argument Support *-----------------------------------------------*/ diff --git a/src/unity_internals.h b/src/unity_internals.h index 562f5b6d..2c8ed9ad 100644 --- a/src/unity_internals.h +++ b/src/unity_internals.h @@ -512,13 +512,30 @@ typedef enum UNITY_ARRAY_UNKNOWN } UNITY_FLAGS_T; +#ifndef UNITY_EXCLUDE_DETAILS +#ifdef UNITY_DETAIL_STACK_SIZE +#ifndef UNITY_DETAIL_LABEL_TYPE +#define UNITY_DETAIL_LABEL_TYPE uint8_t +#endif +#ifndef UNITY_DETAIL_VALUE_TYPE +#define UNITY_DETAIL_VALUE_TYPE UNITY_PTR_TO_INT +#endif +#endif +#endif + struct UNITY_STORAGE_T { const char* TestFile; const char* CurrentTestName; #ifndef UNITY_EXCLUDE_DETAILS +#ifdef UNITY_DETAIL_STACK_SIZE + UNITY_DETAIL_LABEL_TYPE CurrentDetailStackLabels[UNITY_DETAIL_STACK_SIZE]; + UNITY_DETAIL_VALUE_TYPE CurrentDetailStackValues[UNITY_DETAIL_STACK_SIZE]; + UNITY_COUNTER_TYPE CurrentDetailStackSize; +#else const char* CurrentDetail1; const char* CurrentDetail2; +#endif #endif UNITY_LINE_TYPE CurrentTestLineNumber; UNITY_COUNTER_TYPE NumberOfTests; @@ -561,10 +578,6 @@ void UnityDefaultTestRun(UnityTestFunction Func, const char* FuncName, const int #define UNITY_SET_DETAIL(d1) #define UNITY_SET_DETAILS(d1,d2) #else -#define UNITY_CLR_DETAILS() do { Unity.CurrentDetail1 = 0; Unity.CurrentDetail2 = 0; } while (0) -#define UNITY_SET_DETAIL(d1) do { Unity.CurrentDetail1 = (d1); Unity.CurrentDetail2 = 0; } while (0) -#define UNITY_SET_DETAILS(d1,d2) do { Unity.CurrentDetail1 = (d1); Unity.CurrentDetail2 = (d2); } while (0) - #ifndef UNITY_DETAIL1_NAME #define UNITY_DETAIL1_NAME "Function" #endif @@ -572,6 +585,47 @@ void UnityDefaultTestRun(UnityTestFunction Func, const char* FuncName, const int #ifndef UNITY_DETAIL2_NAME #define UNITY_DETAIL2_NAME "Argument" #endif + +#ifdef UNITY_DETAIL_STACK_SIZE +/* stack based implementation */ +#ifndef UNITY_DETAIL_LABEL_NAMES +/* Note: If the label name string starts with '#', the second byte is interpreted as UNITY_DISPLAY_STYLE_T, + * and the detail value will be printed as number (e.g. "#\x24Line" to output "Line "). + * Otherwise, the detail value must be a pointer to a string that is valid until it is pop'ed. + */ +#define UNITY_DETAIL_LABEL_NAMES {0, UNITY_DETAIL1_NAME, UNITY_DETAIL2_NAME} +typedef enum +{ + UNITY_DETAIL_NONE = 0, + UNITY_DETAIL_D1 = 1, + UNITY_DETAIL_D2 = 2 +} UNITY_DETAIL_LABEL_T; +#endif +void UnityPushDetail(UNITY_DETAIL_LABEL_TYPE label, UNITY_DETAIL_VALUE_TYPE value, const UNITY_LINE_TYPE line); +void UnityPopDetail(UNITY_DETAIL_LABEL_TYPE label, UNITY_DETAIL_VALUE_TYPE value, const UNITY_LINE_TYPE line); + +#define UNITY_CLR_DETAILS() do { \ + if(Unity.CurrentDetailStackSize && \ + Unity.CurrentDetailStackLabels[Unity.CurrentDetailStackSize - 1] == UNITY_DETAIL_D2) { \ + Unity.CurrentDetailStackLabels[--Unity.CurrentDetailStackSize] = UNITY_DETAIL_NONE;} \ + if(Unity.CurrentDetailStackSize && \ + Unity.CurrentDetailStackLabels[Unity.CurrentDetailStackSize - 1] == UNITY_DETAIL_D1) { \ + Unity.CurrentDetailStackLabels[--Unity.CurrentDetailStackSize] = UNITY_DETAIL_NONE;} \ + } while (0) +#define UNITY_SET_DETAIL(d1) do { UNITY_CLR_DETAILS(); \ + UnityPushDetail(UNITY_DETAIL_D1, (UNITY_DETAIL_VALUE_TYPE)(d1), __LINE__); \ + } while (0) +#define UNITY_SET_DETAILS(d1,d2) do { UNITY_CLR_DETAILS(); \ + UnityPushDetail(UNITY_DETAIL_D1, (UNITY_DETAIL_VALUE_TYPE)(d1), __LINE__); \ + UnityPushDetail(UNITY_DETAIL_D2, (UNITY_DETAIL_VALUE_TYPE)(d2), __LINE__); \ + } while (0) + +#else +/* just two hardcoded slots */ +#define UNITY_CLR_DETAILS() do { Unity.CurrentDetail1 = 0; Unity.CurrentDetail2 = 0; } while (0) +#define UNITY_SET_DETAIL(d1) do { Unity.CurrentDetail1 = (d1); Unity.CurrentDetail2 = 0; } while (0) +#define UNITY_SET_DETAILS(d1,d2) do { Unity.CurrentDetail1 = (d1); Unity.CurrentDetail2 = (d2); } while (0) +#endif #endif #ifdef UNITY_PRINT_TEST_CONTEXT @@ -1179,5 +1233,13 @@ int UnityTestMatches(void); #define UNITY_TEST_ASSERT_DOUBLE_IS_NOT_DETERMINATE(actual, line, message) UnityAssertDoubleSpecial((UNITY_DOUBLE)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_FLOAT_IS_NOT_DET) #endif +#if !defined(UNITY_EXCLUDE_DETAILS) && defined(UNITY_DETAIL_STACK_SIZE) +#define UNITY_DETAIL_PUSH(label, value) UnityPushDetail((UNITY_DETAIL_LABEL_TYPE)(label), (UNITY_DETAIL_VALUE_TYPE)(value), __LINE__) +#define UNITY_DETAIL_POP(label, value) UnityPopDetail((UNITY_DETAIL_LABEL_TYPE)(label), (UNITY_DETAIL_VALUE_TYPE)(value), __LINE__) +#else +#define UNITY_DETAIL_PUSH(label, value) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErrDetailStack) +#define UNITY_DETAIL_POP(label, value) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErrDetailStack) +#endif + /* End of UNITY_INTERNALS_H */ #endif From bfc785c6656c90f7d6a22396bd57adadf7d1cf48 Mon Sep 17 00:00:00 2001 From: ml-physec <206103694+ml-physec@users.noreply.github.com> Date: Wed, 16 Apr 2025 19:21:48 +0200 Subject: [PATCH 430/454] Add example --- examples/example_5/makefile | 63 +++++++++++++++++++ examples/example_5/readme.txt | 38 +++++++++++ examples/example_5/src/ProductionCode.c | 56 +++++++++++++++++ examples/example_5/src/ProductionCode.h | 16 +++++ examples/example_5/subprojects/unity.wrap | 3 + examples/example_5/test/TestProductionCode.c | 45 +++++++++++++ .../test_runners/TestProductionCode_Runner.c | 48 ++++++++++++++ examples/example_5/test/unity_detail_config.h | 18 ++++++ 8 files changed, 287 insertions(+) create mode 100644 examples/example_5/makefile create mode 100644 examples/example_5/readme.txt create mode 100644 examples/example_5/src/ProductionCode.c create mode 100644 examples/example_5/src/ProductionCode.h create mode 100644 examples/example_5/subprojects/unity.wrap create mode 100644 examples/example_5/test/TestProductionCode.c create mode 100644 examples/example_5/test/test_runners/TestProductionCode_Runner.c create mode 100644 examples/example_5/test/unity_detail_config.h diff --git a/examples/example_5/makefile b/examples/example_5/makefile new file mode 100644 index 00000000..82d39ad1 --- /dev/null +++ b/examples/example_5/makefile @@ -0,0 +1,63 @@ +# ========================================================================= +# Unity - A Test Framework for C +# ThrowTheSwitch.org +# Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams +# SPDX-License-Identifier: MIT +# ========================================================================= + +#We try to detect the OS we are running on, and adjust commands as needed +ifeq ($(OS),Windows_NT) + ifeq ($(shell uname -s),) # not in a bash-like shell + CLEANUP = del /F /Q + MKDIR = mkdir + else # in a bash-like shell, like msys + CLEANUP = rm -f + MKDIR = mkdir -p + endif + TARGET_EXTENSION=.exe +else + CLEANUP = rm -f + MKDIR = mkdir -p + TARGET_EXTENSION=.out +endif + +C_COMPILER=gcc +ifeq ($(shell uname -s), Darwin) +C_COMPILER=clang +endif + +UNITY_ROOT=../.. + +CFLAGS=-std=c89 +CFLAGS += -Wall +CFLAGS += -Wextra +CFLAGS += -Wpointer-arith +CFLAGS += -Wcast-align +CFLAGS += -Wwrite-strings +CFLAGS += -Wswitch-default +CFLAGS += -Wunreachable-code +CFLAGS += -Winit-self +CFLAGS += -Wmissing-field-initializers +CFLAGS += -Wno-unknown-pragmas +CFLAGS += -Wstrict-prototypes +CFLAGS += -Wundef +CFLAGS += -Wold-style-definition +#CFLAGS += -Wno-misleading-indentation + + +TARGET_BASE1=test1 +TARGET1 = $(TARGET_BASE1)$(TARGET_EXTENSION) +SRC_FILES1=$(UNITY_ROOT)/src/unity.c src/ProductionCode.c test/TestProductionCode.c test/test_runners/TestProductionCode_Runner.c +INC_DIRS=-Isrc -I$(UNITY_ROOT)/src +SYMBOLS=-include"test/unity_detail_config.h" -DUNIT_TESTING + +all: clean default + +default: $(SRC_FILES1) + $(C_COMPILER) $(CFLAGS) $(INC_DIRS) $(SYMBOLS) $(SRC_FILES1) -o $(TARGET1) + - ./$(TARGET1) +clean: + $(CLEANUP) $(TARGET1) $(TARGET2) + +ci: CFLAGS += -Werror +ci: default diff --git a/examples/example_5/readme.txt b/examples/example_5/readme.txt new file mode 100644 index 00000000..c84468eb --- /dev/null +++ b/examples/example_5/readme.txt @@ -0,0 +1,38 @@ +Example 5 +========= + +Demonstrate Details Stack usage to implement something similar to a stacktrace. +This allows locating the error source much faster in branching/iterating code. + +Build and run with Make +--- +Just run `make`. + +Output +--- +Below the output is annotated with source of the elements. + +``` +test/TestProductionCode.c:36:test_BitExtractor:FAIL: Expected 0 Was 1. During call BitExtractor. During call BitExtractor_down. Bit Position 6. Bit Mask 0x02. Unexpected bit value +``` + +| String | Source | +|-----------------------------|---------------------------------------------------------------------------| +| `test/TestProductionCode.c` | `Unity.TestFile` | +| `36` | `UNITY_TEST_ASSERT_EQUAL_INT` line | +| `test_BitExtractor` | `RUN_TEST` name | +| `FAIL` | `UnityStrFail` | +| `Expected 1 Was 0` | `UnityAssertEqualNumber` | +| `During call` | Detail 0, Label | +| `BitExtractor` | Detail 0, Value | +| `During call` | Detail 0, Label | +| `BitExtractor` | Detail 0, Value | +| `During call` | Detail 1, Label | +| `BitExtractor_down` | Detail 1, Value | +| `Bit Position` | Detail 2, Label (literal starts with #\x18, so value is printed as INT32) | +| `6` | Detail 2 Value | +| `Bit Mask` | Detail 2, Label (literal starts with #\x41, so value is printed as HEX8) | +| `0x02` | Detail 2 Value | +| `Unexpected bit value` | `UNITY_TEST_ASSERT_EQUAL_INT` message | + +While this example is a bit contrived, the source of the error can be clearly located to be within the `test_BitExtractor->BitExtractor->BitExtractor_down` diff --git a/examples/example_5/src/ProductionCode.c b/examples/example_5/src/ProductionCode.c new file mode 100644 index 00000000..c6e2b0cd --- /dev/null +++ b/examples/example_5/src/ProductionCode.c @@ -0,0 +1,56 @@ +/* ========================================================================= + Unity - A Test Framework for C + ThrowTheSwitch.org + Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams + SPDX-License-Identifier: MIT +========================================================================= */ + +#include "ProductionCode.h" + +#include + +#ifdef UNIT_TESTING +#include "unity.h" +#else +/* No-Op when not testing */ +#define UNITY_DETAIL_PUSH +#define UNITY_DETAIL_POP +#endif + +static void BitExtractor_up(uint8_t input, callback_t cb) +{ + int32_t pos; + UNITY_DETAIL_PUSH(UNITY_DETAIL_CALL, __FUNCTION__); + for(pos=0; pos<8; pos++) { + UNITY_DETAIL_PUSH(UNITY_DETAIL_BIT_POS, pos); + UNITY_DETAIL_PUSH(UNITY_DETAIL_BIT_MASK, 1<>pos); + cb(pos, !!(input & (0x80>>pos))); + UNITY_DETAIL_POP(UNITY_DETAIL_BIT_MASK, 0x80>>pos); + UNITY_DETAIL_POP(UNITY_DETAIL_BIT_POS, pos); + } + UNITY_DETAIL_POP(UNITY_DETAIL_CALL, __FUNCTION__); +} +void BitExtractor(bit_direction_t dir, uint8_t input, callback_t cb) +{ + UNITY_DETAIL_PUSH(UNITY_DETAIL_CALL, __FUNCTION__); + if(dir == BIT_DIRECTION_UP) { + BitExtractor_up(input, cb); + } else { + BitExtractor_down(input, cb); + } + UNITY_DETAIL_POP(UNITY_DETAIL_CALL, __FUNCTION__); +} diff --git a/examples/example_5/src/ProductionCode.h b/examples/example_5/src/ProductionCode.h new file mode 100644 index 00000000..67de534b --- /dev/null +++ b/examples/example_5/src/ProductionCode.h @@ -0,0 +1,16 @@ +/* ========================================================================= + Unity - A Test Framework for C + ThrowTheSwitch.org + Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams + SPDX-License-Identifier: MIT +========================================================================= */ + +#include + +typedef void callback_t(int position, int bit_value); +typedef enum { + BIT_DIRECTION_UP, + BIT_DIRECTION_DOWN, +} bit_direction_t; + +void BitExtractor(bit_direction_t dir, uint8_t input, callback_t cb); diff --git a/examples/example_5/subprojects/unity.wrap b/examples/example_5/subprojects/unity.wrap new file mode 100644 index 00000000..6df241bd --- /dev/null +++ b/examples/example_5/subprojects/unity.wrap @@ -0,0 +1,3 @@ +[wrap-git] +url = https://github.com/ThrowTheSwitch/Unity.git +revision = head diff --git a/examples/example_5/test/TestProductionCode.c b/examples/example_5/test/TestProductionCode.c new file mode 100644 index 00000000..38692ad5 --- /dev/null +++ b/examples/example_5/test/TestProductionCode.c @@ -0,0 +1,45 @@ +/* ========================================================================= + Unity - A Test Framework for C + ThrowTheSwitch.org + Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams + SPDX-License-Identifier: MIT +========================================================================= */ + +#include "ProductionCode.h" +#include "unity.h" + +const int* current_expected_bits = NULL; +UNITY_LINE_TYPE current_vector_line = 0; +typedef struct { + UNITY_LINE_TYPE line; + uint8_t value; + bit_direction_t dir; + int expected_bits[8]; +} test_vector_t; + +void setUp(void) +{ +} + +void tearDown(void) +{ +} + +static void be_bit_tester(int position, int value) { + UNITY_TEST_ASSERT_EQUAL_INT(current_expected_bits[position], value, current_vector_line, "Unexpected bit value"); +} + +void test_BitExtractor(void) +{ + const test_vector_t test_vectors[] = { + {__LINE__, 7, BIT_DIRECTION_UP, {1,1,1,0,0,0,0,0}}, + {__LINE__, 7, BIT_DIRECTION_DOWN, {0,0,0,0,0,1,0,1}}, + {0} + }; + const test_vector_t* tv; + for (tv = test_vectors; tv->line; tv++) { + current_vector_line = tv->line; + current_expected_bits = tv->expected_bits; + BitExtractor(tv->dir, tv->value, be_bit_tester); + } +} diff --git a/examples/example_5/test/test_runners/TestProductionCode_Runner.c b/examples/example_5/test/test_runners/TestProductionCode_Runner.c new file mode 100644 index 00000000..564eea31 --- /dev/null +++ b/examples/example_5/test/test_runners/TestProductionCode_Runner.c @@ -0,0 +1,48 @@ +/* AUTOGENERATED FILE. DO NOT EDIT. */ + +/*=======Test Runner Used To Run Each Test Below=====*/ +#define RUN_TEST(TestFunc, TestLineNum) \ +{ \ + Unity.CurrentTestName = #TestFunc; \ + Unity.CurrentTestLineNumber = TestLineNum; \ + Unity.NumberOfTests++; \ + if (TEST_PROTECT()) \ + { \ + setUp(); \ + TestFunc(); \ + } \ + if (TEST_PROTECT()) \ + { \ + tearDown(); \ + } \ + UnityConcludeTest(); \ +} + +/*=======Automagically Detected Files To Include=====*/ +#include "unity.h" +#include +#include +#include "ProductionCode.h" + +/*=======External Functions This Runner Calls=====*/ +extern void setUp(void); +extern void tearDown(void); +extern void test_BitExtractor(void); + + +/*=======Test Reset Option=====*/ +void resetTest(void); +void resetTest(void) +{ + tearDown(); + setUp(); +} + + +/*=======MAIN=====*/ +int main(void) +{ + UnityBegin("test/TestProductionCode.c"); + RUN_TEST(test_BitExtractor, 32); + return UNITY_END(); +} diff --git a/examples/example_5/test/unity_detail_config.h b/examples/example_5/test/unity_detail_config.h new file mode 100644 index 00000000..0305a66e --- /dev/null +++ b/examples/example_5/test/unity_detail_config.h @@ -0,0 +1,18 @@ +#define UNITY_DETAIL_STACK_SIZE 5 +#define LABEL_AS_INT32 "#\x18" /*UNITY_DISPLAY_STYLE_INT32 = 0x18 */ +#define LABEL_AS_HEX8 "#\x41" /* UNITY_DISPLAY_STYLE_HEX8 = 0x41 */ +#define UNITY_DETAIL_LABEL_NAMES { 0, \ + UNITY_DETAIL1_NAME, \ + UNITY_DETAIL2_NAME, \ + "During call", \ + LABEL_AS_INT32 "Bit Position", \ + LABEL_AS_HEX8 "Bit Mask", \ +} +typedef enum { + UNITY_DETAIL_NONE = 0, + UNITY_DETAIL_D1 = 1, + UNITY_DETAIL_D2 = 2, + UNITY_DETAIL_CALL, + UNITY_DETAIL_BIT_POS, + UNITY_DETAIL_BIT_MASK, +} UNITY_DETAIL_LABEL_T; From 69478185a3c909113d2ca032a3f5c14cd2f160ba Mon Sep 17 00:00:00 2001 From: yahyayozo Date: Sat, 19 Apr 2025 18:54:28 +0100 Subject: [PATCH 431/454] [Docs] Fix typos in docs files --- README.md | 2 +- docs/UnityConfigurationGuide.md | 2 +- docs/UnityHelperScriptsGuide.md | 24 ++++++++++++------------ src/unity.h | 2 +- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index 2ebf988e..6be02aa5 100644 --- a/README.md +++ b/README.md @@ -75,7 +75,7 @@ Like INT, there are variants for different sizes also. Compares two integers for equality and display errors as hexadecimal. Like the other integer comparisons, you can specify the size... -here the size will also effect how many nibbles are shown (for example, `HEX16` will show 4 nibbles). +here the size will also affect how many nibbles are shown (for example, `HEX16` will show 4 nibbles). TEST_ASSERT_EQUAL(expected, actual) diff --git a/docs/UnityConfigurationGuide.md b/docs/UnityConfigurationGuide.md index 0b735f7a..c2027fcc 100644 --- a/docs/UnityConfigurationGuide.md +++ b/docs/UnityConfigurationGuide.md @@ -33,7 +33,7 @@ In either case, you've got a couple choices for configuring these options: Unfortunately, it doesn't usually work well to just #define these things in the test itself. These defines need to take effect where ever unity.h is included. -This would be test test, the test runner (if you're generating one), and from unity.c when it's compiled. +This would be the test, the test runner (if you're generating one), and from unity.c when it's compiled. ## The Options diff --git a/docs/UnityHelperScriptsGuide.md b/docs/UnityHelperScriptsGuide.md index 9a8941c2..30841cf9 100644 --- a/docs/UnityHelperScriptsGuide.md +++ b/docs/UnityHelperScriptsGuide.md @@ -94,12 +94,12 @@ UnityTestRunnerGenerator.new.run(testfile, runner_name, options) ``` If you have multiple files to generate in a build script (such as a Rakefile), you might want to instantiate a generator object with your options and call it to generate each runner afterwards. -Like thus: +Like this: ```Ruby gen = UnityTestRunnerGenerator.new(options) test_files.each do |f| - gen.run(f, File.basename(f,'.c')+"Runner.c" + gen.run(f, File.basename(f,'.c')+"Runner.c") end ``` @@ -205,7 +205,7 @@ Few usage examples can be found in `/test/tests/test_unity_parameterized.c` file You should define `UNITY_SUPPORT_TEST_CASES` macro for tests success compiling, if you enable current option. -You can see list of supported macros list in the +You can see a list of supported macros in the [Parameterized tests provided macros](#parameterized-tests-provided-macros) section that follows. @@ -299,7 +299,7 @@ Unity provides support for few param tests generators, that can be combined with each other. You must define test function as usual C function with usual C arguments, and test generator will pass what you tell as a list of arguments. -Let's show how all of them works on the following test function definitions: +Let's show how all of them work on the following test function definitions: ```C /* Place your test generators here, usually one generator per one or few lines */ @@ -401,17 +401,17 @@ TEST_CASE(4, 6, 30) Test matix is an advanced generator. It single call can be converted to zero, one or few `TEST_CASE` equivalent commands. -That generator will create tests for all cobinations of the provided list. Each argument has to be given as a list of one or more elements in the format `[, , ..., , ]`. +That generator will create tests for all combinations of the provided list. Each argument has to be given as a list of one or more elements in the format `[, , ..., , ]`. -All parameters supported by the `TEST_CASE` is supported as arguments: +All parameters supported by the `TEST_CASE` are supported as arguments: - Numbers incl type specifiers e.g. `<1>`, `<1u>`, `<1l>`, `<2.3>`, or `<2.3f>` -- Strings incl string concatianion e.g. `<"string">`, or `<"partial" "string">` +- Strings incl string concatenation e.g. `<"string">`, or `<"partial" "string">` - Chars e.g. `<'c'>` - Enums e.g. `` - Elements of arrays e.g. `` -Let's use our `test_demoParamFunction` test for checking, what ranges -will be generated for our single `TEST_RANGE` row: +Let's use our `test_demoParamFunction` test for checking what ranges +will be generated for our single `TEST_MATRIX` row: ```C TEST_MATRIX([3, 4, 7], [10, 8, 2, 1],[30u, 20.0f]) @@ -450,11 +450,11 @@ As we can see: | Parameter | Format | Count of values | |---|---|---| -| `a` | `[3, 4, 7]` | 2 | +| `a` | `[3, 4, 7]` | 3 | | `b` | `[10, 8, 2, 1]` | 4 | | `c` | `[30u, 20.0f]` | 2 | -We totally have 2 * 4 * 2 = 16 equal test cases, that can be written as following: +We totally have 3 * 4 * 2 = 24 equal test cases, that can be written as following: ```C TEST_CASE(3, 10, 30u) @@ -516,7 +516,7 @@ ruby unity_test_summary.rb build/test/ ~/projects/myproject/ Or, if you're more of a Windows sort of person: ```Shell -ruby unity_test_summary.rb build\teat\ C:\projects\myproject\ +ruby unity_test_summary.rb build\test\ C:\projects\myproject\ ``` When configured correctly, you'll see a final summary, like so: diff --git a/src/unity.h b/src/unity.h index 9e2a97b7..3d176da9 100644 --- a/src/unity.h +++ b/src/unity.h @@ -45,7 +45,7 @@ int suiteTearDown(int num_failures); * Test Reset and Verify *-------------------------------------------------------*/ -/* These functions are intended to be called before during tests in order +/* These functions are intended to be called before or during tests in order * to support complex test loops, etc. Both are NOT built into Unity. Instead * the test runner generator will create them. resetTest will run teardown and * setup again, verifying any end-of-test needs between. verifyTest will only From 3fb2484313aa550c274203fe59457bf33f76596b Mon Sep 17 00:00:00 2001 From: Roland Stahn Date: Tue, 27 May 2025 14:33:15 +0200 Subject: [PATCH 432/454] Add IAR specific mapping for UNITY_NORETURN --- src/unity_internals.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/unity_internals.h b/src/unity_internals.h index 562f5b6d..97fc9b49 100644 --- a/src/unity_internals.h +++ b/src/unity_internals.h @@ -87,6 +87,13 @@ /* Since C23, the keyword _Noreturn has been replaced by the attribute noreturn, based on: */ /* https://en.cppreference.com/w/c/language/attributes/noreturn */ #define UNITY_NORETURN [[ noreturn ]] + #elif defined(__IAR_SYSTEMS_ICC__) && (__IAR_SYSTEMS_ICC__ >= 8) + /* For IAR compilers supporting at least C99 use the IAR specific '__noreturn' keyword */ + /* Based on tests and: */ + /* https://wwwfiles.iar.com/arm/webic/doc/EWARM_DevelopmentGuide.ENU.pdf */ + /* https://wwwfiles.iar.com/AVR/webic/doc/EWAVR_CompilerGuide.pdf */ + /* https://wwwfiles.iar.com/msp430/webic/doc/EW430_CompilerReference.pdf */ + #define UNITY_NORETURN __noreturn #endif #endif #ifndef UNITY_NORETURN From 5edda03c780eca28f3af3218eade98af14cf3c00 Mon Sep 17 00:00:00 2001 From: Roland Stahn Date: Wed, 28 May 2025 09:55:17 +0200 Subject: [PATCH 433/454] Cleanup definition of UNITY_COMPARISON_T in unity_internals.h remove unused values UNITY_WITHIN and UNITY_UNKNOWN update value UNITY_NOT_EQUAL --- src/unity_internals.h | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/unity_internals.h b/src/unity_internals.h index 97fc9b49..d12e3a7a 100644 --- a/src/unity_internals.h +++ b/src/unity_internals.h @@ -487,14 +487,12 @@ typedef enum typedef enum { - UNITY_WITHIN = 0x0, UNITY_EQUAL_TO = 0x1, UNITY_GREATER_THAN = 0x2, UNITY_GREATER_OR_EQUAL = 0x2 + UNITY_EQUAL_TO, UNITY_SMALLER_THAN = 0x4, UNITY_SMALLER_OR_EQUAL = 0x4 + UNITY_EQUAL_TO, - UNITY_NOT_EQUAL = 0x0, - UNITY_UNKNOWN + UNITY_NOT_EQUAL = 0x6 } UNITY_COMPARISON_T; #ifndef UNITY_EXCLUDE_FLOAT From 50c37200b9f5c422c332615b171e033d88d2b1e8 Mon Sep 17 00:00:00 2001 From: Roland Stahn Date: Wed, 28 May 2025 10:07:04 +0200 Subject: [PATCH 434/454] Fix definition of UNITY_NOT_EQUAL in unity_internals.h --- src/unity_internals.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/unity_internals.h b/src/unity_internals.h index d12e3a7a..f83fdc6e 100644 --- a/src/unity_internals.h +++ b/src/unity_internals.h @@ -492,7 +492,7 @@ typedef enum UNITY_GREATER_OR_EQUAL = 0x2 + UNITY_EQUAL_TO, UNITY_SMALLER_THAN = 0x4, UNITY_SMALLER_OR_EQUAL = 0x4 + UNITY_EQUAL_TO, - UNITY_NOT_EQUAL = 0x6 + UNITY_NOT_EQUAL = 0x8 } UNITY_COMPARISON_T; #ifndef UNITY_EXCLUDE_FLOAT From bcb0746186d752665b6d2debd960f94a84d090c7 Mon Sep 17 00:00:00 2001 From: Buccno Date: Thu, 5 Jun 2025 11:00:57 +0300 Subject: [PATCH 435/454] fix: Correct UINT max value handling --- src/unity.c | 41 ++++++++++++++++++++++++++++-------- src/unity_internals.h | 49 ++++++++++++++++++++++++------------------- 2 files changed, 60 insertions(+), 30 deletions(-) diff --git a/src/unity.c b/src/unity.c index 7fa2dc63..5f719aad 100644 --- a/src/unity.c +++ b/src/unity.c @@ -223,10 +223,6 @@ void UnityPrintNumberByStyle(const UNITY_INT number, const UNITY_DISPLAY_STYLE_T UnityPrintNumber(number); } } - else if ((style & UNITY_DISPLAY_RANGE_UINT) == UNITY_DISPLAY_RANGE_UINT) - { - UnityPrintNumberUnsigned((UNITY_UINT)number); - } else { UNITY_OUTPUT_CHAR('0'); @@ -235,6 +231,14 @@ void UnityPrintNumberByStyle(const UNITY_INT number, const UNITY_DISPLAY_STYLE_T } } +void UnityPrintUintNumberByStyle(const UNITY_UINT number, const UNITY_DISPLAY_STYLE_T style) +{ + if ((style & UNITY_DISPLAY_RANGE_UINT) == UNITY_DISPLAY_RANGE_UINT) + { + UnityPrintNumberUnsigned(number); + } +} + /*-----------------------------------------------*/ void UnityPrintNumber(const UNITY_INT number_to_print) { @@ -709,11 +713,11 @@ void UnityAssertBits(const UNITY_INT mask, } /*-----------------------------------------------*/ -void UnityAssertEqualNumber(const UNITY_INT expected, - const UNITY_INT actual, - const char* msg, - const UNITY_LINE_TYPE lineNumber, - const UNITY_DISPLAY_STYLE_T style) +void UnityAssertEqualIntNumber(const UNITY_INT expected, + const UNITY_INT actual, + const char* msg, + const UNITY_LINE_TYPE lineNumber, + const UNITY_DISPLAY_STYLE_T style) { RETURN_IF_FAIL_OR_IGNORE; @@ -729,6 +733,25 @@ void UnityAssertEqualNumber(const UNITY_INT expected, } } +void UnityAssertEqualUintNumber(const UNITY_UINT expected, + const UNITY_UINT actual, + const char* msg, + const UNITY_LINE_TYPE lineNumber, + const UNITY_DISPLAY_STYLE_T style) +{ + RETURN_IF_FAIL_OR_IGNORE; + + if (expected != actual) + { + UnityTestResultsFailBegin(lineNumber); + UnityPrint(UnityStrExpected); + UnityPrintUintNumberByStyle(expected, style); + UnityPrint(UnityStrWas); + UnityPrintUintNumberByStyle(actual, style); + UnityAddMsgIfSpecified(msg); + UNITY_FAIL_AND_BAIL; + } +} /*-----------------------------------------------*/ void UnityAssertGreaterOrLessOrEqualNumber(const UNITY_INT threshold, const UNITY_INT actual, diff --git a/src/unity_internals.h b/src/unity_internals.h index f83fdc6e..7311e544 100644 --- a/src/unity_internals.h +++ b/src/unity_internals.h @@ -596,6 +596,7 @@ void UnityPrintF(const UNITY_LINE_TYPE line, const char* format, ...); void UnityPrintLen(const char* string, const UNITY_UINT32 length); void UnityPrintMask(const UNITY_UINT mask, const UNITY_UINT number); void UnityPrintNumberByStyle(const UNITY_INT number, const UNITY_DISPLAY_STYLE_T style); +void UnityPrintUintNumberByStyle(const UNITY_UINT number, const UNITY_DISPLAY_STYLE_T style); void UnityPrintNumber(const UNITY_INT number_to_print); void UnityPrintNumberUnsigned(const UNITY_UINT number); void UnityPrintNumberHex(const UNITY_UINT number, const char nibbles_to_print); @@ -612,11 +613,17 @@ void UnityPrintFloat(const UNITY_DOUBLE input_number); * convention and will pull in file and line information * for you. */ -void UnityAssertEqualNumber(const UNITY_INT expected, - const UNITY_INT actual, - const char* msg, - const UNITY_LINE_TYPE lineNumber, - const UNITY_DISPLAY_STYLE_T style); +void UnityAssertEqualIntNumber(const UNITY_INT expected, + const UNITY_INT actual, + const char* msg, + const UNITY_LINE_TYPE lineNumber, + const UNITY_DISPLAY_STYLE_T style); + +void UnityAssertEqualUintNumber(const UNITY_UINT expected, + const UNITY_UINT actual, + const char* msg, + const UNITY_LINE_TYPE lineNumber, + const UNITY_DISPLAY_STYLE_T style); void UnityAssertGreaterOrLessOrEqualNumber(const UNITY_INT threshold, const UNITY_INT actual, @@ -899,18 +906,18 @@ int UnityTestMatches(void); #define UNITY_TEST_ASSERT_EMPTY(pointer, line, message) UNITY_TEST_ASSERT(((pointer[0]) == 0), (line), (message)) #define UNITY_TEST_ASSERT_NOT_EMPTY(pointer, line, message) UNITY_TEST_ASSERT(((pointer[0]) != 0), (line), (message)) -#define UNITY_TEST_ASSERT_EQUAL_INT(expected, actual, line, message) UnityAssertEqualNumber((UNITY_INT)(expected), (UNITY_INT)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT) -#define UNITY_TEST_ASSERT_EQUAL_INT8(expected, actual, line, message) UnityAssertEqualNumber((UNITY_INT)(UNITY_INT8 )(expected), (UNITY_INT)(UNITY_INT8 )(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT8) -#define UNITY_TEST_ASSERT_EQUAL_INT16(expected, actual, line, message) UnityAssertEqualNumber((UNITY_INT)(UNITY_INT16)(expected), (UNITY_INT)(UNITY_INT16)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT16) -#define UNITY_TEST_ASSERT_EQUAL_INT32(expected, actual, line, message) UnityAssertEqualNumber((UNITY_INT)(UNITY_INT32)(expected), (UNITY_INT)(UNITY_INT32)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT32) -#define UNITY_TEST_ASSERT_EQUAL_UINT(expected, actual, line, message) UnityAssertEqualNumber((UNITY_INT)(expected), (UNITY_INT)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT) -#define UNITY_TEST_ASSERT_EQUAL_UINT8(expected, actual, line, message) UnityAssertEqualNumber((UNITY_INT)(UNITY_UINT8 )(expected), (UNITY_INT)(UNITY_UINT8 )(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT8) -#define UNITY_TEST_ASSERT_EQUAL_UINT16(expected, actual, line, message) UnityAssertEqualNumber((UNITY_INT)(UNITY_UINT16)(expected), (UNITY_INT)(UNITY_UINT16)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT16) -#define UNITY_TEST_ASSERT_EQUAL_UINT32(expected, actual, line, message) UnityAssertEqualNumber((UNITY_INT)(UNITY_UINT32)(expected), (UNITY_INT)(UNITY_UINT32)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT32) -#define UNITY_TEST_ASSERT_EQUAL_HEX8(expected, actual, line, message) UnityAssertEqualNumber((UNITY_INT)(UNITY_INT8 )(expected), (UNITY_INT)(UNITY_INT8 )(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX8) -#define UNITY_TEST_ASSERT_EQUAL_HEX16(expected, actual, line, message) UnityAssertEqualNumber((UNITY_INT)(UNITY_INT16)(expected), (UNITY_INT)(UNITY_INT16)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX16) -#define UNITY_TEST_ASSERT_EQUAL_HEX32(expected, actual, line, message) UnityAssertEqualNumber((UNITY_INT)(UNITY_INT32)(expected), (UNITY_INT)(UNITY_INT32)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX32) -#define UNITY_TEST_ASSERT_EQUAL_CHAR(expected, actual, line, message) UnityAssertEqualNumber((UNITY_INT)(UNITY_INT8 )(expected), (UNITY_INT)(UNITY_INT8 )(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_CHAR) +#define UNITY_TEST_ASSERT_EQUAL_INT(expected, actual, line, message) UnityAssertEqualIntNumber((UNITY_INT)(expected), (UNITY_INT)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT) +#define UNITY_TEST_ASSERT_EQUAL_INT8(expected, actual, line, message) UnityAssertEqualIntNumber((UNITY_INT)(UNITY_INT8 )(expected), (UNITY_INT)(UNITY_INT8 )(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT8) +#define UNITY_TEST_ASSERT_EQUAL_INT16(expected, actual, line, message) UnityAssertEqualIntNumber((UNITY_INT)(UNITY_INT16)(expected), (UNITY_INT)(UNITY_INT16)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT16) +#define UNITY_TEST_ASSERT_EQUAL_INT32(expected, actual, line, message) UnityAssertEqualIntNumber((UNITY_INT)(UNITY_INT32)(expected), (UNITY_INT)(UNITY_INT32)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT32) +#define UNITY_TEST_ASSERT_EQUAL_UINT(expected, actual, line, message) UnityAssertEqualUintNumber((UNITY_UINT)(expected), (UNITY_UINT)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT) +#define UNITY_TEST_ASSERT_EQUAL_UINT8(expected, actual, line, message) UnityAssertEqualUintNumber((UNITY_UINT)(UNITY_UINT8 )(expected), (UNITY_UINT)(UNITY_UINT8 )(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT8) +#define UNITY_TEST_ASSERT_EQUAL_UINT16(expected, actual, line, message) UnityAssertEqualUintNumber((UNITY_UINT)(UNITY_UINT16)(expected), (UNITY_UINT)(UNITY_UINT16)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT16) +#define UNITY_TEST_ASSERT_EQUAL_UINT32(expected, actual, line, message) UnityAssertEqualUintNumber((UNITY_UINT)(UNITY_UINT32)(expected), (UNITY_UINT)(UNITY_UINT32)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT32) +#define UNITY_TEST_ASSERT_EQUAL_HEX8(expected, actual, line, message) UnityAssertEqualIntNumber((UNITY_INT)(UNITY_INT8 )(expected), (UNITY_INT)(UNITY_INT8 )(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX8) +#define UNITY_TEST_ASSERT_EQUAL_HEX16(expected, actual, line, message) UnityAssertEqualIntNumber((UNITY_INT)(UNITY_INT16)(expected), (UNITY_INT)(UNITY_INT16)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX16) +#define UNITY_TEST_ASSERT_EQUAL_HEX32(expected, actual, line, message) UnityAssertEqualIntNumber((UNITY_INT)(UNITY_INT32)(expected), (UNITY_INT)(UNITY_INT32)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX32) +#define UNITY_TEST_ASSERT_EQUAL_CHAR(expected, actual, line, message) UnityAssertEqualIntNumber((UNITY_INT)(UNITY_INT8 )(expected), (UNITY_INT)(UNITY_INT8 )(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_CHAR) #define UNITY_TEST_ASSERT_BITS(mask, expected, actual, line, message) UnityAssertBits((UNITY_INT)(mask), (UNITY_INT)(expected), (UNITY_INT)(actual), (message), (UNITY_LINE_TYPE)(line)) #define UNITY_TEST_ASSERT_NOT_EQUAL_INT(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(threshold), (UNITY_INT)(actual), UNITY_NOT_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT) @@ -1005,7 +1012,7 @@ int UnityTestMatches(void); #define UNITY_TEST_ASSERT_CHAR_ARRAY_WITHIN(delta, expected, actual, num_elements, line, message) UnityAssertNumbersArrayWithin((UNITY_UINT8 )(delta), (UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), ((UNITY_UINT32)(num_elements)), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_CHAR, UNITY_ARRAY_TO_ARRAY) -#define UNITY_TEST_ASSERT_EQUAL_PTR(expected, actual, line, message) UnityAssertEqualNumber((UNITY_PTR_TO_INT)(expected), (UNITY_PTR_TO_INT)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_POINTER) +#define UNITY_TEST_ASSERT_EQUAL_PTR(expected, actual, line, message) UnityAssertEqualIntNumber((UNITY_PTR_TO_INT)(expected), (UNITY_PTR_TO_INT)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_POINTER) #define UNITY_TEST_ASSERT_EQUAL_STRING(expected, actual, line, message) UnityAssertEqualString((const char*)(expected), (const char*)(actual), (message), (UNITY_LINE_TYPE)(line)) #define UNITY_TEST_ASSERT_EQUAL_STRING_LEN(expected, actual, len, line, message) UnityAssertEqualStringLen((const char*)(expected), (const char*)(actual), (UNITY_UINT32)(len), (message), (UNITY_LINE_TYPE)(line)) #define UNITY_TEST_ASSERT_EQUAL_MEMORY(expected, actual, len, line, message) UnityAssertEqualMemory((UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(len), 1, (message), (UNITY_LINE_TYPE)(line), UNITY_ARRAY_TO_ARRAY) @@ -1043,9 +1050,9 @@ int UnityTestMatches(void); #define UNITY_TEST_ASSERT_EACH_EQUAL_CHAR(expected, actual, num_elements, line, message) UnityAssertEqualIntArray(UnityNumToPtr((UNITY_INT)(UNITY_INT8 )(expected), 1), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_CHAR, UNITY_ARRAY_TO_VAL) #ifdef UNITY_SUPPORT_64 -#define UNITY_TEST_ASSERT_EQUAL_INT64(expected, actual, line, message) UnityAssertEqualNumber((UNITY_INT)(expected), (UNITY_INT)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT64) -#define UNITY_TEST_ASSERT_EQUAL_UINT64(expected, actual, line, message) UnityAssertEqualNumber((UNITY_INT)(expected), (UNITY_INT)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT64) -#define UNITY_TEST_ASSERT_EQUAL_HEX64(expected, actual, line, message) UnityAssertEqualNumber((UNITY_INT)(expected), (UNITY_INT)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX64) +#define UNITY_TEST_ASSERT_EQUAL_INT64(expected, actual, line, message) UnityAssertEqualIntNumber((UNITY_INT)(expected), (UNITY_INT)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT64) +#define UNITY_TEST_ASSERT_EQUAL_UINT64(expected, actual, line, message) UnityAssertEqualIntNumber((UNITY_INT)(expected), (UNITY_INT)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT64) +#define UNITY_TEST_ASSERT_EQUAL_HEX64(expected, actual, line, message) UnityAssertEqualIntNumber((UNITY_INT)(expected), (UNITY_INT)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX64) #define UNITY_TEST_ASSERT_EQUAL_INT64_ARRAY(expected, actual, num_elements, line, message) UnityAssertEqualIntArray((UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT64, UNITY_ARRAY_TO_ARRAY) #define UNITY_TEST_ASSERT_EQUAL_UINT64_ARRAY(expected, actual, num_elements, line, message) UnityAssertEqualIntArray((UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT64, UNITY_ARRAY_TO_ARRAY) #define UNITY_TEST_ASSERT_EQUAL_HEX64_ARRAY(expected, actual, num_elements, line, message) UnityAssertEqualIntArray((UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX64, UNITY_ARRAY_TO_ARRAY) From ac52c4182a8c8105a3cddd6593423701aea879d7 Mon Sep 17 00:00:00 2001 From: burakutkuc Date: Fri, 13 Jun 2025 16:25:22 +0300 Subject: [PATCH 436/454] fix: Fail when values are equal but equality is not allowed. Handled HEX asserts as unsigned; applied the same unsigned logic across all integer-based comparisons. --- src/unity.c | 160 +++++++++++++++---------- src/unity_internals.h | 264 ++++++++++++++++++++++-------------------- 2 files changed, 239 insertions(+), 185 deletions(-) diff --git a/src/unity.c b/src/unity.c index 5f719aad..fc6cd710 100644 --- a/src/unity.c +++ b/src/unity.c @@ -185,7 +185,7 @@ void UnityPrintLen(const char* string, const UNITY_UINT32 length) } /*-----------------------------------------------*/ -void UnityPrintNumberByStyle(const UNITY_INT number, const UNITY_DISPLAY_STYLE_T style) +void UnityPrintIntNumberByStyle(const UNITY_INT number, const UNITY_DISPLAY_STYLE_T style) { if ((style & UNITY_DISPLAY_RANGE_INT) == UNITY_DISPLAY_RANGE_INT) { @@ -223,12 +223,6 @@ void UnityPrintNumberByStyle(const UNITY_INT number, const UNITY_DISPLAY_STYLE_T UnityPrintNumber(number); } } - else - { - UNITY_OUTPUT_CHAR('0'); - UNITY_OUTPUT_CHAR('x'); - UnityPrintNumberHex((UNITY_UINT)number, (char)((style & 0xF) * 2)); - } } void UnityPrintUintNumberByStyle(const UNITY_UINT number, const UNITY_DISPLAY_STYLE_T style) @@ -237,6 +231,12 @@ void UnityPrintUintNumberByStyle(const UNITY_UINT number, const UNITY_DISPLAY_ST { UnityPrintNumberUnsigned(number); } + else + { + UNITY_OUTPUT_CHAR('0'); + UNITY_OUTPUT_CHAR('x'); + UnityPrintNumberHex((UNITY_UINT)number, (char)((style & 0xF) * 2)); + } } /*-----------------------------------------------*/ @@ -725,9 +725,9 @@ void UnityAssertEqualIntNumber(const UNITY_INT expected, { UnityTestResultsFailBegin(lineNumber); UnityPrint(UnityStrExpected); - UnityPrintNumberByStyle(expected, style); + UnityPrintIntNumberByStyle(expected, style); UnityPrint(UnityStrWas); - UnityPrintNumberByStyle(actual, style); + UnityPrintIntNumberByStyle(actual, style); UnityAddMsgIfSpecified(msg); UNITY_FAIL_AND_BAIL; } @@ -753,40 +753,62 @@ void UnityAssertEqualUintNumber(const UNITY_UINT expected, } } /*-----------------------------------------------*/ -void UnityAssertGreaterOrLessOrEqualNumber(const UNITY_INT threshold, - const UNITY_INT actual, - const UNITY_COMPARISON_T compare, - const char *msg, - const UNITY_LINE_TYPE lineNumber, - const UNITY_DISPLAY_STYLE_T style) +void UnityAssertIntGreaterOrLessOrEqualNumber(const UNITY_INT threshold, + const UNITY_INT actual, + const UNITY_COMPARISON_T compare, + const char *msg, + const UNITY_LINE_TYPE lineNumber, + const UNITY_DISPLAY_STYLE_T style) { int failed = 0; RETURN_IF_FAIL_OR_IGNORE; - if ((threshold == actual) && (compare & UNITY_EQUAL_TO)) { return; } - if ((threshold == actual)) { failed = 1; } + if ((threshold == actual) && !(compare & UNITY_EQUAL_TO)) { failed = 1; } - if ((style & UNITY_DISPLAY_RANGE_INT) == UNITY_DISPLAY_RANGE_INT) - { - if ((actual > threshold) && (compare & UNITY_SMALLER_THAN)) { failed = 1; } - if ((actual < threshold) && (compare & UNITY_GREATER_THAN)) { failed = 1; } - } - else /* UINT or HEX */ + if ((actual > threshold) && (compare & UNITY_SMALLER_THAN)) { failed = 1; } + if ((actual < threshold) && (compare & UNITY_GREATER_THAN)) { failed = 1; } + + if (failed) { - if (((UNITY_UINT)actual > (UNITY_UINT)threshold) && (compare & UNITY_SMALLER_THAN)) { failed = 1; } - if (((UNITY_UINT)actual < (UNITY_UINT)threshold) && (compare & UNITY_GREATER_THAN)) { failed = 1; } + UnityTestResultsFailBegin(lineNumber); + UnityPrint(UnityStrExpected); + UnityPrintIntNumberByStyle(actual, style); + if (compare & UNITY_GREATER_THAN) { UnityPrint(UnityStrGt); } + if (compare & UNITY_SMALLER_THAN) { UnityPrint(UnityStrLt); } + if (compare & UNITY_EQUAL_TO) { UnityPrint(UnityStrOrEqual); } + if (compare == UNITY_NOT_EQUAL) { UnityPrint(UnityStrNotEqual); } + UnityPrintIntNumberByStyle(threshold, style); + UnityAddMsgIfSpecified(msg); + UNITY_FAIL_AND_BAIL; } +} + +void UnityAssertUintGreaterOrLessOrEqualNumber(const UNITY_UINT threshold, + const UNITY_UINT actual, + const UNITY_COMPARISON_T compare, + const char *msg, + const UNITY_LINE_TYPE lineNumber, + const UNITY_DISPLAY_STYLE_T style) +{ + int failed = 0; + RETURN_IF_FAIL_OR_IGNORE; + + if ((threshold == actual) && !(compare & UNITY_EQUAL_TO)) { failed = 1; } + + /* UINT or HEX */ + if ((actual > threshold) && (compare & UNITY_SMALLER_THAN)) { failed = 1; } + if ((actual < threshold) && (compare & UNITY_GREATER_THAN)) { failed = 1; } if (failed) { UnityTestResultsFailBegin(lineNumber); UnityPrint(UnityStrExpected); - UnityPrintNumberByStyle(actual, style); + UnityPrintUintNumberByStyle(actual, style); if (compare & UNITY_GREATER_THAN) { UnityPrint(UnityStrGt); } if (compare & UNITY_SMALLER_THAN) { UnityPrint(UnityStrLt); } if (compare & UNITY_EQUAL_TO) { UnityPrint(UnityStrOrEqual); } if (compare == UNITY_NOT_EQUAL) { UnityPrint(UnityStrNotEqual); } - UnityPrintNumberByStyle(threshold, style); + UnityPrintUintNumberByStyle(threshold, style); UnityAddMsgIfSpecified(msg); UNITY_FAIL_AND_BAIL; } @@ -900,9 +922,9 @@ void UnityAssertEqualIntArray(UNITY_INTERNAL_PTR expected, UnityPrint(UnityStrElement); UnityPrintNumberUnsigned(num_elements - elements - 1); UnityPrint(UnityStrExpected); - UnityPrintNumberByStyle(expect_val, style); + UnityPrintIntNumberByStyle(expect_val, style); UnityPrint(UnityStrWas); - UnityPrintNumberByStyle(actual_val, style); + UnityPrintIntNumberByStyle(actual_val, style); UnityAddMsgIfSpecified(msg); UNITY_FAIL_AND_BAIL; } @@ -1400,47 +1422,65 @@ void UnityAssertDoubleSpecial(const UNITY_DOUBLE actual, #endif /* not UNITY_EXCLUDE_DOUBLE */ /*-----------------------------------------------*/ -void UnityAssertNumbersWithin(const UNITY_UINT delta, - const UNITY_INT expected, - const UNITY_INT actual, - const char* msg, - const UNITY_LINE_TYPE lineNumber, - const UNITY_DISPLAY_STYLE_T style) +void UnityAssertIntNumbersWithin(const UNITY_UINT delta, + const UNITY_INT expected, + const UNITY_INT actual, + const char* msg, + const UNITY_LINE_TYPE lineNumber, + const UNITY_DISPLAY_STYLE_T style) { RETURN_IF_FAIL_OR_IGNORE; - if ((style & UNITY_DISPLAY_RANGE_INT) == UNITY_DISPLAY_RANGE_INT) + if (actual > expected) { - if (actual > expected) - { - Unity.CurrentTestFailed = (((UNITY_UINT)actual - (UNITY_UINT)expected) > delta); - } - else - { - Unity.CurrentTestFailed = (((UNITY_UINT)expected - (UNITY_UINT)actual) > delta); - } + Unity.CurrentTestFailed = (((UNITY_UINT)actual - (UNITY_UINT)expected) > delta); } else { - if ((UNITY_UINT)actual > (UNITY_UINT)expected) - { - Unity.CurrentTestFailed = (((UNITY_UINT)actual - (UNITY_UINT)expected) > delta); - } - else - { - Unity.CurrentTestFailed = (((UNITY_UINT)expected - (UNITY_UINT)actual) > delta); - } + Unity.CurrentTestFailed = (((UNITY_UINT)expected - (UNITY_UINT)actual) > delta); + } + + if (Unity.CurrentTestFailed) + { + UnityTestResultsFailBegin(lineNumber); + UnityPrint(UnityStrDelta); + UnityPrintIntNumberByStyle((UNITY_INT)delta, style); + UnityPrint(UnityStrExpected); + UnityPrintIntNumberByStyle(expected, style); + UnityPrint(UnityStrWas); + UnityPrintIntNumberByStyle(actual, style); + UnityAddMsgIfSpecified(msg); + UNITY_FAIL_AND_BAIL; + } +} + +void UnityAssertUintNumbersWithin(const UNITY_UINT delta, + const UNITY_UINT expected, + const UNITY_UINT actual, + const char* msg, + const UNITY_LINE_TYPE lineNumber, + const UNITY_DISPLAY_STYLE_T style) +{ + RETURN_IF_FAIL_OR_IGNORE; + + if (actual > expected) + { + Unity.CurrentTestFailed = ((actual - expected) > delta); + } + else + { + Unity.CurrentTestFailed = ((expected - actual) > delta); } if (Unity.CurrentTestFailed) { UnityTestResultsFailBegin(lineNumber); UnityPrint(UnityStrDelta); - UnityPrintNumberByStyle((UNITY_INT)delta, style); + UnityPrintUintNumberByStyle(delta, style); UnityPrint(UnityStrExpected); - UnityPrintNumberByStyle(expected, style); + UnityPrintUintNumberByStyle(expected, style); UnityPrint(UnityStrWas); - UnityPrintNumberByStyle(actual, style); + UnityPrintUintNumberByStyle(actual, style); UnityAddMsgIfSpecified(msg); UNITY_FAIL_AND_BAIL; } @@ -1591,13 +1631,13 @@ void UnityAssertNumbersArrayWithin(const UNITY_UINT delta, } UnityTestResultsFailBegin(lineNumber); UnityPrint(UnityStrDelta); - UnityPrintNumberByStyle((UNITY_INT)delta, style); + UnityPrintIntNumberByStyle((UNITY_INT)delta, style); UnityPrint(UnityStrElement); UnityPrintNumberUnsigned(num_elements - elements - 1); UnityPrint(UnityStrExpected); - UnityPrintNumberByStyle(expect_val, style); + UnityPrintIntNumberByStyle(expect_val, style); UnityPrint(UnityStrWas); - UnityPrintNumberByStyle(actual_val, style); + UnityPrintIntNumberByStyle(actual_val, style); UnityAddMsgIfSpecified(msg); UNITY_FAIL_AND_BAIL; } @@ -1828,9 +1868,9 @@ void UnityAssertEqualMemory(UNITY_INTERNAL_PTR expected, UnityPrint(UnityStrByte); UnityPrintNumberUnsigned(length - bytes - 1); UnityPrint(UnityStrExpected); - UnityPrintNumberByStyle(*ptr_exp, UNITY_DISPLAY_STYLE_HEX8); + UnityPrintIntNumberByStyle(*ptr_exp, UNITY_DISPLAY_STYLE_HEX8); UnityPrint(UnityStrWas); - UnityPrintNumberByStyle(*ptr_act, UNITY_DISPLAY_STYLE_HEX8); + UnityPrintIntNumberByStyle(*ptr_act, UNITY_DISPLAY_STYLE_HEX8); UnityAddMsgIfSpecified(msg); UNITY_FAIL_AND_BAIL; } diff --git a/src/unity_internals.h b/src/unity_internals.h index 7311e544..19766982 100644 --- a/src/unity_internals.h +++ b/src/unity_internals.h @@ -595,7 +595,7 @@ void UnityPrintF(const UNITY_LINE_TYPE line, const char* format, ...); void UnityPrintLen(const char* string, const UNITY_UINT32 length); void UnityPrintMask(const UNITY_UINT mask, const UNITY_UINT number); -void UnityPrintNumberByStyle(const UNITY_INT number, const UNITY_DISPLAY_STYLE_T style); +void UnityPrintIntNumberByStyle(const UNITY_INT number, const UNITY_DISPLAY_STYLE_T style); void UnityPrintUintNumberByStyle(const UNITY_UINT number, const UNITY_DISPLAY_STYLE_T style); void UnityPrintNumber(const UNITY_INT number_to_print); void UnityPrintNumberUnsigned(const UNITY_UINT number); @@ -625,12 +625,19 @@ void UnityAssertEqualUintNumber(const UNITY_UINT expected, const UNITY_LINE_TYPE lineNumber, const UNITY_DISPLAY_STYLE_T style); -void UnityAssertGreaterOrLessOrEqualNumber(const UNITY_INT threshold, - const UNITY_INT actual, - const UNITY_COMPARISON_T compare, - const char *msg, - const UNITY_LINE_TYPE lineNumber, - const UNITY_DISPLAY_STYLE_T style); +void UnityAssertIntGreaterOrLessOrEqualNumber(const UNITY_INT threshold, + const UNITY_INT actual, + const UNITY_COMPARISON_T compare, + const char *msg, + const UNITY_LINE_TYPE lineNumber, + const UNITY_DISPLAY_STYLE_T style); + +void UnityAssertUintGreaterOrLessOrEqualNumber(const UNITY_UINT threshold, + const UNITY_UINT actual, + const UNITY_COMPARISON_T compare, + const char *msg, + const UNITY_LINE_TYPE lineNumber, + const UNITY_DISPLAY_STYLE_T style); void UnityAssertEqualIntArray(UNITY_INTERNAL_PTR expected, UNITY_INTERNAL_PTR actual, @@ -672,12 +679,19 @@ void UnityAssertEqualMemory( UNITY_INTERNAL_PTR expected, const UNITY_LINE_TYPE lineNumber, const UNITY_FLAGS_T flags); -void UnityAssertNumbersWithin(const UNITY_UINT delta, - const UNITY_INT expected, - const UNITY_INT actual, - const char* msg, - const UNITY_LINE_TYPE lineNumber, - const UNITY_DISPLAY_STYLE_T style); +void UnityAssertIntNumbersWithin(const UNITY_UINT delta, + const UNITY_INT expected, + const UNITY_INT actual, + const char* msg, + const UNITY_LINE_TYPE lineNumber, + const UNITY_DISPLAY_STYLE_T style); + +void UnityAssertUintNumbersWithin(const UNITY_UINT delta, + const UNITY_UINT expected, + const UNITY_UINT actual, + const char* msg, + const UNITY_LINE_TYPE lineNumber, + const UNITY_DISPLAY_STYLE_T style); void UnityAssertNumbersArrayWithin(const UNITY_UINT delta, UNITY_INTERNAL_PTR expected, @@ -911,105 +925,105 @@ int UnityTestMatches(void); #define UNITY_TEST_ASSERT_EQUAL_INT16(expected, actual, line, message) UnityAssertEqualIntNumber((UNITY_INT)(UNITY_INT16)(expected), (UNITY_INT)(UNITY_INT16)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT16) #define UNITY_TEST_ASSERT_EQUAL_INT32(expected, actual, line, message) UnityAssertEqualIntNumber((UNITY_INT)(UNITY_INT32)(expected), (UNITY_INT)(UNITY_INT32)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT32) #define UNITY_TEST_ASSERT_EQUAL_UINT(expected, actual, line, message) UnityAssertEqualUintNumber((UNITY_UINT)(expected), (UNITY_UINT)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT) -#define UNITY_TEST_ASSERT_EQUAL_UINT8(expected, actual, line, message) UnityAssertEqualUintNumber((UNITY_UINT)(UNITY_UINT8 )(expected), (UNITY_UINT)(UNITY_UINT8 )(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT8) +#define UNITY_TEST_ASSERT_EQUAL_UINT8(expected, actual, line, message) UnityAssertEqualUintNumber((UNITY_UINT)(UNITY_UINT8)(expected), (UNITY_UINT)(UNITY_UINT8)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT8) #define UNITY_TEST_ASSERT_EQUAL_UINT16(expected, actual, line, message) UnityAssertEqualUintNumber((UNITY_UINT)(UNITY_UINT16)(expected), (UNITY_UINT)(UNITY_UINT16)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT16) #define UNITY_TEST_ASSERT_EQUAL_UINT32(expected, actual, line, message) UnityAssertEqualUintNumber((UNITY_UINT)(UNITY_UINT32)(expected), (UNITY_UINT)(UNITY_UINT32)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT32) -#define UNITY_TEST_ASSERT_EQUAL_HEX8(expected, actual, line, message) UnityAssertEqualIntNumber((UNITY_INT)(UNITY_INT8 )(expected), (UNITY_INT)(UNITY_INT8 )(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX8) -#define UNITY_TEST_ASSERT_EQUAL_HEX16(expected, actual, line, message) UnityAssertEqualIntNumber((UNITY_INT)(UNITY_INT16)(expected), (UNITY_INT)(UNITY_INT16)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX16) -#define UNITY_TEST_ASSERT_EQUAL_HEX32(expected, actual, line, message) UnityAssertEqualIntNumber((UNITY_INT)(UNITY_INT32)(expected), (UNITY_INT)(UNITY_INT32)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX32) +#define UNITY_TEST_ASSERT_EQUAL_HEX8(expected, actual, line, message) UnityAssertEqualUintNumber((UNITY_UINT)(UNITY_UINT8)(expected), (UNITY_UINT)(UNITY_UINT8)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX8) +#define UNITY_TEST_ASSERT_EQUAL_HEX16(expected, actual, line, message) UnityAssertEqualUintNumber((UNITY_UINT)(UNITY_UINT16)(expected), (UNITY_UINT)(UNITY_UINT16)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX16) +#define UNITY_TEST_ASSERT_EQUAL_HEX32(expected, actual, line, message) UnityAssertEqualUintNumber((UNITY_UINT)(UNITY_UINT32)(expected), (UNITY_UINT)(UNITY_UINT32)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX32) #define UNITY_TEST_ASSERT_EQUAL_CHAR(expected, actual, line, message) UnityAssertEqualIntNumber((UNITY_INT)(UNITY_INT8 )(expected), (UNITY_INT)(UNITY_INT8 )(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_CHAR) #define UNITY_TEST_ASSERT_BITS(mask, expected, actual, line, message) UnityAssertBits((UNITY_INT)(mask), (UNITY_INT)(expected), (UNITY_INT)(actual), (message), (UNITY_LINE_TYPE)(line)) -#define UNITY_TEST_ASSERT_NOT_EQUAL_INT(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(threshold), (UNITY_INT)(actual), UNITY_NOT_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT) -#define UNITY_TEST_ASSERT_NOT_EQUAL_INT8(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_INT8 )(threshold), (UNITY_INT)(UNITY_INT8 )(actual), UNITY_NOT_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT8) -#define UNITY_TEST_ASSERT_NOT_EQUAL_INT16(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_INT16)(threshold), (UNITY_INT)(UNITY_INT16)(actual), UNITY_NOT_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT16) -#define UNITY_TEST_ASSERT_NOT_EQUAL_INT32(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_INT32)(threshold), (UNITY_INT)(UNITY_INT32)(actual), UNITY_NOT_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT32) -#define UNITY_TEST_ASSERT_NOT_EQUAL_UINT(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(threshold), (UNITY_INT)(actual), UNITY_NOT_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT) -#define UNITY_TEST_ASSERT_NOT_EQUAL_UINT8(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_UINT8 )(threshold), (UNITY_INT)(UNITY_UINT8 )(actual), UNITY_NOT_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT8) -#define UNITY_TEST_ASSERT_NOT_EQUAL_UINT16(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_UINT16)(threshold), (UNITY_INT)(UNITY_UINT16)(actual), UNITY_NOT_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT16) -#define UNITY_TEST_ASSERT_NOT_EQUAL_UINT32(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_UINT32)(threshold), (UNITY_INT)(UNITY_UINT32)(actual), UNITY_NOT_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT32) -#define UNITY_TEST_ASSERT_NOT_EQUAL_HEX8(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_UINT8 )(threshold), (UNITY_INT)(UNITY_UINT8 )(actual), UNITY_NOT_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX8) -#define UNITY_TEST_ASSERT_NOT_EQUAL_HEX16(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_UINT16)(threshold), (UNITY_INT)(UNITY_UINT16)(actual), UNITY_NOT_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX16) -#define UNITY_TEST_ASSERT_NOT_EQUAL_HEX32(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_UINT32)(threshold), (UNITY_INT)(UNITY_UINT32)(actual), UNITY_NOT_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX32) -#define UNITY_TEST_ASSERT_NOT_EQUAL_CHAR(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_INT8 )(threshold), (UNITY_INT)(UNITY_INT8 )(actual), UNITY_NOT_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_CHAR) - -#define UNITY_TEST_ASSERT_GREATER_THAN_INT(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(threshold), (UNITY_INT)(actual), UNITY_GREATER_THAN, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT) -#define UNITY_TEST_ASSERT_GREATER_THAN_INT8(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_INT8 )(threshold), (UNITY_INT)(UNITY_INT8 )(actual), UNITY_GREATER_THAN, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT8) -#define UNITY_TEST_ASSERT_GREATER_THAN_INT16(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_INT16)(threshold), (UNITY_INT)(UNITY_INT16)(actual), UNITY_GREATER_THAN, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT16) -#define UNITY_TEST_ASSERT_GREATER_THAN_INT32(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_INT32)(threshold), (UNITY_INT)(UNITY_INT32)(actual), UNITY_GREATER_THAN, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT32) -#define UNITY_TEST_ASSERT_GREATER_THAN_UINT(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(threshold), (UNITY_INT)(actual), UNITY_GREATER_THAN, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT) -#define UNITY_TEST_ASSERT_GREATER_THAN_UINT8(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_UINT8 )(threshold), (UNITY_INT)(UNITY_UINT8 )(actual), UNITY_GREATER_THAN, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT8) -#define UNITY_TEST_ASSERT_GREATER_THAN_UINT16(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_UINT16)(threshold), (UNITY_INT)(UNITY_UINT16)(actual), UNITY_GREATER_THAN, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT16) -#define UNITY_TEST_ASSERT_GREATER_THAN_UINT32(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_UINT32)(threshold), (UNITY_INT)(UNITY_UINT32)(actual), UNITY_GREATER_THAN, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT32) -#define UNITY_TEST_ASSERT_GREATER_THAN_HEX8(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_UINT8 )(threshold), (UNITY_INT)(UNITY_UINT8 )(actual), UNITY_GREATER_THAN, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX8) -#define UNITY_TEST_ASSERT_GREATER_THAN_HEX16(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_UINT16)(threshold), (UNITY_INT)(UNITY_UINT16)(actual), UNITY_GREATER_THAN, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX16) -#define UNITY_TEST_ASSERT_GREATER_THAN_HEX32(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_UINT32)(threshold), (UNITY_INT)(UNITY_UINT32)(actual), UNITY_GREATER_THAN, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX32) -#define UNITY_TEST_ASSERT_GREATER_THAN_CHAR(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_INT8 )(threshold), (UNITY_INT)(UNITY_INT8 )(actual), UNITY_GREATER_THAN, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_CHAR) - -#define UNITY_TEST_ASSERT_SMALLER_THAN_INT(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(threshold), (UNITY_INT)(actual), UNITY_SMALLER_THAN, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT) -#define UNITY_TEST_ASSERT_SMALLER_THAN_INT8(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_INT8 )(threshold), (UNITY_INT)(UNITY_INT8 )(actual), UNITY_SMALLER_THAN, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT8) -#define UNITY_TEST_ASSERT_SMALLER_THAN_INT16(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_INT16)(threshold), (UNITY_INT)(UNITY_INT16)(actual), UNITY_SMALLER_THAN, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT16) -#define UNITY_TEST_ASSERT_SMALLER_THAN_INT32(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_INT32)(threshold), (UNITY_INT)(UNITY_INT32)(actual), UNITY_SMALLER_THAN, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT32) -#define UNITY_TEST_ASSERT_SMALLER_THAN_UINT(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(threshold), (UNITY_INT)(actual), UNITY_SMALLER_THAN, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT) -#define UNITY_TEST_ASSERT_SMALLER_THAN_UINT8(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_UINT8 )(threshold), (UNITY_INT)(UNITY_UINT8 )(actual), UNITY_SMALLER_THAN, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT8) -#define UNITY_TEST_ASSERT_SMALLER_THAN_UINT16(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_UINT16)(threshold), (UNITY_INT)(UNITY_UINT16)(actual), UNITY_SMALLER_THAN, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT16) -#define UNITY_TEST_ASSERT_SMALLER_THAN_UINT32(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_UINT32)(threshold), (UNITY_INT)(UNITY_UINT32)(actual), UNITY_SMALLER_THAN, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT32) -#define UNITY_TEST_ASSERT_SMALLER_THAN_HEX8(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_UINT8 )(threshold), (UNITY_INT)(UNITY_UINT8 )(actual), UNITY_SMALLER_THAN, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX8) -#define UNITY_TEST_ASSERT_SMALLER_THAN_HEX16(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_UINT16)(threshold), (UNITY_INT)(UNITY_UINT16)(actual), UNITY_SMALLER_THAN, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX16) -#define UNITY_TEST_ASSERT_SMALLER_THAN_HEX32(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_UINT32)(threshold), (UNITY_INT)(UNITY_UINT32)(actual), UNITY_SMALLER_THAN, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX32) -#define UNITY_TEST_ASSERT_SMALLER_THAN_CHAR(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_INT8 )(threshold), (UNITY_INT)(UNITY_INT8 )(actual), UNITY_SMALLER_THAN, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_CHAR) - -#define UNITY_TEST_ASSERT_GREATER_OR_EQUAL_INT(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT) (threshold), (UNITY_INT) (actual), UNITY_GREATER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT) -#define UNITY_TEST_ASSERT_GREATER_OR_EQUAL_INT8(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_INT8 ) (threshold), (UNITY_INT)(UNITY_INT8 ) (actual), UNITY_GREATER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT8) -#define UNITY_TEST_ASSERT_GREATER_OR_EQUAL_INT16(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_INT16) (threshold), (UNITY_INT)(UNITY_INT16) (actual), UNITY_GREATER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT16) -#define UNITY_TEST_ASSERT_GREATER_OR_EQUAL_INT32(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_INT32) (threshold), (UNITY_INT)(UNITY_INT32) (actual), UNITY_GREATER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT32) -#define UNITY_TEST_ASSERT_GREATER_OR_EQUAL_UINT(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT) (threshold), (UNITY_INT) (actual), UNITY_GREATER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT) -#define UNITY_TEST_ASSERT_GREATER_OR_EQUAL_UINT8(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_UINT8 )(threshold), (UNITY_INT)(UNITY_UINT8 )(actual), UNITY_GREATER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT8) -#define UNITY_TEST_ASSERT_GREATER_OR_EQUAL_UINT16(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_UINT16)(threshold), (UNITY_INT)(UNITY_UINT16)(actual), UNITY_GREATER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT16) -#define UNITY_TEST_ASSERT_GREATER_OR_EQUAL_UINT32(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_UINT32)(threshold), (UNITY_INT)(UNITY_UINT32)(actual), UNITY_GREATER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT32) -#define UNITY_TEST_ASSERT_GREATER_OR_EQUAL_HEX8(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_UINT8 )(threshold), (UNITY_INT)(UNITY_UINT8 )(actual), UNITY_GREATER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX8) -#define UNITY_TEST_ASSERT_GREATER_OR_EQUAL_HEX16(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_UINT16)(threshold), (UNITY_INT)(UNITY_UINT16)(actual), UNITY_GREATER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX16) -#define UNITY_TEST_ASSERT_GREATER_OR_EQUAL_HEX32(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_UINT32)(threshold), (UNITY_INT)(UNITY_UINT32)(actual), UNITY_GREATER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX32) -#define UNITY_TEST_ASSERT_GREATER_OR_EQUAL_CHAR(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_INT8 ) (threshold), (UNITY_INT)(UNITY_INT8 ) (actual), UNITY_GREATER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_CHAR) - -#define UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_INT(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT) (threshold), (UNITY_INT) (actual), UNITY_SMALLER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT) -#define UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_INT8(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_INT8 )(threshold), (UNITY_INT)(UNITY_INT8 ) (actual), UNITY_SMALLER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT8) -#define UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_INT16(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_INT16)(threshold), (UNITY_INT)(UNITY_INT16) (actual), UNITY_SMALLER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT16) -#define UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_INT32(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_INT32)(threshold), (UNITY_INT)(UNITY_INT32) (actual), UNITY_SMALLER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT32) -#define UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_UINT(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT) (threshold), (UNITY_INT) (actual), UNITY_SMALLER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT) -#define UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_UINT8(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_UINT8 )(threshold), (UNITY_INT)(UNITY_UINT8 )(actual), UNITY_SMALLER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT8) -#define UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_UINT16(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_UINT16)(threshold), (UNITY_INT)(UNITY_UINT16)(actual), UNITY_SMALLER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT16) -#define UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_UINT32(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_UINT32)(threshold), (UNITY_INT)(UNITY_UINT32)(actual), UNITY_SMALLER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT32) -#define UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_HEX8(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_UINT8 )(threshold), (UNITY_INT)(UNITY_UINT8 )(actual), UNITY_SMALLER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX8) -#define UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_HEX16(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_UINT16)(threshold), (UNITY_INT)(UNITY_UINT16)(actual), UNITY_SMALLER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX16) -#define UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_HEX32(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_UINT32)(threshold), (UNITY_INT)(UNITY_UINT32)(actual), UNITY_SMALLER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX32) -#define UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_CHAR(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_INT8 )(threshold), (UNITY_INT)(UNITY_INT8 ) (actual), UNITY_SMALLER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_CHAR) - -#define UNITY_TEST_ASSERT_INT_WITHIN(delta, expected, actual, line, message) UnityAssertNumbersWithin( (delta), (UNITY_INT) (expected), (UNITY_INT) (actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT) -#define UNITY_TEST_ASSERT_INT8_WITHIN(delta, expected, actual, line, message) UnityAssertNumbersWithin((UNITY_UINT8 )(delta), (UNITY_INT)(UNITY_INT8 ) (expected), (UNITY_INT)(UNITY_INT8 ) (actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT8) -#define UNITY_TEST_ASSERT_INT16_WITHIN(delta, expected, actual, line, message) UnityAssertNumbersWithin((UNITY_UINT16)(delta), (UNITY_INT)(UNITY_INT16) (expected), (UNITY_INT)(UNITY_INT16) (actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT16) -#define UNITY_TEST_ASSERT_INT32_WITHIN(delta, expected, actual, line, message) UnityAssertNumbersWithin((UNITY_UINT32)(delta), (UNITY_INT)(UNITY_INT32) (expected), (UNITY_INT)(UNITY_INT32) (actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT32) -#define UNITY_TEST_ASSERT_UINT_WITHIN(delta, expected, actual, line, message) UnityAssertNumbersWithin( (delta), (UNITY_INT) (expected), (UNITY_INT) (actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT) -#define UNITY_TEST_ASSERT_UINT8_WITHIN(delta, expected, actual, line, message) UnityAssertNumbersWithin((UNITY_UINT8 )(delta), (UNITY_INT)(UNITY_UINT)(UNITY_UINT8 )(expected), (UNITY_INT)(UNITY_UINT)(UNITY_UINT8 )(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT8) -#define UNITY_TEST_ASSERT_UINT16_WITHIN(delta, expected, actual, line, message) UnityAssertNumbersWithin((UNITY_UINT16)(delta), (UNITY_INT)(UNITY_UINT)(UNITY_UINT16)(expected), (UNITY_INT)(UNITY_UINT)(UNITY_UINT16)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT16) -#define UNITY_TEST_ASSERT_UINT32_WITHIN(delta, expected, actual, line, message) UnityAssertNumbersWithin((UNITY_UINT32)(delta), (UNITY_INT)(UNITY_UINT)(UNITY_UINT32)(expected), (UNITY_INT)(UNITY_UINT)(UNITY_UINT32)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT32) -#define UNITY_TEST_ASSERT_HEX8_WITHIN(delta, expected, actual, line, message) UnityAssertNumbersWithin((UNITY_UINT8 )(delta), (UNITY_INT)(UNITY_UINT)(UNITY_UINT8 )(expected), (UNITY_INT)(UNITY_UINT)(UNITY_UINT8 )(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX8) -#define UNITY_TEST_ASSERT_HEX16_WITHIN(delta, expected, actual, line, message) UnityAssertNumbersWithin((UNITY_UINT16)(delta), (UNITY_INT)(UNITY_UINT)(UNITY_UINT16)(expected), (UNITY_INT)(UNITY_UINT)(UNITY_UINT16)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX16) -#define UNITY_TEST_ASSERT_HEX32_WITHIN(delta, expected, actual, line, message) UnityAssertNumbersWithin((UNITY_UINT32)(delta), (UNITY_INT)(UNITY_UINT)(UNITY_UINT32)(expected), (UNITY_INT)(UNITY_UINT)(UNITY_UINT32)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX32) -#define UNITY_TEST_ASSERT_CHAR_WITHIN(delta, expected, actual, line, message) UnityAssertNumbersWithin((UNITY_UINT8 )(delta), (UNITY_INT)(UNITY_INT8 ) (expected), (UNITY_INT)(UNITY_INT8 ) (actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_CHAR) - -#define UNITY_TEST_ASSERT_INT_ARRAY_WITHIN(delta, expected, actual, num_elements, line, message) UnityAssertNumbersArrayWithin( (delta), (UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), ((UNITY_UINT32)(num_elements)), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT, UNITY_ARRAY_TO_ARRAY) -#define UNITY_TEST_ASSERT_INT8_ARRAY_WITHIN(delta, expected, actual, num_elements, line, message) UnityAssertNumbersArrayWithin((UNITY_UINT8 )(delta), (UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), ((UNITY_UINT32)(num_elements)), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT8, UNITY_ARRAY_TO_ARRAY) -#define UNITY_TEST_ASSERT_INT16_ARRAY_WITHIN(delta, expected, actual, num_elements, line, message) UnityAssertNumbersArrayWithin((UNITY_UINT16)(delta), (UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), ((UNITY_UINT32)(num_elements)), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT16, UNITY_ARRAY_TO_ARRAY) -#define UNITY_TEST_ASSERT_INT32_ARRAY_WITHIN(delta, expected, actual, num_elements, line, message) UnityAssertNumbersArrayWithin((UNITY_UINT32)(delta), (UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), ((UNITY_UINT32)(num_elements)), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT32, UNITY_ARRAY_TO_ARRAY) -#define UNITY_TEST_ASSERT_UINT_ARRAY_WITHIN(delta, expected, actual, num_elements, line, message) UnityAssertNumbersArrayWithin( (delta), (UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), ((UNITY_UINT32)(num_elements)), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT, UNITY_ARRAY_TO_ARRAY) -#define UNITY_TEST_ASSERT_UINT8_ARRAY_WITHIN(delta, expected, actual, num_elements, line, message) UnityAssertNumbersArrayWithin((UNITY_UINT8 )(delta), (UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), ((UNITY_UINT32)(num_elements)), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT8, UNITY_ARRAY_TO_ARRAY) -#define UNITY_TEST_ASSERT_UINT16_ARRAY_WITHIN(delta, expected, actual, num_elements, line, message) UnityAssertNumbersArrayWithin((UNITY_UINT16)(delta), (UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), ((UNITY_UINT32)(num_elements)), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT16, UNITY_ARRAY_TO_ARRAY) -#define UNITY_TEST_ASSERT_UINT32_ARRAY_WITHIN(delta, expected, actual, num_elements, line, message) UnityAssertNumbersArrayWithin((UNITY_UINT32)(delta), (UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), ((UNITY_UINT32)(num_elements)), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT32, UNITY_ARRAY_TO_ARRAY) -#define UNITY_TEST_ASSERT_HEX8_ARRAY_WITHIN(delta, expected, actual, num_elements, line, message) UnityAssertNumbersArrayWithin((UNITY_UINT8 )(delta), (UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), ((UNITY_UINT32)(num_elements)), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX8, UNITY_ARRAY_TO_ARRAY) -#define UNITY_TEST_ASSERT_HEX16_ARRAY_WITHIN(delta, expected, actual, num_elements, line, message) UnityAssertNumbersArrayWithin((UNITY_UINT16)(delta), (UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), ((UNITY_UINT32)(num_elements)), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX16, UNITY_ARRAY_TO_ARRAY) -#define UNITY_TEST_ASSERT_HEX32_ARRAY_WITHIN(delta, expected, actual, num_elements, line, message) UnityAssertNumbersArrayWithin((UNITY_UINT32)(delta), (UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), ((UNITY_UINT32)(num_elements)), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX32, UNITY_ARRAY_TO_ARRAY) -#define UNITY_TEST_ASSERT_CHAR_ARRAY_WITHIN(delta, expected, actual, num_elements, line, message) UnityAssertNumbersArrayWithin((UNITY_UINT8 )(delta), (UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), ((UNITY_UINT32)(num_elements)), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_CHAR, UNITY_ARRAY_TO_ARRAY) +#define UNITY_TEST_ASSERT_NOT_EQUAL_INT(threshold, actual, line, message) UnityAssertIntGreaterOrLessOrEqualNumber((UNITY_INT)(threshold), (UNITY_INT)(actual), UNITY_NOT_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT) +#define UNITY_TEST_ASSERT_NOT_EQUAL_INT8(threshold, actual, line, message) UnityAssertIntGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_INT8 )(threshold), (UNITY_INT)(UNITY_INT8 )(actual), UNITY_NOT_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT8) +#define UNITY_TEST_ASSERT_NOT_EQUAL_INT16(threshold, actual, line, message) UnityAssertIntGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_INT16)(threshold), (UNITY_INT)(UNITY_INT16)(actual), UNITY_NOT_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT16) +#define UNITY_TEST_ASSERT_NOT_EQUAL_INT32(threshold, actual, line, message) UnityAssertIntGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_INT32)(threshold), (UNITY_INT)(UNITY_INT32)(actual), UNITY_NOT_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT32) +#define UNITY_TEST_ASSERT_NOT_EQUAL_UINT(threshold, actual, line, message) UnityAssertUintGreaterOrLessOrEqualNumber((UNITY_UINT)(threshold), (UNITY_UINT)(actual), UNITY_NOT_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT) +#define UNITY_TEST_ASSERT_NOT_EQUAL_UINT8(threshold, actual, line, message) UnityAssertUintGreaterOrLessOrEqualNumber((UNITY_UINT)(UNITY_UINT8 )(threshold), (UNITY_UINT)(UNITY_UINT8 )(actual), UNITY_NOT_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT8) +#define UNITY_TEST_ASSERT_NOT_EQUAL_UINT16(threshold, actual, line, message) UnityAssertUintGreaterOrLessOrEqualNumber((UNITY_UINT)(UNITY_UINT16)(threshold), (UNITY_UINT)(UNITY_UINT16)(actual), UNITY_NOT_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT16) +#define UNITY_TEST_ASSERT_NOT_EQUAL_UINT32(threshold, actual, line, message) UnityAssertUintGreaterOrLessOrEqualNumber((UNITY_UINT)(UNITY_UINT32)(threshold), (UNITY_UINT)(UNITY_UINT32)(actual), UNITY_NOT_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT32) +#define UNITY_TEST_ASSERT_NOT_EQUAL_HEX8(threshold, actual, line, message) UnityAssertUintGreaterOrLessOrEqualNumber((UNITY_UINT)(UNITY_UINT8 )(threshold), (UNITY_UINT)(UNITY_UINT8 )(actual), UNITY_NOT_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX8) +#define UNITY_TEST_ASSERT_NOT_EQUAL_HEX16(threshold, actual, line, message) UnityAssertUintGreaterOrLessOrEqualNumber((UNITY_UINT)(UNITY_UINT16)(threshold), (UNITY_UINT)(UNITY_UINT16)(actual), UNITY_NOT_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX16) +#define UNITY_TEST_ASSERT_NOT_EQUAL_HEX32(threshold, actual, line, message) UnityAssertUintGreaterOrLessOrEqualNumber((UNITY_UINT)(UNITY_UINT32)(threshold), (UNITY_UINT)(UNITY_UINT32)(actual), UNITY_NOT_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX32) +#define UNITY_TEST_ASSERT_NOT_EQUAL_CHAR(threshold, actual, line, message) UnityAssertIntGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_INT8 )(threshold), (UNITY_INT)(UNITY_INT8 )(actual), UNITY_NOT_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_CHAR) + +#define UNITY_TEST_ASSERT_GREATER_THAN_INT(threshold, actual, line, message) UnityAssertIntGreaterOrLessOrEqualNumber((UNITY_INT)(threshold), (UNITY_INT)(actual), UNITY_GREATER_THAN, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT) +#define UNITY_TEST_ASSERT_GREATER_THAN_INT8(threshold, actual, line, message) UnityAssertIntGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_INT8 )(threshold), (UNITY_INT)(UNITY_INT8 )(actual), UNITY_GREATER_THAN, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT8) +#define UNITY_TEST_ASSERT_GREATER_THAN_INT16(threshold, actual, line, message) UnityAssertIntGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_INT16)(threshold), (UNITY_INT)(UNITY_INT16)(actual), UNITY_GREATER_THAN, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT16) +#define UNITY_TEST_ASSERT_GREATER_THAN_INT32(threshold, actual, line, message) UnityAssertIntGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_INT32)(threshold), (UNITY_INT)(UNITY_INT32)(actual), UNITY_GREATER_THAN, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT32) +#define UNITY_TEST_ASSERT_GREATER_THAN_UINT(threshold, actual, line, message) UnityAssertUintGreaterOrLessOrEqualNumber((UNITY_UINT)(threshold), (UNITY_UINT)(actual), UNITY_GREATER_THAN, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT) +#define UNITY_TEST_ASSERT_GREATER_THAN_UINT8(threshold, actual, line, message) UnityAssertUintGreaterOrLessOrEqualNumber((UNITY_UINT)(UNITY_UINT8 )(threshold), (UNITY_UINT)(UNITY_UINT8 )(actual), UNITY_GREATER_THAN, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT8) +#define UNITY_TEST_ASSERT_GREATER_THAN_UINT16(threshold, actual, line, message) UnityAssertUintGreaterOrLessOrEqualNumber((UNITY_UINT)(UNITY_UINT16)(threshold), (UNITY_UINT)(UNITY_UINT16)(actual), UNITY_GREATER_THAN, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT16) +#define UNITY_TEST_ASSERT_GREATER_THAN_UINT32(threshold, actual, line, message) UnityAssertUintGreaterOrLessOrEqualNumber((UNITY_UINT)(UNITY_UINT32)(threshold), (UNITY_UINT)(UNITY_UINT32)(actual), UNITY_GREATER_THAN, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT32) +#define UNITY_TEST_ASSERT_GREATER_THAN_HEX8(threshold, actual, line, message) UnityAssertUintGreaterOrLessOrEqualNumber((UNITY_UINT)(UNITY_UINT8 )(threshold), (UNITY_UINT)(UNITY_UINT8 )(actual), UNITY_GREATER_THAN, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX8) +#define UNITY_TEST_ASSERT_GREATER_THAN_HEX16(threshold, actual, line, message) UnityAssertUintGreaterOrLessOrEqualNumber((UNITY_UINT)(UNITY_UINT16)(threshold), (UNITY_UINT)(UNITY_UINT16)(actual), UNITY_GREATER_THAN, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX16) +#define UNITY_TEST_ASSERT_GREATER_THAN_HEX32(threshold, actual, line, message) UnityAssertUintGreaterOrLessOrEqualNumber((UNITY_UINT)(UNITY_UINT32)(threshold), (UNITY_UINT)(UNITY_UINT32)(actual), UNITY_GREATER_THAN, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX32) +#define UNITY_TEST_ASSERT_GREATER_THAN_CHAR(threshold, actual, line, message) UnityAssertIntGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_INT8 )(threshold), (UNITY_INT)(UNITY_INT8 )(actual), UNITY_GREATER_THAN, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_CHAR) + +#define UNITY_TEST_ASSERT_SMALLER_THAN_INT(threshold, actual, line, message) UnityAssertIntGreaterOrLessOrEqualNumber((UNITY_INT)(threshold), (UNITY_INT)(actual), UNITY_SMALLER_THAN, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT) +#define UNITY_TEST_ASSERT_SMALLER_THAN_INT8(threshold, actual, line, message) UnityAssertIntGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_INT8 )(threshold), (UNITY_INT)(UNITY_INT8 )(actual), UNITY_SMALLER_THAN, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT8) +#define UNITY_TEST_ASSERT_SMALLER_THAN_INT16(threshold, actual, line, message) UnityAssertIntGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_INT16)(threshold), (UNITY_INT)(UNITY_INT16)(actual), UNITY_SMALLER_THAN, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT16) +#define UNITY_TEST_ASSERT_SMALLER_THAN_INT32(threshold, actual, line, message) UnityAssertIntGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_INT32)(threshold), (UNITY_INT)(UNITY_INT32)(actual), UNITY_SMALLER_THAN, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT32) +#define UNITY_TEST_ASSERT_SMALLER_THAN_UINT(threshold, actual, line, message) UnityAssertUintGreaterOrLessOrEqualNumber((UNITY_UINT)(threshold), (UNITY_UINT)(actual), UNITY_SMALLER_THAN, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT) +#define UNITY_TEST_ASSERT_SMALLER_THAN_UINT8(threshold, actual, line, message) UnityAssertUintGreaterOrLessOrEqualNumber((UNITY_UINT)(UNITY_UINT8 )(threshold), (UNITY_UINT)(UNITY_UINT8 )(actual), UNITY_SMALLER_THAN, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT8) +#define UNITY_TEST_ASSERT_SMALLER_THAN_UINT16(threshold, actual, line, message) UnityAssertUintGreaterOrLessOrEqualNumber((UNITY_UINT)(UNITY_UINT16)(threshold), (UNITY_UINT)(UNITY_UINT16)(actual), UNITY_SMALLER_THAN, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT16) +#define UNITY_TEST_ASSERT_SMALLER_THAN_UINT32(threshold, actual, line, message) UnityAssertUintGreaterOrLessOrEqualNumber((UNITY_UINT)(UNITY_UINT32)(threshold), (UNITY_UINT)(UNITY_UINT32)(actual), UNITY_SMALLER_THAN, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT32) +#define UNITY_TEST_ASSERT_SMALLER_THAN_HEX8(threshold, actual, line, message) UnityAssertUintGreaterOrLessOrEqualNumber((UNITY_UINT)(UNITY_UINT8 )(threshold), (UNITY_UINT)(UNITY_UINT8 )(actual), UNITY_SMALLER_THAN, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX8) +#define UNITY_TEST_ASSERT_SMALLER_THAN_HEX16(threshold, actual, line, message) UnityAssertUintGreaterOrLessOrEqualNumber((UNITY_UINT)(UNITY_UINT16)(threshold), (UNITY_UINT)(UNITY_UINT16)(actual), UNITY_SMALLER_THAN, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX16) +#define UNITY_TEST_ASSERT_SMALLER_THAN_HEX32(threshold, actual, line, message) UnityAssertUintGreaterOrLessOrEqualNumber((UNITY_UINT)(UNITY_UINT32)(threshold), (UNITY_UINT)(UNITY_UINT32)(actual), UNITY_SMALLER_THAN, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX32) +#define UNITY_TEST_ASSERT_SMALLER_THAN_CHAR(threshold, actual, line, message) UnityAssertIntGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_INT8 )(threshold), (UNITY_INT)(UNITY_INT8 )(actual), UNITY_SMALLER_THAN, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_CHAR) + +#define UNITY_TEST_ASSERT_GREATER_OR_EQUAL_INT(threshold, actual, line, message) UnityAssertIntGreaterOrLessOrEqualNumber((UNITY_INT) (threshold), (UNITY_INT) (actual), UNITY_GREATER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT) +#define UNITY_TEST_ASSERT_GREATER_OR_EQUAL_INT8(threshold, actual, line, message) UnityAssertIntGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_INT8 ) (threshold), (UNITY_INT)(UNITY_INT8 ) (actual), UNITY_GREATER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT8) +#define UNITY_TEST_ASSERT_GREATER_OR_EQUAL_INT16(threshold, actual, line, message) UnityAssertIntGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_INT16) (threshold), (UNITY_INT)(UNITY_INT16) (actual), UNITY_GREATER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT16) +#define UNITY_TEST_ASSERT_GREATER_OR_EQUAL_INT32(threshold, actual, line, message) UnityAssertIntGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_INT32) (threshold), (UNITY_INT)(UNITY_INT32) (actual), UNITY_GREATER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT32) +#define UNITY_TEST_ASSERT_GREATER_OR_EQUAL_UINT(threshold, actual, line, message) UnityAssertUintGreaterOrLessOrEqualNumber((UNITY_UINT) (threshold), (UNITY_UINT) (actual), UNITY_GREATER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT) +#define UNITY_TEST_ASSERT_GREATER_OR_EQUAL_UINT8(threshold, actual, line, message) UnityAssertUintGreaterOrLessOrEqualNumber((UNITY_UINT)(UNITY_UINT8 )(threshold), (UNITY_UINT)(UNITY_UINT8 )(actual), UNITY_GREATER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT8) +#define UNITY_TEST_ASSERT_GREATER_OR_EQUAL_UINT16(threshold, actual, line, message) UnityAssertUintGreaterOrLessOrEqualNumber((UNITY_UINT)(UNITY_UINT16)(threshold), (UNITY_UINT)(UNITY_UINT16)(actual), UNITY_GREATER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT16) +#define UNITY_TEST_ASSERT_GREATER_OR_EQUAL_UINT32(threshold, actual, line, message) UnityAssertUintGreaterOrLessOrEqualNumber((UNITY_UINT)(UNITY_UINT32)(threshold), (UNITY_UINT)(UNITY_UINT32)(actual), UNITY_GREATER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT32) +#define UNITY_TEST_ASSERT_GREATER_OR_EQUAL_HEX8(threshold, actual, line, message) UnityAssertUintGreaterOrLessOrEqualNumber((UNITY_UINT)(UNITY_UINT8 )(threshold), (UNITY_UINT)(UNITY_UINT8 )(actual), UNITY_GREATER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX8) +#define UNITY_TEST_ASSERT_GREATER_OR_EQUAL_HEX16(threshold, actual, line, message) UnityAssertUintGreaterOrLessOrEqualNumber((UNITY_UINT)(UNITY_UINT16)(threshold), (UNITY_UINT)(UNITY_UINT16)(actual), UNITY_GREATER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX16) +#define UNITY_TEST_ASSERT_GREATER_OR_EQUAL_HEX32(threshold, actual, line, message) UnityAssertUintGreaterOrLessOrEqualNumber((UNITY_UINT)(UNITY_UINT32)(threshold), (UNITY_UINT)(UNITY_UINT32)(actual), UNITY_GREATER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX32) +#define UNITY_TEST_ASSERT_GREATER_OR_EQUAL_CHAR(threshold, actual, line, message) UnityAssertIntGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_INT8 ) (threshold), (UNITY_INT)(UNITY_INT8 ) (actual), UNITY_GREATER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_CHAR) + +#define UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_INT(threshold, actual, line, message) UnityAssertIntGreaterOrLessOrEqualNumber((UNITY_INT) (threshold), (UNITY_INT) (actual), UNITY_SMALLER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT) +#define UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_INT8(threshold, actual, line, message) UnityAssertIntGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_INT8 )(threshold), (UNITY_INT)(UNITY_INT8 ) (actual), UNITY_SMALLER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT8) +#define UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_INT16(threshold, actual, line, message) UnityAssertIntGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_INT16)(threshold), (UNITY_INT)(UNITY_INT16) (actual), UNITY_SMALLER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT16) +#define UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_INT32(threshold, actual, line, message) UnityAssertIntGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_INT32)(threshold), (UNITY_INT)(UNITY_INT32) (actual), UNITY_SMALLER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT32) +#define UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_UINT(threshold, actual, line, message) UnityAssertUintGreaterOrLessOrEqualNumber((UNITY_UINT) (threshold), (UNITY_UINT) (actual), UNITY_SMALLER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT) +#define UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_UINT8(threshold, actual, line, message) UnityAssertUintGreaterOrLessOrEqualNumber((UNITY_UINT)(UNITY_UINT8 )(threshold), (UNITY_UINT)(UNITY_UINT8 )(actual), UNITY_SMALLER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT8) +#define UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_UINT16(threshold, actual, line, message) UnityAssertUintGreaterOrLessOrEqualNumber((UNITY_UINT)(UNITY_UINT16)(threshold), (UNITY_UINT)(UNITY_UINT16)(actual), UNITY_SMALLER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT16) +#define UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_UINT32(threshold, actual, line, message) UnityAssertUintGreaterOrLessOrEqualNumber((UNITY_UINT)(UNITY_UINT32)(threshold), (UNITY_UINT)(UNITY_UINT32)(actual), UNITY_SMALLER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT32) +#define UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_HEX8(threshold, actual, line, message) UnityAssertUintGreaterOrLessOrEqualNumber((UNITY_UINT)(UNITY_UINT8 )(threshold), (UNITY_UINT)(UNITY_UINT8 )(actual), UNITY_SMALLER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX8) +#define UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_HEX16(threshold, actual, line, message) UnityAssertUintGreaterOrLessOrEqualNumber((UNITY_UINT)(UNITY_UINT16)(threshold), (UNITY_UINT)(UNITY_UINT16)(actual), UNITY_SMALLER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX16) +#define UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_HEX32(threshold, actual, line, message) UnityAssertUintGreaterOrLessOrEqualNumber((UNITY_UINT)(UNITY_UINT32)(threshold), (UNITY_UINT)(UNITY_UINT32)(actual), UNITY_SMALLER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX32) +#define UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_CHAR(threshold, actual, line, message) UnityAssertIntGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_INT8 )(threshold), (UNITY_INT)(UNITY_INT8 ) (actual), UNITY_SMALLER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_CHAR) + +#define UNITY_TEST_ASSERT_INT_WITHIN(delta, expected, actual, line, message) UnityAssertIntNumbersWithin( (delta), (UNITY_INT) (expected), (UNITY_INT) (actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT) +#define UNITY_TEST_ASSERT_INT8_WITHIN(delta, expected, actual, line, message) UnityAssertIntNumbersWithin((UNITY_UINT8 )(delta), (UNITY_INT)(UNITY_INT8 ) (expected), (UNITY_INT)(UNITY_INT8 ) (actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT8) +#define UNITY_TEST_ASSERT_INT16_WITHIN(delta, expected, actual, line, message) UnityAssertIntNumbersWithin((UNITY_UINT16)(delta), (UNITY_INT)(UNITY_INT16) (expected), (UNITY_INT)(UNITY_INT16) (actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT16) +#define UNITY_TEST_ASSERT_INT32_WITHIN(delta, expected, actual, line, message) UnityAssertIntNumbersWithin((UNITY_UINT32)(delta), (UNITY_INT)(UNITY_INT32) (expected), (UNITY_INT)(UNITY_INT32) (actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT32) +#define UNITY_TEST_ASSERT_UINT_WITHIN(delta, expected, actual, line, message) UnityAssertUintNumbersWithin( (delta), (UNITY_UINT) (expected), (UNITY_UINT) (actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT) +#define UNITY_TEST_ASSERT_UINT8_WITHIN(delta, expected, actual, line, message) UnityAssertUintNumbersWithin((UNITY_UINT8 )(delta), (UNITY_UINT)(UNITY_UINT)(UNITY_UINT8 )(expected), (UNITY_UINT)(UNITY_UINT)(UNITY_UINT8 )(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT8) +#define UNITY_TEST_ASSERT_UINT16_WITHIN(delta, expected, actual, line, message) UnityAssertUintNumbersWithin((UNITY_UINT16)(delta), (UNITY_UINT)(UNITY_UINT)(UNITY_UINT16)(expected), (UNITY_UINT)(UNITY_UINT)(UNITY_UINT16)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT16) +#define UNITY_TEST_ASSERT_UINT32_WITHIN(delta, expected, actual, line, message) UnityAssertUintNumbersWithin((UNITY_UINT32)(delta), (UNITY_UINT)(UNITY_UINT)(UNITY_UINT32)(expected), (UNITY_UINT)(UNITY_UINT)(UNITY_UINT32)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT32) +#define UNITY_TEST_ASSERT_HEX8_WITHIN(delta, expected, actual, line, message) UnityAssertUintNumbersWithin((UNITY_UINT8 )(delta), (UNITY_UINT)(UNITY_UINT)(UNITY_UINT8 )(expected), (UNITY_UINT)(UNITY_UINT)(UNITY_UINT8 )(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX8) +#define UNITY_TEST_ASSERT_HEX16_WITHIN(delta, expected, actual, line, message) UnityAssertUintNumbersWithin((UNITY_UINT16)(delta), (UNITY_UINT)(UNITY_UINT)(UNITY_UINT16)(expected), (UNITY_UINT)(UNITY_UINT)(UNITY_UINT16)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX16) +#define UNITY_TEST_ASSERT_HEX32_WITHIN(delta, expected, actual, line, message) UnityAssertUintNumbersWithin((UNITY_UINT32)(delta), (UNITY_UINT)(UNITY_UINT)(UNITY_UINT32)(expected), (UNITY_UINT)(UNITY_UINT)(UNITY_UINT32)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX32) +#define UNITY_TEST_ASSERT_CHAR_WITHIN(delta, expected, actual, line, message) UnityAssertIntNumbersWithin((UNITY_UINT8 )(delta), (UNITY_INT)(UNITY_INT8 ) (expected), (UNITY_INT)(UNITY_INT8 ) (actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_CHAR) + +#define UNITY_TEST_ASSERT_INT_ARRAY_WITHIN(delta, expected, actual, num_elements, line, message) UnityAssertIntNumbersWithin( (delta), (UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), ((UNITY_UINT32)(num_elements)), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT, UNITY_ARRAY_TO_ARRAY) +#define UNITY_TEST_ASSERT_INT8_ARRAY_WITHIN(delta, expected, actual, num_elements, line, message) UnityAssertIntNumbersWithin((UNITY_UINT8)(delta), (UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), ((UNITY_UINT32)(num_elements)), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT8, UNITY_ARRAY_TO_ARRAY) +#define UNITY_TEST_ASSERT_INT16_ARRAY_WITHIN(delta, expected, actual, num_elements, line, message) UnityAssertIntNumbersWithin((UNITY_UINT16)(delta), (UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), ((UNITY_UINT32)(num_elements)), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT16, UNITY_ARRAY_TO_ARRAY) +#define UNITY_TEST_ASSERT_INT32_ARRAY_WITHIN(delta, expected, actual, num_elements, line, message) UnityAssertIntNumbersWithin((UNITY_UINT32)(delta), (UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), ((UNITY_UINT32)(num_elements)), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT32, UNITY_ARRAY_TO_ARRAY) +#define UNITY_TEST_ASSERT_UINT_ARRAY_WITHIN(delta, expected, actual, num_elements, line, message) UnityAssertUintNumbersWithin( (delta), (UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), ((UNITY_UINT32)(num_elements)), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT, UNITY_ARRAY_TO_ARRAY) +#define UNITY_TEST_ASSERT_UINT8_ARRAY_WITHIN(delta, expected, actual, num_elements, line, message) UnityAssertUintNumbersWithin((UNITY_UINT8)(delta), (UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), ((UNITY_UINT32)(num_elements)), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT8, UNITY_ARRAY_TO_ARRAY) +#define UNITY_TEST_ASSERT_UINT16_ARRAY_WITHIN(delta, expected, actual, num_elements, line, message) UnityAssertUintNumbersWithin((UNITY_UINT16)(delta), (UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), ((UNITY_UINT32)(num_elements)), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT16, UNITY_ARRAY_TO_ARRAY) +#define UNITY_TEST_ASSERT_UINT32_ARRAY_WITHIN(delta, expected, actual, num_elements, line, message) UnityAssertUintNumbersWithin((UNITY_UINT32)(delta), (UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), ((UNITY_UINT32)(num_elements)), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT32, UNITY_ARRAY_TO_ARRAY) +#define UNITY_TEST_ASSERT_HEX8_ARRAY_WITHIN(delta, expected, actual, num_elements, line, message) UnityAssertUintNumbersWithin((UNITY_UINT8 )(delta), (UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), ((UNITY_UINT32)(num_elements)), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX8, UNITY_ARRAY_TO_ARRAY) +#define UNITY_TEST_ASSERT_HEX16_ARRAY_WITHIN(delta, expected, actual, num_elements, line, message) UnityAssertUintNumbersWithin((UNITY_UINT16)(delta), (UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), ((UNITY_UINT32)(num_elements)), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX16, UNITY_ARRAY_TO_ARRAY) +#define UNITY_TEST_ASSERT_HEX32_ARRAY_WITHIN(delta, expected, actual, num_elements, line, message) UnityAssertUintNumbersWithin((UNITY_UINT32)(delta), (UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), ((UNITY_UINT32)(num_elements)), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX32, UNITY_ARRAY_TO_ARRAY) +#define UNITY_TEST_ASSERT_CHAR_ARRAY_WITHIN(delta, expected, actual, num_elements, line, message) UnityAssertIntNumbersWithin((UNITY_UINT8)(delta), (UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), ((UNITY_UINT32)(num_elements)), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_CHAR, UNITY_ARRAY_TO_ARRAY) #define UNITY_TEST_ASSERT_EQUAL_PTR(expected, actual, line, message) UnityAssertEqualIntNumber((UNITY_PTR_TO_INT)(expected), (UNITY_PTR_TO_INT)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_POINTER) @@ -1059,24 +1073,24 @@ int UnityTestMatches(void); #define UNITY_TEST_ASSERT_EACH_EQUAL_INT64(expected, actual, num_elements, line, message) UnityAssertEqualIntArray(UnityNumToPtr((UNITY_INT)(UNITY_INT64)(expected), 8), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT64, UNITY_ARRAY_TO_VAL) #define UNITY_TEST_ASSERT_EACH_EQUAL_UINT64(expected, actual, num_elements, line, message) UnityAssertEqualIntArray(UnityNumToPtr((UNITY_INT)(UNITY_UINT64)(expected), 8), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT64, UNITY_ARRAY_TO_VAL) #define UNITY_TEST_ASSERT_EACH_EQUAL_HEX64(expected, actual, num_elements, line, message) UnityAssertEqualIntArray(UnityNumToPtr((UNITY_INT)(UNITY_INT64)(expected), 8), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX64, UNITY_ARRAY_TO_VAL) -#define UNITY_TEST_ASSERT_INT64_WITHIN(delta, expected, actual, line, message) UnityAssertNumbersWithin((delta), (UNITY_INT)(expected), (UNITY_INT)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT64) -#define UNITY_TEST_ASSERT_UINT64_WITHIN(delta, expected, actual, line, message) UnityAssertNumbersWithin((delta), (UNITY_INT)(expected), (UNITY_INT)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT64) -#define UNITY_TEST_ASSERT_HEX64_WITHIN(delta, expected, actual, line, message) UnityAssertNumbersWithin((delta), (UNITY_INT)(expected), (UNITY_INT)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX64) -#define UNITY_TEST_ASSERT_NOT_EQUAL_INT64(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(threshold), (UNITY_INT)(actual), UNITY_NOT_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT64) -#define UNITY_TEST_ASSERT_NOT_EQUAL_UINT64(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(threshold), (UNITY_INT)(actual), UNITY_NOT_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT64) -#define UNITY_TEST_ASSERT_NOT_EQUAL_HEX64(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(threshold), (UNITY_INT)(actual), UNITY_NOT_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX64) -#define UNITY_TEST_ASSERT_GREATER_THAN_INT64(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(threshold), (UNITY_INT)(actual), UNITY_GREATER_THAN, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT64) -#define UNITY_TEST_ASSERT_GREATER_THAN_UINT64(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(threshold), (UNITY_INT)(actual), UNITY_GREATER_THAN, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT64) -#define UNITY_TEST_ASSERT_GREATER_THAN_HEX64(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(threshold), (UNITY_INT)(actual), UNITY_GREATER_THAN, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX64) -#define UNITY_TEST_ASSERT_GREATER_OR_EQUAL_INT64(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(threshold), (UNITY_INT)(actual), UNITY_GREATER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT64) -#define UNITY_TEST_ASSERT_GREATER_OR_EQUAL_UINT64(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(threshold), (UNITY_INT)(actual), UNITY_GREATER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT64) -#define UNITY_TEST_ASSERT_GREATER_OR_EQUAL_HEX64(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(threshold), (UNITY_INT)(actual), UNITY_GREATER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX64) -#define UNITY_TEST_ASSERT_SMALLER_THAN_INT64(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(threshold), (UNITY_INT)(actual), UNITY_SMALLER_THAN, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT64) -#define UNITY_TEST_ASSERT_SMALLER_THAN_UINT64(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(threshold), (UNITY_INT)(actual), UNITY_SMALLER_THAN, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT64) -#define UNITY_TEST_ASSERT_SMALLER_THAN_HEX64(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(threshold), (UNITY_INT)(actual), UNITY_SMALLER_THAN, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX64) -#define UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_INT64(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(threshold), (UNITY_INT)(actual), UNITY_SMALLER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT64) -#define UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_UINT64(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(threshold), (UNITY_INT)(actual), UNITY_SMALLER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT64) -#define UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_HEX64(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(threshold), (UNITY_INT)(actual), UNITY_SMALLER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX64) +#define UNITY_TEST_ASSERT_INT64_WITHIN(delta, expected, actual, line, message) UnityAssertIntNumbersWithin((delta), (expected), (actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT64) +#define UNITY_TEST_ASSERT_UINT64_WITHIN(delta, expected, actual, line, message) UnityAssertUintNumbersWithin((delta), (expected), (actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT64) +#define UNITY_TEST_ASSERT_HEX64_WITHIN(delta, expected, actual, line, message) UnityAssertUintNumbersWithin((delta), (expected), (actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX64) +#define UNITY_TEST_ASSERT_NOT_EQUAL_INT64(threshold, actual, line, message) UnityAssertIntGreaterOrLessOrEqualNumber((UNITY_INT)(threshold), (UNITY_INT)(actual), UNITY_NOT_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT64) +#define UNITY_TEST_ASSERT_NOT_EQUAL_UINT64(threshold, actual, line, message) UnityAssertUintGreaterOrLessOrEqualNumber((UNITY_UINT)(threshold), (UNITY_UINT)(actual), UNITY_NOT_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT64) +#define UNITY_TEST_ASSERT_NOT_EQUAL_HEX64(threshold, actual, line, message) UnityAssertUintGreaterOrLessOrEqualNumber((UNITY_UINT)(threshold), (UNITY_UINT)(actual), UNITY_NOT_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX64) +#define UNITY_TEST_ASSERT_GREATER_THAN_INT64(threshold, actual, line, message) UnityAssertIntGreaterOrLessOrEqualNumber((UNITY_INT)(threshold), (UNITY_INT)(actual), UNITY_GREATER_THAN, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT64) +#define UNITY_TEST_ASSERT_GREATER_THAN_UINT64(threshold, actual, line, message) UnityAssertUintGreaterOrLessOrEqualNumber((UNITY_UINT)(threshold), (UNITY_UINT)(actual), UNITY_GREATER_THAN, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT64) +#define UNITY_TEST_ASSERT_GREATER_THAN_HEX64(threshold, actual, line, message) UnityAssertUintGreaterOrLessOrEqualNumber((UNITY_UINT)(threshold), (UNITY_UINT)(actual), UNITY_GREATER_THAN, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX64) +#define UNITY_TEST_ASSERT_GREATER_OR_EQUAL_INT64(threshold, actual, line, message) UnityAssertIntGreaterOrLessOrEqualNumber((UNITY_INT)(threshold), (UNITY_INT)(actual), UNITY_GREATER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT64) +#define UNITY_TEST_ASSERT_GREATER_OR_EQUAL_UINT64(threshold, actual, line, message) UnityAssertUintGreaterOrLessOrEqualNumber((UNITY_UINT)(threshold), (UNITY_UINT)(actual), UNITY_GREATER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT64) +#define UNITY_TEST_ASSERT_GREATER_OR_EQUAL_HEX64(threshold, actual, line, message) UnityAssertUintGreaterOrLessOrEqualNumber((UNITY_UINT)(threshold), (UNITY_UINT)(actual), UNITY_GREATER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX64) +#define UNITY_TEST_ASSERT_SMALLER_THAN_INT64(threshold, actual, line, message) UnityAssertIntGreaterOrLessOrEqualNumber((UNITY_INT)(threshold), (UNITY_INT)(actual), UNITY_SMALLER_THAN, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT64) +#define UNITY_TEST_ASSERT_SMALLER_THAN_UINT64(threshold, actual, line, message) UnityAssertUintGreaterOrLessOrEqualNumber((UNITY_UINT)(threshold), (UNITY_UINT)(actual), UNITY_SMALLER_THAN, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT64) +#define UNITY_TEST_ASSERT_SMALLER_THAN_HEX64(threshold, actual, line, message) UnityAssertUintGreaterOrLessOrEqualNumber((UNITY_UINT)(threshold), (UNITY_UINT)(actual), UNITY_SMALLER_THAN, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX64) +#define UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_INT64(threshold, actual, line, message) UnityAssertIntGreaterOrLessOrEqualNumber((UNITY_INT)(threshold), (UNITY_INT)(actual), UNITY_SMALLER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT64) +#define UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_UINT64(threshold, actual, line, message) UnityAssertUintGreaterOrLessOrEqualNumber((UNITY_UINT)(threshold), (UNITY_UINT)(actual), UNITY_SMALLER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT64) +#define UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_HEX64(threshold, actual, line, message) UnityAssertUintGreaterOrLessOrEqualNumber((UNITY_UINT)(threshold), (UNITY_UINT)(actual), UNITY_SMALLER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX64) #define UNITY_TEST_ASSERT_INT64_ARRAY_WITHIN(delta, expected, actual, num_elements, line, message) UnityAssertNumbersArrayWithin((UNITY_UINT64)(delta), (UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT64, UNITY_ARRAY_TO_ARRAY) #define UNITY_TEST_ASSERT_UINT64_ARRAY_WITHIN(delta, expected, actual, num_elements, line, message) UnityAssertNumbersArrayWithin((UNITY_UINT64)(delta), (UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT64, UNITY_ARRAY_TO_ARRAY) #define UNITY_TEST_ASSERT_HEX64_ARRAY_WITHIN(delta, expected, actual, num_elements, line, message) UnityAssertNumbersArrayWithin((UNITY_UINT64)(delta), (UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX64, UNITY_ARRAY_TO_ARRAY) From 6a3fc440e33b577a6948669f5457096242538e1e Mon Sep 17 00:00:00 2001 From: burakutkuc Date: Fri, 13 Jun 2025 16:43:35 +0300 Subject: [PATCH 437/454] fix: Add casts in function-like macros for type safety --- src/unity_internals.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/unity_internals.h b/src/unity_internals.h index 19766982..445363d9 100644 --- a/src/unity_internals.h +++ b/src/unity_internals.h @@ -1073,9 +1073,9 @@ int UnityTestMatches(void); #define UNITY_TEST_ASSERT_EACH_EQUAL_INT64(expected, actual, num_elements, line, message) UnityAssertEqualIntArray(UnityNumToPtr((UNITY_INT)(UNITY_INT64)(expected), 8), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT64, UNITY_ARRAY_TO_VAL) #define UNITY_TEST_ASSERT_EACH_EQUAL_UINT64(expected, actual, num_elements, line, message) UnityAssertEqualIntArray(UnityNumToPtr((UNITY_INT)(UNITY_UINT64)(expected), 8), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT64, UNITY_ARRAY_TO_VAL) #define UNITY_TEST_ASSERT_EACH_EQUAL_HEX64(expected, actual, num_elements, line, message) UnityAssertEqualIntArray(UnityNumToPtr((UNITY_INT)(UNITY_INT64)(expected), 8), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX64, UNITY_ARRAY_TO_VAL) -#define UNITY_TEST_ASSERT_INT64_WITHIN(delta, expected, actual, line, message) UnityAssertIntNumbersWithin((delta), (expected), (actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT64) -#define UNITY_TEST_ASSERT_UINT64_WITHIN(delta, expected, actual, line, message) UnityAssertUintNumbersWithin((delta), (expected), (actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT64) -#define UNITY_TEST_ASSERT_HEX64_WITHIN(delta, expected, actual, line, message) UnityAssertUintNumbersWithin((delta), (expected), (actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX64) +#define UNITY_TEST_ASSERT_INT64_WITHIN(delta, expected, actual, line, message) UnityAssertIntNumbersWithin((delta), (UNITY_INT)(expected), (UNITY_INT)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT64) +#define UNITY_TEST_ASSERT_UINT64_WITHIN(delta, expected, actual, line, message) UnityAssertUintNumbersWithin((delta), (UNITY_UINT)(expected), (UNITY_UINT)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT64) +#define UNITY_TEST_ASSERT_HEX64_WITHIN(delta, expected, actual, line, message) UnityAssertUintNumbersWithin((delta), (UNITY_UINT)(expected), (UNITY_UINT)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX64) #define UNITY_TEST_ASSERT_NOT_EQUAL_INT64(threshold, actual, line, message) UnityAssertIntGreaterOrLessOrEqualNumber((UNITY_INT)(threshold), (UNITY_INT)(actual), UNITY_NOT_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT64) #define UNITY_TEST_ASSERT_NOT_EQUAL_UINT64(threshold, actual, line, message) UnityAssertUintGreaterOrLessOrEqualNumber((UNITY_UINT)(threshold), (UNITY_UINT)(actual), UNITY_NOT_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT64) #define UNITY_TEST_ASSERT_NOT_EQUAL_HEX64(threshold, actual, line, message) UnityAssertUintGreaterOrLessOrEqualNumber((UNITY_UINT)(threshold), (UNITY_UINT)(actual), UNITY_NOT_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX64) From 4c8dab0edd16ce6a4b7b628430de1cd42d03f31a Mon Sep 17 00:00:00 2001 From: Ross Smyth Date: Mon, 10 Mar 2025 16:00:38 -0400 Subject: [PATCH 438/454] Fix meson pkg-config generation The pkg-config file does not include the subdir in its build flags, so files will fail to find the Unity headers. --- meson.build | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/meson.build b/meson.build index 6585129c..9489aef4 100644 --- a/meson.build +++ b/meson.build @@ -64,10 +64,10 @@ unity_dep = declare_dependency( if not meson.is_subproject() pkg = import('pkgconfig') pkg.generate( - name: meson.project_name(), + unity_lib, version: meson.project_version(), - libraries: [ unity_lib ], - description: 'C Unit testing framework.' + subdirs: 'unity', + extra_cflags: unity_args, ) endif From e4942f1a21cc9a7478092ff2d84c7abb10b80512 Mon Sep 17 00:00:00 2001 From: Ross Smyth Date: Wed, 25 Jun 2025 14:42:32 -0400 Subject: [PATCH 439/454] Fix up shebangs in the auto directory --- auto/generate_test_runner.rb | 2 +- auto/stylize_as_junit.py | 2 +- auto/stylize_as_junit.rb | 2 +- auto/unity_test_summary.py | 2 +- auto/unity_test_summary.rb | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/auto/generate_test_runner.rb b/auto/generate_test_runner.rb index 2c2d5956..5b902295 100755 --- a/auto/generate_test_runner.rb +++ b/auto/generate_test_runner.rb @@ -1,4 +1,4 @@ -#!/usr/bin/ruby +#!/usr/bin/env ruby # ========================================================================= # Unity - A Test Framework for C # ThrowTheSwitch.org diff --git a/auto/stylize_as_junit.py b/auto/stylize_as_junit.py index 020ec440..49e8aff7 100644 --- a/auto/stylize_as_junit.py +++ b/auto/stylize_as_junit.py @@ -1,4 +1,4 @@ -#! python3 +#!/usr/bin/env python3 # ========================================================================= # Unity - A Test Framework for C # ThrowTheSwitch.org diff --git a/auto/stylize_as_junit.rb b/auto/stylize_as_junit.rb index 23d89a65..e003918a 100755 --- a/auto/stylize_as_junit.rb +++ b/auto/stylize_as_junit.rb @@ -1,4 +1,4 @@ -#!/usr/bin/ruby +#!/usr/bin/env ruby # ========================================================================= # Unity - A Test Framework for C # ThrowTheSwitch.org diff --git a/auto/unity_test_summary.py b/auto/unity_test_summary.py index 43e5af7c..60f5fd41 100644 --- a/auto/unity_test_summary.py +++ b/auto/unity_test_summary.py @@ -1,4 +1,4 @@ -#! python3 +#!/usr/bin/env python3 # ========================================================================= # Unity - A Test Framework for C # ThrowTheSwitch.org diff --git a/auto/unity_test_summary.rb b/auto/unity_test_summary.rb index 33c8d7a3..f6a64dea 100644 --- a/auto/unity_test_summary.rb +++ b/auto/unity_test_summary.rb @@ -1,3 +1,4 @@ +#!/usr/bin/env ruby # ========================================================================= # Unity - A Test Framework for C # ThrowTheSwitch.org @@ -5,7 +6,6 @@ # SPDX-License-Identifier: MIT # ========================================================================= -# !/usr/bin/ruby # # unity_test_summary.rb # From 442a060acd1e3cae383093fbee182345f7e644ae Mon Sep 17 00:00:00 2001 From: Ross Smyth <18294397+RossSmyth@users.noreply.github.com> Date: Wed, 2 Jul 2025 21:12:45 -0400 Subject: [PATCH 440/454] Fix clang errors in makefile --- test/Makefile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/Makefile b/test/Makefile index 82b61af9..532cc400 100644 --- a/test/Makefile +++ b/test/Makefile @@ -12,6 +12,8 @@ ifeq ($(findstring clang, $(CC)), clang) E = -Weverything CFLAGS += $E -Wno-unknown-warning-option -Wno-missing-prototypes CFLAGS += -Wno-unused-macros -Wno-padded -Wno-missing-noreturn +CFLAGS += -Wno-unsafe-buffer-usage -Wno-reserved-identifier +CFLAGS += -Wno-extra-semi-stmt endif CFLAGS += -std=c99 -pedantic -Wall -Wextra -Werror #CFLAGS += -Wconversion #disabled because if falsely complains about the isinf and isnan macros From 1638627cb5ac3c24c9840ea837c9115119158a02 Mon Sep 17 00:00:00 2001 From: Ross Smyth <18294397+RossSmyth@users.noreply.github.com> Date: Wed, 2 Jul 2025 21:12:40 -0400 Subject: [PATCH 441/454] Fix -Wextra-semi-stmt error with proper macro hygiene "empty expression statement has no effect; remove unnecessary ';'" These macros were not properly wrapped --- test/Makefile | 1 - test/tests/self_assessment_utils.h | 12 ++++++------ 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/test/Makefile b/test/Makefile index 532cc400..2275e3b8 100644 --- a/test/Makefile +++ b/test/Makefile @@ -13,7 +13,6 @@ E = -Weverything CFLAGS += $E -Wno-unknown-warning-option -Wno-missing-prototypes CFLAGS += -Wno-unused-macros -Wno-padded -Wno-missing-noreturn CFLAGS += -Wno-unsafe-buffer-usage -Wno-reserved-identifier -CFLAGS += -Wno-extra-semi-stmt endif CFLAGS += -std=c99 -pedantic -Wall -Wextra -Werror #CFLAGS += -Wconversion #disabled because if falsely complains about the isinf and isnan macros diff --git a/test/tests/self_assessment_utils.h b/test/tests/self_assessment_utils.h index 6051bda8..f764ca95 100644 --- a/test/tests/self_assessment_utils.h +++ b/test/tests/self_assessment_utils.h @@ -133,19 +133,19 @@ void flushSpy(void) if (flushSpyEnabled){ flushSpyCalls++; } } -#define TEST_ASSERT_EQUAL_PRINT_NUMBERS(expected, actual) { \ +#define TEST_ASSERT_EQUAL_PRINT_NUMBERS(expected, actual) do { \ startPutcharSpy(); UnityPrintNumber((actual)); endPutcharSpy(); \ TEST_ASSERT_EQUAL_STRING((expected), getBufferPutcharSpy()); \ - } + } while (0) -#define TEST_ASSERT_EQUAL_PRINT_UNSIGNED_NUMBERS(expected, actual) { \ +#define TEST_ASSERT_EQUAL_PRINT_UNSIGNED_NUMBERS(expected, actual) do { \ startPutcharSpy(); UnityPrintNumberUnsigned((actual)); endPutcharSpy(); \ TEST_ASSERT_EQUAL_STRING((expected), getBufferPutcharSpy()); \ - } + } while (0) -#define TEST_ASSERT_EQUAL_PRINT_FLOATING(expected, actual) { \ +#define TEST_ASSERT_EQUAL_PRINT_FLOATING(expected, actual) do { \ startPutcharSpy(); UnityPrintFloat((actual)); endPutcharSpy(); \ TEST_ASSERT_EQUAL_STRING((expected), getBufferPutcharSpy()); \ - } + } while (0) #endif From 8bac36463ddb0c112979e6724091eabe1746defb Mon Sep 17 00:00:00 2001 From: Ross Smyth <18294397+RossSmyth@users.noreply.github.com> Date: Wed, 2 Jul 2025 21:27:10 -0400 Subject: [PATCH 442/454] Fix reserved-identifier errors These are reserved by the standard --- test/Makefile | 2 +- test/tests/test_unity_core.c | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/test/Makefile b/test/Makefile index 2275e3b8..3c3c7510 100644 --- a/test/Makefile +++ b/test/Makefile @@ -12,7 +12,7 @@ ifeq ($(findstring clang, $(CC)), clang) E = -Weverything CFLAGS += $E -Wno-unknown-warning-option -Wno-missing-prototypes CFLAGS += -Wno-unused-macros -Wno-padded -Wno-missing-noreturn -CFLAGS += -Wno-unsafe-buffer-usage -Wno-reserved-identifier +CFLAGS += -Wno-unsafe-buffer-usage endif CFLAGS += -std=c99 -pedantic -Wall -Wextra -Werror #CFLAGS += -Wconversion #disabled because if falsely complains about the isinf and isnan macros diff --git a/test/tests/test_unity_core.c b/test/tests/test_unity_core.c index 866f2ab1..921f535d 100644 --- a/test/tests/test_unity_core.c +++ b/test/tests/test_unity_core.c @@ -61,7 +61,7 @@ void testUnitySizeInitializationReminder(void) #ifndef UNITY_EXCLUDE_SETJMP_H jmp_buf AbortFrame; #endif - } _Expected_Unity; + } Expected_Unity; #else struct { const char* TestFile; @@ -81,7 +81,7 @@ void testUnitySizeInitializationReminder(void) #ifndef UNITY_EXCLUDE_SETJMP_H jmp_buf AbortFrame; #endif - } _Expected_Unity; + } Expected_Unity; #endif /* Compare our fake structure's size to the actual structure's size. They @@ -89,7 +89,7 @@ void testUnitySizeInitializationReminder(void) * * This accounts for alignment, padding, and packing issues that might come * up between different architectures. */ - TEST_ASSERT_EQUAL_MESSAGE(sizeof(_Expected_Unity), sizeof(Unity), message); + TEST_ASSERT_EQUAL_MESSAGE(sizeof(Expected_Unity), sizeof(Unity), message); } void testPassShouldEndImmediatelyWithPass(void) From faaaaa4fca1dec9cf959c8180682fc9794650ec1 Mon Sep 17 00:00:00 2001 From: Ross Smyth <18294397+RossSmyth@users.noreply.github.com> Date: Wed, 2 Jul 2025 21:34:02 -0400 Subject: [PATCH 443/454] Fix Wmissing-noreturn errors --- test/Makefile | 2 +- test/tests/test_unity_core.c | 8 ++++---- test/tests/test_unity_floats.c | 9 +++++++++ 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/test/Makefile b/test/Makefile index 3c3c7510..fac16ee9 100644 --- a/test/Makefile +++ b/test/Makefile @@ -11,7 +11,7 @@ endif ifeq ($(findstring clang, $(CC)), clang) E = -Weverything CFLAGS += $E -Wno-unknown-warning-option -Wno-missing-prototypes -CFLAGS += -Wno-unused-macros -Wno-padded -Wno-missing-noreturn +CFLAGS += -Wno-unused-macros -Wno-padded CFLAGS += -Wno-unsafe-buffer-usage endif CFLAGS += -std=c99 -pedantic -Wall -Wextra -Werror diff --git a/test/tests/test_unity_core.c b/test/tests/test_unity_core.c index 921f535d..1f5a9a76 100644 --- a/test/tests/test_unity_core.c +++ b/test/tests/test_unity_core.c @@ -92,19 +92,19 @@ void testUnitySizeInitializationReminder(void) TEST_ASSERT_EQUAL_MESSAGE(sizeof(Expected_Unity), sizeof(Unity), message); } -void testPassShouldEndImmediatelyWithPass(void) +UNITY_FUNCTION_ATTR(noreturn) void testPassShouldEndImmediatelyWithPass(void) { TEST_PASS(); TEST_FAIL_MESSAGE("We should have passed already and finished this test"); } -void testPassShouldEndImmediatelyWithPassAndMessage(void) +UNITY_FUNCTION_ATTR(noreturn) void testPassShouldEndImmediatelyWithPassAndMessage(void) { TEST_PASS_MESSAGE("Woohoo! This Automatically Passes!"); TEST_FAIL_MESSAGE("We should have passed already and finished this test"); } -void testMessageShouldDisplayMessageWithoutEndingAndGoOnToPass(void) +UNITY_FUNCTION_ATTR(noreturn) void testMessageShouldDisplayMessageWithoutEndingAndGoOnToPass(void) { TEST_MESSAGE("This is just a message"); TEST_MESSAGE("This is another message"); @@ -282,7 +282,7 @@ void testProtection(void) TEST_ASSERT_EQUAL(3, mask); } -void testIgnoredAndThenFailInTearDown(void) +UNITY_FUNCTION_ATTR(noreturn) void testIgnoredAndThenFailInTearDown(void) { SetToOneToFailInTearDown = 1; TEST_IGNORE(); diff --git a/test/tests/test_unity_floats.c b/test/tests/test_unity_floats.c index 006c76ab..9744c134 100644 --- a/test/tests/test_unity_floats.c +++ b/test/tests/test_unity_floats.c @@ -1208,6 +1208,9 @@ void testNotEqualFloatEachEqualLengthZero(void) #endif } +#if defined(UNITY_EXCLUDE_FLOAT_PRINT) || defined(UNITY_INCLUDE_DOUBLE) || !defined(USING_OUTPUT_SPY) +UNITY_FUNCTION_ATTR(noreturn) +#endif void testFloatPrinting(void) { #if defined(UNITY_EXCLUDE_FLOAT_PRINT) || defined(UNITY_INCLUDE_DOUBLE) || !defined(USING_OUTPUT_SPY) @@ -1257,6 +1260,9 @@ void testFloatPrinting(void) #endif } +#if defined(UNITY_EXCLUDE_FLOAT_PRINT) || defined(UNITY_INCLUDE_DOUBLE) || !defined(USING_OUTPUT_SPY) +UNITY_FUNCTION_ATTR(noreturn) +#endif void testFloatPrintingRoundTiesToEven(void) { #if defined(UNITY_EXCLUDE_FLOAT_PRINT) || defined(UNITY_INCLUDE_DOUBLE) || !defined(USING_OUTPUT_SPY) @@ -1368,6 +1374,9 @@ static void printFloatValue(float f) #endif #endif +#if !defined(UNITY_TEST_ALL_FLOATS_PRINT_OK) || !defined(USING_OUTPUT_SPY) +UNITY_FUNCTION_ATTR(noreturn) +#endif void testFloatPrintingRandomSamples(void) { #if !defined(UNITY_TEST_ALL_FLOATS_PRINT_OK) || !defined(USING_OUTPUT_SPY) From 6decd7aa29f3c6d996e7a5c1cd9207fe633f96e5 Mon Sep 17 00:00:00 2001 From: Ross Smyth <18294397+RossSmyth@users.noreply.github.com> Date: Wed, 2 Jul 2025 21:38:12 -0400 Subject: [PATCH 444/454] Wno-unused-macros and Wno-padded don't emit anything --- test/Makefile | 1 - 1 file changed, 1 deletion(-) diff --git a/test/Makefile b/test/Makefile index fac16ee9..c5a26abf 100644 --- a/test/Makefile +++ b/test/Makefile @@ -11,7 +11,6 @@ endif ifeq ($(findstring clang, $(CC)), clang) E = -Weverything CFLAGS += $E -Wno-unknown-warning-option -Wno-missing-prototypes -CFLAGS += -Wno-unused-macros -Wno-padded CFLAGS += -Wno-unsafe-buffer-usage endif CFLAGS += -std=c99 -pedantic -Wall -Wextra -Werror From 4a59f29362bedf0bc1ca7636a1cd086c205074be Mon Sep 17 00:00:00 2001 From: Ross Smyth <18294397+RossSmyth@users.noreply.github.com> Date: Wed, 2 Jul 2025 21:43:20 -0400 Subject: [PATCH 445/454] Fix -Wmissing-prototypes errors This one was a bit tough, but I think this works fine. --- test/Makefile | 2 +- test/tests/self_assessment_utils.h | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/test/Makefile b/test/Makefile index c5a26abf..b0b96995 100644 --- a/test/Makefile +++ b/test/Makefile @@ -10,7 +10,7 @@ CC = clang endif ifeq ($(findstring clang, $(CC)), clang) E = -Weverything -CFLAGS += $E -Wno-unknown-warning-option -Wno-missing-prototypes +CFLAGS += $E -Wno-unknown-warning-option CFLAGS += -Wno-unsafe-buffer-usage endif CFLAGS += -std=c99 -pedantic -Wall -Wextra -Werror diff --git a/test/tests/self_assessment_utils.h b/test/tests/self_assessment_utils.h index f764ca95..24b755f1 100644 --- a/test/tests/self_assessment_utils.h +++ b/test/tests/self_assessment_utils.h @@ -72,6 +72,11 @@ static char putcharSpyBuffer[SPY_BUFFER_MAX]; static UNITY_COUNTER_TYPE indexSpyBuffer; static UNITY_COUNTER_TYPE putcharSpyEnabled; +#ifdef __clang__ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wmissing-prototypes" +#endif + void startPutcharSpy(void) { indexSpyBuffer = 0; @@ -133,6 +138,10 @@ void flushSpy(void) if (flushSpyEnabled){ flushSpyCalls++; } } +#ifdef __clang__ +#pragma clang diagnostic pop +#endif + #define TEST_ASSERT_EQUAL_PRINT_NUMBERS(expected, actual) do { \ startPutcharSpy(); UnityPrintNumber((actual)); endPutcharSpy(); \ TEST_ASSERT_EQUAL_STRING((expected), getBufferPutcharSpy()); \ @@ -149,3 +158,10 @@ void flushSpy(void) } while (0) #endif + +// The reason this isn't folded into the above diagnostic is to semi-isolate +// the header contents from the user content it is included into. +#ifdef __clang__ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wmissing-prototypes" +#endif From 12705bf83fd02a05e11c57288a11b8ccd15794f0 Mon Sep 17 00:00:00 2001 From: Ross Smyth <18294397+RossSmyth@users.noreply.github.com> Date: Wed, 2 Jul 2025 22:27:44 -0400 Subject: [PATCH 446/454] Remove warning without emits --- test/Makefile | 1 - 1 file changed, 1 deletion(-) diff --git a/test/Makefile b/test/Makefile index b0b96995..35c2822b 100644 --- a/test/Makefile +++ b/test/Makefile @@ -16,7 +16,6 @@ endif CFLAGS += -std=c99 -pedantic -Wall -Wextra -Werror #CFLAGS += -Wconversion #disabled because if falsely complains about the isinf and isnan macros CFLAGS += -Wno-switch-enum -Wno-double-promotion -CFLAGS += -Wno-poison-system-directories CFLAGS += -Wno-covered-switch-default CFLAGS += -Wbad-function-cast -Wcast-qual -Wold-style-definition -Wshadow -Wstrict-overflow \ -Wstrict-prototypes -Wswitch-default -Wundef From eb79bce1b5b242ff580ccc99d8d4660625e8ffa9 Mon Sep 17 00:00:00 2001 From: Mark VanderVoord Date: Wed, 9 Jul 2025 17:00:30 -0400 Subject: [PATCH 447/454] Bump version to encapsulate recent changes. --- src/unity.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/unity.h b/src/unity.h index 3d176da9..7c749c2c 100644 --- a/src/unity.h +++ b/src/unity.h @@ -11,7 +11,7 @@ #define UNITY_VERSION_MAJOR 2 #define UNITY_VERSION_MINOR 6 -#define UNITY_VERSION_BUILD 1 +#define UNITY_VERSION_BUILD 2 #define UNITY_VERSION ((UNITY_VERSION_MAJOR << 16) | (UNITY_VERSION_MINOR << 8) | UNITY_VERSION_BUILD) #ifdef __cplusplus From f96b64f5521c2f87fa6b9745c107ce162971b7d8 Mon Sep 17 00:00:00 2001 From: burakutkuc Date: Thu, 10 Jul 2025 13:35:15 +0300 Subject: [PATCH 448/454] fix: fixed error from regression test results; removed the unnecessary int-uint distinction for hex values in the "array within" feature. --- src/unity_internals.h | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/src/unity_internals.h b/src/unity_internals.h index 445363d9..c17b86a8 100644 --- a/src/unity_internals.h +++ b/src/unity_internals.h @@ -999,10 +999,10 @@ int UnityTestMatches(void); #define UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_HEX32(threshold, actual, line, message) UnityAssertUintGreaterOrLessOrEqualNumber((UNITY_UINT)(UNITY_UINT32)(threshold), (UNITY_UINT)(UNITY_UINT32)(actual), UNITY_SMALLER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX32) #define UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_CHAR(threshold, actual, line, message) UnityAssertIntGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_INT8 )(threshold), (UNITY_INT)(UNITY_INT8 ) (actual), UNITY_SMALLER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_CHAR) -#define UNITY_TEST_ASSERT_INT_WITHIN(delta, expected, actual, line, message) UnityAssertIntNumbersWithin( (delta), (UNITY_INT) (expected), (UNITY_INT) (actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT) -#define UNITY_TEST_ASSERT_INT8_WITHIN(delta, expected, actual, line, message) UnityAssertIntNumbersWithin((UNITY_UINT8 )(delta), (UNITY_INT)(UNITY_INT8 ) (expected), (UNITY_INT)(UNITY_INT8 ) (actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT8) -#define UNITY_TEST_ASSERT_INT16_WITHIN(delta, expected, actual, line, message) UnityAssertIntNumbersWithin((UNITY_UINT16)(delta), (UNITY_INT)(UNITY_INT16) (expected), (UNITY_INT)(UNITY_INT16) (actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT16) -#define UNITY_TEST_ASSERT_INT32_WITHIN(delta, expected, actual, line, message) UnityAssertIntNumbersWithin((UNITY_UINT32)(delta), (UNITY_INT)(UNITY_INT32) (expected), (UNITY_INT)(UNITY_INT32) (actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT32) +#define UNITY_TEST_ASSERT_INT_WITHIN(delta, expected, actual, line, message) UnityAssertIntNumbersWithin( (delta), (UNITY_INT) (expected), (UNITY_INT) (actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT) +#define UNITY_TEST_ASSERT_INT8_WITHIN(delta, expected, actual, line, message) UnityAssertIntNumbersWithin((UNITY_UINT8 )(delta), (UNITY_INT)(UNITY_INT8 ) (expected), (UNITY_INT)(UNITY_INT8 ) (actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT8) +#define UNITY_TEST_ASSERT_INT16_WITHIN(delta, expected, actual, line, message) UnityAssertIntNumbersWithin((UNITY_UINT16 )(delta), (UNITY_INT)(UNITY_INT16) (expected), (UNITY_INT)(UNITY_INT16) (actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT16) +#define UNITY_TEST_ASSERT_INT32_WITHIN(delta, expected, actual, line, message) UnityAssertIntNumbersWithin((UNITY_UINT32 )(delta), (UNITY_INT)(UNITY_INT32) (expected), (UNITY_INT)(UNITY_INT32) (actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT32) #define UNITY_TEST_ASSERT_UINT_WITHIN(delta, expected, actual, line, message) UnityAssertUintNumbersWithin( (delta), (UNITY_UINT) (expected), (UNITY_UINT) (actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT) #define UNITY_TEST_ASSERT_UINT8_WITHIN(delta, expected, actual, line, message) UnityAssertUintNumbersWithin((UNITY_UINT8 )(delta), (UNITY_UINT)(UNITY_UINT)(UNITY_UINT8 )(expected), (UNITY_UINT)(UNITY_UINT)(UNITY_UINT8 )(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT8) #define UNITY_TEST_ASSERT_UINT16_WITHIN(delta, expected, actual, line, message) UnityAssertUintNumbersWithin((UNITY_UINT16)(delta), (UNITY_UINT)(UNITY_UINT)(UNITY_UINT16)(expected), (UNITY_UINT)(UNITY_UINT)(UNITY_UINT16)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT16) @@ -1012,18 +1012,18 @@ int UnityTestMatches(void); #define UNITY_TEST_ASSERT_HEX32_WITHIN(delta, expected, actual, line, message) UnityAssertUintNumbersWithin((UNITY_UINT32)(delta), (UNITY_UINT)(UNITY_UINT)(UNITY_UINT32)(expected), (UNITY_UINT)(UNITY_UINT)(UNITY_UINT32)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX32) #define UNITY_TEST_ASSERT_CHAR_WITHIN(delta, expected, actual, line, message) UnityAssertIntNumbersWithin((UNITY_UINT8 )(delta), (UNITY_INT)(UNITY_INT8 ) (expected), (UNITY_INT)(UNITY_INT8 ) (actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_CHAR) -#define UNITY_TEST_ASSERT_INT_ARRAY_WITHIN(delta, expected, actual, num_elements, line, message) UnityAssertIntNumbersWithin( (delta), (UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), ((UNITY_UINT32)(num_elements)), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT, UNITY_ARRAY_TO_ARRAY) -#define UNITY_TEST_ASSERT_INT8_ARRAY_WITHIN(delta, expected, actual, num_elements, line, message) UnityAssertIntNumbersWithin((UNITY_UINT8)(delta), (UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), ((UNITY_UINT32)(num_elements)), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT8, UNITY_ARRAY_TO_ARRAY) -#define UNITY_TEST_ASSERT_INT16_ARRAY_WITHIN(delta, expected, actual, num_elements, line, message) UnityAssertIntNumbersWithin((UNITY_UINT16)(delta), (UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), ((UNITY_UINT32)(num_elements)), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT16, UNITY_ARRAY_TO_ARRAY) -#define UNITY_TEST_ASSERT_INT32_ARRAY_WITHIN(delta, expected, actual, num_elements, line, message) UnityAssertIntNumbersWithin((UNITY_UINT32)(delta), (UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), ((UNITY_UINT32)(num_elements)), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT32, UNITY_ARRAY_TO_ARRAY) -#define UNITY_TEST_ASSERT_UINT_ARRAY_WITHIN(delta, expected, actual, num_elements, line, message) UnityAssertUintNumbersWithin( (delta), (UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), ((UNITY_UINT32)(num_elements)), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT, UNITY_ARRAY_TO_ARRAY) -#define UNITY_TEST_ASSERT_UINT8_ARRAY_WITHIN(delta, expected, actual, num_elements, line, message) UnityAssertUintNumbersWithin((UNITY_UINT8)(delta), (UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), ((UNITY_UINT32)(num_elements)), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT8, UNITY_ARRAY_TO_ARRAY) -#define UNITY_TEST_ASSERT_UINT16_ARRAY_WITHIN(delta, expected, actual, num_elements, line, message) UnityAssertUintNumbersWithin((UNITY_UINT16)(delta), (UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), ((UNITY_UINT32)(num_elements)), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT16, UNITY_ARRAY_TO_ARRAY) -#define UNITY_TEST_ASSERT_UINT32_ARRAY_WITHIN(delta, expected, actual, num_elements, line, message) UnityAssertUintNumbersWithin((UNITY_UINT32)(delta), (UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), ((UNITY_UINT32)(num_elements)), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT32, UNITY_ARRAY_TO_ARRAY) -#define UNITY_TEST_ASSERT_HEX8_ARRAY_WITHIN(delta, expected, actual, num_elements, line, message) UnityAssertUintNumbersWithin((UNITY_UINT8 )(delta), (UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), ((UNITY_UINT32)(num_elements)), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX8, UNITY_ARRAY_TO_ARRAY) -#define UNITY_TEST_ASSERT_HEX16_ARRAY_WITHIN(delta, expected, actual, num_elements, line, message) UnityAssertUintNumbersWithin((UNITY_UINT16)(delta), (UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), ((UNITY_UINT32)(num_elements)), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX16, UNITY_ARRAY_TO_ARRAY) -#define UNITY_TEST_ASSERT_HEX32_ARRAY_WITHIN(delta, expected, actual, num_elements, line, message) UnityAssertUintNumbersWithin((UNITY_UINT32)(delta), (UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), ((UNITY_UINT32)(num_elements)), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX32, UNITY_ARRAY_TO_ARRAY) -#define UNITY_TEST_ASSERT_CHAR_ARRAY_WITHIN(delta, expected, actual, num_elements, line, message) UnityAssertIntNumbersWithin((UNITY_UINT8)(delta), (UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), ((UNITY_UINT32)(num_elements)), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_CHAR, UNITY_ARRAY_TO_ARRAY) +#define UNITY_TEST_ASSERT_INT_ARRAY_WITHIN(delta, expected, actual, num_elements, line, message) UnityAssertNumbersArrayWithin( (delta), (UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), ((UNITY_UINT32)(num_elements)), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT, UNITY_ARRAY_TO_ARRAY) +#define UNITY_TEST_ASSERT_INT8_ARRAY_WITHIN(delta, expected, actual, num_elements, line, message) UnityAssertNumbersArrayWithin((UNITY_UINT8 )(delta), (UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), ((UNITY_UINT32)(num_elements)), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT8, UNITY_ARRAY_TO_ARRAY) +#define UNITY_TEST_ASSERT_INT16_ARRAY_WITHIN(delta, expected, actual, num_elements, line, message) UnityAssertNumbersArrayWithin((UNITY_UINT16)(delta), (UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), ((UNITY_UINT32)(num_elements)), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT16, UNITY_ARRAY_TO_ARRAY) +#define UNITY_TEST_ASSERT_INT32_ARRAY_WITHIN(delta, expected, actual, num_elements, line, message) UnityAssertNumbersArrayWithin((UNITY_UINT32)(delta), (UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), ((UNITY_UINT32)(num_elements)), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT32, UNITY_ARRAY_TO_ARRAY) +#define UNITY_TEST_ASSERT_UINT_ARRAY_WITHIN(delta, expected, actual, num_elements, line, message) UnityAssertNumbersArrayWithin( (delta), (UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), ((UNITY_UINT32)(num_elements)), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT, UNITY_ARRAY_TO_ARRAY) +#define UNITY_TEST_ASSERT_UINT8_ARRAY_WITHIN(delta, expected, actual, num_elements, line, message) UnityAssertNumbersArrayWithin((UNITY_UINT8 )(delta), (UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), ((UNITY_UINT32)(num_elements)), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT8, UNITY_ARRAY_TO_ARRAY) +#define UNITY_TEST_ASSERT_UINT16_ARRAY_WITHIN(delta, expected, actual, num_elements, line, message) UnityAssertNumbersArrayWithin((UNITY_UINT16)(delta), (UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), ((UNITY_UINT32)(num_elements)), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT16, UNITY_ARRAY_TO_ARRAY) +#define UNITY_TEST_ASSERT_UINT32_ARRAY_WITHIN(delta, expected, actual, num_elements, line, message) UnityAssertNumbersArrayWithin((UNITY_UINT32)(delta), (UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), ((UNITY_UINT32)(num_elements)), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT32, UNITY_ARRAY_TO_ARRAY) +#define UNITY_TEST_ASSERT_HEX8_ARRAY_WITHIN(delta, expected, actual, num_elements, line, message) UnityAssertNumbersArrayWithin((UNITY_UINT8 )(delta), (UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), ((UNITY_UINT32)(num_elements)), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX8, UNITY_ARRAY_TO_ARRAY) +#define UNITY_TEST_ASSERT_HEX16_ARRAY_WITHIN(delta, expected, actual, num_elements, line, message) UnityAssertNumbersArrayWithin((UNITY_UINT16)(delta), (UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), ((UNITY_UINT32)(num_elements)), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX16, UNITY_ARRAY_TO_ARRAY) +#define UNITY_TEST_ASSERT_HEX32_ARRAY_WITHIN(delta, expected, actual, num_elements, line, message) UnityAssertNumbersArrayWithin((UNITY_UINT32)(delta), (UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), ((UNITY_UINT32)(num_elements)), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX32, UNITY_ARRAY_TO_ARRAY) +#define UNITY_TEST_ASSERT_CHAR_ARRAY_WITHIN(delta, expected, actual, num_elements, line, message) UnityAssertNumbersArrayWithin((UNITY_UINT8)( delta), (UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), ((UNITY_UINT32)(num_elements)), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_CHAR, UNITY_ARRAY_TO_ARRAY) #define UNITY_TEST_ASSERT_EQUAL_PTR(expected, actual, line, message) UnityAssertEqualIntNumber((UNITY_PTR_TO_INT)(expected), (UNITY_PTR_TO_INT)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_POINTER) From 25e9af9edd9ec1776c664022eef9353e279e5137 Mon Sep 17 00:00:00 2001 From: ml-physec <206103694+ml-physec@users.noreply.github.com> Date: Thu, 7 Aug 2025 13:44:02 +0200 Subject: [PATCH 449/454] Update detail-stack implementation after #784 --- examples/example_5/test/TestProductionCode.c | 2 +- src/unity.c | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/examples/example_5/test/TestProductionCode.c b/examples/example_5/test/TestProductionCode.c index 38692ad5..ab3d3e29 100644 --- a/examples/example_5/test/TestProductionCode.c +++ b/examples/example_5/test/TestProductionCode.c @@ -33,7 +33,7 @@ void test_BitExtractor(void) { const test_vector_t test_vectors[] = { {__LINE__, 7, BIT_DIRECTION_UP, {1,1,1,0,0,0,0,0}}, - {__LINE__, 7, BIT_DIRECTION_DOWN, {0,0,0,0,0,1,0,1}}, + {__LINE__, 7, BIT_DIRECTION_DOWN, {0,0,0,0,0,1,0,1}}, /* intentionally wrong to demonstrate detail output */ {0} }; const test_vector_t* tv; diff --git a/src/unity.c b/src/unity.c index c22bdae3..3ea455d0 100644 --- a/src/unity.c +++ b/src/unity.c @@ -601,7 +601,11 @@ static void UnityAddMsgIfSpecified(const char* msg) if ((label[0] == '#') && (label[1] != 0)) { UnityPrint(label + 2); UNITY_OUTPUT_CHAR(' '); - UnityPrintNumberByStyle(Unity.CurrentDetailStackValues[c], label[1]); + if ((label[1] & UNITY_DISPLAY_RANGE_INT) == UNITY_DISPLAY_RANGE_INT) { + UnityPrintIntNumberByStyle((UNITY_INT)Unity.CurrentDetailStackValues[c], label[1]); + } else { + UnityPrintUintNumberByStyle((UNITY_UINT)Unity.CurrentDetailStackValues[c], label[1]); + } } else if (Unity.CurrentDetailStackValues[c] != 0){ UnityPrint(label); UNITY_OUTPUT_CHAR(' '); From 864b4ea554d75e63d1b96e1d8bf0c92ac35fa122 Mon Sep 17 00:00:00 2001 From: Roland Marchand Date: Thu, 25 Sep 2025 21:22:51 -0400 Subject: [PATCH 450/454] Convert C++ comments to ANSI C style --- src/unity.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/unity.c b/src/unity.c index 3ea455d0..9e8b3a15 100644 --- a/src/unity.c +++ b/src/unity.c @@ -2037,7 +2037,7 @@ static enum UnityLengthModifier UnityLengthModifierGet(const char *pch, int *len } case 'h': { - // short and char are converted to int + /* short and char are converted to int */ length_mod = UNITY_LENGTH_MODIFIER_NONE; if (pch[1] == 'h') { @@ -2054,7 +2054,7 @@ static enum UnityLengthModifier UnityLengthModifierGet(const char *pch, int *len case 't': case 'L': { - // Not supported, but should gobble up the length specifier anyway + /* Not supported, but should gobble up the length specifier anyway */ length_mod = UNITY_LENGTH_MODIFIER_NONE; *length = 1; break; @@ -2515,7 +2515,7 @@ static int IsStringInBiggerString(const char* longstring, const char* shortstrin } } - // If we didn't match and we're on strict matching, we already know we failed + /* If we didn't match and we're on strict matching, we already know we failed */ if (UnityStrictMatch) { return 0; From 3240ac98116ecd58b333a78b3ca2073349b9eaf6 Mon Sep 17 00:00:00 2001 From: savashn Date: Mon, 27 Oct 2025 10:06:33 +0300 Subject: [PATCH 451/454] add table of contents in docs --- docs/UnityAssertionsReference.md | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/docs/UnityAssertionsReference.md b/docs/UnityAssertionsReference.md index 0a0e51b6..90a3e5fd 100644 --- a/docs/UnityAssertionsReference.md +++ b/docs/UnityAssertionsReference.md @@ -1,5 +1,35 @@ # Unity Assertions Reference +## Table of Contents + +1. [Background and Overview](#background-and-overview) + 1. [Super Condensed Version](#super-condensed-version) + 2. [Unity Is Several Things But Mainly It’s Assertions](#unity-is-several-things-but-mainly-its-assertions) + 3. [What’s an Assertion?](#whats-an-assertion) + 4. [Unity’s Assertions: Helpful Messages _and_ Free Source Code Documentation](#unitys-assertions-helpful-messages-and-free-source-code-documentation) +2. [Assertion Conventions and Configurations](#assertion-conventions-and-configurations) + 1. [Naming and Parameter Conventions](#naming-and-parameter-conventions) + 2. [TEST_ASSERT_EACH_EQUAL_X Variants](#test_assert_each_equal_x-variants) + 3. [Configuration](#configuration) +3. [The Assertions in All Their Blessed Glory](#the-assertions-in-all-their-blessed-glory) + 1. [Basic Fail, Pass and Ignore](#basic-fail-pass-and-ignore) + 2. [Boolean](#boolean) + 3. [Signed and Unsigned Integers (of all sizes)](#signed-and-unsigned-integers-of-all-sizes) + 4. [Unsigned Integers (of all sizes) in Hexadecimal](#unsigned-integers-of-all-sizes-in-hexadecimal) + 5. [Characters](#characters) + 6. [Masked and Bit-level Assertions](#masked-and-bit-level-assertions) + 7. [Integer Less Than / Greater Than](#integer-less-than--greater-than) + 8. [Integer Ranges (of all sizes)](#integer-ranges-of-all-sizes) + 9. [Structs and Strings](#structs-and-strings) + 10. [Arrays](#arrays) + 11. [Integer Array Ranges (of all sizes)](#integer-array-ranges-of-all-sizes) + 12. [Each Equal (Arrays to Single Value)](#each-equal-arrays-to-single-value) + 13. [Floating Point (If enabled)](#floating-point-if-enabled) + 14. [Double (If enabled)](#double-if-enabled) +4. [Advanced Asserting: Details On Tricky Assertions](#advanced-asserting-details-on-tricky-assertions) + 1. [How do the EQUAL assertions work for FLOAT and DOUBLE?](#how-do-the-equal-assertions-work-for-float-and-double) + 2. [How do we deal with targets with non-standard int sizes?](#how-do-we-deal-with-targets-with-non-standard-int-sizes) + ## Background and Overview ### Super Condensed Version From 18c4e9376778a007ed71d1aba75d37d886ad0023 Mon Sep 17 00:00:00 2001 From: James Browning Date: Wed, 12 Nov 2025 04:48:49 -0800 Subject: [PATCH 452/454] Try build Unity w/ -UUNITY_EXCLUDE_FLOAT_PRINT --- src/unity.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/unity.c b/src/unity.c index 9e8b3a15..e031ebbd 100644 --- a/src/unity.c +++ b/src/unity.c @@ -1110,6 +1110,7 @@ void UnityAssertFloatsWithin(const UNITY_FLOAT delta, } } +#ifndef UNITY_EXCLUDE_FLOAT_PRINT /*-----------------------------------------------*/ void UnityAssertFloatsNotWithin(const UNITY_FLOAT delta, const UNITY_FLOAT expected, @@ -1163,6 +1164,7 @@ void UnityAssertGreaterOrLessFloat(const UNITY_FLOAT threshold, UNITY_FAIL_AND_BAIL; } } +#endif // UNITY_EXCLUDE_FLOAT_PRINT /*-----------------------------------------------*/ void UnityAssertFloatSpecial(const UNITY_FLOAT actual, @@ -1337,6 +1339,7 @@ void UnityAssertDoublesWithin(const UNITY_DOUBLE delta, } } +#ifndef UNITY_EXCLUDE_FLOAT_PRINT /*-----------------------------------------------*/ void UnityAssertDoublesNotWithin(const UNITY_DOUBLE delta, const UNITY_DOUBLE expected, @@ -1390,6 +1393,7 @@ void UnityAssertGreaterOrLessDouble(const UNITY_DOUBLE threshold, UNITY_FAIL_AND_BAIL; } } +#endif // UNITY_EXCLUDE_FLOAT_PRINT /*-----------------------------------------------*/ void UnityAssertDoubleSpecial(const UNITY_DOUBLE actual, From 747c2ee73f44de813c9b719e39531d6e8dc026c3 Mon Sep 17 00:00:00 2001 From: James Browning Date: Wed, 12 Nov 2025 05:19:20 -0800 Subject: [PATCH 453/454] Misadress style CI bot failure, my bad --- src/unity.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/unity.c b/src/unity.c index e031ebbd..8be0d033 100644 --- a/src/unity.c +++ b/src/unity.c @@ -1164,7 +1164,7 @@ void UnityAssertGreaterOrLessFloat(const UNITY_FLOAT threshold, UNITY_FAIL_AND_BAIL; } } -#endif // UNITY_EXCLUDE_FLOAT_PRINT +#endif /* ! UNITY_EXCLUDE_FLOAT_PRINT */ /*-----------------------------------------------*/ void UnityAssertFloatSpecial(const UNITY_FLOAT actual, @@ -1393,7 +1393,7 @@ void UnityAssertGreaterOrLessDouble(const UNITY_DOUBLE threshold, UNITY_FAIL_AND_BAIL; } } -#endif // UNITY_EXCLUDE_FLOAT_PRINT +#endif /* ! UNITY_EXCLUDE_FLOAT_PRINT */ /*-----------------------------------------------*/ void UnityAssertDoubleSpecial(const UNITY_DOUBLE actual, From d1fe18bd54434efd1ac0dad035d3ab0f8591e086 Mon Sep 17 00:00:00 2001 From: Mark VanderVoord Date: Fri, 23 Jan 2026 11:18:36 -0500 Subject: [PATCH 454/454] Updates for the new year. --- LICENSE.txt | 2 +- auto/__init__.py | 2 +- auto/colour_prompt.rb | 2 +- auto/colour_reporter.rb | 2 +- auto/extract_version.py | 2 +- auto/generate_config.yml | 2 +- auto/generate_module.rb | 2 +- auto/generate_test_runner.rb | 2 +- auto/parse_output.rb | 2 +- auto/stylize_as_junit.py | 2 +- auto/stylize_as_junit.rb | 2 +- auto/test_file_filter.rb | 2 +- auto/type_sanitizer.rb | 2 +- auto/unity_test_summary.py | 2 +- auto/unity_test_summary.rb | 2 +- auto/yaml_helper.rb | 2 +- examples/example_1/src/ProductionCode.c | 2 +- examples/example_1/src/ProductionCode.h | 2 +- examples/example_1/src/ProductionCode2.c | 2 +- examples/example_1/src/ProductionCode2.h | 2 +- examples/example_1/test/TestProductionCode.c | 2 +- examples/example_1/test/TestProductionCode2.c | 2 +- examples/example_2/src/ProductionCode.c | 2 +- examples/example_2/src/ProductionCode.h | 2 +- examples/example_2/src/ProductionCode2.c | 2 +- examples/example_2/src/ProductionCode2.h | 2 +- examples/example_2/test/TestProductionCode.c | 2 +- examples/example_2/test/TestProductionCode2.c | 2 +- .../test/test_runners/TestProductionCode2_Runner.c | 2 +- .../test/test_runners/TestProductionCode_Runner.c | 2 +- examples/example_2/test/test_runners/all_tests.c | 2 +- examples/example_3/helper/UnityHelper.c | 2 +- examples/example_3/helper/UnityHelper.h | 2 +- examples/example_3/rakefile.rb | 2 +- examples/example_3/rakefile_helper.rb | 2 +- examples/example_3/src/ProductionCode.c | 2 +- examples/example_3/src/ProductionCode.h | 2 +- examples/example_3/src/ProductionCode2.c | 2 +- examples/example_3/src/ProductionCode2.h | 2 +- examples/example_3/target_gcc_32.yml | 2 +- examples/example_3/test/TestProductionCode.c | 2 +- examples/example_3/test/TestProductionCode2.c | 2 +- examples/example_4/src/ProductionCode.c | 2 +- examples/example_4/src/ProductionCode.h | 2 +- examples/example_4/src/ProductionCode2.c | 2 +- examples/example_4/src/ProductionCode2.h | 2 +- examples/example_4/test/TestProductionCode.c | 2 +- examples/example_4/test/TestProductionCode2.c | 2 +- examples/example_5/src/ProductionCode.c | 2 +- examples/example_5/src/ProductionCode.h | 2 +- examples/example_5/test/TestProductionCode.c | 2 +- examples/example_5/test/unity_detail_config.h | 7 +++++++ examples/unity_config.h | 2 +- extras/bdd/src/unity_bdd.h | 2 +- extras/bdd/test/test_bdd.c | 2 +- extras/fixture/src/unity_fixture.c | 2 +- extras/fixture/src/unity_fixture.h | 2 +- extras/fixture/src/unity_fixture_internals.h | 2 +- extras/fixture/test/main/AllTests.c | 2 +- extras/fixture/test/template_fixture_tests.c | 2 +- extras/fixture/test/unity_fixture_Test.c | 2 +- extras/fixture/test/unity_fixture_TestRunner.c | 2 +- extras/memory/src/unity_memory.c | 2 +- extras/memory/src/unity_memory.h | 2 +- extras/memory/test/unity_memory_Test.c | 2 +- extras/memory/test/unity_memory_TestRunner.c | 2 +- extras/memory/test/unity_output_Spy.c | 2 +- extras/memory/test/unity_output_Spy.h | 2 +- src/unity.c | 2 +- src/unity.h | 2 +- src/unity_internals.h | 2 +- test/rakefile | 2 +- test/rakefile_helper.rb | 2 +- test/spec/generate_module_existing_file_spec.rb | 2 +- test/targets/ansi.yml | 2 +- test/targets/clang_file.yml | 2 +- test/targets/clang_strict.yml | 2 +- test/targets/gcc_32.yml | 2 +- test/targets/gcc_64.yml | 2 +- test/targets/gcc_auto_limits.yml | 2 +- test/targets/gcc_auto_stdint.yml | 2 +- test/targets/gcc_manual_math.yml | 2 +- test/targets/hitech_picc18.yml | 2 +- test/targets/iar_arm_v4.yml | 2 +- test/targets/iar_arm_v5.yml | 2 +- test/targets/iar_arm_v5_3.yml | 2 +- test/targets/iar_armcortex_LM3S9B92_v5_4.yml | 2 +- test/targets/iar_cortexm3_v5.yml | 2 +- test/targets/iar_msp430.yml | 2 +- test/targets/iar_sh2a_v6.yml | 2 +- test/testdata/CException.h | 2 +- test/testdata/Defs.h | 2 +- test/testdata/cmock.h | 2 +- test/testdata/mockMock.h | 2 +- test/testdata/testRunnerGenerator.c | 2 +- test/testdata/testRunnerGeneratorSmall.c | 2 +- test/testdata/testRunnerGeneratorWithMocks.c | 2 +- test/tests/self_assessment_utils.h | 2 +- test/tests/test_generate_test_runner.rb | 2 +- test/tests/test_unity_arrays.c | 2 +- test/tests/test_unity_core.c | 2 +- test/tests/test_unity_doubles.c | 2 +- test/tests/test_unity_floats.c | 2 +- test/tests/test_unity_integers.c | 2 +- test/tests/test_unity_integers_64.c | 2 +- test/tests/test_unity_memory.c | 2 +- test/tests/test_unity_parameterized.c | 2 +- test/tests/test_unity_parameterizedDemo.c | 2 +- test/tests/test_unity_strings.c | 2 +- test/tests/types_for_test.h | 2 +- 110 files changed, 116 insertions(+), 109 deletions(-) diff --git a/LICENSE.txt b/LICENSE.txt index 3e3aad5b..bd46b907 100644 --- a/LICENSE.txt +++ b/LICENSE.txt @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams +Copyright (c) 2007-26 Mike Karlesky, Mark VanderVoord, & Greg Williams Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/auto/__init__.py b/auto/__init__.py index 15f87c39..6323a252 100644 --- a/auto/__init__.py +++ b/auto/__init__.py @@ -1,7 +1,7 @@ # ========================================================================= # Unity - A Test Framework for C # ThrowTheSwitch.org -# Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams +# Copyright (c) 2007-26 Mike Karlesky, Mark VanderVoord, & Greg Williams # SPDX-License-Identifier: MIT # ========================================================================= diff --git a/auto/colour_prompt.rb b/auto/colour_prompt.rb index 566efe9e..2de38a4b 100644 --- a/auto/colour_prompt.rb +++ b/auto/colour_prompt.rb @@ -1,7 +1,7 @@ # ========================================================================= # Unity - A Test Framework for C # ThrowTheSwitch.org -# Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams +# Copyright (c) 2007-26 Mike Karlesky, Mark VanderVoord, & Greg Williams # SPDX-License-Identifier: MIT # ========================================================================= diff --git a/auto/colour_reporter.rb b/auto/colour_reporter.rb index cac748f8..10a17d37 100644 --- a/auto/colour_reporter.rb +++ b/auto/colour_reporter.rb @@ -1,7 +1,7 @@ # ========================================================================= # Unity - A Test Framework for C # ThrowTheSwitch.org -# Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams +# Copyright (c) 2007-26 Mike Karlesky, Mark VanderVoord, & Greg Williams # SPDX-License-Identifier: MIT # ========================================================================= diff --git a/auto/extract_version.py b/auto/extract_version.py index 7c2f3d30..1494bd52 100755 --- a/auto/extract_version.py +++ b/auto/extract_version.py @@ -2,7 +2,7 @@ # ========================================================================= # Unity - A Test Framework for C # ThrowTheSwitch.org -# Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams +# Copyright (c) 2007-26 Mike Karlesky, Mark VanderVoord, & Greg Williams # SPDX-License-Identifier: MIT # ========================================================================= diff --git a/auto/generate_config.yml b/auto/generate_config.yml index d1cd9b20..72b06549 100644 --- a/auto/generate_config.yml +++ b/auto/generate_config.yml @@ -1,7 +1,7 @@ # ========================================================================= # Unity - A Test Framework for C # ThrowTheSwitch.org -# Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams +# Copyright (c) 2007-26 Mike Karlesky, Mark VanderVoord, & Greg Williams # SPDX-License-Identifier: MIT # ========================================================================= diff --git a/auto/generate_module.rb b/auto/generate_module.rb index d335cab2..0b5024bd 100644 --- a/auto/generate_module.rb +++ b/auto/generate_module.rb @@ -1,7 +1,7 @@ # ========================================================================= # Unity - A Test Framework for C # ThrowTheSwitch.org -# Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams +# Copyright (c) 2007-26 Mike Karlesky, Mark VanderVoord, & Greg Williams # SPDX-License-Identifier: MIT # ========================================================================= diff --git a/auto/generate_test_runner.rb b/auto/generate_test_runner.rb index cc82cfcf..2b2cf61b 100755 --- a/auto/generate_test_runner.rb +++ b/auto/generate_test_runner.rb @@ -2,7 +2,7 @@ # ========================================================================= # Unity - A Test Framework for C # ThrowTheSwitch.org -# Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams +# Copyright (c) 2007-26 Mike Karlesky, Mark VanderVoord, & Greg Williams # SPDX-License-Identifier: MIT # ========================================================================= diff --git a/auto/parse_output.rb b/auto/parse_output.rb index 1711337a..3ecc04c8 100644 --- a/auto/parse_output.rb +++ b/auto/parse_output.rb @@ -1,7 +1,7 @@ # ========================================================================= # Unity - A Test Framework for C # ThrowTheSwitch.org -# Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams +# Copyright (c) 2007-26 Mike Karlesky, Mark VanderVoord, & Greg Williams # SPDX-License-Identifier: MIT # ========================================================================= diff --git a/auto/stylize_as_junit.py b/auto/stylize_as_junit.py index 49e8aff7..24e68321 100644 --- a/auto/stylize_as_junit.py +++ b/auto/stylize_as_junit.py @@ -2,7 +2,7 @@ # ========================================================================= # Unity - A Test Framework for C # ThrowTheSwitch.org -# Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams +# Copyright (c) 2007-26 Mike Karlesky, Mark VanderVoord, & Greg Williams # SPDX-License-Identifier: MIT # ========================================================================= diff --git a/auto/stylize_as_junit.rb b/auto/stylize_as_junit.rb index e003918a..9a1edca5 100755 --- a/auto/stylize_as_junit.rb +++ b/auto/stylize_as_junit.rb @@ -2,7 +2,7 @@ # ========================================================================= # Unity - A Test Framework for C # ThrowTheSwitch.org -# Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams +# Copyright (c) 2007-26 Mike Karlesky, Mark VanderVoord, & Greg Williams # SPDX-License-Identifier: MIT # ========================================================================= diff --git a/auto/test_file_filter.rb b/auto/test_file_filter.rb index f9c8d904..7439192a 100644 --- a/auto/test_file_filter.rb +++ b/auto/test_file_filter.rb @@ -1,7 +1,7 @@ # ========================================================================= # Unity - A Test Framework for C # ThrowTheSwitch.org -# Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams +# Copyright (c) 2007-26 Mike Karlesky, Mark VanderVoord, & Greg Williams # SPDX-License-Identifier: MIT # ========================================================================= diff --git a/auto/type_sanitizer.rb b/auto/type_sanitizer.rb index cfadb0dc..dca96be1 100644 --- a/auto/type_sanitizer.rb +++ b/auto/type_sanitizer.rb @@ -1,7 +1,7 @@ # ========================================================================= # Unity - A Test Framework for C # ThrowTheSwitch.org -# Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams +# Copyright (c) 2007-26 Mike Karlesky, Mark VanderVoord, & Greg Williams # SPDX-License-Identifier: MIT # ========================================================================= diff --git a/auto/unity_test_summary.py b/auto/unity_test_summary.py index 60f5fd41..d3c47c6a 100644 --- a/auto/unity_test_summary.py +++ b/auto/unity_test_summary.py @@ -2,7 +2,7 @@ # ========================================================================= # Unity - A Test Framework for C # ThrowTheSwitch.org -# Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams +# Copyright (c) 2007-26 Mike Karlesky, Mark VanderVoord, & Greg Williams # SPDX-License-Identifier: MIT # ========================================================================= diff --git a/auto/unity_test_summary.rb b/auto/unity_test_summary.rb index f6a64dea..cfa267b5 100644 --- a/auto/unity_test_summary.rb +++ b/auto/unity_test_summary.rb @@ -2,7 +2,7 @@ # ========================================================================= # Unity - A Test Framework for C # ThrowTheSwitch.org -# Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams +# Copyright (c) 2007-26 Mike Karlesky, Mark VanderVoord, & Greg Williams # SPDX-License-Identifier: MIT # ========================================================================= diff --git a/auto/yaml_helper.rb b/auto/yaml_helper.rb index 6d1bf7ae..e11792aa 100644 --- a/auto/yaml_helper.rb +++ b/auto/yaml_helper.rb @@ -1,7 +1,7 @@ # ========================================================================= # Unity - A Test Framework for C # ThrowTheSwitch.org -# Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams +# Copyright (c) 2007-26 Mike Karlesky, Mark VanderVoord, & Greg Williams # SPDX-License-Identifier: MIT # ========================================================================= diff --git a/examples/example_1/src/ProductionCode.c b/examples/example_1/src/ProductionCode.c index 8a52aff0..9a100330 100644 --- a/examples/example_1/src/ProductionCode.c +++ b/examples/example_1/src/ProductionCode.c @@ -1,7 +1,7 @@ /* ========================================================================= Unity - A Test Framework for C ThrowTheSwitch.org - Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams + Copyright (c) 2007-26 Mike Karlesky, Mark VanderVoord, & Greg Williams SPDX-License-Identifier: MIT ========================================================================= */ diff --git a/examples/example_1/src/ProductionCode.h b/examples/example_1/src/ProductionCode.h index d8929bfb..57ccf41f 100644 --- a/examples/example_1/src/ProductionCode.h +++ b/examples/example_1/src/ProductionCode.h @@ -1,7 +1,7 @@ /* ========================================================================= Unity - A Test Framework for C ThrowTheSwitch.org - Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams + Copyright (c) 2007-26 Mike Karlesky, Mark VanderVoord, & Greg Williams SPDX-License-Identifier: MIT ========================================================================= */ diff --git a/examples/example_1/src/ProductionCode2.c b/examples/example_1/src/ProductionCode2.c index ff8a537f..ae72f91c 100644 --- a/examples/example_1/src/ProductionCode2.c +++ b/examples/example_1/src/ProductionCode2.c @@ -1,7 +1,7 @@ /* ========================================================================= Unity - A Test Framework for C ThrowTheSwitch.org - Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams + Copyright (c) 2007-26 Mike Karlesky, Mark VanderVoord, & Greg Williams SPDX-License-Identifier: MIT ========================================================================= */ diff --git a/examples/example_1/src/ProductionCode2.h b/examples/example_1/src/ProductionCode2.h index 5204543f..0a0bd76e 100644 --- a/examples/example_1/src/ProductionCode2.h +++ b/examples/example_1/src/ProductionCode2.h @@ -1,7 +1,7 @@ /* ========================================================================= Unity - A Test Framework for C ThrowTheSwitch.org - Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams + Copyright (c) 2007-26 Mike Karlesky, Mark VanderVoord, & Greg Williams SPDX-License-Identifier: MIT ========================================================================= */ diff --git a/examples/example_1/test/TestProductionCode.c b/examples/example_1/test/TestProductionCode.c index ceb6d8b5..63e49771 100644 --- a/examples/example_1/test/TestProductionCode.c +++ b/examples/example_1/test/TestProductionCode.c @@ -1,7 +1,7 @@ /* ========================================================================= Unity - A Test Framework for C ThrowTheSwitch.org - Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams + Copyright (c) 2007-26 Mike Karlesky, Mark VanderVoord, & Greg Williams SPDX-License-Identifier: MIT ========================================================================= */ diff --git a/examples/example_1/test/TestProductionCode2.c b/examples/example_1/test/TestProductionCode2.c index 32bbfdf0..62742c9b 100644 --- a/examples/example_1/test/TestProductionCode2.c +++ b/examples/example_1/test/TestProductionCode2.c @@ -1,7 +1,7 @@ /* ========================================================================= Unity - A Test Framework for C ThrowTheSwitch.org - Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams + Copyright (c) 2007-26 Mike Karlesky, Mark VanderVoord, & Greg Williams SPDX-License-Identifier: MIT ========================================================================= */ diff --git a/examples/example_2/src/ProductionCode.c b/examples/example_2/src/ProductionCode.c index b84c4276..841f91af 100644 --- a/examples/example_2/src/ProductionCode.c +++ b/examples/example_2/src/ProductionCode.c @@ -1,7 +1,7 @@ /* ========================================================================= Unity - A Test Framework for C ThrowTheSwitch.org - Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams + Copyright (c) 2007-26 Mike Karlesky, Mark VanderVoord, & Greg Williams SPDX-License-Identifier: MIT ========================================================================= */ diff --git a/examples/example_2/src/ProductionCode.h b/examples/example_2/src/ProductionCode.h index d8929bfb..57ccf41f 100644 --- a/examples/example_2/src/ProductionCode.h +++ b/examples/example_2/src/ProductionCode.h @@ -1,7 +1,7 @@ /* ========================================================================= Unity - A Test Framework for C ThrowTheSwitch.org - Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams + Copyright (c) 2007-26 Mike Karlesky, Mark VanderVoord, & Greg Williams SPDX-License-Identifier: MIT ========================================================================= */ diff --git a/examples/example_2/src/ProductionCode2.c b/examples/example_2/src/ProductionCode2.c index 80040187..c5c50112 100644 --- a/examples/example_2/src/ProductionCode2.c +++ b/examples/example_2/src/ProductionCode2.c @@ -1,7 +1,7 @@ /* ========================================================================= Unity - A Test Framework for C ThrowTheSwitch.org - Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams + Copyright (c) 2007-26 Mike Karlesky, Mark VanderVoord, & Greg Williams SPDX-License-Identifier: MIT ========================================================================= */ diff --git a/examples/example_2/src/ProductionCode2.h b/examples/example_2/src/ProductionCode2.h index 5204543f..0a0bd76e 100644 --- a/examples/example_2/src/ProductionCode2.h +++ b/examples/example_2/src/ProductionCode2.h @@ -1,7 +1,7 @@ /* ========================================================================= Unity - A Test Framework for C ThrowTheSwitch.org - Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams + Copyright (c) 2007-26 Mike Karlesky, Mark VanderVoord, & Greg Williams SPDX-License-Identifier: MIT ========================================================================= */ diff --git a/examples/example_2/test/TestProductionCode.c b/examples/example_2/test/TestProductionCode.c index 9635f32a..b424e24a 100644 --- a/examples/example_2/test/TestProductionCode.c +++ b/examples/example_2/test/TestProductionCode.c @@ -1,7 +1,7 @@ /* ========================================================================= Unity - A Test Framework for C ThrowTheSwitch.org - Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams + Copyright (c) 2007-26 Mike Karlesky, Mark VanderVoord, & Greg Williams SPDX-License-Identifier: MIT ========================================================================= */ diff --git a/examples/example_2/test/TestProductionCode2.c b/examples/example_2/test/TestProductionCode2.c index d0233c0a..a43bec4e 100644 --- a/examples/example_2/test/TestProductionCode2.c +++ b/examples/example_2/test/TestProductionCode2.c @@ -1,7 +1,7 @@ /* ========================================================================= Unity - A Test Framework for C ThrowTheSwitch.org - Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams + Copyright (c) 2007-26 Mike Karlesky, Mark VanderVoord, & Greg Williams SPDX-License-Identifier: MIT ========================================================================= */ diff --git a/examples/example_2/test/test_runners/TestProductionCode2_Runner.c b/examples/example_2/test/test_runners/TestProductionCode2_Runner.c index eaa057fd..f40f8357 100644 --- a/examples/example_2/test/test_runners/TestProductionCode2_Runner.c +++ b/examples/example_2/test/test_runners/TestProductionCode2_Runner.c @@ -1,7 +1,7 @@ /* ========================================================================= Unity - A Test Framework for C ThrowTheSwitch.org - Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams + Copyright (c) 2007-26 Mike Karlesky, Mark VanderVoord, & Greg Williams SPDX-License-Identifier: MIT ========================================================================= */ diff --git a/examples/example_2/test/test_runners/TestProductionCode_Runner.c b/examples/example_2/test/test_runners/TestProductionCode_Runner.c index f0acf24f..c50664f2 100644 --- a/examples/example_2/test/test_runners/TestProductionCode_Runner.c +++ b/examples/example_2/test/test_runners/TestProductionCode_Runner.c @@ -1,7 +1,7 @@ /* ========================================================================= Unity - A Test Framework for C ThrowTheSwitch.org - Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams + Copyright (c) 2007-26 Mike Karlesky, Mark VanderVoord, & Greg Williams SPDX-License-Identifier: MIT ========================================================================= */ diff --git a/examples/example_2/test/test_runners/all_tests.c b/examples/example_2/test/test_runners/all_tests.c index 5376dbe2..54c4d250 100644 --- a/examples/example_2/test/test_runners/all_tests.c +++ b/examples/example_2/test/test_runners/all_tests.c @@ -1,7 +1,7 @@ /* ========================================================================= Unity - A Test Framework for C ThrowTheSwitch.org - Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams + Copyright (c) 2007-26 Mike Karlesky, Mark VanderVoord, & Greg Williams SPDX-License-Identifier: MIT ========================================================================= */ diff --git a/examples/example_3/helper/UnityHelper.c b/examples/example_3/helper/UnityHelper.c index 17830959..728ddbc9 100644 --- a/examples/example_3/helper/UnityHelper.c +++ b/examples/example_3/helper/UnityHelper.c @@ -1,7 +1,7 @@ /* ========================================================================= Unity - A Test Framework for C ThrowTheSwitch.org - Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams + Copyright (c) 2007-26 Mike Karlesky, Mark VanderVoord, & Greg Williams SPDX-License-Identifier: MIT ========================================================================= */ diff --git a/examples/example_3/helper/UnityHelper.h b/examples/example_3/helper/UnityHelper.h index 6ebf8604..8d3e4b66 100644 --- a/examples/example_3/helper/UnityHelper.h +++ b/examples/example_3/helper/UnityHelper.h @@ -1,7 +1,7 @@ /* ========================================================================= Unity - A Test Framework for C ThrowTheSwitch.org - Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams + Copyright (c) 2007-26 Mike Karlesky, Mark VanderVoord, & Greg Williams SPDX-License-Identifier: MIT ========================================================================= */ diff --git a/examples/example_3/rakefile.rb b/examples/example_3/rakefile.rb index a1eb35a4..ace9eb8d 100644 --- a/examples/example_3/rakefile.rb +++ b/examples/example_3/rakefile.rb @@ -1,7 +1,7 @@ # ========================================================================= # Unity - A Test Framework for C # ThrowTheSwitch.org -# Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams +# Copyright (c) 2007-26 Mike Karlesky, Mark VanderVoord, & Greg Williams # SPDX-License-Identifier: MIT # ========================================================================= diff --git a/examples/example_3/rakefile_helper.rb b/examples/example_3/rakefile_helper.rb index 55885741..be73b185 100644 --- a/examples/example_3/rakefile_helper.rb +++ b/examples/example_3/rakefile_helper.rb @@ -1,7 +1,7 @@ # ========================================================================= # Unity - A Test Framework for C # ThrowTheSwitch.org -# Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams +# Copyright (c) 2007-26 Mike Karlesky, Mark VanderVoord, & Greg Williams # SPDX-License-Identifier: MIT # ========================================================================= diff --git a/examples/example_3/src/ProductionCode.c b/examples/example_3/src/ProductionCode.c index b84c4276..841f91af 100644 --- a/examples/example_3/src/ProductionCode.c +++ b/examples/example_3/src/ProductionCode.c @@ -1,7 +1,7 @@ /* ========================================================================= Unity - A Test Framework for C ThrowTheSwitch.org - Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams + Copyright (c) 2007-26 Mike Karlesky, Mark VanderVoord, & Greg Williams SPDX-License-Identifier: MIT ========================================================================= */ diff --git a/examples/example_3/src/ProductionCode.h b/examples/example_3/src/ProductionCode.h index d8929bfb..57ccf41f 100644 --- a/examples/example_3/src/ProductionCode.h +++ b/examples/example_3/src/ProductionCode.h @@ -1,7 +1,7 @@ /* ========================================================================= Unity - A Test Framework for C ThrowTheSwitch.org - Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams + Copyright (c) 2007-26 Mike Karlesky, Mark VanderVoord, & Greg Williams SPDX-License-Identifier: MIT ========================================================================= */ diff --git a/examples/example_3/src/ProductionCode2.c b/examples/example_3/src/ProductionCode2.c index 80040187..c5c50112 100644 --- a/examples/example_3/src/ProductionCode2.c +++ b/examples/example_3/src/ProductionCode2.c @@ -1,7 +1,7 @@ /* ========================================================================= Unity - A Test Framework for C ThrowTheSwitch.org - Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams + Copyright (c) 2007-26 Mike Karlesky, Mark VanderVoord, & Greg Williams SPDX-License-Identifier: MIT ========================================================================= */ diff --git a/examples/example_3/src/ProductionCode2.h b/examples/example_3/src/ProductionCode2.h index 5204543f..0a0bd76e 100644 --- a/examples/example_3/src/ProductionCode2.h +++ b/examples/example_3/src/ProductionCode2.h @@ -1,7 +1,7 @@ /* ========================================================================= Unity - A Test Framework for C ThrowTheSwitch.org - Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams + Copyright (c) 2007-26 Mike Karlesky, Mark VanderVoord, & Greg Williams SPDX-License-Identifier: MIT ========================================================================= */ diff --git a/examples/example_3/target_gcc_32.yml b/examples/example_3/target_gcc_32.yml index a3d123d4..b7324d82 100644 --- a/examples/example_3/target_gcc_32.yml +++ b/examples/example_3/target_gcc_32.yml @@ -1,7 +1,7 @@ # ========================================================================= # Unity - A Test Framework for C # ThrowTheSwitch.org -# Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams +# Copyright (c) 2007-26 Mike Karlesky, Mark VanderVoord, & Greg Williams # SPDX-License-Identifier: MIT # ========================================================================= diff --git a/examples/example_3/test/TestProductionCode.c b/examples/example_3/test/TestProductionCode.c index 7f48ea76..654de52d 100644 --- a/examples/example_3/test/TestProductionCode.c +++ b/examples/example_3/test/TestProductionCode.c @@ -1,7 +1,7 @@ /* ========================================================================= Unity - A Test Framework for C ThrowTheSwitch.org - Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams + Copyright (c) 2007-26 Mike Karlesky, Mark VanderVoord, & Greg Williams SPDX-License-Identifier: MIT ========================================================================= */ diff --git a/examples/example_3/test/TestProductionCode2.c b/examples/example_3/test/TestProductionCode2.c index 7ab3926e..32ba6be4 100644 --- a/examples/example_3/test/TestProductionCode2.c +++ b/examples/example_3/test/TestProductionCode2.c @@ -1,7 +1,7 @@ /* ========================================================================= Unity - A Test Framework for C ThrowTheSwitch.org - Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams + Copyright (c) 2007-26 Mike Karlesky, Mark VanderVoord, & Greg Williams SPDX-License-Identifier: MIT ========================================================================= */ diff --git a/examples/example_4/src/ProductionCode.c b/examples/example_4/src/ProductionCode.c index 8a52aff0..9a100330 100644 --- a/examples/example_4/src/ProductionCode.c +++ b/examples/example_4/src/ProductionCode.c @@ -1,7 +1,7 @@ /* ========================================================================= Unity - A Test Framework for C ThrowTheSwitch.org - Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams + Copyright (c) 2007-26 Mike Karlesky, Mark VanderVoord, & Greg Williams SPDX-License-Identifier: MIT ========================================================================= */ diff --git a/examples/example_4/src/ProductionCode.h b/examples/example_4/src/ProductionCode.h index d8929bfb..57ccf41f 100644 --- a/examples/example_4/src/ProductionCode.h +++ b/examples/example_4/src/ProductionCode.h @@ -1,7 +1,7 @@ /* ========================================================================= Unity - A Test Framework for C ThrowTheSwitch.org - Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams + Copyright (c) 2007-26 Mike Karlesky, Mark VanderVoord, & Greg Williams SPDX-License-Identifier: MIT ========================================================================= */ diff --git a/examples/example_4/src/ProductionCode2.c b/examples/example_4/src/ProductionCode2.c index ff8a537f..ae72f91c 100644 --- a/examples/example_4/src/ProductionCode2.c +++ b/examples/example_4/src/ProductionCode2.c @@ -1,7 +1,7 @@ /* ========================================================================= Unity - A Test Framework for C ThrowTheSwitch.org - Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams + Copyright (c) 2007-26 Mike Karlesky, Mark VanderVoord, & Greg Williams SPDX-License-Identifier: MIT ========================================================================= */ diff --git a/examples/example_4/src/ProductionCode2.h b/examples/example_4/src/ProductionCode2.h index 5204543f..0a0bd76e 100644 --- a/examples/example_4/src/ProductionCode2.h +++ b/examples/example_4/src/ProductionCode2.h @@ -1,7 +1,7 @@ /* ========================================================================= Unity - A Test Framework for C ThrowTheSwitch.org - Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams + Copyright (c) 2007-26 Mike Karlesky, Mark VanderVoord, & Greg Williams SPDX-License-Identifier: MIT ========================================================================= */ diff --git a/examples/example_4/test/TestProductionCode.c b/examples/example_4/test/TestProductionCode.c index a7cf1449..63b6618e 100644 --- a/examples/example_4/test/TestProductionCode.c +++ b/examples/example_4/test/TestProductionCode.c @@ -1,7 +1,7 @@ /* ========================================================================= Unity - A Test Framework for C ThrowTheSwitch.org - Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams + Copyright (c) 2007-26 Mike Karlesky, Mark VanderVoord, & Greg Williams SPDX-License-Identifier: MIT ========================================================================= */ diff --git a/examples/example_4/test/TestProductionCode2.c b/examples/example_4/test/TestProductionCode2.c index 168564e1..5292d960 100644 --- a/examples/example_4/test/TestProductionCode2.c +++ b/examples/example_4/test/TestProductionCode2.c @@ -1,7 +1,7 @@ /* ========================================================================= Unity - A Test Framework for C ThrowTheSwitch.org - Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams + Copyright (c) 2007-26 Mike Karlesky, Mark VanderVoord, & Greg Williams SPDX-License-Identifier: MIT ========================================================================= */ diff --git a/examples/example_5/src/ProductionCode.c b/examples/example_5/src/ProductionCode.c index c6e2b0cd..7120adc4 100644 --- a/examples/example_5/src/ProductionCode.c +++ b/examples/example_5/src/ProductionCode.c @@ -1,7 +1,7 @@ /* ========================================================================= Unity - A Test Framework for C ThrowTheSwitch.org - Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams + Copyright (c) 2007-26 Mike Karlesky, Mark VanderVoord, & Greg Williams SPDX-License-Identifier: MIT ========================================================================= */ diff --git a/examples/example_5/src/ProductionCode.h b/examples/example_5/src/ProductionCode.h index 67de534b..7e143587 100644 --- a/examples/example_5/src/ProductionCode.h +++ b/examples/example_5/src/ProductionCode.h @@ -1,7 +1,7 @@ /* ========================================================================= Unity - A Test Framework for C ThrowTheSwitch.org - Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams + Copyright (c) 2007-26 Mike Karlesky, Mark VanderVoord, & Greg Williams SPDX-License-Identifier: MIT ========================================================================= */ diff --git a/examples/example_5/test/TestProductionCode.c b/examples/example_5/test/TestProductionCode.c index ab3d3e29..ec4cbed3 100644 --- a/examples/example_5/test/TestProductionCode.c +++ b/examples/example_5/test/TestProductionCode.c @@ -1,7 +1,7 @@ /* ========================================================================= Unity - A Test Framework for C ThrowTheSwitch.org - Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams + Copyright (c) 2007-26 Mike Karlesky, Mark VanderVoord, & Greg Williams SPDX-License-Identifier: MIT ========================================================================= */ diff --git a/examples/example_5/test/unity_detail_config.h b/examples/example_5/test/unity_detail_config.h index 0305a66e..1680da5c 100644 --- a/examples/example_5/test/unity_detail_config.h +++ b/examples/example_5/test/unity_detail_config.h @@ -1,3 +1,10 @@ +/* ========================================================================= + Unity - A Test Framework for C + ThrowTheSwitch.org + Copyright (c) 2007-26 Mike Karlesky, Mark VanderVoord, & Greg Williams + SPDX-License-Identifier: MIT +========================================================================= */ + #define UNITY_DETAIL_STACK_SIZE 5 #define LABEL_AS_INT32 "#\x18" /*UNITY_DISPLAY_STYLE_INT32 = 0x18 */ #define LABEL_AS_HEX8 "#\x41" /* UNITY_DISPLAY_STYLE_HEX8 = 0x41 */ diff --git a/examples/unity_config.h b/examples/unity_config.h index efd91232..c79dd5a9 100644 --- a/examples/unity_config.h +++ b/examples/unity_config.h @@ -1,7 +1,7 @@ /* ========================================================================= Unity - A Test Framework for C ThrowTheSwitch.org - Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams + Copyright (c) 2007-26 Mike Karlesky, Mark VanderVoord, & Greg Williams SPDX-License-Identifier: MIT ========================================================================= */ diff --git a/extras/bdd/src/unity_bdd.h b/extras/bdd/src/unity_bdd.h index feff492c..41ee2adf 100644 --- a/extras/bdd/src/unity_bdd.h +++ b/extras/bdd/src/unity_bdd.h @@ -1,7 +1,7 @@ /* ========================================================================= Unity - A Test Framework for C ThrowTheSwitch.org - Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams + Copyright (c) 2007-26 Mike Karlesky, Mark VanderVoord, & Greg Williams SPDX-License-Identifier: MIT ========================================================================= */ diff --git a/extras/bdd/test/test_bdd.c b/extras/bdd/test/test_bdd.c index f86e5abd..be51324d 100644 --- a/extras/bdd/test/test_bdd.c +++ b/extras/bdd/test/test_bdd.c @@ -1,7 +1,7 @@ /* ========================================================================= Unity - A Test Framework for C ThrowTheSwitch.org - Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams + Copyright (c) 2007-26 Mike Karlesky, Mark VanderVoord, & Greg Williams SPDX-License-Identifier: MIT ========================================================================= */ diff --git a/extras/fixture/src/unity_fixture.c b/extras/fixture/src/unity_fixture.c index cd0df2ca..a89677ed 100644 --- a/extras/fixture/src/unity_fixture.c +++ b/extras/fixture/src/unity_fixture.c @@ -1,7 +1,7 @@ /* ========================================================================= Unity - A Test Framework for C ThrowTheSwitch.org - Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams + Copyright (c) 2007-26 Mike Karlesky, Mark VanderVoord, & Greg Williams SPDX-License-Identifier: MIT ========================================================================= */ diff --git a/extras/fixture/src/unity_fixture.h b/extras/fixture/src/unity_fixture.h index ed6ff482..fa2fc5be 100644 --- a/extras/fixture/src/unity_fixture.h +++ b/extras/fixture/src/unity_fixture.h @@ -1,7 +1,7 @@ /* ========================================================================= Unity - A Test Framework for C ThrowTheSwitch.org - Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams + Copyright (c) 2007-26 Mike Karlesky, Mark VanderVoord, & Greg Williams SPDX-License-Identifier: MIT ========================================================================= */ diff --git a/extras/fixture/src/unity_fixture_internals.h b/extras/fixture/src/unity_fixture_internals.h index 6a552c1f..b2aff1f6 100644 --- a/extras/fixture/src/unity_fixture_internals.h +++ b/extras/fixture/src/unity_fixture_internals.h @@ -1,7 +1,7 @@ /* ========================================================================= Unity - A Test Framework for C ThrowTheSwitch.org - Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams + Copyright (c) 2007-26 Mike Karlesky, Mark VanderVoord, & Greg Williams SPDX-License-Identifier: MIT ========================================================================= */ diff --git a/extras/fixture/test/main/AllTests.c b/extras/fixture/test/main/AllTests.c index d5eec4be..caa3c7ec 100644 --- a/extras/fixture/test/main/AllTests.c +++ b/extras/fixture/test/main/AllTests.c @@ -1,7 +1,7 @@ /* ========================================================================= Unity - A Test Framework for C ThrowTheSwitch.org - Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams + Copyright (c) 2007-26 Mike Karlesky, Mark VanderVoord, & Greg Williams SPDX-License-Identifier: MIT ========================================================================= */ diff --git a/extras/fixture/test/template_fixture_tests.c b/extras/fixture/test/template_fixture_tests.c index 2397f105..1b1c9ec6 100644 --- a/extras/fixture/test/template_fixture_tests.c +++ b/extras/fixture/test/template_fixture_tests.c @@ -1,7 +1,7 @@ /* ========================================================================= Unity - A Test Framework for C ThrowTheSwitch.org - Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams + Copyright (c) 2007-26 Mike Karlesky, Mark VanderVoord, & Greg Williams SPDX-License-Identifier: MIT ========================================================================= */ diff --git a/extras/fixture/test/unity_fixture_Test.c b/extras/fixture/test/unity_fixture_Test.c index f5103ff1..b894d4c0 100644 --- a/extras/fixture/test/unity_fixture_Test.c +++ b/extras/fixture/test/unity_fixture_Test.c @@ -1,7 +1,7 @@ /* ========================================================================= Unity - A Test Framework for C ThrowTheSwitch.org - Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams + Copyright (c) 2007-26 Mike Karlesky, Mark VanderVoord, & Greg Williams SPDX-License-Identifier: MIT ========================================================================= */ diff --git a/extras/fixture/test/unity_fixture_TestRunner.c b/extras/fixture/test/unity_fixture_TestRunner.c index 07099d36..cecdcc09 100644 --- a/extras/fixture/test/unity_fixture_TestRunner.c +++ b/extras/fixture/test/unity_fixture_TestRunner.c @@ -1,7 +1,7 @@ /* ========================================================================= Unity - A Test Framework for C ThrowTheSwitch.org - Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams + Copyright (c) 2007-26 Mike Karlesky, Mark VanderVoord, & Greg Williams SPDX-License-Identifier: MIT ========================================================================= */ diff --git a/extras/memory/src/unity_memory.c b/extras/memory/src/unity_memory.c index e9eaae35..c71f77f8 100644 --- a/extras/memory/src/unity_memory.c +++ b/extras/memory/src/unity_memory.c @@ -1,7 +1,7 @@ /* ========================================================================= Unity - A Test Framework for C ThrowTheSwitch.org - Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams + Copyright (c) 2007-26 Mike Karlesky, Mark VanderVoord, & Greg Williams SPDX-License-Identifier: MIT ========================================================================= */ diff --git a/extras/memory/src/unity_memory.h b/extras/memory/src/unity_memory.h index 70a7f25f..7351be35 100644 --- a/extras/memory/src/unity_memory.h +++ b/extras/memory/src/unity_memory.h @@ -1,7 +1,7 @@ /* ========================================================================= Unity - A Test Framework for C ThrowTheSwitch.org - Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams + Copyright (c) 2007-26 Mike Karlesky, Mark VanderVoord, & Greg Williams SPDX-License-Identifier: MIT ========================================================================= */ diff --git a/extras/memory/test/unity_memory_Test.c b/extras/memory/test/unity_memory_Test.c index b66e6deb..1e654101 100644 --- a/extras/memory/test/unity_memory_Test.c +++ b/extras/memory/test/unity_memory_Test.c @@ -1,7 +1,7 @@ /* ========================================================================= Unity - A Test Framework for C ThrowTheSwitch.org - Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams + Copyright (c) 2007-26 Mike Karlesky, Mark VanderVoord, & Greg Williams SPDX-License-Identifier: MIT ========================================================================= */ diff --git a/extras/memory/test/unity_memory_TestRunner.c b/extras/memory/test/unity_memory_TestRunner.c index 0a8ed3da..9fe2ead1 100644 --- a/extras/memory/test/unity_memory_TestRunner.c +++ b/extras/memory/test/unity_memory_TestRunner.c @@ -1,7 +1,7 @@ /* ========================================================================= Unity - A Test Framework for C ThrowTheSwitch.org - Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams + Copyright (c) 2007-26 Mike Karlesky, Mark VanderVoord, & Greg Williams SPDX-License-Identifier: MIT ========================================================================= */ diff --git a/extras/memory/test/unity_output_Spy.c b/extras/memory/test/unity_output_Spy.c index 044c5def..e5b6db0f 100644 --- a/extras/memory/test/unity_output_Spy.c +++ b/extras/memory/test/unity_output_Spy.c @@ -1,7 +1,7 @@ /* ========================================================================= Unity - A Test Framework for C ThrowTheSwitch.org - Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams + Copyright (c) 2007-26 Mike Karlesky, Mark VanderVoord, & Greg Williams SPDX-License-Identifier: MIT ========================================================================= */ diff --git a/extras/memory/test/unity_output_Spy.h b/extras/memory/test/unity_output_Spy.h index 3c2e9b97..8c2dd315 100644 --- a/extras/memory/test/unity_output_Spy.h +++ b/extras/memory/test/unity_output_Spy.h @@ -1,7 +1,7 @@ /* ========================================================================= Unity - A Test Framework for C ThrowTheSwitch.org - Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams + Copyright (c) 2007-26 Mike Karlesky, Mark VanderVoord, & Greg Williams SPDX-License-Identifier: MIT ========================================================================= */ diff --git a/src/unity.c b/src/unity.c index 8be0d033..4b1aea6c 100644 --- a/src/unity.c +++ b/src/unity.c @@ -1,7 +1,7 @@ /* ========================================================================= Unity - A Test Framework for C ThrowTheSwitch.org - Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams + Copyright (c) 2007-26 Mike Karlesky, Mark VanderVoord, & Greg Williams SPDX-License-Identifier: MIT ========================================================================= */ diff --git a/src/unity.h b/src/unity.h index 7c749c2c..63109130 100644 --- a/src/unity.h +++ b/src/unity.h @@ -1,7 +1,7 @@ /* ========================================================================= Unity - A Test Framework for C ThrowTheSwitch.org - Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams + Copyright (c) 2007-26 Mike Karlesky, Mark VanderVoord, & Greg Williams SPDX-License-Identifier: MIT ========================================================================= */ diff --git a/src/unity_internals.h b/src/unity_internals.h index a66859ae..da17059f 100644 --- a/src/unity_internals.h +++ b/src/unity_internals.h @@ -1,7 +1,7 @@ /* ========================================================================= Unity - A Test Framework for C ThrowTheSwitch.org - Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams + Copyright (c) 2007-26 Mike Karlesky, Mark VanderVoord, & Greg Williams SPDX-License-Identifier: MIT ========================================================================= */ diff --git a/test/rakefile b/test/rakefile index 7747f305..f278d42c 100644 --- a/test/rakefile +++ b/test/rakefile @@ -1,7 +1,7 @@ # ========================================================================= # Unity - A Test Framework for C # ThrowTheSwitch.org -# Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams +# Copyright (c) 2007-26 Mike Karlesky, Mark VanderVoord, & Greg Williams # SPDX-License-Identifier: MIT # ========================================================================= diff --git a/test/rakefile_helper.rb b/test/rakefile_helper.rb index 80a4976d..cabcc995 100644 --- a/test/rakefile_helper.rb +++ b/test/rakefile_helper.rb @@ -1,7 +1,7 @@ # ========================================================================= # Unity - A Test Framework for C # ThrowTheSwitch.org -# Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams +# Copyright (c) 2007-26 Mike Karlesky, Mark VanderVoord, & Greg Williams # SPDX-License-Identifier: MIT # ========================================================================= diff --git a/test/spec/generate_module_existing_file_spec.rb b/test/spec/generate_module_existing_file_spec.rb index f4dd13e3..732e6d73 100644 --- a/test/spec/generate_module_existing_file_spec.rb +++ b/test/spec/generate_module_existing_file_spec.rb @@ -1,7 +1,7 @@ # ========================================================================= # Unity - A Test Framework for C # ThrowTheSwitch.org -# Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams +# Copyright (c) 2007-26 Mike Karlesky, Mark VanderVoord, & Greg Williams # SPDX-License-Identifier: MIT # ========================================================================= diff --git a/test/targets/ansi.yml b/test/targets/ansi.yml index fcc24557..c09642fd 100644 --- a/test/targets/ansi.yml +++ b/test/targets/ansi.yml @@ -1,7 +1,7 @@ # ========================================================================= # Unity - A Test Framework for C # ThrowTheSwitch.org -# Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams +# Copyright (c) 2007-26 Mike Karlesky, Mark VanderVoord, & Greg Williams # SPDX-License-Identifier: MIT # ========================================================================= diff --git a/test/targets/clang_file.yml b/test/targets/clang_file.yml index f962ced3..1c4ed537 100644 --- a/test/targets/clang_file.yml +++ b/test/targets/clang_file.yml @@ -1,7 +1,7 @@ # ========================================================================= # Unity - A Test Framework for C # ThrowTheSwitch.org -# Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams +# Copyright (c) 2007-26 Mike Karlesky, Mark VanderVoord, & Greg Williams # SPDX-License-Identifier: MIT # ========================================================================= diff --git a/test/targets/clang_strict.yml b/test/targets/clang_strict.yml index 1c82f624..11017350 100644 --- a/test/targets/clang_strict.yml +++ b/test/targets/clang_strict.yml @@ -1,7 +1,7 @@ # ========================================================================= # Unity - A Test Framework for C # ThrowTheSwitch.org -# Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams +# Copyright (c) 2007-26 Mike Karlesky, Mark VanderVoord, & Greg Williams # SPDX-License-Identifier: MIT # ========================================================================= diff --git a/test/targets/gcc_32.yml b/test/targets/gcc_32.yml index 3375e4ee..5a17b307 100644 --- a/test/targets/gcc_32.yml +++ b/test/targets/gcc_32.yml @@ -1,7 +1,7 @@ # ========================================================================= # Unity - A Test Framework for C # ThrowTheSwitch.org -# Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams +# Copyright (c) 2007-26 Mike Karlesky, Mark VanderVoord, & Greg Williams # SPDX-License-Identifier: MIT # ========================================================================= diff --git a/test/targets/gcc_64.yml b/test/targets/gcc_64.yml index 55223ceb..104cf7d7 100644 --- a/test/targets/gcc_64.yml +++ b/test/targets/gcc_64.yml @@ -1,7 +1,7 @@ # ========================================================================= # Unity - A Test Framework for C # ThrowTheSwitch.org -# Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams +# Copyright (c) 2007-26 Mike Karlesky, Mark VanderVoord, & Greg Williams # SPDX-License-Identifier: MIT # ========================================================================= diff --git a/test/targets/gcc_auto_limits.yml b/test/targets/gcc_auto_limits.yml index 9159b385..3da6922b 100644 --- a/test/targets/gcc_auto_limits.yml +++ b/test/targets/gcc_auto_limits.yml @@ -1,7 +1,7 @@ # ========================================================================= # Unity - A Test Framework for C # ThrowTheSwitch.org -# Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams +# Copyright (c) 2007-26 Mike Karlesky, Mark VanderVoord, & Greg Williams # SPDX-License-Identifier: MIT # ========================================================================= diff --git a/test/targets/gcc_auto_stdint.yml b/test/targets/gcc_auto_stdint.yml index 18221609..9697ff74 100644 --- a/test/targets/gcc_auto_stdint.yml +++ b/test/targets/gcc_auto_stdint.yml @@ -1,7 +1,7 @@ # ========================================================================= # Unity - A Test Framework for C # ThrowTheSwitch.org -# Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams +# Copyright (c) 2007-26 Mike Karlesky, Mark VanderVoord, & Greg Williams # SPDX-License-Identifier: MIT # ========================================================================= diff --git a/test/targets/gcc_manual_math.yml b/test/targets/gcc_manual_math.yml index 22e69aa6..0524f727 100644 --- a/test/targets/gcc_manual_math.yml +++ b/test/targets/gcc_manual_math.yml @@ -1,7 +1,7 @@ # ========================================================================= # Unity - A Test Framework for C # ThrowTheSwitch.org -# Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams +# Copyright (c) 2007-26 Mike Karlesky, Mark VanderVoord, & Greg Williams # SPDX-License-Identifier: MIT # ========================================================================= diff --git a/test/targets/hitech_picc18.yml b/test/targets/hitech_picc18.yml index 547cb2b5..8dc91295 100644 --- a/test/targets/hitech_picc18.yml +++ b/test/targets/hitech_picc18.yml @@ -1,7 +1,7 @@ # ========================================================================= # Unity - A Test Framework for C # ThrowTheSwitch.org -# Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams +# Copyright (c) 2007-26 Mike Karlesky, Mark VanderVoord, & Greg Williams # SPDX-License-Identifier: MIT # ========================================================================= diff --git a/test/targets/iar_arm_v4.yml b/test/targets/iar_arm_v4.yml index 26a0f462..74d137de 100644 --- a/test/targets/iar_arm_v4.yml +++ b/test/targets/iar_arm_v4.yml @@ -1,7 +1,7 @@ # ========================================================================= # Unity - A Test Framework for C # ThrowTheSwitch.org -# Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams +# Copyright (c) 2007-26 Mike Karlesky, Mark VanderVoord, & Greg Williams # SPDX-License-Identifier: MIT # ========================================================================= diff --git a/test/targets/iar_arm_v5.yml b/test/targets/iar_arm_v5.yml index afd51775..cd0930d0 100644 --- a/test/targets/iar_arm_v5.yml +++ b/test/targets/iar_arm_v5.yml @@ -1,7 +1,7 @@ # ========================================================================= # Unity - A Test Framework for C # ThrowTheSwitch.org -# Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams +# Copyright (c) 2007-26 Mike Karlesky, Mark VanderVoord, & Greg Williams # SPDX-License-Identifier: MIT # ========================================================================= diff --git a/test/targets/iar_arm_v5_3.yml b/test/targets/iar_arm_v5_3.yml index afd51775..cd0930d0 100644 --- a/test/targets/iar_arm_v5_3.yml +++ b/test/targets/iar_arm_v5_3.yml @@ -1,7 +1,7 @@ # ========================================================================= # Unity - A Test Framework for C # ThrowTheSwitch.org -# Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams +# Copyright (c) 2007-26 Mike Karlesky, Mark VanderVoord, & Greg Williams # SPDX-License-Identifier: MIT # ========================================================================= diff --git a/test/targets/iar_armcortex_LM3S9B92_v5_4.yml b/test/targets/iar_armcortex_LM3S9B92_v5_4.yml index b4aa5d8e..1fc07c6f 100644 --- a/test/targets/iar_armcortex_LM3S9B92_v5_4.yml +++ b/test/targets/iar_armcortex_LM3S9B92_v5_4.yml @@ -1,7 +1,7 @@ # ========================================================================= # Unity - A Test Framework for C # ThrowTheSwitch.org -# Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams +# Copyright (c) 2007-26 Mike Karlesky, Mark VanderVoord, & Greg Williams # SPDX-License-Identifier: MIT # ========================================================================= diff --git a/test/targets/iar_cortexm3_v5.yml b/test/targets/iar_cortexm3_v5.yml index e27b0f6b..c5d6ad28 100644 --- a/test/targets/iar_cortexm3_v5.yml +++ b/test/targets/iar_cortexm3_v5.yml @@ -1,7 +1,7 @@ # ========================================================================= # Unity - A Test Framework for C # ThrowTheSwitch.org -# Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams +# Copyright (c) 2007-26 Mike Karlesky, Mark VanderVoord, & Greg Williams # SPDX-License-Identifier: MIT # ========================================================================= diff --git a/test/targets/iar_msp430.yml b/test/targets/iar_msp430.yml index 041ebdaf..de89245f 100644 --- a/test/targets/iar_msp430.yml +++ b/test/targets/iar_msp430.yml @@ -1,7 +1,7 @@ # ========================================================================= # Unity - A Test Framework for C # ThrowTheSwitch.org -# Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams +# Copyright (c) 2007-26 Mike Karlesky, Mark VanderVoord, & Greg Williams # SPDX-License-Identifier: MIT # ========================================================================= diff --git a/test/targets/iar_sh2a_v6.yml b/test/targets/iar_sh2a_v6.yml index 21761d4b..8e5ded4b 100644 --- a/test/targets/iar_sh2a_v6.yml +++ b/test/targets/iar_sh2a_v6.yml @@ -1,7 +1,7 @@ # ========================================================================= # Unity - A Test Framework for C # ThrowTheSwitch.org -# Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams +# Copyright (c) 2007-26 Mike Karlesky, Mark VanderVoord, & Greg Williams # SPDX-License-Identifier: MIT # ========================================================================= diff --git a/test/testdata/CException.h b/test/testdata/CException.h index 0c11eaaa..c4c58edd 100644 --- a/test/testdata/CException.h +++ b/test/testdata/CException.h @@ -1,7 +1,7 @@ /* ========================================================================= Unity - A Test Framework for C ThrowTheSwitch.org - Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams + Copyright (c) 2007-26 Mike Karlesky, Mark VanderVoord, & Greg Williams SPDX-License-Identifier: MIT ========================================================================= */ diff --git a/test/testdata/Defs.h b/test/testdata/Defs.h index aa5ed670..ec83d6fd 100644 --- a/test/testdata/Defs.h +++ b/test/testdata/Defs.h @@ -1,7 +1,7 @@ /* ========================================================================= Unity - A Test Framework for C ThrowTheSwitch.org - Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams + Copyright (c) 2007-26 Mike Karlesky, Mark VanderVoord, & Greg Williams SPDX-License-Identifier: MIT ========================================================================= */ diff --git a/test/testdata/cmock.h b/test/testdata/cmock.h index 440220d0..37efb0b1 100644 --- a/test/testdata/cmock.h +++ b/test/testdata/cmock.h @@ -1,7 +1,7 @@ /* ========================================================================= Unity - A Test Framework for C ThrowTheSwitch.org - Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams + Copyright (c) 2007-26 Mike Karlesky, Mark VanderVoord, & Greg Williams SPDX-License-Identifier: MIT ========================================================================= */ diff --git a/test/testdata/mockMock.h b/test/testdata/mockMock.h index ca65fc93..0aa5a005 100644 --- a/test/testdata/mockMock.h +++ b/test/testdata/mockMock.h @@ -1,7 +1,7 @@ /* ========================================================================= Unity - A Test Framework for C ThrowTheSwitch.org - Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams + Copyright (c) 2007-26 Mike Karlesky, Mark VanderVoord, & Greg Williams SPDX-License-Identifier: MIT ========================================================================= */ diff --git a/test/testdata/testRunnerGenerator.c b/test/testdata/testRunnerGenerator.c index c10a96e6..ef8f4684 100644 --- a/test/testdata/testRunnerGenerator.c +++ b/test/testdata/testRunnerGenerator.c @@ -1,7 +1,7 @@ /* ========================================================================= Unity - A Test Framework for C ThrowTheSwitch.org - Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams + Copyright (c) 2007-26 Mike Karlesky, Mark VanderVoord, & Greg Williams SPDX-License-Identifier: MIT ========================================================================= */ diff --git a/test/testdata/testRunnerGeneratorSmall.c b/test/testdata/testRunnerGeneratorSmall.c index bc9f7fcf..076efff7 100644 --- a/test/testdata/testRunnerGeneratorSmall.c +++ b/test/testdata/testRunnerGeneratorSmall.c @@ -1,7 +1,7 @@ /* ========================================================================= Unity - A Test Framework for C ThrowTheSwitch.org - Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams + Copyright (c) 2007-26 Mike Karlesky, Mark VanderVoord, & Greg Williams SPDX-License-Identifier: MIT ========================================================================= */ diff --git a/test/testdata/testRunnerGeneratorWithMocks.c b/test/testdata/testRunnerGeneratorWithMocks.c index adc2a295..5bacd4b3 100644 --- a/test/testdata/testRunnerGeneratorWithMocks.c +++ b/test/testdata/testRunnerGeneratorWithMocks.c @@ -1,7 +1,7 @@ /* ========================================================================= Unity - A Test Framework for C ThrowTheSwitch.org - Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams + Copyright (c) 2007-26 Mike Karlesky, Mark VanderVoord, & Greg Williams SPDX-License-Identifier: MIT ========================================================================= */ diff --git a/test/tests/self_assessment_utils.h b/test/tests/self_assessment_utils.h index 24b755f1..95822bf0 100644 --- a/test/tests/self_assessment_utils.h +++ b/test/tests/self_assessment_utils.h @@ -1,7 +1,7 @@ /* ========================================================================= Unity - A Test Framework for C ThrowTheSwitch.org - Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams + Copyright (c) 2007-26 Mike Karlesky, Mark VanderVoord, & Greg Williams SPDX-License-Identifier: MIT ========================================================================= */ diff --git a/test/tests/test_generate_test_runner.rb b/test/tests/test_generate_test_runner.rb index 79a2e48e..5e0133f0 100644 --- a/test/tests/test_generate_test_runner.rb +++ b/test/tests/test_generate_test_runner.rb @@ -1,7 +1,7 @@ # ========================================================================= # Unity - A Test Framework for C # ThrowTheSwitch.org -# Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams +# Copyright (c) 2007-26 Mike Karlesky, Mark VanderVoord, & Greg Williams # SPDX-License-Identifier: MIT # ========================================================================= diff --git a/test/tests/test_unity_arrays.c b/test/tests/test_unity_arrays.c index f852c269..9e811258 100644 --- a/test/tests/test_unity_arrays.c +++ b/test/tests/test_unity_arrays.c @@ -1,7 +1,7 @@ /* ========================================================================= Unity - A Test Framework for C ThrowTheSwitch.org - Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams + Copyright (c) 2007-26 Mike Karlesky, Mark VanderVoord, & Greg Williams SPDX-License-Identifier: MIT ========================================================================= */ diff --git a/test/tests/test_unity_core.c b/test/tests/test_unity_core.c index 1f5a9a76..dc3a1bf4 100644 --- a/test/tests/test_unity_core.c +++ b/test/tests/test_unity_core.c @@ -1,7 +1,7 @@ /* ========================================================================= Unity - A Test Framework for C ThrowTheSwitch.org - Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams + Copyright (c) 2007-26 Mike Karlesky, Mark VanderVoord, & Greg Williams SPDX-License-Identifier: MIT ========================================================================= */ diff --git a/test/tests/test_unity_doubles.c b/test/tests/test_unity_doubles.c index b9e70cff..7a41d03b 100644 --- a/test/tests/test_unity_doubles.c +++ b/test/tests/test_unity_doubles.c @@ -1,7 +1,7 @@ /* ========================================================================= Unity - A Test Framework for C ThrowTheSwitch.org - Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams + Copyright (c) 2007-26 Mike Karlesky, Mark VanderVoord, & Greg Williams SPDX-License-Identifier: MIT ========================================================================= */ diff --git a/test/tests/test_unity_floats.c b/test/tests/test_unity_floats.c index 9744c134..e02c6563 100644 --- a/test/tests/test_unity_floats.c +++ b/test/tests/test_unity_floats.c @@ -1,7 +1,7 @@ /* ========================================================================= Unity - A Test Framework for C ThrowTheSwitch.org - Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams + Copyright (c) 2007-26 Mike Karlesky, Mark VanderVoord, & Greg Williams SPDX-License-Identifier: MIT ========================================================================= */ diff --git a/test/tests/test_unity_integers.c b/test/tests/test_unity_integers.c index 1b8c6e30..495d87da 100644 --- a/test/tests/test_unity_integers.c +++ b/test/tests/test_unity_integers.c @@ -1,7 +1,7 @@ /* ========================================================================= Unity - A Test Framework for C ThrowTheSwitch.org - Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams + Copyright (c) 2007-26 Mike Karlesky, Mark VanderVoord, & Greg Williams SPDX-License-Identifier: MIT ========================================================================= */ diff --git a/test/tests/test_unity_integers_64.c b/test/tests/test_unity_integers_64.c index 6fb0957f..e6a965aa 100644 --- a/test/tests/test_unity_integers_64.c +++ b/test/tests/test_unity_integers_64.c @@ -1,7 +1,7 @@ /* ========================================================================= Unity - A Test Framework for C ThrowTheSwitch.org - Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams + Copyright (c) 2007-26 Mike Karlesky, Mark VanderVoord, & Greg Williams SPDX-License-Identifier: MIT ========================================================================= */ diff --git a/test/tests/test_unity_memory.c b/test/tests/test_unity_memory.c index d4897de4..7ee48d2b 100644 --- a/test/tests/test_unity_memory.c +++ b/test/tests/test_unity_memory.c @@ -1,7 +1,7 @@ /* ========================================================================= Unity - A Test Framework for C ThrowTheSwitch.org - Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams + Copyright (c) 2007-26 Mike Karlesky, Mark VanderVoord, & Greg Williams SPDX-License-Identifier: MIT ========================================================================= */ diff --git a/test/tests/test_unity_parameterized.c b/test/tests/test_unity_parameterized.c index b9550986..80598933 100644 --- a/test/tests/test_unity_parameterized.c +++ b/test/tests/test_unity_parameterized.c @@ -1,7 +1,7 @@ /* ========================================================================= Unity - A Test Framework for C ThrowTheSwitch.org - Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams + Copyright (c) 2007-26 Mike Karlesky, Mark VanderVoord, & Greg Williams SPDX-License-Identifier: MIT ========================================================================= */ diff --git a/test/tests/test_unity_parameterizedDemo.c b/test/tests/test_unity_parameterizedDemo.c index 6de6e686..d0ea9626 100644 --- a/test/tests/test_unity_parameterizedDemo.c +++ b/test/tests/test_unity_parameterizedDemo.c @@ -1,7 +1,7 @@ /* ========================================================================= Unity - A Test Framework for C ThrowTheSwitch.org - Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams + Copyright (c) 2007-26 Mike Karlesky, Mark VanderVoord, & Greg Williams SPDX-License-Identifier: MIT ========================================================================= */ diff --git a/test/tests/test_unity_strings.c b/test/tests/test_unity_strings.c index 6a421135..bb38ecbb 100644 --- a/test/tests/test_unity_strings.c +++ b/test/tests/test_unity_strings.c @@ -1,7 +1,7 @@ /* ========================================================================= Unity - A Test Framework for C ThrowTheSwitch.org - Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams + Copyright (c) 2007-26 Mike Karlesky, Mark VanderVoord, & Greg Williams SPDX-License-Identifier: MIT ========================================================================= */ diff --git a/test/tests/types_for_test.h b/test/tests/types_for_test.h index 66828b95..00f580d3 100644 --- a/test/tests/types_for_test.h +++ b/test/tests/types_for_test.h @@ -1,7 +1,7 @@ /* ========================================================================= Unity - A Test Framework for C ThrowTheSwitch.org - Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams + Copyright (c) 2007-26 Mike Karlesky, Mark VanderVoord, & Greg Williams SPDX-License-Identifier: MIT ========================================================================= */