mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-06-02 09:57:40 +00:00
Update for SDL3 coding style (#6717)
I updated .clang-format and ran clang-format 14 over the src and test directories to standardize the code base. In general I let clang-format have it's way, and added markup to prevent formatting of code that would break or be completely unreadable if formatted. The script I ran for the src directory is added as build-scripts/clang-format-src.sh This fixes: #6592 #6593 #6594
This commit is contained in:
parent
14b902faca
commit
5750bcb174
781 changed files with 51659 additions and 55763 deletions
|
@ -16,7 +16,7 @@
|
|||
* compare them directly, so we push it through a function to keep the
|
||||
* compiler quiet. --ryan.
|
||||
*/
|
||||
static int _compareSizeOfType( size_t sizeoftype, size_t hardcodetype )
|
||||
static int _compareSizeOfType(size_t sizeoftype, size_t hardcodetype)
|
||||
{
|
||||
return sizeoftype != hardcodetype;
|
||||
}
|
||||
|
@ -28,21 +28,21 @@ static int _compareSizeOfType( size_t sizeoftype, size_t hardcodetype )
|
|||
*/
|
||||
int platform_testTypes(void *arg)
|
||||
{
|
||||
int ret;
|
||||
int ret;
|
||||
|
||||
ret = _compareSizeOfType( sizeof(Uint8), 1 );
|
||||
SDLTest_AssertCheck( ret == 0, "sizeof(Uint8) = %lu, expected 1", (unsigned long)sizeof(Uint8) );
|
||||
ret = _compareSizeOfType(sizeof(Uint8), 1);
|
||||
SDLTest_AssertCheck(ret == 0, "sizeof(Uint8) = %lu, expected 1", (unsigned long)sizeof(Uint8));
|
||||
|
||||
ret = _compareSizeOfType( sizeof(Uint16), 2 );
|
||||
SDLTest_AssertCheck( ret == 0, "sizeof(Uint16) = %lu, expected 2", (unsigned long)sizeof(Uint16) );
|
||||
ret = _compareSizeOfType(sizeof(Uint16), 2);
|
||||
SDLTest_AssertCheck(ret == 0, "sizeof(Uint16) = %lu, expected 2", (unsigned long)sizeof(Uint16));
|
||||
|
||||
ret = _compareSizeOfType( sizeof(Uint32), 4 );
|
||||
SDLTest_AssertCheck( ret == 0, "sizeof(Uint32) = %lu, expected 4", (unsigned long)sizeof(Uint32) );
|
||||
ret = _compareSizeOfType(sizeof(Uint32), 4);
|
||||
SDLTest_AssertCheck(ret == 0, "sizeof(Uint32) = %lu, expected 4", (unsigned long)sizeof(Uint32));
|
||||
|
||||
ret = _compareSizeOfType( sizeof(Uint64), 8 );
|
||||
SDLTest_AssertCheck( ret == 0, "sizeof(Uint64) = %lu, expected 8", (unsigned long)sizeof(Uint64) );
|
||||
ret = _compareSizeOfType(sizeof(Uint64), 8);
|
||||
SDLTest_AssertCheck(ret == 0, "sizeof(Uint64) = %lu, expected 8", (unsigned long)sizeof(Uint64));
|
||||
|
||||
return TEST_COMPLETED;
|
||||
return TEST_COMPLETED;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -58,9 +58,10 @@ int platform_testEndianessAndSwap(void *arg)
|
|||
Uint32 value32 = 0xEFBEADDE;
|
||||
Uint32 swapped32 = 0xDEADBEEF;
|
||||
|
||||
union {
|
||||
double d;
|
||||
Uint32 ui32[2];
|
||||
union
|
||||
{
|
||||
double d;
|
||||
Uint32 ui32[2];
|
||||
} value_double;
|
||||
|
||||
Uint64 value64, swapped64;
|
||||
|
@ -72,17 +73,17 @@ int platform_testEndianessAndSwap(void *arg)
|
|||
swapped64 |= 0xDEADBEEF;
|
||||
value_double.d = 3.141593;
|
||||
|
||||
if ((*((char *) &value) >> 4) == 0x1) {
|
||||
if ((*((char *)&value) >> 4) == 0x1) {
|
||||
real_byteorder = SDL_BIG_ENDIAN;
|
||||
} else {
|
||||
real_byteorder = SDL_LIL_ENDIAN;
|
||||
}
|
||||
|
||||
/* Test endianness. */
|
||||
SDLTest_AssertCheck( real_byteorder == SDL_BYTEORDER,
|
||||
"Machine detected as %s endian, appears to be %s endian.",
|
||||
(SDL_BYTEORDER == SDL_LIL_ENDIAN) ? "little" : "big",
|
||||
(real_byteorder == SDL_LIL_ENDIAN) ? "little" : "big" );
|
||||
SDLTest_AssertCheck(real_byteorder == SDL_BYTEORDER,
|
||||
"Machine detected as %s endian, appears to be %s endian.",
|
||||
(SDL_BYTEORDER == SDL_LIL_ENDIAN) ? "little" : "big",
|
||||
(real_byteorder == SDL_LIL_ENDIAN) ? "little" : "big");
|
||||
|
||||
if (value_double.ui32[0] == 0x82c2bd7f && value_double.ui32[1] == 0x400921fb) {
|
||||
real_floatwordorder = SDL_LIL_ENDIAN;
|
||||
|
@ -91,27 +92,28 @@ int platform_testEndianessAndSwap(void *arg)
|
|||
}
|
||||
|
||||
/* Test endianness. */
|
||||
SDLTest_AssertCheck( real_floatwordorder == SDL_FLOATWORDORDER,
|
||||
"Machine detected as having %s endian float word order, appears to be %s endian.",
|
||||
(SDL_FLOATWORDORDER == SDL_LIL_ENDIAN) ? "little" : "big",
|
||||
(real_floatwordorder == SDL_LIL_ENDIAN) ? "little" : (real_floatwordorder == SDL_BIG_ENDIAN) ? "big" : "unknown" );
|
||||
SDLTest_AssertCheck(real_floatwordorder == SDL_FLOATWORDORDER,
|
||||
"Machine detected as having %s endian float word order, appears to be %s endian.",
|
||||
(SDL_FLOATWORDORDER == SDL_LIL_ENDIAN) ? "little" : "big",
|
||||
(real_floatwordorder == SDL_LIL_ENDIAN) ? "little" : (real_floatwordorder == SDL_BIG_ENDIAN) ? "big"
|
||||
: "unknown");
|
||||
|
||||
/* Test 16 swap. */
|
||||
SDLTest_AssertCheck( SDL_Swap16(value16) == swapped16,
|
||||
"SDL_Swap16(): 16 bit swapped: 0x%X => 0x%X",
|
||||
value16, SDL_Swap16(value16) );
|
||||
SDLTest_AssertCheck(SDL_Swap16(value16) == swapped16,
|
||||
"SDL_Swap16(): 16 bit swapped: 0x%X => 0x%X",
|
||||
value16, SDL_Swap16(value16));
|
||||
|
||||
/* Test 32 swap. */
|
||||
SDLTest_AssertCheck( SDL_Swap32(value32) == swapped32,
|
||||
"SDL_Swap32(): 32 bit swapped: 0x%" SDL_PRIX32 " => 0x%" SDL_PRIX32,
|
||||
value32, SDL_Swap32(value32) );
|
||||
SDLTest_AssertCheck(SDL_Swap32(value32) == swapped32,
|
||||
"SDL_Swap32(): 32 bit swapped: 0x%" SDL_PRIX32 " => 0x%" SDL_PRIX32,
|
||||
value32, SDL_Swap32(value32));
|
||||
|
||||
/* Test 64 swap. */
|
||||
SDLTest_AssertCheck( SDL_Swap64(value64) == swapped64,
|
||||
"SDL_Swap64(): 64 bit swapped: 0x%"SDL_PRIX64" => 0x%"SDL_PRIX64,
|
||||
value64, SDL_Swap64(value64) );
|
||||
SDLTest_AssertCheck(SDL_Swap64(value64) == swapped64,
|
||||
"SDL_Swap64(): 64 bit swapped: 0x%" SDL_PRIX64 " => 0x%" SDL_PRIX64,
|
||||
value64, SDL_Swap64(value64));
|
||||
|
||||
return TEST_COMPLETED;
|
||||
return TEST_COMPLETED;
|
||||
}
|
||||
|
||||
/* !
|
||||
|
@ -122,41 +124,41 @@ int platform_testEndianessAndSwap(void *arg)
|
|||
* http://wiki.libsdl.org/SDL_GetCPUCacheLineSize
|
||||
* http://wiki.libsdl.org/SDL_GetRevision
|
||||
*/
|
||||
int platform_testGetFunctions (void *arg)
|
||||
int platform_testGetFunctions(void *arg)
|
||||
{
|
||||
char *platform;
|
||||
char *revision;
|
||||
int ret;
|
||||
size_t len;
|
||||
char *platform;
|
||||
char *revision;
|
||||
int ret;
|
||||
size_t len;
|
||||
|
||||
platform = (char *)SDL_GetPlatform();
|
||||
SDLTest_AssertPass("SDL_GetPlatform()");
|
||||
SDLTest_AssertCheck(platform != NULL, "SDL_GetPlatform() != NULL");
|
||||
if (platform != NULL) {
|
||||
len = SDL_strlen(platform);
|
||||
SDLTest_AssertCheck(len > 0,
|
||||
"SDL_GetPlatform(): expected non-empty platform, was platform: '%s', len: %i",
|
||||
platform,
|
||||
(int) len);
|
||||
}
|
||||
platform = (char *)SDL_GetPlatform();
|
||||
SDLTest_AssertPass("SDL_GetPlatform()");
|
||||
SDLTest_AssertCheck(platform != NULL, "SDL_GetPlatform() != NULL");
|
||||
if (platform != NULL) {
|
||||
len = SDL_strlen(platform);
|
||||
SDLTest_AssertCheck(len > 0,
|
||||
"SDL_GetPlatform(): expected non-empty platform, was platform: '%s', len: %i",
|
||||
platform,
|
||||
(int)len);
|
||||
}
|
||||
|
||||
ret = SDL_GetCPUCount();
|
||||
SDLTest_AssertPass("SDL_GetCPUCount()");
|
||||
SDLTest_AssertCheck(ret > 0,
|
||||
"SDL_GetCPUCount(): expected count > 0, was: %i",
|
||||
ret);
|
||||
ret = SDL_GetCPUCount();
|
||||
SDLTest_AssertPass("SDL_GetCPUCount()");
|
||||
SDLTest_AssertCheck(ret > 0,
|
||||
"SDL_GetCPUCount(): expected count > 0, was: %i",
|
||||
ret);
|
||||
|
||||
ret = SDL_GetCPUCacheLineSize();
|
||||
SDLTest_AssertPass("SDL_GetCPUCacheLineSize()");
|
||||
SDLTest_AssertCheck(ret >= 0,
|
||||
"SDL_GetCPUCacheLineSize(): expected size >= 0, was: %i",
|
||||
ret);
|
||||
ret = SDL_GetCPUCacheLineSize();
|
||||
SDLTest_AssertPass("SDL_GetCPUCacheLineSize()");
|
||||
SDLTest_AssertCheck(ret >= 0,
|
||||
"SDL_GetCPUCacheLineSize(): expected size >= 0, was: %i",
|
||||
ret);
|
||||
|
||||
revision = (char *)SDL_GetRevision();
|
||||
SDLTest_AssertPass("SDL_GetRevision()");
|
||||
SDLTest_AssertCheck(revision != NULL, "SDL_GetRevision() != NULL");
|
||||
revision = (char *)SDL_GetRevision();
|
||||
SDLTest_AssertPass("SDL_GetRevision()");
|
||||
SDLTest_AssertCheck(revision != NULL, "SDL_GetRevision() != NULL");
|
||||
|
||||
return TEST_COMPLETED;
|
||||
return TEST_COMPLETED;
|
||||
}
|
||||
|
||||
/* !
|
||||
|
@ -173,41 +175,41 @@ int platform_testGetFunctions (void *arg)
|
|||
* http://wiki.libsdl.org/SDL_HasSSE42
|
||||
* http://wiki.libsdl.org/SDL_HasAVX
|
||||
*/
|
||||
int platform_testHasFunctions (void *arg)
|
||||
int platform_testHasFunctions(void *arg)
|
||||
{
|
||||
/* TODO: independently determine and compare values as well */
|
||||
/* TODO: independently determine and compare values as well */
|
||||
|
||||
SDL_HasRDTSC();
|
||||
SDLTest_AssertPass("SDL_HasRDTSC()");
|
||||
SDL_HasRDTSC();
|
||||
SDLTest_AssertPass("SDL_HasRDTSC()");
|
||||
|
||||
SDL_HasAltiVec();
|
||||
SDLTest_AssertPass("SDL_HasAltiVec()");
|
||||
SDL_HasAltiVec();
|
||||
SDLTest_AssertPass("SDL_HasAltiVec()");
|
||||
|
||||
SDL_HasMMX();
|
||||
SDLTest_AssertPass("SDL_HasMMX()");
|
||||
SDL_HasMMX();
|
||||
SDLTest_AssertPass("SDL_HasMMX()");
|
||||
|
||||
SDL_Has3DNow();
|
||||
SDLTest_AssertPass("SDL_Has3DNow()");
|
||||
SDL_Has3DNow();
|
||||
SDLTest_AssertPass("SDL_Has3DNow()");
|
||||
|
||||
SDL_HasSSE();
|
||||
SDLTest_AssertPass("SDL_HasSSE()");
|
||||
SDL_HasSSE();
|
||||
SDLTest_AssertPass("SDL_HasSSE()");
|
||||
|
||||
SDL_HasSSE2();
|
||||
SDLTest_AssertPass("SDL_HasSSE2()");
|
||||
SDL_HasSSE2();
|
||||
SDLTest_AssertPass("SDL_HasSSE2()");
|
||||
|
||||
SDL_HasSSE3();
|
||||
SDLTest_AssertPass("SDL_HasSSE3()");
|
||||
SDL_HasSSE3();
|
||||
SDLTest_AssertPass("SDL_HasSSE3()");
|
||||
|
||||
SDL_HasSSE41();
|
||||
SDLTest_AssertPass("SDL_HasSSE41()");
|
||||
SDL_HasSSE41();
|
||||
SDLTest_AssertPass("SDL_HasSSE41()");
|
||||
|
||||
SDL_HasSSE42();
|
||||
SDLTest_AssertPass("SDL_HasSSE42()");
|
||||
SDL_HasSSE42();
|
||||
SDLTest_AssertPass("SDL_HasSSE42()");
|
||||
|
||||
SDL_HasAVX();
|
||||
SDLTest_AssertPass("SDL_HasAVX()");
|
||||
SDL_HasAVX();
|
||||
SDLTest_AssertPass("SDL_HasAVX()");
|
||||
|
||||
return TEST_COMPLETED;
|
||||
return TEST_COMPLETED;
|
||||
}
|
||||
|
||||
/* !
|
||||
|
@ -217,67 +219,65 @@ int platform_testHasFunctions (void *arg)
|
|||
*/
|
||||
int platform_testGetVersion(void *arg)
|
||||
{
|
||||
SDL_version linked;
|
||||
int major = SDL_MAJOR_VERSION;
|
||||
int minor = SDL_MINOR_VERSION;
|
||||
SDL_version linked;
|
||||
int major = SDL_MAJOR_VERSION;
|
||||
int minor = SDL_MINOR_VERSION;
|
||||
|
||||
SDL_GetVersion(&linked);
|
||||
SDLTest_AssertCheck( linked.major >= major,
|
||||
"SDL_GetVersion(): returned major %i (>= %i)",
|
||||
linked.major,
|
||||
major);
|
||||
SDLTest_AssertCheck( linked.minor >= minor,
|
||||
"SDL_GetVersion(): returned minor %i (>= %i)",
|
||||
linked.minor,
|
||||
minor);
|
||||
SDL_GetVersion(&linked);
|
||||
SDLTest_AssertCheck(linked.major >= major,
|
||||
"SDL_GetVersion(): returned major %i (>= %i)",
|
||||
linked.major,
|
||||
major);
|
||||
SDLTest_AssertCheck(linked.minor >= minor,
|
||||
"SDL_GetVersion(): returned minor %i (>= %i)",
|
||||
linked.minor,
|
||||
minor);
|
||||
|
||||
return TEST_COMPLETED;
|
||||
return TEST_COMPLETED;
|
||||
}
|
||||
|
||||
|
||||
/* !
|
||||
* \brief Tests SDL_VERSION macro
|
||||
*/
|
||||
int platform_testSDLVersion(void *arg)
|
||||
{
|
||||
SDL_version compiled;
|
||||
int major = SDL_MAJOR_VERSION;
|
||||
int minor = SDL_MINOR_VERSION;
|
||||
SDL_version compiled;
|
||||
int major = SDL_MAJOR_VERSION;
|
||||
int minor = SDL_MINOR_VERSION;
|
||||
|
||||
SDL_VERSION(&compiled);
|
||||
SDLTest_AssertCheck( compiled.major >= major,
|
||||
"SDL_VERSION() returned major %i (>= %i)",
|
||||
compiled.major,
|
||||
major);
|
||||
SDLTest_AssertCheck( compiled.minor >= minor,
|
||||
"SDL_VERSION() returned minor %i (>= %i)",
|
||||
compiled.minor,
|
||||
minor);
|
||||
SDL_VERSION(&compiled);
|
||||
SDLTest_AssertCheck(compiled.major >= major,
|
||||
"SDL_VERSION() returned major %i (>= %i)",
|
||||
compiled.major,
|
||||
major);
|
||||
SDLTest_AssertCheck(compiled.minor >= minor,
|
||||
"SDL_VERSION() returned minor %i (>= %i)",
|
||||
compiled.minor,
|
||||
minor);
|
||||
|
||||
return TEST_COMPLETED;
|
||||
return TEST_COMPLETED;
|
||||
}
|
||||
|
||||
|
||||
/* !
|
||||
* \brief Tests default SDL_Init
|
||||
*/
|
||||
int platform_testDefaultInit(void *arg)
|
||||
{
|
||||
int ret;
|
||||
int subsystem;
|
||||
int ret;
|
||||
int subsystem;
|
||||
|
||||
subsystem = SDL_WasInit(SDL_INIT_EVERYTHING);
|
||||
SDLTest_AssertCheck( subsystem != 0,
|
||||
"SDL_WasInit(0): returned %i, expected != 0",
|
||||
subsystem);
|
||||
subsystem = SDL_WasInit(SDL_INIT_EVERYTHING);
|
||||
SDLTest_AssertCheck(subsystem != 0,
|
||||
"SDL_WasInit(0): returned %i, expected != 0",
|
||||
subsystem);
|
||||
|
||||
ret = SDL_Init(SDL_WasInit(SDL_INIT_EVERYTHING));
|
||||
SDLTest_AssertCheck( ret == 0,
|
||||
"SDL_Init(0): returned %i, expected 0, error: %s",
|
||||
ret,
|
||||
SDL_GetError());
|
||||
ret = SDL_Init(SDL_WasInit(SDL_INIT_EVERYTHING));
|
||||
SDLTest_AssertCheck(ret == 0,
|
||||
"SDL_Init(0): returned %i, expected 0, error: %s",
|
||||
ret,
|
||||
SDL_GetError());
|
||||
|
||||
return TEST_COMPLETED;
|
||||
return TEST_COMPLETED;
|
||||
}
|
||||
|
||||
/* !
|
||||
|
@ -289,47 +289,47 @@ int platform_testDefaultInit(void *arg)
|
|||
*/
|
||||
int platform_testGetSetClearError(void *arg)
|
||||
{
|
||||
int result;
|
||||
const char *testError = "Testing";
|
||||
char *lastError;
|
||||
size_t len;
|
||||
int result;
|
||||
const char *testError = "Testing";
|
||||
char *lastError;
|
||||
size_t len;
|
||||
|
||||
SDL_ClearError();
|
||||
SDLTest_AssertPass("SDL_ClearError()");
|
||||
SDL_ClearError();
|
||||
SDLTest_AssertPass("SDL_ClearError()");
|
||||
|
||||
lastError = (char *)SDL_GetError();
|
||||
SDLTest_AssertPass("SDL_GetError()");
|
||||
SDLTest_AssertCheck(lastError != NULL,
|
||||
"SDL_GetError() != NULL");
|
||||
if (lastError != NULL) {
|
||||
len = SDL_strlen(lastError);
|
||||
SDLTest_AssertCheck(len == 0,
|
||||
"SDL_GetError(): no message expected, len: %i", (int) len);
|
||||
}
|
||||
lastError = (char *)SDL_GetError();
|
||||
SDLTest_AssertPass("SDL_GetError()");
|
||||
SDLTest_AssertCheck(lastError != NULL,
|
||||
"SDL_GetError() != NULL");
|
||||
if (lastError != NULL) {
|
||||
len = SDL_strlen(lastError);
|
||||
SDLTest_AssertCheck(len == 0,
|
||||
"SDL_GetError(): no message expected, len: %i", (int)len);
|
||||
}
|
||||
|
||||
result = SDL_SetError("%s", testError);
|
||||
SDLTest_AssertPass("SDL_SetError()");
|
||||
SDLTest_AssertCheck(result == -1, "SDL_SetError: expected -1, got: %i", result);
|
||||
lastError = (char *)SDL_GetError();
|
||||
SDLTest_AssertCheck(lastError != NULL,
|
||||
"SDL_GetError() != NULL");
|
||||
if (lastError != NULL) {
|
||||
len = SDL_strlen(lastError);
|
||||
SDLTest_AssertCheck(len == SDL_strlen(testError),
|
||||
"SDL_GetError(): expected message len %i, was len: %i",
|
||||
(int) SDL_strlen(testError),
|
||||
(int) len);
|
||||
SDLTest_AssertCheck(SDL_strcmp(lastError, testError) == 0,
|
||||
"SDL_GetError(): expected message %s, was message: %s",
|
||||
testError,
|
||||
lastError);
|
||||
}
|
||||
result = SDL_SetError("%s", testError);
|
||||
SDLTest_AssertPass("SDL_SetError()");
|
||||
SDLTest_AssertCheck(result == -1, "SDL_SetError: expected -1, got: %i", result);
|
||||
lastError = (char *)SDL_GetError();
|
||||
SDLTest_AssertCheck(lastError != NULL,
|
||||
"SDL_GetError() != NULL");
|
||||
if (lastError != NULL) {
|
||||
len = SDL_strlen(lastError);
|
||||
SDLTest_AssertCheck(len == SDL_strlen(testError),
|
||||
"SDL_GetError(): expected message len %i, was len: %i",
|
||||
(int)SDL_strlen(testError),
|
||||
(int)len);
|
||||
SDLTest_AssertCheck(SDL_strcmp(lastError, testError) == 0,
|
||||
"SDL_GetError(): expected message %s, was message: %s",
|
||||
testError,
|
||||
lastError);
|
||||
}
|
||||
|
||||
/* Clean up */
|
||||
SDL_ClearError();
|
||||
SDLTest_AssertPass("SDL_ClearError()");
|
||||
/* Clean up */
|
||||
SDL_ClearError();
|
||||
SDLTest_AssertPass("SDL_ClearError()");
|
||||
|
||||
return TEST_COMPLETED;
|
||||
return TEST_COMPLETED;
|
||||
}
|
||||
|
||||
/* !
|
||||
|
@ -339,34 +339,34 @@ int platform_testGetSetClearError(void *arg)
|
|||
*/
|
||||
int platform_testSetErrorEmptyInput(void *arg)
|
||||
{
|
||||
int result;
|
||||
const char *testError = "";
|
||||
char *lastError;
|
||||
size_t len;
|
||||
int result;
|
||||
const char *testError = "";
|
||||
char *lastError;
|
||||
size_t len;
|
||||
|
||||
result = SDL_SetError("%s", testError);
|
||||
SDLTest_AssertPass("SDL_SetError()");
|
||||
SDLTest_AssertCheck(result == -1, "SDL_SetError: expected -1, got: %i", result);
|
||||
lastError = (char *)SDL_GetError();
|
||||
SDLTest_AssertCheck(lastError != NULL,
|
||||
"SDL_GetError() != NULL");
|
||||
if (lastError != NULL) {
|
||||
len = SDL_strlen(lastError);
|
||||
SDLTest_AssertCheck(len == SDL_strlen(testError),
|
||||
"SDL_GetError(): expected message len %i, was len: %i",
|
||||
(int) SDL_strlen(testError),
|
||||
(int) len);
|
||||
SDLTest_AssertCheck(SDL_strcmp(lastError, testError) == 0,
|
||||
"SDL_GetError(): expected message '%s', was message: '%s'",
|
||||
testError,
|
||||
lastError);
|
||||
}
|
||||
result = SDL_SetError("%s", testError);
|
||||
SDLTest_AssertPass("SDL_SetError()");
|
||||
SDLTest_AssertCheck(result == -1, "SDL_SetError: expected -1, got: %i", result);
|
||||
lastError = (char *)SDL_GetError();
|
||||
SDLTest_AssertCheck(lastError != NULL,
|
||||
"SDL_GetError() != NULL");
|
||||
if (lastError != NULL) {
|
||||
len = SDL_strlen(lastError);
|
||||
SDLTest_AssertCheck(len == SDL_strlen(testError),
|
||||
"SDL_GetError(): expected message len %i, was len: %i",
|
||||
(int)SDL_strlen(testError),
|
||||
(int)len);
|
||||
SDLTest_AssertCheck(SDL_strcmp(lastError, testError) == 0,
|
||||
"SDL_GetError(): expected message '%s', was message: '%s'",
|
||||
testError,
|
||||
lastError);
|
||||
}
|
||||
|
||||
/* Clean up */
|
||||
SDL_ClearError();
|
||||
SDLTest_AssertPass("SDL_ClearError()");
|
||||
/* Clean up */
|
||||
SDL_ClearError();
|
||||
SDLTest_AssertPass("SDL_ClearError()");
|
||||
|
||||
return TEST_COMPLETED;
|
||||
return TEST_COMPLETED;
|
||||
}
|
||||
|
||||
#if defined(HAVE_WFORMAT_OVERFLOW)
|
||||
|
@ -381,77 +381,77 @@ int platform_testSetErrorEmptyInput(void *arg)
|
|||
*/
|
||||
int platform_testSetErrorInvalidInput(void *arg)
|
||||
{
|
||||
int result;
|
||||
const char *invalidError = NULL;
|
||||
const char *probeError = "Testing";
|
||||
char *lastError;
|
||||
size_t len;
|
||||
int result;
|
||||
const char *invalidError = NULL;
|
||||
const char *probeError = "Testing";
|
||||
char *lastError;
|
||||
size_t len;
|
||||
|
||||
/* Reset */
|
||||
SDL_ClearError();
|
||||
SDLTest_AssertPass("SDL_ClearError()");
|
||||
/* Reset */
|
||||
SDL_ClearError();
|
||||
SDLTest_AssertPass("SDL_ClearError()");
|
||||
|
||||
/* Check for no-op */
|
||||
result = SDL_SetError("%s", invalidError);
|
||||
SDLTest_AssertPass("SDL_SetError()");
|
||||
SDLTest_AssertCheck(result == -1, "SDL_SetError: expected -1, got: %i", result);
|
||||
lastError = (char *)SDL_GetError();
|
||||
SDLTest_AssertCheck(lastError != NULL,
|
||||
"SDL_GetError() != NULL");
|
||||
if (lastError != NULL) {
|
||||
len = SDL_strlen(lastError);
|
||||
SDLTest_AssertCheck(len == 0 || SDL_strcmp(lastError, "(null)") == 0,
|
||||
"SDL_GetError(): expected message len 0, was len: %i",
|
||||
(int) len);
|
||||
}
|
||||
/* Check for no-op */
|
||||
result = SDL_SetError("%s", invalidError);
|
||||
SDLTest_AssertPass("SDL_SetError()");
|
||||
SDLTest_AssertCheck(result == -1, "SDL_SetError: expected -1, got: %i", result);
|
||||
lastError = (char *)SDL_GetError();
|
||||
SDLTest_AssertCheck(lastError != NULL,
|
||||
"SDL_GetError() != NULL");
|
||||
if (lastError != NULL) {
|
||||
len = SDL_strlen(lastError);
|
||||
SDLTest_AssertCheck(len == 0 || SDL_strcmp(lastError, "(null)") == 0,
|
||||
"SDL_GetError(): expected message len 0, was len: %i",
|
||||
(int)len);
|
||||
}
|
||||
|
||||
/* Set */
|
||||
result = SDL_SetError("%s", probeError);
|
||||
SDLTest_AssertPass("SDL_SetError('%s')", probeError);
|
||||
SDLTest_AssertCheck(result == -1, "SDL_SetError: expected -1, got: %i", result);
|
||||
/* Set */
|
||||
result = SDL_SetError("%s", probeError);
|
||||
SDLTest_AssertPass("SDL_SetError('%s')", probeError);
|
||||
SDLTest_AssertCheck(result == -1, "SDL_SetError: expected -1, got: %i", result);
|
||||
|
||||
/* Check for no-op */
|
||||
result = SDL_SetError("%s", invalidError);
|
||||
SDLTest_AssertPass("SDL_SetError(NULL)");
|
||||
SDLTest_AssertCheck(result == -1, "SDL_SetError: expected -1, got: %i", result);
|
||||
lastError = (char *)SDL_GetError();
|
||||
SDLTest_AssertCheck(lastError != NULL,
|
||||
"SDL_GetError() != NULL");
|
||||
if (lastError != NULL) {
|
||||
len = SDL_strlen(lastError);
|
||||
SDLTest_AssertCheck(len == 0 || SDL_strcmp( lastError, "(null)" ) == 0,
|
||||
"SDL_GetError(): expected message len 0, was len: %i",
|
||||
(int) len);
|
||||
}
|
||||
/* Check for no-op */
|
||||
result = SDL_SetError("%s", invalidError);
|
||||
SDLTest_AssertPass("SDL_SetError(NULL)");
|
||||
SDLTest_AssertCheck(result == -1, "SDL_SetError: expected -1, got: %i", result);
|
||||
lastError = (char *)SDL_GetError();
|
||||
SDLTest_AssertCheck(lastError != NULL,
|
||||
"SDL_GetError() != NULL");
|
||||
if (lastError != NULL) {
|
||||
len = SDL_strlen(lastError);
|
||||
SDLTest_AssertCheck(len == 0 || SDL_strcmp(lastError, "(null)") == 0,
|
||||
"SDL_GetError(): expected message len 0, was len: %i",
|
||||
(int)len);
|
||||
}
|
||||
|
||||
/* Reset */
|
||||
SDL_ClearError();
|
||||
SDLTest_AssertPass("SDL_ClearError()");
|
||||
/* Reset */
|
||||
SDL_ClearError();
|
||||
SDLTest_AssertPass("SDL_ClearError()");
|
||||
|
||||
/* Set and check */
|
||||
result = SDL_SetError("%s", probeError);
|
||||
SDLTest_AssertPass("SDL_SetError()");
|
||||
SDLTest_AssertCheck(result == -1, "SDL_SetError: expected -1, got: %i", result);
|
||||
lastError = (char *)SDL_GetError();
|
||||
SDLTest_AssertCheck(lastError != NULL,
|
||||
"SDL_GetError() != NULL");
|
||||
if (lastError != NULL) {
|
||||
len = SDL_strlen(lastError);
|
||||
SDLTest_AssertCheck(len == SDL_strlen(probeError),
|
||||
"SDL_GetError(): expected message len %i, was len: %i",
|
||||
(int) SDL_strlen(probeError),
|
||||
(int) len);
|
||||
SDLTest_AssertCheck(SDL_strcmp(lastError, probeError) == 0,
|
||||
"SDL_GetError(): expected message '%s', was message: '%s'",
|
||||
probeError,
|
||||
lastError);
|
||||
}
|
||||
/* Set and check */
|
||||
result = SDL_SetError("%s", probeError);
|
||||
SDLTest_AssertPass("SDL_SetError()");
|
||||
SDLTest_AssertCheck(result == -1, "SDL_SetError: expected -1, got: %i", result);
|
||||
lastError = (char *)SDL_GetError();
|
||||
SDLTest_AssertCheck(lastError != NULL,
|
||||
"SDL_GetError() != NULL");
|
||||
if (lastError != NULL) {
|
||||
len = SDL_strlen(lastError);
|
||||
SDLTest_AssertCheck(len == SDL_strlen(probeError),
|
||||
"SDL_GetError(): expected message len %i, was len: %i",
|
||||
(int)SDL_strlen(probeError),
|
||||
(int)len);
|
||||
SDLTest_AssertCheck(SDL_strcmp(lastError, probeError) == 0,
|
||||
"SDL_GetError(): expected message '%s', was message: '%s'",
|
||||
probeError,
|
||||
lastError);
|
||||
}
|
||||
|
||||
/* Clean up */
|
||||
SDL_ClearError();
|
||||
SDLTest_AssertPass("SDL_ClearError()");
|
||||
/* Clean up */
|
||||
SDL_ClearError();
|
||||
SDLTest_AssertPass("SDL_ClearError()");
|
||||
|
||||
return TEST_COMPLETED;
|
||||
return TEST_COMPLETED;
|
||||
}
|
||||
|
||||
#if defined(HAVE_WFORMAT_OVERFLOW)
|
||||
|
@ -465,114 +465,124 @@ int platform_testSetErrorInvalidInput(void *arg)
|
|||
*/
|
||||
int platform_testGetPowerInfo(void *arg)
|
||||
{
|
||||
SDL_PowerState state;
|
||||
SDL_PowerState stateAgain;
|
||||
int secs;
|
||||
int secsAgain;
|
||||
int pct;
|
||||
int pctAgain;
|
||||
SDL_PowerState state;
|
||||
SDL_PowerState stateAgain;
|
||||
int secs;
|
||||
int secsAgain;
|
||||
int pct;
|
||||
int pctAgain;
|
||||
|
||||
state = SDL_GetPowerInfo(&secs, &pct);
|
||||
SDLTest_AssertPass("SDL_GetPowerInfo()");
|
||||
SDLTest_AssertCheck(
|
||||
state==SDL_POWERSTATE_UNKNOWN ||
|
||||
state==SDL_POWERSTATE_ON_BATTERY ||
|
||||
state==SDL_POWERSTATE_NO_BATTERY ||
|
||||
state==SDL_POWERSTATE_CHARGING ||
|
||||
state==SDL_POWERSTATE_CHARGED,
|
||||
"SDL_GetPowerInfo(): state %i is one of the expected values",
|
||||
(int)state);
|
||||
state = SDL_GetPowerInfo(&secs, &pct);
|
||||
SDLTest_AssertPass("SDL_GetPowerInfo()");
|
||||
SDLTest_AssertCheck(
|
||||
state == SDL_POWERSTATE_UNKNOWN ||
|
||||
state == SDL_POWERSTATE_ON_BATTERY ||
|
||||
state == SDL_POWERSTATE_NO_BATTERY ||
|
||||
state == SDL_POWERSTATE_CHARGING ||
|
||||
state == SDL_POWERSTATE_CHARGED,
|
||||
"SDL_GetPowerInfo(): state %i is one of the expected values",
|
||||
(int)state);
|
||||
|
||||
if (state==SDL_POWERSTATE_ON_BATTERY) {
|
||||
SDLTest_AssertCheck(
|
||||
secs >= 0,
|
||||
"SDL_GetPowerInfo(): on battery, secs >= 0, was: %i",
|
||||
secs);
|
||||
SDLTest_AssertCheck(
|
||||
(pct >= 0) && (pct <= 100),
|
||||
"SDL_GetPowerInfo(): on battery, pct=[0,100], was: %i",
|
||||
pct);
|
||||
}
|
||||
if (state == SDL_POWERSTATE_ON_BATTERY) {
|
||||
SDLTest_AssertCheck(
|
||||
secs >= 0,
|
||||
"SDL_GetPowerInfo(): on battery, secs >= 0, was: %i",
|
||||
secs);
|
||||
SDLTest_AssertCheck(
|
||||
(pct >= 0) && (pct <= 100),
|
||||
"SDL_GetPowerInfo(): on battery, pct=[0,100], was: %i",
|
||||
pct);
|
||||
}
|
||||
|
||||
if (state==SDL_POWERSTATE_UNKNOWN ||
|
||||
state==SDL_POWERSTATE_NO_BATTERY)
|
||||
{
|
||||
SDLTest_AssertCheck(
|
||||
secs == -1,
|
||||
"SDL_GetPowerInfo(): no battery, secs == -1, was: %i",
|
||||
secs);
|
||||
SDLTest_AssertCheck(
|
||||
pct == -1,
|
||||
"SDL_GetPowerInfo(): no battery, pct == -1, was: %i",
|
||||
pct);
|
||||
}
|
||||
if (state == SDL_POWERSTATE_UNKNOWN ||
|
||||
state == SDL_POWERSTATE_NO_BATTERY) {
|
||||
SDLTest_AssertCheck(
|
||||
secs == -1,
|
||||
"SDL_GetPowerInfo(): no battery, secs == -1, was: %i",
|
||||
secs);
|
||||
SDLTest_AssertCheck(
|
||||
pct == -1,
|
||||
"SDL_GetPowerInfo(): no battery, pct == -1, was: %i",
|
||||
pct);
|
||||
}
|
||||
|
||||
/* Partial return value variations */
|
||||
stateAgain = SDL_GetPowerInfo(&secsAgain, NULL);
|
||||
SDLTest_AssertCheck(
|
||||
state==stateAgain,
|
||||
/* Partial return value variations */
|
||||
stateAgain = SDL_GetPowerInfo(&secsAgain, NULL);
|
||||
SDLTest_AssertCheck(
|
||||
state == stateAgain,
|
||||
"State %i returned when only 'secs' requested",
|
||||
stateAgain);
|
||||
SDLTest_AssertCheck(
|
||||
secs==secsAgain,
|
||||
SDLTest_AssertCheck(
|
||||
secs == secsAgain,
|
||||
"Value %i matches when only 'secs' requested",
|
||||
secsAgain);
|
||||
stateAgain = SDL_GetPowerInfo(NULL, &pctAgain);
|
||||
SDLTest_AssertCheck(
|
||||
state==stateAgain,
|
||||
stateAgain = SDL_GetPowerInfo(NULL, &pctAgain);
|
||||
SDLTest_AssertCheck(
|
||||
state == stateAgain,
|
||||
"State %i returned when only 'pct' requested",
|
||||
stateAgain);
|
||||
SDLTest_AssertCheck(
|
||||
pct==pctAgain,
|
||||
SDLTest_AssertCheck(
|
||||
pct == pctAgain,
|
||||
"Value %i matches when only 'pct' requested",
|
||||
pctAgain);
|
||||
stateAgain = SDL_GetPowerInfo(NULL, NULL);
|
||||
SDLTest_AssertCheck(
|
||||
state==stateAgain,
|
||||
stateAgain = SDL_GetPowerInfo(NULL, NULL);
|
||||
SDLTest_AssertCheck(
|
||||
state == stateAgain,
|
||||
"State %i returned when no value requested",
|
||||
stateAgain);
|
||||
|
||||
return TEST_COMPLETED;
|
||||
return TEST_COMPLETED;
|
||||
}
|
||||
|
||||
/* ================= Test References ================== */
|
||||
|
||||
/* Platform test cases */
|
||||
static const SDLTest_TestCaseReference platformTest1 =
|
||||
{ (SDLTest_TestCaseFp)platform_testTypes, "platform_testTypes", "Tests predefined types", TEST_ENABLED};
|
||||
static const SDLTest_TestCaseReference platformTest1 = {
|
||||
(SDLTest_TestCaseFp)platform_testTypes, "platform_testTypes", "Tests predefined types", TEST_ENABLED
|
||||
};
|
||||
|
||||
static const SDLTest_TestCaseReference platformTest2 =
|
||||
{ (SDLTest_TestCaseFp)platform_testEndianessAndSwap, "platform_testEndianessAndSwap", "Tests endianness and swap functions", TEST_ENABLED};
|
||||
static const SDLTest_TestCaseReference platformTest2 = {
|
||||
(SDLTest_TestCaseFp)platform_testEndianessAndSwap, "platform_testEndianessAndSwap", "Tests endianness and swap functions", TEST_ENABLED
|
||||
};
|
||||
|
||||
static const SDLTest_TestCaseReference platformTest3 =
|
||||
{ (SDLTest_TestCaseFp)platform_testGetFunctions, "platform_testGetFunctions", "Tests various SDL_GetXYZ functions", TEST_ENABLED};
|
||||
static const SDLTest_TestCaseReference platformTest3 = {
|
||||
(SDLTest_TestCaseFp)platform_testGetFunctions, "platform_testGetFunctions", "Tests various SDL_GetXYZ functions", TEST_ENABLED
|
||||
};
|
||||
|
||||
static const SDLTest_TestCaseReference platformTest4 =
|
||||
{ (SDLTest_TestCaseFp)platform_testHasFunctions, "platform_testHasFunctions", "Tests various SDL_HasXYZ functions", TEST_ENABLED};
|
||||
static const SDLTest_TestCaseReference platformTest4 = {
|
||||
(SDLTest_TestCaseFp)platform_testHasFunctions, "platform_testHasFunctions", "Tests various SDL_HasXYZ functions", TEST_ENABLED
|
||||
};
|
||||
|
||||
static const SDLTest_TestCaseReference platformTest5 =
|
||||
{ (SDLTest_TestCaseFp)platform_testGetVersion, "platform_testGetVersion", "Tests SDL_GetVersion function", TEST_ENABLED};
|
||||
static const SDLTest_TestCaseReference platformTest5 = {
|
||||
(SDLTest_TestCaseFp)platform_testGetVersion, "platform_testGetVersion", "Tests SDL_GetVersion function", TEST_ENABLED
|
||||
};
|
||||
|
||||
static const SDLTest_TestCaseReference platformTest6 =
|
||||
{ (SDLTest_TestCaseFp)platform_testSDLVersion, "platform_testSDLVersion", "Tests SDL_VERSION macro", TEST_ENABLED};
|
||||
static const SDLTest_TestCaseReference platformTest6 = {
|
||||
(SDLTest_TestCaseFp)platform_testSDLVersion, "platform_testSDLVersion", "Tests SDL_VERSION macro", TEST_ENABLED
|
||||
};
|
||||
|
||||
static const SDLTest_TestCaseReference platformTest7 =
|
||||
{ (SDLTest_TestCaseFp)platform_testDefaultInit, "platform_testDefaultInit", "Tests default SDL_Init", TEST_ENABLED};
|
||||
static const SDLTest_TestCaseReference platformTest7 = {
|
||||
(SDLTest_TestCaseFp)platform_testDefaultInit, "platform_testDefaultInit", "Tests default SDL_Init", TEST_ENABLED
|
||||
};
|
||||
|
||||
static const SDLTest_TestCaseReference platformTest8 =
|
||||
{ (SDLTest_TestCaseFp)platform_testGetSetClearError, "platform_testGetSetClearError", "Tests SDL_Get/Set/ClearError", TEST_ENABLED};
|
||||
static const SDLTest_TestCaseReference platformTest8 = {
|
||||
(SDLTest_TestCaseFp)platform_testGetSetClearError, "platform_testGetSetClearError", "Tests SDL_Get/Set/ClearError", TEST_ENABLED
|
||||
};
|
||||
|
||||
static const SDLTest_TestCaseReference platformTest9 =
|
||||
{ (SDLTest_TestCaseFp)platform_testSetErrorEmptyInput, "platform_testSetErrorEmptyInput", "Tests SDL_SetError with empty input", TEST_ENABLED};
|
||||
static const SDLTest_TestCaseReference platformTest9 = {
|
||||
(SDLTest_TestCaseFp)platform_testSetErrorEmptyInput, "platform_testSetErrorEmptyInput", "Tests SDL_SetError with empty input", TEST_ENABLED
|
||||
};
|
||||
|
||||
static const SDLTest_TestCaseReference platformTest10 =
|
||||
{ (SDLTest_TestCaseFp)platform_testSetErrorInvalidInput, "platform_testSetErrorInvalidInput", "Tests SDL_SetError with invalid input", TEST_ENABLED};
|
||||
static const SDLTest_TestCaseReference platformTest10 = {
|
||||
(SDLTest_TestCaseFp)platform_testSetErrorInvalidInput, "platform_testSetErrorInvalidInput", "Tests SDL_SetError with invalid input", TEST_ENABLED
|
||||
};
|
||||
|
||||
static const SDLTest_TestCaseReference platformTest11 =
|
||||
{ (SDLTest_TestCaseFp)platform_testGetPowerInfo, "platform_testGetPowerInfo", "Tests SDL_GetPowerInfo function", TEST_ENABLED };
|
||||
static const SDLTest_TestCaseReference platformTest11 = {
|
||||
(SDLTest_TestCaseFp)platform_testGetPowerInfo, "platform_testGetPowerInfo", "Tests SDL_GetPowerInfo function", TEST_ENABLED
|
||||
};
|
||||
|
||||
/* Sequence of Platform test cases */
|
||||
static const SDLTest_TestCaseReference *platformTests[] = {
|
||||
static const SDLTest_TestCaseReference *platformTests[] = {
|
||||
&platformTest1,
|
||||
&platformTest2,
|
||||
&platformTest3,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue