void CuAssertPtrEquals_LineMsg(CuTest *tc, const char *file, int line, const char *message, void *expected, void *actual) { char buf[STRING_MAX]; if (expected == actual) return; sprintf(buf, "expected pointer <0x%p> but was <0x%p>", expected, actual); CuFail_Line(tc, file, line, message, buf); }
void CuAssertIntEquals_LineMsg(CuTest *tc, const char *file, int line, const char *message, int expected, int actual) { char buf[STRING_MAX]; if (expected == actual) return; sprintf(buf, "expected <%d> but was <%d>", expected, actual); CuFail_Line(tc, file, line, message, buf); }
void CuAssertDblEquals_LineMsg(CuTest* tc, const char* file, int line, const char* message, double expected, double actual, double delta) { char buf[STRING_MAX]; if (fabs(expected - actual) <= delta) return; sprintf(buf, "expected <%e> but was <%e>", expected, actual); CuFail_Line(tc, file, line, message, buf); }
void CuAssertPtrNotEqual_LineMsg(CuTest* tc, const char* file, int line, const char* message, const void* expected, const void* actual) { char buf[STRING_MAX]; if (expected != actual) return; sprintf(buf, "expected pointer <0x%p> to be different from <0x%p>", expected, actual); CuFail_Line(tc, file, line, message, buf); }
bool CuAssert_Line (CuTest_t *tc, const char *file, unsigned long int line, const char *message, int condition) { if (tc) { ++tc->assertCnt; if (condition) return false; CuFail_Line (tc, file, line, message, NULL); return true; } return false; }
void Extended_CuAssertIntArrayEquals_LineMsg(CuTest* tc, const char* file, int line, const char* message, int* expected, int* actual, int elementCount) { int i; char buf[STRING_MAX]; for(i = 0; i < elementCount; ++i) { if(expected[i] != actual[i]) { sprintf(buf, "Mismatched elements at index [%d]: Expected (%d) but found (%d)", i, expected[i], actual[i]); CuFail_Line(tc, file, line, message, buf); } } return; }
bool CuAssertGeneralEquals_LineMsg(CuTest_t* tc, const char* file, unsigned long int line, const char* message, const void *expected, const void *actual, char *expectedStr, char *actualStr, size_t maxStrLen, CuTestCmpFncPtr_t cmpFnc) { if (tc){ bool result; //increase counter for assertions within that test ++tc->assertCnt; //char *expectedStr=NULL, *actualStr=NULL; //init to NULL to enable tracking of missing ptr assignment // CuString *cmpmsg = CuStringNew(); //char* buf = (char*)calloc(STRING_MAX, sizeof(char)); //assert (NULL != buf); //String functions will create new instance if NULL Ptr is passed //CuString *compResult = CuStringNew(); if ( false == (result = cmpFnc (expected, actual, expectedStr, actualStr, maxStrLen, tc->message/*cmpmsg*/) ) ) { assert (NULL != expectedStr); assert (NULL != actualStr); //sprintf(buf, "expected <%d> but was <%d>", expected, actual); CuFail_Line (tc, file, line, message, " "); //CuStringAppend(tc->message, ": "); //here axctual and expected are exchanged which is reasoned in the va macros used in more deeply nested function //CuStringAppendISvsNOT(tc->message, "%d", actual, expected); CuStringAppendISvsNOT(tc->message, "%s", actualStr, expectedStr); // CuTestAppendMessage(tc, CuStringCStr(cmpmsg)); //return true; } //CuStringDelete(compResult); //free(buf); //CuStringDelete(cmpmsg); return !result; } return true; }
void CuAssert_Line(CuTest* tc, const char* file, int line, const char* message, int condition) { if (condition) return; CuFail_Line(tc, file, line, NULL, message); }
void CuTestAssertForDb(const char *msg, const char *file, int line) { CuFail_Line(NULL, file, line, NULL, msg); }