Added existing common.c/.h functions to test lib; minor assert refactoring
This commit is contained in:
parent
de32627287
commit
84aaf1fed9
8 changed files with 1491 additions and 20 deletions
|
@ -35,6 +35,12 @@ const char *SDLTest_AssertCheckFmt = "Assert '%s': %s";
|
|||
/* Assert summary message format */
|
||||
const char *SDLTest_AssertSummaryFmt = "Assert Summary: Total=%d Passed=%d Failed=%d";
|
||||
|
||||
/*! \brief counts the failed asserts */
|
||||
static Uint32 SDLTest_AssertsFailed = 0;
|
||||
|
||||
/*! \brief counts the passed asserts */
|
||||
static Uint32 SDLTest_AssertsPassed = 0;
|
||||
|
||||
/*
|
||||
* Assert that logs and break execution flow on failures (i.e. for harness errors).
|
||||
*/
|
||||
|
@ -89,3 +95,19 @@ void SDLTest_LogAssertSummary()
|
|||
SDLTest_LogError(fmt, totalAsserts, SDLTest_AssertsPassed, SDLTest_AssertsFailed);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Converts the current assert state into a test result
|
||||
*/
|
||||
int SDLTest_AssertSummaryToTestResult()
|
||||
{
|
||||
if (SDLTest_AssertsFailed > 0) {
|
||||
return TEST_RESULT_FAILED;
|
||||
} else {
|
||||
if (SDLTest_AssertsPassed > 0) {
|
||||
return TEST_RESULT_PASSED;
|
||||
} else {
|
||||
return TEST_RESULT_NO_ASSERT;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue