Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement CuAssertPtrNotEquals #4

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions CuTest.c
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,15 @@ void CuAssertPtrEquals_LineMsg(CuTest* tc, const char* file, int line, const cha
CuFail_Line(tc, file, line, message, buf);
}

void CuAssertPtrNotEquals_LineMsg(CuTest* tc, const char* file, int line, const char* message,
void* reject, void* actual)
{
char buf[STRING_MAX];
if (reject != actual) return;
sprintf(buf, "expected pointer different from <0x%p>", actual);
CuFail_Line(tc, file, line, message, buf);
}


/*-------------------------------------------------------------------------*
* CuSuite
Expand Down
5 changes: 5 additions & 0 deletions CuTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ void CuAssertDblEquals_LineMsg(CuTest* tc,
void CuAssertPtrEquals_LineMsg(CuTest* tc,
const char* file, int line, const char* message,
void* expected, void* actual);
void CuAssertPtrNotEquals_LineMsg(CuTest* tc,
const char* file, int line, const char* message,
void* reject, void* actual);

/* public assert functions */

Expand All @@ -86,6 +89,8 @@ void CuAssertPtrEquals_LineMsg(CuTest* tc,
#define CuAssertDblEquals_Msg(tc,ms,ex,ac,dl) CuAssertDblEquals_LineMsg((tc),__FILE__,__LINE__,(ms),(ex),(ac),(dl))
#define CuAssertPtrEquals(tc,ex,ac) CuAssertPtrEquals_LineMsg((tc),__FILE__,__LINE__,NULL,(ex),(ac))
#define CuAssertPtrEquals_Msg(tc,ms,ex,ac) CuAssertPtrEquals_LineMsg((tc),__FILE__,__LINE__,(ms),(ex),(ac))
#define CuAssertPtrNotEquals(tc,rj,ac) CuAssertPtrNotEquals_LineMsg((tc),__FILE__,__LINE__,NULL,(rj),(ac))
#define CuAssertPtrNotEquals_Msg(tc,ms,rj,ac) CuAssertPtrNotEquals_LineMsg((tc),__FILE__,__LINE__,(ms),(rj),(ac))

#define CuAssertPtrNotNull(tc,p) CuAssert_Line((tc),__FILE__,__LINE__,"null pointer unexpected",((p) != NULL))
#define CuAssertPtrNotNullMsg(tc,msg,p) CuAssert_Line((tc),__FILE__,__LINE__,(msg),((p) != NULL))
Expand Down