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
This commit is contained in:
Sam Lantinga 2017-08-13 21:18:59 -07:00
parent eb06aba8ae
commit 0112f61889

View File

@ -2,17 +2,20 @@
* SDL_test test suite * SDL_test test suite
*/ */
#include <limits.h>
/* Visual Studio 2008 doesn't have stdint.h */ /* Visual Studio 2008 doesn't have stdint.h */
#if defined(_MSC_VER) && _MSC_VER <= 1500 #if defined(_MSC_VER) && _MSC_VER <= 1500
#define UINT8_MAX ~(Uint8)0 #define UINT8_MAX _UI8_MAX
#define UINT16_MAX ~(Uint16)0 #define UINT16_MAX _UI16_MAX
#define UINT32_MAX ~(Uint32)0 #define UINT32_MAX _UI32_MAX
#define UINT64_MAX ~(Uint64)0 #define INT64_MIN _I64_MIN
#define INT64_MAX _I64_MAX
#define UINT64_MAX _UI64_MAX
#else #else
#include <stdint.h> #include <stdint.h>
#endif #endif
#include <stdio.h> #include <stdio.h>
#include <limits.h>
#include <float.h> #include <float.h>
#include <ctype.h> #include <ctype.h>
@ -988,38 +991,38 @@ sdltest_randomBoundaryNumberSint64(void *arg)
"Validate result value for parameters (1,20,SDL_FALSE); expected: 0|21, got: %"SDL_PRIs64, sresult); "Validate result value for parameters (1,20,SDL_FALSE); expected: 0|21, got: %"SDL_PRIs64, sresult);
/* RandomSintXBoundaryValue(LLONG_MIN, 99, SDL_FALSE) returns 100 */ /* RandomSintXBoundaryValue(LLONG_MIN, 99, SDL_FALSE) returns 100 */
sresult = (Sint64)SDLTest_RandomSint64BoundaryValue(LLONG_MIN, 99, SDL_FALSE); sresult = (Sint64)SDLTest_RandomSint64BoundaryValue(INT64_MIN, 99, SDL_FALSE);
SDLTest_AssertPass("Call to SDLTest_RandomSint64BoundaryValue"); SDLTest_AssertPass("Call to SDLTest_RandomSint64BoundaryValue");
SDLTest_AssertCheck( SDLTest_AssertCheck(
sresult == 100, sresult == 100,
"Validate result value for parameters (LLONG_MIN,99,SDL_FALSE); expected: 100, got: %"SDL_PRIs64, sresult); "Validate result value for parameters (LLONG_MIN,99,SDL_FALSE); expected: 100, got: %"SDL_PRIs64, sresult);
/* RandomSintXBoundaryValue(LLONG_MIN + 1, LLONG_MAX, SDL_FALSE) returns LLONG_MIN (no error) */ /* RandomSintXBoundaryValue(LLONG_MIN + 1, LLONG_MAX, SDL_FALSE) returns LLONG_MIN (no error) */
sresult = (Sint64)SDLTest_RandomSint64BoundaryValue(LLONG_MIN + 1, LLONG_MAX, SDL_FALSE); sresult = (Sint64)SDLTest_RandomSint64BoundaryValue(INT64_MIN + 1, INT64_MAX, SDL_FALSE);
SDLTest_AssertPass("Call to SDLTest_RandomSint64BoundaryValue"); SDLTest_AssertPass("Call to SDLTest_RandomSint64BoundaryValue");
SDLTest_AssertCheck( SDLTest_AssertCheck(
sresult == LLONG_MIN, sresult == INT64_MIN,
"Validate result value for parameters (LLONG_MIN+1,LLONG_MAX,SDL_FALSE); expected: %"SDL_PRIs64", got: %"SDL_PRIs64, LLONG_MIN, sresult); "Validate result value for parameters (LLONG_MIN+1,LLONG_MAX,SDL_FALSE); expected: %"SDL_PRIs64", got: %"SDL_PRIs64, INT64_MIN, sresult);
lastError = (char *)SDL_GetError(); lastError = (char *)SDL_GetError();
SDLTest_AssertPass("SDL_GetError()"); SDLTest_AssertPass("SDL_GetError()");
SDLTest_AssertCheck(lastError == NULL || lastError[0] == '\0', "Validate no error message was set"); SDLTest_AssertCheck(lastError == NULL || lastError[0] == '\0', "Validate no error message was set");
/* RandomSintXBoundaryValue(LLONG_MIN, LLONG_MAX - 1, SDL_FALSE) returns LLONG_MAX (no error) */ /* RandomSintXBoundaryValue(LLONG_MIN, LLONG_MAX - 1, SDL_FALSE) returns LLONG_MAX (no error) */
sresult = (Sint64)SDLTest_RandomSint64BoundaryValue(LLONG_MIN, LLONG_MAX - 1, SDL_FALSE); sresult = (Sint64)SDLTest_RandomSint64BoundaryValue(INT64_MIN, INT64_MAX - 1, SDL_FALSE);
SDLTest_AssertPass("Call to SDLTest_RandomSint64BoundaryValue"); SDLTest_AssertPass("Call to SDLTest_RandomSint64BoundaryValue");
SDLTest_AssertCheck( SDLTest_AssertCheck(
sresult == LLONG_MAX, sresult == INT64_MAX,
"Validate result value for parameters (LLONG_MIN,LLONG_MAX - 1,SDL_FALSE); expected: %"SDL_PRIs64", got: %"SDL_PRIs64, LLONG_MAX, sresult); "Validate result value for parameters (LLONG_MIN,LLONG_MAX - 1,SDL_FALSE); expected: %"SDL_PRIs64", got: %"SDL_PRIs64, INT64_MAX, sresult);
lastError = (char *)SDL_GetError(); lastError = (char *)SDL_GetError();
SDLTest_AssertPass("SDL_GetError()"); SDLTest_AssertPass("SDL_GetError()");
SDLTest_AssertCheck(lastError == NULL || lastError[0] == '\0', "Validate no error message was set"); SDLTest_AssertCheck(lastError == NULL || lastError[0] == '\0', "Validate no error message was set");
/* RandomSintXBoundaryValue(LLONG_MIN, LLONG_MAX, SDL_FALSE) returns 0 (sets error) */ /* RandomSintXBoundaryValue(LLONG_MIN, LLONG_MAX, SDL_FALSE) returns 0 (sets error) */
sresult = (Sint64)SDLTest_RandomSint64BoundaryValue(LLONG_MIN, LLONG_MAX, SDL_FALSE); sresult = (Sint64)SDLTest_RandomSint64BoundaryValue(INT64_MIN, INT64_MAX, SDL_FALSE);
SDLTest_AssertPass("Call to SDLTest_RandomSint64BoundaryValue"); SDLTest_AssertPass("Call to SDLTest_RandomSint64BoundaryValue");
SDLTest_AssertCheck( SDLTest_AssertCheck(
sresult == LLONG_MIN, sresult == INT64_MIN,
"Validate result value for parameters(LLONG_MIN,LLONG_MAX,SDL_FALSE); expected: %"SDL_PRIs64", got: %"SDL_PRIs64, LLONG_MIN, sresult); "Validate result value for parameters(LLONG_MIN,LLONG_MAX,SDL_FALSE); expected: %"SDL_PRIs64", got: %"SDL_PRIs64, INT64_MIN, sresult);
lastError = (char *)SDL_GetError(); lastError = (char *)SDL_GetError();
SDLTest_AssertPass("SDL_GetError()"); SDLTest_AssertPass("SDL_GetError()");
SDLTest_AssertCheck(lastError != NULL && SDL_strcmp(lastError, expectedError) == 0, SDLTest_AssertCheck(lastError != NULL && SDL_strcmp(lastError, expectedError) == 0,