zenilib  0.5.3.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
SDL_test_assert.c File Reference
#include "SDL_config.h"
#include "SDL_test.h"

Go to the source code of this file.

Functions

void SDLTest_Assert (int assertCondition, const char *assertDescription,...)
 Assert that logs and break execution flow on failures. More...
 
int SDLTest_AssertCheck (int assertCondition, const char *assertDescription,...)
 Assert for test cases that logs but does not break execution flow on failures. Updates assertion counters. More...
 
void SDLTest_AssertPass (const char *assertDescription,...)
 Explicitely pass without checking an assertion condition. Updates assertion counter. More...
 
int SDLTest_AssertSummaryToTestResult ()
 Converts the current assert summary state to a test result. More...
 
void SDLTest_LogAssertSummary ()
 Logs summary of all assertions (total, pass, fail) since last reset as INFO or ERROR. More...
 
void SDLTest_ResetAssertSummary ()
 Resets the assert summary counters to zero. More...
 

Variables

const char * SDLTest_AssertCheckFormat = "Assert '%s': %s"
 
static Uint32 SDLTest_AssertsFailed = 0
 
static Uint32 SDLTest_AssertsPassed = 0
 
const char * SDLTest_AssertSummaryFormat = "Assert Summary: Total=%d Passed=%d Failed=%d"
 

Function Documentation

void SDLTest_Assert ( int  assertCondition,
const char *  assertDescription,
  ... 
)

Assert that logs and break execution flow on failures.

Parameters
assertConditionEvaluated condition or variable to assert; fail (==0) or pass (!=0).
assertDescriptionMessage to log with the assert describing it.

Definition at line 47 of file SDL_test_assert.c.

References SDL_assert, SDL_memset(), SDL_vsnprintf(), SDLTest_AssertCheck(), and SDLTEST_MAX_LOGMESSAGE_LENGTH.

int SDLTest_AssertCheck ( int  assertCondition,
const char *  assertDescription,
  ... 
)

Assert for test cases that logs but does not break execution flow on failures. Updates assertion counters.

Parameters
assertConditionEvaluated condition or variable to assert; fail (==0) or pass (!=0).
assertDescriptionMessage to log with the assert describing it.
Returns
Returns the assertCondition so it can be used to externally to break execution flow if desired.

Definition at line 65 of file SDL_test_assert.c.

References ASSERT_FAIL, SDL_memset(), SDL_vsnprintf(), SDLTest_AssertCheckFormat, SDLTest_AssertsFailed, SDLTest_AssertsPassed, SDLTest_Log(), SDLTest_LogError(), and SDLTEST_MAX_LOGMESSAGE_LENGTH.

Referenced by SDLTest_Assert().

void SDLTest_AssertPass ( const char *  assertDescription,
  ... 
)

Explicitely pass without checking an assertion condition. Updates assertion counter.

Parameters
assertDescriptionMessage to log with the assert describing it.

Definition at line 94 of file SDL_test_assert.c.

References SDL_memset(), SDL_vsnprintf(), SDLTest_AssertCheckFormat, SDLTest_AssertsPassed, SDLTest_Log(), and SDLTEST_MAX_LOGMESSAGE_LENGTH.

int SDLTest_AssertSummaryToTestResult ( )

Converts the current assert summary state to a test result.

Returns
TEST_RESULT_PASSED, TEST_RESULT_FAILED, or TEST_RESULT_NO_ASSERT

Definition at line 139 of file SDL_test_assert.c.

References SDLTest_AssertsFailed, SDLTest_AssertsPassed, TEST_RESULT_FAILED, TEST_RESULT_NO_ASSERT, and TEST_RESULT_PASSED.

Referenced by SDLTest_RunTest().

void SDLTest_LogAssertSummary ( )

Logs summary of all assertions (total, pass, fail) since last reset as INFO or ERROR.

Definition at line 123 of file SDL_test_assert.c.

References SDLTest_AssertsFailed, SDLTest_AssertsPassed, SDLTest_AssertSummaryFormat, SDLTest_Log(), and SDLTest_LogError().

Referenced by SDLTest_RunTest().

void SDLTest_ResetAssertSummary ( )

Resets the assert summary counters to zero.

Definition at line 113 of file SDL_test_assert.c.

References SDLTest_AssertsFailed, and SDLTest_AssertsPassed.

Referenced by SDLTest_RunTest().

Variable Documentation

const char* SDLTest_AssertCheckFormat = "Assert '%s': %s"

Definition at line 33 of file SDL_test_assert.c.

Referenced by SDLTest_AssertCheck(), and SDLTest_AssertPass().

Uint32 SDLTest_AssertsFailed = 0
static
const char* SDLTest_AssertSummaryFormat = "Assert Summary: Total=%d Passed=%d Failed=%d"

Definition at line 36 of file SDL_test_assert.c.

Referenced by SDLTest_LogAssertSummary().