mirror of
https://github.com/ThrowTheSwitch/Unity.git
synced 2025-10-15 03:06:38 +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
|
||||
typedef struct _PointerPair
|
||||
struct PointerPair
|
||||
{
|
||||
struct _PointerPair* next;
|
||||
void** pointer;
|
||||
void* old_value;
|
||||
} PointerPair;
|
||||
};
|
||||
|
||||
enum {MAX_POINTERS=50};
|
||||
static PointerPair pointer_store[MAX_POINTERS+1];
|
||||
enum { MAX_POINTERS = 50 };
|
||||
static struct PointerPair pointer_store[MAX_POINTERS];
|
||||
static int pointer_index = 0;
|
||||
|
||||
void UnityPointer_Init(void)
|
||||
@ -315,11 +314,11 @@ void UnityPointer_Init(void)
|
||||
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)
|
||||
{
|
||||
TEST_FAIL_MESSAGE("Too many pointers set");
|
||||
UNITY_TEST_FAIL(line, "Too many pointers set");
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -64,7 +64,7 @@ int UnityMain(int argc, const char* argv[], void (*runAllTests)(void));
|
||||
TEST_##group##_GROUP_RUNNER(); }
|
||||
|
||||
//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_BYTES_EQUAL(expected, actual) TEST_ASSERT_EQUAL_HEX8(0xff & (expected), 0xff & (actual))
|
||||
#define FAIL(message) TEST_FAIL_MESSAGE((message))
|
||||
|
@ -34,7 +34,7 @@ UNITY_COUNTER_TYPE UnityTestsCount(void);
|
||||
int UnityGetCommandLineOptions(int argc, const char* argv[]);
|
||||
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_Init(void);
|
||||
|
||||
|
Reference in New Issue
Block a user