提交 4e4046a8 编写于 作者: M mvandervoord

- updated memory assert to be more verbose (and dropped memcmp)

git-svn-id: http://unity.svn.sourceforge.net/svnroot/unity/trunk@127 e7d17a6e-8845-0410-bbbc-c8efb4fdad7e
上级 bc1674df
...@@ -22,7 +22,8 @@ const char* UnityStrExpected = " Expected "; ...@@ -22,7 +22,8 @@ const char* UnityStrExpected = " Expected ";
const char* UnityStrWas = " Was "; const char* UnityStrWas = " Was ";
const char* UnityStrTo = " To "; const char* UnityStrTo = " To ";
const char* UnityStrElement = " Element "; const char* UnityStrElement = " Element ";
const char* UnityStrMemory = " Memory Mismatch"; const char* UnityStrByte = " Byte ";
const char* UnityStrMemory = " Memory Mismatch.";
const char* UnityStrDelta = " Values Not Within Delta "; const char* UnityStrDelta = " Values Not Within Delta ";
const char* UnityStrPointless= " You Asked Me To Compare Nothing, Which Was Pointless."; const char* UnityStrPointless= " You Asked Me To Compare Nothing, Which Was Pointless.";
const char* UnityStrNullPointerForExpected= " Expected pointer to be NULL"; const char* UnityStrNullPointerForExpected= " Expected pointer to be NULL";
...@@ -725,9 +726,10 @@ void UnityAssertEqualMemory( const void* expected, ...@@ -725,9 +726,10 @@ void UnityAssertEqualMemory( const void* expected,
const char* msg, const char* msg,
const UNITY_LINE_TYPE lineNumber) const UNITY_LINE_TYPE lineNumber)
{ {
unsigned char* expected_ptr = (unsigned char*)expected; unsigned char* ptr_exp = (unsigned char*)expected;
unsigned char* actual_ptr = (unsigned char*)actual; unsigned char* ptr_act = (unsigned char*)actual;
_UU32 elements = num_elements; _UU32 elements = num_elements;
_UU32 bytes;
UNITY_SKIP_EXECUTION; UNITY_SKIP_EXECUTION;
...@@ -744,26 +746,33 @@ void UnityAssertEqualMemory( const void* expected, ...@@ -744,26 +746,33 @@ void UnityAssertEqualMemory( const void* expected,
while (elements--) while (elements--)
{ {
if (memcmp((const void*)expected_ptr, (const void*)actual_ptr, length) != 0) /////////////////////////////////////
bytes = length;
while (bytes--)
{ {
Unity.CurrentTestFailed = 1; if (*ptr_exp != *ptr_act)
break; {
} UnityTestResultsFailBegin(lineNumber);
expected_ptr += length; UnityPrint(UnityStrMemory);
actual_ptr += length; if (num_elements > 1)
} {
UnityPrint(UnityStrElement);
if (Unity.CurrentTestFailed) UnityPrintNumberByStyle((num_elements - elements - 1), UNITY_DISPLAY_STYLE_UINT);
{ }
UnityTestResultsFailBegin(lineNumber); UnityPrint(UnityStrByte);
if (num_elements > 1) UnityPrintNumberByStyle((length - bytes - 1), UNITY_DISPLAY_STYLE_UINT);
{ UnityPrint(UnityStrExpected);
UnityPrint(UnityStrElement); UnityPrintNumberByStyle(*ptr_exp, UNITY_DISPLAY_STYLE_HEX8);
UnityPrintNumberByStyle((num_elements - elements - 1), UNITY_DISPLAY_STYLE_UINT); UnityPrint(UnityStrWas);
UnityPrintNumberByStyle(*ptr_act, UNITY_DISPLAY_STYLE_HEX8);
UnityAddMsgIfSpecified(msg);
UNITY_FAIL_AND_BAIL;
}
ptr_exp += 1;
ptr_act += 1;
} }
UnityPrint(UnityStrMemory); /////////////////////////////////////
UnityAddMsgIfSpecified(msg);
UNITY_FAIL_AND_BAIL;
} }
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册