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
This commit is contained in:
mkarlesky
2009-11-03 15:52:54 +00:00
parent 6901c8eb04
commit a4923232ee
2 changed files with 12 additions and 10 deletions

View File

@ -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;
}