Fixed bug 3743 - make testautomation_sdltest.c to compile
authorSam Lantinga <slouken@libsdl.org>
Sun, 13 Aug 2017 21:18:59 -0700
changeset 11277a2792ce0ec8c
parent 11276 ebbad52788e1
child 11278 37f4d29e155d
Fixed bug 3743 - make testautomation_sdltest.c to compile

Ozkan Sezer

The attached patch makes testautomation_sdltest.c more compatible wrt
LLONG_{MIN|MAX} macros and makes it to compile on older systems (e.g.
glibc-2.8) too, by replacing LLONG_{MIN|MAX} with INT64_{MIN|MAX}.

c.f.: bug #3494, where the same issue was described for SDL_test_fuzzer.c
test/testautomation_sdltest.c
     1.1 --- a/test/testautomation_sdltest.c	Sun Aug 13 21:16:58 2017 -0700
     1.2 +++ b/test/testautomation_sdltest.c	Sun Aug 13 21:18:59 2017 -0700
     1.3 @@ -2,17 +2,20 @@
     1.4   * SDL_test test suite
     1.5   */
     1.6  
     1.7 +#include <limits.h>
     1.8  /* Visual Studio 2008 doesn't have stdint.h */
     1.9  #if defined(_MSC_VER) && _MSC_VER <= 1500
    1.10 -#define UINT8_MAX   ~(Uint8)0
    1.11 -#define UINT16_MAX  ~(Uint16)0
    1.12 -#define UINT32_MAX  ~(Uint32)0
    1.13 -#define UINT64_MAX  ~(Uint64)0
    1.14 +#define UINT8_MAX   _UI8_MAX
    1.15 +#define UINT16_MAX  _UI16_MAX
    1.16 +#define UINT32_MAX  _UI32_MAX
    1.17 +#define INT64_MIN    _I64_MIN
    1.18 +#define INT64_MAX    _I64_MAX
    1.19 +#define UINT64_MAX  _UI64_MAX
    1.20  #else
    1.21  #include <stdint.h>
    1.22  #endif
    1.23 +
    1.24  #include <stdio.h>
    1.25 -#include <limits.h>
    1.26  #include <float.h>
    1.27  #include <ctype.h>
    1.28  
    1.29 @@ -988,38 +991,38 @@
    1.30      "Validate result value for parameters (1,20,SDL_FALSE); expected: 0|21, got: %"SDL_PRIs64, sresult);
    1.31  
    1.32    /* RandomSintXBoundaryValue(LLONG_MIN, 99, SDL_FALSE) returns 100 */
    1.33 -  sresult = (Sint64)SDLTest_RandomSint64BoundaryValue(LLONG_MIN, 99, SDL_FALSE);
    1.34 +  sresult = (Sint64)SDLTest_RandomSint64BoundaryValue(INT64_MIN, 99, SDL_FALSE);
    1.35    SDLTest_AssertPass("Call to SDLTest_RandomSint64BoundaryValue");
    1.36    SDLTest_AssertCheck(
    1.37      sresult == 100,
    1.38      "Validate result value for parameters (LLONG_MIN,99,SDL_FALSE); expected: 100, got: %"SDL_PRIs64, sresult);
    1.39  
    1.40    /* RandomSintXBoundaryValue(LLONG_MIN + 1, LLONG_MAX, SDL_FALSE) returns LLONG_MIN (no error) */
    1.41 -  sresult = (Sint64)SDLTest_RandomSint64BoundaryValue(LLONG_MIN + 1, LLONG_MAX, SDL_FALSE);
    1.42 +  sresult = (Sint64)SDLTest_RandomSint64BoundaryValue(INT64_MIN + 1, INT64_MAX, SDL_FALSE);
    1.43    SDLTest_AssertPass("Call to SDLTest_RandomSint64BoundaryValue");
    1.44    SDLTest_AssertCheck(
    1.45 -    sresult == LLONG_MIN,
    1.46 -    "Validate result value for parameters (LLONG_MIN+1,LLONG_MAX,SDL_FALSE); expected: %"SDL_PRIs64", got: %"SDL_PRIs64, LLONG_MIN, sresult);
    1.47 +    sresult == INT64_MIN,
    1.48 +    "Validate result value for parameters (LLONG_MIN+1,LLONG_MAX,SDL_FALSE); expected: %"SDL_PRIs64", got: %"SDL_PRIs64, INT64_MIN, sresult);
    1.49    lastError = (char *)SDL_GetError();
    1.50    SDLTest_AssertPass("SDL_GetError()");
    1.51    SDLTest_AssertCheck(lastError == NULL || lastError[0] == '\0', "Validate no error message was set");
    1.52  
    1.53    /* RandomSintXBoundaryValue(LLONG_MIN, LLONG_MAX - 1, SDL_FALSE) returns LLONG_MAX (no error) */
    1.54 -  sresult = (Sint64)SDLTest_RandomSint64BoundaryValue(LLONG_MIN, LLONG_MAX - 1, SDL_FALSE);
    1.55 +  sresult = (Sint64)SDLTest_RandomSint64BoundaryValue(INT64_MIN, INT64_MAX - 1, SDL_FALSE);
    1.56    SDLTest_AssertPass("Call to SDLTest_RandomSint64BoundaryValue");
    1.57    SDLTest_AssertCheck(
    1.58 -    sresult == LLONG_MAX,
    1.59 -    "Validate result value for parameters (LLONG_MIN,LLONG_MAX - 1,SDL_FALSE); expected: %"SDL_PRIs64", got: %"SDL_PRIs64, LLONG_MAX, sresult);
    1.60 +    sresult == INT64_MAX,
    1.61 +    "Validate result value for parameters (LLONG_MIN,LLONG_MAX - 1,SDL_FALSE); expected: %"SDL_PRIs64", got: %"SDL_PRIs64, INT64_MAX, sresult);
    1.62    lastError = (char *)SDL_GetError();
    1.63    SDLTest_AssertPass("SDL_GetError()");
    1.64    SDLTest_AssertCheck(lastError == NULL || lastError[0] == '\0', "Validate no error message was set");
    1.65  
    1.66    /* RandomSintXBoundaryValue(LLONG_MIN, LLONG_MAX, SDL_FALSE) returns 0 (sets error) */
    1.67 -  sresult = (Sint64)SDLTest_RandomSint64BoundaryValue(LLONG_MIN, LLONG_MAX, SDL_FALSE);
    1.68 +  sresult = (Sint64)SDLTest_RandomSint64BoundaryValue(INT64_MIN, INT64_MAX, SDL_FALSE);
    1.69    SDLTest_AssertPass("Call to SDLTest_RandomSint64BoundaryValue");
    1.70    SDLTest_AssertCheck(
    1.71 -    sresult == LLONG_MIN,
    1.72 -    "Validate result value for parameters(LLONG_MIN,LLONG_MAX,SDL_FALSE); expected: %"SDL_PRIs64", got: %"SDL_PRIs64, LLONG_MIN, sresult);
    1.73 +    sresult == INT64_MIN,
    1.74 +    "Validate result value for parameters(LLONG_MIN,LLONG_MAX,SDL_FALSE); expected: %"SDL_PRIs64", got: %"SDL_PRIs64, INT64_MIN, sresult);
    1.75    lastError = (char *)SDL_GetError();
    1.76    SDLTest_AssertPass("SDL_GetError()");
    1.77    SDLTest_AssertCheck(lastError != NULL && SDL_strcmp(lastError, expectedError) == 0,