提交 6b664fc8 编写于 作者: J jsalling

Pass through correct line info on failures in Fixture pointer setting

上级 4c384658
...@@ -299,15 +299,14 @@ void* unity_realloc(void* oldMem, size_t size) ...@@ -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) ...@@ -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)); ...@@ -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); ...@@ -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);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册