mirror of
https://github.com/ThrowTheSwitch/Unity.git
synced 2025-10-20 13:54:26 +08:00
Pass through correct line info on failures in Fixture pointer setting
This commit is contained in:
@ -299,15 +299,14 @@ void* unity_realloc(void* oldMem, size_t size)
|
|||||||
|
|
||||||
//--------------------------------------------------------
|
//--------------------------------------------------------
|
||||||
//Automatic pointer restoration functions
|
//Automatic pointer restoration functions
|
||||||
typedef struct _PointerPair
|
struct PointerPair
|
||||||
{
|
{
|
||||||
struct _PointerPair* next;
|
|
||||||
void** pointer;
|
void** pointer;
|
||||||
void* old_value;
|
void* old_value;
|
||||||
} PointerPair;
|
};
|
||||||
|
|
||||||
enum {MAX_POINTERS=50};
|
enum { MAX_POINTERS = 50 };
|
||||||
static PointerPair pointer_store[MAX_POINTERS+1];
|
static struct PointerPair pointer_store[MAX_POINTERS];
|
||||||
static int pointer_index = 0;
|
static int pointer_index = 0;
|
||||||
|
|
||||||
void UnityPointer_Init(void)
|
void UnityPointer_Init(void)
|
||||||
@ -315,11 +314,11 @@ void UnityPointer_Init(void)
|
|||||||
pointer_index = 0;
|
pointer_index = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void UnityPointer_Set(void** pointer, void* newValue)
|
void UnityPointer_Set(void** pointer, void* newValue, UNITY_LINE_TYPE line)
|
||||||
{
|
{
|
||||||
if (pointer_index >= MAX_POINTERS)
|
if (pointer_index >= MAX_POINTERS)
|
||||||
{
|
{
|
||||||
TEST_FAIL_MESSAGE("Too many pointers set");
|
UNITY_TEST_FAIL(line, "Too many pointers set");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@ -64,7 +64,7 @@ int UnityMain(int argc, const char* argv[], void (*runAllTests)(void));
|
|||||||
TEST_##group##_GROUP_RUNNER(); }
|
TEST_##group##_GROUP_RUNNER(); }
|
||||||
|
|
||||||
//CppUTest Compatibility Macros
|
//CppUTest Compatibility Macros
|
||||||
#define UT_PTR_SET(ptr, newPointerValue) UnityPointer_Set((void**)&(ptr), (void*)(newPointerValue))
|
#define UT_PTR_SET(ptr, newPointerValue) UnityPointer_Set((void**)&(ptr), (void*)(newPointerValue), __LINE__)
|
||||||
#define TEST_ASSERT_POINTERS_EQUAL(expected, actual) TEST_ASSERT_EQUAL_PTR((expected), (actual))
|
#define TEST_ASSERT_POINTERS_EQUAL(expected, actual) TEST_ASSERT_EQUAL_PTR((expected), (actual))
|
||||||
#define TEST_ASSERT_BYTES_EQUAL(expected, actual) TEST_ASSERT_EQUAL_HEX8(0xff & (expected), 0xff & (actual))
|
#define TEST_ASSERT_BYTES_EQUAL(expected, actual) TEST_ASSERT_EQUAL_HEX8(0xff & (expected), 0xff & (actual))
|
||||||
#define FAIL(message) TEST_FAIL_MESSAGE((message))
|
#define FAIL(message) TEST_FAIL_MESSAGE((message))
|
||||||
|
|||||||
@ -34,7 +34,7 @@ UNITY_COUNTER_TYPE UnityTestsCount(void);
|
|||||||
int UnityGetCommandLineOptions(int argc, const char* argv[]);
|
int UnityGetCommandLineOptions(int argc, const char* argv[]);
|
||||||
void UnityConcludeFixtureTest(void);
|
void UnityConcludeFixtureTest(void);
|
||||||
|
|
||||||
void UnityPointer_Set(void** ptr, void* newValue);
|
void UnityPointer_Set(void** ptr, void* newValue, UNITY_LINE_TYPE line);
|
||||||
void UnityPointer_UndoAllSets(void);
|
void UnityPointer_UndoAllSets(void);
|
||||||
void UnityPointer_Init(void);
|
void UnityPointer_Init(void);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user