mirror of
https://github.com/ThrowTheSwitch/Unity.git
synced 2025-06-24 00:28:35 +08:00
Merge pull request #237 from jsalling/feature/ptr-set-size
Fixture - Ability to set size of pointer list
This commit is contained in:
@ -305,8 +305,7 @@ struct PointerPair
|
|||||||
void* old_value;
|
void* old_value;
|
||||||
};
|
};
|
||||||
|
|
||||||
enum { MAX_POINTERS = 50 };
|
static struct PointerPair pointer_store[UNITY_MAX_POINTERS];
|
||||||
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)
|
||||||
@ -316,7 +315,7 @@ void UnityPointer_Init(void)
|
|||||||
|
|
||||||
void UnityPointer_Set(void** pointer, void* newValue, UNITY_LINE_TYPE line)
|
void UnityPointer_Set(void** pointer, void* newValue, UNITY_LINE_TYPE line)
|
||||||
{
|
{
|
||||||
if (pointer_index >= MAX_POINTERS)
|
if (pointer_index >= UNITY_MAX_POINTERS)
|
||||||
{
|
{
|
||||||
UNITY_TEST_FAIL(line, "Too many pointers set");
|
UNITY_TEST_FAIL(line, "Too many pointers set");
|
||||||
}
|
}
|
||||||
|
@ -40,6 +40,9 @@ void UnityConcludeFixtureTest(void);
|
|||||||
void UnityPointer_Set(void** ptr, void* newValue, UNITY_LINE_TYPE line);
|
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);
|
||||||
|
#ifndef UNITY_MAX_POINTERS
|
||||||
|
#define UNITY_MAX_POINTERS 5
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
@ -465,7 +465,7 @@ TEST(LeakDetection, PointerSettingMax)
|
|||||||
TEST_IGNORE();
|
TEST_IGNORE();
|
||||||
#else
|
#else
|
||||||
int i;
|
int i;
|
||||||
for (i = 0; i < 50; i++) UT_PTR_SET(pointer1, &int1);
|
for (i = 0; i < UNITY_MAX_POINTERS; i++) UT_PTR_SET(pointer1, &int1);
|
||||||
UnityOutputCharSpy_Enable(1);
|
UnityOutputCharSpy_Enable(1);
|
||||||
EXPECT_ABORT_BEGIN
|
EXPECT_ABORT_BEGIN
|
||||||
UT_PTR_SET(pointer1, &int1);
|
UT_PTR_SET(pointer1, &int1);
|
||||||
|
Reference in New Issue
Block a user