Remove more reserved identifiers (#6925)

This commit is contained in:
Sylvain Becker 2022-12-29 22:58:16 +01:00 committed by GitHub
parent ce412c2c71
commit d7d3c22dbf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
29 changed files with 517 additions and 517 deletions

View file

@ -51,7 +51,7 @@ assert can have unique static variables associated with it.
/* Don't include intrin.h here because it contains C++ code */ /* Don't include intrin.h here because it contains C++ code */
extern void __cdecl __debugbreak(void); extern void __cdecl __debugbreak(void);
#define SDL_TriggerBreakpoint() __debugbreak() #define SDL_TriggerBreakpoint() __debugbreak()
#elif _SDL_HAS_BUILTIN(__builtin_debugtrap) #elif SDL_HAS_BUILTIN(__builtin_debugtrap)
#define SDL_TriggerBreakpoint() __builtin_debugtrap() #define SDL_TriggerBreakpoint() __builtin_debugtrap()
#elif (defined(__GNUC__) || defined(__clang__)) && (defined(__i386__) || defined(__x86_64__)) #elif (defined(__GNUC__) || defined(__clang__)) && (defined(__i386__) || defined(__x86_64__))
#define SDL_TriggerBreakpoint() __asm__ __volatile__ ( "int $3\n\t" ) #define SDL_TriggerBreakpoint() __asm__ __volatile__ ( "int $3\n\t" )

View file

@ -154,18 +154,18 @@
#define SDL_FALLTHROUGH [[fallthrough]] #define SDL_FALLTHROUGH [[fallthrough]]
#else #else
#if defined(__has_attribute) #if defined(__has_attribute)
#define _HAS_FALLTHROUGH __has_attribute(__fallthrough__) #define SDL_HAS_FALLTHROUGH __has_attribute(__fallthrough__)
#else #else
#define _HAS_FALLTHROUGH 0 #define SDL_HAS_FALLTHROUGH 0
#endif /* __has_attribute */ #endif /* __has_attribute */
#if _HAS_FALLTHROUGH && \ #if SDL_HAS_FALLTHROUGH && \
((defined(__GNUC__) && __GNUC__ >= 7) || \ ((defined(__GNUC__) && __GNUC__ >= 7) || \
(defined(__clang_major__) && __clang_major__ >= 10)) (defined(__clang_major__) && __clang_major__ >= 10))
#define SDL_FALLTHROUGH __attribute__((__fallthrough__)) #define SDL_FALLTHROUGH __attribute__((__fallthrough__))
#else #else
#define SDL_FALLTHROUGH do {} while (0) /* fallthrough */ #define SDL_FALLTHROUGH do {} while (0) /* fallthrough */
#endif /* _HAS_FALLTHROUGH */ #endif /* SDL_HAS_FALLTHROUGH */
#undef _HAS_FALLTHROUGH #undef SDL_HAS_FALLTHROUGH
#endif /* C++17 or C2x */ #endif /* C++17 or C2x */
#endif /* SDL_FALLTHROUGH not defined */ #endif /* SDL_FALLTHROUGH not defined */

View file

@ -122,11 +122,11 @@ extern "C" {
/* various modern compilers may have builtin swap */ /* various modern compilers may have builtin swap */
#if defined(__GNUC__) || defined(__clang__) #if defined(__GNUC__) || defined(__clang__)
# define HAS_BUILTIN_BSWAP16 (_SDL_HAS_BUILTIN(__builtin_bswap16)) || \ # define HAS_BUILTIN_BSWAP16 (SDL_HAS_BUILTIN(__builtin_bswap16)) || \
(__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8)) (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8))
# define HAS_BUILTIN_BSWAP32 (_SDL_HAS_BUILTIN(__builtin_bswap32)) || \ # define HAS_BUILTIN_BSWAP32 (SDL_HAS_BUILTIN(__builtin_bswap32)) || \
(__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)) (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))
# define HAS_BUILTIN_BSWAP64 (_SDL_HAS_BUILTIN(__builtin_bswap64)) || \ # define HAS_BUILTIN_BSWAP64 (SDL_HAS_BUILTIN(__builtin_bswap64)) || \
(__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)) (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))
/* this one is broken */ /* this one is broken */

View file

@ -72,9 +72,9 @@ char *alloca();
* instead of checking the clang version if possible. * instead of checking the clang version if possible.
*/ */
#ifdef __has_builtin #ifdef __has_builtin
#define _SDL_HAS_BUILTIN(x) __has_builtin(x) #define SDL_HAS_BUILTIN(x) __has_builtin(x)
#else #else
#define _SDL_HAS_BUILTIN(x) 0 #define SDL_HAS_BUILTIN(x) 0
#endif #endif
/** /**
@ -694,7 +694,7 @@ SDL_FORCE_INLINE int SDL_size_mul_overflow (size_t a,
return 0; return 0;
} }
#if _SDL_HAS_BUILTIN(__builtin_mul_overflow) #if SDL_HAS_BUILTIN(__builtin_mul_overflow)
/* This needs to be wrapped in an inline rather than being a direct #define, /* This needs to be wrapped in an inline rather than being a direct #define,
* because __builtin_mul_overflow() is type-generic, but we want to be * because __builtin_mul_overflow() is type-generic, but we want to be
* consistent about interpreting a and b as size_t. */ * consistent about interpreting a and b as size_t. */
@ -724,7 +724,7 @@ SDL_FORCE_INLINE int SDL_size_add_overflow (size_t a,
return 0; return 0;
} }
#if _SDL_HAS_BUILTIN(__builtin_add_overflow) #if SDL_HAS_BUILTIN(__builtin_add_overflow)
/* This needs to be wrapped in an inline rather than being a direct #define, /* This needs to be wrapped in an inline rather than being a direct #define,
* the same as the call to __builtin_mul_overflow() above. */ * the same as the call to __builtin_mul_overflow() above. */
SDL_FORCE_INLINE int SDL_size_add_overflow_builtin (size_t a, SDL_FORCE_INLINE int SDL_size_add_overflow_builtin (size_t a,

View file

@ -31,18 +31,18 @@
#include "SDL_audiodev_c.h" #include "SDL_audiodev_c.h"
#ifndef _PATH_DEV_DSP #ifndef SDL_PATH_DEV_DSP
#if defined(__NETBSD__) || defined(__OPENBSD__) #if defined(__NETBSD__) || defined(__OPENBSD__)
#define _PATH_DEV_DSP "/dev/audio" #define SDL_PATH_DEV_DSP "/dev/audio"
#else #else
#define _PATH_DEV_DSP "/dev/dsp" #define SDL_PATH_DEV_DSP "/dev/dsp"
#endif #endif
#endif #endif
#ifndef _PATH_DEV_DSP24 #ifndef SDL_PATH_DEV_DSP24
#define _PATH_DEV_DSP24 "/dev/sound/dsp" #define SDL_PATH_DEV_DSP24 "/dev/sound/dsp"
#endif #endif
#ifndef _PATH_DEV_AUDIO #ifndef SDL_PATH_DEV_AUDIO
#define _PATH_DEV_AUDIO "/dev/audio" #define SDL_PATH_DEV_AUDIO "/dev/audio"
#endif #endif
static void test_device(const int iscapture, const char *fname, int flags, int (*test)(int fd)) static void test_device(const int iscapture, const char *fname, int flags, int (*test)(int fd))
@ -91,15 +91,15 @@ static void SDL_EnumUnixAudioDevices_Internal(const int iscapture, const int cla
} }
if (audiodev == NULL) { if (audiodev == NULL) {
if (classic) { if (classic) {
audiodev = _PATH_DEV_AUDIO; audiodev = SDL_PATH_DEV_AUDIO;
} else { } else {
struct stat sb; struct stat sb;
/* Added support for /dev/sound/\* in Linux 2.4 */ /* Added support for /dev/sound/\* in Linux 2.4 */
if (((stat("/dev/sound", &sb) == 0) && S_ISDIR(sb.st_mode)) && ((stat(_PATH_DEV_DSP24, &sb) == 0) && S_ISCHR(sb.st_mode))) { if (((stat("/dev/sound", &sb) == 0) && S_ISDIR(sb.st_mode)) && ((stat(SDL_PATH_DEV_DSP24, &sb) == 0) && S_ISCHR(sb.st_mode))) {
audiodev = _PATH_DEV_DSP24; audiodev = SDL_PATH_DEV_DSP24;
} else { } else {
audiodev = _PATH_DEV_DSP; audiodev = SDL_PATH_DEV_DSP;
} }
} }
} }

View file

@ -41,7 +41,7 @@
#define DBUS_TIMEOUT 500 #define DBUS_TIMEOUT 500
typedef struct _FcitxClient typedef struct FcitxClient
{ {
SDL_DBusContext *dbus; SDL_DBusContext *dbus;

View file

@ -24,21 +24,21 @@
#include "SDL_ibus.h" #include "SDL_ibus.h"
#include "SDL_fcitx.h" #include "SDL_fcitx.h"
typedef SDL_bool (*_SDL_IME_Init)(void); typedef SDL_bool (*SDL_IME_Init_t)(void);
typedef void (*_SDL_IME_Quit)(void); typedef void (*SDL_IME_Quit_t)(void);
typedef void (*_SDL_IME_SetFocus)(SDL_bool); typedef void (*SDL_IME_SetFocus_t)(SDL_bool);
typedef void (*_SDL_IME_Reset)(void); typedef void (*SDL_IME_Reset_t)(void);
typedef SDL_bool (*_SDL_IME_ProcessKeyEvent)(Uint32, Uint32, Uint8 state); typedef SDL_bool (*SDL_IME_ProcessKeyEvent_t)(Uint32, Uint32, Uint8 state);
typedef void (*_SDL_IME_UpdateTextRect)(const SDL_Rect *); typedef void (*SDL_IME_UpdateTextRect_t)(const SDL_Rect *);
typedef void (*_SDL_IME_PumpEvents)(void); typedef void (*SDL_IME_PumpEvents_t)(void);
static _SDL_IME_Init SDL_IME_Init_Real = NULL; static SDL_IME_Init_t SDL_IME_Init_Real = NULL;
static _SDL_IME_Quit SDL_IME_Quit_Real = NULL; static SDL_IME_Quit_t SDL_IME_Quit_Real = NULL;
static _SDL_IME_SetFocus SDL_IME_SetFocus_Real = NULL; static SDL_IME_SetFocus_t SDL_IME_SetFocus_Real = NULL;
static _SDL_IME_Reset SDL_IME_Reset_Real = NULL; static SDL_IME_Reset_t SDL_IME_Reset_Real = NULL;
static _SDL_IME_ProcessKeyEvent SDL_IME_ProcessKeyEvent_Real = NULL; static SDL_IME_ProcessKeyEvent_t SDL_IME_ProcessKeyEvent_Real = NULL;
static _SDL_IME_UpdateTextRect SDL_IME_UpdateTextRect_Real = NULL; static SDL_IME_UpdateTextRect_t SDL_IME_UpdateTextRect_Real = NULL;
static _SDL_IME_PumpEvents SDL_IME_PumpEvents_Real = NULL; static SDL_IME_PumpEvents_t SDL_IME_PumpEvents_Real = NULL;
static void InitIME() static void InitIME()
{ {

View file

@ -68,18 +68,18 @@ static SDL_DisabledEventBlock *SDL_disabled_events[256];
static Uint32 SDL_userevents = SDL_USEREVENT; static Uint32 SDL_userevents = SDL_USEREVENT;
/* Private data -- event queue */ /* Private data -- event queue */
typedef struct _SDL_EventEntry typedef struct SDL_EventEntry
{ {
SDL_Event event; SDL_Event event;
SDL_SysWMmsg msg; SDL_SysWMmsg msg;
struct _SDL_EventEntry *prev; struct SDL_EventEntry *prev;
struct _SDL_EventEntry *next; struct SDL_EventEntry *next;
} SDL_EventEntry; } SDL_EventEntry;
typedef struct _SDL_SysWMEntry typedef struct SDL_SysWMEntry
{ {
SDL_SysWMmsg msg; SDL_SysWMmsg msg;
struct _SDL_SysWMEntry *next; struct SDL_SysWMEntry *next;
} SDL_SysWMEntry; } SDL_SysWMEntry;
static struct static struct

View file

@ -622,7 +622,7 @@ static void SDLCALL SDL_AppleTVRemoteRotationHintChanged(void *udata, const char
static int IOS_JoystickInit(void) static int IOS_JoystickInit(void)
{ {
#if defined(__MACOS__) #if defined(__MACOS__)
#if _SDL_HAS_BUILTIN(__builtin_available) #if SDL_HAS_BUILTIN(__builtin_available)
if (@available(macOS 10.16, *)) { if (@available(macOS 10.16, *)) {
/* Continue with initialization on macOS 11+ */ /* Continue with initialization on macOS 11+ */
} else { } else {

View file

@ -46,9 +46,9 @@
#define USB_PACKET_LENGTH 64 #define USB_PACKET_LENGTH 64
/* Forward declaration */ /* Forward declaration */
struct _SDL_HIDAPI_DeviceDriver; struct SDL_HIDAPI_DeviceDriver;
typedef struct _SDL_HIDAPI_Device typedef struct SDL_HIDAPI_Device
{ {
char *name; char *name;
char *path; char *path;
@ -67,7 +67,7 @@ typedef struct _SDL_HIDAPI_Device
SDL_JoystickType joystick_type; SDL_JoystickType joystick_type;
SDL_GamepadType type; SDL_GamepadType type;
struct _SDL_HIDAPI_DeviceDriver *driver; struct SDL_HIDAPI_DeviceDriver *driver;
void *context; void *context;
SDL_mutex *dev_lock; SDL_mutex *dev_lock;
SDL_hid_device *dev; SDL_hid_device *dev;
@ -81,14 +81,14 @@ typedef struct _SDL_HIDAPI_Device
/* Used to flag that the device is being updated */ /* Used to flag that the device is being updated */
SDL_bool updating; SDL_bool updating;
struct _SDL_HIDAPI_Device *parent; struct SDL_HIDAPI_Device *parent;
int num_children; int num_children;
struct _SDL_HIDAPI_Device **children; struct SDL_HIDAPI_Device **children;
struct _SDL_HIDAPI_Device *next; struct SDL_HIDAPI_Device *next;
} SDL_HIDAPI_Device; } SDL_HIDAPI_Device;
typedef struct _SDL_HIDAPI_DeviceDriver typedef struct SDL_HIDAPI_DeviceDriver
{ {
const char *name; const char *name;
SDL_bool enabled; SDL_bool enabled;

View file

@ -93,7 +93,7 @@ static int SDL_RAWINPUT_numjoysticks = 0;
static void RAWINPUT_JoystickClose(SDL_Joystick *joystick); static void RAWINPUT_JoystickClose(SDL_Joystick *joystick);
typedef struct _SDL_RAWINPUT_Device typedef struct SDL_RAWINPUT_Device
{ {
SDL_atomic_t refcount; SDL_atomic_t refcount;
char *name; char *name;
@ -110,7 +110,7 @@ typedef struct _SDL_RAWINPUT_Device
SDL_Joystick *joystick; SDL_Joystick *joystick;
SDL_JoystickID joystick_id; SDL_JoystickID joystick_id;
struct _SDL_RAWINPUT_Device *next; struct SDL_RAWINPUT_Device *next;
} SDL_RAWINPUT_Device; } SDL_RAWINPUT_Device;
struct joystick_hwdata struct joystick_hwdata

View file

@ -23,7 +23,7 @@
#ifndef SDL_sensor_c_h_ #ifndef SDL_sensor_c_h_
#define SDL_sensor_c_h_ #define SDL_sensor_c_h_
struct _SDL_SensorDriver; struct SDL_SensorDriver;
/* Useful functions and variables from SDL_sensor.c */ /* Useful functions and variables from SDL_sensor.c */

View file

@ -37,7 +37,7 @@ struct SDL_Sensor
float data[16]; /* The current state of the sensor */ float data[16]; /* The current state of the sensor */
struct _SDL_SensorDriver *driver; struct SDL_SensorDriver *driver;
struct sensor_hwdata *hwdata; /* Driver dependent information */ struct sensor_hwdata *hwdata; /* Driver dependent information */
@ -46,7 +46,7 @@ struct SDL_Sensor
struct SDL_Sensor *next; /* pointer to next sensor we have allocated */ struct SDL_Sensor *next; /* pointer to next sensor we have allocated */
}; };
typedef struct _SDL_SensorDriver typedef struct SDL_SensorDriver
{ {
/* Function to scan the system for sensors. /* Function to scan the system for sensors.
* sensor 0 should be the system default sensor. * sensor 0 should be the system default sensor.

View file

@ -27,7 +27,7 @@
#if !defined(__EMSCRIPTEN__) || !SDL_THREADS_DISABLED #if !defined(__EMSCRIPTEN__) || !SDL_THREADS_DISABLED
typedef struct _SDL_Timer typedef struct SDL_Timer
{ {
int timerID; int timerID;
SDL_TimerCallback callback; SDL_TimerCallback callback;
@ -35,14 +35,14 @@ typedef struct _SDL_Timer
Uint64 interval; Uint64 interval;
Uint64 scheduled; Uint64 scheduled;
SDL_atomic_t canceled; SDL_atomic_t canceled;
struct _SDL_Timer *next; struct SDL_Timer *next;
} SDL_Timer; } SDL_Timer;
typedef struct _SDL_TimerMap typedef struct SDL_TimerMap
{ {
int timerID; int timerID;
SDL_Timer *timer; SDL_Timer *timer;
struct _SDL_TimerMap *next; struct SDL_TimerMap *next;
} SDL_TimerMap; } SDL_TimerMap;
/* The timers are kept in a sorted list */ /* The timers are kept in a sorted list */
@ -370,14 +370,14 @@ SDL_bool SDL_RemoveTimer(SDL_TimerID id)
#include <emscripten/emscripten.h> #include <emscripten/emscripten.h>
#include <emscripten/eventloop.h> #include <emscripten/eventloop.h>
typedef struct _SDL_TimerMap typedef struct SDL_TimerMap
{ {
int timerID; int timerID;
int timeoutID; int timeoutID;
Uint32 interval; Uint32 interval;
SDL_TimerCallback callback; SDL_TimerCallback callback;
void *param; void *param;
struct _SDL_TimerMap *next; struct SDL_TimerMap *next;
} SDL_TimerMap; } SDL_TimerMap;
typedef struct typedef struct

View file

@ -29,7 +29,7 @@
#define MAX_CURSOR_W 512 #define MAX_CURSOR_W 512
#define MAX_CURSOR_H 512 #define MAX_CURSOR_H 512
typedef struct _KMSDRM_CursorData typedef struct KMSDRM_CursorData
{ {
int hot_x, hot_y; int hot_x, hot_y;
int w, h; int w, h;

View file

@ -17,7 +17,7 @@
/* Fixture */ /* Fixture */
void _audioSetUp(void *arg) static void audioSetUp(void *arg)
{ {
/* Start SDL audio subsystem */ /* Start SDL audio subsystem */
int ret = SDL_InitSubSystem(SDL_INIT_AUDIO); int ret = SDL_InitSubSystem(SDL_INIT_AUDIO);
@ -28,7 +28,7 @@ void _audioSetUp(void *arg)
} }
} }
void _audioTearDown(void *arg) static void audioTearDown(void *arg)
{ {
/* Remove a possibly created file from SDL disk writer audio driver; ignore errors */ /* Remove a possibly created file from SDL disk writer audio driver; ignore errors */
(void)remove("sdlaudio.raw"); (void)remove("sdlaudio.raw");
@ -37,17 +37,17 @@ void _audioTearDown(void *arg)
} }
/* Global counter for callback invocation */ /* Global counter for callback invocation */
int _audio_testCallbackCounter; static int g_audio_testCallbackCounter;
/* Global accumulator for total callback length */ /* Global accumulator for total callback length */
int _audio_testCallbackLength; static int g_audio_testCallbackLength;
/* Test callback function */ /* Test callback function */
void SDLCALL _audio_testCallback(void *userdata, Uint8 *stream, int len) static void SDLCALL audio_testCallback(void *userdata, Uint8 *stream, int len)
{ {
/* track that callback was called */ /* track that callback was called */
_audio_testCallbackCounter++; g_audio_testCallbackCounter++;
_audio_testCallbackLength += len; g_audio_testCallbackLength += len;
} }
/* Test case functions */ /* Test case functions */
@ -65,7 +65,7 @@ int audio_quitInitAudioSubSystem()
SDLTest_AssertPass("Call to SDL_QuitSubSystem(SDL_INIT_AUDIO)"); SDLTest_AssertPass("Call to SDL_QuitSubSystem(SDL_INIT_AUDIO)");
/* Restart audio again */ /* Restart audio again */
_audioSetUp(NULL); audioSetUp(NULL);
return TEST_COMPLETED; return TEST_COMPLETED;
} }
@ -121,7 +121,7 @@ int audio_initQuitAudio()
SDLTest_AssertPass("Call to SDL_QuitSubSystem(SDL_INIT_AUDIO)"); SDLTest_AssertPass("Call to SDL_QuitSubSystem(SDL_INIT_AUDIO)");
/* Restart audio again */ /* Restart audio again */
_audioSetUp(NULL); audioSetUp(NULL);
return TEST_COMPLETED; return TEST_COMPLETED;
} }
@ -173,7 +173,7 @@ int audio_initOpenCloseQuitAudio()
desired.format = AUDIO_S16SYS; desired.format = AUDIO_S16SYS;
desired.channels = 2; desired.channels = 2;
desired.samples = 4096; desired.samples = 4096;
desired.callback = _audio_testCallback; desired.callback = audio_testCallback;
desired.userdata = NULL; desired.userdata = NULL;
case 1: case 1:
@ -182,7 +182,7 @@ int audio_initOpenCloseQuitAudio()
desired.format = AUDIO_F32SYS; desired.format = AUDIO_F32SYS;
desired.channels = 2; desired.channels = 2;
desired.samples = 2048; desired.samples = 2048;
desired.callback = _audio_testCallback; desired.callback = audio_testCallback;
desired.userdata = NULL; desired.userdata = NULL;
break; break;
} }
@ -211,7 +211,7 @@ int audio_initOpenCloseQuitAudio()
} /* driver loop */ } /* driver loop */
/* Restart audio again */ /* Restart audio again */
_audioSetUp(NULL); audioSetUp(NULL);
return TEST_COMPLETED; return TEST_COMPLETED;
} }
@ -263,7 +263,7 @@ int audio_pauseUnpauseAudio()
desired.format = AUDIO_S16SYS; desired.format = AUDIO_S16SYS;
desired.channels = 2; desired.channels = 2;
desired.samples = 4096; desired.samples = 4096;
desired.callback = _audio_testCallback; desired.callback = audio_testCallback;
desired.userdata = NULL; desired.userdata = NULL;
case 1: case 1:
@ -272,7 +272,7 @@ int audio_pauseUnpauseAudio()
desired.format = AUDIO_F32SYS; desired.format = AUDIO_F32SYS;
desired.channels = 2; desired.channels = 2;
desired.samples = 2048; desired.samples = 2048;
desired.callback = _audio_testCallback; desired.callback = audio_testCallback;
desired.userdata = NULL; desired.userdata = NULL;
break; break;
} }
@ -287,8 +287,8 @@ int audio_pauseUnpauseAudio()
SDLTest_Log("Pause/Unpause iteration: %d", l + 1); SDLTest_Log("Pause/Unpause iteration: %d", l + 1);
/* Reset callback counters */ /* Reset callback counters */
_audio_testCallbackCounter = 0; g_audio_testCallbackCounter = 0;
_audio_testCallbackLength = 0; g_audio_testCallbackLength = 0;
/* Un-pause audio to start playing (maybe multiple times) */ /* Un-pause audio to start playing (maybe multiple times) */
pause_on = 0; pause_on = 0;
@ -302,9 +302,9 @@ int audio_pauseUnpauseAudio()
do { do {
SDL_Delay(10); SDL_Delay(10);
totalDelay += 10; totalDelay += 10;
} while (_audio_testCallbackCounter == 0 && totalDelay < 1000); } while (g_audio_testCallbackCounter == 0 && totalDelay < 1000);
SDLTest_AssertCheck(_audio_testCallbackCounter > 0, "Verify callback counter; expected: >0 got: %d", _audio_testCallbackCounter); SDLTest_AssertCheck(g_audio_testCallbackCounter > 0, "Verify callback counter; expected: >0 got: %d", g_audio_testCallbackCounter);
SDLTest_AssertCheck(_audio_testCallbackLength > 0, "Verify callback length; expected: >0 got: %d", _audio_testCallbackLength); SDLTest_AssertCheck(g_audio_testCallbackLength > 0, "Verify callback length; expected: >0 got: %d", g_audio_testCallbackLength);
/* Pause audio to stop playing (maybe multiple times) */ /* Pause audio to stop playing (maybe multiple times) */
for (k = 0; k <= j; k++) { for (k = 0; k <= j; k++) {
@ -314,9 +314,9 @@ int audio_pauseUnpauseAudio()
} }
/* Ensure callback is not called again */ /* Ensure callback is not called again */
originalCounter = _audio_testCallbackCounter; originalCounter = g_audio_testCallbackCounter;
SDL_Delay(totalDelay + 10); SDL_Delay(totalDelay + 10);
SDLTest_AssertCheck(originalCounter == _audio_testCallbackCounter, "Verify callback counter; expected: %d, got: %d", originalCounter, _audio_testCallbackCounter); SDLTest_AssertCheck(originalCounter == g_audio_testCallbackCounter, "Verify callback counter; expected: %d, got: %d", originalCounter, g_audio_testCallbackCounter);
} }
/* Call Close */ /* Call Close */
@ -331,7 +331,7 @@ int audio_pauseUnpauseAudio()
} /* driver loop */ } /* driver loop */
/* Restart audio again */ /* Restart audio again */
_audioSetUp(NULL); audioSetUp(NULL);
return TEST_COMPLETED; return TEST_COMPLETED;
} }
@ -490,17 +490,17 @@ int audio_printCurrentAudioDriver()
} }
/* Definition of all formats, channels, and frequencies used to test audio conversions */ /* Definition of all formats, channels, and frequencies used to test audio conversions */
const int _numAudioFormats = 18; const int g_numAudioFormats = 18;
SDL_AudioFormat _audioFormats[] = { AUDIO_S8, AUDIO_U8, AUDIO_S16LSB, AUDIO_S16MSB, AUDIO_S16SYS, AUDIO_S16, AUDIO_U16LSB, static SDL_AudioFormat g_audioFormats[] = { AUDIO_S8, AUDIO_U8, AUDIO_S16LSB, AUDIO_S16MSB, AUDIO_S16SYS, AUDIO_S16, AUDIO_U16LSB,
AUDIO_U16MSB, AUDIO_U16SYS, AUDIO_U16, AUDIO_S32LSB, AUDIO_S32MSB, AUDIO_S32SYS, AUDIO_S32, AUDIO_U16MSB, AUDIO_U16SYS, AUDIO_U16, AUDIO_S32LSB, AUDIO_S32MSB, AUDIO_S32SYS, AUDIO_S32,
AUDIO_F32LSB, AUDIO_F32MSB, AUDIO_F32SYS, AUDIO_F32 }; AUDIO_F32LSB, AUDIO_F32MSB, AUDIO_F32SYS, AUDIO_F32 };
const char *_audioFormatsVerbose[] = { "AUDIO_S8", "AUDIO_U8", "AUDIO_S16LSB", "AUDIO_S16MSB", "AUDIO_S16SYS", "AUDIO_S16", "AUDIO_U16LSB", const char *g_audioFormatsVerbose[] = { "AUDIO_S8", "AUDIO_U8", "AUDIO_S16LSB", "AUDIO_S16MSB", "AUDIO_S16SYS", "AUDIO_S16", "AUDIO_U16LSB",
"AUDIO_U16MSB", "AUDIO_U16SYS", "AUDIO_U16", "AUDIO_S32LSB", "AUDIO_S32MSB", "AUDIO_S32SYS", "AUDIO_S32", "AUDIO_U16MSB", "AUDIO_U16SYS", "AUDIO_U16", "AUDIO_S32LSB", "AUDIO_S32MSB", "AUDIO_S32SYS", "AUDIO_S32",
"AUDIO_F32LSB", "AUDIO_F32MSB", "AUDIO_F32SYS", "AUDIO_F32" }; "AUDIO_F32LSB", "AUDIO_F32MSB", "AUDIO_F32SYS", "AUDIO_F32" };
const int _numAudioChannels = 4; const int g_numAudioChannels = 4;
Uint8 _audioChannels[] = { 1, 2, 4, 6 }; Uint8 g_audioChannels[] = { 1, 2, 4, 6 };
const int _numAudioFrequencies = 4; const int g_numAudioFrequencies = 4;
int _audioFrequencies[] = { 11025, 22050, 44100, 48000 }; int g_audioFrequencies[] = { 11025, 22050, 44100, 48000 };
/** /**
* \brief Builds various audio conversion structures * \brief Builds various audio conversion structures
@ -537,22 +537,22 @@ int audio_buildAudioCVT()
SDLTest_AssertCheck(result == 1, "Verify result value; expected: 1, got: %i", result); SDLTest_AssertCheck(result == 1, "Verify result value; expected: 1, got: %i", result);
/* All source conversions with random conversion targets, allow 'null' conversions */ /* All source conversions with random conversion targets, allow 'null' conversions */
for (i = 0; i < _numAudioFormats; i++) { for (i = 0; i < g_numAudioFormats; i++) {
for (j = 0; j < _numAudioChannels; j++) { for (j = 0; j < g_numAudioChannels; j++) {
for (k = 0; k < _numAudioFrequencies; k++) { for (k = 0; k < g_numAudioFrequencies; k++) {
spec1.format = _audioFormats[i]; spec1.format = g_audioFormats[i];
spec1.channels = _audioChannels[j]; spec1.channels = g_audioChannels[j];
spec1.freq = _audioFrequencies[k]; spec1.freq = g_audioFrequencies[k];
ii = SDLTest_RandomIntegerInRange(0, _numAudioFormats - 1); ii = SDLTest_RandomIntegerInRange(0, g_numAudioFormats - 1);
jj = SDLTest_RandomIntegerInRange(0, _numAudioChannels - 1); jj = SDLTest_RandomIntegerInRange(0, g_numAudioChannels - 1);
kk = SDLTest_RandomIntegerInRange(0, _numAudioFrequencies - 1); kk = SDLTest_RandomIntegerInRange(0, g_numAudioFrequencies - 1);
spec2.format = _audioFormats[ii]; spec2.format = g_audioFormats[ii];
spec2.channels = _audioChannels[jj]; spec2.channels = g_audioChannels[jj];
spec2.freq = _audioFrequencies[kk]; spec2.freq = g_audioFrequencies[kk];
result = SDL_BuildAudioCVT(&cvt, spec1.format, spec1.channels, spec1.freq, result = SDL_BuildAudioCVT(&cvt, spec1.format, spec1.channels, spec1.freq,
spec2.format, spec2.channels, spec2.freq); spec2.format, spec2.channels, spec2.freq);
SDLTest_AssertPass("Call to SDL_BuildAudioCVT(format[%i]=%s(%i),channels[%i]=%i,freq[%i]=%i ==> format[%i]=%s(%i),channels[%i]=%i,freq[%i]=%i)", SDLTest_AssertPass("Call to SDL_BuildAudioCVT(format[%i]=%s(%i),channels[%i]=%i,freq[%i]=%i ==> format[%i]=%s(%i),channels[%i]=%i,freq[%i]=%i)",
i, _audioFormatsVerbose[i], spec1.format, j, spec1.channels, k, spec1.freq, ii, _audioFormatsVerbose[ii], spec2.format, jj, spec2.channels, kk, spec2.freq); i, g_audioFormatsVerbose[i], spec1.format, j, spec1.channels, k, spec1.freq, ii, g_audioFormatsVerbose[ii], spec2.format, jj, spec2.channels, kk, spec2.freq);
SDLTest_AssertCheck(result == 0 || result == 1, "Verify result value; expected: 0 or 1, got: %i", result); SDLTest_AssertCheck(result == 0 || result == 1, "Verify result value; expected: 0 or 1, got: %i", result);
if (result < 0) { if (result < 0) {
SDLTest_LogError("%s", SDL_GetError()); SDLTest_LogError("%s", SDL_GetError());
@ -712,7 +712,7 @@ int audio_openCloseAndGetAudioStatus()
desired.format = AUDIO_S16SYS; desired.format = AUDIO_S16SYS;
desired.channels = 2; desired.channels = 2;
desired.samples = 4096; desired.samples = 4096;
desired.callback = _audio_testCallback; desired.callback = audio_testCallback;
desired.userdata = NULL; desired.userdata = NULL;
/* Open device */ /* Open device */
@ -772,7 +772,7 @@ int audio_lockUnlockOpenAudioDevice()
desired.format = AUDIO_S16SYS; desired.format = AUDIO_S16SYS;
desired.channels = 2; desired.channels = 2;
desired.samples = 4096; desired.samples = 4096;
desired.callback = _audio_testCallback; desired.callback = audio_testCallback;
desired.userdata = NULL; desired.userdata = NULL;
/* Open device */ /* Open device */
@ -834,39 +834,39 @@ int audio_convertAudio()
} }
SDLTest_Log("%s", message); SDLTest_Log("%s", message);
/* All source conversions with random conversion targets */ /* All source conversions with random conversion targets */
for (i = 0; i < _numAudioFormats; i++) { for (i = 0; i < g_numAudioFormats; i++) {
for (j = 0; j < _numAudioChannels; j++) { for (j = 0; j < g_numAudioChannels; j++) {
for (k = 0; k < _numAudioFrequencies; k++) { for (k = 0; k < g_numAudioFrequencies; k++) {
spec1.format = _audioFormats[i]; spec1.format = g_audioFormats[i];
spec1.channels = _audioChannels[j]; spec1.channels = g_audioChannels[j];
spec1.freq = _audioFrequencies[k]; spec1.freq = g_audioFrequencies[k];
/* Ensure we have a different target format */ /* Ensure we have a different target format */
do { do {
if (c & 1) { if (c & 1) {
ii = SDLTest_RandomIntegerInRange(0, _numAudioFormats - 1); ii = SDLTest_RandomIntegerInRange(0, g_numAudioFormats - 1);
} else { } else {
ii = 1; ii = 1;
} }
if (c & 2) { if (c & 2) {
jj = SDLTest_RandomIntegerInRange(0, _numAudioChannels - 1); jj = SDLTest_RandomIntegerInRange(0, g_numAudioChannels - 1);
} else { } else {
jj = j; jj = j;
} }
if (c & 4) { if (c & 4) {
kk = SDLTest_RandomIntegerInRange(0, _numAudioFrequencies - 1); kk = SDLTest_RandomIntegerInRange(0, g_numAudioFrequencies - 1);
} else { } else {
kk = k; kk = k;
} }
} while ((i == ii) && (j == jj) && (k == kk)); } while ((i == ii) && (j == jj) && (k == kk));
spec2.format = _audioFormats[ii]; spec2.format = g_audioFormats[ii];
spec2.channels = _audioChannels[jj]; spec2.channels = g_audioChannels[jj];
spec2.freq = _audioFrequencies[kk]; spec2.freq = g_audioFrequencies[kk];
result = SDL_BuildAudioCVT(&cvt, spec1.format, spec1.channels, spec1.freq, result = SDL_BuildAudioCVT(&cvt, spec1.format, spec1.channels, spec1.freq,
spec2.format, spec2.channels, spec2.freq); spec2.format, spec2.channels, spec2.freq);
SDLTest_AssertPass("Call to SDL_BuildAudioCVT(format[%i]=%s(%i),channels[%i]=%i,freq[%i]=%i ==> format[%i]=%s(%i),channels[%i]=%i,freq[%i]=%i)", SDLTest_AssertPass("Call to SDL_BuildAudioCVT(format[%i]=%s(%i),channels[%i]=%i,freq[%i]=%i ==> format[%i]=%s(%i),channels[%i]=%i,freq[%i]=%i)",
i, _audioFormatsVerbose[i], spec1.format, j, spec1.channels, k, spec1.freq, ii, _audioFormatsVerbose[ii], spec2.format, jj, spec2.channels, kk, spec2.freq); i, g_audioFormatsVerbose[i], spec1.format, j, spec1.channels, k, spec1.freq, ii, g_audioFormatsVerbose[ii], spec2.format, jj, spec2.channels, kk, spec2.freq);
SDLTest_AssertCheck(result == 1, "Verify result value; expected: 1, got: %i", result); SDLTest_AssertCheck(result == 1, "Verify result value; expected: 1, got: %i", result);
if (result != 1) { if (result != 1) {
SDLTest_LogError("%s", SDL_GetError()); SDLTest_LogError("%s", SDL_GetError());
@ -938,7 +938,7 @@ int audio_openCloseAudioDeviceConnected()
desired.format = AUDIO_S16SYS; desired.format = AUDIO_S16SYS;
desired.channels = 2; desired.channels = 2;
desired.samples = 4096; desired.samples = 4096;
desired.callback = _audio_testCallback; desired.callback = audio_testCallback;
desired.userdata = NULL; desired.userdata = NULL;
/* Open device */ /* Open device */
@ -1046,7 +1046,7 @@ static const SDLTest_TestCaseReference *audioTests[] = {
/* Audio test suite (global) */ /* Audio test suite (global) */
SDLTest_TestSuiteReference audioTestSuite = { SDLTest_TestSuiteReference audioTestSuite = {
"Audio", "Audio",
_audioSetUp, audioSetUp,
audioTests, audioTests,
_audioTearDown audioTearDown
}; };

View file

@ -9,27 +9,27 @@
/* Test case functions */ /* Test case functions */
/* Flag indicating if the userdata should be checked */ /* Flag indicating if the userdata should be checked */
int _userdataCheck = 0; static int g_userdataCheck = 0;
/* Userdata value to check */ /* Userdata value to check */
int _userdataValue = 0; static int g_userdataValue = 0;
/* Flag indicating that the filter was called */ /* Flag indicating that the filter was called */
int _eventFilterCalled = 0; static int g_eventFilterCalled = 0;
/* Userdata values for event */ /* Userdata values for event */
int _userdataValue1 = 1; static int g_userdataValue1 = 1;
int _userdataValue2 = 2; static int g_userdataValue2 = 2;
/* Event filter that sets some flags and optionally checks userdata */ /* Event filter that sets some flags and optionally checks userdata */
int SDLCALL _events_sampleNullEventFilter(void *userdata, SDL_Event *event) static int SDLCALL events_sampleNullEventFilter(void *userdata, SDL_Event *event)
{ {
_eventFilterCalled = 1; g_eventFilterCalled = 1;
if (_userdataCheck != 0) { if (g_userdataCheck != 0) {
SDLTest_AssertCheck(userdata != NULL, "Check userdata pointer, expected: non-NULL, got: %s", (userdata != NULL) ? "non-NULL" : "NULL"); SDLTest_AssertCheck(userdata != NULL, "Check userdata pointer, expected: non-NULL, got: %s", (userdata != NULL) ? "non-NULL" : "NULL");
if (userdata != NULL) { if (userdata != NULL) {
SDLTest_AssertCheck(*(int *)userdata == _userdataValue, "Check userdata value, expected: %i, got: %i", _userdataValue, *(int *)userdata); SDLTest_AssertCheck(*(int *)userdata == g_userdataValue, "Check userdata value, expected: %i, got: %i", g_userdataValue, *(int *)userdata);
} }
} }
@ -51,8 +51,8 @@ int events_pushPumpAndPollUserevent(void *arg)
/* Create user event */ /* Create user event */
event1.type = SDL_USEREVENT; event1.type = SDL_USEREVENT;
event1.user.code = SDLTest_RandomSint32(); event1.user.code = SDLTest_RandomSint32();
event1.user.data1 = (void *)&_userdataValue1; event1.user.data1 = (void *)&g_userdataValue1;
event1.user.data2 = (void *)&_userdataValue2; event1.user.data2 = (void *)&g_userdataValue2;
/* Push a user event onto the queue and force queue update */ /* Push a user event onto the queue and force queue update */
SDL_PushEvent(&event1); SDL_PushEvent(&event1);
@ -82,17 +82,17 @@ int events_addDelEventWatch(void *arg)
/* Create user event */ /* Create user event */
event.type = SDL_USEREVENT; event.type = SDL_USEREVENT;
event.user.code = SDLTest_RandomSint32(); event.user.code = SDLTest_RandomSint32();
event.user.data1 = (void *)&_userdataValue1; event.user.data1 = (void *)&g_userdataValue1;
event.user.data2 = (void *)&_userdataValue2; event.user.data2 = (void *)&g_userdataValue2;
/* Disable userdata check */ /* Disable userdata check */
_userdataCheck = 0; g_userdataCheck = 0;
/* Reset event filter call tracker */ /* Reset event filter call tracker */
_eventFilterCalled = 0; g_eventFilterCalled = 0;
/* Add watch */ /* Add watch */
SDL_AddEventWatch(_events_sampleNullEventFilter, NULL); SDL_AddEventWatch(events_sampleNullEventFilter, NULL);
SDLTest_AssertPass("Call to SDL_AddEventWatch()"); SDLTest_AssertPass("Call to SDL_AddEventWatch()");
/* Push a user event onto the queue and force queue update */ /* Push a user event onto the queue and force queue update */
@ -100,19 +100,19 @@ int events_addDelEventWatch(void *arg)
SDLTest_AssertPass("Call to SDL_PushEvent()"); SDLTest_AssertPass("Call to SDL_PushEvent()");
SDL_PumpEvents(); SDL_PumpEvents();
SDLTest_AssertPass("Call to SDL_PumpEvents()"); SDLTest_AssertPass("Call to SDL_PumpEvents()");
SDLTest_AssertCheck(_eventFilterCalled == 1, "Check that event filter was called"); SDLTest_AssertCheck(g_eventFilterCalled == 1, "Check that event filter was called");
/* Delete watch */ /* Delete watch */
SDL_DelEventWatch(_events_sampleNullEventFilter, NULL); SDL_DelEventWatch(events_sampleNullEventFilter, NULL);
SDLTest_AssertPass("Call to SDL_DelEventWatch()"); SDLTest_AssertPass("Call to SDL_DelEventWatch()");
/* Push a user event onto the queue and force queue update */ /* Push a user event onto the queue and force queue update */
_eventFilterCalled = 0; g_eventFilterCalled = 0;
SDL_PushEvent(&event); SDL_PushEvent(&event);
SDLTest_AssertPass("Call to SDL_PushEvent()"); SDLTest_AssertPass("Call to SDL_PushEvent()");
SDL_PumpEvents(); SDL_PumpEvents();
SDLTest_AssertPass("Call to SDL_PumpEvents()"); SDLTest_AssertPass("Call to SDL_PumpEvents()");
SDLTest_AssertCheck(_eventFilterCalled == 0, "Check that event filter was NOT called"); SDLTest_AssertCheck(g_eventFilterCalled == 0, "Check that event filter was NOT called");
return TEST_COMPLETED; return TEST_COMPLETED;
} }
@ -131,18 +131,18 @@ int events_addDelEventWatchWithUserdata(void *arg)
/* Create user event */ /* Create user event */
event.type = SDL_USEREVENT; event.type = SDL_USEREVENT;
event.user.code = SDLTest_RandomSint32(); event.user.code = SDLTest_RandomSint32();
event.user.data1 = (void *)&_userdataValue1; event.user.data1 = (void *)&g_userdataValue1;
event.user.data2 = (void *)&_userdataValue2; event.user.data2 = (void *)&g_userdataValue2;
/* Enable userdata check and set a value to check */ /* Enable userdata check and set a value to check */
_userdataCheck = 1; g_userdataCheck = 1;
_userdataValue = SDLTest_RandomIntegerInRange(-1024, 1024); g_userdataValue = SDLTest_RandomIntegerInRange(-1024, 1024);
/* Reset event filter call tracker */ /* Reset event filter call tracker */
_eventFilterCalled = 0; g_eventFilterCalled = 0;
/* Add watch */ /* Add watch */
SDL_AddEventWatch(_events_sampleNullEventFilter, (void *)&_userdataValue); SDL_AddEventWatch(events_sampleNullEventFilter, (void *)&g_userdataValue);
SDLTest_AssertPass("Call to SDL_AddEventWatch()"); SDLTest_AssertPass("Call to SDL_AddEventWatch()");
/* Push a user event onto the queue and force queue update */ /* Push a user event onto the queue and force queue update */
@ -150,19 +150,19 @@ int events_addDelEventWatchWithUserdata(void *arg)
SDLTest_AssertPass("Call to SDL_PushEvent()"); SDLTest_AssertPass("Call to SDL_PushEvent()");
SDL_PumpEvents(); SDL_PumpEvents();
SDLTest_AssertPass("Call to SDL_PumpEvents()"); SDLTest_AssertPass("Call to SDL_PumpEvents()");
SDLTest_AssertCheck(_eventFilterCalled == 1, "Check that event filter was called"); SDLTest_AssertCheck(g_eventFilterCalled == 1, "Check that event filter was called");
/* Delete watch */ /* Delete watch */
SDL_DelEventWatch(_events_sampleNullEventFilter, (void *)&_userdataValue); SDL_DelEventWatch(events_sampleNullEventFilter, (void *)&g_userdataValue);
SDLTest_AssertPass("Call to SDL_DelEventWatch()"); SDLTest_AssertPass("Call to SDL_DelEventWatch()");
/* Push a user event onto the queue and force queue update */ /* Push a user event onto the queue and force queue update */
_eventFilterCalled = 0; g_eventFilterCalled = 0;
SDL_PushEvent(&event); SDL_PushEvent(&event);
SDLTest_AssertPass("Call to SDL_PushEvent()"); SDLTest_AssertPass("Call to SDL_PushEvent()");
SDL_PumpEvents(); SDL_PumpEvents();
SDLTest_AssertPass("Call to SDL_PumpEvents()"); SDLTest_AssertPass("Call to SDL_PumpEvents()");
SDLTest_AssertCheck(_eventFilterCalled == 0, "Check that event filter was NOT called"); SDLTest_AssertCheck(g_eventFilterCalled == 0, "Check that event filter was NOT called");
return TEST_COMPLETED; return TEST_COMPLETED;
} }

View file

@ -5,7 +5,7 @@
#include <SDL3/SDL.h> #include <SDL3/SDL.h>
#include <SDL3/SDL_test.h> #include <SDL3/SDL_test.h>
const char *_HintsEnum[] = { const char *HintsEnum[] = {
SDL_HINT_ACCELEROMETER_AS_JOYSTICK, SDL_HINT_ACCELEROMETER_AS_JOYSTICK,
SDL_HINT_FRAMEBUFFER_ACCELERATION, SDL_HINT_FRAMEBUFFER_ACCELERATION,
SDL_HINT_GAMECONTROLLERCONFIG, SDL_HINT_GAMECONTROLLERCONFIG,
@ -29,7 +29,7 @@ const char *_HintsEnum[] = {
SDL_HINT_VIDEO_X11_XRANDR, SDL_HINT_VIDEO_X11_XRANDR,
SDL_HINT_XINPUT_ENABLED, SDL_HINT_XINPUT_ENABLED,
}; };
const char *_HintsVerbose[] = { const char *HintsVerbose[] = {
"SDL_ACCELEROMETER_AS_JOYSTICK", "SDL_ACCELEROMETER_AS_JOYSTICK",
"SDL_FRAMEBUFFER_ACCELERATION", "SDL_FRAMEBUFFER_ACCELERATION",
"SDL_GAMECONTROLLERCONFIG", "SDL_GAMECONTROLLERCONFIG",
@ -54,9 +54,9 @@ const char *_HintsVerbose[] = {
"SDL_XINPUT_ENABLED" "SDL_XINPUT_ENABLED"
}; };
SDL_COMPILE_TIME_ASSERT(HintsEnum, SDL_arraysize(_HintsEnum) == SDL_arraysize(_HintsVerbose)); SDL_COMPILE_TIME_ASSERT(HintsEnum, SDL_arraysize(HintsEnum) == SDL_arraysize(HintsVerbose));
const int _numHintsEnum = SDL_arraysize(_HintsEnum); const int numHintsEnum = SDL_arraysize(HintsEnum);
/* Test case functions */ /* Test case functions */
@ -69,11 +69,11 @@ int hints_getHint(void *arg)
const char *result2; const char *result2;
int i; int i;
for (i = 0; i < _numHintsEnum; i++) { for (i = 0; i < numHintsEnum; i++) {
result1 = SDL_GetHint(_HintsEnum[i]); result1 = SDL_GetHint(HintsEnum[i]);
SDLTest_AssertPass("Call to SDL_GetHint(%s) - using define definition", (char *)_HintsEnum[i]); SDLTest_AssertPass("Call to SDL_GetHint(%s) - using define definition", (char *)HintsEnum[i]);
result2 = SDL_GetHint(_HintsVerbose[i]); result2 = SDL_GetHint(HintsVerbose[i]);
SDLTest_AssertPass("Call to SDL_GetHint(%s) - using string definition", (char *)_HintsVerbose[i]); SDLTest_AssertPass("Call to SDL_GetHint(%s) - using string definition", (char *)HintsVerbose[i]);
SDLTest_AssertCheck( SDLTest_AssertCheck(
(result1 == NULL && result2 == NULL) || (SDL_strcmp(result1, result2) == 0), (result1 == NULL && result2 == NULL) || (SDL_strcmp(result1, result2) == 0),
"Verify returned values are equal; got: result1='%s' result2='%s", "Verify returned values are equal; got: result1='%s' result2='%s",
@ -105,24 +105,24 @@ int hints_setHint(void *arg)
/* Create random values to set */ /* Create random values to set */
value = SDLTest_RandomAsciiStringOfSize(10); value = SDLTest_RandomAsciiStringOfSize(10);
for (i = 0; i < _numHintsEnum; i++) { for (i = 0; i < numHintsEnum; i++) {
/* Capture current value */ /* Capture current value */
originalValue = SDL_GetHint(_HintsEnum[i]); originalValue = SDL_GetHint(HintsEnum[i]);
SDLTest_AssertPass("Call to SDL_GetHint(%s)", _HintsEnum[i]); SDLTest_AssertPass("Call to SDL_GetHint(%s)", HintsEnum[i]);
/* Copy the original value, since it will be freed when we set it again */ /* Copy the original value, since it will be freed when we set it again */
originalValue = originalValue ? SDL_strdup(originalValue) : NULL; originalValue = originalValue ? SDL_strdup(originalValue) : NULL;
/* Set value (twice) */ /* Set value (twice) */
for (j = 1; j <= 2; j++) { for (j = 1; j <= 2; j++) {
result = SDL_SetHint(_HintsEnum[i], value); result = SDL_SetHint(HintsEnum[i], value);
SDLTest_AssertPass("Call to SDL_SetHint(%s, %s) (iteration %i)", _HintsEnum[i], value, j); SDLTest_AssertPass("Call to SDL_SetHint(%s, %s) (iteration %i)", HintsEnum[i], value, j);
SDLTest_AssertCheck( SDLTest_AssertCheck(
result == SDL_TRUE || result == SDL_FALSE, result == SDL_TRUE || result == SDL_FALSE,
"Verify valid result was returned, got: %i", "Verify valid result was returned, got: %i",
(int)result); (int)result);
testValue = SDL_GetHint(_HintsEnum[i]); testValue = SDL_GetHint(HintsEnum[i]);
SDLTest_AssertPass("Call to SDL_GetHint(%s) - using string definition", _HintsVerbose[i]); SDLTest_AssertPass("Call to SDL_GetHint(%s) - using string definition", HintsVerbose[i]);
SDLTest_AssertCheck( SDLTest_AssertCheck(
(SDL_strcmp(value, testValue) == 0), (SDL_strcmp(value, testValue) == 0),
"Verify returned value equals set value; got: testValue='%s' value='%s", "Verify returned value equals set value; got: testValue='%s' value='%s",
@ -131,8 +131,8 @@ int hints_setHint(void *arg)
} }
/* Reset original value */ /* Reset original value */
result = SDL_SetHint(_HintsEnum[i], originalValue); result = SDL_SetHint(HintsEnum[i], originalValue);
SDLTest_AssertPass("Call to SDL_SetHint(%s, originalValue)", _HintsEnum[i]); SDLTest_AssertPass("Call to SDL_SetHint(%s, originalValue)", HintsEnum[i]);
SDLTest_AssertCheck( SDLTest_AssertCheck(
result == SDL_TRUE || result == SDL_FALSE, result == SDL_TRUE || result == SDL_FALSE,
"Verify valid result was returned, got: %i", "Verify valid result was returned, got: %i",

View file

@ -98,7 +98,7 @@ int keyboard_getKeyFromName(void *arg)
/* /*
* Local helper to check for the invalid scancode error message * Local helper to check for the invalid scancode error message
*/ */
void _checkInvalidScancodeError() static void checkInvalidScancodeError()
{ {
const char *expectedError = "Parameter 'scancode' is invalid"; const char *expectedError = "Parameter 'scancode' is invalid";
const char *error; const char *error;
@ -140,13 +140,13 @@ int keyboard_getKeyFromScancode(void *arg)
result = SDL_GetKeyFromScancode(-999); result = SDL_GetKeyFromScancode(-999);
SDLTest_AssertPass("Call to SDL_GetKeyFromScancode(-999)"); SDLTest_AssertPass("Call to SDL_GetKeyFromScancode(-999)");
SDLTest_AssertCheck(result == SDLK_UNKNOWN, "Verify result from call is UNKNOWN, expected: %i, got: %" SDL_PRIs32, SDLK_UNKNOWN, result); SDLTest_AssertCheck(result == SDLK_UNKNOWN, "Verify result from call is UNKNOWN, expected: %i, got: %" SDL_PRIs32, SDLK_UNKNOWN, result);
_checkInvalidScancodeError(); checkInvalidScancodeError();
/* Case where input is invalid (too big) */ /* Case where input is invalid (too big) */
result = SDL_GetKeyFromScancode(999); result = SDL_GetKeyFromScancode(999);
SDLTest_AssertPass("Call to SDL_GetKeyFromScancode(999)"); SDLTest_AssertPass("Call to SDL_GetKeyFromScancode(999)");
SDLTest_AssertCheck(result == SDLK_UNKNOWN, "Verify result from call is UNKNOWN, expected: %i, got: %" SDL_PRIs32, SDLK_UNKNOWN, result); SDLTest_AssertCheck(result == SDLK_UNKNOWN, "Verify result from call is UNKNOWN, expected: %i, got: %" SDL_PRIs32, SDLK_UNKNOWN, result);
_checkInvalidScancodeError(); checkInvalidScancodeError();
return TEST_COMPLETED; return TEST_COMPLETED;
} }
@ -227,7 +227,7 @@ int keyboard_getScancodeNameNegative(void *arg)
SDLTest_AssertPass("Call to SDL_GetScancodeName(%d/large)", scancode); SDLTest_AssertPass("Call to SDL_GetScancodeName(%d/large)", scancode);
SDLTest_AssertCheck(result != NULL, "Verify result from call is not NULL"); SDLTest_AssertCheck(result != NULL, "Verify result from call is not NULL");
SDLTest_AssertCheck(SDL_strcmp(result, expected) == 0, "Verify result from call is valid, expected: '%s', got: '%s'", expected, result); SDLTest_AssertCheck(SDL_strcmp(result, expected) == 0, "Verify result from call is valid, expected: '%s', got: '%s'", expected, result);
_checkInvalidScancodeError(); checkInvalidScancodeError();
return TEST_COMPLETED; return TEST_COMPLETED;
} }
@ -260,7 +260,7 @@ int keyboard_getKeyNameNegative(void *arg)
SDLTest_AssertPass("Call to SDL_GetKeyName(%" SDL_PRIs32 "/negative)", keycode); SDLTest_AssertPass("Call to SDL_GetKeyName(%" SDL_PRIs32 "/negative)", keycode);
SDLTest_AssertCheck(result != NULL, "Verify result from call is not NULL"); SDLTest_AssertCheck(result != NULL, "Verify result from call is not NULL");
SDLTest_AssertCheck(SDL_strcmp(result, expected) == 0, "Verify result from call is valid, expected: '%s', got: '%s'", expected, result); SDLTest_AssertCheck(SDL_strcmp(result, expected) == 0, "Verify result from call is valid, expected: '%s', got: '%s'", expected, result);
_checkInvalidScancodeError(); checkInvalidScancodeError();
SDL_ClearError(); SDL_ClearError();
SDLTest_AssertPass("Call to SDL_ClearError()"); SDLTest_AssertPass("Call to SDL_ClearError()");
@ -359,7 +359,7 @@ int keyboard_startStopTextInput(void *arg)
} }
/* Internal function to test SDL_SetTextInputRect */ /* Internal function to test SDL_SetTextInputRect */
void _testSetTextInputRect(SDL_Rect refRect) static void testSetTextInputRect(SDL_Rect refRect)
{ {
SDL_Rect testRect; SDL_Rect testRect;
@ -387,63 +387,63 @@ int keyboard_setTextInputRect(void *arg)
refRect.y = SDLTest_RandomIntegerInRange(1, 50); refRect.y = SDLTest_RandomIntegerInRange(1, 50);
refRect.w = SDLTest_RandomIntegerInRange(10, 50); refRect.w = SDLTest_RandomIntegerInRange(10, 50);
refRect.h = SDLTest_RandomIntegerInRange(10, 50); refRect.h = SDLTest_RandomIntegerInRange(10, 50);
_testSetTextInputRect(refRect); testSetTextInputRect(refRect);
/* Normal visible refRect, origin 0,0 */ /* Normal visible refRect, origin 0,0 */
refRect.x = 0; refRect.x = 0;
refRect.y = 0; refRect.y = 0;
refRect.w = SDLTest_RandomIntegerInRange(10, 50); refRect.w = SDLTest_RandomIntegerInRange(10, 50);
refRect.h = SDLTest_RandomIntegerInRange(10, 50); refRect.h = SDLTest_RandomIntegerInRange(10, 50);
_testSetTextInputRect(refRect); testSetTextInputRect(refRect);
/* 1Pixel refRect */ /* 1Pixel refRect */
refRect.x = SDLTest_RandomIntegerInRange(10, 50); refRect.x = SDLTest_RandomIntegerInRange(10, 50);
refRect.y = SDLTest_RandomIntegerInRange(10, 50); refRect.y = SDLTest_RandomIntegerInRange(10, 50);
refRect.w = 1; refRect.w = 1;
refRect.h = 1; refRect.h = 1;
_testSetTextInputRect(refRect); testSetTextInputRect(refRect);
/* 0pixel refRect */ /* 0pixel refRect */
refRect.x = 1; refRect.x = 1;
refRect.y = 1; refRect.y = 1;
refRect.w = 1; refRect.w = 1;
refRect.h = 0; refRect.h = 0;
_testSetTextInputRect(refRect); testSetTextInputRect(refRect);
/* 0pixel refRect */ /* 0pixel refRect */
refRect.x = 1; refRect.x = 1;
refRect.y = 1; refRect.y = 1;
refRect.w = 0; refRect.w = 0;
refRect.h = 1; refRect.h = 1;
_testSetTextInputRect(refRect); testSetTextInputRect(refRect);
/* 0pixel refRect */ /* 0pixel refRect */
refRect.x = 1; refRect.x = 1;
refRect.y = 1; refRect.y = 1;
refRect.w = 0; refRect.w = 0;
refRect.h = 0; refRect.h = 0;
_testSetTextInputRect(refRect); testSetTextInputRect(refRect);
/* 0pixel refRect */ /* 0pixel refRect */
refRect.x = 0; refRect.x = 0;
refRect.y = 0; refRect.y = 0;
refRect.w = 0; refRect.w = 0;
refRect.h = 0; refRect.h = 0;
_testSetTextInputRect(refRect); testSetTextInputRect(refRect);
/* negative refRect */ /* negative refRect */
refRect.x = SDLTest_RandomIntegerInRange(-200, -100); refRect.x = SDLTest_RandomIntegerInRange(-200, -100);
refRect.y = SDLTest_RandomIntegerInRange(-200, -100); refRect.y = SDLTest_RandomIntegerInRange(-200, -100);
refRect.w = 50; refRect.w = 50;
refRect.h = 50; refRect.h = 50;
_testSetTextInputRect(refRect); testSetTextInputRect(refRect);
/* oversized refRect */ /* oversized refRect */
refRect.x = SDLTest_RandomIntegerInRange(1, 50); refRect.x = SDLTest_RandomIntegerInRange(1, 50);
refRect.y = SDLTest_RandomIntegerInRange(1, 50); refRect.y = SDLTest_RandomIntegerInRange(1, 50);
refRect.w = 5000; refRect.w = 5000;
refRect.h = 5000; refRect.h = 5000;
_testSetTextInputRect(refRect); testSetTextInputRect(refRect);
/* NULL refRect */ /* NULL refRect */
SDL_SetTextInputRect(NULL); SDL_SetTextInputRect(NULL);
@ -568,7 +568,7 @@ int keyboard_getScancodeFromName(void *arg)
/* /*
* Local helper to check for the invalid scancode error message * Local helper to check for the invalid scancode error message
*/ */
void _checkInvalidNameError() static void checkInvalidNameError()
{ {
const char *expectedError = "Parameter 'name' is invalid"; const char *expectedError = "Parameter 'name' is invalid";
const char *error; const char *error;
@ -608,21 +608,21 @@ int keyboard_getScancodeFromNameNegative(void *arg)
SDLTest_AssertPass("Call to SDL_GetScancodeFromName('%s')", name); SDLTest_AssertPass("Call to SDL_GetScancodeFromName('%s')", name);
SDL_free((void *)name); SDL_free((void *)name);
SDLTest_AssertCheck(scancode == SDL_SCANCODE_UNKNOWN, "Validate return value from SDL_GetScancodeFromName, expected: %i, got: %i", SDL_SCANCODE_UNKNOWN, scancode); SDLTest_AssertCheck(scancode == SDL_SCANCODE_UNKNOWN, "Validate return value from SDL_GetScancodeFromName, expected: %i, got: %i", SDL_SCANCODE_UNKNOWN, scancode);
_checkInvalidNameError(); checkInvalidNameError();
/* Zero length string input */ /* Zero length string input */
name = ""; name = "";
scancode = SDL_GetScancodeFromName(name); scancode = SDL_GetScancodeFromName(name);
SDLTest_AssertPass("Call to SDL_GetScancodeFromName(NULL)"); SDLTest_AssertPass("Call to SDL_GetScancodeFromName(NULL)");
SDLTest_AssertCheck(scancode == SDL_SCANCODE_UNKNOWN, "Validate return value from SDL_GetScancodeFromName, expected: %i, got: %i", SDL_SCANCODE_UNKNOWN, scancode); SDLTest_AssertCheck(scancode == SDL_SCANCODE_UNKNOWN, "Validate return value from SDL_GetScancodeFromName, expected: %i, got: %i", SDL_SCANCODE_UNKNOWN, scancode);
_checkInvalidNameError(); checkInvalidNameError();
/* NULL input */ /* NULL input */
name = NULL; name = NULL;
scancode = SDL_GetScancodeFromName(name); scancode = SDL_GetScancodeFromName(name);
SDLTest_AssertPass("Call to SDL_GetScancodeFromName(NULL)"); SDLTest_AssertPass("Call to SDL_GetScancodeFromName(NULL)");
SDLTest_AssertCheck(scancode == SDL_SCANCODE_UNKNOWN, "Validate return value from SDL_GetScancodeFromName, expected: %i, got: %i", SDL_SCANCODE_UNKNOWN, scancode); SDLTest_AssertCheck(scancode == SDL_SCANCODE_UNKNOWN, "Validate return value from SDL_GetScancodeFromName, expected: %i, got: %i", SDL_SCANCODE_UNKNOWN, scancode);
_checkInvalidNameError(); checkInvalidNameError();
return TEST_COMPLETED; return TEST_COMPLETED;
} }

View file

@ -11,7 +11,7 @@
/* Test case functions */ /* Test case functions */
/* Helper to evaluate state returned from SDL_GetMouseState */ /* Helper to evaluate state returned from SDL_GetMouseState */
int _mouseStateCheck(Uint32 state) static int mouseStateCheck(Uint32 state)
{ {
return (state == 0) || return (state == 0) ||
(state == SDL_BUTTON(SDL_BUTTON_LEFT)) || (state == SDL_BUTTON(SDL_BUTTON_LEFT)) ||
@ -38,21 +38,21 @@ int mouse_getMouseState(void *arg)
/* Case where x, y pointer is NULL */ /* Case where x, y pointer is NULL */
state = SDL_GetMouseState(NULL, NULL); state = SDL_GetMouseState(NULL, NULL);
SDLTest_AssertPass("Call to SDL_GetMouseState(NULL, NULL)"); SDLTest_AssertPass("Call to SDL_GetMouseState(NULL, NULL)");
SDLTest_AssertCheck(_mouseStateCheck(state), "Validate state returned from function, got: %" SDL_PRIu32, state); SDLTest_AssertCheck(mouseStateCheck(state), "Validate state returned from function, got: %" SDL_PRIu32, state);
/* Case where x pointer is not NULL */ /* Case where x pointer is not NULL */
x = INT_MIN; x = INT_MIN;
state = SDL_GetMouseState(&x, NULL); state = SDL_GetMouseState(&x, NULL);
SDLTest_AssertPass("Call to SDL_GetMouseState(&x, NULL)"); SDLTest_AssertPass("Call to SDL_GetMouseState(&x, NULL)");
SDLTest_AssertCheck(x > INT_MIN, "Validate that value of x is > INT_MIN, got: %i", x); SDLTest_AssertCheck(x > INT_MIN, "Validate that value of x is > INT_MIN, got: %i", x);
SDLTest_AssertCheck(_mouseStateCheck(state), "Validate state returned from function, got: %" SDL_PRIu32, state); SDLTest_AssertCheck(mouseStateCheck(state), "Validate state returned from function, got: %" SDL_PRIu32, state);
/* Case where y pointer is not NULL */ /* Case where y pointer is not NULL */
y = INT_MIN; y = INT_MIN;
state = SDL_GetMouseState(NULL, &y); state = SDL_GetMouseState(NULL, &y);
SDLTest_AssertPass("Call to SDL_GetMouseState(NULL, &y)"); SDLTest_AssertPass("Call to SDL_GetMouseState(NULL, &y)");
SDLTest_AssertCheck(y > INT_MIN, "Validate that value of y is > INT_MIN, got: %i", y); SDLTest_AssertCheck(y > INT_MIN, "Validate that value of y is > INT_MIN, got: %i", y);
SDLTest_AssertCheck(_mouseStateCheck(state), "Validate state returned from function, got: %" SDL_PRIu32, state); SDLTest_AssertCheck(mouseStateCheck(state), "Validate state returned from function, got: %" SDL_PRIu32, state);
/* Case where x and y pointer is not NULL */ /* Case where x and y pointer is not NULL */
x = INT_MIN; x = INT_MIN;
@ -61,7 +61,7 @@ int mouse_getMouseState(void *arg)
SDLTest_AssertPass("Call to SDL_GetMouseState(&x, &y)"); SDLTest_AssertPass("Call to SDL_GetMouseState(&x, &y)");
SDLTest_AssertCheck(x > INT_MIN, "Validate that value of x is > INT_MIN, got: %i", x); SDLTest_AssertCheck(x > INT_MIN, "Validate that value of x is > INT_MIN, got: %i", x);
SDLTest_AssertCheck(y > INT_MIN, "Validate that value of y is > INT_MIN, got: %i", y); SDLTest_AssertCheck(y > INT_MIN, "Validate that value of y is > INT_MIN, got: %i", y);
SDLTest_AssertCheck(_mouseStateCheck(state), "Validate state returned from function, got: %" SDL_PRIu32, state); SDLTest_AssertCheck(mouseStateCheck(state), "Validate state returned from function, got: %" SDL_PRIu32, state);
return TEST_COMPLETED; return TEST_COMPLETED;
} }
@ -83,21 +83,21 @@ int mouse_getRelativeMouseState(void *arg)
/* Case where x, y pointer is NULL */ /* Case where x, y pointer is NULL */
state = SDL_GetRelativeMouseState(NULL, NULL); state = SDL_GetRelativeMouseState(NULL, NULL);
SDLTest_AssertPass("Call to SDL_GetRelativeMouseState(NULL, NULL)"); SDLTest_AssertPass("Call to SDL_GetRelativeMouseState(NULL, NULL)");
SDLTest_AssertCheck(_mouseStateCheck(state), "Validate state returned from function, got: %" SDL_PRIu32, state); SDLTest_AssertCheck(mouseStateCheck(state), "Validate state returned from function, got: %" SDL_PRIu32, state);
/* Case where x pointer is not NULL */ /* Case where x pointer is not NULL */
x = INT_MIN; x = INT_MIN;
state = SDL_GetRelativeMouseState(&x, NULL); state = SDL_GetRelativeMouseState(&x, NULL);
SDLTest_AssertPass("Call to SDL_GetRelativeMouseState(&x, NULL)"); SDLTest_AssertPass("Call to SDL_GetRelativeMouseState(&x, NULL)");
SDLTest_AssertCheck(x > INT_MIN, "Validate that value of x is > INT_MIN, got: %i", x); SDLTest_AssertCheck(x > INT_MIN, "Validate that value of x is > INT_MIN, got: %i", x);
SDLTest_AssertCheck(_mouseStateCheck(state), "Validate state returned from function, got: %" SDL_PRIu32, state); SDLTest_AssertCheck(mouseStateCheck(state), "Validate state returned from function, got: %" SDL_PRIu32, state);
/* Case where y pointer is not NULL */ /* Case where y pointer is not NULL */
y = INT_MIN; y = INT_MIN;
state = SDL_GetRelativeMouseState(NULL, &y); state = SDL_GetRelativeMouseState(NULL, &y);
SDLTest_AssertPass("Call to SDL_GetRelativeMouseState(NULL, &y)"); SDLTest_AssertPass("Call to SDL_GetRelativeMouseState(NULL, &y)");
SDLTest_AssertCheck(y > INT_MIN, "Validate that value of y is > INT_MIN, got: %i", y); SDLTest_AssertCheck(y > INT_MIN, "Validate that value of y is > INT_MIN, got: %i", y);
SDLTest_AssertCheck(_mouseStateCheck(state), "Validate state returned from function, got: %" SDL_PRIu32, state); SDLTest_AssertCheck(mouseStateCheck(state), "Validate state returned from function, got: %" SDL_PRIu32, state);
/* Case where x and y pointer is not NULL */ /* Case where x and y pointer is not NULL */
x = INT_MIN; x = INT_MIN;
@ -106,13 +106,13 @@ int mouse_getRelativeMouseState(void *arg)
SDLTest_AssertPass("Call to SDL_GetRelativeMouseState(&x, &y)"); SDLTest_AssertPass("Call to SDL_GetRelativeMouseState(&x, &y)");
SDLTest_AssertCheck(x > INT_MIN, "Validate that value of x is > INT_MIN, got: %i", x); SDLTest_AssertCheck(x > INT_MIN, "Validate that value of x is > INT_MIN, got: %i", x);
SDLTest_AssertCheck(y > INT_MIN, "Validate that value of y is > INT_MIN, got: %i", y); SDLTest_AssertCheck(y > INT_MIN, "Validate that value of y is > INT_MIN, got: %i", y);
SDLTest_AssertCheck(_mouseStateCheck(state), "Validate state returned from function, got: %" SDL_PRIu32, state); SDLTest_AssertCheck(mouseStateCheck(state), "Validate state returned from function, got: %" SDL_PRIu32, state);
return TEST_COMPLETED; return TEST_COMPLETED;
} }
/* XPM definition of mouse Cursor */ /* XPM definition of mouse Cursor */
static const char *_mouseArrowData[] = { static const char *g_mouseArrowData[] = {
/* pixels */ /* pixels */
"X ", "X ",
"XX ", "XX ",
@ -149,7 +149,7 @@ static const char *_mouseArrowData[] = {
}; };
/* Helper that creates a new mouse cursor from an XPM */ /* Helper that creates a new mouse cursor from an XPM */
static SDL_Cursor *_initArrowCursor(const char *image[]) static SDL_Cursor *initArrowCursor(const char *image[])
{ {
SDL_Cursor *cursor; SDL_Cursor *cursor;
int i, row, col; int i, row, col;
@ -195,7 +195,7 @@ int mouse_createFreeCursor(void *arg)
SDL_Cursor *cursor; SDL_Cursor *cursor;
/* Create a cursor */ /* Create a cursor */
cursor = _initArrowCursor(_mouseArrowData); cursor = initArrowCursor(g_mouseArrowData);
SDLTest_AssertPass("Call to SDL_CreateCursor()"); SDLTest_AssertPass("Call to SDL_CreateCursor()");
SDLTest_AssertCheck(cursor != NULL, "Validate result from SDL_CreateCursor() is not NULL"); SDLTest_AssertCheck(cursor != NULL, "Validate result from SDL_CreateCursor() is not NULL");
if (cursor == NULL) { if (cursor == NULL) {
@ -247,7 +247,7 @@ int mouse_createFreeColorCursor(void *arg)
} }
/* Helper that changes cursor visibility */ /* Helper that changes cursor visibility */
void _changeCursorVisibility(SDL_bool state) static void changeCursorVisibility(SDL_bool state)
{ {
SDL_bool newState; SDL_bool newState;
@ -279,12 +279,12 @@ int mouse_showCursor(void *arg)
SDLTest_AssertPass("Call to SDL_CursorVisible()"); SDLTest_AssertPass("Call to SDL_CursorVisible()");
if (currentState) { if (currentState) {
/* Hide the cursor, then show it again */ /* Hide the cursor, then show it again */
_changeCursorVisibility(SDL_FALSE); changeCursorVisibility(SDL_FALSE);
_changeCursorVisibility(SDL_TRUE); changeCursorVisibility(SDL_TRUE);
} else { } else {
/* Show the cursor, then hide it again */ /* Show the cursor, then hide it again */
_changeCursorVisibility(SDL_TRUE); changeCursorVisibility(SDL_TRUE);
_changeCursorVisibility(SDL_FALSE); changeCursorVisibility(SDL_FALSE);
} }
return TEST_COMPLETED; return TEST_COMPLETED;
@ -300,7 +300,7 @@ int mouse_setCursor(void *arg)
SDL_Cursor *cursor; SDL_Cursor *cursor;
/* Create a cursor */ /* Create a cursor */
cursor = _initArrowCursor(_mouseArrowData); cursor = initArrowCursor(g_mouseArrowData);
SDLTest_AssertPass("Call to SDL_CreateCursor()"); SDLTest_AssertPass("Call to SDL_CreateCursor()");
SDLTest_AssertCheck(cursor != NULL, "Validate result from SDL_CreateCursor() is not NULL"); SDLTest_AssertCheck(cursor != NULL, "Validate result from SDL_CreateCursor() is not NULL");
if (cursor == NULL) { if (cursor == NULL) {
@ -400,11 +400,11 @@ int mouse_getSetRelativeMouseMode(void *arg)
/** /**
* Creates a test window * Creates a test window
*/ */
SDL_Window *_createMouseSuiteTestWindow() static SDL_Window *createMouseSuiteTestWindow()
{ {
int posX = 100, posY = 100, width = MOUSE_TESTWINDOW_WIDTH, height = MOUSE_TESTWINDOW_HEIGHT; int posX = 100, posY = 100, width = MOUSE_TESTWINDOW_WIDTH, height = MOUSE_TESTWINDOW_HEIGHT;
SDL_Window *window; SDL_Window *window;
window = SDL_CreateWindow("mouse_createMouseSuiteTestWindow", posX, posY, width, height, 0); window = SDL_CreateWindow("mousecreateMouseSuiteTestWindow", posX, posY, width, height, 0);
SDLTest_AssertPass("SDL_CreateWindow()"); SDLTest_AssertPass("SDL_CreateWindow()");
SDLTest_AssertCheck(window != NULL, "Check SDL_CreateWindow result"); SDLTest_AssertCheck(window != NULL, "Check SDL_CreateWindow result");
return window; return window;
@ -413,7 +413,7 @@ SDL_Window *_createMouseSuiteTestWindow()
/* /*
* Destroy test window * Destroy test window
*/ */
void _destroyMouseSuiteTestWindow(SDL_Window *window) static void destroyMouseSuiteTestWindow(SDL_Window *window)
{ {
if (window != NULL) { if (window != NULL) {
SDL_DestroyWindow(window); SDL_DestroyWindow(window);
@ -449,7 +449,7 @@ int mouse_warpMouseInWindow(void *arg)
yPositions[4] = h; yPositions[4] = h;
yPositions[5] = h + 1; yPositions[5] = h + 1;
/* Create test window */ /* Create test window */
window = _createMouseSuiteTestWindow(); window = createMouseSuiteTestWindow();
if (window == NULL) { if (window == NULL) {
return TEST_ABORTED; return TEST_ABORTED;
} }
@ -479,7 +479,7 @@ int mouse_warpMouseInWindow(void *arg)
} }
/* Clean up test window */ /* Clean up test window */
_destroyMouseSuiteTestWindow(window); destroyMouseSuiteTestWindow(window);
return TEST_COMPLETED; return TEST_COMPLETED;
} }
@ -501,7 +501,7 @@ int mouse_getMouseFocus(void *arg)
SDLTest_AssertPass("SDL_GetMouseFocus()"); SDLTest_AssertPass("SDL_GetMouseFocus()");
/* Create test window */ /* Create test window */
window = _createMouseSuiteTestWindow(); window = createMouseSuiteTestWindow();
if (window == NULL) { if (window == NULL) {
return TEST_ABORTED; return TEST_ABORTED;
} }
@ -530,7 +530,7 @@ int mouse_getMouseFocus(void *arg)
SDLTest_AssertPass("SDL_WarpMouseInWindow(...,%i,%i)", x, y); SDLTest_AssertPass("SDL_WarpMouseInWindow(...,%i,%i)", x, y);
/* Clean up test window */ /* Clean up test window */
_destroyMouseSuiteTestWindow(window); destroyMouseSuiteTestWindow(window);
/* Pump events to update focus state */ /* Pump events to update focus state */
SDL_PumpEvents(); SDL_PumpEvents();
@ -580,7 +580,7 @@ int mouse_getGlobalMouseState(void *arg)
SDLTest_AssertPass("Call to SDL_GetGlobalMouseState()"); SDLTest_AssertPass("Call to SDL_GetGlobalMouseState()");
SDLTest_AssertCheck(x > INT_MIN, "Validate that value of x is > INT_MIN, got: %i", x); SDLTest_AssertCheck(x > INT_MIN, "Validate that value of x is > INT_MIN, got: %i", x);
SDLTest_AssertCheck(y > INT_MIN, "Validate that value of y is > INT_MIN, got: %i", y); SDLTest_AssertCheck(y > INT_MIN, "Validate that value of y is > INT_MIN, got: %i", y);
SDLTest_AssertCheck(_mouseStateCheck(state), "Validate state returned from function, got: %" SDL_PRIu32, state); SDLTest_AssertCheck(mouseStateCheck(state), "Validate state returned from function, got: %" SDL_PRIu32, state);
return TEST_COMPLETED; return TEST_COMPLETED;
} }

View file

@ -7,8 +7,8 @@
/* Test case functions */ /* Test case functions */
/* Definition of all RGB formats used to test pixel conversions */ /* Definition of all RGB formats used to test pixel conversions */
const int _numRGBPixelFormats = 31; const int g_numRGBPixelFormats = 31;
Uint32 _RGBPixelFormats[] = { Uint32 g_RGBPixelFormats[] = {
SDL_PIXELFORMAT_INDEX1LSB, SDL_PIXELFORMAT_INDEX1LSB,
SDL_PIXELFORMAT_INDEX1MSB, SDL_PIXELFORMAT_INDEX1MSB,
SDL_PIXELFORMAT_INDEX4LSB, SDL_PIXELFORMAT_INDEX4LSB,
@ -41,7 +41,7 @@ Uint32 _RGBPixelFormats[] = {
SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_BGRA8888,
SDL_PIXELFORMAT_ARGB2101010 SDL_PIXELFORMAT_ARGB2101010
}; };
const char *_RGBPixelFormatsVerbose[] = { const char *g_RGBPixelFormatsVerbose[] = {
"SDL_PIXELFORMAT_INDEX1LSB", "SDL_PIXELFORMAT_INDEX1LSB",
"SDL_PIXELFORMAT_INDEX1MSB", "SDL_PIXELFORMAT_INDEX1MSB",
"SDL_PIXELFORMAT_INDEX4LSB", "SDL_PIXELFORMAT_INDEX4LSB",
@ -76,8 +76,8 @@ const char *_RGBPixelFormatsVerbose[] = {
}; };
/* Definition of all Non-RGB formats used to test pixel conversions */ /* Definition of all Non-RGB formats used to test pixel conversions */
const int _numNonRGBPixelFormats = 7; const int g_numNonRGBPixelFormats = 7;
Uint32 _nonRGBPixelFormats[] = { static Uint32 g_nonRGBPixelFormats[] = {
SDL_PIXELFORMAT_YV12, SDL_PIXELFORMAT_YV12,
SDL_PIXELFORMAT_IYUV, SDL_PIXELFORMAT_IYUV,
SDL_PIXELFORMAT_YUY2, SDL_PIXELFORMAT_YUY2,
@ -86,7 +86,7 @@ Uint32 _nonRGBPixelFormats[] = {
SDL_PIXELFORMAT_NV12, SDL_PIXELFORMAT_NV12,
SDL_PIXELFORMAT_NV21 SDL_PIXELFORMAT_NV21
}; };
const char *_nonRGBPixelFormatsVerbose[] = { const char *g_nonRGBPixelFormatsVerbose[] = {
"SDL_PIXELFORMAT_YV12", "SDL_PIXELFORMAT_YV12",
"SDL_PIXELFORMAT_IYUV", "SDL_PIXELFORMAT_IYUV",
"SDL_PIXELFORMAT_YUY2", "SDL_PIXELFORMAT_YUY2",
@ -97,12 +97,12 @@ const char *_nonRGBPixelFormatsVerbose[] = {
}; };
/* Definition of some invalid formats for negative tests */ /* Definition of some invalid formats for negative tests */
const int _numInvalidPixelFormats = 2; const int g_numInvalidPixelFormats = 2;
Uint32 _invalidPixelFormats[] = { static Uint32 g_invalidPixelFormats[] = {
0xfffffffe, 0xfffffffe,
0xffffffff 0xffffffff
}; };
const char *_invalidPixelFormatsVerbose[] = { const char *g_invalidPixelFormatsVerbose[] = {
"SDL_PIXELFORMAT_UNKNOWN", "SDL_PIXELFORMAT_UNKNOWN",
"SDL_PIXELFORMAT_UNKNOWN" "SDL_PIXELFORMAT_UNKNOWN"
}; };
@ -146,9 +146,9 @@ int pixels_allocFreeFormat(void *arg)
} }
/* RGB formats */ /* RGB formats */
for (i = 0; i < _numRGBPixelFormats; i++) { for (i = 0; i < g_numRGBPixelFormats; i++) {
format = _RGBPixelFormats[i]; format = g_RGBPixelFormats[i];
SDLTest_Log("RGB Format: %s (%" SDL_PRIu32 ")", _RGBPixelFormatsVerbose[i], format); SDLTest_Log("RGB Format: %s (%" SDL_PRIu32 ")", g_RGBPixelFormatsVerbose[i], format);
/* Allocate format */ /* Allocate format */
result = SDL_CreatePixelFormat(format); result = SDL_CreatePixelFormat(format);
@ -170,9 +170,9 @@ int pixels_allocFreeFormat(void *arg)
} }
/* Non-RGB formats */ /* Non-RGB formats */
for (i = 0; i < _numNonRGBPixelFormats; i++) { for (i = 0; i < g_numNonRGBPixelFormats; i++) {
format = _nonRGBPixelFormats[i]; format = g_nonRGBPixelFormats[i];
SDLTest_Log("non-RGB Format: %s (%" SDL_PRIu32 ")", _nonRGBPixelFormatsVerbose[i], format); SDLTest_Log("non-RGB Format: %s (%" SDL_PRIu32 ")", g_nonRGBPixelFormatsVerbose[i], format);
/* Try to allocate format */ /* Try to allocate format */
result = SDL_CreatePixelFormat(format); result = SDL_CreatePixelFormat(format);
@ -183,10 +183,10 @@ int pixels_allocFreeFormat(void *arg)
/* Negative cases */ /* Negative cases */
/* Invalid Formats */ /* Invalid Formats */
for (i = 0; i < _numInvalidPixelFormats; i++) { for (i = 0; i < g_numInvalidPixelFormats; i++) {
SDL_ClearError(); SDL_ClearError();
SDLTest_AssertPass("Call to SDL_ClearError()"); SDLTest_AssertPass("Call to SDL_ClearError()");
format = _invalidPixelFormats[i]; format = g_invalidPixelFormats[i];
result = SDL_CreatePixelFormat(format); result = SDL_CreatePixelFormat(format);
SDLTest_AssertPass("Call to SDL_CreatePixelFormat(%" SDL_PRIu32 ")", format); SDLTest_AssertPass("Call to SDL_CreatePixelFormat(%" SDL_PRIu32 ")", format);
SDLTest_AssertCheck(result == NULL, "Verify result is NULL"); SDLTest_AssertCheck(result == NULL, "Verify result is NULL");
@ -243,9 +243,9 @@ int pixels_getPixelFormatName(void *arg)
} }
/* RGB formats */ /* RGB formats */
for (i = 0; i < _numRGBPixelFormats; i++) { for (i = 0; i < g_numRGBPixelFormats; i++) {
format = _RGBPixelFormats[i]; format = g_RGBPixelFormats[i];
SDLTest_Log("RGB Format: %s (%" SDL_PRIu32 ")", _RGBPixelFormatsVerbose[i], format); SDLTest_Log("RGB Format: %s (%" SDL_PRIu32 ")", g_RGBPixelFormatsVerbose[i], format);
/* Get name of format */ /* Get name of format */
result = SDL_GetPixelFormatName(format); result = SDL_GetPixelFormatName(format);
@ -253,15 +253,15 @@ int pixels_getPixelFormatName(void *arg)
SDLTest_AssertCheck(result != NULL, "Verify result is not NULL"); SDLTest_AssertCheck(result != NULL, "Verify result is not NULL");
if (result != NULL) { if (result != NULL) {
SDLTest_AssertCheck(result[0] != '\0', "Verify result is non-empty"); SDLTest_AssertCheck(result[0] != '\0', "Verify result is non-empty");
SDLTest_AssertCheck(SDL_strcmp(result, _RGBPixelFormatsVerbose[i]) == 0, SDLTest_AssertCheck(SDL_strcmp(result, g_RGBPixelFormatsVerbose[i]) == 0,
"Verify result text; expected: %s, got %s", _RGBPixelFormatsVerbose[i], result); "Verify result text; expected: %s, got %s", g_RGBPixelFormatsVerbose[i], result);
} }
} }
/* Non-RGB formats */ /* Non-RGB formats */
for (i = 0; i < _numNonRGBPixelFormats; i++) { for (i = 0; i < g_numNonRGBPixelFormats; i++) {
format = _nonRGBPixelFormats[i]; format = g_nonRGBPixelFormats[i];
SDLTest_Log("non-RGB Format: %s (%" SDL_PRIu32 ")", _nonRGBPixelFormatsVerbose[i], format); SDLTest_Log("non-RGB Format: %s (%" SDL_PRIu32 ")", g_nonRGBPixelFormatsVerbose[i], format);
/* Get name of format */ /* Get name of format */
result = SDL_GetPixelFormatName(format); result = SDL_GetPixelFormatName(format);
@ -269,8 +269,8 @@ int pixels_getPixelFormatName(void *arg)
SDLTest_AssertCheck(result != NULL, "Verify result is not NULL"); SDLTest_AssertCheck(result != NULL, "Verify result is not NULL");
if (result != NULL) { if (result != NULL) {
SDLTest_AssertCheck(result[0] != '\0', "Verify result is non-empty"); SDLTest_AssertCheck(result[0] != '\0', "Verify result is non-empty");
SDLTest_AssertCheck(SDL_strcmp(result, _nonRGBPixelFormatsVerbose[i]) == 0, SDLTest_AssertCheck(SDL_strcmp(result, g_nonRGBPixelFormatsVerbose[i]) == 0,
"Verify result text; expected: %s, got %s", _nonRGBPixelFormatsVerbose[i], result); "Verify result text; expected: %s, got %s", g_nonRGBPixelFormatsVerbose[i], result);
} }
} }
@ -279,16 +279,16 @@ int pixels_getPixelFormatName(void *arg)
/* Invalid Formats */ /* Invalid Formats */
SDL_ClearError(); SDL_ClearError();
SDLTest_AssertPass("Call to SDL_ClearError()"); SDLTest_AssertPass("Call to SDL_ClearError()");
for (i = 0; i < _numInvalidPixelFormats; i++) { for (i = 0; i < g_numInvalidPixelFormats; i++) {
format = _invalidPixelFormats[i]; format = g_invalidPixelFormats[i];
result = SDL_GetPixelFormatName(format); result = SDL_GetPixelFormatName(format);
SDLTest_AssertPass("Call to SDL_GetPixelFormatName(%" SDL_PRIu32 ")", format); SDLTest_AssertPass("Call to SDL_GetPixelFormatName(%" SDL_PRIu32 ")", format);
SDLTest_AssertCheck(result != NULL, "Verify result is not NULL"); SDLTest_AssertCheck(result != NULL, "Verify result is not NULL");
if (result != NULL) { if (result != NULL) {
SDLTest_AssertCheck(result[0] != '\0', SDLTest_AssertCheck(result[0] != '\0',
"Verify result is non-empty; got: %s", result); "Verify result is non-empty; got: %s", result);
SDLTest_AssertCheck(SDL_strcmp(result, _invalidPixelFormatsVerbose[i]) == 0, SDLTest_AssertCheck(SDL_strcmp(result, g_invalidPixelFormatsVerbose[i]) == 0,
"Validate name is UNKNOWN, expected: '%s', got: '%s'", _invalidPixelFormatsVerbose[i], result); "Validate name is UNKNOWN, expected: '%s', got: '%s'", g_invalidPixelFormatsVerbose[i], result);
} }
error = SDL_GetError(); error = SDL_GetError();
SDLTest_AssertPass("Call to SDL_GetError()"); SDLTest_AssertPass("Call to SDL_GetError()");

View file

@ -16,7 +16,7 @@
* compare them directly, so we push it through a function to keep the * compare them directly, so we push it through a function to keep the
* compiler quiet. --ryan. * compiler quiet. --ryan.
*/ */
static int _compareSizeOfType(size_t sizeoftype, size_t hardcodetype) static int compareSizeOfType(size_t sizeoftype, size_t hardcodetype)
{ {
return sizeoftype != hardcodetype; return sizeoftype != hardcodetype;
} }
@ -30,16 +30,16 @@ int platform_testTypes(void *arg)
{ {
int ret; int ret;
ret = _compareSizeOfType(sizeof(Uint8), 1); ret = compareSizeOfType(sizeof(Uint8), 1);
SDLTest_AssertCheck(ret == 0, "sizeof(Uint8) = %u, expected 1", (unsigned int)sizeof(Uint8)); SDLTest_AssertCheck(ret == 0, "sizeof(Uint8) = %u, expected 1", (unsigned int)sizeof(Uint8));
ret = _compareSizeOfType(sizeof(Uint16), 2); ret = compareSizeOfType(sizeof(Uint16), 2);
SDLTest_AssertCheck(ret == 0, "sizeof(Uint16) = %u, expected 2", (unsigned int)sizeof(Uint16)); SDLTest_AssertCheck(ret == 0, "sizeof(Uint16) = %u, expected 2", (unsigned int)sizeof(Uint16));
ret = _compareSizeOfType(sizeof(Uint32), 4); ret = compareSizeOfType(sizeof(Uint32), 4);
SDLTest_AssertCheck(ret == 0, "sizeof(Uint32) = %u, expected 4", (unsigned int)sizeof(Uint32)); SDLTest_AssertCheck(ret == 0, "sizeof(Uint32) = %u, expected 4", (unsigned int)sizeof(Uint32));
ret = _compareSizeOfType(sizeof(Uint64), 8); ret = compareSizeOfType(sizeof(Uint64), 8);
SDLTest_AssertCheck(ret == 0, "sizeof(Uint64) = %u, expected 8", (unsigned int)sizeof(Uint64)); SDLTest_AssertCheck(ret == 0, "sizeof(Uint64) = %u, expected 8", (unsigned int)sizeof(Uint64));
return TEST_COMPLETED; return TEST_COMPLETED;

View file

@ -12,7 +12,7 @@
/* ! /* !
* \brief Private helper to check SDL_GetRectAndLineIntersection results * \brief Private helper to check SDL_GetRectAndLineIntersection results
*/ */
void _validateIntersectRectAndLineResults( static void validateIntersectRectAndLineResults(
SDL_bool intersection, SDL_bool expectedIntersection, SDL_bool intersection, SDL_bool expectedIntersection,
SDL_Rect *rect, SDL_Rect *refRect, SDL_Rect *rect, SDL_Rect *refRect,
int x1, int y1, int x2, int y2, int x1, int y1, int x2, int y2,
@ -61,7 +61,7 @@ int rect_testIntersectRectAndLine(void *arg)
y2 = 15; y2 = 15;
rect = refRect; rect = refRect;
intersected = SDL_GetRectAndLineIntersection(&rect, &x1, &y1, &x2, &y2); intersected = SDL_GetRectAndLineIntersection(&rect, &x1, &y1, &x2, &y2);
_validateIntersectRectAndLineResults(intersected, SDL_TRUE, &rect, &refRect, x1, y1, x2, y2, 0, 15, 31, 15); validateIntersectRectAndLineResults(intersected, SDL_TRUE, &rect, &refRect, x1, y1, x2, y2, 0, 15, 31, 15);
x1 = 15; x1 = 15;
y1 = yTop; y1 = yTop;
@ -69,7 +69,7 @@ int rect_testIntersectRectAndLine(void *arg)
y2 = yBottom; y2 = yBottom;
rect = refRect; rect = refRect;
intersected = SDL_GetRectAndLineIntersection(&rect, &x1, &y1, &x2, &y2); intersected = SDL_GetRectAndLineIntersection(&rect, &x1, &y1, &x2, &y2);
_validateIntersectRectAndLineResults(intersected, SDL_TRUE, &rect, &refRect, x1, y1, x2, y2, 15, 0, 15, 31); validateIntersectRectAndLineResults(intersected, SDL_TRUE, &rect, &refRect, x1, y1, x2, y2, 15, 0, 15, 31);
x1 = -refRect.w; x1 = -refRect.w;
y1 = -refRect.h; y1 = -refRect.h;
@ -77,7 +77,7 @@ int rect_testIntersectRectAndLine(void *arg)
y2 = 2 * refRect.h; y2 = 2 * refRect.h;
rect = refRect; rect = refRect;
intersected = SDL_GetRectAndLineIntersection(&rect, &x1, &y1, &x2, &y2); intersected = SDL_GetRectAndLineIntersection(&rect, &x1, &y1, &x2, &y2);
_validateIntersectRectAndLineResults(intersected, SDL_TRUE, &rect, &refRect, x1, y1, x2, y2, 0, 0, 31, 31); validateIntersectRectAndLineResults(intersected, SDL_TRUE, &rect, &refRect, x1, y1, x2, y2, 0, 0, 31, 31);
x1 = 2 * refRect.w; x1 = 2 * refRect.w;
y1 = 2 * refRect.h; y1 = 2 * refRect.h;
@ -85,7 +85,7 @@ int rect_testIntersectRectAndLine(void *arg)
y2 = -refRect.h; y2 = -refRect.h;
rect = refRect; rect = refRect;
intersected = SDL_GetRectAndLineIntersection(&rect, &x1, &y1, &x2, &y2); intersected = SDL_GetRectAndLineIntersection(&rect, &x1, &y1, &x2, &y2);
_validateIntersectRectAndLineResults(intersected, SDL_TRUE, &rect, &refRect, x1, y1, x2, y2, 31, 31, 0, 0); validateIntersectRectAndLineResults(intersected, SDL_TRUE, &rect, &refRect, x1, y1, x2, y2, 31, 31, 0, 0);
x1 = -1; x1 = -1;
y1 = 32; y1 = 32;
@ -93,7 +93,7 @@ int rect_testIntersectRectAndLine(void *arg)
y2 = -1; y2 = -1;
rect = refRect; rect = refRect;
intersected = SDL_GetRectAndLineIntersection(&rect, &x1, &y1, &x2, &y2); intersected = SDL_GetRectAndLineIntersection(&rect, &x1, &y1, &x2, &y2);
_validateIntersectRectAndLineResults(intersected, SDL_TRUE, &rect, &refRect, x1, y1, x2, y2, 0, 31, 31, 0); validateIntersectRectAndLineResults(intersected, SDL_TRUE, &rect, &refRect, x1, y1, x2, y2, 0, 31, 31, 0);
x1 = 32; x1 = 32;
y1 = -1; y1 = -1;
@ -101,7 +101,7 @@ int rect_testIntersectRectAndLine(void *arg)
y2 = 32; y2 = 32;
rect = refRect; rect = refRect;
intersected = SDL_GetRectAndLineIntersection(&rect, &x1, &y1, &x2, &y2); intersected = SDL_GetRectAndLineIntersection(&rect, &x1, &y1, &x2, &y2);
_validateIntersectRectAndLineResults(intersected, SDL_TRUE, &rect, &refRect, x1, y1, x2, y2, 31, 0, 0, 31); validateIntersectRectAndLineResults(intersected, SDL_TRUE, &rect, &refRect, x1, y1, x2, y2, 31, 0, 0, 31);
return TEST_COMPLETED; return TEST_COMPLETED;
} }
@ -135,7 +135,7 @@ int rect_testIntersectRectAndLineInside(void *arg)
y2 = y2Ref; y2 = y2Ref;
rect = refRect; rect = refRect;
intersected = SDL_GetRectAndLineIntersection(&rect, &x1, &y1, &x2, &y2); intersected = SDL_GetRectAndLineIntersection(&rect, &x1, &y1, &x2, &y2);
_validateIntersectRectAndLineResults(intersected, SDL_TRUE, &rect, &refRect, x1, y1, x2, y2, x1Ref, y1Ref, x2Ref, y2Ref); validateIntersectRectAndLineResults(intersected, SDL_TRUE, &rect, &refRect, x1, y1, x2, y2, x1Ref, y1Ref, x2Ref, y2Ref);
x1 = x1Ref; x1 = x1Ref;
y1 = y1Ref; y1 = y1Ref;
@ -143,7 +143,7 @@ int rect_testIntersectRectAndLineInside(void *arg)
y2 = ymax; y2 = ymax;
rect = refRect; rect = refRect;
intersected = SDL_GetRectAndLineIntersection(&rect, &x1, &y1, &x2, &y2); intersected = SDL_GetRectAndLineIntersection(&rect, &x1, &y1, &x2, &y2);
_validateIntersectRectAndLineResults(intersected, SDL_TRUE, &rect, &refRect, x1, y1, x2, y2, x1Ref, y1Ref, xmax, ymax); validateIntersectRectAndLineResults(intersected, SDL_TRUE, &rect, &refRect, x1, y1, x2, y2, x1Ref, y1Ref, xmax, ymax);
x1 = xmin; x1 = xmin;
y1 = ymin; y1 = ymin;
@ -151,7 +151,7 @@ int rect_testIntersectRectAndLineInside(void *arg)
y2 = y2Ref; y2 = y2Ref;
rect = refRect; rect = refRect;
intersected = SDL_GetRectAndLineIntersection(&rect, &x1, &y1, &x2, &y2); intersected = SDL_GetRectAndLineIntersection(&rect, &x1, &y1, &x2, &y2);
_validateIntersectRectAndLineResults(intersected, SDL_TRUE, &rect, &refRect, x1, y1, x2, y2, xmin, ymin, x2Ref, y2Ref); validateIntersectRectAndLineResults(intersected, SDL_TRUE, &rect, &refRect, x1, y1, x2, y2, xmin, ymin, x2Ref, y2Ref);
x1 = xmin; x1 = xmin;
y1 = ymin; y1 = ymin;
@ -159,7 +159,7 @@ int rect_testIntersectRectAndLineInside(void *arg)
y2 = ymax; y2 = ymax;
rect = refRect; rect = refRect;
intersected = SDL_GetRectAndLineIntersection(&rect, &x1, &y1, &x2, &y2); intersected = SDL_GetRectAndLineIntersection(&rect, &x1, &y1, &x2, &y2);
_validateIntersectRectAndLineResults(intersected, SDL_TRUE, &rect, &refRect, x1, y1, x2, y2, xmin, ymin, xmax, ymax); validateIntersectRectAndLineResults(intersected, SDL_TRUE, &rect, &refRect, x1, y1, x2, y2, xmin, ymin, xmax, ymax);
x1 = xmin; x1 = xmin;
y1 = ymax; y1 = ymax;
@ -167,7 +167,7 @@ int rect_testIntersectRectAndLineInside(void *arg)
y2 = ymin; y2 = ymin;
rect = refRect; rect = refRect;
intersected = SDL_GetRectAndLineIntersection(&rect, &x1, &y1, &x2, &y2); intersected = SDL_GetRectAndLineIntersection(&rect, &x1, &y1, &x2, &y2);
_validateIntersectRectAndLineResults(intersected, SDL_TRUE, &rect, &refRect, x1, y1, x2, y2, xmin, ymax, xmax, ymin); validateIntersectRectAndLineResults(intersected, SDL_TRUE, &rect, &refRect, x1, y1, x2, y2, xmin, ymax, xmax, ymin);
return TEST_COMPLETED; return TEST_COMPLETED;
} }
@ -197,7 +197,7 @@ int rect_testIntersectRectAndLineOutside(void *arg)
y2 = 31; y2 = 31;
rect = refRect; rect = refRect;
intersected = SDL_GetRectAndLineIntersection(&rect, &x1, &y1, &x2, &y2); intersected = SDL_GetRectAndLineIntersection(&rect, &x1, &y1, &x2, &y2);
_validateIntersectRectAndLineResults(intersected, SDL_FALSE, &rect, &refRect, x1, y1, x2, y2, xLeft, 0, xLeft, 31); validateIntersectRectAndLineResults(intersected, SDL_FALSE, &rect, &refRect, x1, y1, x2, y2, xLeft, 0, xLeft, 31);
x1 = xRight; x1 = xRight;
y1 = 0; y1 = 0;
@ -205,7 +205,7 @@ int rect_testIntersectRectAndLineOutside(void *arg)
y2 = 31; y2 = 31;
rect = refRect; rect = refRect;
intersected = SDL_GetRectAndLineIntersection(&rect, &x1, &y1, &x2, &y2); intersected = SDL_GetRectAndLineIntersection(&rect, &x1, &y1, &x2, &y2);
_validateIntersectRectAndLineResults(intersected, SDL_FALSE, &rect, &refRect, x1, y1, x2, y2, xRight, 0, xRight, 31); validateIntersectRectAndLineResults(intersected, SDL_FALSE, &rect, &refRect, x1, y1, x2, y2, xRight, 0, xRight, 31);
x1 = 0; x1 = 0;
y1 = yTop; y1 = yTop;
@ -213,7 +213,7 @@ int rect_testIntersectRectAndLineOutside(void *arg)
y2 = yTop; y2 = yTop;
rect = refRect; rect = refRect;
intersected = SDL_GetRectAndLineIntersection(&rect, &x1, &y1, &x2, &y2); intersected = SDL_GetRectAndLineIntersection(&rect, &x1, &y1, &x2, &y2);
_validateIntersectRectAndLineResults(intersected, SDL_FALSE, &rect, &refRect, x1, y1, x2, y2, 0, yTop, 31, yTop); validateIntersectRectAndLineResults(intersected, SDL_FALSE, &rect, &refRect, x1, y1, x2, y2, 0, yTop, 31, yTop);
x1 = 0; x1 = 0;
y1 = yBottom; y1 = yBottom;
@ -221,7 +221,7 @@ int rect_testIntersectRectAndLineOutside(void *arg)
y2 = yBottom; y2 = yBottom;
rect = refRect; rect = refRect;
intersected = SDL_GetRectAndLineIntersection(&rect, &x1, &y1, &x2, &y2); intersected = SDL_GetRectAndLineIntersection(&rect, &x1, &y1, &x2, &y2);
_validateIntersectRectAndLineResults(intersected, SDL_FALSE, &rect, &refRect, x1, y1, x2, y2, 0, yBottom, 31, yBottom); validateIntersectRectAndLineResults(intersected, SDL_FALSE, &rect, &refRect, x1, y1, x2, y2, 0, yBottom, 31, yBottom);
return TEST_COMPLETED; return TEST_COMPLETED;
} }
@ -255,7 +255,7 @@ int rect_testIntersectRectAndLineEmpty(void *arg)
y2 = y2Ref; y2 = y2Ref;
rect = refRect; rect = refRect;
intersected = SDL_GetRectAndLineIntersection(&rect, &x1, &y1, &x2, &y2); intersected = SDL_GetRectAndLineIntersection(&rect, &x1, &y1, &x2, &y2);
_validateIntersectRectAndLineResults(intersected, SDL_FALSE, &rect, &refRect, x1, y1, x2, y2, x1Ref, y1Ref, x2Ref, y2Ref); validateIntersectRectAndLineResults(intersected, SDL_FALSE, &rect, &refRect, x1, y1, x2, y2, x1Ref, y1Ref, x2Ref, y2Ref);
return TEST_COMPLETED; return TEST_COMPLETED;
} }
@ -297,7 +297,7 @@ int rect_testIntersectRectAndLineParam(void *arg)
/* ! /* !
* \brief Private helper to check SDL_HasRectIntersection results * \brief Private helper to check SDL_HasRectIntersection results
*/ */
void _validateHasIntersectionResults( static void validateHasIntersectionResults(
SDL_bool intersection, SDL_bool expectedIntersection, SDL_bool intersection, SDL_bool expectedIntersection,
SDL_Rect *rectA, SDL_Rect *rectB, SDL_Rect *refRectA, SDL_Rect *refRectB) SDL_Rect *rectA, SDL_Rect *rectB, SDL_Rect *refRectA, SDL_Rect *refRectB)
{ {
@ -320,12 +320,12 @@ void _validateHasIntersectionResults(
/* ! /* !
* \brief Private helper to check SDL_GetRectIntersection results * \brief Private helper to check SDL_GetRectIntersection results
*/ */
void _validateIntersectRectResults( static void validateIntersectRectResults(
SDL_bool intersection, SDL_bool expectedIntersection, SDL_bool intersection, SDL_bool expectedIntersection,
SDL_Rect *rectA, SDL_Rect *rectB, SDL_Rect *refRectA, SDL_Rect *refRectB, SDL_Rect *rectA, SDL_Rect *rectB, SDL_Rect *refRectA, SDL_Rect *refRectB,
SDL_Rect *result, SDL_Rect *expectedResult) SDL_Rect *result, SDL_Rect *expectedResult)
{ {
_validateHasIntersectionResults(intersection, expectedIntersection, rectA, rectB, refRectA, refRectB); validateHasIntersectionResults(intersection, expectedIntersection, rectA, rectB, refRectA, refRectB);
if (result && expectedResult) { if (result && expectedResult) {
SDLTest_AssertCheck(result->x == expectedResult->x && result->y == expectedResult->y && result->w == expectedResult->w && result->h == expectedResult->h, SDLTest_AssertCheck(result->x == expectedResult->x && result->y == expectedResult->y && result->w == expectedResult->w && result->h == expectedResult->h,
"Check that intersection of rectangles A (%d,%d,%d,%d) and B (%d,%d,%d,%d) was correctly calculated, got (%d,%d,%d,%d) expected (%d,%d,%d,%d)", "Check that intersection of rectangles A (%d,%d,%d,%d) and B (%d,%d,%d,%d) was correctly calculated, got (%d,%d,%d,%d) expected (%d,%d,%d,%d)",
@ -339,7 +339,7 @@ void _validateIntersectRectResults(
/* ! /* !
* \brief Private helper to check SDL_GetRectUnion results * \brief Private helper to check SDL_GetRectUnion results
*/ */
void _validateUnionRectResults( static void validateUnionRectResults(
SDL_Rect *rectA, SDL_Rect *rectB, SDL_Rect *refRectA, SDL_Rect *refRectB, SDL_Rect *rectA, SDL_Rect *rectB, SDL_Rect *refRectA, SDL_Rect *refRectB,
SDL_Rect *result, SDL_Rect *expectedResult) SDL_Rect *result, SDL_Rect *expectedResult)
{ {
@ -362,7 +362,7 @@ void _validateUnionRectResults(
/* ! /* !
* \brief Private helper to check SDL_RectEmpty results * \brief Private helper to check SDL_RectEmpty results
*/ */
void _validateRectEmptyResults( static void validateRectEmptyResults(
SDL_bool empty, SDL_bool expectedEmpty, SDL_bool empty, SDL_bool expectedEmpty,
SDL_Rect *rect, SDL_Rect *refRect) SDL_Rect *rect, SDL_Rect *refRect)
{ {
@ -380,7 +380,7 @@ void _validateRectEmptyResults(
/* ! /* !
* \brief Private helper to check SDL_RectsEqual results * \brief Private helper to check SDL_RectsEqual results
*/ */
void _validateRectEqualsResults( static void validateRectEqualsResults(
SDL_bool equals, SDL_bool expectedEquals, SDL_bool equals, SDL_bool expectedEquals,
SDL_Rect *rectA, SDL_Rect *rectB, SDL_Rect *refRectA, SDL_Rect *refRectB) SDL_Rect *rectA, SDL_Rect *rectB, SDL_Rect *refRectA, SDL_Rect *refRectB)
{ {
@ -403,7 +403,7 @@ void _validateRectEqualsResults(
/* ! /* !
* \brief Private helper to check SDL_RectsEqualF results * \brief Private helper to check SDL_RectsEqualF results
*/ */
void _validateFRectEqualsResults( static void validateFRectEqualsResults(
SDL_bool equals, SDL_bool expectedEquals, SDL_bool equals, SDL_bool expectedEquals,
SDL_FRect *rectA, SDL_FRect *rectB, SDL_FRect *refRectA, SDL_FRect *refRectB) SDL_FRect *rectA, SDL_FRect *rectB, SDL_FRect *refRectA, SDL_FRect *refRectB)
{ {
@ -449,7 +449,7 @@ int rect_testIntersectRectInside(void *arg)
rectA = refRectA; rectA = refRectA;
rectB = refRectB; rectB = refRectB;
intersection = SDL_GetRectIntersection(&rectA, &rectB, &result); intersection = SDL_GetRectIntersection(&rectA, &rectB, &result);
_validateIntersectRectResults(intersection, SDL_TRUE, &rectA, &rectB, &refRectA, &refRectB, &result, &refRectB); validateIntersectRectResults(intersection, SDL_TRUE, &rectA, &rectB, &refRectA, &refRectB, &result, &refRectB);
return TEST_COMPLETED; return TEST_COMPLETED;
} }
@ -477,7 +477,7 @@ int rect_testIntersectRectOutside(void *arg)
rectA = refRectA; rectA = refRectA;
rectB = refRectB; rectB = refRectB;
intersection = SDL_GetRectIntersection(&rectA, &rectB, &result); intersection = SDL_GetRectIntersection(&rectA, &rectB, &result);
_validateIntersectRectResults(intersection, SDL_FALSE, &rectA, &rectB, &refRectA, &refRectB, (SDL_Rect *)NULL, (SDL_Rect *)NULL); validateIntersectRectResults(intersection, SDL_FALSE, &rectA, &rectB, &refRectA, &refRectB, (SDL_Rect *)NULL, (SDL_Rect *)NULL);
return TEST_COMPLETED; return TEST_COMPLETED;
} }
@ -510,7 +510,7 @@ int rect_testIntersectRectPartial(void *arg)
expectedResult.w = refRectA.w - refRectB.x; expectedResult.w = refRectA.w - refRectB.x;
expectedResult.h = refRectA.h - refRectB.y; expectedResult.h = refRectA.h - refRectB.y;
intersection = SDL_GetRectIntersection(&rectA, &rectB, &result); intersection = SDL_GetRectIntersection(&rectA, &rectB, &result);
_validateIntersectRectResults(intersection, SDL_TRUE, &rectA, &rectB, &refRectA, &refRectB, &result, &expectedResult); validateIntersectRectResults(intersection, SDL_TRUE, &rectA, &rectB, &refRectA, &refRectB, &result, &expectedResult);
/* rectB right edge */ /* rectB right edge */
refRectB.x = rectA.w - 1; refRectB.x = rectA.w - 1;
@ -524,7 +524,7 @@ int rect_testIntersectRectPartial(void *arg)
expectedResult.w = 1; expectedResult.w = 1;
expectedResult.h = refRectB.h; expectedResult.h = refRectB.h;
intersection = SDL_GetRectIntersection(&rectA, &rectB, &result); intersection = SDL_GetRectIntersection(&rectA, &rectB, &result);
_validateIntersectRectResults(intersection, SDL_TRUE, &rectA, &rectB, &refRectA, &refRectB, &result, &expectedResult); validateIntersectRectResults(intersection, SDL_TRUE, &rectA, &rectB, &refRectA, &refRectB, &result, &expectedResult);
/* rectB left edge */ /* rectB left edge */
refRectB.x = 1 - rectA.w; refRectB.x = 1 - rectA.w;
@ -538,7 +538,7 @@ int rect_testIntersectRectPartial(void *arg)
expectedResult.w = 1; expectedResult.w = 1;
expectedResult.h = refRectB.h; expectedResult.h = refRectB.h;
intersection = SDL_GetRectIntersection(&rectA, &rectB, &result); intersection = SDL_GetRectIntersection(&rectA, &rectB, &result);
_validateIntersectRectResults(intersection, SDL_TRUE, &rectA, &rectB, &refRectA, &refRectB, &result, &expectedResult); validateIntersectRectResults(intersection, SDL_TRUE, &rectA, &rectB, &refRectA, &refRectB, &result, &expectedResult);
/* rectB bottom edge */ /* rectB bottom edge */
refRectB.x = rectA.x; refRectB.x = rectA.x;
@ -552,7 +552,7 @@ int rect_testIntersectRectPartial(void *arg)
expectedResult.w = refRectB.w; expectedResult.w = refRectB.w;
expectedResult.h = 1; expectedResult.h = 1;
intersection = SDL_GetRectIntersection(&rectA, &rectB, &result); intersection = SDL_GetRectIntersection(&rectA, &rectB, &result);
_validateIntersectRectResults(intersection, SDL_TRUE, &rectA, &rectB, &refRectA, &refRectB, &result, &expectedResult); validateIntersectRectResults(intersection, SDL_TRUE, &rectA, &rectB, &refRectA, &refRectB, &result, &expectedResult);
/* rectB top edge */ /* rectB top edge */
refRectB.x = rectA.x; refRectB.x = rectA.x;
@ -566,7 +566,7 @@ int rect_testIntersectRectPartial(void *arg)
expectedResult.w = refRectB.w; expectedResult.w = refRectB.w;
expectedResult.h = 1; expectedResult.h = 1;
intersection = SDL_GetRectIntersection(&rectA, &rectB, &result); intersection = SDL_GetRectIntersection(&rectA, &rectB, &result);
_validateIntersectRectResults(intersection, SDL_TRUE, &rectA, &rectB, &refRectA, &refRectB, &result, &expectedResult); validateIntersectRectResults(intersection, SDL_TRUE, &rectA, &rectB, &refRectA, &refRectB, &result, &expectedResult);
return TEST_COMPLETED; return TEST_COMPLETED;
} }
@ -595,7 +595,7 @@ int rect_testIntersectRectPoint(void *arg)
rectA = refRectA; rectA = refRectA;
rectB = refRectB; rectB = refRectB;
intersection = SDL_GetRectIntersection(&rectA, &rectB, &result); intersection = SDL_GetRectIntersection(&rectA, &rectB, &result);
_validateIntersectRectResults(intersection, SDL_TRUE, &rectA, &rectB, &refRectA, &refRectB, &result, &refRectA); validateIntersectRectResults(intersection, SDL_TRUE, &rectA, &rectB, &refRectA, &refRectB, &result, &refRectA);
/* non-intersecting pixels cases */ /* non-intersecting pixels cases */
for (offsetX = -1; offsetX <= 1; offsetX++) { for (offsetX = -1; offsetX <= 1; offsetX++) {
@ -610,7 +610,7 @@ int rect_testIntersectRectPoint(void *arg)
rectA = refRectA; rectA = refRectA;
rectB = refRectB; rectB = refRectB;
intersection = SDL_GetRectIntersection(&rectA, &rectB, &result); intersection = SDL_GetRectIntersection(&rectA, &rectB, &result);
_validateIntersectRectResults(intersection, SDL_FALSE, &rectA, &rectB, &refRectA, &refRectB, (SDL_Rect *)NULL, (SDL_Rect *)NULL); validateIntersectRectResults(intersection, SDL_FALSE, &rectA, &rectB, &refRectA, &refRectB, (SDL_Rect *)NULL, (SDL_Rect *)NULL);
} }
} }
} }
@ -647,7 +647,7 @@ int rect_testIntersectRectEmpty(void *arg)
rectA = refRectA; rectA = refRectA;
rectB = refRectB; rectB = refRectB;
intersection = SDL_GetRectIntersection(&rectA, &rectB, &result); intersection = SDL_GetRectIntersection(&rectA, &rectB, &result);
_validateIntersectRectResults(intersection, SDL_FALSE, &rectA, &rectB, &refRectA, &refRectB, (SDL_Rect *)NULL, (SDL_Rect *)NULL); validateIntersectRectResults(intersection, SDL_FALSE, &rectA, &rectB, &refRectA, &refRectB, (SDL_Rect *)NULL, (SDL_Rect *)NULL);
empty = SDL_RectEmpty(&result); empty = SDL_RectEmpty(&result);
SDLTest_AssertCheck(empty == SDL_TRUE, "Validate result is empty Rect; got: %s", (empty == SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE"); SDLTest_AssertCheck(empty == SDL_TRUE, "Validate result is empty Rect; got: %s", (empty == SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE");
@ -664,7 +664,7 @@ int rect_testIntersectRectEmpty(void *arg)
rectA = refRectA; rectA = refRectA;
rectB = refRectB; rectB = refRectB;
intersection = SDL_GetRectIntersection(&rectA, &rectB, &result); intersection = SDL_GetRectIntersection(&rectA, &rectB, &result);
_validateIntersectRectResults(intersection, SDL_FALSE, &rectA, &rectB, &refRectA, &refRectB, (SDL_Rect *)NULL, (SDL_Rect *)NULL); validateIntersectRectResults(intersection, SDL_FALSE, &rectA, &rectB, &refRectA, &refRectB, (SDL_Rect *)NULL, (SDL_Rect *)NULL);
empty = SDL_RectEmpty(&result); empty = SDL_RectEmpty(&result);
SDLTest_AssertCheck(empty == SDL_TRUE, "Validate result is empty Rect; got: %s", (empty == SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE"); SDLTest_AssertCheck(empty == SDL_TRUE, "Validate result is empty Rect; got: %s", (empty == SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE");
@ -683,7 +683,7 @@ int rect_testIntersectRectEmpty(void *arg)
rectA = refRectA; rectA = refRectA;
rectB = refRectB; rectB = refRectB;
intersection = SDL_GetRectIntersection(&rectA, &rectB, &result); intersection = SDL_GetRectIntersection(&rectA, &rectB, &result);
_validateIntersectRectResults(intersection, SDL_FALSE, &rectA, &rectB, &refRectA, &refRectB, (SDL_Rect *)NULL, (SDL_Rect *)NULL); validateIntersectRectResults(intersection, SDL_FALSE, &rectA, &rectB, &refRectA, &refRectB, (SDL_Rect *)NULL, (SDL_Rect *)NULL);
empty = SDL_RectEmpty(&result); empty = SDL_RectEmpty(&result);
SDLTest_AssertCheck(empty == SDL_TRUE, "Validate result is empty Rect; got: %s", (empty == SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE"); SDLTest_AssertCheck(empty == SDL_TRUE, "Validate result is empty Rect; got: %s", (empty == SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE");
@ -742,7 +742,7 @@ int rect_testHasIntersectionInside(void *arg)
rectA = refRectA; rectA = refRectA;
rectB = refRectB; rectB = refRectB;
intersection = SDL_HasRectIntersection(&rectA, &rectB); intersection = SDL_HasRectIntersection(&rectA, &rectB);
_validateHasIntersectionResults(intersection, SDL_TRUE, &rectA, &rectB, &refRectA, &refRectB); validateHasIntersectionResults(intersection, SDL_TRUE, &rectA, &rectB, &refRectA, &refRectB);
return TEST_COMPLETED; return TEST_COMPLETED;
} }
@ -769,7 +769,7 @@ int rect_testHasIntersectionOutside(void *arg)
rectA = refRectA; rectA = refRectA;
rectB = refRectB; rectB = refRectB;
intersection = SDL_HasRectIntersection(&rectA, &rectB); intersection = SDL_HasRectIntersection(&rectA, &rectB);
_validateHasIntersectionResults(intersection, SDL_FALSE, &rectA, &rectB, &refRectA, &refRectB); validateHasIntersectionResults(intersection, SDL_FALSE, &rectA, &rectB, &refRectA, &refRectB);
return TEST_COMPLETED; return TEST_COMPLETED;
} }
@ -796,7 +796,7 @@ int rect_testHasIntersectionPartial(void *arg)
rectA = refRectA; rectA = refRectA;
rectB = refRectB; rectB = refRectB;
intersection = SDL_HasRectIntersection(&rectA, &rectB); intersection = SDL_HasRectIntersection(&rectA, &rectB);
_validateHasIntersectionResults(intersection, SDL_TRUE, &rectA, &rectB, &refRectA, &refRectB); validateHasIntersectionResults(intersection, SDL_TRUE, &rectA, &rectB, &refRectA, &refRectB);
/* rectB right edge */ /* rectB right edge */
refRectB.x = rectA.w - 1; refRectB.x = rectA.w - 1;
@ -806,7 +806,7 @@ int rect_testHasIntersectionPartial(void *arg)
rectA = refRectA; rectA = refRectA;
rectB = refRectB; rectB = refRectB;
intersection = SDL_HasRectIntersection(&rectA, &rectB); intersection = SDL_HasRectIntersection(&rectA, &rectB);
_validateHasIntersectionResults(intersection, SDL_TRUE, &rectA, &rectB, &refRectA, &refRectB); validateHasIntersectionResults(intersection, SDL_TRUE, &rectA, &rectB, &refRectA, &refRectB);
/* rectB left edge */ /* rectB left edge */
refRectB.x = 1 - rectA.w; refRectB.x = 1 - rectA.w;
@ -816,7 +816,7 @@ int rect_testHasIntersectionPartial(void *arg)
rectA = refRectA; rectA = refRectA;
rectB = refRectB; rectB = refRectB;
intersection = SDL_HasRectIntersection(&rectA, &rectB); intersection = SDL_HasRectIntersection(&rectA, &rectB);
_validateHasIntersectionResults(intersection, SDL_TRUE, &rectA, &rectB, &refRectA, &refRectB); validateHasIntersectionResults(intersection, SDL_TRUE, &rectA, &rectB, &refRectA, &refRectB);
/* rectB bottom edge */ /* rectB bottom edge */
refRectB.x = rectA.x; refRectB.x = rectA.x;
@ -826,7 +826,7 @@ int rect_testHasIntersectionPartial(void *arg)
rectA = refRectA; rectA = refRectA;
rectB = refRectB; rectB = refRectB;
intersection = SDL_HasRectIntersection(&rectA, &rectB); intersection = SDL_HasRectIntersection(&rectA, &rectB);
_validateHasIntersectionResults(intersection, SDL_TRUE, &rectA, &rectB, &refRectA, &refRectB); validateHasIntersectionResults(intersection, SDL_TRUE, &rectA, &rectB, &refRectA, &refRectB);
/* rectB top edge */ /* rectB top edge */
refRectB.x = rectA.x; refRectB.x = rectA.x;
@ -836,7 +836,7 @@ int rect_testHasIntersectionPartial(void *arg)
rectA = refRectA; rectA = refRectA;
rectB = refRectB; rectB = refRectB;
intersection = SDL_HasRectIntersection(&rectA, &rectB); intersection = SDL_HasRectIntersection(&rectA, &rectB);
_validateHasIntersectionResults(intersection, SDL_TRUE, &rectA, &rectB, &refRectA, &refRectB); validateHasIntersectionResults(intersection, SDL_TRUE, &rectA, &rectB, &refRectA, &refRectB);
return TEST_COMPLETED; return TEST_COMPLETED;
} }
@ -864,7 +864,7 @@ int rect_testHasIntersectionPoint(void *arg)
rectA = refRectA; rectA = refRectA;
rectB = refRectB; rectB = refRectB;
intersection = SDL_HasRectIntersection(&rectA, &rectB); intersection = SDL_HasRectIntersection(&rectA, &rectB);
_validateHasIntersectionResults(intersection, SDL_TRUE, &rectA, &rectB, &refRectA, &refRectB); validateHasIntersectionResults(intersection, SDL_TRUE, &rectA, &rectB, &refRectA, &refRectB);
/* non-intersecting pixels cases */ /* non-intersecting pixels cases */
for (offsetX = -1; offsetX <= 1; offsetX++) { for (offsetX = -1; offsetX <= 1; offsetX++) {
@ -879,7 +879,7 @@ int rect_testHasIntersectionPoint(void *arg)
rectA = refRectA; rectA = refRectA;
rectB = refRectB; rectB = refRectB;
intersection = SDL_HasRectIntersection(&rectA, &rectB); intersection = SDL_HasRectIntersection(&rectA, &rectB);
_validateHasIntersectionResults(intersection, SDL_FALSE, &rectA, &rectB, &refRectA, &refRectB); validateHasIntersectionResults(intersection, SDL_FALSE, &rectA, &rectB, &refRectA, &refRectB);
} }
} }
} }
@ -912,7 +912,7 @@ int rect_testHasIntersectionEmpty(void *arg)
rectA = refRectA; rectA = refRectA;
rectB = refRectB; rectB = refRectB;
intersection = SDL_HasRectIntersection(&rectA, &rectB); intersection = SDL_HasRectIntersection(&rectA, &rectB);
_validateHasIntersectionResults(intersection, SDL_FALSE, &rectA, &rectB, &refRectA, &refRectB); validateHasIntersectionResults(intersection, SDL_FALSE, &rectA, &rectB, &refRectA, &refRectB);
/* Rect B empty */ /* Rect B empty */
refRectA.x = SDLTest_RandomIntegerInRange(1, 100); refRectA.x = SDLTest_RandomIntegerInRange(1, 100);
@ -925,7 +925,7 @@ int rect_testHasIntersectionEmpty(void *arg)
rectA = refRectA; rectA = refRectA;
rectB = refRectB; rectB = refRectB;
intersection = SDL_HasRectIntersection(&rectA, &rectB); intersection = SDL_HasRectIntersection(&rectA, &rectB);
_validateHasIntersectionResults(intersection, SDL_FALSE, &rectA, &rectB, &refRectA, &refRectB); validateHasIntersectionResults(intersection, SDL_FALSE, &rectA, &rectB, &refRectA, &refRectB);
/* Rect A and B empty */ /* Rect A and B empty */
refRectA.x = SDLTest_RandomIntegerInRange(1, 100); refRectA.x = SDLTest_RandomIntegerInRange(1, 100);
@ -940,7 +940,7 @@ int rect_testHasIntersectionEmpty(void *arg)
rectA = refRectA; rectA = refRectA;
rectB = refRectB; rectB = refRectB;
intersection = SDL_HasRectIntersection(&rectA, &rectB); intersection = SDL_HasRectIntersection(&rectA, &rectB);
_validateHasIntersectionResults(intersection, SDL_FALSE, &rectA, &rectB, &refRectA, &refRectB); validateHasIntersectionResults(intersection, SDL_FALSE, &rectA, &rectB, &refRectA, &refRectB);
return TEST_COMPLETED; return TEST_COMPLETED;
} }
@ -1303,7 +1303,7 @@ int rect_testUnionRectOutside(void *arg)
rectA = refRectA; rectA = refRectA;
rectB = refRectB; rectB = refRectB;
SDL_GetRectUnion(&rectA, &rectB, &result); SDL_GetRectUnion(&rectA, &rectB, &result);
_validateUnionRectResults(&rectA, &rectB, &refRectA, &refRectB, &result, &expectedResult); validateUnionRectResults(&rectA, &rectB, &refRectA, &refRectB, &result, &expectedResult);
} }
} }
} }
@ -1336,7 +1336,7 @@ int rect_testUnionRectOutside(void *arg)
rectA = refRectA; rectA = refRectA;
rectB = refRectB; rectB = refRectB;
SDL_GetRectUnion(&rectA, &rectB, &result); SDL_GetRectUnion(&rectA, &rectB, &result);
_validateUnionRectResults(&rectA, &rectB, &refRectA, &refRectB, &result, &expectedResult); validateUnionRectResults(&rectA, &rectB, &refRectA, &refRectB, &result, &expectedResult);
} }
} }
} }
@ -1370,7 +1370,7 @@ int rect_testUnionRectEmpty(void *arg)
rectA = refRectA; rectA = refRectA;
rectB = refRectB; rectB = refRectB;
SDL_GetRectUnion(&rectA, &rectB, &result); SDL_GetRectUnion(&rectA, &rectB, &result);
_validateUnionRectResults(&rectA, &rectB, &refRectA, &refRectB, &result, &expectedResult); validateUnionRectResults(&rectA, &rectB, &refRectA, &refRectB, &result, &expectedResult);
/* B empty */ /* B empty */
refRectA.x = SDLTest_RandomIntegerInRange(-1024, 1024); refRectA.x = SDLTest_RandomIntegerInRange(-1024, 1024);
@ -1385,7 +1385,7 @@ int rect_testUnionRectEmpty(void *arg)
rectA = refRectA; rectA = refRectA;
rectB = refRectB; rectB = refRectB;
SDL_GetRectUnion(&rectA, &rectB, &result); SDL_GetRectUnion(&rectA, &rectB, &result);
_validateUnionRectResults(&rectA, &rectB, &refRectA, &refRectB, &result, &expectedResult); validateUnionRectResults(&rectA, &rectB, &refRectA, &refRectB, &result, &expectedResult);
/* A and B empty */ /* A and B empty */
refRectA.x = SDLTest_RandomIntegerInRange(-1024, 1024); refRectA.x = SDLTest_RandomIntegerInRange(-1024, 1024);
@ -1404,7 +1404,7 @@ int rect_testUnionRectEmpty(void *arg)
rectA = refRectA; rectA = refRectA;
rectB = refRectB; rectB = refRectB;
SDL_GetRectUnion(&rectA, &rectB, &result); SDL_GetRectUnion(&rectA, &rectB, &result);
_validateUnionRectResults(&rectA, &rectB, &refRectA, &refRectB, &result, &expectedResult); validateUnionRectResults(&rectA, &rectB, &refRectA, &refRectB, &result, &expectedResult);
return TEST_COMPLETED; return TEST_COMPLETED;
} }
@ -1431,7 +1431,7 @@ int rect_testUnionRectInside(void *arg)
expectedResult = refRectA; expectedResult = refRectA;
rectA = refRectA; rectA = refRectA;
SDL_GetRectUnion(&rectA, &rectA, &result); SDL_GetRectUnion(&rectA, &rectA, &result);
_validateUnionRectResults(&rectA, &rectA, &refRectA, &refRectA, &result, &expectedResult); validateUnionRectResults(&rectA, &rectA, &refRectA, &refRectA, &result, &expectedResult);
/* Union 1x1 somewhere inside */ /* Union 1x1 somewhere inside */
refRectA.x = SDLTest_RandomIntegerInRange(-1024, 1024); refRectA.x = SDLTest_RandomIntegerInRange(-1024, 1024);
@ -1446,7 +1446,7 @@ int rect_testUnionRectInside(void *arg)
rectA = refRectA; rectA = refRectA;
rectB = refRectB; rectB = refRectB;
SDL_GetRectUnion(&rectA, &rectB, &result); SDL_GetRectUnion(&rectA, &rectB, &result);
_validateUnionRectResults(&rectA, &rectB, &refRectA, &refRectB, &result, &expectedResult); validateUnionRectResults(&rectA, &rectB, &refRectA, &refRectB, &result, &expectedResult);
/* Union inside with edges modified */ /* Union inside with edges modified */
for (dx = -1; dx < 2; dx++) { for (dx = -1; dx < 2; dx++) {
@ -1473,7 +1473,7 @@ int rect_testUnionRectInside(void *arg)
rectA = refRectA; rectA = refRectA;
rectB = refRectB; rectB = refRectB;
SDL_GetRectUnion(&rectA, &rectB, &result); SDL_GetRectUnion(&rectA, &rectB, &result);
_validateUnionRectResults(&rectA, &rectB, &refRectA, &refRectB, &result, &expectedResult); validateUnionRectResults(&rectA, &rectB, &refRectA, &refRectB, &result, &expectedResult);
} }
} }
} }
@ -1531,7 +1531,7 @@ int rect_testRectEmpty(void *arg)
expectedResult = SDL_FALSE; expectedResult = SDL_FALSE;
rect = refRect; rect = refRect;
result = SDL_RectEmpty(&rect); result = SDL_RectEmpty(&rect);
_validateRectEmptyResults(result, expectedResult, &rect, &refRect); validateRectEmptyResults(result, expectedResult, &rect, &refRect);
/* Empty case */ /* Empty case */
for (w = -1; w < 2; w++) { for (w = -1; w < 2; w++) {
@ -1544,7 +1544,7 @@ int rect_testRectEmpty(void *arg)
expectedResult = SDL_TRUE; expectedResult = SDL_TRUE;
rect = refRect; rect = refRect;
result = SDL_RectEmpty(&rect); result = SDL_RectEmpty(&rect);
_validateRectEmptyResults(result, expectedResult, &rect, &refRect); validateRectEmptyResults(result, expectedResult, &rect, &refRect);
} }
} }
} }
@ -1594,7 +1594,7 @@ int rect_testRectEquals(void *arg)
rectA = refRectA; rectA = refRectA;
rectB = refRectB; rectB = refRectB;
result = SDL_RectsEqual(&rectA, &rectB); result = SDL_RectsEqual(&rectA, &rectB);
_validateRectEqualsResults(result, expectedResult, &rectA, &rectB, &refRectA, &refRectB); validateRectEqualsResults(result, expectedResult, &rectA, &rectB, &refRectA, &refRectB);
return TEST_COMPLETED; return TEST_COMPLETED;
} }
@ -1657,7 +1657,7 @@ int rect_testFRectEquals(void *arg)
rectA = refRectA; rectA = refRectA;
rectB = refRectB; rectB = refRectB;
result = SDL_RectsEqualF(&rectA, &rectB); result = SDL_RectsEqualF(&rectA, &rectB);
_validateFRectEqualsResults(result, expectedResult, &rectA, &rectB, &refRectA, &refRectB); validateFRectEqualsResults(result, expectedResult, &rectA, &rectB, &refRectA, &refRectB);
return TEST_COMPLETED; return TEST_COMPLETED;
} }

View file

@ -22,14 +22,14 @@ SDL_Renderer *renderer = NULL;
/* Prototypes for helper functions */ /* Prototypes for helper functions */
static int _clearScreen(void); static int clearScreen(void);
static void _compare(SDL_Surface *reference, int allowable_error); static void compare(SDL_Surface *reference, int allowable_error);
static int _hasTexAlpha(void); static int hasTexAlpha(void);
static int _hasTexColor(void); static int hasTexColor(void);
static SDL_Texture *_loadTestFace(void); static SDL_Texture *loadTestFace(void);
static int _hasBlendModes(void); static int hasBlendModes(void);
static int _hasDrawColor(void); static int hasDrawColor(void);
static int _isSupported(int code); static int isSupported(int code);
/** /**
* Create software renderer for tests * Create software renderer for tests
@ -105,10 +105,10 @@ int render_testPrimitives(void *arg)
int checkFailCount2; int checkFailCount2;
/* Clear surface. */ /* Clear surface. */
_clearScreen(); clearScreen();
/* Need drawcolor or just skip test. */ /* Need drawcolor or just skip test. */
SDLTest_AssertCheck(_hasDrawColor(), "_hasDrawColor"); SDLTest_AssertCheck(hasDrawColor(), "_hasDrawColor");
/* Draw a rectangle. */ /* Draw a rectangle. */
rect.x = 40; rect.x = 40;
@ -185,7 +185,7 @@ int render_testPrimitives(void *arg)
/* See if it's the same. */ /* See if it's the same. */
referenceSurface = SDLTest_ImagePrimitives(); referenceSurface = SDLTest_ImagePrimitives();
_compare(referenceSurface, ALLOWABLE_ERROR_OPAQUE); compare(referenceSurface, ALLOWABLE_ERROR_OPAQUE);
/* Make current */ /* Make current */
SDL_RenderPresent(renderer); SDL_RenderPresent(renderer);
@ -216,11 +216,11 @@ int render_testPrimitivesBlend(void *arg)
int checkFailCount3; int checkFailCount3;
/* Clear surface. */ /* Clear surface. */
_clearScreen(); clearScreen();
/* Need drawcolor and blendmode or just skip test. */ /* Need drawcolor and blendmode or just skip test. */
SDLTest_AssertCheck(_hasDrawColor(), "_hasDrawColor"); SDLTest_AssertCheck(hasDrawColor(), "_hasDrawColor");
SDLTest_AssertCheck(_hasBlendModes(), "_hasBlendModes"); SDLTest_AssertCheck(hasBlendModes(), "_hasBlendModes");
/* Create some rectangles for each blend mode. */ /* Create some rectangles for each blend mode. */
ret = SDL_SetRenderDrawColor(renderer, 255, 255, 255, 0); ret = SDL_SetRenderDrawColor(renderer, 255, 255, 255, 0);
@ -349,7 +349,7 @@ int render_testPrimitivesBlend(void *arg)
/* See if it's the same. */ /* See if it's the same. */
referenceSurface = SDLTest_ImagePrimitivesBlend(); referenceSurface = SDLTest_ImagePrimitivesBlend();
_compare(referenceSurface, ALLOWABLE_ERROR_BLENDED); compare(referenceSurface, ALLOWABLE_ERROR_BLENDED);
/* Make current */ /* Make current */
SDL_RenderPresent(renderer); SDL_RenderPresent(renderer);
@ -380,14 +380,14 @@ int render_testBlit(void *arg)
int checkFailCount1; int checkFailCount1;
/* Clear surface. */ /* Clear surface. */
_clearScreen(); clearScreen();
/* Need drawcolor or just skip test. */ /* Need drawcolor or just skip test. */
SDLTest_AssertCheck(_hasDrawColor(), "_hasDrawColor)"); SDLTest_AssertCheck(hasDrawColor(), "_hasDrawColor)");
/* Create face surface. */ /* Create face surface. */
tface = _loadTestFace(); tface = loadTestFace();
SDLTest_AssertCheck(tface != NULL, "Verify _loadTestFace() result"); SDLTest_AssertCheck(tface != NULL, "Verify loadTestFace() result");
if (tface == NULL) { if (tface == NULL) {
return TEST_ABORTED; return TEST_ABORTED;
} }
@ -417,7 +417,7 @@ int render_testBlit(void *arg)
/* See if it's the same */ /* See if it's the same */
referenceSurface = SDLTest_ImageBlit(); referenceSurface = SDLTest_ImageBlit();
_compare(referenceSurface, ALLOWABLE_ERROR_OPAQUE); compare(referenceSurface, ALLOWABLE_ERROR_OPAQUE);
/* Make current */ /* Make current */
SDL_RenderPresent(renderer); SDL_RenderPresent(renderer);
@ -451,11 +451,11 @@ int render_testBlitColor(void *arg)
int checkFailCount2; int checkFailCount2;
/* Clear surface. */ /* Clear surface. */
_clearScreen(); clearScreen();
/* Create face surface. */ /* Create face surface. */
tface = _loadTestFace(); tface = loadTestFace();
SDLTest_AssertCheck(tface != NULL, "Verify _loadTestFace() result"); SDLTest_AssertCheck(tface != NULL, "Verify loadTestFace() result");
if (tface == NULL) { if (tface == NULL) {
return TEST_ABORTED; return TEST_ABORTED;
} }
@ -493,7 +493,7 @@ int render_testBlitColor(void *arg)
/* See if it's the same. */ /* See if it's the same. */
referenceSurface = SDLTest_ImageBlitColor(); referenceSurface = SDLTest_ImageBlitColor();
_compare(referenceSurface, ALLOWABLE_ERROR_OPAQUE); compare(referenceSurface, ALLOWABLE_ERROR_OPAQUE);
/* Make current */ /* Make current */
SDL_RenderPresent(renderer); SDL_RenderPresent(renderer);
@ -527,14 +527,14 @@ int render_testBlitAlpha(void *arg)
int checkFailCount2; int checkFailCount2;
/* Clear surface. */ /* Clear surface. */
_clearScreen(); clearScreen();
/* Need alpha or just skip test. */ /* Need alpha or just skip test. */
SDLTest_AssertCheck(_hasTexAlpha(), "_hasTexAlpha"); SDLTest_AssertCheck(hasTexAlpha(), "_hasTexAlpha");
/* Create face surface. */ /* Create face surface. */
tface = _loadTestFace(); tface = loadTestFace();
SDLTest_AssertCheck(tface != NULL, "Verify _loadTestFace() result"); SDLTest_AssertCheck(tface != NULL, "Verify loadTestFace() result");
if (tface == NULL) { if (tface == NULL) {
return TEST_ABORTED; return TEST_ABORTED;
} }
@ -572,7 +572,7 @@ int render_testBlitAlpha(void *arg)
/* See if it's the same. */ /* See if it's the same. */
referenceSurface = SDLTest_ImageBlitAlpha(); referenceSurface = SDLTest_ImageBlitAlpha();
_compare(referenceSurface, ALLOWABLE_ERROR_BLENDED); compare(referenceSurface, ALLOWABLE_ERROR_BLENDED);
/* Make current */ /* Make current */
SDL_RenderPresent(renderer); SDL_RenderPresent(renderer);
@ -595,7 +595,7 @@ int render_testBlitAlpha(void *arg)
* http://wiki.libsdl.org/SDL_RenderTexture * http://wiki.libsdl.org/SDL_RenderTexture
*/ */
static void static void
_testBlitBlendMode(SDL_Texture *tface, int mode) testBlitBlendMode(SDL_Texture *tface, int mode)
{ {
int ret; int ret;
Uint32 tformat; Uint32 tformat;
@ -606,7 +606,7 @@ _testBlitBlendMode(SDL_Texture *tface, int mode)
int checkFailCount2; int checkFailCount2;
/* Clear surface. */ /* Clear surface. */
_clearScreen(); clearScreen();
/* Constant values. */ /* Constant values. */
ret = SDL_QueryTexture(tface, &tformat, &taccess, &tw, &th); ret = SDL_QueryTexture(tface, &tformat, &taccess, &tw, &th);
@ -664,13 +664,13 @@ int render_testBlitBlend(void *arg)
int checkFailCount3; int checkFailCount3;
int checkFailCount4; int checkFailCount4;
SDLTest_AssertCheck(_hasBlendModes(), "_hasBlendModes"); SDLTest_AssertCheck(hasBlendModes(), "_hasBlendModes");
SDLTest_AssertCheck(_hasTexColor(), "_hasTexColor"); SDLTest_AssertCheck(hasTexColor(), "_hasTexColor");
SDLTest_AssertCheck(_hasTexAlpha(), "_hasTexAlpha"); SDLTest_AssertCheck(hasTexAlpha(), "_hasTexAlpha");
/* Create face surface. */ /* Create face surface. */
tface = _loadTestFace(); tface = loadTestFace();
SDLTest_AssertCheck(tface != NULL, "Verify _loadTestFace() result"); SDLTest_AssertCheck(tface != NULL, "Verify loadTestFace() result");
if (tface == NULL) { if (tface == NULL) {
return TEST_ABORTED; return TEST_ABORTED;
} }
@ -688,51 +688,51 @@ int render_testBlitBlend(void *arg)
SDLTest_AssertCheck(ret == 0, "Validate result from SDL_SetTextureAlphaMod, expected: 0, got: %i", ret); SDLTest_AssertCheck(ret == 0, "Validate result from SDL_SetTextureAlphaMod, expected: 0, got: %i", ret);
/* Test None. */ /* Test None. */
_testBlitBlendMode(tface, SDL_BLENDMODE_NONE); testBlitBlendMode(tface, SDL_BLENDMODE_NONE);
referenceSurface = SDLTest_ImageBlitBlendNone(); referenceSurface = SDLTest_ImageBlitBlendNone();
/* Compare, then Present */ /* Compare, then Present */
_compare(referenceSurface, ALLOWABLE_ERROR_OPAQUE); compare(referenceSurface, ALLOWABLE_ERROR_OPAQUE);
SDL_RenderPresent(renderer); SDL_RenderPresent(renderer);
SDL_DestroySurface(referenceSurface); SDL_DestroySurface(referenceSurface);
referenceSurface = NULL; referenceSurface = NULL;
/* Test Blend. */ /* Test Blend. */
_testBlitBlendMode(tface, SDL_BLENDMODE_BLEND); testBlitBlendMode(tface, SDL_BLENDMODE_BLEND);
referenceSurface = SDLTest_ImageBlitBlend(); referenceSurface = SDLTest_ImageBlitBlend();
/* Compare, then Present */ /* Compare, then Present */
_compare(referenceSurface, ALLOWABLE_ERROR_BLENDED); compare(referenceSurface, ALLOWABLE_ERROR_BLENDED);
SDL_RenderPresent(renderer); SDL_RenderPresent(renderer);
SDL_DestroySurface(referenceSurface); SDL_DestroySurface(referenceSurface);
referenceSurface = NULL; referenceSurface = NULL;
/* Test Add. */ /* Test Add. */
_testBlitBlendMode(tface, SDL_BLENDMODE_ADD); testBlitBlendMode(tface, SDL_BLENDMODE_ADD);
referenceSurface = SDLTest_ImageBlitBlendAdd(); referenceSurface = SDLTest_ImageBlitBlendAdd();
/* Compare, then Present */ /* Compare, then Present */
_compare(referenceSurface, ALLOWABLE_ERROR_BLENDED); compare(referenceSurface, ALLOWABLE_ERROR_BLENDED);
SDL_RenderPresent(renderer); SDL_RenderPresent(renderer);
SDL_DestroySurface(referenceSurface); SDL_DestroySurface(referenceSurface);
referenceSurface = NULL; referenceSurface = NULL;
/* Test Mod. */ /* Test Mod. */
_testBlitBlendMode(tface, SDL_BLENDMODE_MOD); testBlitBlendMode(tface, SDL_BLENDMODE_MOD);
referenceSurface = SDLTest_ImageBlitBlendMod(); referenceSurface = SDLTest_ImageBlitBlendMod();
/* Compare, then Present */ /* Compare, then Present */
_compare(referenceSurface, ALLOWABLE_ERROR_BLENDED); compare(referenceSurface, ALLOWABLE_ERROR_BLENDED);
SDL_RenderPresent(renderer); SDL_RenderPresent(renderer);
SDL_DestroySurface(referenceSurface); SDL_DestroySurface(referenceSurface);
referenceSurface = NULL; referenceSurface = NULL;
/* Clear surface. */ /* Clear surface. */
_clearScreen(); clearScreen();
/* Loop blit. */ /* Loop blit. */
checkFailCount1 = 0; checkFailCount1 = 0;
@ -789,7 +789,7 @@ int render_testBlitBlend(void *arg)
/* Check to see if final image matches. */ /* Check to see if final image matches. */
referenceSurface = SDLTest_ImageBlitBlendAll(); referenceSurface = SDLTest_ImageBlitBlendAll();
_compare(referenceSurface, ALLOWABLE_ERROR_BLENDED); compare(referenceSurface, ALLOWABLE_ERROR_BLENDED);
/* Make current */ /* Make current */
SDL_RenderPresent(renderer); SDL_RenderPresent(renderer);
@ -804,7 +804,7 @@ int render_testBlitBlend(void *arg)
* @brief Checks to see if functionality is supported. Helper function. * @brief Checks to see if functionality is supported. Helper function.
*/ */
static int static int
_isSupported(int code) isSupported(int code)
{ {
return code == 0; return code == 0;
} }
@ -817,7 +817,7 @@ _isSupported(int code)
* http://wiki.libsdl.org/SDL_GetRenderDrawColor * http://wiki.libsdl.org/SDL_GetRenderDrawColor
*/ */
static int static int
_hasDrawColor(void) hasDrawColor(void)
{ {
int ret, fail; int ret, fail;
Uint8 r, g, b, a; Uint8 r, g, b, a;
@ -826,17 +826,17 @@ _hasDrawColor(void)
/* Set color. */ /* Set color. */
ret = SDL_SetRenderDrawColor(renderer, 100, 100, 100, 100); ret = SDL_SetRenderDrawColor(renderer, 100, 100, 100, 100);
if (!_isSupported(ret)) { if (!isSupported(ret)) {
fail = 1; fail = 1;
} }
ret = SDL_GetRenderDrawColor(renderer, &r, &g, &b, &a); ret = SDL_GetRenderDrawColor(renderer, &r, &g, &b, &a);
if (!_isSupported(ret)) { if (!isSupported(ret)) {
fail = 1; fail = 1;
} }
/* Restore natural. */ /* Restore natural. */
ret = SDL_SetRenderDrawColor(renderer, 0, 0, 0, SDL_ALPHA_OPAQUE); ret = SDL_SetRenderDrawColor(renderer, 0, 0, 0, SDL_ALPHA_OPAQUE);
if (!_isSupported(ret)) { if (!isSupported(ret)) {
fail = 1; fail = 1;
} }
@ -859,7 +859,7 @@ _hasDrawColor(void)
* http://wiki.libsdl.org/SDL_GetRenderDrawBlendMode * http://wiki.libsdl.org/SDL_GetRenderDrawBlendMode
*/ */
static int static int
_hasBlendModes(void) hasBlendModes(void)
{ {
int fail; int fail;
int ret; int ret;
@ -868,51 +868,51 @@ _hasBlendModes(void)
fail = 0; fail = 0;
ret = SDL_SetRenderDrawBlendMode(renderer, SDL_BLENDMODE_BLEND); ret = SDL_SetRenderDrawBlendMode(renderer, SDL_BLENDMODE_BLEND);
if (!_isSupported(ret)) { if (!isSupported(ret)) {
fail = 1; fail = 1;
} }
ret = SDL_GetRenderDrawBlendMode(renderer, &mode); ret = SDL_GetRenderDrawBlendMode(renderer, &mode);
if (!_isSupported(ret)) { if (!isSupported(ret)) {
fail = 1; fail = 1;
} }
ret = (mode != SDL_BLENDMODE_BLEND); ret = (mode != SDL_BLENDMODE_BLEND);
if (!_isSupported(ret)) { if (!isSupported(ret)) {
fail = 1; fail = 1;
} }
ret = SDL_SetRenderDrawBlendMode(renderer, SDL_BLENDMODE_ADD); ret = SDL_SetRenderDrawBlendMode(renderer, SDL_BLENDMODE_ADD);
if (!_isSupported(ret)) { if (!isSupported(ret)) {
fail = 1; fail = 1;
} }
ret = SDL_GetRenderDrawBlendMode(renderer, &mode); ret = SDL_GetRenderDrawBlendMode(renderer, &mode);
if (!_isSupported(ret)) { if (!isSupported(ret)) {
fail = 1; fail = 1;
} }
ret = (mode != SDL_BLENDMODE_ADD); ret = (mode != SDL_BLENDMODE_ADD);
if (!_isSupported(ret)) { if (!isSupported(ret)) {
fail = 1; fail = 1;
} }
ret = SDL_SetRenderDrawBlendMode(renderer, SDL_BLENDMODE_MOD); ret = SDL_SetRenderDrawBlendMode(renderer, SDL_BLENDMODE_MOD);
if (!_isSupported(ret)) { if (!isSupported(ret)) {
fail = 1; fail = 1;
} }
ret = SDL_GetRenderDrawBlendMode(renderer, &mode); ret = SDL_GetRenderDrawBlendMode(renderer, &mode);
if (!_isSupported(ret)) { if (!isSupported(ret)) {
fail = 1; fail = 1;
} }
ret = (mode != SDL_BLENDMODE_MOD); ret = (mode != SDL_BLENDMODE_MOD);
if (!_isSupported(ret)) { if (!isSupported(ret)) {
fail = 1; fail = 1;
} }
ret = SDL_SetRenderDrawBlendMode(renderer, SDL_BLENDMODE_NONE); ret = SDL_SetRenderDrawBlendMode(renderer, SDL_BLENDMODE_NONE);
if (!_isSupported(ret)) { if (!isSupported(ret)) {
fail = 1; fail = 1;
} }
ret = SDL_GetRenderDrawBlendMode(renderer, &mode); ret = SDL_GetRenderDrawBlendMode(renderer, &mode);
if (!_isSupported(ret)) { if (!isSupported(ret)) {
fail = 1; fail = 1;
} }
ret = (mode != SDL_BLENDMODE_NONE); ret = (mode != SDL_BLENDMODE_NONE);
if (!_isSupported(ret)) { if (!isSupported(ret)) {
fail = 1; fail = 1;
} }
@ -926,7 +926,7 @@ _hasBlendModes(void)
* http://wiki.libsdl.org/SDL_CreateTextureFromSurface * http://wiki.libsdl.org/SDL_CreateTextureFromSurface
*/ */
static SDL_Texture * static SDL_Texture *
_loadTestFace(void) loadTestFace(void)
{ {
SDL_Surface *face; SDL_Surface *face;
SDL_Texture *tface; SDL_Texture *tface;
@ -955,7 +955,7 @@ _loadTestFace(void)
* http://wiki.libsdl.org/SDL_DestroyTexture * http://wiki.libsdl.org/SDL_DestroyTexture
*/ */
static int static int
_hasTexColor(void) hasTexColor(void)
{ {
int fail; int fail;
int ret; int ret;
@ -963,7 +963,7 @@ _hasTexColor(void)
Uint8 r, g, b; Uint8 r, g, b;
/* Get test face. */ /* Get test face. */
tface = _loadTestFace(); tface = loadTestFace();
if (tface == NULL) { if (tface == NULL) {
return 0; return 0;
} }
@ -971,11 +971,11 @@ _hasTexColor(void)
/* See if supported. */ /* See if supported. */
fail = 0; fail = 0;
ret = SDL_SetTextureColorMod(tface, 100, 100, 100); ret = SDL_SetTextureColorMod(tface, 100, 100, 100);
if (!_isSupported(ret)) { if (!isSupported(ret)) {
fail = 1; fail = 1;
} }
ret = SDL_GetTextureColorMod(tface, &r, &g, &b); ret = SDL_GetTextureColorMod(tface, &r, &g, &b);
if (!_isSupported(ret)) { if (!isSupported(ret)) {
fail = 1; fail = 1;
} }
@ -999,7 +999,7 @@ _hasTexColor(void)
* http://wiki.libsdl.org/SDL_DestroyTexture * http://wiki.libsdl.org/SDL_DestroyTexture
*/ */
static int static int
_hasTexAlpha(void) hasTexAlpha(void)
{ {
int fail; int fail;
int ret; int ret;
@ -1007,7 +1007,7 @@ _hasTexAlpha(void)
Uint8 a; Uint8 a;
/* Get test face. */ /* Get test face. */
tface = _loadTestFace(); tface = loadTestFace();
if (tface == NULL) { if (tface == NULL) {
return 0; return 0;
} }
@ -1015,11 +1015,11 @@ _hasTexAlpha(void)
/* See if supported. */ /* See if supported. */
fail = 0; fail = 0;
ret = SDL_SetTextureAlphaMod(tface, 100); ret = SDL_SetTextureAlphaMod(tface, 100);
if (!_isSupported(ret)) { if (!isSupported(ret)) {
fail = 1; fail = 1;
} }
ret = SDL_GetTextureAlphaMod(tface, &a); ret = SDL_GetTextureAlphaMod(tface, &a);
if (!_isSupported(ret)) { if (!isSupported(ret)) {
fail = 1; fail = 1;
} }
@ -1045,7 +1045,7 @@ _hasTexAlpha(void)
* http://wiki.libsdl.org/SDL_DestroySurface * http://wiki.libsdl.org/SDL_DestroySurface
*/ */
static void static void
_compare(SDL_Surface *referenceSurface, int allowable_error) compare(SDL_Surface *referenceSurface, int allowable_error)
{ {
int result; int result;
SDL_Rect rect; SDL_Rect rect;
@ -1090,7 +1090,7 @@ _compare(SDL_Surface *referenceSurface, int allowable_error)
* http://wiki.libsdl.org/SDL_SetRenderDrawBlendMode * http://wiki.libsdl.org/SDL_SetRenderDrawBlendMode
*/ */
static int static int
_clearScreen(void) clearScreen(void)
{ {
int ret; int ret;

View file

@ -95,7 +95,7 @@ void RWopsTearDown(void *arg)
* http://wiki.libsdl.org/SDL_RWseek * http://wiki.libsdl.org/SDL_RWseek
* http://wiki.libsdl.org/SDL_RWread * http://wiki.libsdl.org/SDL_RWread
*/ */
void _testGenericRWopsValidations(SDL_RWops *rw, int write) static void testGenericRWopsValidations(SDL_RWops *rw, int write)
{ {
char buf[sizeof(RWopsHelloWorldTestString)]; char buf[sizeof(RWopsHelloWorldTestString)];
Sint64 i; Sint64 i;
@ -242,7 +242,7 @@ int rwops_testMem(void)
SDLTest_AssertCheck(rw->type == SDL_RWOPS_MEMORY, "Verify RWops type is SDL_RWOPS_MEMORY; expected: %d, got: %" SDL_PRIu32, SDL_RWOPS_MEMORY, rw->type); SDLTest_AssertCheck(rw->type == SDL_RWOPS_MEMORY, "Verify RWops type is SDL_RWOPS_MEMORY; expected: %d, got: %" SDL_PRIu32, SDL_RWOPS_MEMORY, rw->type);
/* Run generic tests */ /* Run generic tests */
_testGenericRWopsValidations(rw, 1); testGenericRWopsValidations(rw, 1);
/* Close */ /* Close */
result = SDL_RWclose(rw); result = SDL_RWclose(rw);
@ -278,7 +278,7 @@ int rwops_testConstMem(void)
SDLTest_AssertCheck(rw->type == SDL_RWOPS_MEMORY_RO, "Verify RWops type is SDL_RWOPS_MEMORY_RO; expected: %d, got: %" SDL_PRIu32, SDL_RWOPS_MEMORY_RO, rw->type); SDLTest_AssertCheck(rw->type == SDL_RWOPS_MEMORY_RO, "Verify RWops type is SDL_RWOPS_MEMORY_RO; expected: %d, got: %" SDL_PRIu32, SDL_RWOPS_MEMORY_RO, rw->type);
/* Run generic tests */ /* Run generic tests */
_testGenericRWopsValidations(rw, 0); testGenericRWopsValidations(rw, 0);
/* Close handle */ /* Close handle */
result = SDL_RWclose(rw); result = SDL_RWclose(rw);
@ -326,7 +326,7 @@ int rwops_testFileRead(void)
#endif #endif
/* Run generic tests */ /* Run generic tests */
_testGenericRWopsValidations(rw, 0); testGenericRWopsValidations(rw, 0);
/* Close handle */ /* Close handle */
result = SDL_RWclose(rw); result = SDL_RWclose(rw);
@ -374,7 +374,7 @@ int rwops_testFileWrite(void)
#endif #endif
/* Run generic tests */ /* Run generic tests */
_testGenericRWopsValidations(rw, 1); testGenericRWopsValidations(rw, 1);
/* Close handle */ /* Close handle */
result = SDL_RWclose(rw); result = SDL_RWclose(rw);

View file

@ -35,7 +35,7 @@ static SDL_Surface *testSurface = NULL;
/* Fixture */ /* Fixture */
/* Create a 32-bit writable surface for blitting tests */ /* Create a 32-bit writable surface for blitting tests */
void _surfaceSetUp(void *arg) static void surfaceSetUp(void *arg)
{ {
int result; int result;
SDL_BlendMode blendMode = SDL_BLENDMODE_NONE; SDL_BlendMode blendMode = SDL_BLENDMODE_NONE;
@ -54,7 +54,7 @@ void _surfaceSetUp(void *arg)
} }
} }
void _surfaceTearDown(void *arg) static void surfaceTearDown(void *arg)
{ {
SDL_DestroySurface(referenceSurface); SDL_DestroySurface(referenceSurface);
referenceSurface = NULL; referenceSurface = NULL;
@ -65,7 +65,7 @@ void _surfaceTearDown(void *arg)
/** /**
* Helper that clears the test surface * Helper that clears the test surface
*/ */
void _clearTestSurface() static void clearTestSurface()
{ {
int ret; int ret;
Uint32 color; Uint32 color;
@ -81,7 +81,7 @@ void _clearTestSurface()
/** /**
* Helper that blits in a specific blend mode, -1 for basic blitting, -2 for color mod, -3 for alpha mod, -4 for mixed blend modes. * Helper that blits in a specific blend mode, -1 for basic blitting, -2 for color mod, -3 for alpha mod, -4 for mixed blend modes.
*/ */
void _testBlitBlendMode(int mode) static void testBlitBlendMode(int mode)
{ {
int ret; int ret;
int i, j, ni, nj; int i, j, ni, nj;
@ -123,7 +123,7 @@ void _testBlitBlendMode(int mode)
SDLTest_AssertCheck(ret == 0, "Verify result from SDL_SetSurfaceColorKey(), expected: 0, got: %i", ret); SDLTest_AssertCheck(ret == 0, "Verify result from SDL_SetSurfaceColorKey(), expected: 0, got: %i", ret);
/* Clear the test surface */ /* Clear the test surface */
_clearTestSurface(); clearTestSurface();
/* Target rect size */ /* Target rect size */
rect.w = face->w; rect.w = face->w;
@ -201,7 +201,7 @@ void _testBlitBlendMode(int mode)
} }
/* Helper to check that a file exists */ /* Helper to check that a file exists */
void _AssertFileExist(const char *filename) static void AssertFileExist(const char *filename)
{ {
struct stat st; struct stat st;
int ret = stat(filename, &st); int ret = stat(filename, &st);
@ -235,7 +235,7 @@ int surface_testSaveLoadBitmap(void *arg)
ret = SDL_SaveBMP(face, sampleFilename); ret = SDL_SaveBMP(face, sampleFilename);
SDLTest_AssertPass("Call to SDL_SaveBMP()"); SDLTest_AssertPass("Call to SDL_SaveBMP()");
SDLTest_AssertCheck(ret == 0, "Verify result from SDL_SaveBMP, expected: 0, got: %i", ret); SDLTest_AssertCheck(ret == 0, "Verify result from SDL_SaveBMP, expected: 0, got: %i", ret);
_AssertFileExist(sampleFilename); AssertFileExist(sampleFilename);
/* Load a surface */ /* Load a surface */
rface = SDL_LoadBMP(sampleFilename); rface = SDL_LoadBMP(sampleFilename);
@ -408,7 +408,7 @@ int surface_testBlit(void *arg)
SDL_Surface *compareSurface; SDL_Surface *compareSurface;
/* Basic blitting */ /* Basic blitting */
_testBlitBlendMode(-1); testBlitBlendMode(-1);
/* Verify result by comparing surfaces */ /* Verify result by comparing surfaces */
compareSurface = SDLTest_ImageBlit(); compareSurface = SDLTest_ImageBlit();
@ -430,7 +430,7 @@ int surface_testBlitColorMod(void *arg)
SDL_Surface *compareSurface; SDL_Surface *compareSurface;
/* Basic blitting with color mod */ /* Basic blitting with color mod */
_testBlitBlendMode(-2); testBlitBlendMode(-2);
/* Verify result by comparing surfaces */ /* Verify result by comparing surfaces */
compareSurface = SDLTest_ImageBlitColor(); compareSurface = SDLTest_ImageBlitColor();
@ -452,7 +452,7 @@ int surface_testBlitAlphaMod(void *arg)
SDL_Surface *compareSurface; SDL_Surface *compareSurface;
/* Basic blitting with alpha mod */ /* Basic blitting with alpha mod */
_testBlitBlendMode(-3); testBlitBlendMode(-3);
/* Verify result by comparing surfaces */ /* Verify result by comparing surfaces */
compareSurface = SDLTest_ImageBlitAlpha(); compareSurface = SDLTest_ImageBlitAlpha();
@ -474,7 +474,7 @@ int surface_testBlitBlendNone(void *arg)
SDL_Surface *compareSurface; SDL_Surface *compareSurface;
/* Basic blitting */ /* Basic blitting */
_testBlitBlendMode(SDL_BLENDMODE_NONE); testBlitBlendMode(SDL_BLENDMODE_NONE);
/* Verify result by comparing surfaces */ /* Verify result by comparing surfaces */
compareSurface = SDLTest_ImageBlitBlendNone(); compareSurface = SDLTest_ImageBlitBlendNone();
@ -496,7 +496,7 @@ int surface_testBlitBlendBlend(void *arg)
SDL_Surface *compareSurface; SDL_Surface *compareSurface;
/* Blend blitting */ /* Blend blitting */
_testBlitBlendMode(SDL_BLENDMODE_BLEND); testBlitBlendMode(SDL_BLENDMODE_BLEND);
/* Verify result by comparing surfaces */ /* Verify result by comparing surfaces */
compareSurface = SDLTest_ImageBlitBlend(); compareSurface = SDLTest_ImageBlitBlend();
@ -518,7 +518,7 @@ int surface_testBlitBlendAdd(void *arg)
SDL_Surface *compareSurface; SDL_Surface *compareSurface;
/* Add blitting */ /* Add blitting */
_testBlitBlendMode(SDL_BLENDMODE_ADD); testBlitBlendMode(SDL_BLENDMODE_ADD);
/* Verify result by comparing surfaces */ /* Verify result by comparing surfaces */
compareSurface = SDLTest_ImageBlitBlendAdd(); compareSurface = SDLTest_ImageBlitBlendAdd();
@ -540,7 +540,7 @@ int surface_testBlitBlendMod(void *arg)
SDL_Surface *compareSurface; SDL_Surface *compareSurface;
/* Mod blitting */ /* Mod blitting */
_testBlitBlendMode(SDL_BLENDMODE_MOD); testBlitBlendMode(SDL_BLENDMODE_MOD);
/* Verify result by comparing surfaces */ /* Verify result by comparing surfaces */
compareSurface = SDLTest_ImageBlitBlendMod(); compareSurface = SDLTest_ImageBlitBlendMod();
@ -563,7 +563,7 @@ int surface_testBlitBlendLoop(void *arg)
SDL_Surface *compareSurface; SDL_Surface *compareSurface;
/* All blitting modes */ /* All blitting modes */
_testBlitBlendMode(-4); testBlitBlendMode(-4);
/* Verify result by comparing surfaces */ /* Verify result by comparing surfaces */
compareSurface = SDLTest_ImageBlitBlendAll(); compareSurface = SDLTest_ImageBlitBlendAll();
@ -813,8 +813,8 @@ static const SDLTest_TestCaseReference *surfaceTests[] = {
/* Surface test suite (global) */ /* Surface test suite (global) */
SDLTest_TestSuiteReference surfaceTestSuite = { SDLTest_TestSuiteReference surfaceTestSuite = {
"Surface", "Surface",
_surfaceSetUp, surfaceSetUp,
surfaceTests, surfaceTests,
_surfaceTearDown surfaceTearDown
}; };

View file

@ -5,17 +5,17 @@
#include <SDL3/SDL_test.h> #include <SDL3/SDL_test.h>
/* Flag indicating if the param should be checked */ /* Flag indicating if the param should be checked */
int _paramCheck = 0; static int g_paramCheck = 0;
/* Userdata value to check */ /* Userdata value to check */
int _paramValue = 0; static int g_paramValue = 0;
/* Flag indicating that the callback was called */ /* Flag indicating that the callback was called */
int _timerCallbackCalled = 0; static int g_timerCallbackCalled = 0;
/* Fixture */ /* Fixture */
void _timerSetUp(void *arg) static void timerSetUp(void *arg)
{ {
/* Start SDL timer subsystem */ /* Start SDL timer subsystem */
int ret = SDL_InitSubSystem(SDL_INIT_TIMER); int ret = SDL_InitSubSystem(SDL_INIT_TIMER);
@ -97,14 +97,14 @@ int timer_delayAndGetTicks(void *arg)
} }
/* Test callback */ /* Test callback */
Uint32 SDLCALL _timerTestCallback(Uint32 interval, void *param) static Uint32 SDLCALL timerTestCallback(Uint32 interval, void *param)
{ {
_timerCallbackCalled = 1; g_timerCallbackCalled = 1;
if (_paramCheck != 0) { if (g_paramCheck != 0) {
SDLTest_AssertCheck(param != NULL, "Check param pointer, expected: non-NULL, got: %s", (param != NULL) ? "non-NULL" : "NULL"); SDLTest_AssertCheck(param != NULL, "Check param pointer, expected: non-NULL, got: %s", (param != NULL) ? "non-NULL" : "NULL");
if (param != NULL) { if (param != NULL) {
SDLTest_AssertCheck(*(int *)param == _paramValue, "Check param value, expected: %i, got: %i", _paramValue, *(int *)param); SDLTest_AssertCheck(*(int *)param == g_paramValue, "Check param value, expected: %i, got: %i", g_paramValue, *(int *)param);
} }
} }
@ -121,11 +121,11 @@ int timer_addRemoveTimer(void *arg)
int param; int param;
/* Reset state */ /* Reset state */
_paramCheck = 0; g_paramCheck = 0;
_timerCallbackCalled = 0; g_timerCallbackCalled = 0;
/* Set timer with a long delay */ /* Set timer with a long delay */
id = SDL_AddTimer(10000, _timerTestCallback, NULL); id = SDL_AddTimer(10000, timerTestCallback, NULL);
SDLTest_AssertPass("Call to SDL_AddTimer(10000,...)"); SDLTest_AssertPass("Call to SDL_AddTimer(10000,...)");
SDLTest_AssertCheck(id > 0, "Check result value, expected: >0, got: %d", id); SDLTest_AssertCheck(id > 0, "Check result value, expected: >0, got: %d", id);
@ -133,7 +133,7 @@ int timer_addRemoveTimer(void *arg)
result = SDL_RemoveTimer(id); result = SDL_RemoveTimer(id);
SDLTest_AssertPass("Call to SDL_RemoveTimer()"); SDLTest_AssertPass("Call to SDL_RemoveTimer()");
SDLTest_AssertCheck(result == SDL_TRUE, "Check result value, expected: %i, got: %i", SDL_TRUE, result); SDLTest_AssertCheck(result == SDL_TRUE, "Check result value, expected: %i, got: %i", SDL_TRUE, result);
SDLTest_AssertCheck(_timerCallbackCalled == 0, "Check callback WAS NOT called, expected: 0, got: %i", _timerCallbackCalled); SDLTest_AssertCheck(g_timerCallbackCalled == 0, "Check callback WAS NOT called, expected: 0, got: %i", g_timerCallbackCalled);
/* Try to remove timer again (should be a NOOP) */ /* Try to remove timer again (should be a NOOP) */
result = SDL_RemoveTimer(id); result = SDL_RemoveTimer(id);
@ -142,12 +142,12 @@ int timer_addRemoveTimer(void *arg)
/* Reset state */ /* Reset state */
param = SDLTest_RandomIntegerInRange(-1024, 1024); param = SDLTest_RandomIntegerInRange(-1024, 1024);
_paramCheck = 1; g_paramCheck = 1;
_paramValue = param; g_paramValue = param;
_timerCallbackCalled = 0; g_timerCallbackCalled = 0;
/* Set timer with a short delay */ /* Set timer with a short delay */
id = SDL_AddTimer(10, _timerTestCallback, (void *)&param); id = SDL_AddTimer(10, timerTestCallback, (void *)&param);
SDLTest_AssertPass("Call to SDL_AddTimer(10, param)"); SDLTest_AssertPass("Call to SDL_AddTimer(10, param)");
SDLTest_AssertCheck(id > 0, "Check result value, expected: >0, got: %d", id); SDLTest_AssertCheck(id > 0, "Check result value, expected: >0, got: %d", id);
@ -159,7 +159,7 @@ int timer_addRemoveTimer(void *arg)
result = SDL_RemoveTimer(id); result = SDL_RemoveTimer(id);
SDLTest_AssertPass("Call to SDL_RemoveTimer()"); SDLTest_AssertPass("Call to SDL_RemoveTimer()");
SDLTest_AssertCheck(result == SDL_FALSE, "Check result value, expected: %i, got: %i", SDL_FALSE, result); SDLTest_AssertCheck(result == SDL_FALSE, "Check result value, expected: %i, got: %i", SDL_FALSE, result);
SDLTest_AssertCheck(_timerCallbackCalled == 1, "Check callback WAS called, expected: 1, got: %i", _timerCallbackCalled); SDLTest_AssertCheck(g_timerCallbackCalled == 1, "Check callback WAS called, expected: 1, got: %i", g_timerCallbackCalled);
return TEST_COMPLETED; return TEST_COMPLETED;
} }
@ -191,7 +191,7 @@ static const SDLTest_TestCaseReference *timerTests[] = {
/* Timer test suite (global) */ /* Timer test suite (global) */
SDLTest_TestSuiteReference timerTestSuite = { SDLTest_TestSuiteReference timerTestSuite = {
"Timer", "Timer",
_timerSetUp, timerSetUp,
timerTests, timerTests,
NULL NULL
}; };

View file

@ -9,7 +9,7 @@
/* /*
* Create a test window * Create a test window
*/ */
SDL_Window *_createVideoSuiteTestWindow(const char *title) static SDL_Window *createVideoSuiteTestWindow(const char *title)
{ {
SDL_Window *window; SDL_Window *window;
int x, y, w, h; int x, y, w, h;
@ -32,7 +32,7 @@ SDL_Window *_createVideoSuiteTestWindow(const char *title)
/* /*
* Destroy test window * Destroy test window
*/ */
void _destroyVideoSuiteTestWindow(SDL_Window *window) static void destroyVideoSuiteTestWindow(SDL_Window *window)
{ {
if (window != NULL) { if (window != NULL) {
SDL_DestroyWindow(window); SDL_DestroyWindow(window);
@ -169,7 +169,7 @@ int video_createWindowVariousPositions(void *arg)
SDLTest_AssertCheck(window != NULL, "Validate that returned window struct is not NULL"); SDLTest_AssertCheck(window != NULL, "Validate that returned window struct is not NULL");
/* Clean up */ /* Clean up */
_destroyVideoSuiteTestWindow(window); destroyVideoSuiteTestWindow(window);
} }
} }
@ -225,7 +225,7 @@ int video_createWindowVariousSizes(void *arg)
SDLTest_AssertCheck(window != NULL, "Validate that returned window struct is not NULL"); SDLTest_AssertCheck(window != NULL, "Validate that returned window struct is not NULL");
/* Clean up */ /* Clean up */
_destroyVideoSuiteTestWindow(window); destroyVideoSuiteTestWindow(window);
} }
} }
@ -305,7 +305,7 @@ int video_createWindowVariousFlags(void *arg)
SDLTest_AssertCheck(window != NULL, "Validate that returned window struct is not NULL"); SDLTest_AssertCheck(window != NULL, "Validate that returned window struct is not NULL");
/* Clean up */ /* Clean up */
_destroyVideoSuiteTestWindow(window); destroyVideoSuiteTestWindow(window);
} }
return TEST_COMPLETED; return TEST_COMPLETED;
@ -325,7 +325,7 @@ int video_getWindowFlags(void *arg)
flags = 0; flags = 0;
/* Call against new test window */ /* Call against new test window */
window = _createVideoSuiteTestWindow(title); window = createVideoSuiteTestWindow(title);
if (window != NULL) { if (window != NULL) {
actualFlags = SDL_GetWindowFlags(window); actualFlags = SDL_GetWindowFlags(window);
SDLTest_AssertPass("Call to SDL_GetWindowFlags()"); SDLTest_AssertPass("Call to SDL_GetWindowFlags()");
@ -333,7 +333,7 @@ int video_getWindowFlags(void *arg)
} }
/* Clean up */ /* Clean up */
_destroyVideoSuiteTestWindow(window); destroyVideoSuiteTestWindow(window);
return TEST_COMPLETED; return TEST_COMPLETED;
} }
@ -506,7 +506,7 @@ int video_getWindowDisplayMode(void *arg)
mode.refresh_rate = -1; mode.refresh_rate = -1;
/* Call against new test window */ /* Call against new test window */
window = _createVideoSuiteTestWindow(title); window = createVideoSuiteTestWindow(title);
if (window != NULL) { if (window != NULL) {
result = SDL_GetWindowDisplayMode(window, &mode); result = SDL_GetWindowDisplayMode(window, &mode);
SDLTest_AssertPass("Call to SDL_GetWindowDisplayMode()"); SDLTest_AssertPass("Call to SDL_GetWindowDisplayMode()");
@ -517,13 +517,13 @@ int video_getWindowDisplayMode(void *arg)
} }
/* Clean up */ /* Clean up */
_destroyVideoSuiteTestWindow(window); destroyVideoSuiteTestWindow(window);
return TEST_COMPLETED; return TEST_COMPLETED;
} }
/* Helper function that checks for an 'Invalid window' error */ /* Helper function that checks for an 'Invalid window' error */
void _checkInvalidWindowError() static void checkInvalidWindowError()
{ {
const char *invalidWindowError = "Invalid window"; const char *invalidWindowError = "Invalid window";
char *lastError; char *lastError;
@ -556,7 +556,7 @@ int video_getWindowDisplayModeNegative(void *arg)
int result; int result;
/* Call against new test window */ /* Call against new test window */
window = _createVideoSuiteTestWindow(title); window = createVideoSuiteTestWindow(title);
if (window != NULL) { if (window != NULL) {
result = SDL_GetWindowDisplayMode(window, NULL); result = SDL_GetWindowDisplayMode(window, NULL);
SDLTest_AssertPass("Call to SDL_GetWindowDisplayMode(...,mode=NULL)"); SDLTest_AssertPass("Call to SDL_GetWindowDisplayMode(...,mode=NULL)");
@ -573,19 +573,19 @@ int video_getWindowDisplayModeNegative(void *arg)
} }
/* Clean up */ /* Clean up */
_destroyVideoSuiteTestWindow(window); destroyVideoSuiteTestWindow(window);
/* Call against invalid window */ /* Call against invalid window */
result = SDL_GetWindowDisplayMode(NULL, &mode); result = SDL_GetWindowDisplayMode(NULL, &mode);
SDLTest_AssertPass("Call to SDL_GetWindowDisplayMode(window=NULL,...)"); SDLTest_AssertPass("Call to SDL_GetWindowDisplayMode(window=NULL,...)");
SDLTest_AssertCheck(result == -1, "Validate result value; expected: -1, got: %d", result); SDLTest_AssertCheck(result == -1, "Validate result value; expected: -1, got: %d", result);
_checkInvalidWindowError(); checkInvalidWindowError();
return TEST_COMPLETED; return TEST_COMPLETED;
} }
/* Helper for setting and checking the window mouse grab state */ /* Helper for setting and checking the window mouse grab state */
void _setAndCheckWindowMouseGrabState(SDL_Window *window, SDL_bool desiredState) static void setAndCheckWindowMouseGrabState(SDL_Window *window, SDL_bool desiredState)
{ {
SDL_bool currentState; SDL_bool currentState;
@ -620,7 +620,7 @@ void _setAndCheckWindowMouseGrabState(SDL_Window *window, SDL_bool desiredState)
} }
/* Helper for setting and checking the window keyboard grab state */ /* Helper for setting and checking the window keyboard grab state */
void _setAndCheckWindowKeyboardGrabState(SDL_Window *window, SDL_bool desiredState) static void setAndCheckWindowKeyboardGrabState(SDL_Window *window, SDL_bool desiredState)
{ {
SDL_bool currentState; SDL_bool currentState;
@ -667,7 +667,7 @@ int video_getSetWindowGrab(void *arg)
SDL_bool originalMouseState, originalKeyboardState; SDL_bool originalMouseState, originalKeyboardState;
/* Call against new test window */ /* Call against new test window */
window = _createVideoSuiteTestWindow(title); window = createVideoSuiteTestWindow(title);
if (window == NULL) { if (window == NULL) {
return TEST_ABORTED; return TEST_ABORTED;
} }
@ -679,49 +679,49 @@ int video_getSetWindowGrab(void *arg)
SDLTest_AssertPass("Call to SDL_GetWindowKeyboardGrab()"); SDLTest_AssertPass("Call to SDL_GetWindowKeyboardGrab()");
/* F */ /* F */
_setAndCheckWindowKeyboardGrabState(window, SDL_FALSE); setAndCheckWindowKeyboardGrabState(window, SDL_FALSE);
_setAndCheckWindowMouseGrabState(window, SDL_FALSE); setAndCheckWindowMouseGrabState(window, SDL_FALSE);
SDLTest_AssertCheck(!SDL_GetWindowGrab(window), SDLTest_AssertCheck(!SDL_GetWindowGrab(window),
"SDL_GetWindowGrab should return SDL_FALSE"); "SDL_GetWindowGrab should return SDL_FALSE");
SDLTest_AssertCheck(SDL_GetGrabbedWindow() == NULL, SDLTest_AssertCheck(SDL_GetGrabbedWindow() == NULL,
"Expected NULL grabbed window"); "Expected NULL grabbed window");
/* F --> F */ /* F --> F */
_setAndCheckWindowMouseGrabState(window, SDL_FALSE); setAndCheckWindowMouseGrabState(window, SDL_FALSE);
_setAndCheckWindowKeyboardGrabState(window, SDL_FALSE); setAndCheckWindowKeyboardGrabState(window, SDL_FALSE);
SDLTest_AssertCheck(SDL_GetGrabbedWindow() == NULL, SDLTest_AssertCheck(SDL_GetGrabbedWindow() == NULL,
"Expected NULL grabbed window"); "Expected NULL grabbed window");
/* F --> T */ /* F --> T */
_setAndCheckWindowMouseGrabState(window, SDL_TRUE); setAndCheckWindowMouseGrabState(window, SDL_TRUE);
_setAndCheckWindowKeyboardGrabState(window, SDL_TRUE); setAndCheckWindowKeyboardGrabState(window, SDL_TRUE);
SDLTest_AssertCheck(SDL_GetWindowGrab(window), SDLTest_AssertCheck(SDL_GetWindowGrab(window),
"SDL_GetWindowGrab() should return SDL_TRUE"); "SDL_GetWindowGrab() should return SDL_TRUE");
/* T --> T */ /* T --> T */
_setAndCheckWindowKeyboardGrabState(window, SDL_TRUE); setAndCheckWindowKeyboardGrabState(window, SDL_TRUE);
_setAndCheckWindowMouseGrabState(window, SDL_TRUE); setAndCheckWindowMouseGrabState(window, SDL_TRUE);
SDLTest_AssertCheck(SDL_GetWindowGrab(window), SDLTest_AssertCheck(SDL_GetWindowGrab(window),
"SDL_GetWindowGrab() should return SDL_TRUE"); "SDL_GetWindowGrab() should return SDL_TRUE");
/* M: T --> F */ /* M: T --> F */
/* K: T --> T */ /* K: T --> T */
_setAndCheckWindowKeyboardGrabState(window, SDL_TRUE); setAndCheckWindowKeyboardGrabState(window, SDL_TRUE);
_setAndCheckWindowMouseGrabState(window, SDL_FALSE); setAndCheckWindowMouseGrabState(window, SDL_FALSE);
SDLTest_AssertCheck(SDL_GetWindowGrab(window), SDLTest_AssertCheck(SDL_GetWindowGrab(window),
"SDL_GetWindowGrab() should return SDL_TRUE"); "SDL_GetWindowGrab() should return SDL_TRUE");
/* M: F --> T */ /* M: F --> T */
/* K: T --> F */ /* K: T --> F */
_setAndCheckWindowMouseGrabState(window, SDL_TRUE); setAndCheckWindowMouseGrabState(window, SDL_TRUE);
_setAndCheckWindowKeyboardGrabState(window, SDL_FALSE); setAndCheckWindowKeyboardGrabState(window, SDL_FALSE);
SDLTest_AssertCheck(SDL_GetWindowGrab(window), SDLTest_AssertCheck(SDL_GetWindowGrab(window),
"SDL_GetWindowGrab() should return SDL_TRUE"); "SDL_GetWindowGrab() should return SDL_TRUE");
/* M: T --> F */ /* M: T --> F */
/* K: F --> F */ /* K: F --> F */
_setAndCheckWindowMouseGrabState(window, SDL_FALSE); setAndCheckWindowMouseGrabState(window, SDL_FALSE);
_setAndCheckWindowKeyboardGrabState(window, SDL_FALSE); setAndCheckWindowKeyboardGrabState(window, SDL_FALSE);
SDLTest_AssertCheck(!SDL_GetWindowGrab(window), SDLTest_AssertCheck(!SDL_GetWindowGrab(window),
"SDL_GetWindowGrab() should return SDL_FALSE"); "SDL_GetWindowGrab() should return SDL_FALSE");
SDLTest_AssertCheck(SDL_GetGrabbedWindow() == NULL, SDLTest_AssertCheck(SDL_GetGrabbedWindow() == NULL,
@ -765,34 +765,34 @@ int video_getSetWindowGrab(void *arg)
/* Negative tests */ /* Negative tests */
SDL_GetWindowGrab(NULL); SDL_GetWindowGrab(NULL);
SDLTest_AssertPass("Call to SDL_GetWindowGrab(window=NULL)"); SDLTest_AssertPass("Call to SDL_GetWindowGrab(window=NULL)");
_checkInvalidWindowError(); checkInvalidWindowError();
SDL_GetWindowKeyboardGrab(NULL); SDL_GetWindowKeyboardGrab(NULL);
SDLTest_AssertPass("Call to SDL_GetWindowKeyboardGrab(window=NULL)"); SDLTest_AssertPass("Call to SDL_GetWindowKeyboardGrab(window=NULL)");
_checkInvalidWindowError(); checkInvalidWindowError();
SDL_SetWindowGrab(NULL, SDL_FALSE); SDL_SetWindowGrab(NULL, SDL_FALSE);
SDLTest_AssertPass("Call to SDL_SetWindowGrab(window=NULL,SDL_FALSE)"); SDLTest_AssertPass("Call to SDL_SetWindowGrab(window=NULL,SDL_FALSE)");
_checkInvalidWindowError(); checkInvalidWindowError();
SDL_SetWindowKeyboardGrab(NULL, SDL_FALSE); SDL_SetWindowKeyboardGrab(NULL, SDL_FALSE);
SDLTest_AssertPass("Call to SDL_SetWindowKeyboardGrab(window=NULL,SDL_FALSE)"); SDLTest_AssertPass("Call to SDL_SetWindowKeyboardGrab(window=NULL,SDL_FALSE)");
_checkInvalidWindowError(); checkInvalidWindowError();
SDL_SetWindowGrab(NULL, SDL_TRUE); SDL_SetWindowGrab(NULL, SDL_TRUE);
SDLTest_AssertPass("Call to SDL_SetWindowGrab(window=NULL,SDL_TRUE)"); SDLTest_AssertPass("Call to SDL_SetWindowGrab(window=NULL,SDL_TRUE)");
_checkInvalidWindowError(); checkInvalidWindowError();
SDL_SetWindowKeyboardGrab(NULL, SDL_TRUE); SDL_SetWindowKeyboardGrab(NULL, SDL_TRUE);
SDLTest_AssertPass("Call to SDL_SetWindowKeyboardGrab(window=NULL,SDL_TRUE)"); SDLTest_AssertPass("Call to SDL_SetWindowKeyboardGrab(window=NULL,SDL_TRUE)");
_checkInvalidWindowError(); checkInvalidWindowError();
/* Restore state */ /* Restore state */
_setAndCheckWindowMouseGrabState(window, originalMouseState); setAndCheckWindowMouseGrabState(window, originalMouseState);
_setAndCheckWindowKeyboardGrabState(window, originalKeyboardState); setAndCheckWindowKeyboardGrabState(window, originalKeyboardState);
/* Clean up */ /* Clean up */
_destroyVideoSuiteTestWindow(window); destroyVideoSuiteTestWindow(window);
return TEST_COMPLETED; return TEST_COMPLETED;
} }
@ -811,7 +811,7 @@ int video_getWindowId(void *arg)
Uint32 id, randomId; Uint32 id, randomId;
/* Call against new test window */ /* Call against new test window */
window = _createVideoSuiteTestWindow(title); window = createVideoSuiteTestWindow(title);
if (window == NULL) { if (window == NULL) {
return TEST_ABORTED; return TEST_ABORTED;
} }
@ -837,7 +837,7 @@ int video_getWindowId(void *arg)
SDLTest_AssertPass("Call to SDL_GetWindowID(UINT32_MAX)"); SDLTest_AssertPass("Call to SDL_GetWindowID(UINT32_MAX)");
/* Clean up */ /* Clean up */
_destroyVideoSuiteTestWindow(window); destroyVideoSuiteTestWindow(window);
/* Get window from ID for closed window */ /* Get window from ID for closed window */
result = SDL_GetWindowFromID(id); result = SDL_GetWindowFromID(id);
@ -849,7 +849,7 @@ int video_getWindowId(void *arg)
SDLTest_AssertPass("Call to SDL_ClearError()"); SDLTest_AssertPass("Call to SDL_ClearError()");
id = SDL_GetWindowID(NULL); id = SDL_GetWindowID(NULL);
SDLTest_AssertPass("Call to SDL_GetWindowID(window=NULL)"); SDLTest_AssertPass("Call to SDL_GetWindowID(window=NULL)");
_checkInvalidWindowError(); checkInvalidWindowError();
return TEST_COMPLETED; return TEST_COMPLETED;
} }
@ -866,7 +866,7 @@ int video_getWindowPixelFormat(void *arg)
Uint32 format; Uint32 format;
/* Call against new test window */ /* Call against new test window */
window = _createVideoSuiteTestWindow(title); window = createVideoSuiteTestWindow(title);
if (window == NULL) { if (window == NULL) {
return TEST_ABORTED; return TEST_ABORTED;
} }
@ -877,14 +877,14 @@ int video_getWindowPixelFormat(void *arg)
SDLTest_AssertCheck(format != SDL_PIXELFORMAT_UNKNOWN, "Verify that returned format is valid; expected: != %d, got: %" SDL_PRIu32, SDL_PIXELFORMAT_UNKNOWN, format); SDLTest_AssertCheck(format != SDL_PIXELFORMAT_UNKNOWN, "Verify that returned format is valid; expected: != %d, got: %" SDL_PRIu32, SDL_PIXELFORMAT_UNKNOWN, format);
/* Clean up */ /* Clean up */
_destroyVideoSuiteTestWindow(window); destroyVideoSuiteTestWindow(window);
/* Negative test */ /* Negative test */
SDL_ClearError(); SDL_ClearError();
SDLTest_AssertPass("Call to SDL_ClearError()"); SDLTest_AssertPass("Call to SDL_ClearError()");
format = SDL_GetWindowPixelFormat(NULL); format = SDL_GetWindowPixelFormat(NULL);
SDLTest_AssertPass("Call to SDL_GetWindowPixelFormat(window=NULL)"); SDLTest_AssertPass("Call to SDL_GetWindowPixelFormat(window=NULL)");
_checkInvalidWindowError(); checkInvalidWindowError();
return TEST_COMPLETED; return TEST_COMPLETED;
} }
@ -905,7 +905,7 @@ int video_getSetWindowPosition(void *arg)
int desiredX, desiredY; int desiredX, desiredY;
/* Call against new test window */ /* Call against new test window */
window = _createVideoSuiteTestWindow(title); window = createVideoSuiteTestWindow(title);
if (window == NULL) { if (window == NULL) {
return TEST_ABORTED; return TEST_ABORTED;
} }
@ -983,7 +983,7 @@ int video_getSetWindowPosition(void *arg)
SDLTest_AssertPass("Call to SDL_GetWindowPosition(&x=NULL,&y=NULL)"); SDLTest_AssertPass("Call to SDL_GetWindowPosition(&x=NULL,&y=NULL)");
/* Clean up */ /* Clean up */
_destroyVideoSuiteTestWindow(window); destroyVideoSuiteTestWindow(window);
/* Set some 'magic' value for later check that nothing was changed */ /* Set some 'magic' value for later check that nothing was changed */
referenceX = SDLTest_RandomSint32(); referenceX = SDLTest_RandomSint32();
@ -1003,21 +1003,21 @@ int video_getSetWindowPosition(void *arg)
"Verify that content of X and Y pointers has not been modified; expected: %d,%d; got: %d,%d", "Verify that content of X and Y pointers has not been modified; expected: %d,%d; got: %d,%d",
referenceX, referenceY, referenceX, referenceY,
currentX, currentY); currentX, currentY);
_checkInvalidWindowError(); checkInvalidWindowError();
SDL_GetWindowPosition(NULL, NULL, NULL); SDL_GetWindowPosition(NULL, NULL, NULL);
SDLTest_AssertPass("Call to SDL_GetWindowPosition(NULL, NULL, NULL)"); SDLTest_AssertPass("Call to SDL_GetWindowPosition(NULL, NULL, NULL)");
_checkInvalidWindowError(); checkInvalidWindowError();
SDL_SetWindowPosition(NULL, desiredX, desiredY); SDL_SetWindowPosition(NULL, desiredX, desiredY);
SDLTest_AssertPass("Call to SDL_SetWindowPosition(window=NULL)"); SDLTest_AssertPass("Call to SDL_SetWindowPosition(window=NULL)");
_checkInvalidWindowError(); checkInvalidWindowError();
return TEST_COMPLETED; return TEST_COMPLETED;
} }
/* Helper function that checks for an 'Invalid parameter' error */ /* Helper function that checks for an 'Invalid parameter' error */
void _checkInvalidParameterError() static void checkInvalidParameterError()
{ {
const char *invalidParameterError = "Parameter"; const char *invalidParameterError = "Parameter";
char *lastError; char *lastError;
@ -1062,7 +1062,7 @@ int video_getSetWindowSize(void *arg)
} }
/* Call against new test window */ /* Call against new test window */
window = _createVideoSuiteTestWindow(title); window = createVideoSuiteTestWindow(title);
if (window == NULL) { if (window == NULL) {
return TEST_ABORTED; return TEST_ABORTED;
} }
@ -1165,13 +1165,13 @@ int video_getSetWindowSize(void *arg)
if (desiredW <= 0 || desiredH <= 0) { if (desiredW <= 0 || desiredH <= 0) {
SDL_SetWindowSize(window, desiredW, desiredH); SDL_SetWindowSize(window, desiredW, desiredH);
SDLTest_AssertPass("Call to SDL_SetWindowSize(...,%d,%d)", desiredW, desiredH); SDLTest_AssertPass("Call to SDL_SetWindowSize(...,%d,%d)", desiredW, desiredH);
_checkInvalidParameterError(); checkInvalidParameterError();
} }
} }
} }
/* Clean up */ /* Clean up */
_destroyVideoSuiteTestWindow(window); destroyVideoSuiteTestWindow(window);
/* Set some 'magic' value for later check that nothing was changed */ /* Set some 'magic' value for later check that nothing was changed */
referenceW = SDLTest_RandomSint32(); referenceW = SDLTest_RandomSint32();
@ -1191,15 +1191,15 @@ int video_getSetWindowSize(void *arg)
"Verify that content of W and H pointers has not been modified; expected: %d,%d; got: %d,%d", "Verify that content of W and H pointers has not been modified; expected: %d,%d; got: %d,%d",
referenceW, referenceH, referenceW, referenceH,
currentW, currentH); currentW, currentH);
_checkInvalidWindowError(); checkInvalidWindowError();
SDL_GetWindowSize(NULL, NULL, NULL); SDL_GetWindowSize(NULL, NULL, NULL);
SDLTest_AssertPass("Call to SDL_GetWindowSize(NULL, NULL, NULL)"); SDLTest_AssertPass("Call to SDL_GetWindowSize(NULL, NULL, NULL)");
_checkInvalidWindowError(); checkInvalidWindowError();
SDL_SetWindowSize(NULL, desiredW, desiredH); SDL_SetWindowSize(NULL, desiredW, desiredH);
SDLTest_AssertPass("Call to SDL_SetWindowSize(window=NULL)"); SDLTest_AssertPass("Call to SDL_SetWindowSize(window=NULL)");
_checkInvalidWindowError(); checkInvalidWindowError();
return TEST_COMPLETED; return TEST_COMPLETED;
} }
@ -1229,7 +1229,7 @@ int video_getSetWindowMinimumSize(void *arg)
} }
/* Call against new test window */ /* Call against new test window */
window = _createVideoSuiteTestWindow(title); window = createVideoSuiteTestWindow(title);
if (window == NULL) { if (window == NULL) {
return TEST_ABORTED; return TEST_ABORTED;
} }
@ -1308,13 +1308,13 @@ int video_getSetWindowMinimumSize(void *arg)
if (desiredW <= 0 || desiredH <= 0) { if (desiredW <= 0 || desiredH <= 0) {
SDL_SetWindowMinimumSize(window, desiredW, desiredH); SDL_SetWindowMinimumSize(window, desiredW, desiredH);
SDLTest_AssertPass("Call to SDL_SetWindowMinimumSize(...,%d,%d)", desiredW, desiredH); SDLTest_AssertPass("Call to SDL_SetWindowMinimumSize(...,%d,%d)", desiredW, desiredH);
_checkInvalidParameterError(); checkInvalidParameterError();
} }
} }
} }
/* Clean up */ /* Clean up */
_destroyVideoSuiteTestWindow(window); destroyVideoSuiteTestWindow(window);
/* Set some 'magic' value for later check that nothing was changed */ /* Set some 'magic' value for later check that nothing was changed */
referenceW = SDLTest_RandomSint32(); referenceW = SDLTest_RandomSint32();
@ -1334,15 +1334,15 @@ int video_getSetWindowMinimumSize(void *arg)
"Verify that content of W and H pointers has not been modified; expected: %d,%d; got: %d,%d", "Verify that content of W and H pointers has not been modified; expected: %d,%d; got: %d,%d",
referenceW, referenceH, referenceW, referenceH,
currentW, currentH); currentW, currentH);
_checkInvalidWindowError(); checkInvalidWindowError();
SDL_GetWindowMinimumSize(NULL, NULL, NULL); SDL_GetWindowMinimumSize(NULL, NULL, NULL);
SDLTest_AssertPass("Call to SDL_GetWindowMinimumSize(NULL, NULL, NULL)"); SDLTest_AssertPass("Call to SDL_GetWindowMinimumSize(NULL, NULL, NULL)");
_checkInvalidWindowError(); checkInvalidWindowError();
SDL_SetWindowMinimumSize(NULL, desiredW, desiredH); SDL_SetWindowMinimumSize(NULL, desiredW, desiredH);
SDLTest_AssertPass("Call to SDL_SetWindowMinimumSize(window=NULL)"); SDLTest_AssertPass("Call to SDL_SetWindowMinimumSize(window=NULL)");
_checkInvalidWindowError(); checkInvalidWindowError();
return TEST_COMPLETED; return TEST_COMPLETED;
} }
@ -1371,7 +1371,7 @@ int video_getSetWindowMaximumSize(void *arg)
} }
/* Call against new test window */ /* Call against new test window */
window = _createVideoSuiteTestWindow(title); window = createVideoSuiteTestWindow(title);
if (window == NULL) { if (window == NULL) {
return TEST_ABORTED; return TEST_ABORTED;
} }
@ -1446,13 +1446,13 @@ int video_getSetWindowMaximumSize(void *arg)
if (desiredW <= 0 || desiredH <= 0) { if (desiredW <= 0 || desiredH <= 0) {
SDL_SetWindowMaximumSize(window, desiredW, desiredH); SDL_SetWindowMaximumSize(window, desiredW, desiredH);
SDLTest_AssertPass("Call to SDL_SetWindowMaximumSize(...,%d,%d)", desiredW, desiredH); SDLTest_AssertPass("Call to SDL_SetWindowMaximumSize(...,%d,%d)", desiredW, desiredH);
_checkInvalidParameterError(); checkInvalidParameterError();
} }
} }
} }
/* Clean up */ /* Clean up */
_destroyVideoSuiteTestWindow(window); destroyVideoSuiteTestWindow(window);
/* Set some 'magic' value for later check that nothing was changed */ /* Set some 'magic' value for later check that nothing was changed */
referenceW = SDLTest_RandomSint32(); referenceW = SDLTest_RandomSint32();
@ -1472,15 +1472,15 @@ int video_getSetWindowMaximumSize(void *arg)
"Verify that content of W and H pointers has not been modified; expected: %d,%d; got: %d,%d", "Verify that content of W and H pointers has not been modified; expected: %d,%d; got: %d,%d",
referenceW, referenceH, referenceW, referenceH,
currentW, currentH); currentW, currentH);
_checkInvalidWindowError(); checkInvalidWindowError();
SDL_GetWindowMaximumSize(NULL, NULL, NULL); SDL_GetWindowMaximumSize(NULL, NULL, NULL);
SDLTest_AssertPass("Call to SDL_GetWindowMaximumSize(NULL, NULL, NULL)"); SDLTest_AssertPass("Call to SDL_GetWindowMaximumSize(NULL, NULL, NULL)");
_checkInvalidWindowError(); checkInvalidWindowError();
SDL_SetWindowMaximumSize(NULL, desiredW, desiredH); SDL_SetWindowMaximumSize(NULL, desiredW, desiredH);
SDLTest_AssertPass("Call to SDL_SetWindowMaximumSize(window=NULL)"); SDLTest_AssertPass("Call to SDL_SetWindowMaximumSize(window=NULL)");
_checkInvalidWindowError(); checkInvalidWindowError();
return TEST_COMPLETED; return TEST_COMPLETED;
} }
@ -1509,7 +1509,7 @@ int video_getSetWindowData(void *arg)
int iteration; int iteration;
/* Call against new test window */ /* Call against new test window */
window = _createVideoSuiteTestWindow(title); window = createVideoSuiteTestWindow(title);
if (window == NULL) { if (window == NULL) {
return TEST_ABORTED; return TEST_ABORTED;
} }
@ -1645,52 +1645,52 @@ int video_getSetWindowData(void *arg)
result = (char *)SDL_SetWindowData(NULL, name, userdata); result = (char *)SDL_SetWindowData(NULL, name, userdata);
SDLTest_AssertPass("Call to SDL_SetWindowData(window=NULL)"); SDLTest_AssertPass("Call to SDL_SetWindowData(window=NULL)");
SDLTest_AssertCheck(result == NULL, "Validate that result is NULL"); SDLTest_AssertCheck(result == NULL, "Validate that result is NULL");
_checkInvalidWindowError(); checkInvalidWindowError();
/* Set data with NULL name, valid userdata */ /* Set data with NULL name, valid userdata */
result = (char *)SDL_SetWindowData(window, NULL, userdata); result = (char *)SDL_SetWindowData(window, NULL, userdata);
SDLTest_AssertPass("Call to SDL_SetWindowData(name=NULL)"); SDLTest_AssertPass("Call to SDL_SetWindowData(name=NULL)");
SDLTest_AssertCheck(result == NULL, "Validate that result is NULL"); SDLTest_AssertCheck(result == NULL, "Validate that result is NULL");
_checkInvalidParameterError(); checkInvalidParameterError();
/* Set data with empty name, valid userdata */ /* Set data with empty name, valid userdata */
result = (char *)SDL_SetWindowData(window, "", userdata); result = (char *)SDL_SetWindowData(window, "", userdata);
SDLTest_AssertPass("Call to SDL_SetWindowData(name='')"); SDLTest_AssertPass("Call to SDL_SetWindowData(name='')");
SDLTest_AssertCheck(result == NULL, "Validate that result is NULL"); SDLTest_AssertCheck(result == NULL, "Validate that result is NULL");
_checkInvalidParameterError(); checkInvalidParameterError();
/* Set data with NULL name, NULL userdata */ /* Set data with NULL name, NULL userdata */
result = (char *)SDL_SetWindowData(window, NULL, NULL); result = (char *)SDL_SetWindowData(window, NULL, NULL);
SDLTest_AssertPass("Call to SDL_SetWindowData(name=NULL,userdata=NULL)"); SDLTest_AssertPass("Call to SDL_SetWindowData(name=NULL,userdata=NULL)");
SDLTest_AssertCheck(result == NULL, "Validate that result is NULL"); SDLTest_AssertCheck(result == NULL, "Validate that result is NULL");
_checkInvalidParameterError(); checkInvalidParameterError();
/* Set data with empty name, NULL userdata */ /* Set data with empty name, NULL userdata */
result = (char *)SDL_SetWindowData(window, "", NULL); result = (char *)SDL_SetWindowData(window, "", NULL);
SDLTest_AssertPass("Call to SDL_SetWindowData(name='',userdata=NULL)"); SDLTest_AssertPass("Call to SDL_SetWindowData(name='',userdata=NULL)");
SDLTest_AssertCheck(result == NULL, "Validate that result is NULL"); SDLTest_AssertCheck(result == NULL, "Validate that result is NULL");
_checkInvalidParameterError(); checkInvalidParameterError();
/* Get with invalid window */ /* Get with invalid window */
result = (char *)SDL_GetWindowData(NULL, name); result = (char *)SDL_GetWindowData(NULL, name);
SDLTest_AssertPass("Call to SDL_GetWindowData(window=NULL)"); SDLTest_AssertPass("Call to SDL_GetWindowData(window=NULL)");
SDLTest_AssertCheck(result == NULL, "Validate that result is NULL"); SDLTest_AssertCheck(result == NULL, "Validate that result is NULL");
_checkInvalidWindowError(); checkInvalidWindowError();
/* Get data with NULL name */ /* Get data with NULL name */
result = (char *)SDL_GetWindowData(window, NULL); result = (char *)SDL_GetWindowData(window, NULL);
SDLTest_AssertPass("Call to SDL_GetWindowData(name=NULL)"); SDLTest_AssertPass("Call to SDL_GetWindowData(name=NULL)");
SDLTest_AssertCheck(result == NULL, "Validate that result is NULL"); SDLTest_AssertCheck(result == NULL, "Validate that result is NULL");
_checkInvalidParameterError(); checkInvalidParameterError();
/* Get data with empty name */ /* Get data with empty name */
result = (char *)SDL_GetWindowData(window, ""); result = (char *)SDL_GetWindowData(window, "");
SDLTest_AssertPass("Call to SDL_GetWindowData(name='')"); SDLTest_AssertPass("Call to SDL_GetWindowData(name='')");
SDLTest_AssertCheck(result == NULL, "Validate that result is NULL"); SDLTest_AssertCheck(result == NULL, "Validate that result is NULL");
_checkInvalidParameterError(); checkInvalidParameterError();
/* Clean up */ /* Clean up */
_destroyVideoSuiteTestWindow(window); destroyVideoSuiteTestWindow(window);
cleanup: cleanup:
SDL_free(referenceUserdata); SDL_free(referenceUserdata);
@ -1819,7 +1819,7 @@ int video_setWindowCenteredOnDisplay(void *arg)
SDLTest_AssertCheck(currentY == expectedY, "Validate y (current: %d, expected: %d)", currentY, expectedY); SDLTest_AssertCheck(currentY == expectedY, "Validate y (current: %d, expected: %d)", currentY, expectedY);
/* Clean up */ /* Clean up */
_destroyVideoSuiteTestWindow(window); destroyVideoSuiteTestWindow(window);
} }
} }

View file

@ -262,7 +262,7 @@ link_program(struct shader_data *data)
/* 3D data. Vertex range -0.5..0.5 in all axes. /* 3D data. Vertex range -0.5..0.5 in all axes.
* Z -0.5 is near, 0.5 is far. */ * Z -0.5 is near, 0.5 is far. */
const float _vertices[] = { const float g_vertices[] = {
/* Front face. */ /* Front face. */
/* Bottom left */ /* Bottom left */
-0.5, -0.5,
@ -391,7 +391,7 @@ const float _vertices[] = {
0.5, 0.5,
}; };
const float _colors[] = { const float g_colors[] = {
/* Front face */ /* Front face */
/* Bottom left */ /* Bottom left */
1.0, 0.0, 0.0, /* red */ 1.0, 0.0, 0.0, /* red */
@ -448,7 +448,7 @@ const float _colors[] = {
1.0, 0.0, 1.0, /* magenta */ 1.0, 0.0, 1.0, /* magenta */
}; };
const char *_shader_vert_src = const char *g_shader_vert_src =
" attribute vec4 av4position; " " attribute vec4 av4position; "
" attribute vec3 av3color; " " attribute vec3 av3color; "
" uniform mat4 mvp; " " uniform mat4 mvp; "
@ -458,7 +458,7 @@ const char *_shader_vert_src =
" gl_Position = mvp * av4position; " " gl_Position = mvp * av4position; "
" } "; " } ";
const char *_shader_frag_src = const char *g_shader_frag_src =
" precision lowp float; " " precision lowp float; "
" varying vec3 vv3color; " " varying vec3 vv3color; "
" void main() { " " void main() { "
@ -801,8 +801,8 @@ int main(int argc, char *argv[])
data->angle_z = 0; data->angle_z = 0;
/* Shader Initialization */ /* Shader Initialization */
process_shader(&data->shader_vert, _shader_vert_src, GL_VERTEX_SHADER); process_shader(&data->shader_vert, g_shader_vert_src, GL_VERTEX_SHADER);
process_shader(&data->shader_frag, _shader_frag_src, GL_FRAGMENT_SHADER); process_shader(&data->shader_frag, g_shader_frag_src, GL_FRAGMENT_SHADER);
/* Create shader_program (ready to attach shaders) */ /* Create shader_program (ready to attach shaders) */
data->shader_program = GL_CHECK(ctx.glCreateProgram()); data->shader_program = GL_CHECK(ctx.glCreateProgram());
@ -827,13 +827,13 @@ int main(int argc, char *argv[])
GL_CHECK(ctx.glGenBuffers(1, &data->position_buffer)); GL_CHECK(ctx.glGenBuffers(1, &data->position_buffer));
GL_CHECK(ctx.glBindBuffer(GL_ARRAY_BUFFER, data->position_buffer)); GL_CHECK(ctx.glBindBuffer(GL_ARRAY_BUFFER, data->position_buffer));
GL_CHECK(ctx.glBufferData(GL_ARRAY_BUFFER, sizeof(_vertices), _vertices, GL_STATIC_DRAW)); GL_CHECK(ctx.glBufferData(GL_ARRAY_BUFFER, sizeof(g_vertices), g_vertices, GL_STATIC_DRAW));
GL_CHECK(ctx.glVertexAttribPointer(data->attr_position, 3, GL_FLOAT, GL_FALSE, 0, 0)); GL_CHECK(ctx.glVertexAttribPointer(data->attr_position, 3, GL_FLOAT, GL_FALSE, 0, 0));
GL_CHECK(ctx.glBindBuffer(GL_ARRAY_BUFFER, 0)); GL_CHECK(ctx.glBindBuffer(GL_ARRAY_BUFFER, 0));
GL_CHECK(ctx.glGenBuffers(1, &data->color_buffer)); GL_CHECK(ctx.glGenBuffers(1, &data->color_buffer));
GL_CHECK(ctx.glBindBuffer(GL_ARRAY_BUFFER, data->color_buffer)); GL_CHECK(ctx.glBindBuffer(GL_ARRAY_BUFFER, data->color_buffer));
GL_CHECK(ctx.glBufferData(GL_ARRAY_BUFFER, sizeof(_colors), _colors, GL_STATIC_DRAW)); GL_CHECK(ctx.glBufferData(GL_ARRAY_BUFFER, sizeof(g_colors), g_colors, GL_STATIC_DRAW));
GL_CHECK(ctx.glVertexAttribPointer(data->attr_color, 3, GL_FLOAT, GL_FALSE, 0, 0)); GL_CHECK(ctx.glVertexAttribPointer(data->attr_color, 3, GL_FLOAT, GL_FALSE, 0, 0));
GL_CHECK(ctx.glBindBuffer(GL_ARRAY_BUFFER, 0)); GL_CHECK(ctx.glBindBuffer(GL_ARRAY_BUFFER, 0));