src/test/SDL_test_assert.c
changeset 7191 75360622e65f
parent 6885 700f1b25f77f
child 7678 286c42d7c5ed
     1.1 --- a/src/test/SDL_test_assert.c	Sat May 18 12:48:50 2013 -0700
     1.2 +++ b/src/test/SDL_test_assert.c	Sat May 18 14:17:52 2013 -0700
     1.3 @@ -21,7 +21,7 @@
     1.4  
     1.5  /*
     1.6  
     1.7 - Used by the test framework and test cases. 
     1.8 + Used by the test framework and test cases.
     1.9  
    1.10  */
    1.11  
    1.12 @@ -47,16 +47,16 @@
    1.13  void SDLTest_Assert(int assertCondition, const char *assertDescription, ...)
    1.14  {
    1.15          va_list list;
    1.16 -	char logMessage[SDLTEST_MAX_LOGMESSAGE_LENGTH];
    1.17 -                
    1.18 -	// Print assert description into a buffer
    1.19 -	SDL_memset(logMessage, 0, SDLTEST_MAX_LOGMESSAGE_LENGTH);
    1.20 -	va_start(list, assertDescription);
    1.21 -	SDL_vsnprintf(logMessage, SDLTEST_MAX_LOGMESSAGE_LENGTH - 1, assertDescription, list);
    1.22 -	va_end(list);
    1.23 -	
    1.24 -	// Log, then assert and break on failure
    1.25 -	SDL_assert((SDLTest_AssertCheck(assertCondition, logMessage)));
    1.26 +    char logMessage[SDLTEST_MAX_LOGMESSAGE_LENGTH];
    1.27 +
    1.28 +    /* Print assert description into a buffer */
    1.29 +    SDL_memset(logMessage, 0, SDLTEST_MAX_LOGMESSAGE_LENGTH);
    1.30 +    va_start(list, assertDescription);
    1.31 +    SDL_vsnprintf(logMessage, SDLTEST_MAX_LOGMESSAGE_LENGTH - 1, assertDescription, list);
    1.32 +    va_end(list);
    1.33 +
    1.34 +    /* Log, then assert and break on failure */
    1.35 +    SDL_assert((SDLTest_AssertCheck(assertCondition, logMessage)));
    1.36  }
    1.37  
    1.38  /*
    1.39 @@ -65,27 +65,27 @@
    1.40  int SDLTest_AssertCheck(int assertCondition, const char *assertDescription, ...)
    1.41  {
    1.42      va_list list;
    1.43 -	char logMessage[SDLTEST_MAX_LOGMESSAGE_LENGTH];
    1.44 -                
    1.45 -	// Print assert description into a buffer
    1.46 -	SDL_memset(logMessage, 0, SDLTEST_MAX_LOGMESSAGE_LENGTH);
    1.47 -	va_start(list, assertDescription);
    1.48 -	SDL_vsnprintf(logMessage, SDLTEST_MAX_LOGMESSAGE_LENGTH - 1, assertDescription, list);
    1.49 -	va_end(list);
    1.50 -                                                        
    1.51 -	// Log pass or fail message
    1.52 -	if (assertCondition == ASSERT_FAIL)
    1.53 -	{
    1.54 -		SDLTest_AssertsFailed++;
    1.55 -		SDLTest_LogError(SDLTest_AssertCheckFormat, logMessage, "Failed");
    1.56 -	} 
    1.57 -	else 
    1.58 -	{
    1.59 -		SDLTest_AssertsPassed++;
    1.60 -		SDLTest_Log(SDLTest_AssertCheckFormat, logMessage, "Passed");
    1.61 -	}
    1.62 +    char logMessage[SDLTEST_MAX_LOGMESSAGE_LENGTH];
    1.63 +
    1.64 +    /* Print assert description into a buffer */
    1.65 +    SDL_memset(logMessage, 0, SDLTEST_MAX_LOGMESSAGE_LENGTH);
    1.66 +    va_start(list, assertDescription);
    1.67 +    SDL_vsnprintf(logMessage, SDLTEST_MAX_LOGMESSAGE_LENGTH - 1, assertDescription, list);
    1.68 +    va_end(list);
    1.69  
    1.70 -	return assertCondition;
    1.71 +    /* Log pass or fail message */
    1.72 +    if (assertCondition == ASSERT_FAIL)
    1.73 +    {
    1.74 +        SDLTest_AssertsFailed++;
    1.75 +        SDLTest_LogError(SDLTest_AssertCheckFormat, logMessage, "Failed");
    1.76 +    }
    1.77 +    else
    1.78 +    {
    1.79 +        SDLTest_AssertsPassed++;
    1.80 +        SDLTest_Log(SDLTest_AssertCheckFormat, logMessage, "Passed");
    1.81 +    }
    1.82 +
    1.83 +    return assertCondition;
    1.84  }
    1.85  
    1.86  /*
    1.87 @@ -94,17 +94,17 @@
    1.88  void SDLTest_AssertPass(const char *assertDescription, ...)
    1.89  {
    1.90      va_list list;
    1.91 -	char logMessage[SDLTEST_MAX_LOGMESSAGE_LENGTH];
    1.92 -                
    1.93 -	// Print assert description into a buffer
    1.94 -	SDL_memset(logMessage, 0, SDLTEST_MAX_LOGMESSAGE_LENGTH);
    1.95 -	va_start(list, assertDescription);
    1.96 -	SDL_vsnprintf(logMessage, SDLTEST_MAX_LOGMESSAGE_LENGTH - 1, assertDescription, list);
    1.97 -	va_end(list);
    1.98 -                            
    1.99 -        // Log pass message                            
   1.100 -	SDLTest_AssertsPassed++;
   1.101 -	SDLTest_Log(SDLTest_AssertCheckFormat, logMessage, "Pass");
   1.102 +    char logMessage[SDLTEST_MAX_LOGMESSAGE_LENGTH];
   1.103 +
   1.104 +    /* Print assert description into a buffer */
   1.105 +    SDL_memset(logMessage, 0, SDLTEST_MAX_LOGMESSAGE_LENGTH);
   1.106 +    va_start(list, assertDescription);
   1.107 +    SDL_vsnprintf(logMessage, SDLTEST_MAX_LOGMESSAGE_LENGTH - 1, assertDescription, list);
   1.108 +    va_end(list);
   1.109 +
   1.110 +        /* Log pass message */
   1.111 +    SDLTest_AssertsPassed++;
   1.112 +    SDLTest_Log(SDLTest_AssertCheckFormat, logMessage, "Pass");
   1.113  }
   1.114  
   1.115  /*
   1.116 @@ -112,25 +112,25 @@
   1.117   */
   1.118  void SDLTest_ResetAssertSummary()
   1.119  {
   1.120 -	SDLTest_AssertsPassed = 0;
   1.121 -	SDLTest_AssertsFailed = 0;
   1.122 +    SDLTest_AssertsPassed = 0;
   1.123 +    SDLTest_AssertsFailed = 0;
   1.124  }
   1.125  
   1.126  /*
   1.127 - * Logs summary of all assertions (total, pass, fail) since last reset 
   1.128 + * Logs summary of all assertions (total, pass, fail) since last reset
   1.129   * as INFO (failed==0) or ERROR (failed > 0).
   1.130   */
   1.131  void SDLTest_LogAssertSummary()
   1.132  {
   1.133 -	Uint32 totalAsserts = SDLTest_AssertsPassed + SDLTest_AssertsFailed;
   1.134 -	if (SDLTest_AssertsFailed == 0)
   1.135 -	{
   1.136 -		SDLTest_Log(SDLTest_AssertSummaryFormat, totalAsserts, SDLTest_AssertsPassed, SDLTest_AssertsFailed);
   1.137 -	} 
   1.138 -	else 
   1.139 -	{
   1.140 -		SDLTest_LogError(SDLTest_AssertSummaryFormat, totalAsserts, SDLTest_AssertsPassed, SDLTest_AssertsFailed);
   1.141 -	}
   1.142 +    Uint32 totalAsserts = SDLTest_AssertsPassed + SDLTest_AssertsFailed;
   1.143 +    if (SDLTest_AssertsFailed == 0)
   1.144 +    {
   1.145 +        SDLTest_Log(SDLTest_AssertSummaryFormat, totalAsserts, SDLTest_AssertsPassed, SDLTest_AssertsFailed);
   1.146 +    }
   1.147 +    else
   1.148 +    {
   1.149 +        SDLTest_LogError(SDLTest_AssertSummaryFormat, totalAsserts, SDLTest_AssertsPassed, SDLTest_AssertsFailed);
   1.150 +    }
   1.151  }
   1.152  
   1.153  /*
   1.154 @@ -138,13 +138,13 @@
   1.155   */
   1.156  int SDLTest_AssertSummaryToTestResult()
   1.157  {
   1.158 -	if (SDLTest_AssertsFailed > 0) {
   1.159 -		return TEST_RESULT_FAILED;
   1.160 -	} else {
   1.161 -		if (SDLTest_AssertsPassed > 0) {
   1.162 -			return TEST_RESULT_PASSED;
   1.163 -		} else {
   1.164 -			return TEST_RESULT_NO_ASSERT;
   1.165 -		}
   1.166 -	}
   1.167 +    if (SDLTest_AssertsFailed > 0) {
   1.168 +        return TEST_RESULT_FAILED;
   1.169 +    } else {
   1.170 +        if (SDLTest_AssertsPassed > 0) {
   1.171 +            return TEST_RESULT_PASSED;
   1.172 +        } else {
   1.173 +            return TEST_RESULT_NO_ASSERT;
   1.174 +        }
   1.175 +    }
   1.176  }