mirror of
https://github.com/ThrowTheSwitch/Unity.git
synced 2025-12-17 05:54:07 +08:00
- 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:
45
src/unity.c
45
src/unity.c
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user