File style cleanup for the SDL 2.0 release

This commit is contained in:
Sam Lantinga
2013-05-18 14:17:52 -07:00
parent 3beb70c4bc
commit 0d9b661db8
376 changed files with 17562 additions and 17773 deletions

View File

@@ -21,12 +21,12 @@
typedef struct SurfaceImage_s {
int width;
int height;
unsigned int bytes_per_pixel; /* 3:RGB, 4:RGBA */
unsigned int bytes_per_pixel; /* 3:RGB, 4:RGBA */
const char *pixel_data;
} SurfaceImage_t;
#define ALLOWABLE_ERROR_OPAQUE 0
#define ALLOWABLE_ERROR_BLENDED 64
#define ALLOWABLE_ERROR_OPAQUE 0
#define ALLOWABLE_ERROR_BLENDED 64
/**
* @brief Compares a surface and a surface image for equality.

View File

@@ -20,70 +20,70 @@ FILE* TestSupportRWops_OpenFPFromReadDir(const char *file, const char *mode)
{
FILE* fp = NULL;
// If the file mode is writable, skip all the bundle stuff because generally the bundle is read-only.
if(strcmp("r", mode) && strcmp("rb", mode))
{
return fopen(file, mode);
}
NSAutoreleasePool* autorelease_pool = [[NSAutoreleasePool alloc] init];
/* If the file mode is writable, skip all the bundle stuff because generally the bundle is read-only. */
if(strcmp("r", mode) && strcmp("rb", mode))
{
return fopen(file, mode);
}
NSAutoreleasePool* autorelease_pool = [[NSAutoreleasePool alloc] init];
NSFileManager* file_manager = [NSFileManager defaultManager];
NSString* resource_path = [[NSBundle mainBundle] resourcePath];
NSFileManager* file_manager = [NSFileManager defaultManager];
NSString* resource_path = [[NSBundle mainBundle] resourcePath];
NSString* ns_string_file_component = [file_manager stringWithFileSystemRepresentation:file length:strlen(file)];
NSString* ns_string_file_component = [file_manager stringWithFileSystemRepresentation:file length:strlen(file)];
NSString* full_path_with_file_to_try = [resource_path stringByAppendingPathComponent:ns_string_file_component];
if([file_manager fileExistsAtPath:full_path_with_file_to_try])
{
fp = fopen([full_path_with_file_to_try fileSystemRepresentation], mode);
}
else
{
fp = fopen(file, mode);
}
NSString* full_path_with_file_to_try = [resource_path stringByAppendingPathComponent:ns_string_file_component];
if([file_manager fileExistsAtPath:full_path_with_file_to_try])
{
fp = fopen([full_path_with_file_to_try fileSystemRepresentation], mode);
}
else
{
fp = fopen(file, mode);
}
[autorelease_pool drain];
[autorelease_pool drain];
return fp;
return fp;
}
FILE* TestSupportRWops_OpenFPFromWriteDir(const char *file, const char *mode)
{
FILE* fp = NULL;
NSAutoreleasePool* autorelease_pool = [[NSAutoreleasePool alloc] init];
NSFileManager* file_manager = [NSFileManager defaultManager];
NSString* ns_string_file_component = [file_manager stringWithFileSystemRepresentation:file length:strlen(file)];
NSString* full_path_with_file_to_try = [NSTemporaryDirectory() stringByAppendingPathComponent:ns_string_file_component];
fp = fopen([full_path_with_file_to_try fileSystemRepresentation], mode);
[autorelease_pool drain];
return fp;
NSAutoreleasePool* autorelease_pool = [[NSAutoreleasePool alloc] init];
NSFileManager* file_manager = [NSFileManager defaultManager];
NSString* ns_string_file_component = [file_manager stringWithFileSystemRepresentation:file length:strlen(file)];
NSString* full_path_with_file_to_try = [NSTemporaryDirectory() stringByAppendingPathComponent:ns_string_file_component];
fp = fopen([full_path_with_file_to_try fileSystemRepresentation], mode);
[autorelease_pool drain];
return fp;
}
SDL_RWops* TestSupportRWops_OpenRWopsFromReadDir(const char *file, const char *mode)
{
return SDL_RWFromFile(file, mode);
return SDL_RWFromFile(file, mode);
}
SDL_RWops* TestSupportRWops_OpenRWopsFromWriteDir(const char *file, const char *mode)
{
SDL_RWops* rw = NULL;
SDL_RWops* rw = NULL;
NSAutoreleasePool* autorelease_pool = [[NSAutoreleasePool alloc] init];
NSFileManager* file_manager = [NSFileManager defaultManager];
NSString* ns_string_file_component = [file_manager stringWithFileSystemRepresentation:file length:strlen(file)];
NSString* full_path_with_file_to_try = [NSTemporaryDirectory() stringByAppendingPathComponent:ns_string_file_component];
rw = SDL_RWFromFile( [full_path_with_file_to_try fileSystemRepresentation], mode );
NSAutoreleasePool* autorelease_pool = [[NSAutoreleasePool alloc] init];
[autorelease_pool drain];
return rw;
NSFileManager* file_manager = [NSFileManager defaultManager];
NSString* ns_string_file_component = [file_manager stringWithFileSystemRepresentation:file length:strlen(file)];
NSString* full_path_with_file_to_try = [NSTemporaryDirectory() stringByAppendingPathComponent:ns_string_file_component];
rw = SDL_RWFromFile( [full_path_with_file_to_try fileSystemRepresentation], mode );
[autorelease_pool drain];
return rw;
}

View File

@@ -2,7 +2,7 @@
* Customizations for specific platforms should go in alternative files.
*/
// quiet windows compiler warnings
/* quiet windows compiler warnings */
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
@@ -13,20 +13,20 @@ const char* RWOPS_WRITE = "rwops/write";
FILE* TestSupportRWops_OpenFPFromReadDir(const char *file, const char *mode)
{
return fopen(file, mode);
return fopen(file, mode);
}
FILE* TestSupportRWops_OpenFPFromWriteDir(const char *file, const char *mode)
{
return fopen(file, mode);
return fopen(file, mode);
}
SDL_RWops* TestSupportRWops_OpenRWopsFromReadDir(const char *file, const char *mode)
{
return SDL_RWFromFile(file, mode);
return SDL_RWFromFile(file, mode);
}
SDL_RWops* TestSupportRWops_OpenRWopsFromWriteDir(const char *file, const char *mode)
{
return SDL_RWFromFile(file, mode);
return SDL_RWFromFile(file, mode);
}

View File

@@ -49,9 +49,9 @@ static void surface_testLoad( SDL_Surface *testsur )
/* Create the blit surface. */
#ifdef __APPLE__
face = SDL_LoadBMP("icon.bmp");
face = SDL_LoadBMP("icon.bmp");
#else
face = SDL_LoadBMP("../icon.bmp");
face = SDL_LoadBMP("../icon.bmp");
#endif
if (SDL_ATassert( "SDL_CreateLoadBmp", face != NULL))
@@ -428,7 +428,7 @@ int test_surface (void)
* Surface on surface tests.
*/
/* Create the test surface. */
testsur = SDL_CreateRGBSurface( 0, 80, 60, 32,
testsur = SDL_CreateRGBSurface( 0, 80, 60, 32,
RMASK, GMASK, BMASK, AMASK );
if (SDL_ATassert( "SDL_CreateRGBSurface", testsur != NULL))
goto err;

View File

@@ -11,7 +11,7 @@
*/
/* Simple program: Loop, watching keystrokes
Note that you need to call SDL_PollEvent() or SDL_WaitEvent() to
Note that you need to call SDL_PollEvent() or SDL_WaitEvent() to
pump the event loop and catch keystrokes.
*/

View File

@@ -12,8 +12,8 @@
/* Program to load a wave file and loop playing it using SDL sound */
/* loopwaves.c is much more robust in handling WAVE files --
This is only for simple WAVEs
/* loopwaves.c is much more robust in handling WAVE files --
This is only for simple WAVEs
*/
#include "SDL_config.h"

View File

@@ -35,12 +35,12 @@
#define ASSERT_FAILURE 0
//! Definition of all the possible test results
#define TEST_RESULT_PASS 0
#define TEST_RESULT_FAILURE 1
#define TEST_RESULT_NO_ASSERT 2
#define TEST_RESULT_SKIPPED 3
#define TEST_RESULT_KILLED 4
#define TEST_RESULT_SETUP_FAILURE 5
#define TEST_RESULT_PASS 0
#define TEST_RESULT_FAILURE 1
#define TEST_RESULT_NO_ASSERT 2
#define TEST_RESULT_SKIPPED 3
#define TEST_RESULT_KILLED 4
#define TEST_RESULT_SETUP_FAILURE 5
//! Definitions for test requirements
#define TEST_REQUIRES_AUDIO 1
@@ -51,16 +51,16 @@
* Holds information about a test case
*/
typedef struct TestCaseReference {
/*!< "Func2Stress" */
char *name;
/*!< "This test beats the crap out of func2()" */
char *description;
/*!< Set to TEST_ENABLED or TEST_DISABLED */
int enabled;
/*!< Set to TEST_REQUIRES_OPENGL, TEST_REQUIRES_AUDIO, ... */
long requirements;
/*<! Timeout value in seconds. If exceeded runner will kill the test. 0 means infinite time */
long timeout;
/*!< "Func2Stress" */
char *name;
/*!< "This test beats the crap out of func2()" */
char *description;
/*!< Set to TEST_ENABLED or TEST_DISABLED */
int enabled;
/*!< Set to TEST_REQUIRES_OPENGL, TEST_REQUIRES_AUDIO, ... */
long requirements;
/*<! Timeout value in seconds. If exceeded runner will kill the test. 0 means infinite time */
long timeout;
} TestCaseReference;
/*!

View File

@@ -46,37 +46,37 @@ SDL_bool canBailOut;
void
_InitTestEnvironment(Uint64 execKey, SDL_bool inproc)
{
InitFuzzer(execKey);
InitFuzzer(execKey);
canBailOut = inproc == 0;
canBailOut = inproc == 0;
_testReturnValue = TEST_RESULT_PASS;
_testAssertsFailed = 0;
_testAssertsPassed = 0;
_testReturnValue = TEST_RESULT_PASS;
_testAssertsFailed = 0;
_testAssertsPassed = 0;
}
int
_QuitTestEnvironment()
{
AssertSummary(_testAssertsFailed + _testAssertsPassed,
AssertSummary(_testAssertsFailed + _testAssertsPassed,
_testAssertsFailed, _testAssertsPassed, time(0));
if(_testAssertsFailed == 0 && _testAssertsPassed == 0) {
_testReturnValue = TEST_RESULT_NO_ASSERT;
}
if(_testAssertsFailed == 0 && _testAssertsPassed == 0) {
_testReturnValue = TEST_RESULT_NO_ASSERT;
}
if(GetInvocationCount() > 0) {
Log(time(0), "Fuzzer invocation count: %d", GetInvocationCount());
}
if(GetInvocationCount() > 0) {
Log(time(0), "Fuzzer invocation count: %d", GetInvocationCount());
}
DeinitFuzzer();
DeinitFuzzer();
return _testReturnValue;
return _testReturnValue;
}
int
_CountFailedAsserts() {
return _testAssertsFailed;
return _testAssertsFailed;
}
/*!
@@ -87,18 +87,18 @@ void
_BailOut()
{
if(!canBailOut)
return ;
return ;
AssertSummary(_testAssertsFailed + _testAssertsPassed,
AssertSummary(_testAssertsFailed + _testAssertsPassed,
_testAssertsFailed, _testAssertsPassed, time(0));
if(GetInvocationCount() > 0) {
Log(time(0), "Fuzzer invocation count: %d", GetInvocationCount());
}
if(GetInvocationCount() > 0) {
Log(time(0), "Fuzzer invocation count: %d", GetInvocationCount());
}
DeinitFuzzer();
DeinitFuzzer();
exit(TEST_RESULT_FAILURE); // bail out from the test
exit(TEST_RESULT_FAILURE); // bail out from the test
}
void
@@ -120,8 +120,8 @@ AssertEquals(int expected, int actual, char *message, ...)
_BailOut();
} else {
AssertWithValues("AssertEquals", 1, buf,
actual, expected, time(0));
AssertWithValues("AssertEquals", 1, buf,
actual, expected, time(0));
_testAssertsPassed++;
}
@@ -145,9 +145,9 @@ AssertTrue(int condition, char *message, ...)
_BailOut();
} else {
Assert("AssertTrue", 1, buf, time(0));
Assert("AssertTrue", 1, buf, time(0));
_testAssertsPassed++;
_testAssertsPassed++;
}
}
@@ -156,7 +156,7 @@ AssertPass(char *message, ...)
{
va_list args;
char buf[256];
va_start( args, message );
SDL_vsnprintf( buf, sizeof(buf), message, args );
va_end( args );
@@ -172,7 +172,7 @@ AssertFail(char *message, ...)
{
va_list args;
char buf[256];
va_start( args, message );
SDL_vsnprintf( buf, sizeof(buf), message, args );
va_end( args );

View File

@@ -22,12 +22,12 @@
typedef struct SurfaceImage_s {
int width;
int height;
unsigned int bytes_per_pixel; /* 3:RGB, 4:RGBA */
unsigned int bytes_per_pixel; /* 3:RGB, 4:RGBA */
const unsigned char pixel_data[];
} SurfaceImage_t;
#define ALLOWABLE_ERROR_OPAQUE 0
#define ALLOWABLE_ERROR_BLENDED 64
#define ALLOWABLE_ERROR_OPAQUE 0
#define ALLOWABLE_ERROR_BLENDED 64
/**
* @brief Compares a surface and a surface image for equality.

View File

@@ -38,156 +38,156 @@ int invocationCounter = 0;
Uint64
GenerateExecKey(char *runSeed, char *suiteName,
char *testName, int iterationNumber)
char *testName, int iterationNumber)
{
if(runSeed == NULL) {
fprintf(stderr, "Error: Incorrect runSeed given to GenerateExecKey function\n");
return -1;
}
if(runSeed == NULL) {
fprintf(stderr, "Error: Incorrect runSeed given to GenerateExecKey function\n");
return -1;
}
if(suiteName == NULL) {
fprintf(stderr, "Error: Incorrect suiteName given to GenerateExecKey function\n");
return -1;
}
if(suiteName == NULL) {
fprintf(stderr, "Error: Incorrect suiteName given to GenerateExecKey function\n");
return -1;
}
if(testName == NULL) {
fprintf(stderr, "Error: Incorrect testName given to GenerateExecKey function\n");
return -1;
}
if(testName == NULL) {
fprintf(stderr, "Error: Incorrect testName given to GenerateExecKey function\n");
return -1;
}
if(iterationNumber < 0) {
fprintf(stderr, "Error: Incorrect iteration number given to GenerateExecKey function\n");
return -1;
}
if(iterationNumber < 0) {
fprintf(stderr, "Error: Incorrect iteration number given to GenerateExecKey function\n");
return -1;
}
char iterationString[16];
memset(iterationString, 0, sizeof(iterationString));
SDL_snprintf(iterationString, sizeof(iterationString) - 1, "%d", iterationNumber);
char iterationString[16];
memset(iterationString, 0, sizeof(iterationString));
SDL_snprintf(iterationString, sizeof(iterationString) - 1, "%d", iterationNumber);
// combine the parameters
const Uint32 runSeedLength = strlen(runSeed);
const Uint32 suiteNameLength = strlen(suiteName);
const Uint32 testNameLength = strlen(testName);
const Uint32 iterationStringLength = strlen(iterationString);
// combine the parameters
const Uint32 runSeedLength = strlen(runSeed);
const Uint32 suiteNameLength = strlen(suiteName);
const Uint32 testNameLength = strlen(testName);
const Uint32 iterationStringLength = strlen(iterationString);
// size of the entire + 3 for slashes and + 1 for '\0'
const Uint32 entireString = runSeedLength + suiteNameLength +
testNameLength + iterationStringLength + 3 + 1;
// size of the entire + 3 for slashes and + 1 for '\0'
const Uint32 entireString = runSeedLength + suiteNameLength +
testNameLength + iterationStringLength + 3 + 1;
char *buffer = SDL_malloc(entireString);
if(!buffer) {
return 0;
}
char *buffer = SDL_malloc(entireString);
if(!buffer) {
return 0;
}
SDL_snprintf(buffer, entireString, "%s/%s/%s/%d", runSeed, suiteName,
testName, iterationNumber);
SDL_snprintf(buffer, entireString, "%s/%s/%s/%d", runSeed, suiteName,
testName, iterationNumber);
MD5_CTX md5Context;
utl_md5Init(&md5Context);
utl_md5Update(&md5Context, buffer, entireString);
utl_md5Final(&md5Context);
MD5_CTX md5Context;
utl_md5Init(&md5Context);
utl_md5Update(&md5Context, buffer, entireString);
utl_md5Final(&md5Context);
SDL_free(buffer);
SDL_free(buffer);
Uint64 *keys = (Uint64 *)md5Context.digest;
Uint64 *keys = (Uint64 *)md5Context.digest;
return keys[0];
return keys[0];
}
void
InitFuzzer(Uint64 execKey)
{
Uint32 a = (execKey >> 32) & 0x00000000FFFFFFFF;
Uint32 b = execKey & 0x00000000FFFFFFFF;
utl_randomInit(&rndContext, a, b);
Uint32 a = (execKey >> 32) & 0x00000000FFFFFFFF;
Uint32 b = execKey & 0x00000000FFFFFFFF;
utl_randomInit(&rndContext, a, b);
}
int
GetInvocationCount()
{
return invocationCounter;
return invocationCounter;
}
void
DeinitFuzzer()
{
invocationCounter = 0;
invocationCounter = 0;
}
Uint8
RandomUint8()
{
invocationCounter++;
invocationCounter++;
return (Uint8) utl_randomInt(&rndContext) & 0x000000FF;
return (Uint8) utl_randomInt(&rndContext) & 0x000000FF;
}
Sint8
RandomSint8()
{
invocationCounter++;
invocationCounter++;
return (Sint8) utl_randomInt(&rndContext) & 0x000000FF;
return (Sint8) utl_randomInt(&rndContext) & 0x000000FF;
}
Uint16
RandomUint16()
{
invocationCounter++;
invocationCounter++;
return (Uint16) utl_randomInt(&rndContext) & 0x0000FFFF;
return (Uint16) utl_randomInt(&rndContext) & 0x0000FFFF;
}
Sint16
RandomSint16()
{
invocationCounter++;
invocationCounter++;
return (Sint16) utl_randomInt(&rndContext) & 0x0000FFFF;
return (Sint16) utl_randomInt(&rndContext) & 0x0000FFFF;
}
Sint32
RandomSint32()
{
invocationCounter++;
invocationCounter++;
return (Sint32) utl_randomInt(&rndContext);
return (Sint32) utl_randomInt(&rndContext);
}
Uint32
RandomUint32()
{
invocationCounter++;
invocationCounter++;
return (Uint32) utl_randomInt(&rndContext);
return (Uint32) utl_randomInt(&rndContext);
}
Uint64
RandomUint64()
{
Uint64 value;
Uint64 value;
invocationCounter++;
invocationCounter++;
Uint32 *vp = (Uint32*)&value;
vp[0] = RandomSint32();
vp[1] = RandomSint32();
Uint32 *vp = (Uint32*)&value;
vp[0] = RandomSint32();
vp[1] = RandomSint32();
return value;
return value;
}
Sint64
RandomSint64()
{
Uint64 value;
Uint64 value;
invocationCounter++;
invocationCounter++;
Uint32 *vp = (Uint32*)&value;
vp[0] = RandomSint32();
vp[1] = RandomSint32();
Uint32 *vp = (Uint32*)&value;
vp[0] = RandomSint32();
vp[1] = RandomSint32();
return value;
return value;
}
@@ -195,20 +195,20 @@ RandomSint64()
Sint32
RandomIntegerInRange(Sint32 pMin, Sint32 pMax)
{
Sint64 min = pMin;
Sint64 max = pMax;
Sint64 min = pMin;
Sint64 max = pMax;
if(pMin > pMax) {
Sint64 temp = min;
min = max;
max = temp;
} else if(pMin == pMax) {
return min;
}
if(pMin > pMax) {
Sint64 temp = min;
min = max;
max = temp;
} else if(pMin == pMax) {
return min;
}
Sint64 number = RandomUint32(); // invocation count increment in there
Sint64 number = RandomUint32(); // invocation count increment in there
return (Sint32)((number % ((max + 1) - min)) + min);
return (Sint32)((number % ((max + 1) - min)) + min);
}
/*!
@@ -230,7 +230,7 @@ RandomIntegerInRange(Sint32 pMin, Sint32 pMax)
* If outbuffer != NULL, it'll be freed.
*
* \param maxValue The biggest value that is acceptable for this data type.
* For instance, for Uint8 -> 255, Uint16 -> 65536 etc.
* For instance, for Uint8 -> 255, Uint16 -> 65536 etc.
* \param pBoundary1 defines lower boundary
* \param pBoundary2 defines upper boundary
* \param validDomain Generate only for valid domain (for the data type)
@@ -241,164 +241,164 @@ RandomIntegerInRange(Sint32 pMin, Sint32 pMax)
*/
Uint32
GenerateUnsignedBoundaryValues(const Uint64 maxValue,
Uint64 pBoundary1, Uint64 pBoundary2, SDL_bool validDomain,
Uint64 *outBuffer)
Uint64 pBoundary1, Uint64 pBoundary2, SDL_bool validDomain,
Uint64 *outBuffer)
{
Uint64 boundary1 = pBoundary1, boundary2 = pBoundary2;
Uint64 boundary1 = pBoundary1, boundary2 = pBoundary2;
if(outBuffer != NULL) {
SDL_free(outBuffer);
}
if(outBuffer != NULL) {
SDL_free(outBuffer);
}
if(boundary1 > boundary2) {
Uint64 temp = boundary1;
boundary1 = boundary2;
boundary2 = temp;
}
if(boundary1 > boundary2) {
Uint64 temp = boundary1;
boundary1 = boundary2;
boundary2 = temp;
}
Uint64 tempBuf[4];
Uint64 index = 0;
Uint64 tempBuf[4];
Uint64 index = 0;
if(boundary1 == boundary2) {
tempBuf[index++] = boundary1;
}
else if(validDomain) {
tempBuf[index++] = boundary1;
if(boundary1 == boundary2) {
tempBuf[index++] = boundary1;
}
else if(validDomain) {
tempBuf[index++] = boundary1;
if(boundary1 < UINT64_MAX)
tempBuf[index++] = boundary1 + 1;
if(boundary1 < UINT64_MAX)
tempBuf[index++] = boundary1 + 1;
tempBuf[index++] = boundary2 - 1;
tempBuf[index++] = boundary2;
}
else {
if(boundary1 > 0) {
tempBuf[index++] = boundary1 - 1;
}
tempBuf[index++] = boundary2 - 1;
tempBuf[index++] = boundary2;
}
else {
if(boundary1 > 0) {
tempBuf[index++] = boundary1 - 1;
}
if(boundary2 < maxValue && boundary2 < UINT64_MAX) {
tempBuf[index++] = boundary2 + 1;
}
}
if(boundary2 < maxValue && boundary2 < UINT64_MAX) {
tempBuf[index++] = boundary2 + 1;
}
}
if(index == 0) {
// There are no valid boundaries
return 0;
}
if(index == 0) {
// There are no valid boundaries
return 0;
}
// Create the return buffer
outBuffer = SDL_malloc(index * sizeof(Uint64));
if(outBuffer == NULL) {
return 0;
}
// Create the return buffer
outBuffer = SDL_malloc(index * sizeof(Uint64));
if(outBuffer == NULL) {
return 0;
}
SDL_memcpy(outBuffer, tempBuf, index * sizeof(Uint64));
SDL_memcpy(outBuffer, tempBuf, index * sizeof(Uint64));
return index;
return index;
}
Uint8
RandomUint8BoundaryValue(Uint8 boundary1, Uint8 boundary2, SDL_bool validDomain)
{
Uint64 *buffer = NULL;
Uint32 size;
Uint64 *buffer = NULL;
Uint32 size;
// max value for Uint8
const Uint64 maxValue = UINT8_MAX;
// max value for Uint8
const Uint64 maxValue = UINT8_MAX;
size = GenerateUnsignedBoundaryValues(maxValue,
(Uint64) boundary1, (Uint64) boundary2,
validDomain, buffer);
if(size == 0) {
return 0;
}
size = GenerateUnsignedBoundaryValues(maxValue,
(Uint64) boundary1, (Uint64) boundary2,
validDomain, buffer);
if(size == 0) {
return 0;
}
Uint32 index = RandomSint32() % size;
Uint8 retVal = (Uint8) buffer[index];
Uint32 index = RandomSint32() % size;
Uint8 retVal = (Uint8) buffer[index];
SDL_free(buffer);
SDL_free(buffer);
invocationCounter++;
invocationCounter++;
return retVal;
return retVal;
}
Uint16
RandomUint16BoundaryValue(Uint16 boundary1, Uint16 boundary2, SDL_bool validDomain)
{
Uint64 *buffer = NULL;
Uint32 size;
Uint64 *buffer = NULL;
Uint32 size;
// max value for Uint16
const Uint64 maxValue = UINT16_MAX;
// max value for Uint16
const Uint64 maxValue = UINT16_MAX;
size = GenerateUnsignedBoundaryValues(maxValue,
(Uint64) boundary1, (Uint64) boundary2,
validDomain, buffer);
if(size == 0) {
return 0;
}
size = GenerateUnsignedBoundaryValues(maxValue,
(Uint64) boundary1, (Uint64) boundary2,
validDomain, buffer);
if(size == 0) {
return 0;
}
Uint32 index = RandomSint32() % size;
Uint16 retVal = (Uint16) buffer[index];
Uint32 index = RandomSint32() % size;
Uint16 retVal = (Uint16) buffer[index];
SDL_free(buffer);
SDL_free(buffer);
invocationCounter++;
invocationCounter++;
return retVal;
return retVal;
}
Uint32
RandomUint32BoundaryValue(Uint32 boundary1, Uint32 boundary2, SDL_bool validDomain)
{
Uint64 *buffer = NULL;
Uint32 size;
Uint64 *buffer = NULL;
Uint32 size;
// max value for Uint32
const Uint64 maxValue = UINT32_MAX;
// max value for Uint32
const Uint64 maxValue = UINT32_MAX;
size = GenerateUnsignedBoundaryValues(maxValue,
(Uint64) boundary1, (Uint64) boundary2,
validDomain, buffer);
if(size == 0) {
return 0;
}
size = GenerateUnsignedBoundaryValues(maxValue,
(Uint64) boundary1, (Uint64) boundary2,
validDomain, buffer);
if(size == 0) {
return 0;
}
Uint32 index = RandomSint32() % size;
Uint32 retVal = (Uint32) buffer[index];
Uint32 index = RandomSint32() % size;
Uint32 retVal = (Uint32) buffer[index];
SDL_free(buffer);
SDL_free(buffer);
invocationCounter++;
invocationCounter++;
return retVal;
return retVal;
}
Uint64
RandomUint64BoundaryValue(Uint64 boundary1, Uint64 boundary2, SDL_bool validDomain)
{
Uint64 *buffer = NULL;
Uint32 size;
Uint64 *buffer = NULL;
Uint32 size;
// max value for Uint64
const Uint64 maxValue = UINT64_MAX;
// max value for Uint64
const Uint64 maxValue = UINT64_MAX;
size = GenerateUnsignedBoundaryValues(maxValue,
(Uint64) boundary1, (Uint64) boundary2,
validDomain, buffer);
if(size == 0) {
return 0;
}
size = GenerateUnsignedBoundaryValues(maxValue,
(Uint64) boundary1, (Uint64) boundary2,
validDomain, buffer);
if(size == 0) {
return 0;
}
Uint32 index = RandomSint32() % size;
Uint64 retVal = (Uint64) buffer[index];
Uint32 index = RandomSint32() % size;
Uint64 retVal = (Uint64) buffer[index];
SDL_free(buffer);
SDL_free(buffer);
invocationCounter++;
invocationCounter++;
return retVal;
return retVal;
}
/*!
@@ -421,9 +421,9 @@ RandomUint64BoundaryValue(Uint64 boundary1, Uint64 boundary2, SDL_bool validDoma
*
*
* \param minValue The smallest value that is acceptable for this data type.
* For instance, for Uint8 -> -128, Uint16 -> -32,768 etc.
* For instance, for Uint8 -> -128, Uint16 -> -32,768 etc.
* \param maxValue The biggest value that is acceptable for this data type.
* For instance, for Uint8 -> 127, Uint16 -> 32767 etc.
* For instance, for Uint8 -> 127, Uint16 -> 32767 etc.
* \param pBoundary1 defines lower boundary
* \param pBoundary2 defines upper boundary
* \param validDomain Generate only for valid domain (for the data type)
@@ -434,229 +434,229 @@ RandomUint64BoundaryValue(Uint64 boundary1, Uint64 boundary2, SDL_bool validDoma
*/
Uint32
GenerateSignedBoundaryValues(const Sint64 minValue, const Sint64 maxValue,
Sint64 pBoundary1, Sint64 pBoundary2, SDL_bool validDomain,
Sint64 *outBuffer)
Sint64 pBoundary1, Sint64 pBoundary2, SDL_bool validDomain,
Sint64 *outBuffer)
{
Sint64 boundary1 = pBoundary1, boundary2 = pBoundary2;
Sint64 boundary1 = pBoundary1, boundary2 = pBoundary2;
if(outBuffer != NULL) {
SDL_free(outBuffer);
}
if(outBuffer != NULL) {
SDL_free(outBuffer);
}
if(boundary1 > boundary2) {
Sint64 temp = boundary1;
boundary1 = boundary2;
boundary2 = temp;
}
if(boundary1 > boundary2) {
Sint64 temp = boundary1;
boundary1 = boundary2;
boundary2 = temp;
}
Sint64 tempBuf[4];
Sint64 tempBuf[4];
Sint64 index = 0;
Sint64 index = 0;
if(boundary1 == boundary2) {
tempBuf[index++] = boundary1;
}
else if(validDomain) {
tempBuf[index++] = boundary1;
if(boundary1 == boundary2) {
tempBuf[index++] = boundary1;
}
else if(validDomain) {
tempBuf[index++] = boundary1;
if(boundary1 < LLONG_MAX)
tempBuf[index++] = boundary1 + 1;
if(boundary1 < LLONG_MAX)
tempBuf[index++] = boundary1 + 1;
if(boundary2 > LLONG_MIN)
tempBuf[index++] = boundary2 - 1;
if(boundary2 > LLONG_MIN)
tempBuf[index++] = boundary2 - 1;
tempBuf[index++] = boundary2;
}
else {
if(boundary1 > minValue && boundary1 > LLONG_MIN) {
tempBuf[index++] = boundary1 - 1;
}
tempBuf[index++] = boundary2;
}
else {
if(boundary1 > minValue && boundary1 > LLONG_MIN) {
tempBuf[index++] = boundary1 - 1;
}
if(boundary2 < maxValue && boundary2 < UINT64_MAX) {
tempBuf[index++] = boundary2 + 1;
}
}
if(boundary2 < maxValue && boundary2 < UINT64_MAX) {
tempBuf[index++] = boundary2 + 1;
}
}
if(index == 0) {
// There are no valid boundaries
return 0;
}
if(index == 0) {
// There are no valid boundaries
return 0;
}
// Create the return buffer
outBuffer = SDL_malloc(index * sizeof(Sint64));
if(outBuffer == NULL) {
return 0;
}
// Create the return buffer
outBuffer = SDL_malloc(index * sizeof(Sint64));
if(outBuffer == NULL) {
return 0;
}
SDL_memcpy(outBuffer, tempBuf, index * sizeof(Sint64));
SDL_memcpy(outBuffer, tempBuf, index * sizeof(Sint64));
return index;
return index;
}
Sint8
RandomSint8BoundaryValue(Sint8 boundary1, Sint8 boundary2, SDL_bool validDomain)
{
Sint64 *buffer = NULL;
Uint32 size;
Sint64 *buffer = NULL;
Uint32 size;
// min & max values for Sint8
const Sint64 maxValue = CHAR_MAX;
const Sint64 minValue = CHAR_MIN;
// min & max values for Sint8
const Sint64 maxValue = CHAR_MAX;
const Sint64 minValue = CHAR_MIN;
size = GenerateSignedBoundaryValues(minValue, maxValue,
(Sint64) boundary1, (Sint64) boundary2,
validDomain, buffer);
if(size == 0) {
return CHAR_MIN;
}
size = GenerateSignedBoundaryValues(minValue, maxValue,
(Sint64) boundary1, (Sint64) boundary2,
validDomain, buffer);
if(size == 0) {
return CHAR_MIN;
}
Uint32 index = RandomSint32() % size;
Sint8 retVal = (Sint8) buffer[index];
Uint32 index = RandomSint32() % size;
Sint8 retVal = (Sint8) buffer[index];
SDL_free(buffer);
SDL_free(buffer);
invocationCounter++;
invocationCounter++;
return retVal;
return retVal;
}
Sint16
RandomSint16BoundaryValue(Sint16 boundary1, Sint16 boundary2, SDL_bool validDomain)
{
Sint64 *buffer = NULL;
Uint32 size;
Sint64 *buffer = NULL;
Uint32 size;
// min & max values for Sint16
const Sint64 maxValue = SHRT_MAX;
const Sint64 minValue = SHRT_MIN;
// min & max values for Sint16
const Sint64 maxValue = SHRT_MAX;
const Sint64 minValue = SHRT_MIN;
size = GenerateSignedBoundaryValues(minValue, maxValue,
(Sint64) boundary1, (Sint64) boundary2,
validDomain, buffer);
if(size == 0) {
return SHRT_MIN;
}
size = GenerateSignedBoundaryValues(minValue, maxValue,
(Sint64) boundary1, (Sint64) boundary2,
validDomain, buffer);
if(size == 0) {
return SHRT_MIN;
}
Uint32 index = RandomSint32() % size;
Sint16 retVal = (Sint16) buffer[index];
Uint32 index = RandomSint32() % size;
Sint16 retVal = (Sint16) buffer[index];
SDL_free(buffer);
SDL_free(buffer);
invocationCounter++;
invocationCounter++;
return retVal;
return retVal;
}
Sint32
RandomSint32BoundaryValue(Sint32 boundary1, Sint32 boundary2, SDL_bool validDomain)
{
Sint64 *buffer = NULL;
Uint32 size;
Sint64 *buffer = NULL;
Uint32 size;
// min & max values for Sint32
const Sint64 maxValue = INT_MAX;
const Sint64 minValue = INT_MIN;
// min & max values for Sint32
const Sint64 maxValue = INT_MAX;
const Sint64 minValue = INT_MIN;
size = GenerateSignedBoundaryValues(minValue, maxValue,
(Sint64) boundary1, (Sint64) boundary2,
validDomain, buffer);
if(size == 0) {
return INT_MIN;
}
size = GenerateSignedBoundaryValues(minValue, maxValue,
(Sint64) boundary1, (Sint64) boundary2,
validDomain, buffer);
if(size == 0) {
return INT_MIN;
}
Uint32 index = RandomSint32() % size;
Sint32 retVal = (Sint32) buffer[index];
Uint32 index = RandomSint32() % size;
Sint32 retVal = (Sint32) buffer[index];
SDL_free(buffer);
SDL_free(buffer);
invocationCounter++;
invocationCounter++;
return retVal;
return retVal;
}
Sint64
RandomSint64BoundaryValue(Sint64 boundary1, Sint64 boundary2, SDL_bool validDomain)
{
Sint64 *buffer = NULL;
Uint32 size;
Sint64 *buffer = NULL;
Uint32 size;
// min & max values for Sint64
const Sint64 maxValue = LLONG_MAX;
const Sint64 minValue = LLONG_MIN;
// min & max values for Sint64
const Sint64 maxValue = LLONG_MAX;
const Sint64 minValue = LLONG_MIN;
size = GenerateSignedBoundaryValues(minValue, maxValue,
(Sint64) boundary1, (Sint64) boundary2,
validDomain, buffer);
if(size == 0) {
return LLONG_MIN;
}
size = GenerateSignedBoundaryValues(minValue, maxValue,
(Sint64) boundary1, (Sint64) boundary2,
validDomain, buffer);
if(size == 0) {
return LLONG_MIN;
}
Uint32 index = RandomSint32() % size;
Sint64 retVal = (Sint64) buffer[index];
Uint32 index = RandomSint32() % size;
Sint64 retVal = (Sint64) buffer[index];
SDL_free(buffer);
SDL_free(buffer);
invocationCounter++;
invocationCounter++;
return retVal;
return retVal;
}
float
RandomUnitFloat()
{
return (float) RandomUint32() / UINT_MAX;
return (float) RandomUint32() / UINT_MAX;
}
double
RandomUnitDouble()
{
return (RandomUint64() >> 11) * (1.0/9007199254740992.0);
return (RandomUint64() >> 11) * (1.0/9007199254740992.0);
}
float
RandomFloat()
{
invocationCounter++;
invocationCounter++;
// \todo to be implemented
return 0.0f;
// \todo to be implemented
return 0.0f;
}
double
RandomDouble()
{
invocationCounter++;
invocationCounter++;
// \todo to be implemented
return 0.0f;
// \todo to be implemented
return 0.0f;
}
char *
RandomAsciiString()
{
// note: invocationCounter is increment in the RandomAsciiStringWithMaximumLenght
return RandomAsciiStringWithMaximumLength(255);
// note: invocationCounter is increment in the RandomAsciiStringWithMaximumLenght
return RandomAsciiStringWithMaximumLength(255);
}
char *
RandomAsciiStringWithMaximumLength(int maxSize)
{
invocationCounter++;
invocationCounter++;
if(maxSize < 1) {
return NULL;
}
if(maxSize < 1) {
return NULL;
}
int size = (RandomUint32() % (maxSize + 1)) + 1;
char *string = SDL_malloc(size * sizeof(char));
int size = (RandomUint32() % (maxSize + 1)) + 1;
char *string = SDL_malloc(size * sizeof(char));
int counter = 0;
for( ; counter < size; ++counter) {
string[counter] = (char) RandomIntegerInRange(1, 127);
}
int counter = 0;
for( ; counter < size; ++counter) {
string[counter] = (char) RandomIntegerInRange(1, 127);
}
string[counter] = '\0';
string[counter] = '\0';
return string;
return string;
}

View File

@@ -349,7 +349,7 @@ char *RandomAsciiStringWithMaximumLength(int maxLength);
* \param iterationNumber of test iteration
*
* \return Generated execution key as blob of 16 bytes. It needs be deallocated.
* On error, returns NULL.
* On error, returns NULL.
*/
Uint64 GenerateExecKey(char *runSeed, char *suiteName, char *testName, int iterationNumber);

View File

@@ -9,10 +9,10 @@ int utl_crc32Init(CRC32_CTX *crcContext)
/* Sanity check context pointer */
if (crcContext==NULL) {
return(-1);
}
}
/*
* Build auxiliary table for parallel byte-at-a-time CRC-32
* Build auxiliary table for parallel byte-at-a-time CRC-32
*/
#ifdef ORIGINAL_METHOD
for (i = 0; i < 256; ++i) {
@@ -34,7 +34,7 @@ int utl_crc32Init(CRC32_CTX *crcContext)
crcContext->crc32_table[i] = c;
}
#endif
return(0);
}
@@ -50,7 +50,7 @@ int utl_crc32Calc(CRC32_CTX * crcContext, CrcUint8 *inBuf, CrcUint32 inLen, CrcU
}
if (utl_crc32CalcEnd(crcContext, crc32)) {
return(-1);
}
}
return(0);
}
@@ -62,10 +62,10 @@ int utl_crc32CalcStart(CRC32_CTX * crcContext, CrcUint32 *crc32)
if (crcContext==NULL) {
*crc32=0;
return(-1);
}
}
/*
* Preload shift register, per CRC-32 spec
* Preload shift register, per CRC-32 spec
*/
*crc32 = 0xffffffff;
@@ -77,7 +77,7 @@ int utl_crc32CalcStart(CRC32_CTX * crcContext, CrcUint32 *crc32)
int utl_crc32CalcEnd(CRC32_CTX * crcContext, CrcUint32 *crc32)
{
/*
* Return complement, per CRC-32 spec
* Return complement, per CRC-32 spec
*/
*crc32 = (~(*crc32));
@@ -95,22 +95,22 @@ int utl_crc32CalcBuffer(CRC32_CTX * crcContext, CrcUint8 *inBuf, CrcUint32 inLen
if (crcContext==NULL) {
*crc32=0;
return(-1);
}
}
/*
* Calculate CRC from data
* Calculate CRC from data
*/
crc = *crc32;
for (p = inBuf; inLen > 0; ++p, --inLen) {
#ifdef ORIGINAL_METHOD
#ifdef ORIGINAL_METHOD
crc = (crc << 8) ^ crcContext->crc32_table[(crc >> 24) ^ *p];
#else
crc = ((crc >> 8) & 0x00FFFFFF) ^ crcContext->crc32_table[ (crc ^ *p) & 0xFF ];
#endif
}
#endif
}
*crc32 = crc;
return(0);
}
@@ -119,7 +119,7 @@ int utl_crc32Done(CRC32_CTX * crcContext)
/* Sanity check context pointer */
if (crcContext==NULL) {
return(-1);
}
}
return(0);
}

View File

@@ -15,14 +15,14 @@ extern "C" {
/* Definition shared by all CRC routines */
#ifndef CrcUint32
#define CrcUint32 unsigned int
#define CrcUint32 unsigned int
#endif
#ifndef CrcUint8
#define CrcUint8 unsigned char
#define CrcUint8 unsigned char
#endif
#ifdef ORIGINAL_METHOD
#define CRC32_POLY 0x04c11db7 /* AUTODIN II, Ethernet, & FDDI */
#define CRC32_POLY 0x04c11db7 /* AUTODIN II, Ethernet, & FDDI */
#else
#define CRC32_POLY 0xEDB88320 /* Perl String::CRC32 compatible */
#endif
@@ -45,12 +45,12 @@ extern "C" {
#define DLLINTERFACE
#endif
/*
/*
* utl_crc32Init: initialize the CRC context
*
* Parameters:
*
* crcContext pointer to context variable
* crcContext pointer to context variable
*
* Return value:
*
@@ -64,10 +64,10 @@ extern "C" {
/*
* utl_crc32Calc: calculate a crc32 from a data block
*
*
* Parameters:
*
* crcContext pointer to context variable
* crcContext pointer to context variable
* inBuf input buffer to checksum
* inLen length of input buffer
* crc32 pointer to Uint32 to store the final CRC into
@@ -93,7 +93,7 @@ extern "C" {
*
* Parameters:
*
* crcContext pointer to context variable
* crcContext pointer to context variable
*
* Return value:
*

View File

@@ -81,7 +81,7 @@ static unsigned char MD5PADDING[64] = {
(a) += (b); \
}
/*
/*
The routine MD5Init initializes the message-digest context
mdContext. All fields are set to zero.
*/
@@ -99,26 +99,26 @@ void utl_md5Init(MD5_CTX * mdContext)
mdContext->buf[3] = (MD5UINT4) 0x10325476;
}
/*
/*
The routine MD5Update updates the message-digest context to
account for the presence of each of the characters inBuf[0..inLen-1]
in the message whose digest is being computed.
*/
void utl_md5Update(MD5_CTX * mdContext, unsigned char *inBuf,
unsigned int inLen)
unsigned int inLen)
{
MD5UINT4 in[16];
int mdi;
unsigned int i, ii;
/*
* compute number of bytes mod 64
* compute number of bytes mod 64
*/
mdi = (int) ((mdContext->i[0] >> 3) & 0x3F);
/*
* update number of bits
* update number of bits
*/
if ((mdContext->i[0] + ((MD5UINT4) inLen << 3)) < mdContext->i[0])
mdContext->i[1]++;
@@ -127,26 +127,26 @@ void utl_md5Update(MD5_CTX * mdContext, unsigned char *inBuf,
while (inLen--) {
/*
* add new character to buffer, increment mdi
* add new character to buffer, increment mdi
*/
mdContext->in[mdi++] = *inBuf++;
/*
* transform if necessary
* transform if necessary
*/
if (mdi == 0x40) {
for (i = 0, ii = 0; i < 16; i++, ii += 4)
in[i] = (((MD5UINT4) mdContext->in[ii + 3]) << 24) |
(((MD5UINT4) mdContext->in[ii + 2]) << 16) |
(((MD5UINT4) mdContext->in[ii + 1]) << 8) |
((MD5UINT4) mdContext->in[ii]);
in[i] = (((MD5UINT4) mdContext->in[ii + 3]) << 24) |
(((MD5UINT4) mdContext->in[ii + 2]) << 16) |
(((MD5UINT4) mdContext->in[ii + 1]) << 8) |
((MD5UINT4) mdContext->in[ii]);
Transform(mdContext->buf, in);
mdi = 0;
}
}
}
/*
/*
The routine MD5Final terminates the message-digest computation and
ends with the desired message digest in mdContext->digest[0...15].
*/
@@ -159,24 +159,24 @@ void utl_md5Final(MD5_CTX * mdContext)
unsigned int padLen;
/*
* save number of bits
* save number of bits
*/
in[14] = mdContext->i[0];
in[15] = mdContext->i[1];
/*
* compute number of bytes mod 64
* compute number of bytes mod 64
*/
mdi = (int) ((mdContext->i[0] >> 3) & 0x3F);
/*
* pad out to 56 mod 64
* pad out to 56 mod 64
*/
padLen = (mdi < 56) ? (56 - mdi) : (120 - mdi);
utl_md5Update(mdContext, MD5PADDING, padLen);
/*
* append length in bits and transform
* append length in bits and transform
*/
for (i = 0, ii = 0; i < 14; i++, ii += 4)
in[i] = (((MD5UINT4) mdContext->in[ii + 3]) << 24) |
@@ -186,7 +186,7 @@ void utl_md5Final(MD5_CTX * mdContext)
Transform(mdContext->buf, in);
/*
* store buffer in digest
* store buffer in digest
*/
for (i = 0, ii = 0; i < 4; i++, ii += 4) {
mdContext->digest[ii] = (unsigned char) (mdContext->buf[i] & 0xFF);
@@ -206,100 +206,100 @@ static void Transform(MD5UINT4 * buf, MD5UINT4 * in)
MD5UINT4 a = buf[0], b = buf[1], c = buf[2], d = buf[3];
/*
* Round 1
* Round 1
*/
#define S11 7
#define S12 12
#define S13 17
#define S14 22
FF(a, b, c, d, in[0], S11, 3614090360u); /* 1 */
FF(d, a, b, c, in[1], S12, 3905402710u); /* 2 */
FF(c, d, a, b, in[2], S13, 606105819u); /* 3 */
FF(b, c, d, a, in[3], S14, 3250441966u); /* 4 */
FF(a, b, c, d, in[4], S11, 4118548399u); /* 5 */
FF(d, a, b, c, in[5], S12, 1200080426u); /* 6 */
FF(c, d, a, b, in[6], S13, 2821735955u); /* 7 */
FF(b, c, d, a, in[7], S14, 4249261313u); /* 8 */
FF(a, b, c, d, in[8], S11, 1770035416u); /* 9 */
FF(d, a, b, c, in[9], S12, 2336552879u); /* 10 */
FF(c, d, a, b, in[10], S13, 4294925233u); /* 11 */
FF(b, c, d, a, in[11], S14, 2304563134u); /* 12 */
FF(a, b, c, d, in[12], S11, 1804603682u); /* 13 */
FF(d, a, b, c, in[13], S12, 4254626195u); /* 14 */
FF(c, d, a, b, in[14], S13, 2792965006u); /* 15 */
FF(b, c, d, a, in[15], S14, 1236535329u); /* 16 */
FF(a, b, c, d, in[0], S11, 3614090360u); /* 1 */
FF(d, a, b, c, in[1], S12, 3905402710u); /* 2 */
FF(c, d, a, b, in[2], S13, 606105819u); /* 3 */
FF(b, c, d, a, in[3], S14, 3250441966u); /* 4 */
FF(a, b, c, d, in[4], S11, 4118548399u); /* 5 */
FF(d, a, b, c, in[5], S12, 1200080426u); /* 6 */
FF(c, d, a, b, in[6], S13, 2821735955u); /* 7 */
FF(b, c, d, a, in[7], S14, 4249261313u); /* 8 */
FF(a, b, c, d, in[8], S11, 1770035416u); /* 9 */
FF(d, a, b, c, in[9], S12, 2336552879u); /* 10 */
FF(c, d, a, b, in[10], S13, 4294925233u); /* 11 */
FF(b, c, d, a, in[11], S14, 2304563134u); /* 12 */
FF(a, b, c, d, in[12], S11, 1804603682u); /* 13 */
FF(d, a, b, c, in[13], S12, 4254626195u); /* 14 */
FF(c, d, a, b, in[14], S13, 2792965006u); /* 15 */
FF(b, c, d, a, in[15], S14, 1236535329u); /* 16 */
/*
* Round 2
* Round 2
*/
#define S21 5
#define S22 9
#define S23 14
#define S24 20
GG(a, b, c, d, in[1], S21, 4129170786u); /* 17 */
GG(d, a, b, c, in[6], S22, 3225465664u); /* 18 */
GG(c, d, a, b, in[11], S23, 643717713u); /* 19 */
GG(b, c, d, a, in[0], S24, 3921069994u); /* 20 */
GG(a, b, c, d, in[5], S21, 3593408605u); /* 21 */
GG(d, a, b, c, in[10], S22, 38016083u); /* 22 */
GG(c, d, a, b, in[15], S23, 3634488961u); /* 23 */
GG(b, c, d, a, in[4], S24, 3889429448u); /* 24 */
GG(a, b, c, d, in[9], S21, 568446438u); /* 25 */
GG(d, a, b, c, in[14], S22, 3275163606u); /* 26 */
GG(c, d, a, b, in[3], S23, 4107603335u); /* 27 */
GG(b, c, d, a, in[8], S24, 1163531501u); /* 28 */
GG(a, b, c, d, in[13], S21, 2850285829u); /* 29 */
GG(d, a, b, c, in[2], S22, 4243563512u); /* 30 */
GG(c, d, a, b, in[7], S23, 1735328473u); /* 31 */
GG(b, c, d, a, in[12], S24, 2368359562u); /* 32 */
GG(a, b, c, d, in[1], S21, 4129170786u); /* 17 */
GG(d, a, b, c, in[6], S22, 3225465664u); /* 18 */
GG(c, d, a, b, in[11], S23, 643717713u); /* 19 */
GG(b, c, d, a, in[0], S24, 3921069994u); /* 20 */
GG(a, b, c, d, in[5], S21, 3593408605u); /* 21 */
GG(d, a, b, c, in[10], S22, 38016083u); /* 22 */
GG(c, d, a, b, in[15], S23, 3634488961u); /* 23 */
GG(b, c, d, a, in[4], S24, 3889429448u); /* 24 */
GG(a, b, c, d, in[9], S21, 568446438u); /* 25 */
GG(d, a, b, c, in[14], S22, 3275163606u); /* 26 */
GG(c, d, a, b, in[3], S23, 4107603335u); /* 27 */
GG(b, c, d, a, in[8], S24, 1163531501u); /* 28 */
GG(a, b, c, d, in[13], S21, 2850285829u); /* 29 */
GG(d, a, b, c, in[2], S22, 4243563512u); /* 30 */
GG(c, d, a, b, in[7], S23, 1735328473u); /* 31 */
GG(b, c, d, a, in[12], S24, 2368359562u); /* 32 */
/*
* Round 3
* Round 3
*/
#define S31 4
#define S32 11
#define S33 16
#define S34 23
HH(a, b, c, d, in[5], S31, 4294588738u); /* 33 */
HH(d, a, b, c, in[8], S32, 2272392833u); /* 34 */
HH(c, d, a, b, in[11], S33, 1839030562u); /* 35 */
HH(b, c, d, a, in[14], S34, 4259657740u); /* 36 */
HH(a, b, c, d, in[1], S31, 2763975236u); /* 37 */
HH(d, a, b, c, in[4], S32, 1272893353u); /* 38 */
HH(c, d, a, b, in[7], S33, 4139469664u); /* 39 */
HH(b, c, d, a, in[10], S34, 3200236656u); /* 40 */
HH(a, b, c, d, in[13], S31, 681279174u); /* 41 */
HH(d, a, b, c, in[0], S32, 3936430074u); /* 42 */
HH(c, d, a, b, in[3], S33, 3572445317u); /* 43 */
HH(b, c, d, a, in[6], S34, 76029189u); /* 44 */
HH(a, b, c, d, in[9], S31, 3654602809u); /* 45 */
HH(d, a, b, c, in[12], S32, 3873151461u); /* 46 */
HH(c, d, a, b, in[15], S33, 530742520u); /* 47 */
HH(b, c, d, a, in[2], S34, 3299628645u); /* 48 */
HH(a, b, c, d, in[5], S31, 4294588738u); /* 33 */
HH(d, a, b, c, in[8], S32, 2272392833u); /* 34 */
HH(c, d, a, b, in[11], S33, 1839030562u); /* 35 */
HH(b, c, d, a, in[14], S34, 4259657740u); /* 36 */
HH(a, b, c, d, in[1], S31, 2763975236u); /* 37 */
HH(d, a, b, c, in[4], S32, 1272893353u); /* 38 */
HH(c, d, a, b, in[7], S33, 4139469664u); /* 39 */
HH(b, c, d, a, in[10], S34, 3200236656u); /* 40 */
HH(a, b, c, d, in[13], S31, 681279174u); /* 41 */
HH(d, a, b, c, in[0], S32, 3936430074u); /* 42 */
HH(c, d, a, b, in[3], S33, 3572445317u); /* 43 */
HH(b, c, d, a, in[6], S34, 76029189u); /* 44 */
HH(a, b, c, d, in[9], S31, 3654602809u); /* 45 */
HH(d, a, b, c, in[12], S32, 3873151461u); /* 46 */
HH(c, d, a, b, in[15], S33, 530742520u); /* 47 */
HH(b, c, d, a, in[2], S34, 3299628645u); /* 48 */
/*
* Round 4
* Round 4
*/
#define S41 6
#define S42 10
#define S43 15
#define S44 21
II(a, b, c, d, in[0], S41, 4096336452u); /* 49 */
II(d, a, b, c, in[7], S42, 1126891415u); /* 50 */
II(c, d, a, b, in[14], S43, 2878612391u); /* 51 */
II(b, c, d, a, in[5], S44, 4237533241u); /* 52 */
II(a, b, c, d, in[12], S41, 1700485571u); /* 53 */
II(d, a, b, c, in[3], S42, 2399980690u); /* 54 */
II(c, d, a, b, in[10], S43, 4293915773u); /* 55 */
II(b, c, d, a, in[1], S44, 2240044497u); /* 56 */
II(a, b, c, d, in[8], S41, 1873313359u); /* 57 */
II(d, a, b, c, in[15], S42, 4264355552u); /* 58 */
II(c, d, a, b, in[6], S43, 2734768916u); /* 59 */
II(b, c, d, a, in[13], S44, 1309151649u); /* 60 */
II(a, b, c, d, in[4], S41, 4149444226u); /* 61 */
II(d, a, b, c, in[11], S42, 3174756917u); /* 62 */
II(c, d, a, b, in[2], S43, 718787259u); /* 63 */
II(b, c, d, a, in[9], S44, 3951481745u); /* 64 */
II(a, b, c, d, in[0], S41, 4096336452u); /* 49 */
II(d, a, b, c, in[7], S42, 1126891415u); /* 50 */
II(c, d, a, b, in[14], S43, 2878612391u); /* 51 */
II(b, c, d, a, in[5], S44, 4237533241u); /* 52 */
II(a, b, c, d, in[12], S41, 1700485571u); /* 53 */
II(d, a, b, c, in[3], S42, 2399980690u); /* 54 */
II(c, d, a, b, in[10], S43, 4293915773u); /* 55 */
II(b, c, d, a, in[1], S44, 2240044497u); /* 56 */
II(a, b, c, d, in[8], S41, 1873313359u); /* 57 */
II(d, a, b, c, in[15], S42, 4264355552u); /* 58 */
II(c, d, a, b, in[6], S43, 2734768916u); /* 59 */
II(b, c, d, a, in[13], S44, 1309151649u); /* 60 */
II(a, b, c, d, in[4], S41, 4149444226u); /* 61 */
II(d, a, b, c, in[11], S42, 3174756917u); /* 62 */
II(c, d, a, b, in[2], S43, 718787259u); /* 63 */
II(b, c, d, a, in[9], S44, 3951481745u); /* 64 */
buf[0] += a;
buf[1] += b;

View File

@@ -40,10 +40,10 @@ extern "C" {
/* Data structure for MD5 (Message-Digest) computation */
typedef struct {
MD5UINT4 i[2]; /* number of _bits_ handled mod 2^64 */
MD5UINT4 buf[4]; /* scratch buffer */
unsigned char in[64]; /* input buffer */
unsigned char digest[16]; /* actual digest after MD5Final call */
MD5UINT4 i[2]; /* number of _bits_ handled mod 2^64 */
MD5UINT4 buf[4]; /* scratch buffer */
unsigned char in[64]; /* input buffer */
unsigned char digest[16]; /* actual digest after MD5Final call */
} MD5_CTX;
/* ---------- Function Prototypes ------------- */
@@ -58,19 +58,19 @@ extern "C" {
#define DLLINTERFACE
#endif
/*
/*
* utl_md5Init: initialize the context
*
* Parameters:
*
* mdContext pointer to context variable
* mdContext pointer to context variable
*
* Return value:
*
* none
*
* Note: The function initializes the message-digest context
* mdContext. Call before each new use of the context -
* mdContext. Call before each new use of the context -
* all fields are set to zero.
*/
DLLINTERFACE void utl_md5Init(MD5_CTX * mdContext);
@@ -78,7 +78,7 @@ extern "C" {
/*
* utl_md5update: update digest from variable length data
*
*
* Parameters:
*
* mdContext pointer to context variable
@@ -89,13 +89,13 @@ extern "C" {
*
* none
*
* Note: The function updates the message-digest context to account
* Note: The function updates the message-digest context to account
* for the presence of each of the characters inBuf[0..inLen-1]
* in the message whose digest is being computed.
*/
DLLINTERFACE void utl_md5Update(MD5_CTX * mdContext, unsigned char *inBuf,
unsigned int inLen);
unsigned int inLen);
/*
@@ -103,7 +103,7 @@ extern "C" {
*
* Parameters:
*
* mdContext pointer to context variable
* mdContext pointer to context variable
*
* Return value:
*

View File

@@ -1,10 +1,10 @@
/*
/*
utl_random
A "32-bit Multiply with carry" random number generator.
A "32-bit Multiply with carry" random number generator.
*/
@@ -20,7 +20,7 @@ void utl_randomInit(RND_CTX * rndContext, unsigned int xi, unsigned int ci)
* 1791398085 1929682203 1683268614 1965537969 1675393560
* 1967773755 1517746329 1447497129 1655692410 1606218150
* 2051013963 1075433238 1557985959 1781943330 1893513180
* 1631296680 2131995753 2083801278 1873196400 1554115554
* 1631296680 2131995753 2083801278 1873196400 1554115554
*/
rndContext->a = 1655692410;
rndContext->x = 30903;
@@ -37,7 +37,7 @@ void utl_randomInit(RND_CTX * rndContext, unsigned int xi, unsigned int ci)
void utl_randomInitTime(RND_CTX * rndContext)
{
int a,b;
srand(time(NULL));
a=rand();
srand(clock());

View File

@@ -1,11 +1,11 @@
/*
/*
A "32-bit Multiply with carry: random number generator.
A "32-bit Multiply with carry: random number generator.
Has a list of recommended multipliers. Very fast and good.
multiply-with-carry generator" x(n) = a*x(n-1) + carry mod 2^32.
period" (a*2^31)-1
*/
#ifndef _utl_random_h
@@ -28,8 +28,8 @@ extern "C" {
* Macros that return random number in a specific format. See utl_random()
* below for details. Float values are in the range [0.0-1.0].
*/
#define utl_randomInt(c) ((int)utl_random(c))
#define utl_randomFloat(c) ((double)utl_random(c)/(unsigned long)0xffffffff)
#define utl_randomInt(c) ((int)utl_random(c))
#define utl_randomFloat(c) ((double)utl_random(c)/(unsigned long)0xffffffff)
typedef struct {
unsigned int a;
@@ -51,8 +51,8 @@ extern "C" {
#define DLLINTERFACE
#endif
/*
* utl_randomInit: Initialize random number generator with two integers.
/*
* utl_randomInit: Initialize random number generator with two integers.
*
* Paramaters:
*
@@ -68,10 +68,10 @@ extern "C" {
*
*/
DLLINTERFACE void utl_randomInit(RND_CTX * rndContext, unsigned int xi,
unsigned int ci);
unsigned int ci);
/*
* utl_randomInitTime: Initialize random number generator with the time
/*
* utl_randomInitTime: Initialize random number generator with the time
*
* Parameters:
*
@@ -85,8 +85,8 @@ extern "C" {
DLLINTERFACE void utl_randomInitTime(RND_CTX * rndContext);
/*
* utl_random: Returns random numbers
/*
* utl_random: Returns random numbers
*
* Parameters:
*

View File

@@ -33,12 +33,12 @@
* \returns Given integer as string
*/
char *IntToString(const int integer) {
static char buffer[256]; // malloc might work better
memset(buffer, 0, sizeof(buffer));
static char buffer[256]; // malloc might work better
memset(buffer, 0, sizeof(buffer));
SDL_snprintf(buffer, sizeof(buffer), "%d", integer);
SDL_snprintf(buffer, sizeof(buffer), "%d", integer);
return buffer;
return buffer;
}
/*!
@@ -53,12 +53,12 @@ char *IntToString(const int integer) {
* \returns Given integer as string in hex fomat
*/
char *IntToHexString(const Uint64 integer) {
static char buffer[256]; // malloc might work better
memset(buffer, 0, sizeof(buffer));
static char buffer[256]; // malloc might work better
memset(buffer, 0, sizeof(buffer));
SDL_snprintf(buffer, sizeof(buffer), "%llX", integer);
SDL_snprintf(buffer, sizeof(buffer), "%llX", integer);
return buffer;
return buffer;
}
/*!
@@ -72,12 +72,12 @@ char *IntToHexString(const Uint64 integer) {
* \returns Given double value as string
*/
char *DoubleToString(const double decimal) {
static char buffer[256]; // malloc might work better
memset(buffer, 0, sizeof(buffer));
static char buffer[256]; // malloc might work better
memset(buffer, 0, sizeof(buffer));
SDL_snprintf(buffer, sizeof(buffer), "%.5f", decimal);
SDL_snprintf(buffer, sizeof(buffer), "%.5f", decimal);
return buffer;
return buffer;
}
/*!
@@ -91,15 +91,15 @@ char *DoubleToString(const double decimal) {
* \return Ascii presentation
*/
char *TimestampToString(const time_t timestamp) {
static char buffer[256];
memset(buffer, 0, sizeof(buffer));
static char buffer[256];
memset(buffer, 0, sizeof(buffer));
time_t copy = timestamp;
time_t copy = timestamp;
struct tm *local = localtime(&copy);
strftime(buffer, sizeof(buffer), "%a %Y-%m-%d %H:%M:%S %Z", local);
struct tm *local = localtime(&copy);
strftime(buffer, sizeof(buffer), "%a %Y-%m-%d %H:%M:%S %Z", local);
return buffer;
return buffer;
}
/*!
@@ -115,15 +115,15 @@ char *TimestampToString(const time_t timestamp) {
* \return Ascii presentation
*/
char *TimestampToStringWithFormat(const time_t timestamp, char *format) {
static char buffer[256];
memset(buffer, 0, sizeof(buffer));
static char buffer[256];
memset(buffer, 0, sizeof(buffer));
time_t copy = timestamp;
time_t copy = timestamp;
struct tm *local = localtime(&copy);
strftime(buffer, sizeof(buffer), format, local);
struct tm *local = localtime(&copy);
strftime(buffer, sizeof(buffer), format, local);
return buffer;
return buffer;
}
/*! Turns all the characters of the given
@@ -135,23 +135,23 @@ char *TimestampToStringWithFormat(const time_t timestamp, char *format) {
char *
ToLowerCase(const char *string)
{
if(ValidateString(string) == 0) {
return NULL;
}
if(ValidateString(string) == 0) {
return NULL;
}
const int size = SDL_strlen(string);
char *ret = SDL_malloc(size + 1);
strncpy(ret, string, size);
ret[size] = '\0';
const int size = SDL_strlen(string);
char *ret = SDL_malloc(size + 1);
strncpy(ret, string, size);
ret[size] = '\0';
int counter = 0;
for(; counter < size; ++counter) {
ret[counter] = tolower(ret[counter]);
}
int counter = 0;
for(; counter < size; ++counter) {
ret[counter] = tolower(ret[counter]);
}
// printf("Debug: %s == %s\n", string, ret);
// printf("Debug: %s == %s\n", string, ret);
return ret;
return ret;
}
/*!
@@ -164,19 +164,19 @@ ToLowerCase(const char *string)
int
ValidateString(const char *string)
{
int retVal = 1;
int retVal = 1;
if(string != NULL) {
if(SDL_strlen(string) > 0) {
retVal = 1;
}
if(string != NULL) {
if(SDL_strlen(string) > 0) {
retVal = 1;
}
retVal = 1;
} else {
retVal = 0;
}
retVal = 1;
} else {
retVal = 0;
}
return retVal;
return retVal;
}

View File

@@ -48,178 +48,178 @@ static FILE *logFile;
int
Output(const int currentIndentLevel, const char *message, ...)
{
if(logFile == NULL) {
fprintf(stderr, "logfile is NULL\n");
exit(3);
}
if(logFile == NULL) {
fprintf(stderr, "logfile is NULL\n");
exit(3);
}
int indent = 0;
for( ; indent < currentIndentLevel; ++indent) {
fprintf(logFile, " "); // \todo make configurable?
}
int indent = 0;
for( ; indent < currentIndentLevel; ++indent) {
fprintf(logFile, " "); // \todo make configurable?
}
char buffer[1024];
memset(buffer, 0, 1024);
char buffer[1024];
memset(buffer, 0, 1024);
va_list list;
va_start(list, message);
va_list list;
va_start(list, message);
SDL_vsnprintf(buffer, 1024, message, list);
SDL_vsnprintf(buffer, 1024, message, list);
va_end(list);
fprintf(logFile, "%s\n", buffer);
fflush(logFile);
va_end(list);
fprintf(logFile, "%s\n", buffer);
fflush(logFile);
}
void
PlainRunStarted(int parameterCount, char *runnerParameters[], char *runSeed,
time_t eventTime, LoggerData *data)
time_t eventTime, LoggerData *data)
{
if(data == NULL) {
fprintf(stderr, "Logger data is NULL\n");
exit(3);
}
if(data == NULL) {
fprintf(stderr, "Logger data is NULL\n");
exit(3);
}
// Set up the logging destination
if(data->stdoutEnabled == 1) {
logFile = stdout;
} else {
logFile = fopen(data->filename, "w");
if(logFile == NULL) {
fprintf(stderr, "Log file %s couldn't opened\n", data->filename);
exit(3);
}
}
// Set up the logging destination
if(data->stdoutEnabled == 1) {
logFile = stdout;
} else {
logFile = fopen(data->filename, "w");
if(logFile == NULL) {
fprintf(stderr, "Log file %s couldn't opened\n", data->filename);
exit(3);
}
}
level = data->level;
level = data->level;
Output(indentLevel, "Test run started at %s", TimestampToString(eventTime));
Output(indentLevel, "Fuzzer seed is: %s", runSeed);
Output(indentLevel, "Runner parameters: ");
Output(indentLevel, "Test run started at %s", TimestampToString(eventTime));
Output(indentLevel, "Fuzzer seed is: %s", runSeed);
Output(indentLevel, "Runner parameters: ");
int counter = 0;
for(counter = 0; counter < parameterCount; counter++) {
char *parameter = runnerParameters[counter];
Output(indentLevel, "\t%s", parameter);
}
int counter = 0;
for(counter = 0; counter < parameterCount; counter++) {
char *parameter = runnerParameters[counter];
Output(indentLevel, "\t%s", parameter);
}
Output(indentLevel, "");
Output(indentLevel, "");
}
void
PlainRunEnded(int testCount, int suiteCount, int testPassCount, int testFailCount,
int testSkippedCount, time_t endTime, double totalRuntime)
int testSkippedCount, time_t endTime, double totalRuntime)
{
Output(indentLevel, "Test run ended at %s", TimestampToString(endTime));
Output(indentLevel, "Test run ended at %s", TimestampToString(endTime));
Output(indentLevel, "Ran %d tests in %0.5f seconds from %d suites.",
testCount, totalRuntime, suiteCount);
Output(indentLevel, "Ran %d tests in %0.5f seconds from %d suites.",
testCount, totalRuntime, suiteCount);
Output(indentLevel, "%d tests passed", testPassCount);
Output(indentLevel, "%d tests failed", testFailCount);
Output(indentLevel, "%d tests skipped", testSkippedCount);
Output(indentLevel, "%d tests passed", testPassCount);
Output(indentLevel, "%d tests failed", testFailCount);
Output(indentLevel, "%d tests skipped", testSkippedCount);
fclose(logFile);
fclose(logFile);
}
void
PlainSuiteStarted(const char *suiteName, time_t eventTime)
{
Output(indentLevel++, "Executing tests from %s", suiteName);
Output(indentLevel++, "Executing tests from %s", suiteName);
}
void
PlainSuiteEnded(int testsPassed, int testsFailed, int testsSkipped,
time_t endTime, double totalRuntime)
{
Output(--indentLevel, "Suite executed. %d passed, %d failed and %d skipped. Total runtime %0.5f seconds",
testsPassed, testsFailed, testsSkipped, totalRuntime);
Output(indentLevel, "");
Output(--indentLevel, "Suite executed. %d passed, %d failed and %d skipped. Total runtime %0.5f seconds",
testsPassed, testsFailed, testsSkipped, totalRuntime);
Output(indentLevel, "");
}
void
PlainTestStarted(const char *testName, const char *suiteName,
const char *testDescription, Uint64 execKey, time_t startTime)
const char *testDescription, Uint64 execKey, time_t startTime)
{
Output(indentLevel, "Executing test: %s (in %s, exec key: %llX)", testName, suiteName, execKey);
Output(indentLevel++, "Test description: %s", testDescription);
Output(indentLevel, "Executing test: %s (in %s, exec key: %llX)", testName, suiteName, execKey);
Output(indentLevel++, "Test description: %s", testDescription);
}
void
PlainTestEnded(const char *testName, const char *suiteName,
int testResult, time_t endTime, double totalRuntime)
{
switch(testResult) {
case TEST_RESULT_PASS:
Output(--indentLevel, "%s: ok", testName);
break;
case TEST_RESULT_FAILURE:
Output(--indentLevel, "%s: failed", testName);
break;
case TEST_RESULT_NO_ASSERT:
Output(--indentLevel, "%s: failed -> no assert", testName);
break;
case TEST_RESULT_SKIPPED:
Output(--indentLevel, "%s: skipped", testName);
break;
case TEST_RESULT_KILLED:
Output(--indentLevel, "%s: killed, exceeded timeout", testName);
break;
case TEST_RESULT_SETUP_FAILURE:
Output(--indentLevel, "%s: killed, setup failure", testName);
break;
}
switch(testResult) {
case TEST_RESULT_PASS:
Output(--indentLevel, "%s: ok", testName);
break;
case TEST_RESULT_FAILURE:
Output(--indentLevel, "%s: failed", testName);
break;
case TEST_RESULT_NO_ASSERT:
Output(--indentLevel, "%s: failed -> no assert", testName);
break;
case TEST_RESULT_SKIPPED:
Output(--indentLevel, "%s: skipped", testName);
break;
case TEST_RESULT_KILLED:
Output(--indentLevel, "%s: killed, exceeded timeout", testName);
break;
case TEST_RESULT_SETUP_FAILURE:
Output(--indentLevel, "%s: killed, setup failure", testName);
break;
}
}
void
PlainAssert(const char *assertName, int assertResult, const char *assertMessage,
time_t eventTime)
time_t eventTime)
{
// Log passed asserts only on VERBOSE level
if(level <= LOGGER_TERSE && assertResult == ASSERT_PASS) {
return ;
}
// Log passed asserts only on VERBOSE level
if(level <= LOGGER_TERSE && assertResult == ASSERT_PASS) {
return ;
}
const char *result = (assertResult) ? "passed" : "failed";
Output(indentLevel, "%s: %s - %s", assertName, result, assertMessage);
const char *result = (assertResult) ? "passed" : "failed";
Output(indentLevel, "%s: %s - %s", assertName, result, assertMessage);
}
void
PlainAssertWithValues(const char *assertName, int assertResult, const char *assertMessage,
int actualValue, int expectedValue, time_t eventTime)
int actualValue, int expectedValue, time_t eventTime)
{
// Log passed asserts only on VERBOSE level
if(level <= LOGGER_TERSE && assertResult == ASSERT_PASS) {
return ;
}
// Log passed asserts only on VERBOSE level
if(level <= LOGGER_TERSE && assertResult == ASSERT_PASS) {
return ;
}
const char *result = (assertResult) ? "passed" : "failed";
Output(indentLevel, "%s: %s (expected %d, actualValue %d) - %s",
assertName, result, expectedValue, actualValue, assertMessage);
const char *result = (assertResult) ? "passed" : "failed";
Output(indentLevel, "%s: %s (expected %d, actualValue %d) - %s",
assertName, result, expectedValue, actualValue, assertMessage);
}
void
PlainAssertSummary(int numAsserts, int numAssertsFailed, int numAssertsPass, time_t eventTime)
{
Output(indentLevel, "Assert summary: %d failed, %d passed (total: %d)",
numAssertsFailed, numAssertsPass, numAsserts);
Output(indentLevel, "Assert summary: %d failed, %d passed (total: %d)",
numAssertsFailed, numAssertsPass, numAsserts);
}
void
PlainLog(time_t eventTime, char *fmt, ...)
{
// create the log message
va_list args;
char logMessage[1024];
memset(logMessage, 0, sizeof(logMessage));
// create the log message
va_list args;
char logMessage[1024];
memset(logMessage, 0, sizeof(logMessage));
va_start( args, fmt );
SDL_vsnprintf( logMessage, sizeof(logMessage), fmt, args );
va_end( args );
va_start( args, fmt );
SDL_vsnprintf( logMessage, sizeof(logMessage), fmt, args );
va_end( args );
Output(indentLevel, "%s", logMessage);
Output(indentLevel, "%s", logMessage);
}
#endif

View File

@@ -36,7 +36,7 @@
*
*/
void PlainRunStarted(int parameterCount, char *runnerParameters[], char *runSeed,
time_t eventTime, LoggerData *data);
time_t eventTime, LoggerData *data);
/*!
* Prints out information about ending the test run.
@@ -50,7 +50,7 @@ void PlainRunStarted(int parameterCount, char *runnerParameters[], char *runSeed
* \param totalRuntime How long the execution took
*/
void PlainRunEnded(int testCount, int suiteCount, int testPassCount, int testFailCount,
int testSkippedCount, time_t endTime, double totalRuntime);
int testSkippedCount, time_t endTime, double totalRuntime);
/*!
* Prints the data about the test suite that'll be executed next
@@ -106,7 +106,7 @@ void PlainTestEnded(const char *testName, const char *suiteName,
* \param eventTime When the assert happened
*/
void PlainAssert(const char *assertName, int assertResult, const char *assertMessage,
time_t eventTime);
time_t eventTime);
/*!
* Prints information about assert that has actual and expected values
@@ -119,7 +119,7 @@ void PlainAssert(const char *assertName, int assertResult, const char *assertMes
* \param eventTime When the assert happened
*/
void PlainAssertWithValues(const char *assertName, int assertResult, const char *assertMessage,
int actualValue, int expected, time_t eventTime);
int actualValue, int expected, time_t eventTime);
/*!
* Prints summary of all assertions of certain tests

View File

@@ -39,8 +39,8 @@ static const char *root;
* Defines structure used for "counting" open XML-tags
*/
typedef struct TagList {
const char *tag;
struct TagList *next;
const char *tag;
struct TagList *next;
} TagList;
static TagList *openTags = NULL;
@@ -53,26 +53,26 @@ static TagList *openTags = NULL;
static int
AddOpenTag(const char *tag)
{
TagList *openTag = SDL_malloc(sizeof(TagList));
if(openTag == NULL) {
return 1;
}
memset(openTag, 0, sizeof(TagList));
TagList *openTag = SDL_malloc(sizeof(TagList));
if(openTag == NULL) {
return 1;
}
memset(openTag, 0, sizeof(TagList));
const int tagSize = SDL_strlen(tag) + 1;
openTag->tag = SDL_malloc(tagSize);
if(openTag->tag == NULL) {
SDL_free(openTag);
return 1;
}
const int tagSize = SDL_strlen(tag) + 1;
openTag->tag = SDL_malloc(tagSize);
if(openTag->tag == NULL) {
SDL_free(openTag);
return 1;
}
strncpy((char *)openTag->tag, (char *)tag, tagSize);
strncpy((char *)openTag->tag, (char *)tag, tagSize);
openTag->next = openTags;
openTag->next = openTags;
openTags = openTag;
openTags = openTag;
return 0;
return 0;
}
/*!
@@ -83,30 +83,30 @@ AddOpenTag(const char *tag)
static int
RemoveOpenTag(const char *tag)
{
if(openTags == NULL || ValidateString(tag) == 0) {
return 1;
}
if(openTags == NULL || ValidateString(tag) == 0) {
return 1;
}
int retVal = 0;
int retVal = 0;
const int size = SDL_strlen(tag);
char *tempTag = SDL_malloc(size);
strncpy(tempTag, tag, size);
const int size = SDL_strlen(tag);
char *tempTag = SDL_malloc(size);
strncpy(tempTag, tag, size);
// Tag should always be the same as previously opened tag
// It prevents opening and ending tag mismatch
if(SDL_strncmp(tempTag, tag, size) == 0) {
TagList *openTag = openTags;
SDL_free((char *)openTag->tag);
// Tag should always be the same as previously opened tag
// It prevents opening and ending tag mismatch
if(SDL_strncmp(tempTag, tag, size) == 0) {
TagList *openTag = openTags;
SDL_free((char *)openTag->tag);
openTags = openTags->next;
SDL_free(openTag);
} else {
//printf("Debug | xml.c:RemoveOpenTag(): open/end tag mismatch");
retVal = 1;
}
openTags = openTags->next;
SDL_free(openTag);
} else {
//printf("Debug | xml.c:RemoveOpenTag(): open/end tag mismatch");
retVal = 1;
}
return retVal;
return retVal;
}
/*!
@@ -115,12 +115,12 @@ RemoveOpenTag(const char *tag)
static void
PrintOpenTags()
{
printf("\nOpen tags:\n");
printf("\nOpen tags:\n");
TagList *openTag = NULL;
for(openTag = openTags; openTag; openTag = openTag->next) {
printf("\ttag: %s\n", openTag->tag);
}
TagList *openTag = NULL;
for(openTag = openTags; openTag; openTag = openTag->next) {
printf("\ttag: %s\n", openTag->tag);
}
}
@@ -134,83 +134,83 @@ PrintOpenTags()
const char *
EscapeString(const char *string)
{
// Calculate the size of the escaped string
int totalSize = 0;
// Calculate the size of the escaped string
int totalSize = 0;
const int maxCount = SDL_strlen(string);
const int maxCount = SDL_strlen(string);
int counter = 0;
for(; counter < maxCount; ++counter) {
char character = string[counter];
int counter = 0;
for(; counter < maxCount; ++counter) {
char character = string[counter];
switch(character) {
case '&': totalSize += 5; //SDL_strlen("&amp;");
break;
case '\'': totalSize += 6; //SDL_strlen("&apos;");
break;
case '"': totalSize += 6; //SDL_strlen("&quot;");
break;
case '<': totalSize += 4; //SDL_strlen("&lt;");
break;
case '>': totalSize += 4; //SDL_strlen("&gt;");
break;
default:
totalSize += 1;
break;
}
}
totalSize += 1; // for '\0'
switch(character) {
case '&': totalSize += 5; //SDL_strlen("&amp;");
break;
case '\'': totalSize += 6; //SDL_strlen("&apos;");
break;
case '"': totalSize += 6; //SDL_strlen("&quot;");
break;
case '<': totalSize += 4; //SDL_strlen("&lt;");
break;
case '>': totalSize += 4; //SDL_strlen("&gt;");
break;
default:
totalSize += 1;
break;
}
}
totalSize += 1; // for '\0'
char *retBuffer = SDL_malloc(totalSize * sizeof(char));
if(retBuffer == NULL) {
return NULL;
}
char *retBuffer = SDL_malloc(totalSize * sizeof(char));
if(retBuffer == NULL) {
return NULL;
}
// escape the string
char *curRetBuffer = retBuffer;
const char *curString = string;
// escape the string
char *curRetBuffer = retBuffer;
const char *curString = string;
char character = *curString;
while( (character = *curString++) ) {
char character = *curString;
while( (character = *curString++) ) {
switch(character) {
case '&':
memcpy((void *)curRetBuffer, (void *)"&amp;", 5);
curRetBuffer += 5;
break;
case '\'':
memcpy((void *)curRetBuffer, (void *)"&apos;", 6);
curRetBuffer += 6;
break;
case '"':
memcpy((void *)curRetBuffer, (void *)"&quot;", 6);
curRetBuffer += 6;
break;
case '<':
memcpy((void *)curRetBuffer, (void *)"&lt;", 4);
curRetBuffer += 4;
break;
case '>':
memcpy((void *)curRetBuffer, (void *)"&gt;", 4);
curRetBuffer += 4;
break;
default:
*curRetBuffer = character;
curRetBuffer += 1;
break;
}
}
switch(character) {
case '&':
memcpy((void *)curRetBuffer, (void *)"&amp;", 5);
curRetBuffer += 5;
break;
case '\'':
memcpy((void *)curRetBuffer, (void *)"&apos;", 6);
curRetBuffer += 6;
break;
case '"':
memcpy((void *)curRetBuffer, (void *)"&quot;", 6);
curRetBuffer += 6;
break;
case '<':
memcpy((void *)curRetBuffer, (void *)"&lt;", 4);
curRetBuffer += 4;
break;
case '>':
memcpy((void *)curRetBuffer, (void *)"&gt;", 4);
curRetBuffer += 4;
break;
default:
*curRetBuffer = character;
curRetBuffer += 1;
break;
}
}
*curRetBuffer = '\0';
*curRetBuffer = '\0';
return retBuffer;
return retBuffer;
}
/*
===================
Functions to handle creation of XML elements
Functions to handle creation of XML elements
===================
*/
@@ -218,159 +218,159 @@ EscapeString(const char *string)
char *
XMLOpenDocument(const char *rootTag, const char *xslStyle)
{
const char *doctype = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n";
const char *doctype = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n";
//! \todo refactor this mess
char *style = NULL;
if(xslStyle) {
const char *styleStart = "<?xml-stylesheet type=\"text/xsl\" href=\"";
const char *styleEnd = "\"?>\n";
//! \todo refactor this mess
char *style = NULL;
if(xslStyle) {
const char *styleStart = "<?xml-stylesheet type=\"text/xsl\" href=\"";
const char *styleEnd = "\"?>\n";
const int sizeStyleStart = SDL_strlen(styleStart);
const int sizeStyleEnd = SDL_strlen(styleEnd);
const int sizeStyleSheetName = SDL_strlen(xslStyle);
const int sizeStyleStart = SDL_strlen(styleStart);
const int sizeStyleEnd = SDL_strlen(styleEnd);
const int sizeStyleSheetName = SDL_strlen(xslStyle);
const int tempSize = sizeStyleStart + sizeStyleEnd + sizeStyleSheetName + 1;
style = SDL_malloc(tempSize);
memset(style, 0, tempSize);
SDL_snprintf(style, tempSize, "%s%s%s", styleStart, xslStyle, styleEnd);
}
const int tempSize = sizeStyleStart + sizeStyleEnd + sizeStyleSheetName + 1;
style = SDL_malloc(tempSize);
memset(style, 0, tempSize);
SDL_snprintf(style, tempSize, "%s%s%s", styleStart, xslStyle, styleEnd);
}
memset(buffer, 0, bufferSize);
SDL_snprintf(buffer, bufferSize, "<%s>", rootTag);
memset(buffer, 0, bufferSize);
SDL_snprintf(buffer, bufferSize, "<%s>", rootTag);
AddOpenTag(rootTag);
AddOpenTag(rootTag);
root = rootTag; // it's fine, as long as rootTag points to static memory?
root = rootTag; // it's fine, as long as rootTag points to static memory?
char *retBuf = NULL;
if(xslStyle) {
const int doctypeSize = SDL_strlen(doctype);
const int styleSize = SDL_strlen(style);
const int tagSize = SDL_strlen(buffer);
char *retBuf = NULL;
if(xslStyle) {
const int doctypeSize = SDL_strlen(doctype);
const int styleSize = SDL_strlen(style);
const int tagSize = SDL_strlen(buffer);
const int size = doctypeSize + styleSize + tagSize + 1; // extra byte for '\0'
retBuf = SDL_malloc(size);
const int size = doctypeSize + styleSize + tagSize + 1; // extra byte for '\0'
retBuf = SDL_malloc(size);
SDL_snprintf(retBuf, size, "%s%s%s", doctype, style, buffer);
SDL_snprintf(retBuf, size, "%s%s%s", doctype, style, buffer);
SDL_free(style);
} else {
const int doctypeSize = SDL_strlen(doctype);
const int tagSize = SDL_strlen(buffer);
SDL_free(style);
} else {
const int doctypeSize = SDL_strlen(doctype);
const int tagSize = SDL_strlen(buffer);
const int size = doctypeSize + tagSize + 1; // extra byte for '\0'
retBuf = SDL_malloc(size);
const int size = doctypeSize + tagSize + 1; // extra byte for '\0'
retBuf = SDL_malloc(size);
SDL_snprintf(retBuf, size, "%s%s", doctype, buffer);
}
SDL_snprintf(retBuf, size, "%s%s", doctype, buffer);
}
return retBuf;
return retBuf;
}
char *
XMLCloseDocument() {
return XMLCloseElement(root);
return XMLCloseElement(root);
}
char *
XMLOpenElement(const char *tag)
{
memset(buffer, 0, bufferSize);
SDL_snprintf(buffer, bufferSize, "<%s>", tag);
memset(buffer, 0, bufferSize);
SDL_snprintf(buffer, bufferSize, "<%s>", tag);
AddOpenTag(tag);
AddOpenTag(tag);
const int size = SDL_strlen(buffer);
char *ret = SDL_malloc(size + 1);
strncpy(ret, buffer, size);
ret[size] = '\0';
const int size = SDL_strlen(buffer);
char *ret = SDL_malloc(size + 1);
strncpy(ret, buffer, size);
ret[size] = '\0';
return ret;
return ret;
}
char *
XMLAddContent(const char *content)
{
if(ValidateString(content) == 0) {
return NULL;
}
if(ValidateString(content) == 0) {
return NULL;
}
const char *escapedContent = EscapeString(content);
const char *escapedContent = EscapeString(content);
if(SDL_strlen(escapedContent) >= bufferSize) {
return NULL;
}
if(SDL_strlen(escapedContent) >= bufferSize) {
return NULL;
}
memset(buffer, 0, bufferSize);
SDL_snprintf(buffer, bufferSize, "%s", escapedContent);
SDL_free((char *)escapedContent);
memset(buffer, 0, bufferSize);
SDL_snprintf(buffer, bufferSize, "%s", escapedContent);
SDL_free((char *)escapedContent);
const int size = SDL_strlen(buffer);
char *ret = SDL_malloc(size + 1);
strncpy(ret, buffer, size);
ret[size] = '\0';
const int size = SDL_strlen(buffer);
char *ret = SDL_malloc(size + 1);
strncpy(ret, buffer, size);
ret[size] = '\0';
return ret;
return ret;
}
char *
XMLCloseElement(const char *tag)
{
if(ValidateString(tag) == 0) {
return NULL;
}
if(ValidateString(tag) == 0) {
return NULL;
}
int retBufferSize = 150;
char *ret = SDL_malloc(retBufferSize);
memset(ret, 0, retBufferSize);
int retBufferSize = 150;
char *ret = SDL_malloc(retBufferSize);
memset(ret, 0, retBufferSize);
// \todo check that element we're trying to close is actually open,
// otherwise it'll cause nesting problems
// \todo check that element we're trying to close is actually open,
// otherwise it'll cause nesting problems
// Close the open tags with proper nesting. Closes tags until it finds
// the given tag which is the last tag that will be closed
TagList *openTag = openTags;
while(openTag) {
TagList *temp = openTag->next;
// Close the open tags with proper nesting. Closes tags until it finds
// the given tag which is the last tag that will be closed
TagList *openTag = openTags;
while(openTag) {
TagList *temp = openTag->next;
char *lowOpenTag = ToLowerCase(openTag->tag);
char *lowTag = ToLowerCase(tag);
char *lowOpenTag = ToLowerCase(openTag->tag);
char *lowTag = ToLowerCase(tag);
const int openTagSize = SDL_strlen(lowOpenTag);
const int tagSize = SDL_strlen(lowTag);
const int compSize = (openTagSize > tagSize) ? openTagSize : tagSize;
const int openTagSize = SDL_strlen(lowOpenTag);
const int tagSize = SDL_strlen(lowTag);
const int compSize = (openTagSize > tagSize) ? openTagSize : tagSize;
memset(buffer, 0, bufferSize);
memset(buffer, 0, bufferSize);
int breakOut = 0;
if(SDL_strncmp(lowOpenTag, lowTag, compSize) == 0) {
breakOut = 1;
SDL_snprintf(buffer, bufferSize, "</%s>", tag);
} else {
SDL_snprintf(buffer, bufferSize, "</%s>", openTag->tag);
}
int breakOut = 0;
if(SDL_strncmp(lowOpenTag, lowTag, compSize) == 0) {
breakOut = 1;
SDL_snprintf(buffer, bufferSize, "</%s>", tag);
} else {
SDL_snprintf(buffer, bufferSize, "</%s>", openTag->tag);
}
SDL_free(lowOpenTag);
SDL_free(lowTag);
SDL_free(lowOpenTag);
SDL_free(lowTag);
int bytesLeft = bufferSize - SDL_strlen(ret);
if(bytesLeft) {
strncat(ret, buffer, bytesLeft);
} else {
// \! todo there's probably better way to report an error?
fprintf(stderr, "xml.c | XMLCloseElement: Buffer is full");
}
int bytesLeft = bufferSize - SDL_strlen(ret);
if(bytesLeft) {
strncat(ret, buffer, bytesLeft);
} else {
// \! todo there's probably better way to report an error?
fprintf(stderr, "xml.c | XMLCloseElement: Buffer is full");
}
RemoveOpenTag(openTag->tag);
RemoveOpenTag(openTag->tag);
openTag = temp;
openTag = temp;
if(breakOut) {
break;
}
}
if(breakOut) {
break;
}
}
return ret;
return ret;
}

View File

@@ -23,8 +23,8 @@
/*! Defines attribute for XML elements */
typedef struct Attribute {
const char *attribute;
const char *value;
const char *attribute;
const char *value;
} Attribute;

View File

@@ -93,582 +93,582 @@ static FILE *logFile = NULL;
*/
void
XMLOutputter(const int currentIndentLevel,
int EOL, const char *message)
int EOL, const char *message)
{
if(ValidateString(message)) {
int indent = 0;
for( ; indent < currentIndentLevel && prevEOL; ++indent) {
fprintf(logFile, " "); // \todo make configurable?
}
if(ValidateString(message)) {
int indent = 0;
for( ; indent < currentIndentLevel && prevEOL; ++indent) {
fprintf(logFile, " "); // \todo make configurable?
}
prevEOL = EOL;
prevEOL = EOL;
if(EOL) {
fprintf(logFile, "%s\n", message);
} else {
fprintf(logFile, "%s", message);
}
if(EOL) {
fprintf(logFile, "%s\n", message);
} else {
fprintf(logFile, "%s", message);
}
fflush(logFile);
} else {
fprintf(logFile, "Error: Tried to output invalid string!");
}
fflush(logFile);
} else {
fprintf(logFile, "Error: Tried to output invalid string!");
}
SDL_free((char *)message);
SDL_free((char *)message);
}
void
XMLRunStarted(int parameterCount, char *runnerParameters[], char *runSeed,
time_t eventTime, LoggerData *data)
time_t eventTime, LoggerData *data)
{
// Set up the logging destination
if(data->stdoutEnabled) {
logFile = stdout;
} else {
logFile = fopen(data->filename, "w");
if(logFile == NULL) {
fprintf(stderr, "Log file %s couldn't opened\n", data->filename);
exit(3);
}
}
// Set up the logging destination
if(data->stdoutEnabled) {
logFile = stdout;
} else {
logFile = fopen(data->filename, "w");
if(logFile == NULL) {
fprintf(stderr, "Log file %s couldn't opened\n", data->filename);
exit(3);
}
}
// Set up the style sheet
char *xslStylesheet = (char *)data->custom;
level = data->level;
//printf("Debug: %d == %d\n", level, data->level);
// Set up the style sheet
char *xslStylesheet = (char *)data->custom;
level = data->level;
//printf("Debug: %d == %d\n", level, data->level);
char *output = XMLOpenDocument(documentRoot, xslStylesheet);
XMLOutputter(indentLevel++, YES, output);
char *output = XMLOpenDocument(documentRoot, xslStylesheet);
XMLOutputter(indentLevel++, YES, output);
// log harness parameters
output = XMLOpenElement(parametersElementName);
XMLOutputter(indentLevel++, YES, output);
// log harness parameters
output = XMLOpenElement(parametersElementName);
XMLOutputter(indentLevel++, YES, output);
int counter = 0;
for(counter = 0; counter < parameterCount; counter++) {
char *parameter = runnerParameters[counter];
int counter = 0;
for(counter = 0; counter < parameterCount; counter++) {
char *parameter = runnerParameters[counter];
output = XMLOpenElement(parameterElementName);
XMLOutputter(indentLevel++, NO, output);
output = XMLOpenElement(parameterElementName);
XMLOutputter(indentLevel++, NO, output);
output = XMLAddContent(parameter);
XMLOutputter(indentLevel, NO, output);
output = XMLAddContent(parameter);
XMLOutputter(indentLevel, NO, output);
output = XMLCloseElement(parameterElementName);
XMLOutputter(--indentLevel, YES, output);
}
output = XMLCloseElement(parameterElementName);
XMLOutputter(--indentLevel, YES, output);
}
output = XMLCloseElement(parametersElementName);
XMLOutputter(--indentLevel, YES, output);
output = XMLCloseElement(parametersElementName);
XMLOutputter(--indentLevel, YES, output);
// log seed
output = XMLOpenElement(seedElementName);
XMLOutputter(indentLevel++, NO, output);
// log seed
output = XMLOpenElement(seedElementName);
XMLOutputter(indentLevel++, NO, output);
output = XMLAddContent(runSeed);
XMLOutputter(indentLevel, NO, output);
output = XMLAddContent(runSeed);
XMLOutputter(indentLevel, NO, output);
output = XMLCloseElement(seedElementName);
XMLOutputter(--indentLevel, YES, output);
output = XMLCloseElement(seedElementName);
XMLOutputter(--indentLevel, YES, output);
// log start time
output = XMLOpenElement(startTimeElementName);
XMLOutputter(indentLevel++, NO, output);
// log start time
output = XMLOpenElement(startTimeElementName);
XMLOutputter(indentLevel++, NO, output);
output = XMLAddContent(TimestampToString(eventTime));
XMLOutputter(indentLevel, NO, output);
output = XMLAddContent(TimestampToString(eventTime));
XMLOutputter(indentLevel, NO, output);
output = XMLCloseElement(startTimeElementName);
XMLOutputter(--indentLevel, YES, output);
output = XMLCloseElement(startTimeElementName);
XMLOutputter(--indentLevel, YES, output);
}
void
XMLRunEnded(int testCount, int suiteCount, int testPassCount, int testFailCount,
int testSkippedCount, time_t endTime, double totalRuntime)
int testSkippedCount, time_t endTime, double totalRuntime)
{
// log suite count
char *output = XMLOpenElement(numSuitesElementName);
XMLOutputter(indentLevel++, NO, output);
// log suite count
char *output = XMLOpenElement(numSuitesElementName);
XMLOutputter(indentLevel++, NO, output);
output = XMLAddContent(IntToString(suiteCount));
XMLOutputter(indentLevel, NO, output);
output = XMLAddContent(IntToString(suiteCount));
XMLOutputter(indentLevel, NO, output);
output = XMLCloseElement(numSuitesElementName);
XMLOutputter(--indentLevel, YES, output);
output = XMLCloseElement(numSuitesElementName);
XMLOutputter(--indentLevel, YES, output);
// log test count
output = XMLOpenElement(numTestElementName);
XMLOutputter(indentLevel++, NO, output);
// log test count
output = XMLOpenElement(numTestElementName);
XMLOutputter(indentLevel++, NO, output);
output = XMLAddContent(IntToString(testCount));
XMLOutputter(indentLevel, NO, output);
output = XMLAddContent(IntToString(testCount));
XMLOutputter(indentLevel, NO, output);
output = XMLCloseElement(numTestElementName);
XMLOutputter(--indentLevel, YES, output);
output = XMLCloseElement(numTestElementName);
XMLOutputter(--indentLevel, YES, output);
// log passed test count
output = XMLOpenElement(numPassedTestsElementName);
XMLOutputter(indentLevel++, NO, output);
// log passed test count
output = XMLOpenElement(numPassedTestsElementName);
XMLOutputter(indentLevel++, NO, output);
output = XMLAddContent(IntToString(testPassCount));
XMLOutputter(indentLevel, NO, output);
output = XMLAddContent(IntToString(testPassCount));
XMLOutputter(indentLevel, NO, output);
output = XMLCloseElement(numPassedTestsElementName);
XMLOutputter(--indentLevel, YES, output);
output = XMLCloseElement(numPassedTestsElementName);
XMLOutputter(--indentLevel, YES, output);
// log failed test count
output = XMLOpenElement(numFailedTestsElementName);
XMLOutputter(indentLevel++, NO, output);
// log failed test count
output = XMLOpenElement(numFailedTestsElementName);
XMLOutputter(indentLevel++, NO, output);
output = XMLAddContent(IntToString(testFailCount));
XMLOutputter(indentLevel, NO, output);
output = XMLAddContent(IntToString(testFailCount));
XMLOutputter(indentLevel, NO, output);
output = XMLCloseElement(numFailedTestsElementName);
XMLOutputter(--indentLevel, YES, output);
output = XMLCloseElement(numFailedTestsElementName);
XMLOutputter(--indentLevel, YES, output);
// log skipped test count
output = XMLOpenElement(numSkippedTestsElementName);
XMLOutputter(indentLevel++, NO, output);
// log skipped test count
output = XMLOpenElement(numSkippedTestsElementName);
XMLOutputter(indentLevel++, NO, output);
output = XMLAddContent(IntToString(testSkippedCount));
XMLOutputter(indentLevel, NO, output);
output = XMLAddContent(IntToString(testSkippedCount));
XMLOutputter(indentLevel, NO, output);
output = XMLCloseElement(numSkippedTestsElementName);
XMLOutputter(--indentLevel, YES, output);
output = XMLCloseElement(numSkippedTestsElementName);
XMLOutputter(--indentLevel, YES, output);
// log end tite
output = XMLOpenElement(endTimeElementName);
XMLOutputter(indentLevel++, NO, output);
// log end tite
output = XMLOpenElement(endTimeElementName);
XMLOutputter(indentLevel++, NO, output);
output = XMLAddContent(TimestampToString(endTime));
XMLOutputter(indentLevel, NO, output);
output = XMLAddContent(TimestampToString(endTime));
XMLOutputter(indentLevel, NO, output);
output = XMLCloseElement(endTimeElementName);
XMLOutputter(--indentLevel, YES, output);
output = XMLCloseElement(endTimeElementName);
XMLOutputter(--indentLevel, YES, output);
// log total runtime
output = XMLOpenElement(totalRuntimeElementName);
XMLOutputter(indentLevel++, NO, output);
// log total runtime
output = XMLOpenElement(totalRuntimeElementName);
XMLOutputter(indentLevel++, NO, output);
output = XMLAddContent(DoubleToString(totalRuntime));
XMLOutputter(indentLevel, NO, output);
output = XMLAddContent(DoubleToString(totalRuntime));
XMLOutputter(indentLevel, NO, output);
output = XMLCloseElement(totalRuntimeElementName);
XMLOutputter(--indentLevel, YES, output);
output = XMLCloseElement(totalRuntimeElementName);
XMLOutputter(--indentLevel, YES, output);
output = XMLCloseDocument(documentRoot);
XMLOutputter(--indentLevel, YES, output);
output = XMLCloseDocument(documentRoot);
XMLOutputter(--indentLevel, YES, output);
// close the log file
fclose(logFile);
// close the log file
fclose(logFile);
}
void
XMLSuiteStarted(const char *suiteName, time_t eventTime)
{
// log suite name
char *output = XMLOpenElement(suiteElementName);
XMLOutputter(indentLevel++, YES, output);
// log suite name
char *output = XMLOpenElement(suiteElementName);
XMLOutputter(indentLevel++, YES, output);
output = XMLOpenElement(nameElementName);
XMLOutputter(indentLevel++, NO, output);
output = XMLOpenElement(nameElementName);
XMLOutputter(indentLevel++, NO, output);
output = XMLAddContent(suiteName);
XMLOutputter(indentLevel, NO, output);
output = XMLAddContent(suiteName);
XMLOutputter(indentLevel, NO, output);
// log test name
output = XMLCloseElement(nameElementName);
XMLOutputter(--indentLevel, YES, output);
// log test name
output = XMLCloseElement(nameElementName);
XMLOutputter(--indentLevel, YES, output);
output = XMLOpenElement(startTimeElementName);
XMLOutputter(indentLevel++, NO, output);
output = XMLOpenElement(startTimeElementName);
XMLOutputter(indentLevel++, NO, output);
// log beginning time
output = XMLAddContent(TimestampToString(eventTime));
XMLOutputter(indentLevel, NO, output);
// log beginning time
output = XMLAddContent(TimestampToString(eventTime));
XMLOutputter(indentLevel, NO, output);
output = XMLCloseElement(startTimeElementName);
XMLOutputter(--indentLevel, YES, output);
output = XMLCloseElement(startTimeElementName);
XMLOutputter(--indentLevel, YES, output);
}
void
XMLSuiteEnded(int testsPassed, int testsFailed, int testsSkipped,
time_t endTime, double totalRuntime)
{
// log tests passed
char *output = XMLOpenElement(testsPassedElementName);
XMLOutputter(indentLevel++, NO, output);
// log tests passed
char *output = XMLOpenElement(testsPassedElementName);
XMLOutputter(indentLevel++, NO, output);
output = XMLAddContent(IntToString(testsPassed));
XMLOutputter(indentLevel, NO, output);
output = XMLAddContent(IntToString(testsPassed));
XMLOutputter(indentLevel, NO, output);
output = XMLCloseElement(testsPassedElementName);
XMLOutputter(--indentLevel, YES, output);
output = XMLCloseElement(testsPassedElementName);
XMLOutputter(--indentLevel, YES, output);
// log tests failed
output = XMLOpenElement(testsFailedElementName);
XMLOutputter(indentLevel++, NO, output);
// log tests failed
output = XMLOpenElement(testsFailedElementName);
XMLOutputter(indentLevel++, NO, output);
output = XMLAddContent(IntToString(testsFailed));
XMLOutputter(indentLevel, NO, output);
output = XMLAddContent(IntToString(testsFailed));
XMLOutputter(indentLevel, NO, output);
output = XMLCloseElement(testsFailedElementName);
XMLOutputter(--indentLevel, YES, output);
output = XMLCloseElement(testsFailedElementName);
XMLOutputter(--indentLevel, YES, output);
// log tests skipped
output = XMLOpenElement(testsSkippedElementName);
XMLOutputter(indentLevel++, NO, output);
// log tests skipped
output = XMLOpenElement(testsSkippedElementName);
XMLOutputter(indentLevel++, NO, output);
output = XMLAddContent(IntToString(testsSkipped));
XMLOutputter(indentLevel, NO, output);
output = XMLAddContent(IntToString(testsSkipped));
XMLOutputter(indentLevel, NO, output);
output = XMLCloseElement(testsSkippedElementName);
XMLOutputter(--indentLevel, YES, output);
output = XMLCloseElement(testsSkippedElementName);
XMLOutputter(--indentLevel, YES, output);
// log tests skipped
output = XMLOpenElement(endTimeElementName);
XMLOutputter(indentLevel++, NO, output);
// log tests skipped
output = XMLOpenElement(endTimeElementName);
XMLOutputter(indentLevel++, NO, output);
output = XMLAddContent(TimestampToString(endTime));
XMLOutputter(indentLevel, NO, output);
output = XMLAddContent(TimestampToString(endTime));
XMLOutputter(indentLevel, NO, output);
output = XMLCloseElement(endTimeElementName);
XMLOutputter(--indentLevel, YES, output);
output = XMLCloseElement(endTimeElementName);
XMLOutputter(--indentLevel, YES, output);
// log total runtime
output = XMLOpenElement(totalRuntimeElementName);
XMLOutputter(indentLevel++, NO, output);
// log total runtime
output = XMLOpenElement(totalRuntimeElementName);
XMLOutputter(indentLevel++, NO, output);
output = XMLAddContent(DoubleToString(totalRuntime));
XMLOutputter(indentLevel, NO, output);
output = XMLAddContent(DoubleToString(totalRuntime));
XMLOutputter(indentLevel, NO, output);
output = XMLCloseElement(totalRuntimeElementName);
XMLOutputter(--indentLevel, YES, output);
output = XMLCloseElement(totalRuntimeElementName);
XMLOutputter(--indentLevel, YES, output);
output = XMLCloseElement(suiteElementName);
XMLOutputter(--indentLevel, YES, output);
output = XMLCloseElement(suiteElementName);
XMLOutputter(--indentLevel, YES, output);
}
void
XMLTestStarted(const char *testName, const char *suiteName,
const char *testDescription, Uint64 execKey, time_t startTime)
const char *testDescription, Uint64 execKey, time_t startTime)
{
char * output = XMLOpenElement(testElementName);
XMLOutputter(indentLevel++, YES, output);
char * output = XMLOpenElement(testElementName);
XMLOutputter(indentLevel++, YES, output);
// log test name
output = XMLOpenElement(nameElementName);
XMLOutputter(indentLevel++, NO, output);
// log test name
output = XMLOpenElement(nameElementName);
XMLOutputter(indentLevel++, NO, output);
output = XMLAddContent(testName);
XMLOutputter(indentLevel, NO, output);
output = XMLAddContent(testName);
XMLOutputter(indentLevel, NO, output);
output = XMLCloseElement(nameElementName);
XMLOutputter(--indentLevel, YES, output);
output = XMLCloseElement(nameElementName);
XMLOutputter(--indentLevel, YES, output);
// log test description
output = XMLOpenElement(descriptionElementName);
XMLOutputter(indentLevel++, NO, output);
// log test description
output = XMLOpenElement(descriptionElementName);
XMLOutputter(indentLevel++, NO, output);
output = XMLAddContent(testDescription);
XMLOutputter(indentLevel, NO, output);
output = XMLAddContent(testDescription);
XMLOutputter(indentLevel, NO, output);
output = XMLCloseElement(descriptionElementName);
XMLOutputter(--indentLevel, YES, output);
output = XMLCloseElement(descriptionElementName);
XMLOutputter(--indentLevel, YES, output);
// log execution key
output = XMLOpenElement(execKeyElementName);
XMLOutputter(indentLevel++, NO, output);
// log execution key
output = XMLOpenElement(execKeyElementName);
XMLOutputter(indentLevel++, NO, output);
output = XMLAddContent(IntToHexString(execKey));
XMLOutputter(indentLevel, NO, output);
output = XMLAddContent(IntToHexString(execKey));
XMLOutputter(indentLevel, NO, output);
output = XMLCloseElement(execKeyElementName);
XMLOutputter(--indentLevel, YES, output);
output = XMLCloseElement(execKeyElementName);
XMLOutputter(--indentLevel, YES, output);
// log start time
output = XMLOpenElement(startTimeElementName);
XMLOutputter(indentLevel++, NO, output);
// log start time
output = XMLOpenElement(startTimeElementName);
XMLOutputter(indentLevel++, NO, output);
output = XMLAddContent(TimestampToString(startTime));
XMLOutputter(indentLevel, NO, output);
output = XMLAddContent(TimestampToString(startTime));
XMLOutputter(indentLevel, NO, output);
output = XMLCloseElement(startTimeElementName);
XMLOutputter(--indentLevel, YES, output);
output = XMLCloseElement(startTimeElementName);
XMLOutputter(--indentLevel, YES, output);
}
void
XMLTestEnded(const char *testName, const char *suiteName,
int testResult, time_t endTime, double totalRuntime)
{
// Log test result
char *output = XMLOpenElement(resultElementName);
XMLOutputter(indentLevel++, NO, output);
// Log test result
char *output = XMLOpenElement(resultElementName);
XMLOutputter(indentLevel++, NO, output);
switch(testResult) {
case TEST_RESULT_PASS:
output = XMLAddContent("passed");
break;
case TEST_RESULT_FAILURE:
output = XMLAddContent("failed");
break;
case TEST_RESULT_NO_ASSERT:
output = XMLAddContent("failed");
break;
case TEST_RESULT_SKIPPED:
output = XMLAddContent("skipped");
break;
case TEST_RESULT_KILLED:
output = XMLAddContent("failed");
break;
case TEST_RESULT_SETUP_FAILURE:
output = XMLAddContent("failed");
break;
}
XMLOutputter(indentLevel, NO, output);
switch(testResult) {
case TEST_RESULT_PASS:
output = XMLAddContent("passed");
break;
case TEST_RESULT_FAILURE:
output = XMLAddContent("failed");
break;
case TEST_RESULT_NO_ASSERT:
output = XMLAddContent("failed");
break;
case TEST_RESULT_SKIPPED:
output = XMLAddContent("skipped");
break;
case TEST_RESULT_KILLED:
output = XMLAddContent("failed");
break;
case TEST_RESULT_SETUP_FAILURE:
output = XMLAddContent("failed");
break;
}
XMLOutputter(indentLevel, NO, output);
output = XMLCloseElement(resultElementName);
XMLOutputter(--indentLevel, YES, output);
output = XMLCloseElement(resultElementName);
XMLOutputter(--indentLevel, YES, output);
// Log description of test result. Why the test failed,
// if there's some specific reason
output = XMLOpenElement(resultDescriptionElementName);
XMLOutputter(indentLevel++, NO, output);
// Log description of test result. Why the test failed,
// if there's some specific reason
output = XMLOpenElement(resultDescriptionElementName);
XMLOutputter(indentLevel++, NO, output);
switch(testResult) {
case TEST_RESULT_PASS:
case TEST_RESULT_FAILURE:
case TEST_RESULT_SKIPPED:
output = XMLAddContent("");
break;
case TEST_RESULT_NO_ASSERT:
output = XMLAddContent("No assert");
break;
case TEST_RESULT_KILLED:
output = XMLAddContent("Timeout exceeded");
break;
case TEST_RESULT_SETUP_FAILURE:
output = XMLAddContent("Setup failure, couldn't be executed");
break;
}
XMLOutputter(indentLevel, NO, output);
switch(testResult) {
case TEST_RESULT_PASS:
case TEST_RESULT_FAILURE:
case TEST_RESULT_SKIPPED:
output = XMLAddContent("");
break;
case TEST_RESULT_NO_ASSERT:
output = XMLAddContent("No assert");
break;
case TEST_RESULT_KILLED:
output = XMLAddContent("Timeout exceeded");
break;
case TEST_RESULT_SETUP_FAILURE:
output = XMLAddContent("Setup failure, couldn't be executed");
break;
}
XMLOutputter(indentLevel, NO, output);
output = XMLCloseElement(resultDescriptionElementName);
XMLOutputter(--indentLevel, YES, output);
output = XMLCloseElement(resultDescriptionElementName);
XMLOutputter(--indentLevel, YES, output);
// log total runtime
output = XMLOpenElement(endTimeElementName);
XMLOutputter(indentLevel++, NO, output);
// log total runtime
output = XMLOpenElement(endTimeElementName);
XMLOutputter(indentLevel++, NO, output);
output = XMLAddContent(TimestampToString(endTime));
XMLOutputter(indentLevel, NO, output);
output = XMLAddContent(TimestampToString(endTime));
XMLOutputter(indentLevel, NO, output);
output = XMLCloseElement(endTimeElementName);
XMLOutputter(--indentLevel, YES, output);
output = XMLCloseElement(endTimeElementName);
XMLOutputter(--indentLevel, YES, output);
// log total runtime
output = XMLOpenElement(totalRuntimeElementName);
XMLOutputter(indentLevel++, NO, output);
// log total runtime
output = XMLOpenElement(totalRuntimeElementName);
XMLOutputter(indentLevel++, NO, output);
output = XMLAddContent(DoubleToString(totalRuntime));
XMLOutputter(indentLevel, NO, output);
output = XMLAddContent(DoubleToString(totalRuntime));
XMLOutputter(indentLevel, NO, output);
output = XMLCloseElement(totalRuntimeElementName);
XMLOutputter(--indentLevel, YES, output);
output = XMLCloseElement(totalRuntimeElementName);
XMLOutputter(--indentLevel, YES, output);
output = XMLCloseElement(testElementName);
XMLOutputter(--indentLevel, YES, output);
output = XMLCloseElement(testElementName);
XMLOutputter(--indentLevel, YES, output);
}
void
XMLAssert(const char *assertName, int assertResult, const char *assertMessage,
time_t eventTime)
time_t eventTime)
{
// Log passed asserts only on VERBOSE level
if(level <= LOGGER_TERSE && assertResult == ASSERT_PASS) {
return ;
}
// Log passed asserts only on VERBOSE level
if(level <= LOGGER_TERSE && assertResult == ASSERT_PASS) {
return ;
}
char *output = XMLOpenElement(assertElementName);
XMLOutputter(indentLevel++, YES, output);
char *output = XMLOpenElement(assertElementName);
XMLOutputter(indentLevel++, YES, output);
// log assert name
output = XMLOpenElement(nameElementName);
XMLOutputter(indentLevel++, NO, output);
// log assert name
output = XMLOpenElement(nameElementName);
XMLOutputter(indentLevel++, NO, output);
output = XMLAddContent(assertName);
XMLOutputter(indentLevel, NO, output);
output = XMLAddContent(assertName);
XMLOutputter(indentLevel, NO, output);
output = XMLCloseElement(nameElementName);
XMLOutputter(--indentLevel, YES, output);
output = XMLCloseElement(nameElementName);
XMLOutputter(--indentLevel, YES, output);
// log assert result
output = XMLOpenElement(resultElementName);
XMLOutputter(indentLevel++, NO, output);
// log assert result
output = XMLOpenElement(resultElementName);
XMLOutputter(indentLevel++, NO, output);
output = XMLAddContent((assertResult) ? "pass" : "failure");
XMLOutputter(indentLevel, NO, output);
output = XMLAddContent((assertResult) ? "pass" : "failure");
XMLOutputter(indentLevel, NO, output);
output = XMLCloseElement(resultElementName);
XMLOutputter(--indentLevel, YES, output);
output = XMLCloseElement(resultElementName);
XMLOutputter(--indentLevel, YES, output);
// log assert message
output = XMLOpenElement(messageElementName);
XMLOutputter(indentLevel++, NO, output);
// log assert message
output = XMLOpenElement(messageElementName);
XMLOutputter(indentLevel++, NO, output);
output = XMLAddContent(assertMessage);
XMLOutputter(indentLevel, NO, output);
output = XMLAddContent(assertMessage);
XMLOutputter(indentLevel, NO, output);
output = XMLCloseElement(messageElementName);
XMLOutputter(--indentLevel, YES, output);
output = XMLCloseElement(messageElementName);
XMLOutputter(--indentLevel, YES, output);
// log event time
output = XMLOpenElement(timeElementName);
XMLOutputter(indentLevel++, NO, output);
// log event time
output = XMLOpenElement(timeElementName);
XMLOutputter(indentLevel++, NO, output);
output = XMLAddContent(TimestampToString(eventTime));
XMLOutputter(indentLevel, NO, output);
output = XMLAddContent(TimestampToString(eventTime));
XMLOutputter(indentLevel, NO, output);
output = XMLCloseElement(timeElementName);
XMLOutputter(--indentLevel, YES, output);
output = XMLCloseElement(timeElementName);
XMLOutputter(--indentLevel, YES, output);
output = XMLCloseElement(assertElementName);
XMLOutputter(--indentLevel, YES, output);
output = XMLCloseElement(assertElementName);
XMLOutputter(--indentLevel, YES, output);
}
void
XMLAssertWithValues(const char *assertName, int assertResult, const char *assertMessage,
int actualValue, int excpected, time_t eventTime)
int actualValue, int excpected, time_t eventTime)
{
// Log passed asserts only on VERBOSE level
if(level <= LOGGER_TERSE && assertResult == ASSERT_PASS) {
return ;
}
// Log passed asserts only on VERBOSE level
if(level <= LOGGER_TERSE && assertResult == ASSERT_PASS) {
return ;
}
char *output = XMLOpenElement(assertElementName);
XMLOutputter(indentLevel++, YES, output);
char *output = XMLOpenElement(assertElementName);
XMLOutputter(indentLevel++, YES, output);
// log assert name
output = XMLOpenElement(nameElementName);
XMLOutputter(indentLevel++, NO, output);
// log assert name
output = XMLOpenElement(nameElementName);
XMLOutputter(indentLevel++, NO, output);
output = XMLAddContent(assertName);
XMLOutputter(indentLevel, NO, output);
output = XMLAddContent(assertName);
XMLOutputter(indentLevel, NO, output);
output = XMLCloseElement(nameElementName);
XMLOutputter(--indentLevel, YES, output);
output = XMLCloseElement(nameElementName);
XMLOutputter(--indentLevel, YES, output);
// log assert result
output = XMLOpenElement(resultElementName);
XMLOutputter(indentLevel++, NO, output);
// log assert result
output = XMLOpenElement(resultElementName);
XMLOutputter(indentLevel++, NO, output);
output = XMLAddContent((assertResult) ? "pass" : "failure");
XMLOutputter(indentLevel, NO, output);
output = XMLAddContent((assertResult) ? "pass" : "failure");
XMLOutputter(indentLevel, NO, output);
output = XMLCloseElement(resultElementName);
XMLOutputter(--indentLevel, YES, output);
output = XMLCloseElement(resultElementName);
XMLOutputter(--indentLevel, YES, output);
// log assert message
output = XMLOpenElement(messageElementName);
XMLOutputter(indentLevel++, NO, output);
// log assert message
output = XMLOpenElement(messageElementName);
XMLOutputter(indentLevel++, NO, output);
output = XMLAddContent(assertMessage);
XMLOutputter(indentLevel, NO, output);
output = XMLAddContent(assertMessage);
XMLOutputter(indentLevel, NO, output);
output = XMLCloseElement(messageElementName);
XMLOutputter(--indentLevel, YES, output);
output = XMLCloseElement(messageElementName);
XMLOutputter(--indentLevel, YES, output);
// log event time
output = XMLOpenElement(timeElementName);
XMLOutputter(indentLevel++, NO, output);
// log event time
output = XMLOpenElement(timeElementName);
XMLOutputter(indentLevel++, NO, output);
output = XMLAddContent(TimestampToString(eventTime));
XMLOutputter(indentLevel, NO, output);
output = XMLAddContent(TimestampToString(eventTime));
XMLOutputter(indentLevel, NO, output);
output = XMLCloseElement(timeElementName);
XMLOutputter(--indentLevel, YES, output);
output = XMLCloseElement(timeElementName);
XMLOutputter(--indentLevel, YES, output);
output = XMLCloseElement(assertElementName);
XMLOutputter(--indentLevel, YES, output);
output = XMLCloseElement(assertElementName);
XMLOutputter(--indentLevel, YES, output);
}
void
XMLAssertSummary(int numAsserts, int numAssertsFailed,
int numAssertsPass, time_t eventTime)
int numAssertsPass, time_t eventTime)
{
char *output = XMLOpenElement(assertSummaryElementName);
XMLOutputter(indentLevel++, YES, output);
char *output = XMLOpenElement(assertSummaryElementName);
XMLOutputter(indentLevel++, YES, output);
output = XMLOpenElement(assertCountElementName);
XMLOutputter(indentLevel++, NO, output);
output = XMLOpenElement(assertCountElementName);
XMLOutputter(indentLevel++, NO, output);
output = XMLAddContent(IntToString(numAsserts));
XMLOutputter(indentLevel, NO, output);
output = XMLAddContent(IntToString(numAsserts));
XMLOutputter(indentLevel, NO, output);
output = XMLCloseElement(assertCountElementName);
XMLOutputter(--indentLevel, YES, output);
output = XMLCloseElement(assertCountElementName);
XMLOutputter(--indentLevel, YES, output);
output = XMLOpenElement(assertsPassedElementName);
XMLOutputter(indentLevel++, NO, output);
output = XMLOpenElement(assertsPassedElementName);
XMLOutputter(indentLevel++, NO, output);
output = XMLAddContent(IntToString(numAssertsPass));
XMLOutputter(indentLevel, NO, output);
output = XMLAddContent(IntToString(numAssertsPass));
XMLOutputter(indentLevel, NO, output);
output = XMLCloseElement(assertsPassedElementName);
XMLOutputter(--indentLevel, YES, output);
output = XMLCloseElement(assertsPassedElementName);
XMLOutputter(--indentLevel, YES, output);
output = XMLOpenElement(assertsFailedElementName);
XMLOutputter(indentLevel++, NO, output);
output = XMLOpenElement(assertsFailedElementName);
XMLOutputter(indentLevel++, NO, output);
output = XMLAddContent(IntToString(numAsserts));
XMLOutputter(indentLevel, NO, output);
output = XMLAddContent(IntToString(numAsserts));
XMLOutputter(indentLevel, NO, output);
output = XMLCloseElement(assertsFailedElementName);
XMLOutputter(--indentLevel, YES, output);
output = XMLCloseElement(assertsFailedElementName);
XMLOutputter(--indentLevel, YES, output);
output = XMLCloseElement(assertSummaryElementName);
XMLOutputter(--indentLevel, YES, output);
output = XMLCloseElement(assertSummaryElementName);
XMLOutputter(--indentLevel, YES, output);
}
void
XMLLog(time_t eventTime, char *fmt, ...)
{
// create the log message
va_list args;
char logMessage[1024];
memset(logMessage, 0, sizeof(logMessage));
// create the log message
va_list args;
char logMessage[1024];
memset(logMessage, 0, sizeof(logMessage));
va_start( args, fmt );
SDL_vsnprintf( logMessage, sizeof(logMessage), fmt, args );
va_end( args );
va_start( args, fmt );
SDL_vsnprintf( logMessage, sizeof(logMessage), fmt, args );
va_end( args );
char *output = XMLOpenElement(logElementName);
XMLOutputter(indentLevel++, YES, output);
char *output = XMLOpenElement(logElementName);
XMLOutputter(indentLevel++, YES, output);
// log message
output = XMLOpenElement(messageElementName);
XMLOutputter(indentLevel++, NO, output);
// log message
output = XMLOpenElement(messageElementName);
XMLOutputter(indentLevel++, NO, output);
// fix this here!
output = XMLAddContent(logMessage);
XMLOutputter(indentLevel, NO, output);
// fix this here!
output = XMLAddContent(logMessage);
XMLOutputter(indentLevel, NO, output);
output = XMLCloseElement(messageElementName);
XMLOutputter(--indentLevel, YES, output);
output = XMLCloseElement(messageElementName);
XMLOutputter(--indentLevel, YES, output);
// log eventTime
output = XMLOpenElement(timeElementName);
XMLOutputter(indentLevel++, NO, output);
// log eventTime
output = XMLOpenElement(timeElementName);
XMLOutputter(indentLevel++, NO, output);
output = XMLAddContent(TimestampToString(eventTime));
XMLOutputter(indentLevel, NO, output);
output = XMLAddContent(TimestampToString(eventTime));
XMLOutputter(indentLevel, NO, output);
output = XMLCloseElement(timeElementName);
XMLOutputter(--indentLevel, YES, output);
output = XMLCloseElement(timeElementName);
XMLOutputter(--indentLevel, YES, output);
output = XMLCloseElement(logElementName);
XMLOutputter(--indentLevel, YES, output);
output = XMLCloseElement(logElementName);
XMLOutputter(--indentLevel, YES, output);
}

View File

@@ -35,7 +35,7 @@
* \param data LoggerData structure which contains data for the logger
*/
void XMLRunStarted(int parameterCount, char *runnerParameters[], char *runSeed,
time_t eventTime, LoggerData *data);
time_t eventTime, LoggerData *data);
/*!
* Prints out information about ending the test run in XML
@@ -49,7 +49,7 @@ void XMLRunStarted(int parameterCount, char *runnerParameters[], char *runSeed,
* \param totalRuntime How long the execution took
*/
void XMLRunEnded(int testCount, int suiteCount, int testPassCount, int testFailCount,
int testSkippedCount, time_t endTime, double totalRuntime);
int testSkippedCount, time_t endTime, double totalRuntime);
/*!
* Prints the data about the test suite that'll be executed next in XML
@@ -81,7 +81,7 @@ void XMLSuiteEnded(int testsPassed, int testsFailed, int testsSkipped,
* \param startTime When the test started to execute
*/
void XMLTestStarted(const char *testName, const char *suiteName,
const char *testDescription, Uint64 execKey, time_t startTime);
const char *testDescription, Uint64 execKey, time_t startTime);
/*!
* Prints information about the test test that was just executed in XML
@@ -104,7 +104,7 @@ void XMLTestEnded(const char *testName, const char *suiteName,
* \param eventTime When the assert happened
*/
void XMLAssert(const char *assertName, int assertResult, const char *assertMessage,
time_t eventTime);
time_t eventTime);
/*!
* Prints information about assert that has actual and expected values in XML
@@ -117,7 +117,7 @@ void XMLAssert(const char *assertName, int assertResult, const char *assertMessa
* \param eventTime When the assert happened
*/
void XMLAssertWithValues(const char *assertName, int assertResult, const char *assertMessage,
int actualValue, int expected, time_t eventTime);
int actualValue, int expected, time_t eventTime);
/*!
* Prints summary of all assertions of certain tests in XML

View File

@@ -26,8 +26,8 @@
/* Logging levels */
typedef enum LogLevel {
LOGGER_TERSE = 1,
LOGGER_VERBOSE
LOGGER_TERSE = 1,
LOGGER_VERBOSE
} Level;
//! Default logging level
@@ -35,14 +35,14 @@ typedef enum LogLevel {
//! Contains information for the logger
typedef struct LoggerData {
//! If enabled logger will write to stdout instead of file
int stdoutEnabled;
//!< Name and directory of the log file (ie. logs/runner-seed.log)
char *filename;
//!< Logging level of the logger (such as VERBOSE)
Level level;
//!< Some custom data that a logger needs
char *custom;
//! If enabled logger will write to stdout instead of file
int stdoutEnabled;
//!< Name and directory of the log file (ie. logs/runner-seed.log)
char *filename;
//!< Logging level of the logger (such as VERBOSE)
Level level;
//!< Some custom data that a logger needs
char *custom;
} LoggerData;
/*!
@@ -50,30 +50,30 @@ typedef struct LoggerData {
* logging interface. See the headers of implementations (plain_logger.h or
* xml_logger.h) for more information.
*/
typedef void (*RunStartedFp)(int parameterCount, char *runnerParameters[], char *runSeed, time_t eventTime, LoggerData *data);
typedef void (*RunEndedFp)(int testCount, int suiteCount, int testPassCount, int testFailCount,
typedef void (*RunStartedFp)(int parameterCount, char *runnerParameters[], char *runSeed, time_t eventTime, LoggerData *data);
typedef void (*RunEndedFp)(int testCount, int suiteCount, int testPassCount, int testFailCount,
int testSkippedCount, time_t endTime, double totalRuntime);
typedef void (*SuiteStartedFp)(const char *suiteName, time_t eventTime);
typedef void (*SuiteEndedFp)(int testsPassed, int testsFailed, int testsSkipped,
time_t endTime, double totalRuntime);
typedef void (*SuiteStartedFp)(const char *suiteName, time_t eventTime);
typedef void (*SuiteEndedFp)(int testsPassed, int testsFailed, int testsSkipped,
time_t endTime, double totalRuntime);
typedef void (*TestStartedFp)(const char *testName, const char *suiteName,
typedef void (*TestStartedFp)(const char *testName, const char *suiteName,
const char *testDescription, Uint64 execKey, time_t startTime);
typedef void (*TestEndedFp)(const char *testName, const char *suiteName, int testResult,
typedef void (*TestEndedFp)(const char *testName, const char *suiteName, int testResult,
time_t endTime, double totalRuntime);
typedef void (*AssertFp)(const char *assertName, int assertResult,
const char *assertMessage, time_t eventTime);
typedef void (*AssertFp)(const char *assertName, int assertResult,
const char *assertMessage, time_t eventTime);
typedef void (*AssertWithValuesFp)(const char *assertName, int assertResult,
const char *assertMessage, int actualValue, int expected,
time_t eventTime);
typedef void (*AssertWithValuesFp)(const char *assertName, int assertResult,
const char *assertMessage, int actualValue, int expected,
time_t eventTime);
typedef void (*AssertSummaryFp)(int numAsserts, int numAssertsFailed,
int numAssertsPass, time_t eventTime);
typedef void (*AssertSummaryFp)(int numAsserts, int numAssertsFailed,
int numAssertsPass, time_t eventTime);
typedef void (*LogFp)(time_t eventTime, char *fmt, ...);
typedef void (*LogFp)(time_t eventTime, char *fmt, ...);
/*! Function pointers to actual logging function implementations */

File diff suppressed because it is too large Load Diff

View File

@@ -25,28 +25,28 @@
int
PlatformSupportsAudio()
{
int retValue = 0;
int retValue = 0;
#ifdef SDL_AUDIO_DRIVER_COREAUDIO
retValue = 1;
retValue = 1;
#endif
#ifdef SDL_AUDIO_DRIVER_OSS
retValue = 1;
retValue = 1;
#endif
return retValue;
return retValue;
}
int
PlatformSupportsStdio()
{
int retValue = 0;
int retValue = 0;
#ifdef HAVE_STDIO_H
retValue = 1;
retValue = 1;
#endif
return retValue;
return retValue;
}
@@ -64,12 +64,12 @@ SDL_test.h
int
PlatformSupportsOpenGL() {
int retValue = 0;
int retValue = 0;
#define SDL_VIDEO_OPENGL
retValue = 1;
retValue = 1;
#endif
return retValue;
return retValue;
}
*/

View File

@@ -11,25 +11,25 @@
/* Test cases */
static const TestCaseReference test1 =
(TestCaseReference){ "audio_enumerateAndNameAudioDevices", "Enumerate and name available audio devices (output and capture)", TEST_ENABLED, TEST_REQUIRES_AUDIO, 0};
(TestCaseReference){ "audio_enumerateAndNameAudioDevices", "Enumerate and name available audio devices (output and capture)", TEST_ENABLED, TEST_REQUIRES_AUDIO, 0};
static const TestCaseReference test2 =
(TestCaseReference){ "audio_enumerateAndNameAudioDevicesNegativeTests", "Netative tests around enumeration and naming of audio devices.", TEST_ENABLED, TEST_REQUIRES_AUDIO, 0};
(TestCaseReference){ "audio_enumerateAndNameAudioDevicesNegativeTests", "Netative tests around enumeration and naming of audio devices.", TEST_ENABLED, TEST_REQUIRES_AUDIO, 0};
static const TestCaseReference test3 =
(TestCaseReference){ "audio_printAudioDrivers", "Checks available audio driver names.", TEST_ENABLED, TEST_REQUIRES_AUDIO, 0};
(TestCaseReference){ "audio_printAudioDrivers", "Checks available audio driver names.", TEST_ENABLED, TEST_REQUIRES_AUDIO, 0};
static const TestCaseReference test4 =
(TestCaseReference){ "audio_printCurrentAudioDriver", "Checks current audio driver name with initialized audio.", TEST_ENABLED, TEST_REQUIRES_AUDIO, 0};
(TestCaseReference){ "audio_printCurrentAudioDriver", "Checks current audio driver name with initialized audio.", TEST_ENABLED, TEST_REQUIRES_AUDIO, 0};
/* Test suite */
extern const TestCaseReference *testSuite[] = {
&test1, &test2, &test3, &test4, NULL
&test1, &test2, &test3, &test4, NULL
};
TestCaseReference **QueryTestSuite() {
return (TestCaseReference **)testSuite;
return (TestCaseReference **)testSuite;
}
/* Fixture */
@@ -37,23 +37,23 @@ TestCaseReference **QueryTestSuite() {
void
SetUp(void *arg)
{
/* Start SDL. */
int ret = SDL_Init( SDL_INIT_AUDIO );
AssertTrue(ret==0, "SDL_Init(SDL_INIT_AUDIO): %s", SDL_GetError());
/* Start SDL. */
int ret = SDL_Init( SDL_INIT_AUDIO );
AssertTrue(ret==0, "SDL_Init(SDL_INIT_AUDIO): %s", SDL_GetError());
}
void
TearDown(void *arg)
{
/* Quit SDL. */
SDL_Quit();
/* Quit SDL. */
SDL_Quit();
}
/* Test case functions */
/**
* \brief Enumerate and name available audio devices (output and capture).
*
*
* \sa http://wiki.libsdl.org/moin.cgi/SDL_GetNumAudioDevices
* \sa http://wiki.libsdl.org/moin.cgi/SDL_GetAudioDeviceName
*/
@@ -66,13 +66,13 @@ int audio_enumerateAndNameAudioDevices()
/* Iterate over types: t=0 output device, t=1 input/capture device */
for (t=0; t<2; t++) {
/* Get number of devices. */
n = SDL_GetNumAudioDevices(t);
AssertTrue(n>=0,
"Number of %s devices < 0, reported as %i: %s",
AssertTrue(n>=0,
"Number of %s devices < 0, reported as %i: %s",
(t) ? "output" : "capture",
n,
n,
SDL_GetError());
/* Variation of non-zero type */
@@ -82,8 +82,8 @@ int audio_enumerateAndNameAudioDevices()
AssertTrue(n==nn, "SDL_GetNumAudioDevices(%i) : expected same number of audio devices %i, got %i", tt, n, nn);
nn = SDL_GetNumAudioDevices(-tt);
AssertTrue(n==nn, "SDL_GetNumAudioDevices(%i) : expected same number of audio devices %i, got %i", -tt, n, nn);
}
}
/* List devices. */
if (n>0) {
for (i=0; i<n; i++) {
@@ -95,8 +95,8 @@ int audio_enumerateAndNameAudioDevices()
nameAgain = SDL_GetAudioDeviceName(i, tt);
AssertTrue(nameAgain != NULL, "SDL_GetAudioDeviceName(%i, %i): returned NULL name", i, tt);
AssertTrue(strlen(nameAgain)>0, "SDL_GetAudioDeviceName(%i, %i): returned empty name string", i, tt);
AssertTrue(strcmp(name, nameAgain)==0,
"SDL_GetAudioDeviceName(%i, %i): returned unexpected name string %s, expected %s",
AssertTrue(strcmp(name, nameAgain)==0,
"SDL_GetAudioDeviceName(%i, %i): returned unexpected name string %s, expected %s",
i, tt, nameAgain, name);
}
}
@@ -106,7 +106,7 @@ int audio_enumerateAndNameAudioDevices()
/**
* \brief Negative tests around enumeration and naming of audio devices.
*
*
* \sa http://wiki.libsdl.org/moin.cgi/SDL_GetNumAudioDevices
* \sa http://wiki.libsdl.org/moin.cgi/SDL_GetAudioDeviceName
*/
@@ -116,25 +116,25 @@ int audio_enumerateAndNameAudioDevicesNegativeTests()
int t;
int i, j, no, nc;
const char *name;
/* Get number of devices. */
no = SDL_GetNumAudioDevices(0);
nc = SDL_GetNumAudioDevices(1);
/* Invalid device index when getting name */
for (t=0; t<2; t++) {
/* Negative device index */
i = -1;
name = SDL_GetAudioDeviceName(i, t);
AssertTrue(name == NULL, "SDL_GetAudioDeviceName(%i, %i): returned a name, should return NULL", i, t);
/* Device index past range */
for (j=0; j<3; j++) {
i = (t) ? nc+j : no+j;
name = SDL_GetAudioDeviceName(i, t);
AssertTrue(name == NULL, "SDL_GetAudioDeviceName(%i, %i): returned a name, should return NULL", i, t);
}
/* Capture index past capture range but within output range */
if ((no>0) && (no>nc) && (t==1)) {
i = no-1;
@@ -155,7 +155,7 @@ int audio_printAudioDrivers()
/* Get number of drivers */
n = SDL_GetNumAudioDrivers();
AssertTrue(n>=0, "Number of audio drivers >= 0");
/* List drivers. */
if (n>0)
{

View File

@@ -12,24 +12,24 @@
/* Test cases */
static const TestCaseReference test1 =
(TestCaseReference){ "clipboard_testHasClipboardText", "Check call to SDL_HasClipboardText", TEST_ENABLED, 0, 0 };
(TestCaseReference){ "clipboard_testHasClipboardText", "Check call to SDL_HasClipboardText", TEST_ENABLED, 0, 0 };
static const TestCaseReference test2 =
(TestCaseReference){ "clipboard_testGetClipboardText", "Check call to SDL_GetClipboardText", TEST_ENABLED, 0, 0 };
(TestCaseReference){ "clipboard_testGetClipboardText", "Check call to SDL_GetClipboardText", TEST_ENABLED, 0, 0 };
static const TestCaseReference test3 =
(TestCaseReference){ "clipboard_testSetClipboardText", "Check call to SDL_SetClipboardText", TEST_ENABLED, 0, 0 };
(TestCaseReference){ "clipboard_testSetClipboardText", "Check call to SDL_SetClipboardText", TEST_ENABLED, 0, 0 };
static const TestCaseReference test4 =
(TestCaseReference){ "clipboard_testClipboardTextFunctions", "End-to-end test of SDL_xyzClipboardText functions", TEST_ENABLED, 0, 0 };
(TestCaseReference){ "clipboard_testClipboardTextFunctions", "End-to-end test of SDL_xyzClipboardText functions", TEST_ENABLED, 0, 0 };
/* Test suite */
extern const TestCaseReference *testSuite[] = {
&test1, &test2, &test3, &test4, NULL
&test1, &test2, &test3, &test4, NULL
};
TestCaseReference **QueryTestSuite() {
return (TestCaseReference **)testSuite;
return (TestCaseReference **)testSuite;
}
void
@@ -39,7 +39,7 @@ SetUp(void *arg)
int ret = SDL_InitSubSystem( SDL_INIT_VIDEO );
AssertTrue(ret==0, "SDL_Init(SDL_INIT_VIDEO) failed: %s", SDL_GetError());
}
void
TearDown(void *arg)
{
@@ -50,52 +50,52 @@ TearDown(void *arg)
/**
* \brief Check call to SDL_HasClipboardText
*
* \sa
* \sa
* http://wiki.libsdl.org/moin.cgi/SDL_HasClipboardText
*/
int
clipboard_testHasClipboardText(void *arg)
{
SDL_bool result;
result = SDL_HasClipboardText();
AssertPass("Call to SDL_HasClipboardText succeeded");
SDL_bool result;
result = SDL_HasClipboardText();
AssertPass("Call to SDL_HasClipboardText succeeded");
}
/**
* \brief Check call to SDL_GetClipboardText
*
* \sa
* \sa
* http://wiki.libsdl.org/moin.cgi/SDL_GetClipboardText
*/
int
clipboard_testGetClipboardText(void *arg)
{
char *result;
result = SDL_GetClipboardText();
AssertPass("Call to SDL_GetClipboardText succeeded");
char *result;
result = SDL_GetClipboardText();
AssertPass("Call to SDL_GetClipboardText succeeded");
}
/**
* \brief Check call to SDL_SetClipboardText
* \sa
* \sa
* http://wiki.libsdl.org/moin.cgi/SDL_SetClipboardText
*/
int
clipboard_testSetClipboardText(void *arg)
{
char *textRef = RandomAsciiString();
char *text = strdup(textRef);
int result;
result = SDL_SetClipboardText((const char *)text);
AssertTrue(
result == 0,
"Call to SDL_SetClipboardText failed with error %i: %s",
result, SDL_GetError());
AssertTrue(
strcmp(textRef, text) == 0,
"SDL_SetClipboardText modified input string: expected %s, got %s",
textRef, text);
char *textRef = RandomAsciiString();
char *text = strdup(textRef);
int result;
result = SDL_SetClipboardText((const char *)text);
AssertTrue(
result == 0,
"Call to SDL_SetClipboardText failed with error %i: %s",
result, SDL_GetError());
AssertTrue(
strcmp(textRef, text) == 0,
"SDL_SetClipboardText modified input string: expected %s, got %s",
textRef, text);
/* Cleanup */
if (textRef) free(textRef);
if (text) free(text);
@@ -104,7 +104,7 @@ clipboard_testSetClipboardText(void *arg)
/**
* \brief End-to-end test of SDL_xyzClipboardText functions
* \sa
* \sa
* http://wiki.libsdl.org/moin.cgi/SDL_HasClipboardText
* http://wiki.libsdl.org/moin.cgi/SDL_GetClipboardText
* http://wiki.libsdl.org/moin.cgi/SDL_SetClipboardText
@@ -112,54 +112,54 @@ clipboard_testSetClipboardText(void *arg)
int
clipboard_testClipboardTextFunctions(void *arg)
{
char *textRef = RandomAsciiString();
char *text = strdup(textRef);
SDL_bool boolResult;
int intResult;
char *charResult;
/* Clear clipboard text state */
boolResult = SDL_HasClipboardText();
if (boolResult == SDL_TRUE) {
char *textRef = RandomAsciiString();
char *text = strdup(textRef);
SDL_bool boolResult;
int intResult;
char *charResult;
/* Clear clipboard text state */
boolResult = SDL_HasClipboardText();
if (boolResult == SDL_TRUE) {
intResult = SDL_SetClipboardText((const char *)NULL);
AssertTrue(
intResult == 0,
"Call to SDL_SetClipboardText("") failed with error %i: %s",
intResult, SDL_GetError());
charResult = SDL_GetClipboardText();
boolResult = SDL_HasClipboardText();
AssertTrue(
AssertTrue(
intResult == 0,
"Call to SDL_SetClipboardText("") failed with error %i: %s",
intResult, SDL_GetError());
charResult = SDL_GetClipboardText();
boolResult = SDL_HasClipboardText();
AssertTrue(
boolResult == SDL_FALSE,
"SDL_HasClipboardText returned TRUE, expected FALSE");
"SDL_HasClipboardText returned TRUE, expected FALSE");
}
/* Empty clipboard */
charResult = SDL_GetClipboardText();
AssertTrue(
charResult != NULL,
"SDL_GetClipboardText returned NULL");
AssertTrue(
strlen(charResult) == 0,
"SDL_GetClipboardText returned string with length >0: got length %i",
strlen(charResult));
intResult = SDL_SetClipboardText((const char *)text);
AssertTrue(
intResult == 0,
"Call to SDL_SetClipboardText failed with error %i: %s",
intResult, SDL_GetError());
AssertTrue(
strcmp(textRef, text) == 0,
"SDL_SetClipboardText modified input string: expected %s, got %s",
textRef, text);
boolResult = SDL_HasClipboardText();
AssertTrue(
/* Empty clipboard */
charResult = SDL_GetClipboardText();
AssertTrue(
charResult != NULL,
"SDL_GetClipboardText returned NULL");
AssertTrue(
strlen(charResult) == 0,
"SDL_GetClipboardText returned string with length >0: got length %i",
strlen(charResult));
intResult = SDL_SetClipboardText((const char *)text);
AssertTrue(
intResult == 0,
"Call to SDL_SetClipboardText failed with error %i: %s",
intResult, SDL_GetError());
AssertTrue(
strcmp(textRef, text) == 0,
"SDL_SetClipboardText modified input string: expected %s, got %s",
textRef, text);
boolResult = SDL_HasClipboardText();
AssertTrue(
boolResult == SDL_TRUE,
"SDL_HasClipboardText returned FALSE, expected TRUE");
charResult = SDL_GetClipboardText();
AssertTrue(
strcmp(textRef, charResult) == 0,
"SDL_GetClipboardText did not return correst string: expected %s, got %s",
textRef, charResult);
"SDL_HasClipboardText returned FALSE, expected TRUE");
charResult = SDL_GetClipboardText();
AssertTrue(
strcmp(textRef, charResult) == 0,
"SDL_GetClipboardText did not return correst string: expected %s, got %s",
textRef, charResult);
/* Cleanup */
if (textRef) free(textRef);

View File

@@ -35,25 +35,25 @@
/* Test case references */
static const TestCaseReference test1 =
(TestCaseReference){ "test_dummy1", "description", TEST_ENABLED, 0, 4};
(TestCaseReference){ "test_dummy1", "description", TEST_ENABLED, 0, 4};
static const TestCaseReference test2 =
(TestCaseReference){ "test_dummy2", "description", TEST_ENABLED, 0, 0};
(TestCaseReference){ "test_dummy2", "description", TEST_ENABLED, 0, 0};
static const TestCaseReference test3 =
(TestCaseReference){ "test_fuzzy", "description", TEST_ENABLED, 0, 2};
(TestCaseReference){ "test_fuzzy", "description", TEST_ENABLED, 0, 2};
static const TestCaseReference test4 =
(TestCaseReference){ "test_leak", "description", TEST_ENABLED, 0, 2};
(TestCaseReference){ "test_leak", "description", TEST_ENABLED, 0, 2};
/* Test suite */
extern const TestCaseReference *testSuite[] = {
&test1, &test2, &test3, &test4, NULL
&test1, &test2, &test3, &test4, NULL
};
TestCaseReference **QueryTestSuite() {
return (TestCaseReference **)testSuite;
return (TestCaseReference **)testSuite;
}
/* Create test fixture */
@@ -72,8 +72,8 @@ TestCaseReference **QueryTestSuite() {
void
SetUp(void *arg)
{
// create test fixture,
// for example, set up static variables used by test cases here
// create test fixture,
// for example, set up static variables used by test cases here
}
/*!
@@ -87,71 +87,71 @@ SetUp(void *arg)
void
TearDown(void *arg)
{
// destroy test fixture
// destroy test fixture
}
/* Test case functions */
void
test_dummy1(void *arg)
{
AssertEquals(5, 5, "Assert message");
AssertEquals(5, 5, "Assert message");
/*
for( ; 1 ; )
Log(0, "uint8 (same value): %u", RandomUint32());
// */
/*
for( ; 1 ; )
Log(0, "uint8 (same value): %u", RandomUint32());
// */
//Log(0, "uint8 (same value): %d", RandomUint8BoundaryValue(200, 200, SDL_TRUE));
//Log(0, "uint8 (same value): %d", RandomUint8BoundaryValue(200, 200, SDL_TRUE));
int c = 0;
//for(; c < 100 ; c++)
printf("%f\n", RandomUnitFloat());
int c = 0;
//for(; c < 100 ; c++)
printf("%f\n", RandomUnitFloat());
for(; 0 ; )
printf("%d\n", RandomSint16());
for(; 0 ; )
printf("%d\n", RandomSint16());
for( ; 0 ; ) {
//Log(0, "sint8: %d", RandomSint8BoundaryValue(-11, 10, SDL_TRUE));
//Log(0, "sint16: %d", RandomSint16BoundaryValue(SHRT_MIN, SHRT_MAX, SDL_FALSE));
Log(0, "sint32: %d", RandomSint32BoundaryValue(INT_MIN, 3000, SDL_FALSE));
//Log(0, "sint64: %lld", RandomSint64BoundaryValue(-34, -34, SDL_FALSE));
}
for( ; 0 ; ) {
//Log(0, "sint8: %d", RandomSint8BoundaryValue(-11, 10, SDL_TRUE));
//Log(0, "sint16: %d", RandomSint16BoundaryValue(SHRT_MIN, SHRT_MAX, SDL_FALSE));
Log(0, "sint32: %d", RandomSint32BoundaryValue(INT_MIN, 3000, SDL_FALSE));
//Log(0, "sint64: %lld", RandomSint64BoundaryValue(-34, -34, SDL_FALSE));
}
for(; 0 ;) {
//Log(0, "int8: %u", RandomUint8BoundaryValue(0, 255, SDL_FALSE));
//Log(0, "uint16: %u", RandomUint16BoundaryValue(0, UINT16_MAX, SDL_FALSE));
//Log(0, "int32: %u", RandomUint32BoundaryValue(0, 0xFFFFFFFE, SDL_FALSE));
Log(0, "int64: %llu", RandomUint64BoundaryValue(2, 0xFFFFFFFFFFFFFFFE, SDL_FALSE));
}
for(; 0 ;) {
//Log(0, "int8: %u", RandomUint8BoundaryValue(0, 255, SDL_FALSE));
//Log(0, "uint16: %u", RandomUint16BoundaryValue(0, UINT16_MAX, SDL_FALSE));
//Log(0, "int32: %u", RandomUint32BoundaryValue(0, 0xFFFFFFFE, SDL_FALSE));
Log(0, "int64: %llu", RandomUint64BoundaryValue(2, 0xFFFFFFFFFFFFFFFE, SDL_FALSE));
}
for(; 0 ;) {
int min = -5;
int max = 5;
int random = RandomIntegerInRange(min, max);
if(random < min || random > max ) {
AssertFail("Generated incorrect integer");
}
Log(0, "%d", random);
}
for(; 0 ;) {
int min = -5;
int max = 5;
int random = RandomIntegerInRange(min, max);
if(random < min || random > max ) {
AssertFail("Generated incorrect integer");
}
Log(0, "%d", random);
}
//Log(0, "Random: %s", RandomAsciiString());
//Log(0, "Random: %s", RandomAsciiString());
}
void
test_dummy2(void *arg)
{
char *msg = "eello";
//msg[0] = 'H';
AssertTrue(1, "Assert message");
AssertTrue(0, "Assert message");
AssertTrue(1, "Assert message");
char *msg = "eello";
//msg[0] = 'H';
AssertTrue(1, "Assert message");
AssertTrue(0, "Assert message");
AssertTrue(1, "Assert message");
}
void
test_fuzzy(void *arg)
{
// Simulates a fuzzing failure
AssertTrue(RandomUint8() != 100, "Value is 100");
// Simulates a fuzzing failure
AssertTrue(RandomUint8() != 100, "Value is 100");
}
static void
@@ -164,9 +164,9 @@ f(void) {
void
test_leak(void *arg)
{
// Creates a memory leak
f();
// Creates a memory leak
f();
AssertPass("");
AssertPass("");
}

View File

@@ -13,15 +13,15 @@
/* Test cases */
static const TestCaseReference test1 =
(TestCaseReference){ "events_test", "description", TEST_DISABLED, 0, 0 };
(TestCaseReference){ "events_test", "description", TEST_DISABLED, 0, 0 };
/* Test suite */
extern const TestCaseReference *testSuite[] = {
&test1, NULL
&test1, NULL
};
TestCaseReference **QueryTestSuite() {
return (TestCaseReference **)testSuite;
return (TestCaseReference **)testSuite;
}
/**
@@ -30,5 +30,5 @@ TestCaseReference **QueryTestSuite() {
int
events_test(void *arg)
{
AssertPass("");
AssertPass("");
}

View File

@@ -13,15 +13,15 @@
/* Test cases */
static const TestCaseReference test1 =
(TestCaseReference){ "keyboard_test", "description", TEST_DISABLED, 0, 0 };
(TestCaseReference){ "keyboard_test", "description", TEST_DISABLED, 0, 0 };
/* Test suite */
extern const TestCaseReference *testSuite[] = {
&test1, NULL
&test1, NULL
};
TestCaseReference **QueryTestSuite() {
return (TestCaseReference **)testSuite;
return (TestCaseReference **)testSuite;
}
/**
@@ -30,5 +30,5 @@ TestCaseReference **QueryTestSuite() {
int
keyboard_test(void *arg)
{
AssertPass("");
AssertPass("");
}

View File

@@ -11,45 +11,45 @@
/* Test cases */
static const TestCaseReference test1 =
(TestCaseReference){ "platform_testTypes", "Tests predefined types", TEST_ENABLED, 0, 0 };
(TestCaseReference){ "platform_testTypes", "Tests predefined types", TEST_ENABLED, 0, 0 };
static const TestCaseReference test2 =
(TestCaseReference){ "platform_testEndianessAndSwap", "Tests endianess and swap functions", TEST_ENABLED, 0, 0 };
(TestCaseReference){ "platform_testEndianessAndSwap", "Tests endianess and swap functions", TEST_ENABLED, 0, 0 };
static const TestCaseReference test3 =
(TestCaseReference){ "platform_testGetFunctions", "Tests various SDL_GetXYZ functions", TEST_ENABLED, 0, 0 };
(TestCaseReference){ "platform_testGetFunctions", "Tests various SDL_GetXYZ functions", TEST_ENABLED, 0, 0 };
static const TestCaseReference test4 =
(TestCaseReference){ "platform_testHasFunctions", "Tests various SDL_HasXYZ functions", TEST_ENABLED, 0, 0 };
(TestCaseReference){ "platform_testHasFunctions", "Tests various SDL_HasXYZ functions", TEST_ENABLED, 0, 0 };
static const TestCaseReference test5 =
(TestCaseReference){ "platform_testGetVersion", "Tests SDL_GetVersion function", TEST_ENABLED, 0, 0 };
(TestCaseReference){ "platform_testGetVersion", "Tests SDL_GetVersion function", TEST_ENABLED, 0, 0 };
static const TestCaseReference test6 =
(TestCaseReference){ "platform_testSDLVersion", "Tests SDL_VERSION macro", TEST_ENABLED, 0, 0 };
(TestCaseReference){ "platform_testSDLVersion", "Tests SDL_VERSION macro", TEST_ENABLED, 0, 0 };
static const TestCaseReference test7 =
(TestCaseReference){ "platform_testDefaultInit", "Tests default SDL_Init", TEST_ENABLED, 0, 0 };
(TestCaseReference){ "platform_testDefaultInit", "Tests default SDL_Init", TEST_ENABLED, 0, 0 };
static const TestCaseReference test8 =
(TestCaseReference){ "platform_testGetSetClearError", "Tests SDL_Get/Set/ClearError", TEST_ENABLED, 0, 0 };
(TestCaseReference){ "platform_testGetSetClearError", "Tests SDL_Get/Set/ClearError", TEST_ENABLED, 0, 0 };
static const TestCaseReference test9 =
(TestCaseReference){ "platform_testSetErrorEmptyInput", "Tests SDL_SetError with empty input", TEST_ENABLED, 0, 0 };
(TestCaseReference){ "platform_testSetErrorEmptyInput", "Tests SDL_SetError with empty input", TEST_ENABLED, 0, 0 };
static const TestCaseReference test10 =
(TestCaseReference){ "platform_testSetErrorInvalidInput", "Tests SDL_SetError with invalid input", TEST_ENABLED, 0, 0 };
(TestCaseReference){ "platform_testSetErrorInvalidInput", "Tests SDL_SetError with invalid input", TEST_ENABLED, 0, 0 };
static const TestCaseReference test11 =
(TestCaseReference){ "platform_testGetPowerInfo", "Tests SDL_GetPowerInfo function", TEST_ENABLED, 0, 0 };
(TestCaseReference){ "platform_testGetPowerInfo", "Tests SDL_GetPowerInfo function", TEST_ENABLED, 0, 0 };
/* Test suite */
extern const TestCaseReference *testSuite[] = {
&test1, &test2, &test3, &test4, &test5, &test6, &test7, &test8, &test9, &test10, &test11, NULL
&test1, &test2, &test3, &test4, &test5, &test6, &test7, &test8, &test9, &test10, &test11, NULL
};
TestCaseReference **QueryTestSuite() {
return (TestCaseReference **)testSuite;
return (TestCaseReference **)testSuite;
}
/**
@@ -103,14 +103,14 @@ int platform_testEndianessAndSwap(void *arg)
swapped64 = 0x1234ABCD;
swapped64 <<= 32;
swapped64 |= 0xDEADBEEF;
if ((*((char *) &value) >> 4) == 0x1) {
real_byteorder = SDL_BIG_ENDIAN;
} else {
real_byteorder = SDL_LIL_ENDIAN;
}
/* Test endianness. */
/* Test endianness. */
AssertTrue( real_byteorder == SDL_BYTEORDER,
"Machine detected as %s endian, appears to be %s endian.",
(SDL_BYTEORDER == SDL_LIL_ENDIAN) ? "little" : "big",
@@ -151,29 +151,29 @@ int platform_testGetFunctions (void *arg)
char *revision;
int ret;
int len;
platform = (char *)SDL_GetPlatform();
AssertPass("SDL_GetPlatform()");
AssertTrue(platform != NULL, "SDL_GetPlatform() != NULL");
if (platform != NULL) {
len = strlen(platform);
AssertTrue(len > 0,
"SDL_GetPlatform(): expected non-empty platform, was platform: '%s', len: %i",
platform,
AssertTrue(len > 0,
"SDL_GetPlatform(): expected non-empty platform, was platform: '%s', len: %i",
platform,
len);
}
ret = SDL_GetCPUCount();
AssertPass("SDL_GetCPUCount()");
AssertTrue(ret > 0,
"SDL_GetCPUCount(): expected count > 0, was: %i",
ret);
"SDL_GetCPUCount(): expected count > 0, was: %i",
ret);
ret = SDL_GetCPUCacheLineSize();
AssertPass("SDL_GetCPUCacheLineSize()");
AssertTrue(ret >= 0,
"SDL_GetCPUCacheLineSize(): expected size >= 0, was: %i",
ret);
"SDL_GetCPUCacheLineSize(): expected size >= 0, was: %i",
ret);
revision = (char *)SDL_GetRevision();
AssertPass("SDL_GetRevision()");
@@ -199,12 +199,12 @@ int platform_testGetFunctions (void *arg)
int platform_testHasFunctions (void *arg)
{
int ret;
// TODO: independently determine and compare values as well
ret = SDL_HasRDTSC();
AssertPass("SDL_HasRDTSC()");
ret = SDL_HasAltiVec();
AssertPass("SDL_HasAltiVec()");
@@ -238,16 +238,16 @@ int platform_testHasFunctions (void *arg)
int platform_testGetVersion(void *arg)
{
SDL_version linked;
SDL_GetVersion(&linked);
AssertTrue( linked.major >= SDL_MAJOR_VERSION,
"SDL_GetVersion(): returned major %i (>= %i)",
linked.major,
SDL_MAJOR_VERSION);
SDL_MAJOR_VERSION);
AssertTrue( linked.minor >= SDL_MINOR_VERSION,
"SDL_GetVersion(): returned minor %i (>= %i)",
linked.minor,
SDL_MINOR_VERSION);
SDL_MINOR_VERSION);
}
/*!
@@ -256,16 +256,16 @@ int platform_testGetVersion(void *arg)
int platform_testSDLVersion(void *arg)
{
SDL_version compiled;
SDL_VERSION(&compiled);
AssertTrue( compiled.major >= SDL_MAJOR_VERSION,
"SDL_VERSION() returned major %i (>= %i)",
compiled.major,
SDL_MAJOR_VERSION);
SDL_MAJOR_VERSION);
AssertTrue( compiled.minor >= SDL_MINOR_VERSION,
"SDL_VERSION() returned minor %i (>= %i)",
compiled.minor,
SDL_MINOR_VERSION);
SDL_MINOR_VERSION);
}
/*!
@@ -275,24 +275,24 @@ int platform_testDefaultInit(void *arg)
{
int ret;
int subsystem;
ret = SDL_Init(0);
AssertTrue( ret == 0,
ret = SDL_Init(0);
AssertTrue( ret == 0,
"SDL_Init(0): returned %i, expected 0, error: %s",
ret,
SDL_GetError());
subsystem = SDL_WasInit(0);
AssertTrue( subsystem == 0,
AssertTrue( subsystem == 0,
"SDL_WasInit(0): returned %i, expected 0",
ret);
ret);
SDL_Quit();
}
/*!
* \brief Tests SDL_Get/Set/ClearError
* \sa
* \sa
* http://wiki.libsdl.org/moin.cgi/SDL_GetError
* http://wiki.libsdl.org/moin.cgi/SDL_SetError
* http://wiki.libsdl.org/moin.cgi/SDL_ClearError
@@ -302,40 +302,40 @@ int platform_testGetSetClearError(void *arg)
const char *testError = "Testing";
char *lastError;
int len;
SDL_ClearError();
AssertPass("SDL_ClearError()");
lastError = (char *)SDL_GetError();
lastError = (char *)SDL_GetError();
AssertPass("SDL_GetError()");
AssertTrue(lastError != NULL,
AssertTrue(lastError != NULL,
"SDL_GetError() != NULL");
if (lastError != NULL)
{
len = strlen(lastError);
AssertTrue(len == 0,
AssertTrue(len == 0,
"SDL_GetError(): no message expected, len: %i", len);
}
SDL_SetError("%s", testError);
AssertPass("SDL_SetError()");
lastError = (char *)SDL_GetError();
AssertTrue(lastError != NULL,
lastError = (char *)SDL_GetError();
AssertTrue(lastError != NULL,
"SDL_GetError() != NULL");
if (lastError != NULL)
{
len = strlen(lastError);
AssertTrue(len == strlen(testError),
"SDL_GetError(): expected message len %i, was len: %i",
strlen(testError),
AssertTrue(len == strlen(testError),
"SDL_GetError(): expected message len %i, was len: %i",
strlen(testError),
len);
AssertTrue(strcmp(lastError, testError) == 0,
"SDL_GetError(): expected message %s, was message: %s",
testError,
AssertTrue(strcmp(lastError, testError) == 0,
"SDL_GetError(): expected message %s, was message: %s",
testError,
lastError);
}
// Clean up
// Clean up
SDL_ClearError();
}
@@ -349,32 +349,32 @@ int platform_testSetErrorEmptyInput(void *arg)
const char *testError = "";
char *lastError;
int len;
SDL_SetError("%s", testError);
AssertPass("SDL_SetError()");
lastError = (char *)SDL_GetError();
AssertTrue(lastError != NULL,
lastError = (char *)SDL_GetError();
AssertTrue(lastError != NULL,
"SDL_GetError() != NULL");
if (lastError != NULL)
{
len = strlen(lastError);
AssertTrue(len == strlen(testError),
"SDL_GetError(): expected message len %i, was len: %i",
strlen(testError),
AssertTrue(len == strlen(testError),
"SDL_GetError(): expected message len %i, was len: %i",
strlen(testError),
len);
AssertTrue(strcmp(lastError, testError) == 0,
"SDL_GetError(): expected message '%s', was message: '%s'",
testError,
AssertTrue(strcmp(lastError, testError) == 0,
"SDL_GetError(): expected message '%s', was message: '%s'",
testError,
lastError);
}
// Clean up
// Clean up
SDL_ClearError();
}
/*!
* \brief Tests SDL_SetError with invalid input
* \sa
* \sa
* http://wiki.libsdl.org/moin.cgi/SDL_SetError
*/
int platform_testSetErrorInvalidInput(void *arg)
@@ -386,48 +386,48 @@ int platform_testSetErrorInvalidInput(void *arg)
// Reset
SDL_ClearError();
// Check for no-op
SDL_SetError(testError);
AssertPass("SDL_SetError()");
lastError = (char *)SDL_GetError();
AssertTrue(lastError != NULL,
lastError = (char *)SDL_GetError();
AssertTrue(lastError != NULL,
"SDL_GetError() != NULL");
if (lastError != NULL)
{
len = strlen(lastError);
AssertTrue(len == 0,
"SDL_GetError(): expected message len 0, was len: %i",
0,
AssertTrue(len == 0,
"SDL_GetError(): expected message len 0, was len: %i",
0,
len);
AssertTrue(strcmp(lastError, "") == 0,
"SDL_GetError(): expected message '', was message: '%s'",
AssertTrue(strcmp(lastError, "") == 0,
"SDL_GetError(): expected message '', was message: '%s'",
lastError);
}
// Set
SDL_SetError(probeError);
// Check for no-op
SDL_SetError(testError);
AssertPass("SDL_SetError()");
lastError = (char *)SDL_GetError();
AssertTrue(lastError != NULL,
lastError = (char *)SDL_GetError();
AssertTrue(lastError != NULL,
"SDL_GetError() != NULL");
if (lastError != NULL)
{
len = strlen(lastError);
AssertTrue(len == strlen(probeError),
"SDL_GetError(): expected message len %i, was len: %i",
strlen(probeError),
AssertTrue(len == strlen(probeError),
"SDL_GetError(): expected message len %i, was len: %i",
strlen(probeError),
len);
AssertTrue(strcmp(lastError, probeError) == 0,
AssertTrue(strcmp(lastError, probeError) == 0,
"SDL_GetError(): expected message '%s', was message: '%s'",
probeError,
lastError);
}
// Clean up
// Clean up
SDL_ClearError();
}
@@ -444,7 +444,7 @@ int platform_testGetPowerInfo(void *arg)
int secsAgain;
int pct;
int pctAgain;
state = SDL_GetPowerInfo(&secs, &pct);
AssertPass("SDL_GetPowerInfo()");
AssertTrue(
@@ -455,7 +455,7 @@ int platform_testGetPowerInfo(void *arg)
state==SDL_POWERSTATE_CHARGED,
"SDL_GetPowerInfo(): state %i is one of the expected values",
(int)state);
if (state==SDL_POWERSTATE_ON_BATTERY)
{
AssertTrue(
@@ -465,7 +465,7 @@ int platform_testGetPowerInfo(void *arg)
AssertTrue(
(pct >= 0) && (pct <= 100),
"SDL_GetPowerInfo(): on battery, pct=[0,100], was: %i",
pct);
pct);
}
if (state==SDL_POWERSTATE_UNKNOWN ||
@@ -478,31 +478,31 @@ int platform_testGetPowerInfo(void *arg)
AssertTrue(
pct == -1,
"SDL_GetPowerInfo(): no battery, pct == -1, was: %i",
pct);
pct);
}
// Partial return value variations
// Partial return value variations
stateAgain = SDL_GetPowerInfo(&secsAgain, NULL);
AssertTrue(
state==stateAgain,
"State %i returned when only 'secs' requested",
stateAgain);
stateAgain);
AssertTrue(
secs==secsAgain,
"Value %i matches when only 'secs' requested",
secsAgain);
secsAgain);
stateAgain = SDL_GetPowerInfo(NULL, &pctAgain);
AssertTrue(
state==stateAgain,
"State %i returned when only 'pct' requested",
stateAgain);
stateAgain);
AssertTrue(
pct==pctAgain,
"Value %i matches when only 'pct' requested",
pctAgain);
pctAgain);
stateAgain = SDL_GetPowerInfo(NULL, NULL);
AssertTrue(
state==stateAgain,
"State %i returned when no value requested",
stateAgain);
stateAgain);
}

View File

@@ -11,98 +11,98 @@
/* SDL_IntersectRectAndLine */
static const TestCaseReference test1 =
(TestCaseReference){ "rect_testIntersectRectAndLine", "Tests SDL_IntersectRectAndLine clipping cases", TEST_ENABLED, 0, 0 };
(TestCaseReference){ "rect_testIntersectRectAndLine", "Tests SDL_IntersectRectAndLine clipping cases", TEST_ENABLED, 0, 0 };
static const TestCaseReference test2 =
(TestCaseReference){ "rect_testIntersectRectAndLineInside", "Tests SDL_IntersectRectAndLine with line fully contained in rect", TEST_ENABLED, 0, 0 };
(TestCaseReference){ "rect_testIntersectRectAndLineInside", "Tests SDL_IntersectRectAndLine with line fully contained in rect", TEST_ENABLED, 0, 0 };
static const TestCaseReference test3 =
(TestCaseReference){ "rect_testIntersectRectAndLineOutside", "Tests SDL_IntersectRectAndLine with line fully outside of rect", TEST_ENABLED, 0, 0 };
(TestCaseReference){ "rect_testIntersectRectAndLineOutside", "Tests SDL_IntersectRectAndLine with line fully outside of rect", TEST_ENABLED, 0, 0 };
static const TestCaseReference test4 =
(TestCaseReference){ "rect_testIntersectRectAndLineEmpty", "Tests SDL_IntersectRectAndLine with empty rectangle ", TEST_ENABLED, 0, 0 };
(TestCaseReference){ "rect_testIntersectRectAndLineEmpty", "Tests SDL_IntersectRectAndLine with empty rectangle ", TEST_ENABLED, 0, 0 };
static const TestCaseReference test5 =
(TestCaseReference){ "rect_testIntersectRectAndLineParam", "Negative tests against SDL_IntersectRectAndLine with invalid parameters", TEST_ENABLED, 0, 0 };
(TestCaseReference){ "rect_testIntersectRectAndLineParam", "Negative tests against SDL_IntersectRectAndLine with invalid parameters", TEST_ENABLED, 0, 0 };
/* SDL_IntersectRect */
static const TestCaseReference test6 =
(TestCaseReference){ "rect_testIntersectRectInside", "Tests SDL_IntersectRect with B fully contained in A", TEST_ENABLED, 0, 0 };
(TestCaseReference){ "rect_testIntersectRectInside", "Tests SDL_IntersectRect with B fully contained in A", TEST_ENABLED, 0, 0 };
static const TestCaseReference test7 =
(TestCaseReference){ "rect_testIntersectRectOutside", "Tests SDL_IntersectRect with B fully outside of A", TEST_ENABLED, 0, 0 };
(TestCaseReference){ "rect_testIntersectRectOutside", "Tests SDL_IntersectRect with B fully outside of A", TEST_ENABLED, 0, 0 };
static const TestCaseReference test8 =
(TestCaseReference){ "rect_testIntersectRectPartial", "Tests SDL_IntersectRect with B partially intersecting A", TEST_ENABLED, 0, 0 };
(TestCaseReference){ "rect_testIntersectRectPartial", "Tests SDL_IntersectRect with B partially intersecting A", TEST_ENABLED, 0, 0 };
static const TestCaseReference test9 =
(TestCaseReference){ "rect_testIntersectRectPoint", "Tests SDL_IntersectRect with 1x1 sized rectangles", TEST_ENABLED, 0, 0 };
(TestCaseReference){ "rect_testIntersectRectPoint", "Tests SDL_IntersectRect with 1x1 sized rectangles", TEST_ENABLED, 0, 0 };
static const TestCaseReference test10 =
(TestCaseReference){ "rect_testIntersectRectEmpty", "Tests SDL_IntersectRect with empty rectangles", TEST_ENABLED, 0, 0 };
(TestCaseReference){ "rect_testIntersectRectEmpty", "Tests SDL_IntersectRect with empty rectangles", TEST_ENABLED, 0, 0 };
static const TestCaseReference test11 =
(TestCaseReference){ "rect_testIntersectRectParam", "Negative tests against SDL_IntersectRect with invalid parameters", TEST_ENABLED, 0, 0 };
(TestCaseReference){ "rect_testIntersectRectParam", "Negative tests against SDL_IntersectRect with invalid parameters", TEST_ENABLED, 0, 0 };
/* SDL_HasIntersection */
static const TestCaseReference test12 =
(TestCaseReference){ "rect_testHasIntersectionInside", "Tests SDL_HasIntersection with B fully contained in A", TEST_ENABLED, 0, 0 };
(TestCaseReference){ "rect_testHasIntersectionInside", "Tests SDL_HasIntersection with B fully contained in A", TEST_ENABLED, 0, 0 };
static const TestCaseReference test13 =
(TestCaseReference){ "rect_testHasIntersectionOutside", "Tests SDL_HasIntersection with B fully outside of A", TEST_ENABLED, 0, 0 };
(TestCaseReference){ "rect_testHasIntersectionOutside", "Tests SDL_HasIntersection with B fully outside of A", TEST_ENABLED, 0, 0 };
static const TestCaseReference test14 =
(TestCaseReference){ "rect_testHasIntersectionPartial", "Tests SDL_HasIntersection with B partially intersecting A", TEST_ENABLED, 0, 0 };
(TestCaseReference){ "rect_testHasIntersectionPartial", "Tests SDL_HasIntersection with B partially intersecting A", TEST_ENABLED, 0, 0 };
static const TestCaseReference test15 =
(TestCaseReference){ "rect_testHasIntersectionPoint", "Tests SDL_HasIntersection with 1x1 sized rectangles", TEST_ENABLED, 0, 0 };
(TestCaseReference){ "rect_testHasIntersectionPoint", "Tests SDL_HasIntersection with 1x1 sized rectangles", TEST_ENABLED, 0, 0 };
static const TestCaseReference test16 =
(TestCaseReference){ "rect_testHasIntersectionEmpty", "Tests SDL_HasIntersection with empty rectangles", TEST_ENABLED, 0, 0 };
(TestCaseReference){ "rect_testHasIntersectionEmpty", "Tests SDL_HasIntersection with empty rectangles", TEST_ENABLED, 0, 0 };
static const TestCaseReference test17 =
(TestCaseReference){ "rect_testHasIntersectionParam", "Negative tests against SDL_HasIntersection with invalid parameters", TEST_ENABLED, 0, 0 };
(TestCaseReference){ "rect_testHasIntersectionParam", "Negative tests against SDL_HasIntersection with invalid parameters", TEST_ENABLED, 0, 0 };
/* SDL_EnclosePoints */
static const TestCaseReference test18 =
(TestCaseReference){ "rect_testEnclosePoints", "Tests SDL_EnclosePoints without clipping", TEST_ENABLED, 0, 0 };
(TestCaseReference){ "rect_testEnclosePoints", "Tests SDL_EnclosePoints without clipping", TEST_ENABLED, 0, 0 };
static const TestCaseReference test19 =
(TestCaseReference){ "rect_testEnclosePointsWithClipping", "Tests SDL_EnclosePoints with clipping", TEST_ENABLED, 0, 0 };
(TestCaseReference){ "rect_testEnclosePointsWithClipping", "Tests SDL_EnclosePoints with clipping", TEST_ENABLED, 0, 0 };
static const TestCaseReference test20 =
(TestCaseReference){ "rect_testEnclosePointsRepeatedInput", "Tests SDL_EnclosePoints with repeated input", TEST_ENABLED, 0, 0 };
(TestCaseReference){ "rect_testEnclosePointsRepeatedInput", "Tests SDL_EnclosePoints with repeated input", TEST_ENABLED, 0, 0 };
static const TestCaseReference test21 =
(TestCaseReference){ "rect_testEnclosePointsParam", "Negative tests against SDL_EnclosePoints with invalid parameters", TEST_ENABLED, 0, 0 };
(TestCaseReference){ "rect_testEnclosePointsParam", "Negative tests against SDL_EnclosePoints with invalid parameters", TEST_ENABLED, 0, 0 };
/* SDL_UnionRect */
static const TestCaseReference test22 =
(TestCaseReference){ "rect_testUnionRectInside", "Tests SDL_UnionRect where rect B is inside rect A", TEST_ENABLED, 0, 0 };
(TestCaseReference){ "rect_testUnionRectInside", "Tests SDL_UnionRect where rect B is inside rect A", TEST_ENABLED, 0, 0 };
static const TestCaseReference test23 =
(TestCaseReference){ "rect_testUnionRectOutside", "Tests SDL_UnionRect where rect B is outside rect A", TEST_ENABLED, 0, 0 };
(TestCaseReference){ "rect_testUnionRectOutside", "Tests SDL_UnionRect where rect B is outside rect A", TEST_ENABLED, 0, 0 };
static const TestCaseReference test24 =
(TestCaseReference){ "rect_testUnionRectEmpty", "Tests SDL_UnionRect where rect A or rect B are empty", TEST_ENABLED, 0, 0 };
(TestCaseReference){ "rect_testUnionRectEmpty", "Tests SDL_UnionRect where rect A or rect B are empty", TEST_ENABLED, 0, 0 };
static const TestCaseReference test25 =
(TestCaseReference){ "rect_testUnionRectParam", "Negative tests against SDL_UnionRect with invalid parameters", TEST_ENABLED, 0, 0 };
(TestCaseReference){ "rect_testUnionRectParam", "Negative tests against SDL_UnionRect with invalid parameters", TEST_ENABLED, 0, 0 };
/* SDL_RectEmpty */
static const TestCaseReference test26 =
(TestCaseReference){ "rect_testRectEmpty", "Tests SDL_RectEmpty with various inputs", TEST_ENABLED, 0, 0 };
(TestCaseReference){ "rect_testRectEmpty", "Tests SDL_RectEmpty with various inputs", TEST_ENABLED, 0, 0 };
static const TestCaseReference test27 =
(TestCaseReference){ "rect_testRectEmptyParam", "Negative tests against SDL_RectEmpty with invalid parameters", TEST_ENABLED, 0, 0 };
(TestCaseReference){ "rect_testRectEmptyParam", "Negative tests against SDL_RectEmpty with invalid parameters", TEST_ENABLED, 0, 0 };
/* SDL_RectEquals */
static const TestCaseReference test28 =
(TestCaseReference){ "rect_testRectEquals", "Tests SDL_RectEquals with various inputs", TEST_ENABLED, 0, 0 };
(TestCaseReference){ "rect_testRectEquals", "Tests SDL_RectEquals with various inputs", TEST_ENABLED, 0, 0 };
static const TestCaseReference test29 =
(TestCaseReference){ "rect_testRectEqualsParam", "Negative tests against SDL_RectEquals with invalid parameters", TEST_ENABLED, 0, 0 };
(TestCaseReference){ "rect_testRectEqualsParam", "Negative tests against SDL_RectEquals with invalid parameters", TEST_ENABLED, 0, 0 };
/*!
@@ -112,13 +112,13 @@ static const TestCaseReference test29 =
* http://wiki.libsdl.org/moin.cgi/CategoryRect
*/
extern const TestCaseReference *testSuite[] = {
&test1, &test2, &test3, &test4, &test5, &test6, &test7, &test8, &test9, &test10, &test11, &test12, &test13, &test14,
&test15, &test16, &test17, &test18, &test19, &test20, &test21, &test22, &test23, &test24, &test25, &test26, &test27,
&test28, &test29, NULL
&test1, &test2, &test3, &test4, &test5, &test6, &test7, &test8, &test9, &test10, &test11, &test12, &test13, &test14,
&test15, &test16, &test17, &test18, &test19, &test20, &test21, &test22, &test23, &test24, &test25, &test26, &test27,
&test28, &test29, NULL
};
TestCaseReference **QueryTestSuite() {
return (TestCaseReference **)testSuite;
return (TestCaseReference **)testSuite;
}
/*!
@@ -130,7 +130,7 @@ void _validateIntersectRectAndLineResults(
int x1, int y1, int x2, int y2,
int x1Ref, int y1Ref, int x2Ref, int y2Ref)
{
AssertTrue(intersection == expectedIntersection,
AssertTrue(intersection == expectedIntersection,
"Incorrect intersection result: expected %s, got %s intersecting rect (%d,%d,%d,%d) with line (%d,%d - %d,%d)\n",
(expectedIntersection == SDL_TRUE) ? "true" : "false",
(intersection == SDL_TRUE) ? "true" : "false",
@@ -344,7 +344,7 @@ int rect_testIntersectRectAndLineEmpty (void *arg)
int x1, y1, x1Ref, y1Ref;
int x2, y2, x2Ref, y2Ref;
SDL_bool intersected;
refRect.x = RandomIntegerInRange(1, 1024);
refRect.y = RandomIntegerInRange(1, 1024);
refRect.w = 0;
@@ -377,10 +377,10 @@ int rect_testIntersectRectAndLineParam (void *arg)
int x2 = x1;
int y2 = 2 * rect.h;
SDL_bool intersected;
intersected = SDL_IntersectRectAndLine(&rect, &x1, &y1, &x2, &y2);
AssertTrue(intersected == SDL_TRUE, "Test variables not intersected as expected");
intersected = SDL_IntersectRectAndLine((SDL_Rect *)NULL, &x1, &y1, &x2, &y2);
AssertTrue(intersected == SDL_FALSE, "Incorrect intersected result when 1st parameter is NULL");
intersected = SDL_IntersectRectAndLine(&rect, (int *)NULL, &y1, &x2, &y2);
@@ -399,14 +399,14 @@ int rect_testIntersectRectAndLineParam (void *arg)
* \brief Private helper to check SDL_HasIntersection results
*/
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)
{
AssertTrue(intersection == expectedIntersection,
AssertTrue(intersection == expectedIntersection,
"Incorrect intersection result: expected %s, got %s intersecting A (%d,%d,%d,%d) with B (%d,%d,%d,%d)\n",
(expectedIntersection == SDL_TRUE) ? "true" : "false",
(intersection == SDL_TRUE) ? "true" : "false",
rectA->x, rectA->y, rectA->w, rectA->h,
rectA->x, rectA->y, rectA->w, rectA->h,
rectB->x, rectB->y, rectB->w, rectB->h);
AssertTrue(rectA->x == refRectA->x && rectA->y == refRectA->y && rectA->w == refRectA->w && rectA->h == refRectA->h,
"Source rectangle A was modified: got (%d,%d,%d,%d) expected (%d,%d,%d,%d)",
@@ -422,15 +422,15 @@ void _validateHasIntersectionResults(
* \brief Private helper to check SDL_IntersectRect results
*/
void _validateIntersectRectResults(
SDL_bool intersection, SDL_bool expectedIntersection,
SDL_Rect *rectA, SDL_Rect *rectB, SDL_Rect *refRectA, SDL_Rect *refRectB,
SDL_bool intersection, SDL_bool expectedIntersection,
SDL_Rect *rectA, SDL_Rect *rectB, SDL_Rect *refRectA, SDL_Rect *refRectB,
SDL_Rect *result, SDL_Rect *expectedResult)
{
_validateHasIntersectionResults(intersection, expectedIntersection, rectA, rectB, refRectA, refRectB);
if (result && expectedResult) {
AssertTrue(result->x == expectedResult->x && result->y == expectedResult->y && result->w == expectedResult->w && result->h == expectedResult->h,
"Intersection of rectangles A (%d,%d,%d,%d) and B (%d,%d,%d,%d) was incorrectly calculated, got (%d,%d,%d,%d) expected (%d,%d,%d,%d)",
rectA->x, rectA->y, rectA->w, rectA->h,
rectA->x, rectA->y, rectA->w, rectA->h,
rectB->x, rectB->y, rectB->w, rectB->h,
result->x, result->y, result->w, result->h,
expectedResult->x, expectedResult->y, expectedResult->w, expectedResult->h);
@@ -441,7 +441,7 @@ void _validateIntersectRectResults(
* \brief Private helper to check SDL_UnionRect results
*/
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)
{
AssertTrue(rectA->x == refRectA->x && rectA->y == refRectA->y && rectA->w == refRectA->w && rectA->h == refRectA->h,
@@ -454,7 +454,7 @@ void _validateUnionRectResults(
refRectB->x, refRectB->y, refRectB->w, refRectB->h);
AssertTrue(result->x == expectedResult->x && result->y == expectedResult->y && result->w == expectedResult->w && result->h == expectedResult->h,
"Union of rectangles A (%d,%d,%d,%d) and B (%d,%d,%d,%d) was incorrectly calculated, got (%d,%d,%d,%d) expected (%d,%d,%d,%d)",
rectA->x, rectA->y, rectA->w, rectA->h,
rectA->x, rectA->y, rectA->w, rectA->h,
rectB->x, rectB->y, rectB->w, rectB->h,
result->x, result->y, result->w, result->h,
expectedResult->x, expectedResult->y, expectedResult->w, expectedResult->h);
@@ -464,10 +464,10 @@ void _validateUnionRectResults(
* \brief Private helper to check SDL_RectEmpty results
*/
void _validateRectEmptyResults(
SDL_bool empty, SDL_bool expectedEmpty,
SDL_bool empty, SDL_bool expectedEmpty,
SDL_Rect *rect, SDL_Rect *refRect)
{
AssertTrue(empty == expectedEmpty,
AssertTrue(empty == expectedEmpty,
"Incorrect empty result: expected %s, got %s testing (%d,%d,%d,%d)\n",
(expectedEmpty == SDL_TRUE) ? "true" : "false",
(empty == SDL_TRUE) ? "true" : "false",
@@ -482,10 +482,10 @@ void _validateRectEmptyResults(
* \brief Private helper to check SDL_RectEquals results
*/
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)
{
AssertTrue(equals == expectedEquals,
AssertTrue(equals == expectedEquals,
"Incorrect equals result: expected %s, got %s testing (%d,%d,%d,%d) and (%d,%d,%d,%d) \n",
(expectedEquals == SDL_TRUE) ? "true" : "false",
(equals == SDL_TRUE) ? "true" : "false",
@@ -550,7 +550,7 @@ int rect_testIntersectRectOutside (void *arg)
rectA = refRectA;
rectB = refRectB;
intersection = SDL_IntersectRect(&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);
}
/*!
@@ -579,7 +579,7 @@ int rect_testIntersectRectPartial (void *arg)
expectedResult.x = refRectB.x;
expectedResult.y = refRectB.y;
expectedResult.w = refRectA.w - refRectB.x;
expectedResult.h = refRectA.h - refRectB.y;
expectedResult.h = refRectA.h - refRectB.y;
intersection = SDL_IntersectRect(&rectA, &rectB, &result);
_validateIntersectRectResults(intersection, SDL_TRUE, &rectA, &rectB, &refRectA, &refRectB, &result, &expectedResult);
@@ -593,7 +593,7 @@ int rect_testIntersectRectPartial (void *arg)
expectedResult.x = refRectB.x;
expectedResult.y = refRectB.y;
expectedResult.w = 1;
expectedResult.h = refRectB.h;
expectedResult.h = refRectB.h;
intersection = SDL_IntersectRect(&rectA, &rectB, &result);
_validateIntersectRectResults(intersection, SDL_TRUE, &rectA, &rectB, &refRectA, &refRectB, &result, &expectedResult);
@@ -607,7 +607,7 @@ int rect_testIntersectRectPartial (void *arg)
expectedResult.x = 0;
expectedResult.y = refRectB.y;
expectedResult.w = 1;
expectedResult.h = refRectB.h;
expectedResult.h = refRectB.h;
intersection = SDL_IntersectRect(&rectA, &rectB, &result);
_validateIntersectRectResults(intersection, SDL_TRUE, &rectA, &rectB, &refRectA, &refRectB, &result, &expectedResult);
@@ -621,7 +621,7 @@ int rect_testIntersectRectPartial (void *arg)
expectedResult.x = refRectB.x;
expectedResult.y = refRectB.y;
expectedResult.w = refRectB.w;
expectedResult.h = 1;
expectedResult.h = 1;
intersection = SDL_IntersectRect(&rectA, &rectB, &result);
_validateIntersectRectResults(intersection, SDL_TRUE, &rectA, &rectB, &refRectA, &refRectB, &result, &expectedResult);
@@ -635,7 +635,7 @@ int rect_testIntersectRectPartial (void *arg)
expectedResult.x = refRectB.x;
expectedResult.y = 0;
expectedResult.w = refRectB.w;
expectedResult.h = 1;
expectedResult.h = 1;
intersection = SDL_IntersectRect(&rectA, &rectB, &result);
_validateIntersectRectResults(intersection, SDL_TRUE, &rectA, &rectB, &refRectA, &refRectB, &result, &expectedResult);
}
@@ -673,7 +673,7 @@ int rect_testIntersectRectPoint (void *arg)
refRectA.x = RandomIntegerInRange(1, 100);
refRectA.y = RandomIntegerInRange(1, 100);
refRectB.x = refRectA.x;
refRectB.y = refRectA.y;
refRectB.y = refRectA.y;
refRectB.x += offsetX;
refRectB.y += offsetY;
rectA = refRectA;
@@ -757,17 +757,17 @@ int rect_testIntersectRectParam(void *arg)
// invalid parameter combinations
intersection = SDL_IntersectRect((SDL_Rect *)NULL, &rectB, &result);
AssertTrue(intersection == SDL_FALSE, "Function did not return false when 1st parameter was NULL");
AssertTrue(intersection == SDL_FALSE, "Function did not return false when 1st parameter was NULL");
intersection = SDL_IntersectRect(&rectA, (SDL_Rect *)NULL, &result);
AssertTrue(intersection == SDL_FALSE, "Function did not return false when 2st parameter was NULL");
AssertTrue(intersection == SDL_FALSE, "Function did not return false when 2st parameter was NULL");
intersection = SDL_IntersectRect(&rectA, &rectB, (SDL_Rect *)NULL);
AssertTrue(intersection == SDL_FALSE, "Function did not return false when 3st parameter was NULL");
AssertTrue(intersection == SDL_FALSE, "Function did not return false when 3st parameter was NULL");
intersection = SDL_IntersectRect((SDL_Rect *)NULL, (SDL_Rect *)NULL, &result);
AssertTrue(intersection == SDL_FALSE, "Function did not return false when 1st and 2nd parameters were NULL");
AssertTrue(intersection == SDL_FALSE, "Function did not return false when 1st and 2nd parameters were NULL");
intersection = SDL_IntersectRect((SDL_Rect *)NULL, &rectB, (SDL_Rect *)NULL);
AssertTrue(intersection == SDL_FALSE, "Function did not return false when 1st and 3rd parameters were NULL ");
AssertTrue(intersection == SDL_FALSE, "Function did not return false when 1st and 3rd parameters were NULL ");
intersection = SDL_IntersectRect((SDL_Rect *)NULL, (SDL_Rect *)NULL, (SDL_Rect *)NULL);
AssertTrue(intersection == SDL_FALSE, "Function did not return false when all parameters were NULL");
AssertTrue(intersection == SDL_FALSE, "Function did not return false when all parameters were NULL");
}
/*!
@@ -918,7 +918,7 @@ int rect_testHasIntersectionPoint (void *arg)
refRectA.x = RandomIntegerInRange(1, 100);
refRectA.y = RandomIntegerInRange(1, 100);
refRectB.x = refRectA.x;
refRectB.y = refRectA.y;
refRectB.y = refRectA.y;
refRectB.x += offsetX;
refRectB.y += offsetY;
rectA = refRectA;
@@ -1000,11 +1000,11 @@ int rect_testHasIntersectionParam(void *arg)
// invalid parameter combinations
intersection = SDL_HasIntersection((SDL_Rect *)NULL, &rectB);
AssertTrue(intersection == SDL_FALSE, "Function did not return false when 1st parameter was NULL");
AssertTrue(intersection == SDL_FALSE, "Function did not return false when 1st parameter was NULL");
intersection = SDL_HasIntersection(&rectA, (SDL_Rect *)NULL);
AssertTrue(intersection == SDL_FALSE, "Function did not return false when 2st parameter was NULL");
AssertTrue(intersection == SDL_FALSE, "Function did not return false when 2st parameter was NULL");
intersection = SDL_HasIntersection((SDL_Rect *)NULL, (SDL_Rect *)NULL);
AssertTrue(intersection == SDL_FALSE, "Function did not return false when all parameters were NULL");
AssertTrue(intersection == SDL_FALSE, "Function did not return false when all parameters were NULL");
}
/*!
@@ -1045,26 +1045,26 @@ int rect_testEnclosePoints(void *arg)
if (newy>maxy) maxy=newy;
}
}
// Call function and validate - special case: no result requested
anyEnclosedNoResult = SDL_EnclosePoints((const SDL_Point *)points, numPoints, (const SDL_Rect *)NULL, (SDL_Rect *)NULL);
AssertTrue(expectedEnclosed==anyEnclosedNoResult,
"Expected return value %s, got %s",
AssertTrue(expectedEnclosed==anyEnclosedNoResult,
"Expected return value %s, got %s",
(expectedEnclosed==SDL_TRUE) ? "true" : "false", (anyEnclosedNoResult==SDL_TRUE) ? "true" : "false");
for (i=0; i<numPoints; i++) {
AssertTrue(refPoints[i].x==points[i].x && refPoints[i].y==points[i].y,
"Source point %i was incorrectly modified: expected (%i,%i) actual (%i,%i)",
"Source point %i was incorrectly modified: expected (%i,%i) actual (%i,%i)",
i, refPoints[i].x, refPoints[i].y, points[i].x, points[i].y);
}
// Call function and validate
anyEnclosed = SDL_EnclosePoints((const SDL_Point *)points, numPoints, (const SDL_Rect *)NULL, &result);
AssertTrue(expectedEnclosed==anyEnclosed,
"Expected return value %s, got %s",
AssertTrue(expectedEnclosed==anyEnclosed,
"Expected return value %s, got %s",
(expectedEnclosed==SDL_TRUE) ? "true" : "false", (anyEnclosed==SDL_TRUE) ? "true" : "false");
for (i=0; i<numPoints; i++) {
AssertTrue(refPoints[i].x==points[i].x && refPoints[i].y==points[i].y,
"Source point %i was incorrectly modified: expected (%i,%i) actual (%i,%i)",
"Source point %i was incorrectly modified: expected (%i,%i) actual (%i,%i)",
i, refPoints[i].x, refPoints[i].y, points[i].x, points[i].y);
}
AssertTrue(result.x==minx && result.y==miny && result.w==(maxx - minx + 1) && result.h==(maxy - miny + 1),
@@ -1119,23 +1119,23 @@ int rect_testEnclosePointsRepeatedInput(void *arg)
// Call function and validate - special case: no result requested
anyEnclosedNoResult = SDL_EnclosePoints((const SDL_Point *)points, numPoints, (const SDL_Rect *)NULL, (SDL_Rect *)NULL);
AssertTrue(expectedEnclosed==anyEnclosedNoResult,
"Expected return value %s, got %s",
AssertTrue(expectedEnclosed==anyEnclosedNoResult,
"Expected return value %s, got %s",
(expectedEnclosed==SDL_TRUE) ? "true" : "false", (anyEnclosedNoResult==SDL_TRUE) ? "true" : "false");
for (i=0; i<numPoints; i++) {
AssertTrue(refPoints[i].x==points[i].x && refPoints[i].y==points[i].y,
"Source point %i was incorrectly modified: expected (%i,%i) actual (%i,%i)",
"Source point %i was incorrectly modified: expected (%i,%i) actual (%i,%i)",
i, refPoints[i].x, refPoints[i].y, points[i].x, points[i].y);
}
// Call function and validate
anyEnclosed = SDL_EnclosePoints((const SDL_Point *)points, numPoints, (const SDL_Rect *)NULL, &result);
AssertTrue(expectedEnclosed==anyEnclosed,
"Expected return value %s, got %s",
AssertTrue(expectedEnclosed==anyEnclosed,
"Expected return value %s, got %s",
(expectedEnclosed==SDL_TRUE) ? "true" : "false", (anyEnclosed==SDL_TRUE) ? "true" : "false");
for (i=0; i<numPoints; i++) {
AssertTrue(refPoints[i].x==points[i].x && refPoints[i].y==points[i].y,
"Source point %i was incorrectly modified: expected (%i,%i) actual (%i,%i)",
"Source point %i was incorrectly modified: expected (%i,%i) actual (%i,%i)",
i, refPoints[i].x, refPoints[i].y, points[i].x, points[i].y);
}
AssertTrue(result.x==minx && result.y==miny && result.w==(maxx - minx + 1) && result.h==(maxy - miny + 1),
@@ -1197,25 +1197,25 @@ int rect_testEnclosePointsWithClipping(void *arg)
// Call function and validate - special case: no result requested
clip = refClip;
anyEnclosedNoResult = SDL_EnclosePoints((const SDL_Point *)points, numPoints, (const SDL_Rect *)&clip, (SDL_Rect *)NULL);
AssertTrue(expectedEnclosed==anyEnclosedNoResult,
"Expected return value %s, got %s",
AssertTrue(expectedEnclosed==anyEnclosedNoResult,
"Expected return value %s, got %s",
(expectedEnclosed==SDL_TRUE) ? "true" : "false", (anyEnclosedNoResult==SDL_TRUE) ? "true" : "false");
for (i=0; i<numPoints; i++) {
AssertTrue(refPoints[i].x==points[i].x && refPoints[i].y==points[i].y,
"Source point %i was incorrectly modified: expected (%i,%i) actual (%i,%i)",
"Source point %i was incorrectly modified: expected (%i,%i) actual (%i,%i)",
i, refPoints[i].x, refPoints[i].y, points[i].x, points[i].y);
}
AssertTrue(refClip.x==clip.x && refClip.y==clip.y && refClip.w==clip.w && refClip.h==clip.h,
"Source clipping rectangle was incorrectly modified");
// Call function and validate
anyEnclosed = SDL_EnclosePoints((const SDL_Point *)points, numPoints, (const SDL_Rect *)&clip, &result);
AssertTrue(expectedEnclosed==anyEnclosed,
"Expected return value %s, got %s",
AssertTrue(expectedEnclosed==anyEnclosed,
"Expected return value %s, got %s",
(expectedEnclosed==SDL_TRUE) ? "true" : "false", (anyEnclosed==SDL_TRUE) ? "true" : "false");
for (i=0; i<numPoints; i++) {
AssertTrue(refPoints[i].x==points[i].x && refPoints[i].y==points[i].y,
"Source point %i was incorrectly modified: expected (%i,%i) actual (%i,%i)",
"Source point %i was incorrectly modified: expected (%i,%i) actual (%i,%i)",
i, refPoints[i].x, refPoints[i].y, points[i].x, points[i].y);
}
AssertTrue(refClip.x==clip.x && refClip.y==clip.y && refClip.w==clip.w && refClip.h==clip.h,
@@ -1224,16 +1224,16 @@ int rect_testEnclosePointsWithClipping(void *arg)
AssertTrue(result.x==minx && result.y==miny && result.w==(maxx - minx + 1) && result.h==(maxy - miny + 1),
"Resulting enclosing rectangle incorrect: expected (%i,%i - %i,%i), actual (%i,%i - %i,%i)",
minx, miny, maxx, maxy, result.x, result.y, result.x + result.w - 1, result.y + result.h - 1);
}
}
/* Empty clipping rectangle */
clip.w = 0;
clip.h = 0;
expectedEnclosed = SDL_FALSE;
anyEnclosed = SDL_EnclosePoints((const SDL_Point *)points, numPoints, (const SDL_Rect *)&clip, &result);
AssertTrue(expectedEnclosed==anyEnclosed,
"Expected return value %s, got %s",
(expectedEnclosed==SDL_TRUE) ? "true" : "false", (anyEnclosed==SDL_TRUE) ? "true" : "false");
AssertTrue(expectedEnclosed==anyEnclosed,
"Expected return value %s, got %s",
(expectedEnclosed==SDL_TRUE) ? "true" : "false", (anyEnclosed==SDL_TRUE) ? "true" : "false");
}
/*!
@@ -1252,14 +1252,14 @@ int rect_testEnclosePointsParam(void *arg)
// invalid parameter combinations
anyEnclosed = SDL_EnclosePoints((SDL_Point *)NULL, 1, (const SDL_Rect *)&clip, &result);
AssertTrue(anyEnclosed == SDL_FALSE, "Function did not return false when 1st parameter was NULL");
AssertTrue(anyEnclosed == SDL_FALSE, "Function did not return false when 1st parameter was NULL");
anyEnclosed = SDL_EnclosePoints((const SDL_Point *)points, 0, (const SDL_Rect *)&clip, &result);
AssertTrue(anyEnclosed == SDL_FALSE, "Function did not return false when 2nd parameter was 0");
count = RandomIntegerInRange(-100, -1);
anyEnclosed = SDL_EnclosePoints((const SDL_Point *)points, count, (const SDL_Rect *)&clip, &result);
AssertTrue(anyEnclosed == SDL_FALSE, "Function did not return false when 2nd parameter was %i", count);
AssertTrue(anyEnclosed == SDL_FALSE, "Function did not return false when 2nd parameter was %i", count);
anyEnclosed = SDL_EnclosePoints((SDL_Point *)NULL, 0, (const SDL_Rect *)&clip, &result);
AssertTrue(anyEnclosed == SDL_FALSE, "Function did not return false when 1st parameter was NULL and 2nd parameter was 0");
AssertTrue(anyEnclosed == SDL_FALSE, "Function did not return false when 1st parameter was NULL and 2nd parameter was 0");
}
@@ -1277,9 +1277,9 @@ int rect_testUnionRectOutside(void *arg)
SDL_Rect result;
int minx, maxx, miny, maxy;
int dx, dy;
/* Union 1x1 outside */
for (dx = -1; dx < 2; dx++) {
for (dx = -1; dx < 2; dx++) {
for (dy = -1; dy < 2; dy++) {
if ((dx != 0) || (dy != 0)) {
refRectA.x=RandomIntegerInRange(-1024, 1024);
@@ -1293,7 +1293,7 @@ int rect_testUnionRectOutside(void *arg)
minx = (refRectA.x<refRectB.x) ? refRectA.x : refRectB.x;
maxx = (refRectA.x>refRectB.x) ? refRectA.x : refRectB.x;
miny = (refRectA.y<refRectB.y) ? refRectA.y : refRectB.y;
maxy = (refRectA.y>refRectB.y) ? refRectA.y : refRectB.y;
maxy = (refRectA.y>refRectB.y) ? refRectA.y : refRectB.y;
expectedResult.x = minx;
expectedResult.y = miny;
expectedResult.w = maxx - minx + 1;
@@ -1307,7 +1307,7 @@ int rect_testUnionRectOutside(void *arg)
}
/* Union outside overlap */
for (dx = -1; dx < 2; dx++) {
for (dx = -1; dx < 2; dx++) {
for (dy = -1; dy < 2; dy++) {
if ((dx != 0) || (dy != 0)) {
refRectA.x=RandomIntegerInRange(-1024, 1024);
@@ -1345,7 +1345,7 @@ int rect_testUnionRectEmpty(void *arg)
SDL_Rect expectedResult;
SDL_Rect result;
/* A empty */
/* A empty */
refRectA.x=RandomIntegerInRange(-1024, 1024);
refRectA.y=RandomIntegerInRange(-1024, 1024);
refRectA.w=0;
@@ -1359,8 +1359,8 @@ int rect_testUnionRectEmpty(void *arg)
rectB = refRectB;
SDL_UnionRect(&rectA, &rectB, &result);
_validateUnionRectResults(&rectA, &rectB, &refRectA, &refRectB, &result, &expectedResult);
/* B empty */
/* B empty */
refRectA.x=RandomIntegerInRange(-1024, 1024);
refRectA.y=RandomIntegerInRange(-1024, 1024);
refRectA.w=RandomIntegerInRange(1, 1024);
@@ -1375,7 +1375,7 @@ int rect_testUnionRectEmpty(void *arg)
SDL_UnionRect(&rectA, &rectB, &result);
_validateUnionRectResults(&rectA, &rectB, &refRectA, &refRectB, &result, &expectedResult);
/* A and B empty */
/* A and B empty */
refRectA.x=RandomIntegerInRange(-1024, 1024);
refRectA.y=RandomIntegerInRange(-1024, 1024);
refRectA.w=0;
@@ -1409,7 +1409,7 @@ int rect_testUnionRectInside(void *arg)
SDL_Rect result;
int minx, maxx, miny, maxy;
int dx, dy;
/* Union 1x1 with itself */
refRectA.x=RandomIntegerInRange(-1024, 1024);
refRectA.y=RandomIntegerInRange(-1024, 1024);
@@ -1436,7 +1436,7 @@ int rect_testUnionRectInside(void *arg)
_validateUnionRectResults(&rectA, &rectB, &refRectA, &refRectB, &result, &expectedResult);
/* Union inside with edges modified */
for (dx = -1; dx < 2; dx++) {
for (dx = -1; dx < 2; dx++) {
for (dy = -1; dy < 2; dy++) {
if ((dx != 0) || (dy != 0)) {
refRectA.x=RandomIntegerInRange(-1024, 1024);
@@ -1447,7 +1447,7 @@ int rect_testUnionRectInside(void *arg)
if (dx == -1) refRectB.x++;
if ((dx == 1) || (dx == -1)) refRectB.w--;
if (dy == -1) refRectB.y++;
if ((dy == 1) || (dy == -1)) refRectB.h--;
if ((dy == 1) || (dy == -1)) refRectB.h--;
expectedResult = refRectA;
rectA = refRectA;
rectB = refRectB;
@@ -1471,17 +1471,17 @@ int rect_testUnionRectParam(void *arg)
// invalid parameter combinations
SDL_UnionRect((SDL_Rect *)NULL, &rectB, &result);
AssertPass("Function did return when 1st parameter was NULL");
AssertPass("Function did return when 1st parameter was NULL");
SDL_UnionRect(&rectA, (SDL_Rect *)NULL, &result);
AssertPass("Function did return when 2nd parameter was NULL");
AssertPass("Function did return when 2nd parameter was NULL");
SDL_UnionRect(&rectA, &rectB, (SDL_Rect *)NULL);
AssertPass("Function did return when 3rd parameter was NULL");
AssertPass("Function did return when 3rd parameter was NULL");
SDL_UnionRect((SDL_Rect *)NULL, &rectB, (SDL_Rect *)NULL);
AssertPass("Function did return when 1st and 3rd parameter were NULL");
AssertPass("Function did return when 1st and 3rd parameter were NULL");
SDL_UnionRect(&rectA, (SDL_Rect *)NULL, (SDL_Rect *)NULL);
AssertPass("Function did return when 2nd and 3rd parameter were NULL");
AssertPass("Function did return when 2nd and 3rd parameter were NULL");
SDL_UnionRect((SDL_Rect *)NULL, (SDL_Rect *)NULL, (SDL_Rect *)NULL);
AssertPass("Function did return when all parameters were NULL");
AssertPass("Function did return when all parameters were NULL");
}
/*!
@@ -1507,7 +1507,7 @@ int rect_testRectEmpty(void *arg)
rect = refRect;
result = SDL_RectEmpty((const SDL_Rect *)&rect);
_validateRectEmptyResults(result, expectedResult, &rect, &refRect);
// Empty case
for (w=-1; w<2; w++) {
for (h=-1; h<2; h++) {
@@ -1537,7 +1537,7 @@ int rect_testRectEmptyParam(void *arg)
// invalid parameter combinations
result = SDL_RectEmpty((const SDL_Rect *)NULL);
AssertTrue(result == SDL_TRUE, "Function did not return TRUE when 1st parameter was NULL");
AssertTrue(result == SDL_TRUE, "Function did not return TRUE when 1st parameter was NULL");
}
/*!
@@ -1560,7 +1560,7 @@ int rect_testRectEquals(void *arg)
refRectA.y=RandomIntegerInRange(-1024, 1024);
refRectA.w=RandomIntegerInRange(1, 1024);
refRectA.h=RandomIntegerInRange(1, 1024);
refRectB = refRectA;
refRectB = refRectA;
expectedResult = SDL_TRUE;
rectA = refRectA;
rectB = refRectB;
@@ -1592,9 +1592,9 @@ int rect_testRectEqualsParam(void *arg)
// invalid parameter combinations
result = SDL_RectEquals((const SDL_Rect *)NULL, (const SDL_Rect *)&rectB);
AssertTrue(result == SDL_FALSE, "Function did not return FALSE when 1st parameter was NULL");
AssertTrue(result == SDL_FALSE, "Function did not return FALSE when 1st parameter was NULL");
result = SDL_RectEquals((const SDL_Rect *)&rectA, (const SDL_Rect *)NULL);
AssertTrue(result == SDL_FALSE, "Function did not return FALSE when 2nd parameter was NULL");
AssertTrue(result == SDL_FALSE, "Function did not return FALSE when 2nd parameter was NULL");
result = SDL_RectEquals((const SDL_Rect *)NULL, (const SDL_Rect *)NULL);
AssertTrue(result == SDL_FALSE, "Function did not return FALSE when 1st and 2nd parameter were NULL");
AssertTrue(result == SDL_FALSE, "Function did not return FALSE when 1st and 2nd parameter were NULL");
}

View File

@@ -30,38 +30,38 @@ static int _isSupported(int code);
/* Test cases */
static const TestCaseReference test1 =
(TestCaseReference){ "render_testGetNumRenderDrivers", "Tests call to SDL_GetNumRenderDrivers", TEST_ENABLED, 0, 0 };
(TestCaseReference){ "render_testGetNumRenderDrivers", "Tests call to SDL_GetNumRenderDrivers", TEST_ENABLED, 0, 0 };
static const TestCaseReference test2 =
(TestCaseReference){ "render_testCreateRenderer", "Tests SDL_CreateRenderer", TEST_ENABLED, 0, 0 };
(TestCaseReference){ "render_testCreateRenderer", "Tests SDL_CreateRenderer", TEST_ENABLED, 0, 0 };
static const TestCaseReference test3 =
(TestCaseReference){ "render_testPrimitives", "Tests rendering primitives", TEST_ENABLED, 0, 0 };
(TestCaseReference){ "render_testPrimitives", "Tests rendering primitives", TEST_ENABLED, 0, 0 };
static const TestCaseReference test4 =
(TestCaseReference){ "render_testPrimitivesBlend", "Tests rendering primitives with blending", TEST_ENABLED, 0, 0 };
(TestCaseReference){ "render_testPrimitivesBlend", "Tests rendering primitives with blending", TEST_ENABLED, 0, 0 };
static const TestCaseReference test5 =
(TestCaseReference){ "render_testBlit", "Tests blitting", TEST_ENABLED, 0, 0 };
(TestCaseReference){ "render_testBlit", "Tests blitting", TEST_ENABLED, 0, 0 };
static const TestCaseReference test6 =
(TestCaseReference){ "render_testBlitColour", "Tests blitting with color", TEST_ENABLED, 0, 0 };
(TestCaseReference){ "render_testBlitColour", "Tests blitting with color", TEST_ENABLED, 0, 0 };
static const TestCaseReference test7 =
(TestCaseReference){ "render_testBlitAlpha", "Tests blitting with alpha", TEST_ENABLED, 0, 0 };
(TestCaseReference){ "render_testBlitAlpha", "Tests blitting with alpha", TEST_ENABLED, 0, 0 };
static const TestCaseReference test8 =
(TestCaseReference){ "render_testBlitBlend", "Tests blitting with blending", TEST_ENABLED, 0, 0 };
(TestCaseReference){ "render_testBlitBlend", "Tests blitting with blending", TEST_ENABLED, 0, 0 };
/* Test suite */
extern const TestCaseReference *testSuite[] = {
&test1, &test2, &test3, &test4, &test5, &test6, &test7, &test8, NULL
&test1, &test2, &test3, &test4, &test5, &test6, &test7, &test8, NULL
};
TestCaseReference **QueryTestSuite() {
return (TestCaseReference **)testSuite;
return (TestCaseReference **)testSuite;
}
// Fixture
@@ -74,10 +74,10 @@ SetUp(void *arg)
AssertTrue(ret==0, "SDL_Init(SDL_INIT_VIDEO): %s", SDL_GetError());
SDL_Window *w = SDL_CreateWindow( "title", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED,
80, 60, SDL_WINDOW_SHOWN );
80, 60, SDL_WINDOW_SHOWN );
renderer = SDL_CreateRenderer(w, 0, 0);
}
void
TearDown(void *arg)
{
@@ -88,7 +88,7 @@ TearDown(void *arg)
/**
* @brief Tests call to SDL_GetNumRenderDrivers
*
* \sa
* \sa
* http://wiki.libsdl.org/moin.cgi/SDL_GetNumRenderDrivers
*/
int
@@ -118,7 +118,7 @@ render_testCreateRenderer(void *arg)
if (window != NULL) {
AssertPass("Window created");
renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_SOFTWARE);
if (renderer) {
if (renderer) {
AssertPass("Renderer created");
SDL_DestroyRenderer(renderer);
} else {
@@ -127,7 +127,7 @@ render_testCreateRenderer(void *arg)
SDL_DestroyWindow(window);
} else {
AssertFail("Could not create window: %s", SDL_GetError());
}
}
}

View File

@@ -22,35 +22,35 @@ static const char const_mem[] = "Hello World!";
/* Test cases */
static const TestCaseReference test1 =
(TestCaseReference){ "rwops_testParam", " Negative test for SDL_RWFromFile parameters", TEST_ENABLED, 0, 60 };
(TestCaseReference){ "rwops_testParam", " Negative test for SDL_RWFromFile parameters", TEST_ENABLED, 0, 60 };
static const TestCaseReference test2 =
(TestCaseReference){ "rwops_testMem", "Tests opening from memory", TEST_ENABLED, 0, 60 };
(TestCaseReference){ "rwops_testMem", "Tests opening from memory", TEST_ENABLED, 0, 60 };
static const TestCaseReference test3 =
(TestCaseReference){ "rwops_testConstMem", "Tests opening from (const) memory", TEST_ENABLED, 0, 60 };
(TestCaseReference){ "rwops_testConstMem", "Tests opening from (const) memory", TEST_ENABLED, 0, 60 };
static const TestCaseReference test4 =
(TestCaseReference){ "rwops_testFileRead", "Tests reading from a file", TEST_ENABLED, 0, 60 };
(TestCaseReference){ "rwops_testFileRead", "Tests reading from a file", TEST_ENABLED, 0, 60 };
static const TestCaseReference test5 =
(TestCaseReference){ "rwops_testFileWrite", "Test writing to a file", TEST_ENABLED, 0, 60 };
(TestCaseReference){ "rwops_testFileWrite", "Test writing to a file", TEST_ENABLED, 0, 60 };
static const TestCaseReference test6 =
(TestCaseReference){ "rwops_testFPRead", "Test reading from stdio", TEST_ENABLED, TEST_REQUIRES_STDIO, 60 };
(TestCaseReference){ "rwops_testFPRead", "Test reading from stdio", TEST_ENABLED, TEST_REQUIRES_STDIO, 60 };
static const TestCaseReference test7 =
(TestCaseReference){ "rwops_testFPWrite", "Test writing to stdio", TEST_ENABLED, TEST_REQUIRES_STDIO, 60 };
(TestCaseReference){ "rwops_testFPWrite", "Test writing to stdio", TEST_ENABLED, TEST_REQUIRES_STDIO, 60 };
/* Test suite */
extern const TestCaseReference *testSuite[] = {
&test1, &test2, &test3, &test4, &test5, &test6, &test7, NULL
&test1, &test2, &test3, &test4, &test5, &test6, &test7, NULL
};
TestCaseReference **QueryTestSuite() {
return (TestCaseReference **)testSuite;
return (TestCaseReference **)testSuite;
}
@@ -58,19 +58,19 @@ TestCaseReference **QueryTestSuite() {
void
SetUp(void *arg)
{
FILE *handle = fopen(RWOPS_READ, "w");
AssertTrue(handle != NULL, "Creating file '%s' failed", RWOPS_READ);
FILE *handle = fopen(RWOPS_READ, "w");
AssertTrue(handle != NULL, "Creating file '%s' failed", RWOPS_READ);
fwrite(hello_world, 1, SDL_strlen(hello_world), handle);
fclose(handle);
fwrite(hello_world, 1, SDL_strlen(hello_world), handle);
fclose(handle);
}
void
TearDown(void *arg)
{
// Remove the created files
remove(RWOPS_READ);
remove(RWOPS_WRITE);
// Remove the created files
remove(RWOPS_READ);
remove(RWOPS_WRITE);
}
/**
@@ -93,10 +93,10 @@ int _testGeneric( SDL_RWops *rw, int write )
i = SDL_RWwrite( rw, hello_world, sizeof(hello_world)-1, 1);
if (write) {
AssertEquals(i, 1, "Writing with SDL_RWwrite (failed to write)");
AssertEquals(i, 1, "Writing with SDL_RWwrite (failed to write)");
}
else {
AssertTrue(i <= 0, "Writing with SDL_RWwrite (wrote when shouldn't have): %d <= 0", i);
AssertTrue(i <= 0, "Writing with SDL_RWwrite (wrote when shouldn't have): %d <= 0", i);
}
/* Test seek. */

View File

@@ -11,47 +11,47 @@
/* Test case references */
static const TestCaseReference test1 =
(TestCaseReference){ "surface_testLoad", "Tests sprite loading.", TEST_ENABLED, 0, 0};
(TestCaseReference){ "surface_testLoad", "Tests sprite loading.", TEST_ENABLED, 0, 0};
static const TestCaseReference test2 =
(TestCaseReference){ "surface_testBlit", "Tests some blitting routines.", TEST_ENABLED, 0, 0};
(TestCaseReference){ "surface_testBlit", "Tests some blitting routines.", TEST_ENABLED, 0, 0};
static const TestCaseReference test3 =
(TestCaseReference){ "surface_testBlitBlendNone", "Tests blitting routines with none blending.", TEST_ENABLED, 0, 0};
(TestCaseReference){ "surface_testBlitBlendNone", "Tests blitting routines with none blending.", TEST_ENABLED, 0, 0};
static const TestCaseReference test4 =
(TestCaseReference){ "surface_testLoadFailure", "Tests sprite loading. A failure case.", TEST_ENABLED, 0, 0};
(TestCaseReference){ "surface_testLoadFailure", "Tests sprite loading. A failure case.", TEST_ENABLED, 0, 0};
static const TestCaseReference test5 =
(TestCaseReference){ "surface_testConversion", "Tests sprite conversion.", TEST_ENABLED, 0, 0};
(TestCaseReference){ "surface_testConversion", "Tests sprite conversion.", TEST_ENABLED, 0, 0};
static const TestCaseReference test6 =
(TestCaseReference){ "surface_testBlitColorMod", "Tests some blitting routines with color mod.", TEST_ENABLED, 0, 0};
(TestCaseReference){ "surface_testBlitColorMod", "Tests some blitting routines with color mod.", TEST_ENABLED, 0, 0};
static const TestCaseReference test7 =
(TestCaseReference){ "surface_testBlitAlphaMod", "Tests some blitting routines with alpha mod.", TEST_ENABLED, 0, 0};
(TestCaseReference){ "surface_testBlitAlphaMod", "Tests some blitting routines with alpha mod.", TEST_ENABLED, 0, 0};
static const TestCaseReference test8 =
(TestCaseReference){ "surface_testBlitBlendLoop", "Test blittin routines with blending", TEST_ENABLED, 0, 0};
(TestCaseReference){ "surface_testBlitBlendLoop", "Test blittin routines with blending", TEST_ENABLED, 0, 0};
static const TestCaseReference test9 =
(TestCaseReference){ "surface_testBlitBlendBlend", "Tests blitting routines with blend blending.", TEST_ENABLED, 0, 0};
(TestCaseReference){ "surface_testBlitBlendBlend", "Tests blitting routines with blend blending.", TEST_ENABLED, 0, 0};
static const TestCaseReference test10 =
(TestCaseReference){ "surface_testBlitBlendAdd", "Tests blitting routines with add blending.", TEST_ENABLED, 0, 0};
(TestCaseReference){ "surface_testBlitBlendAdd", "Tests blitting routines with add blending.", TEST_ENABLED, 0, 0};
static const TestCaseReference test11 =
(TestCaseReference){ "surface_testBlitBlendMod", "Tests blitting routines with modblending.", TEST_ENABLED, 0, 0};
(TestCaseReference){ "surface_testBlitBlendMod", "Tests blitting routines with modblending.", TEST_ENABLED, 0, 0};
/* Test suite */
extern const TestCaseReference *testSuite[] = {
&test1, &test2, &test3, &test4, &test5,
&test6, &test7, &test8, &test9, &test10, &test11, NULL
&test1, &test2, &test3, &test4, &test5,
&test6, &test7, &test8, &test9, &test10, &test11, NULL
};
TestCaseReference **QueryTestSuite() {
return (TestCaseReference **)testSuite;
return (TestCaseReference **)testSuite;
}
/* Function prototypes */
@@ -66,19 +66,19 @@ static SDL_Surface *testsur = NULL;
void
SetUp(void *arg)
{
int ret = SDL_Init(SDL_INIT_VIDEO);
AssertTrue(ret == 0, "SDL_Init(SDL_INIT_VIDEO)");
int ret = SDL_Init(SDL_INIT_VIDEO);
AssertTrue(ret == 0, "SDL_Init(SDL_INIT_VIDEO)");
testsur = _CreateTestSurface();
AssertTrue(testsur != NULL, "SDL_Init(SDL_INIT_VIDEO)");
testsur = _CreateTestSurface();
AssertTrue(testsur != NULL, "SDL_Init(SDL_INIT_VIDEO)");
}
void
TearDown(void *arg)
{
SDL_FreeSurface( testsur );
SDL_FreeSurface( testsur );
SDL_Quit();
SDL_Quit();
}
/* Helper functions for the test cases */
@@ -93,24 +93,24 @@ TearDown(void *arg)
SDL_Surface *
_CreateTestSurface()
{
SDL_Surface *testsur = NULL;
SDL_Surface *testsur = NULL;
/* Create the test surface. */
testsur = SDL_CreateRGBSurface( 0,
TEST_SURFACE_WIDTH, TEST_SURFACE_HEIGHT, 32,
RMASK, GMASK, BMASK, AMASK );
/* Create the test surface. */
testsur = SDL_CreateRGBSurface( 0,
TEST_SURFACE_WIDTH, TEST_SURFACE_HEIGHT, 32,
RMASK, GMASK, BMASK, AMASK );
if(testsur->w != TEST_SURFACE_WIDTH) {
AssertFail("Test surface width doesn't match");
}
if(testsur->w != TEST_SURFACE_WIDTH) {
AssertFail("Test surface width doesn't match");
}
if(testsur->h != TEST_SURFACE_HEIGHT) {
AssertFail("Test surface height doesn't match");
}
if(testsur->h != TEST_SURFACE_HEIGHT) {
AssertFail("Test surface height doesn't match");
}
AssertTrue(testsur != NULL, "SDL_CreateRGBSurface");
AssertTrue(testsur != NULL, "SDL_CreateRGBSurface");
return testsur;
return testsur;
}
/*!
@@ -119,26 +119,26 @@ _CreateTestSurface()
SDL_Surface *
_createTestSurfaceFromMemory()
{
SDL_Surface *face = NULL;
SDL_Surface *face = NULL;
/* Create face surface. */
face = SDL_CreateRGBSurfaceFrom( (void*)img_face.pixel_data,
img_face.width, img_face.height, 32, img_face.width*4,
#if (SDL_BYTEORDER == SDL_BIG_ENDIAN)
0xff000000, /* Red bit mask. */
0x00ff0000, /* Green bit mask. */
0x0000ff00, /* Blue bit mask. */
0x000000ff /* Alpha bit mask. */
#else
0x000000ff, /* Red bit mask. */
0x0000ff00, /* Green bit mask. */
0x00ff0000, /* Blue bit mask. */
0xff000000 /* Alpha bit mask. */
#endif
);
AssertTrue(face != NULL, "SDL_CreateRGBSurfaceFrom");
/* Create face surface. */
face = SDL_CreateRGBSurfaceFrom( (void*)img_face.pixel_data,
img_face.width, img_face.height, 32, img_face.width*4,
#if (SDL_BYTEORDER == SDL_BIG_ENDIAN)
0xff000000, /* Red bit mask. */
0x00ff0000, /* Green bit mask. */
0x0000ff00, /* Blue bit mask. */
0x000000ff /* Alpha bit mask. */
#else
0x000000ff, /* Red bit mask. */
0x0000ff00, /* Green bit mask. */
0x00ff0000, /* Blue bit mask. */
0xff000000 /* Alpha bit mask. */
#endif
);
AssertTrue(face != NULL, "SDL_CreateRGBSurfaceFrom");
return face;
return face;
}
/**
@@ -146,50 +146,50 @@ _createTestSurfaceFromMemory()
*/
void _testBlitBlendMode(SDL_Surface *testsur, SDL_Surface *face, int mode)
{
int ret;
int i, j, ni, nj;
SDL_Rect rect;
int ret;
int i, j, ni, nj;
SDL_Rect rect;
AssertTrue(testsur != NULL, "testsur != NULL");
AssertTrue(face != NULL, "face != NULL");
AssertTrue(testsur != NULL, "testsur != NULL");
AssertTrue(face != NULL, "face != NULL");
/* Clear surface. */
ret = SDL_FillRect( testsur, NULL,
SDL_MapRGB( testsur->format, 0, 0, 0 ) );
AssertTrue(ret == 0, "SDL_FillRect");
/* Clear surface. */
ret = SDL_FillRect( testsur, NULL,
SDL_MapRGB( testsur->format, 0, 0, 0 ) );
AssertTrue(ret == 0, "SDL_FillRect");
/* Steps to take. */
ni = testsur->w - face->w;
nj = testsur->h - face->h;
/* Steps to take. */
ni = testsur->w - face->w;
nj = testsur->h - face->h;
/* Constant values. */
rect.w = face->w;
rect.h = face->h;
/* Constant values. */
rect.w = face->w;
rect.h = face->h;
/* Test blend mode. */
for (j=0; j <= nj; j+=4) {
for (i=0; i <= ni; i+=4) {
/* Set blend mode. */
ret = SDL_SetSurfaceBlendMode( face, mode );
AssertTrue(ret == 0, "SDL_SetSurfaceBlendMode");
/* Test blend mode. */
for (j=0; j <= nj; j+=4) {
for (i=0; i <= ni; i+=4) {
/* Set blend mode. */
ret = SDL_SetSurfaceBlendMode( face, mode );
AssertTrue(ret == 0, "SDL_SetSurfaceBlendMode");
/* Blitting. */
rect.x = i;
rect.y = j;
// TODO Add pixel level validation, SDL_BlitSurface might be no-op
ret = SDL_BlitSurface( face, NULL, testsur, &rect );
AssertTrue(ret == 0, "SDL_BlitSurface");
}
}
/* Blitting. */
rect.x = i;
rect.y = j;
// TODO Add pixel level validation, SDL_BlitSurface might be no-op
ret = SDL_BlitSurface( face, NULL, testsur, &rect );
AssertTrue(ret == 0, "SDL_BlitSurface");
}
}
}
int
_AssertFileExist(const char *filename)
{
struct stat st;
int ret = stat(filename, &st);
struct stat st;
int ret = stat(filename, &st);
AssertTrue(ret == 0, "Does file %s exist", filename);
AssertTrue(ret == 0, "Does file %s exist", filename);
}
/* Test case functions */
@@ -198,25 +198,25 @@ _AssertFileExist(const char *filename)
*/
void surface_testLoad(void *arg)
{
int ret;
int ret;
SDL_Surface *face, *rface;
/* Clear surface. */
/*
ret = SDL_FillRect( testsur, NULL,
SDL_MapRGB( testsur->format, 0, 0, 0 ) );
AssertTrue(ret == 0, "SDL_FillRect");
*/
AssertTrue(ret == 0, "SDL_FillRect");
*/
/* Create the blit surface. */
const char *filename = "data/images/icon.bmp";
_AssertFileExist(filename);
const char *filename = "data/images/icon.bmp";
_AssertFileExist(filename);
face = SDL_LoadBMP(filename);
AssertTrue(face != NULL, "SDL_CreateLoadBmp");
face = SDL_LoadBMP(filename);
AssertTrue(face != NULL, "SDL_CreateLoadBmp");
AssertTrue(face->w == 32, "testing icon width");
AssertTrue(face->h == 32, "testing icon height");
AssertTrue(face->w == 32, "testing icon width");
AssertTrue(face->h == 32, "testing icon height");
}
/*!
@@ -224,32 +224,32 @@ void surface_testLoad(void *arg)
*/
void surface_testConversion(void *arg)
{
SDL_Surface *rface = NULL, *face = NULL;
int ret = 0;
SDL_Surface *rface = NULL, *face = NULL;
int ret = 0;
const char *filename = "data/images/icon.bmp";
_AssertFileExist(filename);
const char *filename = "data/images/icon.bmp";
_AssertFileExist(filename);
face = SDL_LoadBMP(filename);
AssertTrue(face != NULL, "SDL_CreateLoadBmp");
face = SDL_LoadBMP(filename);
AssertTrue(face != NULL, "SDL_CreateLoadBmp");
/* Set transparent pixel as the pixel at (0,0) */
if (face->format->palette) {
ret = SDL_SetColorKey(face, SDL_RLEACCEL, *(Uint8 *) face->pixels);
AssertTrue(ret == 0, "SDL_SetColorKey");
}
/* Set transparent pixel as the pixel at (0,0) */
if (face->format->palette) {
ret = SDL_SetColorKey(face, SDL_RLEACCEL, *(Uint8 *) face->pixels);
AssertTrue(ret == 0, "SDL_SetColorKey");
}
/* Convert to 32 bit to compare. */
rface = SDL_ConvertSurface( face, testsur->format, 0 );
AssertTrue(rface != NULL, "SDL_ConvertSurface");
/* Convert to 32 bit to compare. */
rface = SDL_ConvertSurface( face, testsur->format, 0 );
AssertTrue(rface != NULL, "SDL_ConvertSurface");
/* See if it's the same. */
AssertTrue(surface_compare( rface, &img_face, 0 ) == 0,
"Comparing primitives output.");
/* See if it's the same. */
AssertTrue(surface_compare( rface, &img_face, 0 ) == 0,
"Comparing primitives output.");
/* Clean up. */
SDL_FreeSurface( rface );
SDL_FreeSurface( face );
/* Clean up. */
SDL_FreeSurface( rface );
SDL_FreeSurface( face );
}
@@ -258,8 +258,8 @@ void surface_testConversion(void *arg)
*/
void surface_testLoadFailure(void *arg)
{
SDL_Surface *face = SDL_LoadBMP("nonexistant.bmp");
AssertTrue(face == NULL, "SDL_CreateLoadBmp");
SDL_Surface *face = SDL_LoadBMP("nonexistant.bmp");
AssertTrue(face == NULL, "SDL_CreateLoadBmp");
}
/**
@@ -302,7 +302,7 @@ void surface_testBlit(void *arg)
/* See if it's the same. */
AssertTrue(surface_compare( testsur, &img_blit, 0 ) == 0,
"Comparing blitting output (normal blit).");
"Comparing blitting output (normal blit).");
/* Clean up. */
SDL_FreeSurface( face );
@@ -357,7 +357,7 @@ void surface_testBlitColorMod(void *arg)
/* See if it's the same. */
AssertTrue(surface_compare( testsur, &img_blitColour, 0 ) == 0,
"Comparing blitting output (using SDL_SetSurfaceColorMod).");
"Comparing blitting output (using SDL_SetSurfaceColorMod).");
/* Clean up. */
SDL_FreeSurface( face );
@@ -415,7 +415,7 @@ void surface_testBlitAlphaMod(void *arg)
/* See if it's the same. */
AssertTrue(surface_compare( testsur, &img_blitAlpha, 0 ) == 0,
"Comparing blitting output (using SDL_SetSurfaceAlphaMod).");
"Comparing blitting output (using SDL_SetSurfaceAlphaMod).");
/* Clean up. */
SDL_FreeSurface( face );
@@ -458,22 +458,22 @@ void surface_testBlitBlendNone(void *arg)
/* Test None. */
_testBlitBlendMode( testsur, face, SDL_BLENDMODE_NONE );
AssertTrue(surface_compare( testsur, &img_blendNone, 0 ) == 0,
"Comparing blitting blending output (using SDL_BLENDMODE_NONE).");
"Comparing blitting blending output (using SDL_BLENDMODE_NONE).");
/* Test Blend. */
_testBlitBlendMode( testsur, face, SDL_BLENDMODE_BLEND );
AssertTrue(surface_compare( testsur, &img_blendBlend, 0 ) == 0,
"Comparing blitting blending output (using SDL_BLENDMODE_BLEND).");
"Comparing blitting blending output (using SDL_BLENDMODE_BLEND).");
/* Test Add. */
_testBlitBlendMode( testsur, face, SDL_BLENDMODE_ADD );
AssertTrue(surface_compare( testsur, &img_blendAdd, 0 ) == 0,
"Comparing blitting blending output (using SDL_BLENDMODE_ADD).");
"Comparing blitting blending output (using SDL_BLENDMODE_ADD).");
/* Test Mod. */
_testBlitBlendMode( testsur, face, SDL_BLENDMODE_MOD );
AssertTrue(surface_compare( testsur, &img_blendMod, 0 ) == 0,
"Comparing blitting blending output not the same (using SDL_BLENDMODE_MOD).");
"Comparing blitting blending output not the same (using SDL_BLENDMODE_MOD).");
}
/**
@@ -513,7 +513,7 @@ void surface_testBlitBlendBlend(void *arg)
/* Test Blend. */
_testBlitBlendMode( testsur, face, SDL_BLENDMODE_BLEND );
AssertTrue(surface_compare( testsur, &img_blendBlend, 0 ) == 0,
"Comparing blitting blending output (using SDL_BLENDMODE_BLEND).");
"Comparing blitting blending output (using SDL_BLENDMODE_BLEND).");
}
/**
@@ -553,7 +553,7 @@ void surface_testBlitBlendAdd(void *arg)
/* Test Add. */
_testBlitBlendMode( testsur, face, SDL_BLENDMODE_ADD );
AssertTrue(surface_compare( testsur, &img_blendAdd, 0 ) == 0,
"Comparing blitting blending output (using SDL_BLENDMODE_ADD).");
"Comparing blitting blending output (using SDL_BLENDMODE_ADD).");
}
/**
@@ -594,41 +594,41 @@ void surface_testBlitBlendMod(void *arg)
/* Test Mod. */
_testBlitBlendMode( testsur, face, SDL_BLENDMODE_MOD );
AssertTrue(surface_compare( testsur, &img_blendMod, 0 ) == 0,
"Comparing blitting blending output (using SDL_BLENDMODE_MOD).");
"Comparing blitting blending output (using SDL_BLENDMODE_MOD).");
}
/**
* @brief Tests some more blitting routines with loop
*/
void surface_testBlitBlendLoop(void *arg) {
int ret;
SDL_Rect rect;
SDL_Surface *face;
int i, j, ni, nj;
int mode;
int ret;
SDL_Rect rect;
SDL_Surface *face;
int i, j, ni, nj;
int mode;
/* Clear surface. */
ret = SDL_FillRect( testsur, NULL,
SDL_MapRGB( testsur->format, 0, 0, 0 ) );
AssertTrue(ret == 0, "SDL_FillRect");
/* Clear surface. */
ret = SDL_FillRect( testsur, NULL,
SDL_MapRGB( testsur->format, 0, 0, 0 ) );
AssertTrue(ret == 0, "SDL_FillRect");
face = _createTestSurfaceFromMemory();
face = _createTestSurfaceFromMemory();
/* Set alpha mod. */
// TODO alpha value could be generated by fuzzer
ret = SDL_SetSurfaceAlphaMod( face, 100 );
AssertTrue(ret == 0, "SDL_SetSurfaceAlphaMod");
/* Set alpha mod. */
// TODO alpha value could be generated by fuzzer
ret = SDL_SetSurfaceAlphaMod( face, 100 );
AssertTrue(ret == 0, "SDL_SetSurfaceAlphaMod");
/* Steps to take. */
ni = testsur->w - face->w;
nj = testsur->h - face->h;
/* Steps to take. */
ni = testsur->w - face->w;
nj = testsur->h - face->h;
AssertTrue(ni != 0, "ni != 0");
AssertTrue(nj != 0, "nj != 0");
AssertTrue(ni != 0, "ni != 0");
AssertTrue(nj != 0, "nj != 0");
/* Constant values. */
rect.w = face->w;
rect.h = face->h;
/* Constant values. */
rect.w = face->w;
rect.h = face->h;
/* Clear surface. */
ret = SDL_FillRect( testsur, NULL,
@@ -668,7 +668,7 @@ void surface_testBlitBlendLoop(void *arg) {
/* Check to see if matches. */
AssertTrue(surface_compare( testsur, &img_blendAll, 0 ) == 0,
"Surface comparison (surface_compare).");
"Surface comparison (surface_compare).");
/* Clean up. */
SDL_FreeSurface( face );

View File

@@ -13,15 +13,15 @@
/* Test cases */
static const TestCaseReference test1 =
(TestCaseReference){ "syswm_test", "description", TEST_DISABLED, 0, 0 };
(TestCaseReference){ "syswm_test", "description", TEST_DISABLED, 0, 0 };
/* Test suite */
extern const TestCaseReference *testSuite[] = {
&test1, NULL
&test1, NULL
};
TestCaseReference **QueryTestSuite() {
return (TestCaseReference **)testSuite;
return (TestCaseReference **)testSuite;
}
/**
@@ -30,5 +30,5 @@ TestCaseReference **QueryTestSuite() {
int
syswm_test(void *arg)
{
AssertPass("");
AssertPass("");
}

View File

@@ -13,15 +13,15 @@
/* Test cases */
static const TestCaseReference test1 =
(TestCaseReference){ "video_test", "video stuff", TEST_DISABLED, 0, 0 };
(TestCaseReference){ "video_test", "video stuff", TEST_DISABLED, 0, 0 };
/* Test suite */
extern const TestCaseReference *testSuite[] = {
&test1, NULL
&test1, NULL
};
TestCaseReference **QueryTestSuite() {
return (TestCaseReference **)testSuite;
return (TestCaseReference **)testSuite;
}
/**
@@ -30,5 +30,5 @@ TestCaseReference **QueryTestSuite() {
int
video_test(void *arg)
{
AssertPass("");
AssertPass("");
}

View File

@@ -53,7 +53,7 @@ void RunBasicTest()
printf("AtomicUnlock lock=%d\n", lock);
printf("\natomic -----------------------------------------\n\n");
SDL_AtomicSet(&v, 0);
tfret = SDL_AtomicSet(&v, 10) == 0;
printf("AtomicSet(10) tfret=%s val=%d\n", tf(tfret), SDL_AtomicGet(&v));
@@ -95,27 +95,27 @@ void RunBasicTest()
* at the end the value is compared with the expected
* and with a non-atomic counter.
*/
/* Number of concurrent incrementers */
#define NThreads 2
#define CountInc 100
#define VALBITS (sizeof(atomicValue)*8)
#define atomicValue int
#define CountTo ((atomicValue)((unsigned int)(1<<(VALBITS-1))-1))
#define NInter (CountTo/CountInc/NThreads)
#define Expect (CountTo-NInter*CountInc*NThreads)
SDL_COMPILE_TIME_ASSERT(size, CountTo>0); /* check for rollover */
static SDL_atomic_t good = { 42 };
static atomicValue bad = 42;
static SDL_atomic_t threadsRunning;
static SDL_sem *threadDone;
static
int adder(void* junk)
{
@@ -129,111 +129,111 @@ int adder(void* junk)
SDL_SemPost(threadDone);
return 0;
}
static
void runAdder(void)
{
Uint32 start, end;
int T=NThreads;
start = SDL_GetTicks();
threadDone = SDL_CreateSemaphore(0);
SDL_AtomicSet(&threadsRunning, NThreads);
while (T--)
SDL_CreateThread(adder, "Adder", NULL);
while (SDL_AtomicGet(&threadsRunning) > 0)
SDL_SemWait(threadDone);
SDL_DestroySemaphore(threadDone);
end = SDL_GetTicks();
printf("Finished in %f sec\n", (end - start) / 1000.f);
}
static
void RunEpicTest()
{
int b;
atomicValue v;
printf("\nepic test---------------------------------------\n\n");
printf("Size asserted to be >= 32-bit\n");
SDL_assert(sizeof(atomicValue)>=4);
printf("Check static initializer\n");
v=SDL_AtomicGet(&good);
SDL_assert(v==42);
SDL_assert(bad==42);
printf("Test negative values\n");
SDL_AtomicSet(&good, -5);
v=SDL_AtomicGet(&good);
SDL_assert(v==-5);
printf("Verify maximum value\n");
SDL_AtomicSet(&good, CountTo);
v=SDL_AtomicGet(&good);
SDL_assert(v==CountTo);
printf("Test compare and exchange\n");
b=SDL_AtomicCAS(&good, 500, 43);
SDL_assert(!b); /* no swap since CountTo!=500 */
v=SDL_AtomicGet(&good);
SDL_assert(v==CountTo); /* ensure no swap */
b=SDL_AtomicCAS(&good, CountTo, 44);
SDL_assert(!!b); /* will swap */
v=SDL_AtomicGet(&good);
SDL_assert(v==44);
printf("Test Add\n");
v=SDL_AtomicAdd(&good, 1);
SDL_assert(v==44);
v=SDL_AtomicGet(&good);
SDL_assert(v==45);
v=SDL_AtomicAdd(&good, 10);
SDL_assert(v==45);
v=SDL_AtomicGet(&good);
SDL_assert(v==55);
printf("Test Add (Negative values)\n");
v=SDL_AtomicAdd(&good, -20);
SDL_assert(v==55);
v=SDL_AtomicGet(&good);
SDL_assert(v==35);
v=SDL_AtomicAdd(&good, -50); /* crossing zero down */
SDL_assert(v==35);
v=SDL_AtomicGet(&good);
SDL_assert(v==-15);
v=SDL_AtomicAdd(&good, 30); /* crossing zero up */
SDL_assert(v==-15);
v=SDL_AtomicGet(&good);
SDL_assert(v==15);
printf("Reset before count down test\n");
SDL_AtomicSet(&good, CountTo);
v=SDL_AtomicGet(&good);
SDL_assert(v==CountTo);
bad=CountTo;
SDL_assert(bad==CountTo);
printf("Counting down from %d, Expect %d remaining\n",CountTo,Expect);
runAdder();
v=SDL_AtomicGet(&good);
printf("Atomic %d Non-Atomic %d\n",v,bad);
SDL_assert(v==Expect);
@@ -599,7 +599,7 @@ static void RunFIFOTest(SDL_bool lock_free)
Uint32 start, end;
int i, j;
int grand_total;
printf("\nFIFO test---------------------------------------\n\n");
printf("Mode: %s\n", lock_free ? "LockFree" : "Mutex");
@@ -614,7 +614,7 @@ static void RunFIFOTest(SDL_bool lock_free)
}
start = SDL_GetTicks();
#ifdef TEST_SPINLOCK_FIFO
/* Start a monitoring thread */
if (lock_free) {
@@ -646,12 +646,12 @@ static void RunFIFOTest(SDL_bool lock_free)
writerData[i].lock_free = lock_free;
SDL_CreateThread(FIFO_Writer, name, &writerData[i]);
}
/* Wait for the writers */
while (SDL_AtomicGet(&writersRunning) > 0) {
SDL_SemWait(writersDone);
}
/* Shut down the queue so readers exit */
queue.active = SDL_FALSE;
@@ -661,14 +661,14 @@ static void RunFIFOTest(SDL_bool lock_free)
}
end = SDL_GetTicks();
SDL_DestroySemaphore(readersDone);
SDL_DestroySemaphore(writersDone);
if (!lock_free) {
SDL_DestroyMutex(queue.mutex);
}
printf("Finished in %f sec\n", (end - start) / 1000.f);
printf("\n");

View File

@@ -57,27 +57,27 @@ main(int argc, char *argv[])
if (argv[i + 1]) {
testIterations = SDL_atoi(argv[i + 1]);
if (testIterations < 1) testIterations = 1;
consumed = 2;
consumed = 2;
}
}
}
else if (SDL_strcasecmp(argv[i], "--execKey") == 0) {
if (argv[i + 1]) {
SDL_sscanf(argv[i + 1], "%llu", (long long unsigned int *)&userExecKey);
consumed = 2;
consumed = 2;
}
}
}
else if (SDL_strcasecmp(argv[i], "--seed") == 0) {
if (argv[i + 1]) {
userRunSeed = SDL_strdup(argv[i + 1]);
consumed = 2;
}
}
}
else if (SDL_strcasecmp(argv[i], "--filter") == 0) {
if (argv[i + 1]) {
filter = SDL_strdup(argv[i + 1]);
consumed = 2;
}
}
}
}
if (consumed < 0) {
fprintf(stderr,
@@ -85,11 +85,11 @@ main(int argc, char *argv[])
argv[0], SDLTest_CommonUsage(state));
quit(1);
}
i += consumed;
}
/* Initialize common state */
/* Initialize common state */
if (!SDLTest_CommonInit(state)) {
quit(2);
}
@@ -104,7 +104,7 @@ main(int argc, char *argv[])
/* Call Harness */
result = SDLTest_RunSuites(testSuites, (const char *)userRunSeed, userExecKey, (const char *)filter, testIterations);
/* Empty event queue */
/* Empty event queue */
done = 0;
for (i=0; i<100; i++) {
while (SDL_PollEvent(&event)) {
@@ -120,9 +120,9 @@ main(int argc, char *argv[])
if (filter != NULL) {
SDL_free(filter);
}
/* Shutdown everything */
quit(result);
quit(result);
return(result);
}

View File

@@ -16,11 +16,11 @@
void
_audioSetUp(void *arg)
{
/* Start SDL audio subsystem */
int ret = SDL_InitSubSystem( SDL_INIT_AUDIO );
/* Start SDL audio subsystem */
int ret = SDL_InitSubSystem( SDL_INIT_AUDIO );
SDLTest_AssertPass("Call to SDL_InitSubSystem(SDL_INIT_AUDIO)");
SDLTest_AssertCheck(ret==0, "Check result from SDL_InitSubSystem(SDL_INIT_AUDIO)");
if (ret != 0) {
SDLTest_AssertCheck(ret==0, "Check result from SDL_InitSubSystem(SDL_INIT_AUDIO)");
if (ret != 0) {
SDLTest_LogError("%s", SDL_GetError());
}
}
@@ -37,14 +37,14 @@ void _audio_testCallback(void *userdata, Uint8 *stream, int len)
/**
* \brief Stop and restart audio subsystem
*
*
* \sa http://wiki.libsdl.org/moin.cgi/SDL_QuitSubSystem
* \sa http://wiki.libsdl.org/moin.cgi/SDL_InitSubSystem
*/
int audio_quitInitAudioSubSystem()
{
/* Stop SDL audio subsystem */
SDL_QuitSubSystem( SDL_INIT_AUDIO );
/* Stop SDL audio subsystem */
SDL_QuitSubSystem( SDL_INIT_AUDIO );
SDLTest_AssertPass("Call to SDL_QuitSubSystem(SDL_INIT_AUDIO)");
/* Restart audio again */
@@ -55,18 +55,18 @@ int audio_quitInitAudioSubSystem()
/**
* \brief Start and stop audio directly
*
*
* \sa http://wiki.libsdl.org/moin.cgi/SDL_InitAudio
* \sa http://wiki.libsdl.org/moin.cgi/SDL_QuitAudio
*/
int audio_initQuitAudio()
{
int result;
int i, iMax;
const char* audioDriver;
/* Stop SDL audio subsystem */
SDL_QuitSubSystem( SDL_INIT_AUDIO );
int i, iMax;
const char* audioDriver;
/* Stop SDL audio subsystem */
SDL_QuitSubSystem( SDL_INIT_AUDIO );
SDLTest_AssertPass("Call to SDL_QuitSubSystem(SDL_INIT_AUDIO)");
/* Loop over all available audio drivers */
@@ -74,33 +74,33 @@ int audio_initQuitAudio()
SDLTest_AssertPass("Call to SDL_GetNumAudioDrivers");
SDLTest_AssertCheck(iMax > 0, "Validate number of audio drivers; expected: >0 got: %d", iMax);
for (i = 0; i < iMax; i++) {
audioDriver = SDL_GetAudioDriver(i);
SDLTest_AssertPass("Call to SDL_GetAudioDriver(%d)", i);
SDLTest_AssertCheck(audioDriver != NULL, "Audio driver name is not NULL");
SDLTest_AssertCheck(SDL_strlen(audioDriver) > 0, "Audio driver name is not empty; got: %s", audioDriver);
/* Call Init */
result = SDL_AudioInit(audioDriver);
SDLTest_AssertPass("Call to SDL_AudioInit('%s')", audioDriver);
SDLTest_AssertCheck(result == 0, "Validate result value; expected: 0 got: %d", result);
/* Call Quit */
SDL_AudioQuit();
SDLTest_AssertPass("Call to SDL_AudioQuit()");
}
/* NULL driver specification */
audioDriver = NULL;
/* Call Init */
result = SDL_AudioInit(audioDriver);
SDLTest_AssertPass("Call to SDL_AudioInit(NULL)");
SDLTest_AssertCheck(result == 0, "Validate result value; expected: 0 got: %d", result);
/* Call Quit */
SDL_AudioQuit();
SDLTest_AssertPass("Call to SDL_AudioQuit()");
audioDriver = SDL_GetAudioDriver(i);
SDLTest_AssertPass("Call to SDL_GetAudioDriver(%d)", i);
SDLTest_AssertCheck(audioDriver != NULL, "Audio driver name is not NULL");
SDLTest_AssertCheck(SDL_strlen(audioDriver) > 0, "Audio driver name is not empty; got: %s", audioDriver);
/* Call Init */
result = SDL_AudioInit(audioDriver);
SDLTest_AssertPass("Call to SDL_AudioInit('%s')", audioDriver);
SDLTest_AssertCheck(result == 0, "Validate result value; expected: 0 got: %d", result);
/* Call Quit */
SDL_AudioQuit();
SDLTest_AssertPass("Call to SDL_AudioQuit()");
}
/* NULL driver specification */
audioDriver = NULL;
/* Call Init */
result = SDL_AudioInit(audioDriver);
SDLTest_AssertPass("Call to SDL_AudioInit(NULL)");
SDLTest_AssertCheck(result == 0, "Validate result value; expected: 0 got: %d", result);
/* Call Quit */
SDL_AudioQuit();
SDLTest_AssertPass("Call to SDL_AudioQuit()");
/* Restart audio again */
_audioSetUp(NULL);
@@ -109,7 +109,7 @@ int audio_initQuitAudio()
/**
* \brief Start, open, close and stop audio
*
*
* \sa http://wiki.libsdl.org/moin.cgi/SDL_InitAudio
* \sa http://wiki.libsdl.org/moin.cgi/SDL_OpenAudio
* \sa http://wiki.libsdl.org/moin.cgi/SDL_CloseAudio
@@ -118,12 +118,12 @@ int audio_initQuitAudio()
int audio_initOpenCloseQuitAudio()
{
int result;
int i, iMax, j;
const char* audioDriver;
SDL_AudioSpec desired;
/* Stop SDL audio subsystem */
SDL_QuitSubSystem( SDL_INIT_AUDIO );
int i, iMax, j;
const char* audioDriver;
SDL_AudioSpec desired;
/* Stop SDL audio subsystem */
SDL_QuitSubSystem( SDL_INIT_AUDIO );
SDLTest_AssertPass("Call to SDL_QuitSubSystem(SDL_INIT_AUDIO)");
/* Loop over all available audio drivers */
@@ -131,58 +131,58 @@ int audio_initOpenCloseQuitAudio()
SDLTest_AssertPass("Call to SDL_GetNumAudioDrivers");
SDLTest_AssertCheck(iMax > 0, "Validate number of audio drivers; expected: >0 got: %d", iMax);
for (i = 0; i < iMax; i++) {
audioDriver = SDL_GetAudioDriver(i);
SDLTest_AssertPass("Call to SDL_GetAudioDriver(%d)", i);
SDLTest_AssertCheck(audioDriver != NULL, "Audio driver name is not NULL");
SDLTest_AssertCheck(SDL_strlen(audioDriver) > 0, "Audio driver name is not empty; got: %s", audioDriver);
/* Change specs */
for (j = 0; j < 2; j++) {
/* Call Init */
result = SDL_AudioInit(audioDriver);
SDLTest_AssertPass("Call to SDL_AudioInit('%s')", audioDriver);
SDLTest_AssertCheck(result == 0, "Validate result value; expected: 0 got: %d", result);
/* Set spec */
SDL_memset(&desired, 0, sizeof(desired));
switch (j) {
case 0:
/* Set standard desired spec */
desired.freq = 22050;
desired.format = AUDIO_S16SYS;
desired.channels = 2;
desired.samples = 4096;
desired.callback = _audio_testCallback;
desired.userdata = NULL;
case 1:
/* Set custom desired spec */
desired.freq = 48000;
desired.format = AUDIO_F32SYS;
desired.channels = 2;
desired.samples = 2048;
desired.callback = _audio_testCallback;
desired.userdata = NULL;
break;
}
audioDriver = SDL_GetAudioDriver(i);
SDLTest_AssertPass("Call to SDL_GetAudioDriver(%d)", i);
SDLTest_AssertCheck(audioDriver != NULL, "Audio driver name is not NULL");
SDLTest_AssertCheck(SDL_strlen(audioDriver) > 0, "Audio driver name is not empty; got: %s", audioDriver);
/* Change specs */
for (j = 0; j < 2; j++) {
/* Call Init */
result = SDL_AudioInit(audioDriver);
SDLTest_AssertPass("Call to SDL_AudioInit('%s')", audioDriver);
SDLTest_AssertCheck(result == 0, "Validate result value; expected: 0 got: %d", result);
/* Set spec */
SDL_memset(&desired, 0, sizeof(desired));
switch (j) {
case 0:
/* Set standard desired spec */
desired.freq = 22050;
desired.format = AUDIO_S16SYS;
desired.channels = 2;
desired.samples = 4096;
desired.callback = _audio_testCallback;
desired.userdata = NULL;
case 1:
/* Set custom desired spec */
desired.freq = 48000;
desired.format = AUDIO_F32SYS;
desired.channels = 2;
desired.samples = 2048;
desired.callback = _audio_testCallback;
desired.userdata = NULL;
break;
}
/* Call Open */
result = SDL_OpenAudio(&desired, NULL);
SDLTest_AssertPass("Call to SDL_OpenAudio(desired_spec_%d, NULL)", j);
SDLTest_AssertCheck(result == 0, "Verify return value; expected: 0 got: %d", result);
/* Call Close */
SDL_CloseAudio();
SDLTest_AssertPass("Call to SDL_CloseAudio()");
/* Call Quit */
SDL_AudioQuit();
SDLTest_AssertPass("Call to SDL_AudioQuit()");
} /* spec loop */
} /* driver loop */
/* Call Open */
result = SDL_OpenAudio(&desired, NULL);
SDLTest_AssertPass("Call to SDL_OpenAudio(desired_spec_%d, NULL)", j);
SDLTest_AssertCheck(result == 0, "Verify return value; expected: 0 got: %d", result);
/* Call Close */
SDL_CloseAudio();
SDLTest_AssertPass("Call to SDL_CloseAudio()");
/* Call Quit */
SDL_AudioQuit();
SDLTest_AssertPass("Call to SDL_AudioQuit()");
} /* spec loop */
} /* driver loop */
/* Restart audio again */
_audioSetUp(NULL);
@@ -191,7 +191,7 @@ int audio_initOpenCloseQuitAudio()
/**
* \brief Enumerate and name available audio devices (output and capture).
*
*
* \sa http://wiki.libsdl.org/moin.cgi/SDL_GetNumAudioDevices
* \sa http://wiki.libsdl.org/moin.cgi/SDL_GetAudioDeviceName
*/
@@ -203,7 +203,7 @@ int audio_enumerateAndNameAudioDevices()
/* Iterate over types: t=0 output device, t=1 input/capture device */
for (t=0; t<2; t++) {
/* Get number of devices. */
n = SDL_GetNumAudioDevices(t);
SDLTest_AssertPass("Call to SDL_GetNumAudioDevices(%i)", t);
@@ -217,8 +217,8 @@ int audio_enumerateAndNameAudioDevices()
SDLTest_AssertCheck(n==nn, "Verify result from SDL_GetNumAudioDevices(%i), expected same number of audio devices %i, got %i", tt, n, nn);
nn = SDL_GetNumAudioDevices(-tt);
SDLTest_AssertCheck(n==nn, "Verify result from SDL_GetNumAudioDevices(%i), expected same number of audio devices %i, got %i", -tt, n, nn);
}
}
/* List devices. */
if (n>0) {
for (i=0; i<n; i++) {
@@ -234,8 +234,8 @@ int audio_enumerateAndNameAudioDevices()
SDLTest_AssertCheck(nameAgain != NULL, "Verify result from SDL_GetAudioDeviceName(%i, %i) is not NULL", i, tt);
if (nameAgain != NULL) {
SDLTest_AssertCheck(SDL_strlen(nameAgain)>0, "Verify result from SDL_GetAudioDeviceName(%i, %i) is not empty, got: '%s'", i, tt, nameAgain);
SDLTest_AssertCheck(SDL_strcmp(name, nameAgain)==0,
"Verify SDL_GetAudioDeviceName(%i, %i) and SDL_GetAudioDeviceName(%i %i) return the same string",
SDLTest_AssertCheck(SDL_strcmp(name, nameAgain)==0,
"Verify SDL_GetAudioDeviceName(%i, %i) and SDL_GetAudioDeviceName(%i %i) return the same string",
i, t, i, tt);
}
}
@@ -243,13 +243,13 @@ int audio_enumerateAndNameAudioDevices()
}
}
}
return TEST_COMPLETED;
}
/**
* \brief Negative tests around enumeration and naming of audio devices.
*
*
* \sa http://wiki.libsdl.org/moin.cgi/SDL_GetNumAudioDevices
* \sa http://wiki.libsdl.org/moin.cgi/SDL_GetAudioDeviceName
*/
@@ -258,13 +258,13 @@ int audio_enumerateAndNameAudioDevicesNegativeTests()
int t;
int i, j, no, nc;
const char *name;
/* Get number of devices. */
no = SDL_GetNumAudioDevices(0);
SDLTest_AssertPass("Call to SDL_GetNumAudioDevices(0)");
nc = SDL_GetNumAudioDevices(1);
SDLTest_AssertPass("Call to SDL_GetNumAudioDevices(1)");
/* Invalid device index when getting name */
for (t=0; t<2; t++) {
/* Negative device index */
@@ -272,7 +272,7 @@ int audio_enumerateAndNameAudioDevicesNegativeTests()
name = SDL_GetAudioDeviceName(i, t);
SDLTest_AssertPass("Call to SDL_GetAudioDeviceName(%i, %i)", i, t);
SDLTest_AssertCheck(name == NULL, "Check SDL_GetAudioDeviceName(%i, %i) result NULL, expected NULL, got: %s", i, t, (name == NULL) ? "NULL" : name);
/* Device index past range */
for (j=0; j<3; j++) {
i = (t) ? nc+j : no+j;
@@ -280,7 +280,7 @@ int audio_enumerateAndNameAudioDevicesNegativeTests()
SDLTest_AssertPass("Call to SDL_GetAudioDeviceName(%i, %i)", i, t);
SDLTest_AssertCheck(name == NULL, "Check SDL_GetAudioDeviceName(%i, %i) result, expected: NULL, got: %s", i, t, (name == NULL) ? "NULL" : name);
}
/* Capture index past capture range but within output range */
if ((no>0) && (no>nc) && (t==1)) {
i = no-1;
@@ -309,7 +309,7 @@ int audio_printAudioDrivers()
n = SDL_GetNumAudioDrivers();
SDLTest_AssertPass("Call to SDL_GetNumAudioDrivers()");
SDLTest_AssertCheck(n>=0, "Verify number of audio drivers >= 0, got: %i", n);
/* List drivers. */
if (n>0)
{
@@ -347,11 +347,11 @@ int audio_printCurrentAudioDriver()
/* Definition of all formats, channels, and frequencies used to test audio conversions */
const int _numAudioFormats = 18;
SDL_AudioFormat _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,
SDL_AudioFormat _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_F32LSB, AUDIO_F32MSB, AUDIO_F32SYS, AUDIO_F32 };
char *_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",
char *_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_F32LSB", "AUDIO_F32MSB", "AUDIO_F32SYS", "AUDIO_F32" };
const int _numAudioChannels = 4;
Uint8 _audioChannels[] = { 1, 2, 4, 6 };
@@ -371,7 +371,7 @@ int audio_buildAudioCVT()
SDL_AudioSpec spec1;
SDL_AudioSpec spec2;
int i, ii, j, jj, k, kk;
/* No conversion needed */
spec1.format = AUDIO_S16LSB;
spec1.channels = 2;
@@ -387,7 +387,7 @@ int audio_buildAudioCVT()
spec1.freq = 22050;
spec2.format = AUDIO_S16LSB;
spec2.channels = 2;
spec2.freq = 44100;
spec2.freq = 44100;
result = SDL_BuildAudioCVT(&cvt, spec1.format, spec1.channels, spec1.freq,
spec2.format, spec2.channels, spec2.freq);
SDLTest_AssertPass("Call to SDL_BuildAudioCVT(spec1 ==> spec2)");
@@ -408,7 +408,7 @@ int audio_buildAudioCVT()
spec2.freq = _audioFrequencies[kk];
result = SDL_BuildAudioCVT(&cvt, spec1.format, spec1.channels, spec1.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);
SDLTest_AssertCheck(result == 0 || result == 1, "Verify result value; expected: 0 or 1, got: %i", result);
if (result<0) {
@@ -431,7 +431,7 @@ int audio_buildAudioCVT()
int audio_buildAudioCVTNegative()
{
const char *expectedError = "Parameter 'cvt' is invalid";
const char *error;
const char *error;
int result;
SDL_AudioCVT cvt;
SDL_AudioSpec spec1;
@@ -439,13 +439,13 @@ int audio_buildAudioCVTNegative()
int i;
char message[256];
/* Valid format */
/* Valid format */
spec1.format = AUDIO_S8;
spec1.channels = 1;
spec1.freq = 22050;
spec2.format = AUDIO_S16LSB;
spec2.channels = 2;
spec2.freq = 44100;
spec2.freq = 44100;
SDL_ClearError();
SDLTest_AssertPass("Call to SDL_ClearError()");
@@ -454,51 +454,51 @@ int audio_buildAudioCVTNegative()
result = SDL_BuildAudioCVT((SDL_AudioCVT *)NULL, spec1.format, spec1.channels, spec1.freq,
spec2.format, spec2.channels, spec2.freq);
SDLTest_AssertPass("Call to SDL_BuildAudioCVT(NULL,...)");
SDLTest_AssertCheck(result == -1, "Verify result value; expected: -1, got: %i", result);
SDLTest_AssertCheck(result == -1, "Verify result value; expected: -1, got: %i", result);
error = SDL_GetError();
SDLTest_AssertPass("Call to SDL_GetError()");
SDLTest_AssertCheck(error != NULL, "Validate that error message was not NULL");
if (error != NULL) {
SDLTest_AssertCheck(SDL_strcmp(error, expectedError) == 0,
SDLTest_AssertCheck(SDL_strcmp(error, expectedError) == 0,
"Validate error message, expected: '%s', got: '%s'", expectedError, error);
}
/* Invalid conversions */
for (i = 1; i < 64; i++) {
/* Valid format to start with */
/* Valid format to start with */
spec1.format = AUDIO_S8;
spec1.channels = 1;
spec1.freq = 22050;
spec2.format = AUDIO_S16LSB;
spec2.channels = 2;
spec2.freq = 44100;
spec2.freq = 44100;
SDL_ClearError();
SDLTest_AssertPass("Call to SDL_ClearError()");
/* Set various invalid format inputs */
SDL_strlcpy(message, "Invalid: ", 256);
if (i & 1) {
SDL_strlcat(message, " spec1.format", 256);
spec1.format = 0;
}
if (i & 2) {
if (i & 2) {
SDL_strlcat(message, " spec1.channels", 256);
spec1.channels = 0;
}
if (i & 4) {
if (i & 4) {
SDL_strlcat(message, " spec1.freq", 256);
spec1.freq = 0;
}
if (i & 8) {
if (i & 8) {
SDL_strlcat(message, " spec2.format", 256);
spec2.format = 0;
}
if (i & 16) {
if (i & 16) {
SDL_strlcat(message, " spec2.channels", 256);
spec2.channels = 0;
}
if (i & 32) {
if (i & 32) {
SDL_strlcat(message, " spec2.freq", 256);
spec2.freq = 0;
}
@@ -514,7 +514,7 @@ int audio_buildAudioCVTNegative()
SDL_ClearError();
SDLTest_AssertPass("Call to SDL_ClearError()");
return TEST_COMPLETED;
}
@@ -531,7 +531,7 @@ int audio_getAudioStatus()
result = SDL_GetAudioStatus();
SDLTest_AssertPass("Call to SDL_GetAudioStatus()");
SDLTest_AssertCheck(result == SDL_AUDIO_STOPPED || result == SDL_AUDIO_PLAYING || result == SDL_AUDIO_PAUSED,
"Verify returned value; expected: STOPPED (%i) | PLAYING (%i) | PAUSED (%i), got: %i",
"Verify returned value; expected: STOPPED (%i) | PLAYING (%i) | PAUSED (%i), got: %i",
SDL_AUDIO_STOPPED, SDL_AUDIO_PLAYING, SDL_AUDIO_PAUSED, result);
return TEST_COMPLETED;
@@ -549,10 +549,10 @@ int audio_openCloseAndGetAudioStatus()
SDL_AudioStatus result;
int i;
int count;
char *device;
char *device;
SDL_AudioDeviceID id;
SDL_AudioSpec desired, obtained;
/* Get number of devices. */
count = SDL_GetNumAudioDevices(0);
SDLTest_AssertPass("Call to SDL_GetNumAudioDevices(0)");
@@ -571,20 +571,20 @@ int audio_openCloseAndGetAudioStatus()
desired.samples=4096;
desired.callback=_audio_testCallback;
desired.userdata=NULL;
/* Open device */
id = SDL_OpenAudioDevice((const char *)device, 0, &desired, &obtained, SDL_AUDIO_ALLOW_ANY_CHANGE);
SDLTest_AssertPass("SDL_OpenAudioDevice('%s',...)", device);
SDLTest_AssertCheck(id > 1, "Validate device ID; expected: >=2, got: %i", id);
if (id > 1) {
/* Check device audio status */
result = SDL_GetAudioDeviceStatus(id);
SDLTest_AssertPass("Call to SDL_GetAudioDeviceStatus()");
SDLTest_AssertCheck(result == SDL_AUDIO_STOPPED || result == SDL_AUDIO_PLAYING || result == SDL_AUDIO_PAUSED,
"Verify returned value; expected: STOPPED (%i) | PLAYING (%i) | PAUSED (%i), got: %i",
SDL_AUDIO_STOPPED, SDL_AUDIO_PLAYING, SDL_AUDIO_PAUSED, result);
"Verify returned value; expected: STOPPED (%i) | PLAYING (%i) | PAUSED (%i), got: %i",
SDL_AUDIO_STOPPED, SDL_AUDIO_PLAYING, SDL_AUDIO_PAUSED, result);
/* Close device again */
SDL_CloseAudioDevice(id);
SDLTest_AssertPass("Call to SDL_CloseAudioDevice()");
@@ -593,7 +593,7 @@ int audio_openCloseAndGetAudioStatus()
} else {
SDLTest_Log("No devices to test with");
}
return TEST_COMPLETED;
}
@@ -607,10 +607,10 @@ int audio_lockUnlockOpenAudioDevice()
{
int i;
int count;
char *device;
char *device;
SDL_AudioDeviceID id;
SDL_AudioSpec desired, obtained;
/* Get number of devices. */
count = SDL_GetNumAudioDevices(0);
SDLTest_AssertPass("Call to SDL_GetNumAudioDevices(0)");
@@ -629,24 +629,24 @@ int audio_lockUnlockOpenAudioDevice()
desired.samples=4096;
desired.callback=_audio_testCallback;
desired.userdata=NULL;
/* Open device */
id = SDL_OpenAudioDevice((const char *)device, 0, &desired, &obtained, SDL_AUDIO_ALLOW_ANY_CHANGE);
SDLTest_AssertPass("SDL_OpenAudioDevice('%s',...)", device);
SDLTest_AssertCheck(id > 1, "Validate device ID; expected: >=2, got: %i", id);
if (id > 1) {
if (id > 1) {
/* Lock to protect callback */
SDL_LockAudioDevice(id);
SDLTest_AssertPass("SDL_LockAudioDevice(%i)", id);
/* Simulate callback processing */
SDL_Delay(10);
SDLTest_Log("Simulate callback processing - delay");
/* Unlock again*/
/* Unlock again*/
SDL_UnlockAudioDevice(id);
SDLTest_AssertPass("SDL_UnlockAudioDevice(%i)", id);
SDLTest_AssertPass("SDL_UnlockAudioDevice(%i)", id);
/* Close device again */
SDL_CloseAudioDevice(id);
SDLTest_AssertPass("Call to SDL_CloseAudioDevice()");
@@ -655,7 +655,7 @@ int audio_lockUnlockOpenAudioDevice()
} else {
SDLTest_Log("No devices to test with");
}
return TEST_COMPLETED;
}
@@ -692,11 +692,11 @@ int audio_convertAudio()
/* All source conversions with random conversion targets */
for (i = 0; i < _numAudioFormats; i++) {
for (j = 0; j < _numAudioChannels; j++) {
for (k = 0; k < _numAudioFrequencies; k++) {
for (k = 0; k < _numAudioFrequencies; k++) {
spec1.format = _audioFormats[i];
spec1.channels = _audioChannels[j];
spec1.freq = _audioFrequencies[k];
/* Ensure we have a different target format */
do {
if (c & 1) {
@@ -718,10 +718,10 @@ int audio_convertAudio()
spec2.format = _audioFormats[ii];
spec2.channels = _audioChannels[jj];
spec2.freq = _audioFrequencies[kk];
result = SDL_BuildAudioCVT(&cvt, spec1.format, spec1.channels, spec1.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);
SDLTest_AssertCheck(result == 1, "Verify result value; expected: 1, got: %i", result);
if (result != 1) {
@@ -729,7 +729,7 @@ int audio_convertAudio()
} else {
SDLTest_AssertCheck(cvt.len_mult > 0, "Verify that cvt.len_mult value; expected: >0, got: %i", cvt.len_mult);
if (cvt.len_mult < 1) return TEST_ABORTED;
/* Create some random data to convert */
l = 64;
ll = l * cvt.len_mult;
@@ -738,20 +738,20 @@ int audio_convertAudio()
cvt.buf = (Uint8 *)SDL_malloc(ll);
SDLTest_AssertCheck(cvt.buf != NULL, "Check data buffer to convert is not NULL");
if (cvt.buf == NULL) return TEST_ABORTED;
/* Convert the data */
result = SDL_ConvertAudio(&cvt);
SDLTest_AssertPass("Call to SDL_ConvertAudio()");
SDLTest_AssertCheck(result == 0, "Verify result value; expected: 0; got: %i", result);
SDLTest_AssertCheck(cvt.buf != NULL, "Verify conversion buffer is not NULL");
SDLTest_AssertCheck(cvt.len_ratio > 0.0, "Verify conversion length ratio; expected: >0; got: %f", cvt.len_ratio);
/* Free converted buffer */
if (cvt.buf != NULL) {
SDL_free(cvt.buf);
cvt.buf = NULL;
}
}
SDL_free(cvt.buf);
cvt.buf = NULL;
}
}
}
}
}
@@ -771,10 +771,10 @@ int audio_openCloseAudioDeviceConnected()
int result = -1;
int i;
int count;
char *device;
char *device;
SDL_AudioDeviceID id;
SDL_AudioSpec desired, obtained;
/* Get number of devices. */
count = SDL_GetNumAudioDevices(0);
SDLTest_AssertPass("Call to SDL_GetNumAudioDevices(0)");
@@ -793,7 +793,7 @@ int audio_openCloseAudioDeviceConnected()
desired.samples=4096;
desired.callback=_audio_testCallback;
desired.userdata=NULL;
/* Open device */
id = SDL_OpenAudioDevice((const char *)device, 0, &desired, &obtained, SDL_AUDIO_ALLOW_ANY_CHANGE);
SDLTest_AssertPass("SDL_OpenAudioDevice('%s',...)", device);
@@ -802,13 +802,13 @@ int audio_openCloseAudioDeviceConnected()
/* TODO: enable test code when function is available in SDL2 */
#ifdef AUDIODEVICECONNECTED_DEFINED
#ifdef AUDIODEVICECONNECTED_DEFINED
/* Get connected status */
result = SDL_AudioDeviceConnected(id);
SDLTest_AssertPass("Call to SDL_AudioDeviceConnected()");
#endif
SDLTest_AssertCheck(result == 1, "Verify returned value; expected: 1; got: %i", result);
/* Close device again */
SDL_CloseAudioDevice(id);
SDLTest_AssertPass("Call to SDL_CloseAudioDevice()");
@@ -817,7 +817,7 @@ int audio_openCloseAudioDeviceConnected()
} else {
SDLTest_Log("No devices to test with");
}
return TEST_COMPLETED;
}
@@ -827,69 +827,69 @@ int audio_openCloseAudioDeviceConnected()
/* Audio test cases */
static const SDLTest_TestCaseReference audioTest1 =
{ (SDLTest_TestCaseFp)audio_enumerateAndNameAudioDevices, "audio_enumerateAndNameAudioDevices", "Enumerate and name available audio devices (output and capture)", TEST_ENABLED };
{ (SDLTest_TestCaseFp)audio_enumerateAndNameAudioDevices, "audio_enumerateAndNameAudioDevices", "Enumerate and name available audio devices (output and capture)", TEST_ENABLED };
static const SDLTest_TestCaseReference audioTest2 =
{ (SDLTest_TestCaseFp)audio_enumerateAndNameAudioDevicesNegativeTests, "audio_enumerateAndNameAudioDevicesNegativeTests", "Negative tests around enumeration and naming of audio devices.", TEST_ENABLED };
{ (SDLTest_TestCaseFp)audio_enumerateAndNameAudioDevicesNegativeTests, "audio_enumerateAndNameAudioDevicesNegativeTests", "Negative tests around enumeration and naming of audio devices.", TEST_ENABLED };
static const SDLTest_TestCaseReference audioTest3 =
{ (SDLTest_TestCaseFp)audio_printAudioDrivers, "audio_printAudioDrivers", "Checks available audio driver names.", TEST_ENABLED };
{ (SDLTest_TestCaseFp)audio_printAudioDrivers, "audio_printAudioDrivers", "Checks available audio driver names.", TEST_ENABLED };
static const SDLTest_TestCaseReference audioTest4 =
{ (SDLTest_TestCaseFp)audio_printCurrentAudioDriver, "audio_printCurrentAudioDriver", "Checks current audio driver name with initialized audio.", TEST_ENABLED };
{ (SDLTest_TestCaseFp)audio_printCurrentAudioDriver, "audio_printCurrentAudioDriver", "Checks current audio driver name with initialized audio.", TEST_ENABLED };
static const SDLTest_TestCaseReference audioTest5 =
{ (SDLTest_TestCaseFp)audio_buildAudioCVT, "audio_buildAudioCVT", "Builds various audio conversion structures.", TEST_ENABLED };
{ (SDLTest_TestCaseFp)audio_buildAudioCVT, "audio_buildAudioCVT", "Builds various audio conversion structures.", TEST_ENABLED };
static const SDLTest_TestCaseReference audioTest6 =
{ (SDLTest_TestCaseFp)audio_buildAudioCVTNegative, "audio_buildAudioCVTNegative", "Checks calls with invalid input to SDL_BuildAudioCVT", TEST_ENABLED };
{ (SDLTest_TestCaseFp)audio_buildAudioCVTNegative, "audio_buildAudioCVTNegative", "Checks calls with invalid input to SDL_BuildAudioCVT", TEST_ENABLED };
static const SDLTest_TestCaseReference audioTest7 =
{ (SDLTest_TestCaseFp)audio_getAudioStatus, "audio_getAudioStatus", "Checks current audio status.", TEST_ENABLED };
{ (SDLTest_TestCaseFp)audio_getAudioStatus, "audio_getAudioStatus", "Checks current audio status.", TEST_ENABLED };
static const SDLTest_TestCaseReference audioTest8 =
{ (SDLTest_TestCaseFp)audio_openCloseAndGetAudioStatus, "audio_openCloseAndGetAudioStatus", "Opens and closes audio device and get audio status.", TEST_ENABLED };
{ (SDLTest_TestCaseFp)audio_openCloseAndGetAudioStatus, "audio_openCloseAndGetAudioStatus", "Opens and closes audio device and get audio status.", TEST_ENABLED };
static const SDLTest_TestCaseReference audioTest9 =
{ (SDLTest_TestCaseFp)audio_lockUnlockOpenAudioDevice, "audio_lockUnlockOpenAudioDevice", "Locks and unlocks an open audio device.", TEST_ENABLED };
{ (SDLTest_TestCaseFp)audio_lockUnlockOpenAudioDevice, "audio_lockUnlockOpenAudioDevice", "Locks and unlocks an open audio device.", TEST_ENABLED };
/* TODO: enable test when SDL_ConvertAudio segfaults on cygwin have been fixed. */
/* For debugging, test case can be run manually using --filter audio_convertAudio */
static const SDLTest_TestCaseReference audioTest10 =
{ (SDLTest_TestCaseFp)audio_convertAudio, "audio_convertAudio", "Convert audio using available formats.", TEST_DISABLED };
{ (SDLTest_TestCaseFp)audio_convertAudio, "audio_convertAudio", "Convert audio using available formats.", TEST_DISABLED };
/* TODO: enable test when SDL_AudioDeviceConnected has been implemented. */
static const SDLTest_TestCaseReference audioTest11 =
{ (SDLTest_TestCaseFp)audio_openCloseAudioDeviceConnected, "audio_openCloseAudioDeviceConnected", "Opens and closes audio device and get connected status.", TEST_DISABLED };
{ (SDLTest_TestCaseFp)audio_openCloseAudioDeviceConnected, "audio_openCloseAudioDeviceConnected", "Opens and closes audio device and get connected status.", TEST_DISABLED };
static const SDLTest_TestCaseReference audioTest12 =
{ (SDLTest_TestCaseFp)audio_quitInitAudioSubSystem, "audio_quitInitAudioSubSystem", "Quit and re-init audio subsystem.", TEST_ENABLED };
{ (SDLTest_TestCaseFp)audio_quitInitAudioSubSystem, "audio_quitInitAudioSubSystem", "Quit and re-init audio subsystem.", TEST_ENABLED };
/* TODO: enable when bugs 1343 and 1396 are fixed. */
/* For debugging, test case can be run manually using --filter audio_initQuitAudio */
static const SDLTest_TestCaseReference audioTest13 =
{ (SDLTest_TestCaseFp)audio_initQuitAudio, "audio_initQuitAudio", "Init and quit audio drivers directly.", TEST_DISABLED };
{ (SDLTest_TestCaseFp)audio_initQuitAudio, "audio_initQuitAudio", "Init and quit audio drivers directly.", TEST_DISABLED };
/* TODO: enable when bugs 1343 and 1396 are fixed. */
/* For debugging, test case can be run manually using --filter audio_initOpenCloseQuitAudio */
static const SDLTest_TestCaseReference audioTest14 =
{ (SDLTest_TestCaseFp)audio_initOpenCloseQuitAudio, "audio_initOpenCloseQuitAudio", "Cycle through init, open, close and quit with various audio specs.", TEST_DISABLED };
{ (SDLTest_TestCaseFp)audio_initOpenCloseQuitAudio, "audio_initOpenCloseQuitAudio", "Cycle through init, open, close and quit with various audio specs.", TEST_DISABLED };
/* Sequence of Audio test cases */
static const SDLTest_TestCaseReference *audioTests[] = {
&audioTest1, &audioTest2, &audioTest3, &audioTest4, &audioTest5, &audioTest6,
&audioTest7, &audioTest8, &audioTest9, &audioTest10, &audioTest11,
&audioTest12, &audioTest13, &audioTest14, NULL
&audioTest1, &audioTest2, &audioTest3, &audioTest4, &audioTest5, &audioTest6,
&audioTest7, &audioTest8, &audioTest9, &audioTest10, &audioTest11,
&audioTest12, &audioTest13, &audioTest14, NULL
};
/* Audio test suite (global) */
SDLTest_TestSuiteReference audioTestSuite = {
"Audio",
_audioSetUp,
audioTests,
NULL
"Audio",
_audioSetUp,
audioTests,
NULL
};

View File

@@ -21,9 +21,9 @@
int
clipboard_testHasClipboardText(void *arg)
{
SDL_bool result;
result = SDL_HasClipboardText();
SDLTest_AssertPass("Call to SDL_HasClipboardText succeeded");
SDL_bool result;
result = SDL_HasClipboardText();
SDLTest_AssertPass("Call to SDL_HasClipboardText succeeded");
return TEST_COMPLETED;
}
@@ -37,11 +37,11 @@ clipboard_testHasClipboardText(void *arg)
int
clipboard_testGetClipboardText(void *arg)
{
char *charResult;
charResult = SDL_GetClipboardText();
SDLTest_AssertPass("Call to SDL_GetClipboardText succeeded");
char *charResult;
charResult = SDL_GetClipboardText();
SDLTest_AssertPass("Call to SDL_GetClipboardText succeeded");
if (charResult) SDL_free(charResult);
if (charResult) SDL_free(charResult);
return TEST_COMPLETED;
}
@@ -54,19 +54,19 @@ clipboard_testGetClipboardText(void *arg)
int
clipboard_testSetClipboardText(void *arg)
{
char *textRef = SDLTest_RandomAsciiString();
char *text = SDL_strdup(textRef);
int result;
result = SDL_SetClipboardText((const char *)text);
SDLTest_AssertPass("Call to SDL_SetClipboardText succeeded");
SDLTest_AssertCheck(
result == 0,
"Validate SDL_SetClipboardText result, expected 0, got %i",
result);
SDLTest_AssertCheck(
SDL_strcmp(textRef, text) == 0,
"Verify SDL_SetClipboardText did not modify input string, expected '%s', got '%s'",
textRef, text);
char *textRef = SDLTest_RandomAsciiString();
char *text = SDL_strdup(textRef);
int result;
result = SDL_SetClipboardText((const char *)text);
SDLTest_AssertPass("Call to SDL_SetClipboardText succeeded");
SDLTest_AssertCheck(
result == 0,
"Validate SDL_SetClipboardText result, expected 0, got %i",
result);
SDLTest_AssertCheck(
SDL_strcmp(textRef, text) == 0,
"Verify SDL_SetClipboardText did not modify input string, expected '%s', got '%s'",
textRef, text);
/* Cleanup */
if (textRef) SDL_free(textRef);
@@ -85,64 +85,64 @@ clipboard_testSetClipboardText(void *arg)
int
clipboard_testClipboardTextFunctions(void *arg)
{
char *textRef = SDLTest_RandomAsciiString();
char *text = SDL_strdup(textRef);
SDL_bool boolResult;
int intResult;
char *charResult;
char *textRef = SDLTest_RandomAsciiString();
char *text = SDL_strdup(textRef);
SDL_bool boolResult;
int intResult;
char *charResult;
/* Clear clipboard text state */
boolResult = SDL_HasClipboardText();
SDLTest_AssertPass("Call to SDL_HasClipboardText succeeded");
if (boolResult == SDL_TRUE) {
/* Clear clipboard text state */
boolResult = SDL_HasClipboardText();
SDLTest_AssertPass("Call to SDL_HasClipboardText succeeded");
if (boolResult == SDL_TRUE) {
intResult = SDL_SetClipboardText((const char *)NULL);
SDLTest_AssertPass("Call to SDL_SetClipboardText(NULL) succeeded");
SDLTest_AssertCheck(
intResult == 0,
"Verify result from SDL_SetClipboardText(NULL), expected 0, got %i",
intResult);
charResult = SDL_GetClipboardText();
SDLTest_AssertPass("Call to SDL_GetClipboardText succeeded");
boolResult = SDL_HasClipboardText();
SDLTest_AssertPass("Call to SDL_HasClipboardText succeeded");
SDLTest_AssertCheck(
SDLTest_AssertCheck(
intResult == 0,
"Verify result from SDL_SetClipboardText(NULL), expected 0, got %i",
intResult);
charResult = SDL_GetClipboardText();
SDLTest_AssertPass("Call to SDL_GetClipboardText succeeded");
boolResult = SDL_HasClipboardText();
SDLTest_AssertPass("Call to SDL_HasClipboardText succeeded");
SDLTest_AssertCheck(
boolResult == SDL_FALSE,
"Verify SDL_HasClipboardText returned SDL_FALSE, got %s",
(boolResult) ? "SDL_TRUE" : "SDL_FALSE");
"Verify SDL_HasClipboardText returned SDL_FALSE, got %s",
(boolResult) ? "SDL_TRUE" : "SDL_FALSE");
}
/* Empty clipboard */
charResult = SDL_GetClipboardText();
SDLTest_AssertPass("Call to SDL_GetClipboardText succeeded");
SDLTest_AssertCheck(
charResult != NULL,
"Verify SDL_GetClipboardText did not return NULL");
SDLTest_AssertCheck(
SDL_strlen(charResult) == 0,
"Verify SDL_GetClipboardText returned string with length 0, got length %i",
SDL_strlen(charResult));
charResult = SDL_GetClipboardText();
SDLTest_AssertPass("Call to SDL_GetClipboardText succeeded");
SDLTest_AssertCheck(
charResult != NULL,
"Verify SDL_GetClipboardText did not return NULL");
SDLTest_AssertCheck(
SDL_strlen(charResult) == 0,
"Verify SDL_GetClipboardText returned string with length 0, got length %i",
SDL_strlen(charResult));
intResult = SDL_SetClipboardText((const char *)text);
SDLTest_AssertPass("Call to SDL_SetClipboardText succeeded");
SDLTest_AssertCheck(
intResult == 0,
"Verify result from SDL_SetClipboardText(NULL), expected 0, got %i",
intResult);
SDLTest_AssertCheck(
SDL_strcmp(textRef, text) == 0,
"Verify SDL_SetClipboardText did not modify input string, expected '%s', got '%s'",
textRef, text);
boolResult = SDL_HasClipboardText();
SDLTest_AssertPass("Call to SDL_HasClipboardText succeeded");
SDLTest_AssertCheck(
SDLTest_AssertPass("Call to SDL_SetClipboardText succeeded");
SDLTest_AssertCheck(
intResult == 0,
"Verify result from SDL_SetClipboardText(NULL), expected 0, got %i",
intResult);
SDLTest_AssertCheck(
SDL_strcmp(textRef, text) == 0,
"Verify SDL_SetClipboardText did not modify input string, expected '%s', got '%s'",
textRef, text);
boolResult = SDL_HasClipboardText();
SDLTest_AssertPass("Call to SDL_HasClipboardText succeeded");
SDLTest_AssertCheck(
boolResult == SDL_TRUE,
"Verify SDL_HasClipboardText returned SDL_TRUE, got %s",
(boolResult) ? "SDL_TRUE" : "SDL_FALSE");
charResult = SDL_GetClipboardText();
SDLTest_AssertPass("Call to SDL_GetClipboardText succeeded");
SDLTest_AssertCheck(
strcmp(textRef, charResult) == 0,
"Verify SDL_GetClipboardText returned correct string, expected '%s', got '%s'",
textRef, charResult);
"Verify SDL_HasClipboardText returned SDL_TRUE, got %s",
(boolResult) ? "SDL_TRUE" : "SDL_FALSE");
charResult = SDL_GetClipboardText();
SDLTest_AssertPass("Call to SDL_GetClipboardText succeeded");
SDLTest_AssertCheck(
strcmp(textRef, charResult) == 0,
"Verify SDL_GetClipboardText returned correct string, expected '%s', got '%s'",
textRef, charResult);
/* Cleanup */
if (textRef) SDL_free(textRef);
@@ -157,26 +157,26 @@ clipboard_testClipboardTextFunctions(void *arg)
/* Clipboard test cases */
static const SDLTest_TestCaseReference clipboardTest1 =
{ (SDLTest_TestCaseFp)clipboard_testHasClipboardText, "clipboard_testHasClipboardText", "Check call to SDL_HasClipboardText", TEST_ENABLED };
{ (SDLTest_TestCaseFp)clipboard_testHasClipboardText, "clipboard_testHasClipboardText", "Check call to SDL_HasClipboardText", TEST_ENABLED };
static const SDLTest_TestCaseReference clipboardTest2 =
{ (SDLTest_TestCaseFp)clipboard_testGetClipboardText, "clipboard_testGetClipboardText", "Check call to SDL_GetClipboardText", TEST_ENABLED };
{ (SDLTest_TestCaseFp)clipboard_testGetClipboardText, "clipboard_testGetClipboardText", "Check call to SDL_GetClipboardText", TEST_ENABLED };
static const SDLTest_TestCaseReference clipboardTest3 =
{ (SDLTest_TestCaseFp)clipboard_testSetClipboardText, "clipboard_testSetClipboardText", "Check call to SDL_SetClipboardText", TEST_ENABLED };
{ (SDLTest_TestCaseFp)clipboard_testSetClipboardText, "clipboard_testSetClipboardText", "Check call to SDL_SetClipboardText", TEST_ENABLED };
static const SDLTest_TestCaseReference clipboardTest4 =
{ (SDLTest_TestCaseFp)clipboard_testClipboardTextFunctions, "clipboard_testClipboardTextFunctions", "End-to-end test of SDL_xyzClipboardText functions", TEST_ENABLED };
{ (SDLTest_TestCaseFp)clipboard_testClipboardTextFunctions, "clipboard_testClipboardTextFunctions", "End-to-end test of SDL_xyzClipboardText functions", TEST_ENABLED };
/* Sequence of Clipboard test cases */
static const SDLTest_TestCaseReference *clipboardTests[] = {
&clipboardTest1, &clipboardTest2, &clipboardTest3, &clipboardTest4, NULL
&clipboardTest1, &clipboardTest2, &clipboardTest3, &clipboardTest4, NULL
};
/* Clipboard test suite (global) */
SDLTest_TestSuiteReference clipboardTestSuite = {
"Clipboard",
NULL,
clipboardTests,
NULL
"Clipboard",
NULL,
clipboardTests,
NULL
};

View File

@@ -28,14 +28,14 @@ int _userdataValue2 = 2;
int _events_sampleNullEventFilter(void *userdata, SDL_Event *event)
{
_eventFilterCalled = 1;
if (_userdataCheck != 0) {
SDLTest_AssertCheck(userdata != NULL, "Check userdata pointer, expected: non-NULL, got: %s", (userdata != NULL) ? "non-NULL" : "NULL");
if (userdata != NULL) {
SDLTest_AssertCheck(*(int *)userdata == _userdataValue, "Check userdata value, expected: %i, got: %i", _userdataValue, *(int *)userdata);
}
}
return 0;
}
@@ -51,24 +51,24 @@ events_pushPumpAndPollUserevent(void *arg)
SDL_Event event1;
SDL_Event event2;
int result;
/* Create user event */
event1.type = SDL_USEREVENT;
event1.user.code = SDLTest_RandomSint32();
event1.user.data1 = (void *)&_userdataValue1;
event1.user.data2 = (void *)&_userdataValue2;
/* Push a user event onto the queue and force queue update*/
SDL_PushEvent(&event1);
SDLTest_AssertPass("Call to SDL_PushEvent()");
SDL_PumpEvents();
SDLTest_AssertPass("Call to SDL_PumpEvents()");
/* Poll for user event */
result = SDL_PollEvent(&event2);
SDLTest_AssertPass("Call to SDL_PollEvent()");
SDLTest_AssertCheck(result == 1, "Check result from SDL_PollEvent, expected: 1, got: %d", result);
return TEST_COMPLETED;
}
@@ -84,7 +84,7 @@ int
events_addDelEventWatch(void *arg)
{
SDL_Event event;
/* Create user event */
event.type = SDL_USEREVENT;
event.user.code = SDLTest_RandomSint32();;
@@ -97,10 +97,10 @@ events_addDelEventWatch(void *arg)
/* Reset event filter call tracker */
_eventFilterCalled = 0;
/* Add watch */
/* Add watch */
SDL_AddEventWatch(_events_sampleNullEventFilter, NULL);
SDLTest_AssertPass("Call to SDL_AddEventWatch()");
/* Push a user event onto the queue and force queue update*/
SDL_PushEvent(&event);
SDLTest_AssertPass("Call to SDL_PushEvent()");
@@ -134,13 +134,13 @@ int
events_addDelEventWatchWithUserdata(void *arg)
{
SDL_Event event;
/* Create user event */
event.type = SDL_USEREVENT;
event.user.code = SDLTest_RandomSint32();;
event.user.data1 = (void *)&_userdataValue1;
event.user.data2 = (void *)&_userdataValue2;
/* Enable userdata check and set a value to check */
_userdataCheck = 1;
_userdataValue = SDLTest_RandomIntegerInRange(-1024, 1024);
@@ -148,7 +148,7 @@ events_addDelEventWatchWithUserdata(void *arg)
/* Reset event filter call tracker */
_eventFilterCalled = 0;
/* Add watch */
/* Add watch */
SDL_AddEventWatch(_events_sampleNullEventFilter, (void *)&_userdataValue);
SDLTest_AssertPass("Call to SDL_AddEventWatch()");
@@ -162,7 +162,7 @@ events_addDelEventWatchWithUserdata(void *arg)
/* Delete watch */
SDL_DelEventWatch(_events_sampleNullEventFilter, (void *)&_userdataValue);
SDLTest_AssertPass("Call to SDL_DelEventWatch()");
/* Push a user event onto the queue and force queue update*/
_eventFilterCalled = 0;
SDL_PushEvent(&event);
@@ -170,7 +170,7 @@ events_addDelEventWatchWithUserdata(void *arg)
SDL_PumpEvents();
SDLTest_AssertPass("Call to SDL_PumpEvents()");
SDLTest_AssertCheck(_eventFilterCalled == 0, "Check that event filter was NOT called");
return TEST_COMPLETED;
}
@@ -179,23 +179,23 @@ events_addDelEventWatchWithUserdata(void *arg)
/* Events test cases */
static const SDLTest_TestCaseReference eventsTest1 =
{ (SDLTest_TestCaseFp)events_pushPumpAndPollUserevent, "events_pushPumpAndPollUserevent", "Pushes, pumps and polls a user event", TEST_ENABLED };
{ (SDLTest_TestCaseFp)events_pushPumpAndPollUserevent, "events_pushPumpAndPollUserevent", "Pushes, pumps and polls a user event", TEST_ENABLED };
static const SDLTest_TestCaseReference eventsTest2 =
{ (SDLTest_TestCaseFp)events_addDelEventWatch, "events_addDelEventWatch", "Adds and deletes an event watch function with NULL userdata", TEST_ENABLED };
{ (SDLTest_TestCaseFp)events_addDelEventWatch, "events_addDelEventWatch", "Adds and deletes an event watch function with NULL userdata", TEST_ENABLED };
static const SDLTest_TestCaseReference eventsTest3 =
{ (SDLTest_TestCaseFp)events_addDelEventWatchWithUserdata, "events_addDelEventWatchWithUserdata", "Adds and deletes an event watch function with userdata", TEST_ENABLED };
{ (SDLTest_TestCaseFp)events_addDelEventWatchWithUserdata, "events_addDelEventWatchWithUserdata", "Adds and deletes an event watch function with userdata", TEST_ENABLED };
/* Sequence of Events test cases */
static const SDLTest_TestCaseReference *eventsTests[] = {
&eventsTest1, &eventsTest2, &eventsTest3, NULL
&eventsTest1, &eventsTest2, &eventsTest3, NULL
};
/* Events test suite (global) */
SDLTest_TestSuiteReference eventsTestSuite = {
"Events",
NULL,
eventsTests,
NULL
"Events",
NULL,
eventsTests,
NULL
};

View File

@@ -15,7 +15,7 @@
/**
* @brief Check call to SDL_GetKeyboardState with and without numkeys reference.
*
*
* @sa http://wiki.libsdl.org/moin.cgi/SDL_GetKeyboardState
*/
int
@@ -24,7 +24,7 @@ keyboard_getKeyboardState(void *arg)
int numkeys;
Uint8 *state;
/* Case where numkeys pointer is NULL */
/* Case where numkeys pointer is NULL */
state = SDL_GetKeyboardState(NULL);
SDLTest_AssertPass("Call to SDL_GetKeyboardState(NULL)");
SDLTest_AssertCheck(state != NULL, "Validate that return value from SDL_GetKeyboardState is not NULL");
@@ -35,13 +35,13 @@ keyboard_getKeyboardState(void *arg)
SDLTest_AssertPass("Call to SDL_GetKeyboardState(&numkeys)");
SDLTest_AssertCheck(state != NULL, "Validate that return value from SDL_GetKeyboardState is not NULL");
SDLTest_AssertCheck(numkeys >= 0, "Validate that value of numkeys is >= 0, got: %i", numkeys);
return TEST_COMPLETED;
}
/**
* @brief Check call to SDL_GetKeyboardFocus
*
*
* @sa http://wiki.libsdl.org/moin.cgi/SDL_GetKeyboardFocus
*/
int
@@ -58,7 +58,7 @@ keyboard_getKeyboardFocus(void *arg)
/**
* @brief Check call to SDL_GetKeyFromName for known, unknown and invalid name.
*
*
* @sa http://wiki.libsdl.org/moin.cgi/SDL_GetKeyFromName
*/
int
@@ -104,19 +104,19 @@ keyboard_getKeyFromName(void *arg)
return TEST_COMPLETED;
}
/*
/*
* Local helper to check for the invalid scancode error message
*/
void
_checkInvalidScancodeError()
{
const char *expectedError = "Parameter 'scancode' is invalid";
const char *error;
const char *error;
error = SDL_GetError();
SDLTest_AssertPass("Call to SDL_GetError()");
SDLTest_AssertCheck(error != NULL, "Validate that error message was not NULL");
if (error != NULL) {
SDLTest_AssertCheck(SDL_strcmp(error, expectedError) == 0,
SDLTest_AssertCheck(SDL_strcmp(error, expectedError) == 0,
"Validate error message, expected: '%s', got: '%s'", expectedError, error);
SDL_ClearError();
SDLTest_AssertPass("Call to SDL_ClearError()");
@@ -125,7 +125,7 @@ _checkInvalidScancodeError()
/**
* @brief Check call to SDL_GetKeyFromScancode
*
*
* @sa http://wiki.libsdl.org/moin.cgi/SDL_GetKeyFromScancode
*/
int
@@ -164,12 +164,12 @@ keyboard_getKeyFromScancode(void *arg)
/**
* @brief Check call to SDL_GetKeyName
*
*
* @sa http://wiki.libsdl.org/moin.cgi/SDL_GetKeyName
*/
int
keyboard_getKeyName(void *arg)
{
{
char *result;
char *expected;
@@ -220,12 +220,12 @@ keyboard_getKeyName(void *arg)
/**
* @brief SDL_GetScancodeName negative cases
*
*
* @sa http://wiki.libsdl.org/moin.cgi/SDL_GetScancodeName
*/
int
keyboard_getScancodeNameNegative(void *arg)
{
{
SDL_Scancode scancode;
char *result;
char *expected = "";
@@ -247,12 +247,12 @@ keyboard_getScancodeNameNegative(void *arg)
/**
* @brief SDL_GetKeyName negative cases
*
*
* @sa http://wiki.libsdl.org/moin.cgi/SDL_GetKeyName
*/
int
keyboard_getKeyNameNegative(void *arg)
{
{
SDL_Keycode keycode;
char *result;
char *expected = "";
@@ -284,17 +284,17 @@ keyboard_getKeyNameNegative(void *arg)
/**
* @brief Check call to SDL_GetModState and SDL_SetModState
*
*
* @sa http://wiki.libsdl.org/moin.cgi/SDL_GetModState
* @sa http://wiki.libsdl.org/moin.cgi/SDL_SetModState
*/
int
keyboard_getSetModState(void *arg)
{
{
SDL_Keymod result;
SDL_Keymod currentState;
SDL_Keymod newState;
SDL_Keymod allStates =
SDL_Keymod allStates =
KMOD_NONE |
KMOD_LSHIFT |
KMOD_RSHIFT |
@@ -309,13 +309,13 @@ keyboard_getSetModState(void *arg)
KMOD_MODE |
KMOD_RESERVED;
/* Get state, cache for later reset */
/* Get state, cache for later reset */
result = SDL_GetModState();
SDLTest_AssertPass("Call to SDL_GetModState()");
SDLTest_AssertCheck(result >=0 && result <= allStates, "Verify result from call is valid, expected: 0 <= result <= %i, got: %i", allStates, result);
SDLTest_AssertCheck(result >=0 && result <= allStates, "Verify result from call is valid, expected: 0 <= result <= %i, got: %i", allStates, result);
currentState = result;
/* Set random state */
/* Set random state */
newState = SDLTest_RandomIntegerInRange(0, allStates);
SDL_SetModState(newState);
SDLTest_AssertPass("Call to SDL_SetModState(%i)", newState);
@@ -345,13 +345,13 @@ keyboard_getSetModState(void *arg)
/**
* @brief Check call to SDL_StartTextInput and SDL_StopTextInput
*
*
* @sa http://wiki.libsdl.org/moin.cgi/SDL_StartTextInput
* @sa http://wiki.libsdl.org/moin.cgi/SDL_StopTextInput
*/
int
keyboard_startStopTextInput(void *arg)
{
{
/* Start-Stop */
SDL_StartTextInput();
SDLTest_AssertPass("Call to SDL_StartTextInput()");
@@ -361,12 +361,12 @@ keyboard_startStopTextInput(void *arg)
/* Stop-Start */
SDL_StartTextInput();
SDLTest_AssertPass("Call to SDL_StartTextInput()");
/* Start-Start */
SDL_StartTextInput();
SDLTest_AssertPass("Call to SDL_StartTextInput()");
/* Stop-Stop */
/* Stop-Stop */
SDL_StopTextInput();
SDLTest_AssertPass("Call to SDL_StopTextInput()");
SDL_StopTextInput();
@@ -379,34 +379,34 @@ keyboard_startStopTextInput(void *arg)
void _testSetTextInputRect(SDL_Rect refRect)
{
SDL_Rect testRect;
testRect = refRect;
SDL_SetTextInputRect(&testRect);
SDLTest_AssertPass("Call to SDL_SetTextInputRect with refRect(x:%i,y:%i,w:%i,h:%i)", refRect.x, refRect.y, refRect.w, refRect.h);
SDLTest_AssertCheck(
(refRect.x == testRect.x) && (refRect.y == testRect.y) && (refRect.w == testRect.w) && (refRect.h == testRect.h),
"Check that input data was not modified, expected: x:%i,y:%i,w:%i,h:%i, got: x:%i,y:%i,w:%i,h:%i",
refRect.x, refRect.y, refRect.w, refRect.h,
(refRect.x == testRect.x) && (refRect.y == testRect.y) && (refRect.w == testRect.w) && (refRect.h == testRect.h),
"Check that input data was not modified, expected: x:%i,y:%i,w:%i,h:%i, got: x:%i,y:%i,w:%i,h:%i",
refRect.x, refRect.y, refRect.w, refRect.h,
testRect.x, testRect.y, testRect.w, testRect.h);
}
/**
* @brief Check call to SDL_SetTextInputRect
*
*
* @sa http://wiki.libsdl.org/moin.cgi/SDL_SetTextInputRect
*/
int
keyboard_setTextInputRect(void *arg)
{
{
SDL_Rect refRect;
/* Normal visible refRect, origin inside */
refRect.x = SDLTest_RandomIntegerInRange(1, 50);;
refRect.y = SDLTest_RandomIntegerInRange(1, 50);;
refRect.w = SDLTest_RandomIntegerInRange(10, 50);
refRect.h = SDLTest_RandomIntegerInRange(10, 50);
_testSetTextInputRect(refRect);
/* Normal visible refRect, origin 0,0 */
refRect.x = 0;
refRect.y = 0;
@@ -472,133 +472,133 @@ keyboard_setTextInputRect(void *arg)
/**
* @brief Check call to SDL_SetTextInputRect with invalid data
*
*
* @sa http://wiki.libsdl.org/moin.cgi/SDL_SetTextInputRect
*/
int
keyboard_setTextInputRectNegative(void *arg)
{
{
/* Some platforms set also an error message; prepare for checking it */
#if SDL_VIDEO_DRIVER_WINDOWS || SDL_VIDEO_DRIVER_ANDROID || SDL_VIDEO_DRIVER_COCOA
#if SDL_VIDEO_DRIVER_WINDOWS || SDL_VIDEO_DRIVER_ANDROID || SDL_VIDEO_DRIVER_COCOA
const char *expectedError = "Parameter 'rect' is invalid";
const char *error;
SDL_ClearError();
SDLTest_AssertPass("Call to SDL_ClearError()");
#endif
/* NULL refRect */
SDL_SetTextInputRect(NULL);
SDLTest_AssertPass("Call to SDL_SetTextInputRect(NULL)");
/* Some platforms set also an error message; so check it */
#if SDL_VIDEO_DRIVER_WINDOWS || SDL_VIDEO_DRIVER_ANDROID || SDL_VIDEO_DRIVER_COCOA
#if SDL_VIDEO_DRIVER_WINDOWS || SDL_VIDEO_DRIVER_ANDROID || SDL_VIDEO_DRIVER_COCOA
error = SDL_GetError();
SDLTest_AssertPass("Call to SDL_GetError()");
SDLTest_AssertCheck(error != NULL, "Validate that error message was not NULL");
if (error != NULL) {
SDLTest_AssertCheck(SDL_strcmp(error, expectedError) == 0,
SDLTest_AssertCheck(SDL_strcmp(error, expectedError) == 0,
"Validate error message, expected: '%s', got: '%s'", expectedError, error);
}
SDL_ClearError();
SDLTest_AssertPass("Call to SDL_ClearError()");
#endif
return TEST_COMPLETED;
}
/**
* @brief Check call to SDL_GetScancodeFromKey
*
*
* @sa http://wiki.libsdl.org/moin.cgi/SDL_GetScancodeFromKey
* @sa http://wiki.libsdl.org/moin.cgi/SDL_Keycode
*/
int
keyboard_getScancodeFromKey(void *arg)
{
{
SDL_Scancode scancode;
/* Regular key */
scancode = SDL_GetScancodeFromKey(SDLK_4);
SDLTest_AssertPass("Call to SDL_GetScancodeFromKey(SDLK_4)");
SDLTest_AssertCheck(scancode == SDL_SCANCODE_4, "Validate return value from SDL_GetScancodeFromKey, expected: %i, got: %i", SDL_SCANCODE_4, scancode);
SDLTest_AssertCheck(scancode == SDL_SCANCODE_4, "Validate return value from SDL_GetScancodeFromKey, expected: %i, got: %i", SDL_SCANCODE_4, scancode);
/* Virtual key */
scancode = SDL_GetScancodeFromKey(SDLK_PLUS);
SDLTest_AssertPass("Call to SDL_GetScancodeFromKey(SDLK_PLUS)");
SDLTest_AssertCheck(scancode == 0, "Validate return value from SDL_GetScancodeFromKey, expected: 0, got: %i", scancode);
SDLTest_AssertCheck(scancode == 0, "Validate return value from SDL_GetScancodeFromKey, expected: 0, got: %i", scancode);
return TEST_COMPLETED;
}
/**
* @brief Check call to SDL_GetScancodeFromName
*
*
* @sa http://wiki.libsdl.org/moin.cgi/SDL_GetScancodeFromName
* @sa http://wiki.libsdl.org/moin.cgi/SDL_Keycode
*/
int
keyboard_getScancodeFromName(void *arg)
{
{
SDL_Scancode scancode;
/* Regular key, 1 character, first name in list */
scancode = SDL_GetScancodeFromName("A");
SDLTest_AssertPass("Call to SDL_GetScancodeFromName('A')");
SDLTest_AssertCheck(scancode == SDL_SCANCODE_A, "Validate return value from SDL_GetScancodeFromName, expected: %i, got: %i", SDL_SCANCODE_A, scancode);
SDLTest_AssertCheck(scancode == SDL_SCANCODE_A, "Validate return value from SDL_GetScancodeFromName, expected: %i, got: %i", SDL_SCANCODE_A, scancode);
/* Regular key, 1 character */
scancode = SDL_GetScancodeFromName("4");
SDLTest_AssertPass("Call to SDL_GetScancodeFromName('4')");
SDLTest_AssertCheck(scancode == SDL_SCANCODE_4, "Validate return value from SDL_GetScancodeFromName, expected: %i, got: %i", SDL_SCANCODE_4, scancode);
SDLTest_AssertCheck(scancode == SDL_SCANCODE_4, "Validate return value from SDL_GetScancodeFromName, expected: %i, got: %i", SDL_SCANCODE_4, scancode);
/* Regular key, 2 characters */
scancode = SDL_GetScancodeFromName("F1");
SDLTest_AssertPass("Call to SDL_GetScancodeFromName('F1')");
SDLTest_AssertCheck(scancode == SDL_SCANCODE_F1, "Validate return value from SDL_GetScancodeFromName, expected: %i, got: %i", SDL_SCANCODE_F1, scancode);
SDLTest_AssertCheck(scancode == SDL_SCANCODE_F1, "Validate return value from SDL_GetScancodeFromName, expected: %i, got: %i", SDL_SCANCODE_F1, scancode);
/* Regular key, 3 characters */
scancode = SDL_GetScancodeFromName("End");
SDLTest_AssertPass("Call to SDL_GetScancodeFromName('End')");
SDLTest_AssertCheck(scancode == SDL_SCANCODE_END, "Validate return value from SDL_GetScancodeFromName, expected: %i, got: %i", SDL_SCANCODE_END, scancode);
SDLTest_AssertCheck(scancode == SDL_SCANCODE_END, "Validate return value from SDL_GetScancodeFromName, expected: %i, got: %i", SDL_SCANCODE_END, scancode);
/* Regular key, 4 characters */
scancode = SDL_GetScancodeFromName("Find");
SDLTest_AssertPass("Call to SDL_GetScancodeFromName('Find')");
SDLTest_AssertCheck(scancode == SDL_SCANCODE_FIND, "Validate return value from SDL_GetScancodeFromName, expected: %i, got: %i", SDL_SCANCODE_FIND, scancode);
SDLTest_AssertCheck(scancode == SDL_SCANCODE_FIND, "Validate return value from SDL_GetScancodeFromName, expected: %i, got: %i", SDL_SCANCODE_FIND, scancode);
/* Regular key, several characters */
scancode = SDL_GetScancodeFromName("Backspace");
SDLTest_AssertPass("Call to SDL_GetScancodeFromName('Backspace')");
SDLTest_AssertCheck(scancode == SDL_SCANCODE_BACKSPACE, "Validate return value from SDL_GetScancodeFromName, expected: %i, got: %i", SDL_SCANCODE_BACKSPACE, scancode);
SDLTest_AssertCheck(scancode == SDL_SCANCODE_BACKSPACE, "Validate return value from SDL_GetScancodeFromName, expected: %i, got: %i", SDL_SCANCODE_BACKSPACE, scancode);
/* Regular key, several characters with space */
scancode = SDL_GetScancodeFromName("Keypad Enter");
SDLTest_AssertPass("Call to SDL_GetScancodeFromName('Keypad Enter')");
SDLTest_AssertCheck(scancode == SDL_SCANCODE_KP_ENTER, "Validate return value from SDL_GetScancodeFromName, expected: %i, got: %i", SDL_SCANCODE_KP_ENTER, scancode);
SDLTest_AssertCheck(scancode == SDL_SCANCODE_KP_ENTER, "Validate return value from SDL_GetScancodeFromName, expected: %i, got: %i", SDL_SCANCODE_KP_ENTER, scancode);
/* Regular key, last name in list */
scancode = SDL_GetScancodeFromName("Sleep");
SDLTest_AssertPass("Call to SDL_GetScancodeFromName('Sleep')");
SDLTest_AssertCheck(scancode == SDL_SCANCODE_SLEEP, "Validate return value from SDL_GetScancodeFromName, expected: %i, got: %i", SDL_SCANCODE_SLEEP, scancode);
SDLTest_AssertCheck(scancode == SDL_SCANCODE_SLEEP, "Validate return value from SDL_GetScancodeFromName, expected: %i, got: %i", SDL_SCANCODE_SLEEP, scancode);
return TEST_COMPLETED;
}
/*
/*
* Local helper to check for the invalid scancode error message
*/
void
_checkInvalidNameError()
{
const char *expectedError = "Parameter 'name' is invalid";
const char *error;
const char *error;
error = SDL_GetError();
SDLTest_AssertPass("Call to SDL_GetError()");
SDLTest_AssertCheck(error != NULL, "Validate that error message was not NULL");
if (error != NULL) {
SDLTest_AssertCheck(SDL_strcmp(error, expectedError) == 0,
SDLTest_AssertCheck(SDL_strcmp(error, expectedError) == 0,
"Validate error message, expected: '%s', got: '%s'", expectedError, error);
SDL_ClearError();
SDLTest_AssertPass("Call to SDL_ClearError()");
@@ -607,13 +607,13 @@ _checkInvalidNameError()
/**
* @brief Check call to SDL_GetScancodeFromName with invalid data
*
*
* @sa http://wiki.libsdl.org/moin.cgi/SDL_GetScancodeFromName
* @sa http://wiki.libsdl.org/moin.cgi/SDL_Keycode
*/
int
keyboard_getScancodeFromNameNegative(void *arg)
{
{
char *name;
SDL_Scancode scancode;
@@ -626,13 +626,13 @@ keyboard_getScancodeFromNameNegative(void *arg)
SDLTest_Assert(name != NULL, "Check that random name is not NULL");
if (name == NULL) {
return TEST_ABORTED;
}
}
scancode = SDL_GetScancodeFromName((const char *)name);
SDLTest_AssertPass("Call to SDL_GetScancodeFromName('%s')", name);
SDL_free(name);
SDLTest_AssertCheck(scancode == SDL_SCANCODE_UNKNOWN, "Validate return value from SDL_GetScancodeFromName, expected: %i, got: %i", SDL_SCANCODE_UNKNOWN, scancode);
_checkInvalidNameError();
/* Zero length string input */
name = "";
scancode = SDL_GetScancodeFromName((const char *)name);
@@ -646,7 +646,7 @@ keyboard_getScancodeFromNameNegative(void *arg)
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);
_checkInvalidNameError();
return TEST_COMPLETED;
}
@@ -656,58 +656,58 @@ keyboard_getScancodeFromNameNegative(void *arg)
/* Keyboard test cases */
static const SDLTest_TestCaseReference keyboardTest1 =
{ (SDLTest_TestCaseFp)keyboard_getKeyboardState, "keyboard_getKeyboardState", "Check call to SDL_GetKeyboardState with and without numkeys reference", TEST_ENABLED };
{ (SDLTest_TestCaseFp)keyboard_getKeyboardState, "keyboard_getKeyboardState", "Check call to SDL_GetKeyboardState with and without numkeys reference", TEST_ENABLED };
static const SDLTest_TestCaseReference keyboardTest2 =
{ (SDLTest_TestCaseFp)keyboard_getKeyboardFocus, "keyboard_getKeyboardFocus", "Check call to SDL_GetKeyboardFocus", TEST_ENABLED };
{ (SDLTest_TestCaseFp)keyboard_getKeyboardFocus, "keyboard_getKeyboardFocus", "Check call to SDL_GetKeyboardFocus", TEST_ENABLED };
static const SDLTest_TestCaseReference keyboardTest3 =
{ (SDLTest_TestCaseFp)keyboard_getKeyFromName, "keyboard_getKeyFromName", "Check call to SDL_GetKeyFromName for known, unknown and invalid name", TEST_ENABLED };
{ (SDLTest_TestCaseFp)keyboard_getKeyFromName, "keyboard_getKeyFromName", "Check call to SDL_GetKeyFromName for known, unknown and invalid name", TEST_ENABLED };
static const SDLTest_TestCaseReference keyboardTest4 =
{ (SDLTest_TestCaseFp)keyboard_getKeyFromScancode, "keyboard_getKeyFromScancode", "Check call to SDL_GetKeyFromScancode", TEST_ENABLED };
{ (SDLTest_TestCaseFp)keyboard_getKeyFromScancode, "keyboard_getKeyFromScancode", "Check call to SDL_GetKeyFromScancode", TEST_ENABLED };
static const SDLTest_TestCaseReference keyboardTest5 =
{ (SDLTest_TestCaseFp)keyboard_getKeyName, "keyboard_getKeyName", "Check call to SDL_GetKeyName", TEST_ENABLED };
{ (SDLTest_TestCaseFp)keyboard_getKeyName, "keyboard_getKeyName", "Check call to SDL_GetKeyName", TEST_ENABLED };
static const SDLTest_TestCaseReference keyboardTest6 =
{ (SDLTest_TestCaseFp)keyboard_getSetModState, "keyboard_getSetModState", "Check call to SDL_GetModState and SDL_SetModState", TEST_ENABLED };
{ (SDLTest_TestCaseFp)keyboard_getSetModState, "keyboard_getSetModState", "Check call to SDL_GetModState and SDL_SetModState", TEST_ENABLED };
static const SDLTest_TestCaseReference keyboardTest7 =
{ (SDLTest_TestCaseFp)keyboard_startStopTextInput, "keyboard_startStopTextInput", "Check call to SDL_StartTextInput and SDL_StopTextInput", TEST_ENABLED };
{ (SDLTest_TestCaseFp)keyboard_startStopTextInput, "keyboard_startStopTextInput", "Check call to SDL_StartTextInput and SDL_StopTextInput", TEST_ENABLED };
static const SDLTest_TestCaseReference keyboardTest8 =
{ (SDLTest_TestCaseFp)keyboard_setTextInputRect, "keyboard_setTextInputRect", "Check call to SDL_SetTextInputRect", TEST_ENABLED };
{ (SDLTest_TestCaseFp)keyboard_setTextInputRect, "keyboard_setTextInputRect", "Check call to SDL_SetTextInputRect", TEST_ENABLED };
static const SDLTest_TestCaseReference keyboardTest9 =
{ (SDLTest_TestCaseFp)keyboard_setTextInputRectNegative, "keyboard_setTextInputRectNegative", "Check call to SDL_SetTextInputRect with invalid data", TEST_ENABLED };
{ (SDLTest_TestCaseFp)keyboard_setTextInputRectNegative, "keyboard_setTextInputRectNegative", "Check call to SDL_SetTextInputRect with invalid data", TEST_ENABLED };
static const SDLTest_TestCaseReference keyboardTest10 =
{ (SDLTest_TestCaseFp)keyboard_getScancodeFromKey, "keyboard_getScancodeFromKey", "Check call to SDL_GetScancodeFromKey", TEST_ENABLED };
{ (SDLTest_TestCaseFp)keyboard_getScancodeFromKey, "keyboard_getScancodeFromKey", "Check call to SDL_GetScancodeFromKey", TEST_ENABLED };
static const SDLTest_TestCaseReference keyboardTest11 =
{ (SDLTest_TestCaseFp)keyboard_getScancodeFromName, "keyboard_getScancodeFromName", "Check call to SDL_GetScancodeFromName", TEST_ENABLED };
{ (SDLTest_TestCaseFp)keyboard_getScancodeFromName, "keyboard_getScancodeFromName", "Check call to SDL_GetScancodeFromName", TEST_ENABLED };
static const SDLTest_TestCaseReference keyboardTest12 =
{ (SDLTest_TestCaseFp)keyboard_getScancodeFromNameNegative, "keyboard_getScancodeFromNameNegative", "Check call to SDL_GetScancodeFromName with invalid data", TEST_ENABLED };
{ (SDLTest_TestCaseFp)keyboard_getScancodeFromNameNegative, "keyboard_getScancodeFromNameNegative", "Check call to SDL_GetScancodeFromName with invalid data", TEST_ENABLED };
static const SDLTest_TestCaseReference keyboardTest13 =
{ (SDLTest_TestCaseFp)keyboard_getKeyNameNegative, "keyboard_getKeyNameNegative", "Check call to SDL_GetKeyName with invalid data", TEST_ENABLED };
{ (SDLTest_TestCaseFp)keyboard_getKeyNameNegative, "keyboard_getKeyNameNegative", "Check call to SDL_GetKeyName with invalid data", TEST_ENABLED };
static const SDLTest_TestCaseReference keyboardTest14 =
{ (SDLTest_TestCaseFp)keyboard_getScancodeNameNegative, "keyboard_getScancodeNameNegative", "Check call to SDL_GetScancodeName with invalid data", TEST_ENABLED };
{ (SDLTest_TestCaseFp)keyboard_getScancodeNameNegative, "keyboard_getScancodeNameNegative", "Check call to SDL_GetScancodeName with invalid data", TEST_ENABLED };
/* Sequence of Keyboard test cases */
static const SDLTest_TestCaseReference *keyboardTests[] = {
&keyboardTest1, &keyboardTest2, &keyboardTest3, &keyboardTest4, &keyboardTest5, &keyboardTest6,
&keyboardTest7, &keyboardTest8, &keyboardTest9, &keyboardTest10, &keyboardTest11, &keyboardTest12,
&keyboardTest13, &keyboardTest14, NULL
&keyboardTest1, &keyboardTest2, &keyboardTest3, &keyboardTest4, &keyboardTest5, &keyboardTest6,
&keyboardTest7, &keyboardTest8, &keyboardTest9, &keyboardTest10, &keyboardTest11, &keyboardTest12,
&keyboardTest13, &keyboardTest14, NULL
};
/* Keyboard test suite (global) */
SDLTest_TestSuiteReference keyboardTestSuite = {
"Keyboard",
NULL,
keyboardTests,
NULL
"Keyboard",
NULL,
keyboardTests,
NULL
};

View File

@@ -126,32 +126,32 @@ static int main_testImpliedJoystickQuit (void *arg)
}
static const SDLTest_TestCaseReference mainTest1 =
{ (SDLTest_TestCaseFp)main_testInitQuitJoystickHaptic, "main_testInitQuitJoystickHaptic", "Tests SDL_Init/Quit of Joystick and Haptic subsystem", TEST_ENABLED};
{ (SDLTest_TestCaseFp)main_testInitQuitJoystickHaptic, "main_testInitQuitJoystickHaptic", "Tests SDL_Init/Quit of Joystick and Haptic subsystem", TEST_ENABLED};
static const SDLTest_TestCaseReference mainTest2 =
{ (SDLTest_TestCaseFp)main_testInitQuitSubSystem, "main_testInitQuitSubSystem", "Tests SDL_InitSubSystem/QuitSubSystem", TEST_ENABLED};
{ (SDLTest_TestCaseFp)main_testInitQuitSubSystem, "main_testInitQuitSubSystem", "Tests SDL_InitSubSystem/QuitSubSystem", TEST_ENABLED};
static const SDLTest_TestCaseReference mainTest3 =
{ (SDLTest_TestCaseFp)main_testImpliedJoystickInit, "main_testImpliedJoystickInit", "Tests that init for gamecontroller properly implies joystick", TEST_ENABLED};
{ (SDLTest_TestCaseFp)main_testImpliedJoystickInit, "main_testImpliedJoystickInit", "Tests that init for gamecontroller properly implies joystick", TEST_ENABLED};
static const SDLTest_TestCaseReference mainTest4 =
{ (SDLTest_TestCaseFp)main_testImpliedJoystickQuit, "main_testImpliedJoystickQuit", "Tests that quit for gamecontroller doesn't quit joystick if you inited it explicitly", TEST_ENABLED};
{ (SDLTest_TestCaseFp)main_testImpliedJoystickQuit, "main_testImpliedJoystickQuit", "Tests that quit for gamecontroller doesn't quit joystick if you inited it explicitly", TEST_ENABLED};
/* Sequence of Platform test cases */
static const SDLTest_TestCaseReference *mainTests[] = {
&mainTest1,
&mainTest2,
&mainTest3,
&mainTest4,
NULL
&mainTest1,
&mainTest2,
&mainTest3,
&mainTest4,
NULL
};
/* Platform test suite (global) */
SDLTest_TestSuiteReference mainTestSuite = {
"Main",
NULL,
mainTests,
NULL
"Main",
NULL,
mainTests,
NULL
};
/* vi: set ts=4 sw=4 expandtab: */

View File

@@ -15,17 +15,17 @@
/* Helper to evaluate state returned from SDL_GetMouseState */
int _mouseStateCheck(Uint32 state)
{
return (state == 0) ||
(state == SDL_BUTTON(SDL_BUTTON_LEFT)) ||
(state == SDL_BUTTON(SDL_BUTTON_MIDDLE)) ||
(state == SDL_BUTTON(SDL_BUTTON_RIGHT)) ||
(state == SDL_BUTTON(SDL_BUTTON_X1)) ||
return (state == 0) ||
(state == SDL_BUTTON(SDL_BUTTON_LEFT)) ||
(state == SDL_BUTTON(SDL_BUTTON_MIDDLE)) ||
(state == SDL_BUTTON(SDL_BUTTON_RIGHT)) ||
(state == SDL_BUTTON(SDL_BUTTON_X1)) ||
(state == SDL_BUTTON(SDL_BUTTON_X2));
}
/**
* @brief Check call to SDL_GetMouseState
*
*
*/
int
mouse_getMouseState(void *arg)
@@ -38,7 +38,7 @@ mouse_getMouseState(void *arg)
SDL_PumpEvents();
SDLTest_AssertPass("Call to SDL_PumpEvents()");
/* Case where x, y pointer is NULL */
/* Case where x, y pointer is NULL */
state = SDL_GetMouseState(NULL, NULL);
SDLTest_AssertPass("Call to SDL_GetMouseState(NULL, NULL)");
SDLTest_AssertCheck(_mouseStateCheck(state), "Validate state returned from function, got: %i", state);
@@ -65,13 +65,13 @@ mouse_getMouseState(void *arg)
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(_mouseStateCheck(state), "Validate state returned from function, got: %i", state);
return TEST_COMPLETED;
}
/**
* @brief Check call to SDL_GetRelativeMouseState
*
*
*/
int
mouse_getRelativeMouseState(void *arg)
@@ -84,7 +84,7 @@ mouse_getRelativeMouseState(void *arg)
SDL_PumpEvents();
SDLTest_AssertPass("Call to SDL_PumpEvents()");
/* Case where x, y pointer is NULL */
/* Case where x, y pointer is NULL */
state = SDL_GetRelativeMouseState(NULL, NULL);
SDLTest_AssertPass("Call to SDL_GetRelativeMouseState(NULL, NULL)");
SDLTest_AssertCheck(_mouseStateCheck(state), "Validate state returned from function, got: %i", state);
@@ -111,7 +111,7 @@ mouse_getRelativeMouseState(void *arg)
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(_mouseStateCheck(state), "Validate state returned from function, got: %i", state);
return TEST_COMPLETED;
}
@@ -191,225 +191,225 @@ static SDL_Cursor *_initArrowCursor(const char *image[])
/**
* @brief Check call to SDL_CreateCursor and SDL_FreeCursor
*
*
* @sa http://wiki.libsdl.org/moin.cgi/SDL_CreateCursor
* @sa http://wiki.libsdl.org/moin.cgi/SDL_FreeCursor
*/
int
mouse_createFreeCursor(void *arg)
{
SDL_Cursor *cursor;
SDL_Cursor *cursor;
/* Create a cursor */
cursor = _initArrowCursor(_mouseArrowData);
/* Create a cursor */
cursor = _initArrowCursor(_mouseArrowData);
SDLTest_AssertPass("Call to SDL_CreateCursor()");
SDLTest_AssertCheck(cursor != NULL, "Validate result from SDL_CreateCursor() is not NULL");
if (cursor == NULL) {
return TEST_ABORTED;
}
SDLTest_AssertCheck(cursor != NULL, "Validate result from SDL_CreateCursor() is not NULL");
if (cursor == NULL) {
return TEST_ABORTED;
}
/* Free cursor again */
SDL_FreeCursor(cursor);
SDLTest_AssertPass("Call to SDL_FreeCursor()");
/* Free cursor again */
SDL_FreeCursor(cursor);
SDLTest_AssertPass("Call to SDL_FreeCursor()");
return TEST_COMPLETED;
return TEST_COMPLETED;
}
/**
* @brief Check call to SDL_CreateColorCursor and SDL_FreeCursor
*
*
* @sa http://wiki.libsdl.org/moin.cgi/SDL_CreateColorCursor
* @sa http://wiki.libsdl.org/moin.cgi/SDL_FreeCursor
*/
int
mouse_createFreeColorCursor(void *arg)
{
SDL_Surface *face;
SDL_Cursor *cursor;
SDL_Surface *face;
SDL_Cursor *cursor;
/* Get sample surface */
face = SDLTest_ImageFace();
SDLTest_AssertCheck(face != NULL, "Validate sample input image is not NULL");
if (face == NULL) return TEST_ABORTED;
/* Create a color cursor from surface */
cursor = SDL_CreateColorCursor(face, 0, 0);
/* Get sample surface */
face = SDLTest_ImageFace();
SDLTest_AssertCheck(face != NULL, "Validate sample input image is not NULL");
if (face == NULL) return TEST_ABORTED;
/* Create a color cursor from surface */
cursor = SDL_CreateColorCursor(face, 0, 0);
SDLTest_AssertPass("Call to SDL_CreateColorCursor()");
SDLTest_AssertCheck(cursor != NULL, "Validate result from SDL_CreateColorCursor() is not NULL");
if (cursor == NULL) {
SDL_FreeSurface(face);
return TEST_ABORTED;
}
SDLTest_AssertCheck(cursor != NULL, "Validate result from SDL_CreateColorCursor() is not NULL");
if (cursor == NULL) {
SDL_FreeSurface(face);
return TEST_ABORTED;
}
/* Free cursor again */
SDL_FreeCursor(cursor);
SDLTest_AssertPass("Call to SDL_FreeCursor()");
/* Free cursor again */
SDL_FreeCursor(cursor);
SDLTest_AssertPass("Call to SDL_FreeCursor()");
/* Clean up */
SDL_FreeSurface(face);
return TEST_COMPLETED;
/* Clean up */
SDL_FreeSurface(face);
return TEST_COMPLETED;
}
/* Helper that changes cursor visibility */
void _changeCursorVisibility(int state)
{
int oldState;
int newState;
int result;
int oldState;
int newState;
int result;
oldState = SDL_ShowCursor(SDL_QUERY);
SDLTest_AssertPass("Call to SDL_ShowCursor(SDL_QUERY)");
SDLTest_AssertPass("Call to SDL_ShowCursor(SDL_QUERY)");
result = SDL_ShowCursor(state);
SDLTest_AssertPass("Call to SDL_ShowCursor(%s)", (state == SDL_ENABLE) ? "SDL_ENABLE" : "SDL_DISABLE");
SDLTest_AssertCheck(result == oldState, "Validate result from SDL_ShowCursor(%s), expected: %i, got: %i",
(state == SDL_ENABLE) ? "SDL_ENABLE" : "SDL_DISABLE", oldState, result);
newState = SDL_ShowCursor(SDL_QUERY);
SDLTest_AssertPass("Call to SDL_ShowCursor(SDL_QUERY)");
SDLTest_AssertCheck(state == newState, "Validate new state, expected: %i, got: %i",
state, newState);
SDLTest_AssertPass("Call to SDL_ShowCursor(%s)", (state == SDL_ENABLE) ? "SDL_ENABLE" : "SDL_DISABLE");
SDLTest_AssertCheck(result == oldState, "Validate result from SDL_ShowCursor(%s), expected: %i, got: %i",
(state == SDL_ENABLE) ? "SDL_ENABLE" : "SDL_DISABLE", oldState, result);
newState = SDL_ShowCursor(SDL_QUERY);
SDLTest_AssertPass("Call to SDL_ShowCursor(SDL_QUERY)");
SDLTest_AssertCheck(state == newState, "Validate new state, expected: %i, got: %i",
state, newState);
}
/**
* @brief Check call to SDL_ShowCursor
*
*
* @sa http://wiki.libsdl.org/moin.cgi/SDL_ShowCursor
*/
int
mouse_showCursor(void *arg)
{
int currentState;
int currentState;
/* Get current state */
currentState = SDL_ShowCursor(SDL_QUERY);
SDLTest_AssertPass("Call to SDL_ShowCursor(SDL_QUERY)");
SDLTest_AssertCheck(currentState == SDL_DISABLE || currentState == SDL_ENABLE,
"Validate result is %i or %i, got: %i", SDL_DISABLE, SDL_ENABLE, currentState);
if (currentState == SDL_DISABLE) {
/* Show the cursor, then hide it again */
_changeCursorVisibility(SDL_ENABLE);
_changeCursorVisibility(SDL_DISABLE);
} else if (currentState == SDL_ENABLE) {
/* Hide the cursor, then show it again */
_changeCursorVisibility(SDL_DISABLE);
_changeCursorVisibility(SDL_ENABLE);
} else {
return TEST_ABORTED;
}
/* Get current state */
currentState = SDL_ShowCursor(SDL_QUERY);
SDLTest_AssertPass("Call to SDL_ShowCursor(SDL_QUERY)");
SDLTest_AssertCheck(currentState == SDL_DISABLE || currentState == SDL_ENABLE,
"Validate result is %i or %i, got: %i", SDL_DISABLE, SDL_ENABLE, currentState);
if (currentState == SDL_DISABLE) {
/* Show the cursor, then hide it again */
_changeCursorVisibility(SDL_ENABLE);
_changeCursorVisibility(SDL_DISABLE);
} else if (currentState == SDL_ENABLE) {
/* Hide the cursor, then show it again */
_changeCursorVisibility(SDL_DISABLE);
_changeCursorVisibility(SDL_ENABLE);
} else {
return TEST_ABORTED;
}
return TEST_COMPLETED;
return TEST_COMPLETED;
}
/**
* @brief Check call to SDL_SetCursor
*
*
* @sa http://wiki.libsdl.org/moin.cgi/SDL_SetCursor
*/
int
mouse_setCursor(void *arg)
{
SDL_Cursor *cursor;
SDL_Cursor *cursor;
/* Create a cursor */
cursor = _initArrowCursor(_mouseArrowData);
/* Create a cursor */
cursor = _initArrowCursor(_mouseArrowData);
SDLTest_AssertPass("Call to SDL_CreateCursor()");
SDLTest_AssertCheck(cursor != NULL, "Validate result from SDL_CreateCursor() is not NULL");
if (cursor == NULL) {
return TEST_ABORTED;
}
SDLTest_AssertCheck(cursor != NULL, "Validate result from SDL_CreateCursor() is not NULL");
if (cursor == NULL) {
return TEST_ABORTED;
}
/* Set the arrow cursor */
SDL_SetCursor(cursor);
SDLTest_AssertPass("Call to SDL_SetCursor(cursor)");
/* Set the arrow cursor */
SDL_SetCursor(cursor);
SDLTest_AssertPass("Call to SDL_SetCursor(cursor)");
/* Force redraw */
SDL_SetCursor(NULL);
SDLTest_AssertPass("Call to SDL_SetCursor(NULL)");
/* Force redraw */
SDL_SetCursor(NULL);
SDLTest_AssertPass("Call to SDL_SetCursor(NULL)");
/* Free cursor again */
SDL_FreeCursor(cursor);
SDLTest_AssertPass("Call to SDL_FreeCursor()");
/* Free cursor again */
SDL_FreeCursor(cursor);
SDLTest_AssertPass("Call to SDL_FreeCursor()");
return TEST_COMPLETED;
return TEST_COMPLETED;
}
/**
* @brief Check call to SDL_GetCursor
*
*
* @sa http://wiki.libsdl.org/moin.cgi/SDL_GetCursor
*/
int
mouse_getCursor(void *arg)
{
SDL_Cursor *cursor;
SDL_Cursor *cursor;
/* Get current cursor */
cursor = SDL_GetCursor();
/* Get current cursor */
cursor = SDL_GetCursor();
SDLTest_AssertPass("Call to SDL_GetCursor()");
SDLTest_AssertCheck(cursor != NULL, "Validate result from SDL_GetCursor() is not NULL");
SDLTest_AssertCheck(cursor != NULL, "Validate result from SDL_GetCursor() is not NULL");
return TEST_COMPLETED;
return TEST_COMPLETED;
}
/**
* @brief Check call to SDL_GetRelativeMouseMode and SDL_SetRelativeMouseMode
*
*
* @sa http://wiki.libsdl.org/moin.cgi/SDL_GetRelativeMouseMode
* @sa http://wiki.libsdl.org/moin.cgi/SDL_SetRelativeMouseMode
*/
int
mouse_getSetRelativeMouseMode(void *arg)
{
int result;
int result;
int i;
SDL_bool initialState;
SDL_bool currentState;
SDL_bool initialState;
SDL_bool currentState;
/* Capture original state so we can revert back to it later */
initialState = SDL_GetRelativeMouseMode();
/* Capture original state so we can revert back to it later */
initialState = SDL_GetRelativeMouseMode();
SDLTest_AssertPass("Call to SDL_GetRelativeMouseMode()");
/* Repeat twice to check D->D transition */
for (i=0; i<2; i++) {
/* Disable - should always be supported */
/* Disable - should always be supported */
result = SDL_SetRelativeMouseMode(SDL_FALSE);
SDLTest_AssertPass("Call to SDL_SetRelativeMouseMode(FALSE)");
SDLTest_AssertCheck(result == 0, "Validate result value from SDL_SetRelativeMouseMode, expected: 0, got: %i", result);
currentState = SDL_GetRelativeMouseMode();
currentState = SDL_GetRelativeMouseMode();
SDLTest_AssertPass("Call to SDL_GetRelativeMouseMode()");
SDLTest_AssertCheck(currentState == SDL_FALSE, "Validate current state is FALSE, got: %i", currentState);
}
/* Repeat twice to check D->E->E transition */
for (i=0; i<2; i++) {
/* Enable - may not be supported */
/* Enable - may not be supported */
result = SDL_SetRelativeMouseMode(SDL_TRUE);
SDLTest_AssertPass("Call to SDL_SetRelativeMouseMode(TRUE)");
if (result != -1) {
SDLTest_AssertCheck(result == 0, "Validate result value from SDL_SetRelativeMouseMode, expected: 0, got: %i", result);
currentState = SDL_GetRelativeMouseMode();
currentState = SDL_GetRelativeMouseMode();
SDLTest_AssertPass("Call to SDL_GetRelativeMouseMode()");
SDLTest_AssertCheck(currentState == SDL_TRUE, "Validate current state is TRUE, got: %i", currentState);
}
}
/* Disable to check E->D transition */
/* Disable to check E->D transition */
result = SDL_SetRelativeMouseMode(SDL_FALSE);
SDLTest_AssertPass("Call to SDL_SetRelativeMouseMode(FALSE)");
SDLTest_AssertCheck(result == 0, "Validate result value from SDL_SetRelativeMouseMode, expected: 0, got: %i", result);
currentState = SDL_GetRelativeMouseMode();
currentState = SDL_GetRelativeMouseMode();
SDLTest_AssertPass("Call to SDL_GetRelativeMouseMode()");
SDLTest_AssertCheck(currentState == SDL_FALSE, "Validate current state is FALSE, got: %i", currentState);
/* Revert to original state - ignore result */
result = SDL_SetRelativeMouseMode(initialState);
return TEST_COMPLETED;
return TEST_COMPLETED;
}
#define MOUSE_TESTWINDOW_WIDTH 320
#define MOUSE_TESTWINDOW_WIDTH 320
#define MOUSE_TESTWINDOW_HEIGHT 200
/**
@@ -426,11 +426,11 @@ SDL_Window *_createMouseSuiteTestWindow()
}
/*
* Destroy test window
* Destroy test window
*/
void _destroyMouseSuiteTestWindow(SDL_Window *window)
{
if (window != NULL) {
if (window != NULL) {
SDL_DestroyWindow(window);
window = NULL;
SDLTest_AssertPass("SDL_DestroyWindow()");
@@ -439,156 +439,156 @@ void _destroyMouseSuiteTestWindow(SDL_Window *window)
/**
* @brief Check call to SDL_WarpMouseInWindow
*
*
* @sa http://wiki.libsdl.org/moin.cgi/SDL_WarpMouseInWindow
*/
int
mouse_warpMouseInWindow(void *arg)
{
const int w = MOUSE_TESTWINDOW_WIDTH, h = MOUSE_TESTWINDOW_HEIGHT;
int numPositions = 6;
int xPositions[] = {-1, 0, 1, w-1, w, w+1 };
int yPositions[] = {-1, 0, 1, h-1, h, h+1 };
int x, y, i, j;
SDL_Window *window;
/* Create test window */
window = _createMouseSuiteTestWindow();
if (window == NULL) return TEST_ABORTED;
const int w = MOUSE_TESTWINDOW_WIDTH, h = MOUSE_TESTWINDOW_HEIGHT;
int numPositions = 6;
int xPositions[] = {-1, 0, 1, w-1, w, w+1 };
int yPositions[] = {-1, 0, 1, h-1, h, h+1 };
int x, y, i, j;
SDL_Window *window;
/* Mouse to random position inside window */
x = SDLTest_RandomIntegerInRange(1, w-1);
y = SDLTest_RandomIntegerInRange(1, h-1);
SDL_WarpMouseInWindow(window, x, y);
SDLTest_AssertPass("SDL_WarpMouseInWindow(...,%i,%i)", x, y);
/* Create test window */
window = _createMouseSuiteTestWindow();
if (window == NULL) return TEST_ABORTED;
/* Mouse to random position inside window */
x = SDLTest_RandomIntegerInRange(1, w-1);
y = SDLTest_RandomIntegerInRange(1, h-1);
SDL_WarpMouseInWindow(window, x, y);
SDLTest_AssertPass("SDL_WarpMouseInWindow(...,%i,%i)", x, y);
/* Same position again */
SDL_WarpMouseInWindow(window, x, y);
SDLTest_AssertPass("SDL_WarpMouseInWindow(...,%i,%i)", x, y);
SDL_WarpMouseInWindow(window, x, y);
SDLTest_AssertPass("SDL_WarpMouseInWindow(...,%i,%i)", x, y);
/* Mouse to various boundary positions */
for (i=0; i<numPositions; i++) {
for (j=0; j<numPositions; j++) {
x = xPositions[i];
y = yPositions[j];
SDL_WarpMouseInWindow(window, x, y);
SDLTest_AssertPass("SDL_WarpMouseInWindow(...,%i,%i)", x, y);
/* Mouse to various boundary positions */
for (i=0; i<numPositions; i++) {
for (j=0; j<numPositions; j++) {
x = xPositions[i];
y = yPositions[j];
SDL_WarpMouseInWindow(window, x, y);
SDLTest_AssertPass("SDL_WarpMouseInWindow(...,%i,%i)", x, y);
/* TODO: add tracking of events and check that each call generates a mouse motion event */
SDL_PumpEvents();
SDLTest_AssertPass("SDL_PumpEvents()");
}
}
/* TODO: add tracking of events and check that each call generates a mouse motion event */
SDL_PumpEvents();
SDLTest_AssertPass("SDL_PumpEvents()");
}
}
/* Clean up test window */
_destroyMouseSuiteTestWindow(window);
return TEST_COMPLETED;
/* Clean up test window */
_destroyMouseSuiteTestWindow(window);
return TEST_COMPLETED;
}
/**
* @brief Check call to SDL_GetMouseFocus
*
*
* @sa http://wiki.libsdl.org/moin.cgi/SDL_GetMouseFocus
*/
int
mouse_getMouseFocus(void *arg)
{
const int w = MOUSE_TESTWINDOW_WIDTH, h = MOUSE_TESTWINDOW_HEIGHT;
int x, y;
SDL_Window *window;
SDL_Window *focusWindow;
const int w = MOUSE_TESTWINDOW_WIDTH, h = MOUSE_TESTWINDOW_HEIGHT;
int x, y;
SDL_Window *window;
SDL_Window *focusWindow;
/* Get focus - focus non-deterministic */
focusWindow = SDL_GetMouseFocus();
SDLTest_AssertPass("SDL_GetMouseFocus()");
/* Get focus - focus non-deterministic */
focusWindow = SDL_GetMouseFocus();
SDLTest_AssertPass("SDL_GetMouseFocus()");
/* Create test window */
window = _createMouseSuiteTestWindow();
if (window == NULL) return TEST_ABORTED;
/* Create test window */
window = _createMouseSuiteTestWindow();
if (window == NULL) return TEST_ABORTED;
/* Mouse to random position inside window */
x = SDLTest_RandomIntegerInRange(1, w-1);
y = SDLTest_RandomIntegerInRange(1, h-1);
SDL_WarpMouseInWindow(window, x, y);
SDLTest_AssertPass("SDL_WarpMouseInWindow(...,%i,%i)", x, y);
/* Mouse to random position inside window */
x = SDLTest_RandomIntegerInRange(1, w-1);
y = SDLTest_RandomIntegerInRange(1, h-1);
SDL_WarpMouseInWindow(window, x, y);
SDLTest_AssertPass("SDL_WarpMouseInWindow(...,%i,%i)", x, y);
/* Pump events to update focus state */
SDL_PumpEvents();
SDLTest_AssertPass("SDL_PumpEvents()");
/* Pump events to update focus state */
SDL_PumpEvents();
SDLTest_AssertPass("SDL_PumpEvents()");
/* Get focus with explicit window setup - focus deterministic */
focusWindow = SDL_GetMouseFocus();
SDLTest_AssertPass("SDL_GetMouseFocus()");
SDLTest_AssertCheck (focusWindow != NULL, "Check returned window value is not NULL");
SDLTest_AssertCheck (focusWindow == window, "Check returned window value is test window");
/* Get focus with explicit window setup - focus deterministic */
focusWindow = SDL_GetMouseFocus();
SDLTest_AssertPass("SDL_GetMouseFocus()");
SDLTest_AssertCheck (focusWindow != NULL, "Check returned window value is not NULL");
SDLTest_AssertCheck (focusWindow == window, "Check returned window value is test window");
/* Mouse to random position outside window */
x = SDLTest_RandomIntegerInRange(-9, -1);
y = SDLTest_RandomIntegerInRange(-9, -1);
SDL_WarpMouseInWindow(window, x, y);
SDLTest_AssertPass("SDL_WarpMouseInWindow(...,%i,%i)", x, y);
/* Mouse to random position outside window */
x = SDLTest_RandomIntegerInRange(-9, -1);
y = SDLTest_RandomIntegerInRange(-9, -1);
SDL_WarpMouseInWindow(window, x, y);
SDLTest_AssertPass("SDL_WarpMouseInWindow(...,%i,%i)", x, y);
/* Clean up test window */
_destroyMouseSuiteTestWindow(window);
/* Clean up test window */
_destroyMouseSuiteTestWindow(window);
/* Pump events to update focus state */
SDL_PumpEvents();
SDLTest_AssertPass("SDL_PumpEvents()");
/* Pump events to update focus state */
SDL_PumpEvents();
SDLTest_AssertPass("SDL_PumpEvents()");
/* Get focus for non-existing window */
focusWindow = SDL_GetMouseFocus();
SDLTest_AssertPass("SDL_GetMouseFocus()");
SDLTest_AssertCheck (focusWindow == NULL, "Check returned window value is NULL");
/* Get focus for non-existing window */
focusWindow = SDL_GetMouseFocus();
SDLTest_AssertPass("SDL_GetMouseFocus()");
SDLTest_AssertCheck (focusWindow == NULL, "Check returned window value is NULL");
return TEST_COMPLETED;
return TEST_COMPLETED;
}
/* ================= Test References ================== */
/* Mouse test cases */
static const SDLTest_TestCaseReference mouseTest1 =
{ (SDLTest_TestCaseFp)mouse_getMouseState, "mouse_getMouseState", "Check call to SDL_GetMouseState", TEST_ENABLED };
{ (SDLTest_TestCaseFp)mouse_getMouseState, "mouse_getMouseState", "Check call to SDL_GetMouseState", TEST_ENABLED };
static const SDLTest_TestCaseReference mouseTest2 =
{ (SDLTest_TestCaseFp)mouse_getRelativeMouseState, "mouse_getRelativeMouseState", "Check call to SDL_GetRelativeMouseState", TEST_ENABLED };
{ (SDLTest_TestCaseFp)mouse_getRelativeMouseState, "mouse_getRelativeMouseState", "Check call to SDL_GetRelativeMouseState", TEST_ENABLED };
static const SDLTest_TestCaseReference mouseTest3 =
{ (SDLTest_TestCaseFp)mouse_createFreeCursor, "mouse_createFreeCursor", "Check call to SDL_CreateCursor and SDL_FreeCursor", TEST_ENABLED };
{ (SDLTest_TestCaseFp)mouse_createFreeCursor, "mouse_createFreeCursor", "Check call to SDL_CreateCursor and SDL_FreeCursor", TEST_ENABLED };
static const SDLTest_TestCaseReference mouseTest4 =
{ (SDLTest_TestCaseFp)mouse_showCursor, "mouse_showCursor", "Check call to SDL_ShowCursor", TEST_ENABLED };
{ (SDLTest_TestCaseFp)mouse_showCursor, "mouse_showCursor", "Check call to SDL_ShowCursor", TEST_ENABLED };
static const SDLTest_TestCaseReference mouseTest5 =
{ (SDLTest_TestCaseFp)mouse_setCursor, "mouse_setCursor", "Check call to SDL_SetCursor", TEST_ENABLED };
{ (SDLTest_TestCaseFp)mouse_setCursor, "mouse_setCursor", "Check call to SDL_SetCursor", TEST_ENABLED };
static const SDLTest_TestCaseReference mouseTest6 =
{ (SDLTest_TestCaseFp)mouse_getCursor, "mouse_getCursor", "Check call to SDL_GetCursor", TEST_ENABLED };
{ (SDLTest_TestCaseFp)mouse_getCursor, "mouse_getCursor", "Check call to SDL_GetCursor", TEST_ENABLED };
static const SDLTest_TestCaseReference mouseTest7 =
{ (SDLTest_TestCaseFp)mouse_warpMouseInWindow, "mouse_warpMouseInWindow", "Check call to SDL_WarpMouseInWindow", TEST_ENABLED };
{ (SDLTest_TestCaseFp)mouse_warpMouseInWindow, "mouse_warpMouseInWindow", "Check call to SDL_WarpMouseInWindow", TEST_ENABLED };
static const SDLTest_TestCaseReference mouseTest8 =
{ (SDLTest_TestCaseFp)mouse_getMouseFocus, "mouse_getMouseFocus", "Check call to SDL_getMouseFocus", TEST_ENABLED };
{ (SDLTest_TestCaseFp)mouse_getMouseFocus, "mouse_getMouseFocus", "Check call to SDL_getMouseFocus", TEST_ENABLED };
static const SDLTest_TestCaseReference mouseTest9 =
{ (SDLTest_TestCaseFp)mouse_createFreeColorCursor, "mouse_createFreeColorCursor", "Check call to SDL_CreateColorCursor and SDL_FreeCursor", TEST_ENABLED };
{ (SDLTest_TestCaseFp)mouse_createFreeColorCursor, "mouse_createFreeColorCursor", "Check call to SDL_CreateColorCursor and SDL_FreeCursor", TEST_ENABLED };
static const SDLTest_TestCaseReference mouseTest10 =
{ (SDLTest_TestCaseFp)mouse_getSetRelativeMouseMode, "mouse_getSetRelativeMouseMode", "Check call to SDL_GetRelativeMouseMode and SDL_SetRelativeMouseMode", TEST_ENABLED };
{ (SDLTest_TestCaseFp)mouse_getSetRelativeMouseMode, "mouse_getSetRelativeMouseMode", "Check call to SDL_GetRelativeMouseMode and SDL_SetRelativeMouseMode", TEST_ENABLED };
/* Sequence of Mouse test cases */
static const SDLTest_TestCaseReference *mouseTests[] = {
&mouseTest1, &mouseTest2, &mouseTest3, &mouseTest4, &mouseTest5, &mouseTest6,
&mouseTest7, &mouseTest8, &mouseTest9, &mouseTest10, NULL
&mouseTest1, &mouseTest2, &mouseTest3, &mouseTest4, &mouseTest5, &mouseTest6,
&mouseTest7, &mouseTest8, &mouseTest9, &mouseTest10, NULL
};
/* Mouse test suite (global) */
SDLTest_TestSuiteReference mouseTestSuite = {
"Mouse",
NULL,
mouseTests,
NULL
"Mouse",
NULL,
mouseTests,
NULL
};

View File

@@ -11,7 +11,7 @@
/* Definition of all RGB formats used to test pixel conversions */
const int _numRGBPixelFormats = 30;
Uint32 _RGBPixelFormats[] =
Uint32 _RGBPixelFormats[] =
{
SDL_PIXELFORMAT_INDEX1LSB,
SDL_PIXELFORMAT_INDEX1MSB,
@@ -44,7 +44,7 @@ Uint32 _RGBPixelFormats[] =
SDL_PIXELFORMAT_BGRA8888,
SDL_PIXELFORMAT_ARGB2101010
};
char* _RGBPixelFormatsVerbose[] =
char* _RGBPixelFormatsVerbose[] =
{
"SDL_PIXELFORMAT_INDEX1LSB",
"SDL_PIXELFORMAT_INDEX1MSB",
@@ -80,31 +80,31 @@ char* _RGBPixelFormatsVerbose[] =
/* Definition of all Non-RGB formats used to test pixel conversions */
const int _numNonRGBPixelFormats = 5;
Uint32 _nonRGBPixelFormats[] =
Uint32 _nonRGBPixelFormats[] =
{
SDL_PIXELFORMAT_YV12,
SDL_PIXELFORMAT_IYUV,
SDL_PIXELFORMAT_YUY2,
SDL_PIXELFORMAT_UYVY,
SDL_PIXELFORMAT_YVYU
SDL_PIXELFORMAT_YVYU
};
char* _nonRGBPixelFormatsVerbose[] =
char* _nonRGBPixelFormatsVerbose[] =
{
"SDL_PIXELFORMAT_YV12",
"SDL_PIXELFORMAT_IYUV",
"SDL_PIXELFORMAT_YUY2",
"SDL_PIXELFORMAT_UYVY",
"SDL_PIXELFORMAT_YVYU"
"SDL_PIXELFORMAT_YVYU"
};
/* Definition of some invalid formats for negative tests */
const int _numInvalidPixelFormats = 2;
Uint32 _invalidPixelFormats[] =
Uint32 _invalidPixelFormats[] =
{
0xfffffffe,
0xffffffff
};
char* _invalidPixelFormatsVerbose[] =
char* _invalidPixelFormatsVerbose[] =
{
"SDL_PIXELFORMAT_UNKNOWN",
"SDL_PIXELFORMAT_UNKNOWN"
@@ -116,14 +116,14 @@ char* _invalidPixelFormatsVerbose[] =
* @brief Call to SDL_AllocFormat and SDL_FreeFormat
*
* @sa http://wiki.libsdl.org/moin.fcg/SDL_AllocFormat
* @sa http://wiki.libsdl.org/moin.fcg/SDL_FreeFormat
* @sa http://wiki.libsdl.org/moin.fcg/SDL_FreeFormat
*/
int
pixels_allocFreeFormat(void *arg)
{
const char *unknownFormat = "SDL_PIXELFORMAT_UNKNOWN";
const char *expectedError = "Parameter 'format' is invalid";
const char *error;
const char *error;
int i;
Uint32 format;
Uint32 masks;
@@ -132,44 +132,44 @@ pixels_allocFreeFormat(void *arg)
/* Blank/unknown format */
format = 0;
SDLTest_Log("RGB Format: %s (%u)", unknownFormat, format);
/* Allocate format */
result = SDL_AllocFormat(format);
SDLTest_AssertPass("Call to SDL_AllocFormat()");
SDLTest_AssertCheck(result != NULL, "Verify result is not NULL");
SDLTest_AssertCheck(result != NULL, "Verify result is not NULL");
if (result != NULL) {
SDLTest_AssertCheck(result->format == format, "Verify value of result.format; expected: %u, got %u", format, result->format);
SDLTest_AssertCheck(result->BitsPerPixel == 0, "Verify value of result.BitsPerPixel; expected: 0, got %u", result->BitsPerPixel);
SDLTest_AssertCheck(result->BytesPerPixel == 0, "Verify value of result.BytesPerPixel; expected: 0, got %u", result->BytesPerPixel);
SDLTest_AssertCheck(result->format == format, "Verify value of result.format; expected: %u, got %u", format, result->format);
SDLTest_AssertCheck(result->BitsPerPixel == 0, "Verify value of result.BitsPerPixel; expected: 0, got %u", result->BitsPerPixel);
SDLTest_AssertCheck(result->BytesPerPixel == 0, "Verify value of result.BytesPerPixel; expected: 0, got %u", result->BytesPerPixel);
masks = result->Rmask | result->Gmask | result->Bmask | result->Amask;
SDLTest_AssertCheck(masks == 0, "Verify value of result.[RGBA]mask combined; expected: 0, got %u", masks);
/* Deallocate again */
SDL_FreeFormat(result);
SDLTest_AssertPass("Call to SDL_FreeFormat()");
SDLTest_AssertPass("Call to SDL_FreeFormat()");
}
/* RGB formats */
for (i = 0; i < _numRGBPixelFormats; i++) {
format = _RGBPixelFormats[i];
SDLTest_Log("RGB Format: %s (%u)", _RGBPixelFormatsVerbose[i], format);
/* Allocate format */
result = SDL_AllocFormat(format);
SDLTest_AssertPass("Call to SDL_AllocFormat()");
SDLTest_AssertCheck(result != NULL, "Verify result is not NULL");
SDLTest_AssertCheck(result != NULL, "Verify result is not NULL");
if (result != NULL) {
SDLTest_AssertCheck(result->format == format, "Verify value of result.format; expected: %u, got %u", format, result->format);
SDLTest_AssertCheck(result->BitsPerPixel > 0, "Verify value of result.BitsPerPixel; expected: >0, got %u", result->BitsPerPixel);
SDLTest_AssertCheck(result->BytesPerPixel > 0, "Verify value of result.BytesPerPixel; expected: >0, got %u", result->BytesPerPixel);
if (result->palette != NULL) {
SDLTest_AssertCheck(result->format == format, "Verify value of result.format; expected: %u, got %u", format, result->format);
SDLTest_AssertCheck(result->BitsPerPixel > 0, "Verify value of result.BitsPerPixel; expected: >0, got %u", result->BitsPerPixel);
SDLTest_AssertCheck(result->BytesPerPixel > 0, "Verify value of result.BytesPerPixel; expected: >0, got %u", result->BytesPerPixel);
if (result->palette != NULL) {
masks = result->Rmask | result->Gmask | result->Bmask | result->Amask;
SDLTest_AssertCheck(masks > 0, "Verify value of result.[RGBA]mask combined; expected: >0, got %u", masks);
}
/* Deallocate again */
SDL_FreeFormat(result);
SDLTest_AssertPass("Call to SDL_FreeFormat()");
SDLTest_AssertPass("Call to SDL_FreeFormat()");
}
}
@@ -177,28 +177,28 @@ pixels_allocFreeFormat(void *arg)
for (i = 0; i < _numNonRGBPixelFormats; i++) {
format = _nonRGBPixelFormats[i];
SDLTest_Log("non-RGB Format: %s (%u)", _nonRGBPixelFormatsVerbose[i], format);
/* Try to allocate format */
result = SDL_AllocFormat(format);
SDLTest_AssertPass("Call to SDL_AllocFormat()");
SDLTest_AssertCheck(result == NULL, "Verify result is NULL");
SDLTest_AssertCheck(result == NULL, "Verify result is NULL");
}
/* Negative cases */
/* Invalid Formats */
/* Invalid Formats */
for (i = 0; i < _numInvalidPixelFormats; i++) {
SDL_ClearError();
SDLTest_AssertPass("Call to SDL_ClearError()");
format = _invalidPixelFormats[i];
result = SDL_AllocFormat(format);
SDLTest_AssertPass("Call to SDL_AllocFormat(%u)", format);
SDLTest_AssertCheck(result == NULL, "Verify result is NULL");
SDLTest_AssertCheck(result == NULL, "Verify result is NULL");
error = SDL_GetError();
SDLTest_AssertPass("Call to SDL_GetError()");
SDLTest_AssertCheck(error != NULL, "Validate that error message was not NULL");
if (error != NULL) {
SDLTest_AssertCheck(SDL_strcmp(error, expectedError) == 0,
SDLTest_AssertCheck(SDL_strcmp(error, expectedError) == 0,
"Validate error message, expected: '%s', got: '%s'", expectedError, error);
}
}
@@ -212,10 +212,10 @@ pixels_allocFreeFormat(void *arg)
SDLTest_AssertPass("Call to SDL_GetError()");
SDLTest_AssertCheck(error != NULL, "Validate that error message was not NULL");
if (error != NULL) {
SDLTest_AssertCheck(SDL_strcmp(error, expectedError) == 0,
SDLTest_AssertCheck(SDL_strcmp(error, expectedError) == 0,
"Validate error message, expected: '%s', got: '%s'", expectedError, error);
}
return TEST_COMPLETED;
}
@@ -228,7 +228,7 @@ int
pixels_getPixelFormatName(void *arg)
{
const char *unknownFormat = "SDL_PIXELFORMAT_UNKNOWN";
const char *error;
const char *error;
int i;
Uint32 format;
char* result;
@@ -236,14 +236,14 @@ pixels_getPixelFormatName(void *arg)
/* Blank/undefined format */
format = 0;
SDLTest_Log("RGB Format: %s (%u)", unknownFormat, format);
/* Get name of format */
result = (char *)SDL_GetPixelFormatName(format);
SDLTest_AssertPass("Call to SDL_GetPixelFormatName()");
SDLTest_AssertCheck(result != NULL, "Verify result is not NULL");
SDLTest_AssertCheck(result != NULL, "Verify result is not NULL");
if (result != NULL) {
SDLTest_AssertCheck(SDL_strlen(result) > 0, "Verify result is non-empty");
SDLTest_AssertCheck(SDL_strcmp(result, unknownFormat) == 0,
SDLTest_AssertCheck(SDL_strcmp(result, unknownFormat) == 0,
"Verify result text; expected: %s, got %s", unknownFormat, result);
}
@@ -251,14 +251,14 @@ pixels_getPixelFormatName(void *arg)
for (i = 0; i < _numRGBPixelFormats; i++) {
format = _RGBPixelFormats[i];
SDLTest_Log("RGB Format: %s (%u)", _RGBPixelFormatsVerbose[i], format);
/* Get name of format */
result = (char *)SDL_GetPixelFormatName(format);
SDLTest_AssertPass("Call to SDL_GetPixelFormatName()");
SDLTest_AssertCheck(result != NULL, "Verify result is not NULL");
SDLTest_AssertCheck(result != NULL, "Verify result is not NULL");
if (result != NULL) {
SDLTest_AssertCheck(SDL_strlen(result) > 0, "Verify result is non-empty");
SDLTest_AssertCheck(SDL_strcmp(result, _RGBPixelFormatsVerbose[i]) == 0,
SDLTest_AssertCheck(SDL_strcmp(result, _RGBPixelFormatsVerbose[i]) == 0,
"Verify result text; expected: %s, got %s", _RGBPixelFormatsVerbose[i], result);
}
}
@@ -267,30 +267,30 @@ pixels_getPixelFormatName(void *arg)
for (i = 0; i < _numNonRGBPixelFormats; i++) {
format = _nonRGBPixelFormats[i];
SDLTest_Log("non-RGB Format: %s (%u)", _nonRGBPixelFormatsVerbose[i], format);
/* Get name of format */
result = (char *)SDL_GetPixelFormatName(format);
SDLTest_AssertPass("Call to SDL_GetPixelFormatName()");
SDLTest_AssertCheck(result != NULL, "Verify result is not NULL");
SDLTest_AssertCheck(result != NULL, "Verify result is not NULL");
if (result != NULL) {
SDLTest_AssertCheck(SDL_strlen(result) > 0, "Verify result is non-empty");
SDLTest_AssertCheck(SDL_strcmp(result, _nonRGBPixelFormatsVerbose[i]) == 0,
SDLTest_AssertCheck(SDL_strcmp(result, _nonRGBPixelFormatsVerbose[i]) == 0,
"Verify result text; expected: %s, got %s", _nonRGBPixelFormatsVerbose[i], result);
}
}
/* Negative cases */
/* Invalid Formats */
/* Invalid Formats */
SDL_ClearError();
SDLTest_AssertPass("Call to SDL_ClearError()");
for (i = 0; i < _numInvalidPixelFormats; i++) {
format = _invalidPixelFormats[i];
result = (char *)SDL_GetPixelFormatName(format);
SDLTest_AssertPass("Call to SDL_GetPixelFormatName(%u)", format);
SDLTest_AssertCheck(result != NULL, "Verify result is not NULL");
SDLTest_AssertCheck(result != NULL, "Verify result is not NULL");
if (result != NULL) {
SDLTest_AssertCheck(SDL_strlen(result) > 0,
SDLTest_AssertCheck(SDL_strlen(result) > 0,
"Verify result is non-empty; got: %s", result);
SDLTest_AssertCheck(SDL_strcmp(result, _invalidPixelFormatsVerbose[i]) == 0,
"Validate name is UNKNOWN, expected: '%s', got: '%s'", _invalidPixelFormatsVerbose[i], result);
@@ -314,14 +314,14 @@ pixels_allocFreePalette(void *arg)
{
const char *expectedError1 = "Parameter 'ncolors' is invalid";
const char *expectedError2 = "Parameter 'palette' is invalid";
const char *error;
const char *error;
int variation;
int i;
int ncolors;
SDL_Palette* result;
/* Allocate palette */
for (variation = 1; variation <= 3; variation++) {
for (variation = 1; variation <= 3; variation++) {
switch (variation) {
/* Just one color */
case 1:
@@ -339,28 +339,28 @@ pixels_allocFreePalette(void *arg)
result = SDL_AllocPalette(ncolors);
SDLTest_AssertPass("Call to SDL_AllocPalette(%d)", ncolors);
SDLTest_AssertCheck(result != NULL, "Verify result is not NULL");
SDLTest_AssertCheck(result != NULL, "Verify result is not NULL");
if (result != NULL) {
SDLTest_AssertCheck(result->ncolors == ncolors, "Verify value of result.ncolors; expected: %u, got %u", ncolors, result->ncolors);
SDLTest_AssertCheck(result->ncolors == ncolors, "Verify value of result.ncolors; expected: %u, got %u", ncolors, result->ncolors);
if (result->ncolors > 0) {
SDLTest_AssertCheck(result->colors != NULL, "Verify value of result.colors is not NULL");
if (result->colors != NULL) {
for(i = 0; i < result->ncolors; i++) {
SDLTest_AssertCheck(result->colors[i].r == 255, "Verify value of result.colors[%d].r; expected: 255, got %u", i, result->colors[i].r);
SDLTest_AssertCheck(result->colors[i].g == 255, "Verify value of result.colors[%d].g; expected: 255, got %u", i, result->colors[i].g);
SDLTest_AssertCheck(result->colors[i].b == 255, "Verify value of result.colors[%d].b; expected: 255, got %u", i, result->colors[i].b);
SDLTest_AssertCheck(result->colors[i].r == 255, "Verify value of result.colors[%d].r; expected: 255, got %u", i, result->colors[i].r);
SDLTest_AssertCheck(result->colors[i].g == 255, "Verify value of result.colors[%d].g; expected: 255, got %u", i, result->colors[i].g);
SDLTest_AssertCheck(result->colors[i].b == 255, "Verify value of result.colors[%d].b; expected: 255, got %u", i, result->colors[i].b);
}
}
}
}
/* Deallocate again */
SDL_FreePalette(result);
SDLTest_AssertPass("Call to SDL_FreePalette()");
SDLTest_AssertPass("Call to SDL_FreePalette()");
}
}
/* Negative cases */
/* Invalid number of colors */
for (ncolors = 0; ncolors > -3; ncolors--) {
SDL_ClearError();
@@ -372,7 +372,7 @@ pixels_allocFreePalette(void *arg)
SDLTest_AssertPass("Call to SDL_GetError()");
SDLTest_AssertCheck(error != NULL, "Validate that error message was not NULL");
if (error != NULL) {
SDLTest_AssertCheck(SDL_strcmp(error, expectedError1) == 0,
SDLTest_AssertCheck(SDL_strcmp(error, expectedError1) == 0,
"Validate error message, expected: '%s', got: '%s'", expectedError1, error);
}
}
@@ -386,10 +386,10 @@ pixels_allocFreePalette(void *arg)
SDLTest_AssertPass("Call to SDL_GetError()");
SDLTest_AssertCheck(error != NULL, "Validate that error message was not NULL");
if (error != NULL) {
SDLTest_AssertCheck(SDL_strcmp(error, expectedError2) == 0,
SDLTest_AssertCheck(SDL_strcmp(error, expectedError2) == 0,
"Validate error message, expected: '%s', got: '%s'", expectedError2, error);
}
return TEST_COMPLETED;
}
@@ -403,7 +403,7 @@ pixels_calcGammaRamp(void *arg)
{
const char *expectedError1 = "Parameter 'gamma' is invalid";
const char *expectedError2 = "Parameter 'ramp' is invalid";
const char *error;
const char *error;
float gamma;
Uint16 *ramp;
int variation;
@@ -415,29 +415,29 @@ pixels_calcGammaRamp(void *arg)
ramp = (Uint16 *)SDL_malloc(256 * sizeof(Uint16));
SDLTest_AssertCheck(ramp != NULL, "Validate temp ramp array could be allocated");
if (ramp == NULL) return TEST_ABORTED;
/* Make call with different gamma values */
for (variation = 0; variation < 4; variation++) {
switch (variation) {
/* gamma = 0 all black */
case 0:
case 0:
gamma = 0.0f;
break;
/* gamma = 1 identity */
case 1:
gamma = 1.0f;
break;
/* gamma = [0.2,0.8] normal range */
/* gamma = [0.2,0.8] normal range */
case 2:
gamma = 0.2f + 0.8f * SDLTest_RandomUnitFloat();
break;
/* gamma = >1.1 non-standard range */
/* gamma = >1.1 non-standard range */
case 3:
gamma = 1.1f + SDLTest_RandomUnitFloat();
break;
}
/* Make call and check that values were updated */
/* Make call and check that values were updated */
for (i = 0; i < 256; i++) ramp[i] = magic;
SDL_CalculateGammaRamp(gamma, ramp);
SDLTest_AssertPass("Call to SDL_CalculateGammaRamp(%f)", gamma);
@@ -460,7 +460,7 @@ pixels_calcGammaRamp(void *arg)
break;
}
}
/* Negative cases */
SDL_ClearError();
SDLTest_AssertPass("Call to SDL_ClearError()");
@@ -472,7 +472,7 @@ pixels_calcGammaRamp(void *arg)
SDLTest_AssertPass("Call to SDL_GetError()");
SDLTest_AssertCheck(error != NULL, "Validate that error message was not NULL");
if (error != NULL) {
SDLTest_AssertCheck(SDL_strcmp(error, expectedError1) == 0,
SDLTest_AssertCheck(SDL_strcmp(error, expectedError1) == 0,
"Validate error message, expected: '%s', got: '%s'", expectedError1, error);
}
changed = 0;
@@ -485,14 +485,14 @@ pixels_calcGammaRamp(void *arg)
SDLTest_AssertPass("Call to SDL_GetError()");
SDLTest_AssertCheck(error != NULL, "Validate that error message was not NULL");
if (error != NULL) {
SDLTest_AssertCheck(SDL_strcmp(error, expectedError2) == 0,
SDLTest_AssertCheck(SDL_strcmp(error, expectedError2) == 0,
"Validate error message, expected: '%s', got: '%s'", expectedError2, error);
}
/* Cleanup */
SDL_free(ramp);
return TEST_COMPLETED;
}
@@ -500,26 +500,26 @@ pixels_calcGammaRamp(void *arg)
/* Pixels test cases */
static const SDLTest_TestCaseReference pixelsTest1 =
{ (SDLTest_TestCaseFp)pixels_allocFreeFormat, "pixels_allocFreeFormat", "Call to SDL_AllocFormat and SDL_FreeFormat", TEST_ENABLED };
{ (SDLTest_TestCaseFp)pixels_allocFreeFormat, "pixels_allocFreeFormat", "Call to SDL_AllocFormat and SDL_FreeFormat", TEST_ENABLED };
static const SDLTest_TestCaseReference pixelsTest2 =
{ (SDLTest_TestCaseFp)pixels_allocFreePalette, "pixels_allocFreePalette", "Call to SDL_AllocPalette and SDL_FreePalette", TEST_ENABLED };
{ (SDLTest_TestCaseFp)pixels_allocFreePalette, "pixels_allocFreePalette", "Call to SDL_AllocPalette and SDL_FreePalette", TEST_ENABLED };
static const SDLTest_TestCaseReference pixelsTest3 =
{ (SDLTest_TestCaseFp)pixels_calcGammaRamp, "pixels_calcGammaRamp", "Call to SDL_CalculateGammaRamp", TEST_ENABLED };
{ (SDLTest_TestCaseFp)pixels_calcGammaRamp, "pixels_calcGammaRamp", "Call to SDL_CalculateGammaRamp", TEST_ENABLED };
static const SDLTest_TestCaseReference pixelsTest4 =
{ (SDLTest_TestCaseFp)pixels_getPixelFormatName, "pixels_getPixelFormatName", "Call to SDL_GetPixelFormatName", TEST_ENABLED };
{ (SDLTest_TestCaseFp)pixels_getPixelFormatName, "pixels_getPixelFormatName", "Call to SDL_GetPixelFormatName", TEST_ENABLED };
/* Sequence of Pixels test cases */
static const SDLTest_TestCaseReference *pixelsTests[] = {
&pixelsTest1, &pixelsTest2, &pixelsTest3, &pixelsTest4, NULL
&pixelsTest1, &pixelsTest2, &pixelsTest3, &pixelsTest4, NULL
};
/* Pixels test suite (global) */
SDLTest_TestSuiteReference pixelsTestSuite = {
"Pixels",
NULL,
pixelsTests,
NULL
"Pixels",
NULL,
pixelsTests,
NULL
};

View File

@@ -504,58 +504,58 @@ int platform_testGetPowerInfo(void *arg)
/* Platform test cases */
static const SDLTest_TestCaseReference platformTest1 =
{ (SDLTest_TestCaseFp)platform_testTypes, "platform_testTypes", "Tests predefined types", TEST_ENABLED};
{ (SDLTest_TestCaseFp)platform_testTypes, "platform_testTypes", "Tests predefined types", TEST_ENABLED};
static const SDLTest_TestCaseReference platformTest2 =
{ (SDLTest_TestCaseFp)platform_testEndianessAndSwap, "platform_testEndianessAndSwap", "Tests endianess and swap functions", TEST_ENABLED};
{ (SDLTest_TestCaseFp)platform_testEndianessAndSwap, "platform_testEndianessAndSwap", "Tests endianess and swap functions", TEST_ENABLED};
static const SDLTest_TestCaseReference platformTest3 =
{ (SDLTest_TestCaseFp)platform_testGetFunctions, "platform_testGetFunctions", "Tests various SDL_GetXYZ functions", TEST_ENABLED};
{ (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};
{ (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};
{ (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};
{ (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};
{ (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};
{ (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};
{ (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};
{ (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 };
{ (SDLTest_TestCaseFp)platform_testGetPowerInfo, "platform_testGetPowerInfo", "Tests SDL_GetPowerInfo function", TEST_ENABLED };
/* Sequence of Platform test cases */
static const SDLTest_TestCaseReference *platformTests[] = {
&platformTest1,
&platformTest2,
&platformTest3,
&platformTest4,
&platformTest5,
&platformTest6,
&platformTest7,
&platformTest8,
&platformTest9,
&platformTest10,
&platformTest11,
NULL
&platformTest1,
&platformTest2,
&platformTest3,
&platformTest4,
&platformTest5,
&platformTest6,
&platformTest7,
&platformTest8,
&platformTest9,
&platformTest10,
&platformTest11,
NULL
};
/* Platform test suite (global) */
SDLTest_TestSuiteReference platformTestSuite = {
"Platform",
NULL,
platformTests,
NULL
"Platform",
NULL,
platformTests,
NULL
};

View File

@@ -21,7 +21,7 @@ void _validateIntersectRectAndLineResults(
int x1, int y1, int x2, int y2,
int x1Ref, int y1Ref, int x2Ref, int y2Ref)
{
SDLTest_AssertCheck(intersection == expectedIntersection,
SDLTest_AssertCheck(intersection == expectedIntersection,
"Check for correct intersection result: expected %s, got %s intersecting rect (%d,%d,%d,%d) with line (%d,%d - %d,%d)",
(expectedIntersection == SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE",
(intersection == SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE",
@@ -45,7 +45,7 @@ void _validateIntersectRectAndLineResults(
* \sa
* http://wiki.libsdl.org/moin.cgi/SDL_IntersectRectAndLine
*/
int
int
rect_testIntersectRectAndLine (void *arg)
{
SDL_Rect refRect = { 0, 0, 32, 32 };
@@ -107,7 +107,7 @@ rect_testIntersectRectAndLine (void *arg)
intersected = SDL_IntersectRectAndLine(&rect, &x1, &y1, &x2, &y2);
_validateIntersectRectAndLineResults(intersected, SDL_TRUE, &rect, &refRect, x1, y1, x2, y2, 31, 0, 0, 31);
return TEST_COMPLETED;
return TEST_COMPLETED;
}
/*!
@@ -116,7 +116,7 @@ rect_testIntersectRectAndLine (void *arg)
* \sa
* http://wiki.libsdl.org/moin.cgi/SDL_IntersectRectAndLine
*/
int
int
rect_testIntersectRectAndLineInside (void *arg)
{
SDL_Rect refRect = { 0, 0, 32, 32 };
@@ -174,7 +174,7 @@ rect_testIntersectRectAndLineInside (void *arg)
intersected = SDL_IntersectRectAndLine(&rect, &x1, &y1, &x2, &y2);
_validateIntersectRectAndLineResults(intersected, SDL_TRUE, &rect, &refRect, x1, y1, x2, y2, xmin, ymax, xmax, ymin);
return TEST_COMPLETED;
return TEST_COMPLETED;
}
/*!
@@ -183,7 +183,7 @@ rect_testIntersectRectAndLineInside (void *arg)
* \sa
* http://wiki.libsdl.org/moin.cgi/SDL_IntersectRectAndLine
*/
int
int
rect_testIntersectRectAndLineOutside (void *arg)
{
SDL_Rect refRect = { 0, 0, 32, 32 };
@@ -229,7 +229,7 @@ rect_testIntersectRectAndLineOutside (void *arg)
intersected = SDL_IntersectRectAndLine(&rect, &x1, &y1, &x2, &y2);
_validateIntersectRectAndLineResults(intersected, SDL_FALSE, &rect, &refRect, x1, y1, x2, y2, 0, yBottom, 31, yBottom);
return TEST_COMPLETED;
return TEST_COMPLETED;
}
/*!
@@ -238,7 +238,7 @@ rect_testIntersectRectAndLineOutside (void *arg)
* \sa
* http://wiki.libsdl.org/moin.cgi/SDL_IntersectRectAndLine
*/
int
int
rect_testIntersectRectAndLineEmpty (void *arg)
{
SDL_Rect refRect;
@@ -246,7 +246,7 @@ rect_testIntersectRectAndLineEmpty (void *arg)
int x1, y1, x1Ref, y1Ref;
int x2, y2, x2Ref, y2Ref;
SDL_bool intersected;
refRect.x = SDLTest_RandomIntegerInRange(1, 1024);
refRect.y = SDLTest_RandomIntegerInRange(1, 1024);
refRect.w = 0;
@@ -264,7 +264,7 @@ rect_testIntersectRectAndLineEmpty (void *arg)
intersected = SDL_IntersectRectAndLine(&rect, &x1, &y1, &x2, &y2);
_validateIntersectRectAndLineResults(intersected, SDL_FALSE, &rect, &refRect, x1, y1, x2, y2, x1Ref, y1Ref, x2Ref, y2Ref);
return TEST_COMPLETED;
return TEST_COMPLETED;
}
/*!
@@ -273,7 +273,7 @@ rect_testIntersectRectAndLineEmpty (void *arg)
* \sa
* http://wiki.libsdl.org/moin.cgi/SDL_IntersectRectAndLine
*/
int
int
rect_testIntersectRectAndLineParam (void *arg)
{
SDL_Rect rect = { 0, 0, 32, 32 };
@@ -282,10 +282,10 @@ rect_testIntersectRectAndLineParam (void *arg)
int x2 = x1;
int y2 = 2 * rect.h;
SDL_bool intersected;
intersected = SDL_IntersectRectAndLine(&rect, &x1, &y1, &x2, &y2);
SDLTest_AssertCheck(intersected == SDL_TRUE, "Check that intersection result was SDL_TRUE");
intersected = SDL_IntersectRectAndLine((SDL_Rect *)NULL, &x1, &y1, &x2, &y2);
SDLTest_AssertCheck(intersected == SDL_FALSE, "Check that function returns SDL_FALSE when 1st parameter is NULL");
intersected = SDL_IntersectRectAndLine(&rect, (int *)NULL, &y1, &x2, &y2);
@@ -299,21 +299,21 @@ rect_testIntersectRectAndLineParam (void *arg)
intersected = SDL_IntersectRectAndLine((SDL_Rect *)NULL, (int *)NULL, (int *)NULL, (int *)NULL, (int *)NULL);
SDLTest_AssertCheck(intersected == SDL_FALSE, "Check that function returns SDL_FALSE when all parameters are NULL");
return TEST_COMPLETED;
return TEST_COMPLETED;
}
/*!
* \brief Private helper to check SDL_HasIntersection results
*/
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)
{
SDLTest_AssertCheck(intersection == expectedIntersection,
SDLTest_AssertCheck(intersection == expectedIntersection,
"Check intersection result: expected %s, got %s intersecting A (%d,%d,%d,%d) with B (%d,%d,%d,%d)",
(expectedIntersection == SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE",
(intersection == SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE",
rectA->x, rectA->y, rectA->w, rectA->h,
rectA->x, rectA->y, rectA->w, rectA->h,
rectB->x, rectB->y, rectB->w, rectB->h);
SDLTest_AssertCheck(rectA->x == refRectA->x && rectA->y == refRectA->y && rectA->w == refRectA->w && rectA->h == refRectA->h,
"Check that source rectangle A was not modified: got (%d,%d,%d,%d) expected (%d,%d,%d,%d)",
@@ -329,15 +329,15 @@ void _validateHasIntersectionResults(
* \brief Private helper to check SDL_IntersectRect results
*/
void _validateIntersectRectResults(
SDL_bool intersection, SDL_bool expectedIntersection,
SDL_Rect *rectA, SDL_Rect *rectB, SDL_Rect *refRectA, SDL_Rect *refRectB,
SDL_bool intersection, SDL_bool expectedIntersection,
SDL_Rect *rectA, SDL_Rect *rectB, SDL_Rect *refRectA, SDL_Rect *refRectB,
SDL_Rect *result, SDL_Rect *expectedResult)
{
_validateHasIntersectionResults(intersection, expectedIntersection, rectA, rectB, refRectA, refRectB);
if (result && expectedResult) {
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)",
rectA->x, rectA->y, rectA->w, rectA->h,
rectA->x, rectA->y, rectA->w, rectA->h,
rectB->x, rectB->y, rectB->w, rectB->h,
result->x, result->y, result->w, result->h,
expectedResult->x, expectedResult->y, expectedResult->w, expectedResult->h);
@@ -348,7 +348,7 @@ void _validateIntersectRectResults(
* \brief Private helper to check SDL_UnionRect results
*/
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)
{
SDLTest_AssertCheck(rectA->x == refRectA->x && rectA->y == refRectA->y && rectA->w == refRectA->w && rectA->h == refRectA->h,
@@ -361,7 +361,7 @@ void _validateUnionRectResults(
refRectB->x, refRectB->y, refRectB->w, refRectB->h);
SDLTest_AssertCheck(result->x == expectedResult->x && result->y == expectedResult->y && result->w == expectedResult->w && result->h == expectedResult->h,
"Check that union 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)",
rectA->x, rectA->y, rectA->w, rectA->h,
rectA->x, rectA->y, rectA->w, rectA->h,
rectB->x, rectB->y, rectB->w, rectB->h,
result->x, result->y, result->w, result->h,
expectedResult->x, expectedResult->y, expectedResult->w, expectedResult->h);
@@ -371,10 +371,10 @@ void _validateUnionRectResults(
* \brief Private helper to check SDL_RectEmpty results
*/
void _validateRectEmptyResults(
SDL_bool empty, SDL_bool expectedEmpty,
SDL_bool empty, SDL_bool expectedEmpty,
SDL_Rect *rect, SDL_Rect *refRect)
{
SDLTest_AssertCheck(empty == expectedEmpty,
SDLTest_AssertCheck(empty == expectedEmpty,
"Check for correct empty result: expected %s, got %s testing (%d,%d,%d,%d)",
(expectedEmpty == SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE",
(empty == SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE",
@@ -389,10 +389,10 @@ void _validateRectEmptyResults(
* \brief Private helper to check SDL_RectEquals results
*/
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)
{
SDLTest_AssertCheck(equals == expectedEquals,
SDLTest_AssertCheck(equals == expectedEquals,
"Check for correct equals result: expected %s, got %s testing (%d,%d,%d,%d) and (%d,%d,%d,%d)",
(expectedEquals == SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE",
(equals == SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE",
@@ -433,7 +433,7 @@ int rect_testIntersectRectInside (void *arg)
intersection = SDL_IntersectRect(&rectA, &rectB, &result);
_validateIntersectRectResults(intersection, SDL_TRUE, &rectA, &rectB, &refRectA, &refRectB, &result, &refRectB);
return TEST_COMPLETED;
return TEST_COMPLETED;
}
/*!
@@ -459,9 +459,9 @@ int rect_testIntersectRectOutside (void *arg)
rectA = refRectA;
rectB = refRectB;
intersection = SDL_IntersectRect(&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;
}
/*!
@@ -490,7 +490,7 @@ int rect_testIntersectRectPartial (void *arg)
expectedResult.x = refRectB.x;
expectedResult.y = refRectB.y;
expectedResult.w = refRectA.w - refRectB.x;
expectedResult.h = refRectA.h - refRectB.y;
expectedResult.h = refRectA.h - refRectB.y;
intersection = SDL_IntersectRect(&rectA, &rectB, &result);
_validateIntersectRectResults(intersection, SDL_TRUE, &rectA, &rectB, &refRectA, &refRectB, &result, &expectedResult);
@@ -504,7 +504,7 @@ int rect_testIntersectRectPartial (void *arg)
expectedResult.x = refRectB.x;
expectedResult.y = refRectB.y;
expectedResult.w = 1;
expectedResult.h = refRectB.h;
expectedResult.h = refRectB.h;
intersection = SDL_IntersectRect(&rectA, &rectB, &result);
_validateIntersectRectResults(intersection, SDL_TRUE, &rectA, &rectB, &refRectA, &refRectB, &result, &expectedResult);
@@ -518,7 +518,7 @@ int rect_testIntersectRectPartial (void *arg)
expectedResult.x = 0;
expectedResult.y = refRectB.y;
expectedResult.w = 1;
expectedResult.h = refRectB.h;
expectedResult.h = refRectB.h;
intersection = SDL_IntersectRect(&rectA, &rectB, &result);
_validateIntersectRectResults(intersection, SDL_TRUE, &rectA, &rectB, &refRectA, &refRectB, &result, &expectedResult);
@@ -532,7 +532,7 @@ int rect_testIntersectRectPartial (void *arg)
expectedResult.x = refRectB.x;
expectedResult.y = refRectB.y;
expectedResult.w = refRectB.w;
expectedResult.h = 1;
expectedResult.h = 1;
intersection = SDL_IntersectRect(&rectA, &rectB, &result);
_validateIntersectRectResults(intersection, SDL_TRUE, &rectA, &rectB, &refRectA, &refRectB, &result, &expectedResult);
@@ -546,11 +546,11 @@ int rect_testIntersectRectPartial (void *arg)
expectedResult.x = refRectB.x;
expectedResult.y = 0;
expectedResult.w = refRectB.w;
expectedResult.h = 1;
expectedResult.h = 1;
intersection = SDL_IntersectRect(&rectA, &rectB, &result);
_validateIntersectRectResults(intersection, SDL_TRUE, &rectA, &rectB, &refRectA, &refRectB, &result, &expectedResult);
return TEST_COMPLETED;
return TEST_COMPLETED;
}
/*!
@@ -586,7 +586,7 @@ int rect_testIntersectRectPoint (void *arg)
refRectA.x = SDLTest_RandomIntegerInRange(1, 100);
refRectA.y = SDLTest_RandomIntegerInRange(1, 100);
refRectB.x = refRectA.x;
refRectB.y = refRectA.y;
refRectB.y = refRectA.y;
refRectB.x += offsetX;
refRectB.y += offsetY;
rectA = refRectA;
@@ -597,7 +597,7 @@ int rect_testIntersectRectPoint (void *arg)
}
}
return TEST_COMPLETED;
return TEST_COMPLETED;
}
/*!
@@ -632,7 +632,7 @@ int rect_testIntersectRectEmpty (void *arg)
_validateIntersectRectResults(intersection, SDL_FALSE, &rectA, &rectB, &refRectA, &refRectB, (SDL_Rect *)NULL, (SDL_Rect *)NULL);
empty = (SDL_bool)SDL_RectEmpty(&result);
SDLTest_AssertCheck(empty == SDL_TRUE, "Validate result is empty Rect; got: %s", (empty == SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE");
// Rect B empty
result.w = SDLTest_RandomIntegerInRange(1, 100);
result.h = SDLTest_RandomIntegerInRange(1, 100);
@@ -687,19 +687,19 @@ int rect_testIntersectRectParam(void *arg)
// invalid parameter combinations
intersection = SDL_IntersectRect((SDL_Rect *)NULL, &rectB, &result);
SDLTest_AssertCheck(intersection == SDL_FALSE, "Check that function returns SDL_FALSE when 1st parameter is NULL");
SDLTest_AssertCheck(intersection == SDL_FALSE, "Check that function returns SDL_FALSE when 1st parameter is NULL");
intersection = SDL_IntersectRect(&rectA, (SDL_Rect *)NULL, &result);
SDLTest_AssertCheck(intersection == SDL_FALSE, "Check that function returns SDL_FALSE when 2st parameter is NULL");
SDLTest_AssertCheck(intersection == SDL_FALSE, "Check that function returns SDL_FALSE when 2st parameter is NULL");
intersection = SDL_IntersectRect(&rectA, &rectB, (SDL_Rect *)NULL);
SDLTest_AssertCheck(intersection == SDL_FALSE, "Check that function returns SDL_FALSE when 3st parameter is NULL");
SDLTest_AssertCheck(intersection == SDL_FALSE, "Check that function returns SDL_FALSE when 3st parameter is NULL");
intersection = SDL_IntersectRect((SDL_Rect *)NULL, (SDL_Rect *)NULL, &result);
SDLTest_AssertCheck(intersection == SDL_FALSE, "Check that function returns SDL_FALSE when 1st and 2nd parameters are NULL");
SDLTest_AssertCheck(intersection == SDL_FALSE, "Check that function returns SDL_FALSE when 1st and 2nd parameters are NULL");
intersection = SDL_IntersectRect((SDL_Rect *)NULL, &rectB, (SDL_Rect *)NULL);
SDLTest_AssertCheck(intersection == SDL_FALSE, "Check that function returns SDL_FALSE when 1st and 3rd parameters are NULL ");
SDLTest_AssertCheck(intersection == SDL_FALSE, "Check that function returns SDL_FALSE when 1st and 3rd parameters are NULL ");
intersection = SDL_IntersectRect((SDL_Rect *)NULL, (SDL_Rect *)NULL, (SDL_Rect *)NULL);
SDLTest_AssertCheck(intersection == SDL_FALSE, "Check that function returns SDL_FALSE when all parameters are NULL");
SDLTest_AssertCheck(intersection == SDL_FALSE, "Check that function returns SDL_FALSE when all parameters are NULL");
return TEST_COMPLETED;
return TEST_COMPLETED;
}
/*!
@@ -726,7 +726,7 @@ int rect_testHasIntersectionInside (void *arg)
intersection = SDL_HasIntersection(&rectA, &rectB);
_validateHasIntersectionResults(intersection, SDL_TRUE, &rectA, &rectB, &refRectA, &refRectB);
return TEST_COMPLETED;
return TEST_COMPLETED;
}
/*!
@@ -753,7 +753,7 @@ int rect_testHasIntersectionOutside (void *arg)
intersection = SDL_HasIntersection(&rectA, &rectB);
_validateHasIntersectionResults(intersection, SDL_FALSE, &rectA, &rectB, &refRectA, &refRectB);
return TEST_COMPLETED;
return TEST_COMPLETED;
}
/*!
@@ -820,7 +820,7 @@ int rect_testHasIntersectionPartial (void *arg)
intersection = SDL_HasIntersection(&rectA, &rectB);
_validateHasIntersectionResults(intersection, SDL_TRUE, &rectA, &rectB, &refRectA, &refRectB);
return TEST_COMPLETED;
return TEST_COMPLETED;
}
/*!
@@ -855,7 +855,7 @@ int rect_testHasIntersectionPoint (void *arg)
refRectA.x = SDLTest_RandomIntegerInRange(1, 100);
refRectA.y = SDLTest_RandomIntegerInRange(1, 100);
refRectB.x = refRectA.x;
refRectB.y = refRectA.y;
refRectB.y = refRectA.y;
refRectB.x += offsetX;
refRectB.y += offsetY;
rectA = refRectA;
@@ -866,7 +866,7 @@ int rect_testHasIntersectionPoint (void *arg)
}
}
return TEST_COMPLETED;
return TEST_COMPLETED;
}
/*!
@@ -924,7 +924,7 @@ int rect_testHasIntersectionEmpty (void *arg)
intersection = SDL_HasIntersection(&rectA, &rectB);
_validateHasIntersectionResults(intersection, SDL_FALSE, &rectA, &rectB, &refRectA, &refRectB);
return TEST_COMPLETED;
return TEST_COMPLETED;
}
/*!
@@ -941,13 +941,13 @@ int rect_testHasIntersectionParam(void *arg)
// invalid parameter combinations
intersection = SDL_HasIntersection((SDL_Rect *)NULL, &rectB);
SDLTest_AssertCheck(intersection == SDL_FALSE, "Check that function returns SDL_FALSE when 1st parameter is NULL");
SDLTest_AssertCheck(intersection == SDL_FALSE, "Check that function returns SDL_FALSE when 1st parameter is NULL");
intersection = SDL_HasIntersection(&rectA, (SDL_Rect *)NULL);
SDLTest_AssertCheck(intersection == SDL_FALSE, "Check that function returns SDL_FALSE when 2st parameter is NULL");
SDLTest_AssertCheck(intersection == SDL_FALSE, "Check that function returns SDL_FALSE when 2st parameter is NULL");
intersection = SDL_HasIntersection((SDL_Rect *)NULL, (SDL_Rect *)NULL);
SDLTest_AssertCheck(intersection == SDL_FALSE, "Check that function returns SDL_FALSE when all parameters are NULL");
SDLTest_AssertCheck(intersection == SDL_FALSE, "Check that function returns SDL_FALSE when all parameters are NULL");
return TEST_COMPLETED;
return TEST_COMPLETED;
}
/*!
@@ -989,35 +989,35 @@ int rect_testEnclosePoints(void *arg)
if (newy > maxy) maxy = newy;
}
}
// Call function and validate - special case: no result requested
anyEnclosedNoResult = SDL_EnclosePoints((const SDL_Point *)points, numPoints, (const SDL_Rect *)NULL, (SDL_Rect *)NULL);
SDLTest_AssertCheck(expectedEnclosed==anyEnclosedNoResult,
"Check expected return value %s, got %s",
(expectedEnclosed==SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE",
(anyEnclosedNoResult==SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE");
SDLTest_AssertCheck(expectedEnclosed==anyEnclosedNoResult,
"Check expected return value %s, got %s",
(expectedEnclosed==SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE",
(anyEnclosedNoResult==SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE");
for (i=0; i<numPoints; i++) {
SDLTest_AssertCheck(refPoints[i].x==points[i].x && refPoints[i].y==points[i].y,
"Check that source point %i was not modified: expected (%i,%i) actual (%i,%i)",
"Check that source point %i was not modified: expected (%i,%i) actual (%i,%i)",
i, refPoints[i].x, refPoints[i].y, points[i].x, points[i].y);
}
// Call function and validate
anyEnclosed = SDL_EnclosePoints((const SDL_Point *)points, numPoints, (const SDL_Rect *)NULL, &result);
SDLTest_AssertCheck(expectedEnclosed==anyEnclosed,
"Check return value %s, got %s",
(expectedEnclosed==SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE",
(anyEnclosed==SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE");
SDLTest_AssertCheck(expectedEnclosed==anyEnclosed,
"Check return value %s, got %s",
(expectedEnclosed==SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE",
(anyEnclosed==SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE");
for (i=0; i<numPoints; i++) {
SDLTest_AssertCheck(refPoints[i].x==points[i].x && refPoints[i].y==points[i].y,
"Check that source point %i was not modified: expected (%i,%i) actual (%i,%i)",
"Check that source point %i was not modified: expected (%i,%i) actual (%i,%i)",
i, refPoints[i].x, refPoints[i].y, points[i].x, points[i].y);
}
SDLTest_AssertCheck(result.x==minx && result.y==miny && result.w==(maxx - minx + 1) && result.h==(maxy - miny + 1),
"Resulting enclosing rectangle incorrect: expected (%i,%i - %i,%i), actual (%i,%i - %i,%i)",
minx, miny, maxx, maxy, result.x, result.y, result.x + result.w - 1, result.y + result.h - 1);
return TEST_COMPLETED;
return TEST_COMPLETED;
}
/*!
@@ -1068,32 +1068,32 @@ int rect_testEnclosePointsRepeatedInput(void *arg)
// Call function and validate - special case: no result requested
anyEnclosedNoResult = SDL_EnclosePoints((const SDL_Point *)points, numPoints, (const SDL_Rect *)NULL, (SDL_Rect *)NULL);
SDLTest_AssertCheck(expectedEnclosed==anyEnclosedNoResult,
"Check return value %s, got %s",
(expectedEnclosed==SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE",
(anyEnclosedNoResult==SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE");
SDLTest_AssertCheck(expectedEnclosed==anyEnclosedNoResult,
"Check return value %s, got %s",
(expectedEnclosed==SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE",
(anyEnclosedNoResult==SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE");
for (i=0; i<numPoints; i++) {
SDLTest_AssertCheck(refPoints[i].x==points[i].x && refPoints[i].y==points[i].y,
"Check that source point %i was not modified: expected (%i,%i) actual (%i,%i)",
"Check that source point %i was not modified: expected (%i,%i) actual (%i,%i)",
i, refPoints[i].x, refPoints[i].y, points[i].x, points[i].y);
}
// Call function and validate
anyEnclosed = SDL_EnclosePoints((const SDL_Point *)points, numPoints, (const SDL_Rect *)NULL, &result);
SDLTest_AssertCheck(expectedEnclosed==anyEnclosed,
"Check return value %s, got %s",
(expectedEnclosed==SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE",
(anyEnclosed==SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE");
SDLTest_AssertCheck(expectedEnclosed==anyEnclosed,
"Check return value %s, got %s",
(expectedEnclosed==SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE",
(anyEnclosed==SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE");
for (i=0; i<numPoints; i++) {
SDLTest_AssertCheck(refPoints[i].x==points[i].x && refPoints[i].y==points[i].y,
"Check that source point %i was not modified: expected (%i,%i) actual (%i,%i)",
"Check that source point %i was not modified: expected (%i,%i) actual (%i,%i)",
i, refPoints[i].x, refPoints[i].y, points[i].x, points[i].y);
}
SDLTest_AssertCheck(result.x==minx && result.y==miny && result.w==(maxx - minx + 1) && result.h==(maxy - miny + 1),
"Check resulting enclosing rectangle: expected (%i,%i - %i,%i), actual (%i,%i - %i,%i)",
minx, miny, maxx, maxy, result.x, result.y, result.x + result.w - 1, result.y + result.h - 1);
return TEST_COMPLETED;
return TEST_COMPLETED;
}
/*!
@@ -1151,27 +1151,27 @@ int rect_testEnclosePointsWithClipping(void *arg)
// Call function and validate - special case: no result requested
clip = refClip;
anyEnclosedNoResult = SDL_EnclosePoints((const SDL_Point *)points, numPoints, (const SDL_Rect *)&clip, (SDL_Rect *)NULL);
SDLTest_AssertCheck(expectedEnclosed==anyEnclosedNoResult,
"Expected return value %s, got %s",
(expectedEnclosed==SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE",
(anyEnclosedNoResult==SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE");
SDLTest_AssertCheck(expectedEnclosed==anyEnclosedNoResult,
"Expected return value %s, got %s",
(expectedEnclosed==SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE",
(anyEnclosedNoResult==SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE");
for (i=0; i<numPoints; i++) {
SDLTest_AssertCheck(refPoints[i].x==points[i].x && refPoints[i].y==points[i].y,
"Check that source point %i was not modified: expected (%i,%i) actual (%i,%i)",
"Check that source point %i was not modified: expected (%i,%i) actual (%i,%i)",
i, refPoints[i].x, refPoints[i].y, points[i].x, points[i].y);
}
SDLTest_AssertCheck(refClip.x==clip.x && refClip.y==clip.y && refClip.w==clip.w && refClip.h==clip.h,
"Check that source clipping rectangle was not modified");
// Call function and validate
anyEnclosed = SDL_EnclosePoints((const SDL_Point *)points, numPoints, (const SDL_Rect *)&clip, &result);
SDLTest_AssertCheck(expectedEnclosed==anyEnclosed,
"Check return value %s, got %s",
(expectedEnclosed==SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE",
(anyEnclosed==SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE");
SDLTest_AssertCheck(expectedEnclosed==anyEnclosed,
"Check return value %s, got %s",
(expectedEnclosed==SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE",
(anyEnclosed==SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE");
for (i=0; i<numPoints; i++) {
SDLTest_AssertCheck(refPoints[i].x==points[i].x && refPoints[i].y==points[i].y,
"Check that source point %i was not modified: expected (%i,%i) actual (%i,%i)",
"Check that source point %i was not modified: expected (%i,%i) actual (%i,%i)",
i, refPoints[i].x, refPoints[i].y, points[i].x, points[i].y);
}
SDLTest_AssertCheck(refClip.x==clip.x && refClip.y==clip.y && refClip.w==clip.w && refClip.h==clip.h,
@@ -1180,19 +1180,19 @@ int rect_testEnclosePointsWithClipping(void *arg)
SDLTest_AssertCheck(result.x==minx && result.y==miny && result.w==(maxx - minx + 1) && result.h==(maxy - miny + 1),
"Check resulting enclosing rectangle: expected (%i,%i - %i,%i), actual (%i,%i - %i,%i)",
minx, miny, maxx, maxy, result.x, result.y, result.x + result.w - 1, result.y + result.h - 1);
}
}
/* Empty clipping rectangle */
clip.w = 0;
clip.h = 0;
expectedEnclosed = SDL_FALSE;
anyEnclosed = SDL_EnclosePoints((const SDL_Point *)points, numPoints, (const SDL_Rect *)&clip, &result);
SDLTest_AssertCheck(expectedEnclosed==anyEnclosed,
"Check return value %s, got %s",
(expectedEnclosed==SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE",
(anyEnclosed==SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE");
SDLTest_AssertCheck(expectedEnclosed==anyEnclosed,
"Check return value %s, got %s",
(expectedEnclosed==SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE",
(anyEnclosed==SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE");
return TEST_COMPLETED;
return TEST_COMPLETED;
}
/*!
@@ -1211,16 +1211,16 @@ int rect_testEnclosePointsParam(void *arg)
// invalid parameter combinations
anyEnclosed = SDL_EnclosePoints((SDL_Point *)NULL, 1, (const SDL_Rect *)&clip, &result);
SDLTest_AssertCheck(anyEnclosed == SDL_FALSE, "Check that functions returns SDL_FALSE when 1st parameter is NULL");
SDLTest_AssertCheck(anyEnclosed == SDL_FALSE, "Check that functions returns SDL_FALSE when 1st parameter is NULL");
anyEnclosed = SDL_EnclosePoints((const SDL_Point *)points, 0, (const SDL_Rect *)&clip, &result);
SDLTest_AssertCheck(anyEnclosed == SDL_FALSE, "Check that functions returns SDL_FALSE when 2nd parameter is 0");
count = SDLTest_RandomIntegerInRange(-100, -1);
anyEnclosed = SDL_EnclosePoints((const SDL_Point *)points, count, (const SDL_Rect *)&clip, &result);
SDLTest_AssertCheck(anyEnclosed == SDL_FALSE, "Check that functions returns SDL_FALSE when 2nd parameter is %i (negative)", count);
SDLTest_AssertCheck(anyEnclosed == SDL_FALSE, "Check that functions returns SDL_FALSE when 2nd parameter is %i (negative)", count);
anyEnclosed = SDL_EnclosePoints((SDL_Point *)NULL, 0, (const SDL_Rect *)&clip, &result);
SDLTest_AssertCheck(anyEnclosed == SDL_FALSE, "Check that functions returns SDL_FALSE when 1st parameter is NULL and 2nd parameter was 0");
SDLTest_AssertCheck(anyEnclosed == SDL_FALSE, "Check that functions returns SDL_FALSE when 1st parameter is NULL and 2nd parameter was 0");
return TEST_COMPLETED;
return TEST_COMPLETED;
}
/*!
@@ -1237,9 +1237,9 @@ int rect_testUnionRectOutside(void *arg)
SDL_Rect result;
int minx, maxx, miny, maxy;
int dx, dy;
/* Union 1x1 outside */
for (dx = -1; dx < 2; dx++) {
for (dx = -1; dx < 2; dx++) {
for (dy = -1; dy < 2; dy++) {
if ((dx != 0) || (dy != 0)) {
refRectA.x=SDLTest_RandomIntegerInRange(-1024, 1024);
@@ -1253,7 +1253,7 @@ int rect_testUnionRectOutside(void *arg)
minx = (refRectA.x<refRectB.x) ? refRectA.x : refRectB.x;
maxx = (refRectA.x>refRectB.x) ? refRectA.x : refRectB.x;
miny = (refRectA.y<refRectB.y) ? refRectA.y : refRectB.y;
maxy = (refRectA.y>refRectB.y) ? refRectA.y : refRectB.y;
maxy = (refRectA.y>refRectB.y) ? refRectA.y : refRectB.y;
expectedResult.x = minx;
expectedResult.y = miny;
expectedResult.w = maxx - minx + 1;
@@ -1267,7 +1267,7 @@ int rect_testUnionRectOutside(void *arg)
}
/* Union outside overlap */
for (dx = -1; dx < 2; dx++) {
for (dx = -1; dx < 2; dx++) {
for (dy = -1; dy < 2; dy++) {
if ((dx != 0) || (dy != 0)) {
refRectA.x=SDLTest_RandomIntegerInRange(-1024, 1024);
@@ -1291,7 +1291,7 @@ int rect_testUnionRectOutside(void *arg)
}
}
return TEST_COMPLETED;
return TEST_COMPLETED;
}
/*!
@@ -1307,7 +1307,7 @@ int rect_testUnionRectEmpty(void *arg)
SDL_Rect expectedResult;
SDL_Rect result;
/* A empty */
/* A empty */
refRectA.x=SDLTest_RandomIntegerInRange(-1024, 1024);
refRectA.y=SDLTest_RandomIntegerInRange(-1024, 1024);
refRectA.w=0;
@@ -1321,8 +1321,8 @@ int rect_testUnionRectEmpty(void *arg)
rectB = refRectB;
SDL_UnionRect(&rectA, &rectB, &result);
_validateUnionRectResults(&rectA, &rectB, &refRectA, &refRectB, &result, &expectedResult);
/* B empty */
/* B empty */
refRectA.x=SDLTest_RandomIntegerInRange(-1024, 1024);
refRectA.y=SDLTest_RandomIntegerInRange(-1024, 1024);
refRectA.w=SDLTest_RandomIntegerInRange(1, 1024);
@@ -1337,7 +1337,7 @@ int rect_testUnionRectEmpty(void *arg)
SDL_UnionRect(&rectA, &rectB, &result);
_validateUnionRectResults(&rectA, &rectB, &refRectA, &refRectB, &result, &expectedResult);
/* A and B empty */
/* A and B empty */
refRectA.x=SDLTest_RandomIntegerInRange(-1024, 1024);
refRectA.y=SDLTest_RandomIntegerInRange(-1024, 1024);
refRectA.w=0;
@@ -1356,7 +1356,7 @@ int rect_testUnionRectEmpty(void *arg)
SDL_UnionRect(&rectA, &rectB, &result);
_validateUnionRectResults(&rectA, &rectB, &refRectA, &refRectB, &result, &expectedResult);
return TEST_COMPLETED;
return TEST_COMPLETED;
}
/*!
@@ -1372,7 +1372,7 @@ int rect_testUnionRectInside(void *arg)
SDL_Rect expectedResult;
SDL_Rect result;
int dx, dy;
/* Union 1x1 with itself */
refRectA.x=SDLTest_RandomIntegerInRange(-1024, 1024);
refRectA.y=SDLTest_RandomIntegerInRange(-1024, 1024);
@@ -1399,7 +1399,7 @@ int rect_testUnionRectInside(void *arg)
_validateUnionRectResults(&rectA, &rectB, &refRectA, &refRectB, &result, &expectedResult);
/* Union inside with edges modified */
for (dx = -1; dx < 2; dx++) {
for (dx = -1; dx < 2; dx++) {
for (dy = -1; dy < 2; dy++) {
if ((dx != 0) || (dy != 0)) {
refRectA.x=SDLTest_RandomIntegerInRange(-1024, 1024);
@@ -1410,7 +1410,7 @@ int rect_testUnionRectInside(void *arg)
if (dx == -1) refRectB.x++;
if ((dx == 1) || (dx == -1)) refRectB.w--;
if (dy == -1) refRectB.y++;
if ((dy == 1) || (dy == -1)) refRectB.h--;
if ((dy == 1) || (dy == -1)) refRectB.h--;
expectedResult = refRectA;
rectA = refRectA;
rectB = refRectB;
@@ -1420,7 +1420,7 @@ int rect_testUnionRectInside(void *arg)
}
}
return TEST_COMPLETED;
return TEST_COMPLETED;
}
/*!
@@ -1436,19 +1436,19 @@ int rect_testUnionRectParam(void *arg)
// invalid parameter combinations
SDL_UnionRect((SDL_Rect *)NULL, &rectB, &result);
SDLTest_AssertPass("Check that function returns when 1st parameter is NULL");
SDLTest_AssertPass("Check that function returns when 1st parameter is NULL");
SDL_UnionRect(&rectA, (SDL_Rect *)NULL, &result);
SDLTest_AssertPass("Check that function returns when 2nd parameter is NULL");
SDLTest_AssertPass("Check that function returns when 2nd parameter is NULL");
SDL_UnionRect(&rectA, &rectB, (SDL_Rect *)NULL);
SDLTest_AssertPass("Check that function returns when 3rd parameter is NULL");
SDLTest_AssertPass("Check that function returns when 3rd parameter is NULL");
SDL_UnionRect((SDL_Rect *)NULL, &rectB, (SDL_Rect *)NULL);
SDLTest_AssertPass("Check that function returns when 1st and 3rd parameter are NULL");
SDLTest_AssertPass("Check that function returns when 1st and 3rd parameter are NULL");
SDL_UnionRect(&rectA, (SDL_Rect *)NULL, (SDL_Rect *)NULL);
SDLTest_AssertPass("Check that function returns when 2nd and 3rd parameter are NULL");
SDLTest_AssertPass("Check that function returns when 2nd and 3rd parameter are NULL");
SDL_UnionRect((SDL_Rect *)NULL, (SDL_Rect *)NULL, (SDL_Rect *)NULL);
SDLTest_AssertPass("Check that function returns when all parameters are NULL");
SDLTest_AssertPass("Check that function returns when all parameters are NULL");
return TEST_COMPLETED;
return TEST_COMPLETED;
}
/*!
@@ -1474,7 +1474,7 @@ int rect_testRectEmpty(void *arg)
rect = refRect;
result = (SDL_bool)SDL_RectEmpty((const SDL_Rect *)&rect);
_validateRectEmptyResults(result, expectedResult, &rect, &refRect);
// Empty case
for (w=-1; w<2; w++) {
for (h=-1; h<2; h++) {
@@ -1491,7 +1491,7 @@ int rect_testRectEmpty(void *arg)
}
}
return TEST_COMPLETED;
return TEST_COMPLETED;
}
/*!
@@ -1506,9 +1506,9 @@ int rect_testRectEmptyParam(void *arg)
// invalid parameter combinations
result = (SDL_bool)SDL_RectEmpty((const SDL_Rect *)NULL);
SDLTest_AssertCheck(result == SDL_TRUE, "Check that function returns TRUE when 1st parameter is NULL");
SDLTest_AssertCheck(result == SDL_TRUE, "Check that function returns TRUE when 1st parameter is NULL");
return TEST_COMPLETED;
return TEST_COMPLETED;
}
/*!
@@ -1531,14 +1531,14 @@ int rect_testRectEquals(void *arg)
refRectA.y=SDLTest_RandomIntegerInRange(-1024, 1024);
refRectA.w=SDLTest_RandomIntegerInRange(1, 1024);
refRectA.h=SDLTest_RandomIntegerInRange(1, 1024);
refRectB = refRectA;
refRectB = refRectA;
expectedResult = SDL_TRUE;
rectA = refRectA;
rectB = refRectB;
result = (SDL_bool)SDL_RectEquals((const SDL_Rect *)&rectA, (const SDL_Rect *)&rectB);
_validateRectEqualsResults(result, expectedResult, &rectA, &rectB, &refRectA, &refRectB);
return TEST_COMPLETED;
return TEST_COMPLETED;
}
/*!
@@ -1565,13 +1565,13 @@ int rect_testRectEqualsParam(void *arg)
// invalid parameter combinations
result = (SDL_bool)SDL_RectEquals((const SDL_Rect *)NULL, (const SDL_Rect *)&rectB);
SDLTest_AssertCheck(result == SDL_FALSE, "Check that function returns SDL_FALSE when 1st parameter is NULL");
SDLTest_AssertCheck(result == SDL_FALSE, "Check that function returns SDL_FALSE when 1st parameter is NULL");
result = (SDL_bool)SDL_RectEquals((const SDL_Rect *)&rectA, (const SDL_Rect *)NULL);
SDLTest_AssertCheck(result == SDL_FALSE, "Check that function returns SDL_FALSE when 2nd parameter is NULL");
SDLTest_AssertCheck(result == SDL_FALSE, "Check that function returns SDL_FALSE when 2nd parameter is NULL");
result = (SDL_bool)SDL_RectEquals((const SDL_Rect *)NULL, (const SDL_Rect *)NULL);
SDLTest_AssertCheck(result == SDL_FALSE, "Check that function returns SDL_FALSE when 1st and 2nd parameter are NULL");
SDLTest_AssertCheck(result == SDL_FALSE, "Check that function returns SDL_FALSE when 1st and 2nd parameter are NULL");
return TEST_COMPLETED;
return TEST_COMPLETED;
}
/* ================= Test References ================== */
@@ -1580,98 +1580,98 @@ int rect_testRectEqualsParam(void *arg)
/* SDL_IntersectRectAndLine */
static const SDLTest_TestCaseReference rectTest1 =
{ (SDLTest_TestCaseFp)rect_testIntersectRectAndLine,"rect_testIntersectRectAndLine", "Tests SDL_IntersectRectAndLine clipping cases", TEST_ENABLED };
{ (SDLTest_TestCaseFp)rect_testIntersectRectAndLine,"rect_testIntersectRectAndLine", "Tests SDL_IntersectRectAndLine clipping cases", TEST_ENABLED };
static const SDLTest_TestCaseReference rectTest2 =
{ (SDLTest_TestCaseFp)rect_testIntersectRectAndLineInside, "rect_testIntersectRectAndLineInside", "Tests SDL_IntersectRectAndLine with line fully contained in rect", TEST_ENABLED };
{ (SDLTest_TestCaseFp)rect_testIntersectRectAndLineInside, "rect_testIntersectRectAndLineInside", "Tests SDL_IntersectRectAndLine with line fully contained in rect", TEST_ENABLED };
static const SDLTest_TestCaseReference rectTest3 =
{ (SDLTest_TestCaseFp)rect_testIntersectRectAndLineOutside, "rect_testIntersectRectAndLineOutside", "Tests SDL_IntersectRectAndLine with line fully outside of rect", TEST_ENABLED };
{ (SDLTest_TestCaseFp)rect_testIntersectRectAndLineOutside, "rect_testIntersectRectAndLineOutside", "Tests SDL_IntersectRectAndLine with line fully outside of rect", TEST_ENABLED };
static const SDLTest_TestCaseReference rectTest4 =
{ (SDLTest_TestCaseFp)rect_testIntersectRectAndLineEmpty, "rect_testIntersectRectAndLineEmpty", "Tests SDL_IntersectRectAndLine with empty rectangle ", TEST_ENABLED };
{ (SDLTest_TestCaseFp)rect_testIntersectRectAndLineEmpty, "rect_testIntersectRectAndLineEmpty", "Tests SDL_IntersectRectAndLine with empty rectangle ", TEST_ENABLED };
static const SDLTest_TestCaseReference rectTest5 =
{ (SDLTest_TestCaseFp)rect_testIntersectRectAndLineParam, "rect_testIntersectRectAndLineParam", "Negative tests against SDL_IntersectRectAndLine with invalid parameters", TEST_ENABLED };
{ (SDLTest_TestCaseFp)rect_testIntersectRectAndLineParam, "rect_testIntersectRectAndLineParam", "Negative tests against SDL_IntersectRectAndLine with invalid parameters", TEST_ENABLED };
/* SDL_IntersectRect */
static const SDLTest_TestCaseReference rectTest6 =
{ (SDLTest_TestCaseFp)rect_testIntersectRectInside, "rect_testIntersectRectInside", "Tests SDL_IntersectRect with B fully contained in A", TEST_ENABLED };
{ (SDLTest_TestCaseFp)rect_testIntersectRectInside, "rect_testIntersectRectInside", "Tests SDL_IntersectRect with B fully contained in A", TEST_ENABLED };
static const SDLTest_TestCaseReference rectTest7 =
{ (SDLTest_TestCaseFp)rect_testIntersectRectOutside, "rect_testIntersectRectOutside", "Tests SDL_IntersectRect with B fully outside of A", TEST_ENABLED };
{ (SDLTest_TestCaseFp)rect_testIntersectRectOutside, "rect_testIntersectRectOutside", "Tests SDL_IntersectRect with B fully outside of A", TEST_ENABLED };
static const SDLTest_TestCaseReference rectTest8 =
{ (SDLTest_TestCaseFp)rect_testIntersectRectPartial, "rect_testIntersectRectPartial", "Tests SDL_IntersectRect with B partially intersecting A", TEST_ENABLED };
{ (SDLTest_TestCaseFp)rect_testIntersectRectPartial, "rect_testIntersectRectPartial", "Tests SDL_IntersectRect with B partially intersecting A", TEST_ENABLED };
static const SDLTest_TestCaseReference rectTest9 =
{ (SDLTest_TestCaseFp)rect_testIntersectRectPoint, "rect_testIntersectRectPoint", "Tests SDL_IntersectRect with 1x1 sized rectangles", TEST_ENABLED };
{ (SDLTest_TestCaseFp)rect_testIntersectRectPoint, "rect_testIntersectRectPoint", "Tests SDL_IntersectRect with 1x1 sized rectangles", TEST_ENABLED };
static const SDLTest_TestCaseReference rectTest10 =
{ (SDLTest_TestCaseFp)rect_testIntersectRectEmpty, "rect_testIntersectRectEmpty", "Tests SDL_IntersectRect with empty rectangles", TEST_ENABLED };
{ (SDLTest_TestCaseFp)rect_testIntersectRectEmpty, "rect_testIntersectRectEmpty", "Tests SDL_IntersectRect with empty rectangles", TEST_ENABLED };
static const SDLTest_TestCaseReference rectTest11 =
{ (SDLTest_TestCaseFp)rect_testIntersectRectParam, "rect_testIntersectRectParam", "Negative tests against SDL_IntersectRect with invalid parameters", TEST_ENABLED };
{ (SDLTest_TestCaseFp)rect_testIntersectRectParam, "rect_testIntersectRectParam", "Negative tests against SDL_IntersectRect with invalid parameters", TEST_ENABLED };
/* SDL_HasIntersection */
static const SDLTest_TestCaseReference rectTest12 =
{ (SDLTest_TestCaseFp)rect_testHasIntersectionInside, "rect_testHasIntersectionInside", "Tests SDL_HasIntersection with B fully contained in A", TEST_ENABLED };
{ (SDLTest_TestCaseFp)rect_testHasIntersectionInside, "rect_testHasIntersectionInside", "Tests SDL_HasIntersection with B fully contained in A", TEST_ENABLED };
static const SDLTest_TestCaseReference rectTest13 =
{ (SDLTest_TestCaseFp)rect_testHasIntersectionOutside, "rect_testHasIntersectionOutside", "Tests SDL_HasIntersection with B fully outside of A", TEST_ENABLED };
{ (SDLTest_TestCaseFp)rect_testHasIntersectionOutside, "rect_testHasIntersectionOutside", "Tests SDL_HasIntersection with B fully outside of A", TEST_ENABLED };
static const SDLTest_TestCaseReference rectTest14 =
{ (SDLTest_TestCaseFp)rect_testHasIntersectionPartial,"rect_testHasIntersectionPartial", "Tests SDL_HasIntersection with B partially intersecting A", TEST_ENABLED };
{ (SDLTest_TestCaseFp)rect_testHasIntersectionPartial,"rect_testHasIntersectionPartial", "Tests SDL_HasIntersection with B partially intersecting A", TEST_ENABLED };
static const SDLTest_TestCaseReference rectTest15 =
{ (SDLTest_TestCaseFp)rect_testHasIntersectionPoint, "rect_testHasIntersectionPoint", "Tests SDL_HasIntersection with 1x1 sized rectangles", TEST_ENABLED };
{ (SDLTest_TestCaseFp)rect_testHasIntersectionPoint, "rect_testHasIntersectionPoint", "Tests SDL_HasIntersection with 1x1 sized rectangles", TEST_ENABLED };
static const SDLTest_TestCaseReference rectTest16 =
{ (SDLTest_TestCaseFp)rect_testHasIntersectionEmpty, "rect_testHasIntersectionEmpty", "Tests SDL_HasIntersection with empty rectangles", TEST_ENABLED };
{ (SDLTest_TestCaseFp)rect_testHasIntersectionEmpty, "rect_testHasIntersectionEmpty", "Tests SDL_HasIntersection with empty rectangles", TEST_ENABLED };
static const SDLTest_TestCaseReference rectTest17 =
{ (SDLTest_TestCaseFp)rect_testHasIntersectionParam, "rect_testHasIntersectionParam", "Negative tests against SDL_HasIntersection with invalid parameters", TEST_ENABLED };
{ (SDLTest_TestCaseFp)rect_testHasIntersectionParam, "rect_testHasIntersectionParam", "Negative tests against SDL_HasIntersection with invalid parameters", TEST_ENABLED };
/* SDL_EnclosePoints */
static const SDLTest_TestCaseReference rectTest18 =
{ (SDLTest_TestCaseFp)rect_testEnclosePoints, "rect_testEnclosePoints", "Tests SDL_EnclosePoints without clipping", TEST_ENABLED };
{ (SDLTest_TestCaseFp)rect_testEnclosePoints, "rect_testEnclosePoints", "Tests SDL_EnclosePoints without clipping", TEST_ENABLED };
static const SDLTest_TestCaseReference rectTest19 =
{ (SDLTest_TestCaseFp)rect_testEnclosePointsWithClipping, "rect_testEnclosePointsWithClipping", "Tests SDL_EnclosePoints with clipping", TEST_ENABLED };
{ (SDLTest_TestCaseFp)rect_testEnclosePointsWithClipping, "rect_testEnclosePointsWithClipping", "Tests SDL_EnclosePoints with clipping", TEST_ENABLED };
static const SDLTest_TestCaseReference rectTest20 =
{ (SDLTest_TestCaseFp)rect_testEnclosePointsRepeatedInput, "rect_testEnclosePointsRepeatedInput", "Tests SDL_EnclosePoints with repeated input", TEST_ENABLED };
{ (SDLTest_TestCaseFp)rect_testEnclosePointsRepeatedInput, "rect_testEnclosePointsRepeatedInput", "Tests SDL_EnclosePoints with repeated input", TEST_ENABLED };
static const SDLTest_TestCaseReference rectTest21 =
{ (SDLTest_TestCaseFp)rect_testEnclosePointsParam, "rect_testEnclosePointsParam", "Negative tests against SDL_EnclosePoints with invalid parameters", TEST_ENABLED };
{ (SDLTest_TestCaseFp)rect_testEnclosePointsParam, "rect_testEnclosePointsParam", "Negative tests against SDL_EnclosePoints with invalid parameters", TEST_ENABLED };
/* SDL_UnionRect */
static const SDLTest_TestCaseReference rectTest22 =
{ (SDLTest_TestCaseFp)rect_testUnionRectInside, "rect_testUnionRectInside", "Tests SDL_UnionRect where rect B is inside rect A", TEST_ENABLED };
{ (SDLTest_TestCaseFp)rect_testUnionRectInside, "rect_testUnionRectInside", "Tests SDL_UnionRect where rect B is inside rect A", TEST_ENABLED };
static const SDLTest_TestCaseReference rectTest23 =
{ (SDLTest_TestCaseFp)rect_testUnionRectOutside, "rect_testUnionRectOutside", "Tests SDL_UnionRect where rect B is outside rect A", TEST_ENABLED };
{ (SDLTest_TestCaseFp)rect_testUnionRectOutside, "rect_testUnionRectOutside", "Tests SDL_UnionRect where rect B is outside rect A", TEST_ENABLED };
static const SDLTest_TestCaseReference rectTest24 =
{ (SDLTest_TestCaseFp)rect_testUnionRectEmpty, "rect_testUnionRectEmpty", "Tests SDL_UnionRect where rect A or rect B are empty", TEST_ENABLED };
{ (SDLTest_TestCaseFp)rect_testUnionRectEmpty, "rect_testUnionRectEmpty", "Tests SDL_UnionRect where rect A or rect B are empty", TEST_ENABLED };
static const SDLTest_TestCaseReference rectTest25 =
{ (SDLTest_TestCaseFp)rect_testUnionRectParam, "rect_testUnionRectParam", "Negative tests against SDL_UnionRect with invalid parameters", TEST_ENABLED };
{ (SDLTest_TestCaseFp)rect_testUnionRectParam, "rect_testUnionRectParam", "Negative tests against SDL_UnionRect with invalid parameters", TEST_ENABLED };
/* SDL_RectEmpty */
static const SDLTest_TestCaseReference rectTest26 =
{ (SDLTest_TestCaseFp)rect_testRectEmpty, "rect_testRectEmpty", "Tests SDL_RectEmpty with various inputs", TEST_ENABLED };
{ (SDLTest_TestCaseFp)rect_testRectEmpty, "rect_testRectEmpty", "Tests SDL_RectEmpty with various inputs", TEST_ENABLED };
static const SDLTest_TestCaseReference rectTest27 =
{ (SDLTest_TestCaseFp)rect_testRectEmptyParam, "rect_testRectEmptyParam", "Negative tests against SDL_RectEmpty with invalid parameters", TEST_ENABLED };
{ (SDLTest_TestCaseFp)rect_testRectEmptyParam, "rect_testRectEmptyParam", "Negative tests against SDL_RectEmpty with invalid parameters", TEST_ENABLED };
/* SDL_RectEquals */
static const SDLTest_TestCaseReference rectTest28 =
{ (SDLTest_TestCaseFp)rect_testRectEquals, "rect_testRectEquals", "Tests SDL_RectEquals with various inputs", TEST_ENABLED };
{ (SDLTest_TestCaseFp)rect_testRectEquals, "rect_testRectEquals", "Tests SDL_RectEquals with various inputs", TEST_ENABLED };
static const SDLTest_TestCaseReference rectTest29 =
{ (SDLTest_TestCaseFp)rect_testRectEqualsParam, "rect_testRectEqualsParam", "Negative tests against SDL_RectEquals with invalid parameters", TEST_ENABLED };
{ (SDLTest_TestCaseFp)rect_testRectEqualsParam, "rect_testRectEqualsParam", "Negative tests against SDL_RectEquals with invalid parameters", TEST_ENABLED };
/*!
@@ -1681,16 +1681,16 @@ static const SDLTest_TestCaseReference rectTest29 =
* http://wiki.libsdl.org/moin.cgi/CategoryRect
*/
static const SDLTest_TestCaseReference *rectTests[] = {
&rectTest1, &rectTest2, &rectTest3, &rectTest4, &rectTest5, &rectTest6, &rectTest7, &rectTest8, &rectTest9, &rectTest10, &rectTest11, &rectTest12, &rectTest13, &rectTest14,
&rectTest15, &rectTest16, &rectTest17, &rectTest18, &rectTest19, &rectTest20, &rectTest21, &rectTest22, &rectTest23, &rectTest24, &rectTest25, &rectTest26, &rectTest27,
&rectTest28, &rectTest29, NULL
&rectTest1, &rectTest2, &rectTest3, &rectTest4, &rectTest5, &rectTest6, &rectTest7, &rectTest8, &rectTest9, &rectTest10, &rectTest11, &rectTest12, &rectTest13, &rectTest14,
&rectTest15, &rectTest16, &rectTest17, &rectTest18, &rectTest19, &rectTest20, &rectTest21, &rectTest22, &rectTest23, &rectTest24, &rectTest25, &rectTest26, &rectTest27,
&rectTest28, &rectTest29, NULL
};
/* Rect test suite (global) */
SDLTest_TestSuiteReference rectTestSuite = {
"Rect",
NULL,
rectTests,
NULL
"Rect",
NULL,
rectTests,
NULL
};

View File

@@ -19,8 +19,8 @@
#define RENDER_COMPARE_GMASK 0x0000ff00 /**< Green bit mask. */
#define RENDER_COMPARE_BMASK 0x000000ff /**< Blue bit mask. */
#define ALLOWABLE_ERROR_OPAQUE 0
#define ALLOWABLE_ERROR_BLENDED 64
#define ALLOWABLE_ERROR_OPAQUE 0
#define ALLOWABLE_ERROR_BLENDED 64
/* Test window and renderer */
SDL_Window *window = NULL;
@@ -50,7 +50,7 @@ void InitCreateRenderer(void *arg)
if (window == NULL) {
return;
}
renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED);
SDLTest_AssertPass("SDL_CreateRenderer()");
SDLTest_AssertCheck(renderer != 0, "Check SDL_CreateRenderer result");
@@ -61,17 +61,17 @@ void InitCreateRenderer(void *arg)
}
/*
* Destroy renderer for tests
* Destroy renderer for tests
*/
void CleanupDestroyRenderer(void *arg)
{
if (renderer != NULL) {
if (renderer != NULL) {
SDL_DestroyRenderer(renderer);
renderer = NULL;
SDLTest_AssertPass("SDL_DestroyRenderer()");
}
if (window != NULL) {
if (window != NULL) {
SDL_DestroyWindow(window);
window = NULL;
SDLTest_AssertPass("SDL_DestroyWindow");
@@ -288,7 +288,7 @@ int render_testPrimitivesBlend (void *arg)
SDLTest_AssertCheck(checkFailCount1 == 0, "Validate results from calls to SDL_SetRenderDrawColor, expected: 0, got: %i", checkFailCount1);
SDLTest_AssertCheck(checkFailCount2 == 0, "Validate results from calls to SDL_SetRenderDrawBlendMode, expected: 0, got: %i", checkFailCount2);
SDLTest_AssertCheck(checkFailCount3 == 0, "Validate results from calls to SDL_RenderDrawLine, expected: 0, got: %i", checkFailCount3);
checkFailCount1 = 0;
checkFailCount2 = 0;
checkFailCount3 = 0;
@@ -323,7 +323,7 @@ int render_testPrimitivesBlend (void *arg)
ret = SDL_RenderDrawPoint(renderer, i, j );
if (ret != 0) checkFailCount3++;
}
}
}
SDLTest_AssertCheck(checkFailCount1 == 0, "Validate results from calls to SDL_SetRenderDrawColor, expected: 0, got: %i", checkFailCount1);
SDLTest_AssertCheck(checkFailCount2 == 0, "Validate results from calls to SDL_SetRenderDrawBlendMode, expected: 0, got: %i", checkFailCount2);
SDLTest_AssertCheck(checkFailCount3 == 0, "Validate results from calls to SDL_RenderDrawPoint, expected: 0, got: %i", checkFailCount3);
@@ -533,7 +533,7 @@ render_testBlitAlpha (void *arg)
ret = SDL_RenderCopy(renderer, tface, NULL, &rect );
if (ret != 0) checkFailCount2++;
}
}
}
SDLTest_AssertCheck(checkFailCount1 == 0, "Validate results from calls to SDL_SetTextureAlphaMod, expected: 0, got: %i", checkFailCount1);
SDLTest_AssertCheck(checkFailCount2 == 0, "Validate results from calls to SDL_RenderCopy, expected: 0, got: %i", checkFailCount2);
@@ -654,12 +654,12 @@ render_testBlitBlend (void *arg)
/* Test None. */
_testBlitBlendMode( tface, SDL_BLENDMODE_NONE );
referenceSurface = SDLTest_ImageBlitBlendNone();
_compare(referenceSurface, ALLOWABLE_ERROR_OPAQUE );
_compare(referenceSurface, ALLOWABLE_ERROR_OPAQUE );
if (referenceSurface != NULL) {
SDL_FreeSurface(referenceSurface);
referenceSurface = NULL;
}
/* Test Blend. */
_testBlitBlendMode( tface, SDL_BLENDMODE_BLEND );
referenceSurface = SDLTest_ImageBlitBlend();
@@ -773,7 +773,7 @@ _hasDrawColor (void)
ret = SDL_GetRenderDrawColor(renderer, &r, &g, &b, &a );
if (!_isSupported(ret))
fail = 1;
/* Restore natural. */
ret = SDL_SetRenderDrawColor(renderer, 0, 0, 0, SDL_ALPHA_OPAQUE );
if (!_isSupported(ret))
@@ -782,7 +782,7 @@ _hasDrawColor (void)
/* Something failed, consider not available. */
if (fail)
return 0;
/* Not set properly, consider failed. */
else if ((r != 100) || (g != 100) || (b != 100) || (a != 100))
return 0;
@@ -862,7 +862,7 @@ _loadTestFace(void)
if (face == NULL) {
return NULL;
}
tface = SDL_CreateTextureFromSurface(renderer, face);
if (tface == NULL) {
SDLTest_LogError("SDL_CreateTextureFromSurface() failed with error: %s", SDL_GetError());
@@ -996,7 +996,7 @@ _compare(SDL_Surface *referenceSurface, int allowable_error)
/* Clean up. */
if (pixels != NULL) {
SDL_free(pixels);
SDL_free(pixels);
}
if (testSurface != NULL) {
SDL_FreeSurface(testSurface);
@@ -1038,38 +1038,38 @@ _clearScreen(void)
/* Render test cases */
static const SDLTest_TestCaseReference renderTest1 =
{ (SDLTest_TestCaseFp)render_testGetNumRenderDrivers, "render_testGetNumRenderDrivers", "Tests call to SDL_GetNumRenderDrivers", TEST_ENABLED };
{ (SDLTest_TestCaseFp)render_testGetNumRenderDrivers, "render_testGetNumRenderDrivers", "Tests call to SDL_GetNumRenderDrivers", TEST_ENABLED };
static const SDLTest_TestCaseReference renderTest2 =
{ (SDLTest_TestCaseFp)render_testPrimitives, "render_testPrimitives", "Tests rendering primitives", TEST_ENABLED };
{ (SDLTest_TestCaseFp)render_testPrimitives, "render_testPrimitives", "Tests rendering primitives", TEST_ENABLED };
/* TODO: rewrite test case, define new test data and re-enable; current implementation fails */
static const SDLTest_TestCaseReference renderTest3 =
{ (SDLTest_TestCaseFp)render_testPrimitivesBlend, "render_testPrimitivesBlend", "Tests rendering primitives with blending", TEST_DISABLED };
{ (SDLTest_TestCaseFp)render_testPrimitivesBlend, "render_testPrimitivesBlend", "Tests rendering primitives with blending", TEST_DISABLED };
static const SDLTest_TestCaseReference renderTest4 =
{ (SDLTest_TestCaseFp)render_testBlit, "render_testBlit", "Tests blitting", TEST_ENABLED };
{ (SDLTest_TestCaseFp)render_testBlit, "render_testBlit", "Tests blitting", TEST_ENABLED };
static const SDLTest_TestCaseReference renderTest5 =
{ (SDLTest_TestCaseFp)render_testBlitColor, "render_testBlitColor", "Tests blitting with color", TEST_ENABLED };
{ (SDLTest_TestCaseFp)render_testBlitColor, "render_testBlitColor", "Tests blitting with color", TEST_ENABLED };
/* TODO: rewrite test case, define new test data and re-enable; current implementation fails */
static const SDLTest_TestCaseReference renderTest6 =
{ (SDLTest_TestCaseFp)render_testBlitAlpha, "render_testBlitAlpha", "Tests blitting with alpha", TEST_DISABLED };
{ (SDLTest_TestCaseFp)render_testBlitAlpha, "render_testBlitAlpha", "Tests blitting with alpha", TEST_DISABLED };
/* TODO: rewrite test case, define new test data and re-enable; current implementation fails */
static const SDLTest_TestCaseReference renderTest7 =
{ (SDLTest_TestCaseFp)render_testBlitBlend, "render_testBlitBlend", "Tests blitting with blending", TEST_DISABLED };
{ (SDLTest_TestCaseFp)render_testBlitBlend, "render_testBlitBlend", "Tests blitting with blending", TEST_DISABLED };
/* Sequence of Render test cases */
static const SDLTest_TestCaseReference *renderTests[] = {
&renderTest1, &renderTest2, &renderTest3, &renderTest4, &renderTest5, &renderTest6, &renderTest7, NULL
&renderTest1, &renderTest2, &renderTest3, &renderTest4, &renderTest5, &renderTest6, &renderTest7, NULL
};
/* Render test suite (global) */
SDLTest_TestSuiteReference renderTestSuite = {
"Render",
InitCreateRenderer,
renderTests,
CleanupDestroyRenderer
"Render",
InitCreateRenderer,
renderTests,
CleanupDestroyRenderer
};

View File

@@ -32,56 +32,56 @@ static const char RWopsAlphabetString[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
void
RWopsSetUp(void *arg)
{
int fileLen;
FILE *handle;
int writtenLen;
int result;
int fileLen;
FILE *handle;
int writtenLen;
int result;
/* Clean up from previous runs (if any); ignore errors */
remove(RWopsReadTestFilename);
remove(RWopsWriteTestFilename);
remove(RWopsAlphabetFilename);
/* Clean up from previous runs (if any); ignore errors */
remove(RWopsReadTestFilename);
remove(RWopsWriteTestFilename);
remove(RWopsAlphabetFilename);
/* Create a test file */
handle = fopen(RWopsReadTestFilename, "w");
SDLTest_AssertCheck(handle != NULL, "Verify creation of file '%s' returned non NULL handle", RWopsReadTestFilename);
/* Create a test file */
handle = fopen(RWopsReadTestFilename, "w");
SDLTest_AssertCheck(handle != NULL, "Verify creation of file '%s' returned non NULL handle", RWopsReadTestFilename);
if (handle == NULL) return;
/* Write some known text into it */
fileLen = SDL_strlen(RWopsHelloWorldTestString);
writtenLen = (int)fwrite(RWopsHelloWorldTestString, 1, fileLen, handle);
SDLTest_AssertCheck(fileLen == writtenLen, "Verify number of written bytes, expected %i, got %i", fileLen, writtenLen);
result = fclose(handle);
SDLTest_AssertCheck(result == 0, "Verify result from fclose, expected 0, got %i", result);
/* Write some known text into it */
fileLen = SDL_strlen(RWopsHelloWorldTestString);
writtenLen = (int)fwrite(RWopsHelloWorldTestString, 1, fileLen, handle);
SDLTest_AssertCheck(fileLen == writtenLen, "Verify number of written bytes, expected %i, got %i", fileLen, writtenLen);
result = fclose(handle);
SDLTest_AssertCheck(result == 0, "Verify result from fclose, expected 0, got %i", result);
/* Create a second test file */
handle = fopen(RWopsAlphabetFilename, "w");
SDLTest_AssertCheck(handle != NULL, "Verify creation of file '%s' returned non NULL handle", RWopsAlphabetFilename);
/* Create a second test file */
handle = fopen(RWopsAlphabetFilename, "w");
SDLTest_AssertCheck(handle != NULL, "Verify creation of file '%s' returned non NULL handle", RWopsAlphabetFilename);
if (handle == NULL) return;
/* Write alphabet text into it */
fileLen = SDL_strlen(RWopsAlphabetString);
writtenLen = (int)fwrite(RWopsAlphabetString, 1, fileLen, handle);
SDLTest_AssertCheck(fileLen == writtenLen, "Verify number of written bytes, expected %i, got %i", fileLen, writtenLen);
result = fclose(handle);
SDLTest_AssertCheck(result == 0, "Verify result from fclose, expected 0, got %i", result);
/* Write alphabet text into it */
fileLen = SDL_strlen(RWopsAlphabetString);
writtenLen = (int)fwrite(RWopsAlphabetString, 1, fileLen, handle);
SDLTest_AssertCheck(fileLen == writtenLen, "Verify number of written bytes, expected %i, got %i", fileLen, writtenLen);
result = fclose(handle);
SDLTest_AssertCheck(result == 0, "Verify result from fclose, expected 0, got %i", result);
SDLTest_AssertPass("Creation of test file completed");
SDLTest_AssertPass("Creation of test file completed");
}
void
RWopsTearDown(void *arg)
{
int result;
/* Remove the created files to clean up; ignore errors for write filename */
result = remove(RWopsReadTestFilename);
SDLTest_AssertCheck(result == 0, "Verify result from remove(%s), expected 0, got %i", RWopsReadTestFilename, result);
remove(RWopsWriteTestFilename);
result = remove(RWopsAlphabetFilename);
SDLTest_AssertCheck(result == 0, "Verify result from remove(%s), expected 0, got %i", RWopsAlphabetFilename, result);
int result;
SDLTest_AssertPass("Cleanup of test files completed");
/* Remove the created files to clean up; ignore errors for write filename */
result = remove(RWopsReadTestFilename);
SDLTest_AssertCheck(result == 0, "Verify result from remove(%s), expected 0, got %i", RWopsReadTestFilename, result);
remove(RWopsWriteTestFilename);
result = remove(RWopsAlphabetFilename);
SDLTest_AssertCheck(result == 0, "Verify result from remove(%s), expected 0, got %i", RWopsAlphabetFilename, result);
SDLTest_AssertPass("Cleanup of test files completed");
}
/**
@@ -91,7 +91,7 @@ RWopsTearDown(void *arg)
* http://wiki.libsdl.org/moin.cgi/SDL_RWseek
* http://wiki.libsdl.org/moin.cgi/SDL_RWread
*/
void
void
_testGenericRWopsValidations(SDL_RWops *rw, int write)
{
char buf[sizeof(RWopsHelloWorldTestString)];
@@ -111,10 +111,10 @@ _testGenericRWopsValidations(SDL_RWops *rw, int write)
s = SDL_RWwrite(rw, RWopsHelloWorldTestString, sizeof(RWopsHelloWorldTestString)-1, 1);
SDLTest_AssertPass("Call to SDL_RWwrite succeeded");
if (write) {
SDLTest_AssertCheck(s == (size_t)1, "Verify result of writing one byte with SDL_RWwrite, expected 1, got %i", s);
SDLTest_AssertCheck(s == (size_t)1, "Verify result of writing one byte with SDL_RWwrite, expected 1, got %i", s);
}
else {
SDLTest_AssertCheck(s == (size_t)0, "Verify result of writing with SDL_RWwrite, expected: 0, got %i", s);
SDLTest_AssertCheck(s == (size_t)0, "Verify result of writing with SDL_RWwrite, expected: 0, got %i", s);
}
/* Test seek to random position */
@@ -131,38 +131,38 @@ _testGenericRWopsValidations(SDL_RWops *rw, int write)
s = SDL_RWread( rw, buf, 1, sizeof(RWopsHelloWorldTestString)-1 );
SDLTest_AssertPass("Call to SDL_RWread succeeded");
SDLTest_AssertCheck(
s == (size_t)(sizeof(RWopsHelloWorldTestString)-1),
"Verify result from SDL_RWread, expected %i, got %i",
sizeof(RWopsHelloWorldTestString)-1,
s);
s == (size_t)(sizeof(RWopsHelloWorldTestString)-1),
"Verify result from SDL_RWread, expected %i, got %i",
sizeof(RWopsHelloWorldTestString)-1,
s);
SDLTest_AssertCheck(
SDL_memcmp(buf, RWopsHelloWorldTestString, sizeof(RWopsHelloWorldTestString)-1 ) == 0,
"Verify read bytes match expected string, expected '%s', got '%s'", RWopsHelloWorldTestString, buf);
SDL_memcmp(buf, RWopsHelloWorldTestString, sizeof(RWopsHelloWorldTestString)-1 ) == 0,
"Verify read bytes match expected string, expected '%s', got '%s'", RWopsHelloWorldTestString, buf);
/* More seek tests. */
i = SDL_RWseek( rw, -4, RW_SEEK_CUR );
SDLTest_AssertPass("Call to SDL_RWseek(...,-4,RW_SEEK_CUR) succeeded");
SDLTest_AssertCheck(
i == (Sint64)(sizeof(RWopsHelloWorldTestString)-5),
"Verify seek to -4 with SDL_RWseek (RW_SEEK_CUR), expected %i, got %i",
sizeof(RWopsHelloWorldTestString)-5,
i);
i == (Sint64)(sizeof(RWopsHelloWorldTestString)-5),
"Verify seek to -4 with SDL_RWseek (RW_SEEK_CUR), expected %i, got %i",
sizeof(RWopsHelloWorldTestString)-5,
i);
i = SDL_RWseek( rw, -1, RW_SEEK_END );
SDLTest_AssertPass("Call to SDL_RWseek(...,-1,RW_SEEK_END) succeeded");
SDLTest_AssertCheck(
i == (Sint64)(sizeof(RWopsHelloWorldTestString)-2),
"Verify seek to -1 with SDL_RWseek (RW_SEEK_END), expected %i, got %i",
sizeof(RWopsHelloWorldTestString)-2,
i);
i == (Sint64)(sizeof(RWopsHelloWorldTestString)-2),
"Verify seek to -1 with SDL_RWseek (RW_SEEK_END), expected %i, got %i",
sizeof(RWopsHelloWorldTestString)-2,
i);
/* Invalid whence seek */
i = SDL_RWseek( rw, 0, 999 );
SDLTest_AssertPass("Call to SDL_RWseek(...,0,invalid_whence) succeeded");
SDLTest_AssertCheck(
i == (Sint64)(-1),
"Verify seek with SDL_RWseek (invalid_whence); expected: -1, got %i",
i);
i == (Sint64)(-1),
"Verify seek with SDL_RWseek (invalid_whence); expected: -1, got %i",
i);
}
/*!
@@ -258,7 +258,7 @@ rwops_testMem (void)
* http://wiki.libsdl.org/moin.cgi/SDL_RWFromConstMem
* http://wiki.libsdl.org/moin.cgi/SDL_RWClose
*/
int
int
rwops_testConstMem (void)
{
SDL_RWops *rw;
@@ -311,15 +311,15 @@ rwops_testFileRead(void)
/* Check type */
#if defined(ANDROID)
SDLTest_AssertCheck(
rw->type == SDL_RWOPS_STDFILE || rw->type == SDL_RWOPS_JNIFILE,
rw->type == SDL_RWOPS_STDFILE || rw->type == SDL_RWOPS_JNIFILE,
"Verify RWops type is SDL_RWOPS_STDFILE or SDL_RWOPS_JNIFILE; expected: %d|%d, got: %d", SDL_RWOPS_STDFILE, SDL_RWOPS_JNIFILE, rw->type);
#elif defined(__WIN32__)
SDLTest_AssertCheck(
rw->type == SDL_RWOPS_WINFILE,
rw->type == SDL_RWOPS_WINFILE,
"Verify RWops type is SDL_RWOPS_WINFILE; expected: %d, got: %d", SDL_RWOPS_WINFILE, rw->type);
#else
SDLTest_AssertCheck(
rw->type == SDL_RWOPS_STDFILE,
rw->type == SDL_RWOPS_STDFILE,
"Verify RWops type is SDL_RWOPS_STDFILE; expected: %d, got: %d", SDL_RWOPS_STDFILE, rw->type);
#endif
@@ -358,15 +358,15 @@ rwops_testFileWrite(void)
/* Check type */
#if defined(ANDROID)
SDLTest_AssertCheck(
rw->type == SDL_RWOPS_STDFILE || rw->type == SDL_RWOPS_JNIFILE,
rw->type == SDL_RWOPS_STDFILE || rw->type == SDL_RWOPS_JNIFILE,
"Verify RWops type is SDL_RWOPS_STDFILE or SDL_RWOPS_JNIFILE; expected: %d|%d, got: %d", SDL_RWOPS_STDFILE, SDL_RWOPS_JNIFILE, rw->type);
#elif defined(__WIN32__)
SDLTest_AssertCheck(
rw->type == SDL_RWOPS_WINFILE,
rw->type == SDL_RWOPS_WINFILE,
"Verify RWops type is SDL_RWOPS_WINFILE; expected: %d, got: %d", SDL_RWOPS_WINFILE, rw->type);
#else
SDLTest_AssertCheck(
rw->type == SDL_RWOPS_STDFILE,
rw->type == SDL_RWOPS_STDFILE,
"Verify RWops type is SDL_RWOPS_STDFILE; expected: %d, got: %d", SDL_RWOPS_STDFILE, rw->type);
#endif
@@ -417,7 +417,7 @@ rwops_testFPRead(void)
/* Check type */
SDLTest_AssertCheck(
rw->type == SDL_RWOPS_STDFILE,
rw->type == SDL_RWOPS_STDFILE,
"Verify RWops type is SDL_RWOPS_STDFILE; expected: %d, got: %d", SDL_RWOPS_STDFILE, rw->type);
/* Run generic tests */
@@ -467,7 +467,7 @@ rwops_testFPWrite(void)
/* Check type */
SDLTest_AssertCheck(
rw->type == SDL_RWOPS_STDFILE,
rw->type == SDL_RWOPS_STDFILE,
"Verify RWops type is SDL_RWOPS_STDFILE; expected: %d, got: %d", SDL_RWOPS_STDFILE, rw->type);
/* Run generic tests */
@@ -498,9 +498,9 @@ rwops_testAllocFree (void)
/* Check type */
SDLTest_AssertCheck(
rw->type == SDL_RWOPS_UNKNOWN,
rw->type == SDL_RWOPS_UNKNOWN,
"Verify RWops type is SDL_RWOPS_UNKNOWN; expected: %d, got: %d", SDL_RWOPS_UNKNOWN, rw->type);
/* Free context again */
SDL_FreeRW(rw);
SDLTest_AssertPass("Call to SDL_FreeRW() succeeded");
@@ -529,13 +529,13 @@ rwops_testCompareRWFromMemWithRWFromFile(void)
int size;
int result;
for (size=5; size<10; size++)
{
/* Terminate buffer */
buffer_file[slen] = 0;
buffer_mem[slen] = 0;
/* Read/seek from memory */
rwops_mem = SDL_RWFromMem((void *)RWopsAlphabetString, slen);
SDLTest_AssertPass("Call to SDL_RWFromMem()");
@@ -557,7 +557,7 @@ rwops_testCompareRWFromMemWithRWFromFile(void)
result = SDL_RWclose(rwops_file);
SDLTest_AssertPass("Call to SDL_RWclose(file)");
SDLTest_AssertCheck(result == 0, "Verify result value is 0; got: %d", result);
/* Compare */
SDLTest_AssertCheck(rv_mem == rv_file, "Verify returned read blocks matches for mem and file reads; got: rv_mem=%d rv_file=%d", rv_mem, rv_file);
SDLTest_AssertCheck(sv_mem == sv_file, "Verify SEEK_END position matches for mem and file seeks; got: sv_mem=%llu sv_file=%llu", sv_mem, sv_file);
@@ -570,7 +570,7 @@ rwops_testCompareRWFromMemWithRWFromFile(void)
SDL_strncmp(buffer_file, RWopsAlphabetString, slen) == 0,
"Verify file buffer contain alphabet string; expected: %s, got: %s", RWopsAlphabetString, buffer_file);
}
return TEST_COMPLETED;
}
@@ -605,7 +605,7 @@ rwops_testFileWriteReadEndian(void)
int cresult;
for (mode = 0; mode < 3; mode++) {
/* Create test data */
switch (mode) {
case 0:
@@ -636,7 +636,7 @@ rwops_testFileWriteReadEndian(void)
LE64value = SDLTest_RandomUint64();
break;
}
/* Write test. */
rw = SDL_RWFromFile(RWopsWriteTestFilename, "w+");
SDLTest_AssertPass("Call to SDL_RWFromFile(..,\"w+\")");
@@ -648,22 +648,22 @@ rwops_testFileWriteReadEndian(void)
/* Write test data */
objectsWritten = SDL_WriteBE16(rw, BE16value);
SDLTest_AssertPass("Call to SDL_WriteBE16");
SDLTest_AssertCheck(objectsWritten == 1, "Validate number of objects written, expected: 1, got: %i", objectsWritten);
SDLTest_AssertCheck(objectsWritten == 1, "Validate number of objects written, expected: 1, got: %i", objectsWritten);
objectsWritten = SDL_WriteBE32(rw, BE32value);
SDLTest_AssertPass("Call to SDL_WriteBE32");
SDLTest_AssertCheck(objectsWritten == 1, "Validate number of objects written, expected: 1, got: %i", objectsWritten);
SDLTest_AssertCheck(objectsWritten == 1, "Validate number of objects written, expected: 1, got: %i", objectsWritten);
objectsWritten = SDL_WriteBE64(rw, BE64value);
SDLTest_AssertPass("Call to SDL_WriteBE64");
SDLTest_AssertCheck(objectsWritten == 1, "Validate number of objects written, expected: 1, got: %i", objectsWritten);
SDLTest_AssertCheck(objectsWritten == 1, "Validate number of objects written, expected: 1, got: %i", objectsWritten);
objectsWritten = SDL_WriteLE16(rw, LE16value);
SDLTest_AssertPass("Call to SDL_WriteLE16");
SDLTest_AssertCheck(objectsWritten == 1, "Validate number of objects written, expected: 1, got: %i", objectsWritten);
SDLTest_AssertCheck(objectsWritten == 1, "Validate number of objects written, expected: 1, got: %i", objectsWritten);
objectsWritten = SDL_WriteLE32(rw, LE32value);
SDLTest_AssertPass("Call to SDL_WriteLE32");
SDLTest_AssertCheck(objectsWritten == 1, "Validate number of objects written, expected: 1, got: %i", objectsWritten);
SDLTest_AssertCheck(objectsWritten == 1, "Validate number of objects written, expected: 1, got: %i", objectsWritten);
objectsWritten = SDL_WriteLE64(rw, LE64value);
SDLTest_AssertPass("Call to SDL_WriteLE64");
SDLTest_AssertCheck(objectsWritten == 1, "Validate number of objects written, expected: 1, got: %i", objectsWritten);
SDLTest_AssertCheck(objectsWritten == 1, "Validate number of objects written, expected: 1, got: %i", objectsWritten);
/* Test seek to start */
result = SDL_RWseek( rw, 0, RW_SEEK_SET );
@@ -676,16 +676,16 @@ rwops_testFileWriteReadEndian(void)
SDLTest_AssertCheck(BE16test == BE16value, "Validate return value from SDL_ReadBE16, expected: %hu, got: %hu", BE16value, BE16test);
BE32test = SDL_ReadBE32(rw);
SDLTest_AssertPass("Call to SDL_ReadBE32");
SDLTest_AssertCheck(BE32test == BE32value, "Validate return value from SDL_ReadBE32, expected: %u, got: %u", BE32value, BE32test);
SDLTest_AssertCheck(BE32test == BE32value, "Validate return value from SDL_ReadBE32, expected: %u, got: %u", BE32value, BE32test);
BE64test = SDL_ReadBE64(rw);
SDLTest_AssertPass("Call to SDL_ReadBE64");
SDLTest_AssertCheck(BE64test == BE64value, "Validate return value from SDL_ReadBE64, expected: %llu, got: %llu", BE64value, BE64test);
SDLTest_AssertCheck(BE64test == BE64value, "Validate return value from SDL_ReadBE64, expected: %llu, got: %llu", BE64value, BE64test);
LE16test = SDL_ReadLE16(rw);
SDLTest_AssertPass("Call to SDL_ReadLE16");
SDLTest_AssertCheck(LE16test == LE16value, "Validate return value from SDL_ReadLE16, expected: %hu, got: %hu", LE16value, LE16test);
LE32test = SDL_ReadLE32(rw);
SDLTest_AssertPass("Call to SDL_ReadLE32");
SDLTest_AssertCheck(LE32test == LE32value, "Validate return value from SDL_ReadLE32, expected: %u, got: %u", LE32value, LE32test);
SDLTest_AssertCheck(LE32test == LE32value, "Validate return value from SDL_ReadLE32, expected: %u, got: %u", LE32value, LE32test);
LE64test = SDL_ReadLE64(rw);
SDLTest_AssertPass("Call to SDL_ReadLE64");
SDLTest_AssertCheck(LE64test == LE64value, "Validate return value from SDL_ReadLE64, expected: %llu, got: %llu", LE64value, LE64test);
@@ -693,7 +693,7 @@ rwops_testFileWriteReadEndian(void)
/* Close handle */
cresult = SDL_RWclose(rw);
SDLTest_AssertPass("Call to SDL_RWclose() succeeded");
SDLTest_AssertCheck(cresult == 0, "Verify result value is 0; got: %d", cresult);
SDLTest_AssertCheck(cresult == 0, "Verify result value is 0; got: %d", cresult);
}
return TEST_COMPLETED;
@@ -704,45 +704,45 @@ rwops_testFileWriteReadEndian(void)
/* RWops test cases */
static const SDLTest_TestCaseReference rwopsTest1 =
{ (SDLTest_TestCaseFp)rwops_testParamNegative, "rwops_testParamNegative", "Negative test for SDL_RWFromFile parameters", TEST_ENABLED };
{ (SDLTest_TestCaseFp)rwops_testParamNegative, "rwops_testParamNegative", "Negative test for SDL_RWFromFile parameters", TEST_ENABLED };
static const SDLTest_TestCaseReference rwopsTest2 =
{ (SDLTest_TestCaseFp)rwops_testMem, "rwops_testMem", "Tests opening from memory", TEST_ENABLED };
{ (SDLTest_TestCaseFp)rwops_testMem, "rwops_testMem", "Tests opening from memory", TEST_ENABLED };
static const SDLTest_TestCaseReference rwopsTest3 =
{ (SDLTest_TestCaseFp)rwops_testConstMem, "rwops_testConstMem", "Tests opening from (const) memory", TEST_ENABLED };
{ (SDLTest_TestCaseFp)rwops_testConstMem, "rwops_testConstMem", "Tests opening from (const) memory", TEST_ENABLED };
static const SDLTest_TestCaseReference rwopsTest4 =
{ (SDLTest_TestCaseFp)rwops_testFileRead, "rwops_testFileRead", "Tests reading from a file", TEST_ENABLED };
{ (SDLTest_TestCaseFp)rwops_testFileRead, "rwops_testFileRead", "Tests reading from a file", TEST_ENABLED };
static const SDLTest_TestCaseReference rwopsTest5 =
{ (SDLTest_TestCaseFp)rwops_testFileWrite, "rwops_testFileWrite", "Test writing to a file", TEST_ENABLED };
{ (SDLTest_TestCaseFp)rwops_testFileWrite, "rwops_testFileWrite", "Test writing to a file", TEST_ENABLED };
static const SDLTest_TestCaseReference rwopsTest6 =
{ (SDLTest_TestCaseFp)rwops_testFPRead, "rwops_testFPRead", "Test reading from file pointer", TEST_ENABLED };
{ (SDLTest_TestCaseFp)rwops_testFPRead, "rwops_testFPRead", "Test reading from file pointer", TEST_ENABLED };
static const SDLTest_TestCaseReference rwopsTest7 =
{ (SDLTest_TestCaseFp)rwops_testFPWrite, "rwops_testFPWrite", "Test writing to file pointer", TEST_ENABLED };
{ (SDLTest_TestCaseFp)rwops_testFPWrite, "rwops_testFPWrite", "Test writing to file pointer", TEST_ENABLED };
static const SDLTest_TestCaseReference rwopsTest8 =
{ (SDLTest_TestCaseFp)rwops_testAllocFree, "rwops_testAllocFree", "Test alloc and free of RW context", TEST_ENABLED };
{ (SDLTest_TestCaseFp)rwops_testAllocFree, "rwops_testAllocFree", "Test alloc and free of RW context", TEST_ENABLED };
static const SDLTest_TestCaseReference rwopsTest9 =
{ (SDLTest_TestCaseFp)rwops_testFileWriteReadEndian, "rwops_testFileWriteReadEndian", "Test writing and reading via the Endian aware functions", TEST_ENABLED };
{ (SDLTest_TestCaseFp)rwops_testFileWriteReadEndian, "rwops_testFileWriteReadEndian", "Test writing and reading via the Endian aware functions", TEST_ENABLED };
static const SDLTest_TestCaseReference rwopsTest10 =
{ (SDLTest_TestCaseFp)rwops_testCompareRWFromMemWithRWFromFile, "rwops_testCompareRWFromMemWithRWFromFile", "Compare RWFromMem and RWFromFile RWops for read and seek", TEST_ENABLED };
{ (SDLTest_TestCaseFp)rwops_testCompareRWFromMemWithRWFromFile, "rwops_testCompareRWFromMemWithRWFromFile", "Compare RWFromMem and RWFromFile RWops for read and seek", TEST_ENABLED };
/* Sequence of RWops test cases */
static const SDLTest_TestCaseReference *rwopsTests[] = {
&rwopsTest1, &rwopsTest2, &rwopsTest3, &rwopsTest4, &rwopsTest5, &rwopsTest6,
&rwopsTest7, &rwopsTest8, &rwopsTest9, &rwopsTest10, NULL
&rwopsTest1, &rwopsTest2, &rwopsTest3, &rwopsTest4, &rwopsTest5, &rwopsTest6,
&rwopsTest7, &rwopsTest8, &rwopsTest9, &rwopsTest10, NULL
};
/* RWops test suite (global) */
SDLTest_TestSuiteReference rwopsTestSuite = {
"RWops",
RWopsSetUp,
rwopsTests,
RWopsTearDown
"RWops",
RWopsSetUp,
rwopsTests,
RWopsTearDown
};

View File

@@ -29,18 +29,18 @@ sdltest_getFuzzerInvocationCount(void *arg)
{
Uint8 result;
int fuzzerCount1, fuzzerCount2;
fuzzerCount1 = SDLTest_GetFuzzerInvocationCount();
SDLTest_AssertPass("Call to SDLTest_GetFuzzerInvocationCount()");
SDLTest_AssertCheck(fuzzerCount1 >= 0, "Verify returned value, expected: >=0, got: %d", fuzzerCount1);
result = SDLTest_RandomUint8();
SDLTest_AssertPass("Call to SDLTest_RandomUint8(), returned %d", result);
fuzzerCount2 = SDLTest_GetFuzzerInvocationCount();
SDLTest_AssertPass("Call to SDLTest_GetFuzzerInvocationCount()");
SDLTest_AssertCheck(fuzzerCount2 > fuzzerCount1, "Verify returned value, expected: >%d, got: %d", fuzzerCount1, fuzzerCount2);
return TEST_COMPLETED;
}
@@ -56,7 +56,7 @@ sdltest_randomNumber(void *arg)
double dresult;
Uint64 umax;
Sint64 min, max;
result = (Sint64)SDLTest_RandomUint8();
umax = (1 << 8) - 1;
SDLTest_AssertPass("Call to SDLTest_RandomUint8");
@@ -67,7 +67,7 @@ sdltest_randomNumber(void *arg)
max = (1 << 7) - 1;
SDLTest_AssertPass("Call to SDLTest_RandomSint8");
SDLTest_AssertCheck(result >= min && result <= max, "Verify result value, expected: [%lld,%lld], got: %lld", min, max, result);
result = (Sint64)SDLTest_RandomUint16();
umax = (1 << 16) - 1;
SDLTest_AssertPass("Call to SDLTest_RandomUint16");
@@ -99,7 +99,7 @@ sdltest_randomNumber(void *arg)
dresult = (double)SDLTest_RandomUnitFloat();
SDLTest_AssertPass("Call to SDLTest_RandomUnitFloat");
SDLTest_AssertCheck(dresult >= 0.0 && dresult < 1.0, "Verify result value, expected: [0.0,1.0[, got: %e", dresult);
dresult = (double)SDLTest_RandomFloat();
SDLTest_AssertPass("Call to SDLTest_RandomFloat");
SDLTest_AssertCheck(dresult >= (double)(-FLT_MAX) && dresult <= (double)FLT_MAX, "Verify result value, expected: [%e,%e], got: %e", (double)(-FLT_MAX), (double)FLT_MAX, dresult);
@@ -110,7 +110,7 @@ sdltest_randomNumber(void *arg)
dresult = SDLTest_RandomDouble();
SDLTest_AssertPass("Call to SDLTest_RandomDouble");
return TEST_COMPLETED;
}
@@ -133,56 +133,56 @@ sdltest_randomBoundaryNumberUint8(void *arg)
SDLTest_AssertPass("Call to SDLTest_RandomUint8BoundaryValue");
SDLTest_AssertCheck(
uresult == 10,
"Validate result value for parameters (10,10,SDL_TRUE); expected: 10, got: %lld", uresult);
"Validate result value for parameters (10,10,SDL_TRUE); expected: 10, got: %lld", uresult);
/* RandomUintXBoundaryValue(10, 11, SDL_TRUE) returns 10, 11 */
uresult = (Uint64)SDLTest_RandomUint8BoundaryValue(10, 11, SDL_TRUE);
SDLTest_AssertPass("Call to SDLTest_RandomUint8BoundaryValue");
SDLTest_AssertCheck(
uresult == 10 || uresult == 11,
"Validate result value for parameters (10,11,SDL_TRUE); expected: 10|11, got: %lld", uresult);
"Validate result value for parameters (10,11,SDL_TRUE); expected: 10|11, got: %lld", uresult);
/* RandomUintXBoundaryValue(10, 12, SDL_TRUE) returns 10, 11, 12 */
uresult = (Uint64)SDLTest_RandomUint8BoundaryValue(10, 12, SDL_TRUE);
SDLTest_AssertPass("Call to SDLTest_RandomUint8BoundaryValue");
SDLTest_AssertCheck(
uresult == 10 || uresult == 11 || uresult == 12,
"Validate result value for parameters (10,12,SDL_TRUE); expected: 10|11|12, got: %lld", uresult);
"Validate result value for parameters (10,12,SDL_TRUE); expected: 10|11|12, got: %lld", uresult);
/* RandomUintXBoundaryValue(10, 13, SDL_TRUE) returns 10, 11, 12, 13 */
uresult = (Uint64)SDLTest_RandomUint8BoundaryValue(10, 13, SDL_TRUE);
SDLTest_AssertPass("Call to SDLTest_RandomUint8BoundaryValue");
SDLTest_AssertCheck(
uresult == 10 || uresult == 11 || uresult == 12 || uresult == 13,
"Validate result value for parameters (10,13,SDL_TRUE); expected: 10|11|12|13, got: %lld", uresult);
"Validate result value for parameters (10,13,SDL_TRUE); expected: 10|11|12|13, got: %lld", uresult);
/* RandomUintXBoundaryValue(10, 20, SDL_TRUE) returns 10, 11, 19 or 20 */
uresult = (Uint64)SDLTest_RandomUint8BoundaryValue(10, 20, SDL_TRUE);
SDLTest_AssertPass("Call to SDLTest_RandomUint8BoundaryValue");
SDLTest_AssertCheck(
uresult == 10 || uresult == 11 || uresult == 19 || uresult == 20,
"Validate result value for parameters (10,20,SDL_TRUE); expected: 10|11|19|20, got: %lld", uresult);
"Validate result value for parameters (10,20,SDL_TRUE); expected: 10|11|19|20, got: %lld", uresult);
/* RandomUintXBoundaryValue(20, 10, SDL_TRUE) returns 10, 11, 19 or 20 */
uresult = (Uint64)SDLTest_RandomUint8BoundaryValue(20, 10, SDL_TRUE);
SDLTest_AssertPass("Call to SDLTest_RandomUint8BoundaryValue");
SDLTest_AssertCheck(
uresult == 10 || uresult == 11 || uresult == 19 || uresult == 20,
"Validate result value for parameters (20,10,SDL_TRUE); expected: 10|11|19|20, got: %lld", uresult);
"Validate result value for parameters (20,10,SDL_TRUE); expected: 10|11|19|20, got: %lld", uresult);
/* RandomUintXBoundaryValue(1, 20, SDL_FALSE) returns 0, 21 */
uresult = (Uint64)SDLTest_RandomUint8BoundaryValue(1, 20, SDL_FALSE);
SDLTest_AssertPass("Call to SDLTest_RandomUint8BoundaryValue");
SDLTest_AssertCheck(
uresult == 0 || uresult == 21,
"Validate result value for parameters (1,20,SDL_FALSE); expected: 0|21, got: %lld", uresult);
"Validate result value for parameters (1,20,SDL_FALSE); expected: 0|21, got: %lld", uresult);
/* RandomUintXBoundaryValue(0, 99, SDL_FALSE) returns 100 */
uresult = (Uint64)SDLTest_RandomUint8BoundaryValue(0, 99, SDL_FALSE);
SDLTest_AssertPass("Call to SDLTest_RandomUint8BoundaryValue");
SDLTest_AssertCheck(
uresult == 100,
"Validate result value for parameters (0,99,SDL_FALSE); expected: 100, got: %lld", uresult);
"Validate result value for parameters (0,99,SDL_FALSE); expected: 100, got: %lld", uresult);
/* RandomUintXBoundaryValue(1, 0xff, SDL_FALSE) returns 0 (no error) */
uresult = (Uint64)SDLTest_RandomUint8BoundaryValue(1, 255, SDL_FALSE);
@@ -243,56 +243,56 @@ sdltest_randomBoundaryNumberUint16(void *arg)
SDLTest_AssertPass("Call to SDLTest_RandomUint16BoundaryValue");
SDLTest_AssertCheck(
uresult == 10,
"Validate result value for parameters (10,10,SDL_TRUE); expected: 10, got: %lld", uresult);
"Validate result value for parameters (10,10,SDL_TRUE); expected: 10, got: %lld", uresult);
/* RandomUintXBoundaryValue(10, 11, SDL_TRUE) returns 10, 11 */
uresult = (Uint64)SDLTest_RandomUint16BoundaryValue(10, 11, SDL_TRUE);
SDLTest_AssertPass("Call to SDLTest_RandomUint16BoundaryValue");
SDLTest_AssertCheck(
uresult == 10 || uresult == 11,
"Validate result value for parameters (10,11,SDL_TRUE); expected: 10|11, got: %lld", uresult);
"Validate result value for parameters (10,11,SDL_TRUE); expected: 10|11, got: %lld", uresult);
/* RandomUintXBoundaryValue(10, 12, SDL_TRUE) returns 10, 11, 12 */
uresult = (Uint64)SDLTest_RandomUint16BoundaryValue(10, 12, SDL_TRUE);
SDLTest_AssertPass("Call to SDLTest_RandomUint16BoundaryValue");
SDLTest_AssertCheck(
uresult == 10 || uresult == 11 || uresult == 12,
"Validate result value for parameters (10,12,SDL_TRUE); expected: 10|11|12, got: %lld", uresult);
"Validate result value for parameters (10,12,SDL_TRUE); expected: 10|11|12, got: %lld", uresult);
/* RandomUintXBoundaryValue(10, 13, SDL_TRUE) returns 10, 11, 12, 13 */
uresult = (Uint64)SDLTest_RandomUint16BoundaryValue(10, 13, SDL_TRUE);
SDLTest_AssertPass("Call to SDLTest_RandomUint16BoundaryValue");
SDLTest_AssertCheck(
uresult == 10 || uresult == 11 || uresult == 12 || uresult == 13,
"Validate result value for parameters (10,13,SDL_TRUE); expected: 10|11|12|13, got: %lld", uresult);
"Validate result value for parameters (10,13,SDL_TRUE); expected: 10|11|12|13, got: %lld", uresult);
/* RandomUintXBoundaryValue(10, 20, SDL_TRUE) returns 10, 11, 19 or 20 */
uresult = (Uint64)SDLTest_RandomUint16BoundaryValue(10, 20, SDL_TRUE);
SDLTest_AssertPass("Call to SDLTest_RandomUint16BoundaryValue");
SDLTest_AssertCheck(
uresult == 10 || uresult == 11 || uresult == 19 || uresult == 20,
"Validate result value for parameters (10,20,SDL_TRUE); expected: 10|11|19|20, got: %lld", uresult);
"Validate result value for parameters (10,20,SDL_TRUE); expected: 10|11|19|20, got: %lld", uresult);
/* RandomUintXBoundaryValue(20, 10, SDL_TRUE) returns 10, 11, 19 or 20 */
uresult = (Uint64)SDLTest_RandomUint16BoundaryValue(20, 10, SDL_TRUE);
SDLTest_AssertPass("Call to SDLTest_RandomUint16BoundaryValue");
SDLTest_AssertCheck(
uresult == 10 || uresult == 11 || uresult == 19 || uresult == 20,
"Validate result value for parameters (20,10,SDL_TRUE); expected: 10|11|19|20, got: %lld", uresult);
"Validate result value for parameters (20,10,SDL_TRUE); expected: 10|11|19|20, got: %lld", uresult);
/* RandomUintXBoundaryValue(1, 20, SDL_FALSE) returns 0, 21 */
uresult = (Uint64)SDLTest_RandomUint16BoundaryValue(1, 20, SDL_FALSE);
SDLTest_AssertPass("Call to SDLTest_RandomUint16BoundaryValue");
SDLTest_AssertCheck(
uresult == 0 || uresult == 21,
"Validate result value for parameters (1,20,SDL_FALSE); expected: 0|21, got: %lld", uresult);
"Validate result value for parameters (1,20,SDL_FALSE); expected: 0|21, got: %lld", uresult);
/* RandomUintXBoundaryValue(0, 99, SDL_FALSE) returns 100 */
uresult = (Uint64)SDLTest_RandomUint16BoundaryValue(0, 99, SDL_FALSE);
SDLTest_AssertPass("Call to SDLTest_RandomUint16BoundaryValue");
SDLTest_AssertCheck(
uresult == 100,
"Validate result value for parameters (0,99,SDL_FALSE); expected: 100, got: %lld", uresult);
"Validate result value for parameters (0,99,SDL_FALSE); expected: 100, got: %lld", uresult);
/* RandomUintXBoundaryValue(1, 0xffff, SDL_FALSE) returns 0 (no error) */
uresult = (Uint64)SDLTest_RandomUint16BoundaryValue(1, 0xffff, SDL_FALSE);
@@ -333,7 +333,7 @@ sdltest_randomBoundaryNumberUint16(void *arg)
return TEST_COMPLETED;
}
/*
* @brief Calls to random boundary number generators for Uint32
*/
@@ -353,56 +353,56 @@ sdltest_randomBoundaryNumberUint32(void *arg)
SDLTest_AssertPass("Call to SDLTest_RandomUint32BoundaryValue");
SDLTest_AssertCheck(
uresult == 10,
"Validate result value for parameters (10,10,SDL_TRUE); expected: 10, got: %lld", uresult);
"Validate result value for parameters (10,10,SDL_TRUE); expected: 10, got: %lld", uresult);
/* RandomUintXBoundaryValue(10, 11, SDL_TRUE) returns 10, 11 */
uresult = (Uint64)SDLTest_RandomUint32BoundaryValue(10, 11, SDL_TRUE);
SDLTest_AssertPass("Call to SDLTest_RandomUint32BoundaryValue");
SDLTest_AssertCheck(
uresult == 10 || uresult == 11,
"Validate result value for parameters (10,11,SDL_TRUE); expected: 10|11, got: %lld", uresult);
"Validate result value for parameters (10,11,SDL_TRUE); expected: 10|11, got: %lld", uresult);
/* RandomUintXBoundaryValue(10, 12, SDL_TRUE) returns 10, 11, 12 */
uresult = (Uint64)SDLTest_RandomUint32BoundaryValue(10, 12, SDL_TRUE);
SDLTest_AssertPass("Call to SDLTest_RandomUint32BoundaryValue");
SDLTest_AssertCheck(
uresult == 10 || uresult == 11 || uresult == 12,
"Validate result value for parameters (10,12,SDL_TRUE); expected: 10|11|12, got: %lld", uresult);
"Validate result value for parameters (10,12,SDL_TRUE); expected: 10|11|12, got: %lld", uresult);
/* RandomUintXBoundaryValue(10, 13, SDL_TRUE) returns 10, 11, 12, 13 */
uresult = (Uint64)SDLTest_RandomUint32BoundaryValue(10, 13, SDL_TRUE);
SDLTest_AssertPass("Call to SDLTest_RandomUint32BoundaryValue");
SDLTest_AssertCheck(
uresult == 10 || uresult == 11 || uresult == 12 || uresult == 13,
"Validate result value for parameters (10,13,SDL_TRUE); expected: 10|11|12|13, got: %lld", uresult);
"Validate result value for parameters (10,13,SDL_TRUE); expected: 10|11|12|13, got: %lld", uresult);
/* RandomUintXBoundaryValue(10, 20, SDL_TRUE) returns 10, 11, 19 or 20 */
uresult = (Uint64)SDLTest_RandomUint32BoundaryValue(10, 20, SDL_TRUE);
SDLTest_AssertPass("Call to SDLTest_RandomUint32BoundaryValue");
SDLTest_AssertCheck(
uresult == 10 || uresult == 11 || uresult == 19 || uresult == 20,
"Validate result value for parameters (10,20,SDL_TRUE); expected: 10|11|19|20, got: %lld", uresult);
"Validate result value for parameters (10,20,SDL_TRUE); expected: 10|11|19|20, got: %lld", uresult);
/* RandomUintXBoundaryValue(20, 10, SDL_TRUE) returns 10, 11, 19 or 20 */
uresult = (Uint64)SDLTest_RandomUint32BoundaryValue(20, 10, SDL_TRUE);
SDLTest_AssertPass("Call to SDLTest_RandomUint32BoundaryValue");
SDLTest_AssertCheck(
uresult == 10 || uresult == 11 || uresult == 19 || uresult == 20,
"Validate result value for parameters (20,10,SDL_TRUE); expected: 10|11|19|20, got: %lld", uresult);
"Validate result value for parameters (20,10,SDL_TRUE); expected: 10|11|19|20, got: %lld", uresult);
/* RandomUintXBoundaryValue(1, 20, SDL_FALSE) returns 0, 21 */
uresult = (Uint64)SDLTest_RandomUint32BoundaryValue(1, 20, SDL_FALSE);
SDLTest_AssertPass("Call to SDLTest_RandomUint32BoundaryValue");
SDLTest_AssertCheck(
uresult == 0 || uresult == 21,
"Validate result value for parameters (1,20,SDL_FALSE); expected: 0|21, got: %lld", uresult);
"Validate result value for parameters (1,20,SDL_FALSE); expected: 0|21, got: %lld", uresult);
/* RandomUintXBoundaryValue(0, 99, SDL_FALSE) returns 100 */
uresult = (Uint64)SDLTest_RandomUint32BoundaryValue(0, 99, SDL_FALSE);
SDLTest_AssertPass("Call to SDLTest_RandomUint32BoundaryValue");
SDLTest_AssertCheck(
uresult == 100,
"Validate result value for parameters (0,99,SDL_FALSE); expected: 100, got: %lld", uresult);
"Validate result value for parameters (0,99,SDL_FALSE); expected: 100, got: %lld", uresult);
/* RandomUintXBoundaryValue(1, 0xffffffff, SDL_FALSE) returns 0 (no error) */
uresult = (Uint64)SDLTest_RandomUint32BoundaryValue(1, 0xffffffff, SDL_FALSE);
@@ -463,56 +463,56 @@ sdltest_randomBoundaryNumberUint64(void *arg)
SDLTest_AssertPass("Call to SDLTest_RandomUint64BoundaryValue");
SDLTest_AssertCheck(
uresult == 10,
"Validate result value for parameters (10,10,SDL_TRUE); expected: 10, got: %lld", uresult);
"Validate result value for parameters (10,10,SDL_TRUE); expected: 10, got: %lld", uresult);
/* RandomUintXBoundaryValue(10, 11, SDL_TRUE) returns 10, 11 */
uresult = (Uint64)SDLTest_RandomUint64BoundaryValue(10, 11, SDL_TRUE);
SDLTest_AssertPass("Call to SDLTest_RandomUint64BoundaryValue");
SDLTest_AssertCheck(
uresult == 10 || uresult == 11,
"Validate result value for parameters (10,11,SDL_TRUE); expected: 10|11, got: %lld", uresult);
"Validate result value for parameters (10,11,SDL_TRUE); expected: 10|11, got: %lld", uresult);
/* RandomUintXBoundaryValue(10, 12, SDL_TRUE) returns 10, 11, 12 */
uresult = (Uint64)SDLTest_RandomUint64BoundaryValue(10, 12, SDL_TRUE);
SDLTest_AssertPass("Call to SDLTest_RandomUint64BoundaryValue");
SDLTest_AssertCheck(
uresult == 10 || uresult == 11 || uresult == 12,
"Validate result value for parameters (10,12,SDL_TRUE); expected: 10|11|12, got: %lld", uresult);
"Validate result value for parameters (10,12,SDL_TRUE); expected: 10|11|12, got: %lld", uresult);
/* RandomUintXBoundaryValue(10, 13, SDL_TRUE) returns 10, 11, 12, 13 */
uresult = (Uint64)SDLTest_RandomUint64BoundaryValue(10, 13, SDL_TRUE);
SDLTest_AssertPass("Call to SDLTest_RandomUint64BoundaryValue");
SDLTest_AssertCheck(
uresult == 10 || uresult == 11 || uresult == 12 || uresult == 13,
"Validate result value for parameters (10,13,SDL_TRUE); expected: 10|11|12|13, got: %lld", uresult);
"Validate result value for parameters (10,13,SDL_TRUE); expected: 10|11|12|13, got: %lld", uresult);
/* RandomUintXBoundaryValue(10, 20, SDL_TRUE) returns 10, 11, 19 or 20 */
uresult = (Uint64)SDLTest_RandomUint64BoundaryValue(10, 20, SDL_TRUE);
SDLTest_AssertPass("Call to SDLTest_RandomUint64BoundaryValue");
SDLTest_AssertCheck(
uresult == 10 || uresult == 11 || uresult == 19 || uresult == 20,
"Validate result value for parameters (10,20,SDL_TRUE); expected: 10|11|19|20, got: %lld", uresult);
"Validate result value for parameters (10,20,SDL_TRUE); expected: 10|11|19|20, got: %lld", uresult);
/* RandomUintXBoundaryValue(20, 10, SDL_TRUE) returns 10, 11, 19 or 20 */
uresult = (Uint64)SDLTest_RandomUint64BoundaryValue(20, 10, SDL_TRUE);
SDLTest_AssertPass("Call to SDLTest_RandomUint64BoundaryValue");
SDLTest_AssertCheck(
uresult == 10 || uresult == 11 || uresult == 19 || uresult == 20,
"Validate result value for parameters (20,10,SDL_TRUE); expected: 10|11|19|20, got: %lld", uresult);
"Validate result value for parameters (20,10,SDL_TRUE); expected: 10|11|19|20, got: %lld", uresult);
/* RandomUintXBoundaryValue(1, 20, SDL_FALSE) returns 0, 21 */
uresult = (Uint64)SDLTest_RandomUint64BoundaryValue(1, 20, SDL_FALSE);
SDLTest_AssertPass("Call to SDLTest_RandomUint64BoundaryValue");
SDLTest_AssertCheck(
uresult == 0 || uresult == 21,
"Validate result value for parameters (1,20,SDL_FALSE); expected: 0|21, got: %lld", uresult);
"Validate result value for parameters (1,20,SDL_FALSE); expected: 0|21, got: %lld", uresult);
/* RandomUintXBoundaryValue(0, 99, SDL_FALSE) returns 100 */
uresult = (Uint64)SDLTest_RandomUint64BoundaryValue(0, 99, SDL_FALSE);
SDLTest_AssertPass("Call to SDLTest_RandomUint64BoundaryValue");
SDLTest_AssertCheck(
uresult == 100,
"Validate result value for parameters (0,99,SDL_FALSE); expected: 100, got: %lld", uresult);
"Validate result value for parameters (0,99,SDL_FALSE); expected: 100, got: %lld", uresult);
/* RandomUintXBoundaryValue(1, 0xffffffffffffffff, SDL_FALSE) returns 0 (no error) */
uresult = (Uint64)SDLTest_RandomUint64BoundaryValue(1, (Uint64)0xffffffffffffffffULL, SDL_FALSE);
@@ -573,56 +573,56 @@ sdltest_randomBoundaryNumberSint8(void *arg)
SDLTest_AssertPass("Call to SDLTest_RandomSint8BoundaryValue");
SDLTest_AssertCheck(
sresult == 10,
"Validate result value for parameters (10,10,SDL_TRUE); expected: 10, got: %lld", sresult);
"Validate result value for parameters (10,10,SDL_TRUE); expected: 10, got: %lld", sresult);
/* RandomSintXBoundaryValue(10, 11, SDL_TRUE) returns 10, 11 */
sresult = (Sint64)SDLTest_RandomSint8BoundaryValue(10, 11, SDL_TRUE);
SDLTest_AssertPass("Call to SDLTest_RandomSint8BoundaryValue");
SDLTest_AssertCheck(
sresult == 10 || sresult == 11,
"Validate result value for parameters (10,11,SDL_TRUE); expected: 10|11, got: %lld", sresult);
"Validate result value for parameters (10,11,SDL_TRUE); expected: 10|11, got: %lld", sresult);
/* RandomSintXBoundaryValue(10, 12, SDL_TRUE) returns 10, 11, 12 */
sresult = (Sint64)SDLTest_RandomSint8BoundaryValue(10, 12, SDL_TRUE);
SDLTest_AssertPass("Call to SDLTest_RandomSint8BoundaryValue");
SDLTest_AssertCheck(
sresult == 10 || sresult == 11 || sresult == 12,
"Validate result value for parameters (10,12,SDL_TRUE); expected: 10|11|12, got: %lld", sresult);
"Validate result value for parameters (10,12,SDL_TRUE); expected: 10|11|12, got: %lld", sresult);
/* RandomSintXBoundaryValue(10, 13, SDL_TRUE) returns 10, 11, 12, 13 */
sresult = (Sint64)SDLTest_RandomSint8BoundaryValue(10, 13, SDL_TRUE);
SDLTest_AssertPass("Call to SDLTest_RandomSint8BoundaryValue");
SDLTest_AssertCheck(
sresult == 10 || sresult == 11 || sresult == 12 || sresult == 13,
"Validate result value for parameters (10,13,SDL_TRUE); expected: 10|11|12|13, got: %lld", sresult);
"Validate result value for parameters (10,13,SDL_TRUE); expected: 10|11|12|13, got: %lld", sresult);
/* RandomSintXBoundaryValue(10, 20, SDL_TRUE) returns 10, 11, 19 or 20 */
sresult = (Sint64)SDLTest_RandomSint8BoundaryValue(10, 20, SDL_TRUE);
SDLTest_AssertPass("Call to SDLTest_RandomSint8BoundaryValue");
SDLTest_AssertCheck(
sresult == 10 || sresult == 11 || sresult == 19 || sresult == 20,
"Validate result value for parameters (10,20,SDL_TRUE); expected: 10|11|19|20, got: %lld", sresult);
"Validate result value for parameters (10,20,SDL_TRUE); expected: 10|11|19|20, got: %lld", sresult);
/* RandomSintXBoundaryValue(20, 10, SDL_TRUE) returns 10, 11, 19 or 20 */
sresult = (Sint64)SDLTest_RandomSint8BoundaryValue(20, 10, SDL_TRUE);
SDLTest_AssertPass("Call to SDLTest_RandomSint8BoundaryValue");
SDLTest_AssertCheck(
sresult == 10 || sresult == 11 || sresult == 19 || sresult == 20,
"Validate result value for parameters (20,10,SDL_TRUE); expected: 10|11|19|20, got: %lld", sresult);
"Validate result value for parameters (20,10,SDL_TRUE); expected: 10|11|19|20, got: %lld", sresult);
/* RandomSintXBoundaryValue(1, 20, SDL_FALSE) returns 0, 21 */
sresult = (Sint64)SDLTest_RandomSint8BoundaryValue(1, 20, SDL_FALSE);
SDLTest_AssertPass("Call to SDLTest_RandomSint8BoundaryValue");
SDLTest_AssertCheck(
sresult == 0 || sresult == 21,
"Validate result value for parameters (1,20,SDL_FALSE); expected: 0|21, got: %lld", sresult);
"Validate result value for parameters (1,20,SDL_FALSE); expected: 0|21, got: %lld", sresult);
/* RandomSintXBoundaryValue(SCHAR_MIN, 99, SDL_FALSE) returns 100 */
sresult = (Sint64)SDLTest_RandomSint8BoundaryValue(SCHAR_MIN, 99, SDL_FALSE);
SDLTest_AssertPass("Call to SDLTest_RandomSint8BoundaryValue");
SDLTest_AssertCheck(
sresult == 100,
"Validate result value for parameters (SCHAR_MIN,99,SDL_FALSE); expected: 100, got: %lld", sresult);
"Validate result value for parameters (SCHAR_MIN,99,SDL_FALSE); expected: 100, got: %lld", sresult);
/* RandomSintXBoundaryValue(SCHAR_MIN + 1, SCHAR_MAX, SDL_FALSE) returns SCHAR_MIN (no error) */
sresult = (Sint64)SDLTest_RandomSint8BoundaryValue(SCHAR_MIN + 1, SCHAR_MAX, SDL_FALSE);
@@ -660,7 +660,7 @@ sdltest_randomBoundaryNumberSint8(void *arg)
/* Clear error messages */
SDL_ClearError();
SDLTest_AssertPass("SDL_ClearError()");
return TEST_COMPLETED;
}
@@ -683,56 +683,56 @@ sdltest_randomBoundaryNumberSint16(void *arg)
SDLTest_AssertPass("Call to SDLTest_RandomSint16BoundaryValue");
SDLTest_AssertCheck(
sresult == 10,
"Validate result value for parameters (10,10,SDL_TRUE); expected: 10, got: %lld", sresult);
"Validate result value for parameters (10,10,SDL_TRUE); expected: 10, got: %lld", sresult);
/* RandomSintXBoundaryValue(10, 11, SDL_TRUE) returns 10, 11 */
sresult = (Sint64)SDLTest_RandomSint16BoundaryValue(10, 11, SDL_TRUE);
SDLTest_AssertPass("Call to SDLTest_RandomSint16BoundaryValue");
SDLTest_AssertCheck(
sresult == 10 || sresult == 11,
"Validate result value for parameters (10,11,SDL_TRUE); expected: 10|11, got: %lld", sresult);
"Validate result value for parameters (10,11,SDL_TRUE); expected: 10|11, got: %lld", sresult);
/* RandomSintXBoundaryValue(10, 12, SDL_TRUE) returns 10, 11, 12 */
sresult = (Sint64)SDLTest_RandomSint16BoundaryValue(10, 12, SDL_TRUE);
SDLTest_AssertPass("Call to SDLTest_RandomSint16BoundaryValue");
SDLTest_AssertCheck(
sresult == 10 || sresult == 11 || sresult == 12,
"Validate result value for parameters (10,12,SDL_TRUE); expected: 10|11|12, got: %lld", sresult);
"Validate result value for parameters (10,12,SDL_TRUE); expected: 10|11|12, got: %lld", sresult);
/* RandomSintXBoundaryValue(10, 13, SDL_TRUE) returns 10, 11, 12, 13 */
sresult = (Sint64)SDLTest_RandomSint16BoundaryValue(10, 13, SDL_TRUE);
SDLTest_AssertPass("Call to SDLTest_RandomSint16BoundaryValue");
SDLTest_AssertCheck(
sresult == 10 || sresult == 11 || sresult == 12 || sresult == 13,
"Validate result value for parameters (10,13,SDL_TRUE); expected: 10|11|12|13, got: %lld", sresult);
"Validate result value for parameters (10,13,SDL_TRUE); expected: 10|11|12|13, got: %lld", sresult);
/* RandomSintXBoundaryValue(10, 20, SDL_TRUE) returns 10, 11, 19 or 20 */
sresult = (Sint64)SDLTest_RandomSint16BoundaryValue(10, 20, SDL_TRUE);
SDLTest_AssertPass("Call to SDLTest_RandomSint16BoundaryValue");
SDLTest_AssertCheck(
sresult == 10 || sresult == 11 || sresult == 19 || sresult == 20,
"Validate result value for parameters (10,20,SDL_TRUE); expected: 10|11|19|20, got: %lld", sresult);
"Validate result value for parameters (10,20,SDL_TRUE); expected: 10|11|19|20, got: %lld", sresult);
/* RandomSintXBoundaryValue(20, 10, SDL_TRUE) returns 10, 11, 19 or 20 */
sresult = (Sint64)SDLTest_RandomSint16BoundaryValue(20, 10, SDL_TRUE);
SDLTest_AssertPass("Call to SDLTest_RandomSint16BoundaryValue");
SDLTest_AssertCheck(
sresult == 10 || sresult == 11 || sresult == 19 || sresult == 20,
"Validate result value for parameters (20,10,SDL_TRUE); expected: 10|11|19|20, got: %lld", sresult);
"Validate result value for parameters (20,10,SDL_TRUE); expected: 10|11|19|20, got: %lld", sresult);
/* RandomSintXBoundaryValue(1, 20, SDL_FALSE) returns 0, 21 */
sresult = (Sint64)SDLTest_RandomSint16BoundaryValue(1, 20, SDL_FALSE);
SDLTest_AssertPass("Call to SDLTest_RandomSint16BoundaryValue");
SDLTest_AssertCheck(
sresult == 0 || sresult == 21,
"Validate result value for parameters (1,20,SDL_FALSE); expected: 0|21, got: %lld", sresult);
"Validate result value for parameters (1,20,SDL_FALSE); expected: 0|21, got: %lld", sresult);
/* RandomSintXBoundaryValue(SHRT_MIN, 99, SDL_FALSE) returns 100 */
sresult = (Sint64)SDLTest_RandomSint16BoundaryValue(SHRT_MIN, 99, SDL_FALSE);
SDLTest_AssertPass("Call to SDLTest_RandomSint16BoundaryValue");
SDLTest_AssertCheck(
sresult == 100,
"Validate result value for parameters (SHRT_MIN,99,SDL_FALSE); expected: 100, got: %lld", sresult);
"Validate result value for parameters (SHRT_MIN,99,SDL_FALSE); expected: 100, got: %lld", sresult);
/* RandomSintXBoundaryValue(SHRT_MIN + 1, SHRT_MAX, SDL_FALSE) returns SHRT_MIN (no error) */
sresult = (Sint64)SDLTest_RandomSint16BoundaryValue(SHRT_MIN + 1, SHRT_MAX, SDL_FALSE);
@@ -773,7 +773,7 @@ sdltest_randomBoundaryNumberSint16(void *arg)
return TEST_COMPLETED;
}
/*
* @brief Calls to random boundary number generators for Sint32
*/
@@ -784,7 +784,7 @@ sdltest_randomBoundaryNumberSint32(void *arg)
char *lastError;
Sint64 sresult;
#if ((ULONG_MAX) == (UINT_MAX))
Sint32 long_min = LONG_MIN;
Sint32 long_min = LONG_MIN;
Sint32 long_max = LONG_MAX;
#else
Sint32 long_min = INT_MIN;
@@ -800,56 +800,56 @@ sdltest_randomBoundaryNumberSint32(void *arg)
SDLTest_AssertPass("Call to SDLTest_RandomSint32BoundaryValue");
SDLTest_AssertCheck(
sresult == 10,
"Validate result value for parameters (10,10,SDL_TRUE); expected: 10, got: %lld", sresult);
"Validate result value for parameters (10,10,SDL_TRUE); expected: 10, got: %lld", sresult);
/* RandomSintXBoundaryValue(10, 11, SDL_TRUE) returns 10, 11 */
sresult = (Sint64)SDLTest_RandomSint32BoundaryValue(10, 11, SDL_TRUE);
SDLTest_AssertPass("Call to SDLTest_RandomSint32BoundaryValue");
SDLTest_AssertCheck(
sresult == 10 || sresult == 11,
"Validate result value for parameters (10,11,SDL_TRUE); expected: 10|11, got: %lld", sresult);
"Validate result value for parameters (10,11,SDL_TRUE); expected: 10|11, got: %lld", sresult);
/* RandomSintXBoundaryValue(10, 12, SDL_TRUE) returns 10, 11, 12 */
sresult = (Sint64)SDLTest_RandomSint32BoundaryValue(10, 12, SDL_TRUE);
SDLTest_AssertPass("Call to SDLTest_RandomSint32BoundaryValue");
SDLTest_AssertCheck(
sresult == 10 || sresult == 11 || sresult == 12,
"Validate result value for parameters (10,12,SDL_TRUE); expected: 10|11|12, got: %lld", sresult);
"Validate result value for parameters (10,12,SDL_TRUE); expected: 10|11|12, got: %lld", sresult);
/* RandomSintXBoundaryValue(10, 13, SDL_TRUE) returns 10, 11, 12, 13 */
sresult = (Sint64)SDLTest_RandomSint32BoundaryValue(10, 13, SDL_TRUE);
SDLTest_AssertPass("Call to SDLTest_RandomSint32BoundaryValue");
SDLTest_AssertCheck(
sresult == 10 || sresult == 11 || sresult == 12 || sresult == 13,
"Validate result value for parameters (10,13,SDL_TRUE); expected: 10|11|12|13, got: %lld", sresult);
"Validate result value for parameters (10,13,SDL_TRUE); expected: 10|11|12|13, got: %lld", sresult);
/* RandomSintXBoundaryValue(10, 20, SDL_TRUE) returns 10, 11, 19 or 20 */
sresult = (Sint64)SDLTest_RandomSint32BoundaryValue(10, 20, SDL_TRUE);
SDLTest_AssertPass("Call to SDLTest_RandomSint32BoundaryValue");
SDLTest_AssertCheck(
sresult == 10 || sresult == 11 || sresult == 19 || sresult == 20,
"Validate result value for parameters (10,20,SDL_TRUE); expected: 10|11|19|20, got: %lld", sresult);
"Validate result value for parameters (10,20,SDL_TRUE); expected: 10|11|19|20, got: %lld", sresult);
/* RandomSintXBoundaryValue(20, 10, SDL_TRUE) returns 10, 11, 19 or 20 */
sresult = (Sint64)SDLTest_RandomSint32BoundaryValue(20, 10, SDL_TRUE);
SDLTest_AssertPass("Call to SDLTest_RandomSint32BoundaryValue");
SDLTest_AssertCheck(
sresult == 10 || sresult == 11 || sresult == 19 || sresult == 20,
"Validate result value for parameters (20,10,SDL_TRUE); expected: 10|11|19|20, got: %lld", sresult);
"Validate result value for parameters (20,10,SDL_TRUE); expected: 10|11|19|20, got: %lld", sresult);
/* RandomSintXBoundaryValue(1, 20, SDL_FALSE) returns 0, 21 */
sresult = (Sint64)SDLTest_RandomSint32BoundaryValue(1, 20, SDL_FALSE);
SDLTest_AssertPass("Call to SDLTest_RandomSint32BoundaryValue");
SDLTest_AssertCheck(
sresult == 0 || sresult == 21,
"Validate result value for parameters (1,20,SDL_FALSE); expected: 0|21, got: %lld", sresult);
"Validate result value for parameters (1,20,SDL_FALSE); expected: 0|21, got: %lld", sresult);
/* RandomSintXBoundaryValue(LONG_MIN, 99, SDL_FALSE) returns 100 */
sresult = (Sint64)SDLTest_RandomSint32BoundaryValue(long_min, 99, SDL_FALSE);
SDLTest_AssertPass("Call to SDLTest_RandomSint32BoundaryValue");
SDLTest_AssertCheck(
sresult == 100,
"Validate result value for parameters (LONG_MIN,99,SDL_FALSE); expected: 100, got: %lld", sresult);
"Validate result value for parameters (LONG_MIN,99,SDL_FALSE); expected: 100, got: %lld", sresult);
/* RandomSintXBoundaryValue(LONG_MIN + 1, LONG_MAX, SDL_FALSE) returns LONG_MIN (no error) */
sresult = (Sint64)SDLTest_RandomSint32BoundaryValue(long_min + 1, long_max, SDL_FALSE);
@@ -910,56 +910,56 @@ sdltest_randomBoundaryNumberSint64(void *arg)
SDLTest_AssertPass("Call to SDLTest_RandomSint64BoundaryValue");
SDLTest_AssertCheck(
sresult == 10,
"Validate result value for parameters (10,10,SDL_TRUE); expected: 10, got: %lld", sresult);
"Validate result value for parameters (10,10,SDL_TRUE); expected: 10, got: %lld", sresult);
/* RandomSintXBoundaryValue(10, 11, SDL_TRUE) returns 10, 11 */
sresult = (Sint64)SDLTest_RandomSint64BoundaryValue(10, 11, SDL_TRUE);
SDLTest_AssertPass("Call to SDLTest_RandomSint64BoundaryValue");
SDLTest_AssertCheck(
sresult == 10 || sresult == 11,
"Validate result value for parameters (10,11,SDL_TRUE); expected: 10|11, got: %lld", sresult);
"Validate result value for parameters (10,11,SDL_TRUE); expected: 10|11, got: %lld", sresult);
/* RandomSintXBoundaryValue(10, 12, SDL_TRUE) returns 10, 11, 12 */
sresult = (Sint64)SDLTest_RandomSint64BoundaryValue(10, 12, SDL_TRUE);
SDLTest_AssertPass("Call to SDLTest_RandomSint64BoundaryValue");
SDLTest_AssertCheck(
sresult == 10 || sresult == 11 || sresult == 12,
"Validate result value for parameters (10,12,SDL_TRUE); expected: 10|11|12, got: %lld", sresult);
"Validate result value for parameters (10,12,SDL_TRUE); expected: 10|11|12, got: %lld", sresult);
/* RandomSintXBoundaryValue(10, 13, SDL_TRUE) returns 10, 11, 12, 13 */
sresult = (Sint64)SDLTest_RandomSint64BoundaryValue(10, 13, SDL_TRUE);
SDLTest_AssertPass("Call to SDLTest_RandomSint64BoundaryValue");
SDLTest_AssertCheck(
sresult == 10 || sresult == 11 || sresult == 12 || sresult == 13,
"Validate result value for parameters (10,13,SDL_TRUE); expected: 10|11|12|13, got: %lld", sresult);
"Validate result value for parameters (10,13,SDL_TRUE); expected: 10|11|12|13, got: %lld", sresult);
/* RandomSintXBoundaryValue(10, 20, SDL_TRUE) returns 10, 11, 19 or 20 */
sresult = (Sint64)SDLTest_RandomSint64BoundaryValue(10, 20, SDL_TRUE);
SDLTest_AssertPass("Call to SDLTest_RandomSint64BoundaryValue");
SDLTest_AssertCheck(
sresult == 10 || sresult == 11 || sresult == 19 || sresult == 20,
"Validate result value for parameters (10,20,SDL_TRUE); expected: 10|11|19|20, got: %lld", sresult);
"Validate result value for parameters (10,20,SDL_TRUE); expected: 10|11|19|20, got: %lld", sresult);
/* RandomSintXBoundaryValue(20, 10, SDL_TRUE) returns 10, 11, 19 or 20 */
sresult = (Sint64)SDLTest_RandomSint64BoundaryValue(20, 10, SDL_TRUE);
SDLTest_AssertPass("Call to SDLTest_RandomSint64BoundaryValue");
SDLTest_AssertCheck(
sresult == 10 || sresult == 11 || sresult == 19 || sresult == 20,
"Validate result value for parameters (20,10,SDL_TRUE); expected: 10|11|19|20, got: %lld", sresult);
"Validate result value for parameters (20,10,SDL_TRUE); expected: 10|11|19|20, got: %lld", sresult);
/* RandomSintXBoundaryValue(1, 20, SDL_FALSE) returns 0, 21 */
sresult = (Sint64)SDLTest_RandomSint64BoundaryValue(1, 20, SDL_FALSE);
SDLTest_AssertPass("Call to SDLTest_RandomSint64BoundaryValue");
SDLTest_AssertCheck(
sresult == 0 || sresult == 21,
"Validate result value for parameters (1,20,SDL_FALSE); expected: 0|21, got: %lld", sresult);
"Validate result value for parameters (1,20,SDL_FALSE); expected: 0|21, got: %lld", sresult);
/* RandomSintXBoundaryValue(LLONG_MIN, 99, SDL_FALSE) returns 100 */
sresult = (Sint64)SDLTest_RandomSint64BoundaryValue(LLONG_MIN, 99, SDL_FALSE);
SDLTest_AssertPass("Call to SDLTest_RandomSint64BoundaryValue");
SDLTest_AssertCheck(
sresult == 100,
"Validate result value for parameters (LLONG_MIN,99,SDL_FALSE); expected: 100, got: %lld", sresult);
"Validate result value for parameters (LLONG_MIN,99,SDL_FALSE); expected: 100, got: %lld", sresult);
/* RandomSintXBoundaryValue(LLONG_MIN + 1, LLONG_MAX, SDL_FALSE) returns LLONG_MIN (no error) */
sresult = (Sint64)SDLTest_RandomSint64BoundaryValue(LLONG_MIN + 1, LLONG_MAX, SDL_FALSE);
@@ -1010,7 +1010,7 @@ sdltest_randomIntegerInRange(void *arg)
Sint32 min, max;
Sint32 result;
#if ((ULONG_MAX) == (UINT_MAX))
Sint32 long_min = LONG_MIN;
Sint32 long_min = LONG_MIN;
Sint32 long_max = LONG_MAX;
#else
Sint32 long_min = INT_MIN;
@@ -1101,11 +1101,11 @@ sdltest_randomAsciiString(void *arg)
}
SDLTest_AssertCheck(nonAsciiCharacters == 0, "Validate that result does not contain non-Ascii characters, got: %d", nonAsciiCharacters);
if (nonAsciiCharacters) {
SDLTest_LogError("Invalid result from generator: '%s'", result);
SDLTest_LogError("Invalid result from generator: '%s'", result);
}
SDL_free(result);
SDL_free(result);
}
return TEST_COMPLETED;
}
@@ -1139,9 +1139,9 @@ sdltest_randomAsciiStringWithMaximumLength(void *arg)
}
SDLTest_AssertCheck(nonAsciiCharacters == 0, "Validate that result does not contain non-Ascii characters, got: %d", nonAsciiCharacters);
if (nonAsciiCharacters) {
SDLTest_LogError("Invalid result from generator: '%s'", result);
SDLTest_LogError("Invalid result from generator: '%s'", result);
}
SDL_free(result);
SDL_free(result);
}
/* Negative test */
@@ -1159,7 +1159,7 @@ sdltest_randomAsciiStringWithMaximumLength(void *arg)
/* Clear error messages */
SDL_ClearError();
SDLTest_AssertPass("SDL_ClearError()");
return TEST_COMPLETED;
}
@@ -1193,11 +1193,11 @@ sdltest_randomAsciiStringOfSize(void *arg)
}
SDLTest_AssertCheck(nonAsciiCharacters == 0, "Validate that result does not contain non-ASCII characters, got: %d", nonAsciiCharacters);
if (nonAsciiCharacters) {
SDLTest_LogError("Invalid result from generator: '%s'", result);
SDLTest_LogError("Invalid result from generator: '%s'", result);
}
SDL_free(result);
SDL_free(result);
}
/* Negative test */
targetLen = 0;
result = SDLTest_RandomAsciiStringOfSize(targetLen);
@@ -1213,7 +1213,7 @@ sdltest_randomAsciiStringOfSize(void *arg)
/* Clear error messages */
SDL_ClearError();
SDLTest_AssertPass("SDL_ClearError()");
return TEST_COMPLETED;
}
@@ -1222,58 +1222,58 @@ sdltest_randomAsciiStringOfSize(void *arg)
/* SDL_test test cases */
static const SDLTest_TestCaseReference sdltestTest1 =
{ (SDLTest_TestCaseFp)sdltest_getFuzzerInvocationCount, "sdltest_getFuzzerInvocationCount", "Call to sdltest_GetFuzzerInvocationCount", TEST_ENABLED };
{ (SDLTest_TestCaseFp)sdltest_getFuzzerInvocationCount, "sdltest_getFuzzerInvocationCount", "Call to sdltest_GetFuzzerInvocationCount", TEST_ENABLED };
static const SDLTest_TestCaseReference sdltestTest2 =
{ (SDLTest_TestCaseFp)sdltest_randomNumber, "sdltest_randomNumber", "Calls to random number generators", TEST_ENABLED };
{ (SDLTest_TestCaseFp)sdltest_randomNumber, "sdltest_randomNumber", "Calls to random number generators", TEST_ENABLED };
static const SDLTest_TestCaseReference sdltestTest3 =
{ (SDLTest_TestCaseFp)sdltest_randomBoundaryNumberUint8, "sdltest_randomBoundaryNumberUint8", "Calls to random boundary number generators for Uint8", TEST_ENABLED };
{ (SDLTest_TestCaseFp)sdltest_randomBoundaryNumberUint8, "sdltest_randomBoundaryNumberUint8", "Calls to random boundary number generators for Uint8", TEST_ENABLED };
static const SDLTest_TestCaseReference sdltestTest4 =
{ (SDLTest_TestCaseFp)sdltest_randomBoundaryNumberUint16, "sdltest_randomBoundaryNumberUint16", "Calls to random boundary number generators for Uint16", TEST_ENABLED };
{ (SDLTest_TestCaseFp)sdltest_randomBoundaryNumberUint16, "sdltest_randomBoundaryNumberUint16", "Calls to random boundary number generators for Uint16", TEST_ENABLED };
static const SDLTest_TestCaseReference sdltestTest5 =
{ (SDLTest_TestCaseFp)sdltest_randomBoundaryNumberUint32, "sdltest_randomBoundaryNumberUint32", "Calls to random boundary number generators for Uint32", TEST_ENABLED };
{ (SDLTest_TestCaseFp)sdltest_randomBoundaryNumberUint32, "sdltest_randomBoundaryNumberUint32", "Calls to random boundary number generators for Uint32", TEST_ENABLED };
static const SDLTest_TestCaseReference sdltestTest6 =
{ (SDLTest_TestCaseFp)sdltest_randomBoundaryNumberUint64, "sdltest_randomBoundaryNumberUint64", "Calls to random boundary number generators for Uint64", TEST_ENABLED };
{ (SDLTest_TestCaseFp)sdltest_randomBoundaryNumberUint64, "sdltest_randomBoundaryNumberUint64", "Calls to random boundary number generators for Uint64", TEST_ENABLED };
static const SDLTest_TestCaseReference sdltestTest7 =
{ (SDLTest_TestCaseFp)sdltest_randomBoundaryNumberSint8, "sdltest_randomBoundaryNumberSint8", "Calls to random boundary number generators for Sint8", TEST_ENABLED };
{ (SDLTest_TestCaseFp)sdltest_randomBoundaryNumberSint8, "sdltest_randomBoundaryNumberSint8", "Calls to random boundary number generators for Sint8", TEST_ENABLED };
static const SDLTest_TestCaseReference sdltestTest8 =
{ (SDLTest_TestCaseFp)sdltest_randomBoundaryNumberSint16, "sdltest_randomBoundaryNumberSint16", "Calls to random boundary number generators for Sint16", TEST_ENABLED };
{ (SDLTest_TestCaseFp)sdltest_randomBoundaryNumberSint16, "sdltest_randomBoundaryNumberSint16", "Calls to random boundary number generators for Sint16", TEST_ENABLED };
static const SDLTest_TestCaseReference sdltestTest9 =
{ (SDLTest_TestCaseFp)sdltest_randomBoundaryNumberSint32, "sdltest_randomBoundaryNumberSint32", "Calls to random boundary number generators for Sint32", TEST_ENABLED };
{ (SDLTest_TestCaseFp)sdltest_randomBoundaryNumberSint32, "sdltest_randomBoundaryNumberSint32", "Calls to random boundary number generators for Sint32", TEST_ENABLED };
static const SDLTest_TestCaseReference sdltestTest10 =
{ (SDLTest_TestCaseFp)sdltest_randomBoundaryNumberSint64, "sdltest_randomBoundaryNumberSint64", "Calls to random boundary number generators for Sint64", TEST_ENABLED };
{ (SDLTest_TestCaseFp)sdltest_randomBoundaryNumberSint64, "sdltest_randomBoundaryNumberSint64", "Calls to random boundary number generators for Sint64", TEST_ENABLED };
static const SDLTest_TestCaseReference sdltestTest11 =
{ (SDLTest_TestCaseFp)sdltest_randomIntegerInRange, "sdltest_randomIntegerInRange", "Calls to ranged random number generator", TEST_ENABLED };
{ (SDLTest_TestCaseFp)sdltest_randomIntegerInRange, "sdltest_randomIntegerInRange", "Calls to ranged random number generator", TEST_ENABLED };
static const SDLTest_TestCaseReference sdltestTest12 =
{ (SDLTest_TestCaseFp)sdltest_randomAsciiString, "sdltest_randomAsciiString", "Calls to default ASCII string generator", TEST_ENABLED };
{ (SDLTest_TestCaseFp)sdltest_randomAsciiString, "sdltest_randomAsciiString", "Calls to default ASCII string generator", TEST_ENABLED };
static const SDLTest_TestCaseReference sdltestTest13 =
{ (SDLTest_TestCaseFp)sdltest_randomAsciiStringWithMaximumLength, "sdltest_randomAsciiStringWithMaximumLength", "Calls to random maximum length ASCII string generator", TEST_ENABLED };
{ (SDLTest_TestCaseFp)sdltest_randomAsciiStringWithMaximumLength, "sdltest_randomAsciiStringWithMaximumLength", "Calls to random maximum length ASCII string generator", TEST_ENABLED };
static const SDLTest_TestCaseReference sdltestTest14 =
{ (SDLTest_TestCaseFp)sdltest_randomAsciiStringOfSize, "sdltest_randomAsciiStringOfSize", "Calls to fixed size ASCII string generator", TEST_ENABLED };
{ (SDLTest_TestCaseFp)sdltest_randomAsciiStringOfSize, "sdltest_randomAsciiStringOfSize", "Calls to fixed size ASCII string generator", TEST_ENABLED };
/* Sequence of SDL_test test cases */
static const SDLTest_TestCaseReference *sdltestTests[] = {
&sdltestTest1, &sdltestTest2, &sdltestTest3, &sdltestTest4, &sdltestTest5, &sdltestTest6,
&sdltestTest7, &sdltestTest8, &sdltestTest9, &sdltestTest10, &sdltestTest11, &sdltestTest12,
&sdltestTest13, &sdltestTest14, NULL
&sdltestTest1, &sdltestTest2, &sdltestTest3, &sdltestTest4, &sdltestTest5, &sdltestTest6,
&sdltestTest7, &sdltestTest8, &sdltestTest9, &sdltestTest10, &sdltestTest11, &sdltestTest12,
&sdltestTest13, &sdltestTest14, NULL
};
/* SDL_test test suite (global) */
SDLTest_TestSuiteReference sdltestTestSuite = {
"SDLtest",
NULL,
sdltestTests,
NULL
"SDLtest",
NULL,
sdltestTests,
NULL
};

View File

@@ -28,23 +28,23 @@ extern SDLTest_TestSuiteReference pixelsTestSuite;
// All test suites
SDLTest_TestSuiteReference *testSuites[] = {
&audioTestSuite,
&clipboardTestSuite,
&eventsTestSuite,
&keyboardTestSuite,
&mainTestSuite,
&platformTestSuite,
&rectTestSuite,
&renderTestSuite,
&rwopsTestSuite,
&surfaceTestSuite,
&syswmTestSuite,
&sdltestTestSuite,
&videoTestSuite,
&mouseTestSuite,
&timerTestSuite,
&pixelsTestSuite,
NULL
&audioTestSuite,
&clipboardTestSuite,
&eventsTestSuite,
&keyboardTestSuite,
&mainTestSuite,
&platformTestSuite,
&rectTestSuite,
&renderTestSuite,
&rwopsTestSuite,
&surfaceTestSuite,
&syswmTestSuite,
&sdltestTestSuite,
&videoTestSuite,
&mouseTestSuite,
&timerTestSuite,
&pixelsTestSuite,
NULL
};
#endif

View File

@@ -56,21 +56,21 @@ _surfaceSetUp(void *arg)
SDLTest_AssertCheck(result == 0, "Validate result from SDL_SetSurfaceBlendMode, expected: 0, got: %i", result);
result = SDL_GetSurfaceBlendMode(testSurface, &currentBlendMode);
SDLTest_AssertCheck(result == 0, "Validate result from SDL_GetSurfaceBlendMode, expected: 0, got: %i", result);
SDLTest_AssertCheck(currentBlendMode == blendMode, "Validate blendMode, expected: %i, got: %i", blendMode, currentBlendMode);
SDLTest_AssertCheck(currentBlendMode == blendMode, "Validate blendMode, expected: %i, got: %i", blendMode, currentBlendMode);
}
}
void
_surfaceTearDown(void *arg)
{
if (referenceSurface != NULL) {
SDL_FreeSurface(referenceSurface);
referenceSurface = NULL;
}
if (testSurface != NULL) {
SDL_FreeSurface(testSurface);
testSurface = NULL;
}
if (referenceSurface != NULL) {
SDL_FreeSurface(referenceSurface);
referenceSurface = NULL;
}
if (testSurface != NULL) {
SDL_FreeSurface(testSurface);
testSurface = NULL;
}
}
/**
@@ -78,15 +78,15 @@ _surfaceTearDown(void *arg)
*/
void _clearTestSurface()
{
int ret;
Uint32 color;
int ret;
Uint32 color;
/* Clear surface. */
color = SDL_MapRGBA( testSurface->format, 0, 0, 0, 0);
SDLTest_AssertPass("Call to SDL_MapRGBA()");
ret = SDL_FillRect( testSurface, NULL, color);
SDLTest_AssertPass("Call to SDL_FillRect()");
SDLTest_AssertCheck(ret == 0, "Verify result from SDL_FillRect, expected: 0, got: %i", ret);
/* Clear surface. */
color = SDL_MapRGBA( testSurface->format, 0, 0, 0, 0);
SDLTest_AssertPass("Call to SDL_MapRGBA()");
ret = SDL_FillRect( testSurface, NULL, color);
SDLTest_AssertPass("Call to SDL_FillRect()");
SDLTest_AssertCheck(ret == 0, "Verify result from SDL_FillRect, expected: 0, got: %i", ret);
}
/**
@@ -94,119 +94,119 @@ void _clearTestSurface()
*/
void _testBlitBlendMode(int mode)
{
int ret;
int i, j, ni, nj;
SDL_Surface *face;
SDL_Rect rect;
int nmode;
SDL_BlendMode bmode;
int checkFailCount1;
int checkFailCount2;
int checkFailCount3;
int checkFailCount4;
int ret;
int i, j, ni, nj;
SDL_Surface *face;
SDL_Rect rect;
int nmode;
SDL_BlendMode bmode;
int checkFailCount1;
int checkFailCount2;
int checkFailCount3;
int checkFailCount4;
/* Check test surface */
SDLTest_AssertCheck(testSurface != NULL, "Verify testSurface is not NULL");
if (testSurface == NULL) return;
/* Create sample surface */
face = SDLTest_ImageFace();
SDLTest_AssertCheck(face != NULL, "Verify face surface is not NULL");
if (face == NULL) return;
/* Check test surface */
SDLTest_AssertCheck(testSurface != NULL, "Verify testSurface is not NULL");
if (testSurface == NULL) return;
/* Reset alpha modulation */
ret = SDL_SetSurfaceAlphaMod(face, 255);
SDLTest_AssertPass("Call to SDL_SetSurfaceAlphaMod()");
SDLTest_AssertCheck(ret == 0, "Verify result from SDL_SetSurfaceAlphaMod(), expected: 0, got: %i", ret);
/* Create sample surface */
face = SDLTest_ImageFace();
SDLTest_AssertCheck(face != NULL, "Verify face surface is not NULL");
if (face == NULL) return;
/* Reset color modulation */
ret = SDL_SetSurfaceColorMod(face, 255, 255, 255);
SDLTest_AssertPass("Call to SDL_SetSurfaceColorMod()");
SDLTest_AssertCheck(ret == 0, "Verify result from SDL_SetSurfaceColorMod(), expected: 0, got: %i", ret);
/* Reset alpha modulation */
ret = SDL_SetSurfaceAlphaMod(face, 255);
SDLTest_AssertPass("Call to SDL_SetSurfaceAlphaMod()");
SDLTest_AssertCheck(ret == 0, "Verify result from SDL_SetSurfaceAlphaMod(), expected: 0, got: %i", ret);
/* Reset color key */
ret = SDL_SetColorKey(face, SDL_FALSE, 0);
SDLTest_AssertPass("Call to SDL_SetColorKey()");
SDLTest_AssertCheck(ret == 0, "Verify result from SDL_SetColorKey(), expected: 0, got: %i", ret);
/* Reset color modulation */
ret = SDL_SetSurfaceColorMod(face, 255, 255, 255);
SDLTest_AssertPass("Call to SDL_SetSurfaceColorMod()");
SDLTest_AssertCheck(ret == 0, "Verify result from SDL_SetSurfaceColorMod(), expected: 0, got: %i", ret);
/* Clear the test surface */
/* Reset color key */
ret = SDL_SetColorKey(face, SDL_FALSE, 0);
SDLTest_AssertPass("Call to SDL_SetColorKey()");
SDLTest_AssertCheck(ret == 0, "Verify result from SDL_SetColorKey(), expected: 0, got: %i", ret);
/* Clear the test surface */
_clearTestSurface();
/* Target rect size */
rect.w = face->w;
rect.h = face->h;
/* Steps to take */
ni = testSurface->w - face->w;
nj = testSurface->h - face->h;
/* Optionally set blend mode. */
if (mode >= 0) {
ret = SDL_SetSurfaceBlendMode( face, (SDL_BlendMode)mode );
SDLTest_AssertPass("Call to SDL_SetSurfaceBlendMode()");
SDLTest_AssertCheck(ret == 0, "Verify result from SDL_SetSurfaceBlendMode(..., %i), expected: 0, got: %i", mode, ret);
}
/* Test blend mode. */
checkFailCount1 = 0;
checkFailCount2 = 0;
checkFailCount3 = 0;
checkFailCount4 = 0;
for (j=0; j <= nj; j+=4) {
for (i=0; i <= ni; i+=4) {
if (mode == -2) {
/* Set color mod. */
ret = SDL_SetSurfaceColorMod( face, (255/nj)*j, (255/ni)*i, (255/nj)*j );
if (ret != 0) checkFailCount2++;
}
else if (mode == -3) {
/* Set alpha mod. */
ret = SDL_SetSurfaceAlphaMod( face, (255/ni)*i );
if (ret != 0) checkFailCount3++;
}
else if (mode == -4) {
/* Crazy blending mode magic. */
nmode = (i/4*j/4) % 4;
if (nmode==0) {
bmode = SDL_BLENDMODE_NONE;
} else if (nmode==1) {
bmode = SDL_BLENDMODE_BLEND;
} else if (nmode==2) {
bmode = SDL_BLENDMODE_ADD;
} else if (nmode==3) {
bmode = SDL_BLENDMODE_MOD;
}
ret = SDL_SetSurfaceBlendMode( face, bmode );
if (ret != 0) checkFailCount4++;
}
/* Target rect size */
rect.w = face->w;
rect.h = face->h;
/* Blitting. */
rect.x = i;
rect.y = j;
ret = SDL_BlitSurface( face, NULL, testSurface, &rect );
if (ret != 0) checkFailCount1++;
}
}
SDLTest_AssertCheck(checkFailCount1 == 0, "Validate results from calls to SDL_BlitSurface, expected: 0, got: %i", checkFailCount1);
SDLTest_AssertCheck(checkFailCount2 == 0, "Validate results from calls to SDL_SetSurfaceColorMod, expected: 0, got: %i", checkFailCount2);
SDLTest_AssertCheck(checkFailCount3 == 0, "Validate results from calls to SDL_SetSurfaceAlphaMod, expected: 0, got: %i", checkFailCount3);
SDLTest_AssertCheck(checkFailCount4 == 0, "Validate results from calls to SDL_SetSurfaceBlendMode, expected: 0, got: %i", checkFailCount4);
/* Clean up */
if (face != NULL) {
SDL_FreeSurface(face);
face = NULL;
}
/* Steps to take */
ni = testSurface->w - face->w;
nj = testSurface->h - face->h;
/* Optionally set blend mode. */
if (mode >= 0) {
ret = SDL_SetSurfaceBlendMode( face, (SDL_BlendMode)mode );
SDLTest_AssertPass("Call to SDL_SetSurfaceBlendMode()");
SDLTest_AssertCheck(ret == 0, "Verify result from SDL_SetSurfaceBlendMode(..., %i), expected: 0, got: %i", mode, ret);
}
/* Test blend mode. */
checkFailCount1 = 0;
checkFailCount2 = 0;
checkFailCount3 = 0;
checkFailCount4 = 0;
for (j=0; j <= nj; j+=4) {
for (i=0; i <= ni; i+=4) {
if (mode == -2) {
/* Set color mod. */
ret = SDL_SetSurfaceColorMod( face, (255/nj)*j, (255/ni)*i, (255/nj)*j );
if (ret != 0) checkFailCount2++;
}
else if (mode == -3) {
/* Set alpha mod. */
ret = SDL_SetSurfaceAlphaMod( face, (255/ni)*i );
if (ret != 0) checkFailCount3++;
}
else if (mode == -4) {
/* Crazy blending mode magic. */
nmode = (i/4*j/4) % 4;
if (nmode==0) {
bmode = SDL_BLENDMODE_NONE;
} else if (nmode==1) {
bmode = SDL_BLENDMODE_BLEND;
} else if (nmode==2) {
bmode = SDL_BLENDMODE_ADD;
} else if (nmode==3) {
bmode = SDL_BLENDMODE_MOD;
}
ret = SDL_SetSurfaceBlendMode( face, bmode );
if (ret != 0) checkFailCount4++;
}
/* Blitting. */
rect.x = i;
rect.y = j;
ret = SDL_BlitSurface( face, NULL, testSurface, &rect );
if (ret != 0) checkFailCount1++;
}
}
SDLTest_AssertCheck(checkFailCount1 == 0, "Validate results from calls to SDL_BlitSurface, expected: 0, got: %i", checkFailCount1);
SDLTest_AssertCheck(checkFailCount2 == 0, "Validate results from calls to SDL_SetSurfaceColorMod, expected: 0, got: %i", checkFailCount2);
SDLTest_AssertCheck(checkFailCount3 == 0, "Validate results from calls to SDL_SetSurfaceAlphaMod, expected: 0, got: %i", checkFailCount3);
SDLTest_AssertCheck(checkFailCount4 == 0, "Validate results from calls to SDL_SetSurfaceBlendMode, expected: 0, got: %i", checkFailCount4);
/* Clean up */
if (face != NULL) {
SDL_FreeSurface(face);
face = NULL;
}
}
/* Helper to check that a file exists */
void
_AssertFileExist(const char *filename)
{
struct stat st;
int ret = stat(filename, &st);
struct stat st;
int ret = stat(filename, &st);
SDLTest_AssertCheck(ret == 0, "Verify file '%s' exists", filename);
SDLTest_AssertCheck(ret == 0, "Verify file '%s' exists", filename);
}
@@ -234,16 +234,16 @@ surface_testSaveLoadBitmap(void *arg)
/* Save a surface */
ret = SDL_SaveBMP(face, sampleFilename);
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);
/* Load a surface */
rface = SDL_LoadBMP(sampleFilename);
SDLTest_AssertPass("Call to SDL_LoadBMP()");
SDLTest_AssertCheck(rface != NULL, "Verify result from SDL_LoadBMP is not NULL");
if (rface != NULL) {
SDLTest_AssertCheck(face->w == rface->w, "Verify width of loaded surface, expected: %i, got: %i", face->w, rface->w);
SDLTest_AssertCheck(face->h == rface->h, "Verify height of loaded surface, expected: %i, got: %i", face->h, rface->h);
SDLTest_AssertCheck(face->w == rface->w, "Verify width of loaded surface, expected: %i, got: %i", face->w, rface->w);
SDLTest_AssertCheck(face->h == rface->h, "Verify height of loaded surface, expected: %i, got: %i", face->h, rface->h);
}
/* Delete test file; ignore errors */
@@ -251,14 +251,14 @@ surface_testSaveLoadBitmap(void *arg)
/* Clean up */
if (face != NULL) {
SDL_FreeSurface(face);
face = NULL;
SDL_FreeSurface(face);
face = NULL;
}
if (rface != NULL) {
SDL_FreeSurface(rface);
rface = NULL;
SDL_FreeSurface(rface);
rface = NULL;
}
return TEST_COMPLETED;
}
@@ -268,42 +268,42 @@ surface_testSaveLoadBitmap(void *arg)
int
surface_testSurfaceConversion(void *arg)
{
SDL_Surface *rface = NULL, *face = NULL;
int ret = 0;
SDL_Surface *rface = NULL, *face = NULL;
int ret = 0;
/* Create sample surface */
face = SDLTest_ImageFace();
SDLTest_AssertCheck(face != NULL, "Verify face surface is not NULL");
if (face == NULL)
return TEST_ABORTED;
/* Create sample surface */
face = SDLTest_ImageFace();
SDLTest_AssertCheck(face != NULL, "Verify face surface is not NULL");
if (face == NULL)
return TEST_ABORTED;
/* Set transparent pixel as the pixel at (0,0) */
if (face->format->palette) {
ret = SDL_SetColorKey(face, SDL_RLEACCEL, *(Uint8 *) face->pixels);
SDLTest_AssertPass("Call to SDL_SetColorKey()");
SDLTest_AssertCheck(ret == 0, "Verify result from SDL_SetColorKey, expected: 0, got: %i", ret);
}
/* Set transparent pixel as the pixel at (0,0) */
if (face->format->palette) {
ret = SDL_SetColorKey(face, SDL_RLEACCEL, *(Uint8 *) face->pixels);
SDLTest_AssertPass("Call to SDL_SetColorKey()");
SDLTest_AssertCheck(ret == 0, "Verify result from SDL_SetColorKey, expected: 0, got: %i", ret);
}
/* Convert to 32 bit to compare. */
rface = SDL_ConvertSurface( face, testSurface->format, 0 );
SDLTest_AssertPass("Call to SDL_ConvertSurface()");
SDLTest_AssertCheck(rface != NULL, "Verify result from SDL_ConvertSurface is not NULL");
/* Convert to 32 bit to compare. */
rface = SDL_ConvertSurface( face, testSurface->format, 0 );
SDLTest_AssertPass("Call to SDL_ConvertSurface()");
SDLTest_AssertCheck(rface != NULL, "Verify result from SDL_ConvertSurface is not NULL");
/* Compare surface. */
ret = SDLTest_CompareSurfaces( rface, face, 0 );
SDLTest_AssertCheck(ret == 0, "Validate result from SDLTest_CompareSurfaces, expected: 0, got: %i", ret);
/* Clean up. */
if (face != NULL) {
SDL_FreeSurface( face );
face = NULL;
}
if (rface != NULL) {
SDL_FreeSurface( rface );
rface = NULL;
}
/* Compare surface. */
ret = SDLTest_CompareSurfaces( rface, face, 0 );
SDLTest_AssertCheck(ret == 0, "Validate result from SDLTest_CompareSurfaces, expected: 0, got: %i", ret);
return TEST_COMPLETED;
/* Clean up. */
if (face != NULL) {
SDL_FreeSurface( face );
face = NULL;
}
if (rface != NULL) {
SDL_FreeSurface( rface );
rface = NULL;
}
return TEST_COMPLETED;
}
@@ -313,10 +313,10 @@ surface_testSurfaceConversion(void *arg)
int
surface_testLoadFailure(void *arg)
{
SDL_Surface *face = SDL_LoadBMP("nonexistant.bmp");
SDLTest_AssertCheck(face == NULL, "SDL_CreateLoadBmp");
SDL_Surface *face = SDL_LoadBMP("nonexistant.bmp");
SDLTest_AssertCheck(face == NULL, "SDL_CreateLoadBmp");
return TEST_COMPLETED;
return TEST_COMPLETED;
}
/**
@@ -328,17 +328,17 @@ surface_testBlit(void *arg)
int ret;
SDL_Surface *compareSurface;
/* Basic blitting */
/* Basic blitting */
_testBlitBlendMode(-1);
/* Verify result by comparing surfaces */
compareSurface = SDLTest_ImageBlit();
ret = SDLTest_CompareSurfaces( testSurface, compareSurface, 0 );
SDLTest_AssertCheck(ret == 0, "Validate result from SDLTest_CompareSurfaces, expected: 0, got: %i", ret);
/* Clean up. */
if (compareSurface != NULL) {
SDL_FreeSurface( compareSurface );
if (compareSurface != NULL) {
SDL_FreeSurface( compareSurface );
}
return TEST_COMPLETED;
@@ -353,17 +353,17 @@ surface_testBlitColorMod(void *arg)
int ret;
SDL_Surface *compareSurface;
/* Basic blitting with color mod */
/* Basic blitting with color mod */
_testBlitBlendMode(-2);
/* Verify result by comparing surfaces */
compareSurface = SDLTest_ImageBlitColor();
ret = SDLTest_CompareSurfaces( testSurface, compareSurface, 0 );
SDLTest_AssertCheck(ret == 0, "Validate result from SDLTest_CompareSurfaces, expected: 0, got: %i", ret);
/* Clean up. */
if (compareSurface != NULL) {
SDL_FreeSurface( compareSurface );
if (compareSurface != NULL) {
SDL_FreeSurface( compareSurface );
}
return TEST_COMPLETED;
@@ -378,17 +378,17 @@ surface_testBlitAlphaMod(void *arg)
int ret;
SDL_Surface *compareSurface;
/* Basic blitting with alpha mod */
/* Basic blitting with alpha mod */
_testBlitBlendMode(-3);
/* Verify result by comparing surfaces */
compareSurface = SDLTest_ImageBlitAlpha();
ret = SDLTest_CompareSurfaces( testSurface, compareSurface, 0 );
SDLTest_AssertCheck(ret == 0, "Validate result from SDLTest_CompareSurfaces, expected: 0, got: %i", ret);
/* Clean up. */
if (compareSurface != NULL) {
SDL_FreeSurface( compareSurface );
if (compareSurface != NULL) {
SDL_FreeSurface( compareSurface );
}
return TEST_COMPLETED;
@@ -404,17 +404,17 @@ surface_testBlitBlendNone(void *arg)
int ret;
SDL_Surface *compareSurface;
/* Basic blitting */
/* Basic blitting */
_testBlitBlendMode(SDL_BLENDMODE_NONE);
/* Verify result by comparing surfaces */
compareSurface = SDLTest_ImageBlitBlendNone();
ret = SDLTest_CompareSurfaces( testSurface, compareSurface, 0 );
SDLTest_AssertCheck(ret == 0, "Validate result from SDLTest_CompareSurfaces, expected: 0, got: %i", ret);
/* Clean up. */
if (compareSurface != NULL) {
SDL_FreeSurface( compareSurface );
if (compareSurface != NULL) {
SDL_FreeSurface( compareSurface );
}
return TEST_COMPLETED;
@@ -429,17 +429,17 @@ surface_testBlitBlendBlend(void *arg)
int ret;
SDL_Surface *compareSurface;
/* Blend blitting */
/* Blend blitting */
_testBlitBlendMode(SDL_BLENDMODE_BLEND);
/* Verify result by comparing surfaces */
compareSurface = SDLTest_ImageBlitBlend();
ret = SDLTest_CompareSurfaces( testSurface, compareSurface, 0 );
SDLTest_AssertCheck(ret == 0, "Validate result from SDLTest_CompareSurfaces, expected: 0, got: %i", ret);
/* Clean up. */
if (compareSurface != NULL) {
SDL_FreeSurface( compareSurface );
if (compareSurface != NULL) {
SDL_FreeSurface( compareSurface );
}
return TEST_COMPLETED;
@@ -454,17 +454,17 @@ surface_testBlitBlendAdd(void *arg)
int ret;
SDL_Surface *compareSurface;
/* Add blitting */
/* Add blitting */
_testBlitBlendMode(SDL_BLENDMODE_ADD);
/* Verify result by comparing surfaces */
compareSurface = SDLTest_ImageBlitBlendAdd();
ret = SDLTest_CompareSurfaces( testSurface, compareSurface, 0 );
SDLTest_AssertCheck(ret == 0, "Validate result from SDLTest_CompareSurfaces, expected: 0, got: %i", ret);
/* Clean up. */
if (compareSurface != NULL) {
SDL_FreeSurface( compareSurface );
if (compareSurface != NULL) {
SDL_FreeSurface( compareSurface );
}
return TEST_COMPLETED;
@@ -479,17 +479,17 @@ surface_testBlitBlendMod(void *arg)
int ret;
SDL_Surface *compareSurface;
/* Mod blitting */
/* Mod blitting */
_testBlitBlendMode(SDL_BLENDMODE_MOD);
/* Verify result by comparing surfaces */
compareSurface = SDLTest_ImageBlitBlendMod();
ret = SDLTest_CompareSurfaces( testSurface, compareSurface, 0 );
SDLTest_AssertCheck(ret == 0, "Validate result from SDLTest_CompareSurfaces, expected: 0, got: %i", ret);
/* Clean up. */
if (compareSurface != NULL) {
SDL_FreeSurface( compareSurface );
if (compareSurface != NULL) {
SDL_FreeSurface( compareSurface );
}
return TEST_COMPLETED;
@@ -504,17 +504,17 @@ surface_testBlitBlendLoop(void *arg) {
int ret;
SDL_Surface *compareSurface;
/* All blitting modes */
/* All blitting modes */
_testBlitBlendMode(-4);
/* Verify result by comparing surfaces */
compareSurface = SDLTest_ImageBlitBlendAll();
ret = SDLTest_CompareSurfaces( testSurface, compareSurface, 0 );
SDLTest_AssertCheck(ret == 0, "Validate result from SDLTest_CompareSurfaces, expected: 0, got: %i", ret);
/* Clean up. */
if (compareSurface != NULL) {
SDL_FreeSurface(compareSurface);
if (compareSurface != NULL) {
SDL_FreeSurface(compareSurface);
}
return TEST_COMPLETED;
@@ -525,52 +525,52 @@ surface_testBlitBlendLoop(void *arg) {
/* Surface test cases */
static const SDLTest_TestCaseReference surfaceTest1 =
{ (SDLTest_TestCaseFp)surface_testSaveLoadBitmap, "surface_testSaveLoadBitmap", "Tests sprite saving and loading.", TEST_ENABLED};
{ (SDLTest_TestCaseFp)surface_testSaveLoadBitmap, "surface_testSaveLoadBitmap", "Tests sprite saving and loading.", TEST_ENABLED};
static const SDLTest_TestCaseReference surfaceTest2 =
{ (SDLTest_TestCaseFp)surface_testBlit, "surface_testBlit", "Tests basic blitting.", TEST_ENABLED};
{ (SDLTest_TestCaseFp)surface_testBlit, "surface_testBlit", "Tests basic blitting.", TEST_ENABLED};
static const SDLTest_TestCaseReference surfaceTest3 =
{ (SDLTest_TestCaseFp)surface_testBlitBlendNone, "surface_testBlitBlendNone", "Tests blitting routines with none blending mode.", TEST_ENABLED};
{ (SDLTest_TestCaseFp)surface_testBlitBlendNone, "surface_testBlitBlendNone", "Tests blitting routines with none blending mode.", TEST_ENABLED};
static const SDLTest_TestCaseReference surfaceTest4 =
{ (SDLTest_TestCaseFp)surface_testLoadFailure, "surface_testLoadFailure", "Tests sprite loading. A failure case.", TEST_ENABLED};
{ (SDLTest_TestCaseFp)surface_testLoadFailure, "surface_testLoadFailure", "Tests sprite loading. A failure case.", TEST_ENABLED};
static const SDLTest_TestCaseReference surfaceTest5 =
{ (SDLTest_TestCaseFp)surface_testSurfaceConversion, "surface_testSurfaceConversion", "Tests surface conversion.", TEST_ENABLED};
{ (SDLTest_TestCaseFp)surface_testSurfaceConversion, "surface_testSurfaceConversion", "Tests surface conversion.", TEST_ENABLED};
static const SDLTest_TestCaseReference surfaceTest6 =
{ (SDLTest_TestCaseFp)surface_testBlitColorMod, "surface_testBlitColorMod", "Tests some blitting routines with color mod.", TEST_ENABLED};
{ (SDLTest_TestCaseFp)surface_testBlitColorMod, "surface_testBlitColorMod", "Tests some blitting routines with color mod.", TEST_ENABLED};
static const SDLTest_TestCaseReference surfaceTest7 =
{ (SDLTest_TestCaseFp)surface_testBlitAlphaMod, "surface_testBlitAlphaMod", "Tests some blitting routines with alpha mod.", TEST_ENABLED};
{ (SDLTest_TestCaseFp)surface_testBlitAlphaMod, "surface_testBlitAlphaMod", "Tests some blitting routines with alpha mod.", TEST_ENABLED};
/* TODO: rewrite test case, define new test data and re-enable; current implementation fails */
static const SDLTest_TestCaseReference surfaceTest8 =
{ (SDLTest_TestCaseFp)surface_testBlitBlendLoop, "surface_testBlitBlendLoop", "Test blittin routines with verious blending modes", TEST_DISABLED};
{ (SDLTest_TestCaseFp)surface_testBlitBlendLoop, "surface_testBlitBlendLoop", "Test blittin routines with verious blending modes", TEST_DISABLED};
/* TODO: rewrite test case, define new test data and re-enable; current implementation fails */
static const SDLTest_TestCaseReference surfaceTest9 =
{ (SDLTest_TestCaseFp)surface_testBlitBlendBlend, "surface_testBlitBlendBlend", "Tests blitting routines with blend blending mode.", TEST_DISABLED};
{ (SDLTest_TestCaseFp)surface_testBlitBlendBlend, "surface_testBlitBlendBlend", "Tests blitting routines with blend blending mode.", TEST_DISABLED};
/* TODO: rewrite test case, define new test data and re-enable; current implementation fails */
static const SDLTest_TestCaseReference surfaceTest10 =
{ (SDLTest_TestCaseFp)surface_testBlitBlendAdd, "surface_testBlitBlendAdd", "Tests blitting routines with add blending mode.", TEST_DISABLED};
{ (SDLTest_TestCaseFp)surface_testBlitBlendAdd, "surface_testBlitBlendAdd", "Tests blitting routines with add blending mode.", TEST_DISABLED};
static const SDLTest_TestCaseReference surfaceTest11 =
{ (SDLTest_TestCaseFp)surface_testBlitBlendMod, "surface_testBlitBlendMod", "Tests blitting routines with mod blending mode.", TEST_ENABLED};
{ (SDLTest_TestCaseFp)surface_testBlitBlendMod, "surface_testBlitBlendMod", "Tests blitting routines with mod blending mode.", TEST_ENABLED};
/* Sequence of Surface test cases */
static const SDLTest_TestCaseReference *surfaceTests[] = {
&surfaceTest1, &surfaceTest2, &surfaceTest3, &surfaceTest4, &surfaceTest5,
&surfaceTest6, &surfaceTest7, &surfaceTest8, &surfaceTest9, &surfaceTest10, &surfaceTest11, NULL
&surfaceTest1, &surfaceTest2, &surfaceTest3, &surfaceTest4, &surfaceTest5,
&surfaceTest6, &surfaceTest7, &surfaceTest8, &surfaceTest9, &surfaceTest10, &surfaceTest11, NULL
};
/* Surface test suite (global) */
SDLTest_TestSuiteReference surfaceTestSuite = {
"Surface",
_surfaceSetUp,
surfaceTests,
_surfaceTearDown
"Surface",
_surfaceSetUp,
surfaceTests,
_surfaceTearDown
};

View File

@@ -17,27 +17,27 @@ int
syswm_getWindowWMInfo(void *arg)
{
SDL_bool result;
SDL_Window *window;
SDL_Window *window;
SDL_SysWMinfo info;
window = SDL_CreateWindow("", 0, 0, 0, 0, SDL_WINDOW_HIDDEN);
SDLTest_AssertPass("Call to SDL_CreateWindow()");
SDLTest_AssertCheck(window != NULL, "Check that value returned from SDL_CreateWindow is not NULL");
if (window == NULL) {
return TEST_ABORTED;
}
/* Initialize info structure with SDL version info */
SDL_VERSION(&info.version);
SDL_VERSION(&info.version);
/* Make call */
result = SDL_GetWindowWMInfo(window, &info);
SDLTest_AssertPass("Call to SDL_GetWindowWMInfo");
SDLTest_Log((result == SDL_TRUE) ? "Got window information" : "Couldn't get window information");
SDL_DestroyWindow(window);
SDLTest_AssertPass("Call to SDL_DestroyWindow()");
return TEST_COMPLETED;
}
@@ -45,17 +45,17 @@ syswm_getWindowWMInfo(void *arg)
/* SysWM test cases */
static const SDLTest_TestCaseReference syswmTest1 =
{ (SDLTest_TestCaseFp)syswm_getWindowWMInfo, "syswm_getWindowWMInfo", "Call to SDL_GetWindowWMInfo", TEST_ENABLED };
{ (SDLTest_TestCaseFp)syswm_getWindowWMInfo, "syswm_getWindowWMInfo", "Call to SDL_GetWindowWMInfo", TEST_ENABLED };
/* Sequence of SysWM test cases */
static const SDLTest_TestCaseReference *syswmTests[] = {
&syswmTest1, NULL
&syswmTest1, NULL
};
/* SysWM test suite (global) */
SDLTest_TestSuiteReference syswmTestSuite = {
"SysWM",
NULL,
syswmTests,
NULL
"SysWM",
NULL,
syswmTests,
NULL
};

View File

@@ -21,11 +21,11 @@ int _timerCallbackCalled = 0;
void
_timerSetUp(void *arg)
{
/* Start SDL timer subsystem */
int ret = SDL_InitSubSystem( SDL_INIT_TIMER );
/* Start SDL timer subsystem */
int ret = SDL_InitSubSystem( SDL_INIT_TIMER );
SDLTest_AssertPass("Call to SDL_InitSubSystem(SDL_INIT_TIMER)");
SDLTest_AssertCheck(ret==0, "Check result from SDL_InitSubSystem(SDL_INIT_TIMER)");
if (ret != 0) {
SDLTest_AssertCheck(ret==0, "Check result from SDL_InitSubSystem(SDL_INIT_TIMER)");
if (ret != 0) {
SDLTest_LogError("%s", SDL_GetError());
}
}
@@ -39,11 +39,11 @@ int
timer_getPerformanceCounter(void *arg)
{
Uint64 result;
result = SDL_GetPerformanceCounter();
SDLTest_AssertPass("Call to SDL_GetPerformanceCounter()");
SDLTest_AssertCheck(result > 0, "Check result value, expected: >0, got: %lu", result);
return TEST_COMPLETED;
}
@@ -54,11 +54,11 @@ int
timer_getPerformanceFrequency(void *arg)
{
Uint64 result;
result = SDL_GetPerformanceFrequency();
SDLTest_AssertPass("Call to SDL_GetPerformanceFrequency()");
SDLTest_AssertCheck(result > 0, "Check result value, expected: >0, got: %lu", result);
return TEST_COMPLETED;
}
@@ -74,18 +74,18 @@ timer_delayAndGetTicks(void *arg)
Uint32 result2;
Uint32 difference;
/* Zero delay */
/* Zero delay */
SDL_Delay(0);
SDLTest_AssertPass("Call to SDL_Delay(0)");
/* Non-zero delay */
SDL_Delay(1);
SDLTest_AssertPass("Call to SDL_Delay(1)");
SDL_Delay(SDLTest_RandomIntegerInRange(5, 15));
SDLTest_AssertPass("Call to SDL_Delay()");
/* Get ticks count - should be non-zero by now */
/* Get ticks count - should be non-zero by now */
result = SDL_GetTicks();
SDLTest_AssertPass("Call to SDL_GetTicks()");
SDLTest_AssertCheck(result > 0, "Check result value, expected: >0, got: %d", result);
@@ -99,7 +99,7 @@ timer_delayAndGetTicks(void *arg)
difference = result2 - result;
SDLTest_AssertCheck(difference > (testDelay - marginOfError), "Check difference, expected: >%d, got: %d", testDelay - marginOfError, difference);
SDLTest_AssertCheck(difference < (testDelay + marginOfError), "Check difference, expected: <%d, got: %d", testDelay + marginOfError, difference);
return TEST_COMPLETED;
}
@@ -107,14 +107,14 @@ timer_delayAndGetTicks(void *arg)
Uint32 _timerTestCallback(Uint32 interval, void *param)
{
_timerCallbackCalled = 1;
if (_paramCheck != 0) {
SDLTest_AssertCheck(param != NULL, "Check param pointer, expected: non-NULL, got: %s", (param != NULL) ? "non-NULL" : "NULL");
if (param != NULL) {
SDLTest_AssertCheck(*(int *)param == _paramValue, "Check param value, expected: %i, got: %i", _paramValue, *(int *)param);
}
}
return 0;
}
@@ -131,12 +131,12 @@ timer_addRemoveTimer(void *arg)
/* Reset state */
_paramCheck = 0;
_timerCallbackCalled = 0;
/* Set timer with a long delay */
/* Set timer with a long delay */
id = SDL_AddTimer(10000, _timerTestCallback, NULL);
SDLTest_AssertPass("Call to SDL_AddTimer(10000,...)");
SDLTest_AssertCheck(id > 0, "Check result value, expected: >0, got: %d", id);
/* Remove timer again and check that callback was not called */
result = SDL_RemoveTimer(id);
SDLTest_AssertPass("Call to SDL_RemoveTimer()");
@@ -154,21 +154,21 @@ timer_addRemoveTimer(void *arg)
_paramValue = param;
_timerCallbackCalled = 0;
/* Set timer with a short delay */
/* Set timer with a short delay */
id = SDL_AddTimer(10, _timerTestCallback, (void *)&param);
SDLTest_AssertPass("Call to SDL_AddTimer(10, param)");
SDLTest_AssertCheck(id > 0, "Check result value, expected: >0, got: %d", id);
/* Wait to let timer trigger callback */
SDL_Delay(100);
SDLTest_AssertPass("Call to SDL_Delay(100)");
/* Remove timer again and check that callback was called */
result = SDL_RemoveTimer(id);
SDLTest_AssertPass("Call to SDL_RemoveTimer()");
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);
return TEST_COMPLETED;
}
@@ -176,26 +176,26 @@ timer_addRemoveTimer(void *arg)
/* Timer test cases */
static const SDLTest_TestCaseReference timerTest1 =
{ (SDLTest_TestCaseFp)timer_getPerformanceCounter, "timer_getPerformanceCounter", "Call to SDL_GetPerformanceCounter", TEST_ENABLED };
{ (SDLTest_TestCaseFp)timer_getPerformanceCounter, "timer_getPerformanceCounter", "Call to SDL_GetPerformanceCounter", TEST_ENABLED };
static const SDLTest_TestCaseReference timerTest2 =
{ (SDLTest_TestCaseFp)timer_getPerformanceFrequency, "timer_getPerformanceFrequency", "Call to SDL_GetPerformanceFrequency", TEST_ENABLED };
{ (SDLTest_TestCaseFp)timer_getPerformanceFrequency, "timer_getPerformanceFrequency", "Call to SDL_GetPerformanceFrequency", TEST_ENABLED };
static const SDLTest_TestCaseReference timerTest3 =
{ (SDLTest_TestCaseFp)timer_delayAndGetTicks, "timer_delayAndGetTicks", "Call to SDL_Delay and SDL_GetTicks", TEST_ENABLED };
{ (SDLTest_TestCaseFp)timer_delayAndGetTicks, "timer_delayAndGetTicks", "Call to SDL_Delay and SDL_GetTicks", TEST_ENABLED };
static const SDLTest_TestCaseReference timerTest4 =
{ (SDLTest_TestCaseFp)timer_addRemoveTimer, "timer_addRemoveTimer", "Call to SDL_AddTimer and SDL_RemoveTimer", TEST_ENABLED };
{ (SDLTest_TestCaseFp)timer_addRemoveTimer, "timer_addRemoveTimer", "Call to SDL_AddTimer and SDL_RemoveTimer", TEST_ENABLED };
/* Sequence of Timer test cases */
static const SDLTest_TestCaseReference *timerTests[] = {
&timerTest1, &timerTest2, &timerTest3, &timerTest4, NULL
&timerTest1, &timerTest2, &timerTest3, &timerTest4, NULL
};
/* Timer test suite (global) */
SDLTest_TestSuiteReference timerTestSuite = {
"Timer",
_timerSetUp,
timerTests,
NULL
"Timer",
_timerSetUp,
timerTests,
NULL
};

File diff suppressed because it is too large Load Diff

View File

@@ -18,7 +18,7 @@
#include "SDL_test_common.h"
#define NUM_OBJECTS 100
#define NUM_OBJECTS 100
static SDLTest_CommonState *state;
static int num_objects;

View File

@@ -30,11 +30,11 @@
/* WARNING ! those 2 files will be destroyed by this test program */
#ifdef __IPHONEOS__
#define FBASENAME1 "../Documents/sdldata1" /* this file will be created during tests */
#define FBASENAME1 "../Documents/sdldata1" /* this file will be created during tests */
#define FBASENAME2 "../Documents/sdldata2" /* this file should not exist before starting test */
#else
#define FBASENAME1 "sdldata1" /* this file will be created during tests */
#define FBASENAME2 "sdldata2" /* this file should not exist before starting test */
#define FBASENAME1 "sdldata1" /* this file will be created during tests */
#define FBASENAME2 "sdldata2" /* this file should not exist before starting test */
#endif
#ifndef NULL
@@ -61,7 +61,7 @@ rwops_error_quit(unsigned line, SDL_RWops * rwops)
exit(1); /* quit with rwops error (test failed) */
}
#define RWOP_ERR_QUIT(x) rwops_error_quit( __LINE__, (x) )
#define RWOP_ERR_QUIT(x) rwops_error_quit( __LINE__, (x) )
@@ -93,9 +93,9 @@ main(int argc, char *argv[])
printf("test1 OK\n");
/* test 2 : check that inexistant file is not successfully opened/created when required */
/* modes : r, r+ implie that file MUST exist
/* modes : r, r+ implie that file MUST exist
modes : a, a+, w, w+ checks that it succeeds (file may not exists)
*/
rwops = SDL_RWFromFile(FBASENAME2, "rb"); /* this file doesn't exist that call must fail */
if (rwops)
@@ -125,8 +125,8 @@ main(int argc, char *argv[])
unlink(FBASENAME2);
printf("test2 OK\n");
/* test 3 : creation, writing , reading, seeking,
test : w mode, r mode, w+ mode
/* test 3 : creation, writing , reading, seeking,
test : w mode, r mode, w+ mode
*/
rwops = SDL_RWFromFile(FBASENAME1, "wb"); /* write only */
if (!rwops)

View File

@@ -125,7 +125,7 @@ WatchGameController(SDL_GameController * gamecontroller)
/* Print info about the controller we are watching */
printf("Watching controller %s\n", name ? name : "Unknown Controller");
/* Loop, getting controller events! */
while (!done) {
/* blank screen, set up for drawing this frame. */
@@ -199,7 +199,7 @@ WatchGameController(SDL_GameController * gamecontroller)
SDL_SetRenderDrawColor(screen, 0x00, 0x00, 0xFF, SDL_ALPHA_OPAQUE);
SDL_RenderPresent(screen);
if ( !done )
done = SDL_GameControllerGetAttached( gamecontroller ) == 0;
}

View File

@@ -93,12 +93,12 @@ void setpix(SDL_Surface *screen, float _x, float _y, unsigned int col)
int x = (int)_x;
int y = (int)_y;
float a;
if(x < 0 || x >= screen->w) return;
if(y < 0 || y >= screen->h) return;
pixmem32 = (Uint32*) screen->pixels + y*screen->pitch/BPP + x;
SDL_memcpy(&colour,pixmem32,screen->format->BytesPerPixel);
SDL_GetRGB(colour,screen->format,&r,&g,&b);
@@ -110,7 +110,7 @@ void setpix(SDL_Surface *screen, float _x, float _y, unsigned int col)
g = (Uint8)(g*(1-a) + ((col>> 8)&0xFF)*(a));
b = (Uint8)(b*(1-a) + ((col>> 0)&0xFF)*(a));
colour = SDL_MapRGB( screen->format,r, g, b);
*pixmem32 = colour;
}
@@ -129,7 +129,7 @@ void drawCircle(SDL_Surface* screen,float x,float y,float r,unsigned int c)
xr = (float)sqrt(r*r - ty*ty);
if(r > 0) { //r > 0 ==> filled circle
for(tx=-xr+.5f;tx<=xr-.5;tx++) {
setpix(screen,x+tx,y+ty,c);
setpix(screen,x+tx,y+ty,c);
}
}
else {
@@ -140,9 +140,9 @@ void drawCircle(SDL_Surface* screen,float x,float y,float r,unsigned int c)
}
void drawKnob(SDL_Surface* screen,Knob k) {
drawCircle(screen,k.p.x*screen->w,k.p.y*screen->h,k.r*screen->w,0xFFFFFF);
drawCircle(screen,k.p.x*screen->w,k.p.y*screen->h,k.r*screen->w,0xFFFFFF);
drawCircle(screen,(k.p.x+k.r/2*cosf(k.ang))*screen->w,
(k.p.y+k.r/2*sinf(k.ang))*screen->h,k.r/4*screen->w,0);
(k.p.y+k.r/2*sinf(k.ang))*screen->h,k.r/4*screen->w,0);
}
void DrawScreen(SDL_Surface* screen)
@@ -154,36 +154,36 @@ void DrawScreen(SDL_Surface* screen)
int x, y;
for(y = 0;y < screen->h;y++)
for(x = 0;x < screen->w;x++)
setpix(screen,(float)x,(float)y,((x%255)<<16) + ((y%255)<<8) + (x+y)%255);
setpix(screen,(float)x,(float)y,((x%255)<<16) + ((y%255)<<8) + (x+y)%255);
#endif
//draw Touch History
for(i = eventWrite; i < eventWrite+EVENT_BUF_SIZE; ++i) {
const SDL_Event *event = &events[i&(EVENT_BUF_SIZE-1)];
float age = (float)(i - eventWrite) / EVENT_BUF_SIZE;
float x, y;
unsigned int c, col;
float x, y;
unsigned int c, col;
if(event->type == SDL_FINGERMOTION ||
if(event->type == SDL_FINGERMOTION ||
event->type == SDL_FINGERDOWN ||
event->type == SDL_FINGERUP) {
x = event->tfinger.x;
y = event->tfinger.y;
//draw the touch:
c = colors[event->tfinger.fingerId%7];
//draw the touch:
c = colors[event->tfinger.fingerId%7];
col = ((unsigned int)(c*(.1+.85))) | (unsigned int)(0xFF*age)<<24;
if(event->type == SDL_FINGERMOTION)
drawCircle(screen,x*screen->w,y*screen->h,5,col);
drawCircle(screen,x*screen->w,y*screen->h,5,col);
else if(event->type == SDL_FINGERDOWN)
drawCircle(screen,x*screen->w,y*screen->h,-10,col);
drawCircle(screen,x*screen->w,y*screen->h,-10,col);
}
}
if(knob.p.x > 0)
drawKnob(screen,knob);
SDL_UpdateWindowSurface(window);
}
@@ -201,7 +201,7 @@ SDL_Surface* initScreen(int width,int height)
}
int main(int argc, char* argv[])
{
{
SDL_Surface *screen;
SDL_Event event;
SDL_bool quitting = SDL_FALSE;
@@ -212,7 +212,7 @@ int main(int argc, char* argv[])
knob.ang = 0;
if (SDL_Init(SDL_INIT_VIDEO) < 0 ) return 1;
if (!(screen = initScreen(WIDTH,HEIGHT)))
{
SDL_Quit();
@@ -220,92 +220,92 @@ int main(int argc, char* argv[])
}
while(!quitting) {
while(SDL_PollEvent(&event))
while(SDL_PollEvent(&event))
{
//Record _all_ events
events[eventWrite & (EVENT_BUF_SIZE-1)] = event;
eventWrite++;
switch (event.type)
{
case SDL_QUIT:
quitting = SDL_TRUE;
break;
case SDL_KEYDOWN:
switch (event.key.keysym.sym)
{
case SDLK_SPACE:
SDL_RecordGesture(-1);
break;
case SDLK_s:
src = SDL_RWFromFile("gestureSave","w");
SDL_Log("Wrote %i templates",SDL_SaveAllDollarTemplates(src));
SDL_RWclose(src);
break;
case SDLK_l:
src = SDL_RWFromFile("gestureSave","r");
SDL_Log("Loaded: %i",SDL_LoadDollarTemplates(-1,src));
SDL_RWclose(src);
break;
case SDLK_ESCAPE:
quitting = SDL_TRUE;
break;
}
break;
case SDL_WINDOWEVENT:
//Record _all_ events
events[eventWrite & (EVENT_BUF_SIZE-1)] = event;
eventWrite++;
switch (event.type)
{
case SDL_QUIT:
quitting = SDL_TRUE;
break;
case SDL_KEYDOWN:
switch (event.key.keysym.sym)
{
case SDLK_SPACE:
SDL_RecordGesture(-1);
break;
case SDLK_s:
src = SDL_RWFromFile("gestureSave","w");
SDL_Log("Wrote %i templates",SDL_SaveAllDollarTemplates(src));
SDL_RWclose(src);
break;
case SDLK_l:
src = SDL_RWFromFile("gestureSave","r");
SDL_Log("Loaded: %i",SDL_LoadDollarTemplates(-1,src));
SDL_RWclose(src);
break;
case SDLK_ESCAPE:
quitting = SDL_TRUE;
break;
}
break;
case SDL_WINDOWEVENT:
if (event.window.event == SDL_WINDOWEVENT_RESIZED) {
if (!(screen = initScreen(event.window.data1, event.window.data2)))
{
SDL_Quit();
return 1;
}
if (!(screen = initScreen(event.window.data1, event.window.data2)))
{
SDL_Quit();
return 1;
}
}
break;
case SDL_FINGERMOTION:
break;
case SDL_FINGERMOTION:
#if VERBOSE
SDL_Log("Finger: %i,x: %i, y: %i",event.tfinger.fingerId,
event.tfinger.x,event.tfinger.y);
SDL_Log("Finger: %i,x: %i, y: %i",event.tfinger.fingerId,
event.tfinger.x,event.tfinger.y);
#endif
break;
case SDL_FINGERDOWN:
break;
case SDL_FINGERDOWN:
#if VERBOSE
SDL_Log("Finger: %"PRIs64" down - x: %i, y: %i",
event.tfinger.fingerId,event.tfinger.x,event.tfinger.y);
SDL_Log("Finger: %"PRIs64" down - x: %i, y: %i",
event.tfinger.fingerId,event.tfinger.x,event.tfinger.y);
#endif
break;
case SDL_FINGERUP:
break;
case SDL_FINGERUP:
#if VERBOSE
SDL_Log("Finger: %"PRIs64" up - x: %i, y: %i",
event.tfinger.fingerId,event.tfinger.x,event.tfinger.y);
SDL_Log("Finger: %"PRIs64" up - x: %i, y: %i",
event.tfinger.fingerId,event.tfinger.x,event.tfinger.y);
#endif
break;
case SDL_MULTIGESTURE:
#if VERBOSE
SDL_Log("Multi Gesture: x = %f, y = %f, dAng = %f, dR = %f",
event.mgesture.x,
event.mgesture.y,
event.mgesture.dTheta,
event.mgesture.dDist);
SDL_Log("MG: numDownTouch = %i",event.mgesture.numFingers);
break;
case SDL_MULTIGESTURE:
#if VERBOSE
SDL_Log("Multi Gesture: x = %f, y = %f, dAng = %f, dR = %f",
event.mgesture.x,
event.mgesture.y,
event.mgesture.dTheta,
event.mgesture.dDist);
SDL_Log("MG: numDownTouch = %i",event.mgesture.numFingers);
#endif
knob.p.x = event.mgesture.x;
knob.p.y = event.mgesture.y;
knob.ang += event.mgesture.dTheta;
knob.r += event.mgesture.dDist;
break;
case SDL_DOLLARGESTURE:
SDL_Log("Gesture %"PRIs64" performed, error: %f",
event.dgesture.gestureId,
event.dgesture.error);
break;
case SDL_DOLLARRECORD:
SDL_Log("Recorded gesture: %"PRIs64"",event.dgesture.gestureId);
break;
}
knob.p.x = event.mgesture.x;
knob.p.y = event.mgesture.y;
knob.ang += event.mgesture.dTheta;
knob.r += event.mgesture.dDist;
break;
case SDL_DOLLARGESTURE:
SDL_Log("Gesture %"PRIs64" performed, error: %f",
event.dgesture.gestureId,
event.dgesture.error);
break;
case SDL_DOLLARRECORD:
SDL_Log("Recorded gesture: %"PRIs64"",event.dgesture.gestureId);
break;
}
}
DrawScreen(screen);
}
SDL_Quit();
}
SDL_Quit();
return 0;
}

View File

@@ -238,7 +238,7 @@ int main(int argc, char *argv[]) {
}
}
}
if (!SDLTest_CommonInit(state)) {
return 2;
}
@@ -267,7 +267,7 @@ int main(int argc, char *argv[]) {
SDL_SetRenderDrawColor(renderer, 0xA0, 0xA0, 0xA0, 0xFF);
SDL_RenderClear(renderer);
}
Redraw();
Redraw();
/* Main render loop */
done = 0;
while (!done) {
@@ -356,7 +356,7 @@ int main(int argc, char *argv[]) {
break;
}
break;
}
}
}

View File

@@ -19,7 +19,7 @@
#include "SDL_test_common.h"
#define SWAP(typ,a,b) do{typ t=a;a=b;b=t;}while(0)
#define NUM_OBJECTS 100
#define NUM_OBJECTS 100
static SDLTest_CommonState *state;
static int num_objects;

View File

@@ -21,11 +21,11 @@
#ifndef SDL_JOYSTICK_DISABLED
#ifdef __IPHONEOS__
#define SCREEN_WIDTH 320
#define SCREEN_HEIGHT 480
#define SCREEN_WIDTH 320
#define SCREEN_HEIGHT 480
#else
#define SCREEN_WIDTH 640
#define SCREEN_HEIGHT 480
#define SCREEN_WIDTH 640
#define SCREEN_HEIGHT 480
#endif

View File

@@ -10,7 +10,7 @@
freely.
*/
/* Test the thread and mutex locking functions
/* Test the thread and mutex locking functions
Also exercises the system's signal/thread interaction
*/

View File

@@ -18,7 +18,7 @@
#define WINDOW_W 640
#define WINDOW_H 480
#define NUM_SPRITES 100
#define MAX_SPEED 1
#define MAX_SPEED 1
static NativeWindowFactory *factories[] = {
#ifdef TEST_NATIVE_WINDOWS

View File

@@ -35,7 +35,7 @@ main(int argc, char *argv[])
int i, done;
SDL_Event event;
/* Initialize test framework */
state = SDLTest_CommonCreateState(argv, SDL_INIT_VIDEO);
if (!state) {

View File

@@ -74,7 +74,7 @@ TestWaitTimeout(void)
fprintf(stderr, "Wait took %d milliseconds\n", duration);
/* Check to make sure the return value indicates timed out */
if (retval != SDL_MUTEX_TIMEDOUT)
if (retval != SDL_MUTEX_TIMEDOUT)
fprintf(stderr, "SDL_SemWaitTimeout returned: %d; expected: %d\n", retval, SDL_MUTEX_TIMEDOUT);
}

View File

@@ -119,7 +119,7 @@ static ShaderData shaders[NUM_SHADERS] = {
"}"
},
};
static PFNGLATTACHOBJECTARBPROC glAttachObjectARB;
static PFNGLCOMPILESHADERARBPROC glCompileShaderARB;
static PFNGLCREATEPROGRAMOBJECTARBPROC glCreateProgramObjectARB;
@@ -195,7 +195,7 @@ static SDL_bool CompileShaderProgram(ShaderData *data)
}
}
glUseProgramObjectARB(0);
return (glGetError() == GL_NO_ERROR);
}
@@ -382,7 +382,7 @@ void DrawGLScene(GLuint texture, GLfloat * texcoord)
glLoadIdentity(); // Reset The View
glTranslatef(-1.5f,0.0f,0.0f); // Move Left 1.5 Units
// draw a triangle (in smooth coloring mode)
glBegin(GL_POLYGON); // start drawing a polygon
glColor3f(1.0f,0.0f,0.0f); // Set The Color To Red
@@ -390,8 +390,8 @@ void DrawGLScene(GLuint texture, GLfloat * texcoord)
glColor3f(0.0f,1.0f,0.0f); // Set The Color To Green
glVertex3f( 1.0f,-1.0f, 0.0f); // Bottom Right
glColor3f(0.0f,0.0f,1.0f); // Set The Color To Blue
glVertex3f(-1.0f,-1.0f, 0.0f); // Bottom Left
glEnd(); // we're done with the polygon (smooth color interpolation)
glVertex3f(-1.0f,-1.0f, 0.0f); // Bottom Left
glEnd(); // we're done with the polygon (smooth color interpolation)
glTranslatef(3.0f,0.0f,0.0f); // Move Right 3 Units
@@ -416,7 +416,7 @@ void DrawGLScene(GLuint texture, GLfloat * texcoord)
glTexCoord2f(texcoord[MAXX], texcoord[MAXY]);
glVertex3f( 1.0f,-1.0f, 0.0f); // Bottom Right
glTexCoord2f(texcoord[MINX], texcoord[MAXY]);
glVertex3f(-1.0f,-1.0f, 0.0f); // Bottom Left
glVertex3f(-1.0f,-1.0f, 0.0f); // Bottom Left
glEnd(); // done with the polygon
if (shaders_supported) {
@@ -428,8 +428,8 @@ void DrawGLScene(GLuint texture, GLfloat * texcoord)
SDL_GL_SwapBuffers();
}
int main(int argc, char **argv)
{
int main(int argc, char **argv)
{
int done;
SDL_Surface *surface;
GLuint texture;

View File

@@ -32,10 +32,10 @@ void render(SDL_Renderer *renderer,SDL_Texture *texture,SDL_Rect texture_dimensi
//Clear render-target to blue.
SDL_SetRenderDrawColor(renderer,0x00,0x00,0xff,0xff);
SDL_RenderClear(renderer);
//Render the texture.
SDL_RenderCopy(renderer,texture,&texture_dimensions,&texture_dimensions);
SDL_RenderPresent(renderer);
}
@@ -72,12 +72,12 @@ int main(int argc,char** argv)
printf("SDL_Shape requires at least one bitmap file as argument.\n");
exit(-1);
}
if(SDL_VideoInit(NULL) == -1) {
printf("Could not initialize SDL video.\n");
exit(-2);
}
num_pictures = argc - 1;
pictures = (LoadedPicture *)malloc(sizeof(LoadedPicture)*num_pictures);
for(i=0;i<num_pictures;i++)
@@ -105,7 +105,7 @@ int main(int argc,char** argv)
pictures[i].mode.parameters.colorKey = black;
}
}
window = SDL_CreateShapedWindow("SDL_Shape test",SHAPED_WINDOW_X,SHAPED_WINDOW_Y,SHAPED_WINDOW_DIMENSION,SHAPED_WINDOW_DIMENSION,SDL_WINDOW_RESIZABLE | SDL_WINDOW_SHOWN);
if(window == NULL) {
for(i=0;i<num_pictures;i++)
@@ -125,7 +125,7 @@ int main(int argc,char** argv)
printf("Could not create rendering context for SDL_Shape window.\n");
exit(-5);
}
for(i=0;i<num_pictures;i++)
pictures[i].texture = NULL;
for(i=0;i<num_pictures;i++) {
@@ -145,7 +145,7 @@ int main(int argc,char** argv)
exit(-6);
}
}
event_pending = 0;
should_exit = 0;
event_pending = SDL_PollEvent(&event);
@@ -184,7 +184,7 @@ int main(int argc,char** argv)
SDL_Delay(time_left());
next_time += TICK_INTERVAL;
}
//Free the textures.
for(i=0;i<num_pictures;i++)
SDL_DestroyTexture(pictures[i].texture);

View File

@@ -28,7 +28,7 @@ int main(int argc, char *argv[])
#include "SDL.h"
#define DEFAULT_RESOLUTION 1
#define DEFAULT_RESOLUTION 1
static int ticks = 0;

View File

@@ -129,8 +129,8 @@ main(int argc, char *argv[])
SDL_FreeCursor(cursor);
quit(0);
// keep the compiler happy ...
return(0);
// keep the compiler happy ...
return(0);
}
/* vi: set ts=4 sw=4 expandtab: */