mirror of
https://github.com/ennorehling/cutest.git
synced 2024-12-22 07:52:21 +00:00
Implement CuAssertPtrNotEquals
This commit is contained in:
parent
dd1efa973d
commit
05b68f5a66
9
CuTest.c
9
CuTest.c
@ -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
|
||||
|
5
CuTest.h
5
CuTest.h
@ -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 */
|
||||
|
||||
@ -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))
|
||||
|
Loading…
Reference in New Issue
Block a user