Skip to content
Permalink
Browse files

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
  • Loading branch information
slouken committed Aug 14, 2017
1 parent eb06aba commit 0112f61889813bc2c232e9b637a339e2e1e8d792
Showing with 18 additions and 15 deletions.
  1. +18 −15 test/testautomation_sdltest.c
@@ -2,17 +2,20 @@
* SDL_test test suite
*/

#include <limits.h>
/* Visual Studio 2008 doesn't have stdint.h */
#if defined(_MSC_VER) && _MSC_VER <= 1500
#define UINT8_MAX ~(Uint8)0
#define UINT16_MAX ~(Uint16)0
#define UINT32_MAX ~(Uint32)0
#define UINT64_MAX ~(Uint64)0
#define UINT8_MAX _UI8_MAX
#define UINT16_MAX _UI16_MAX
#define UINT32_MAX _UI32_MAX
#define INT64_MIN _I64_MIN
#define INT64_MAX _I64_MAX
#define UINT64_MAX _UI64_MAX
#else
#include <stdint.h>
#endif

#include <stdio.h>
#include <limits.h>
#include <float.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);

/* 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_AssertCheck(
sresult == 100,
"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) */
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_AssertCheck(
sresult == LLONG_MIN,
"Validate result value for parameters (LLONG_MIN+1,LLONG_MAX,SDL_FALSE); expected: %"SDL_PRIs64", got: %"SDL_PRIs64, LLONG_MIN, sresult);
sresult == INT64_MIN,
"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();
SDLTest_AssertPass("SDL_GetError()");
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) */
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_AssertCheck(
sresult == LLONG_MAX,
"Validate result value for parameters (LLONG_MIN,LLONG_MAX - 1,SDL_FALSE); expected: %"SDL_PRIs64", got: %"SDL_PRIs64, LLONG_MAX, sresult);
sresult == INT64_MAX,
"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();
SDLTest_AssertPass("SDL_GetError()");
SDLTest_AssertCheck(lastError == NULL || lastError[0] == '\0', "Validate no error message was set");

/* 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_AssertCheck(
sresult == LLONG_MIN,
"Validate result value for parameters(LLONG_MIN,LLONG_MAX,SDL_FALSE); expected: %"SDL_PRIs64", got: %"SDL_PRIs64, LLONG_MIN, sresult);
sresult == INT64_MIN,
"Validate result value for parameters(LLONG_MIN,LLONG_MAX,SDL_FALSE); expected: %"SDL_PRIs64", got: %"SDL_PRIs64, INT64_MIN, sresult);
lastError = (char *)SDL_GetError();
SDLTest_AssertPass("SDL_GetError()");
SDLTest_AssertCheck(lastError != NULL && SDL_strcmp(lastError, expectedError) == 0,

0 comments on commit 0112f61

Please sign in to comment.