src/test/SDL_test_assert.c
changeset 6718 918ba414168b
parent 6717 2acd95060548
child 6721 53b71f45a53a
     1.1 --- a/src/test/SDL_test_assert.c	Fri Nov 30 23:25:34 2012 -0800
     1.2 +++ b/src/test/SDL_test_assert.c	Sat Dec 01 14:48:30 2012 -0800
     1.3 @@ -30,10 +30,10 @@
     1.4  #include "SDL_test.h"
     1.5  
     1.6  /*! \brief counts the failed asserts */
     1.7 -static Uint32 SDLTest_testAssertsFailed = 0;
     1.8 +static Uint32 SDLTest_AssertsFailed = 0;
     1.9  
    1.10  /*! \brief counts the passed asserts */
    1.11 -static Uint32 SDLTest_testAssertsPassed = 0;
    1.12 +static Uint32 SDLTest_AssertsPassed = 0;
    1.13  
    1.14  /* Assert check message format */
    1.15  const char *SDLTest_AssertCheckFmt = "Assert %s: %s";
    1.16 @@ -46,26 +46,27 @@
    1.17   */
    1.18  void SDLTest_Assert(int assertCondition, char *assertDescription)
    1.19  {
    1.20 -	SDLTest_AssertCheck(assertCondition, assertDescription);
    1.21 -	SDL_assert((assertCondition));
    1.22 +	SDL_assert((SDLTest_AssertCheck(assertCondition, assertDescription)));
    1.23  }
    1.24  
    1.25  /*
    1.26   * Assert that logs but does not break execution flow on failures (i.e. for test cases).
    1.27   */
    1.28 -void SDLTest_AssertCheck(int assertCondition, char *assertDescription)
    1.29 +int SDLTest_AssertCheck(int assertCondition, char *assertDescription)
    1.30  {
    1.31  	char *fmt = (char *)SDLTest_AssertCheckFmt;
    1.32 -	if (assertCondition)
    1.33 +	if (assertCondition == ASSERT_FAIL)
    1.34  	{
    1.35 -		SDLTest_testAssertsPassed++;
    1.36 -		SDLTest_Log(fmt, "Passed", assertDescription);
    1.37 +		SDLTest_AssertsFailed++;
    1.38 +		SDLTest_LogError(fmt, "Failed", assertDescription);
    1.39  	} 
    1.40  	else 
    1.41  	{
    1.42 -		SDLTest_testAssertsFailed++;
    1.43 -		SDLTest_LogError(fmt, "Failed", assertDescription);
    1.44 +		SDLTest_AssertsPassed++;
    1.45 +		SDLTest_Log(fmt, "Passed", assertDescription);
    1.46  	}
    1.47 +
    1.48 +	return assertCondition;
    1.49  }
    1.50  
    1.51  /*
    1.52 @@ -73,8 +74,8 @@
    1.53   */
    1.54  void SDLTest_ResetAssertSummary()
    1.55  {
    1.56 -	SDLTest_testAssertsPassed = 0;
    1.57 -	SDLTest_testAssertsFailed = 0;
    1.58 +	SDLTest_AssertsPassed = 0;
    1.59 +	SDLTest_AssertsFailed = 0;
    1.60  }
    1.61  
    1.62  /*
    1.63 @@ -84,13 +85,13 @@
    1.64  void SDLTest_LogAssertSummary()
    1.65  {
    1.66  	char *fmt = (char *)SDLTest_AssertSummaryFmt;
    1.67 -	Uint32 totalAsserts = SDLTest_testAssertsPassed + SDLTest_testAssertsFailed;
    1.68 -	if (SDLTest_testAssertsFailed == 0)
    1.69 +	Uint32 totalAsserts = SDLTest_AssertsPassed + SDLTest_AssertsFailed;
    1.70 +	if (SDLTest_AssertsFailed == 0)
    1.71  	{
    1.72 -		SDLTest_Log(fmt, totalAsserts, SDLTest_testAssertsPassed, SDLTest_testAssertsFailed);
    1.73 +		SDLTest_Log(fmt, totalAsserts, SDLTest_AssertsPassed, SDLTest_AssertsFailed);
    1.74  	} 
    1.75  	else 
    1.76  	{
    1.77 -		SDLTest_LogError(fmt, totalAsserts, SDLTest_testAssertsPassed, SDLTest_testAssertsFailed);
    1.78 +		SDLTest_LogError(fmt, totalAsserts, SDLTest_AssertsPassed, SDLTest_AssertsFailed);
    1.79  	}
    1.80  }