test/test-automation/testplatform/testplatform.c
changeset 5766 8cc2ae74cd83
parent 5763 7e74c43ecda2
child 5774 4f9f82aa1a33
equal deleted inserted replaced
5765:f4ed7142727a 5766:8cc2ae74cd83
   350  * http://wiki.libsdl.org/moin.cgi/SDL_SetError
   350  * http://wiki.libsdl.org/moin.cgi/SDL_SetError
   351  */
   351  */
   352 int platform_testSetErrorInvalidInput(void *arg)
   352 int platform_testSetErrorInvalidInput(void *arg)
   353 {
   353 {
   354    const char *testError = NULL;
   354    const char *testError = NULL;
       
   355    const char *probeError = "Testing";
   355    char *lastError;
   356    char *lastError;
   356    
   357    int len;
       
   358 
       
   359    // Reset
       
   360    SDL_ClearError();
       
   361    
       
   362    // Check for no-op
   357    SDL_SetError(testError);
   363    SDL_SetError(testError);
   358    AssertPass("SDL_SetError()");
   364    AssertPass("SDL_SetError()");
   359    lastError = (char *)SDL_GetError();   
   365    lastError = (char *)SDL_GetError();   
   360    AssertTrue(lastError == NULL, 
   366    AssertTrue(lastError != NULL, 
   361              "SDL_GetError() == NULL");
   367              "SDL_GetError() != NULL");
       
   368    if (lastError != NULL)
       
   369    {
       
   370      len = strlen(lastError);
       
   371      AssertTrue(len == 0, 
       
   372              "SDL_GetError(): expected message len 0, was len: %i", 
       
   373              0, 
       
   374              len);
       
   375      AssertTrue(strcmp(lastError, "") == 0, 
       
   376              "SDL_GetError(): expected message '', was message: '%s'",           
       
   377              lastError);
       
   378    }
       
   379    
       
   380    // Set
       
   381    SDL_SetError(probeError);
       
   382    
       
   383    // Check for no-op
       
   384    SDL_SetError(testError);
       
   385    AssertPass("SDL_SetError()");
       
   386    lastError = (char *)SDL_GetError();   
       
   387    AssertTrue(lastError != NULL, 
       
   388              "SDL_GetError() != NULL");
       
   389    if (lastError != NULL)
       
   390    {
       
   391      len = strlen(lastError);
       
   392      AssertTrue(len == strlen(probeError), 
       
   393              "SDL_GetError(): expected message len %i, was len: %i", 
       
   394              strlen(probeError), 
       
   395              len);
       
   396      AssertTrue(strcmp(lastError, probeError) == 0, 
       
   397              "SDL_GetError(): expected message '%s', was message: '%s'",
       
   398              probeError,
       
   399              lastError);
       
   400    }
   362 
   401 
   363    // Clean up                
   402    // Clean up                
   364    SDL_ClearError();
   403    SDL_ClearError();
   365 }
   404 }