Added the automation test to the autoconf build system
authorSam Lantinga <slouken@libsdl.org>
Sat, 22 Dec 2012 17:24:42 -0800
changeset 6769b49778d885cd
parent 6768 22c37bf0afbc
child 6770 9a111d2aa992
Added the automation test to the autoconf build system
test/Makefile.in
test/testautomation.c
test/testautomation_clipboard.c
test/testautomation_platform.c
test/testautomation_rect.c
test/testautomation_render.c
test/testautomation_rwops.c
test/testautomation_suites.h
test/tests/testclipboard.c
test/tests/testplatform.c
test/tests/testrect.c
test/tests/testrender.c
test/tests/testrwops.c
test/tests/testsuites.h
     1.1 --- a/test/Makefile.in	Sat Dec 22 17:24:14 2012 -0800
     1.2 +++ b/test/Makefile.in	Sat Dec 22 17:24:42 2012 -0800
     1.3 @@ -11,6 +11,7 @@
     1.4  	checkkeys$(EXE) \
     1.5  	loopwave$(EXE) \
     1.6  	testaudioinfo$(EXE) \
     1.7 +	testautomation$(EXE) \
     1.8  	testdraw2$(EXE) \
     1.9  	testerror$(EXE) \
    1.10  	testfile$(EXE) \
    1.11 @@ -67,6 +68,14 @@
    1.12  testaudioinfo$(EXE): $(srcdir)/testaudioinfo.c
    1.13  	$(CC) -o $@ $^ $(CFLAGS) $(LIBS)
    1.14  
    1.15 +testautomation$(EXE): $(srcdir)/testautomation.c \
    1.16 +		      $(srcdir)/testautomation_clipboard.c \
    1.17 +		      $(srcdir)/testautomation_platform.c \
    1.18 +		      $(srcdir)/testautomation_rect.c \
    1.19 +		      $(srcdir)/testautomation_render.c \
    1.20 +		      $(srcdir)/testautomation_rwops.c
    1.21 +	$(CC) -o $@ $^ $(CFLAGS) $(LIBS) -lSDL2_test
    1.22 +
    1.23  testmultiaudio$(EXE): $(srcdir)/testmultiaudio.c
    1.24  	$(CC) -o $@ $^ $(CFLAGS) $(LIBS)
    1.25  
     2.1 --- a/test/testautomation.c	Sat Dec 22 17:24:14 2012 -0800
     2.2 +++ b/test/testautomation.c	Sat Dec 22 17:24:42 2012 -0800
     2.3 @@ -17,7 +17,7 @@
     2.4  #include "SDL.h"
     2.5  #include "SDL_test.h"
     2.6  
     2.7 -#include "tests/testsuites.h"
     2.8 +#include "testautomation_suites.h"
     2.9  
    2.10  static SDLTest_CommonState *state;
    2.11  
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/test/testautomation_clipboard.c	Sat Dec 22 17:24:42 2012 -0800
     3.3 @@ -0,0 +1,182 @@
     3.4 +/**
     3.5 + * New/updated tests: aschiffler at ferzkopp dot net
     3.6 + */
     3.7 +
     3.8 +#include <stdio.h>
     3.9 +#include <string.h>
    3.10 +
    3.11 +#include "SDL.h"
    3.12 +#include "SDL_test.h"
    3.13 +
    3.14 +/* ================= Test Case Implementation ================== */
    3.15 +
    3.16 +/* Test case functions */
    3.17 +
    3.18 +/**
    3.19 + * \brief Check call to SDL_HasClipboardText
    3.20 + *
    3.21 + * \sa
    3.22 + * http://wiki.libsdl.org/moin.cgi/SDL_HasClipboardText
    3.23 + */
    3.24 +int
    3.25 +clipboard_testHasClipboardText(void *arg)
    3.26 +{
    3.27 +	SDL_bool result;
    3.28 +	result = SDL_HasClipboardText();
    3.29 +	SDLTest_AssertPass("Call to SDL_HasClipboardText succeeded");
    3.30 +
    3.31 +    return TEST_COMPLETED;
    3.32 +}
    3.33 +
    3.34 +/**
    3.35 + * \brief Check call to SDL_GetClipboardText
    3.36 + *
    3.37 + * \sa
    3.38 + * http://wiki.libsdl.org/moin.cgi/SDL_GetClipboardText
    3.39 + */
    3.40 +int
    3.41 +clipboard_testGetClipboardText(void *arg)
    3.42 +{
    3.43 +	char *charResult;
    3.44 +	charResult = SDL_GetClipboardText();
    3.45 +	SDLTest_AssertPass("Call to SDL_GetClipboardText succeeded");
    3.46 +
    3.47 +	if (charResult) SDL_free(charResult);
    3.48 +
    3.49 +    return TEST_COMPLETED;
    3.50 +}
    3.51 +
    3.52 +/**
    3.53 + * \brief Check call to SDL_SetClipboardText
    3.54 + * \sa
    3.55 + * http://wiki.libsdl.org/moin.cgi/SDL_SetClipboardText
    3.56 + */
    3.57 +int
    3.58 +clipboard_testSetClipboardText(void *arg)
    3.59 +{
    3.60 +	char *textRef = SDLTest_RandomAsciiString();
    3.61 +	char *text = SDL_strdup(textRef);
    3.62 +	int result;
    3.63 +	result = SDL_SetClipboardText((const char *)text);
    3.64 +	SDLTest_AssertPass("Call to SDL_SetClipboardText succeeded");
    3.65 +	SDLTest_AssertCheck(
    3.66 +		result == 0,
    3.67 +		"Validate SDL_SetClipboardText result, expected 0, got %i",
    3.68 +		result);
    3.69 +	SDLTest_AssertCheck(
    3.70 +		SDL_strcmp(textRef, text) == 0,
    3.71 +		"Verify SDL_SetClipboardText did not modify input string, expected '%s', got '%s'",
    3.72 +		textRef, text);
    3.73 +
    3.74 +    /* Cleanup */
    3.75 +    if (textRef) SDL_free(textRef);
    3.76 +    if (text) SDL_free(text);
    3.77 +
    3.78 +   return TEST_COMPLETED;
    3.79 +}
    3.80 +
    3.81 +/**
    3.82 + * \brief End-to-end test of SDL_xyzClipboardText functions
    3.83 + * \sa
    3.84 + * http://wiki.libsdl.org/moin.cgi/SDL_HasClipboardText
    3.85 + * http://wiki.libsdl.org/moin.cgi/SDL_GetClipboardText
    3.86 + * http://wiki.libsdl.org/moin.cgi/SDL_SetClipboardText
    3.87 + */
    3.88 +int
    3.89 +clipboard_testClipboardTextFunctions(void *arg)
    3.90 +{
    3.91 +	char *textRef = SDLTest_RandomAsciiString();
    3.92 +	char *text = SDL_strdup(textRef);
    3.93 +	SDL_bool boolResult;
    3.94 +	int intResult;
    3.95 +	char *charResult;
    3.96 +
    3.97 +	/* Clear clipboard text state */
    3.98 +	boolResult = SDL_HasClipboardText();
    3.99 +	SDLTest_AssertPass("Call to SDL_HasClipboardText succeeded");
   3.100 +	if (boolResult == SDL_TRUE) {
   3.101 +        intResult = SDL_SetClipboardText((const char *)NULL);
   3.102 +		SDLTest_AssertPass("Call to DL_SetClipboardText(NULL) succeeded");
   3.103 +	    SDLTest_AssertCheck(
   3.104 +			intResult == 0,
   3.105 +			"Verify result from SDL_SetClipboardText(NULL), expected 0, got %i",
   3.106 +			intResult);
   3.107 +	    charResult = SDL_GetClipboardText();
   3.108 +		SDLTest_AssertPass("Call to SDL_GetClipboardText succeeded");
   3.109 +	    boolResult = SDL_HasClipboardText();
   3.110 +		SDLTest_AssertPass("Call to SDL_HasClipboardText succeeded");
   3.111 +	    SDLTest_AssertCheck(
   3.112 +            boolResult == SDL_FALSE,
   3.113 +	        "Verify SDL_HasClipboardText returned SDL_FALSE, got %s",
   3.114 +			(boolResult) ? "SDL_TRUE" : "SDL_FALSE");
   3.115 +    }
   3.116 +
   3.117 +    /* Empty clipboard  */
   3.118 +	charResult = SDL_GetClipboardText();
   3.119 +	SDLTest_AssertPass("Call to SDL_GetClipboardText succeeded");
   3.120 +	SDLTest_AssertCheck(
   3.121 +		charResult != NULL,
   3.122 +		"Verify SDL_GetClipboardText did not return NULL");
   3.123 +	SDLTest_AssertCheck(
   3.124 +		strlen(charResult) == 0,
   3.125 +		"Verify SDL_GetClipboardText returned string with length 0, got length %i",
   3.126 +		strlen(charResult));
   3.127 +    intResult = SDL_SetClipboardText((const char *)text);
   3.128 +	SDLTest_AssertPass("Call to SDL_SetClipboardText succeeded");
   3.129 +	SDLTest_AssertCheck(
   3.130 +		intResult == 0,
   3.131 +		"Verify result from SDL_SetClipboardText(NULL), expected 0, got %i",
   3.132 +		intResult);
   3.133 +	SDLTest_AssertCheck(
   3.134 +		strcmp(textRef, text) == 0,
   3.135 +		"Verify SDL_SetClipboardText did not modify input string, expected '%s', got '%s'",
   3.136 +		textRef, text);
   3.137 +	boolResult = SDL_HasClipboardText();
   3.138 +	SDLTest_AssertPass("Call to SDL_HasClipboardText succeeded");
   3.139 +	SDLTest_AssertCheck(
   3.140 +        boolResult == SDL_TRUE,
   3.141 +	    "Verify SDL_HasClipboardText returned SDL_TRUE, got %s",
   3.142 +		(boolResult) ? "SDL_TRUE" : "SDL_FALSE");
   3.143 +	charResult = SDL_GetClipboardText();
   3.144 +	SDLTest_AssertPass("Call to SDL_GetClipboardText succeeded");
   3.145 +	SDLTest_AssertCheck(
   3.146 +		strcmp(textRef, charResult) == 0,
   3.147 +		"Verify SDL_GetClipboardText returned correct string, expected '%s', got '%s'",
   3.148 +		textRef, charResult);
   3.149 +
   3.150 +    /* Cleanup */
   3.151 +    if (textRef) SDL_free(textRef);
   3.152 +    if (text) SDL_free(text);
   3.153 +    if (charResult) SDL_free(charResult);
   3.154 +
   3.155 +   return TEST_COMPLETED;
   3.156 +}
   3.157 +
   3.158 +
   3.159 +/* ================= Test References ================== */
   3.160 +
   3.161 +/* Clipboard test cases */
   3.162 +static const SDLTest_TestCaseReference clipboardTest1 =
   3.163 +		{ (SDLTest_TestCaseFp)clipboard_testHasClipboardText, "clipboard_testHasClipboardText", "Check call to SDL_HasClipboardText", TEST_ENABLED };
   3.164 +
   3.165 +static const SDLTest_TestCaseReference clipboardTest2 =
   3.166 +		{ (SDLTest_TestCaseFp)clipboard_testGetClipboardText, "clipboard_testGetClipboardText", "Check call to SDL_GetClipboardText", TEST_ENABLED };
   3.167 +
   3.168 +static const SDLTest_TestCaseReference clipboardTest3 =
   3.169 +		{ (SDLTest_TestCaseFp)clipboard_testSetClipboardText, "clipboard_testSetClipboardText", "Check call to SDL_SetClipboardText", TEST_ENABLED };
   3.170 +
   3.171 +static const SDLTest_TestCaseReference clipboardTest4 =
   3.172 +		{ (SDLTest_TestCaseFp)clipboard_testClipboardTextFunctions, "clipboard_testClipboardTextFunctions", "End-to-end test of SDL_xyzClipboardText functions", TEST_ENABLED };
   3.173 +
   3.174 +/* Sequence of Clipboard test cases */
   3.175 +static const SDLTest_TestCaseReference *clipboardTests[] =  {
   3.176 +	&clipboardTest1, &clipboardTest2, &clipboardTest3, &clipboardTest4, NULL
   3.177 +};
   3.178 +
   3.179 +/* Clipboard test suite (global) */
   3.180 +SDLTest_TestSuiteReference clipboardTestSuite = {
   3.181 +	"Clipboard",
   3.182 +	NULL,
   3.183 +	clipboardTests,
   3.184 +	NULL
   3.185 +};
     4.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.2 +++ b/test/testautomation_platform.c	Sat Dec 22 17:24:42 2012 -0800
     4.3 @@ -0,0 +1,561 @@
     4.4 +/**
     4.5 + * Original code: automated SDL platform test written by Edgar Simo "bobbens"
     4.6 + * Extended and updated by aschiffler at ferzkopp dot net
     4.7 + */
     4.8 +
     4.9 +#include <stdio.h>
    4.10 +
    4.11 +#include "SDL.h"
    4.12 +#include "SDL_test.h"
    4.13 +
    4.14 +/* ================= Test Case Implementation ================== */
    4.15 +
    4.16 +/* Helper functions */
    4.17 +
    4.18 +/**
    4.19 + * @brief Compare sizes of types.
    4.20 + *
    4.21 + * @note Watcom C flags these as Warning 201: "Unreachable code" if you just
    4.22 + *  compare them directly, so we push it through a function to keep the
    4.23 + *  compiler quiet.  --ryan.
    4.24 + */
    4.25 +static int _compareSizeOfType( size_t sizeoftype, size_t hardcodetype )
    4.26 +{
    4.27 +    return sizeoftype != hardcodetype;
    4.28 +}
    4.29 +
    4.30 +/* Test case functions */
    4.31 +
    4.32 +/**
    4.33 + * @brief Tests type sizes.
    4.34 + */
    4.35 +int platform_testTypes(void *arg)
    4.36 +{
    4.37 +   int ret;
    4.38 +
    4.39 +   ret = _compareSizeOfType( sizeof(Uint8), 1 );
    4.40 +   SDLTest_AssertCheck( ret == 0, "sizeof(Uint8) = %lu, expected  1", sizeof(Uint8) );
    4.41 +
    4.42 +   ret = _compareSizeOfType( sizeof(Uint16), 2 );
    4.43 +   SDLTest_AssertCheck( ret == 0, "sizeof(Uint16) = %lu, expected 2", sizeof(Uint16) );
    4.44 +
    4.45 +   ret = _compareSizeOfType( sizeof(Uint32), 4 );
    4.46 +   SDLTest_AssertCheck( ret == 0, "sizeof(Uint32) = %lu, expected 4", sizeof(Uint32) );
    4.47 +
    4.48 +   ret = _compareSizeOfType( sizeof(Uint64), 8 );
    4.49 +   SDLTest_AssertCheck( ret == 0, "sizeof(Uint64) = %lu, expected 8", sizeof(Uint64) );
    4.50 +
    4.51 +   return TEST_COMPLETED;
    4.52 +}
    4.53 +
    4.54 +/**
    4.55 + * @brief Tests platform endianness and SDL_SwapXY functions.
    4.56 + */
    4.57 +int platform_testEndianessAndSwap(void *arg)
    4.58 +{
    4.59 +    int real_byteorder;
    4.60 +    Uint16 value = 0x1234;
    4.61 +    Uint16 value16 = 0xCDAB;
    4.62 +    Uint16 swapped16 = 0xABCD;
    4.63 +    Uint32 value32 = 0xEFBEADDE;
    4.64 +    Uint32 swapped32 = 0xDEADBEEF;
    4.65 +
    4.66 +    Uint64 value64, swapped64;
    4.67 +    value64 = 0xEFBEADDE;
    4.68 +    value64 <<= 32;
    4.69 +    value64 |= 0xCDAB3412;
    4.70 +    swapped64 = 0x1234ABCD;
    4.71 +    swapped64 <<= 32;
    4.72 +    swapped64 |= 0xDEADBEEF;
    4.73 +
    4.74 +    if ((*((char *) &value) >> 4) == 0x1) {
    4.75 +        real_byteorder = SDL_BIG_ENDIAN;
    4.76 +    } else {
    4.77 +        real_byteorder = SDL_LIL_ENDIAN;
    4.78 +    }
    4.79 +
    4.80 +    /* Test endianness. */
    4.81 +    SDLTest_AssertCheck( real_byteorder == SDL_BYTEORDER,
    4.82 +             "Machine detected as %s endian, appears to be %s endian.",
    4.83 +             (SDL_BYTEORDER == SDL_LIL_ENDIAN) ? "little" : "big",
    4.84 +             (real_byteorder == SDL_LIL_ENDIAN) ? "little" : "big" );
    4.85 +
    4.86 +    /* Test 16 swap. */
    4.87 +    SDLTest_AssertCheck( SDL_Swap16(value16) == swapped16,
    4.88 +             "SDL_Swap16(): 16 bit swapped: 0x%X => 0x%X",
    4.89 +             value16, SDL_Swap16(value16) );
    4.90 +
    4.91 +    /* Test 32 swap. */
    4.92 +    SDLTest_AssertCheck( SDL_Swap32(value32) == swapped32,
    4.93 +             "SDL_Swap32(): 32 bit swapped: 0x%X => 0x%X",
    4.94 +             value32, SDL_Swap32(value32) );
    4.95 +
    4.96 +    /* Test 64 swap. */
    4.97 +    SDLTest_AssertCheck( SDL_Swap64(value64) == swapped64,
    4.98 +#ifdef _MSC_VER
    4.99 +             "SDL_Swap64(): 64 bit swapped: 0x%I64X => 0x%I64X",
   4.100 +#else
   4.101 +             "SDL_Swap64(): 64 bit swapped: 0x%llX => 0x%llX",
   4.102 +#endif
   4.103 +             value64, SDL_Swap64(value64) );
   4.104 +
   4.105 +   return TEST_COMPLETED;
   4.106 +}
   4.107 +
   4.108 +/*!
   4.109 + * \brief Tests SDL_GetXYZ() functions
   4.110 + * \sa
   4.111 + * http://wiki.libsdl.org/moin.cgi/SDL_GetPlatform
   4.112 + * http://wiki.libsdl.org/moin.cgi/SDL_GetCPUCount
   4.113 + * http://wiki.libsdl.org/moin.cgi/SDL_GetCPUCacheLineSize
   4.114 + * http://wiki.libsdl.org/moin.cgi/SDL_GetRevision
   4.115 + * http://wiki.libsdl.org/moin.cgi/SDL_GetRevisionNumber
   4.116 + */
   4.117 +int platform_testGetFunctions (void *arg)
   4.118 +{
   4.119 +   char *platform;
   4.120 +   char *revision;
   4.121 +   int ret;
   4.122 +   int len;
   4.123 +
   4.124 +   platform = (char *)SDL_GetPlatform();
   4.125 +   SDLTest_AssertPass("SDL_GetPlatform()");
   4.126 +   SDLTest_AssertCheck(platform != NULL, "SDL_GetPlatform() != NULL");
   4.127 +   if (platform != NULL) {
   4.128 +     len = strlen(platform);
   4.129 +     SDLTest_AssertCheck(len > 0,
   4.130 +             "SDL_GetPlatform(): expected non-empty platform, was platform: '%s', len: %i",
   4.131 +             platform,
   4.132 +             len);
   4.133 +   }
   4.134 +
   4.135 +   ret = SDL_GetCPUCount();
   4.136 +   SDLTest_AssertPass("SDL_GetCPUCount()");
   4.137 +   SDLTest_AssertCheck(ret > 0,
   4.138 +             "SDL_GetCPUCount(): expected count > 0, was: %i",
   4.139 +             ret);
   4.140 +
   4.141 +   ret = SDL_GetCPUCacheLineSize();
   4.142 +   SDLTest_AssertPass("SDL_GetCPUCacheLineSize()");
   4.143 +   SDLTest_AssertCheck(ret >= 0,
   4.144 +             "SDL_GetCPUCacheLineSize(): expected size >= 0, was: %i",
   4.145 +             ret);
   4.146 +
   4.147 +   revision = (char *)SDL_GetRevision();
   4.148 +   SDLTest_AssertPass("SDL_GetRevision()");
   4.149 +   SDLTest_AssertCheck(revision != NULL, "SDL_GetRevision() != NULL");
   4.150 +
   4.151 +   ret = SDL_GetRevisionNumber();
   4.152 +   SDLTest_AssertPass("SDL_GetRevisionNumber()");
   4.153 +
   4.154 +   return TEST_COMPLETED;
   4.155 +}
   4.156 +
   4.157 +/*!
   4.158 + * \brief Tests SDL_HasXYZ() functions
   4.159 + * \sa
   4.160 + * http://wiki.libsdl.org/moin.cgi/SDL_Has3DNow
   4.161 + * http://wiki.libsdl.org/moin.cgi/SDL_HasAltiVec
   4.162 + * http://wiki.libsdl.org/moin.cgi/SDL_HasMMX
   4.163 + * http://wiki.libsdl.org/moin.cgi/SDL_HasRDTSC
   4.164 + * http://wiki.libsdl.org/moin.cgi/SDL_HasSSE
   4.165 + * http://wiki.libsdl.org/moin.cgi/SDL_HasSSE2
   4.166 + * http://wiki.libsdl.org/moin.cgi/SDL_HasSSE3
   4.167 + * http://wiki.libsdl.org/moin.cgi/SDL_HasSSE41
   4.168 + * http://wiki.libsdl.org/moin.cgi/SDL_HasSSE42
   4.169 + */
   4.170 +int platform_testHasFunctions (void *arg)
   4.171 +{
   4.172 +   int ret;
   4.173 +
   4.174 +   // TODO: independently determine and compare values as well
   4.175 +
   4.176 +   ret = SDL_HasRDTSC();
   4.177 +   SDLTest_AssertPass("SDL_HasRDTSC()");
   4.178 +
   4.179 +   ret = SDL_HasAltiVec();
   4.180 +   SDLTest_AssertPass("SDL_HasAltiVec()");
   4.181 +
   4.182 +   ret = SDL_HasMMX();
   4.183 +   SDLTest_AssertPass("SDL_HasMMX()");
   4.184 +
   4.185 +   ret = SDL_Has3DNow();
   4.186 +   SDLTest_AssertPass("SDL_Has3DNow()");
   4.187 +
   4.188 +   ret = SDL_HasSSE();
   4.189 +   SDLTest_AssertPass("SDL_HasSSE()");
   4.190 +
   4.191 +   ret = SDL_HasSSE2();
   4.192 +   SDLTest_AssertPass("SDL_HasSSE2()");
   4.193 +
   4.194 +   ret = SDL_HasSSE3();
   4.195 +   SDLTest_AssertPass("SDL_HasSSE3()");
   4.196 +
   4.197 +   ret = SDL_HasSSE41();
   4.198 +   SDLTest_AssertPass("SDL_HasSSE41()");
   4.199 +
   4.200 +   ret = SDL_HasSSE42();
   4.201 +   SDLTest_AssertPass("SDL_HasSSE42()");
   4.202 +
   4.203 +   return TEST_COMPLETED;
   4.204 +}
   4.205 +
   4.206 +/*!
   4.207 + * \brief Tests SDL_GetVersion
   4.208 + * \sa
   4.209 + * http://wiki.libsdl.org/moin.cgi/SDL_GetVersion
   4.210 + */
   4.211 +int platform_testGetVersion(void *arg)
   4.212 +{
   4.213 +   SDL_version linked;
   4.214 +   int major = SDL_MAJOR_VERSION;
   4.215 +   int minor = SDL_MINOR_VERSION;
   4.216 +
   4.217 +   SDL_GetVersion(&linked);
   4.218 +   SDLTest_AssertCheck( linked.major >= major,
   4.219 +             "SDL_GetVersion(): returned major %i (>= %i)",
   4.220 +             linked.major,
   4.221 +             major);
   4.222 +   SDLTest_AssertCheck( linked.minor >= minor,
   4.223 +             "SDL_GetVersion(): returned minor %i (>= %i)",
   4.224 +             linked.minor,
   4.225 +             minor);
   4.226 +
   4.227 +   return TEST_COMPLETED;
   4.228 +}
   4.229 +
   4.230 +
   4.231 +/*!
   4.232 + * \brief Tests SDL_VERSION macro
   4.233 + */
   4.234 +int platform_testSDLVersion(void *arg)
   4.235 +{
   4.236 +   SDL_version compiled;
   4.237 +   int major = SDL_MAJOR_VERSION;
   4.238 +   int minor = SDL_MINOR_VERSION;
   4.239 +
   4.240 +   SDL_VERSION(&compiled);
   4.241 +   SDLTest_AssertCheck( compiled.major >= major,
   4.242 +             "SDL_VERSION() returned major %i (>= %i)",
   4.243 +             compiled.major,
   4.244 +             major);
   4.245 +   SDLTest_AssertCheck( compiled.minor >= minor,
   4.246 +             "SDL_VERSION() returned minor %i (>= %i)",
   4.247 +             compiled.minor,
   4.248 +             minor);
   4.249 +
   4.250 +   return TEST_COMPLETED;
   4.251 +}
   4.252 +
   4.253 +
   4.254 +/*!
   4.255 + * \brief Tests default SDL_Init
   4.256 + */
   4.257 +int platform_testDefaultInit(void *arg)
   4.258 +{
   4.259 +   int ret;
   4.260 +   int subsystem;
   4.261 +
   4.262 +   subsystem = SDL_WasInit(SDL_INIT_EVERYTHING);
   4.263 +   SDLTest_AssertCheck( subsystem != 0,
   4.264 +             "SDL_WasInit(0): returned %i, expected != 0",
   4.265 +             subsystem);
   4.266 +
   4.267 +   ret = SDL_Init(SDL_WasInit(SDL_INIT_EVERYTHING));
   4.268 +   SDLTest_AssertCheck( ret == 0,
   4.269 +             "SDL_Init(0): returned %i, expected 0, error: %s",
   4.270 +             ret,
   4.271 +             SDL_GetError());
   4.272 +
   4.273 +   return TEST_COMPLETED;
   4.274 +}
   4.275 +
   4.276 +/*!
   4.277 + * \brief Tests SDL_Get/Set/ClearError
   4.278 + * \sa
   4.279 + * http://wiki.libsdl.org/moin.cgi/SDL_GetError
   4.280 + * http://wiki.libsdl.org/moin.cgi/SDL_SetError
   4.281 + * http://wiki.libsdl.org/moin.cgi/SDL_ClearError
   4.282 + */
   4.283 +int platform_testGetSetClearError(void *arg)
   4.284 +{
   4.285 +   const char *testError = "Testing";
   4.286 +   char *lastError;
   4.287 +   int len;
   4.288 +
   4.289 +   SDL_ClearError();
   4.290 +   SDLTest_AssertPass("SDL_ClearError()");
   4.291 +
   4.292 +   lastError = (char *)SDL_GetError();
   4.293 +   SDLTest_AssertPass("SDL_GetError()");
   4.294 +   SDLTest_AssertCheck(lastError != NULL,
   4.295 +             "SDL_GetError() != NULL");
   4.296 +   if (lastError != NULL)
   4.297 +   {
   4.298 +     len = strlen(lastError);
   4.299 +     SDLTest_AssertCheck(len == 0,
   4.300 +             "SDL_GetError(): no message expected, len: %i", len);
   4.301 +   }
   4.302 +
   4.303 +   SDL_SetError("%s", testError);
   4.304 +   SDLTest_AssertPass("SDL_SetError()");
   4.305 +   lastError = (char *)SDL_GetError();
   4.306 +   SDLTest_AssertCheck(lastError != NULL,
   4.307 +             "SDL_GetError() != NULL");
   4.308 +   if (lastError != NULL)
   4.309 +   {
   4.310 +     len = strlen(lastError);
   4.311 +     SDLTest_AssertCheck(len == strlen(testError),
   4.312 +             "SDL_GetError(): expected message len %i, was len: %i",
   4.313 +             strlen(testError),
   4.314 +             len);
   4.315 +     SDLTest_AssertCheck(strcmp(lastError, testError) == 0,
   4.316 +             "SDL_GetError(): expected message %s, was message: %s",
   4.317 +             testError,
   4.318 +             lastError);
   4.319 +   }
   4.320 +
   4.321 +   // Clean up
   4.322 +   SDL_ClearError();
   4.323 +   SDLTest_AssertPass("SDL_ClearError()");
   4.324 +
   4.325 +   return TEST_COMPLETED;
   4.326 +}
   4.327 +
   4.328 +/*!
   4.329 + * \brief Tests SDL_SetError with empty input
   4.330 + * \sa
   4.331 + * http://wiki.libsdl.org/moin.cgi/SDL_SetError
   4.332 + */
   4.333 +int platform_testSetErrorEmptyInput(void *arg)
   4.334 +{
   4.335 +   const char *testError = "";
   4.336 +   char *lastError;
   4.337 +   int len;
   4.338 +
   4.339 +   SDL_SetError("%s", testError);
   4.340 +   SDLTest_AssertPass("SDL_SetError()");
   4.341 +   lastError = (char *)SDL_GetError();
   4.342 +   SDLTest_AssertCheck(lastError != NULL,
   4.343 +             "SDL_GetError() != NULL");
   4.344 +   if (lastError != NULL)
   4.345 +   {
   4.346 +     len = strlen(lastError);
   4.347 +     SDLTest_AssertCheck(len == strlen(testError),
   4.348 +             "SDL_GetError(): expected message len %i, was len: %i",
   4.349 +             strlen(testError),
   4.350 +             len);
   4.351 +     SDLTest_AssertCheck(strcmp(lastError, testError) == 0,
   4.352 +             "SDL_GetError(): expected message '%s', was message: '%s'",
   4.353 +             testError,
   4.354 +             lastError);
   4.355 +   }
   4.356 +
   4.357 +   // Clean up
   4.358 +   SDL_ClearError();
   4.359 +   SDLTest_AssertPass("SDL_ClearError()");
   4.360 +
   4.361 +   return TEST_COMPLETED;
   4.362 +}
   4.363 +
   4.364 +/*!
   4.365 + * \brief Tests SDL_SetError with invalid input
   4.366 + * \sa
   4.367 + * http://wiki.libsdl.org/moin.cgi/SDL_SetError
   4.368 + */
   4.369 +int platform_testSetErrorInvalidInput(void *arg)
   4.370 +{
   4.371 +   const char *testError = NULL;
   4.372 +   const char *probeError = "Testing";
   4.373 +   char *lastError;
   4.374 +   int len;
   4.375 +
   4.376 +   // Reset
   4.377 +   SDL_ClearError();
   4.378 +   SDLTest_AssertPass("SDL_ClearError()");
   4.379 +
   4.380 +   // Check for no-op
   4.381 +   SDL_SetError(testError);
   4.382 +   SDLTest_AssertPass("SDL_SetError()");
   4.383 +   lastError = (char *)SDL_GetError();
   4.384 +   SDLTest_AssertCheck(lastError != NULL,
   4.385 +             "SDL_GetError() != NULL");
   4.386 +   if (lastError != NULL)
   4.387 +   {
   4.388 +     len = strlen(lastError);
   4.389 +     SDLTest_AssertCheck(len == 0,
   4.390 +             "SDL_GetError(): expected message len 0, was len: %i",
   4.391 +             0,
   4.392 +             len);
   4.393 +     SDLTest_AssertCheck(strcmp(lastError, "") == 0,
   4.394 +             "SDL_GetError(): expected message '', was message: '%s'",
   4.395 +             lastError);
   4.396 +   }
   4.397 +
   4.398 +   // Set
   4.399 +   SDL_SetError(probeError);
   4.400 +   SDLTest_AssertPass("SDL_SetError()");
   4.401 +
   4.402 +   // Check for no-op
   4.403 +   SDL_SetError(testError);
   4.404 +   SDLTest_AssertPass("SDL_SetError()");
   4.405 +   lastError = (char *)SDL_GetError();
   4.406 +   SDLTest_AssertCheck(lastError != NULL,
   4.407 +             "SDL_GetError() != NULL");
   4.408 +   if (lastError != NULL)
   4.409 +   {
   4.410 +     len = strlen(lastError);
   4.411 +     SDLTest_AssertCheck(len == strlen(probeError),
   4.412 +             "SDL_GetError(): expected message len %i, was len: %i",
   4.413 +             strlen(probeError),
   4.414 +             len);
   4.415 +     SDLTest_AssertCheck(strcmp(lastError, probeError) == 0,
   4.416 +             "SDL_GetError(): expected message '%s', was message: '%s'",
   4.417 +             probeError,
   4.418 +             lastError);
   4.419 +   }
   4.420 +
   4.421 +   // Clean up
   4.422 +   SDL_ClearError();
   4.423 +   SDLTest_AssertPass("SDL_ClearError()");
   4.424 +
   4.425 +   return TEST_COMPLETED;
   4.426 +}
   4.427 +
   4.428 +/*!
   4.429 + * \brief Tests SDL_GetPowerInfo
   4.430 + * \sa
   4.431 + * http://wiki.libsdl.org/moin.cgi/SDL_GetPowerInfo
   4.432 + */
   4.433 +int platform_testGetPowerInfo(void *arg)
   4.434 +{
   4.435 +   SDL_PowerState state;
   4.436 +   SDL_PowerState stateAgain;
   4.437 +   int secs;
   4.438 +   int secsAgain;
   4.439 +   int pct;
   4.440 +   int pctAgain;
   4.441 +
   4.442 +   state = SDL_GetPowerInfo(&secs, &pct);
   4.443 +   SDLTest_AssertPass("SDL_GetPowerInfo()");
   4.444 +   SDLTest_AssertCheck(
   4.445 +       state==SDL_POWERSTATE_UNKNOWN ||
   4.446 +       state==SDL_POWERSTATE_ON_BATTERY ||
   4.447 +       state==SDL_POWERSTATE_NO_BATTERY ||
   4.448 +       state==SDL_POWERSTATE_CHARGING ||
   4.449 +       state==SDL_POWERSTATE_CHARGED,
   4.450 +       "SDL_GetPowerInfo(): state %i is one of the expected values",
   4.451 +       (int)state);
   4.452 +
   4.453 +   if (state==SDL_POWERSTATE_ON_BATTERY)
   4.454 +   {
   4.455 +      SDLTest_AssertCheck(
   4.456 +         secs >= 0,
   4.457 +         "SDL_GetPowerInfo(): on battery, secs >= 0, was: %i",
   4.458 +         secs);
   4.459 +      SDLTest_AssertCheck(
   4.460 +         (pct >= 0) && (pct <= 100),
   4.461 +         "SDL_GetPowerInfo(): on battery, pct=[0,100], was: %i",
   4.462 +         pct);
   4.463 +   }
   4.464 +
   4.465 +   if (state==SDL_POWERSTATE_UNKNOWN ||
   4.466 +       state==SDL_POWERSTATE_NO_BATTERY)
   4.467 +   {
   4.468 +      SDLTest_AssertCheck(
   4.469 +         secs == -1,
   4.470 +         "SDL_GetPowerInfo(): no battery, secs == -1, was: %i",
   4.471 +         secs);
   4.472 +      SDLTest_AssertCheck(
   4.473 +         pct == -1,
   4.474 +         "SDL_GetPowerInfo(): no battery, pct == -1, was: %i",
   4.475 +         pct);
   4.476 +   }
   4.477 +
   4.478 +   // Partial return value variations
   4.479 +   stateAgain = SDL_GetPowerInfo(&secsAgain, NULL);
   4.480 +   SDLTest_AssertCheck(
   4.481 +        state==stateAgain,
   4.482 +        "State %i returned when only 'secs' requested",
   4.483 +        stateAgain);
   4.484 +   SDLTest_AssertCheck(
   4.485 +        secs==secsAgain,
   4.486 +        "Value %i matches when only 'secs' requested",
   4.487 +        secsAgain);
   4.488 +   stateAgain = SDL_GetPowerInfo(NULL, &pctAgain);
   4.489 +   SDLTest_AssertCheck(
   4.490 +        state==stateAgain,
   4.491 +        "State %i returned when only 'pct' requested",
   4.492 +        stateAgain);
   4.493 +   SDLTest_AssertCheck(
   4.494 +        pct==pctAgain,
   4.495 +        "Value %i matches when only 'pct' requested",
   4.496 +        pctAgain);
   4.497 +   stateAgain = SDL_GetPowerInfo(NULL, NULL);
   4.498 +   SDLTest_AssertCheck(
   4.499 +        state==stateAgain,
   4.500 +        "State %i returned when no value requested",
   4.501 +        stateAgain);
   4.502 +
   4.503 +   return TEST_COMPLETED;
   4.504 +}
   4.505 +
   4.506 +/* ================= Test References ================== */
   4.507 +
   4.508 +/* Platform test cases */
   4.509 +static const SDLTest_TestCaseReference platformTest1 =
   4.510 +		{ (SDLTest_TestCaseFp)platform_testTypes, "platform_testTypes", "Tests predefined types", TEST_ENABLED};
   4.511 +
   4.512 +static const SDLTest_TestCaseReference platformTest2 =
   4.513 +		{ (SDLTest_TestCaseFp)platform_testEndianessAndSwap, "platform_testEndianessAndSwap", "Tests endianess and swap functions", TEST_ENABLED};
   4.514 +
   4.515 +static const SDLTest_TestCaseReference platformTest3 =
   4.516 +		{ (SDLTest_TestCaseFp)platform_testGetFunctions, "platform_testGetFunctions", "Tests various SDL_GetXYZ functions", TEST_ENABLED};
   4.517 +
   4.518 +static const SDLTest_TestCaseReference platformTest4 =
   4.519 +		{ (SDLTest_TestCaseFp)platform_testHasFunctions, "platform_testHasFunctions", "Tests various SDL_HasXYZ functions", TEST_ENABLED};
   4.520 +
   4.521 +static const SDLTest_TestCaseReference platformTest5 =
   4.522 +		{ (SDLTest_TestCaseFp)platform_testGetVersion, "platform_testGetVersion", "Tests SDL_GetVersion function", TEST_ENABLED};
   4.523 +
   4.524 +static const SDLTest_TestCaseReference platformTest6 =
   4.525 +		{ (SDLTest_TestCaseFp)platform_testSDLVersion, "platform_testSDLVersion", "Tests SDL_VERSION macro", TEST_ENABLED};
   4.526 +
   4.527 +static const SDLTest_TestCaseReference platformTest7 =
   4.528 +		{ (SDLTest_TestCaseFp)platform_testDefaultInit, "platform_testDefaultInit", "Tests default SDL_Init", TEST_ENABLED};
   4.529 +
   4.530 +static const SDLTest_TestCaseReference platformTest8 =
   4.531 +		{ (SDLTest_TestCaseFp)platform_testGetSetClearError, "platform_testGetSetClearError", "Tests SDL_Get/Set/ClearError", TEST_ENABLED};
   4.532 +
   4.533 +static const SDLTest_TestCaseReference platformTest9 =
   4.534 +		{ (SDLTest_TestCaseFp)platform_testSetErrorEmptyInput, "platform_testSetErrorEmptyInput", "Tests SDL_SetError with empty input", TEST_ENABLED};
   4.535 +
   4.536 +static const SDLTest_TestCaseReference platformTest10 =
   4.537 +		{ (SDLTest_TestCaseFp)platform_testSetErrorInvalidInput, "platform_testSetErrorInvalidInput", "Tests SDL_SetError with invalid input", TEST_ENABLED};
   4.538 +
   4.539 +static const SDLTest_TestCaseReference platformTest11 =
   4.540 +		{ (SDLTest_TestCaseFp)platform_testGetPowerInfo, "platform_testGetPowerInfo", "Tests SDL_GetPowerInfo function", TEST_ENABLED };
   4.541 +
   4.542 +/* Sequence of Platform test cases */
   4.543 +static const SDLTest_TestCaseReference *platformTests[] =  {
   4.544 +	&platformTest1,
   4.545 +	&platformTest2,
   4.546 +	&platformTest3,
   4.547 +	&platformTest4,
   4.548 +	&platformTest5,
   4.549 +	&platformTest6,
   4.550 +	&platformTest7,
   4.551 +	&platformTest8,
   4.552 +	&platformTest9,
   4.553 +	&platformTest10,
   4.554 +	&platformTest11,
   4.555 +	NULL
   4.556 +};
   4.557 +
   4.558 +/* Platform test suite (global) */
   4.559 +SDLTest_TestSuiteReference platformTestSuite = {
   4.560 +	"Platform",
   4.561 +	NULL,
   4.562 +	platformTests,
   4.563 +	NULL
   4.564 +};
     5.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.2 +++ b/test/testautomation_rect.c	Sat Dec 22 17:24:42 2012 -0800
     5.3 @@ -0,0 +1,1677 @@
     5.4 +/**
     5.5 + * Original code: automated SDL rect test written by Edgar Simo "bobbens"
     5.6 + * New/updated tests: aschiffler at ferzkopp dot net
     5.7 + */
     5.8 +
     5.9 +#include <stdio.h>
    5.10 +
    5.11 +#include "SDL.h"
    5.12 +#include "SDL_test.h"
    5.13 +
    5.14 +/* ================= Test Case Implementation ================== */
    5.15 +
    5.16 +/* Helper functions */
    5.17 +
    5.18 +/*!
    5.19 + * \brief Private helper to check SDL_IntersectRectAndLine results
    5.20 + */
    5.21 +void _validateIntersectRectAndLineResults(
    5.22 +    SDL_bool intersection, SDL_bool expectedIntersection,
    5.23 +    SDL_Rect *rect, SDL_Rect * refRect,
    5.24 +    int x1, int y1, int x2, int y2,
    5.25 +    int x1Ref, int y1Ref, int x2Ref, int y2Ref)
    5.26 +{
    5.27 +    SDLTest_AssertCheck(intersection == expectedIntersection, 
    5.28 +        "Check for correct intersection result: expected %s, got %s intersecting rect (%d,%d,%d,%d) with line (%d,%d - %d,%d)",
    5.29 +        (expectedIntersection == SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE",
    5.30 +        (intersection == SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE",
    5.31 +        refRect->x, refRect->y, refRect->w, refRect->h,
    5.32 +        x1Ref, y1Ref, x2Ref, y2Ref);
    5.33 +    SDLTest_AssertCheck(rect->x == refRect->x && rect->y == refRect->y && rect->w == refRect->w && rect->h == refRect->h,
    5.34 +        "Check that source rectangle was not modified: got (%d,%d,%d,%d) expected (%d,%d,%d,%d)",
    5.35 +        rect->x, rect->y, rect->w, rect->h,
    5.36 +        refRect->x, refRect->y, refRect->w, refRect->h);
    5.37 +    SDLTest_AssertCheck(x1 == x1Ref && y1 == y1Ref && x2 == x2Ref && y2 == y2Ref,
    5.38 +        "Check if line was incorrectly clipped or modified: got (%d,%d - %d,%d) expected (%d,%d - %d,%d)",
    5.39 +        x1, y1, x2, y2,
    5.40 +        x1Ref, y1Ref, x2Ref, y2Ref);
    5.41 +}
    5.42 +
    5.43 +/* Test case functions */
    5.44 +
    5.45 +/*!
    5.46 + * \brief Tests SDL_IntersectRectAndLine() clipping cases
    5.47 + *
    5.48 + * \sa
    5.49 + * http://wiki.libsdl.org/moin.cgi/SDL_IntersectRectAndLine
    5.50 + */
    5.51 +int 
    5.52 +rect_testIntersectRectAndLine (void *arg)
    5.53 +{
    5.54 +    SDL_Rect refRect = { 0, 0, 32, 32 };
    5.55 +    SDL_Rect rect;
    5.56 +    int x1, y1;
    5.57 +    int x2, y2;
    5.58 +    SDL_bool intersected;
    5.59 +
    5.60 +    int xLeft = -SDLTest_RandomIntegerInRange(1, refRect.w);
    5.61 +    int xRight = refRect.w + SDLTest_RandomIntegerInRange(1, refRect.w);
    5.62 +    int yTop = -SDLTest_RandomIntegerInRange(1, refRect.h);
    5.63 +    int yBottom = refRect.h + SDLTest_RandomIntegerInRange(1, refRect.h);
    5.64 +
    5.65 +    x1 = xLeft;
    5.66 +    y1 = 15;
    5.67 +    x2 = xRight;
    5.68 +    y2 = 15;
    5.69 +    rect = refRect;
    5.70 +    intersected = SDL_IntersectRectAndLine(&rect, &x1, &y1, &x2, &y2);
    5.71 +    _validateIntersectRectAndLineResults(intersected, SDL_TRUE, &rect, &refRect, x1, y1, x2, y2, 0, 15, 31, 15);
    5.72 +
    5.73 +    x1 = 15;
    5.74 +    y1 = yTop;
    5.75 +    x2 = 15;
    5.76 +    y2 = yBottom;
    5.77 +    rect = refRect;
    5.78 +    intersected = SDL_IntersectRectAndLine(&rect, &x1, &y1, &x2, &y2);
    5.79 +    _validateIntersectRectAndLineResults(intersected, SDL_TRUE, &rect, &refRect, x1, y1, x2, y2, 15, 0, 15, 31);
    5.80 +
    5.81 +    x1 = -refRect.w;
    5.82 +    y1 = -refRect.h;
    5.83 +    x2 = 2*refRect.w;
    5.84 +    y2 = 2*refRect.h;
    5.85 +    rect = refRect;
    5.86 +    intersected = SDL_IntersectRectAndLine(&rect, &x1, &y1, &x2, &y2);
    5.87 +     _validateIntersectRectAndLineResults(intersected, SDL_TRUE, &rect, &refRect, x1, y1, x2, y2, 0, 0, 31, 31);
    5.88 +
    5.89 +    x1 = 2*refRect.w;
    5.90 +    y1 = 2*refRect.h;
    5.91 +    x2 = -refRect.w;
    5.92 +    y2 = -refRect.h;
    5.93 +    rect = refRect;
    5.94 +    intersected = SDL_IntersectRectAndLine(&rect, &x1, &y1, &x2, &y2);
    5.95 +    _validateIntersectRectAndLineResults(intersected, SDL_TRUE, &rect, &refRect, x1, y1, x2, y2, 31, 31, 0, 0);
    5.96 +
    5.97 +    x1 = -1;
    5.98 +    y1 = 32;
    5.99 +    x2 = 32;
   5.100 +    y2 = -1;
   5.101 +    rect = refRect;
   5.102 +    intersected = SDL_IntersectRectAndLine(&rect, &x1, &y1, &x2, &y2);
   5.103 +    _validateIntersectRectAndLineResults(intersected, SDL_TRUE, &rect, &refRect, x1, y1, x2, y2, 0, 31, 31, 0);
   5.104 +
   5.105 +    x1 = 32;
   5.106 +    y1 = -1;
   5.107 +    x2 = -1;
   5.108 +    y2 = 32;
   5.109 +    rect = refRect;
   5.110 +    intersected = SDL_IntersectRectAndLine(&rect, &x1, &y1, &x2, &y2);
   5.111 +    _validateIntersectRectAndLineResults(intersected, SDL_TRUE, &rect, &refRect, x1, y1, x2, y2, 31, 0, 0, 31);
   5.112 +
   5.113 +	return TEST_COMPLETED;
   5.114 +}
   5.115 +
   5.116 +/*!
   5.117 + * \brief Tests SDL_IntersectRectAndLine() non-clipping case line inside
   5.118 + *
   5.119 + * \sa
   5.120 + * http://wiki.libsdl.org/moin.cgi/SDL_IntersectRectAndLine
   5.121 + */
   5.122 +int 
   5.123 +rect_testIntersectRectAndLineInside (void *arg)
   5.124 +{
   5.125 +    SDL_Rect refRect = { 0, 0, 32, 32 };
   5.126 +    SDL_Rect rect;
   5.127 +    int x1, y1;
   5.128 +    int x2, y2;
   5.129 +    SDL_bool intersected;
   5.130 +
   5.131 +    int xmin = refRect.x;
   5.132 +    int xmax = refRect.x + refRect.w - 1;
   5.133 +    int ymin = refRect.y;
   5.134 +    int ymax = refRect.y + refRect.h - 1;
   5.135 +    int x1Ref = SDLTest_RandomIntegerInRange(xmin + 1, xmax - 1);
   5.136 +    int y1Ref = SDLTest_RandomIntegerInRange(ymin + 1, ymax - 1);
   5.137 +    int x2Ref = SDLTest_RandomIntegerInRange(xmin + 1, xmax - 1);
   5.138 +    int y2Ref = SDLTest_RandomIntegerInRange(ymin + 1, ymax - 1);
   5.139 +
   5.140 +    x1 = x1Ref;
   5.141 +    y1 = y1Ref;
   5.142 +    x2 = x2Ref;
   5.143 +    y2 = y2Ref;
   5.144 +    rect = refRect;
   5.145 +    intersected = SDL_IntersectRectAndLine(&rect, &x1, &y1, &x2, &y2);
   5.146 +    _validateIntersectRectAndLineResults(intersected, SDL_TRUE, &rect, &refRect, x1, y1, x2, y2, x1Ref, y1Ref, x2Ref, y2Ref);
   5.147 +
   5.148 +    x1 = x1Ref;
   5.149 +    y1 = y1Ref;
   5.150 +    x2 = xmax;
   5.151 +    y2 = ymax;
   5.152 +    rect = refRect;
   5.153 +    intersected = SDL_IntersectRectAndLine(&rect, &x1, &y1, &x2, &y2);
   5.154 +    _validateIntersectRectAndLineResults(intersected, SDL_TRUE, &rect, &refRect, x1, y1, x2, y2, x1Ref, y1Ref, xmax, ymax);
   5.155 +
   5.156 +    x1 = xmin;
   5.157 +    y1 = ymin;
   5.158 +    x2 = x2Ref;
   5.159 +    y2 = y2Ref;
   5.160 +    rect = refRect;
   5.161 +    intersected = SDL_IntersectRectAndLine(&rect, &x1, &y1, &x2, &y2);
   5.162 +    _validateIntersectRectAndLineResults(intersected, SDL_TRUE, &rect, &refRect, x1, y1, x2, y2, xmin, ymin, x2Ref, y2Ref);
   5.163 +
   5.164 +    x1 = xmin;
   5.165 +    y1 = ymin;
   5.166 +    x2 = xmax;
   5.167 +    y2 = ymax;
   5.168 +    rect = refRect;
   5.169 +    intersected = SDL_IntersectRectAndLine(&rect, &x1, &y1, &x2, &y2);
   5.170 +    _validateIntersectRectAndLineResults(intersected, SDL_TRUE, &rect, &refRect, x1, y1, x2, y2, xmin, ymin, xmax, ymax);
   5.171 +
   5.172 +    x1 = xmin;
   5.173 +    y1 = ymax;
   5.174 +    x2 = xmax;
   5.175 +    y2 = ymin;
   5.176 +    rect = refRect;
   5.177 +    intersected = SDL_IntersectRectAndLine(&rect, &x1, &y1, &x2, &y2);
   5.178 +    _validateIntersectRectAndLineResults(intersected, SDL_TRUE, &rect, &refRect, x1, y1, x2, y2, xmin, ymax, xmax, ymin);
   5.179 +
   5.180 +	return TEST_COMPLETED;
   5.181 +}
   5.182 +
   5.183 +/*!
   5.184 + * \brief Tests SDL_IntersectRectAndLine() non-clipping cases outside
   5.185 + *
   5.186 + * \sa
   5.187 + * http://wiki.libsdl.org/moin.cgi/SDL_IntersectRectAndLine
   5.188 + */
   5.189 +int 
   5.190 +rect_testIntersectRectAndLineOutside (void *arg)
   5.191 +{
   5.192 +    SDL_Rect refRect = { 0, 0, 32, 32 };
   5.193 +    SDL_Rect rect;
   5.194 +    int x1, y1;
   5.195 +    int x2, y2;
   5.196 +    SDL_bool intersected;
   5.197 +
   5.198 +    int xLeft = -SDLTest_RandomIntegerInRange(1, refRect.w);
   5.199 +    int xRight = refRect.w + SDLTest_RandomIntegerInRange(1, refRect.w);
   5.200 +    int yTop = -SDLTest_RandomIntegerInRange(1, refRect.h);
   5.201 +    int yBottom = refRect.h + SDLTest_RandomIntegerInRange(1, refRect.h);
   5.202 +
   5.203 +    x1 = xLeft;
   5.204 +    y1 = 0;
   5.205 +    x2 = xLeft;
   5.206 +    y2 = 31;
   5.207 +    rect = refRect;
   5.208 +    intersected = SDL_IntersectRectAndLine(&rect, &x1, &y1, &x2, &y2);
   5.209 +    _validateIntersectRectAndLineResults(intersected, SDL_FALSE, &rect, &refRect, x1, y1, x2, y2, xLeft, 0, xLeft, 31);
   5.210 +
   5.211 +    x1 = xRight;
   5.212 +    y1 = 0;
   5.213 +    x2 = xRight;
   5.214 +    y2 = 31;
   5.215 +    rect = refRect;
   5.216 +    intersected = SDL_IntersectRectAndLine(&rect, &x1, &y1, &x2, &y2);
   5.217 +    _validateIntersectRectAndLineResults(intersected, SDL_FALSE, &rect, &refRect, x1, y1, x2, y2, xRight, 0, xRight, 31);
   5.218 +
   5.219 +    x1 = 0;
   5.220 +    y1 = yTop;
   5.221 +    x2 = 31;
   5.222 +    y2 = yTop;
   5.223 +    rect = refRect;
   5.224 +    intersected = SDL_IntersectRectAndLine(&rect, &x1, &y1, &x2, &y2);
   5.225 +    _validateIntersectRectAndLineResults(intersected, SDL_FALSE, &rect, &refRect, x1, y1, x2, y2, 0, yTop, 31, yTop);
   5.226 +
   5.227 +    x1 = 0;
   5.228 +    y1 = yBottom;
   5.229 +    x2 = 31;
   5.230 +    y2 = yBottom;
   5.231 +    rect = refRect;
   5.232 +    intersected = SDL_IntersectRectAndLine(&rect, &x1, &y1, &x2, &y2);
   5.233 +    _validateIntersectRectAndLineResults(intersected, SDL_FALSE, &rect, &refRect, x1, y1, x2, y2, 0, yBottom, 31, yBottom);
   5.234 +
   5.235 +	return TEST_COMPLETED;
   5.236 +}
   5.237 +
   5.238 +/*!
   5.239 + * \brief Tests SDL_IntersectRectAndLine() with empty rectangle
   5.240 + *
   5.241 + * \sa
   5.242 + * http://wiki.libsdl.org/moin.cgi/SDL_IntersectRectAndLine
   5.243 + */
   5.244 +int 
   5.245 +rect_testIntersectRectAndLineEmpty (void *arg)
   5.246 +{
   5.247 +    SDL_Rect refRect;
   5.248 +    SDL_Rect rect;
   5.249 +    int x1, y1, x1Ref, y1Ref;
   5.250 +    int x2, y2, x2Ref, y2Ref;
   5.251 +    SDL_bool intersected;
   5.252 +        
   5.253 +    refRect.x = SDLTest_RandomIntegerInRange(1, 1024);
   5.254 +    refRect.y = SDLTest_RandomIntegerInRange(1, 1024);
   5.255 +    refRect.w = 0;
   5.256 +    refRect.h = 0;
   5.257 +    x1Ref = refRect.x;
   5.258 +    y1Ref = refRect.y;
   5.259 +    x2Ref = SDLTest_RandomIntegerInRange(1, 1024);
   5.260 +    y2Ref = SDLTest_RandomIntegerInRange(1, 1024);
   5.261 +
   5.262 +    x1 = x1Ref;
   5.263 +    y1 = y1Ref;
   5.264 +    x2 = x2Ref;
   5.265 +    y2 = y2Ref;
   5.266 +    rect = refRect;
   5.267 +    intersected = SDL_IntersectRectAndLine(&rect, &x1, &y1, &x2, &y2);
   5.268 +    _validateIntersectRectAndLineResults(intersected, SDL_FALSE, &rect, &refRect, x1, y1, x2, y2, x1Ref, y1Ref, x2Ref, y2Ref);
   5.269 +
   5.270 +	return TEST_COMPLETED;
   5.271 +}
   5.272 +
   5.273 +/*!
   5.274 + * \brief Negative tests against SDL_IntersectRectAndLine() with invalid parameters
   5.275 + *
   5.276 + * \sa
   5.277 + * http://wiki.libsdl.org/moin.cgi/SDL_IntersectRectAndLine
   5.278 + */
   5.279 +int 
   5.280 +rect_testIntersectRectAndLineParam (void *arg)
   5.281 +{
   5.282 +    SDL_Rect rect = { 0, 0, 32, 32 };
   5.283 +    int x1 = rect.w / 2;
   5.284 +    int y1 = rect.h / 2;
   5.285 +    int x2 = x1;
   5.286 +    int y2 = 2 * rect.h;
   5.287 +    SDL_bool intersected;
   5.288 +    
   5.289 +    intersected = SDL_IntersectRectAndLine(&rect, &x1, &y1, &x2, &y2);
   5.290 +    SDLTest_AssertCheck(intersected == SDL_TRUE, "Check that intersection result was SDL_TRUE");
   5.291 +    
   5.292 +    intersected = SDL_IntersectRectAndLine((SDL_Rect *)NULL, &x1, &y1, &x2, &y2);
   5.293 +    SDLTest_AssertCheck(intersected == SDL_FALSE, "Check that function returns SDL_FALSE when 1st parameter is NULL");
   5.294 +    intersected = SDL_IntersectRectAndLine(&rect, (int *)NULL, &y1, &x2, &y2);
   5.295 +    SDLTest_AssertCheck(intersected == SDL_FALSE, "Check that function returns SDL_FALSE when 2nd parameter is NULL");
   5.296 +    intersected = SDL_IntersectRectAndLine(&rect, &x1, (int *)NULL, &x2, &y2);
   5.297 +    SDLTest_AssertCheck(intersected == SDL_FALSE, "Check that function returns SDL_FALSE when 3rd parameter is NULL");
   5.298 +    intersected = SDL_IntersectRectAndLine(&rect, &x1, &y1, (int *)NULL, &y2);
   5.299 +    SDLTest_AssertCheck(intersected == SDL_FALSE, "Check that function returns SDL_FALSE when 4th parameter is NULL");
   5.300 +    intersected = SDL_IntersectRectAndLine(&rect, &x1, &y1, &x2, (int *)NULL);
   5.301 +    SDLTest_AssertCheck(intersected == SDL_FALSE, "Check that function returns SDL_FALSE when 5th parameter is NULL");
   5.302 +    intersected = SDL_IntersectRectAndLine((SDL_Rect *)NULL, (int *)NULL, (int *)NULL, (int *)NULL, (int *)NULL);
   5.303 +    SDLTest_AssertCheck(intersected == SDL_FALSE, "Check that function returns SDL_FALSE when all parameters are NULL");
   5.304 +
   5.305 +	return TEST_COMPLETED;
   5.306 +}
   5.307 +
   5.308 +/*!
   5.309 + * \brief Private helper to check SDL_HasIntersection results
   5.310 + */
   5.311 +void _validateHasIntersectionResults(
   5.312 +    SDL_bool intersection, SDL_bool expectedIntersection, 
   5.313 +    SDL_Rect *rectA, SDL_Rect *rectB, SDL_Rect *refRectA, SDL_Rect *refRectB)
   5.314 +{
   5.315 +    SDLTest_AssertCheck(intersection == expectedIntersection, 
   5.316 +        "Check intersection result: expected %s, got %s intersecting A (%d,%d,%d,%d) with B (%d,%d,%d,%d)",
   5.317 +        (expectedIntersection == SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE",
   5.318 +        (intersection == SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE",
   5.319 +        rectA->x, rectA->y, rectA->w, rectA->h, 
   5.320 +        rectB->x, rectB->y, rectB->w, rectB->h);
   5.321 +    SDLTest_AssertCheck(rectA->x == refRectA->x && rectA->y == refRectA->y && rectA->w == refRectA->w && rectA->h == refRectA->h,
   5.322 +        "Check that source rectangle A was not modified: got (%d,%d,%d,%d) expected (%d,%d,%d,%d)",
   5.323 +        rectA->x, rectA->y, rectA->w, rectA->h,
   5.324 +        refRectA->x, refRectA->y, refRectA->w, refRectA->h);
   5.325 +    SDLTest_AssertCheck(rectB->x == refRectB->x && rectB->y == refRectB->y && rectB->w == refRectB->w && rectB->h == refRectB->h,
   5.326 +        "Check that source rectangle B was not modified: got (%d,%d,%d,%d) expected (%d,%d,%d,%d)",
   5.327 +        rectB->x, rectB->y, rectB->w, rectB->h,
   5.328 +        refRectB->x, refRectB->y, refRectB->w, refRectB->h);
   5.329 +}
   5.330 +
   5.331 +/*!
   5.332 + * \brief Private helper to check SDL_IntersectRect results
   5.333 + */
   5.334 +void _validateIntersectRectResults(
   5.335 +    SDL_bool intersection, SDL_bool expectedIntersection, 
   5.336 +    SDL_Rect *rectA, SDL_Rect *rectB, SDL_Rect *refRectA, SDL_Rect *refRectB, 
   5.337 +    SDL_Rect *result, SDL_Rect *expectedResult)
   5.338 +{
   5.339 +    _validateHasIntersectionResults(intersection, expectedIntersection, rectA, rectB, refRectA, refRectB);
   5.340 +    if (result && expectedResult) {
   5.341 +        SDLTest_AssertCheck(result->x == expectedResult->x && result->y == expectedResult->y && result->w == expectedResult->w && result->h == expectedResult->h,
   5.342 +            "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)",
   5.343 +            rectA->x, rectA->y, rectA->w, rectA->h, 
   5.344 +            rectB->x, rectB->y, rectB->w, rectB->h,
   5.345 +            result->x, result->y, result->w, result->h,
   5.346 +            expectedResult->x, expectedResult->y, expectedResult->w, expectedResult->h);
   5.347 +    }
   5.348 +}
   5.349 +
   5.350 +/*!
   5.351 + * \brief Private helper to check SDL_UnionRect results
   5.352 + */
   5.353 +void _validateUnionRectResults(
   5.354 +    SDL_Rect *rectA, SDL_Rect *rectB, SDL_Rect *refRectA, SDL_Rect *refRectB, 
   5.355 +    SDL_Rect *result, SDL_Rect *expectedResult)
   5.356 +{
   5.357 +    SDLTest_AssertCheck(rectA->x == refRectA->x && rectA->y == refRectA->y && rectA->w == refRectA->w && rectA->h == refRectA->h,
   5.358 +        "Check that source rectangle A was not modified: got (%d,%d,%d,%d) expected (%d,%d,%d,%d)",
   5.359 +        rectA->x, rectA->y, rectA->w, rectA->h,
   5.360 +        refRectA->x, refRectA->y, refRectA->w, refRectA->h);
   5.361 +    SDLTest_AssertCheck(rectB->x == refRectB->x && rectB->y == refRectB->y && rectB->w == refRectB->w && rectB->h == refRectB->h,
   5.362 +        "Check that source rectangle B was not modified: got (%d,%d,%d,%d) expected (%d,%d,%d,%d)",
   5.363 +        rectB->x, rectB->y, rectB->w, rectB->h,
   5.364 +        refRectB->x, refRectB->y, refRectB->w, refRectB->h);
   5.365 +    SDLTest_AssertCheck(result->x == expectedResult->x && result->y == expectedResult->y && result->w == expectedResult->w && result->h == expectedResult->h,
   5.366 +        "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)",
   5.367 +        rectA->x, rectA->y, rectA->w, rectA->h, 
   5.368 +        rectB->x, rectB->y, rectB->w, rectB->h,
   5.369 +        result->x, result->y, result->w, result->h,
   5.370 +        expectedResult->x, expectedResult->y, expectedResult->w, expectedResult->h);
   5.371 +}
   5.372 +
   5.373 +/*!
   5.374 + * \brief Private helper to check SDL_RectEmpty results
   5.375 + */
   5.376 +void _validateRectEmptyResults(
   5.377 +    SDL_bool empty, SDL_bool expectedEmpty, 
   5.378 +    SDL_Rect *rect, SDL_Rect *refRect)
   5.379 +{
   5.380 +    SDLTest_AssertCheck(empty == expectedEmpty, 
   5.381 +        "Check for correct empty result: expected %s, got %s testing (%d,%d,%d,%d)",
   5.382 +        (expectedEmpty == SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE",
   5.383 +        (empty == SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE",
   5.384 +        rect->x, rect->y, rect->w, rect->h);
   5.385 +    SDLTest_AssertCheck(rect->x == refRect->x && rect->y == refRect->y && rect->w == refRect->w && rect->h == refRect->h,
   5.386 +        "Check that source rectangle was not modified: got (%d,%d,%d,%d) expected (%d,%d,%d,%d)",
   5.387 +        rect->x, rect->y, rect->w, rect->h,
   5.388 +        refRect->x, refRect->y, refRect->w, refRect->h);
   5.389 +}
   5.390 +
   5.391 +/*!
   5.392 + * \brief Private helper to check SDL_RectEquals results
   5.393 + */
   5.394 +void _validateRectEqualsResults(
   5.395 +    SDL_bool equals, SDL_bool expectedEquals, 
   5.396 +    SDL_Rect *rectA, SDL_Rect *rectB, SDL_Rect *refRectA, SDL_Rect *refRectB)
   5.397 +{
   5.398 +    SDLTest_AssertCheck(equals == expectedEquals, 
   5.399 +        "Check for correct equals result: expected %s, got %s testing (%d,%d,%d,%d) and (%d,%d,%d,%d)",
   5.400 +        (expectedEquals == SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE",
   5.401 +        (equals == SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE",
   5.402 +        rectA->x, rectA->y, rectA->w, rectA->h,
   5.403 +        rectB->x, rectB->y, rectB->w, rectB->h);
   5.404 +    SDLTest_AssertCheck(rectA->x == refRectA->x && rectA->y == refRectA->y && rectA->w == refRectA->w && rectA->h == refRectA->h,
   5.405 +        "Check that source rectangle A was not modified: got (%d,%d,%d,%d) expected (%d,%d,%d,%d)",
   5.406 +        rectA->x, rectA->y, rectA->w, rectA->h,
   5.407 +        refRectA->x, refRectA->y, refRectA->w, refRectA->h);
   5.408 +    SDLTest_AssertCheck(rectB->x == refRectB->x && rectB->y == refRectB->y && rectB->w == refRectB->w && rectB->h == refRectB->h,
   5.409 +        "Check that source rectangle B was not modified: got (%d,%d,%d,%d) expected (%d,%d,%d,%d)",
   5.410 +        rectB->x, rectB->y, rectB->w, rectB->h,
   5.411 +        refRectB->x, refRectB->y, refRectB->w, refRectB->h);
   5.412 +}
   5.413 +
   5.414 +/*!
   5.415 + * \brief Tests SDL_IntersectRect() with B fully inside A
   5.416 + *
   5.417 + * \sa
   5.418 + * http://wiki.libsdl.org/moin.cgi/SDL_IntersectRect
   5.419 + */
   5.420 +int rect_testIntersectRectInside (void *arg)
   5.421 +{
   5.422 +    SDL_Rect refRectA = { 0, 0, 32, 32 };
   5.423 +    SDL_Rect refRectB;
   5.424 +    SDL_Rect rectA;
   5.425 +    SDL_Rect rectB;
   5.426 +    SDL_Rect result;
   5.427 +    SDL_bool intersection;
   5.428 +
   5.429 +    // rectB fully contained in rectA
   5.430 +    refRectB.x = 0;
   5.431 +    refRectB.y = 0;
   5.432 +    refRectB.w = SDLTest_RandomIntegerInRange(refRectA.x + 1, refRectA.x + refRectA.w - 1);
   5.433 +    refRectB.h = SDLTest_RandomIntegerInRange(refRectA.y + 1, refRectA.y + refRectA.h - 1);
   5.434 +    rectA = refRectA;
   5.435 +    rectB = refRectB;
   5.436 +    intersection = SDL_IntersectRect(&rectA, &rectB, &result);
   5.437 +    _validateIntersectRectResults(intersection, SDL_TRUE, &rectA, &rectB, &refRectA, &refRectB, &result, &refRectB);
   5.438 +
   5.439 +	return TEST_COMPLETED;
   5.440 +}
   5.441 +
   5.442 +/*!
   5.443 + * \brief Tests SDL_IntersectRect() with B fully outside A
   5.444 + *
   5.445 + * \sa
   5.446 + * http://wiki.libsdl.org/moin.cgi/SDL_IntersectRect
   5.447 + */
   5.448 +int rect_testIntersectRectOutside (void *arg)
   5.449 +{
   5.450 +    SDL_Rect refRectA = { 0, 0, 32, 32 };
   5.451 +    SDL_Rect refRectB;
   5.452 +    SDL_Rect rectA;
   5.453 +    SDL_Rect rectB;
   5.454 +    SDL_Rect result;
   5.455 +    SDL_bool intersection;
   5.456 +
   5.457 +    // rectB fully outside of rectA
   5.458 +    refRectB.x = refRectA.x + refRectA.w + SDLTest_RandomIntegerInRange(1, 10);
   5.459 +    refRectB.y = refRectA.y + refRectA.h + SDLTest_RandomIntegerInRange(1, 10);
   5.460 +    refRectB.w = refRectA.w;
   5.461 +    refRectB.h = refRectA.h;
   5.462 +    rectA = refRectA;
   5.463 +    rectB = refRectB;
   5.464 +    intersection = SDL_IntersectRect(&rectA, &rectB, &result);
   5.465 +    _validateIntersectRectResults(intersection, SDL_FALSE, &rectA, &rectB, &refRectA, &refRectB, (SDL_Rect *)NULL, (SDL_Rect *)NULL);    
   5.466 +
   5.467 +	return TEST_COMPLETED;
   5.468 +}
   5.469 +
   5.470 +/*!
   5.471 + * \brief Tests SDL_IntersectRect() with B partially intersecting A
   5.472 + *
   5.473 + * \sa
   5.474 + * http://wiki.libsdl.org/moin.cgi/SDL_IntersectRect
   5.475 + */
   5.476 +int rect_testIntersectRectPartial (void *arg)
   5.477 +{
   5.478 +    SDL_Rect refRectA = { 0, 0, 32, 32 };
   5.479 +    SDL_Rect refRectB;
   5.480 +    SDL_Rect rectA;
   5.481 +    SDL_Rect rectB;
   5.482 +    SDL_Rect result;
   5.483 +    SDL_Rect expectedResult;
   5.484 +    SDL_bool intersection;
   5.485 +
   5.486 +    // rectB partially contained in rectA
   5.487 +    refRectB.x = SDLTest_RandomIntegerInRange(refRectA.x + 1, refRectA.x + refRectA.w - 1);
   5.488 +    refRectB.y = SDLTest_RandomIntegerInRange(refRectA.y + 1, refRectA.y + refRectA.h - 1);
   5.489 +    refRectB.w = refRectA.w;
   5.490 +    refRectB.h = refRectA.h;
   5.491 +    rectA = refRectA;
   5.492 +    rectB = refRectB;
   5.493 +    expectedResult.x = refRectB.x;
   5.494 +    expectedResult.y = refRectB.y;
   5.495 +    expectedResult.w = refRectA.w - refRectB.x;
   5.496 +    expectedResult.h = refRectA.h - refRectB.y;    
   5.497 +    intersection = SDL_IntersectRect(&rectA, &rectB, &result);
   5.498 +    _validateIntersectRectResults(intersection, SDL_TRUE, &rectA, &rectB, &refRectA, &refRectB, &result, &expectedResult);
   5.499 +
   5.500 +    // rectB right edge
   5.501 +    refRectB.x = rectA.w - 1;
   5.502 +    refRectB.y = rectA.y;
   5.503 +    refRectB.w = SDLTest_RandomIntegerInRange(1, refRectA.w - 1);
   5.504 +    refRectB.h = SDLTest_RandomIntegerInRange(1, refRectA.h - 1);
   5.505 +    rectA = refRectA;
   5.506 +    rectB = refRectB;
   5.507 +    expectedResult.x = refRectB.x;
   5.508 +    expectedResult.y = refRectB.y;
   5.509 +    expectedResult.w = 1;
   5.510 +    expectedResult.h = refRectB.h;    
   5.511 +    intersection = SDL_IntersectRect(&rectA, &rectB, &result);
   5.512 +    _validateIntersectRectResults(intersection, SDL_TRUE, &rectA, &rectB, &refRectA, &refRectB, &result, &expectedResult);
   5.513 +
   5.514 +    // rectB left edge
   5.515 +    refRectB.x = 1 - rectA.w;
   5.516 +    refRectB.y = rectA.y;
   5.517 +    refRectB.w = refRectA.w;
   5.518 +    refRectB.h = SDLTest_RandomIntegerInRange(1, refRectA.h - 1);
   5.519 +    rectA = refRectA;
   5.520 +    rectB = refRectB;
   5.521 +    expectedResult.x = 0;
   5.522 +    expectedResult.y = refRectB.y;
   5.523 +    expectedResult.w = 1;
   5.524 +    expectedResult.h = refRectB.h;    
   5.525 +    intersection = SDL_IntersectRect(&rectA, &rectB, &result);
   5.526 +    _validateIntersectRectResults(intersection, SDL_TRUE, &rectA, &rectB, &refRectA, &refRectB, &result, &expectedResult);
   5.527 +
   5.528 +    // rectB bottom edge
   5.529 +    refRectB.x = rectA.x;
   5.530 +    refRectB.y = rectA.h - 1;
   5.531 +    refRectB.w = SDLTest_RandomIntegerInRange(1, refRectA.w - 1);
   5.532 +    refRectB.h = SDLTest_RandomIntegerInRange(1, refRectA.h - 1);
   5.533 +    rectA = refRectA;
   5.534 +    rectB = refRectB;
   5.535 +    expectedResult.x = refRectB.x;
   5.536 +    expectedResult.y = refRectB.y;
   5.537 +    expectedResult.w = refRectB.w;
   5.538 +    expectedResult.h = 1;    
   5.539 +    intersection = SDL_IntersectRect(&rectA, &rectB, &result);
   5.540 +    _validateIntersectRectResults(intersection, SDL_TRUE, &rectA, &rectB, &refRectA, &refRectB, &result, &expectedResult);
   5.541 +
   5.542 +    // rectB top edge
   5.543 +    refRectB.x = rectA.x;
   5.544 +    refRectB.y = 1 - rectA.h;
   5.545 +    refRectB.w = SDLTest_RandomIntegerInRange(1, refRectA.w - 1);
   5.546 +    refRectB.h = rectA.h;
   5.547 +    rectA = refRectA;
   5.548 +    rectB = refRectB;
   5.549 +    expectedResult.x = refRectB.x;
   5.550 +    expectedResult.y = 0;
   5.551 +    expectedResult.w = refRectB.w;
   5.552 +    expectedResult.h = 1;    
   5.553 +    intersection = SDL_IntersectRect(&rectA, &rectB, &result);
   5.554 +    _validateIntersectRectResults(intersection, SDL_TRUE, &rectA, &rectB, &refRectA, &refRectB, &result, &expectedResult);
   5.555 +
   5.556 +	return TEST_COMPLETED;
   5.557 +}
   5.558 +
   5.559 +/*!
   5.560 + * \brief Tests SDL_IntersectRect() with 1x1 pixel sized rectangles
   5.561 + *
   5.562 + * \sa
   5.563 + * http://wiki.libsdl.org/moin.cgi/SDL_IntersectRect
   5.564 + */
   5.565 +int rect_testIntersectRectPoint (void *arg)
   5.566 +{
   5.567 +    SDL_Rect refRectA = { 0, 0, 1, 1 };
   5.568 +    SDL_Rect refRectB = { 0, 0, 1, 1 };
   5.569 +    SDL_Rect rectA;
   5.570 +    SDL_Rect rectB;
   5.571 +    SDL_Rect result;
   5.572 +    SDL_bool intersection;
   5.573 +    int offsetX, offsetY;
   5.574 +
   5.575 +    // intersecting pixels
   5.576 +    refRectA.x = SDLTest_RandomIntegerInRange(1, 100);
   5.577 +    refRectA.y = SDLTest_RandomIntegerInRange(1, 100);
   5.578 +    refRectB.x = refRectA.x;
   5.579 +    refRectB.y = refRectA.y;
   5.580 +    rectA = refRectA;
   5.581 +    rectB = refRectB;
   5.582 +    intersection = SDL_IntersectRect(&rectA, &rectB, &result);
   5.583 +    _validateIntersectRectResults(intersection, SDL_TRUE, &rectA, &rectB, &refRectA, &refRectB, &result, &refRectA);
   5.584 +
   5.585 +    // non-intersecting pixels cases
   5.586 +    for (offsetX = -1; offsetX <= 1; offsetX++) {
   5.587 +        for (offsetY = -1; offsetY <= 1; offsetY++) {
   5.588 +            if (offsetX != 0 || offsetY != 0) {
   5.589 +                refRectA.x = SDLTest_RandomIntegerInRange(1, 100);
   5.590 +                refRectA.y = SDLTest_RandomIntegerInRange(1, 100);
   5.591 +                refRectB.x = refRectA.x;
   5.592 +                refRectB.y = refRectA.y;    
   5.593 +                refRectB.x += offsetX;
   5.594 +                refRectB.y += offsetY;
   5.595 +                rectA = refRectA;
   5.596 +                rectB = refRectB;
   5.597 +                intersection = SDL_IntersectRect(&rectA, &rectB, &result);
   5.598 +                _validateIntersectRectResults(intersection, SDL_FALSE, &rectA, &rectB, &refRectA, &refRectB, (SDL_Rect *)NULL, (SDL_Rect *)NULL);
   5.599 +            }
   5.600 +        }
   5.601 +    }
   5.602 +
   5.603 +	return TEST_COMPLETED;
   5.604 +}
   5.605 +
   5.606 +/*!
   5.607 + * \brief Tests SDL_IntersectRect() with empty rectangles
   5.608 + *
   5.609 + * \sa
   5.610 + * http://wiki.libsdl.org/moin.cgi/SDL_IntersectRect
   5.611 + */
   5.612 +int rect_testIntersectRectEmpty (void *arg)
   5.613 +{
   5.614 +    SDL_Rect refRectA;
   5.615 +    SDL_Rect refRectB;
   5.616 +    SDL_Rect rectA;
   5.617 +    SDL_Rect rectB;
   5.618 +    SDL_Rect result;
   5.619 +    SDL_bool intersection;
   5.620 +
   5.621 +    // Rect A empty
   5.622 +    refRectA.x = SDLTest_RandomIntegerInRange(1, 100);
   5.623 +    refRectA.y = SDLTest_RandomIntegerInRange(1, 100);
   5.624 +    refRectA.w = SDLTest_RandomIntegerInRange(1, 100);
   5.625 +    refRectA.h = SDLTest_RandomIntegerInRange(1, 100);
   5.626 +    refRectB = refRectA;
   5.627 +    refRectA.w = 0;
   5.628 +    refRectA.h = 0;
   5.629 +    rectA = refRectA;
   5.630 +    rectB = refRectB;
   5.631 +    intersection = SDL_IntersectRect(&rectA, &rectB, &result);
   5.632 +    _validateIntersectRectResults(intersection, SDL_FALSE, &rectA, &rectB, &refRectA, &refRectB, (SDL_Rect *)NULL, (SDL_Rect *)NULL);
   5.633 +
   5.634 +    // Rect B empty
   5.635 +    refRectA.x = SDLTest_RandomIntegerInRange(1, 100);
   5.636 +    refRectA.y = SDLTest_RandomIntegerInRange(1, 100);
   5.637 +    refRectA.w = SDLTest_RandomIntegerInRange(1, 100);
   5.638 +    refRectA.h = SDLTest_RandomIntegerInRange(1, 100);
   5.639 +    refRectB = refRectA;
   5.640 +    refRectB.w = 0;
   5.641 +    refRectB.h = 0;
   5.642 +    rectA = refRectA;
   5.643 +    rectB = refRectB;
   5.644 +    intersection = SDL_IntersectRect(&rectA, &rectB, &result);
   5.645 +    _validateIntersectRectResults(intersection, SDL_FALSE, &rectA, &rectB, &refRectA, &refRectB, (SDL_Rect *)NULL, (SDL_Rect *)NULL);
   5.646 +
   5.647 +    // Rect A and B empty
   5.648 +    refRectA.x = SDLTest_RandomIntegerInRange(1, 100);
   5.649 +    refRectA.y = SDLTest_RandomIntegerInRange(1, 100);
   5.650 +    refRectA.w = SDLTest_RandomIntegerInRange(1, 100);
   5.651 +    refRectA.h = SDLTest_RandomIntegerInRange(1, 100);
   5.652 +    refRectB = refRectA;
   5.653 +    refRectA.w = 0;
   5.654 +    refRectA.h = 0;
   5.655 +    refRectB.w = 0;
   5.656 +    refRectB.h = 0;
   5.657 +    rectA = refRectA;
   5.658 +    rectB = refRectB;
   5.659 +    intersection = SDL_IntersectRect(&rectA, &rectB, &result);
   5.660 +    _validateIntersectRectResults(intersection, SDL_FALSE, &rectA, &rectB, &refRectA, &refRectB, (SDL_Rect *)NULL, (SDL_Rect *)NULL);
   5.661 +
   5.662 +	return TEST_COMPLETED;
   5.663 +}
   5.664 +
   5.665 +/*!
   5.666 + * \brief Negative tests against SDL_IntersectRect() with invalid parameters
   5.667 + *
   5.668 + * \sa
   5.669 + * http://wiki.libsdl.org/moin.cgi/SDL_IntersectRect
   5.670 + */
   5.671 +int rect_testIntersectRectParam(void *arg)
   5.672 +{
   5.673 +    SDL_Rect rectA;
   5.674 +    SDL_Rect rectB;
   5.675 +    SDL_Rect result;
   5.676 +    SDL_bool intersection;
   5.677 +
   5.678 +    // invalid parameter combinations
   5.679 +    intersection = SDL_IntersectRect((SDL_Rect *)NULL, &rectB, &result);
   5.680 +    SDLTest_AssertCheck(intersection == SDL_FALSE, "Check that function returns SDL_FALSE when 1st parameter is NULL"); 
   5.681 +    intersection = SDL_IntersectRect(&rectA, (SDL_Rect *)NULL, &result);
   5.682 +    SDLTest_AssertCheck(intersection == SDL_FALSE, "Check that function returns SDL_FALSE when 2st parameter is NULL"); 
   5.683 +    intersection = SDL_IntersectRect(&rectA, &rectB, (SDL_Rect *)NULL);
   5.684 +    SDLTest_AssertCheck(intersection == SDL_FALSE, "Check that function returns SDL_FALSE when 3st parameter is NULL"); 
   5.685 +    intersection = SDL_IntersectRect((SDL_Rect *)NULL, (SDL_Rect *)NULL, &result);
   5.686 +    SDLTest_AssertCheck(intersection == SDL_FALSE, "Check that function returns SDL_FALSE when 1st and 2nd parameters are NULL"); 
   5.687 +    intersection = SDL_IntersectRect((SDL_Rect *)NULL, &rectB, (SDL_Rect *)NULL);
   5.688 +    SDLTest_AssertCheck(intersection == SDL_FALSE, "Check that function returns SDL_FALSE when 1st and 3rd parameters are NULL "); 
   5.689 +    intersection = SDL_IntersectRect((SDL_Rect *)NULL, (SDL_Rect *)NULL, (SDL_Rect *)NULL);
   5.690 +    SDLTest_AssertCheck(intersection == SDL_FALSE, "Check that function returns SDL_FALSE when all parameters are NULL");     
   5.691 +
   5.692 +	return TEST_COMPLETED;
   5.693 +}
   5.694 +
   5.695 +/*!
   5.696 + * \brief Tests SDL_HasIntersection() with B fully inside A
   5.697 + *
   5.698 + * \sa
   5.699 + * http://wiki.libsdl.org/moin.cgi/SDL_HasIntersection
   5.700 + */
   5.701 +int rect_testHasIntersectionInside (void *arg)
   5.702 +{
   5.703 +    SDL_Rect refRectA = { 0, 0, 32, 32 };
   5.704 +    SDL_Rect refRectB;
   5.705 +    SDL_Rect rectA;
   5.706 +    SDL_Rect rectB;
   5.707 +    SDL_bool intersection;
   5.708 +
   5.709 +    // rectB fully contained in rectA
   5.710 +    refRectB.x = 0;
   5.711 +    refRectB.y = 0;
   5.712 +    refRectB.w = SDLTest_RandomIntegerInRange(refRectA.x + 1, refRectA.x + refRectA.w - 1);
   5.713 +    refRectB.h = SDLTest_RandomIntegerInRange(refRectA.y + 1, refRectA.y + refRectA.h - 1);
   5.714 +    rectA = refRectA;
   5.715 +    rectB = refRectB;
   5.716 +    intersection = SDL_HasIntersection(&rectA, &rectB);
   5.717 +    _validateHasIntersectionResults(intersection, SDL_TRUE, &rectA, &rectB, &refRectA, &refRectB);
   5.718 +
   5.719 +	return TEST_COMPLETED;
   5.720 +}
   5.721 +
   5.722 +/*!
   5.723 + * \brief Tests SDL_HasIntersection() with B fully outside A
   5.724 + *
   5.725 + * \sa
   5.726 + * http://wiki.libsdl.org/moin.cgi/SDL_HasIntersection
   5.727 + */
   5.728 +int rect_testHasIntersectionOutside (void *arg)
   5.729 +{
   5.730 +    SDL_Rect refRectA = { 0, 0, 32, 32 };
   5.731 +    SDL_Rect refRectB;
   5.732 +    SDL_Rect rectA;
   5.733 +    SDL_Rect rectB;
   5.734 +    SDL_bool intersection;
   5.735 +
   5.736 +    // rectB fully outside of rectA
   5.737 +    refRectB.x = refRectA.x + refRectA.w + SDLTest_RandomIntegerInRange(1, 10);
   5.738 +    refRectB.y = refRectA.y + refRectA.h + SDLTest_RandomIntegerInRange(1, 10);
   5.739 +    refRectB.w = refRectA.w;
   5.740 +    refRectB.h = refRectA.h;
   5.741 +    rectA = refRectA;
   5.742 +    rectB = refRectB;
   5.743 +    intersection = SDL_HasIntersection(&rectA, &rectB);
   5.744 +    _validateHasIntersectionResults(intersection, SDL_FALSE, &rectA, &rectB, &refRectA, &refRectB);
   5.745 +
   5.746 +	return TEST_COMPLETED;
   5.747 +}
   5.748 +
   5.749 +/*!
   5.750 + * \brief Tests SDL_HasIntersection() with B partially intersecting A
   5.751 + *
   5.752 + * \sa
   5.753 + * http://wiki.libsdl.org/moin.cgi/SDL_HasIntersection
   5.754 + */
   5.755 +int rect_testHasIntersectionPartial (void *arg)
   5.756 +{
   5.757 +    SDL_Rect refRectA = { 0, 0, 32, 32 };
   5.758 +    SDL_Rect refRectB;
   5.759 +    SDL_Rect rectA;
   5.760 +    SDL_Rect rectB;
   5.761 +    SDL_bool intersection;
   5.762 +
   5.763 +    // rectB partially contained in rectA
   5.764 +    refRectB.x = SDLTest_RandomIntegerInRange(refRectA.x + 1, refRectA.x + refRectA.w - 1);
   5.765 +    refRectB.y = SDLTest_RandomIntegerInRange(refRectA.y + 1, refRectA.y + refRectA.h - 1);
   5.766 +    refRectB.w = refRectA.w;
   5.767 +    refRectB.h = refRectA.h;
   5.768 +    rectA = refRectA;
   5.769 +    rectB = refRectB;
   5.770 +    intersection = SDL_HasIntersection(&rectA, &rectB);
   5.771 +    _validateHasIntersectionResults(intersection, SDL_TRUE, &rectA, &rectB, &refRectA, &refRectB);
   5.772 +
   5.773 +    // rectB right edge
   5.774 +    refRectB.x = rectA.w - 1;
   5.775 +    refRectB.y = rectA.y;
   5.776 +    refRectB.w = SDLTest_RandomIntegerInRange(1, refRectA.w - 1);
   5.777 +    refRectB.h = SDLTest_RandomIntegerInRange(1, refRectA.h - 1);
   5.778 +    rectA = refRectA;
   5.779 +    rectB = refRectB;
   5.780 +    intersection = SDL_HasIntersection(&rectA, &rectB);
   5.781 +    _validateHasIntersectionResults(intersection, SDL_TRUE, &rectA, &rectB, &refRectA, &refRectB);
   5.782 +
   5.783 +    // rectB left edge
   5.784 +    refRectB.x = 1 - rectA.w;
   5.785 +    refRectB.y = rectA.y;
   5.786 +    refRectB.w = refRectA.w;
   5.787 +    refRectB.h = SDLTest_RandomIntegerInRange(1, refRectA.h - 1);
   5.788 +    rectA = refRectA;
   5.789 +    rectB = refRectB;
   5.790 +    intersection = SDL_HasIntersection(&rectA, &rectB);
   5.791 +    _validateHasIntersectionResults(intersection, SDL_TRUE, &rectA, &rectB, &refRectA, &refRectB);
   5.792 +
   5.793 +    // rectB bottom edge
   5.794 +    refRectB.x = rectA.x;
   5.795 +    refRectB.y = rectA.h - 1;
   5.796 +    refRectB.w = SDLTest_RandomIntegerInRange(1, refRectA.w - 1);
   5.797 +    refRectB.h = SDLTest_RandomIntegerInRange(1, refRectA.h - 1);
   5.798 +    rectA = refRectA;
   5.799 +    rectB = refRectB;
   5.800 +    intersection = SDL_HasIntersection(&rectA, &rectB);
   5.801 +    _validateHasIntersectionResults(intersection, SDL_TRUE, &rectA, &rectB, &refRectA, &refRectB);
   5.802 +
   5.803 +    // rectB top edge
   5.804 +    refRectB.x = rectA.x;
   5.805 +    refRectB.y = 1 - rectA.h;
   5.806 +    refRectB.w = SDLTest_RandomIntegerInRange(1, refRectA.w - 1);
   5.807 +    refRectB.h = rectA.h;
   5.808 +    rectA = refRectA;
   5.809 +    rectB = refRectB;
   5.810 +    intersection = SDL_HasIntersection(&rectA, &rectB);
   5.811 +    _validateHasIntersectionResults(intersection, SDL_TRUE, &rectA, &rectB, &refRectA, &refRectB);
   5.812 +
   5.813 +	return TEST_COMPLETED;
   5.814 +}
   5.815 +
   5.816 +/*!
   5.817 + * \brief Tests SDL_HasIntersection() with 1x1 pixel sized rectangles
   5.818 + *
   5.819 + * \sa
   5.820 + * http://wiki.libsdl.org/moin.cgi/SDL_HasIntersection
   5.821 + */
   5.822 +int rect_testHasIntersectionPoint (void *arg)
   5.823 +{
   5.824 +    SDL_Rect refRectA = { 0, 0, 1, 1 };
   5.825 +    SDL_Rect refRectB = { 0, 0, 1, 1 };
   5.826 +    SDL_Rect rectA;
   5.827 +    SDL_Rect rectB;
   5.828 +    SDL_bool intersection;
   5.829 +    int offsetX, offsetY;
   5.830 +
   5.831 +    // intersecting pixels
   5.832 +    refRectA.x = SDLTest_RandomIntegerInRange(1, 100);
   5.833 +    refRectA.y = SDLTest_RandomIntegerInRange(1, 100);
   5.834 +    refRectB.x = refRectA.x;
   5.835 +    refRectB.y = refRectA.y;
   5.836 +    rectA = refRectA;
   5.837 +    rectB = refRectB;
   5.838 +    intersection = SDL_HasIntersection(&rectA, &rectB);
   5.839 +    _validateHasIntersectionResults(intersection, SDL_TRUE, &rectA, &rectB, &refRectA, &refRectB);
   5.840 +
   5.841 +    // non-intersecting pixels cases
   5.842 +    for (offsetX = -1; offsetX <= 1; offsetX++) {
   5.843 +        for (offsetY = -1; offsetY <= 1; offsetY++) {
   5.844 +            if (offsetX != 0 || offsetY != 0) {
   5.845 +                refRectA.x = SDLTest_RandomIntegerInRange(1, 100);
   5.846 +                refRectA.y = SDLTest_RandomIntegerInRange(1, 100);
   5.847 +                refRectB.x = refRectA.x;
   5.848 +                refRectB.y = refRectA.y;    
   5.849 +                refRectB.x += offsetX;
   5.850 +                refRectB.y += offsetY;
   5.851 +                rectA = refRectA;
   5.852 +                rectB = refRectB;
   5.853 +                intersection = SDL_HasIntersection(&rectA, &rectB);
   5.854 +                _validateHasIntersectionResults(intersection, SDL_FALSE, &rectA, &rectB, &refRectA, &refRectB);
   5.855 +            }
   5.856 +        }
   5.857 +    }
   5.858 +
   5.859 +	return TEST_COMPLETED;
   5.860 +}
   5.861 +
   5.862 +/*!
   5.863 + * \brief Tests SDL_HasIntersection() with empty rectangles
   5.864 + *
   5.865 + * \sa
   5.866 + * http://wiki.libsdl.org/moin.cgi/SDL_HasIntersection
   5.867 + */
   5.868 +int rect_testHasIntersectionEmpty (void *arg)
   5.869 +{
   5.870 +    SDL_Rect refRectA;
   5.871 +    SDL_Rect refRectB;
   5.872 +    SDL_Rect rectA;
   5.873 +    SDL_Rect rectB;
   5.874 +    SDL_bool intersection;
   5.875 +
   5.876 +    // Rect A empty
   5.877 +    refRectA.x = SDLTest_RandomIntegerInRange(1, 100);
   5.878 +    refRectA.y = SDLTest_RandomIntegerInRange(1, 100);
   5.879 +    refRectA.w = SDLTest_RandomIntegerInRange(1, 100);
   5.880 +    refRectA.h = SDLTest_RandomIntegerInRange(1, 100);
   5.881 +    refRectB = refRectA;
   5.882 +    refRectA.w = 0;
   5.883 +    refRectA.h = 0;
   5.884 +    rectA = refRectA;
   5.885 +    rectB = refRectB;
   5.886 +    intersection = SDL_HasIntersection(&rectA, &rectB);
   5.887 +    _validateHasIntersectionResults(intersection, SDL_FALSE, &rectA, &rectB, &refRectA, &refRectB);
   5.888 +
   5.889 +    // Rect B empty
   5.890 +    refRectA.x = SDLTest_RandomIntegerInRange(1, 100);
   5.891 +    refRectA.y = SDLTest_RandomIntegerInRange(1, 100);
   5.892 +    refRectA.w = SDLTest_RandomIntegerInRange(1, 100);
   5.893 +    refRectA.h = SDLTest_RandomIntegerInRange(1, 100);
   5.894 +    refRectB = refRectA;
   5.895 +    refRectB.w = 0;
   5.896 +    refRectB.h = 0;
   5.897 +    rectA = refRectA;
   5.898 +    rectB = refRectB;
   5.899 +    intersection = SDL_HasIntersection(&rectA, &rectB);
   5.900 +    _validateHasIntersectionResults(intersection, SDL_FALSE, &rectA, &rectB, &refRectA, &refRectB);
   5.901 +
   5.902 +    // Rect A and B empty
   5.903 +    refRectA.x = SDLTest_RandomIntegerInRange(1, 100);
   5.904 +    refRectA.y = SDLTest_RandomIntegerInRange(1, 100);
   5.905 +    refRectA.w = SDLTest_RandomIntegerInRange(1, 100);
   5.906 +    refRectA.h = SDLTest_RandomIntegerInRange(1, 100);
   5.907 +    refRectB = refRectA;
   5.908 +    refRectA.w = 0;
   5.909 +    refRectA.h = 0;
   5.910 +    refRectB.w = 0;
   5.911 +    refRectB.h = 0;
   5.912 +    rectA = refRectA;
   5.913 +    rectB = refRectB;
   5.914 +    intersection = SDL_HasIntersection(&rectA, &rectB);
   5.915 +    _validateHasIntersectionResults(intersection, SDL_FALSE, &rectA, &rectB, &refRectA, &refRectB);
   5.916 +
   5.917 +	return TEST_COMPLETED;
   5.918 +}
   5.919 +
   5.920 +/*!
   5.921 + * \brief Negative tests against SDL_HasIntersection() with invalid parameters
   5.922 + *
   5.923 + * \sa
   5.924 + * http://wiki.libsdl.org/moin.cgi/SDL_HasIntersection
   5.925 + */
   5.926 +int rect_testHasIntersectionParam(void *arg)
   5.927 +{
   5.928 +    SDL_Rect rectA;
   5.929 +    SDL_Rect rectB;
   5.930 +    SDL_bool intersection;
   5.931 +
   5.932 +    // invalid parameter combinations
   5.933 +    intersection = SDL_HasIntersection((SDL_Rect *)NULL, &rectB);
   5.934 +    SDLTest_AssertCheck(intersection == SDL_FALSE, "Check that function returns SDL_FALSE when 1st parameter is NULL"); 
   5.935 +    intersection = SDL_HasIntersection(&rectA, (SDL_Rect *)NULL);
   5.936 +    SDLTest_AssertCheck(intersection == SDL_FALSE, "Check that function returns SDL_FALSE when 2st parameter is NULL"); 
   5.937 +    intersection = SDL_HasIntersection((SDL_Rect *)NULL, (SDL_Rect *)NULL);
   5.938 +    SDLTest_AssertCheck(intersection == SDL_FALSE, "Check that function returns SDL_FALSE when all parameters are NULL");     
   5.939 +
   5.940 +	return TEST_COMPLETED;
   5.941 +}
   5.942 +
   5.943 +/*!
   5.944 + * \brief Test SDL_EnclosePoints() without clipping
   5.945 + *
   5.946 + * \sa
   5.947 + * http://wiki.libsdl.org/moin.cgi/SDL_EnclosePoints
   5.948 + */
   5.949 +int rect_testEnclosePoints(void *arg)
   5.950 +{
   5.951 +    const int numPoints = 16;
   5.952 +    SDL_Point refPoints[16];
   5.953 +    SDL_Point points[16];
   5.954 +    SDL_Rect result;
   5.955 +    SDL_bool anyEnclosed;
   5.956 +    SDL_bool anyEnclosedNoResult;
   5.957 +
   5.958 +    // Create input data, tracking result
   5.959 +    SDL_bool expectedEnclosed = SDL_TRUE;
   5.960 +    int newx, newy;
   5.961 +    int minx, maxx, miny, maxy;
   5.962 +    int i;
   5.963 +    for (i=0; i<numPoints; i++) {
   5.964 +        newx = SDLTest_RandomIntegerInRange(-1024, 1024);
   5.965 +        newy = SDLTest_RandomIntegerInRange(-1024, 1024);
   5.966 +        refPoints[i].x = newx;
   5.967 +        refPoints[i].y = newy;
   5.968 +        points[i].x = newx;
   5.969 +        points[i].y = newy;
   5.970 +        if (i==0) {
   5.971 +            minx=maxx=newx;
   5.972 +            miny=maxy=newy;
   5.973 +        } else {
   5.974 +            if (newx<minx) minx=newx;
   5.975 +            if (newx>maxx) maxx=newx;
   5.976 +            if (newy<miny) miny=newy;
   5.977 +            if (newy>maxy) maxy=newy;
   5.978 +        }
   5.979 +    }
   5.980 +    
   5.981 +    // Call function and validate - special case: no result requested
   5.982 +    anyEnclosedNoResult = SDL_EnclosePoints((const SDL_Point *)points, numPoints, (const SDL_Rect *)NULL, (SDL_Rect *)NULL);
   5.983 +    SDLTest_AssertCheck(expectedEnclosed==anyEnclosedNoResult, 
   5.984 +        "Check expected return value %s, got %s", 
   5.985 +        (expectedEnclosed==SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE", 
   5.986 +		(anyEnclosedNoResult==SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE");
   5.987 +    for (i=0; i<numPoints; i++) {
   5.988 +        SDLTest_AssertCheck(refPoints[i].x==points[i].x && refPoints[i].y==points[i].y,
   5.989 +            "Check that source point %i was not modified: expected (%i,%i) actual (%i,%i)", 
   5.990 +            i, refPoints[i].x, refPoints[i].y, points[i].x, points[i].y);
   5.991 +    }
   5.992 +
   5.993 +    // Call function and validate
   5.994 +    anyEnclosed = SDL_EnclosePoints((const SDL_Point *)points, numPoints, (const SDL_Rect *)NULL, &result);
   5.995 +    SDLTest_AssertCheck(expectedEnclosed==anyEnclosed, 
   5.996 +        "Check return value %s, got %s", 
   5.997 +        (expectedEnclosed==SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE", 
   5.998 +		(anyEnclosed==SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE");
   5.999 +    for (i=0; i<numPoints; i++) {
  5.1000 +        SDLTest_AssertCheck(refPoints[i].x==points[i].x && refPoints[i].y==points[i].y,
  5.1001 +            "Check that source point %i was not modified: expected (%i,%i) actual (%i,%i)", 
  5.1002 +            i, refPoints[i].x, refPoints[i].y, points[i].x, points[i].y);
  5.1003 +    }
  5.1004 +    SDLTest_AssertCheck(result.x==minx && result.y==miny && result.w==(maxx - minx + 1) && result.h==(maxy - miny + 1),
  5.1005 +        "Resulting enclosing rectangle incorrect: expected (%i,%i - %i,%i), actual (%i,%i - %i,%i)",
  5.1006 +        minx, miny, maxx, maxy, result.x, result.y, result.x + result.w - 1, result.y + result.h - 1);
  5.1007 +
  5.1008 +	return TEST_COMPLETED;
  5.1009 +}
  5.1010 +
  5.1011 +/*!
  5.1012 + * \brief Test SDL_EnclosePoints() with repeated input points
  5.1013 + *
  5.1014 + * \sa
  5.1015 + * http://wiki.libsdl.org/moin.cgi/SDL_EnclosePoints
  5.1016 + */
  5.1017 +int rect_testEnclosePointsRepeatedInput(void *arg)
  5.1018 +{
  5.1019 +    const int numPoints = 8;
  5.1020 +    const int halfPoints = 4;
  5.1021 +    SDL_Point refPoints[8];
  5.1022 +    SDL_Point points[8];
  5.1023 +    SDL_Rect result;
  5.1024 +    SDL_bool anyEnclosed;
  5.1025 +    SDL_bool anyEnclosedNoResult;
  5.1026 +
  5.1027 +    // Create input data, tracking result
  5.1028 +    SDL_bool expectedEnclosed = SDL_TRUE;
  5.1029 +    int newx, newy;
  5.1030 +    int minx, maxx, miny, maxy;
  5.1031 +    int i;
  5.1032 +    for (i=0; i<numPoints; i++) {
  5.1033 +        if (i < halfPoints) {
  5.1034 +            newx = SDLTest_RandomIntegerInRange(-1024, 1024);
  5.1035 +            newy = SDLTest_RandomIntegerInRange(-1024, 1024);
  5.1036 +        } else {
  5.1037 +            newx = refPoints[i-halfPoints].x;
  5.1038 +            newy = refPoints[i-halfPoints].y;
  5.1039 +        }
  5.1040 +        refPoints[i].x = newx;
  5.1041 +        refPoints[i].y = newy;
  5.1042 +        points[i].x = newx;
  5.1043 +        points[i].y = newy;
  5.1044 +        if (i==0) {
  5.1045 +            minx=maxx=newx;
  5.1046 +            miny=maxy=newy;
  5.1047 +        } else {
  5.1048 +            if (newx<minx) minx=newx;
  5.1049 +            if (newx>maxx) maxx=newx;
  5.1050 +            if (newy<miny) miny=newy;
  5.1051 +            if (newy>maxy) maxy=newy;
  5.1052 +        }
  5.1053 +    }
  5.1054 +
  5.1055 +    // Call function and validate - special case: no result requested
  5.1056 +    anyEnclosedNoResult = SDL_EnclosePoints((const SDL_Point *)points, numPoints, (const SDL_Rect *)NULL, (SDL_Rect *)NULL);
  5.1057 +    SDLTest_AssertCheck(expectedEnclosed==anyEnclosedNoResult, 
  5.1058 +        "Check return value %s, got %s", 
  5.1059 +        (expectedEnclosed==SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE", 
  5.1060 +		(anyEnclosedNoResult==SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE");
  5.1061 +    for (i=0; i<numPoints; i++) {
  5.1062 +        SDLTest_AssertCheck(refPoints[i].x==points[i].x && refPoints[i].y==points[i].y,
  5.1063 +            "Check that source point %i was not modified: expected (%i,%i) actual (%i,%i)", 
  5.1064 +            i, refPoints[i].x, refPoints[i].y, points[i].x, points[i].y);
  5.1065 +    }
  5.1066 +    
  5.1067 +    // Call function and validate
  5.1068 +    anyEnclosed = SDL_EnclosePoints((const SDL_Point *)points, numPoints, (const SDL_Rect *)NULL, &result);
  5.1069 +    SDLTest_AssertCheck(expectedEnclosed==anyEnclosed, 
  5.1070 +        "Check return value %s, got %s", 
  5.1071 +        (expectedEnclosed==SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE", 
  5.1072 +		(anyEnclosed==SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE");
  5.1073 +    for (i=0; i<numPoints; i++) {
  5.1074 +        SDLTest_AssertCheck(refPoints[i].x==points[i].x && refPoints[i].y==points[i].y,
  5.1075 +            "Check that source point %i was not modified: expected (%i,%i) actual (%i,%i)", 
  5.1076 +            i, refPoints[i].x, refPoints[i].y, points[i].x, points[i].y);
  5.1077 +    }
  5.1078 +    SDLTest_AssertCheck(result.x==minx && result.y==miny && result.w==(maxx - minx + 1) && result.h==(maxy - miny + 1),
  5.1079 +        "Check resulting enclosing rectangle: expected (%i,%i - %i,%i), actual (%i,%i - %i,%i)",
  5.1080 +        minx, miny, maxx, maxy, result.x, result.y, result.x + result.w - 1, result.y + result.h - 1);
  5.1081 +
  5.1082 +	return TEST_COMPLETED;
  5.1083 +}
  5.1084 +
  5.1085 +/*!
  5.1086 + * \brief Test SDL_EnclosePoints() with clipping
  5.1087 + *
  5.1088 + * \sa
  5.1089 + * http://wiki.libsdl.org/moin.cgi/SDL_EnclosePoints
  5.1090 + */
  5.1091 +int rect_testEnclosePointsWithClipping(void *arg)
  5.1092 +{
  5.1093 +    const int numPoints = 16;
  5.1094 +    SDL_Point refPoints[16];
  5.1095 +    SDL_Point points[16];
  5.1096 +    SDL_Rect refClip;
  5.1097 +    SDL_Rect clip;
  5.1098 +    SDL_Rect result;
  5.1099 +    SDL_bool anyEnclosed;
  5.1100 +    SDL_bool anyEnclosedNoResult;
  5.1101 +    SDL_bool expectedEnclosed = SDL_FALSE;
  5.1102 +    int newx, newy;
  5.1103 +    int minx, maxx, miny, maxy;
  5.1104 +    int i;
  5.1105 +
  5.1106 +    // Setup clipping rectangle
  5.1107 +    refClip.x = SDLTest_RandomIntegerInRange(-1024, 1024);
  5.1108 +    refClip.y = SDLTest_RandomIntegerInRange(-1024, 1024);
  5.1109 +    refClip.w = SDLTest_RandomIntegerInRange(1, 1024);
  5.1110 +    refClip.h = SDLTest_RandomIntegerInRange(1, 1024);
  5.1111 +
  5.1112 +    // Create input data, tracking result
  5.1113 +    for (i=0; i<numPoints; i++) {
  5.1114 +        newx = SDLTest_RandomIntegerInRange(-1024, 1024);
  5.1115 +        newy = SDLTest_RandomIntegerInRange(-1024, 1024);
  5.1116 +        refPoints[i].x = newx;
  5.1117 +        refPoints[i].y = newy;
  5.1118 +        points[i].x = newx;
  5.1119 +        points[i].y = newy;
  5.1120 +        if ((newx>=refClip.x) && (newx<(refClip.x + refClip.w)) &&
  5.1121 +            (newy>=refClip.y) && (newy<(refClip.y + refClip.h))) {
  5.1122 +            if (expectedEnclosed==SDL_FALSE) {
  5.1123 +                minx=maxx=newx;
  5.1124 +                miny=maxy=newy;
  5.1125 +            } else {
  5.1126 +                if (newx<minx) minx=newx;
  5.1127 +                if (newx>maxx) maxx=newx;
  5.1128 +                if (newy<miny) miny=newy;
  5.1129 +                if (newy>maxy) maxy=newy;
  5.1130 +            }
  5.1131 +            expectedEnclosed = SDL_TRUE;
  5.1132 +        }
  5.1133 +    }
  5.1134 +
  5.1135 +    // Call function and validate - special case: no result requested
  5.1136 +    clip = refClip;
  5.1137 +    anyEnclosedNoResult = SDL_EnclosePoints((const SDL_Point *)points, numPoints, (const SDL_Rect *)&clip, (SDL_Rect *)NULL);
  5.1138 +    SDLTest_AssertCheck(expectedEnclosed==anyEnclosedNoResult, 
  5.1139 +        "Expected return value %s, got %s", 
  5.1140 +        (expectedEnclosed==SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE", 
  5.1141 +		(anyEnclosedNoResult==SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE");
  5.1142 +    for (i=0; i<numPoints; i++) {
  5.1143 +        SDLTest_AssertCheck(refPoints[i].x==points[i].x && refPoints[i].y==points[i].y,
  5.1144 +            "Check that source point %i was not modified: expected (%i,%i) actual (%i,%i)", 
  5.1145 +            i, refPoints[i].x, refPoints[i].y, points[i].x, points[i].y);
  5.1146 +    }
  5.1147 +    SDLTest_AssertCheck(refClip.x==clip.x && refClip.y==clip.y && refClip.w==clip.w && refClip.h==clip.h,
  5.1148 +        "Check that source clipping rectangle was not modified");
  5.1149 +    
  5.1150 +    // Call function and validate
  5.1151 +    anyEnclosed = SDL_EnclosePoints((const SDL_Point *)points, numPoints, (const SDL_Rect *)&clip, &result);
  5.1152 +    SDLTest_AssertCheck(expectedEnclosed==anyEnclosed, 
  5.1153 +        "Check return value %s, got %s", 
  5.1154 +        (expectedEnclosed==SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE", 
  5.1155 +		(anyEnclosed==SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE");
  5.1156 +    for (i=0; i<numPoints; i++) {
  5.1157 +        SDLTest_AssertCheck(refPoints[i].x==points[i].x && refPoints[i].y==points[i].y,
  5.1158 +            "Check that source point %i was not modified: expected (%i,%i) actual (%i,%i)", 
  5.1159 +            i, refPoints[i].x, refPoints[i].y, points[i].x, points[i].y);
  5.1160 +    }
  5.1161 +    SDLTest_AssertCheck(refClip.x==clip.x && refClip.y==clip.y && refClip.w==clip.w && refClip.h==clip.h,
  5.1162 +        "Check that source clipping rectangle was not modified");
  5.1163 +    if (expectedEnclosed==SDL_TRUE) {
  5.1164 +        SDLTest_AssertCheck(result.x==minx && result.y==miny && result.w==(maxx - minx + 1) && result.h==(maxy - miny + 1),
  5.1165 +            "Check resulting enclosing rectangle: expected (%i,%i - %i,%i), actual (%i,%i - %i,%i)",
  5.1166 +            minx, miny, maxx, maxy, result.x, result.y, result.x + result.w - 1, result.y + result.h - 1);
  5.1167 +    }    
  5.1168 +    
  5.1169 +    /* Empty clipping rectangle */
  5.1170 +    clip.w = 0;
  5.1171 +    clip.h = 0;
  5.1172 +    expectedEnclosed = SDL_FALSE;
  5.1173 +    anyEnclosed = SDL_EnclosePoints((const SDL_Point *)points, numPoints, (const SDL_Rect *)&clip, &result);
  5.1174 +    SDLTest_AssertCheck(expectedEnclosed==anyEnclosed, 
  5.1175 +        "Check return value %s, got %s", 
  5.1176 +        (expectedEnclosed==SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE", 
  5.1177 +		(anyEnclosed==SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE");    
  5.1178 +
  5.1179 +	return TEST_COMPLETED;
  5.1180 +}
  5.1181 +
  5.1182 +/*!
  5.1183 + * \brief Negative tests against SDL_EnclosePoints() with invalid parameters
  5.1184 + *
  5.1185 + * \sa
  5.1186 + * http://wiki.libsdl.org/moin.cgi/SDL_EnclosePoints
  5.1187 + */
  5.1188 +int rect_testEnclosePointsParam(void *arg)
  5.1189 +{
  5.1190 +    SDL_Point points[1];
  5.1191 +    int count;
  5.1192 +    SDL_Rect clip;
  5.1193 +    SDL_Rect result;
  5.1194 +    SDL_bool anyEnclosed;
  5.1195 +
  5.1196 +    // invalid parameter combinations
  5.1197 +    anyEnclosed = SDL_EnclosePoints((SDL_Point *)NULL, 1, (const SDL_Rect *)&clip, &result);
  5.1198 +    SDLTest_AssertCheck(anyEnclosed == SDL_FALSE, "Check that functions returns SDL_FALSE when 1st parameter is NULL"); 
  5.1199 +    anyEnclosed = SDL_EnclosePoints((const SDL_Point *)points, 0, (const SDL_Rect *)&clip, &result);
  5.1200 +    SDLTest_AssertCheck(anyEnclosed == SDL_FALSE, "Check that functions returns SDL_FALSE when 2nd parameter is 0");
  5.1201 +    count = SDLTest_RandomIntegerInRange(-100, -1);
  5.1202 +    anyEnclosed = SDL_EnclosePoints((const SDL_Point *)points, count, (const SDL_Rect *)&clip, &result);
  5.1203 +    SDLTest_AssertCheck(anyEnclosed == SDL_FALSE, "Check that functions returns SDL_FALSE when 2nd parameter is %i (negative)", count); 
  5.1204 +    anyEnclosed = SDL_EnclosePoints((SDL_Point *)NULL, 0, (const SDL_Rect *)&clip, &result);
  5.1205 +    SDLTest_AssertCheck(anyEnclosed == SDL_FALSE, "Check that functions returns SDL_FALSE when 1st parameter is NULL and 2nd parameter was 0"); 
  5.1206 +
  5.1207 +	return TEST_COMPLETED;
  5.1208 +}
  5.1209 +
  5.1210 +/*!
  5.1211 + * \brief Tests SDL_UnionRect() where rect B is outside rect A
  5.1212 + *
  5.1213 + * \sa
  5.1214 + * http://wiki.libsdl.org/moin.cgi/SDL_UnionRect
  5.1215 + */
  5.1216 +int rect_testUnionRectOutside(void *arg)
  5.1217 +{
  5.1218 +    SDL_Rect refRectA, refRectB;
  5.1219 +    SDL_Rect rectA, rectB;
  5.1220 +    SDL_Rect expectedResult;
  5.1221 +    SDL_Rect result;
  5.1222 +    int minx, maxx, miny, maxy;
  5.1223 +    int dx, dy;
  5.1224 +    
  5.1225 +    /* Union 1x1 outside */
  5.1226 +    for (dx = -1; dx < 2; dx++) {     
  5.1227 +        for (dy = -1; dy < 2; dy++) {
  5.1228 +            if ((dx != 0) || (dy != 0)) {
  5.1229 +                refRectA.x=SDLTest_RandomIntegerInRange(-1024, 1024);
  5.1230 +                refRectA.y=SDLTest_RandomIntegerInRange(-1024, 1024);
  5.1231 +                refRectA.w=1;
  5.1232 +                refRectA.h=1;
  5.1233 +                refRectB.x=SDLTest_RandomIntegerInRange(-1024, 1024) + dx*2048;
  5.1234 +                refRectB.y=SDLTest_RandomIntegerInRange(-1024, 1024) + dx*2048;
  5.1235 +                refRectB.w=1;
  5.1236 +                refRectB.h=1;
  5.1237 +                minx = (refRectA.x<refRectB.x) ? refRectA.x : refRectB.x;
  5.1238 +                maxx = (refRectA.x>refRectB.x) ? refRectA.x : refRectB.x;
  5.1239 +                miny = (refRectA.y<refRectB.y) ? refRectA.y : refRectB.y;
  5.1240 +                maxy = (refRectA.y>refRectB.y) ? refRectA.y : refRectB.y;                
  5.1241 +                expectedResult.x = minx;
  5.1242 +                expectedResult.y = miny;
  5.1243 +                expectedResult.w = maxx - minx + 1;
  5.1244 +                expectedResult.h = maxy - miny + 1;
  5.1245 +                rectA = refRectA;
  5.1246 +                rectB = refRectB;
  5.1247 +                SDL_UnionRect(&rectA, &rectB, &result);
  5.1248 +                _validateUnionRectResults(&rectA, &rectB, &refRectA, &refRectB, &result, &expectedResult);
  5.1249 +            }
  5.1250 +        }
  5.1251 +    }
  5.1252 +
  5.1253 +    /* Union outside overlap */
  5.1254 +    for (dx = -1; dx < 2; dx++) {     
  5.1255 +        for (dy = -1; dy < 2; dy++) {
  5.1256 +            if ((dx != 0) || (dy != 0)) {
  5.1257 +                refRectA.x=SDLTest_RandomIntegerInRange(-1024, 1024);
  5.1258 +                refRectA.y=SDLTest_RandomIntegerInRange(-1024, 1024);
  5.1259 +                refRectA.w=SDLTest_RandomIntegerInRange(256, 512);
  5.1260 +                refRectA.h=SDLTest_RandomIntegerInRange(256, 512);
  5.1261 +                refRectB.x=refRectA.x + 1 + dx*2;
  5.1262 +                refRectB.y=refRectA.y + 1 + dy*2;
  5.1263 +                refRectB.w=refRectA.w - 2;
  5.1264 +                refRectB.h=refRectA.h - 2;
  5.1265 +                expectedResult = refRectA;
  5.1266 +                if (dx == -1) expectedResult.x--;
  5.1267 +                if (dy == -1) expectedResult.y--;
  5.1268 +                if ((dx == 1) || (dx == -1)) expectedResult.w++;
  5.1269 +                if ((dy == 1) || (dy == -1)) expectedResult.h++;
  5.1270 +                rectA = refRectA;
  5.1271 +                rectB = refRectB;
  5.1272 +                SDL_UnionRect(&rectA, &rectB, &result);
  5.1273 +                _validateUnionRectResults(&rectA, &rectB, &refRectA, &refRectB, &result, &expectedResult);
  5.1274 +            }
  5.1275 +        }
  5.1276 +    }
  5.1277 +
  5.1278 +	return TEST_COMPLETED;
  5.1279 +}
  5.1280 +
  5.1281 +/*!
  5.1282 + * \brief Tests SDL_UnionRect() where rect A or rect B are empty
  5.1283 + *
  5.1284 + * \sa
  5.1285 + * http://wiki.libsdl.org/moin.cgi/SDL_UnionRect
  5.1286 + */
  5.1287 +int rect_testUnionRectEmpty(void *arg)
  5.1288 +{
  5.1289 +    SDL_Rect refRectA, refRectB;
  5.1290 +    SDL_Rect rectA, rectB;
  5.1291 +    SDL_Rect expectedResult;
  5.1292 +    SDL_Rect result;
  5.1293 +
  5.1294 +    /* A empty */    
  5.1295 +    refRectA.x=SDLTest_RandomIntegerInRange(-1024, 1024);
  5.1296 +    refRectA.y=SDLTest_RandomIntegerInRange(-1024, 1024);
  5.1297 +    refRectA.w=0;
  5.1298 +    refRectA.h=0;
  5.1299 +    refRectB.x=SDLTest_RandomIntegerInRange(-1024, 1024);
  5.1300 +    refRectB.y=SDLTest_RandomIntegerInRange(-1024, 1024);
  5.1301 +    refRectB.w=SDLTest_RandomIntegerInRange(1, 1024);
  5.1302 +    refRectB.h=SDLTest_RandomIntegerInRange(1, 1024);
  5.1303 +    expectedResult = refRectB;
  5.1304 +    rectA = refRectA;
  5.1305 +    rectB = refRectB;
  5.1306 +    SDL_UnionRect(&rectA, &rectB, &result);
  5.1307 +    _validateUnionRectResults(&rectA, &rectB, &refRectA, &refRectB, &result, &expectedResult);
  5.1308 +    
  5.1309 +    /* B empty */    
  5.1310 +    refRectA.x=SDLTest_RandomIntegerInRange(-1024, 1024);
  5.1311 +    refRectA.y=SDLTest_RandomIntegerInRange(-1024, 1024);
  5.1312 +    refRectA.w=SDLTest_RandomIntegerInRange(1, 1024);
  5.1313 +    refRectA.h=SDLTest_RandomIntegerInRange(1, 1024);
  5.1314 +    refRectB.x=SDLTest_RandomIntegerInRange(-1024, 1024);
  5.1315 +    refRectB.y=SDLTest_RandomIntegerInRange(-1024, 1024);
  5.1316 +    refRectB.w=0;
  5.1317 +    refRectB.h=0;
  5.1318 +    expectedResult = refRectA;
  5.1319 +    rectA = refRectA;
  5.1320 +    rectB = refRectB;
  5.1321 +    SDL_UnionRect(&rectA, &rectB, &result);
  5.1322 +    _validateUnionRectResults(&rectA, &rectB, &refRectA, &refRectB, &result, &expectedResult);
  5.1323 +
  5.1324 +    /* A and B empty */    
  5.1325 +    refRectA.x=SDLTest_RandomIntegerInRange(-1024, 1024);
  5.1326 +    refRectA.y=SDLTest_RandomIntegerInRange(-1024, 1024);
  5.1327 +    refRectA.w=0;
  5.1328 +    refRectA.h=0;
  5.1329 +    refRectB.x=SDLTest_RandomIntegerInRange(-1024, 1024);
  5.1330 +    refRectB.y=SDLTest_RandomIntegerInRange(-1024, 1024);
  5.1331 +    refRectB.w=0;
  5.1332 +    refRectB.h=0;
  5.1333 +    result.x=0;
  5.1334 +    result.y=0;
  5.1335 +    result.w=0;
  5.1336 +    result.h=0;
  5.1337 +    expectedResult = result;
  5.1338 +    rectA = refRectA;
  5.1339 +    rectB = refRectB;
  5.1340 +    SDL_UnionRect(&rectA, &rectB, &result);
  5.1341 +    _validateUnionRectResults(&rectA, &rectB, &refRectA, &refRectB, &result, &expectedResult);
  5.1342 +
  5.1343 +	return TEST_COMPLETED;
  5.1344 +}
  5.1345 +
  5.1346 +/*!
  5.1347 + * \brief Tests SDL_UnionRect() where rect B is inside rect A
  5.1348 + *
  5.1349 + * \sa
  5.1350 + * http://wiki.libsdl.org/moin.cgi/SDL_UnionRect
  5.1351 + */
  5.1352 +int rect_testUnionRectInside(void *arg)
  5.1353 +{
  5.1354 +    SDL_Rect refRectA, refRectB;
  5.1355 +    SDL_Rect rectA, rectB;
  5.1356 +    SDL_Rect expectedResult;
  5.1357 +    SDL_Rect result;
  5.1358 +    int dx, dy;
  5.1359 +    
  5.1360 +    /* Union 1x1 with itself */
  5.1361 +    refRectA.x=SDLTest_RandomIntegerInRange(-1024, 1024);
  5.1362 +    refRectA.y=SDLTest_RandomIntegerInRange(-1024, 1024);
  5.1363 +    refRectA.w=1;
  5.1364 +    refRectA.h=1;
  5.1365 +    expectedResult = refRectA;
  5.1366 +    rectA = refRectA;
  5.1367 +    SDL_UnionRect(&rectA, &rectA, &result);
  5.1368 +    _validateUnionRectResults(&rectA, &rectA, &refRectA, &refRectA, &result, &expectedResult);
  5.1369 +
  5.1370 +    /* Union 1x1 somewhere inside */
  5.1371 +    refRectA.x=SDLTest_RandomIntegerInRange(-1024, 1024);
  5.1372 +    refRectA.y=SDLTest_RandomIntegerInRange(-1024, 1024);
  5.1373 +    refRectA.w=SDLTest_RandomIntegerInRange(256, 1024);
  5.1374 +    refRectA.h=SDLTest_RandomIntegerInRange(256, 1024);
  5.1375 +    refRectB.x=refRectA.x + 1 + SDLTest_RandomIntegerInRange(1, refRectA.w - 2);
  5.1376 +    refRectB.y=refRectA.y + 1 + SDLTest_RandomIntegerInRange(1, refRectA.h - 2);
  5.1377 +    refRectB.w=1;
  5.1378 +    refRectB.h=1;
  5.1379 +    expectedResult = refRectA;
  5.1380 +    rectA = refRectA;
  5.1381 +    rectB = refRectB;
  5.1382 +    SDL_UnionRect(&rectA, &rectB, &result);
  5.1383 +    _validateUnionRectResults(&rectA, &rectB, &refRectA, &refRectB, &result, &expectedResult);
  5.1384 +
  5.1385 +    /* Union inside with edges modified */
  5.1386 +    for (dx = -1; dx < 2; dx++) {     
  5.1387 +        for (dy = -1; dy < 2; dy++) {
  5.1388 +            if ((dx != 0) || (dy != 0)) {
  5.1389 +                refRectA.x=SDLTest_RandomIntegerInRange(-1024, 1024);
  5.1390 +                refRectA.y=SDLTest_RandomIntegerInRange(-1024, 1024);
  5.1391 +                refRectA.w=SDLTest_RandomIntegerInRange(256, 1024);
  5.1392 +                refRectA.h=SDLTest_RandomIntegerInRange(256, 1024);
  5.1393 +                refRectB = refRectA;
  5.1394 +                if (dx == -1) refRectB.x++;
  5.1395 +                if ((dx == 1) || (dx == -1)) refRectB.w--;
  5.1396 +                if (dy == -1) refRectB.y++;
  5.1397 +                if ((dy == 1) || (dy == -1)) refRectB.h--;                
  5.1398 +                expectedResult = refRectA;
  5.1399 +                rectA = refRectA;
  5.1400 +                rectB = refRectB;
  5.1401 +                SDL_UnionRect(&rectA, &rectB, &result);
  5.1402 +                _validateUnionRectResults(&rectA, &rectB, &refRectA, &refRectB, &result, &expectedResult);
  5.1403 +            }
  5.1404 +        }
  5.1405 +    }
  5.1406 +
  5.1407 +	return TEST_COMPLETED;
  5.1408 +}
  5.1409 +
  5.1410 +/*!
  5.1411 + * \brief Negative tests against SDL_UnionRect() with invalid parameters
  5.1412 + *
  5.1413 + * \sa
  5.1414 + * http://wiki.libsdl.org/moin.cgi/SDL_UnionRect
  5.1415 + */
  5.1416 +int rect_testUnionRectParam(void *arg)
  5.1417 +{
  5.1418 +    SDL_Rect rectA, rectB;
  5.1419 +    SDL_Rect result;
  5.1420 +
  5.1421 +    // invalid parameter combinations
  5.1422 +    SDL_UnionRect((SDL_Rect *)NULL, &rectB, &result);
  5.1423 +    SDLTest_AssertPass("Check that function returns when 1st parameter is NULL"); 
  5.1424 +    SDL_UnionRect(&rectA, (SDL_Rect *)NULL, &result);
  5.1425 +    SDLTest_AssertPass("Check that function returns  when 2nd parameter is NULL"); 
  5.1426 +    SDL_UnionRect(&rectA, &rectB, (SDL_Rect *)NULL);
  5.1427 +    SDLTest_AssertPass("Check that function returns  when 3rd parameter is NULL"); 
  5.1428 +    SDL_UnionRect((SDL_Rect *)NULL, &rectB, (SDL_Rect *)NULL);
  5.1429 +    SDLTest_AssertPass("Check that function returns  when 1st and 3rd parameter are NULL"); 
  5.1430 +    SDL_UnionRect(&rectA, (SDL_Rect *)NULL, (SDL_Rect *)NULL);
  5.1431 +    SDLTest_AssertPass("Check that function returns  when 2nd and 3rd parameter are NULL"); 
  5.1432 +    SDL_UnionRect((SDL_Rect *)NULL, (SDL_Rect *)NULL, (SDL_Rect *)NULL);
  5.1433 +    SDLTest_AssertPass("Check that function returns  when all parameters are NULL"); 
  5.1434 +
  5.1435 +	return TEST_COMPLETED;
  5.1436 +}
  5.1437 +
  5.1438 +/*!
  5.1439 + * \brief Tests SDL_RectEmpty() with various inputs
  5.1440 + *
  5.1441 + * \sa
  5.1442 + * http://wiki.libsdl.org/moin.cgi/SDL_RectEmpty
  5.1443 + */
  5.1444 +int rect_testRectEmpty(void *arg)
  5.1445 +{
  5.1446 +    SDL_Rect refRect;
  5.1447 +    SDL_Rect rect;
  5.1448 +    SDL_bool expectedResult;
  5.1449 +    SDL_bool result;
  5.1450 +    int w, h;
  5.1451 +
  5.1452 +    // Non-empty case
  5.1453 +    refRect.x=SDLTest_RandomIntegerInRange(-1024, 1024);
  5.1454 +    refRect.y=SDLTest_RandomIntegerInRange(-1024, 1024);
  5.1455 +    refRect.w=SDLTest_RandomIntegerInRange(256, 1024);
  5.1456 +    refRect.h=SDLTest_RandomIntegerInRange(256, 1024);
  5.1457 +    expectedResult = SDL_FALSE;
  5.1458 +    rect = refRect;
  5.1459 +    result = (SDL_bool)SDL_RectEmpty((const SDL_Rect *)&rect);
  5.1460 +    _validateRectEmptyResults(result, expectedResult, &rect, &refRect);
  5.1461 +    
  5.1462 +    // Empty case
  5.1463 +    for (w=-1; w<2; w++) {
  5.1464 +        for (h=-1; h<2; h++) {
  5.1465 +            if ((w != 1) || (h != 1)) {
  5.1466 +                refRect.x=SDLTest_RandomIntegerInRange(-1024, 1024);
  5.1467 +                refRect.y=SDLTest_RandomIntegerInRange(-1024, 1024);
  5.1468 +                refRect.w=w;
  5.1469 +                refRect.h=h;
  5.1470 +                expectedResult = SDL_TRUE;
  5.1471 +                rect = refRect;
  5.1472 +                result = (SDL_bool)SDL_RectEmpty((const SDL_Rect *)&rect);
  5.1473 +                _validateRectEmptyResults(result, expectedResult, &rect, &refRect);
  5.1474 +            }
  5.1475 +        }
  5.1476 +    }
  5.1477 +
  5.1478 +	return TEST_COMPLETED;
  5.1479 +}
  5.1480 +
  5.1481 +/*!
  5.1482 + * \brief Negative tests against SDL_RectEmpty() with invalid parameters
  5.1483 + *
  5.1484 + * \sa
  5.1485 + * http://wiki.libsdl.org/moin.cgi/SDL_RectEmpty
  5.1486 + */
  5.1487 +int rect_testRectEmptyParam(void *arg)
  5.1488 +{
  5.1489 +    SDL_bool result;
  5.1490 +
  5.1491 +    // invalid parameter combinations
  5.1492 +    result = (SDL_bool)SDL_RectEmpty((const SDL_Rect *)NULL);
  5.1493 +    SDLTest_AssertCheck(result == SDL_TRUE, "Check that function returns TRUE when 1st parameter is NULL"); 
  5.1494 +
  5.1495 +	return TEST_COMPLETED;
  5.1496 +}
  5.1497 +
  5.1498 +/*!
  5.1499 + * \brief Tests SDL_RectEquals() with various inputs
  5.1500 + *
  5.1501 + * \sa
  5.1502 + * http://wiki.libsdl.org/moin.cgi/SDL_RectEquals
  5.1503 + */
  5.1504 +int rect_testRectEquals(void *arg)
  5.1505 +{
  5.1506 +    SDL_Rect refRectA;
  5.1507 +    SDL_Rect refRectB;
  5.1508 +    SDL_Rect rectA;
  5.1509 +    SDL_Rect rectB;
  5.1510 +    SDL_bool expectedResult;
  5.1511 +    SDL_bool result;
  5.1512 +
  5.1513 +    // Equals
  5.1514 +    refRectA.x=SDLTest_RandomIntegerInRange(-1024, 1024);
  5.1515 +    refRectA.y=SDLTest_RandomIntegerInRange(-1024, 1024);
  5.1516 +    refRectA.w=SDLTest_RandomIntegerInRange(1, 1024);
  5.1517 +    refRectA.h=SDLTest_RandomIntegerInRange(1, 1024);
  5.1518 +    refRectB = refRectA;    
  5.1519 +    expectedResult = SDL_TRUE;
  5.1520 +    rectA = refRectA;
  5.1521 +    rectB = refRectB;
  5.1522 +    result = (SDL_bool)SDL_RectEquals((const SDL_Rect *)&rectA, (const SDL_Rect *)&rectB);
  5.1523 +    _validateRectEqualsResults(result, expectedResult, &rectA, &rectB, &refRectA, &refRectB);
  5.1524 +
  5.1525 +	return TEST_COMPLETED;
  5.1526 +}
  5.1527 +
  5.1528 +/*!
  5.1529 + * \brief Negative tests against SDL_RectEquals() with invalid parameters
  5.1530 + *
  5.1531 + * \sa
  5.1532 + * http://wiki.libsdl.org/moin.cgi/SDL_RectEquals
  5.1533 + */
  5.1534 +int rect_testRectEqualsParam(void *arg)
  5.1535 +{
  5.1536 +    SDL_Rect rectA;
  5.1537 +    SDL_Rect rectB;
  5.1538 +    SDL_bool result;
  5.1539 +
  5.1540 +    /* data setup */
  5.1541 +    rectA.x=SDLTest_RandomIntegerInRange(-1024, 1024);
  5.1542 +    rectA.y=SDLTest_RandomIntegerInRange(-1024, 1024);
  5.1543 +    rectA.w=SDLTest_RandomIntegerInRange(1, 1024);
  5.1544 +    rectA.h=SDLTest_RandomIntegerInRange(1, 1024);
  5.1545 +    rectB.x=SDLTest_RandomIntegerInRange(-1024, 1024);
  5.1546 +    rectB.y=SDLTest_RandomIntegerInRange(-1024, 1024);
  5.1547 +    rectB.w=SDLTest_RandomIntegerInRange(1, 1024);
  5.1548 +    rectB.h=SDLTest_RandomIntegerInRange(1, 1024);
  5.1549 +
  5.1550 +    // invalid parameter combinations
  5.1551 +    result = (SDL_bool)SDL_RectEquals((const SDL_Rect *)NULL, (const SDL_Rect *)&rectB);
  5.1552 +    SDLTest_AssertCheck(result == SDL_FALSE, "Check that function returns SDL_FALSE when 1st parameter is NULL"); 
  5.1553 +    result = (SDL_bool)SDL_RectEquals((const SDL_Rect *)&rectA, (const SDL_Rect *)NULL);
  5.1554 +    SDLTest_AssertCheck(result == SDL_FALSE, "Check that function returns SDL_FALSE when 2nd parameter is NULL"); 
  5.1555 +    result = (SDL_bool)SDL_RectEquals((const SDL_Rect *)NULL, (const SDL_Rect *)NULL);
  5.1556 +    SDLTest_AssertCheck(result == SDL_FALSE, "Check that function returns SDL_FALSE when 1st and 2nd parameter are NULL"); 
  5.1557 +
  5.1558 +	return TEST_COMPLETED;
  5.1559 +}
  5.1560 +
  5.1561 +/* ================= Test References ================== */
  5.1562 +
  5.1563 +/* Rect test cases */
  5.1564 +
  5.1565 +/* SDL_IntersectRectAndLine */
  5.1566 +static const SDLTest_TestCaseReference rectTest1 =
  5.1567 +		{ (SDLTest_TestCaseFp)rect_testIntersectRectAndLine,"rect_testIntersectRectAndLine",  "Tests SDL_IntersectRectAndLine clipping cases", TEST_ENABLED };
  5.1568 +
  5.1569 +static const SDLTest_TestCaseReference rectTest2 =
  5.1570 +		{ (SDLTest_TestCaseFp)rect_testIntersectRectAndLineInside, "rect_testIntersectRectAndLineInside", "Tests SDL_IntersectRectAndLine with line fully contained in rect", TEST_ENABLED };
  5.1571 +
  5.1572 +static const SDLTest_TestCaseReference rectTest3 =
  5.1573 +		{ (SDLTest_TestCaseFp)rect_testIntersectRectAndLineOutside, "rect_testIntersectRectAndLineOutside", "Tests SDL_IntersectRectAndLine with line fully outside of rect", TEST_ENABLED };
  5.1574 +
  5.1575 +static const SDLTest_TestCaseReference rectTest4 =
  5.1576 +		{ (SDLTest_TestCaseFp)rect_testIntersectRectAndLineEmpty, "rect_testIntersectRectAndLineEmpty", "Tests SDL_IntersectRectAndLine with empty rectangle ", TEST_ENABLED };
  5.1577 +
  5.1578 +static const SDLTest_TestCaseReference rectTest5 =
  5.1579 +		{ (SDLTest_TestCaseFp)rect_testIntersectRectAndLineParam, "rect_testIntersectRectAndLineParam", "Negative tests against SDL_IntersectRectAndLine with invalid parameters", TEST_ENABLED };
  5.1580 +
  5.1581 +/* SDL_IntersectRect */
  5.1582 +static const SDLTest_TestCaseReference rectTest6 =
  5.1583 +		{ (SDLTest_TestCaseFp)rect_testIntersectRectInside, "rect_testIntersectRectInside", "Tests SDL_IntersectRect with B fully contained in A", TEST_ENABLED };
  5.1584 +
  5.1585 +static const SDLTest_TestCaseReference rectTest7 =
  5.1586 +		{ (SDLTest_TestCaseFp)rect_testIntersectRectOutside, "rect_testIntersectRectOutside", "Tests SDL_IntersectRect with B fully outside of A", TEST_ENABLED };
  5.1587 +
  5.1588 +static const SDLTest_TestCaseReference rectTest8 =
  5.1589 +		{ (SDLTest_TestCaseFp)rect_testIntersectRectPartial, "rect_testIntersectRectPartial", "Tests SDL_IntersectRect with B partially intersecting A", TEST_ENABLED };
  5.1590 +
  5.1591 +static const SDLTest_TestCaseReference rectTest9 =
  5.1592 +		{ (SDLTest_TestCaseFp)rect_testIntersectRectPoint, "rect_testIntersectRectPoint", "Tests SDL_IntersectRect with 1x1 sized rectangles", TEST_ENABLED };
  5.1593 +
  5.1594 +static const SDLTest_TestCaseReference rectTest10 =
  5.1595 +		{ (SDLTest_TestCaseFp)rect_testIntersectRectEmpty, "rect_testIntersectRectEmpty", "Tests SDL_IntersectRect with empty rectangles", TEST_ENABLED };
  5.1596 +
  5.1597 +static const SDLTest_TestCaseReference rectTest11 =
  5.1598 +		{ (SDLTest_TestCaseFp)rect_testIntersectRectParam, "rect_testIntersectRectParam", "Negative tests against SDL_IntersectRect with invalid parameters", TEST_ENABLED };
  5.1599 +
  5.1600 +/* SDL_HasIntersection */
  5.1601 +static const SDLTest_TestCaseReference rectTest12 =
  5.1602 +		{ (SDLTest_TestCaseFp)rect_testHasIntersectionInside, "rect_testHasIntersectionInside", "Tests SDL_HasIntersection with B fully contained in A", TEST_ENABLED };
  5.1603 +
  5.1604 +static const SDLTest_TestCaseReference rectTest13 =
  5.1605 +		{ (SDLTest_TestCaseFp)rect_testHasIntersectionOutside, "rect_testHasIntersectionOutside", "Tests SDL_HasIntersection with B fully outside of A", TEST_ENABLED };
  5.1606 +
  5.1607 +static const SDLTest_TestCaseReference rectTest14 =
  5.1608 +		{ (SDLTest_TestCaseFp)rect_testHasIntersectionPartial,"rect_testHasIntersectionPartial",  "Tests SDL_HasIntersection with B partially intersecting A", TEST_ENABLED };
  5.1609 +
  5.1610 +static const SDLTest_TestCaseReference rectTest15 =
  5.1611 +		{ (SDLTest_TestCaseFp)rect_testHasIntersectionPoint, "rect_testHasIntersectionPoint", "Tests SDL_HasIntersection with 1x1 sized rectangles", TEST_ENABLED };
  5.1612 +
  5.1613 +static const SDLTest_TestCaseReference rectTest16 =
  5.1614 +		{ (SDLTest_TestCaseFp)rect_testHasIntersectionEmpty, "rect_testHasIntersectionEmpty", "Tests SDL_HasIntersection with empty rectangles", TEST_ENABLED };
  5.1615 +
  5.1616 +static const SDLTest_TestCaseReference rectTest17 =
  5.1617 +		{ (SDLTest_TestCaseFp)rect_testHasIntersectionParam, "rect_testHasIntersectionParam", "Negative tests against SDL_HasIntersection with invalid parameters", TEST_ENABLED };
  5.1618 +
  5.1619 +/* SDL_EnclosePoints */
  5.1620 +static const SDLTest_TestCaseReference rectTest18 =
  5.1621 +		{ (SDLTest_TestCaseFp)rect_testEnclosePoints, "rect_testEnclosePoints", "Tests SDL_EnclosePoints without clipping", TEST_ENABLED };
  5.1622 +
  5.1623 +static const SDLTest_TestCaseReference rectTest19 =
  5.1624 +		{ (SDLTest_TestCaseFp)rect_testEnclosePointsWithClipping, "rect_testEnclosePointsWithClipping", "Tests SDL_EnclosePoints with clipping", TEST_ENABLED };
  5.1625 +
  5.1626 +static const SDLTest_TestCaseReference rectTest20 =
  5.1627 +		{ (SDLTest_TestCaseFp)rect_testEnclosePointsRepeatedInput, "rect_testEnclosePointsRepeatedInput", "Tests SDL_EnclosePoints with repeated input", TEST_ENABLED };
  5.1628 +
  5.1629 +static const SDLTest_TestCaseReference rectTest21 =
  5.1630 +		{ (SDLTest_TestCaseFp)rect_testEnclosePointsParam, "rect_testEnclosePointsParam", "Negative tests against SDL_EnclosePoints with invalid parameters", TEST_ENABLED };
  5.1631 +
  5.1632 +/* SDL_UnionRect */
  5.1633 +static const SDLTest_TestCaseReference rectTest22 =
  5.1634 +		{ (SDLTest_TestCaseFp)rect_testUnionRectInside, "rect_testUnionRectInside", "Tests SDL_UnionRect where rect B is inside rect A", TEST_ENABLED };
  5.1635 +
  5.1636 +static const SDLTest_TestCaseReference rectTest23 =
  5.1637 +		{ (SDLTest_TestCaseFp)rect_testUnionRectOutside, "rect_testUnionRectOutside", "Tests SDL_UnionRect where rect B is outside rect A", TEST_ENABLED };
  5.1638 +
  5.1639 +static const SDLTest_TestCaseReference rectTest24 =
  5.1640 +		{ (SDLTest_TestCaseFp)rect_testUnionRectEmpty, "rect_testUnionRectEmpty", "Tests SDL_UnionRect where rect A or rect B are empty", TEST_ENABLED };
  5.1641 +
  5.1642 +static const SDLTest_TestCaseReference rectTest25 =
  5.1643 +		{ (SDLTest_TestCaseFp)rect_testUnionRectParam, "rect_testUnionRectParam", "Negative tests against SDL_UnionRect with invalid parameters", TEST_ENABLED };
  5.1644 +
  5.1645 +/* SDL_RectEmpty */
  5.1646 +static const SDLTest_TestCaseReference rectTest26 =
  5.1647 +		{ (SDLTest_TestCaseFp)rect_testRectEmpty, "rect_testRectEmpty", "Tests SDL_RectEmpty with various inputs", TEST_ENABLED };
  5.1648 +
  5.1649 +static const SDLTest_TestCaseReference rectTest27 =
  5.1650 +		{ (SDLTest_TestCaseFp)rect_testRectEmptyParam, "rect_testRectEmptyParam", "Negative tests against SDL_RectEmpty with invalid parameters", TEST_ENABLED };
  5.1651 +
  5.1652 +/* SDL_RectEquals */
  5.1653 +
  5.1654 +static const SDLTest_TestCaseReference rectTest28 =
  5.1655 +		{ (SDLTest_TestCaseFp)rect_testRectEquals, "rect_testRectEquals", "Tests SDL_RectEquals with various inputs", TEST_ENABLED };
  5.1656 +
  5.1657 +static const SDLTest_TestCaseReference rectTest29 =
  5.1658 +		{ (SDLTest_TestCaseFp)rect_testRectEqualsParam, "rect_testRectEqualsParam", "Negative tests against SDL_RectEquals with invalid parameters", TEST_ENABLED };
  5.1659 +
  5.1660 +
  5.1661 +/*!
  5.1662 + * \brief Sequence of Rect test cases; functions that handle simple rectangles including overlaps and merges.
  5.1663 + *
  5.1664 + * \sa
  5.1665 + * http://wiki.libsdl.org/moin.cgi/CategoryRect
  5.1666 + */
  5.1667 +static const SDLTest_TestCaseReference *rectTests[] =  {
  5.1668 +	&rectTest1, &rectTest2, &rectTest3, &rectTest4, &rectTest5, &rectTest6, &rectTest7, &rectTest8, &rectTest9, &rectTest10, &rectTest11, &rectTest12, &rectTest13, &rectTest14, 
  5.1669 +	&rectTest15, &rectTest16, &rectTest17, &rectTest18, &rectTest19, &rectTest20, &rectTest21, &rectTest22, &rectTest23, &rectTest24, &rectTest25, &rectTest26, &rectTest27,
  5.1670 +	&rectTest28, &rectTest29, NULL
  5.1671 +};
  5.1672 +
  5.1673 +
  5.1674 +/* Rect test suite (global) */
  5.1675 +SDLTest_TestSuiteReference rectTestSuite = {
  5.1676 +	"Rect",
  5.1677 +	NULL,
  5.1678 +	rectTests,
  5.1679 +	NULL
  5.1680 +};
     6.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     6.2 +++ b/test/testautomation_render.c	Sat Dec 22 17:24:42 2012 -0800
     6.3 @@ -0,0 +1,1025 @@
     6.4 +/**
     6.5 + * Original code: automated SDL platform test written by Edgar Simo "bobbens"
     6.6 + * Extended and extensively updated by aschiffler at ferzkopp dot net
     6.7 + */
     6.8 +
     6.9 +#include <stdio.h>
    6.10 +
    6.11 +#include "SDL.h"
    6.12 +#include "SDL_test.h"
    6.13 +
    6.14 +/* ================= Test Case Implementation ================== */
    6.15 +
    6.16 +#define TESTRENDER_SCREEN_W     80
    6.17 +#define TESTRENDER_SCREEN_H     60
    6.18 +
    6.19 +#define RENDER_COMPARE_FORMAT  SDL_PIXELFORMAT_ARGB8888
    6.20 +#define RENDER_COMPARE_AMASK   0xff000000 /**< Alpha bit mask. */
    6.21 +#define RENDER_COMPARE_RMASK   0x00ff0000 /**< Red bit mask. */
    6.22 +#define RENDER_COMPARE_GMASK   0x0000ff00 /**< Green bit mask. */
    6.23 +#define RENDER_COMPARE_BMASK   0x000000ff /**< Blue bit mask. */
    6.24 +
    6.25 +#define ALLOWABLE_ERROR_OPAQUE	0
    6.26 +#define ALLOWABLE_ERROR_BLENDED	64
    6.27 +
    6.28 +SDL_Window *window = NULL;
    6.29 +SDL_Renderer *renderer = NULL;
    6.30 +
    6.31 +/* Prototypes for helper functions */
    6.32 +
    6.33 +static int _clearScreen (void);
    6.34 +static void _compare(const char *msg, SDL_Surface *s, int allowable_error);
    6.35 +static int _hasTexAlpha(void);
    6.36 +static int _hasTexColor(void);
    6.37 +static SDL_Texture *_loadTestFace(void);
    6.38 +static int _hasBlendModes(void);
    6.39 +static int _hasDrawColor(void);
    6.40 +static int _isSupported(int code);
    6.41 +
    6.42 +/**
    6.43 + * Create software renderer for tests
    6.44 + */
    6.45 +void InitCreateRenderer(void *arg)
    6.46 +{
    6.47 +  int posX = 100, posY = 100, width = 320, height = 240;
    6.48 +  renderer = NULL;
    6.49 +  window = SDL_CreateWindow("render_testCreateRenderer", posX, posY, width, height, 0);
    6.50 +  SDLTest_AssertPass("SDL_CreateWindow()");
    6.51 +  SDLTest_AssertCheck(window != NULL, "Check SDL_CreateWindow result");
    6.52 +  if (window == NULL) {
    6.53 +      return;
    6.54 +  }
    6.55 +  
    6.56 +  renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED);
    6.57 +  SDLTest_AssertPass("SDL_CreateRenderer()");
    6.58 +  SDLTest_AssertCheck(renderer != 0, "Check SDL_CreateRenderer result");
    6.59 +  if (renderer == 0) {
    6.60 +      SDL_DestroyWindow(window);
    6.61 +      return;
    6.62 +  }
    6.63 +}
    6.64 +
    6.65 +/*
    6.66 + * Destroy renderer for tests  
    6.67 + */
    6.68 +void CleanupDestroyRenderer(void *arg)
    6.69 +{
    6.70 +  if (renderer != NULL) {  
    6.71 +     SDL_DestroyRenderer(renderer);
    6.72 +     SDLTest_AssertPass("SDL_DestroyRenderer()");
    6.73 +  }
    6.74 +  
    6.75 +  if (window != NULL) {  
    6.76 +     SDL_DestroyWindow(window);
    6.77 +     SDLTest_AssertPass("SDL_DestroyWindow");
    6.78 +  }
    6.79 +}
    6.80 +
    6.81 +
    6.82 +/**
    6.83 + * @brief Tests call to SDL_GetNumRenderDrivers
    6.84 + *
    6.85 + * \sa
    6.86 + * http://wiki.libsdl.org/moin.cgi/SDL_GetNumRenderDrivers
    6.87 + */
    6.88 +int
    6.89 +render_testGetNumRenderDrivers(void *arg)
    6.90 +{
    6.91 +  int n;
    6.92 +  n = SDL_GetNumRenderDrivers();
    6.93 +  SDLTest_AssertCheck(n >= 1, "Number of renderers >= 1, reported as %i", n);
    6.94 +  return TEST_COMPLETED;
    6.95 +}
    6.96 +
    6.97 +
    6.98 +/**
    6.99 + * @brief Tests the SDL primitives for rendering.
   6.100 + *
   6.101 + * \sa
   6.102 + * http://wiki.libsdl.org/moin.cgi/SDL_SetRenderDrawColor
   6.103 + * http://wiki.libsdl.org/moin.cgi/SDL_RenderFillRect
   6.104 + * http://wiki.libsdl.org/moin.cgi/SDL_RenderDrawLine
   6.105 + *
   6.106 + */
   6.107 +int render_testPrimitives (void *arg)
   6.108 +{
   6.109 +   int ret;
   6.110 +   int x, y;
   6.111 +   SDL_Rect rect;
   6.112 +   int checkFailCount1;
   6.113 +   int checkFailCount2;
   6.114 +
   6.115 +   /* Need drawcolour or just skip test. */
   6.116 +   SDLTest_AssertCheck(_hasDrawColor(), "_hasDrawColor");
   6.117 +
   6.118 +   /* Draw a rectangle. */
   6.119 +   rect.x = 40;
   6.120 +   rect.y = 0;
   6.121 +   rect.w = 40;
   6.122 +   rect.h = 80;
   6.123 +
   6.124 +   ret = SDL_SetRenderDrawColor(renderer, 13, 73, 200, SDL_ALPHA_OPAQUE );
   6.125 +   SDLTest_AssertCheck(ret == 0, "Validate result from SDL_SetRenderDrawColor, expected: 0, got: %i", ret);
   6.126 +
   6.127 +   ret = SDL_RenderFillRect(renderer, &rect );
   6.128 +   SDLTest_AssertCheck(ret == 0, "Validate result from SDL_RenderFillRect, expected: 0, got: %i", ret);
   6.129 +
   6.130 +   /* Draw a rectangle. */
   6.131 +   rect.x = 10;
   6.132 +   rect.y = 10;
   6.133 +   rect.w = 60;
   6.134 +   rect.h = 40;
   6.135 +   ret = SDL_SetRenderDrawColor(renderer, 200, 0, 100, SDL_ALPHA_OPAQUE );
   6.136 +   SDLTest_AssertCheck(ret == 0, "Validate result from SDL_SetRenderDrawColor, expected: 0, got: %i", ret);
   6.137 +
   6.138 +   ret = SDL_RenderFillRect(renderer, &rect );
   6.139 +   SDLTest_AssertCheck(ret == 0, "Validate result from SDL_RenderFillRect, expected: 0, got: %i", ret);
   6.140 +
   6.141 +   /* Draw some points like so:
   6.142 +    * X.X.X.X..
   6.143 +    * .X.X.X.X.
   6.144 +    * X.X.X.X.. */
   6.145 +   checkFailCount1 = 0;
   6.146 +   checkFailCount2 = 0;
   6.147 +   for (y=0; y<3; y++) {
   6.148 +      for (x = y % 2; x<TESTRENDER_SCREEN_W; x+=2) {
   6.149 +         ret = SDL_SetRenderDrawColor(renderer, x*y, x*y/2, x*y/3, SDL_ALPHA_OPAQUE );
   6.150 +         if (ret != 0) checkFailCount1++;
   6.151 +
   6.152 +         ret = SDL_RenderDrawPoint(renderer, x, y );
   6.153 +         if (ret != 0) checkFailCount2++;
   6.154 +      }
   6.155 +   }
   6.156 +   SDLTest_AssertCheck(checkFailCount1 == 0, "Validate results from calls to SDL_SetRenderDrawColor, expected: 0, got: %i", checkFailCount1);
   6.157 +   SDLTest_AssertCheck(checkFailCount2 == 0, "Validate results from calls to SDL_RenderDrawPoint, expected: 0, got: %i", checkFailCount2);
   6.158 +
   6.159 +   /* Draw some lines. */
   6.160 +   ret = SDL_SetRenderDrawColor(renderer, 0, 255, 0, SDL_ALPHA_OPAQUE );
   6.161 +   SDLTest_AssertCheck(ret == 0, "Validate result from SDL_SetRenderDrawColor");
   6.162 +
   6.163 +   ret = SDL_RenderDrawLine(renderer, 0, 30, TESTRENDER_SCREEN_W, 30 );
   6.164 +   SDLTest_AssertCheck(ret == 0, "Validate result from SDL_RenderDrawLine, expected: 0, got: %i", ret);
   6.165 +
   6.166 +   ret = SDL_SetRenderDrawColor(renderer, 55, 55, 5, SDL_ALPHA_OPAQUE );
   6.167 +   SDLTest_AssertCheck(ret == 0, "Validate result from SDL_SetRenderDrawColor, expected: 0, got: %i", ret);
   6.168 +
   6.169 +   ret = SDL_RenderDrawLine(renderer, 40, 30, 40, 60 );
   6.170 +   SDLTest_AssertCheck(ret == 0, "Validate result from SDL_RenderDrawLine, expected: 0, got: %i", ret);
   6.171 +
   6.172 +   ret = SDL_SetRenderDrawColor(renderer, 5, 105, 105, SDL_ALPHA_OPAQUE );
   6.173 +   SDLTest_AssertCheck(ret == 0, "Validate result from SDL_SetRenderDrawColor, expected: 0, got: %i", ret);
   6.174 +
   6.175 +   ret = SDL_RenderDrawLine(renderer, 0, 0, 29, 29 );
   6.176 +   SDLTest_AssertCheck(ret == 0, "Validate result from SDL_RenderDrawLine, expected: 0, got: %i", ret);
   6.177 +
   6.178 +   ret = SDL_RenderDrawLine(renderer, 29, 30, 0, 59 );
   6.179 +   SDLTest_AssertCheck(ret == 0, "Validate result from SDL_RenderDrawLine, expected: 0, got: %i", ret);
   6.180 +
   6.181 +   ret = SDL_RenderDrawLine(renderer, 79, 0, 50, 29 );
   6.182 +   SDLTest_AssertCheck(ret == 0, "Validate result from SDL_RenderDrawLine, expected: 0, got: %i", ret);
   6.183 +
   6.184 +   ret = SDL_RenderDrawLine(renderer, 79, 59, 50, 30 );
   6.185 +   SDLTest_AssertCheck(ret == 0, "Validate result from SDL_RenderDrawLine, expected: 0, got: %i", ret);
   6.186 +
   6.187 +   /* See if it's the same. */
   6.188 +   _compare( "Primitives output not the same.", SDLTest_ImagePrimitives(), ALLOWABLE_ERROR_OPAQUE );
   6.189 +
   6.190 +   return TEST_COMPLETED;
   6.191 +}
   6.192 +
   6.193 +/**
   6.194 + * @brief Tests the SDL primitives with alpha for rendering.
   6.195 + *
   6.196 + * \sa
   6.197 + * http://wiki.libsdl.org/moin.cgi/SDL_SetRenderDrawColor
   6.198 + * http://wiki.libsdl.org/moin.cgi/SDL_SetRenderDrawBlendMode
   6.199 + * http://wiki.libsdl.org/moin.cgi/SDL_RenderFillRect
   6.200 + */
   6.201 +int render_testPrimitivesBlend (void *arg)
   6.202 +{
   6.203 +   int ret;
   6.204 +   int i, j;
   6.205 +   SDL_Rect rect;
   6.206 +   int checkFailCount1;
   6.207 +   int checkFailCount2;
   6.208 +   int checkFailCount3;
   6.209 +
   6.210 +   /* Need drawcolour and blendmode or just skip test. */
   6.211 +   SDLTest_AssertCheck(_hasDrawColor(), "_hasDrawColor");
   6.212 +   SDLTest_AssertCheck(_hasBlendModes(), "_hasBlendModes");
   6.213 +
   6.214 +   /* Create some rectangles for each blend mode. */
   6.215 +   ret = SDL_SetRenderDrawColor(renderer, 255, 255, 255, 0 );
   6.216 +   SDLTest_AssertCheck(ret == 0, "Validate result from SDL_SetRenderDrawColor, expected: 0, got: %i", ret);
   6.217 +
   6.218 +   ret = SDL_SetRenderDrawBlendMode(renderer, SDL_BLENDMODE_NONE );
   6.219 +   SDLTest_AssertCheck(ret == 0, "Validate result from SDL_SetRenderDrawBlendMode, expected: 0, got: %i", ret);
   6.220 +
   6.221 +   ret = SDL_RenderFillRect(renderer, NULL );
   6.222 +   SDLTest_AssertCheck(ret == 0, "Validate result from SDL_RenderFillRect, expected: 0, got: %i", ret);
   6.223 +
   6.224 +   rect.x = 10;
   6.225 +   rect.y = 25;
   6.226 +   rect.w = 40;
   6.227 +   rect.h = 25;
   6.228 +   ret = SDL_SetRenderDrawColor(renderer, 240, 10, 10, 75 );
   6.229 +   SDLTest_AssertCheck(ret == 0, "Validate result from SDL_SetRenderDrawColor, expected: 0, got: %i", ret);
   6.230 +
   6.231 +   ret = SDL_SetRenderDrawBlendMode(renderer, SDL_BLENDMODE_ADD );
   6.232 +   SDLTest_AssertCheck(ret == 0, "Validate result from SDL_SetRenderDrawBlendMode, expected: 0, got: %i", ret);
   6.233 +
   6.234 +   ret = SDL_RenderFillRect(renderer, &rect );
   6.235 +   SDLTest_AssertCheck(ret == 0, "Validate result from SDL_RenderFillRect, expected: 0, got: %i", ret);
   6.236 +
   6.237 +   rect.x = 30;
   6.238 +   rect.y = 40;
   6.239 +   rect.w = 45;
   6.240 +   rect.h = 15;
   6.241 +   ret = SDL_SetRenderDrawColor(renderer, 10, 240, 10, 100 );
   6.242 +   SDLTest_AssertCheck(ret == 0, "Validate result from SDL_SetRenderDrawColor, expected: 0, got: %i", ret);
   6.243 +
   6.244 +   ret = SDL_SetRenderDrawBlendMode(renderer, SDL_BLENDMODE_BLEND );
   6.245 +   SDLTest_AssertCheck(ret == 0, "Validate result from SDL_SetRenderDrawBlendMode, expected: 0, got: %i", ret);
   6.246 +
   6.247 +   ret = SDL_RenderFillRect(renderer, &rect );
   6.248 +   SDLTest_AssertCheck(ret == 0, "Validate result from SDL_RenderFillRect, expected: 0, got: %i", ret);
   6.249 +
   6.250 +   rect.x = 25;
   6.251 +   rect.y = 25;
   6.252 +   rect.w = 25;
   6.253 +   rect.h = 25;
   6.254 +   ret = SDL_SetRenderDrawColor(renderer, 10, 10, 240, 125 );
   6.255 +   SDLTest_AssertCheck(ret == 0, "Validate result from SDL_SetRenderDrawColor, expected: 0, got: %i", ret);
   6.256 +
   6.257 +   ret = SDL_SetRenderDrawBlendMode(renderer, SDL_BLENDMODE_NONE );
   6.258 +   SDLTest_AssertCheck(ret == 0, "Validate result from SDL_SetRenderDrawBlendMode, expected: 0, got: %i", ret);
   6.259 +
   6.260 +   ret = SDL_RenderFillRect(renderer, &rect );
   6.261 +   SDLTest_AssertCheck(ret == 0, "Validate result from SDL_RenderFillRect, expected: 0, got: %i", ret);
   6.262 +
   6.263 +
   6.264 +   /* Draw blended lines, lines for everyone. */
   6.265 +   checkFailCount1 = 0;
   6.266 +   checkFailCount2 = 0;
   6.267 +   checkFailCount3 = 0;
   6.268 +   for (i=0; i<TESTRENDER_SCREEN_W; i+=2)  {
   6.269 +      ret = SDL_SetRenderDrawColor(renderer, 60+2*i, 240-2*i, 50, 3*i );
   6.270 +      if (ret != 0) checkFailCount1++;
   6.271 +
   6.272 +      ret = SDL_SetRenderDrawBlendMode(renderer,(((i/2)%3)==0) ? SDL_BLENDMODE_BLEND :
   6.273 +            (((i/2)%3)==1) ? SDL_BLENDMODE_ADD : SDL_BLENDMODE_NONE );
   6.274 +      if (ret != 0) checkFailCount2++;
   6.275 +
   6.276 +      ret = SDL_RenderDrawLine(renderer, 0, 0, i, 59 );
   6.277 +      if (ret != 0) checkFailCount3++;
   6.278 +   }
   6.279 +   SDLTest_AssertCheck(checkFailCount1 == 0, "Validate results from calls to SDL_SetRenderDrawColor, expected: 0, got: %i", checkFailCount1);
   6.280 +   SDLTest_AssertCheck(checkFailCount2 == 0, "Validate results from calls to SDL_SetRenderDrawBlendMode, expected: 0, got: %i", checkFailCount2);
   6.281 +   SDLTest_AssertCheck(checkFailCount3 == 0, "Validate results from calls to SDL_RenderDrawLine, expected: 0, got: %i", checkFailCount3);
   6.282 +   
   6.283 +   checkFailCount1 = 0;
   6.284 +   checkFailCount2 = 0;
   6.285 +   checkFailCount3 = 0;
   6.286 +   for (i=0; i<TESTRENDER_SCREEN_H; i+=2)  {
   6.287 +      ret = SDL_SetRenderDrawColor(renderer, 60+2*i, 240-2*i, 50, 3*i );
   6.288 +      if (ret != 0) checkFailCount1++;
   6.289 +
   6.290 +      ret = SDL_SetRenderDrawBlendMode(renderer,(((i/2)%3)==0) ? SDL_BLENDMODE_BLEND :
   6.291 +            (((i/2)%3)==1) ? SDL_BLENDMODE_ADD : SDL_BLENDMODE_NONE );
   6.292 +      if (ret != 0) checkFailCount2++;
   6.293 +
   6.294 +      ret = SDL_RenderDrawLine(renderer, 0, 0, 79, i );
   6.295 +      if (ret != 0) checkFailCount3++;
   6.296 +   }
   6.297 +   SDLTest_AssertCheck(checkFailCount1 == 0, "Validate results from calls to SDL_SetRenderDrawColor, expected: 0, got: %i", checkFailCount1);
   6.298 +   SDLTest_AssertCheck(checkFailCount2 == 0, "Validate results from calls to SDL_SetRenderDrawBlendMode, expected: 0, got: %i", checkFailCount2);
   6.299 +   SDLTest_AssertCheck(checkFailCount3 == 0, "Validate results from calls to SDL_RenderDrawLine, expected: 0, got: %i", checkFailCount3);
   6.300 +
   6.301 +   /* Draw points. */
   6.302 +   checkFailCount1 = 0;
   6.303 +   checkFailCount2 = 0;
   6.304 +   checkFailCount3 = 0;
   6.305 +   for (j=0; j<TESTRENDER_SCREEN_H; j+=3) {
   6.306 +      for (i=0; i<TESTRENDER_SCREEN_W; i+=3) {
   6.307 +         ret = SDL_SetRenderDrawColor(renderer, j*4, i*3, j*4, i*3 );
   6.308 +         if (ret != 0) checkFailCount1++;
   6.309 +
   6.310 +         ret = SDL_SetRenderDrawBlendMode(renderer, ((((i+j)/3)%3)==0) ? SDL_BLENDMODE_BLEND :
   6.311 +               ((((i+j)/3)%3)==1) ? SDL_BLENDMODE_ADD : SDL_BLENDMODE_NONE );
   6.312 +         if (ret != 0) checkFailCount2++;
   6.313 +
   6.314 +         ret = SDL_RenderDrawPoint(renderer, i, j );
   6.315 +         if (ret != 0) checkFailCount3++;
   6.316 +      }
   6.317 +   }   
   6.318 +   SDLTest_AssertCheck(checkFailCount1 == 0, "Validate results from calls to SDL_SetRenderDrawColor, expected: 0, got: %i", checkFailCount1);
   6.319 +   SDLTest_AssertCheck(checkFailCount2 == 0, "Validate results from calls to SDL_SetRenderDrawBlendMode, expected: 0, got: %i", checkFailCount2);
   6.320 +   SDLTest_AssertCheck(checkFailCount3 == 0, "Validate results from calls to SDL_RenderDrawPoint, expected: 0, got: %i", checkFailCount3);
   6.321 +
   6.322 +   /* See if it's the same. */
   6.323 +   _compare( "Blended primitives output not the same.", SDLTest_ImagePrimitivesBlend(), ALLOWABLE_ERROR_BLENDED );
   6.324 +
   6.325 +    return TEST_COMPLETED;
   6.326 +}
   6.327 +
   6.328 +
   6.329 +
   6.330 +/**
   6.331 + * @brief Tests some blitting routines.
   6.332 + *
   6.333 + * \sa
   6.334 + * http://wiki.libsdl.org/moin.cgi/SDL_RenderCopy
   6.335 + * http://wiki.libsdl.org/moin.cgi/SDL_DestroyTexture
   6.336 + */
   6.337 +int
   6.338 +render_testBlit(void *arg)
   6.339 +{
   6.340 +   int ret;
   6.341 +   SDL_Rect rect;
   6.342 +   SDL_Texture *tface;
   6.343 +   Uint32 tformat;
   6.344 +   int taccess, tw, th;
   6.345 +   int i, j, ni, nj;
   6.346 +   int checkFailCount1;
   6.347 +
   6.348 +
   6.349 +   /* Need drawcolour or just skip test. */
   6.350 +   SDLTest_AssertCheck(_hasDrawColor(), "_hasDrawColor)");
   6.351 +
   6.352 +   /* Create face surface. */
   6.353 +   tface = _loadTestFace();
   6.354 +   SDLTest_AssertCheck(tface != NULL,  "Verify _loadTestFace() result");
   6.355 +   if (tface == NULL) {
   6.356 +       return TEST_ABORTED;
   6.357 +   }
   6.358 +
   6.359 +   /* Constant values. */
   6.360 +   ret = SDL_QueryTexture(tface, &tformat, &taccess, &tw, &th);
   6.361 +   SDLTest_AssertCheck(ret == 0, "Verify result from SDL_QueryTexture, expected 0, got %i", ret);
   6.362 +   rect.w = tw;
   6.363 +   rect.h = th;
   6.364 +   ni     = TESTRENDER_SCREEN_W - tw;
   6.365 +   nj     = TESTRENDER_SCREEN_H - th;
   6.366 +
   6.367 +   /* Loop blit. */
   6.368 +   checkFailCount1 = 0;
   6.369 +   for (j=0; j <= nj; j+=4) {
   6.370 +      for (i=0; i <= ni; i+=4) {
   6.371 +         /* Blitting. */
   6.372 +         rect.x = i;
   6.373 +         rect.y = j;
   6.374 +         ret = SDL_RenderCopy(renderer, tface, NULL, &rect );
   6.375 +         if (ret != 0) checkFailCount1++;
   6.376 +      }
   6.377 +   }
   6.378 +   SDLTest_AssertCheck(checkFailCount1 == 0, "Validate results from calls to SDL_RenderCopy, expected: 0, got: %i", checkFailCount1);
   6.379 +
   6.380 +   /* Clean up. */
   6.381 +   SDL_DestroyTexture( tface );
   6.382 +
   6.383 +   /* See if it's the same */
   6.384 +   _compare( "Blit output not the same.", SDLTest_ImageBlit(), ALLOWABLE_ERROR_OPAQUE );
   6.385 +
   6.386 +   return TEST_COMPLETED;
   6.387 +}
   6.388 +
   6.389 +
   6.390 +/**
   6.391 + * @brief Blits doing colour tests.
   6.392 + *
   6.393 + * \sa
   6.394 + * http://wiki.libsdl.org/moin.cgi/SDL_SetTextureColorMod
   6.395 + * http://wiki.libsdl.org/moin.cgi/SDL_RenderCopy
   6.396 + * http://wiki.libsdl.org/moin.cgi/SDL_DestroyTexture
   6.397 + */
   6.398 +int
   6.399 +render_testBlitColor (void *arg)
   6.400 +{
   6.401 +   int ret;
   6.402 +   SDL_Rect rect;
   6.403 +   SDL_Texture *tface;
   6.404 +   Uint32 tformat;
   6.405 +   int taccess, tw, th;
   6.406 +   int i, j, ni, nj;
   6.407 +   int checkFailCount1;
   6.408 +   int checkFailCount2;
   6.409 +
   6.410 +   /* Create face surface. */
   6.411 +   tface = _loadTestFace();
   6.412 +   SDLTest_AssertCheck(tface != NULL, "Verify _loadTestFace() result");
   6.413 +   if (tface == NULL) {
   6.414 +       return TEST_ABORTED;
   6.415 +   }
   6.416 +
   6.417 +   /* Constant values. */
   6.418 +   ret = SDL_QueryTexture(tface, &tformat, &taccess, &tw, &th);
   6.419 +   SDLTest_AssertCheck(ret == 0, "Verify result from SDL_QueryTexture, expected 0, got %i", ret);
   6.420 +   rect.w = tw;
   6.421 +   rect.h = th;
   6.422 +   ni     = TESTRENDER_SCREEN_W - tw;
   6.423 +   nj     = TESTRENDER_SCREEN_H - th;
   6.424 +
   6.425 +   /* Test blitting with colour mod. */
   6.426 +   checkFailCount1 = 0;
   6.427 +   checkFailCount2 = 0;
   6.428 +   for (j=0; j <= nj; j+=4) {
   6.429 +      for (i=0; i <= ni; i+=4) {
   6.430 +         /* Set colour mod. */
   6.431 +         ret = SDL_SetTextureColorMod( tface, (255/nj)*j, (255/ni)*i, (255/nj)*j );
   6.432 +         if (ret != 0) checkFailCount1++;
   6.433 +
   6.434 +         /* Blitting. */
   6.435 +         rect.x = i;
   6.436 +         rect.y = j;
   6.437 +         ret = SDL_RenderCopy(renderer, tface, NULL, &rect );
   6.438 +         if (ret != 0) checkFailCount2++;
   6.439 +      }
   6.440 +   }
   6.441 +   SDLTest_AssertCheck(checkFailCount1 == 0, "Validate results from calls to SDL_SetTextureColorMod, expected: 0, got: %i", checkFailCount1);
   6.442 +   SDLTest_AssertCheck(checkFailCount2 == 0, "Validate results from calls to SDL_RenderCopy, expected: 0, got: %i", checkFailCount2);
   6.443 +
   6.444 +   /* Clean up. */
   6.445 +   SDL_DestroyTexture( tface );
   6.446 +
   6.447 +   /* See if it's the same. */
   6.448 +   _compare( "Blit output not the same (using SDL_SetTextureColorMod).",
   6.449 +            SDLTest_ImageBlitColor(), ALLOWABLE_ERROR_OPAQUE );
   6.450 +
   6.451 +   return TEST_COMPLETED;
   6.452 +}
   6.453 +
   6.454 +
   6.455 +/**
   6.456 + * @brief Tests blitting with alpha.
   6.457 + *
   6.458 + * \sa
   6.459 + * http://wiki.libsdl.org/moin.cgi/SDL_SetTextureAlphaMod
   6.460 + * http://wiki.libsdl.org/moin.cgi/SDL_RenderCopy
   6.461 + * http://wiki.libsdl.org/moin.cgi/SDL_DestroyTexture
   6.462 + */
   6.463 +int
   6.464 +render_testBlitAlpha (void *arg)
   6.465 +{
   6.466 +   int ret;
   6.467 +   SDL_Rect rect;
   6.468 +   SDL_Texture *tface;
   6.469 +   Uint32 tformat;
   6.470 +   int taccess, tw, th;
   6.471 +   int i, j, ni, nj;
   6.472 +   int checkFailCount1;
   6.473 +   int checkFailCount2;
   6.474 +
   6.475 +
   6.476 +   /* Need alpha or just skip test. */
   6.477 +   SDLTest_AssertCheck(_hasTexAlpha(), "_hasTexAlpha");
   6.478 +
   6.479 +   /* Create face surface. */
   6.480 +   tface = _loadTestFace();
   6.481 +   SDLTest_AssertCheck(tface != NULL, "Verify _loadTestFace() result");
   6.482 +   if (tface == NULL) {
   6.483 +       return TEST_ABORTED;
   6.484 +   }
   6.485 +
   6.486 +   /* Constant values. */
   6.487 +   ret = SDL_QueryTexture(tface, &tformat, &taccess, &tw, &th);
   6.488 +   SDLTest_AssertCheck(ret == 0, "Verify result from SDL_QueryTexture, expected 0, got %i", ret);
   6.489 +   rect.w = tw;
   6.490 +   rect.h = th;
   6.491 +   ni     = TESTRENDER_SCREEN_W - tw;
   6.492 +   nj     = TESTRENDER_SCREEN_H - th;
   6.493 +
   6.494 +   /* Test blitting with alpha mod. */
   6.495 +   checkFailCount1 = 0;
   6.496 +   checkFailCount2 = 0;
   6.497 +   for (j=0; j <= nj; j+=4) {
   6.498 +      for (i=0; i <= ni; i+=4) {
   6.499 +         /* Set alpha mod. */
   6.500 +         ret = SDL_SetTextureAlphaMod( tface, (255/ni)*i );
   6.501 +         if (ret != 0) checkFailCount1++;
   6.502 +
   6.503 +         /* Blitting. */
   6.504 +         rect.x = i;
   6.505 +         rect.y = j;
   6.506 +         ret = SDL_RenderCopy(renderer, tface, NULL, &rect );
   6.507 +         if (ret != 0) checkFailCount2++;
   6.508 +      }
   6.509 +   }   
   6.510 +   SDLTest_AssertCheck(checkFailCount1 == 0, "Validate results from calls to SDL_SetTextureAlphaMod, expected: 0, got: %i", checkFailCount1);
   6.511 +   SDLTest_AssertCheck(checkFailCount2 == 0, "Validate results from calls to SDL_RenderCopy, expected: 0, got: %i", checkFailCount2);
   6.512 +
   6.513 +   /* Clean up. */
   6.514 +   SDL_DestroyTexture( tface );
   6.515 +
   6.516 +   /* See if it's the same. */
   6.517 +   _compare( "Blit output not the same (using SDL_SetSurfaceAlphaMod).",
   6.518 +            SDLTest_ImageBlitAlpha(), ALLOWABLE_ERROR_BLENDED );
   6.519 +
   6.520 +   return TEST_COMPLETED;
   6.521 +}
   6.522 +
   6.523 +/* Helper functions */
   6.524 +
   6.525 +/**
   6.526 + * @brief Tests a blend mode.
   6.527 + *
   6.528 + * \sa
   6.529 + * http://wiki.libsdl.org/moin.cgi/SDL_SetTextureBlendMode
   6.530 + * http://wiki.libsdl.org/moin.cgi/SDL_RenderCopy
   6.531 + */
   6.532 +static void
   6.533 +_testBlitBlendMode( SDL_Texture * tface, int mode )
   6.534 +{
   6.535 +   int ret;
   6.536 +   Uint32 tformat;
   6.537 +   int taccess, tw, th;
   6.538 +   int i, j, ni, nj;
   6.539 +   SDL_Rect rect;
   6.540 +   int checkFailCount1;
   6.541 +   int checkFailCount2;
   6.542 +
   6.543 +   /* Clear surface. */
   6.544 +   _clearScreen();
   6.545 +
   6.546 +   /* Constant values. */
   6.547 +   ret = SDL_QueryTexture(tface, &tformat, &taccess, &tw, &th);
   6.548 +   SDLTest_AssertCheck(ret == 0, "Verify result from SDL_QueryTexture, expected 0, got %i", ret);
   6.549 +   rect.w = tw;
   6.550 +   rect.h = th;
   6.551 +   ni     = TESTRENDER_SCREEN_W - tw;
   6.552 +   nj     = TESTRENDER_SCREEN_H - th;
   6.553 +
   6.554 +   /* Test blend mode. */
   6.555 +   checkFailCount1 = 0;
   6.556 +   checkFailCount2 = 0;
   6.557 +   for (j=0; j <= nj; j+=4) {
   6.558 +      for (i=0; i <= ni; i+=4) {
   6.559 +         /* Set blend mode. */
   6.560 +         ret = SDL_SetTextureBlendMode( tface, (SDL_BlendMode)mode );
   6.561 +         if (ret != 0) checkFailCount1++;
   6.562 +
   6.563 +         /* Blitting. */
   6.564 +         rect.x = i;
   6.565 +         rect.y = j;
   6.566 +         ret = SDL_RenderCopy(renderer, tface, NULL, &rect );
   6.567 +         if (ret != 0) checkFailCount2++;
   6.568 +      }
   6.569 +   }
   6.570 +   SDLTest_AssertCheck(checkFailCount1 == 0, "Validate results from calls to SDL_SetTextureBlendMode, expected: 0, got: %i", checkFailCount1);
   6.571 +   SDLTest_AssertCheck(checkFailCount2 == 0, "Validate results from calls to SDL_RenderCopy, expected: 0, got: %i", checkFailCount2);
   6.572 +}
   6.573 +
   6.574 +
   6.575 +/**
   6.576 + * @brief Tests some more blitting routines.
   6.577 + *
   6.578 + * \sa
   6.579 + * http://wiki.libsdl.org/moin.cgi/SDL_SetTextureColorMod
   6.580 + * http://wiki.libsdl.org/moin.cgi/SDL_SetTextureAlphaMod
   6.581 + * http://wiki.libsdl.org/moin.cgi/SDL_SetTextureBlendMode
   6.582 + * http://wiki.libsdl.org/moin.cgi/SDL_DestroyTexture
   6.583 + */
   6.584 +int
   6.585 +render_testBlitBlend (void *arg)
   6.586 +{
   6.587 +   int ret;
   6.588 +   SDL_Rect rect;
   6.589 +   SDL_Texture *tface;
   6.590 +   Uint32 tformat;
   6.591 +   int taccess, tw, th;
   6.592 +   int i, j, ni, nj;
   6.593 +   int mode;
   6.594 +   int checkFailCount1;
   6.595 +   int checkFailCount2;
   6.596 +   int checkFailCount3;
   6.597 +   int checkFailCount4;
   6.598 +
   6.599 +   SDLTest_AssertCheck(_hasBlendModes(), "_hasBlendModes");
   6.600 +   SDLTest_AssertCheck(_hasTexColor(), "_hasTexColor");
   6.601 +   SDLTest_AssertCheck(_hasTexAlpha(), "_hasTexAlpha");
   6.602 +
   6.603 +   /* Create face surface. */
   6.604 +   tface = _loadTestFace();
   6.605 +   SDLTest_AssertCheck(tface != NULL, "Verify _loadTestFace() result");
   6.606 +   if (tface == NULL) {
   6.607 +       return TEST_ABORTED;
   6.608 +   }
   6.609 +
   6.610 +   /* Constant values. */
   6.611 +   ret = SDL_QueryTexture(tface, &tformat, &taccess, &tw, &th);
   6.612 +   SDLTest_AssertCheck(ret == 0, "Verify result from SDL_QueryTexture, expected 0, got %i", ret);
   6.613 +   rect.w = tw;
   6.614 +   rect.h = th;
   6.615 +   ni = TESTRENDER_SCREEN_W - tw;
   6.616 +   nj = TESTRENDER_SCREEN_H - th;
   6.617 +
   6.618 +   /* Set alpha mod. */
   6.619 +   ret = SDL_SetTextureAlphaMod( tface, 100 );
   6.620 +   SDLTest_AssertCheck(ret == 0, "Validate result from SDL_SetTextureAlphaMod, expected: 0, got: %i", ret);
   6.621 +
   6.622 +   /* Test None. */
   6.623 +   _testBlitBlendMode( tface, SDL_BLENDMODE_NONE );
   6.624 +   /* See if it's the same. */
   6.625 +   _compare( "Blit blending output not the same (using SDL_BLENDMODE_NONE).",
   6.626 +            SDLTest_ImageBlitBlendNone(), ALLOWABLE_ERROR_OPAQUE ); 
   6.627 +
   6.628 +
   6.629 +   /* Test Blend. */
   6.630 +   _testBlitBlendMode( tface, SDL_BLENDMODE_BLEND );
   6.631 +   _compare( "Blit blending output not the same (using SDL_BLENDMODE_BLEND).",
   6.632 +            SDLTest_ImageBlitBlend(), ALLOWABLE_ERROR_BLENDED );
   6.633 +
   6.634 +
   6.635 +   /* Test Add. */
   6.636 +   _testBlitBlendMode( tface, SDL_BLENDMODE_ADD );
   6.637 +   _compare( "Blit blending output not the same (using SDL_BLENDMODE_ADD).",
   6.638 +            SDLTest_ImageBlitBlendAdd(), ALLOWABLE_ERROR_BLENDED );
   6.639 +
   6.640 +   /* Test Mod. */
   6.641 +   _testBlitBlendMode( tface, SDL_BLENDMODE_MOD);
   6.642 +   _compare( "Blit blending output not the same (using SDL_BLENDMODE_MOD).",
   6.643 +            SDLTest_ImageBlitBlendMod(), ALLOWABLE_ERROR_BLENDED );
   6.644 +
   6.645 +   /* Clear surface. */
   6.646 +   _clearScreen();
   6.647 +
   6.648 +   /* Loop blit. */
   6.649 +   checkFailCount1 = 0;
   6.650 +   checkFailCount2 = 0;
   6.651 +   checkFailCount3 = 0;
   6.652 +   checkFailCount4 = 0;
   6.653 +   for (j=0; j <= nj; j+=4) {
   6.654 +      for (i=0; i <= ni; i+=4) {
   6.655 +
   6.656 +         /* Set colour mod. */
   6.657 +         ret = SDL_SetTextureColorMod( tface, (255/nj)*j, (255/ni)*i, (255/nj)*j );
   6.658 +         if (ret != 0) checkFailCount1++;
   6.659 +
   6.660 +         /* Set alpha mod. */
   6.661 +         ret = SDL_SetTextureAlphaMod( tface, (100/ni)*i );
   6.662 +         if (ret != 0) checkFailCount2++;
   6.663 +
   6.664 +         /* Crazy blending mode magic. */
   6.665 +         mode = (i/4*j/4) % 4;
   6.666 +         if (mode==0) mode = SDL_BLENDMODE_NONE;
   6.667 +         else if (mode==1) mode = SDL_BLENDMODE_BLEND;
   6.668 +         else if (mode==2) mode = SDL_BLENDMODE_ADD;
   6.669 +         else if (mode==3) mode = SDL_BLENDMODE_MOD;
   6.670 +         ret = SDL_SetTextureBlendMode( tface, (SDL_BlendMode)mode );
   6.671 +         if (ret != 0) checkFailCount3++;
   6.672 +
   6.673 +         /* Blitting. */
   6.674 +         rect.x = i;
   6.675 +         rect.y = j;
   6.676 +         ret = SDL_RenderCopy(renderer, tface, NULL, &rect );
   6.677 +         if (ret != 0) checkFailCount4++;
   6.678 +      }
   6.679 +   }
   6.680 +   SDLTest_AssertCheck(checkFailCount1 == 0, "Validate results from calls to SDL_SetTextureColorMod, expected: 0, got: %i", checkFailCount1);
   6.681 +   SDLTest_AssertCheck(checkFailCount2 == 0, "Validate results from calls to SDL_SetTextureAlphaMod, expected: 0, got: %i", checkFailCount2);
   6.682 +   SDLTest_AssertCheck(checkFailCount3 == 0, "Validate results from calls to SDL_SetTextureBlendMode, expected: 0, got: %i", checkFailCount3);
   6.683 +   SDLTest_AssertCheck(checkFailCount4 == 0, "Validate results from calls to SDL_RenderCopy, expected: 0, got: %i", checkFailCount4);
   6.684 +
   6.685 +   /* Clean up. */
   6.686 +   SDL_DestroyTexture( tface );
   6.687 +
   6.688 +   /* Check to see if matches. */
   6.689 +   _compare( "Blit blending output not the same (using SDL_BLENDMODE_*).",
   6.690 +            SDLTest_ImageBlitBlendAll(), ALLOWABLE_ERROR_BLENDED);
   6.691 +
   6.692 +   return TEST_COMPLETED;
   6.693 +}
   6.694 +
   6.695 +
   6.696 +
   6.697 +/**
   6.698 + * @brief Checks to see if functionality is supported. Helper function.
   6.699 + */
   6.700 +static int
   6.701 +_isSupported( int code )
   6.702 +{
   6.703 +   return (code == 0);
   6.704 +}
   6.705 +
   6.706 +/**
   6.707 + * @brief Test to see if we can vary the draw colour. Helper function.
   6.708 + *
   6.709 + * \sa
   6.710 + * http://wiki.libsdl.org/moin.cgi/SDL_SetRenderDrawColor
   6.711 + * http://wiki.libsdl.org/moin.cgi/SDL_GetRenderDrawColor
   6.712 + */
   6.713 +static int
   6.714 +_hasDrawColor (void)
   6.715 +{
   6.716 +   int ret, fail;
   6.717 +   Uint8 r, g, b, a;
   6.718 +
   6.719 +   fail = 0;
   6.720 +
   6.721 +   /* Set colour. */
   6.722 +   ret = SDL_SetRenderDrawColor(renderer, 100, 100, 100, 100 );
   6.723 +   if (!_isSupported(ret))
   6.724 +      fail = 1;
   6.725 +   ret = SDL_GetRenderDrawColor(renderer, &r, &g, &b, &a );
   6.726 +   if (!_isSupported(ret))
   6.727 +      fail = 1;
   6.728 +   /* Restore natural. */
   6.729 +   ret = SDL_SetRenderDrawColor(renderer, 0, 0, 0, SDL_ALPHA_OPAQUE );
   6.730 +   if (!_isSupported(ret))
   6.731 +      fail = 1;
   6.732 +
   6.733 +   /* Something failed, consider not available. */
   6.734 +   if (fail)
   6.735 +      return 0;
   6.736 +   /* Not set properly, consider failed. */
   6.737 +   else if ((r != 100) || (g != 100) || (b != 100) || (a != 100))
   6.738 +      return 0;
   6.739 +   return 1;
   6.740 +}
   6.741 +
   6.742 +/**
   6.743 + * @brief Test to see if we can vary the blend mode. Helper function.
   6.744 + *
   6.745 + * \sa
   6.746 + * http://wiki.libsdl.org/moin.cgi/SDL_SetRenderDrawBlendMode
   6.747 + * http://wiki.libsdl.org/moin.cgi/SDL_GetRenderDrawBlendMode
   6.748 + */
   6.749 +static int
   6.750 +_hasBlendModes (void)
   6.751 +{
   6.752 +   int fail;
   6.753 +   int ret;
   6.754 +   SDL_BlendMode mode;
   6.755 +
   6.756 +   fail = 0;
   6.757 +
   6.758 +   ret = SDL_SetRenderDrawBlendMode(renderer, SDL_BLENDMODE_BLEND );
   6.759 +   if (!_isSupported(ret))
   6.760 +      fail = 1;
   6.761 +   ret = SDL_GetRenderDrawBlendMode(renderer, &mode );
   6.762 +   if (!_isSupported(ret))
   6.763 +      fail = 1;
   6.764 +   ret = (mode != SDL_BLENDMODE_BLEND);
   6.765 +   if (!_isSupported(ret))
   6.766 +      fail = 1;
   6.767 +   ret = SDL_SetRenderDrawBlendMode(renderer, SDL_BLENDMODE_ADD );
   6.768 +   if (!_isSupported(ret))
   6.769 +      fail = 1;
   6.770 +   ret = SDL_GetRenderDrawBlendMode(renderer, &mode );
   6.771 +   if (!_isSupported(ret))
   6.772 +      fail = 1;
   6.773 +   ret = (mode != SDL_BLENDMODE_ADD);
   6.774 +   if (!_isSupported(ret))
   6.775 +      fail = 1;
   6.776 +   ret = SDL_SetRenderDrawBlendMode(renderer, SDL_BLENDMODE_MOD );
   6.777 +   if (!_isSupported(ret))
   6.778 +      fail = 1;
   6.779 +   ret = SDL_GetRenderDrawBlendMode(renderer, &mode );
   6.780 +   if (!_isSupported(ret))
   6.781 +      fail = 1;
   6.782 +   ret = (mode != SDL_BLENDMODE_MOD);
   6.783 +   if (!_isSupported(ret))
   6.784 +      fail = 1;
   6.785 +   ret = SDL_SetRenderDrawBlendMode(renderer, SDL_BLENDMODE_NONE );
   6.786 +   if (!_isSupported(ret))
   6.787 +      fail = 1;
   6.788 +   ret = SDL_GetRenderDrawBlendMode(renderer, &mode );
   6.789 +   if (!_isSupported(ret))
   6.790 +      fail = 1;
   6.791 +   ret = (mode != SDL_BLENDMODE_NONE);
   6.792 +   if (!_isSupported(ret))
   6.793 +      fail = 1;
   6.794 +
   6.795 +   return !fail;
   6.796 +}
   6.797 +
   6.798 +
   6.799 +/**
   6.800 + * @brief Loads the test image 'Face' as texture. Helper function.
   6.801 + *
   6.802 + * \sa
   6.803 + * http://wiki.libsdl.org/moin.cgi/SDL_CreateTextureFromSurface
   6.804 + */
   6.805 +static SDL_Texture *
   6.806 +_loadTestFace(void)
   6.807 +{
   6.808 +   SDL_Surface *face;
   6.809 +   SDL_Texture *tface;
   6.810 +
   6.811 +   face = SDLTest_ImageFace();
   6.812 +   if (face == NULL) {
   6.813 +      return NULL;
   6.814 +   }
   6.815 +   
   6.816 +   tface = SDL_CreateTextureFromSurface(renderer, face);
   6.817 +   if (tface == NULL) {
   6.818 +       SDLTest_LogError("SDL_CreateTextureFromSurface() failed with error: %s", SDL_GetError());
   6.819 +   }
   6.820 +
   6.821 +   SDL_FreeSurface(face);
   6.822 +
   6.823 +   return tface;
   6.824 +}
   6.825 +
   6.826 +
   6.827 +/**
   6.828 + * @brief Test to see if can set texture colour mode. Helper function.
   6.829 + *
   6.830 + * \sa
   6.831 + * http://wiki.libsdl.org/moin.cgi/SDL_SetTextureColorMod
   6.832 + * http://wiki.libsdl.org/moin.cgi/SDL_GetTextureColorMod
   6.833 + * http://wiki.libsdl.org/moin.cgi/SDL_DestroyTexture
   6.834 + */
   6.835 +static int
   6.836 +_hasTexColor (void)
   6.837 +{
   6.838 +   int fail;
   6.839 +   int ret;
   6.840 +   SDL_Texture *tface;
   6.841 +   Uint8 r, g, b;
   6.842 +
   6.843 +   /* Get test face. */
   6.844 +   tface = _loadTestFace();
   6.845 +   if (tface == 0)
   6.846 +      return 0;
   6.847 +
   6.848 +   /* See if supported. */
   6.849 +   fail = 0;
   6.850 +   ret = SDL_SetTextureColorMod( tface, 100, 100, 100 );
   6.851 +   if (!_isSupported(ret))
   6.852 +      fail = 1;
   6.853 +   ret = SDL_GetTextureColorMod( tface, &r, &g, &b );
   6.854 +   if (!_isSupported(ret))
   6.855 +      fail = 1;
   6.856 +
   6.857 +   /* Clean up. */
   6.858 +   SDL_DestroyTexture( tface );
   6.859 +
   6.860 +   if (fail)
   6.861 +      return 0;
   6.862 +   else if ((r != 100) || (g != 100) || (b != 100))
   6.863 +      return 0;
   6.864 +   return 1;
   6.865 +}
   6.866 +
   6.867 +/**
   6.868 + * @brief Test to see if we can vary the alpha of the texture. Helper function.
   6.869 + *
   6.870 + * \sa
   6.871 + *  http://wiki.libsdl.org/moin.cgi/SDL_SetTextureAlphaMod
   6.872 + *  http://wiki.libsdl.org/moin.cgi/SDL_GetTextureAlphaMod
   6.873 + *  http://wiki.libsdl.org/moin.cgi/SDL_DestroyTexture
   6.874 + */
   6.875 +static int
   6.876 +_hasTexAlpha(void)
   6.877 +{
   6.878 +   int fail;
   6.879 +   int ret;
   6.880 +   SDL_Texture *tface;
   6.881 +   Uint8 a;
   6.882 +
   6.883 +   /* Get test face. */
   6.884 +   tface = _loadTestFace();
   6.885 +   if (tface == 0)
   6.886 +      return 0;
   6.887 +
   6.888 +   /* See if supported. */
   6.889 +   fail = 0;
   6.890 +   ret = SDL_SetTextureAlphaMod( tface, 100 );
   6.891 +   if (!_isSupported(ret))
   6.892 +      fail = 1;
   6.893 +   ret = SDL_GetTextureAlphaMod( tface, &a );
   6.894 +   if (!_isSupported(ret))
   6.895 +      fail = 1;
   6.896 +
   6.897 +   /* Clean up. */
   6.898 +   SDL_DestroyTexture( tface );
   6.899 +
   6.900 +   if (fail)
   6.901 +      return 0;
   6.902 +   else if (a != 100)
   6.903 +      return 0;
   6.904 +   return 1;
   6.905 +}
   6.906 +
   6.907 +static _renderCompareCount = 0;
   6.908 +
   6.909 +/**
   6.910 + * @brief Compares screen pixels with image pixels. Helper function.
   6.911 + *
   6.912 + * @param msg Message on failure.
   6.913 + * @param s Image to compare against.
   6.914 + * @return 0 on success.
   6.915 + *
   6.916 + * \sa
   6.917 + * http://wiki.libsdl.org/moin.cgi/SDL_RenderReadPixels
   6.918 + * http://wiki.libsdl.org/moin.cgi/SDL_CreateRGBSurfaceFrom
   6.919 + * http://wiki.libsdl.org/moin.cgi/SDL_FreeSurface
   6.920 + */
   6.921 +static void
   6.922 +_compare(const char *msg, SDL_Surface *s, int allowable_error)
   6.923 +{
   6.924 +   int ret;
   6.925 +   SDL_Rect rect;
   6.926 +   Uint8 pix[4*80*60];
   6.927 +   SDL_Surface *testsur;
   6.928 +   char imageFilename[128];
   6.929 +   char referenceFilename[128];
   6.930 +
   6.931 +   /* Read pixels. */
   6.932 +   /* Explicitly specify the rect in case the window isn't expected size... */
   6.933 +   rect.x = 0;
   6.934 +   rect.y = 0;
   6.935 +   rect.w = 80;
   6.936 +   rect.h = 60;
   6.937 +   ret = SDL_RenderReadPixels(renderer, &rect, RENDER_COMPARE_FORMAT, pix, 80*4 );
   6.938 +   SDLTest_AssertCheck(ret == 0, "Validate result from SDL_RenderReadPixels, expected: 0, got: %i", ret);
   6.939 +
   6.940 +   /* Create surface. */
   6.941 +   testsur = SDL_CreateRGBSurfaceFrom( pix, TESTRENDER_SCREEN_W, TESTRENDER_SCREEN_H, 32, TESTRENDER_SCREEN_W*4,
   6.942 +                                       RENDER_COMPARE_RMASK, RENDER_COMPARE_GMASK, RENDER_COMPARE_BMASK, RENDER_COMPARE_AMASK);
   6.943 +   SDLTest_AssertCheck(testsur != NULL, "Verify result from SDL_CreateRGBSurfaceFrom");
   6.944 +
   6.945 +   /* Compare surface. */
   6.946 +   ret = SDLTest_CompareSurfaces( testsur, s, allowable_error );
   6.947 +   SDLTest_AssertCheck(ret == 0, "Validate result from SDLTest_CompareSurfaces, expected: 0, got: %i", ret);
   6.948 +
   6.949 +   _renderCompareCount++;
   6.950 +   if (ret != 0) {
   6.951 +      SDL_snprintf(imageFilename, 127, "image%i.bmp", _renderCompareCount);
   6.952 +      SDL_SaveBMP(testsur, imageFilename);
   6.953 +      SDL_snprintf(referenceFilename, 127, "reference%i.bmp", _renderCompareCount);
   6.954 +      SDL_SaveBMP(s, referenceFilename);
   6.955 +      SDLTest_LogError("Surfaces from failed comparison saved as %s and %s", imageFilename, referenceFilename);
   6.956 +   }
   6.957 +
   6.958 +   /* Clean up. */
   6.959 +   SDL_FreeSurface( testsur );
   6.960 +}
   6.961 +
   6.962 +/**
   6.963 + * @brief Clears the screen. Helper function.
   6.964 + *
   6.965 + * \sa
   6.966 + * http://wiki.libsdl.org/moin.cgi/SDL_SetRenderDrawColor
   6.967 + * http://wiki.libsdl.org/moin.cgi/SDL_RenderFillRect
   6.968 + * http://wiki.libsdl.org/moin.cgi/SDL_SetRenderDrawBlendMode
   6.969 + */
   6.970 +static int
   6.971 +_clearScreen(void)
   6.972 +{
   6.973 +   int ret;
   6.974 +
   6.975 +   /* Set colour. */
   6.976 +   ret = SDL_SetRenderDrawColor(renderer, 0, 0, 0, SDL_ALPHA_OPAQUE );
   6.977 +   SDLTest_AssertCheck(ret == 0, "Validate result from SDL_SetRenderDrawColor, expected: 0, got: %i", ret);
   6.978 +
   6.979 +   /* Clear screen. */
   6.980 +   ret = SDL_RenderFillRect(renderer, NULL );
   6.981 +   SDLTest_AssertCheck(ret == 0, "Validate result from SDL_RenderFillRect, expected: 0, got: %i", ret);
   6.982 +
   6.983 +   /* Set defaults. */
   6.984 +   ret = SDL_SetRenderDrawBlendMode(renderer, SDL_BLENDMODE_NONE );
   6.985 +   SDLTest_AssertCheck(ret == 0, "Validate result from SDL_SetRenderDrawBlendMode, expected: 0, got: %i", ret);
   6.986 +
   6.987 +   ret = SDL_SetRenderDrawColor(renderer, 255, 255, 255, SDL_ALPHA_OPAQUE );
   6.988 +   SDLTest_AssertCheck(ret == 0, "Validate result from SDL_SetRenderDrawColor, expected: 0, got: %i", ret);
   6.989 +
   6.990 +   return 0;
   6.991 +}
   6.992 +
   6.993 +/* ================= Test References ================== */
   6.994 +
   6.995 +/* Render test cases */
   6.996 +static const SDLTest_TestCaseReference renderTest1 =
   6.997 +		{ (SDLTest_TestCaseFp)render_testGetNumRenderDrivers, "render_testGetNumRenderDrivers", "Tests call to SDL_GetNumRenderDrivers", TEST_ENABLED };
   6.998 +
   6.999 +static const SDLTest_TestCaseReference renderTest2 =
  6.1000 +		{ (SDLTest_TestCaseFp)render_testPrimitives, "render_testPrimitives", "Tests rendering primitives", TEST_ENABLED };
  6.1001 +
  6.1002 +static const SDLTest_TestCaseReference renderTest3 =
  6.1003 +		{ (SDLTest_TestCaseFp)render_testPrimitivesBlend, "render_testPrimitivesBlend", "Tests rendering primitives with blending", TEST_ENABLED };
  6.1004 +
  6.1005 +static const SDLTest_TestCaseReference renderTest4 =
  6.1006 +		{ (SDLTest_TestCaseFp)render_testBlit, "render_testBlit", "Tests blitting", TEST_ENABLED };
  6.1007 +
  6.1008 +static const SDLTest_TestCaseReference renderTest5 =
  6.1009 +		{ (SDLTest_TestCaseFp)render_testBlitColor, "render_testBlitColor", "Tests blitting with color", TEST_ENABLED };
  6.1010 +
  6.1011 +static const SDLTest_TestCaseReference renderTest6 =
  6.1012 +		{ (SDLTest_TestCaseFp)render_testBlitAlpha, "render_testBlitAlpha", "Tests blitting with alpha", TEST_ENABLED };
  6.1013 +
  6.1014 +static const SDLTest_TestCaseReference renderTest7 =
  6.1015 +		{  (SDLTest_TestCaseFp)render_testBlitBlend, "render_testBlitBlend", "Tests blitting with blending", TEST_ENABLED };
  6.1016 +
  6.1017 +/* Sequence of Render test cases */
  6.1018 +static const SDLTest_TestCaseReference *renderTests[] =  {
  6.1019 +	&renderTest1, &renderTest2, &renderTest3, &renderTest4, &renderTest5, &renderTest6, &renderTest7, NULL
  6.1020 +};
  6.1021 +
  6.1022 +/* Render test suite (global) */
  6.1023 +SDLTest_TestSuiteReference renderTestSuite = {
  6.1024 +	"Render",
  6.1025 +	InitCreateRenderer,
  6.1026 +	renderTests,
  6.1027 +	CleanupDestroyRenderer
  6.1028 +};
     7.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     7.2 +++ b/test/testautomation_rwops.c	Sat Dec 22 17:24:42 2012 -0800
     7.3 @@ -0,0 +1,427 @@
     7.4 +/**
     7.5 + * Automated SDL_RWops test.
     7.6 + *
     7.7 + * Original code written by Edgar Simo "bobbens"
     7.8 + * Ported by Markus Kauppila (markus.kauppila@gmail.com)
     7.9 + * Updated for SDL_test by aschiffler at ferzkopp dot net
    7.10 + *
    7.11 + * Released under Public Domain.
    7.12 + */
    7.13 +
    7.14 +/* quiet windows compiler warnings */
    7.15 +#define _CRT_SECURE_NO_WARNINGS
    7.16 +
    7.17 +#include <stdio.h>
    7.18 +
    7.19 +#include "SDL.h"
    7.20 +#include "SDL_test.h"
    7.21 +
    7.22 +/* ================= Test Case Implementation ================== */
    7.23 +
    7.24 +const char* RWopsReadTestFilename = "rwops_read";
    7.25 +const char* RWopsWriteTestFilename = "rwops_write";
    7.26 +
    7.27 +static const char RWopsHelloWorldTestString[] = "Hello World!";
    7.28 +static const char RWopsHelloWorldCompString[] = "Hello World!";
    7.29 +
    7.30 +/* Fixture */
    7.31 +
    7.32 +void
    7.33 +RWopsSetUp(void *arg)
    7.34 +{
    7.35 +	int fileLen = SDL_strlen(RWopsHelloWorldTestString);
    7.36 +	FILE *handle;
    7.37 +	int writtenLen;
    7.38 +	int result;
    7.39 +
    7.40 +	/* Clean up from previous runs (if any); ignore errors */
    7.41 +	remove(RWopsReadTestFilename);
    7.42 +	remove(RWopsWriteTestFilename);
    7.43 +
    7.44 +	/* Create a test file */
    7.45 +	handle = fopen(RWopsReadTestFilename, "w");
    7.46 +	SDLTest_AssertCheck(handle != NULL, "Verify creation of file '%s' returned non NULL handle", RWopsReadTestFilename);
    7.47 +    if (handle == NULL) return;
    7.48 +
    7.49 +	/* Write some known test into it */
    7.50 +	writtenLen = (int)fwrite(RWopsHelloWorldTestString, 1, fileLen, handle);
    7.51 +	SDLTest_AssertCheck(fileLen == writtenLen, "Verify number of written bytes, expected %i, got %i", fileLen, writtenLen);
    7.52 +	result = fclose(handle);
    7.53 +	SDLTest_AssertCheck(result == 0, "Verify result from fclose, expected 0, got %i", result);
    7.54 +
    7.55 +	SDLTest_AssertPass("Creation of test file completed");
    7.56 +}
    7.57 +
    7.58 +void
    7.59 +RWopsTearDown(void *arg)
    7.60 +{
    7.61 +	int result;
    7.62 +	
    7.63 +	/* Remove the created files to clean up; ignore errors for write filename */
    7.64 +	result = remove(RWopsReadTestFilename);
    7.65 +	SDLTest_AssertCheck(result == 0, "Verify result from remove(%s), expected 0, got %i", RWopsReadTestFilename, result);
    7.66 +	remove(RWopsWriteTestFilename);
    7.67 +
    7.68 +	SDLTest_AssertPass("Cleanup of test files completed");
    7.69 +}
    7.70 +
    7.71 +/**
    7.72 + * @brief Makes sure parameters work properly. Local helper function.
    7.73 + *
    7.74 + * \sa
    7.75 + * http://wiki.libsdl.org/moin.cgi/SDL_RWseek
    7.76 + * http://wiki.libsdl.org/moin.cgi/SDL_RWread
    7.77 + */
    7.78 +void 
    7.79 +_testGenericRWopsValidations(SDL_RWops *rw, int write)
    7.80 +{
    7.81 +   char buf[sizeof(RWopsHelloWorldTestString)];
    7.82 +   int i;
    7.83 +   int seekPos = SDLTest_RandomIntegerInRange(4, 8);
    7.84 +
    7.85 +   /* Clear buffer */
    7.86 +   SDL_zero(buf);
    7.87 +
    7.88 +   /* Set to start. */
    7.89 +   i = SDL_RWseek(rw, 0, RW_SEEK_SET );
    7.90 +   SDLTest_AssertPass("Call to SDL_RWseek succeeded");
    7.91 +   SDLTest_AssertCheck(i == 0, "Verify seek to 0 with SDL_RWseek (RW_SEEK_SET), expected 0, got %i", i);
    7.92 +
    7.93 +   /* Test write. */
    7.94 +   i = SDL_RWwrite(rw, RWopsHelloWorldTestString, sizeof(RWopsHelloWorldTestString)-1, 1);
    7.95 +   SDLTest_AssertPass("Call to SDL_RWwrite succeeded");
    7.96 +   if (write) {
    7.97 +		SDLTest_AssertCheck(i == 1, "Verify result of writing one byte with SDL_RWwrite, expected 1, got %i", i);
    7.98 +   }
    7.99 +   else {
   7.100 +		SDLTest_AssertCheck(i <= 0, "Verify result of writing with SDL_RWwrite, expected <=0, got %i", i);
   7.101 +   }
   7.102 +
   7.103 +   /* Test seek to random position */
   7.104 +   i = SDL_RWseek( rw, seekPos, RW_SEEK_SET );
   7.105 +   SDLTest_AssertPass("Call to SDL_RWseek succeeded");
   7.106 +   SDLTest_AssertCheck(i == seekPos, "Verify seek to %i with SDL_RWseek (RW_SEEK_SET), expected %i, got %i", seekPos, seekPos, i);
   7.107 +
   7.108 +   /* Test seek back to start */
   7.109 +   i = SDL_RWseek(rw, 0, RW_SEEK_SET );
   7.110 +   SDLTest_AssertPass("Call to SDL_RWseek succeeded");
   7.111 +   SDLTest_AssertCheck(i == 0, "Verify seek to 0 with SDL_RWseek (RW_SEEK_SET), expected 0, got %i", i);
   7.112 +
   7.113 +   /* Test read */
   7.114 +   i = SDL_RWread( rw, buf, 1, sizeof(RWopsHelloWorldTestString)-1 );
   7.115 +   SDLTest_AssertPass("Call to SDL_RWread succeeded");
   7.116 +   SDLTest_AssertCheck(
   7.117 +	   i == (sizeof(RWopsHelloWorldTestString)-1), 
   7.118 +	   "Verify result from SDL_RWread, expected %i, got %i",
   7.119 +	   sizeof(RWopsHelloWorldTestString)-1,
   7.120 +	   i);
   7.121 +   SDLTest_AssertCheck(
   7.122 +	   SDL_memcmp(buf, RWopsHelloWorldTestString, sizeof(RWopsHelloWorldTestString)-1 ) == 0, 
   7.123 +	   "Verify read bytes match expected string, expected '%s', got '%s'", RWopsHelloWorldTestString, buf);
   7.124 +
   7.125 +   /* More seek tests. */
   7.126 +   i = SDL_RWseek( rw, -4, RW_SEEK_CUR );
   7.127 +   SDLTest_AssertPass("Call to SDL_RWseek(...,-4,RW_SEEK_CUR) succeeded");
   7.128 +   SDLTest_AssertCheck(
   7.129 +	   i == (sizeof(RWopsHelloWorldTestString)-5), 
   7.130 +	   "Verify seek to -4 with SDL_RWseek (RW_SEEK_CUR), expected %i, got %i",
   7.131 +	   sizeof(RWopsHelloWorldTestString)-5,
   7.132 +	   i);
   7.133 +
   7.134 +   i = SDL_RWseek( rw, -1, RW_SEEK_END );
   7.135 +   SDLTest_AssertPass("Call to SDL_RWseek(...,-1,RW_SEEK_END) succeeded");
   7.136 +   SDLTest_AssertCheck(
   7.137 +	   i == (sizeof(RWopsHelloWorldTestString)-2), 
   7.138 +	   "Verify seek to -1 with SDL_RWseek (RW_SEEK_END), expected %i, got %i",
   7.139 +	   sizeof(RWopsHelloWorldTestString)-2,
   7.140 +	   i);
   7.141 +}
   7.142 +
   7.143 +/*!
   7.144 + * Negative test for SDL_RWFromFile parameters
   7.145 + *
   7.146 + * \sa http://wiki.libsdl.org/moin.cgi/SDL_RWFromFile
   7.147 + *
   7.148 + */
   7.149 +int
   7.150 +rwops_testParamNegative (void)
   7.151 +{
   7.152 +   SDL_RWops *rwops;
   7.153 +
   7.154 +   /* These should all fail. */
   7.155 +   rwops = SDL_RWFromFile(NULL, NULL);
   7.156 +   SDLTest_AssertPass("Call to SDL_RWFromFile(NULL, NULL) succeeded");
   7.157 +   SDLTest_AssertCheck(rwops == NULL, "Verify SDL_RWFromFile(NULL, NULL) returns NULL");
   7.158 +
   7.159 +   rwops = SDL_RWFromFile(NULL, "ab+");
   7.160 +   SDLTest_AssertPass("Call to SDL_RWFromFile(NULL, \"ab+\") succeeded");
   7.161 +   SDLTest_AssertCheck(rwops == NULL, "Verify SDL_RWFromFile(NULL, \"ab+\") returns NULL");
   7.162 +
   7.163 +   rwops = SDL_RWFromFile(NULL, "sldfkjsldkfj");
   7.164 +   SDLTest_AssertPass("Call to SDL_RWFromFile(NULL, \"sldfkjsldkfj\") succeeded");
   7.165 +   SDLTest_AssertCheck(rwops == NULL, "Verify SDL_RWFromFile(NULL, \"sldfkjsldkfj\") returns NULL");
   7.166 +
   7.167 +   rwops = SDL_RWFromFile("something", "");
   7.168 +   SDLTest_AssertPass("Call to SDL_RWFromFile(\"something\", \"\") succeeded");
   7.169 +   SDLTest_AssertCheck(rwops == NULL, "Verify SDL_RWFromFile(\"something\", \"\") returns NULL");
   7.170 +
   7.171 +   rwops = SDL_RWFromFile("something", NULL);
   7.172 +   SDLTest_AssertPass("Call to SDL_RWFromFile(\"something\", NULL) succeeded");
   7.173 +   SDLTest_AssertCheck(rwops == NULL, "Verify SDL_RWFromFile(\"something\", NULL) returns NULL");
   7.174 +
   7.175 +   return TEST_COMPLETED;
   7.176 +}
   7.177 +
   7.178 +/**
   7.179 + * @brief Tests opening from memory.
   7.180 + *
   7.181 + * \sa http://wiki.libsdl.org/moin.cgi/SDL_RWFromMem
   7.182 + */
   7.183 +int
   7.184 +rwops_testMem (void)
   7.185 +{
   7.186 +   char mem[sizeof(RWopsHelloWorldTestString)];
   7.187 +   SDL_RWops *rw;
   7.188 +
   7.189 +   /* Clear buffer */
   7.190 +   SDL_zero(mem);
   7.191 +
   7.192 +   /* Open */
   7.193 +   rw = SDL_RWFromMem(mem, sizeof(RWopsHelloWorldTestString)-1);
   7.194 +   SDLTest_AssertPass("Call to SDL_RWFromMem() succeeded");
   7.195 +   SDLTest_AssertCheck(rw != NULL, "Verify opening memory with SDL_RWFromMem does not return NULL");
   7.196 +
   7.197 +   /* Bail out if NULL */
   7.198 +   if (rw == NULL) return TEST_ABORTED;
   7.199 +
   7.200 +   /* Run generic tests */
   7.201 +   _testGenericRWopsValidations(rw, 1);
   7.202 +
   7.203 +   /* Close */
   7.204 +   SDL_RWclose(rw);
   7.205 +   SDLTest_AssertPass("Call to SDL_RWclose() succeeded");
   7.206 +   SDL_FreeRW(rw);
   7.207 +   SDLTest_AssertPass("Call to SDL_FreeRW() succeeded");
   7.208 +
   7.209 +   return TEST_COMPLETED;
   7.210 +}
   7.211 +
   7.212 +
   7.213 +/**
   7.214 + * @brief Tests opening from memory.
   7.215 + *
   7.216 + * \sa
   7.217 + * http://wiki.libsdl.org/moin.cgi/SDL_RWFromConstMem
   7.218 + */
   7.219 +int 
   7.220 +rwops_testConstMem (void)
   7.221 +{
   7.222 +   SDL_RWops *rw;
   7.223 +
   7.224 +   /* Open handle */
   7.225 +   rw = SDL_RWFromConstMem( RWopsHelloWorldCompString, sizeof(RWopsHelloWorldCompString)-1 );
   7.226 +   SDLTest_AssertPass("Call to SDL_RWFromConstMem() succeeded");
   7.227 +   SDLTest_AssertCheck(rw != NULL, "Verify opening memory with SDL_RWFromConstMem does not return NULL");
   7.228 +
   7.229 +   /* Bail out if NULL */
   7.230 +   if (rw == NULL) return TEST_ABORTED;
   7.231 +
   7.232 +   /* Run generic tests */
   7.233 +   _testGenericRWopsValidations( rw, 0 );
   7.234 +
   7.235 +   /* Close handle */
   7.236 +   SDL_RWclose(rw);
   7.237 +   SDLTest_AssertPass("Call to SDL_RWclose() succeeded");
   7.238 +   SDL_FreeRW( rw );
   7.239 +   SDLTest_AssertPass("Call to SDL_FreeRW() succeeded");
   7.240 +
   7.241 +  return TEST_COMPLETED;
   7.242 +}
   7.243 +
   7.244 +
   7.245 +/**
   7.246 + * @brief Tests reading from file.
   7.247 + *
   7.248 + * \sa
   7.249 + * http://wiki.libsdl.org/moin.cgi/SDL_RWFromFile
   7.250 + * http://wiki.libsdl.org/moin.cgi/SDL_FreeRW
   7.251 + */
   7.252 +int
   7.253 +rwops_testFileRead(void)
   7.254 +{
   7.255 +   SDL_RWops *rw;
   7.256 +
   7.257 +   /* Read test. */
   7.258 +   rw = SDL_RWFromFile(RWopsReadTestFilename, "r");
   7.259 +   SDLTest_AssertPass("Call to SDL_RWFromFile(..,\"r\") succeeded");
   7.260 +   SDLTest_AssertCheck(rw != NULL, "Verify opening file with SDL_RWFromFile in read mode does not return NULL");
   7.261 +
   7.262 +   // Bail out if NULL
   7.263 +   if (rw == NULL) return TEST_ABORTED;
   7.264 +
   7.265 +   /* Run generic tests */
   7.266 +   _testGenericRWopsValidations( rw, 0 );
   7.267 +
   7.268 +   /* Close handle */
   7.269 +   SDL_RWclose(rw);
   7.270 +   SDLTest_AssertPass("Call to SDL_RWclose() succeeded");
   7.271 +   SDL_FreeRW( rw );
   7.272 +   SDLTest_AssertPass("Call to SDL_FreeRW() succeeded");
   7.273 +
   7.274 +   return TEST_COMPLETED;
   7.275 +}
   7.276 +
   7.277 +/**
   7.278 + * @brief Tests writing from memory.
   7.279 + *
   7.280 + * \sa
   7.281 + * http://wiki.libsdl.org/moin.cgi/SDL_RWFromFile
   7.282 + * http://wiki.libsdl.org/moin.cgi/SDL_FreeRW
   7.283 + */
   7.284 +int
   7.285 +rwops_testFileWrite(void)
   7.286 +{
   7.287 +   SDL_RWops *rw;
   7.288 +
   7.289 +   /* Write test. */
   7.290 +   rw = SDL_RWFromFile(RWopsWriteTestFilename, "w+");
   7.291 +   SDLTest_AssertPass("Call to SDL_RWFromFile(..,\"w+\") succeeded");
   7.292 +   SDLTest_AssertCheck(rw != NULL, "Verify opening file with SDL_RWFromFile in write mode does not return NULL");
   7.293 +
   7.294 +   // Bail out if NULL
   7.295 +   if (rw == NULL) return TEST_ABORTED;
   7.296 +
   7.297 +   /* Run generic tests */
   7.298 +   _testGenericRWopsValidations( rw, 1 );
   7.299 +
   7.300 +   /* Close handle */
   7.301 +   SDL_RWclose(rw);
   7.302 +   SDLTest_AssertPass("Call to SDL_RWclose() succeeded");
   7.303 +   SDL_FreeRW( rw );
   7.304 +   SDLTest_AssertPass("Call to SDL_FreeRW() succeeded");
   7.305 +
   7.306 +   return TEST_COMPLETED;
   7.307 +}
   7.308 +
   7.309 +
   7.310 +/**
   7.311 + * @brief Tests reading from file handle
   7.312 + *
   7.313 + * \sa
   7.314 + * http://wiki.libsdl.org/moin.cgi/SDL_RWFromFP
   7.315 + * http://wiki.libsdl.org/moin.cgi/SDL_FreeRW
   7.316 + *
   7.317 + */
   7.318 +int
   7.319 +rwops_testFPRead(void)
   7.320 +{
   7.321 +   FILE *fp;
   7.322 +   SDL_RWops *rw;
   7.323 +
   7.324 +   /* Run read tests. */
   7.325 +   fp = fopen(RWopsReadTestFilename, "r");
   7.326 +   SDLTest_AssertCheck(fp != NULL, "Verify handle from opening file '%s' in read mode is not NULL", RWopsReadTestFilename);
   7.327 +
   7.328 +   /* Bail out if NULL */
   7.329 +   if (fp == NULL) return TEST_ABORTED;
   7.330 +
   7.331 +   /* Open */
   7.332 +   rw = SDL_RWFromFP( fp, 1 );
   7.333 +   SDLTest_AssertPass("Call to SDL_RWFromFP() succeeded");
   7.334 +   SDLTest_AssertCheck(rw != NULL, "Verify opening file with SDL_RWFromFP in read mode does not return NULL");
   7.335 +
   7.336 +   /* Bail out if NULL */
   7.337 +   if (rw == NULL) return TEST_ABORTED;
   7.338 +
   7.339 +   /* Run generic tests */
   7.340 +   _testGenericRWopsValidations( rw, 0 );
   7.341 +
   7.342 +   /* Close handle */
   7.343 +   SDL_RWclose(rw);
   7.344 +   SDLTest_AssertPass("Call to SDL_RWclose() succeeded");
   7.345 +   SDL_FreeRW( rw );
   7.346 +   SDLTest_AssertPass("Call to SDL_FreeRW() succeeded");
   7.347 +   fclose(fp);
   7.348 +
   7.349 +   return TEST_COMPLETED;
   7.350 +}
   7.351 +
   7.352 +
   7.353 +/**
   7.354 + * @brief Tests writing to file handle
   7.355 + *
   7.356 + * \sa
   7.357 + * http://wiki.libsdl.org/moin.cgi/SDL_RWFromFP
   7.358 + * http://wiki.libsdl.org/moin.cgi/SDL_FreeRW
   7.359 + *
   7.360 + */
   7.361 +int
   7.362 +rwops_testFPWrite(void)
   7.363 +{
   7.364 +   FILE *fp;
   7.365 +   SDL_RWops *rw;
   7.366 +
   7.367 +   /* Run write tests. */
   7.368 +   fp = fopen(RWopsWriteTestFilename, "w+");
   7.369 +   SDLTest_AssertCheck(fp != NULL, "Verify handle from opening file '%s' in write mode is not NULL", RWopsWriteTestFilename);
   7.370 +
   7.371 +   /* Bail out if NULL */
   7.372 +   if (fp == NULL) return TEST_ABORTED;
   7.373 +
   7.374 +   /* Open */
   7.375 +   rw = SDL_RWFromFP( fp, 1 );
   7.376 +   SDLTest_AssertPass("Call to SDL_RWFromFP() succeeded");
   7.377 +   SDLTest_AssertCheck(rw != NULL, "Verify opening file with SDL_RWFromFP in write mode does not return NULL");
   7.378 +
   7.379 +   /* Bail out if NULL */
   7.380 +   if (rw == NULL) return TEST_ABORTED;
   7.381 +
   7.382 +   /* Run generic tests */
   7.383 +   _testGenericRWopsValidations( rw, 1 );
   7.384 +
   7.385 +   /* Close handle */
   7.386 +   SDL_RWclose(rw);
   7.387 +   SDLTest_AssertPass("Call to SDL_RWclose() succeeded");
   7.388 +   SDL_FreeRW( rw );
   7.389 +   SDLTest_AssertPass("Call to SDL_FreeRW() succeeded");
   7.390 +   fclose(fp);
   7.391 +
   7.392 +   return TEST_COMPLETED;
   7.393 +}
   7.394 +
   7.395 +/* ================= Test References ================== */
   7.396 +
   7.397 +/* RWops test cases */
   7.398 +static const SDLTest_TestCaseReference rwopsTest1 =
   7.399 +		{ (SDLTest_TestCaseFp)rwops_testParamNegative, "rwops_testParamNegative", "Negative test for SDL_RWFromFile parameters", TEST_ENABLED };
   7.400 +
   7.401 +static const SDLTest_TestCaseReference rwopsTest2 =
   7.402 +		{ (SDLTest_TestCaseFp)rwops_testMem, "rwops_testMem", "Tests opening from memory", TEST_ENABLED };
   7.403 +
   7.404 +static const SDLTest_TestCaseReference rwopsTest3 =
   7.405 +		{ (SDLTest_TestCaseFp)rwops_testConstMem, "rwops_testConstMem", "Tests opening from (const) memory", TEST_ENABLED };
   7.406 +
   7.407 +static const SDLTest_TestCaseReference rwopsTest4 =
   7.408 +		{ (SDLTest_TestCaseFp)rwops_testFileRead, "rwops_testFileRead", "Tests reading from a file", TEST_ENABLED };
   7.409 +
   7.410 +static const SDLTest_TestCaseReference rwopsTest5 =
   7.411 +		{ (SDLTest_TestCaseFp)rwops_testFileWrite, "rwops_testFileWrite", "Test writing to a file", TEST_ENABLED };
   7.412 +
   7.413 +static const SDLTest_TestCaseReference rwopsTest6 =
   7.414 +		{ (SDLTest_TestCaseFp)rwops_testFPRead, "rwops_testFPRead", "Test reading from file pointer", TEST_ENABLED };
   7.415 +
   7.416 +static const SDLTest_TestCaseReference rwopsTest7 =
   7.417 +		{ (SDLTest_TestCaseFp)rwops_testFPWrite, "rwops_testFPWrite", "Test writing to file pointer", TEST_ENABLED };
   7.418 +
   7.419 +/* Sequence of RWops test cases */
   7.420 +static const SDLTest_TestCaseReference *rwopsTests[] =  {
   7.421 +	&rwopsTest1, &rwopsTest2, &rwopsTest3, &rwopsTest4, &rwopsTest5, &rwopsTest6, &rwopsTest7, NULL
   7.422 +};
   7.423 +
   7.424 +/* RWops test suite (global) */
   7.425 +SDLTest_TestSuiteReference rwopsTestSuite = {
   7.426 +	"RWops",
   7.427 +	RWopsSetUp,
   7.428 +	rwopsTests,
   7.429 +	RWopsTearDown
   7.430 +};
     8.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     8.2 +++ b/test/testautomation_suites.h	Sat Dec 22 17:24:42 2012 -0800
     8.3 @@ -0,0 +1,40 @@
     8.4 +/**
     8.5 + * Reference to all test suites.
     8.6 + *
     8.7 + */
     8.8 +
     8.9 +#ifndef _testsuites_h
    8.10 +#define _testsuites_h
    8.11 +
    8.12 +#include "SDL_test.h"
    8.13 +
    8.14 +// Test collections
    8.15 +//extern SDLTest_TestSuiteReference audioTestSuite;
    8.16 +extern SDLTest_TestSuiteReference clipboardTestSuite;
    8.17 +//extern SDLTest_TestSuiteReference eventsTestSuite;
    8.18 +//extern SDLTest_TestSuiteReference keyboardTestSuite;
    8.19 +extern SDLTest_TestSuiteReference platformTestSuite;
    8.20 +extern SDLTest_TestSuiteReference rectTestSuite;
    8.21 +extern SDLTest_TestSuiteReference renderTestSuite;
    8.22 +extern SDLTest_TestSuiteReference rwopsTestSuite;
    8.23 +//extern SDLTest_TestSuiteReference surfaceTestSuite;
    8.24 +//extern SDLTest_TestSuiteReference syswmTestSuite;
    8.25 +//extern SDLTest_TestSuiteReference videoTestSuite;
    8.26 +
    8.27 +// All test suites
    8.28 +SDLTest_TestSuiteReference *testSuites[] =  {
    8.29 +//	&audioTestSuite,
    8.30 +	&clipboardTestSuite,
    8.31 +//	&eventsTestSuite,
    8.32 +//	&keyboardTestSuite,
    8.33 +	&platformTestSuite,
    8.34 +	&rectTestSuite,
    8.35 +	&renderTestSuite,
    8.36 +	&rwopsTestSuite,
    8.37 +//	&surfaceTestSuite,
    8.38 +//	&syswmTestSuite,
    8.39 +//	&videoTestSuite,
    8.40 +	NULL
    8.41 +};
    8.42 +
    8.43 +#endif
     9.1 --- a/test/tests/testclipboard.c	Sat Dec 22 17:24:14 2012 -0800
     9.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     9.3 @@ -1,182 +0,0 @@
     9.4 -/**
     9.5 - * New/updated tests: aschiffler at ferzkopp dot net
     9.6 - */
     9.7 -
     9.8 -#include <stdio.h>
     9.9 -#include <string.h>
    9.10 -
    9.11 -#include "SDL.h"
    9.12 -#include "SDL_test.h"
    9.13 -
    9.14 -/* ================= Test Case Implementation ================== */
    9.15 -
    9.16 -/* Test case functions */
    9.17 -
    9.18 -/**
    9.19 - * \brief Check call to SDL_HasClipboardText
    9.20 - *
    9.21 - * \sa
    9.22 - * http://wiki.libsdl.org/moin.cgi/SDL_HasClipboardText
    9.23 - */
    9.24 -int
    9.25 -clipboard_testHasClipboardText(void *arg)
    9.26 -{
    9.27 -	SDL_bool result;
    9.28 -	result = SDL_HasClipboardText();
    9.29 -	SDLTest_AssertPass("Call to SDL_HasClipboardText succeeded");
    9.30 -
    9.31 -    return TEST_COMPLETED;
    9.32 -}
    9.33 -
    9.34 -/**
    9.35 - * \brief Check call to SDL_GetClipboardText
    9.36 - *
    9.37 - * \sa
    9.38 - * http://wiki.libsdl.org/moin.cgi/SDL_GetClipboardText
    9.39 - */
    9.40 -int
    9.41 -clipboard_testGetClipboardText(void *arg)
    9.42 -{
    9.43 -	char *charResult;
    9.44 -	charResult = SDL_GetClipboardText();
    9.45 -	SDLTest_AssertPass("Call to SDL_GetClipboardText succeeded");
    9.46 -
    9.47 -	if (charResult) SDL_free(charResult);
    9.48 -
    9.49 -    return TEST_COMPLETED;
    9.50 -}
    9.51 -
    9.52 -/**
    9.53 - * \brief Check call to SDL_SetClipboardText
    9.54 - * \sa
    9.55 - * http://wiki.libsdl.org/moin.cgi/SDL_SetClipboardText
    9.56 - */
    9.57 -int
    9.58 -clipboard_testSetClipboardText(void *arg)
    9.59 -{
    9.60 -	char *textRef = SDLTest_RandomAsciiString();
    9.61 -	char *text = SDL_strdup(textRef);
    9.62 -	int result;
    9.63 -	result = SDL_SetClipboardText((const char *)text);
    9.64 -	SDLTest_AssertPass("Call to SDL_SetClipboardText succeeded");
    9.65 -	SDLTest_AssertCheck(
    9.66 -		result == 0,
    9.67 -		"Validate SDL_SetClipboardText result, expected 0, got %i",
    9.68 -		result);
    9.69 -	SDLTest_AssertCheck(
    9.70 -		SDL_strcmp(textRef, text) == 0,
    9.71 -		"Verify SDL_SetClipboardText did not modify input string, expected '%s', got '%s'",
    9.72 -		textRef, text);
    9.73 -
    9.74 -    /* Cleanup */
    9.75 -    if (textRef) SDL_free(textRef);
    9.76 -    if (text) SDL_free(text);
    9.77 -
    9.78 -   return TEST_COMPLETED;
    9.79 -}
    9.80 -
    9.81 -/**
    9.82 - * \brief End-to-end test of SDL_xyzClipboardText functions
    9.83 - * \sa
    9.84 - * http://wiki.libsdl.org/moin.cgi/SDL_HasClipboardText
    9.85 - * http://wiki.libsdl.org/moin.cgi/SDL_GetClipboardText
    9.86 - * http://wiki.libsdl.org/moin.cgi/SDL_SetClipboardText
    9.87 - */
    9.88 -int
    9.89 -clipboard_testClipboardTextFunctions(void *arg)
    9.90 -{
    9.91 -	char *textRef = SDLTest_RandomAsciiString();
    9.92 -	char *text = SDL_strdup(textRef);
    9.93 -	SDL_bool boolResult;
    9.94 -	int intResult;
    9.95 -	char *charResult;
    9.96 -
    9.97 -	/* Clear clipboard text state */
    9.98 -	boolResult = SDL_HasClipboardText();
    9.99 -	SDLTest_AssertPass("Call to SDL_HasClipboardText succeeded");
   9.100 -	if (boolResult == SDL_TRUE) {
   9.101 -        intResult = SDL_SetClipboardText((const char *)NULL);
   9.102 -		SDLTest_AssertPass("Call to DL_SetClipboardText(NULL) succeeded");
   9.103 -	    SDLTest_AssertCheck(
   9.104 -			intResult == 0,
   9.105 -			"Verify result from SDL_SetClipboardText(NULL), expected 0, got %i",
   9.106 -			intResult);
   9.107 -	    charResult = SDL_GetClipboardText();
   9.108 -		SDLTest_AssertPass("Call to SDL_GetClipboardText succeeded");
   9.109 -	    boolResult = SDL_HasClipboardText();
   9.110 -		SDLTest_AssertPass("Call to SDL_HasClipboardText succeeded");
   9.111 -	    SDLTest_AssertCheck(
   9.112 -            boolResult == SDL_FALSE,
   9.113 -	        "Verify SDL_HasClipboardText returned SDL_FALSE, got %s",
   9.114 -			(boolResult) ? "SDL_TRUE" : "SDL_FALSE");
   9.115 -    }
   9.116 -
   9.117 -    /* Empty clipboard  */
   9.118 -	charResult = SDL_GetClipboardText();
   9.119 -	SDLTest_AssertPass("Call to SDL_GetClipboardText succeeded");
   9.120 -	SDLTest_AssertCheck(
   9.121 -		charResult != NULL,
   9.122 -		"Verify SDL_GetClipboardText did not return NULL");
   9.123 -	SDLTest_AssertCheck(
   9.124 -		strlen(charResult) == 0,
   9.125 -		"Verify SDL_GetClipboardText returned string with length 0, got length %i",
   9.126 -		strlen(charResult));
   9.127 -    intResult = SDL_SetClipboardText((const char *)text);
   9.128 -	SDLTest_AssertPass("Call to SDL_SetClipboardText succeeded");
   9.129 -	SDLTest_AssertCheck(
   9.130 -		intResult == 0,
   9.131 -		"Verify result from SDL_SetClipboardText(NULL), expected 0, got %i",
   9.132 -		intResult);
   9.133 -	SDLTest_AssertCheck(
   9.134 -		strcmp(textRef, text) == 0,
   9.135 -		"Verify SDL_SetClipboardText did not modify input string, expected '%s', got '%s'",
   9.136 -		textRef, text);
   9.137 -	boolResult = SDL_HasClipboardText();
   9.138 -	SDLTest_AssertPass("Call to SDL_HasClipboardText succeeded");
   9.139 -	SDLTest_AssertCheck(
   9.140 -        boolResult == SDL_TRUE,
   9.141 -	    "Verify SDL_HasClipboardText returned SDL_TRUE, got %s",
   9.142 -		(boolResult) ? "SDL_TRUE" : "SDL_FALSE");
   9.143 -	charResult = SDL_GetClipboardText();
   9.144 -	SDLTest_AssertPass("Call to SDL_GetClipboardText succeeded");
   9.145 -	SDLTest_AssertCheck(
   9.146 -		strcmp(textRef, charResult) == 0,
   9.147 -		"Verify SDL_GetClipboardText returned correct string, expected '%s', got '%s'",
   9.148 -		textRef, charResult);
   9.149 -
   9.150 -    /* Cleanup */
   9.151 -    if (textRef) SDL_free(textRef);
   9.152 -    if (text) SDL_free(text);
   9.153 -    if (charResult) SDL_free(charResult);
   9.154 -
   9.155 -   return TEST_COMPLETED;
   9.156 -}
   9.157 -
   9.158 -
   9.159 -/* ================= Test References ================== */
   9.160 -
   9.161 -/* Clipboard test cases */
   9.162 -static const SDLTest_TestCaseReference clipboardTest1 =
   9.163 -		{ (SDLTest_TestCaseFp)clipboard_testHasClipboardText, "clipboard_testHasClipboardText", "Check call to SDL_HasClipboardText", TEST_ENABLED };
   9.164 -
   9.165 -static const SDLTest_TestCaseReference clipboardTest2 =
   9.166 -		{ (SDLTest_TestCaseFp)clipboard_testGetClipboardText, "clipboard_testGetClipboardText", "Check call to SDL_GetClipboardText", TEST_ENABLED };
   9.167 -
   9.168 -static const SDLTest_TestCaseReference clipboardTest3 =
   9.169 -		{ (SDLTest_TestCaseFp)clipboard_testSetClipboardText, "clipboard_testSetClipboardText", "Check call to SDL_SetClipboardText", TEST_ENABLED };
   9.170 -
   9.171 -static const SDLTest_TestCaseReference clipboardTest4 =
   9.172 -		{ (SDLTest_TestCaseFp)clipboard_testClipboardTextFunctions, "clipboard_testClipboardTextFunctions", "End-to-end test of SDL_xyzClipboardText functions", TEST_ENABLED };
   9.173 -
   9.174 -/* Sequence of Clipboard test cases */
   9.175 -static const SDLTest_TestCaseReference *clipboardTests[] =  {
   9.176 -	&clipboardTest1, &clipboardTest2, &clipboardTest3, &clipboardTest4, NULL
   9.177 -};
   9.178 -
   9.179 -/* Clipboard test suite (global) */
   9.180 -SDLTest_TestSuiteReference clipboardTestSuite = {
   9.181 -	"Clipboard",
   9.182 -	NULL,
   9.183 -	clipboardTests,
   9.184 -	NULL
   9.185 -};
    10.1 --- a/test/tests/testplatform.c	Sat Dec 22 17:24:14 2012 -0800
    10.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    10.3 @@ -1,561 +0,0 @@
    10.4 -/**
    10.5 - * Original code: automated SDL platform test written by Edgar Simo "bobbens"
    10.6 - * Extended and updated by aschiffler at ferzkopp dot net
    10.7 - */
    10.8 -
    10.9 -#include <stdio.h>
   10.10 -
   10.11 -#include "SDL.h"
   10.12 -#include "SDL_test.h"
   10.13 -
   10.14 -/* ================= Test Case Implementation ================== */
   10.15 -
   10.16 -/* Helper functions */
   10.17 -
   10.18 -/**
   10.19 - * @brief Compare sizes of types.
   10.20 - *
   10.21 - * @note Watcom C flags these as Warning 201: "Unreachable code" if you just
   10.22 - *  compare them directly, so we push it through a function to keep the
   10.23 - *  compiler quiet.  --ryan.
   10.24 - */
   10.25 -static int _compareSizeOfType( size_t sizeoftype, size_t hardcodetype )
   10.26 -{
   10.27 -    return sizeoftype != hardcodetype;
   10.28 -}
   10.29 -
   10.30 -/* Test case functions */
   10.31 -
   10.32 -/**
   10.33 - * @brief Tests type sizes.
   10.34 - */
   10.35 -int platform_testTypes(void *arg)
   10.36 -{
   10.37 -   int ret;
   10.38 -
   10.39 -   ret = _compareSizeOfType( sizeof(Uint8), 1 );
   10.40 -   SDLTest_AssertCheck( ret == 0, "sizeof(Uint8) = %lu, expected  1", sizeof(Uint8) );
   10.41 -
   10.42 -   ret = _compareSizeOfType( sizeof(Uint16), 2 );
   10.43 -   SDLTest_AssertCheck( ret == 0, "sizeof(Uint16) = %lu, expected 2", sizeof(Uint16) );
   10.44 -
   10.45 -   ret = _compareSizeOfType( sizeof(Uint32), 4 );
   10.46 -   SDLTest_AssertCheck( ret == 0, "sizeof(Uint32) = %lu, expected 4", sizeof(Uint32) );
   10.47 -
   10.48 -   ret = _compareSizeOfType( sizeof(Uint64), 8 );
   10.49 -   SDLTest_AssertCheck( ret == 0, "sizeof(Uint64) = %lu, expected 8", sizeof(Uint64) );
   10.50 -
   10.51 -   return TEST_COMPLETED;
   10.52 -}
   10.53 -
   10.54 -/**
   10.55 - * @brief Tests platform endianness and SDL_SwapXY functions.
   10.56 - */
   10.57 -int platform_testEndianessAndSwap(void *arg)
   10.58 -{
   10.59 -    int real_byteorder;
   10.60 -    Uint16 value = 0x1234;
   10.61 -    Uint16 value16 = 0xCDAB;
   10.62 -    Uint16 swapped16 = 0xABCD;
   10.63 -    Uint32 value32 = 0xEFBEADDE;
   10.64 -    Uint32 swapped32 = 0xDEADBEEF;
   10.65 -
   10.66 -    Uint64 value64, swapped64;
   10.67 -    value64 = 0xEFBEADDE;
   10.68 -    value64 <<= 32;
   10.69 -    value64 |= 0xCDAB3412;
   10.70 -    swapped64 = 0x1234ABCD;
   10.71 -    swapped64 <<= 32;
   10.72 -    swapped64 |= 0xDEADBEEF;
   10.73 -
   10.74 -    if ((*((char *) &value) >> 4) == 0x1) {
   10.75 -        real_byteorder = SDL_BIG_ENDIAN;
   10.76 -    } else {
   10.77 -        real_byteorder = SDL_LIL_ENDIAN;
   10.78 -    }
   10.79 -
   10.80 -    /* Test endianness. */
   10.81 -    SDLTest_AssertCheck( real_byteorder == SDL_BYTEORDER,
   10.82 -             "Machine detected as %s endian, appears to be %s endian.",
   10.83 -             (SDL_BYTEORDER == SDL_LIL_ENDIAN) ? "little" : "big",
   10.84 -             (real_byteorder == SDL_LIL_ENDIAN) ? "little" : "big" );
   10.85 -
   10.86 -    /* Test 16 swap. */
   10.87 -    SDLTest_AssertCheck( SDL_Swap16(value16) == swapped16,
   10.88 -             "SDL_Swap16(): 16 bit swapped: 0x%X => 0x%X",
   10.89 -             value16, SDL_Swap16(value16) );
   10.90 -
   10.91 -    /* Test 32 swap. */
   10.92 -    SDLTest_AssertCheck( SDL_Swap32(value32) == swapped32,
   10.93 -             "SDL_Swap32(): 32 bit swapped: 0x%X => 0x%X",
   10.94 -             value32, SDL_Swap32(value32) );
   10.95 -
   10.96 -    /* Test 64 swap. */
   10.97 -    SDLTest_AssertCheck( SDL_Swap64(value64) == swapped64,
   10.98 -#ifdef _MSC_VER
   10.99 -             "SDL_Swap64(): 64 bit swapped: 0x%I64X => 0x%I64X",
  10.100 -#else
  10.101 -             "SDL_Swap64(): 64 bit swapped: 0x%llX => 0x%llX",
  10.102 -#endif
  10.103 -             value64, SDL_Swap64(value64) );
  10.104 -
  10.105 -   return TEST_COMPLETED;
  10.106 -}
  10.107 -
  10.108 -/*!
  10.109 - * \brief Tests SDL_GetXYZ() functions
  10.110 - * \sa
  10.111 - * http://wiki.libsdl.org/moin.cgi/SDL_GetPlatform
  10.112 - * http://wiki.libsdl.org/moin.cgi/SDL_GetCPUCount
  10.113 - * http://wiki.libsdl.org/moin.cgi/SDL_GetCPUCacheLineSize
  10.114 - * http://wiki.libsdl.org/moin.cgi/SDL_GetRevision
  10.115 - * http://wiki.libsdl.org/moin.cgi/SDL_GetRevisionNumber
  10.116 - */
  10.117 -int platform_testGetFunctions (void *arg)
  10.118 -{
  10.119 -   char *platform;
  10.120 -   char *revision;
  10.121 -   int ret;
  10.122 -   int len;
  10.123 -
  10.124 -   platform = (char *)SDL_GetPlatform();
  10.125 -   SDLTest_AssertPass("SDL_GetPlatform()");
  10.126 -   SDLTest_AssertCheck(platform != NULL, "SDL_GetPlatform() != NULL");
  10.127 -   if (platform != NULL) {
  10.128 -     len = strlen(platform);
  10.129 -     SDLTest_AssertCheck(len > 0,
  10.130 -             "SDL_GetPlatform(): expected non-empty platform, was platform: '%s', len: %i",
  10.131 -             platform,
  10.132 -             len);
  10.133 -   }
  10.134 -
  10.135 -   ret = SDL_GetCPUCount();
  10.136 -   SDLTest_AssertPass("SDL_GetCPUCount()");
  10.137 -   SDLTest_AssertCheck(ret > 0,
  10.138 -             "SDL_GetCPUCount(): expected count > 0, was: %i",
  10.139 -             ret);
  10.140 -
  10.141 -   ret = SDL_GetCPUCacheLineSize();
  10.142 -   SDLTest_AssertPass("SDL_GetCPUCacheLineSize()");
  10.143 -   SDLTest_AssertCheck(ret >= 0,
  10.144 -             "SDL_GetCPUCacheLineSize(): expected size >= 0, was: %i",
  10.145 -             ret);
  10.146 -
  10.147 -   revision = (char *)SDL_GetRevision();
  10.148 -   SDLTest_AssertPass("SDL_GetRevision()");
  10.149 -   SDLTest_AssertCheck(revision != NULL, "SDL_GetRevision() != NULL");
  10.150 -
  10.151 -   ret = SDL_GetRevisionNumber();
  10.152 -   SDLTest_AssertPass("SDL_GetRevisionNumber()");
  10.153 -
  10.154 -   return TEST_COMPLETED;
  10.155 -}
  10.156 -
  10.157 -/*!
  10.158 - * \brief Tests SDL_HasXYZ() functions
  10.159 - * \sa
  10.160 - * http://wiki.libsdl.org/moin.cgi/SDL_Has3DNow
  10.161 - * http://wiki.libsdl.org/moin.cgi/SDL_HasAltiVec
  10.162 - * http://wiki.libsdl.org/moin.cgi/SDL_HasMMX
  10.163 - * http://wiki.libsdl.org/moin.cgi/SDL_HasRDTSC
  10.164 - * http://wiki.libsdl.org/moin.cgi/SDL_HasSSE
  10.165 - * http://wiki.libsdl.org/moin.cgi/SDL_HasSSE2
  10.166 - * http://wiki.libsdl.org/moin.cgi/SDL_HasSSE3
  10.167 - * http://wiki.libsdl.org/moin.cgi/SDL_HasSSE41
  10.168 - * http://wiki.libsdl.org/moin.cgi/SDL_HasSSE42
  10.169 - */
  10.170 -int platform_testHasFunctions (void *arg)
  10.171 -{
  10.172 -   int ret;
  10.173 -
  10.174 -   // TODO: independently determine and compare values as well
  10.175 -
  10.176 -   ret = SDL_HasRDTSC();
  10.177 -   SDLTest_AssertPass("SDL_HasRDTSC()");
  10.178 -
  10.179 -   ret = SDL_HasAltiVec();
  10.180 -   SDLTest_AssertPass("SDL_HasAltiVec()");
  10.181 -
  10.182 -   ret = SDL_HasMMX();
  10.183 -   SDLTest_AssertPass("SDL_HasMMX()");
  10.184 -
  10.185 -   ret = SDL_Has3DNow();
  10.186 -   SDLTest_AssertPass("SDL_Has3DNow()");
  10.187 -
  10.188 -   ret = SDL_HasSSE();
  10.189 -   SDLTest_AssertPass("SDL_HasSSE()");
  10.190 -
  10.191 -   ret = SDL_HasSSE2();
  10.192 -   SDLTest_AssertPass("SDL_HasSSE2()");
  10.193 -
  10.194 -   ret = SDL_HasSSE3();
  10.195 -   SDLTest_AssertPass("SDL_HasSSE3()");
  10.196 -
  10.197 -   ret = SDL_HasSSE41();
  10.198 -   SDLTest_AssertPass("SDL_HasSSE41()");
  10.199 -
  10.200 -   ret = SDL_HasSSE42();
  10.201 -   SDLTest_AssertPass("SDL_HasSSE42()");
  10.202 -
  10.203 -   return TEST_COMPLETED;
  10.204 -}
  10.205 -
  10.206 -/*!
  10.207 - * \brief Tests SDL_GetVersion
  10.208 - * \sa
  10.209 - * http://wiki.libsdl.org/moin.cgi/SDL_GetVersion
  10.210 - */
  10.211 -int platform_testGetVersion(void *arg)
  10.212 -{
  10.213 -   SDL_version linked;
  10.214 -   int major = SDL_MAJOR_VERSION;
  10.215 -   int minor = SDL_MINOR_VERSION;
  10.216 -
  10.217 -   SDL_GetVersion(&linked);
  10.218 -   SDLTest_AssertCheck( linked.major >= major,
  10.219 -             "SDL_GetVersion(): returned major %i (>= %i)",
  10.220 -             linked.major,
  10.221 -             major);
  10.222 -   SDLTest_AssertCheck( linked.minor >= minor,
  10.223 -             "SDL_GetVersion(): returned minor %i (>= %i)",
  10.224 -             linked.minor,
  10.225 -             minor);
  10.226 -
  10.227 -   return TEST_COMPLETED;
  10.228 -}
  10.229 -
  10.230 -
  10.231 -/*!
  10.232 - * \brief Tests SDL_VERSION macro
  10.233 - */
  10.234 -int platform_testSDLVersion(void *arg)
  10.235 -{
  10.236 -   SDL_version compiled;
  10.237 -   int major = SDL_MAJOR_VERSION;
  10.238 -   int minor = SDL_MINOR_VERSION;
  10.239 -
  10.240 -   SDL_VERSION(&compiled);
  10.241 -   SDLTest_AssertCheck( compiled.major >= major,
  10.242 -             "SDL_VERSION() returned major %i (>= %i)",
  10.243 -             compiled.major,
  10.244 -             major);
  10.245 -   SDLTest_AssertCheck( compiled.minor >= minor,
  10.246 -             "SDL_VERSION() returned minor %i (>= %i)",
  10.247 -             compiled.minor,
  10.248 -             minor);
  10.249 -
  10.250 -   return TEST_COMPLETED;
  10.251 -}
  10.252 -
  10.253 -
  10.254 -/*!
  10.255 - * \brief Tests default SDL_Init
  10.256 - */
  10.257 -int platform_testDefaultInit(void *arg)
  10.258 -{
  10.259 -   int ret;
  10.260 -   int subsystem;
  10.261 -
  10.262 -   subsystem = SDL_WasInit(SDL_INIT_EVERYTHING);
  10.263 -   SDLTest_AssertCheck( subsystem != 0,
  10.264 -             "SDL_WasInit(0): returned %i, expected != 0",
  10.265 -             subsystem);
  10.266 -
  10.267 -   ret = SDL_Init(SDL_WasInit(SDL_INIT_EVERYTHING));
  10.268 -   SDLTest_AssertCheck( ret == 0,
  10.269 -             "SDL_Init(0): returned %i, expected 0, error: %s",
  10.270 -             ret,
  10.271 -             SDL_GetError());
  10.272 -
  10.273 -   return TEST_COMPLETED;
  10.274 -}
  10.275 -
  10.276 -/*!
  10.277 - * \brief Tests SDL_Get/Set/ClearError
  10.278 - * \sa
  10.279 - * http://wiki.libsdl.org/moin.cgi/SDL_GetError
  10.280 - * http://wiki.libsdl.org/moin.cgi/SDL_SetError
  10.281 - * http://wiki.libsdl.org/moin.cgi/SDL_ClearError
  10.282 - */
  10.283 -int platform_testGetSetClearError(void *arg)
  10.284 -{
  10.285 -   const char *testError = "Testing";
  10.286 -   char *lastError;
  10.287 -   int len;
  10.288 -
  10.289 -   SDL_ClearError();
  10.290 -   SDLTest_AssertPass("SDL_ClearError()");
  10.291 -
  10.292 -   lastError = (char *)SDL_GetError();
  10.293 -   SDLTest_AssertPass("SDL_GetError()");
  10.294 -   SDLTest_AssertCheck(lastError != NULL,
  10.295 -             "SDL_GetError() != NULL");
  10.296 -   if (lastError != NULL)
  10.297 -   {
  10.298 -     len = strlen(lastError);
  10.299 -     SDLTest_AssertCheck(len == 0,
  10.300 -             "SDL_GetError(): no message expected, len: %i", len);
  10.301 -   }
  10.302 -
  10.303 -   SDL_SetError("%s", testError);
  10.304 -   SDLTest_AssertPass("SDL_SetError()");
  10.305 -   lastError = (char *)SDL_GetError();
  10.306 -   SDLTest_AssertCheck(lastError != NULL,
  10.307 -             "SDL_GetError() != NULL");
  10.308 -   if (lastError != NULL)
  10.309 -   {
  10.310 -     len = strlen(lastError);
  10.311 -     SDLTest_AssertCheck(len == strlen(testError),
  10.312 -             "SDL_GetError(): expected message len %i, was len: %i",
  10.313 -             strlen(testError),
  10.314 -             len);
  10.315 -     SDLTest_AssertCheck(strcmp(lastError, testError) == 0,
  10.316 -             "SDL_GetError(): expected message %s, was message: %s",
  10.317 -             testError,
  10.318 -             lastError);
  10.319 -   }
  10.320 -
  10.321 -   // Clean up
  10.322 -   SDL_ClearError();
  10.323 -   SDLTest_AssertPass("SDL_ClearError()");
  10.324 -
  10.325 -   return TEST_COMPLETED;
  10.326 -}
  10.327 -
  10.328 -/*!
  10.329 - * \brief Tests SDL_SetError with empty input
  10.330 - * \sa
  10.331 - * http://wiki.libsdl.org/moin.cgi/SDL_SetError
  10.332 - */
  10.333 -int platform_testSetErrorEmptyInput(void *arg)
  10.334 -{
  10.335 -   const char *testError = "";
  10.336 -   char *lastError;
  10.337 -   int len;
  10.338 -
  10.339 -   SDL_SetError("%s", testError);
  10.340 -   SDLTest_AssertPass("SDL_SetError()");
  10.341 -   lastError = (char *)SDL_GetError();
  10.342 -   SDLTest_AssertCheck(lastError != NULL,
  10.343 -             "SDL_GetError() != NULL");
  10.344 -   if (lastError != NULL)
  10.345 -   {
  10.346 -     len = strlen(lastError);
  10.347 -     SDLTest_AssertCheck(len == strlen(testError),
  10.348 -             "SDL_GetError(): expected message len %i, was len: %i",
  10.349 -             strlen(testError),
  10.350 -             len);
  10.351 -     SDLTest_AssertCheck(strcmp(lastError, testError) == 0,
  10.352 -             "SDL_GetError(): expected message '%s', was message: '%s'",
  10.353 -             testError,
  10.354 -             lastError);
  10.355 -   }
  10.356 -
  10.357 -   // Clean up
  10.358 -   SDL_ClearError();
  10.359 -   SDLTest_AssertPass("SDL_ClearError()");
  10.360 -
  10.361 -   return TEST_COMPLETED;
  10.362 -}
  10.363 -
  10.364 -/*!
  10.365 - * \brief Tests SDL_SetError with invalid input
  10.366 - * \sa
  10.367 - * http://wiki.libsdl.org/moin.cgi/SDL_SetError
  10.368 - */
  10.369 -int platform_testSetErrorInvalidInput(void *arg)
  10.370 -{
  10.371 -   const char *testError = NULL;
  10.372 -   const char *probeError = "Testing";
  10.373 -   char *lastError;
  10.374 -   int len;
  10.375 -
  10.376 -   // Reset
  10.377 -   SDL_ClearError();
  10.378 -   SDLTest_AssertPass("SDL_ClearError()");
  10.379 -
  10.380 -   // Check for no-op
  10.381 -   SDL_SetError(testError);
  10.382 -   SDLTest_AssertPass("SDL_SetError()");
  10.383 -   lastError = (char *)SDL_GetError();
  10.384 -   SDLTest_AssertCheck(lastError != NULL,
  10.385 -             "SDL_GetError() != NULL");
  10.386 -   if (lastError != NULL)
  10.387 -   {
  10.388 -     len = strlen(lastError);
  10.389 -     SDLTest_AssertCheck(len == 0,
  10.390 -             "SDL_GetError(): expected message len 0, was len: %i",
  10.391 -             0,
  10.392 -             len);
  10.393 -     SDLTest_AssertCheck(strcmp(lastError, "") == 0,
  10.394 -             "SDL_GetError(): expected message '', was message: '%s'",
  10.395 -             lastError);
  10.396 -   }
  10.397 -
  10.398 -   // Set
  10.399 -   SDL_SetError(probeError);
  10.400 -   SDLTest_AssertPass("SDL_SetError()");
  10.401 -
  10.402 -   // Check for no-op
  10.403 -   SDL_SetError(testError);
  10.404 -   SDLTest_AssertPass("SDL_SetError()");
  10.405 -   lastError = (char *)SDL_GetError();
  10.406 -   SDLTest_AssertCheck(lastError != NULL,
  10.407 -             "SDL_GetError() != NULL");
  10.408 -   if (lastError != NULL)
  10.409 -   {
  10.410 -     len = strlen(lastError);
  10.411 -     SDLTest_AssertCheck(len == strlen(probeError),
  10.412 -             "SDL_GetError(): expected message len %i, was len: %i",
  10.413 -             strlen(probeError),
  10.414 -             len);
  10.415 -     SDLTest_AssertCheck(strcmp(lastError, probeError) == 0,
  10.416 -             "SDL_GetError(): expected message '%s', was message: '%s'",
  10.417 -             probeError,
  10.418 -             lastError);
  10.419 -   }
  10.420 -
  10.421 -   // Clean up
  10.422 -   SDL_ClearError();
  10.423 -   SDLTest_AssertPass("SDL_ClearError()");
  10.424 -
  10.425 -   return TEST_COMPLETED;
  10.426 -}
  10.427 -
  10.428 -/*!
  10.429 - * \brief Tests SDL_GetPowerInfo
  10.430 - * \sa
  10.431 - * http://wiki.libsdl.org/moin.cgi/SDL_GetPowerInfo
  10.432 - */
  10.433 -int platform_testGetPowerInfo(void *arg)
  10.434 -{
  10.435 -   SDL_PowerState state;
  10.436 -   SDL_PowerState stateAgain;
  10.437 -   int secs;
  10.438 -   int secsAgain;
  10.439 -   int pct;
  10.440 -   int pctAgain;
  10.441 -
  10.442 -   state = SDL_GetPowerInfo(&secs, &pct);
  10.443 -   SDLTest_AssertPass("SDL_GetPowerInfo()");
  10.444 -   SDLTest_AssertCheck(
  10.445 -       state==SDL_POWERSTATE_UNKNOWN ||
  10.446 -       state==SDL_POWERSTATE_ON_BATTERY ||
  10.447 -       state==SDL_POWERSTATE_NO_BATTERY ||
  10.448 -       state==SDL_POWERSTATE_CHARGING ||
  10.449 -       state==SDL_POWERSTATE_CHARGED,
  10.450 -       "SDL_GetPowerInfo(): state %i is one of the expected values",
  10.451 -       (int)state);
  10.452 -
  10.453 -   if (state==SDL_POWERSTATE_ON_BATTERY)
  10.454 -   {
  10.455 -      SDLTest_AssertCheck(
  10.456 -         secs >= 0,
  10.457 -         "SDL_GetPowerInfo(): on battery, secs >= 0, was: %i",
  10.458 -         secs);
  10.459 -      SDLTest_AssertCheck(
  10.460 -         (pct >= 0) && (pct <= 100),
  10.461 -         "SDL_GetPowerInfo(): on battery, pct=[0,100], was: %i",
  10.462 -         pct);
  10.463 -   }
  10.464 -
  10.465 -   if (state==SDL_POWERSTATE_UNKNOWN ||
  10.466 -       state==SDL_POWERSTATE_NO_BATTERY)
  10.467 -   {
  10.468 -      SDLTest_AssertCheck(
  10.469 -         secs == -1,
  10.470 -         "SDL_GetPowerInfo(): no battery, secs == -1, was: %i",
  10.471 -         secs);
  10.472 -      SDLTest_AssertCheck(
  10.473 -         pct == -1,
  10.474 -         "SDL_GetPowerInfo(): no battery, pct == -1, was: %i",
  10.475 -         pct);
  10.476 -   }
  10.477 -
  10.478 -   // Partial return value variations
  10.479 -   stateAgain = SDL_GetPowerInfo(&secsAgain, NULL);
  10.480 -   SDLTest_AssertCheck(
  10.481 -        state==stateAgain,
  10.482 -        "State %i returned when only 'secs' requested",
  10.483 -        stateAgain);
  10.484 -   SDLTest_AssertCheck(
  10.485 -        secs==secsAgain,
  10.486 -        "Value %i matches when only 'secs' requested",
  10.487 -        secsAgain);
  10.488 -   stateAgain = SDL_GetPowerInfo(NULL, &pctAgain);
  10.489 -   SDLTest_AssertCheck(
  10.490 -        state==stateAgain,
  10.491 -        "State %i returned when only 'pct' requested",
  10.492 -        stateAgain);
  10.493 -   SDLTest_AssertCheck(
  10.494 -        pct==pctAgain,
  10.495 -        "Value %i matches when only 'pct' requested",
  10.496 -        pctAgain);
  10.497 -   stateAgain = SDL_GetPowerInfo(NULL, NULL);
  10.498 -   SDLTest_AssertCheck(
  10.499 -        state==stateAgain,
  10.500 -        "State %i returned when no value requested",
  10.501 -        stateAgain);
  10.502 -
  10.503 -   return TEST_COMPLETED;
  10.504 -}
  10.505 -
  10.506 -/* ================= Test References ================== */
  10.507 -
  10.508 -/* Platform test cases */
  10.509 -static const SDLTest_TestCaseReference platformTest1 =
  10.510 -		{ (SDLTest_TestCaseFp)platform_testTypes, "platform_testTypes", "Tests predefined types", TEST_ENABLED};
  10.511 -
  10.512 -static const SDLTest_TestCaseReference platformTest2 =
  10.513 -		{ (SDLTest_TestCaseFp)platform_testEndianessAndSwap, "platform_testEndianessAndSwap", "Tests endianess and swap functions", TEST_ENABLED};
  10.514 -
  10.515 -static const SDLTest_TestCaseReference platformTest3 =
  10.516 -		{ (SDLTest_TestCaseFp)platform_testGetFunctions, "platform_testGetFunctions", "Tests various SDL_GetXYZ functions", TEST_ENABLED};
  10.517 -
  10.518 -static const SDLTest_TestCaseReference platformTest4 =
  10.519 -		{ (SDLTest_TestCaseFp)platform_testHasFunctions, "platform_testHasFunctions", "Tests various SDL_HasXYZ functions", TEST_ENABLED};
  10.520 -
  10.521 -static const SDLTest_TestCaseReference platformTest5 =
  10.522 -		{ (SDLTest_TestCaseFp)platform_testGetVersion, "platform_testGetVersion", "Tests SDL_GetVersion function", TEST_ENABLED};
  10.523 -
  10.524 -static const SDLTest_TestCaseReference platformTest6 =
  10.525 -		{ (SDLTest_TestCaseFp)platform_testSDLVersion, "platform_testSDLVersion", "Tests SDL_VERSION macro", TEST_ENABLED};
  10.526 -
  10.527 -static const SDLTest_TestCaseReference platformTest7 =
  10.528 -		{ (SDLTest_TestCaseFp)platform_testDefaultInit, "platform_testDefaultInit", "Tests default SDL_Init", TEST_ENABLED};
  10.529 -
  10.530 -static const SDLTest_TestCaseReference platformTest8 =
  10.531 -		{ (SDLTest_TestCaseFp)platform_testGetSetClearError, "platform_testGetSetClearError", "Tests SDL_Get/Set/ClearError", TEST_ENABLED};
  10.532 -
  10.533 -static const SDLTest_TestCaseReference platformTest9 =
  10.534 -		{ (SDLTest_TestCaseFp)platform_testSetErrorEmptyInput, "platform_testSetErrorEmptyInput", "Tests SDL_SetError with empty input", TEST_ENABLED};
  10.535 -
  10.536 -static const SDLTest_TestCaseReference platformTest10 =
  10.537 -		{ (SDLTest_TestCaseFp)platform_testSetErrorInvalidInput, "platform_testSetErrorInvalidInput", "Tests SDL_SetError with invalid input", TEST_ENABLED};
  10.538 -
  10.539 -static const SDLTest_TestCaseReference platformTest11 =
  10.540 -		{ (SDLTest_TestCaseFp)platform_testGetPowerInfo, "platform_testGetPowerInfo", "Tests SDL_GetPowerInfo function", TEST_ENABLED };
  10.541 -
  10.542 -/* Sequence of Platform test cases */
  10.543 -static const SDLTest_TestCaseReference *platformTests[] =  {
  10.544 -	&platformTest1,
  10.545 -	&platformTest2,
  10.546 -	&platformTest3,
  10.547 -	&platformTest4,
  10.548 -	&platformTest5,
  10.549 -	&platformTest6,
  10.550 -	&platformTest7,
  10.551 -	&platformTest8,
  10.552 -	&platformTest9,
  10.553 -	&platformTest10,
  10.554 -	&platformTest11,
  10.555 -	NULL
  10.556 -};
  10.557 -
  10.558 -/* Platform test suite (global) */
  10.559 -SDLTest_TestSuiteReference platformTestSuite = {
  10.560 -	"Platform",
  10.561 -	NULL,
  10.562 -	platformTests,
  10.563 -	NULL
  10.564 -};
    11.1 --- a/test/tests/testrect.c	Sat Dec 22 17:24:14 2012 -0800
    11.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    11.3 @@ -1,1677 +0,0 @@
    11.4 -/**
    11.5 - * Original code: automated SDL rect test written by Edgar Simo "bobbens"
    11.6 - * New/updated tests: aschiffler at ferzkopp dot net
    11.7 - */
    11.8 -
    11.9 -#include <stdio.h>
   11.10 -
   11.11 -#include "SDL.h"
   11.12 -#include "SDL_test.h"
   11.13 -
   11.14 -/* ================= Test Case Implementation ================== */
   11.15 -
   11.16 -/* Helper functions */
   11.17 -
   11.18 -/*!
   11.19 - * \brief Private helper to check SDL_IntersectRectAndLine results
   11.20 - */
   11.21 -void _validateIntersectRectAndLineResults(
   11.22 -    SDL_bool intersection, SDL_bool expectedIntersection,
   11.23 -    SDL_Rect *rect, SDL_Rect * refRect,
   11.24 -    int x1, int y1, int x2, int y2,
   11.25 -    int x1Ref, int y1Ref, int x2Ref, int y2Ref)
   11.26 -{
   11.27 -    SDLTest_AssertCheck(intersection == expectedIntersection, 
   11.28 -        "Check for correct intersection result: expected %s, got %s intersecting rect (%d,%d,%d,%d) with line (%d,%d - %d,%d)",
   11.29 -        (expectedIntersection == SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE",
   11.30 -        (intersection == SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE",
   11.31 -        refRect->x, refRect->y, refRect->w, refRect->h,
   11.32 -        x1Ref, y1Ref, x2Ref, y2Ref);
   11.33 -    SDLTest_AssertCheck(rect->x == refRect->x && rect->y == refRect->y && rect->w == refRect->w && rect->h == refRect->h,
   11.34 -        "Check that source rectangle was not modified: got (%d,%d,%d,%d) expected (%d,%d,%d,%d)",
   11.35 -        rect->x, rect->y, rect->w, rect->h,
   11.36 -        refRect->x, refRect->y, refRect->w, refRect->h);
   11.37 -    SDLTest_AssertCheck(x1 == x1Ref && y1 == y1Ref && x2 == x2Ref && y2 == y2Ref,
   11.38 -        "Check if line was incorrectly clipped or modified: got (%d,%d - %d,%d) expected (%d,%d - %d,%d)",
   11.39 -        x1, y1, x2, y2,
   11.40 -        x1Ref, y1Ref, x2Ref, y2Ref);
   11.41 -}
   11.42 -
   11.43 -/* Test case functions */
   11.44 -
   11.45 -/*!
   11.46 - * \brief Tests SDL_IntersectRectAndLine() clipping cases
   11.47 - *
   11.48 - * \sa
   11.49 - * http://wiki.libsdl.org/moin.cgi/SDL_IntersectRectAndLine
   11.50 - */
   11.51 -int 
   11.52 -rect_testIntersectRectAndLine (void *arg)
   11.53 -{
   11.54 -    SDL_Rect refRect = { 0, 0, 32, 32 };
   11.55 -    SDL_Rect rect;
   11.56 -    int x1, y1;
   11.57 -    int x2, y2;
   11.58 -    SDL_bool intersected;
   11.59 -
   11.60 -    int xLeft = -SDLTest_RandomIntegerInRange(1, refRect.w);
   11.61 -    int xRight = refRect.w + SDLTest_RandomIntegerInRange(1, refRect.w);
   11.62 -    int yTop = -SDLTest_RandomIntegerInRange(1, refRect.h);
   11.63 -    int yBottom = refRect.h + SDLTest_RandomIntegerInRange(1, refRect.h);
   11.64 -
   11.65 -    x1 = xLeft;
   11.66 -    y1 = 15;
   11.67 -    x2 = xRight;
   11.68 -    y2 = 15;
   11.69 -    rect = refRect;
   11.70 -    intersected = SDL_IntersectRectAndLine(&rect, &x1, &y1, &x2, &y2);
   11.71 -    _validateIntersectRectAndLineResults(intersected, SDL_TRUE, &rect, &refRect, x1, y1, x2, y2, 0, 15, 31, 15);
   11.72 -
   11.73 -    x1 = 15;
   11.74 -    y1 = yTop;
   11.75 -    x2 = 15;
   11.76 -    y2 = yBottom;
   11.77 -    rect = refRect;
   11.78 -    intersected = SDL_IntersectRectAndLine(&rect, &x1, &y1, &x2, &y2);
   11.79 -    _validateIntersectRectAndLineResults(intersected, SDL_TRUE, &rect, &refRect, x1, y1, x2, y2, 15, 0, 15, 31);
   11.80 -
   11.81 -    x1 = -refRect.w;
   11.82 -    y1 = -refRect.h;
   11.83 -    x2 = 2*refRect.w;
   11.84 -    y2 = 2*refRect.h;
   11.85 -    rect = refRect;
   11.86 -    intersected = SDL_IntersectRectAndLine(&rect, &x1, &y1, &x2, &y2);
   11.87 -     _validateIntersectRectAndLineResults(intersected, SDL_TRUE, &rect, &refRect, x1, y1, x2, y2, 0, 0, 31, 31);
   11.88 -
   11.89 -    x1 = 2*refRect.w;
   11.90 -    y1 = 2*refRect.h;
   11.91 -    x2 = -refRect.w;
   11.92 -    y2 = -refRect.h;
   11.93 -    rect = refRect;
   11.94 -    intersected = SDL_IntersectRectAndLine(&rect, &x1, &y1, &x2, &y2);
   11.95 -    _validateIntersectRectAndLineResults(intersected, SDL_TRUE, &rect, &refRect, x1, y1, x2, y2, 31, 31, 0, 0);
   11.96 -
   11.97 -    x1 = -1;
   11.98 -    y1 = 32;
   11.99 -    x2 = 32;
  11.100 -    y2 = -1;
  11.101 -    rect = refRect;
  11.102 -    intersected = SDL_IntersectRectAndLine(&rect, &x1, &y1, &x2, &y2);
  11.103 -    _validateIntersectRectAndLineResults(intersected, SDL_TRUE, &rect, &refRect, x1, y1, x2, y2, 0, 31, 31, 0);
  11.104 -
  11.105 -    x1 = 32;
  11.106 -    y1 = -1;
  11.107 -    x2 = -1;
  11.108 -    y2 = 32;
  11.109 -    rect = refRect;
  11.110 -    intersected = SDL_IntersectRectAndLine(&rect, &x1, &y1, &x2, &y2);
  11.111 -    _validateIntersectRectAndLineResults(intersected, SDL_TRUE, &rect, &refRect, x1, y1, x2, y2, 31, 0, 0, 31);
  11.112 -
  11.113 -	return TEST_COMPLETED;
  11.114 -}
  11.115 -
  11.116 -/*!
  11.117 - * \brief Tests SDL_IntersectRectAndLine() non-clipping case line inside
  11.118 - *
  11.119 - * \sa
  11.120 - * http://wiki.libsdl.org/moin.cgi/SDL_IntersectRectAndLine
  11.121 - */
  11.122 -int 
  11.123 -rect_testIntersectRectAndLineInside (void *arg)
  11.124 -{
  11.125 -    SDL_Rect refRect = { 0, 0, 32, 32 };
  11.126 -    SDL_Rect rect;
  11.127 -    int x1, y1;
  11.128 -    int x2, y2;
  11.129 -    SDL_bool intersected;
  11.130 -
  11.131 -    int xmin = refRect.x;
  11.132 -    int xmax = refRect.x + refRect.w - 1;
  11.133 -    int ymin = refRect.y;
  11.134 -    int ymax = refRect.y + refRect.h - 1;
  11.135 -    int x1Ref = SDLTest_RandomIntegerInRange(xmin + 1, xmax - 1);
  11.136 -    int y1Ref = SDLTest_RandomIntegerInRange(ymin + 1, ymax - 1);
  11.137 -    int x2Ref = SDLTest_RandomIntegerInRange(xmin + 1, xmax - 1);
  11.138 -    int y2Ref = SDLTest_RandomIntegerInRange(ymin + 1, ymax - 1);
  11.139 -
  11.140 -    x1 = x1Ref;
  11.141 -    y1 = y1Ref;
  11.142 -    x2 = x2Ref;
  11.143 -    y2 = y2Ref;
  11.144 -    rect = refRect;
  11.145 -    intersected = SDL_IntersectRectAndLine(&rect, &x1, &y1, &x2, &y2);
  11.146 -    _validateIntersectRectAndLineResults(intersected, SDL_TRUE, &rect, &refRect, x1, y1, x2, y2, x1Ref, y1Ref, x2Ref, y2Ref);
  11.147 -
  11.148 -    x1 = x1Ref;
  11.149 -    y1 = y1Ref;
  11.150 -    x2 = xmax;
  11.151 -    y2 = ymax;
  11.152 -    rect = refRect;
  11.153 -    intersected = SDL_IntersectRectAndLine(&rect, &x1, &y1, &x2, &y2);
  11.154 -    _validateIntersectRectAndLineResults(intersected, SDL_TRUE, &rect, &refRect, x1, y1, x2, y2, x1Ref, y1Ref, xmax, ymax);
  11.155 -
  11.156 -    x1 = xmin;
  11.157 -    y1 = ymin;
  11.158 -    x2 = x2Ref;
  11.159 -    y2 = y2Ref;
  11.160 -    rect = refRect;
  11.161 -    intersected = SDL_IntersectRectAndLine(&rect, &x1, &y1, &x2, &y2);
  11.162 -    _validateIntersectRectAndLineResults(intersected, SDL_TRUE, &rect, &refRect, x1, y1, x2, y2, xmin, ymin, x2Ref, y2Ref);
  11.163 -
  11.164 -    x1 = xmin;
  11.165 -    y1 = ymin;
  11.166 -    x2 = xmax;
  11.167 -    y2 = ymax;
  11.168 -    rect = refRect;
  11.169 -    intersected = SDL_IntersectRectAndLine(&rect, &x1, &y1, &x2, &y2);
  11.170 -    _validateIntersectRectAndLineResults(intersected, SDL_TRUE, &rect, &refRect, x1, y1, x2, y2, xmin, ymin, xmax, ymax);
  11.171 -
  11.172 -    x1 = xmin;
  11.173 -    y1 = ymax;
  11.174 -    x2 = xmax;
  11.175 -    y2 = ymin;
  11.176 -    rect = refRect;
  11.177 -    intersected = SDL_IntersectRectAndLine(&rect, &x1, &y1, &x2, &y2);
  11.178 -    _validateIntersectRectAndLineResults(intersected, SDL_TRUE, &rect, &refRect, x1, y1, x2, y2, xmin, ymax, xmax, ymin);
  11.179 -
  11.180 -	return TEST_COMPLETED;
  11.181 -}
  11.182 -
  11.183 -/*!
  11.184 - * \brief Tests SDL_IntersectRectAndLine() non-clipping cases outside
  11.185 - *
  11.186 - * \sa
  11.187 - * http://wiki.libsdl.org/moin.cgi/SDL_IntersectRectAndLine
  11.188 - */
  11.189 -int 
  11.190 -rect_testIntersectRectAndLineOutside (void *arg)
  11.191 -{
  11.192 -    SDL_Rect refRect = { 0, 0, 32, 32 };
  11.193 -    SDL_Rect rect;
  11.194 -    int x1, y1;
  11.195 -    int x2, y2;
  11.196 -    SDL_bool intersected;
  11.197 -
  11.198 -    int xLeft = -SDLTest_RandomIntegerInRange(1, refRect.w);
  11.199 -    int xRight = refRect.w + SDLTest_RandomIntegerInRange(1, refRect.w);
  11.200 -    int yTop = -SDLTest_RandomIntegerInRange(1, refRect.h);
  11.201 -    int yBottom = refRect.h + SDLTest_RandomIntegerInRange(1, refRect.h);
  11.202 -
  11.203 -    x1 = xLeft;
  11.204 -    y1 = 0;
  11.205 -    x2 = xLeft;
  11.206 -    y2 = 31;
  11.207 -    rect = refRect;
  11.208 -    intersected = SDL_IntersectRectAndLine(&rect, &x1, &y1, &x2, &y2);
  11.209 -    _validateIntersectRectAndLineResults(intersected, SDL_FALSE, &rect, &refRect, x1, y1, x2, y2, xLeft, 0, xLeft, 31);
  11.210 -
  11.211 -    x1 = xRight;
  11.212 -    y1 = 0;
  11.213 -    x2 = xRight;
  11.214 -    y2 = 31;
  11.215 -    rect = refRect;
  11.216 -    intersected = SDL_IntersectRectAndLine(&rect, &x1, &y1, &x2, &y2);
  11.217 -    _validateIntersectRectAndLineResults(intersected, SDL_FALSE, &rect, &refRect, x1, y1, x2, y2, xRight, 0, xRight, 31);
  11.218 -
  11.219 -    x1 = 0;
  11.220 -    y1 = yTop;
  11.221 -    x2 = 31;
  11.222 -    y2 = yTop;
  11.223 -    rect = refRect;
  11.224 -    intersected = SDL_IntersectRectAndLine(&rect, &x1, &y1, &x2, &y2);
  11.225 -    _validateIntersectRectAndLineResults(intersected, SDL_FALSE, &rect, &refRect, x1, y1, x2, y2, 0, yTop, 31, yTop);
  11.226 -
  11.227 -    x1 = 0;
  11.228 -    y1 = yBottom;
  11.229 -    x2 = 31;
  11.230 -    y2 = yBottom;
  11.231 -    rect = refRect;
  11.232 -    intersected = SDL_IntersectRectAndLine(&rect, &x1, &y1, &x2, &y2);
  11.233 -    _validateIntersectRectAndLineResults(intersected, SDL_FALSE, &rect, &refRect, x1, y1, x2, y2, 0, yBottom, 31, yBottom);
  11.234 -
  11.235 -	return TEST_COMPLETED;
  11.236 -}
  11.237 -
  11.238 -/*!
  11.239 - * \brief Tests SDL_IntersectRectAndLine() with empty rectangle
  11.240 - *
  11.241 - * \sa
  11.242 - * http://wiki.libsdl.org/moin.cgi/SDL_IntersectRectAndLine
  11.243 - */
  11.244 -int 
  11.245 -rect_testIntersectRectAndLineEmpty (void *arg)
  11.246 -{
  11.247 -    SDL_Rect refRect;
  11.248 -    SDL_Rect rect;
  11.249 -    int x1, y1, x1Ref, y1Ref;
  11.250 -    int x2, y2, x2Ref, y2Ref;
  11.251 -    SDL_bool intersected;
  11.252 -        
  11.253 -    refRect.x = SDLTest_RandomIntegerInRange(1, 1024);
  11.254 -    refRect.y = SDLTest_RandomIntegerInRange(1, 1024);
  11.255 -    refRect.w = 0;
  11.256 -    refRect.h = 0;
  11.257 -    x1Ref = refRect.x;
  11.258 -    y1Ref = refRect.y;
  11.259 -    x2Ref = SDLTest_RandomIntegerInRange(1, 1024);
  11.260 -    y2Ref = SDLTest_RandomIntegerInRange(1, 1024);
  11.261 -
  11.262 -    x1 = x1Ref;
  11.263 -    y1 = y1Ref;
  11.264 -    x2 = x2Ref;
  11.265 -    y2 = y2Ref;
  11.266 -    rect = refRect;
  11.267 -    intersected = SDL_IntersectRectAndLine(&rect, &x1, &y1, &x2, &y2);
  11.268 -    _validateIntersectRectAndLineResults(intersected, SDL_FALSE, &rect, &refRect, x1, y1, x2, y2, x1Ref, y1Ref, x2Ref, y2Ref);
  11.269 -
  11.270 -	return TEST_COMPLETED;
  11.271 -}
  11.272 -
  11.273 -/*!
  11.274 - * \brief Negative tests against SDL_IntersectRectAndLine() with invalid parameters
  11.275 - *
  11.276 - * \sa
  11.277 - * http://wiki.libsdl.org/moin.cgi/SDL_IntersectRectAndLine
  11.278 - */
  11.279 -int 
  11.280 -rect_testIntersectRectAndLineParam (void *arg)
  11.281 -{
  11.282 -    SDL_Rect rect = { 0, 0, 32, 32 };
  11.283 -    int x1 = rect.w / 2;
  11.284 -    int y1 = rect.h / 2;
  11.285 -    int x2 = x1;
  11.286 -    int y2 = 2 * rect.h;
  11.287 -    SDL_bool intersected;
  11.288 -    
  11.289 -    intersected = SDL_IntersectRectAndLine(&rect, &x1, &y1, &x2, &y2);
  11.290 -    SDLTest_AssertCheck(intersected == SDL_TRUE, "Check that intersection result was SDL_TRUE");
  11.291 -    
  11.292 -    intersected = SDL_IntersectRectAndLine((SDL_Rect *)NULL, &x1, &y1, &x2, &y2);
  11.293 -    SDLTest_AssertCheck(intersected == SDL_FALSE, "Check that function returns SDL_FALSE when 1st parameter is NULL");
  11.294 -    intersected = SDL_IntersectRectAndLine(&rect, (int *)NULL, &y1, &x2, &y2);
  11.295 -    SDLTest_AssertCheck(intersected == SDL_FALSE, "Check that function returns SDL_FALSE when 2nd parameter is NULL");
  11.296 -    intersected = SDL_IntersectRectAndLine(&rect, &x1, (int *)NULL, &x2, &y2);
  11.297 -    SDLTest_AssertCheck(intersected == SDL_FALSE, "Check that function returns SDL_FALSE when 3rd parameter is NULL");
  11.298 -    intersected = SDL_IntersectRectAndLine(&rect, &x1, &y1, (int *)NULL, &y2);
  11.299 -    SDLTest_AssertCheck(intersected == SDL_FALSE, "Check that function returns SDL_FALSE when 4th parameter is NULL");
  11.300 -    intersected = SDL_IntersectRectAndLine(&rect, &x1, &y1, &x2, (int *)NULL);
  11.301 -    SDLTest_AssertCheck(intersected == SDL_FALSE, "Check that function returns SDL_FALSE when 5th parameter is NULL");
  11.302 -    intersected = SDL_IntersectRectAndLine((SDL_Rect *)NULL, (int *)NULL, (int *)NULL, (int *)NULL, (int *)NULL);
  11.303 -    SDLTest_AssertCheck(intersected == SDL_FALSE, "Check that function returns SDL_FALSE when all parameters are NULL");
  11.304 -
  11.305 -	return TEST_COMPLETED;
  11.306 -}
  11.307 -
  11.308 -/*!
  11.309 - * \brief Private helper to check SDL_HasIntersection results
  11.310 - */
  11.311 -void _validateHasIntersectionResults(
  11.312 -    SDL_bool intersection, SDL_bool expectedIntersection, 
  11.313 -    SDL_Rect *rectA, SDL_Rect *rectB, SDL_Rect *refRectA, SDL_Rect *refRectB)
  11.314 -{
  11.315 -    SDLTest_AssertCheck(intersection == expectedIntersection, 
  11.316 -        "Check intersection result: expected %s, got %s intersecting A (%d,%d,%d,%d) with B (%d,%d,%d,%d)",
  11.317 -        (expectedIntersection == SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE",
  11.318 -        (intersection == SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE",
  11.319 -        rectA->x, rectA->y, rectA->w, rectA->h, 
  11.320 -        rectB->x, rectB->y, rectB->w, rectB->h);
  11.321 -    SDLTest_AssertCheck(rectA->x == refRectA->x && rectA->y == refRectA->y && rectA->w == refRectA->w && rectA->h == refRectA->h,
  11.322 -        "Check that source rectangle A was not modified: got (%d,%d,%d,%d) expected (%d,%d,%d,%d)",
  11.323 -        rectA->x, rectA->y, rectA->w, rectA->h,
  11.324 -        refRectA->x, refRectA->y, refRectA->w, refRectA->h);
  11.325 -    SDLTest_AssertCheck(rectB->x == refRectB->x && rectB->y == refRectB->y && rectB->w == refRectB->w && rectB->h == refRectB->h,
  11.326 -        "Check that source rectangle B was not modified: got (%d,%d,%d,%d) expected (%d,%d,%d,%d)",
  11.327 -        rectB->x, rectB->y, rectB->w, rectB->h,
  11.328 -        refRectB->x, refRectB->y, refRectB->w, refRectB->h);
  11.329 -}
  11.330 -
  11.331 -/*!
  11.332 - * \brief Private helper to check SDL_IntersectRect results
  11.333 - */
  11.334 -void _validateIntersectRectResults(
  11.335 -    SDL_bool intersection, SDL_bool expectedIntersection, 
  11.336 -    SDL_Rect *rectA, SDL_Rect *rectB, SDL_Rect *refRectA, SDL_Rect *refRectB, 
  11.337 -    SDL_Rect *result, SDL_Rect *expectedResult)
  11.338 -{
  11.339 -    _validateHasIntersectionResults(intersection, expectedIntersection, rectA, rectB, refRectA, refRectB);
  11.340 -    if (result && expectedResult) {
  11.341 -        SDLTest_AssertCheck(result->x == expectedResult->x && result->y == expectedResult->y && result->w == expectedResult->w && result->h == expectedResult->h,
  11.342 -            "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)",
  11.343 -            rectA->x, rectA->y, rectA->w, rectA->h, 
  11.344 -            rectB->x, rectB->y, rectB->w, rectB->h,
  11.345 -            result->x, result->y, result->w, result->h,
  11.346 -            expectedResult->x, expectedResult->y, expectedResult->w, expectedResult->h);
  11.347 -    }
  11.348 -}
  11.349 -
  11.350 -/*!
  11.351 - * \brief Private helper to check SDL_UnionRect results
  11.352 - */
  11.353 -void _validateUnionRectResults(
  11.354 -    SDL_Rect *rectA, SDL_Rect *rectB, SDL_Rect *refRectA, SDL_Rect *refRectB, 
  11.355 -    SDL_Rect *result, SDL_Rect *expectedResult)
  11.356 -{
  11.357 -    SDLTest_AssertCheck(rectA->x == refRectA->x && rectA->y == refRectA->y && rectA->w == refRectA->w && rectA->h == refRectA->h,
  11.358 -        "Check that source rectangle A was not modified: got (%d,%d,%d,%d) expected (%d,%d,%d,%d)",
  11.359 -        rectA->x, rectA->y, rectA->w, rectA->h,
  11.360 -        refRectA->x, refRectA->y, refRectA->w, refRectA->h);
  11.361 -    SDLTest_AssertCheck(rectB->x == refRectB->x && rectB->y == refRectB->y && rectB->w == refRectB->w && rectB->h == refRectB->h,
  11.362 -        "Check that source rectangle B was not modified: got (%d,%d,%d,%d) expected (%d,%d,%d,%d)",
  11.363 -        rectB->x, rectB->y, rectB->w, rectB->h,
  11.364 -        refRectB->x, refRectB->y, refRectB->w, refRectB->h);
  11.365 -    SDLTest_AssertCheck(result->x == expectedResult->x && result->y == expectedResult->y && result->w == expectedResult->w && result->h == expectedResult->h,
  11.366 -        "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)",
  11.367 -        rectA->x, rectA->y, rectA->w, rectA->h, 
  11.368 -        rectB->x, rectB->y, rectB->w, rectB->h,
  11.369 -        result->x, result->y, result->w, result->h,
  11.370 -        expectedResult->x, expectedResult->y, expectedResult->w, expectedResult->h);
  11.371 -}
  11.372 -
  11.373 -/*!
  11.374 - * \brief Private helper to check SDL_RectEmpty results
  11.375 - */
  11.376 -void _validateRectEmptyResults(
  11.377 -    SDL_bool empty, SDL_bool expectedEmpty, 
  11.378 -    SDL_Rect *rect, SDL_Rect *refRect)
  11.379 -{
  11.380 -    SDLTest_AssertCheck(empty == expectedEmpty, 
  11.381 -        "Check for correct empty result: expected %s, got %s testing (%d,%d,%d,%d)",
  11.382 -        (expectedEmpty == SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE",
  11.383 -        (empty == SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE",
  11.384 -        rect->x, rect->y, rect->w, rect->h);
  11.385 -    SDLTest_AssertCheck(rect->x == refRect->x && rect->y == refRect->y && rect->w == refRect->w && rect->h == refRect->h,
  11.386 -        "Check that source rectangle was not modified: got (%d,%d,%d,%d) expected (%d,%d,%d,%d)",
  11.387 -        rect->x, rect->y, rect->w, rect->h,
  11.388 -        refRect->x, refRect->y, refRect->w, refRect->h);
  11.389 -}
  11.390 -
  11.391 -/*!
  11.392 - * \brief Private helper to check SDL_RectEquals results
  11.393 - */
  11.394 -void _validateRectEqualsResults(
  11.395 -    SDL_bool equals, SDL_bool expectedEquals, 
  11.396 -    SDL_Rect *rectA, SDL_Rect *rectB, SDL_Rect *refRectA, SDL_Rect *refRectB)
  11.397 -{
  11.398 -    SDLTest_AssertCheck(equals == expectedEquals, 
  11.399 -        "Check for correct equals result: expected %s, got %s testing (%d,%d,%d,%d) and (%d,%d,%d,%d)",
  11.400 -        (expectedEquals == SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE",
  11.401 -        (equals == SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE",
  11.402 -        rectA->x, rectA->y, rectA->w, rectA->h,
  11.403 -        rectB->x, rectB->y, rectB->w, rectB->h);
  11.404 -    SDLTest_AssertCheck(rectA->x == refRectA->x && rectA->y == refRectA->y && rectA->w == refRectA->w && rectA->h == refRectA->h,
  11.405 -        "Check that source rectangle A was not modified: got (%d,%d,%d,%d) expected (%d,%d,%d,%d)",
  11.406 -        rectA->x, rectA->y, rectA->w, rectA->h,
  11.407 -        refRectA->x, refRectA->y, refRectA->w, refRectA->h);
  11.408 -    SDLTest_AssertCheck(rectB->x == refRectB->x && rectB->y == refRectB->y && rectB->w == refRectB->w && rectB->h == refRectB->h,
  11.409 -        "Check that source rectangle B was not modified: got (%d,%d,%d,%d) expected (%d,%d,%d,%d)",
  11.410 -        rectB->x, rectB->y, rectB->w, rectB->h,
  11.411 -        refRectB->x, refRectB->y, refRectB->w, refRectB->h);
  11.412 -}
  11.413 -
  11.414 -/*!
  11.415 - * \brief Tests SDL_IntersectRect() with B fully inside A
  11.416 - *
  11.417 - * \sa
  11.418 - * http://wiki.libsdl.org/moin.cgi/SDL_IntersectRect
  11.419 - */
  11.420 -int rect_testIntersectRectInside (void *arg)
  11.421 -{
  11.422 -    SDL_Rect refRectA = { 0, 0, 32, 32 };
  11.423 -    SDL_Rect refRectB;
  11.424 -    SDL_Rect rectA;
  11.425 -    SDL_Rect rectB;
  11.426 -    SDL_Rect result;
  11.427 -    SDL_bool intersection;
  11.428 -
  11.429 -    // rectB fully contained in rectA
  11.430 -    refRectB.x = 0;
  11.431 -    refRectB.y = 0;
  11.432 -    refRectB.w = SDLTest_RandomIntegerInRange(refRectA.x + 1, refRectA.x + refRectA.w - 1);
  11.433 -    refRectB.h = SDLTest_RandomIntegerInRange(refRectA.y + 1, refRectA.y + refRectA.h - 1);
  11.434 -    rectA = refRectA;
  11.435 -    rectB = refRectB;
  11.436 -    intersection = SDL_IntersectRect(&rectA, &rectB, &result);
  11.437 -    _validateIntersectRectResults(intersection, SDL_TRUE, &rectA, &rectB, &refRectA, &refRectB, &result, &refRectB);
  11.438 -
  11.439 -	return TEST_COMPLETED;
  11.440 -}
  11.441 -
  11.442 -/*!
  11.443 - * \brief Tests SDL_IntersectRect() with B fully outside A
  11.444 - *
  11.445 - * \sa
  11.446 - * http://wiki.libsdl.org/moin.cgi/SDL_IntersectRect
  11.447 - */
  11.448 -int rect_testIntersectRectOutside (void *arg)
  11.449 -{
  11.450 -    SDL_Rect refRectA = { 0, 0, 32, 32 };
  11.451 -    SDL_Rect refRectB;
  11.452 -    SDL_Rect rectA;
  11.453 -    SDL_Rect rectB;
  11.454 -    SDL_Rect result;
  11.455 -    SDL_bool intersection;
  11.456 -
  11.457 -    // rectB fully outside of rectA
  11.458 -    refRectB.x = refRectA.x + refRectA.w + SDLTest_RandomIntegerInRange(1, 10);
  11.459 -    refRectB.y = refRectA.y + refRectA.h + SDLTest_RandomIntegerInRange(1, 10);
  11.460 -    refRectB.w = refRectA.w;
  11.461 -    refRectB.h = refRectA.h;
  11.462 -    rectA = refRectA;
  11.463 -    rectB = refRectB;
  11.464 -    intersection = SDL_IntersectRect(&rectA, &rectB, &result);
  11.465 -    _validateIntersectRectResults(intersection, SDL_FALSE, &rectA, &rectB, &refRectA, &refRectB, (SDL_Rect *)NULL, (SDL_Rect *)NULL);    
  11.466 -
  11.467 -	return TEST_COMPLETED;
  11.468 -}
  11.469 -
  11.470 -/*!
  11.471 - * \brief Tests SDL_IntersectRect() with B partially intersecting A
  11.472 - *
  11.473 - * \sa
  11.474 - * http://wiki.libsdl.org/moin.cgi/SDL_IntersectRect
  11.475 - */
  11.476 -int rect_testIntersectRectPartial (void *arg)
  11.477 -{
  11.478 -    SDL_Rect refRectA = { 0, 0, 32, 32 };
  11.479 -    SDL_Rect refRectB;
  11.480 -    SDL_Rect rectA;
  11.481 -    SDL_Rect rectB;
  11.482 -    SDL_Rect result;
  11.483 -    SDL_Rect expectedResult;
  11.484 -    SDL_bool intersection;
  11.485 -
  11.486 -    // rectB partially contained in rectA
  11.487 -    refRectB.x = SDLTest_RandomIntegerInRange(refRectA.x + 1, refRectA.x + refRectA.w - 1);
  11.488 -    refRectB.y = SDLTest_RandomIntegerInRange(refRectA.y + 1, refRectA.y + refRectA.h - 1);
  11.489 -    refRectB.w = refRectA.w;
  11.490 -    refRectB.h = refRectA.h;
  11.491 -    rectA = refRectA;
  11.492 -    rectB = refRectB;
  11.493 -    expectedResult.x = refRectB.x;
  11.494 -    expectedResult.y = refRectB.y;
  11.495 -    expectedResult.w = refRectA.w - refRectB.x;
  11.496 -    expectedResult.h = refRectA.h - refRectB.y;    
  11.497 -    intersection = SDL_IntersectRect(&rectA, &rectB, &result);
  11.498 -    _validateIntersectRectResults(intersection, SDL_TRUE, &rectA, &rectB, &refRectA, &refRectB, &result, &expectedResult);
  11.499 -
  11.500 -    // rectB right edge
  11.501 -    refRectB.x = rectA.w - 1;
  11.502 -    refRectB.y = rectA.y;
  11.503 -    refRectB.w = SDLTest_RandomIntegerInRange(1, refRectA.w - 1);
  11.504 -    refRectB.h = SDLTest_RandomIntegerInRange(1, refRectA.h - 1);
  11.505 -    rectA = refRectA;
  11.506 -    rectB = refRectB;
  11.507 -    expectedResult.x = refRectB.x;
  11.508 -    expectedResult.y = refRectB.y;
  11.509 -    expectedResult.w = 1;
  11.510 -    expectedResult.h = refRectB.h;    
  11.511 -    intersection = SDL_IntersectRect(&rectA, &rectB, &result);
  11.512 -    _validateIntersectRectResults(intersection, SDL_TRUE, &rectA, &rectB, &refRectA, &refRectB, &result, &expectedResult);
  11.513 -
  11.514 -    // rectB left edge
  11.515 -    refRectB.x = 1 - rectA.w;
  11.516 -    refRectB.y = rectA.y;
  11.517 -    refRectB.w = refRectA.w;
  11.518 -    refRectB.h = SDLTest_RandomIntegerInRange(1, refRectA.h - 1);
  11.519 -    rectA = refRectA;
  11.520 -    rectB = refRectB;
  11.521 -    expectedResult.x = 0;
  11.522 -    expectedResult.y = refRectB.y;
  11.523 -    expectedResult.w = 1;
  11.524 -    expectedResult.h = refRectB.h;    
  11.525 -    intersection = SDL_IntersectRect(&rectA, &rectB, &result);
  11.526 -    _validateIntersectRectResults(intersection, SDL_TRUE, &rectA, &rectB, &refRectA, &refRectB, &result, &expectedResult);
  11.527 -
  11.528 -    // rectB bottom edge
  11.529 -    refRectB.x = rectA.x;
  11.530 -    refRectB.y = rectA.h - 1;
  11.531 -    refRectB.w = SDLTest_RandomIntegerInRange(1, refRectA.w - 1);
  11.532 -    refRectB.h = SDLTest_RandomIntegerInRange(1, refRectA.h - 1);
  11.533 -    rectA = refRectA;
  11.534 -    rectB = refRectB;
  11.535 -    expectedResult.x = refRectB.x;
  11.536 -    expectedResult.y = refRectB.y;
  11.537 -    expectedResult.w = refRectB.w;
  11.538 -    expectedResult.h = 1;    
  11.539 -    intersection = SDL_IntersectRect(&rectA, &rectB, &result);
  11.540 -    _validateIntersectRectResults(intersection, SDL_TRUE, &rectA, &rectB, &refRectA, &refRectB, &result, &expectedResult);
  11.541 -
  11.542 -    // rectB top edge
  11.543 -    refRectB.x = rectA.x;
  11.544 -    refRectB.y = 1 - rectA.h;
  11.545 -    refRectB.w = SDLTest_RandomIntegerInRange(1, refRectA.w - 1);
  11.546 -    refRectB.h = rectA.h;
  11.547 -    rectA = refRectA;
  11.548 -    rectB = refRectB;
  11.549 -    expectedResult.x = refRectB.x;
  11.550 -    expectedResult.y = 0;
  11.551 -    expectedResult.w = refRectB.w;
  11.552 -    expectedResult.h = 1;    
  11.553 -    intersection = SDL_IntersectRect(&rectA, &rectB, &result);
  11.554 -    _validateIntersectRectResults(intersection, SDL_TRUE, &rectA, &rectB, &refRectA, &refRectB, &result, &expectedResult);
  11.555 -
  11.556 -	return TEST_COMPLETED;
  11.557 -}
  11.558 -
  11.559 -/*!
  11.560 - * \brief Tests SDL_IntersectRect() with 1x1 pixel sized rectangles
  11.561 - *
  11.562 - * \sa
  11.563 - * http://wiki.libsdl.org/moin.cgi/SDL_IntersectRect
  11.564 - */
  11.565 -int rect_testIntersectRectPoint (void *arg)
  11.566 -{
  11.567 -    SDL_Rect refRectA = { 0, 0, 1, 1 };
  11.568 -    SDL_Rect refRectB = { 0, 0, 1, 1 };
  11.569 -    SDL_Rect rectA;
  11.570 -    SDL_Rect rectB;
  11.571 -    SDL_Rect result;
  11.572 -    SDL_bool intersection;
  11.573 -    int offsetX, offsetY;
  11.574 -
  11.575 -    // intersecting pixels
  11.576 -    refRectA.x = SDLTest_RandomIntegerInRange(1, 100);
  11.577 -    refRectA.y = SDLTest_RandomIntegerInRange(1, 100);
  11.578 -    refRectB.x = refRectA.x;
  11.579 -    refRectB.y = refRectA.y;
  11.580 -    rectA = refRectA;
  11.581 -    rectB = refRectB;
  11.582 -    intersection = SDL_IntersectRect(&rectA, &rectB, &result);
  11.583 -    _validateIntersectRectResults(intersection, SDL_TRUE, &rectA, &rectB, &refRectA, &refRectB, &result, &refRectA);
  11.584 -
  11.585 -    // non-intersecting pixels cases
  11.586 -    for (offsetX = -1; offsetX <= 1; offsetX++) {
  11.587 -        for (offsetY = -1; offsetY <= 1; offsetY++) {
  11.588 -            if (offsetX != 0 || offsetY != 0) {
  11.589 -                refRectA.x = SDLTest_RandomIntegerInRange(1, 100);
  11.590 -                refRectA.y = SDLTest_RandomIntegerInRange(1, 100);
  11.591 -                refRectB.x = refRectA.x;
  11.592 -                refRectB.y = refRectA.y;    
  11.593 -                refRectB.x += offsetX;
  11.594 -                refRectB.y += offsetY;
  11.595 -                rectA = refRectA;
  11.596 -                rectB = refRectB;
  11.597 -                intersection = SDL_IntersectRect(&rectA, &rectB, &result);
  11.598 -                _validateIntersectRectResults(intersection, SDL_FALSE, &rectA, &rectB, &refRectA, &refRectB, (SDL_Rect *)NULL, (SDL_Rect *)NULL);
  11.599 -            }
  11.600 -        }
  11.601 -    }
  11.602 -
  11.603 -	return TEST_COMPLETED;
  11.604 -}
  11.605 -
  11.606 -/*!
  11.607 - * \brief Tests SDL_IntersectRect() with empty rectangles
  11.608 - *
  11.609 - * \sa
  11.610 - * http://wiki.libsdl.org/moin.cgi/SDL_IntersectRect
  11.611 - */
  11.612 -int rect_testIntersectRectEmpty (void *arg)
  11.613 -{
  11.614 -    SDL_Rect refRectA;
  11.615 -    SDL_Rect refRectB;
  11.616 -    SDL_Rect rectA;
  11.617 -    SDL_Rect rectB;
  11.618 -    SDL_Rect result;
  11.619 -    SDL_bool intersection;
  11.620 -
  11.621 -    // Rect A empty
  11.622 -    refRectA.x = SDLTest_RandomIntegerInRange(1, 100);
  11.623 -    refRectA.y = SDLTest_RandomIntegerInRange(1, 100);
  11.624 -    refRectA.w = SDLTest_RandomIntegerInRange(1, 100);
  11.625 -    refRectA.h = SDLTest_RandomIntegerInRange(1, 100);
  11.626 -    refRectB = refRectA;
  11.627 -    refRectA.w = 0;
  11.628 -    refRectA.h = 0;
  11.629 -    rectA = refRectA;
  11.630 -    rectB = refRectB;
  11.631 -    intersection = SDL_IntersectRect(&rectA, &rectB, &result);
  11.632 -    _validateIntersectRectResults(intersection, SDL_FALSE, &rectA, &rectB, &refRectA, &refRectB, (SDL_Rect *)NULL, (SDL_Rect *)NULL);
  11.633 -
  11.634 -    // Rect B empty
  11.635 -    refRectA.x = SDLTest_RandomIntegerInRange(1, 100);
  11.636 -    refRectA.y = SDLTest_RandomIntegerInRange(1, 100);
  11.637 -    refRectA.w = SDLTest_RandomIntegerInRange(1, 100);
  11.638 -    refRectA.h = SDLTest_RandomIntegerInRange(1, 100);
  11.639 -    refRectB = refRectA;
  11.640 -    refRectB.w = 0;
  11.641 -    refRectB.h = 0;
  11.642 -    rectA = refRectA;
  11.643 -    rectB = refRectB;
  11.644 -    intersection = SDL_IntersectRect(&rectA, &rectB, &result);
  11.645 -    _validateIntersectRectResults(intersection, SDL_FALSE, &rectA, &rectB, &refRectA, &refRectB, (SDL_Rect *)NULL, (SDL_Rect *)NULL);
  11.646 -
  11.647 -    // Rect A and B empty
  11.648 -    refRectA.x = SDLTest_RandomIntegerInRange(1, 100);
  11.649 -    refRectA.y = SDLTest_RandomIntegerInRange(1, 100);
  11.650 -    refRectA.w = SDLTest_RandomIntegerInRange(1, 100);
  11.651 -    refRectA.h = SDLTest_RandomIntegerInRange(1, 100);
  11.652 -    refRectB = refRectA;
  11.653 -    refRectA.w = 0;
  11.654 -    refRectA.h = 0;
  11.655 -    refRectB.w = 0;
  11.656 -    refRectB.h = 0;
  11.657 -    rectA = refRectA;
  11.658 -    rectB = refRectB;
  11.659 -    intersection = SDL_IntersectRect(&rectA, &rectB, &result);
  11.660 -    _validateIntersectRectResults(intersection, SDL_FALSE, &rectA, &rectB, &refRectA, &refRectB, (SDL_Rect *)NULL, (SDL_Rect *)NULL);
  11.661 -
  11.662 -	return TEST_COMPLETED;
  11.663 -}
  11.664 -
  11.665 -/*!
  11.666 - * \brief Negative tests against SDL_IntersectRect() with invalid parameters
  11.667 - *
  11.668 - * \sa
  11.669 - * http://wiki.libsdl.org/moin.cgi/SDL_IntersectRect
  11.670 - */
  11.671 -int rect_testIntersectRectParam(void *arg)
  11.672 -{
  11.673 -    SDL_Rect rectA;
  11.674 -    SDL_Rect rectB;
  11.675 -    SDL_Rect result;
  11.676 -    SDL_bool intersection;
  11.677 -
  11.678 -    // invalid parameter combinations
  11.679 -    intersection = SDL_IntersectRect((SDL_Rect *)NULL, &rectB, &result);
  11.680 -    SDLTest_AssertCheck(intersection == SDL_FALSE, "Check that function returns SDL_FALSE when 1st parameter is NULL"); 
  11.681 -    intersection = SDL_IntersectRect(&rectA, (SDL_Rect *)NULL, &result);
  11.682 -    SDLTest_AssertCheck(intersection == SDL_FALSE, "Check that function returns SDL_FALSE when 2st parameter is NULL"); 
  11.683 -    intersection = SDL_IntersectRect(&rectA, &rectB, (SDL_Rect *)NULL);
  11.684 -    SDLTest_AssertCheck(intersection == SDL_FALSE, "Check that function returns SDL_FALSE when 3st parameter is NULL"); 
  11.685 -    intersection = SDL_IntersectRect((SDL_Rect *)NULL, (SDL_Rect *)NULL, &result);
  11.686 -    SDLTest_AssertCheck(intersection == SDL_FALSE, "Check that function returns SDL_FALSE when 1st and 2nd parameters are NULL"); 
  11.687 -    intersection = SDL_IntersectRect((SDL_Rect *)NULL, &rectB, (SDL_Rect *)NULL);
  11.688 -    SDLTest_AssertCheck(intersection == SDL_FALSE, "Check that function returns SDL_FALSE when 1st and 3rd parameters are NULL "); 
  11.689 -    intersection = SDL_IntersectRect((SDL_Rect *)NULL, (SDL_Rect *)NULL, (SDL_Rect *)NULL);
  11.690 -    SDLTest_AssertCheck(intersection == SDL_FALSE, "Check that function returns SDL_FALSE when all parameters are NULL");     
  11.691 -
  11.692 -	return TEST_COMPLETED;
  11.693 -}
  11.694 -
  11.695 -/*!
  11.696 - * \brief Tests SDL_HasIntersection() with B fully inside A
  11.697 - *
  11.698 - * \sa
  11.699 - * http://wiki.libsdl.org/moin.cgi/SDL_HasIntersection
  11.700 - */
  11.701 -int rect_testHasIntersectionInside (void *arg)
  11.702 -{
  11.703 -    SDL_Rect refRectA = { 0, 0, 32, 32 };
  11.704 -    SDL_Rect refRectB;
  11.705 -    SDL_Rect rectA;
  11.706 -    SDL_Rect rectB;
  11.707 -    SDL_bool intersection;
  11.708 -
  11.709 -    // rectB fully contained in rectA
  11.710 -    refRectB.x = 0;
  11.711 -    refRectB.y = 0;
  11.712 -    refRectB.w = SDLTest_RandomIntegerInRange(refRectA.x + 1, refRectA.x + refRectA.w - 1);
  11.713 -    refRectB.h = SDLTest_RandomIntegerInRange(refRectA.y + 1, refRectA.y + refRectA.h - 1);
  11.714 -    rectA = refRectA;
  11.715 -    rectB = refRectB;
  11.716 -    intersection = SDL_HasIntersection(&rectA, &rectB);
  11.717 -    _validateHasIntersectionResults(intersection, SDL_TRUE, &rectA, &rectB, &refRectA, &refRectB);
  11.718 -
  11.719 -	return TEST_COMPLETED;
  11.720 -}
  11.721 -
  11.722 -/*!
  11.723 - * \brief Tests SDL_HasIntersection() with B fully outside A
  11.724 - *
  11.725 - * \sa
  11.726 - * http://wiki.libsdl.org/moin.cgi/SDL_HasIntersection
  11.727 - */
  11.728 -int rect_testHasIntersectionOutside (void *arg)
  11.729 -{
  11.730 -    SDL_Rect refRectA = { 0, 0, 32, 32 };
  11.731 -    SDL_Rect refRectB;
  11.732 -    SDL_Rect rectA;
  11.733 -    SDL_Rect rectB;
  11.734 -    SDL_bool intersection;
  11.735 -
  11.736 -    // rectB fully outside of rectA
  11.737 -    refRectB.x = refRectA.x + refRectA.w + SDLTest_RandomIntegerInRange(1, 10);
  11.738 -    refRectB.y = refRectA.y + refRectA.h + SDLTest_RandomIntegerInRange(1, 10);
  11.739 -    refRectB.w = refRectA.w;
  11.740 -    refRectB.h = refRectA.h;
  11.741 -    rectA = refRectA;
  11.742 -    rectB = refRectB;
  11.743 -    intersection = SDL_HasIntersection(&rectA, &rectB);
  11.744 -    _validateHasIntersectionResults(intersection, SDL_FALSE, &rectA, &rectB, &refRectA, &refRectB);
  11.745 -
  11.746 -	return TEST_COMPLETED;
  11.747 -}
  11.748 -
  11.749 -/*!
  11.750 - * \brief Tests SDL_HasIntersection() with B partially intersecting A
  11.751 - *
  11.752 - * \sa
  11.753 - * http://wiki.libsdl.org/moin.cgi/SDL_HasIntersection
  11.754 - */
  11.755 -int rect_testHasIntersectionPartial (void *arg)
  11.756 -{
  11.757 -    SDL_Rect refRectA = { 0, 0, 32, 32 };
  11.758 -    SDL_Rect refRectB;
  11.759 -    SDL_Rect rectA;
  11.760 -    SDL_Rect rectB;
  11.761 -    SDL_bool intersection;
  11.762 -
  11.763 -    // rectB partially contained in rectA
  11.764 -    refRectB.x = SDLTest_RandomIntegerInRange(refRectA.x + 1, refRectA.x + refRectA.w - 1);
  11.765 -    refRectB.y = SDLTest_RandomIntegerInRange(refRectA.y + 1, refRectA.y + refRectA.h - 1);
  11.766 -    refRectB.w = refRectA.w;
  11.767 -    refRectB.h = refRectA.h;
  11.768 -    rectA = refRectA;
  11.769 -    rectB = refRectB;
  11.770 -    intersection = SDL_HasIntersection(&rectA, &rectB);
  11.771 -    _validateHasIntersectionResults(intersection, SDL_TRUE, &rectA, &rectB, &refRectA, &refRectB);
  11.772 -
  11.773 -    // rectB right edge
  11.774 -    refRectB.x = rectA.w - 1;
  11.775 -    refRectB.y = rectA.y;
  11.776 -    refRectB.w = SDLTest_RandomIntegerInRange(1, refRectA.w - 1);
  11.777 -    refRectB.h = SDLTest_RandomIntegerInRange(1, refRectA.h - 1);
  11.778 -    rectA = refRectA;
  11.779 -    rectB = refRectB;
  11.780 -    intersection = SDL_HasIntersection(&rectA, &rectB);
  11.781 -    _validateHasIntersectionResults(intersection, SDL_TRUE, &rectA, &rectB, &refRectA, &refRectB);
  11.782 -
  11.783 -    // rectB left edge
  11.784 -    refRectB.x = 1 - rectA.w;
  11.785 -    refRectB.y = rectA.y;
  11.786 -    refRectB.w = refRectA.w;
  11.787 -    refRectB.h = SDLTest_RandomIntegerInRange(1, refRectA.h - 1);
  11.788 -    rectA = refRectA;
  11.789 -    rectB = refRectB;
  11.790 -    intersection = SDL_HasIntersection(&rectA, &rectB);
  11.791 -    _validateHasIntersectionResults(intersection, SDL_TRUE, &rectA, &rectB, &refRectA, &refRectB);
  11.792 -
  11.793 -    // rectB bottom edge
  11.794 -    refRectB.x = rectA.x;
  11.795 -    refRectB.y = rectA.h - 1;
  11.796 -    refRectB.w = SDLTest_RandomIntegerInRange(1, refRectA.w - 1);
  11.797 -    refRectB.h = SDLTest_RandomIntegerInRange(1, refRectA.h - 1);
  11.798 -    rectA = refRectA;
  11.799 -    rectB = refRectB;
  11.800 -    intersection = SDL_HasIntersection(&rectA, &rectB);
  11.801 -    _validateHasIntersectionResults(intersection, SDL_TRUE, &rectA, &rectB, &refRectA, &refRectB);
  11.802 -
  11.803 -    // rectB top edge
  11.804 -    refRectB.x = rectA.x;
  11.805 -    refRectB.y = 1 - rectA.h;
  11.806 -    refRectB.w = SDLTest_RandomIntegerInRange(1, refRectA.w - 1);
  11.807 -    refRectB.h = rectA.h;
  11.808 -    rectA = refRectA;
  11.809 -    rectB = refRectB;
  11.810 -    intersection = SDL_HasIntersection(&rectA, &rectB);
  11.811 -    _validateHasIntersectionResults(intersection, SDL_TRUE, &rectA, &rectB, &refRectA, &refRectB);
  11.812 -
  11.813 -	return TEST_COMPLETED;
  11.814 -}
  11.815 -
  11.816 -/*!
  11.817 - * \brief Tests SDL_HasIntersection() with 1x1 pixel sized rectangles
  11.818 - *
  11.819 - * \sa
  11.820 - * http://wiki.libsdl.org/moin.cgi/SDL_HasIntersection
  11.821 - */
  11.822 -int rect_testHasIntersectionPoint (void *arg)
  11.823 -{
  11.824 -    SDL_Rect refRectA = { 0, 0, 1, 1 };
  11.825 -    SDL_Rect refRectB = { 0, 0, 1, 1 };
  11.826 -    SDL_Rect rectA;
  11.827 -    SDL_Rect rectB;
  11.828 -    SDL_bool intersection;
  11.829 -    int offsetX, offsetY;
  11.830 -
  11.831 -    // intersecting pixels
  11.832 -    refRectA.x = SDLTest_RandomIntegerInRange(1, 100);
  11.833 -    refRectA.y = SDLTest_RandomIntegerInRange(1, 100);
  11.834 -    refRectB.x = refRectA.x;
  11.835 -    refRectB.y = refRectA.y;
  11.836 -    rectA = refRectA;
  11.837 -    rectB = refRectB;
  11.838 -    intersection = SDL_HasIntersection(&rectA, &rectB);
  11.839 -    _validateHasIntersectionResults(intersection, SDL_TRUE, &rectA, &rectB, &refRectA, &refRectB);
  11.840 -
  11.841 -    // non-intersecting pixels cases
  11.842 -    for (offsetX = -1; offsetX <= 1; offsetX++) {
  11.843 -        for (offsetY = -1; offsetY <= 1; offsetY++) {
  11.844 -            if (offsetX != 0 || offsetY != 0) {
  11.845 -                refRectA.x = SDLTest_RandomIntegerInRange(1, 100);
  11.846 -                refRectA.y = SDLTest_RandomIntegerInRange(1, 100);
  11.847 -                refRectB.x = refRectA.x;
  11.848 -                refRectB.y = refRectA.y;    
  11.849 -                refRectB.x += offsetX;
  11.850 -                refRectB.y += offsetY;
  11.851 -                rectA = refRectA;
  11.852 -                rectB = refRectB;
  11.853 -                intersection = SDL_HasIntersection(&rectA, &rectB);
  11.854 -                _validateHasIntersectionResults(intersection, SDL_FALSE, &rectA, &rectB, &refRectA, &refRectB);
  11.855 -            }
  11.856 -        }
  11.857 -    }
  11.858 -
  11.859 -	return TEST_COMPLETED;
  11.860 -}
  11.861 -
  11.862 -/*!
  11.863 - * \brief Tests SDL_HasIntersection() with empty rectangles
  11.864 - *
  11.865 - * \sa
  11.866 - * http://wiki.libsdl.org/moin.cgi/SDL_HasIntersection
  11.867 - */
  11.868 -int rect_testHasIntersectionEmpty (void *arg)
  11.869 -{
  11.870 -    SDL_Rect refRectA;
  11.871 -    SDL_Rect refRectB;
  11.872 -    SDL_Rect rectA;
  11.873 -    SDL_Rect rectB;
  11.874 -    SDL_bool intersection;
  11.875 -
  11.876 -    // Rect A empty
  11.877 -    refRectA.x = SDLTest_RandomIntegerInRange(1, 100);
  11.878 -    refRectA.y = SDLTest_RandomIntegerInRange(1, 100);
  11.879 -    refRectA.w = SDLTest_RandomIntegerInRange(1, 100);
  11.880 -    refRectA.h = SDLTest_RandomIntegerInRange(1, 100);
  11.881 -    refRectB = refRectA;
  11.882 -    refRectA.w = 0;
  11.883 -    refRectA.h = 0;
  11.884 -    rectA = refRectA;
  11.885 -    rectB = refRectB;
  11.886 -    intersection = SDL_HasIntersection(&rectA, &rectB);
  11.887 -    _validateHasIntersectionResults(intersection, SDL_FALSE, &rectA, &rectB, &refRectA, &refRectB);
  11.888 -
  11.889 -    // Rect B empty
  11.890 -    refRectA.x = SDLTest_RandomIntegerInRange(1, 100);
  11.891 -    refRectA.y = SDLTest_RandomIntegerInRange(1, 100);
  11.892 -    refRectA.w = SDLTest_RandomIntegerInRange(1, 100);
  11.893 -    refRectA.h = SDLTest_RandomIntegerInRange(1, 100);
  11.894 -    refRectB = refRectA;
  11.895 -    refRectB.w = 0;
  11.896 -    refRectB.h = 0;
  11.897 -    rectA = refRectA;
  11.898 -    rectB = refRectB;
  11.899 -    intersection = SDL_HasIntersection(&rectA, &rectB);
  11.900 -    _validateHasIntersectionResults(intersection, SDL_FALSE, &rectA, &rectB, &refRectA, &refRectB);
  11.901 -
  11.902 -    // Rect A and B empty
  11.903 -    refRectA.x = SDLTest_RandomIntegerInRange(1, 100);
  11.904 -    refRectA.y = SDLTest_RandomIntegerInRange(1, 100);
  11.905 -    refRectA.w = SDLTest_RandomIntegerInRange(1, 100);
  11.906 -    refRectA.h = SDLTest_RandomIntegerInRange(1, 100);
  11.907 -    refRectB = refRectA;
  11.908 -    refRectA.w = 0;
  11.909 -    refRectA.h = 0;
  11.910 -    refRectB.w = 0;
  11.911 -    refRectB.h = 0;
  11.912 -    rectA = refRectA;
  11.913 -    rectB = refRectB;
  11.914 -    intersection = SDL_HasIntersection(&rectA, &rectB);
  11.915 -    _validateHasIntersectionResults(intersection, SDL_FALSE, &rectA, &rectB, &refRectA, &refRectB);
  11.916 -
  11.917 -	return TEST_COMPLETED;
  11.918 -}
  11.919 -
  11.920 -/*!
  11.921 - * \brief Negative tests against SDL_HasIntersection() with invalid parameters
  11.922 - *
  11.923 - * \sa
  11.924 - * http://wiki.libsdl.org/moin.cgi/SDL_HasIntersection
  11.925 - */
  11.926 -int rect_testHasIntersectionParam(void *arg)
  11.927 -{
  11.928 -    SDL_Rect rectA;
  11.929 -    SDL_Rect rectB;
  11.930 -    SDL_bool intersection;
  11.931 -
  11.932 -    // invalid parameter combinations
  11.933 -    intersection = SDL_HasIntersection((SDL_Rect *)NULL, &rectB);
  11.934 -    SDLTest_AssertCheck(intersection == SDL_FALSE, "Check that function returns SDL_FALSE when 1st parameter is NULL"); 
  11.935 -    intersection = SDL_HasIntersection(&rectA, (SDL_Rect *)NULL);
  11.936 -    SDLTest_AssertCheck(intersection == SDL_FALSE, "Check that function returns SDL_FALSE when 2st parameter is NULL"); 
  11.937 -    intersection = SDL_HasIntersection((SDL_Rect *)NULL, (SDL_Rect *)NULL);
  11.938 -    SDLTest_AssertCheck(intersection == SDL_FALSE, "Check that function returns SDL_FALSE when all parameters are NULL");     
  11.939 -
  11.940 -	return TEST_COMPLETED;
  11.941 -}
  11.942 -
  11.943 -/*!
  11.944 - * \brief Test SDL_EnclosePoints() without clipping
  11.945 - *
  11.946 - * \sa
  11.947 - * http://wiki.libsdl.org/moin.cgi/SDL_EnclosePoints
  11.948 - */
  11.949 -int rect_testEnclosePoints(void *arg)
  11.950 -{
  11.951 -    const int numPoints = 16;
  11.952 -    SDL_Point refPoints[16];
  11.953 -    SDL_Point points[16];
  11.954 -    SDL_Rect result;
  11.955 -    SDL_bool anyEnclosed;
  11.956 -    SDL_bool anyEnclosedNoResult;
  11.957 -
  11.958 -    // Create input data, tracking result
  11.959 -    SDL_bool expectedEnclosed = SDL_TRUE;
  11.960 -    int newx, newy;
  11.961 -    int minx, maxx, miny, maxy;
  11.962 -    int i;
  11.963 -    for (i=0; i<numPoints; i++) {
  11.964 -        newx = SDLTest_RandomIntegerInRange(-1024, 1024);
  11.965 -        newy = SDLTest_RandomIntegerInRange(-1024, 1024);
  11.966 -        refPoints[i].x = newx;
  11.967 -        refPoints[i].y = newy;
  11.968 -        points[i].x = newx;
  11.969 -        points[i].y = newy;
  11.970 -        if (i==0) {
  11.971 -            minx=maxx=newx;
  11.972 -            miny=maxy=newy;
  11.973 -        } else {
  11.974 -            if (newx<minx) minx=newx;
  11.975 -            if (newx>maxx) maxx=newx;
  11.976 -            if (newy<miny) miny=newy;
  11.977 -            if (newy>maxy) maxy=newy;
  11.978 -        }
  11.979 -    }
  11.980 -    
  11.981 -    // Call function and validate - special case: no result requested
  11.982 -    anyEnclosedNoResult = SDL_EnclosePoints((const SDL_Point *)points, numPoints, (const SDL_Rect *)NULL, (SDL_Rect *)NULL);
  11.983 -    SDLTest_AssertCheck(expectedEnclosed==anyEnclosedNoResult, 
  11.984 -        "Check expected return value %s, got %s", 
  11.985 -        (expectedEnclosed==SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE", 
  11.986 -		(anyEnclosedNoResult==SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE");
  11.987 -    for (i=0; i<numPoints; i++) {
  11.988 -        SDLTest_AssertCheck(refPoints[i].x==points[i].x && refPoints[i].y==points[i].y,
  11.989 -            "Check that source point %i was not modified: expected (%i,%i) actual (%i,%i)", 
  11.990 -            i, refPoints[i].x, refPoints[i].y, points[i].x, points[i].y);
  11.991 -    }
  11.992 -
  11.993 -    // Call function and validate
  11.994 -    anyEnclosed = SDL_EnclosePoints((const SDL_Point *)points, numPoints, (const SDL_Rect *)NULL, &result);
  11.995 -    SDLTest_AssertCheck(expectedEnclosed==anyEnclosed, 
  11.996 -        "Check return value %s, got %s", 
  11.997 -        (expectedEnclosed==SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE", 
  11.998 -		(anyEnclosed==SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE");
  11.999 -    for (i=0; i<numPoints; i++) {
 11.1000 -        SDLTest_AssertCheck(refPoints[i].x==points[i].x && refPoints[i].y==points[i].y,
 11.1001 -            "Check that source point %i was not modified: expected (%i,%i) actual (%i,%i)", 
 11.1002 -            i, refPoints[i].x, refPoints[i].y, points[i].x, points[i].y);
 11.1003 -    }
 11.1004 -    SDLTest_AssertCheck(result.x==minx && result.y==miny && result.w==(maxx - minx + 1) && result.h==(maxy - miny + 1),
 11.1005 -        "Resulting enclosing rectangle incorrect: expected (%i,%i - %i,%i), actual (%i,%i - %i,%i)",
 11.1006 -        minx, miny, maxx, maxy, result.x, result.y, result.x + result.w - 1, result.y + result.h - 1);
 11.1007 -
 11.1008 -	return TEST_COMPLETED;
 11.1009 -}
 11.1010 -
 11.1011 -/*!
 11.1012 - * \brief Test SDL_EnclosePoints() with repeated input points
 11.1013 - *
 11.1014 - * \sa
 11.1015 - * http://wiki.libsdl.org/moin.cgi/SDL_EnclosePoints
 11.1016 - */
 11.1017 -int rect_testEnclosePointsRepeatedInput(void *arg)
 11.1018 -{
 11.1019 -    const int numPoints = 8;
 11.1020 -    const int halfPoints = 4;
 11.1021 -    SDL_Point refPoints[8];
 11.1022 -    SDL_Point points[8];
 11.1023 -    SDL_Rect result;
 11.1024 -    SDL_bool anyEnclosed;
 11.1025 -    SDL_bool anyEnclosedNoResult;
 11.1026 -
 11.1027 -    // Create input data, tracking result
 11.1028 -    SDL_bool expectedEnclosed = SDL_TRUE;
 11.1029 -    int newx, newy;
 11.1030 -    int minx, maxx, miny, maxy;
 11.1031 -    int i;
 11.1032 -    for (i=0; i<numPoints; i++) {
 11.1033 -        if (i < halfPoints) {
 11.1034 -            newx = SDLTest_RandomIntegerInRange(-1024, 1024);
 11.1035 -            newy = SDLTest_RandomIntegerInRange(-1024, 1024);
 11.1036 -        } else {
 11.1037 -            newx = refPoints[i-halfPoints].x;
 11.1038 -            newy = refPoints[i-halfPoints].y;
 11.1039 -        }
 11.1040 -        refPoints[i].x = newx;
 11.1041 -        refPoints[i].y = newy;
 11.1042 -        points[i].x = newx;
 11.1043 -        points[i].y = newy;
 11.1044 -        if (i==0) {
 11.1045 -            minx=maxx=newx;
 11.1046 -            miny=maxy=newy;
 11.1047 -        } else {
 11.1048 -            if (newx<minx) minx=newx;
 11.1049 -            if (newx>maxx) maxx=newx;
 11.1050 -            if (newy<miny) miny=newy;
 11.1051 -            if (newy>maxy) maxy=newy;
 11.1052 -        }
 11.1053 -    }
 11.1054 -
 11.1055 -    // Call function and validate - special case: no result requested
 11.1056 -    anyEnclosedNoResult = SDL_EnclosePoints((const SDL_Point *)points, numPoints, (const SDL_Rect *)NULL, (SDL_Rect *)NULL);
 11.1057 -    SDLTest_AssertCheck(expectedEnclosed==anyEnclosedNoResult, 
 11.1058 -        "Check return value %s, got %s", 
 11.1059 -        (expectedEnclosed==SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE", 
 11.1060 -		(anyEnclosedNoResult==SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE");
 11.1061 -    for (i=0; i<numPoints; i++) {
 11.1062 -        SDLTest_AssertCheck(refPoints[i].x==points[i].x && refPoints[i].y==points[i].y,
 11.1063 -            "Check that source point %i was not modified: expected (%i,%i) actual (%i,%i)", 
 11.1064 -            i, refPoints[i].x, refPoints[i].y, points[i].x, points[i].y);
 11.1065 -    }
 11.1066 -    
 11.1067 -    // Call function and validate
 11.1068 -    anyEnclosed = SDL_EnclosePoints((const SDL_Point *)points, numPoints, (const SDL_Rect *)NULL, &result);
 11.1069 -    SDLTest_AssertCheck(expectedEnclosed==anyEnclosed, 
 11.1070 -        "Check return value %s, got %s", 
 11.1071 -        (expectedEnclosed==SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE", 
 11.1072 -		(anyEnclosed==SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE");
 11.1073 -    for (i=0; i<numPoints; i++) {
 11.1074 -        SDLTest_AssertCheck(refPoints[i].x==points[i].x && refPoints[i].y==points[i].y,
 11.1075 -            "Check that source point %i was not modified: expected (%i,%i) actual (%i,%i)", 
 11.1076 -            i, refPoints[i].x, refPoints[i].y, points[i].x, points[i].y);
 11.1077 -    }
 11.1078 -    SDLTest_AssertCheck(result.x==minx && result.y==miny && result.w==(maxx - minx + 1) && result.h==(maxy - miny + 1),
 11.1079 -        "Check resulting enclosing rectangle: expected (%i,%i - %i,%i), actual (%i,%i - %i,%i)",
 11.1080 -        minx, miny, maxx, maxy, result.x, result.y, result.x + result.w - 1, result.y + result.h - 1);
 11.1081 -
 11.1082 -	return TEST_COMPLETED;
 11.1083 -}
 11.1084 -
 11.1085 -/*!
 11.1086 - * \brief Test SDL_EnclosePoints() with clipping
 11.1087 - *
 11.1088 - * \sa
 11.1089 - * http://wiki.libsdl.org/moin.cgi/SDL_EnclosePoints
 11.1090 - */
 11.1091 -int rect_testEnclosePointsWithClipping(void *arg)
 11.1092 -{
 11.1093 -    const int numPoints = 16;
 11.1094 -    SDL_Point refPoints[16];
 11.1095 -    SDL_Point points[16];
 11.1096 -    SDL_Rect refClip;
 11.1097 -    SDL_Rect clip;
 11.1098 -    SDL_Rect result;
 11.1099 -    SDL_bool anyEnclosed;
 11.1100 -    SDL_bool anyEnclosedNoResult;
 11.1101 -    SDL_bool expectedEnclosed = SDL_FALSE;
 11.1102 -    int newx, newy;
 11.1103 -    int minx, maxx, miny, maxy;
 11.1104 -    int i;
 11.1105 -
 11.1106 -    // Setup clipping rectangle
 11.1107 -    refClip.x = SDLTest_RandomIntegerInRange(-1024, 1024);
 11.1108 -    refClip.y = SDLTest_RandomIntegerInRange(-1024, 1024);
 11.1109 -    refClip.w = SDLTest_RandomIntegerInRange(1, 1024);
 11.1110 -    refClip.h = SDLTest_RandomIntegerInRange(1, 1024);
 11.1111 -
 11.1112 -    // Create input data, tracking result
 11.1113 -    for (i=0; i<numPoints; i++) {
 11.1114 -        newx = SDLTest_RandomIntegerInRange(-1024, 1024);
 11.1115 -        newy = SDLTest_RandomIntegerInRange(-1024, 1024);
 11.1116 -        refPoints[i].x = newx;
 11.1117 -        refPoints[i].y = newy;
 11.1118 -        points[i].x = newx;
 11.1119 -        points[i].y = newy;
 11.1120 -        if ((newx>=refClip.x) && (newx<(refClip.x + refClip.w)) &&
 11.1121 -            (newy>=refClip.y) && (newy<(refClip.y + refClip.h))) {
 11.1122 -            if (expectedEnclosed==SDL_FALSE) {
 11.1123 -                minx=maxx=newx;
 11.1124 -                miny=maxy=newy;
 11.1125 -            } else {
 11.1126 -                if (newx<minx) minx=newx;
 11.1127 -                if (newx>maxx) maxx=newx;
 11.1128 -                if (newy<miny) miny=newy;
 11.1129 -                if (newy>maxy) maxy=newy;
 11.1130 -            }
 11.1131 -            expectedEnclosed = SDL_TRUE;
 11.1132 -        }
 11.1133 -    }
 11.1134 -
 11.1135 -    // Call function and validate - special case: no result requested
 11.1136 -    clip = refClip;
 11.1137 -    anyEnclosedNoResult = SDL_EnclosePoints((const SDL_Point *)points, numPoints, (const SDL_Rect *)&clip, (SDL_Rect *)NULL);
 11.1138 -    SDLTest_AssertCheck(expectedEnclosed==anyEnclosedNoResult, 
 11.1139 -        "Expected return value %s, got %s", 
 11.1140 -        (expectedEnclosed==SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE", 
 11.1141 -		(anyEnclosedNoResult==SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE");
 11.1142 -    for (i=0; i<numPoints; i++) {
 11.1143 -        SDLTest_AssertCheck(refPoints[i].x==points[i].x && refPoints[i].y==points[i].y,
 11.1144 -            "Check that source point %i was not modified: expected (%i,%i) actual (%i,%i)", 
 11.1145 -            i, refPoints[i].x, refPoints[i].y, points[i].x, points[i].y);
 11.1146 -    }
 11.1147 -    SDLTest_AssertCheck(refClip.x==clip.x && refClip.y==clip.y && refClip.w==clip.w && refClip.h==clip.h,
 11.1148 -        "Check that source clipping rectangle was not modified");
 11.1149 -    
 11.1150 -    // Call function and validate
 11.1151 -    anyEnclosed = SDL_EnclosePoints((const SDL_Point *)points, numPoints, (const SDL_Rect *)&clip, &result);
 11.1152 -    SDLTest_AssertCheck(expectedEnclosed==anyEnclosed, 
 11.1153 -        "Check return value %s, got %s", 
 11.1154 -        (expectedEnclosed==SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE", 
 11.1155 -		(anyEnclosed==SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE");
 11.1156 -    for (i=0; i<numPoints; i++) {
 11.1157 -        SDLTest_AssertCheck(refPoints[i].x==points[i].x && refPoints[i].y==points[i].y,
 11.1158 -            "Check that source point %i was not modified: expected (%i,%i) actual (%i,%i)", 
 11.1159 -            i, refPoints[i].x, refPoints[i].y, points[i].x, points[i].y);
 11.1160 -    }
 11.1161 -    SDLTest_AssertCheck(refClip.x==clip.x && refClip.y==clip.y && refClip.w==clip.w && refClip.h==clip.h,
 11.1162 -        "Check that source clipping rectangle was not modified");
 11.1163 -    if (expectedEnclosed==SDL_TRUE) {
 11.1164 -        SDLTest_AssertCheck(result.x==minx && result.y==miny && result.w==(maxx - minx + 1) && result.h==(maxy - miny + 1),
 11.1165 -            "Check resulting enclosing rectangle: expected (%i,%i - %i,%i), actual (%i,%i - %i,%i)",
 11.1166 -            minx, miny, maxx, maxy, result.x, result.y, result.x + result.w - 1, result.y + result.h - 1);
 11.1167 -    }    
 11.1168 -    
 11.1169 -    /* Empty clipping rectangle */
 11.1170 -    clip.w = 0;
 11.1171 -    clip.h = 0;
 11.1172 -    expectedEnclosed = SDL_FALSE;
 11.1173 -    anyEnclosed = SDL_EnclosePoints((const SDL_Point *)points, numPoints, (const SDL_Rect *)&clip, &result);
 11.1174 -    SDLTest_AssertCheck(expectedEnclosed==anyEnclosed, 
 11.1175 -        "Check return value %s, got %s", 
 11.1176 -        (expectedEnclosed==SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE", 
 11.1177 -		(anyEnclosed==SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE");    
 11.1178 -
 11.1179 -	return TEST_COMPLETED;
 11.1180 -}
 11.1181 -
 11.1182 -/*!
 11.1183 - * \brief Negative tests against SDL_EnclosePoints() with invalid parameters
 11.1184 - *
 11.1185 - * \sa
 11.1186 - * http://wiki.libsdl.org/moin.cgi/SDL_EnclosePoints
 11.1187 - */
 11.1188 -int rect_testEnclosePointsParam(void *arg)
 11.1189 -{
 11.1190 -    SDL_Point points[1];
 11.1191 -    int count;
 11.1192 -    SDL_Rect clip;
 11.1193 -    SDL_Rect result;
 11.1194 -    SDL_bool anyEnclosed;
 11.1195 -
 11.1196 -    // invalid parameter combinations
 11.1197 -    anyEnclosed = SDL_EnclosePoints((SDL_Point *)NULL, 1, (const SDL_Rect *)&clip, &result);
 11.1198 -    SDLTest_AssertCheck(anyEnclosed == SDL_FALSE, "Check that functions returns SDL_FALSE when 1st parameter is NULL"); 
 11.1199 -    anyEnclosed = SDL_EnclosePoints((const SDL_Point *)points, 0, (const SDL_Rect *)&clip, &result);
 11.1200 -    SDLTest_AssertCheck(anyEnclosed == SDL_FALSE, "Check that functions returns SDL_FALSE when 2nd parameter is 0");
 11.1201 -    count = SDLTest_RandomIntegerInRange(-100, -1);
 11.1202 -    anyEnclosed = SDL_EnclosePoints((const SDL_Point *)points, count, (const SDL_Rect *)&clip, &result);
 11.1203 -    SDLTest_AssertCheck(anyEnclosed == SDL_FALSE, "Check that functions returns SDL_FALSE when 2nd parameter is %i (negative)", count); 
 11.1204 -    anyEnclosed = SDL_EnclosePoints((SDL_Point *)NULL, 0, (const SDL_Rect *)&clip, &result);
 11.1205 -    SDLTest_AssertCheck(anyEnclosed == SDL_FALSE, "Check that functions returns SDL_FALSE when 1st parameter is NULL and 2nd parameter was 0"); 
 11.1206 -
 11.1207 -	return TEST_COMPLETED;
 11.1208 -}
 11.1209 -
 11.1210 -/*!
 11.1211 - * \brief Tests SDL_UnionRect() where rect B is outside rect A
 11.1212 - *
 11.1213 - * \sa
 11.1214 - * http://wiki.libsdl.org/moin.cgi/SDL_UnionRect
 11.1215 - */
 11.1216 -int rect_testUnionRectOutside(void *arg)
 11.1217 -{
 11.1218 -    SDL_Rect refRectA, refRectB;
 11.1219 -    SDL_Rect rectA, rectB;
 11.1220 -    SDL_Rect expectedResult;
 11.1221 -    SDL_Rect result;
 11.1222 -    int minx, maxx, miny, maxy;
 11.1223 -    int dx, dy;
 11.1224 -    
 11.1225 -    /* Union 1x1 outside */
 11.1226 -    for (dx = -1; dx < 2; dx++) {     
 11.1227 -        for (dy = -1; dy < 2; dy++) {
 11.1228 -            if ((dx != 0) || (dy != 0)) {
 11.1229 -                refRectA.x=SDLTest_RandomIntegerInRange(-1024, 1024);
 11.1230 -                refRectA.y=SDLTest_RandomIntegerInRange(-1024, 1024);
 11.1231 -                refRectA.w=1;
 11.1232 -                refRectA.h=1;
 11.1233 -                refRectB.x=SDLTest_RandomIntegerInRange(-1024, 1024) + dx*2048;
 11.1234 -                refRectB.y=SDLTest_RandomIntegerInRange(-1024, 1024) + dx*2048;
 11.1235 -                refRectB.w=1;
 11.1236 -                refRectB.h=1;
 11.1237 -                minx = (refRectA.x<refRectB.x) ? refRectA.x : refRectB.x;
 11.1238 -                maxx = (refRectA.x>refRectB.x) ? refRectA.x : refRectB.x;
 11.1239 -                miny = (refRectA.y<refRectB.y) ? refRectA.y : refRectB.y;
 11.1240 -                maxy = (refRectA.y>refRectB.y) ? refRectA.y : refRectB.y;                
 11.1241 -                expectedResult.x = minx;
 11.1242 -                expectedResult.y = miny;
 11.1243 -                expectedResult.w = maxx - minx + 1;
 11.1244 -                expectedResult.h = maxy - miny + 1;
 11.1245 -                rectA = refRectA;
 11.1246 -                rectB = refRectB;
 11.1247 -                SDL_UnionRect(&rectA, &rectB, &result);
 11.1248 -                _validateUnionRectResults(&rectA, &rectB, &refRectA, &refRectB, &result, &expectedResult);
 11.1249 -            }
 11.1250 -        }
 11.1251 -    }
 11.1252 -
 11.1253 -    /* Union outside overlap */
 11.1254 -    for (dx = -1; dx < 2; dx++) {     
 11.1255 -        for (dy = -1; dy < 2; dy++) {
 11.1256 -            if ((dx != 0) || (dy != 0)) {
 11.1257 -                refRectA.x=SDLTest_RandomIntegerInRange(-1024, 1024);
 11.1258 -                refRectA.y=SDLTest_RandomIntegerInRange(-1024, 1024);
 11.1259 -                refRectA.w=SDLTest_RandomIntegerInRange(256, 512);
 11.1260 -                refRectA.h=SDLTest_RandomIntegerInRange(256, 512);
 11.1261 -                refRectB.x=refRectA.x + 1 + dx*2;
 11.1262 -                refRectB.y=refRectA.y + 1 + dy*2;
 11.1263 -                refRectB.w=refRectA.w - 2;
 11.1264 -                refRectB.h=refRectA.h - 2;
 11.1265 -                expectedResult = refRectA;
 11.1266 -                if (dx == -1) expectedResult.x--;
 11.1267 -                if (dy == -1) expectedResult.y--;
 11.1268 -                if ((dx == 1) || (dx == -1)) expectedResult.w++;
 11.1269 -                if ((dy == 1) || (dy == -1)) expectedResult.h++;
 11.1270 -                rectA = refRectA;
 11.1271 -                rectB = refRectB;
 11.1272 -                SDL_UnionRect(&rectA, &rectB, &result);
 11.1273 -                _validateUnionRectResults(&rectA, &rectB, &refRectA, &refRectB, &result, &expectedResult);
 11.1274 -            }
 11.1275 -        }
 11.1276 -    }
 11.1277 -
 11.1278 -	return TEST_COMPLETED;
 11.1279 -}
 11.1280 -
 11.1281 -/*!
 11.1282 - * \brief Tests SDL_UnionRect() where rect A or rect B are empty
 11.1283 - *
 11.1284 - * \sa
 11.1285 - * http://wiki.libsdl.org/moin.cgi/SDL_UnionRect
 11.1286 - */
 11.1287 -int rect_testUnionRectEmpty(void *arg)
 11.1288 -{
 11.1289 -    SDL_Rect refRectA, refRectB;
 11.1290 -    SDL_Rect rectA, rectB;
 11.1291 -    SDL_Rect expectedResult;
 11.1292 -    SDL_Rect result;
 11.1293 -
 11.1294 -    /* A empty */    
 11.1295 -    refRectA.x=SDLTest_RandomIntegerInRange(-1024, 1024);
 11.1296 -    refRectA.y=SDLTest_RandomIntegerInRange(-1024, 1024);
 11.1297 -    refRectA.w=0;
 11.1298 -    refRectA.h=0;
 11.1299 -    refRectB.x=SDLTest_RandomIntegerInRange(-1024, 1024);
 11.1300 -    refRectB.y=SDLTest_RandomIntegerInRange(-1024, 1024);
 11.1301 -    refRectB.w=SDLTest_RandomIntegerInRange(1, 1024);
 11.1302 -    refRectB.h=SDLTest_RandomIntegerInRange(1, 1024);
 11.1303 -    expectedResult = refRectB;
 11.1304 -    rectA = refRectA;
 11.1305 -    rectB = refRectB;
 11.1306 -    SDL_UnionRect(&rectA, &rectB, &result);
 11.1307 -    _validateUnionRectResults(&rectA, &rectB, &refRectA, &refRectB, &result, &expectedResult);
 11.1308 -    
 11.1309 -    /* B empty */    
 11.1310 -    refRectA.x=SDLTest_RandomIntegerInRange(-1024, 1024);
 11.1311 -    refRectA.y=SDLTest_RandomIntegerInRange(-1024, 1024);
 11.1312 -    refRectA.w=SDLTest_RandomIntegerInRange(1, 1024);
 11.1313 -    refRectA.h=SDLTest_RandomIntegerInRange(1, 1024);
 11.1314 -    refRectB.x=SDLTest_RandomIntegerInRange(-1024, 1024);
 11.1315 -    refRectB.y=SDLTest_RandomIntegerInRange(-1024, 1024);
 11.1316 -    refRectB.w=0;
 11.1317 -    refRectB.h=0;
 11.1318 -    expectedResult = refRectA;
 11.1319 -    rectA = refRectA;
 11.1320 -    rectB = refRectB;
 11.1321 -    SDL_UnionRect(&rectA, &rectB, &result);
 11.1322 -    _validateUnionRectResults(&rectA, &rectB, &refRectA, &refRectB, &result, &expectedResult);
 11.1323 -
 11.1324 -    /* A and B empty */    
 11.1325 -    refRectA.x=SDLTest_RandomIntegerInRange(-1024, 1024);
 11.1326 -    refRectA.y=SDLTest_RandomIntegerInRange(-1024, 1024);
 11.1327 -    refRectA.w=0;
 11.1328 -    refRectA.h=0;
 11.1329 -    refRectB.x=SDLTest_RandomIntegerInRange(-1024, 1024);
 11.1330 -    refRectB.y=SDLTest_RandomIntegerInRange(-1024, 1024);
 11.1331 -    refRectB.w=0;
 11.1332 -    refRectB.h=0;
 11.1333 -    result.x=0;
 11.1334 -    result.y=0;
 11.1335 -    result.w=0;
 11.1336 -    result.h=0;
 11.1337 -    expectedResult = result;
 11.1338 -    rectA = refRectA;
 11.1339 -    rectB = refRectB;
 11.1340 -    SDL_UnionRect(&rectA, &rectB, &result);
 11.1341 -    _validateUnionRectResults(&rectA, &rectB, &refRectA, &refRectB, &result, &expectedResult);
 11.1342 -
 11.1343 -	return TEST_COMPLETED;
 11.1344 -}
 11.1345 -
 11.1346 -/*!
 11.1347 - * \brief Tests SDL_UnionRect() where rect B is inside rect A
 11.1348 - *
 11.1349 - * \sa
 11.1350 - * http://wiki.libsdl.org/moin.cgi/SDL_UnionRect
 11.1351 - */
 11.1352 -int rect_testUnionRectInside(void *arg)
 11.1353 -{
 11.1354 -    SDL_Rect refRectA, refRectB;
 11.1355 -    SDL_Rect rectA, rectB;
 11.1356 -    SDL_Rect expectedResult;
 11.1357 -    SDL_Rect result;
 11.1358 -    int dx, dy;
 11.1359 -    
 11.1360 -    /* Union 1x1 with itself */
 11.1361 -    refRectA.x=SDLTest_RandomIntegerInRange(-1024, 1024);
 11.1362 -    refRectA.y=SDLTest_RandomIntegerInRange(-1024, 1024);
 11.1363 -    refRectA.w=1;
 11.1364 -    refRectA.h=1;
 11.1365 -    expectedResult = refRectA;
 11.1366 -    rectA = refRectA;
 11.1367 -    SDL_UnionRect(&rectA, &rectA, &result);
 11.1368 -    _validateUnionRectResults(&rectA, &rectA, &refRectA, &refRectA, &result, &expectedResult);
 11.1369 -
 11.1370 -    /* Union 1x1 somewhere inside */
 11.1371 -    refRectA.x=SDLTest_RandomIntegerInRange(-1024, 1024);
 11.1372 -    refRectA.y=SDLTest_RandomIntegerInRange(-1024, 1024);
 11.1373 -    refRectA.w=SDLTest_RandomIntegerInRange(256, 1024);
 11.1374 -    refRectA.h=SDLTest_RandomIntegerInRange(256, 1024);
 11.1375 -    refRectB.x=refRectA.x + 1 + SDLTest_RandomIntegerInRange(1, refRectA.w - 2);
 11.1376 -    refRectB.y=refRectA.y + 1 + SDLTest_RandomIntegerInRange(1, refRectA.h - 2);
 11.1377 -    refRectB.w=1;
 11.1378 -    refRectB.h=1;
 11.1379 -    expectedResult = refRectA;
 11.1380 -    rectA = refRectA;
 11.1381 -    rectB = refRectB;
 11.1382 -    SDL_UnionRect(&rectA, &rectB, &result);
 11.1383 -    _validateUnionRectResults(&rectA, &rectB, &refRectA, &refRectB, &result, &expectedResult);
 11.1384 -
 11.1385 -    /* Union inside with edges modified */
 11.1386 -    for (dx = -1; dx < 2; dx++) {     
 11.1387 -        for (dy = -1; dy < 2; dy++) {
 11.1388 -            if ((dx != 0) || (dy != 0)) {
 11.1389 -                refRectA.x=SDLTest_RandomIntegerInRange(-1024, 1024);
 11.1390 -                refRectA.y=SDLTest_RandomIntegerInRange(-1024, 1024);
 11.1391 -                refRectA.w=SDLTest_RandomIntegerInRange(256, 1024);
 11.1392 -                refRectA.h=SDLTest_RandomIntegerInRange(256, 1024);
 11.1393 -                refRectB = refRectA;
 11.1394 -                if (dx == -1) refRectB.x++;
 11.1395 -                if ((dx == 1) || (dx == -1)) refRectB.w--;
 11.1396 -                if (dy == -1) refRectB.y++;
 11.1397 -                if ((dy == 1) || (dy == -1)) refRectB.h--;                
 11.1398 -                expectedResult = refRectA;
 11.1399 -                rectA = refRectA;
 11.1400 -                rectB = refRectB;
 11.1401 -                SDL_UnionRect(&rectA, &rectB, &result);
 11.1402 -                _validateUnionRectResults(&rectA, &rectB, &refRectA, &refRectB, &result, &expectedResult);
 11.1403 -            }
 11.1404 -        }
 11.1405 -    }
 11.1406 -
 11.1407 -	return TEST_COMPLETED;
 11.1408 -}
 11.1409 -
 11.1410 -/*!
 11.1411 - * \brief Negative tests against SDL_UnionRect() with invalid parameters
 11.1412 - *
 11.1413 - * \sa
 11.1414 - * http://wiki.libsdl.org/moin.cgi/SDL_UnionRect
 11.1415 - */
 11.1416 -int rect_testUnionRectParam(void *arg)
 11.1417 -{
 11.1418 -    SDL_Rect rectA, rectB;
 11.1419 -    SDL_Rect result;
 11.1420 -
 11.1421 -    // invalid parameter combinations
 11.1422 -    SDL_UnionRect((SDL_Rect *)NULL, &rectB, &result);
 11.1423 -    SDLTest_AssertPass("Check that function returns when 1st parameter is NULL"); 
 11.1424 -    SDL_UnionRect(&rectA, (SDL_Rect *)NULL, &result);
 11.1425 -    SDLTest_AssertPass("Check that function returns  when 2nd parameter is NULL"); 
 11.1426 -    SDL_UnionRect(&rectA, &rectB, (SDL_Rect *)NULL);
 11.1427 -    SDLTest_AssertPass("Check that function returns  when 3rd parameter is NULL"); 
 11.1428 -    SDL_UnionRect((SDL_Rect *)NULL, &rectB, (SDL_Rect *)NULL);
 11.1429 -    SDLTest_AssertPass("Check that function returns  when 1st and 3rd parameter are NULL"); 
 11.1430 -    SDL_UnionRect(&rectA, (SDL_Rect *)NULL, (SDL_Rect *)NULL);
 11.1431 -    SDLTest_AssertPass("Check that function returns  when 2nd and 3rd parameter are NULL"); 
 11.1432 -    SDL_UnionRect((SDL_Rect *)NULL, (SDL_Rect *)NULL, (SDL_Rect *)NULL);
 11.1433 -    SDLTest_AssertPass("Check that function returns  when all parameters are NULL"); 
 11.1434 -
 11.1435 -	return TEST_COMPLETED;
 11.1436 -}
 11.1437 -
 11.1438 -/*!
 11.1439 - * \brief Tests SDL_RectEmpty() with various inputs
 11.1440 - *
 11.1441 - * \sa
 11.1442 - * http://wiki.libsdl.org/moin.cgi/SDL_RectEmpty
 11.1443 - */
 11.1444 -int rect_testRectEmpty(void *arg)
 11.1445 -{
 11.1446 -    SDL_Rect refRect;
 11.1447 -    SDL_Rect rect;
 11.1448 -    SDL_bool expectedResult;
 11.1449 -    SDL_bool result;
 11.1450 -    int w, h;
 11.1451 -
 11.1452 -    // Non-empty case
 11.1453 -    refRect.x=SDLTest_RandomIntegerInRange(-1024, 1024);
 11.1454 -    refRect.y=SDLTest_RandomIntegerInRange(-1024, 1024);
 11.1455 -    refRect.w=SDLTest_RandomIntegerInRange(256, 1024);
 11.1456 -    refRect.h=SDLTest_RandomIntegerInRange(256, 1024);
 11.1457 -    expectedResult = SDL_FALSE;
 11.1458 -    rect = refRect;
 11.1459 -    result = (SDL_bool)SDL_RectEmpty((const SDL_Rect *)&rect);
 11.1460 -    _validateRectEmptyResults(result, expectedResult, &rect, &refRect);
 11.1461 -    
 11.1462 -    // Empty case
 11.1463 -    for (w=-1; w<2; w++) {
 11.1464 -        for (h=-1; h<2; h++) {
 11.1465 -            if ((w != 1) || (h != 1)) {
 11.1466 -                refRect.x=SDLTest_RandomIntegerInRange(-1024, 1024);
 11.1467 -                refRect.y=SDLTest_RandomIntegerInRange(-1024, 1024);
 11.1468 -                refRect.w=w;
 11.1469 -                refRect.h=h;
 11.1470 -                expectedResult = SDL_TRUE;
 11.1471 -                rect = refRect;
 11.1472 -                result = (SDL_bool)SDL_RectEmpty((const SDL_Rect *)&rect);
 11.1473 -                _validateRectEmptyResults(result, expectedResult, &rect, &refRect);
 11.1474 -            }
 11.1475 -        }
 11.1476 -    }
 11.1477 -
 11.1478 -	return TEST_COMPLETED;
 11.1479 -}
 11.1480 -
 11.1481 -/*!
 11.1482 - * \brief Negative tests against SDL_RectEmpty() with invalid parameters
 11.1483 - *
 11.1484 - * \sa
 11.1485 - * http://wiki.libsdl.org/moin.cgi/SDL_RectEmpty
 11.1486 - */
 11.1487 -int rect_testRectEmptyParam(void *arg)
 11.1488 -{
 11.1489 -    SDL_bool result;
 11.1490 -
 11.1491 -    // invalid parameter combinations
 11.1492 -    result = (SDL_bool)SDL_RectEmpty((const SDL_Rect *)NULL);
 11.1493 -    SDLTest_AssertCheck(result == SDL_TRUE, "Check that function returns TRUE when 1st parameter is NULL"); 
 11.1494 -
 11.1495 -	return TEST_COMPLETED;
 11.1496 -}
 11.1497 -
 11.1498 -/*!
 11.1499 - * \brief Tests SDL_RectEquals() with various inputs
 11.1500 - *
 11.1501 - * \sa
 11.1502 - * http://wiki.libsdl.org/moin.cgi/SDL_RectEquals
 11.1503 - */
 11.1504 -int rect_testRectEquals(void *arg)
 11.1505 -{
 11.1506 -    SDL_Rect refRectA;
 11.1507 -    SDL_Rect refRectB;
 11.1508 -    SDL_Rect rectA;
 11.1509 -    SDL_Rect rectB;
 11.1510 -    SDL_bool expectedResult;
 11.1511 -    SDL_bool result;
 11.1512 -
 11.1513 -    // Equals
 11.1514 -    refRectA.x=SDLTest_RandomIntegerInRange(-1024, 1024);
 11.1515 -    refRectA.y=SDLTest_RandomIntegerInRange(-1024, 1024);
 11.1516 -    refRectA.w=SDLTest_RandomIntegerInRange(1, 1024);
 11.1517 -    refRectA.h=SDLTest_RandomIntegerInRange(1, 1024);
 11.1518 -    refRectB = refRectA;    
 11.1519 -    expectedResult = SDL_TRUE;
 11.1520 -    rectA = refRectA;
 11.1521 -    rectB = refRectB;
 11.1522 -    result = (SDL_bool)SDL_RectEquals((const SDL_Rect *)&rectA, (const SDL_Rect *)&rectB);
 11.1523 -    _validateRectEqualsResults(result, expectedResult, &rectA, &rectB, &refRectA, &refRectB);
 11.1524 -
 11.1525 -	return TEST_COMPLETED;
 11.1526 -}
 11.1527 -
 11.1528 -/*!
 11.1529 - * \brief Negative tests against SDL_RectEquals() with invalid parameters
 11.1530 - *
 11.1531 - * \sa
 11.1532 - * http://wiki.libsdl.org/moin.cgi/SDL_RectEquals
 11.1533 - */
 11.1534 -int rect_testRectEqualsParam(void *arg)
 11.1535 -{
 11.1536 -    SDL_Rect rectA;
 11.1537 -    SDL_Rect rectB;
 11.1538 -    SDL_bool result;
 11.1539 -
 11.1540 -    /* data setup */
 11.1541 -    rectA.x=SDLTest_RandomIntegerInRange(-1024, 1024);
 11.1542 -    rectA.y=SDLTest_RandomIntegerInRange(-1024, 1024);
 11.1543 -    rectA.w=SDLTest_RandomIntegerInRange(1, 1024);
 11.1544 -    rectA.h=SDLTest_RandomIntegerInRange(1, 1024);
 11.1545 -    rectB.x=SDLTest_RandomIntegerInRange(-1024, 1024);
 11.1546 -    rectB.y=SDLTest_RandomIntegerInRange(-1024, 1024);
 11.1547 -    rectB.w=SDLTest_RandomIntegerInRange(1, 1024);
 11.1548 -    rectB.h=SDLTest_RandomIntegerInRange(1, 1024);
 11.1549 -
 11.1550 -    // invalid parameter combinations
 11.1551 -    result = (SDL_bool)SDL_RectEquals((const SDL_Rect *)NULL, (const SDL_Rect *)&rectB);
 11.1552 -    SDLTest_AssertCheck(result == SDL_FALSE, "Check that function returns SDL_FALSE when 1st parameter is NULL"); 
 11.1553 -    result = (SDL_bool)SDL_RectEquals((const SDL_Rect *)&rectA, (const SDL_Rect *)NULL);
 11.1554 -    SDLTest_AssertCheck(result == SDL_FALSE, "Check that function returns SDL_FALSE when 2nd parameter is NULL"); 
 11.1555 -    result = (SDL_bool)SDL_RectEquals((const SDL_Rect *)NULL, (const SDL_Rect *)NULL);
 11.1556 -    SDLTest_AssertCheck(result == SDL_FALSE, "Check that function returns SDL_FALSE when 1st and 2nd parameter are NULL"); 
 11.1557 -
 11.1558 -	return TEST_COMPLETED;
 11.1559 -}
 11.1560 -
 11.1561 -/* ================= Test References ================== */
 11.1562 -
 11.1563 -/* Rect test cases */
 11.1564 -
 11.1565 -/* SDL_IntersectRectAndLine */
 11.1566 -static const SDLTest_TestCaseReference rectTest1 =
 11.1567 -		{ (SDLTest_TestCaseFp)rect_testIntersectRectAndLine,"rect_testIntersectRectAndLine",  "Tests SDL_IntersectRectAndLine clipping cases", TEST_ENABLED };
 11.1568 -
 11.1569 -static const SDLTest_TestCaseReference rectTest2 =
 11.1570 -		{ (SDLTest_TestCaseFp)rect_testIntersectRectAndLineInside, "rect_testIntersectRectAndLineInside", "Tests SDL_IntersectRectAndLine with line fully contained in rect", TEST_ENABLED };
 11.1571 -
 11.1572 -static const SDLTest_TestCaseReference rectTest3 =
 11.1573 -		{ (SDLTest_TestCaseFp)rect_testIntersectRectAndLineOutside, "rect_testIntersectRectAndLineOutside", "Tests SDL_IntersectRectAndLine with line fully outside of rect", TEST_ENABLED };
 11.1574 -
 11.1575 -static const SDLTest_TestCaseReference rectTest4 =
 11.1576 -		{ (SDLTest_TestCaseFp)rect_testIntersectRectAndLineEmpty, "rect_testIntersectRectAndLineEmpty", "Tests SDL_IntersectRectAndLine with empty rectangle ", TEST_ENABLED };
 11.1577 -
 11.1578 -static const SDLTest_TestCaseReference rectTest5 =
 11.1579 -		{ (SDLTest_TestCaseFp)rect_testIntersectRectAndLineParam, "rect_testIntersectRectAndLineParam", "Negative tests against SDL_IntersectRectAndLine with invalid parameters", TEST_ENABLED };
 11.1580 -
 11.1581 -/* SDL_IntersectRect */
 11.1582 -static const SDLTest_TestCaseReference rectTest6 =
 11.1583 -		{ (SDLTest_TestCaseFp)rect_testIntersectRectInside, "rect_testIntersectRectInside", "Tests SDL_IntersectRect with B fully contained in A", TEST_ENABLED };
 11.1584 -
 11.1585 -static const SDLTest_TestCaseReference rectTest7 =
 11.1586 -		{ (SDLTest_TestCaseFp)rect_testIntersectRectOutside, "rect_testIntersectRectOutside", "Tests SDL_IntersectRect with B fully outside of A", TEST_ENABLED };
 11.1587 -
 11.1588 -static const SDLTest_TestCaseReference rectTest8 =
 11.1589 -		{ (SDLTest_TestCaseFp)rect_testIntersectRectPartial, "rect_testIntersectRectPartial", "Tests SDL_IntersectRect with B partially intersecting A", TEST_ENABLED };
 11.1590 -
 11.1591 -static const SDLTest_TestCaseReference rectTest9 =
 11.1592 -		{ (SDLTest_TestCaseFp)rect_testIntersectRectPoint, "rect_testIntersectRectPoint", "Tests SDL_IntersectRect with 1x1 sized rectangles", TEST_ENABLED };
 11.1593 -
 11.1594 -static const SDLTest_TestCaseReference rectTest10 =
 11.1595 -		{ (SDLTest_TestCaseFp)rect_testIntersectRectEmpty, "rect_testIntersectRectEmpty", "Tests SDL_IntersectRect with empty rectangles", TEST_ENABLED };
 11.1596 -
 11.1597 -static const SDLTest_TestCaseReference rectTest11 =
 11.1598 -		{ (SDLTest_TestCaseFp)rect_testIntersectRectParam, "rect_testIntersectRectParam", "Negative tests against SDL_IntersectRect with invalid parameters", TEST_ENABLED };
 11.1599 -
 11.1600 -/* SDL_HasIntersection */
 11.1601 -static const SDLTest_TestCaseReference rectTest12 =
 11.1602 -		{ (SDLTest_TestCaseFp)rect_testHasIntersectionInside, "rect_testHasIntersectionInside", "Tests SDL_HasIntersection with B fully contained in A", TEST_ENABLED };
 11.1603 -
 11.1604 -static const SDLTest_TestCaseReference rectTest13 =
 11.1605 -		{ (SDLTest_TestCaseFp)rect_testHasIntersectionOutside, "rect_testHasIntersectionOutside", "Tests SDL_HasIntersection with B fully outside of A", TEST_ENABLED };
 11.1606 -
 11.1607 -static const SDLTest_TestCaseReference rectTest14 =
 11.1608 -		{ (SDLTest_TestCaseFp)rect_testHasIntersectionPartial,"rect_testHasIntersectionPartial",  "Tests SDL_HasIntersection with B partially intersecting A", TEST_ENABLED };
 11.1609 -
 11.1610 -static const SDLTest_TestCaseReference rectTest15 =
 11.1611 -		{ (SDLTest_TestCaseFp)rect_testHasIntersectionPoint, "rect_testHasIntersectionPoint", "Tests SDL_HasIntersection with 1x1 sized rectangles", TEST_ENABLED };
 11.1612 -
 11.1613 -static const SDLTest_TestCaseReference rectTest16 =
 11.1614 -		{ (SDLTest_TestCaseFp)rect_testHasIntersectionEmpty, "rect_testHasIntersectionEmpty", "Tests SDL_HasIntersection with empty rectangles", TEST_ENABLED };
 11.1615 -
 11.1616 -static const SDLTest_TestCaseReference rectTest17 =
 11.1617 -		{ (SDLTest_TestCaseFp)rect_testHasIntersectionParam, "rect_testHasIntersectionParam", "Negative tests against SDL_HasIntersection with invalid parameters", TEST_ENABLED };
 11.1618 -
 11.1619 -/* SDL_EnclosePoints */
 11.1620 -static const SDLTest_TestCaseReference rectTest18 =
 11.1621 -		{ (SDLTest_TestCaseFp)rect_testEnclosePoints, "rect_testEnclosePoints", "Tests SDL_EnclosePoints without clipping", TEST_ENABLED };
 11.1622 -
 11.1623 -static const SDLTest_TestCaseReference rectTest19 =
 11.1624 -		{ (SDLTest_TestCaseFp)rect_testEnclosePointsWithClipping, "rect_testEnclosePointsWithClipping", "Tests SDL_EnclosePoints with clipping", TEST_ENABLED };
 11.1625 -
 11.1626 -static const SDLTest_TestCaseReference rectTest20 =
 11.1627 -		{ (SDLTest_TestCaseFp)rect_testEnclosePointsRepeatedInput, "rect_testEnclosePointsRepeatedInput", "Tests SDL_EnclosePoints with repeated input", TEST_ENABLED };
 11.1628 -
 11.1629 -static const SDLTest_TestCaseReference rectTest21 =
 11.1630 -		{ (SDLTest_TestCaseFp)rect_testEnclosePointsParam, "rect_testEnclosePointsParam", "Negative tests against SDL_EnclosePoints with invalid parameters", TEST_ENABLED };
 11.1631 -
 11.1632 -/* SDL_UnionRect */
 11.1633 -static const SDLTest_TestCaseReference rectTest22 =
 11.1634 -		{ (SDLTest_TestCaseFp)rect_testUnionRectInside, "rect_testUnionRectInside", "Tests SDL_UnionRect where rect B is inside rect A", TEST_ENABLED };
 11.1635 -
 11.1636 -static const SDLTest_TestCaseReference rectTest23 =
 11.1637 -		{ (SDLTest_TestCaseFp)rect_testUnionRectOutside, "rect_testUnionRectOutside", "Tests SDL_UnionRect where rect B is outside rect A", TEST_ENABLED };
 11.1638 -
 11.1639 -static const SDLTest_TestCaseReference rectTest24 =
 11.1640 -		{ (SDLTest_TestCaseFp)rect_testUnionRectEmpty, "rect_testUnionRectEmpty", "Tests SDL_UnionRect where rect A or rect B are empty", TEST_ENABLED };
 11.1641 -
 11.1642 -static const SDLTest_TestCaseReference rectTest25 =
 11.1643 -		{ (SDLTest_TestCaseFp)rect_testUnionRectParam, "rect_testUnionRectParam", "Negative tests against SDL_UnionRect with invalid parameters", TEST_ENABLED };
 11.1644 -
 11.1645 -/* SDL_RectEmpty */
 11.1646 -static const SDLTest_TestCaseReference rectTest26 =
 11.1647 -		{ (SDLTest_TestCaseFp)rect_testRectEmpty, "rect_testRectEmpty", "Tests SDL_RectEmpty with various inputs", TEST_ENABLED };
 11.1648 -
 11.1649 -static const SDLTest_TestCaseReference rectTest27 =
 11.1650 -		{ (SDLTest_TestCaseFp)rect_testRectEmptyParam, "rect_testRectEmptyParam", "Negative tests against SDL_RectEmpty with invalid parameters", TEST_ENABLED };
 11.1651 -
 11.1652 -/* SDL_RectEquals */
 11.1653 -
 11.1654 -static const SDLTest_TestCaseReference rectTest28 =
 11.1655 -		{ (SDLTest_TestCaseFp)rect_testRectEquals, "rect_testRectEquals", "Tests SDL_RectEquals with various inputs", TEST_ENABLED };
 11.1656 -
 11.1657 -static const SDLTest_TestCaseReference rectTest29 =
 11.1658 -		{ (SDLTest_TestCaseFp)rect_testRectEqualsParam, "rect_testRectEqualsParam", "Negative tests against SDL_RectEquals with invalid parameters", TEST_ENABLED };
 11.1659 -
 11.1660 -
 11.1661 -/*!
 11.1662 - * \brief Sequence of Rect test cases; functions that handle simple rectangles including overlaps and merges.
 11.1663 - *
 11.1664 - * \sa
 11.1665 - * http://wiki.libsdl.org/moin.cgi/CategoryRect
 11.1666 - */
 11.1667 -static const SDLTest_TestCaseReference *rectTests[] =  {
 11.1668 -	&rectTest1, &rectTest2, &rectTest3, &rectTest4, &rectTest5, &rectTest6, &rectTest7, &rectTest8, &rectTest9, &rectTest10, &rectTest11, &rectTest12, &rectTest13, &rectTest14, 
 11.1669 -	&rectTest15, &rectTest16, &rectTest17, &rectTest18, &rectTest19, &rectTest20, &rectTest21, &rectTest22, &rectTest23, &rectTest24, &rectTest25, &rectTest26, &rectTest27,
 11.1670 -	&rectTest28, &rectTest29, NULL
 11.1671 -};
 11.1672 -
 11.1673 -
 11.1674 -/* Rect test suite (global) */
 11.1675 -SDLTest_TestSuiteReference rectTestSuite = {
 11.1676 -	"Rect",
 11.1677 -	NULL,
 11.1678 -	rectTests,
 11.1679 -	NULL
 11.1680 -};
    12.1 --- a/test/tests/testrender.c	Sat Dec 22 17:24:14 2012 -0800
    12.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    12.3 @@ -1,1025 +0,0 @@
    12.4 -/**
    12.5 - * Original code: automated SDL platform test written by Edgar Simo "bobbens"
    12.6 - * Extended and extensively updated by aschiffler at ferzkopp dot net
    12.7 - */
    12.8 -
    12.9 -#include <stdio.h>
   12.10 -
   12.11 -#include "SDL.h"
   12.12 -#include "SDL_test.h"
   12.13 -
   12.14 -/* ================= Test Case Implementation ================== */
   12.15 -
   12.16 -#define TESTRENDER_SCREEN_W     80
   12.17 -#define TESTRENDER_SCREEN_H     60
   12.18 -
   12.19 -#define RENDER_COMPARE_FORMAT  SDL_PIXELFORMAT_ARGB8888
   12.20 -#define RENDER_COMPARE_AMASK   0xff000000 /**< Alpha bit mask. */
   12.21 -#define RENDER_COMPARE_RMASK   0x00ff0000 /**< Red bit mask. */
   12.22 -#define RENDER_COMPARE_GMASK   0x0000ff00 /**< Green bit mask. */
   12.23 -#define RENDER_COMPARE_BMASK   0x000000ff /**< Blue bit mask. */
   12.24 -
   12.25 -#define ALLOWABLE_ERROR_OPAQUE	0
   12.26 -#define ALLOWABLE_ERROR_BLENDED	64
   12.27 -
   12.28 -SDL_Window *window = NULL;
   12.29 -SDL_Renderer *renderer = NULL;
   12.30 -
   12.31 -/* Prototypes for helper functions */
   12.32 -
   12.33 -static int _clearScreen (void);
   12.34 -static void _compare(const char *msg, SDL_Surface *s, int allowable_error);
   12.35 -static int _hasTexAlpha(void);
   12.36 -static int _hasTexColor(void);
   12.37 -static SDL_Texture *_loadTestFace(void);
   12.38 -static int _hasBlendModes(void);
   12.39 -static int _hasDrawColor(void);
   12.40 -static int _isSupported(int code);
   12.41 -
   12.42 -/**
   12.43 - * Create software renderer for tests
   12.44 - */
   12.45 -void InitCreateRenderer(void *arg)
   12.46 -{
   12.47 -  int posX = 100, posY = 100, width = 320, height = 240;
   12.48 -  renderer = NULL;
   12.49 -  window = SDL_CreateWindow("render_testCreateRenderer", posX, posY, width, height, 0);
   12.50 -  SDLTest_AssertPass("SDL_CreateWindow()");
   12.51 -  SDLTest_AssertCheck(window != NULL, "Check SDL_CreateWindow result");
   12.52 -  if (window == NULL) {
   12.53 -      return;
   12.54 -  }
   12.55 -  
   12.56 -  renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED);
   12.57 -  SDLTest_AssertPass("SDL_CreateRenderer()");
   12.58 -  SDLTest_AssertCheck(renderer != 0, "Check SDL_CreateRenderer result");
   12.59 -  if (renderer == 0) {
   12.60 -      SDL_DestroyWindow(window);
   12.61 -      return;
   12.62 -  }
   12.63 -}
   12.64 -
   12.65 -/*
   12.66 - * Destroy renderer for tests  
   12.67 - */
   12.68 -void CleanupDestroyRenderer(void *arg)
   12.69 -{
   12.70 -  if (renderer != NULL) {  
   12.71 -     SDL_DestroyRenderer(renderer);
   12.72 -     SDLTest_AssertPass("SDL_DestroyRenderer()");
   12.73 -  }
   12.74 -  
   12.75 -  if (window != NULL) {  
   12.76 -     SDL_DestroyWindow(window);
   12.77 -     SDLTest_AssertPass("SDL_DestroyWindow");
   12.78 -  }
   12.79 -}
   12.80 -
   12.81 -
   12.82 -/**
   12.83 - * @brief Tests call to SDL_GetNumRenderDrivers
   12.84 - *
   12.85 - * \sa
   12.86 - * http://wiki.libsdl.org/moin.cgi/SDL_GetNumRenderDrivers
   12.87 - */
   12.88 -int
   12.89 -render_testGetNumRenderDrivers(void *arg)
   12.90 -{
   12.91 -  int n;
   12.92 -  n = SDL_GetNumRenderDrivers();
   12.93 -  SDLTest_AssertCheck(n >= 1, "Number of renderers >= 1, reported as %i", n);
   12.94 -  return TEST_COMPLETED;
   12.95 -}
   12.96 -
   12.97 -
   12.98 -/**
   12.99 - * @brief Tests the SDL primitives for rendering.
  12.100 - *
  12.101 - * \sa
  12.102 - * http://wiki.libsdl.org/moin.cgi/SDL_SetRenderDrawColor
  12.103 - * http://wiki.libsdl.org/moin.cgi/SDL_RenderFillRect
  12.104 - * http://wiki.libsdl.org/moin.cgi/SDL_RenderDrawLine
  12.105 - *
  12.106 - */
  12.107 -int render_testPrimitives (void *arg)
  12.108 -{
  12.109 -   int ret;
  12.110 -   int x, y;
  12.111 -   SDL_Rect rect;
  12.112 -   int checkFailCount1;
  12.113 -   int checkFailCount2;
  12.114 -
  12.115 -   /* Need drawcolour or just skip test. */
  12.116 -   SDLTest_AssertCheck(_hasDrawColor(), "_hasDrawColor");
  12.117 -
  12.118 -   /* Draw a rectangle. */
  12.119 -   rect.x = 40;
  12.120 -   rect.y = 0;
  12.121 -   rect.w = 40;
  12.122 -   rect.h = 80;
  12.123 -
  12.124 -   ret = SDL_SetRenderDrawColor(renderer, 13, 73, 200, SDL_ALPHA_OPAQUE );
  12.125 -   SDLTest_AssertCheck(ret == 0, "Validate result from SDL_SetRenderDrawColor, expected: 0, got: %i", ret);
  12.126 -
  12.127 -   ret = SDL_RenderFillRect(renderer, &rect );
  12.128 -   SDLTest_AssertCheck(ret == 0, "Validate result from SDL_RenderFillRect, expected: 0, got: %i", ret);
  12.129 -
  12.130 -   /* Draw a rectangle. */
  12.131 -   rect.x = 10;
  12.132 -   rect.y = 10;
  12.133 -   rect.w = 60;
  12.134 -   rect.h = 40;
  12.135 -   ret = SDL_SetRenderDrawColor(renderer, 200, 0, 100, SDL_ALPHA_OPAQUE );
  12.136 -   SDLTest_AssertCheck(ret == 0, "Validate result from SDL_SetRenderDrawColor, expected: 0, got: %i", ret);
  12.137 -
  12.138 -   ret = SDL_RenderFillRect(renderer, &rect );
  12.139 -   SDLTest_AssertCheck(ret == 0, "Validate result from SDL_RenderFillRect, expected: 0, got: %i", ret);
  12.140 -
  12.141 -   /* Draw some points like so:
  12.142 -    * X.X.X.X..
  12.143 -    * .X.X.X.X.
  12.144 -    * X.X.X.X.. */
  12.145 -   checkFailCount1 = 0;
  12.146 -   checkFailCount2 = 0;
  12.147 -   for (y=0; y<3; y++) {
  12.148 -      for (x = y % 2; x<TESTRENDER_SCREEN_W; x+=2) {
  12.149 -         ret = SDL_SetRenderDrawColor(renderer, x*y, x*y/2, x*y/3, SDL_ALPHA_OPAQUE );
  12.150 -         if (ret != 0) checkFailCount1++;
  12.151 -
  12.152 -         ret = SDL_RenderDrawPoint(renderer, x, y );
  12.153 -         if (ret != 0) checkFailCount2++;
  12.154 -      }
  12.155 -   }
  12.156 -   SDLTest_AssertCheck(checkFailCount1 == 0, "Validate results from calls to SDL_SetRenderDrawColor, expected: 0, got: %i", checkFailCount1);
  12.157 -   SDLTest_AssertCheck(checkFailCount2 == 0, "Validate results from calls to SDL_RenderDrawPoint, expected: 0, got: %i", checkFailCount2);
  12.158 -
  12.159 -   /* Draw some lines. */
  12.160 -   ret = SDL_SetRenderDrawColor(renderer, 0, 255, 0, SDL_ALPHA_OPAQUE );
  12.161 -   SDLTest_AssertCheck(ret == 0, "Validate result from SDL_SetRenderDrawColor");
  12.162 -
  12.163 -   ret = SDL_RenderDrawLine(renderer, 0, 30, TESTRENDER_SCREEN_W, 30 );
  12.164 -   SDLTest_AssertCheck(ret == 0, "Validate result from SDL_RenderDrawLine, expected: 0, got: %i", ret);
  12.165 -
  12.166 -   ret = SDL_SetRenderDrawColor(renderer, 55, 55, 5, SDL_ALPHA_OPAQUE );
  12.167 -   SDLTest_AssertCheck(ret == 0, "Validate result from SDL_SetRenderDrawColor, expected: 0, got: %i", ret);
  12.168 -
  12.169 -   ret = SDL_RenderDrawLine(renderer, 40, 30, 40, 60 );
  12.170 -   SDLTest_AssertCheck(ret == 0, "Validate result from SDL_RenderDrawLine, expected: 0, got: %i", ret);
  12.171 -
  12.172 -   ret = SDL_SetRenderDrawColor(renderer, 5, 105, 105, SDL_ALPHA_OPAQUE );
  12.173 -   SDLTest_AssertCheck(ret == 0, "Validate result from SDL_SetRenderDrawColor, expected: 0, got: %i", ret);
  12.174 -
  12.175 -   ret = SDL_RenderDrawLine(renderer, 0, 0, 29, 29 );
  12.176 -   SDLTest_AssertCheck(ret == 0, "Validate result from SDL_RenderDrawLine, expected: 0, got: %i", ret);
  12.177 -
  12.178 -   ret = SDL_RenderDrawLine(renderer, 29, 30, 0, 59 );
  12.179 -   SDLTest_AssertCheck(ret == 0, "Validate result from SDL_RenderDrawLine, expected: 0, got: %i", ret);
  12.180 -
  12.181 -   ret = SDL_RenderDrawLine(renderer, 79, 0, 50, 29 );
  12.182 -   SDLTest_AssertCheck(ret == 0, "Validate result from SDL_RenderDrawLine, expected: 0, got: %i", ret);
  12.183 -
  12.184 -   ret = SDL_RenderDrawLine(renderer, 79, 59, 50, 30 );
  12.185 -   SDLTest_AssertCheck(ret == 0, "Validate result from SDL_RenderDrawLine, expected: 0, got: %i", ret);
  12.186 -
  12.187 -   /* See if it's the same. */
  12.188 -   _compare( "Primitives output not the same.", SDLTest_ImagePrimitives(), ALLOWABLE_ERROR_OPAQUE );
  12.189 -
  12.190 -   return TEST_COMPLETED;
  12.191 -}
  12.192 -
  12.193 -/**
  12.194 - * @brief Tests the SDL primitives with alpha for rendering.
  12.195 - *
  12.196 - * \sa
  12.197 - * http://wiki.libsdl.org/moin.cgi/SDL_SetRenderDrawColor
  12.198 - * http://wiki.libsdl.org/moin.cgi/SDL_SetRenderDrawBlendMode
  12.199 - * http://wiki.libsdl.org/moin.cgi/SDL_RenderFillRect
  12.200 - */
  12.201 -int render_testPrimitivesBlend (void *arg)
  12.202 -{
  12.203 -   int ret;
  12.204 -   int i, j;
  12.205 -   SDL_Rect rect;
  12.206 -   int checkFailCount1;
  12.207 -   int checkFailCount2;
  12.208 -   int checkFailCount3;
  12.209 -
  12.210 -   /* Need drawcolour and blendmode or just skip test. */
  12.211 -   SDLTest_AssertCheck(_hasDrawColor(), "_hasDrawColor");
  12.212 -   SDLTest_AssertCheck(_hasBlendModes(), "_hasBlendModes");
  12.213 -
  12.214 -   /* Create some rectangles for each blend mode. */
  12.215 -   ret = SDL_SetRenderDrawColor(renderer, 255, 255, 255, 0 );
  12.216 -   SDLTest_AssertCheck(ret == 0, "Validate result from SDL_SetRenderDrawColor, expected: 0, got: %i", ret);
  12.217 -
  12.218 -   ret = SDL_SetRenderDrawBlendMode(renderer, SDL_BLENDMODE_NONE );
  12.219 -   SDLTest_AssertCheck(ret == 0, "Validate result from SDL_SetRenderDrawBlendMode, expected: 0, got: %i", ret);
  12.220 -
  12.221 -   ret = SDL_RenderFillRect(renderer, NULL );
  12.222 -   SDLTest_AssertCheck(ret == 0, "Validate result from SDL_RenderFillRect, expected: 0, got: %i", ret);
  12.223 -
  12.224 -   rect.x = 10;
  12.225 -   rect.y = 25;
  12.226 -   rect.w = 40;
  12.227 -   rect.h = 25;
  12.228 -   ret = SDL_SetRenderDrawColor(renderer, 240, 10, 10, 75 );
  12.229 -   SDLTest_AssertCheck(ret == 0, "Validate result from SDL_SetRenderDrawColor, expected: 0, got: %i", ret);
  12.230 -
  12.231 -   ret = SDL_SetRenderDrawBlendMode(renderer, SDL_BLENDMODE_ADD );
  12.232 -   SDLTest_AssertCheck(ret == 0, "Validate result from SDL_SetRenderDrawBlendMode, expected: 0, got: %i", ret);
  12.233 -
  12.234 -   ret = SDL_RenderFillRect(renderer, &rect );
  12.235 -   SDLTest_AssertCheck(ret == 0, "Validate result from SDL_RenderFillRect, expected: 0, got: %i", ret);
  12.236 -
  12.237 -   rect.x = 30;
  12.238 -   rect.y = 40;
  12.239 -   rect.w = 45;
  12.240 -   rect.h = 15;
  12.241 -   ret = SDL_SetRenderDrawColor(renderer, 10, 240, 10, 100 );
  12.242 -   SDLTest_AssertCheck(ret == 0, "Validate result from SDL_SetRenderDrawColor, expected: 0, got: %i", ret);
  12.243 -
  12.244 -   ret = SDL_SetRenderDrawBlendMode(renderer, SDL_BLENDMODE_BLEND );
  12.245 -   SDLTest_AssertCheck(ret == 0, "Validate result from SDL_SetRenderDrawBlendMode, expected: 0, got: %i", ret);
  12.246 -
  12.247 -   ret = SDL_RenderFillRect(renderer, &rect );
  12.248 -   SDLTest_AssertCheck(ret == 0, "Validate result from SDL_RenderFillRect, expected: 0, got: %i", ret);
  12.249 -
  12.250 -   rect.x = 25;
  12.251 -   rect.y = 25;
  12.252 -   rect.w = 25;
  12.253 -   rect.h = 25;
  12.254 -   ret = SDL_SetRenderDrawColor(renderer, 10, 10, 240, 125 );
  12.255 -   SDLTest_AssertCheck(ret == 0, "Validate result from SDL_SetRenderDrawColor, expected: 0, got: %i", ret);
  12.256 -
  12.257 -   ret = SDL_SetRenderDrawBlendMode(renderer, SDL_BLENDMODE_NONE );
  12.258 -   SDLTest_AssertCheck(ret == 0, "Validate result from SDL_SetRenderDrawBlendMode, expected: 0, got: %i", ret);
  12.259 -
  12.260 -   ret = SDL_RenderFillRect(renderer, &rect );
  12.261 -   SDLTest_AssertCheck(ret == 0, "Validate result from SDL_RenderFillRect, expected: 0, got: %i", ret);
  12.262 -
  12.263 -
  12.264 -   /* Draw blended lines, lines for everyone. */
  12.265 -   checkFailCount1 = 0;
  12.266 -   checkFailCount2 = 0;
  12.267 -   checkFailCount3 = 0;
  12.268 -   for (i=0; i<TESTRENDER_SCREEN_W; i+=2)  {
  12.269 -      ret = SDL_SetRenderDrawColor(renderer, 60+2*i, 240-2*i, 50, 3*i );
  12.270 -      if (ret != 0) checkFailCount1++;
  12.271 -
  12.272 -      ret = SDL_SetRenderDrawBlendMode(renderer,(((i/2)%3)==0) ? SDL_BLENDMODE_BLEND :
  12.273 -            (((i/2)%3)==1) ? SDL_BLENDMODE_ADD : SDL_BLENDMODE_NONE );
  12.274 -      if (ret != 0) checkFailCount2++;
  12.275 -
  12.276 -      ret = SDL_RenderDrawLine(renderer, 0, 0, i, 59 );
  12.277 -      if (ret != 0) checkFailCount3++;
  12.278 -   }
  12.279 -   SDLTest_AssertCheck(checkFailCount1 == 0, "Validate results from calls to SDL_SetRenderDrawColor, expected: 0, got: %i", checkFailCount1);
  12.280 -   SDLTest_AssertCheck(checkFailCount2 == 0, "Validate results from calls to SDL_SetRenderDrawBlendMode, expected: 0, got: %i", checkFailCount2);
  12.281 -   SDLTest_AssertCheck(checkFailCount3 == 0, "Validate results from calls to SDL_RenderDrawLine, expected: 0, got: %i", checkFailCount3);
  12.282 -   
  12.283 -   checkFailCount1 = 0;
  12.284 -   checkFailCount2 = 0;
  12.285 -   checkFailCount3 = 0;
  12.286 -   for (i=0; i<TESTRENDER_SCREEN_H; i+=2)  {
  12.287 -      ret = SDL_SetRenderDrawColor(renderer, 60+2*i, 240-2*i, 50, 3*i );
  12.288 -      if (ret != 0) checkFailCount1++;
  12.289 -
  12.290 -      ret = SDL_SetRenderDrawBlendMode(renderer,(((i/2)%3)==0) ? SDL_BLENDMODE_BLEND :
  12.291 -            (((i/2)%3)==1) ? SDL_BLENDMODE_ADD : SDL_BLENDMODE_NONE );
  12.292 -      if (ret != 0) checkFailCount2++;
  12.293 -
  12.294 -      ret = SDL_RenderDrawLine(renderer, 0, 0, 79, i );
  12.295 -      if (ret != 0) checkFailCount3++;
  12.296 -   }
  12.297 -   SDLTest_AssertCheck(checkFailCount1 == 0, "Validate results from calls to SDL_SetRenderDrawColor, expected: 0, got: %i", checkFailCount1);
  12.298 -   SDLTest_AssertCheck(checkFailCount2 == 0, "Validate results from calls to SDL_SetRenderDrawBlendMode, expected: 0, got: %i", checkFailCount2);
  12.299 -   SDLTest_AssertCheck(checkFailCount3 == 0, "Validate results from calls to SDL_RenderDrawLine, expected: 0, got: %i", checkFailCount3);
  12.300 -
  12.301 -   /* Draw points. */
  12.302 -   checkFailCount1 = 0;
  12.303 -   checkFailCount2 = 0;
  12.304 -   checkFailCount3 = 0;
  12.305 -   for (j=0; j<TESTRENDER_SCREEN_H; j+=3) {
  12.306 -      for (i=0; i<TESTRENDER_SCREEN_W; i+=3) {
  12.307 -         ret = SDL_SetRenderDrawColor(renderer, j*4, i*3, j*4, i*3 );
  12.308 -         if (ret != 0) checkFailCount1++;
  12.309 -
  12.310 -         ret = SDL_SetRenderDrawBlendMode(renderer, ((((i+j)/3)%3)==0) ? SDL_BLENDMODE_BLEND :
  12.311 -               ((((i+j)/3)%3)==1) ? SDL_BLENDMODE_ADD : SDL_BLENDMODE_NONE );
  12.312 -         if (ret != 0) checkFailCount2++;
  12.313 -
  12.314 -         ret = SDL_RenderDrawPoint(renderer, i, j );
  12.315 -         if (ret != 0) checkFailCount3++;
  12.316 -      }
  12.317 -   }   
  12.318 -   SDLTest_AssertCheck(checkFailCount1 == 0, "Validate results from calls to SDL_SetRenderDrawColor, expected: 0, got: %i", checkFailCount1);
  12.319 -   SDLTest_AssertCheck(checkFailCount2 == 0, "Validate results from calls to SDL_SetRenderDrawBlendMode, expected: 0, got: %i", checkFailCount2);
  12.320 -   SDLTest_AssertCheck(checkFailCount3 == 0, "Validate results from calls to SDL_RenderDrawPoint, expected: 0, got: %i", checkFailCount3);
  12.321 -
  12.322 -   /* See if it's the same. */
  12.323 -   _compare( "Blended primitives output not the same.", SDLTest_ImagePrimitivesBlend(), ALLOWABLE_ERROR_BLENDED );
  12.324 -
  12.325 -    return TEST_COMPLETED;
  12.326 -}
  12.327 -
  12.328 -
  12.329 -
  12.330 -/**
  12.331 - * @brief Tests some blitting routines.
  12.332 - *
  12.333 - * \sa
  12.334 - * http://wiki.libsdl.org/moin.cgi/SDL_RenderCopy
  12.335 - * http://wiki.libsdl.org/moin.cgi/SDL_DestroyTexture
  12.336 - */
  12.337 -int
  12.338 -render_testBlit(void *arg)
  12.339 -{
  12.340 -   int ret;
  12.341 -   SDL_Rect rect;
  12.342 -   SDL_Texture *tface;
  12.343 -   Uint32 tformat;
  12.344 -   int taccess, tw, th;
  12.345 -   int i, j, ni, nj;
  12.346 -   int checkFailCount1;
  12.347 -
  12.348 -
  12.349 -   /* Need drawcolour or just skip test. */
  12.350 -   SDLTest_AssertCheck(_hasDrawColor(), "_hasDrawColor)");
  12.351 -
  12.352 -   /* Create face surface. */
  12.353 -   tface = _loadTestFace();
  12.354 -   SDLTest_AssertCheck(tface != NULL,  "Verify _loadTestFace() result");
  12.355 -   if (tface == NULL) {
  12.356 -       return TEST_ABORTED;
  12.357 -   }
  12.358 -
  12.359 -   /* Constant values. */
  12.360 -   ret = SDL_QueryTexture(tface, &tformat, &taccess, &tw, &th);
  12.361 -   SDLTest_AssertCheck(ret == 0, "Verify result from SDL_QueryTexture, expected 0, got %i", ret);
  12.362 -   rect.w = tw;
  12.363 -   rect.h = th;
  12.364 -   ni     = TESTRENDER_SCREEN_W - tw;
  12.365 -   nj     = TESTRENDER_SCREEN_H - th;
  12.366 -
  12.367 -   /* Loop blit. */
  12.368 -   checkFailCount1 = 0;
  12.369 -   for (j=0; j <= nj; j+=4) {
  12.370 -      for (i=0; i <= ni; i+=4) {
  12.371 -         /* Blitting. */
  12.372 -         rect.x = i;
  12.373 -         rect.y = j;
  12.374 -         ret = SDL_RenderCopy(renderer, tface, NULL, &rect );
  12.375 -         if (ret != 0) checkFailCount1++;
  12.376 -      }
  12.377 -   }
  12.378 -   SDLTest_AssertCheck(checkFailCount1 == 0, "Validate results from calls to SDL_RenderCopy, expected: 0, got: %i", checkFailCount1);
  12.379 -
  12.380 -   /* Clean up. */
  12.381 -   SDL_DestroyTexture( tface );
  12.382 -
  12.383 -   /* See if it's the same */
  12.384 -   _compare( "Blit output not the same.", SDLTest_ImageBlit(), ALLOWABLE_ERROR_OPAQUE );
  12.385 -
  12.386 -   return TEST_COMPLETED;
  12.387 -}
  12.388 -
  12.389 -
  12.390 -/**
  12.391 - * @brief Blits doing colour tests.
  12.392 - *
  12.393 - * \sa
  12.394 - * http://wiki.libsdl.org/moin.cgi/SDL_SetTextureColorMod
  12.395 - * http://wiki.libsdl.org/moin.cgi/SDL_RenderCopy
  12.396 - * http://wiki.libsdl.org/moin.cgi/SDL_DestroyTexture
  12.397 - */
  12.398 -int
  12.399 -render_testBlitColor (void *arg)
  12.400 -{
  12.401 -   int ret;
  12.402 -   SDL_Rect rect;
  12.403 -   SDL_Texture *tface;
  12.404 -   Uint32 tformat;
  12.405 -   int taccess, tw, th;
  12.406 -   int i, j, ni, nj;
  12.407 -   int checkFailCount1;
  12.408 -   int checkFailCount2;
  12.409 -
  12.410 -   /* Create face surface. */
  12.411 -   tface = _loadTestFace();
  12.412 -   SDLTest_AssertCheck(tface != NULL, "Verify _loadTestFace() result");
  12.413 -   if (tface == NULL) {
  12.414 -       return TEST_ABORTED;
  12.415 -   }
  12.416 -
  12.417 -   /* Constant values. */
  12.418 -   ret = SDL_QueryTexture(tface, &tformat, &taccess, &tw, &th);
  12.419 -   SDLTest_AssertCheck(ret == 0, "Verify result from SDL_QueryTexture, expected 0, got %i", ret);
  12.420 -   rect.w = tw;
  12.421 -   rect.h = th;
  12.422 -   ni     = TESTRENDER_SCREEN_W - tw;
  12.423 -   nj     = TESTRENDER_SCREEN_H - th;
  12.424 -
  12.425 -   /* Test blitting with colour mod. */
  12.426 -   checkFailCount1 = 0;
  12.427 -   checkFailCount2 = 0;
  12.428 -   for (j=0; j <= nj; j+=4) {
  12.429 -      for (i=0; i <= ni; i+=4) {
  12.430 -         /* Set colour mod. */
  12.431 -         ret = SDL_SetTextureColorMod( tface, (255/nj)*j, (255/ni)*i, (255/nj)*j );
  12.432 -         if (ret != 0) checkFailCount1++;
  12.433 -
  12.434 -         /* Blitting. */
  12.435 -         rect.x = i;
  12.436 -         rect.y = j;
  12.437 -         ret = SDL_RenderCopy(renderer, tface, NULL, &rect );
  12.438 -         if (ret != 0) checkFailCount2++;
  12.439 -      }
  12.440 -   }
  12.441 -   SDLTest_AssertCheck(checkFailCount1 == 0, "Validate results from calls to SDL_SetTextureColorMod, expected: 0, got: %i", checkFailCount1);
  12.442 -   SDLTest_AssertCheck(checkFailCount2 == 0, "Validate results from calls to SDL_RenderCopy, expected: 0, got: %i", checkFailCount2);
  12.443 -
  12.444 -   /* Clean up. */
  12.445 -   SDL_DestroyTexture( tface );
  12.446 -
  12.447 -   /* See if it's the same. */
  12.448 -   _compare( "Blit output not the same (using SDL_SetTextureColorMod).",
  12.449 -            SDLTest_ImageBlitColor(), ALLOWABLE_ERROR_OPAQUE );
  12.450 -
  12.451 -   return TEST_COMPLETED;
  12.452 -}
  12.453 -
  12.454 -
  12.455 -/**
  12.456 - * @brief Tests blitting with alpha.
  12.457 - *
  12.458 - * \sa
  12.459 - * http://wiki.libsdl.org/moin.cgi/SDL_SetTextureAlphaMod
  12.460 - * http://wiki.libsdl.org/moin.cgi/SDL_RenderCopy
  12.461 - * http://wiki.libsdl.org/moin.cgi/SDL_DestroyTexture
  12.462 - */
  12.463 -int
  12.464 -render_testBlitAlpha (void *arg)
  12.465 -{
  12.466 -   int ret;
  12.467 -   SDL_Rect rect;
  12.468 -   SDL_Texture *tface;
  12.469 -   Uint32 tformat;
  12.470 -   int taccess, tw, th;
  12.471 -   int i, j, ni, nj;
  12.472 -   int checkFailCount1;
  12.473 -   int checkFailCount2;
  12.474 -
  12.475 -
  12.476 -   /* Need alpha or just skip test. */
  12.477 -   SDLTest_AssertCheck(_hasTexAlpha(), "_hasTexAlpha");
  12.478 -
  12.479 -   /* Create face surface. */
  12.480 -   tface = _loadTestFace();
  12.481 -   SDLTest_AssertCheck(tface != NULL, "Verify _loadTestFace() result");
  12.482 -   if (tface == NULL) {
  12.483 -       return TEST_ABORTED;
  12.484 -   }
  12.485 -
  12.486 -   /* Constant values. */
  12.487 -   ret = SDL_QueryTexture(tface, &tformat, &taccess, &tw, &th);
  12.488 -   SDLTest_AssertCheck(ret == 0, "Verify result from SDL_QueryTexture, expected 0, got %i", ret);
  12.489 -   rect.w = tw;
  12.490 -   rect.h = th;
  12.491 -   ni     = TESTRENDER_SCREEN_W - tw;
  12.492 -   nj     = TESTRENDER_SCREEN_H - th;
  12.493 -
  12.494 -   /* Test blitting with alpha mod. */
  12.495 -   checkFailCount1 = 0;
  12.496 -   checkFailCount2 = 0;
  12.497 -   for (j=0; j <= nj; j+=4) {
  12.498 -      for (i=0; i <= ni; i+=4) {
  12.499 -         /* Set alpha mod. */
  12.500 -         ret = SDL_SetTextureAlphaMod( tface, (255/ni)*i );
  12.501 -         if (ret != 0) checkFailCount1++;
  12.502 -
  12.503 -         /* Blitting. */
  12.504 -         rect.x = i;
  12.505 -         rect.y = j;
  12.506 -         ret = SDL_RenderCopy(renderer, tface, NULL, &rect );
  12.507 -         if (ret != 0) checkFailCount2++;
  12.508 -      }
  12.509 -   }   
  12.510 -   SDLTest_AssertCheck(checkFailCount1 == 0, "Validate results from calls to SDL_SetTextureAlphaMod, expected: 0, got: %i", checkFailCount1);
  12.511 -   SDLTest_AssertCheck(checkFailCount2 == 0, "Validate results from calls to SDL_RenderCopy, expected: 0, got: %i", checkFailCount2);
  12.512 -
  12.513 -   /* Clean up. */
  12.514 -   SDL_DestroyTexture( tface );
  12.515 -
  12.516 -   /* See if it's the same. */
  12.517 -   _compare( "Blit output not the same (using SDL_SetSurfaceAlphaMod).",
  12.518 -            SDLTest_ImageBlitAlpha(), ALLOWABLE_ERROR_BLENDED );
  12.519 -
  12.520 -   return TEST_COMPLETED;
  12.521 -}
  12.522 -
  12.523 -/* Helper functions */
  12.524 -
  12.525 -/**
  12.526 - * @brief Tests a blend mode.
  12.527 - *
  12.528 - * \sa
  12.529 - * http://wiki.libsdl.org/moin.cgi/SDL_SetTextureBlendMode
  12.530 - * http://wiki.libsdl.org/moin.cgi/SDL_RenderCopy
  12.531 - */
  12.532 -static void
  12.533 -_testBlitBlendMode( SDL_Texture * tface, int mode )
  12.534 -{
  12.535 -   int ret;
  12.536 -   Uint32 tformat;
  12.537 -   int taccess, tw, th;
  12.538 -   int i, j, ni, nj;
  12.539 -   SDL_Rect rect;
  12.540 -   int checkFailCount1;
  12.541 -   int checkFailCount2;
  12.542 -
  12.543 -   /* Clear surface. */
  12.544 -   _clearScreen();
  12.545 -
  12.546 -   /* Constant values. */
  12.547 -   ret = SDL_QueryTexture(tface, &tformat, &taccess, &tw, &th);
  12.548 -   SDLTest_AssertCheck(ret == 0, "Verify result from SDL_QueryTexture, expected 0, got %i", ret);
  12.549 -   rect.w = tw;
  12.550 -   rect.h = th;
  12.551 -   ni     = TESTRENDER_SCREEN_W - tw;
  12.552 -   nj     = TESTRENDER_SCREEN_H - th;
  12.553 -
  12.554 -   /* Test blend mode. */
  12.555 -   checkFailCount1 = 0;
  12.556 -   checkFailCount2 = 0;
  12.557 -   for (j=0; j <= nj; j+=4) {
  12.558 -      for (i=0; i <= ni; i+=4) {
  12.559 -         /* Set blend mode. */
  12.560 -         ret = SDL_SetTextureBlendMode( tface, (SDL_BlendMode)mode );
  12.561 -         if (ret != 0) checkFailCount1++;
  12.562 -
  12.563 -         /* Blitting. */
  12.564 -         rect.x = i;
  12.565 -         rect.y = j;
  12.566 -         ret = SDL_RenderCopy(renderer, tface, NULL, &rect );
  12.567 -         if (ret != 0) checkFailCount2++;
  12.568 -      }
  12.569 -   }
  12.570 -   SDLTest_AssertCheck(checkFailCount1 == 0, "Validate results from calls to SDL_SetTextureBlendMode, expected: 0, got: %i", checkFailCount1);
  12.571 -   SDLTest_AssertCheck(checkFailCount2 == 0, "Validate results from calls to SDL_RenderCopy, expected: 0, got: %i", checkFailCount2);
  12.572 -}
  12.573 -
  12.574 -
  12.575 -/**
  12.576 - * @brief Tests some more blitting routines.
  12.577 - *
  12.578 - * \sa
  12.579 - * http://wiki.libsdl.org/moin.cgi/SDL_SetTextureColorMod
  12.580 - * http://wiki.libsdl.org/moin.cgi/SDL_SetTextureAlphaMod
  12.581 - * http://wiki.libsdl.org/moin.cgi/SDL_SetTextureBlendMode
  12.582 - * http://wiki.libsdl.org/moin.cgi/SDL_DestroyTexture
  12.583 - */
  12.584 -int
  12.585 -render_testBlitBlend (void *arg)
  12.586 -{
  12.587 -   int ret;
  12.588 -   SDL_Rect rect;
  12.589 -   SDL_Texture *tface;
  12.590 -   Uint32 tformat;
  12.591 -   int taccess, tw, th;
  12.592 -   int i, j, ni, nj;
  12.593 -   int mode;
  12.594 -   int checkFailCount1;
  12.595 -   int checkFailCount2;
  12.596 -   int checkFailCount3;
  12.597 -   int checkFailCount4;
  12.598 -
  12.599 -   SDLTest_AssertCheck(_hasBlendModes(), "_hasBlendModes");
  12.600 -   SDLTest_AssertCheck(_hasTexColor(), "_hasTexColor");
  12.601 -   SDLTest_AssertCheck(_hasTexAlpha(), "_hasTexAlpha");
  12.602 -
  12.603 -   /* Create face surface. */
  12.604 -   tface = _loadTestFace();
  12.605 -   SDLTest_AssertCheck(tface != NULL, "Verify _loadTestFace() result");
  12.606 -   if (tface == NULL) {
  12.607 -       return TEST_ABORTED;
  12.608 -   }
  12.609 -
  12.610 -   /* Constant values. */
  12.611 -   ret = SDL_QueryTexture(tface, &tformat, &taccess, &tw, &th);
  12.612 -   SDLTest_AssertCheck(ret == 0, "Verify result from SDL_QueryTexture, expected 0, got %i", ret);
  12.613 -   rect.w = tw;
  12.614 -   rect.h = th;
  12.615 -   ni = TESTRENDER_SCREEN_W - tw;
  12.616 -   nj = TESTRENDER_SCREEN_H - th;
  12.617 -
  12.618 -   /* Set alpha mod. */
  12.619 -   ret = SDL_SetTextureAlphaMod( tface, 100 );
  12.620 -   SDLTest_AssertCheck(ret == 0, "Validate result from SDL_SetTextureAlphaMod, expected: 0, got: %i", ret);
  12.621 -
  12.622 -   /* Test None. */
  12.623 -   _testBlitBlendMode( tface, SDL_BLENDMODE_NONE );
  12.624 -   /* See if it's the same. */
  12.625 -   _compare( "Blit blending output not the same (using SDL_BLENDMODE_NONE).",
  12.626 -            SDLTest_ImageBlitBlendNone(), ALLOWABLE_ERROR_OPAQUE ); 
  12.627 -
  12.628 -
  12.629 -   /* Test Blend. */
  12.630 -   _testBlitBlendMode( tface, SDL_BLENDMODE_BLEND );
  12.631 -   _compare( "Blit blending output not the same (using SDL_BLENDMODE_BLEND).",
  12.632 -            SDLTest_ImageBlitBlend(), ALLOWABLE_ERROR_BLENDED );
  12.633 -
  12.634 -
  12.635 -   /* Test Add. */
  12.636 -   _testBlitBlendMode( tface, SDL_BLENDMODE_ADD );
  12.637 -   _compare( "Blit blending output not the same (using SDL_BLENDMODE_ADD).",
  12.638 -            SDLTest_ImageBlitBlendAdd(), ALLOWABLE_ERROR_BLENDED );
  12.639 -
  12.640 -   /* Test Mod. */
  12.641 -   _testBlitBlendMode( tface, SDL_BLENDMODE_MOD);
  12.642 -   _compare( "Blit blending output not the same (using SDL_BLENDMODE_MOD).",
  12.643 -            SDLTest_ImageBlitBlendMod(), ALLOWABLE_ERROR_BLENDED );
  12.644 -
  12.645 -   /* Clear surface. */
  12.646 -   _clearScreen();
  12.647 -
  12.648 -   /* Loop blit. */
  12.649 -   checkFailCount1 = 0;
  12.650 -   checkFailCount2 = 0;
  12.651 -   checkFailCount3 = 0;
  12.652 -   checkFailCount4 = 0;
  12.653 -   for (j=0; j <= nj; j+=4) {
  12.654 -      for (i=0; i <= ni; i+=4) {
  12.655 -
  12.656 -         /* Set colour mod. */
  12.657 -         ret = SDL_SetTextureColorMod( tface, (255/nj)*j, (255/ni)*i, (255/nj)*j );
  12.658 -         if (ret != 0) checkFailCount1++;
  12.659 -
  12.660 -         /* Set alpha mod. */
  12.661 -         ret = SDL_SetTextureAlphaMod( tface, (100/ni)*i );
  12.662 -         if (ret != 0) checkFailCount2++;
  12.663 -
  12.664 -         /* Crazy blending mode magic. */
  12.665 -         mode = (i/4*j/4) % 4;
  12.666 -         if (mode==0) mode = SDL_BLENDMODE_NONE;
  12.667 -         else if (mode==1) mode = SDL_BLENDMODE_BLEND;
  12.668 -         else if (mode==2) mode = SDL_BLENDMODE_ADD;
  12.669 -         else if (mode==3) mode = SDL_BLENDMODE_MOD;
  12.670 -         ret = SDL_SetTextureBlendMode( tface, (SDL_BlendMode)mode );
  12.671 -         if (ret != 0) checkFailCount3++;
  12.672 -
  12.673 -         /* Blitting. */
  12.674 -         rect.x = i;
  12.675 -         rect.y = j;
  12.676 -         ret = SDL_RenderCopy(renderer, tface, NULL, &rect );
  12.677 -         if (ret != 0) checkFailCount4++;
  12.678 -      }
  12.679 -   }
  12.680 -   SDLTest_AssertCheck(checkFailCount1 == 0, "Validate results from calls to SDL_SetTextureColorMod, expected: 0, got: %i", checkFailCount1);
  12.681 -   SDLTest_AssertCheck(checkFailCount2 == 0, "Validate results from calls to SDL_SetTextureAlphaMod, expected: 0, got: %i", checkFailCount2);
  12.682 -   SDLTest_AssertCheck(checkFailCount3 == 0, "Validate results from calls to SDL_SetTextureBlendMode, expected: 0, got: %i", checkFailCount3);
  12.683 -   SDLTest_AssertCheck(checkFailCount4 == 0, "Validate results from calls to SDL_RenderCopy, expected: 0, got: %i", checkFailCount4);
  12.684 -
  12.685 -   /* Clean up. */
  12.686 -   SDL_DestroyTexture( tface );
  12.687 -
  12.688 -   /* Check to see if matches. */
  12.689 -   _compare( "Blit blending output not the same (using SDL_BLENDMODE_*).",
  12.690 -            SDLTest_ImageBlitBlendAll(), ALLOWABLE_ERROR_BLENDED);
  12.691 -
  12.692 -   return TEST_COMPLETED;
  12.693 -}
  12.694 -
  12.695 -
  12.696 -
  12.697 -/**
  12.698 - * @brief Checks to see if functionality is supported. Helper function.
  12.699 - */
  12.700 -static int
  12.701 -_isSupported( int code )
  12.702 -{
  12.703 -   return (code == 0);
  12.704 -}
  12.705 -
  12.706 -/**
  12.707 - * @brief Test to see if we can vary the draw colour. Helper function.
  12.708 - *
  12.709 - * \sa
  12.710 - * http://wiki.libsdl.org/moin.cgi/SDL_SetRenderDrawColor
  12.711 - * http://wiki.libsdl.org/moin.cgi/SDL_GetRenderDrawColor
  12.712 - */
  12.713 -static int
  12.714 -_hasDrawColor (void)
  12.715 -{
  12.716 -   int ret, fail;
  12.717 -   Uint8 r, g, b, a;
  12.718 -
  12.719 -   fail = 0;
  12.720 -
  12.721 -   /* Set colour. */
  12.722 -   ret = SDL_SetRenderDrawColor(renderer, 100, 100, 100, 100 );
  12.723 -   if (!_isSupported(ret))
  12.724 -      fail = 1;
  12.725 -   ret = SDL_GetRenderDrawColor(renderer, &r, &g, &b, &a );
  12.726 -   if (!_isSupported(ret))
  12.727 -      fail = 1;
  12.728 -   /* Restore natural. */
  12.729 -   ret = SDL_SetRenderDrawColor(renderer, 0, 0, 0, SDL_ALPHA_OPAQUE );
  12.730 -   if (!_isSupported(ret))
  12.731 -      fail = 1;
  12.732 -
  12.733 -   /* Something failed, consider not available. */
  12.734 -   if (fail)
  12.735 -      return 0;
  12.736 -   /* Not set properly, consider failed. */
  12.737 -   else if ((r != 100) || (g != 100) || (b != 100) || (a != 100))
  12.738 -      return 0;
  12.739 -   return 1;
  12.740 -}
  12.741 -
  12.742 -/**
  12.743 - * @brief Test to see if we can vary the blend mode. Helper function.
  12.744 - *
  12.745 - * \sa
  12.746 - * http://wiki.libsdl.org/moin.cgi/SDL_SetRenderDrawBlendMode
  12.747 - * http://wiki.libsdl.org/moin.cgi/SDL_GetRenderDrawBlendMode
  12.748 - */
  12.749 -static int
  12.750 -_hasBlendModes (void)
  12.751 -{
  12.752 -   int fail;
  12.753 -   int ret;
  12.754 -   SDL_BlendMode mode;
  12.755 -
  12.756 -   fail = 0;
  12.757 -
  12.758 -   ret = SDL_SetRenderDrawBlendMode(renderer, SDL_BLENDMODE_BLEND );
  12.759 -   if (!_isSupported(ret))
  12.760 -      fail = 1;
  12.761 -   ret = SDL_GetRenderDrawBlendMode(renderer, &mode );
  12.762 -   if (!_isSupported(ret))
  12.763 -      fail = 1;
  12.764 -   ret = (mode != SDL_BLENDMODE_BLEND);
  12.765 -   if (!_isSupported(ret))
  12.766 -      fail = 1;
  12.767 -   ret = SDL_SetRenderDrawBlendMode(renderer, SDL_BLENDMODE_ADD );
  12.768 -   if (!_isSupported(ret))
  12.769 -      fail = 1;
  12.770 -   ret = SDL_GetRenderDrawBlendMode(renderer, &mode );
  12.771 -   if (!_isSupported(ret))
  12.772 -      fail = 1;
  12.773 -   ret = (mode != SDL_BLENDMODE_ADD);
  12.774 -   if (!_isSupported(ret))
  12.775 -      fail = 1;
  12.776 -   ret = SDL_SetRenderDrawBlendMode(renderer, SDL_BLENDMODE_MOD );
  12.777 -   if (!_isSupported(ret))
  12.778 -      fail = 1;
  12.779 -   ret = SDL_GetRenderDrawBlendMode(renderer, &mode );
  12.780 -   if (!_isSupported(ret))
  12.781 -      fail = 1;
  12.782 -   ret = (mode != SDL_BLENDMODE_MOD);
  12.783 -   if (!_isSupported(ret))
  12.784 -      fail = 1;
  12.785 -   ret = SDL_SetRenderDrawBlendMode(renderer, SDL_BLENDMODE_NONE );
  12.786 -   if (!_isSupported(ret))
  12.787 -      fail = 1;
  12.788 -   ret = SDL_GetRenderDrawBlendMode(renderer, &mode );
  12.789 -   if (!_isSupported(ret))
  12.790 -      fail = 1;
  12.791 -   ret = (mode != SDL_BLENDMODE_NONE);
  12.792 -   if (!_isSupported(ret))
  12.793 -      fail = 1;
  12.794 -
  12.795 -   return !fail;
  12.796 -}
  12.797 -
  12.798 -
  12.799 -/**
  12.800 - * @brief Loads the test image 'Face' as texture. Helper function.
  12.801 - *
  12.802 - * \sa
  12.803 - * http://wiki.libsdl.org/moin.cgi/SDL_CreateTextureFromSurface
  12.804 - */
  12.805 -static SDL_Texture *
  12.806 -_loadTestFace(void)
  12.807 -{
  12.808 -   SDL_Surface *face;
  12.809 -   SDL_Texture *tface;
  12.810 -
  12.811 -   face = SDLTest_ImageFace();
  12.812 -   if (face == NULL) {
  12.813 -      return NULL;
  12.814 -   }
  12.815 -   
  12.816 -   tface = SDL_CreateTextureFromSurface(renderer, face);
  12.817 -   if (tface == NULL) {
  12.818 -       SDLTest_LogError("SDL_CreateTextureFromSurface() failed with error: %s", SDL_GetError());
  12.819 -   }
  12.820 -
  12.821 -   SDL_FreeSurface(face);
  12.822 -
  12.823 -   return tface;
  12.824 -}
  12.825 -
  12.826 -
  12.827 -/**
  12.828 - * @brief Test to see if can set texture colour mode. Helper function.
  12.829 - *
  12.830 - * \sa
  12.831 - * http://wiki.libsdl.org/moin.cgi/SDL_SetTextureColorMod
  12.832 - * http://wiki.libsdl.org/moin.cgi/SDL_GetTextureColorMod
  12.833 - * http://wiki.libsdl.org/moin.cgi/SDL_DestroyTexture
  12.834 - */
  12.835 -static int
  12.836 -_hasTexColor (void)
  12.837 -{
  12.838 -   int fail;
  12.839 -   int ret;
  12.840 -   SDL_Texture *tface;
  12.841 -   Uint8 r, g, b;
  12.842 -
  12.843 -   /* Get test face. */
  12.844 -   tface = _loadTestFace();
  12.845 -   if (tface == 0)
  12.846 -      return 0;
  12.847 -
  12.848 -   /* See if supported. */
  12.849 -   fail = 0;
  12.850 -   ret = SDL_SetTextureColorMod( tface, 100, 100, 100 );
  12.851 -   if (!_isSupported(ret))
  12.852 -      fail = 1;
  12.853 -   ret = SDL_GetTextureColorMod( tface, &r, &g, &b );
  12.854 -   if (!_isSupported(ret))
  12.855 -      fail = 1;
  12.856 -
  12.857 -   /* Clean up. */
  12.858 -   SDL_DestroyTexture( tface );
  12.859 -
  12.860 -   if (fail)
  12.861 -      return 0;
  12.862 -   else if ((r != 100) || (g != 100) || (b != 100))
  12.863 -      return 0;
  12.864 -   return 1;
  12.865 -}
  12.866 -
  12.867 -/**
  12.868 - * @brief Test to see if we can vary the alpha of the texture. Helper function.
  12.869 - *
  12.870 - * \sa
  12.871 - *  http://wiki.libsdl.org/moin.cgi/SDL_SetTextureAlphaMod
  12.872 - *  http://wiki.libsdl.org/moin.cgi/SDL_GetTextureAlphaMod
  12.873 - *  http://wiki.libsdl.org/moin.cgi/SDL_DestroyTexture
  12.874 - */
  12.875 -static int
  12.876 -_hasTexAlpha(void)
  12.877 -{
  12.878 -   int fail;
  12.879 -   int ret;
  12.880 -   SDL_Texture *tface;
  12.881 -   Uint8 a;
  12.882 -
  12.883 -   /* Get test face. */
  12.884 -   tface = _loadTestFace();
  12.885 -   if (tface == 0)
  12.886 -      return 0;
  12.887 -
  12.888 -   /* See if supported. */
  12.889 -   fail = 0;
  12.890 -   ret = SDL_SetTextureAlphaMod( tface, 100 );
  12.891 -   if (!_isSupported(ret))
  12.892 -      fail = 1;
  12.893 -   ret = SDL_GetTextureAlphaMod( tface, &a );
  12.894 -   if (!_isSupported(ret))
  12.895 -      fail = 1;
  12.896 -
  12.897 -   /* Clean up. */
  12.898 -   SDL_DestroyTexture( tface );
  12.899 -
  12.900 -   if (fail)
  12.901 -      return 0;
  12.902 -   else if (a != 100)
  12.903 -      return 0;
  12.904 -   return 1;
  12.905 -}
  12.906 -
  12.907 -static _renderCompareCount = 0;
  12.908 -
  12.909 -/**
  12.910 - * @brief Compares screen pixels with image pixels. Helper function.
  12.911 - *
  12.912 - * @param msg Message on failure.
  12.913 - * @param s Image to compare against.
  12.914 - * @return 0 on success.
  12.915 - *
  12.916 - * \sa
  12.917 - * http://wiki.libsdl.org/moin.cgi/SDL_RenderReadPixels
  12.918 - * http://wiki.libsdl.org/moin.cgi/SDL_CreateRGBSurfaceFrom
  12.919 - * http://wiki.libsdl.org/moin.cgi/SDL_FreeSurface
  12.920 - */
  12.921 -static void
  12.922 -_compare(const char *msg, SDL_Surface *s, int allowable_error)
  12.923 -{
  12.924 -   int ret;
  12.925 -   SDL_Rect rect;
  12.926 -   Uint8 pix[4*80*60];
  12.927 -   SDL_Surface *testsur;
  12.928 -   char imageFilename[128];
  12.929 -   char referenceFilename[128];
  12.930 -
  12.931 -   /* Read pixels. */
  12.932 -   /* Explicitly specify the rect in case the window isn't expected size... */
  12.933 -   rect.x = 0;
  12.934 -   rect.y = 0;
  12.935 -   rect.w = 80;
  12.936 -   rect.h = 60;
  12.937 -   ret = SDL_RenderReadPixels(renderer, &rect, RENDER_COMPARE_FORMAT, pix, 80*4 );
  12.938 -   SDLTest_AssertCheck(ret == 0, "Validate result from SDL_RenderReadPixels, expected: 0, got: %i", ret);
  12.939 -
  12.940 -   /* Create surface. */
  12.941 -   testsur = SDL_CreateRGBSurfaceFrom( pix, TESTRENDER_SCREEN_W, TESTRENDER_SCREEN_H, 32, TESTRENDER_SCREEN_W*4,
  12.942 -                                       RENDER_COMPARE_RMASK, RENDER_COMPARE_GMASK, RENDER_COMPARE_BMASK, RENDER_COMPARE_AMASK);
  12.943 -   SDLTest_AssertCheck(testsur != NULL, "Verify result from SDL_CreateRGBSurfaceFrom");
  12.944 -
  12.945 -   /* Compare surface. */
  12.946 -   ret = SDLTest_CompareSurfaces( testsur, s, allowable_error );
  12.947 -   SDLTest_AssertCheck(ret == 0, "Validate result from SDLTest_CompareSurfaces, expected: 0, got: %i", ret);
  12.948 -
  12.949 -   _renderCompareCount++;
  12.950 -   if (ret != 0) {
  12.951 -      SDL_snprintf(imageFilename, 127, "image%i.bmp", _renderCompareCount);
  12.952 -      SDL_SaveBMP(testsur, imageFilename);
  12.953 -      SDL_snprintf(referenceFilename, 127, "reference%i.bmp", _renderCompareCount);
  12.954 -      SDL_SaveBMP(s, referenceFilename);
  12.955 -      SDLTest_LogError("Surfaces from failed comparison saved as %s and %s", imageFilename, referenceFilename);
  12.956 -   }
  12.957 -
  12.958 -   /* Clean up. */
  12.959 -   SDL_FreeSurface( testsur );
  12.960 -}
  12.961 -
  12.962 -/**
  12.963 - * @brief Clears the screen. Helper function.
  12.964 - *
  12.965 - * \sa
  12.966 - * http://wiki.libsdl.org/moin.cgi/SDL_SetRenderDrawColor
  12.967 - * http://wiki.libsdl.org/moin.cgi/SDL_RenderFillRect
  12.968 - * http://wiki.libsdl.org/moin.cgi/SDL_SetRenderDrawBlendMode
  12.969 - */
  12.970 -static int
  12.971 -_clearScreen(void)
  12.972 -{
  12.973 -   int ret;
  12.974 -
  12.975 -   /* Set colour. */
  12.976 -   ret = SDL_SetRenderDrawColor(renderer, 0, 0, 0, SDL_ALPHA_OPAQUE );
  12.977 -   SDLTest_AssertCheck(ret == 0, "Validate result from SDL_SetRenderDrawColor, expected: 0, got: %i", ret);
  12.978 -
  12.979 -   /* Clear screen. */
  12.980 -   ret = SDL_RenderFillRect(renderer, NULL );
  12.981 -   SDLTest_AssertCheck(ret == 0, "Validate result from SDL_RenderFillRect, expected: 0, got: %i", ret);
  12.982 -
  12.983 -   /* Set defaults. */
  12.984 -   ret = SDL_SetRenderDrawBlendMode(renderer, SDL_BLENDMODE_NONE );
  12.985 -   SDLTest_AssertCheck(ret == 0, "Validate result from SDL_SetRenderDrawBlendMode, expected: 0, got: %i", ret);
  12.986 -
  12.987 -   ret = SDL_SetRenderDrawColor(renderer, 255, 255, 255, SDL_ALPHA_OPAQUE );
  12.988 -   SDLTest_AssertCheck(ret == 0, "Validate result from SDL_SetRenderDrawColor, expected: 0, got: %i", ret);
  12.989 -
  12.990 -   return 0;
  12.991 -}
  12.992 -
  12.993 -/* ================= Test References ================== */
  12.994 -
  12.995 -/* Render test cases */
  12.996 -static const SDLTest_TestCaseReference renderTest1 =
  12.997 -		{ (SDLTest_TestCaseFp)render_testGetNumRenderDrivers, "render_testGetNumRenderDrivers", "Tests call to SDL_GetNumRenderDrivers", TEST_ENABLED };
  12.998 -
  12.999 -static const SDLTest_TestCaseReference renderTest2 =
 12.1000 -		{ (SDLTest_TestCaseFp)render_testPrimitives, "render_testPrimitives", "Tests rendering primitives", TEST_ENABLED };
 12.1001 -
 12.1002 -static const SDLTest_TestCaseReference renderTest3 =
 12.1003 -		{ (SDLTest_TestCaseFp)render_testPrimitivesBlend, "render_testPrimitivesBlend", "Tests rendering primitives with blending", TEST_ENABLED };
 12.1004 -
 12.1005 -static const SDLTest_TestCaseReference renderTest4 =
 12.1006 -		{ (SDLTest_TestCaseFp)render_testBlit, "render_testBlit", "Tests blitting", TEST_ENABLED };
 12.1007 -
 12.1008 -static const SDLTest_TestCaseReference renderTest5 =
 12.1009 -		{ (SDLTest_TestCaseFp)render_testBlitColor, "render_testBlitColor", "Tests blitting with color", TEST_ENABLED };
 12.1010 -
 12.1011 -static const SDLTest_TestCaseReference renderTest6 =
 12.1012 -		{ (SDLTest_TestCaseFp)render_testBlitAlpha, "render_testBlitAlpha", "Tests blitting with alpha", TEST_ENABLED };
 12.1013 -
 12.1014 -static const SDLTest_TestCaseReference renderTest7 =
 12.1015 -		{  (SDLTest_TestCaseFp)render_testBlitBlend, "render_testBlitBlend", "Tests blitting with blending", TEST_ENABLED };
 12.1016 -
 12.1017 -/* Sequence of Render test cases */
 12.1018 -static const SDLTest_TestCaseReference *renderTests[] =  {
 12.1019 -	&renderTest1, &renderTest2, &renderTest3, &renderTest4, &renderTest5, &renderTest6, &renderTest7, NULL
 12.1020 -};
 12.1021 -
 12.1022 -/* Render test suite (global) */
 12.1023 -SDLTest_TestSuiteReference renderTestSuite = {
 12.1024 -	"Render",
 12.1025 -	InitCreateRenderer,
 12.1026 -	renderTests,
 12.1027 -	CleanupDestroyRenderer
 12.1028 -};
    13.1 --- a/test/tests/testrwops.c	Sat Dec 22 17:24:14 2012 -0800
    13.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    13.3 @@ -1,427 +0,0 @@
    13.4 -/**
    13.5 - * Automated SDL_RWops test.
    13.6 - *
    13.7 - * Original code written by Edgar Simo "bobbens"
    13.8 - * Ported by Markus Kauppila (markus.kauppila@gmail.com)
    13.9 - * Updated for SDL_test by aschiffler at ferzkopp dot net
   13.10 - *
   13.11 - * Released under Public Domain.
   13.12 - */
   13.13 -
   13.14 -/* quiet windows compiler warnings */
   13.15 -#define _CRT_SECURE_NO_WARNINGS
   13.16 -
   13.17 -#include <stdio.h>
   13.18 -
   13.19 -#include "SDL.h"
   13.20 -#include "SDL_test.h"
   13.21 -
   13.22 -/* ================= Test Case Implementation ================== */
   13.23 -
   13.24 -const char* RWopsReadTestFilename = "rwops_read";
   13.25 -const char* RWopsWriteTestFilename = "rwops_write";
   13.26 -
   13.27 -static const char RWopsHelloWorldTestString[] = "Hello World!";
   13.28 -static const char RWopsHelloWorldCompString[] = "Hello World!";
   13.29 -
   13.30 -/* Fixture */
   13.31 -
   13.32 -void
   13.33 -RWopsSetUp(void *arg)
   13.34 -{
   13.35 -	int fileLen = SDL_strlen(RWopsHelloWorldTestString);
   13.36 -	FILE *handle;
   13.37 -	int writtenLen;
   13.38 -	int result;
   13.39 -
   13.40 -	/* Clean up from previous runs (if any); ignore errors */
   13.41 -	remove(RWopsReadTestFilename);
   13.42 -	remove(RWopsWriteTestFilename);
   13.43 -
   13.44 -	/* Create a test file */
   13.45 -	handle = fopen(RWopsReadTestFilename, "w");
   13.46 -	SDLTest_AssertCheck(handle != NULL, "Verify creation of file '%s' returned non NULL handle", RWopsReadTestFilename);
   13.47 -    if (handle == NULL) return;
   13.48 -
   13.49 -	/* Write some known test into it */
   13.50 -	writtenLen = (int)fwrite(RWopsHelloWorldTestString, 1, fileLen, handle);
   13.51 -	SDLTest_AssertCheck(fileLen == writtenLen, "Verify number of written bytes, expected %i, got %i", fileLen, writtenLen);
   13.52 -	result = fclose(handle);
   13.53 -	SDLTest_AssertCheck(result == 0, "Verify result from fclose, expected 0, got %i", result);
   13.54 -
   13.55 -	SDLTest_AssertPass("Creation of test file completed");
   13.56 -}
   13.57 -
   13.58 -void
   13.59 -RWopsTearDown(void *arg)
   13.60 -{
   13.61 -	int result;
   13.62 -	
   13.63 -	/* Remove the created files to clean up; ignore errors for write filename */
   13.64 -	result = remove(RWopsReadTestFilename);
   13.65 -	SDLTest_AssertCheck(result == 0, "Verify result from remove(%s), expected 0, got %i", RWopsReadTestFilename, result);
   13.66 -	remove(RWopsWriteTestFilename);
   13.67 -
   13.68 -	SDLTest_AssertPass("Cleanup of test files completed");
   13.69 -}
   13.70 -
   13.71 -/**
   13.72 - * @brief Makes sure parameters work properly. Local helper function.
   13.73 - *
   13.74 - * \sa
   13.75 - * http://wiki.libsdl.org/moin.cgi/SDL_RWseek
   13.76 - * http://wiki.libsdl.org/moin.cgi/SDL_RWread
   13.77 - */
   13.78 -void 
   13.79 -_testGenericRWopsValidations(SDL_RWops *rw, int write)
   13.80 -{
   13.81 -   char buf[sizeof(RWopsHelloWorldTestString)];
   13.82 -   int i;
   13.83 -   int seekPos = SDLTest_RandomIntegerInRange(4, 8);
   13.84 -
   13.85 -   /* Clear buffer */
   13.86 -   SDL_zero(buf);
   13.87 -
   13.88 -   /* Set to start. */
   13.89 -   i = SDL_RWseek(rw, 0, RW_SEEK_SET );
   13.90 -   SDLTest_AssertPass("Call to SDL_RWseek succeeded");
   13.91 -   SDLTest_AssertCheck(i == 0, "Verify seek to 0 with SDL_RWseek (RW_SEEK_SET), expected 0, got %i", i);
   13.92 -
   13.93 -   /* Test write. */
   13.94 -   i = SDL_RWwrite(rw, RWopsHelloWorldTestString, sizeof(RWopsHelloWorldTestString)-1, 1);
   13.95 -   SDLTest_AssertPass("Call to SDL_RWwrite succeeded");
   13.96 -   if (write) {
   13.97 -		SDLTest_AssertCheck(i == 1, "Verify result of writing one byte with SDL_RWwrite, expected 1, got %i", i);
   13.98 -   }
   13.99 -   else {
  13.100 -		SDLTest_AssertCheck(i <= 0, "Verify result of writing with SDL_RWwrite, expected <=0, got %i", i);
  13.101 -   }
  13.102 -
  13.103 -   /* Test seek to random position */
  13.104 -   i = SDL_RWseek( rw, seekPos, RW_SEEK_SET );
  13.105 -   SDLTest_AssertPass("Call to SDL_RWseek succeeded");
  13.106 -   SDLTest_AssertCheck(i == seekPos, "Verify seek to %i with SDL_RWseek (RW_SEEK_SET), expected %i, got %i", seekPos, seekPos, i);
  13.107 -
  13.108 -   /* Test seek back to start */
  13.109 -   i = SDL_RWseek(rw, 0, RW_SEEK_SET );
  13.110 -   SDLTest_AssertPass("Call to SDL_RWseek succeeded");
  13.111 -   SDLTest_AssertCheck(i == 0, "Verify seek to 0 with SDL_RWseek (RW_SEEK_SET), expected 0, got %i", i);
  13.112 -
  13.113 -   /* Test read */
  13.114 -   i = SDL_RWread( rw, buf, 1, sizeof(RWopsHelloWorldTestString)-1 );
  13.115 -   SDLTest_AssertPass("Call to SDL_RWread succeeded");
  13.116 -   SDLTest_AssertCheck(
  13.117 -	   i == (sizeof(RWopsHelloWorldTestString)-1), 
  13.118 -	   "Verify result from SDL_RWread, expected %i, got %i",
  13.119 -	   sizeof(RWopsHelloWorldTestString)-1,
  13.120 -	   i);
  13.121 -   SDLTest_AssertCheck(
  13.122 -	   SDL_memcmp(buf, RWopsHelloWorldTestString, sizeof(RWopsHelloWorldTestString)-1 ) == 0, 
  13.123 -	   "Verify read bytes match expected string, expected '%s', got '%s'", RWopsHelloWorldTestString, buf);
  13.124 -
  13.125 -   /* More seek tests. */
  13.126 -   i = SDL_RWseek( rw, -4, RW_SEEK_CUR );
  13.127 -   SDLTest_AssertPass("Call to SDL_RWseek(...,-4,RW_SEEK_CUR) succeeded");
  13.128 -   SDLTest_AssertCheck(
  13.129 -	   i == (sizeof(RWopsHelloWorldTestString)-5), 
  13.130 -	   "Verify seek to -4 with SDL_RWseek (RW_SEEK_CUR), expected %i, got %i",
  13.131 -	   sizeof(RWopsHelloWorldTestString)-5,
  13.132 -	   i);
  13.133 -
  13.134 -   i = SDL_RWseek( rw, -1, RW_SEEK_END );
  13.135 -   SDLTest_AssertPass("Call to SDL_RWseek(...,-1,RW_SEEK_END) succeeded");
  13.136 -   SDLTest_AssertCheck(
  13.137 -	   i == (sizeof(RWopsHelloWorldTestString)-2), 
  13.138 -	   "Verify seek to -1 with SDL_RWseek (RW_SEEK_END), expected %i, got %i",
  13.139 -	   sizeof(RWopsHelloWorldTestString)-2,
  13.140 -	   i);
  13.141 -}
  13.142 -
  13.143 -/*!
  13.144 - * Negative test for SDL_RWFromFile parameters
  13.145 - *
  13.146 - * \sa http://wiki.libsdl.org/moin.cgi/SDL_RWFromFile
  13.147 - *
  13.148 - */
  13.149 -int
  13.150 -rwops_testParamNegative (void)
  13.151 -{
  13.152 -   SDL_RWops *rwops;
  13.153 -
  13.154 -   /* These should all fail. */
  13.155 -   rwops = SDL_RWFromFile(NULL, NULL);
  13.156 -   SDLTest_AssertPass("Call to SDL_RWFromFile(NULL, NULL) succeeded");
  13.157 -   SDLTest_AssertCheck(rwops == NULL, "Verify SDL_RWFromFile(NULL, NULL) returns NULL");
  13.158 -
  13.159 -   rwops = SDL_RWFromFile(NULL, "ab+");
  13.160 -   SDLTest_AssertPass("Call to SDL_RWFromFile(NULL, \"ab+\") succeeded");
  13.161 -   SDLTest_AssertCheck(rwops == NULL, "Verify SDL_RWFromFile(NULL, \"ab+\") returns NULL");
  13.162 -
  13.163 -   rwops = SDL_RWFromFile(NULL, "sldfkjsldkfj");
  13.164 -   SDLTest_AssertPass("Call to SDL_RWFromFile(NULL, \"sldfkjsldkfj\") succeeded");
  13.165 -   SDLTest_AssertCheck(rwops == NULL, "Verify SDL_RWFromFile(NULL, \"sldfkjsldkfj\") returns NULL");
  13.166 -
  13.167 -   rwops = SDL_RWFromFile("something", "");
  13.168 -   SDLTest_AssertPass("Call to SDL_RWFromFile(\"something\", \"\") succeeded");
  13.169 -   SDLTest_AssertCheck(rwops == NULL, "Verify SDL_RWFromFile(\"something\", \"\") returns NULL");
  13.170 -
  13.171 -   rwops = SDL_RWFromFile("something", NULL);
  13.172 -   SDLTest_AssertPass("Call to SDL_RWFromFile(\"something\", NULL) succeeded");
  13.173 -   SDLTest_AssertCheck(rwops == NULL, "Verify SDL_RWFromFile(\"something\", NULL) returns NULL");
  13.174 -
  13.175 -   return TEST_COMPLETED;
  13.176 -}
  13.177 -
  13.178 -/**
  13.179 - * @brief Tests opening from memory.
  13.180 - *
  13.181 - * \sa http://wiki.libsdl.org/moin.cgi/SDL_RWFromMem
  13.182 - */
  13.183 -int
  13.184 -rwops_testMem (void)
  13.185 -{
  13.186 -   char mem[sizeof(RWopsHelloWorldTestString)];
  13.187 -   SDL_RWops *rw;
  13.188 -
  13.189 -   /* Clear buffer */
  13.190 -   SDL_zero(mem);
  13.191 -
  13.192 -   /* Open */
  13.193 -   rw = SDL_RWFromMem(mem, sizeof(RWopsHelloWorldTestString)-1);
  13.194 -   SDLTest_AssertPass("Call to SDL_RWFromMem() succeeded");
  13.195 -   SDLTest_AssertCheck(rw != NULL, "Verify opening memory with SDL_RWFromMem does not return NULL");
  13.196 -
  13.197 -   /* Bail out if NULL */
  13.198 -   if (rw == NULL) return TEST_ABORTED;
  13.199 -
  13.200 -   /* Run generic tests */
  13.201 -   _testGenericRWopsValidations(rw, 1);
  13.202 -
  13.203 -   /* Close */
  13.204 -   SDL_RWclose(rw);
  13.205 -   SDLTest_AssertPass("Call to SDL_RWclose() succeeded");
  13.206 -   SDL_FreeRW(rw);
  13.207 -   SDLTest_AssertPass("Call to SDL_FreeRW() succeeded");
  13.208 -
  13.209 -   return TEST_COMPLETED;
  13.210 -}
  13.211 -
  13.212 -
  13.213 -/**
  13.214 - * @brief Tests opening from memory.
  13.215 - *
  13.216 - * \sa
  13.217 - * http://wiki.libsdl.org/moin.cgi/SDL_RWFromConstMem
  13.218 - */
  13.219 -int 
  13.220 -rwops_testConstMem (void)
  13.221 -{
  13.222 -   SDL_RWops *rw;
  13.223 -
  13.224 -   /* Open handle */
  13.225 -   rw = SDL_RWFromConstMem( RWopsHelloWorldCompString, sizeof(RWopsHelloWorldCompString)-1 );
  13.226 -   SDLTest_AssertPass("Call to SDL_RWFromConstMem() succeeded");
  13.227 -   SDLTest_AssertCheck(rw != NULL, "Verify opening memory with SDL_RWFromConstMem does not return NULL");
  13.228 -
  13.229 -   /* Bail out if NULL */
  13.230 -   if (rw == NULL) return TEST_ABORTED;
  13.231 -
  13.232 -   /* Run generic tests */
  13.233 -   _testGenericRWopsValidations( rw, 0 );
  13.234 -
  13.235 -   /* Close handle */
  13.236 -   SDL_RWclose(rw);
  13.237 -   SDLTest_AssertPass("Call to SDL_RWclose() succeeded");
  13.238 -   SDL_FreeRW( rw );
  13.239 -   SDLTest_AssertPass("Call to SDL_FreeRW() succeeded");
  13.240 -
  13.241 -  return TEST_COMPLETED;
  13.242 -}
  13.243 -
  13.244 -
  13.245 -/**
  13.246 - * @brief Tests reading from file.
  13.247 - *
  13.248 - * \sa
  13.249 - * http://wiki.libsdl.org/moin.cgi/SDL_RWFromFile
  13.250 - * http://wiki.libsdl.org/moin.cgi/SDL_FreeRW
  13.251 - */
  13.252 -int
  13.253 -rwops_testFileRead(void)
  13.254 -{
  13.255 -   SDL_RWops *rw;
  13.256 -
  13.257 -   /* Read test. */
  13.258 -   rw = SDL_RWFromFile(RWopsReadTestFilename, "r");
  13.259 -   SDLTest_AssertPass("Call to SDL_RWFromFile(..,\"r\") succeeded");
  13.260 -   SDLTest_AssertCheck(rw != NULL, "Verify opening file with SDL_RWFromFile in read mode does not return NULL");
  13.261 -
  13.262 -   // Bail out if NULL
  13.263 -   if (rw == NULL) return TEST_ABORTED;
  13.264 -
  13.265 -   /* Run generic tests */
  13.266 -   _testGenericRWopsValidations( rw, 0 );
  13.267 -
  13.268 -   /* Close handle */
  13.269 -   SDL_RWclose(rw);
  13.270 -   SDLTest_AssertPass("Call to SDL_RWclose() succeeded");
  13.271 -   SDL_FreeRW( rw );
  13.272 -   SDLTest_AssertPass("Call to SDL_FreeRW() succeeded");
  13.273 -
  13.274 -   return TEST_COMPLETED;
  13.275 -}
  13.276 -
  13.277 -/**
  13.278 - * @brief Tests writing from memory.
  13.279 - *
  13.280 - * \sa
  13.281 - * http://wiki.libsdl.org/moin.cgi/SDL_RWFromFile
  13.282 - * http://wiki.libsdl.org/moin.cgi/SDL_FreeRW
  13.283 - */
  13.284 -int
  13.285 -rwops_testFileWrite(void)
  13.286 -{
  13.287 -   SDL_RWops *rw;
  13.288 -
  13.289 -   /* Write test. */
  13.290 -   rw = SDL_RWFromFile(RWopsWriteTestFilename, "w+");
  13.291 -   SDLTest_AssertPass("Call to SDL_RWFromFile(..,\"w+\") succeeded");
  13.292 -   SDLTest_AssertCheck(rw != NULL, "Verify opening file with SDL_RWFromFile in write mode does not return NULL");
  13.293 -
  13.294 -   // Bail out if NULL
  13.295 -   if (rw == NULL) return TEST_ABORTED;
  13.296 -
  13.297 -   /* Run generic tests */
  13.298 -   _testGenericRWopsValidations( rw, 1 );
  13.299 -
  13.300 -   /* Close handle */
  13.301 -   SDL_RWclose(rw);
  13.302 -   SDLTest_AssertPass("Call to SDL_RWclose() succeeded");
  13.303 -   SDL_FreeRW( rw );
  13.304 -   SDLTest_AssertPass("Call to SDL_FreeRW() succeeded");
  13.305 -
  13.306 -   return TEST_COMPLETED;
  13.307 -}
  13.308 -
  13.309 -
  13.310 -/**
  13.311 - * @brief Tests reading from file handle
  13.312 - *
  13.313 - * \sa
  13.314 - * http://wiki.libsdl.org/moin.cgi/SDL_RWFromFP
  13.315 - * http://wiki.libsdl.org/moin.cgi/SDL_FreeRW
  13.316 - *
  13.317 - */
  13.318 -int
  13.319 -rwops_testFPRead(void)
  13.320 -{
  13.321 -   FILE *fp;
  13.322 -   SDL_RWops *rw;
  13.323 -
  13.324 -   /* Run read tests. */
  13.325 -   fp = fopen(RWopsReadTestFilename, "r");
  13.326 -   SDLTest_AssertCheck(fp != NULL, "Verify handle from opening file '%s' in read mode is not NULL", RWopsReadTestFilename);
  13.327 -
  13.328 -   /* Bail out if NULL */
  13.329 -   if (fp == NULL) return TEST_ABORTED;
  13.330 -
  13.331 -   /* Open */
  13.332 -   rw = SDL_RWFromFP( fp, 1 );
  13.333 -   SDLTest_AssertPass("Call to SDL_RWFromFP() succeeded");
  13.334 -   SDLTest_AssertCheck(rw != NULL, "Verify opening file with SDL_RWFromFP in read mode does not return NULL");
  13.335 -
  13.336 -   /* Bail out if NULL */
  13.337 -   if (rw == NULL) return TEST_ABORTED;
  13.338 -
  13.339 -   /* Run generic tests */
  13.340 -   _testGenericRWopsValidations( rw, 0 );
  13.341 -
  13.342 -   /* Close handle */
  13.343 -   SDL_RWclose(rw);
  13.344 -   SDLTest_AssertPass("Call to SDL_RWclose() succeeded");
  13.345 -   SDL_FreeRW( rw );
  13.346 -   SDLTest_AssertPass("Call to SDL_FreeRW() succeeded");
  13.347 -   fclose(fp);
  13.348 -
  13.349 -   return TEST_COMPLETED;
  13.350 -}
  13.351 -
  13.352 -
  13.353 -/**
  13.354 - * @brief Tests writing to file handle
  13.355 - *
  13.356 - * \sa
  13.357 - * http://wiki.libsdl.org/moin.cgi/SDL_RWFromFP
  13.358 - * http://wiki.libsdl.org/moin.cgi/SDL_FreeRW
  13.359 - *
  13.360 - */
  13.361 -int
  13.362 -rwops_testFPWrite(void)
  13.363 -{
  13.364 -   FILE *fp;
  13.365 -   SDL_RWops *rw;
  13.366 -
  13.367 -   /* Run write tests. */
  13.368 -   fp = fopen(RWopsWriteTestFilename, "w+");
  13.369 -   SDLTest_AssertCheck(fp != NULL, "Verify handle from opening file '%s' in write mode is not NULL", RWopsWriteTestFilename);
  13.370 -
  13.371 -   /* Bail out if NULL */
  13.372 -   if (fp == NULL) return TEST_ABORTED;
  13.373 -
  13.374 -   /* Open */
  13.375 -   rw = SDL_RWFromFP( fp, 1 );
  13.376 -   SDLTest_AssertPass("Call to SDL_RWFromFP() succeeded");
  13.377 -   SDLTest_AssertCheck(rw != NULL, "Verify opening file with SDL_RWFromFP in write mode does not return NULL");
  13.378 -
  13.379 -   /* Bail out if NULL */
  13.380 -   if (rw == NULL) return TEST_ABORTED;
  13.381 -
  13.382 -   /* Run generic tests */
  13.383 -   _testGenericRWopsValidations( rw, 1 );
  13.384 -
  13.385 -   /* Close handle */
  13.386 -   SDL_RWclose(rw);
  13.387 -   SDLTest_AssertPass("Call to SDL_RWclose() succeeded");
  13.388 -   SDL_FreeRW( rw );
  13.389 -   SDLTest_AssertPass("Call to SDL_FreeRW() succeeded");
  13.390 -   fclose(fp);
  13.391 -
  13.392 -   return TEST_COMPLETED;
  13.393 -}
  13.394 -
  13.395 -/* ================= Test References ================== */
  13.396 -
  13.397 -/* RWops test cases */
  13.398 -static const SDLTest_TestCaseReference rwopsTest1 =
  13.399 -		{ (SDLTest_TestCaseFp)rwops_testParamNegative, "rwops_testParamNegative", "Negative test for SDL_RWFromFile parameters", TEST_ENABLED };
  13.400 -
  13.401 -static const SDLTest_TestCaseReference rwopsTest2 =
  13.402 -		{ (SDLTest_TestCaseFp)rwops_testMem, "rwops_testMem", "Tests opening from memory", TEST_ENABLED };
  13.403 -
  13.404 -static const SDLTest_TestCaseReference rwopsTest3 =
  13.405 -		{ (SDLTest_TestCaseFp)rwops_testConstMem, "rwops_testConstMem", "Tests opening from (const) memory", TEST_ENABLED };
  13.406 -
  13.407 -static const SDLTest_TestCaseReference rwopsTest4 =
  13.408 -		{ (SDLTest_TestCaseFp)rwops_testFileRead, "rwops_testFileRead", "Tests reading from a file", TEST_ENABLED };
  13.409 -
  13.410 -static const SDLTest_TestCaseReference rwopsTest5 =
  13.411 -		{ (SDLTest_TestCaseFp)rwops_testFileWrite, "rwops_testFileWrite", "Test writing to a file", TEST_ENABLED };
  13.412 -