test/test-automation/testplatform/testplatform.c
changeset 5766 8cc2ae74cd83
parent 5763 7e74c43ecda2
child 5774 4f9f82aa1a33
     1.1 --- a/test/test-automation/testplatform/testplatform.c	Sun Jul 17 19:19:35 2011 +0300
     1.2 +++ b/test/test-automation/testplatform/testplatform.c	Sun Jul 17 20:59:34 2011 -0700
     1.3 @@ -352,13 +352,52 @@
     1.4  int platform_testSetErrorInvalidInput(void *arg)
     1.5  {
     1.6     const char *testError = NULL;
     1.7 +   const char *probeError = "Testing";
     1.8     char *lastError;
     1.9 +   int len;
    1.10 +
    1.11 +   // Reset
    1.12 +   SDL_ClearError();
    1.13     
    1.14 +   // Check for no-op
    1.15     SDL_SetError(testError);
    1.16     AssertPass("SDL_SetError()");
    1.17     lastError = (char *)SDL_GetError();   
    1.18 -   AssertTrue(lastError == NULL, 
    1.19 -             "SDL_GetError() == NULL");
    1.20 +   AssertTrue(lastError != NULL, 
    1.21 +             "SDL_GetError() != NULL");
    1.22 +   if (lastError != NULL)
    1.23 +   {
    1.24 +     len = strlen(lastError);
    1.25 +     AssertTrue(len == 0, 
    1.26 +             "SDL_GetError(): expected message len 0, was len: %i", 
    1.27 +             0, 
    1.28 +             len);
    1.29 +     AssertTrue(strcmp(lastError, "") == 0, 
    1.30 +             "SDL_GetError(): expected message '', was message: '%s'",           
    1.31 +             lastError);
    1.32 +   }
    1.33 +   
    1.34 +   // Set
    1.35 +   SDL_SetError(probeError);
    1.36 +   
    1.37 +   // Check for no-op
    1.38 +   SDL_SetError(testError);
    1.39 +   AssertPass("SDL_SetError()");
    1.40 +   lastError = (char *)SDL_GetError();   
    1.41 +   AssertTrue(lastError != NULL, 
    1.42 +             "SDL_GetError() != NULL");
    1.43 +   if (lastError != NULL)
    1.44 +   {
    1.45 +     len = strlen(lastError);
    1.46 +     AssertTrue(len == strlen(probeError), 
    1.47 +             "SDL_GetError(): expected message len %i, was len: %i", 
    1.48 +             strlen(probeError), 
    1.49 +             len);
    1.50 +     AssertTrue(strcmp(lastError, probeError) == 0, 
    1.51 +             "SDL_GetError(): expected message '%s', was message: '%s'",
    1.52 +             probeError,
    1.53 +             lastError);
    1.54 +   }
    1.55  
    1.56     // Clean up                
    1.57     SDL_ClearError();