mirror of
https://github.com/ThrowTheSwitch/Unity.git
synced 2026-01-23 00:15:58 +01:00
Merge branch 'master' into platform_matrix
This commit is contained in:
@@ -4,10 +4,14 @@
|
||||
#
|
||||
# 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')
|
||||
|
||||
if not meson.is_subproject()
|
||||
install_headers(
|
||||
'unity.h',
|
||||
'unity_internals.h',
|
||||
subdir: meson.project_name()
|
||||
)
|
||||
endif
|
||||
|
||||
21
src/unity.c
21
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;
|
||||
@@ -1607,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;
|
||||
}
|
||||
@@ -1647,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;
|
||||
}
|
||||
@@ -2034,10 +2036,17 @@ static void UnityPrintFVA(const char* format, va_list va)
|
||||
}
|
||||
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, UNITY_MAX_NIBBLES);
|
||||
UnityPrintNumberHex((UNITY_UINT)number, nibbles_to_print);
|
||||
break;
|
||||
}
|
||||
case 'c':
|
||||
|
||||
20
src/unity.h
20
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
|
||||
@@ -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.
|
||||
@@ -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)
|
||||
|
||||
@@ -77,7 +77,7 @@
|
||||
#endif
|
||||
#endif
|
||||
#ifndef UNITY_NORETURN
|
||||
#define UNITY_NORETURN UNITY_FUNCTION_ATTR(noreturn)
|
||||
#define UNITY_NORETURN UNITY_FUNCTION_ATTR(__noreturn__)
|
||||
#endif
|
||||
|
||||
/*-------------------------------------------------------
|
||||
@@ -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
|
||||
@@ -793,6 +805,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
|
||||
|
||||
@@ -953,7 +968,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)
|
||||
|
||||
Reference in New Issue
Block a user