From 6b664fc803f0f785c4e9442b6415b2d2d3d0e507 Mon Sep 17 00:00:00 2001 From: jsalling Date: Fri, 15 Jan 2016 22:59:52 -0600 Subject: [PATCH] Pass through correct line info on failures in Fixture pointer setting --- extras/fixture/src/unity_fixture.c | 13 ++++++------- extras/fixture/src/unity_fixture.h | 2 +- extras/fixture/src/unity_fixture_internals.h | 2 +- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/extras/fixture/src/unity_fixture.c b/extras/fixture/src/unity_fixture.c index b20657d..f9479bc 100644 --- a/extras/fixture/src/unity_fixture.c +++ b/extras/fixture/src/unity_fixture.c @@ -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 { diff --git a/extras/fixture/src/unity_fixture.h b/extras/fixture/src/unity_fixture.h index 57c8868..0d51af2 100644 --- a/extras/fixture/src/unity_fixture.h +++ b/extras/fixture/src/unity_fixture.h @@ -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)) diff --git a/extras/fixture/src/unity_fixture_internals.h b/extras/fixture/src/unity_fixture_internals.h index 1c4fcff..f2625ab 100644 --- a/extras/fixture/src/unity_fixture_internals.h +++ b/extras/fixture/src/unity_fixture_internals.h @@ -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); -- GitLab