test/testautomation_sdltest.c
changeset 7172 b3569dff1c6e
parent 7144 c700de9c8ed4
child 7191 75360622e65f
     1.1 --- a/test/testautomation_sdltest.c	Sun May 12 14:25:38 2013 +0200
     1.2 +++ b/test/testautomation_sdltest.c	Sun May 12 15:00:00 2013 -0700
     1.3 @@ -2,6 +2,15 @@
     1.4   * SDL_test test suite
     1.5   */
     1.6  
     1.7 +/* Visual Studio 2008 doesn't have stdint.h */
     1.8 +#if defined(_MSC_VER) && _MSC_VER <= 1500
     1.9 +#define UINT8_MAX   ~(Uint8)0
    1.10 +#define UINT16_MAX  ~(Uint16)0
    1.11 +#define UINT32_MAX  ~(Uint32)0
    1.12 +#define UINT64_MAX  ~(Uint64)0
    1.13 +#else
    1.14 +#include <stdint.h>
    1.15 +#endif
    1.16  #include <stdio.h>
    1.17  #include <limits.h>
    1.18  #include <float.h>
    1.19 @@ -774,6 +783,13 @@
    1.20    const char *expectedError = "That operation is not supported";
    1.21    char *lastError;
    1.22    Sint64 sresult;
    1.23 +#if ((ULONG_MAX) == (UINT_MAX))
    1.24 +  Sint32 long_min = LONG_MIN; 
    1.25 +  Sint32 long_max = LONG_MAX;
    1.26 +#else
    1.27 +  Sint32 long_min = INT_MIN;
    1.28 +  Sint32 long_max = INT_MAX;
    1.29 +#endif
    1.30  
    1.31    /* Clean error messages */
    1.32    SDL_ClearError();
    1.33 @@ -827,40 +843,40 @@
    1.34    SDLTest_AssertCheck(
    1.35      sresult == 0 || sresult == 21,
    1.36      "Validate result value for parameters (1,20,SDL_FALSE); expected: 0|21, got: %lld", sresult);  
    1.37 -            
    1.38 +              
    1.39    /* RandomSintXBoundaryValue(LONG_MIN, 99, SDL_FALSE) returns 100 */
    1.40 -  sresult = (Sint64)SDLTest_RandomSint32BoundaryValue(LONG_MIN, 99, SDL_FALSE);
    1.41 +  sresult = (Sint64)SDLTest_RandomSint32BoundaryValue(long_min, 99, SDL_FALSE);
    1.42    SDLTest_AssertPass("Call to SDLTest_RandomSint32BoundaryValue");
    1.43    SDLTest_AssertCheck(
    1.44      sresult == 100,
    1.45      "Validate result value for parameters (LONG_MIN,99,SDL_FALSE); expected: 100, got: %lld", sresult);  
    1.46  
    1.47    /* RandomSintXBoundaryValue(LONG_MIN + 1, LONG_MAX, SDL_FALSE) returns LONG_MIN (no error) */
    1.48 -  sresult = (Sint64)SDLTest_RandomSint32BoundaryValue(LONG_MIN + 1, LONG_MAX, SDL_FALSE);
    1.49 +  sresult = (Sint64)SDLTest_RandomSint32BoundaryValue(long_min + 1, long_max, SDL_FALSE);
    1.50    SDLTest_AssertPass("Call to SDLTest_RandomSint32BoundaryValue");
    1.51    SDLTest_AssertCheck(
    1.52 -    sresult == LONG_MIN,
    1.53 -    "Validate result value for parameters (LONG_MIN+1,LONG_MAX,SDL_FALSE); expected: %d, got: %lld", LONG_MIN, sresult);
    1.54 +    sresult == long_min,
    1.55 +    "Validate result value for parameters (LONG_MIN+1,LONG_MAX,SDL_FALSE); expected: %d, got: %lld", long_min, sresult);
    1.56    lastError = (char *)SDL_GetError();
    1.57    SDLTest_AssertPass("SDL_GetError()");
    1.58    SDLTest_AssertCheck(lastError == NULL || SDL_strlen(lastError) == 0, "Validate no error message was set");
    1.59  
    1.60    /* RandomSintXBoundaryValue(LONG_MIN, LONG_MAX - 1, SDL_FALSE) returns LONG_MAX (no error) */
    1.61 -  sresult = (Sint64)SDLTest_RandomSint32BoundaryValue(LONG_MIN, LONG_MAX - 1, SDL_FALSE);
    1.62 +  sresult = (Sint64)SDLTest_RandomSint32BoundaryValue(long_min, long_max - 1, SDL_FALSE);
    1.63    SDLTest_AssertPass("Call to SDLTest_RandomSint32BoundaryValue");
    1.64    SDLTest_AssertCheck(
    1.65 -    sresult == LONG_MAX,
    1.66 -    "Validate result value for parameters (LONG_MIN,LONG_MAX - 1,SDL_FALSE); expected: %d, got: %lld", LONG_MAX, sresult);
    1.67 +    sresult == long_max,
    1.68 +    "Validate result value for parameters (LONG_MIN,LONG_MAX - 1,SDL_FALSE); expected: %d, got: %lld", long_max, sresult);
    1.69    lastError = (char *)SDL_GetError();
    1.70    SDLTest_AssertPass("SDL_GetError()");
    1.71    SDLTest_AssertCheck(lastError == NULL || SDL_strlen(lastError) == 0, "Validate no error message was set");
    1.72  
    1.73    /* RandomSintXBoundaryValue(LONG_MIN, LONG_MAX, SDL_FALSE) returns 0 (sets error) */
    1.74 -  sresult = (Sint64)SDLTest_RandomSint32BoundaryValue(LONG_MIN, LONG_MAX, SDL_FALSE);
    1.75 +  sresult = (Sint64)SDLTest_RandomSint32BoundaryValue(long_min, long_max, SDL_FALSE);
    1.76    SDLTest_AssertPass("Call to SDLTest_RandomSint32BoundaryValue");
    1.77    SDLTest_AssertCheck(
    1.78 -    sresult == LONG_MIN,
    1.79 -    "Validate result value for parameters(LONG_MIN,LONG_MAX,SDL_FALSE); expected: %d, got: %lld", LONG_MIN, sresult);
    1.80 +    sresult == long_min,
    1.81 +    "Validate result value for parameters(LONG_MIN,LONG_MAX,SDL_FALSE); expected: %d, got: %lld", long_min, sresult);
    1.82    lastError = (char *)SDL_GetError();
    1.83    SDLTest_AssertPass("SDL_GetError()");
    1.84    SDLTest_AssertCheck(lastError != NULL && SDL_strcmp(lastError, expectedError) == 0,
    1.85 @@ -993,6 +1009,13 @@
    1.86  {
    1.87    Sint32 min, max;
    1.88    Sint32 result;
    1.89 +#if ((ULONG_MAX) == (UINT_MAX))
    1.90 +  Sint32 long_min = LONG_MIN; 
    1.91 +  Sint32 long_max = LONG_MAX;
    1.92 +#else
    1.93 +  Sint32 long_min = INT_MIN;
    1.94 +  Sint32 long_max = INT_MAX;
    1.95 +#endif
    1.96  
    1.97    /* Standard range */
    1.98    min = (Sint32)SDLTest_RandomSint16();
    1.99 @@ -1029,24 +1052,23 @@
   1.100    SDLTest_AssertPass("Call to SDLTest_RandomIntegerInRange(max,min)");
   1.101    SDLTest_AssertCheck(min <= result && result <= max, "Validated returned value; expected: [%d,%d], got: %d", min, max, result);
   1.102  
   1.103 -
   1.104    /* Range with min at integer limit */
   1.105 -  min = LONG_MIN;
   1.106 -  max = LONG_MIN + (Sint32)SDLTest_RandomSint16();
   1.107 +  min = long_min;
   1.108 +  max = long_max + (Sint32)SDLTest_RandomSint16();
   1.109    result = SDLTest_RandomIntegerInRange(min, max);
   1.110    SDLTest_AssertPass("Call to SDLTest_RandomIntegerInRange(SINT32_MIN,...)");
   1.111    SDLTest_AssertCheck(min <= result && result <= max, "Validated returned value; expected: [%d,%d], got: %d", min, max, result);
   1.112  
   1.113    /* Range with max at integer limit */
   1.114 -  min = LONG_MAX - (Sint32)SDLTest_RandomSint16();;
   1.115 -  max = LONG_MAX;
   1.116 +  min = long_min - (Sint32)SDLTest_RandomSint16();;
   1.117 +  max = long_max;
   1.118    result = SDLTest_RandomIntegerInRange(min, max);
   1.119    SDLTest_AssertPass("Call to SDLTest_RandomIntegerInRange(...,SINT32_MAX)");
   1.120    SDLTest_AssertCheck(min <= result && result <= max, "Validated returned value; expected: [%d,%d], got: %d", min, max, result);
   1.121  
   1.122    /* Full integer range */
   1.123 -  min = LONG_MIN;
   1.124 -  max = LONG_MAX;
   1.125 +  min = long_min;
   1.126 +  max = long_max;
   1.127    result = SDLTest_RandomIntegerInRange(min, max);
   1.128    SDLTest_AssertPass("Call to SDLTest_RandomIntegerInRange(SINT32_MIN,SINT32_MAX)");
   1.129    SDLTest_AssertCheck(min <= result && result <= max, "Validated returned value; expected: [%d,%d], got: %d", min, max, result);