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 2ac8624930
commit 0cb6385637
376 changed files with 17562 additions and 17773 deletions

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
};