- happier with const (and more optimized on some compilers)

- better helper examples
- general purpose memory compare

git-svn-id: http://unity.svn.sourceforge.net/svnroot/unity/trunk@16 e7d17a6e-8845-0410-bbbc-c8efb4fdad7e
This commit is contained in:
mvandervoord
2009-02-19 03:30:45 +00:00
parent 3eeb7dd726
commit 24a56b0c38
7 changed files with 174 additions and 43 deletions

View File

@@ -316,6 +316,51 @@ void UnityAssertEqualString(const char *expected,
}
}
void UnityAssertEqualMemory(void *expected,
void *actual,
unsigned int length,
const char *msg,
unsigned short lineNumber)
{
unsigned int i;
if (length == 0)
return;
// if both pointers not null compare the memory
if (expected && actual)
{
if (memcmp(expected, actual, length) != 0)
{
Unity.CurrentTestFailed = 1;
}
}
else
{ // handle case of one pointers being null (if both null, test should pass)
if (expected != actual)
{
Unity.CurrentTestFailed = 1;
}
}
if (Unity.CurrentTestFailed)
{
UnityTestResultsBegin(lineNumber);
UnityPrint("Expected '");
UnityPrint(expected);
UnityPrint("' was '");
UnityPrint(actual);
UnityPrintChar('\'');
UnityPrintChar('.');
if (msg)
{
UnityPrintChar(' ');
UnityPrint(msg);
}
UnityPrintChar('\n');
}
}
void UnityFail(const char *message, const int line)
{
Unity.CurrentTestFailed = 1;