提交 a4923232 编写于 作者: M mkarlesky

tightened up pointer handling in UnityAssertEqualMemoryArray to satisfy stricter compilers

git-svn-id: http://unity.svn.sourceforge.net/svnroot/unity/trunk@46 e7d17a6e-8845-0410-bbbc-c8efb4fdad7e
上级 6901c8eb
......@@ -539,6 +539,8 @@ void UnityAssertEqualMemoryArray(const void* expected,
const char* msg,
const unsigned short lineNumber)
{
unsigned char* expected_ptr = (unsigned char*)expected;
unsigned char* actual_ptr = (unsigned char*)actual;
unsigned long elements = num_elements;
if ((elements == 0) || (length == 0))
{
......@@ -556,22 +558,22 @@ void UnityAssertEqualMemoryArray(const void* expected,
}
// if both pointers not null compare the memory
if (expected && actual)
if (expected_ptr && actual_ptr)
{
while (elements--)
{
if (memcmp(expected, actual, length) != 0)
if (memcmp((const void*)expected_ptr, (const void*)actual_ptr, length) != 0)
{
Unity.CurrentTestFailed = 1;
break;
}
expected += length;
actual += length;
expected_ptr += length;
actual_ptr += length;
}
}
else
{ // handle case of one pointers being null (if both null, test should pass)
if (expected != actual)
if (expected_ptr != actual_ptr)
{
Unity.CurrentTestFailed = 1;
}
......
......@@ -141,11 +141,11 @@ void UnityAssertEqualMemory(const void* expected,
const unsigned short lineNumber );
void UnityAssertEqualMemoryArray(const void* expected,
const void* actual,
unsigned long length,
unsigned long num_elements,
const char* msg,
const unsigned short lineNumber );
const void* actual,
unsigned long length,
unsigned long num_elements,
const char* msg,
const unsigned short lineNumber );
void UnityAssertFloatsWithin(const float delta,
const float expected,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册