test/testautomation_rect.c
changeset 6769 b49778d885cd
parent 6757 9935f71c8c81
child 6772 5229a117ef97
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/test/testautomation_rect.c	Sat Dec 22 17:24:42 2012 -0800
     1.3 @@ -0,0 +1,1677 @@
     1.4 +/**
     1.5 + * Original code: automated SDL rect test written by Edgar Simo "bobbens"
     1.6 + * New/updated tests: aschiffler at ferzkopp dot net
     1.7 + */
     1.8 +
     1.9 +#include <stdio.h>
    1.10 +
    1.11 +#include "SDL.h"
    1.12 +#include "SDL_test.h"
    1.13 +
    1.14 +/* ================= Test Case Implementation ================== */
    1.15 +
    1.16 +/* Helper functions */
    1.17 +
    1.18 +/*!
    1.19 + * \brief Private helper to check SDL_IntersectRectAndLine results
    1.20 + */
    1.21 +void _validateIntersectRectAndLineResults(
    1.22 +    SDL_bool intersection, SDL_bool expectedIntersection,
    1.23 +    SDL_Rect *rect, SDL_Rect * refRect,
    1.24 +    int x1, int y1, int x2, int y2,
    1.25 +    int x1Ref, int y1Ref, int x2Ref, int y2Ref)
    1.26 +{
    1.27 +    SDLTest_AssertCheck(intersection == expectedIntersection, 
    1.28 +        "Check for correct intersection result: expected %s, got %s intersecting rect (%d,%d,%d,%d) with line (%d,%d - %d,%d)",
    1.29 +        (expectedIntersection == SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE",
    1.30 +        (intersection == SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE",
    1.31 +        refRect->x, refRect->y, refRect->w, refRect->h,
    1.32 +        x1Ref, y1Ref, x2Ref, y2Ref);
    1.33 +    SDLTest_AssertCheck(rect->x == refRect->x && rect->y == refRect->y && rect->w == refRect->w && rect->h == refRect->h,
    1.34 +        "Check that source rectangle was not modified: got (%d,%d,%d,%d) expected (%d,%d,%d,%d)",
    1.35 +        rect->x, rect->y, rect->w, rect->h,
    1.36 +        refRect->x, refRect->y, refRect->w, refRect->h);
    1.37 +    SDLTest_AssertCheck(x1 == x1Ref && y1 == y1Ref && x2 == x2Ref && y2 == y2Ref,
    1.38 +        "Check if line was incorrectly clipped or modified: got (%d,%d - %d,%d) expected (%d,%d - %d,%d)",
    1.39 +        x1, y1, x2, y2,
    1.40 +        x1Ref, y1Ref, x2Ref, y2Ref);
    1.41 +}
    1.42 +
    1.43 +/* Test case functions */
    1.44 +
    1.45 +/*!
    1.46 + * \brief Tests SDL_IntersectRectAndLine() clipping cases
    1.47 + *
    1.48 + * \sa
    1.49 + * http://wiki.libsdl.org/moin.cgi/SDL_IntersectRectAndLine
    1.50 + */
    1.51 +int 
    1.52 +rect_testIntersectRectAndLine (void *arg)
    1.53 +{
    1.54 +    SDL_Rect refRect = { 0, 0, 32, 32 };
    1.55 +    SDL_Rect rect;
    1.56 +    int x1, y1;
    1.57 +    int x2, y2;
    1.58 +    SDL_bool intersected;
    1.59 +
    1.60 +    int xLeft = -SDLTest_RandomIntegerInRange(1, refRect.w);
    1.61 +    int xRight = refRect.w + SDLTest_RandomIntegerInRange(1, refRect.w);
    1.62 +    int yTop = -SDLTest_RandomIntegerInRange(1, refRect.h);
    1.63 +    int yBottom = refRect.h + SDLTest_RandomIntegerInRange(1, refRect.h);
    1.64 +
    1.65 +    x1 = xLeft;
    1.66 +    y1 = 15;
    1.67 +    x2 = xRight;
    1.68 +    y2 = 15;
    1.69 +    rect = refRect;
    1.70 +    intersected = SDL_IntersectRectAndLine(&rect, &x1, &y1, &x2, &y2);
    1.71 +    _validateIntersectRectAndLineResults(intersected, SDL_TRUE, &rect, &refRect, x1, y1, x2, y2, 0, 15, 31, 15);
    1.72 +
    1.73 +    x1 = 15;
    1.74 +    y1 = yTop;
    1.75 +    x2 = 15;
    1.76 +    y2 = yBottom;
    1.77 +    rect = refRect;
    1.78 +    intersected = SDL_IntersectRectAndLine(&rect, &x1, &y1, &x2, &y2);
    1.79 +    _validateIntersectRectAndLineResults(intersected, SDL_TRUE, &rect, &refRect, x1, y1, x2, y2, 15, 0, 15, 31);
    1.80 +
    1.81 +    x1 = -refRect.w;
    1.82 +    y1 = -refRect.h;
    1.83 +    x2 = 2*refRect.w;
    1.84 +    y2 = 2*refRect.h;
    1.85 +    rect = refRect;
    1.86 +    intersected = SDL_IntersectRectAndLine(&rect, &x1, &y1, &x2, &y2);
    1.87 +     _validateIntersectRectAndLineResults(intersected, SDL_TRUE, &rect, &refRect, x1, y1, x2, y2, 0, 0, 31, 31);
    1.88 +
    1.89 +    x1 = 2*refRect.w;
    1.90 +    y1 = 2*refRect.h;
    1.91 +    x2 = -refRect.w;
    1.92 +    y2 = -refRect.h;
    1.93 +    rect = refRect;
    1.94 +    intersected = SDL_IntersectRectAndLine(&rect, &x1, &y1, &x2, &y2);
    1.95 +    _validateIntersectRectAndLineResults(intersected, SDL_TRUE, &rect, &refRect, x1, y1, x2, y2, 31, 31, 0, 0);
    1.96 +
    1.97 +    x1 = -1;
    1.98 +    y1 = 32;
    1.99 +    x2 = 32;
   1.100 +    y2 = -1;
   1.101 +    rect = refRect;
   1.102 +    intersected = SDL_IntersectRectAndLine(&rect, &x1, &y1, &x2, &y2);
   1.103 +    _validateIntersectRectAndLineResults(intersected, SDL_TRUE, &rect, &refRect, x1, y1, x2, y2, 0, 31, 31, 0);
   1.104 +
   1.105 +    x1 = 32;
   1.106 +    y1 = -1;
   1.107 +    x2 = -1;
   1.108 +    y2 = 32;
   1.109 +    rect = refRect;
   1.110 +    intersected = SDL_IntersectRectAndLine(&rect, &x1, &y1, &x2, &y2);
   1.111 +    _validateIntersectRectAndLineResults(intersected, SDL_TRUE, &rect, &refRect, x1, y1, x2, y2, 31, 0, 0, 31);
   1.112 +
   1.113 +	return TEST_COMPLETED;
   1.114 +}
   1.115 +
   1.116 +/*!
   1.117 + * \brief Tests SDL_IntersectRectAndLine() non-clipping case line inside
   1.118 + *
   1.119 + * \sa
   1.120 + * http://wiki.libsdl.org/moin.cgi/SDL_IntersectRectAndLine
   1.121 + */
   1.122 +int 
   1.123 +rect_testIntersectRectAndLineInside (void *arg)
   1.124 +{
   1.125 +    SDL_Rect refRect = { 0, 0, 32, 32 };
   1.126 +    SDL_Rect rect;
   1.127 +    int x1, y1;
   1.128 +    int x2, y2;
   1.129 +    SDL_bool intersected;
   1.130 +
   1.131 +    int xmin = refRect.x;
   1.132 +    int xmax = refRect.x + refRect.w - 1;
   1.133 +    int ymin = refRect.y;
   1.134 +    int ymax = refRect.y + refRect.h - 1;
   1.135 +    int x1Ref = SDLTest_RandomIntegerInRange(xmin + 1, xmax - 1);
   1.136 +    int y1Ref = SDLTest_RandomIntegerInRange(ymin + 1, ymax - 1);
   1.137 +    int x2Ref = SDLTest_RandomIntegerInRange(xmin + 1, xmax - 1);
   1.138 +    int y2Ref = SDLTest_RandomIntegerInRange(ymin + 1, ymax - 1);
   1.139 +
   1.140 +    x1 = x1Ref;
   1.141 +    y1 = y1Ref;
   1.142 +    x2 = x2Ref;
   1.143 +    y2 = y2Ref;
   1.144 +    rect = refRect;
   1.145 +    intersected = SDL_IntersectRectAndLine(&rect, &x1, &y1, &x2, &y2);
   1.146 +    _validateIntersectRectAndLineResults(intersected, SDL_TRUE, &rect, &refRect, x1, y1, x2, y2, x1Ref, y1Ref, x2Ref, y2Ref);
   1.147 +
   1.148 +    x1 = x1Ref;
   1.149 +    y1 = y1Ref;
   1.150 +    x2 = xmax;
   1.151 +    y2 = ymax;
   1.152 +    rect = refRect;
   1.153 +    intersected = SDL_IntersectRectAndLine(&rect, &x1, &y1, &x2, &y2);
   1.154 +    _validateIntersectRectAndLineResults(intersected, SDL_TRUE, &rect, &refRect, x1, y1, x2, y2, x1Ref, y1Ref, xmax, ymax);
   1.155 +
   1.156 +    x1 = xmin;
   1.157 +    y1 = ymin;
   1.158 +    x2 = x2Ref;
   1.159 +    y2 = y2Ref;
   1.160 +    rect = refRect;
   1.161 +    intersected = SDL_IntersectRectAndLine(&rect, &x1, &y1, &x2, &y2);
   1.162 +    _validateIntersectRectAndLineResults(intersected, SDL_TRUE, &rect, &refRect, x1, y1, x2, y2, xmin, ymin, x2Ref, y2Ref);
   1.163 +
   1.164 +    x1 = xmin;
   1.165 +    y1 = ymin;
   1.166 +    x2 = xmax;
   1.167 +    y2 = ymax;
   1.168 +    rect = refRect;
   1.169 +    intersected = SDL_IntersectRectAndLine(&rect, &x1, &y1, &x2, &y2);
   1.170 +    _validateIntersectRectAndLineResults(intersected, SDL_TRUE, &rect, &refRect, x1, y1, x2, y2, xmin, ymin, xmax, ymax);
   1.171 +
   1.172 +    x1 = xmin;
   1.173 +    y1 = ymax;
   1.174 +    x2 = xmax;
   1.175 +    y2 = ymin;
   1.176 +    rect = refRect;
   1.177 +    intersected = SDL_IntersectRectAndLine(&rect, &x1, &y1, &x2, &y2);
   1.178 +    _validateIntersectRectAndLineResults(intersected, SDL_TRUE, &rect, &refRect, x1, y1, x2, y2, xmin, ymax, xmax, ymin);
   1.179 +
   1.180 +	return TEST_COMPLETED;
   1.181 +}
   1.182 +
   1.183 +/*!
   1.184 + * \brief Tests SDL_IntersectRectAndLine() non-clipping cases outside
   1.185 + *
   1.186 + * \sa
   1.187 + * http://wiki.libsdl.org/moin.cgi/SDL_IntersectRectAndLine
   1.188 + */
   1.189 +int 
   1.190 +rect_testIntersectRectAndLineOutside (void *arg)
   1.191 +{
   1.192 +    SDL_Rect refRect = { 0, 0, 32, 32 };
   1.193 +    SDL_Rect rect;
   1.194 +    int x1, y1;
   1.195 +    int x2, y2;
   1.196 +    SDL_bool intersected;
   1.197 +
   1.198 +    int xLeft = -SDLTest_RandomIntegerInRange(1, refRect.w);
   1.199 +    int xRight = refRect.w + SDLTest_RandomIntegerInRange(1, refRect.w);
   1.200 +    int yTop = -SDLTest_RandomIntegerInRange(1, refRect.h);
   1.201 +    int yBottom = refRect.h + SDLTest_RandomIntegerInRange(1, refRect.h);
   1.202 +
   1.203 +    x1 = xLeft;
   1.204 +    y1 = 0;
   1.205 +    x2 = xLeft;
   1.206 +    y2 = 31;
   1.207 +    rect = refRect;
   1.208 +    intersected = SDL_IntersectRectAndLine(&rect, &x1, &y1, &x2, &y2);
   1.209 +    _validateIntersectRectAndLineResults(intersected, SDL_FALSE, &rect, &refRect, x1, y1, x2, y2, xLeft, 0, xLeft, 31);
   1.210 +
   1.211 +    x1 = xRight;
   1.212 +    y1 = 0;
   1.213 +    x2 = xRight;
   1.214 +    y2 = 31;
   1.215 +    rect = refRect;
   1.216 +    intersected = SDL_IntersectRectAndLine(&rect, &x1, &y1, &x2, &y2);
   1.217 +    _validateIntersectRectAndLineResults(intersected, SDL_FALSE, &rect, &refRect, x1, y1, x2, y2, xRight, 0, xRight, 31);
   1.218 +
   1.219 +    x1 = 0;
   1.220 +    y1 = yTop;
   1.221 +    x2 = 31;
   1.222 +    y2 = yTop;
   1.223 +    rect = refRect;
   1.224 +    intersected = SDL_IntersectRectAndLine(&rect, &x1, &y1, &x2, &y2);
   1.225 +    _validateIntersectRectAndLineResults(intersected, SDL_FALSE, &rect, &refRect, x1, y1, x2, y2, 0, yTop, 31, yTop);
   1.226 +
   1.227 +    x1 = 0;
   1.228 +    y1 = yBottom;
   1.229 +    x2 = 31;
   1.230 +    y2 = yBottom;
   1.231 +    rect = refRect;
   1.232 +    intersected = SDL_IntersectRectAndLine(&rect, &x1, &y1, &x2, &y2);
   1.233 +    _validateIntersectRectAndLineResults(intersected, SDL_FALSE, &rect, &refRect, x1, y1, x2, y2, 0, yBottom, 31, yBottom);
   1.234 +
   1.235 +	return TEST_COMPLETED;
   1.236 +}
   1.237 +
   1.238 +/*!
   1.239 + * \brief Tests SDL_IntersectRectAndLine() with empty rectangle
   1.240 + *
   1.241 + * \sa
   1.242 + * http://wiki.libsdl.org/moin.cgi/SDL_IntersectRectAndLine
   1.243 + */
   1.244 +int 
   1.245 +rect_testIntersectRectAndLineEmpty (void *arg)
   1.246 +{
   1.247 +    SDL_Rect refRect;
   1.248 +    SDL_Rect rect;
   1.249 +    int x1, y1, x1Ref, y1Ref;
   1.250 +    int x2, y2, x2Ref, y2Ref;
   1.251 +    SDL_bool intersected;
   1.252 +        
   1.253 +    refRect.x = SDLTest_RandomIntegerInRange(1, 1024);
   1.254 +    refRect.y = SDLTest_RandomIntegerInRange(1, 1024);
   1.255 +    refRect.w = 0;
   1.256 +    refRect.h = 0;
   1.257 +    x1Ref = refRect.x;
   1.258 +    y1Ref = refRect.y;
   1.259 +    x2Ref = SDLTest_RandomIntegerInRange(1, 1024);
   1.260 +    y2Ref = SDLTest_RandomIntegerInRange(1, 1024);
   1.261 +
   1.262 +    x1 = x1Ref;
   1.263 +    y1 = y1Ref;
   1.264 +    x2 = x2Ref;
   1.265 +    y2 = y2Ref;
   1.266 +    rect = refRect;
   1.267 +    intersected = SDL_IntersectRectAndLine(&rect, &x1, &y1, &x2, &y2);
   1.268 +    _validateIntersectRectAndLineResults(intersected, SDL_FALSE, &rect, &refRect, x1, y1, x2, y2, x1Ref, y1Ref, x2Ref, y2Ref);
   1.269 +
   1.270 +	return TEST_COMPLETED;
   1.271 +}
   1.272 +
   1.273 +/*!
   1.274 + * \brief Negative tests against SDL_IntersectRectAndLine() with invalid parameters
   1.275 + *
   1.276 + * \sa
   1.277 + * http://wiki.libsdl.org/moin.cgi/SDL_IntersectRectAndLine
   1.278 + */
   1.279 +int 
   1.280 +rect_testIntersectRectAndLineParam (void *arg)
   1.281 +{
   1.282 +    SDL_Rect rect = { 0, 0, 32, 32 };
   1.283 +    int x1 = rect.w / 2;
   1.284 +    int y1 = rect.h / 2;
   1.285 +    int x2 = x1;
   1.286 +    int y2 = 2 * rect.h;
   1.287 +    SDL_bool intersected;
   1.288 +    
   1.289 +    intersected = SDL_IntersectRectAndLine(&rect, &x1, &y1, &x2, &y2);
   1.290 +    SDLTest_AssertCheck(intersected == SDL_TRUE, "Check that intersection result was SDL_TRUE");
   1.291 +    
   1.292 +    intersected = SDL_IntersectRectAndLine((SDL_Rect *)NULL, &x1, &y1, &x2, &y2);
   1.293 +    SDLTest_AssertCheck(intersected == SDL_FALSE, "Check that function returns SDL_FALSE when 1st parameter is NULL");
   1.294 +    intersected = SDL_IntersectRectAndLine(&rect, (int *)NULL, &y1, &x2, &y2);
   1.295 +    SDLTest_AssertCheck(intersected == SDL_FALSE, "Check that function returns SDL_FALSE when 2nd parameter is NULL");
   1.296 +    intersected = SDL_IntersectRectAndLine(&rect, &x1, (int *)NULL, &x2, &y2);
   1.297 +    SDLTest_AssertCheck(intersected == SDL_FALSE, "Check that function returns SDL_FALSE when 3rd parameter is NULL");
   1.298 +    intersected = SDL_IntersectRectAndLine(&rect, &x1, &y1, (int *)NULL, &y2);
   1.299 +    SDLTest_AssertCheck(intersected == SDL_FALSE, "Check that function returns SDL_FALSE when 4th parameter is NULL");
   1.300 +    intersected = SDL_IntersectRectAndLine(&rect, &x1, &y1, &x2, (int *)NULL);
   1.301 +    SDLTest_AssertCheck(intersected == SDL_FALSE, "Check that function returns SDL_FALSE when 5th parameter is NULL");
   1.302 +    intersected = SDL_IntersectRectAndLine((SDL_Rect *)NULL, (int *)NULL, (int *)NULL, (int *)NULL, (int *)NULL);
   1.303 +    SDLTest_AssertCheck(intersected == SDL_FALSE, "Check that function returns SDL_FALSE when all parameters are NULL");
   1.304 +
   1.305 +	return TEST_COMPLETED;
   1.306 +}
   1.307 +
   1.308 +/*!
   1.309 + * \brief Private helper to check SDL_HasIntersection results
   1.310 + */
   1.311 +void _validateHasIntersectionResults(
   1.312 +    SDL_bool intersection, SDL_bool expectedIntersection, 
   1.313 +    SDL_Rect *rectA, SDL_Rect *rectB, SDL_Rect *refRectA, SDL_Rect *refRectB)
   1.314 +{
   1.315 +    SDLTest_AssertCheck(intersection == expectedIntersection, 
   1.316 +        "Check intersection result: expected %s, got %s intersecting A (%d,%d,%d,%d) with B (%d,%d,%d,%d)",
   1.317 +        (expectedIntersection == SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE",
   1.318 +        (intersection == SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE",
   1.319 +        rectA->x, rectA->y, rectA->w, rectA->h, 
   1.320 +        rectB->x, rectB->y, rectB->w, rectB->h);
   1.321 +    SDLTest_AssertCheck(rectA->x == refRectA->x && rectA->y == refRectA->y && rectA->w == refRectA->w && rectA->h == refRectA->h,
   1.322 +        "Check that source rectangle A was not modified: got (%d,%d,%d,%d) expected (%d,%d,%d,%d)",
   1.323 +        rectA->x, rectA->y, rectA->w, rectA->h,
   1.324 +        refRectA->x, refRectA->y, refRectA->w, refRectA->h);
   1.325 +    SDLTest_AssertCheck(rectB->x == refRectB->x && rectB->y == refRectB->y && rectB->w == refRectB->w && rectB->h == refRectB->h,
   1.326 +        "Check that source rectangle B was not modified: got (%d,%d,%d,%d) expected (%d,%d,%d,%d)",
   1.327 +        rectB->x, rectB->y, rectB->w, rectB->h,
   1.328 +        refRectB->x, refRectB->y, refRectB->w, refRectB->h);
   1.329 +}
   1.330 +
   1.331 +/*!
   1.332 + * \brief Private helper to check SDL_IntersectRect results
   1.333 + */
   1.334 +void _validateIntersectRectResults(
   1.335 +    SDL_bool intersection, SDL_bool expectedIntersection, 
   1.336 +    SDL_Rect *rectA, SDL_Rect *rectB, SDL_Rect *refRectA, SDL_Rect *refRectB, 
   1.337 +    SDL_Rect *result, SDL_Rect *expectedResult)
   1.338 +{
   1.339 +    _validateHasIntersectionResults(intersection, expectedIntersection, rectA, rectB, refRectA, refRectB);
   1.340 +    if (result && expectedResult) {
   1.341 +        SDLTest_AssertCheck(result->x == expectedResult->x && result->y == expectedResult->y && result->w == expectedResult->w && result->h == expectedResult->h,
   1.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)",
   1.343 +            rectA->x, rectA->y, rectA->w, rectA->h, 
   1.344 +            rectB->x, rectB->y, rectB->w, rectB->h,
   1.345 +            result->x, result->y, result->w, result->h,
   1.346 +            expectedResult->x, expectedResult->y, expectedResult->w, expectedResult->h);
   1.347 +    }
   1.348 +}
   1.349 +
   1.350 +/*!
   1.351 + * \brief Private helper to check SDL_UnionRect results
   1.352 + */
   1.353 +void _validateUnionRectResults(
   1.354 +    SDL_Rect *rectA, SDL_Rect *rectB, SDL_Rect *refRectA, SDL_Rect *refRectB, 
   1.355 +    SDL_Rect *result, SDL_Rect *expectedResult)
   1.356 +{
   1.357 +    SDLTest_AssertCheck(rectA->x == refRectA->x && rectA->y == refRectA->y && rectA->w == refRectA->w && rectA->h == refRectA->h,
   1.358 +        "Check that source rectangle A was not modified: got (%d,%d,%d,%d) expected (%d,%d,%d,%d)",
   1.359 +        rectA->x, rectA->y, rectA->w, rectA->h,
   1.360 +        refRectA->x, refRectA->y, refRectA->w, refRectA->h);
   1.361 +    SDLTest_AssertCheck(rectB->x == refRectB->x && rectB->y == refRectB->y && rectB->w == refRectB->w && rectB->h == refRectB->h,
   1.362 +        "Check that source rectangle B was not modified: got (%d,%d,%d,%d) expected (%d,%d,%d,%d)",
   1.363 +        rectB->x, rectB->y, rectB->w, rectB->h,
   1.364 +        refRectB->x, refRectB->y, refRectB->w, refRectB->h);
   1.365 +    SDLTest_AssertCheck(result->x == expectedResult->x && result->y == expectedResult->y && result->w == expectedResult->w && result->h == expectedResult->h,
   1.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)",
   1.367 +        rectA->x, rectA->y, rectA->w, rectA->h, 
   1.368 +        rectB->x, rectB->y, rectB->w, rectB->h,
   1.369 +        result->x, result->y, result->w, result->h,
   1.370 +        expectedResult->x, expectedResult->y, expectedResult->w, expectedResult->h);
   1.371 +}
   1.372 +
   1.373 +/*!
   1.374 + * \brief Private helper to check SDL_RectEmpty results
   1.375 + */
   1.376 +void _validateRectEmptyResults(
   1.377 +    SDL_bool empty, SDL_bool expectedEmpty, 
   1.378 +    SDL_Rect *rect, SDL_Rect *refRect)
   1.379 +{
   1.380 +    SDLTest_AssertCheck(empty == expectedEmpty, 
   1.381 +        "Check for correct empty result: expected %s, got %s testing (%d,%d,%d,%d)",
   1.382 +        (expectedEmpty == SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE",
   1.383 +        (empty == SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE",
   1.384 +        rect->x, rect->y, rect->w, rect->h);
   1.385 +    SDLTest_AssertCheck(rect->x == refRect->x && rect->y == refRect->y && rect->w == refRect->w && rect->h == refRect->h,
   1.386 +        "Check that source rectangle was not modified: got (%d,%d,%d,%d) expected (%d,%d,%d,%d)",
   1.387 +        rect->x, rect->y, rect->w, rect->h,
   1.388 +        refRect->x, refRect->y, refRect->w, refRect->h);
   1.389 +}
   1.390 +
   1.391 +/*!
   1.392 + * \brief Private helper to check SDL_RectEquals results
   1.393 + */
   1.394 +void _validateRectEqualsResults(
   1.395 +    SDL_bool equals, SDL_bool expectedEquals, 
   1.396 +    SDL_Rect *rectA, SDL_Rect *rectB, SDL_Rect *refRectA, SDL_Rect *refRectB)
   1.397 +{
   1.398 +    SDLTest_AssertCheck(equals == expectedEquals, 
   1.399 +        "Check for correct equals result: expected %s, got %s testing (%d,%d,%d,%d) and (%d,%d,%d,%d)",
   1.400 +        (expectedEquals == SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE",
   1.401 +        (equals == SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE",
   1.402 +        rectA->x, rectA->y, rectA->w, rectA->h,
   1.403 +        rectB->x, rectB->y, rectB->w, rectB->h);
   1.404 +    SDLTest_AssertCheck(rectA->x == refRectA->x && rectA->y == refRectA->y && rectA->w == refRectA->w && rectA->h == refRectA->h,
   1.405 +        "Check that source rectangle A was not modified: got (%d,%d,%d,%d) expected (%d,%d,%d,%d)",
   1.406 +        rectA->x, rectA->y, rectA->w, rectA->h,
   1.407 +        refRectA->x, refRectA->y, refRectA->w, refRectA->h);
   1.408 +    SDLTest_AssertCheck(rectB->x == refRectB->x && rectB->y == refRectB->y && rectB->w == refRectB->w && rectB->h == refRectB->h,
   1.409 +        "Check that source rectangle B was not modified: got (%d,%d,%d,%d) expected (%d,%d,%d,%d)",
   1.410 +        rectB->x, rectB->y, rectB->w, rectB->h,
   1.411 +        refRectB->x, refRectB->y, refRectB->w, refRectB->h);
   1.412 +}
   1.413 +
   1.414 +/*!
   1.415 + * \brief Tests SDL_IntersectRect() with B fully inside A
   1.416 + *
   1.417 + * \sa
   1.418 + * http://wiki.libsdl.org/moin.cgi/SDL_IntersectRect
   1.419 + */
   1.420 +int rect_testIntersectRectInside (void *arg)
   1.421 +{
   1.422 +    SDL_Rect refRectA = { 0, 0, 32, 32 };
   1.423 +    SDL_Rect refRectB;
   1.424 +    SDL_Rect rectA;
   1.425 +    SDL_Rect rectB;
   1.426 +    SDL_Rect result;
   1.427 +    SDL_bool intersection;
   1.428 +
   1.429 +    // rectB fully contained in rectA
   1.430 +    refRectB.x = 0;
   1.431 +    refRectB.y = 0;
   1.432 +    refRectB.w = SDLTest_RandomIntegerInRange(refRectA.x + 1, refRectA.x + refRectA.w - 1);
   1.433 +    refRectB.h = SDLTest_RandomIntegerInRange(refRectA.y + 1, refRectA.y + refRectA.h - 1);
   1.434 +    rectA = refRectA;
   1.435 +    rectB = refRectB;
   1.436 +    intersection = SDL_IntersectRect(&rectA, &rectB, &result);
   1.437 +    _validateIntersectRectResults(intersection, SDL_TRUE, &rectA, &rectB, &refRectA, &refRectB, &result, &refRectB);
   1.438 +
   1.439 +	return TEST_COMPLETED;
   1.440 +}
   1.441 +
   1.442 +/*!
   1.443 + * \brief Tests SDL_IntersectRect() with B fully outside A
   1.444 + *
   1.445 + * \sa
   1.446 + * http://wiki.libsdl.org/moin.cgi/SDL_IntersectRect
   1.447 + */
   1.448 +int rect_testIntersectRectOutside (void *arg)
   1.449 +{
   1.450 +    SDL_Rect refRectA = { 0, 0, 32, 32 };
   1.451 +    SDL_Rect refRectB;
   1.452 +    SDL_Rect rectA;
   1.453 +    SDL_Rect rectB;
   1.454 +    SDL_Rect result;
   1.455 +    SDL_bool intersection;
   1.456 +
   1.457 +    // rectB fully outside of rectA
   1.458 +    refRectB.x = refRectA.x + refRectA.w + SDLTest_RandomIntegerInRange(1, 10);
   1.459 +    refRectB.y = refRectA.y + refRectA.h + SDLTest_RandomIntegerInRange(1, 10);
   1.460 +    refRectB.w = refRectA.w;
   1.461 +    refRectB.h = refRectA.h;
   1.462 +    rectA = refRectA;
   1.463 +    rectB = refRectB;
   1.464 +    intersection = SDL_IntersectRect(&rectA, &rectB, &result);
   1.465 +    _validateIntersectRectResults(intersection, SDL_FALSE, &rectA, &rectB, &refRectA, &refRectB, (SDL_Rect *)NULL, (SDL_Rect *)NULL);    
   1.466 +
   1.467 +	return TEST_COMPLETED;
   1.468 +}
   1.469 +
   1.470 +/*!
   1.471 + * \brief Tests SDL_IntersectRect() with B partially intersecting A
   1.472 + *
   1.473 + * \sa
   1.474 + * http://wiki.libsdl.org/moin.cgi/SDL_IntersectRect
   1.475 + */
   1.476 +int rect_testIntersectRectPartial (void *arg)
   1.477 +{
   1.478 +    SDL_Rect refRectA = { 0, 0, 32, 32 };
   1.479 +    SDL_Rect refRectB;
   1.480 +    SDL_Rect rectA;
   1.481 +    SDL_Rect rectB;
   1.482 +    SDL_Rect result;
   1.483 +    SDL_Rect expectedResult;
   1.484 +    SDL_bool intersection;
   1.485 +
   1.486 +    // rectB partially contained in rectA
   1.487 +    refRectB.x = SDLTest_RandomIntegerInRange(refRectA.x + 1, refRectA.x + refRectA.w - 1);
   1.488 +    refRectB.y = SDLTest_RandomIntegerInRange(refRectA.y + 1, refRectA.y + refRectA.h - 1);
   1.489 +    refRectB.w = refRectA.w;
   1.490 +    refRectB.h = refRectA.h;
   1.491 +    rectA = refRectA;
   1.492 +    rectB = refRectB;
   1.493 +    expectedResult.x = refRectB.x;
   1.494 +    expectedResult.y = refRectB.y;
   1.495 +    expectedResult.w = refRectA.w - refRectB.x;
   1.496 +    expectedResult.h = refRectA.h - refRectB.y;    
   1.497 +    intersection = SDL_IntersectRect(&rectA, &rectB, &result);
   1.498 +    _validateIntersectRectResults(intersection, SDL_TRUE, &rectA, &rectB, &refRectA, &refRectB, &result, &expectedResult);
   1.499 +
   1.500 +    // rectB right edge
   1.501 +    refRectB.x = rectA.w - 1;
   1.502 +    refRectB.y = rectA.y;
   1.503 +    refRectB.w = SDLTest_RandomIntegerInRange(1, refRectA.w - 1);
   1.504 +    refRectB.h = SDLTest_RandomIntegerInRange(1, refRectA.h - 1);
   1.505 +    rectA = refRectA;
   1.506 +    rectB = refRectB;
   1.507 +    expectedResult.x = refRectB.x;
   1.508 +    expectedResult.y = refRectB.y;
   1.509 +    expectedResult.w = 1;
   1.510 +    expectedResult.h = refRectB.h;    
   1.511 +    intersection = SDL_IntersectRect(&rectA, &rectB, &result);
   1.512 +    _validateIntersectRectResults(intersection, SDL_TRUE, &rectA, &rectB, &refRectA, &refRectB, &result, &expectedResult);
   1.513 +
   1.514 +    // rectB left edge
   1.515 +    refRectB.x = 1 - rectA.w;
   1.516 +    refRectB.y = rectA.y;
   1.517 +    refRectB.w = refRectA.w;
   1.518 +    refRectB.h = SDLTest_RandomIntegerInRange(1, refRectA.h - 1);
   1.519 +    rectA = refRectA;
   1.520 +    rectB = refRectB;
   1.521 +    expectedResult.x = 0;
   1.522 +    expectedResult.y = refRectB.y;
   1.523 +    expectedResult.w = 1;
   1.524 +    expectedResult.h = refRectB.h;    
   1.525 +    intersection = SDL_IntersectRect(&rectA, &rectB, &result);
   1.526 +    _validateIntersectRectResults(intersection, SDL_TRUE, &rectA, &rectB, &refRectA, &refRectB, &result, &expectedResult);
   1.527 +
   1.528 +    // rectB bottom edge
   1.529 +    refRectB.x = rectA.x;
   1.530 +    refRectB.y = rectA.h - 1;
   1.531 +    refRectB.w = SDLTest_RandomIntegerInRange(1, refRectA.w - 1);
   1.532 +    refRectB.h = SDLTest_RandomIntegerInRange(1, refRectA.h - 1);
   1.533 +    rectA = refRectA;
   1.534 +    rectB = refRectB;
   1.535 +    expectedResult.x = refRectB.x;
   1.536 +    expectedResult.y = refRectB.y;
   1.537 +    expectedResult.w = refRectB.w;
   1.538 +    expectedResult.h = 1;    
   1.539 +    intersection = SDL_IntersectRect(&rectA, &rectB, &result);
   1.540 +    _validateIntersectRectResults(intersection, SDL_TRUE, &rectA, &rectB, &refRectA, &refRectB, &result, &expectedResult);
   1.541 +
   1.542 +    // rectB top edge
   1.543 +    refRectB.x = rectA.x;
   1.544 +    refRectB.y = 1 - rectA.h;
   1.545 +    refRectB.w = SDLTest_RandomIntegerInRange(1, refRectA.w - 1);
   1.546 +    refRectB.h = rectA.h;
   1.547 +    rectA = refRectA;
   1.548 +    rectB = refRectB;
   1.549 +    expectedResult.x = refRectB.x;
   1.550 +    expectedResult.y = 0;
   1.551 +    expectedResult.w = refRectB.w;
   1.552 +    expectedResult.h = 1;    
   1.553 +    intersection = SDL_IntersectRect(&rectA, &rectB, &result);
   1.554 +    _validateIntersectRectResults(intersection, SDL_TRUE, &rectA, &rectB, &refRectA, &refRectB, &result, &expectedResult);
   1.555 +
   1.556 +	return TEST_COMPLETED;
   1.557 +}
   1.558 +
   1.559 +/*!
   1.560 + * \brief Tests SDL_IntersectRect() with 1x1 pixel sized rectangles
   1.561 + *
   1.562 + * \sa
   1.563 + * http://wiki.libsdl.org/moin.cgi/SDL_IntersectRect
   1.564 + */
   1.565 +int rect_testIntersectRectPoint (void *arg)
   1.566 +{
   1.567 +    SDL_Rect refRectA = { 0, 0, 1, 1 };
   1.568 +    SDL_Rect refRectB = { 0, 0, 1, 1 };
   1.569 +    SDL_Rect rectA;
   1.570 +    SDL_Rect rectB;
   1.571 +    SDL_Rect result;
   1.572 +    SDL_bool intersection;
   1.573 +    int offsetX, offsetY;
   1.574 +
   1.575 +    // intersecting pixels
   1.576 +    refRectA.x = SDLTest_RandomIntegerInRange(1, 100);
   1.577 +    refRectA.y = SDLTest_RandomIntegerInRange(1, 100);
   1.578 +    refRectB.x = refRectA.x;
   1.579 +    refRectB.y = refRectA.y;
   1.580 +    rectA = refRectA;
   1.581 +    rectB = refRectB;
   1.582 +    intersection = SDL_IntersectRect(&rectA, &rectB, &result);
   1.583 +    _validateIntersectRectResults(intersection, SDL_TRUE, &rectA, &rectB, &refRectA, &refRectB, &result, &refRectA);
   1.584 +
   1.585 +    // non-intersecting pixels cases
   1.586 +    for (offsetX = -1; offsetX <= 1; offsetX++) {
   1.587 +        for (offsetY = -1; offsetY <= 1; offsetY++) {
   1.588 +            if (offsetX != 0 || offsetY != 0) {
   1.589 +                refRectA.x = SDLTest_RandomIntegerInRange(1, 100);
   1.590 +                refRectA.y = SDLTest_RandomIntegerInRange(1, 100);
   1.591 +                refRectB.x = refRectA.x;
   1.592 +                refRectB.y = refRectA.y;    
   1.593 +                refRectB.x += offsetX;
   1.594 +                refRectB.y += offsetY;
   1.595 +                rectA = refRectA;
   1.596 +                rectB = refRectB;
   1.597 +                intersection = SDL_IntersectRect(&rectA, &rectB, &result);
   1.598 +                _validateIntersectRectResults(intersection, SDL_FALSE, &rectA, &rectB, &refRectA, &refRectB, (SDL_Rect *)NULL, (SDL_Rect *)NULL);
   1.599 +            }
   1.600 +        }
   1.601 +    }
   1.602 +
   1.603 +	return TEST_COMPLETED;
   1.604 +}
   1.605 +
   1.606 +/*!
   1.607 + * \brief Tests SDL_IntersectRect() with empty rectangles
   1.608 + *
   1.609 + * \sa
   1.610 + * http://wiki.libsdl.org/moin.cgi/SDL_IntersectRect
   1.611 + */
   1.612 +int rect_testIntersectRectEmpty (void *arg)
   1.613 +{
   1.614 +    SDL_Rect refRectA;
   1.615 +    SDL_Rect refRectB;
   1.616 +    SDL_Rect rectA;
   1.617 +    SDL_Rect rectB;
   1.618 +    SDL_Rect result;
   1.619 +    SDL_bool intersection;
   1.620 +
   1.621 +    // Rect A empty
   1.622 +    refRectA.x = SDLTest_RandomIntegerInRange(1, 100);
   1.623 +    refRectA.y = SDLTest_RandomIntegerInRange(1, 100);
   1.624 +    refRectA.w = SDLTest_RandomIntegerInRange(1, 100);
   1.625 +    refRectA.h = SDLTest_RandomIntegerInRange(1, 100);
   1.626 +    refRectB = refRectA;
   1.627 +    refRectA.w = 0;
   1.628 +    refRectA.h = 0;
   1.629 +    rectA = refRectA;
   1.630 +    rectB = refRectB;
   1.631 +    intersection = SDL_IntersectRect(&rectA, &rectB, &result);
   1.632 +    _validateIntersectRectResults(intersection, SDL_FALSE, &rectA, &rectB, &refRectA, &refRectB, (SDL_Rect *)NULL, (SDL_Rect *)NULL);
   1.633 +
   1.634 +    // Rect B empty
   1.635 +    refRectA.x = SDLTest_RandomIntegerInRange(1, 100);
   1.636 +    refRectA.y = SDLTest_RandomIntegerInRange(1, 100);
   1.637 +    refRectA.w = SDLTest_RandomIntegerInRange(1, 100);
   1.638 +    refRectA.h = SDLTest_RandomIntegerInRange(1, 100);
   1.639 +    refRectB = refRectA;
   1.640 +    refRectB.w = 0;
   1.641 +    refRectB.h = 0;
   1.642 +    rectA = refRectA;
   1.643 +    rectB = refRectB;
   1.644 +    intersection = SDL_IntersectRect(&rectA, &rectB, &result);
   1.645 +    _validateIntersectRectResults(intersection, SDL_FALSE, &rectA, &rectB, &refRectA, &refRectB, (SDL_Rect *)NULL, (SDL_Rect *)NULL);
   1.646 +
   1.647 +    // Rect A and B empty
   1.648 +    refRectA.x = SDLTest_RandomIntegerInRange(1, 100);
   1.649 +    refRectA.y = SDLTest_RandomIntegerInRange(1, 100);
   1.650 +    refRectA.w = SDLTest_RandomIntegerInRange(1, 100);
   1.651 +    refRectA.h = SDLTest_RandomIntegerInRange(1, 100);
   1.652 +    refRectB = refRectA;
   1.653 +    refRectA.w = 0;
   1.654 +    refRectA.h = 0;
   1.655 +    refRectB.w = 0;
   1.656 +    refRectB.h = 0;
   1.657 +    rectA = refRectA;
   1.658 +    rectB = refRectB;
   1.659 +    intersection = SDL_IntersectRect(&rectA, &rectB, &result);
   1.660 +    _validateIntersectRectResults(intersection, SDL_FALSE, &rectA, &rectB, &refRectA, &refRectB, (SDL_Rect *)NULL, (SDL_Rect *)NULL);
   1.661 +
   1.662 +	return TEST_COMPLETED;
   1.663 +}
   1.664 +
   1.665 +/*!
   1.666 + * \brief Negative tests against SDL_IntersectRect() with invalid parameters
   1.667 + *
   1.668 + * \sa
   1.669 + * http://wiki.libsdl.org/moin.cgi/SDL_IntersectRect
   1.670 + */
   1.671 +int rect_testIntersectRectParam(void *arg)
   1.672 +{
   1.673 +    SDL_Rect rectA;
   1.674 +    SDL_Rect rectB;
   1.675 +    SDL_Rect result;
   1.676 +    SDL_bool intersection;
   1.677 +
   1.678 +    // invalid parameter combinations
   1.679 +    intersection = SDL_IntersectRect((SDL_Rect *)NULL, &rectB, &result);
   1.680 +    SDLTest_AssertCheck(intersection == SDL_FALSE, "Check that function returns SDL_FALSE when 1st parameter is NULL"); 
   1.681 +    intersection = SDL_IntersectRect(&rectA, (SDL_Rect *)NULL, &result);
   1.682 +    SDLTest_AssertCheck(intersection == SDL_FALSE, "Check that function returns SDL_FALSE when 2st parameter is NULL"); 
   1.683 +    intersection = SDL_IntersectRect(&rectA, &rectB, (SDL_Rect *)NULL);
   1.684 +    SDLTest_AssertCheck(intersection == SDL_FALSE, "Check that function returns SDL_FALSE when 3st parameter is NULL"); 
   1.685 +    intersection = SDL_IntersectRect((SDL_Rect *)NULL, (SDL_Rect *)NULL, &result);
   1.686 +    SDLTest_AssertCheck(intersection == SDL_FALSE, "Check that function returns SDL_FALSE when 1st and 2nd parameters are NULL"); 
   1.687 +    intersection = SDL_IntersectRect((SDL_Rect *)NULL, &rectB, (SDL_Rect *)NULL);
   1.688 +    SDLTest_AssertCheck(intersection == SDL_FALSE, "Check that function returns SDL_FALSE when 1st and 3rd parameters are NULL "); 
   1.689 +    intersection = SDL_IntersectRect((SDL_Rect *)NULL, (SDL_Rect *)NULL, (SDL_Rect *)NULL);
   1.690 +    SDLTest_AssertCheck(intersection == SDL_FALSE, "Check that function returns SDL_FALSE when all parameters are NULL");     
   1.691 +
   1.692 +	return TEST_COMPLETED;
   1.693 +}
   1.694 +
   1.695 +/*!
   1.696 + * \brief Tests SDL_HasIntersection() with B fully inside A
   1.697 + *
   1.698 + * \sa
   1.699 + * http://wiki.libsdl.org/moin.cgi/SDL_HasIntersection
   1.700 + */
   1.701 +int rect_testHasIntersectionInside (void *arg)
   1.702 +{
   1.703 +    SDL_Rect refRectA = { 0, 0, 32, 32 };
   1.704 +    SDL_Rect refRectB;
   1.705 +    SDL_Rect rectA;
   1.706 +    SDL_Rect rectB;
   1.707 +    SDL_bool intersection;
   1.708 +
   1.709 +    // rectB fully contained in rectA
   1.710 +    refRectB.x = 0;
   1.711 +    refRectB.y = 0;
   1.712 +    refRectB.w = SDLTest_RandomIntegerInRange(refRectA.x + 1, refRectA.x + refRectA.w - 1);
   1.713 +    refRectB.h = SDLTest_RandomIntegerInRange(refRectA.y + 1, refRectA.y + refRectA.h - 1);
   1.714 +    rectA = refRectA;
   1.715 +    rectB = refRectB;
   1.716 +    intersection = SDL_HasIntersection(&rectA, &rectB);
   1.717 +    _validateHasIntersectionResults(intersection, SDL_TRUE, &rectA, &rectB, &refRectA, &refRectB);
   1.718 +
   1.719 +	return TEST_COMPLETED;
   1.720 +}
   1.721 +
   1.722 +/*!
   1.723 + * \brief Tests SDL_HasIntersection() with B fully outside A
   1.724 + *
   1.725 + * \sa
   1.726 + * http://wiki.libsdl.org/moin.cgi/SDL_HasIntersection
   1.727 + */
   1.728 +int rect_testHasIntersectionOutside (void *arg)
   1.729 +{
   1.730 +    SDL_Rect refRectA = { 0, 0, 32, 32 };
   1.731 +    SDL_Rect refRectB;
   1.732 +    SDL_Rect rectA;
   1.733 +    SDL_Rect rectB;
   1.734 +    SDL_bool intersection;
   1.735 +
   1.736 +    // rectB fully outside of rectA
   1.737 +    refRectB.x = refRectA.x + refRectA.w + SDLTest_RandomIntegerInRange(1, 10);
   1.738 +    refRectB.y = refRectA.y + refRectA.h + SDLTest_RandomIntegerInRange(1, 10);
   1.739 +    refRectB.w = refRectA.w;
   1.740 +    refRectB.h = refRectA.h;
   1.741 +    rectA = refRectA;
   1.742 +    rectB = refRectB;
   1.743 +    intersection = SDL_HasIntersection(&rectA, &rectB);
   1.744 +    _validateHasIntersectionResults(intersection, SDL_FALSE, &rectA, &rectB, &refRectA, &refRectB);
   1.745 +
   1.746 +	return TEST_COMPLETED;
   1.747 +}
   1.748 +
   1.749 +/*!
   1.750 + * \brief Tests SDL_HasIntersection() with B partially intersecting A
   1.751 + *
   1.752 + * \sa
   1.753 + * http://wiki.libsdl.org/moin.cgi/SDL_HasIntersection
   1.754 + */
   1.755 +int rect_testHasIntersectionPartial (void *arg)
   1.756 +{
   1.757 +    SDL_Rect refRectA = { 0, 0, 32, 32 };
   1.758 +    SDL_Rect refRectB;
   1.759 +    SDL_Rect rectA;
   1.760 +    SDL_Rect rectB;
   1.761 +    SDL_bool intersection;
   1.762 +
   1.763 +    // rectB partially contained in rectA
   1.764 +    refRectB.x = SDLTest_RandomIntegerInRange(refRectA.x + 1, refRectA.x + refRectA.w - 1);
   1.765 +    refRectB.y = SDLTest_RandomIntegerInRange(refRectA.y + 1, refRectA.y + refRectA.h - 1);
   1.766 +    refRectB.w = refRectA.w;
   1.767 +    refRectB.h = refRectA.h;
   1.768 +    rectA = refRectA;
   1.769 +    rectB = refRectB;
   1.770 +    intersection = SDL_HasIntersection(&rectA, &rectB);
   1.771 +    _validateHasIntersectionResults(intersection, SDL_TRUE, &rectA, &rectB, &refRectA, &refRectB);
   1.772 +
   1.773 +    // rectB right edge
   1.774 +    refRectB.x = rectA.w - 1;
   1.775 +    refRectB.y = rectA.y;
   1.776 +    refRectB.w = SDLTest_RandomIntegerInRange(1, refRectA.w - 1);
   1.777 +    refRectB.h = SDLTest_RandomIntegerInRange(1, refRectA.h - 1);
   1.778 +    rectA = refRectA;
   1.779 +    rectB = refRectB;
   1.780 +    intersection = SDL_HasIntersection(&rectA, &rectB);
   1.781 +    _validateHasIntersectionResults(intersection, SDL_TRUE, &rectA, &rectB, &refRectA, &refRectB);
   1.782 +
   1.783 +    // rectB left edge
   1.784 +    refRectB.x = 1 - rectA.w;
   1.785 +    refRectB.y = rectA.y;
   1.786 +    refRectB.w = refRectA.w;
   1.787 +    refRectB.h = SDLTest_RandomIntegerInRange(1, refRectA.h - 1);
   1.788 +    rectA = refRectA;
   1.789 +    rectB = refRectB;
   1.790 +    intersection = SDL_HasIntersection(&rectA, &rectB);
   1.791 +    _validateHasIntersectionResults(intersection, SDL_TRUE, &rectA, &rectB, &refRectA, &refRectB);
   1.792 +
   1.793 +    // rectB bottom edge
   1.794 +    refRectB.x = rectA.x;
   1.795 +    refRectB.y = rectA.h - 1;
   1.796 +    refRectB.w = SDLTest_RandomIntegerInRange(1, refRectA.w - 1);
   1.797 +    refRectB.h = SDLTest_RandomIntegerInRange(1, refRectA.h - 1);
   1.798 +    rectA = refRectA;
   1.799 +    rectB = refRectB;
   1.800 +    intersection = SDL_HasIntersection(&rectA, &rectB);
   1.801 +    _validateHasIntersectionResults(intersection, SDL_TRUE, &rectA, &rectB, &refRectA, &refRectB);
   1.802 +
   1.803 +    // rectB top edge
   1.804 +    refRectB.x = rectA.x;
   1.805 +    refRectB.y = 1 - rectA.h;
   1.806 +    refRectB.w = SDLTest_RandomIntegerInRange(1, refRectA.w - 1);
   1.807 +    refRectB.h = rectA.h;
   1.808 +    rectA = refRectA;
   1.809 +    rectB = refRectB;
   1.810 +    intersection = SDL_HasIntersection(&rectA, &rectB);
   1.811 +    _validateHasIntersectionResults(intersection, SDL_TRUE, &rectA, &rectB, &refRectA, &refRectB);
   1.812 +
   1.813 +	return TEST_COMPLETED;
   1.814 +}
   1.815 +
   1.816 +/*!
   1.817 + * \brief Tests SDL_HasIntersection() with 1x1 pixel sized rectangles
   1.818 + *
   1.819 + * \sa
   1.820 + * http://wiki.libsdl.org/moin.cgi/SDL_HasIntersection
   1.821 + */
   1.822 +int rect_testHasIntersectionPoint (void *arg)
   1.823 +{
   1.824 +    SDL_Rect refRectA = { 0, 0, 1, 1 };
   1.825 +    SDL_Rect refRectB = { 0, 0, 1, 1 };
   1.826 +    SDL_Rect rectA;
   1.827 +    SDL_Rect rectB;
   1.828 +    SDL_bool intersection;
   1.829 +    int offsetX, offsetY;
   1.830 +
   1.831 +    // intersecting pixels
   1.832 +    refRectA.x = SDLTest_RandomIntegerInRange(1, 100);
   1.833 +    refRectA.y = SDLTest_RandomIntegerInRange(1, 100);
   1.834 +    refRectB.x = refRectA.x;
   1.835 +    refRectB.y = refRectA.y;
   1.836 +    rectA = refRectA;
   1.837 +    rectB = refRectB;
   1.838 +    intersection = SDL_HasIntersection(&rectA, &rectB);
   1.839 +    _validateHasIntersectionResults(intersection, SDL_TRUE, &rectA, &rectB, &refRectA, &refRectB);
   1.840 +
   1.841 +    // non-intersecting pixels cases
   1.842 +    for (offsetX = -1; offsetX <= 1; offsetX++) {
   1.843 +        for (offsetY = -1; offsetY <= 1; offsetY++) {
   1.844 +            if (offsetX != 0 || offsetY != 0) {
   1.845 +                refRectA.x = SDLTest_RandomIntegerInRange(1, 100);
   1.846 +                refRectA.y = SDLTest_RandomIntegerInRange(1, 100);
   1.847 +                refRectB.x = refRectA.x;
   1.848 +                refRectB.y = refRectA.y;    
   1.849 +                refRectB.x += offsetX;
   1.850 +                refRectB.y += offsetY;
   1.851 +                rectA = refRectA;
   1.852 +                rectB = refRectB;
   1.853 +                intersection = SDL_HasIntersection(&rectA, &rectB);
   1.854 +                _validateHasIntersectionResults(intersection, SDL_FALSE, &rectA, &rectB, &refRectA, &refRectB);
   1.855 +            }
   1.856 +        }
   1.857 +    }
   1.858 +
   1.859 +	return TEST_COMPLETED;
   1.860 +}
   1.861 +
   1.862 +/*!
   1.863 + * \brief Tests SDL_HasIntersection() with empty rectangles
   1.864 + *
   1.865 + * \sa
   1.866 + * http://wiki.libsdl.org/moin.cgi/SDL_HasIntersection
   1.867 + */
   1.868 +int rect_testHasIntersectionEmpty (void *arg)
   1.869 +{
   1.870 +    SDL_Rect refRectA;
   1.871 +    SDL_Rect refRectB;
   1.872 +    SDL_Rect rectA;
   1.873 +    SDL_Rect rectB;
   1.874 +    SDL_bool intersection;
   1.875 +
   1.876 +    // Rect A empty
   1.877 +    refRectA.x = SDLTest_RandomIntegerInRange(1, 100);
   1.878 +    refRectA.y = SDLTest_RandomIntegerInRange(1, 100);
   1.879 +    refRectA.w = SDLTest_RandomIntegerInRange(1, 100);
   1.880 +    refRectA.h = SDLTest_RandomIntegerInRange(1, 100);
   1.881 +    refRectB = refRectA;
   1.882 +    refRectA.w = 0;
   1.883 +    refRectA.h = 0;
   1.884 +    rectA = refRectA;
   1.885 +    rectB = refRectB;
   1.886 +    intersection = SDL_HasIntersection(&rectA, &rectB);
   1.887 +    _validateHasIntersectionResults(intersection, SDL_FALSE, &rectA, &rectB, &refRectA, &refRectB);
   1.888 +
   1.889 +    // Rect B empty
   1.890 +    refRectA.x = SDLTest_RandomIntegerInRange(1, 100);
   1.891 +    refRectA.y = SDLTest_RandomIntegerInRange(1, 100);
   1.892 +    refRectA.w = SDLTest_RandomIntegerInRange(1, 100);
   1.893 +    refRectA.h = SDLTest_RandomIntegerInRange(1, 100);
   1.894 +    refRectB = refRectA;
   1.895 +    refRectB.w = 0;
   1.896 +    refRectB.h = 0;
   1.897 +    rectA = refRectA;
   1.898 +    rectB = refRectB;
   1.899 +    intersection = SDL_HasIntersection(&rectA, &rectB);
   1.900 +    _validateHasIntersectionResults(intersection, SDL_FALSE, &rectA, &rectB, &refRectA, &refRectB);
   1.901 +
   1.902 +    // Rect A and B empty
   1.903 +    refRectA.x = SDLTest_RandomIntegerInRange(1, 100);
   1.904 +    refRectA.y = SDLTest_RandomIntegerInRange(1, 100);
   1.905 +    refRectA.w = SDLTest_RandomIntegerInRange(1, 100);
   1.906 +    refRectA.h = SDLTest_RandomIntegerInRange(1, 100);
   1.907 +    refRectB = refRectA;
   1.908 +    refRectA.w = 0;
   1.909 +    refRectA.h = 0;
   1.910 +    refRectB.w = 0;
   1.911 +    refRectB.h = 0;
   1.912 +    rectA = refRectA;
   1.913 +    rectB = refRectB;
   1.914 +    intersection = SDL_HasIntersection(&rectA, &rectB);
   1.915 +    _validateHasIntersectionResults(intersection, SDL_FALSE, &rectA, &rectB, &refRectA, &refRectB);
   1.916 +
   1.917 +	return TEST_COMPLETED;
   1.918 +}
   1.919 +
   1.920 +/*!
   1.921 + * \brief Negative tests against SDL_HasIntersection() with invalid parameters
   1.922 + *
   1.923 + * \sa
   1.924 + * http://wiki.libsdl.org/moin.cgi/SDL_HasIntersection
   1.925 + */
   1.926 +int rect_testHasIntersectionParam(void *arg)
   1.927 +{
   1.928 +    SDL_Rect rectA;
   1.929 +    SDL_Rect rectB;
   1.930 +    SDL_bool intersection;
   1.931 +
   1.932 +    // invalid parameter combinations
   1.933 +    intersection = SDL_HasIntersection((SDL_Rect *)NULL, &rectB);
   1.934 +    SDLTest_AssertCheck(intersection == SDL_FALSE, "Check that function returns SDL_FALSE when 1st parameter is NULL"); 
   1.935 +    intersection = SDL_HasIntersection(&rectA, (SDL_Rect *)NULL);
   1.936 +    SDLTest_AssertCheck(intersection == SDL_FALSE, "Check that function returns SDL_FALSE when 2st parameter is NULL"); 
   1.937 +    intersection = SDL_HasIntersection((SDL_Rect *)NULL, (SDL_Rect *)NULL);
   1.938 +    SDLTest_AssertCheck(intersection == SDL_FALSE, "Check that function returns SDL_FALSE when all parameters are NULL");     
   1.939 +
   1.940 +	return TEST_COMPLETED;
   1.941 +}
   1.942 +
   1.943 +/*!
   1.944 + * \brief Test SDL_EnclosePoints() without clipping
   1.945 + *
   1.946 + * \sa
   1.947 + * http://wiki.libsdl.org/moin.cgi/SDL_EnclosePoints
   1.948 + */
   1.949 +int rect_testEnclosePoints(void *arg)
   1.950 +{
   1.951 +    const int numPoints = 16;
   1.952 +    SDL_Point refPoints[16];
   1.953 +    SDL_Point points[16];
   1.954 +    SDL_Rect result;
   1.955 +    SDL_bool anyEnclosed;
   1.956 +    SDL_bool anyEnclosedNoResult;
   1.957 +
   1.958 +    // Create input data, tracking result
   1.959 +    SDL_bool expectedEnclosed = SDL_TRUE;
   1.960 +    int newx, newy;
   1.961 +    int minx, maxx, miny, maxy;
   1.962 +    int i;
   1.963 +    for (i=0; i<numPoints; i++) {
   1.964 +        newx = SDLTest_RandomIntegerInRange(-1024, 1024);
   1.965 +        newy = SDLTest_RandomIntegerInRange(-1024, 1024);
   1.966 +        refPoints[i].x = newx;
   1.967 +        refPoints[i].y = newy;
   1.968 +        points[i].x = newx;
   1.969 +        points[i].y = newy;
   1.970 +        if (i==0) {
   1.971 +            minx=maxx=newx;
   1.972 +            miny=maxy=newy;
   1.973 +        } else {
   1.974 +            if (newx<minx) minx=newx;
   1.975 +            if (newx>maxx) maxx=newx;
   1.976 +            if (newy<miny) miny=newy;
   1.977 +            if (newy>maxy) maxy=newy;
   1.978 +        }
   1.979 +    }
   1.980 +    
   1.981 +    // Call function and validate - special case: no result requested
   1.982 +    anyEnclosedNoResult = SDL_EnclosePoints((const SDL_Point *)points, numPoints, (const SDL_Rect *)NULL, (SDL_Rect *)NULL);
   1.983 +    SDLTest_AssertCheck(expectedEnclosed==anyEnclosedNoResult, 
   1.984 +        "Check expected return value %s, got %s", 
   1.985 +        (expectedEnclosed==SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE", 
   1.986 +		(anyEnclosedNoResult==SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE");
   1.987 +    for (i=0; i<numPoints; i++) {
   1.988 +        SDLTest_AssertCheck(refPoints[i].x==points[i].x && refPoints[i].y==points[i].y,
   1.989 +            "Check that source point %i was not modified: expected (%i,%i) actual (%i,%i)", 
   1.990 +            i, refPoints[i].x, refPoints[i].y, points[i].x, points[i].y);
   1.991 +    }
   1.992 +
   1.993 +    // Call function and validate
   1.994 +    anyEnclosed = SDL_EnclosePoints((const SDL_Point *)points, numPoints, (const SDL_Rect *)NULL, &result);
   1.995 +    SDLTest_AssertCheck(expectedEnclosed==anyEnclosed, 
   1.996 +        "Check return value %s, got %s", 
   1.997 +        (expectedEnclosed==SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE", 
   1.998 +		(anyEnclosed==SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE");
   1.999 +    for (i=0; i<numPoints; i++) {
  1.1000 +        SDLTest_AssertCheck(refPoints[i].x==points[i].x && refPoints[i].y==points[i].y,
  1.1001 +            "Check that source point %i was not modified: expected (%i,%i) actual (%i,%i)", 
  1.1002 +            i, refPoints[i].x, refPoints[i].y, points[i].x, points[i].y);
  1.1003 +    }
  1.1004 +    SDLTest_AssertCheck(result.x==minx && result.y==miny && result.w==(maxx - minx + 1) && result.h==(maxy - miny + 1),
  1.1005 +        "Resulting enclosing rectangle incorrect: expected (%i,%i - %i,%i), actual (%i,%i - %i,%i)",
  1.1006 +        minx, miny, maxx, maxy, result.x, result.y, result.x + result.w - 1, result.y + result.h - 1);
  1.1007 +
  1.1008 +	return TEST_COMPLETED;
  1.1009 +}
  1.1010 +
  1.1011 +/*!
  1.1012 + * \brief Test SDL_EnclosePoints() with repeated input points
  1.1013 + *
  1.1014 + * \sa
  1.1015 + * http://wiki.libsdl.org/moin.cgi/SDL_EnclosePoints
  1.1016 + */
  1.1017 +int rect_testEnclosePointsRepeatedInput(void *arg)
  1.1018 +{
  1.1019 +    const int numPoints = 8;
  1.1020 +    const int halfPoints = 4;
  1.1021 +    SDL_Point refPoints[8];
  1.1022 +    SDL_Point points[8];
  1.1023 +    SDL_Rect result;
  1.1024 +    SDL_bool anyEnclosed;
  1.1025 +    SDL_bool anyEnclosedNoResult;
  1.1026 +
  1.1027 +    // Create input data, tracking result
  1.1028 +    SDL_bool expectedEnclosed = SDL_TRUE;
  1.1029 +    int newx, newy;
  1.1030 +    int minx, maxx, miny, maxy;
  1.1031 +    int i;
  1.1032 +    for (i=0; i<numPoints; i++) {
  1.1033 +        if (i < halfPoints) {
  1.1034 +            newx = SDLTest_RandomIntegerInRange(-1024, 1024);
  1.1035 +            newy = SDLTest_RandomIntegerInRange(-1024, 1024);
  1.1036 +        } else {
  1.1037 +            newx = refPoints[i-halfPoints].x;
  1.1038 +            newy = refPoints[i-halfPoints].y;
  1.1039 +        }
  1.1040 +        refPoints[i].x = newx;
  1.1041 +        refPoints[i].y = newy;
  1.1042 +        points[i].x = newx;
  1.1043 +        points[i].y = newy;
  1.1044 +        if (i==0) {
  1.1045 +            minx=maxx=newx;
  1.1046 +            miny=maxy=newy;
  1.1047 +        } else {
  1.1048 +            if (newx<minx) minx=newx;
  1.1049 +            if (newx>maxx) maxx=newx;
  1.1050 +            if (newy<miny) miny=newy;
  1.1051 +            if (newy>maxy) maxy=newy;
  1.1052 +        }
  1.1053 +    }
  1.1054 +
  1.1055 +    // Call function and validate - special case: no result requested
  1.1056 +    anyEnclosedNoResult = SDL_EnclosePoints((const SDL_Point *)points, numPoints, (const SDL_Rect *)NULL, (SDL_Rect *)NULL);
  1.1057 +    SDLTest_AssertCheck(expectedEnclosed==anyEnclosedNoResult, 
  1.1058 +        "Check return value %s, got %s", 
  1.1059 +        (expectedEnclosed==SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE", 
  1.1060 +		(anyEnclosedNoResult==SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE");
  1.1061 +    for (i=0; i<numPoints; i++) {
  1.1062 +        SDLTest_AssertCheck(refPoints[i].x==points[i].x && refPoints[i].y==points[i].y,
  1.1063 +            "Check that source point %i was not modified: expected (%i,%i) actual (%i,%i)", 
  1.1064 +            i, refPoints[i].x, refPoints[i].y, points[i].x, points[i].y);
  1.1065 +    }
  1.1066 +    
  1.1067 +    // Call function and validate
  1.1068 +    anyEnclosed = SDL_EnclosePoints((const SDL_Point *)points, numPoints, (const SDL_Rect *)NULL, &result);
  1.1069 +    SDLTest_AssertCheck(expectedEnclosed==anyEnclosed, 
  1.1070 +        "Check return value %s, got %s", 
  1.1071 +        (expectedEnclosed==SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE", 
  1.1072 +		(anyEnclosed==SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE");
  1.1073 +    for (i=0; i<numPoints; i++) {
  1.1074 +        SDLTest_AssertCheck(refPoints[i].x==points[i].x && refPoints[i].y==points[i].y,
  1.1075 +            "Check that source point %i was not modified: expected (%i,%i) actual (%i,%i)", 
  1.1076 +            i, refPoints[i].x, refPoints[i].y, points[i].x, points[i].y);
  1.1077 +    }
  1.1078 +    SDLTest_AssertCheck(result.x==minx && result.y==miny && result.w==(maxx - minx + 1) && result.h==(maxy - miny + 1),
  1.1079 +        "Check resulting enclosing rectangle: expected (%i,%i - %i,%i), actual (%i,%i - %i,%i)",
  1.1080 +        minx, miny, maxx, maxy, result.x, result.y, result.x + result.w - 1, result.y + result.h - 1);
  1.1081 +
  1.1082 +	return TEST_COMPLETED;
  1.1083 +}
  1.1084 +
  1.1085 +/*!
  1.1086 + * \brief Test SDL_EnclosePoints() with clipping
  1.1087 + *
  1.1088 + * \sa
  1.1089 + * http://wiki.libsdl.org/moin.cgi/SDL_EnclosePoints
  1.1090 + */
  1.1091 +int rect_testEnclosePointsWithClipping(void *arg)
  1.1092 +{
  1.1093 +    const int numPoints = 16;
  1.1094 +    SDL_Point refPoints[16];
  1.1095 +    SDL_Point points[16];
  1.1096 +    SDL_Rect refClip;
  1.1097 +    SDL_Rect clip;
  1.1098 +    SDL_Rect result;
  1.1099 +    SDL_bool anyEnclosed;
  1.1100 +    SDL_bool anyEnclosedNoResult;
  1.1101 +    SDL_bool expectedEnclosed = SDL_FALSE;
  1.1102 +    int newx, newy;
  1.1103 +    int minx, maxx, miny, maxy;
  1.1104 +    int i;
  1.1105 +
  1.1106 +    // Setup clipping rectangle
  1.1107 +    refClip.x = SDLTest_RandomIntegerInRange(-1024, 1024);
  1.1108 +    refClip.y = SDLTest_RandomIntegerInRange(-1024, 1024);
  1.1109 +    refClip.w = SDLTest_RandomIntegerInRange(1, 1024);
  1.1110 +    refClip.h = SDLTest_RandomIntegerInRange(1, 1024);
  1.1111 +
  1.1112 +    // Create input data, tracking result
  1.1113 +    for (i=0; i<numPoints; i++) {
  1.1114 +        newx = SDLTest_RandomIntegerInRange(-1024, 1024);
  1.1115 +        newy = SDLTest_RandomIntegerInRange(-1024, 1024);
  1.1116 +        refPoints[i].x = newx;
  1.1117 +        refPoints[i].y = newy;
  1.1118 +        points[i].x = newx;
  1.1119 +        points[i].y = newy;
  1.1120 +        if ((newx>=refClip.x) && (newx<(refClip.x + refClip.w)) &&
  1.1121 +            (newy>=refClip.y) && (newy<(refClip.y + refClip.h))) {
  1.1122 +            if (expectedEnclosed==SDL_FALSE) {
  1.1123 +                minx=maxx=newx;
  1.1124 +                miny=maxy=newy;
  1.1125 +            } else {
  1.1126 +                if (newx<minx) minx=newx;
  1.1127 +                if (newx>maxx) maxx=newx;
  1.1128 +                if (newy<miny) miny=newy;
  1.1129 +                if (newy>maxy) maxy=newy;
  1.1130 +            }
  1.1131 +            expectedEnclosed = SDL_TRUE;
  1.1132 +        }
  1.1133 +    }
  1.1134 +
  1.1135 +    // Call function and validate - special case: no result requested
  1.1136 +    clip = refClip;
  1.1137 +    anyEnclosedNoResult = SDL_EnclosePoints((const SDL_Point *)points, numPoints, (const SDL_Rect *)&clip, (SDL_Rect *)NULL);
  1.1138 +    SDLTest_AssertCheck(expectedEnclosed==anyEnclosedNoResult, 
  1.1139 +        "Expected return value %s, got %s", 
  1.1140 +        (expectedEnclosed==SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE", 
  1.1141 +		(anyEnclosedNoResult==SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE");
  1.1142 +    for (i=0; i<numPoints; i++) {
  1.1143 +        SDLTest_AssertCheck(refPoints[i].x==points[i].x && refPoints[i].y==points[i].y,
  1.1144 +            "Check that source point %i was not modified: expected (%i,%i) actual (%i,%i)", 
  1.1145 +            i, refPoints[i].x, refPoints[i].y, points[i].x, points[i].y);
  1.1146 +    }
  1.1147 +    SDLTest_AssertCheck(refClip.x==clip.x && refClip.y==clip.y && refClip.w==clip.w && refClip.h==clip.h,
  1.1148 +        "Check that source clipping rectangle was not modified");
  1.1149 +    
  1.1150 +    // Call function and validate
  1.1151 +    anyEnclosed = SDL_EnclosePoints((const SDL_Point *)points, numPoints, (const SDL_Rect *)&clip, &result);
  1.1152 +    SDLTest_AssertCheck(expectedEnclosed==anyEnclosed, 
  1.1153 +        "Check return value %s, got %s", 
  1.1154 +        (expectedEnclosed==SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE", 
  1.1155 +		(anyEnclosed==SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE");
  1.1156 +    for (i=0; i<numPoints; i++) {
  1.1157 +        SDLTest_AssertCheck(refPoints[i].x==points[i].x && refPoints[i].y==points[i].y,
  1.1158 +            "Check that source point %i was not modified: expected (%i,%i) actual (%i,%i)", 
  1.1159 +            i, refPoints[i].x, refPoints[i].y, points[i].x, points[i].y);
  1.1160 +    }
  1.1161 +    SDLTest_AssertCheck(refClip.x==clip.x && refClip.y==clip.y && refClip.w==clip.w && refClip.h==clip.h,
  1.1162 +        "Check that source clipping rectangle was not modified");
  1.1163 +    if (expectedEnclosed==SDL_TRUE) {
  1.1164 +        SDLTest_AssertCheck(result.x==minx && result.y==miny && result.w==(maxx - minx + 1) && result.h==(maxy - miny + 1),
  1.1165 +            "Check resulting enclosing rectangle: expected (%i,%i - %i,%i), actual (%i,%i - %i,%i)",
  1.1166 +            minx, miny, maxx, maxy, result.x, result.y, result.x + result.w - 1, result.y + result.h - 1);
  1.1167 +    }    
  1.1168 +    
  1.1169 +    /* Empty clipping rectangle */
  1.1170 +    clip.w = 0;
  1.1171 +    clip.h = 0;
  1.1172 +    expectedEnclosed = SDL_FALSE;
  1.1173 +    anyEnclosed = SDL_EnclosePoints((const SDL_Point *)points, numPoints, (const SDL_Rect *)&clip, &result);
  1.1174 +    SDLTest_AssertCheck(expectedEnclosed==anyEnclosed, 
  1.1175 +        "Check return value %s, got %s", 
  1.1176 +        (expectedEnclosed==SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE", 
  1.1177 +		(anyEnclosed==SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE");    
  1.1178 +
  1.1179 +	return TEST_COMPLETED;
  1.1180 +}
  1.1181 +
  1.1182 +/*!
  1.1183 + * \brief Negative tests against SDL_EnclosePoints() with invalid parameters
  1.1184 + *
  1.1185 + * \sa
  1.1186 + * http://wiki.libsdl.org/moin.cgi/SDL_EnclosePoints
  1.1187 + */
  1.1188 +int rect_testEnclosePointsParam(void *arg)
  1.1189 +{
  1.1190 +    SDL_Point points[1];
  1.1191 +    int count;
  1.1192 +    SDL_Rect clip;
  1.1193 +    SDL_Rect result;
  1.1194 +    SDL_bool anyEnclosed;
  1.1195 +
  1.1196 +    // invalid parameter combinations
  1.1197 +    anyEnclosed = SDL_EnclosePoints((SDL_Point *)NULL, 1, (const SDL_Rect *)&clip, &result);
  1.1198 +    SDLTest_AssertCheck(anyEnclosed == SDL_FALSE, "Check that functions returns SDL_FALSE when 1st parameter is NULL"); 
  1.1199 +    anyEnclosed = SDL_EnclosePoints((const SDL_Point *)points, 0, (const SDL_Rect *)&clip, &result);
  1.1200 +    SDLTest_AssertCheck(anyEnclosed == SDL_FALSE, "Check that functions returns SDL_FALSE when 2nd parameter is 0");
  1.1201 +    count = SDLTest_RandomIntegerInRange(-100, -1);
  1.1202 +    anyEnclosed = SDL_EnclosePoints((const SDL_Point *)points, count, (const SDL_Rect *)&clip, &result);
  1.1203 +    SDLTest_AssertCheck(anyEnclosed == SDL_FALSE, "Check that functions returns SDL_FALSE when 2nd parameter is %i (negative)", count); 
  1.1204 +    anyEnclosed = SDL_EnclosePoints((SDL_Point *)NULL, 0, (const SDL_Rect *)&clip, &result);
  1.1205 +    SDLTest_AssertCheck(anyEnclosed == SDL_FALSE, "Check that functions returns SDL_FALSE when 1st parameter is NULL and 2nd parameter was 0"); 
  1.1206 +
  1.1207 +	return TEST_COMPLETED;
  1.1208 +}
  1.1209 +
  1.1210 +/*!
  1.1211 + * \brief Tests SDL_UnionRect() where rect B is outside rect A
  1.1212 + *
  1.1213 + * \sa
  1.1214 + * http://wiki.libsdl.org/moin.cgi/SDL_UnionRect
  1.1215 + */
  1.1216 +int rect_testUnionRectOutside(void *arg)
  1.1217 +{
  1.1218 +    SDL_Rect refRectA, refRectB;
  1.1219 +    SDL_Rect rectA, rectB;
  1.1220 +    SDL_Rect expectedResult;
  1.1221 +    SDL_Rect result;
  1.1222 +    int minx, maxx, miny, maxy;
  1.1223 +    int dx, dy;
  1.1224 +    
  1.1225 +    /* Union 1x1 outside */
  1.1226 +    for (dx = -1; dx < 2; dx++) {     
  1.1227 +        for (dy = -1; dy < 2; dy++) {
  1.1228 +            if ((dx != 0) || (dy != 0)) {
  1.1229 +                refRectA.x=SDLTest_RandomIntegerInRange(-1024, 1024);
  1.1230 +                refRectA.y=SDLTest_RandomIntegerInRange(-1024, 1024);
  1.1231 +                refRectA.w=1;
  1.1232 +                refRectA.h=1;
  1.1233 +                refRectB.x=SDLTest_RandomIntegerInRange(-1024, 1024) + dx*2048;
  1.1234 +                refRectB.y=SDLTest_RandomIntegerInRange(-1024, 1024) + dx*2048;
  1.1235 +                refRectB.w=1;
  1.1236 +                refRectB.h=1;
  1.1237 +                minx = (refRectA.x<refRectB.x) ? refRectA.x : refRectB.x;
  1.1238 +                maxx = (refRectA.x>refRectB.x) ? refRectA.x : refRectB.x;
  1.1239 +                miny = (refRectA.y<refRectB.y) ? refRectA.y : refRectB.y;
  1.1240 +                maxy = (refRectA.y>refRectB.y) ? refRectA.y : refRectB.y;                
  1.1241 +                expectedResult.x = minx;
  1.1242 +                expectedResult.y = miny;
  1.1243 +                expectedResult.w = maxx - minx + 1;
  1.1244 +                expectedResult.h = maxy - miny + 1;
  1.1245 +                rectA = refRectA;
  1.1246 +                rectB = refRectB;
  1.1247 +                SDL_UnionRect(&rectA, &rectB, &result);
  1.1248 +                _validateUnionRectResults(&rectA, &rectB, &refRectA, &refRectB, &result, &expectedResult);
  1.1249 +            }
  1.1250 +        }
  1.1251 +    }
  1.1252 +
  1.1253 +    /* Union outside overlap */
  1.1254 +    for (dx = -1; dx < 2; dx++) {     
  1.1255 +        for (dy = -1; dy < 2; dy++) {
  1.1256 +            if ((dx != 0) || (dy != 0)) {
  1.1257 +                refRectA.x=SDLTest_RandomIntegerInRange(-1024, 1024);
  1.1258 +                refRectA.y=SDLTest_RandomIntegerInRange(-1024, 1024);
  1.1259 +                refRectA.w=SDLTest_RandomIntegerInRange(256, 512);
  1.1260 +                refRectA.h=SDLTest_RandomIntegerInRange(256, 512);
  1.1261 +                refRectB.x=refRectA.x + 1 + dx*2;
  1.1262 +                refRectB.y=refRectA.y + 1 + dy*2;
  1.1263 +                refRectB.w=refRectA.w - 2;
  1.1264 +                refRectB.h=refRectA.h - 2;
  1.1265 +                expectedResult = refRectA;
  1.1266 +                if (dx == -1) expectedResult.x--;
  1.1267 +                if (dy == -1) expectedResult.y--;
  1.1268 +                if ((dx == 1) || (dx == -1)) expectedResult.w++;
  1.1269 +                if ((dy == 1) || (dy == -1)) expectedResult.h++;
  1.1270 +                rectA = refRectA;
  1.1271 +                rectB = refRectB;
  1.1272 +                SDL_UnionRect(&rectA, &rectB, &result);
  1.1273 +                _validateUnionRectResults(&rectA, &rectB, &refRectA, &refRectB, &result, &expectedResult);
  1.1274 +            }
  1.1275 +        }
  1.1276 +    }
  1.1277 +
  1.1278 +	return TEST_COMPLETED;
  1.1279 +}
  1.1280 +
  1.1281 +/*!
  1.1282 + * \brief Tests SDL_UnionRect() where rect A or rect B are empty
  1.1283 + *
  1.1284 + * \sa
  1.1285 + * http://wiki.libsdl.org/moin.cgi/SDL_UnionRect
  1.1286 + */
  1.1287 +int rect_testUnionRectEmpty(void *arg)
  1.1288 +{
  1.1289 +    SDL_Rect refRectA, refRectB;
  1.1290 +    SDL_Rect rectA, rectB;
  1.1291 +    SDL_Rect expectedResult;
  1.1292 +    SDL_Rect result;
  1.1293 +
  1.1294 +    /* A empty */    
  1.1295 +    refRectA.x=SDLTest_RandomIntegerInRange(-1024, 1024);
  1.1296 +    refRectA.y=SDLTest_RandomIntegerInRange(-1024, 1024);
  1.1297 +    refRectA.w=0;
  1.1298 +    refRectA.h=0;
  1.1299 +    refRectB.x=SDLTest_RandomIntegerInRange(-1024, 1024);
  1.1300 +    refRectB.y=SDLTest_RandomIntegerInRange(-1024, 1024);
  1.1301 +    refRectB.w=SDLTest_RandomIntegerInRange(1, 1024);
  1.1302 +    refRectB.h=SDLTest_RandomIntegerInRange(1, 1024);
  1.1303 +    expectedResult = refRectB;
  1.1304 +    rectA = refRectA;
  1.1305 +    rectB = refRectB;
  1.1306 +    SDL_UnionRect(&rectA, &rectB, &result);
  1.1307 +    _validateUnionRectResults(&rectA, &rectB, &refRectA, &refRectB, &result, &expectedResult);
  1.1308 +    
  1.1309 +    /* B empty */    
  1.1310 +    refRectA.x=SDLTest_RandomIntegerInRange(-1024, 1024);
  1.1311 +    refRectA.y=SDLTest_RandomIntegerInRange(-1024, 1024);
  1.1312 +    refRectA.w=SDLTest_RandomIntegerInRange(1, 1024);
  1.1313 +    refRectA.h=SDLTest_RandomIntegerInRange(1, 1024);
  1.1314 +    refRectB.x=SDLTest_RandomIntegerInRange(-1024, 1024);
  1.1315 +    refRectB.y=SDLTest_RandomIntegerInRange(-1024, 1024);
  1.1316 +    refRectB.w=0;
  1.1317 +    refRectB.h=0;
  1.1318 +    expectedResult = refRectA;
  1.1319 +    rectA = refRectA;
  1.1320 +    rectB = refRectB;
  1.1321 +    SDL_UnionRect(&rectA, &rectB, &result);
  1.1322 +    _validateUnionRectResults(&rectA, &rectB, &refRectA, &refRectB, &result, &expectedResult);
  1.1323 +
  1.1324 +    /* A and B empty */    
  1.1325 +    refRectA.x=SDLTest_RandomIntegerInRange(-1024, 1024);
  1.1326 +    refRectA.y=SDLTest_RandomIntegerInRange(-1024, 1024);
  1.1327 +    refRectA.w=0;
  1.1328 +    refRectA.h=0;
  1.1329 +    refRectB.x=SDLTest_RandomIntegerInRange(-1024, 1024);
  1.1330 +    refRectB.y=SDLTest_RandomIntegerInRange(-1024, 1024);
  1.1331 +    refRectB.w=0;
  1.1332 +    refRectB.h=0;
  1.1333 +    result.x=0;
  1.1334 +    result.y=0;
  1.1335 +    result.w=0;
  1.1336 +    result.h=0;
  1.1337 +    expectedResult = result;
  1.1338 +    rectA = refRectA;
  1.1339 +    rectB = refRectB;
  1.1340 +    SDL_UnionRect(&rectA, &rectB, &result);
  1.1341 +    _validateUnionRectResults(&rectA, &rectB, &refRectA, &refRectB, &result, &expectedResult);
  1.1342 +
  1.1343 +	return TEST_COMPLETED;
  1.1344 +}
  1.1345 +
  1.1346 +/*!
  1.1347 + * \brief Tests SDL_UnionRect() where rect B is inside rect A
  1.1348 + *
  1.1349 + * \sa
  1.1350 + * http://wiki.libsdl.org/moin.cgi/SDL_UnionRect
  1.1351 + */
  1.1352 +int rect_testUnionRectInside(void *arg)
  1.1353 +{
  1.1354 +    SDL_Rect refRectA, refRectB;
  1.1355 +    SDL_Rect rectA, rectB;
  1.1356 +    SDL_Rect expectedResult;
  1.1357 +    SDL_Rect result;
  1.1358 +    int dx, dy;
  1.1359 +    
  1.1360 +    /* Union 1x1 with itself */
  1.1361 +    refRectA.x=SDLTest_RandomIntegerInRange(-1024, 1024);
  1.1362 +    refRectA.y=SDLTest_RandomIntegerInRange(-1024, 1024);
  1.1363 +    refRectA.w=1;
  1.1364 +    refRectA.h=1;
  1.1365 +    expectedResult = refRectA;
  1.1366 +    rectA = refRectA;
  1.1367 +    SDL_UnionRect(&rectA, &rectA, &result);
  1.1368 +    _validateUnionRectResults(&rectA, &rectA, &refRectA, &refRectA, &result, &expectedResult);
  1.1369 +
  1.1370 +    /* Union 1x1 somewhere inside */
  1.1371 +    refRectA.x=SDLTest_RandomIntegerInRange(-1024, 1024);
  1.1372 +    refRectA.y=SDLTest_RandomIntegerInRange(-1024, 1024);
  1.1373 +    refRectA.w=SDLTest_RandomIntegerInRange(256, 1024);
  1.1374 +    refRectA.h=SDLTest_RandomIntegerInRange(256, 1024);
  1.1375 +    refRectB.x=refRectA.x + 1 + SDLTest_RandomIntegerInRange(1, refRectA.w - 2);
  1.1376 +    refRectB.y=refRectA.y + 1 + SDLTest_RandomIntegerInRange(1, refRectA.h - 2);
  1.1377 +    refRectB.w=1;
  1.1378 +    refRectB.h=1;
  1.1379 +    expectedResult = refRectA;
  1.1380 +    rectA = refRectA;
  1.1381 +    rectB = refRectB;
  1.1382 +    SDL_UnionRect(&rectA, &rectB, &result);
  1.1383 +    _validateUnionRectResults(&rectA, &rectB, &refRectA, &refRectB, &result, &expectedResult);
  1.1384 +
  1.1385 +    /* Union inside with edges modified */
  1.1386 +    for (dx = -1; dx < 2; dx++) {     
  1.1387 +        for (dy = -1; dy < 2; dy++) {
  1.1388 +            if ((dx != 0) || (dy != 0)) {
  1.1389 +                refRectA.x=SDLTest_RandomIntegerInRange(-1024, 1024);
  1.1390 +                refRectA.y=SDLTest_RandomIntegerInRange(-1024, 1024);
  1.1391 +                refRectA.w=SDLTest_RandomIntegerInRange(256, 1024);
  1.1392 +                refRectA.h=SDLTest_RandomIntegerInRange(256, 1024);
  1.1393 +                refRectB = refRectA;
  1.1394 +                if (dx == -1) refRectB.x++;
  1.1395 +                if ((dx == 1) || (dx == -1)) refRectB.w--;
  1.1396 +                if (dy == -1) refRectB.y++;
  1.1397 +                if ((dy == 1) || (dy == -1)) refRectB.h--;                
  1.1398 +                expectedResult = refRectA;
  1.1399 +                rectA = refRectA;
  1.1400 +                rectB = refRectB;
  1.1401 +                SDL_UnionRect(&rectA, &rectB, &result);
  1.1402 +                _validateUnionRectResults(&rectA, &rectB, &refRectA, &refRectB, &result, &expectedResult);
  1.1403 +            }
  1.1404 +        }
  1.1405 +    }
  1.1406 +
  1.1407 +	return TEST_COMPLETED;
  1.1408 +}
  1.1409 +
  1.1410 +/*!
  1.1411 + * \brief Negative tests against SDL_UnionRect() with invalid parameters
  1.1412 + *
  1.1413 + * \sa
  1.1414 + * http://wiki.libsdl.org/moin.cgi/SDL_UnionRect
  1.1415 + */
  1.1416 +int rect_testUnionRectParam(void *arg)
  1.1417 +{
  1.1418 +    SDL_Rect rectA, rectB;
  1.1419 +    SDL_Rect result;
  1.1420 +
  1.1421 +    // invalid parameter combinations
  1.1422 +    SDL_UnionRect((SDL_Rect *)NULL, &rectB, &result);
  1.1423 +    SDLTest_AssertPass("Check that function returns when 1st parameter is NULL"); 
  1.1424 +    SDL_UnionRect(&rectA, (SDL_Rect *)NULL, &result);
  1.1425 +    SDLTest_AssertPass("Check that function returns  when 2nd parameter is NULL"); 
  1.1426 +    SDL_UnionRect(&rectA, &rectB, (SDL_Rect *)NULL);
  1.1427 +    SDLTest_AssertPass("Check that function returns  when 3rd parameter is NULL"); 
  1.1428 +    SDL_UnionRect((SDL_Rect *)NULL, &rectB, (SDL_Rect *)NULL);
  1.1429 +    SDLTest_AssertPass("Check that function returns  when 1st and 3rd parameter are NULL"); 
  1.1430 +    SDL_UnionRect(&rectA, (SDL_Rect *)NULL, (SDL_Rect *)NULL);
  1.1431 +    SDLTest_AssertPass("Check that function returns  when 2nd and 3rd parameter are NULL"); 
  1.1432 +    SDL_UnionRect((SDL_Rect *)NULL, (SDL_Rect *)NULL, (SDL_Rect *)NULL);
  1.1433 +    SDLTest_AssertPass("Check that function returns  when all parameters are NULL"); 
  1.1434 +
  1.1435 +	return TEST_COMPLETED;
  1.1436 +}
  1.1437 +
  1.1438 +/*!
  1.1439 + * \brief Tests SDL_RectEmpty() with various inputs
  1.1440 + *
  1.1441 + * \sa
  1.1442 + * http://wiki.libsdl.org/moin.cgi/SDL_RectEmpty
  1.1443 + */
  1.1444 +int rect_testRectEmpty(void *arg)
  1.1445 +{
  1.1446 +    SDL_Rect refRect;
  1.1447 +    SDL_Rect rect;
  1.1448 +    SDL_bool expectedResult;
  1.1449 +    SDL_bool result;
  1.1450 +    int w, h;
  1.1451 +
  1.1452 +    // Non-empty case
  1.1453 +    refRect.x=SDLTest_RandomIntegerInRange(-1024, 1024);
  1.1454 +    refRect.y=SDLTest_RandomIntegerInRange(-1024, 1024);
  1.1455 +    refRect.w=SDLTest_RandomIntegerInRange(256, 1024);
  1.1456 +    refRect.h=SDLTest_RandomIntegerInRange(256, 1024);
  1.1457 +    expectedResult = SDL_FALSE;
  1.1458 +    rect = refRect;
  1.1459 +    result = (SDL_bool)SDL_RectEmpty((const SDL_Rect *)&rect);
  1.1460 +    _validateRectEmptyResults(result, expectedResult, &rect, &refRect);
  1.1461 +    
  1.1462 +    // Empty case
  1.1463 +    for (w=-1; w<2; w++) {
  1.1464 +        for (h=-1; h<2; h++) {
  1.1465 +            if ((w != 1) || (h != 1)) {
  1.1466 +                refRect.x=SDLTest_RandomIntegerInRange(-1024, 1024);
  1.1467 +                refRect.y=SDLTest_RandomIntegerInRange(-1024, 1024);
  1.1468 +                refRect.w=w;
  1.1469 +                refRect.h=h;
  1.1470 +                expectedResult = SDL_TRUE;
  1.1471 +                rect = refRect;
  1.1472 +                result = (SDL_bool)SDL_RectEmpty((const SDL_Rect *)&rect);
  1.1473 +                _validateRectEmptyResults(result, expectedResult, &rect, &refRect);
  1.1474 +            }
  1.1475 +        }
  1.1476 +    }
  1.1477 +
  1.1478 +	return TEST_COMPLETED;
  1.1479 +}
  1.1480 +
  1.1481 +/*!
  1.1482 + * \brief Negative tests against SDL_RectEmpty() with invalid parameters
  1.1483 + *
  1.1484 + * \sa
  1.1485 + * http://wiki.libsdl.org/moin.cgi/SDL_RectEmpty
  1.1486 + */
  1.1487 +int rect_testRectEmptyParam(void *arg)
  1.1488 +{
  1.1489 +    SDL_bool result;
  1.1490 +
  1.1491 +    // invalid parameter combinations
  1.1492 +    result = (SDL_bool)SDL_RectEmpty((const SDL_Rect *)NULL);
  1.1493 +    SDLTest_AssertCheck(result == SDL_TRUE, "Check that function returns TRUE when 1st parameter is NULL"); 
  1.1494 +
  1.1495 +	return TEST_COMPLETED;
  1.1496 +}
  1.1497 +
  1.1498 +/*!
  1.1499 + * \brief Tests SDL_RectEquals() with various inputs
  1.1500 + *
  1.1501 + * \sa
  1.1502 + * http://wiki.libsdl.org/moin.cgi/SDL_RectEquals
  1.1503 + */
  1.1504 +int rect_testRectEquals(void *arg)
  1.1505 +{
  1.1506 +    SDL_Rect refRectA;
  1.1507 +    SDL_Rect refRectB;
  1.1508 +    SDL_Rect rectA;
  1.1509 +    SDL_Rect rectB;
  1.1510 +    SDL_bool expectedResult;
  1.1511 +    SDL_bool result;
  1.1512 +
  1.1513 +    // Equals
  1.1514 +    refRectA.x=SDLTest_RandomIntegerInRange(-1024, 1024);
  1.1515 +    refRectA.y=SDLTest_RandomIntegerInRange(-1024, 1024);
  1.1516 +    refRectA.w=SDLTest_RandomIntegerInRange(1, 1024);
  1.1517 +    refRectA.h=SDLTest_RandomIntegerInRange(1, 1024);
  1.1518 +    refRectB = refRectA;    
  1.1519 +    expectedResult = SDL_TRUE;
  1.1520 +    rectA = refRectA;
  1.1521 +    rectB = refRectB;
  1.1522 +    result = (SDL_bool)SDL_RectEquals((const SDL_Rect *)&rectA, (const SDL_Rect *)&rectB);
  1.1523 +    _validateRectEqualsResults(result, expectedResult, &rectA, &rectB, &refRectA, &refRectB);
  1.1524 +
  1.1525 +	return TEST_COMPLETED;
  1.1526 +}
  1.1527 +
  1.1528 +/*!
  1.1529 + * \brief Negative tests against SDL_RectEquals() with invalid parameters
  1.1530 + *
  1.1531 + * \sa
  1.1532 + * http://wiki.libsdl.org/moin.cgi/SDL_RectEquals
  1.1533 + */
  1.1534 +int rect_testRectEqualsParam(void *arg)
  1.1535 +{
  1.1536 +    SDL_Rect rectA;
  1.1537 +    SDL_Rect rectB;
  1.1538 +    SDL_bool result;
  1.1539 +
  1.1540 +    /* data setup */
  1.1541 +    rectA.x=SDLTest_RandomIntegerInRange(-1024, 1024);
  1.1542 +    rectA.y=SDLTest_RandomIntegerInRange(-1024, 1024);
  1.1543 +    rectA.w=SDLTest_RandomIntegerInRange(1, 1024);
  1.1544 +    rectA.h=SDLTest_RandomIntegerInRange(1, 1024);
  1.1545 +    rectB.x=SDLTest_RandomIntegerInRange(-1024, 1024);
  1.1546 +    rectB.y=SDLTest_RandomIntegerInRange(-1024, 1024);
  1.1547 +    rectB.w=SDLTest_RandomIntegerInRange(1, 1024);
  1.1548 +    rectB.h=SDLTest_RandomIntegerInRange(1, 1024);
  1.1549 +
  1.1550 +    // invalid parameter combinations
  1.1551 +    result = (SDL_bool)SDL_RectEquals((const SDL_Rect *)NULL, (const SDL_Rect *)&rectB);
  1.1552 +    SDLTest_AssertCheck(result == SDL_FALSE, "Check that function returns SDL_FALSE when 1st parameter is NULL"); 
  1.1553 +    result = (SDL_bool)SDL_RectEquals((const SDL_Rect *)&rectA, (const SDL_Rect *)NULL);
  1.1554 +    SDLTest_AssertCheck(result == SDL_FALSE, "Check that function returns SDL_FALSE when 2nd parameter is NULL"); 
  1.1555 +    result = (SDL_bool)SDL_RectEquals((const SDL_Rect *)NULL, (const SDL_Rect *)NULL);
  1.1556 +    SDLTest_AssertCheck(result == SDL_FALSE, "Check that function returns SDL_FALSE when 1st and 2nd parameter are NULL"); 
  1.1557 +
  1.1558 +	return TEST_COMPLETED;
  1.1559 +}
  1.1560 +
  1.1561 +/* ================= Test References ================== */
  1.1562 +
  1.1563 +/* Rect test cases */
  1.1564 +
  1.1565 +/* SDL_IntersectRectAndLine */
  1.1566 +static const SDLTest_TestCaseReference rectTest1 =
  1.1567 +		{ (SDLTest_TestCaseFp)rect_testIntersectRectAndLine,"rect_testIntersectRectAndLine",  "Tests SDL_IntersectRectAndLine clipping cases", TEST_ENABLED };
  1.1568 +
  1.1569 +static const SDLTest_TestCaseReference rectTest2 =
  1.1570 +		{ (SDLTest_TestCaseFp)rect_testIntersectRectAndLineInside, "rect_testIntersectRectAndLineInside", "Tests SDL_IntersectRectAndLine with line fully contained in rect", TEST_ENABLED };
  1.1571 +
  1.1572 +static const SDLTest_TestCaseReference rectTest3 =
  1.1573 +		{ (SDLTest_TestCaseFp)rect_testIntersectRectAndLineOutside, "rect_testIntersectRectAndLineOutside", "Tests SDL_IntersectRectAndLine with line fully outside of rect", TEST_ENABLED };
  1.1574 +
  1.1575 +static const SDLTest_TestCaseReference rectTest4 =
  1.1576 +		{ (SDLTest_TestCaseFp)rect_testIntersectRectAndLineEmpty, "rect_testIntersectRectAndLineEmpty", "Tests SDL_IntersectRectAndLine with empty rectangle ", TEST_ENABLED };
  1.1577 +
  1.1578 +static const SDLTest_TestCaseReference rectTest5 =
  1.1579 +		{ (SDLTest_TestCaseFp)rect_testIntersectRectAndLineParam, "rect_testIntersectRectAndLineParam", "Negative tests against SDL_IntersectRectAndLine with invalid parameters", TEST_ENABLED };
  1.1580 +
  1.1581 +/* SDL_IntersectRect */
  1.1582 +static const SDLTest_TestCaseReference rectTest6 =
  1.1583 +		{ (SDLTest_TestCaseFp)rect_testIntersectRectInside, "rect_testIntersectRectInside", "Tests SDL_IntersectRect with B fully contained in A", TEST_ENABLED };
  1.1584 +
  1.1585 +static const SDLTest_TestCaseReference rectTest7 =
  1.1586 +		{ (SDLTest_TestCaseFp)rect_testIntersectRectOutside, "rect_testIntersectRectOutside", "Tests SDL_IntersectRect with B fully outside of A", TEST_ENABLED };
  1.1587 +
  1.1588 +static const SDLTest_TestCaseReference rectTest8 =
  1.1589 +		{ (SDLTest_TestCaseFp)rect_testIntersectRectPartial, "rect_testIntersectRectPartial", "Tests SDL_IntersectRect with B partially intersecting A", TEST_ENABLED };
  1.1590 +
  1.1591 +static const SDLTest_TestCaseReference rectTest9 =
  1.1592 +		{ (SDLTest_TestCaseFp)rect_testIntersectRectPoint, "rect_testIntersectRectPoint", "Tests SDL_IntersectRect with 1x1 sized rectangles", TEST_ENABLED };
  1.1593 +
  1.1594 +static const SDLTest_TestCaseReference rectTest10 =
  1.1595 +		{ (SDLTest_TestCaseFp)rect_testIntersectRectEmpty, "rect_testIntersectRectEmpty", "Tests SDL_IntersectRect with empty rectangles", TEST_ENABLED };
  1.1596 +
  1.1597 +static const SDLTest_TestCaseReference rectTest11 =
  1.1598 +		{ (SDLTest_TestCaseFp)rect_testIntersectRectParam, "rect_testIntersectRectParam", "Negative tests against SDL_IntersectRect with invalid parameters", TEST_ENABLED };
  1.1599 +
  1.1600 +/* SDL_HasIntersection */
  1.1601 +static const SDLTest_TestCaseReference rectTest12 =
  1.1602 +		{ (SDLTest_TestCaseFp)rect_testHasIntersectionInside, "rect_testHasIntersectionInside", "Tests SDL_HasIntersection with B fully contained in A", TEST_ENABLED };
  1.1603 +
  1.1604 +static const SDLTest_TestCaseReference rectTest13 =
  1.1605 +		{ (SDLTest_TestCaseFp)rect_testHasIntersectionOutside, "rect_testHasIntersectionOutside", "Tests SDL_HasIntersection with B fully outside of A", TEST_ENABLED };
  1.1606 +
  1.1607 +static const SDLTest_TestCaseReference rectTest14 =
  1.1608 +		{ (SDLTest_TestCaseFp)rect_testHasIntersectionPartial,"rect_testHasIntersectionPartial",  "Tests SDL_HasIntersection with B partially intersecting A", TEST_ENABLED };
  1.1609 +
  1.1610 +static const SDLTest_TestCaseReference rectTest15 =
  1.1611 +		{ (SDLTest_TestCaseFp)rect_testHasIntersectionPoint, "rect_testHasIntersectionPoint", "Tests SDL_HasIntersection with 1x1 sized rectangles", TEST_ENABLED };
  1.1612 +
  1.1613 +static const SDLTest_TestCaseReference rectTest16 =
  1.1614 +		{ (SDLTest_TestCaseFp)rect_testHasIntersectionEmpty, "rect_testHasIntersectionEmpty", "Tests SDL_HasIntersection with empty rectangles", TEST_ENABLED };
  1.1615 +
  1.1616 +static const SDLTest_TestCaseReference rectTest17 =
  1.1617 +		{ (SDLTest_TestCaseFp)rect_testHasIntersectionParam, "rect_testHasIntersectionParam", "Negative tests against SDL_HasIntersection with invalid parameters", TEST_ENABLED };
  1.1618 +
  1.1619 +/* SDL_EnclosePoints */
  1.1620 +static const SDLTest_TestCaseReference rectTest18 =
  1.1621 +		{ (SDLTest_TestCaseFp)rect_testEnclosePoints, "rect_testEnclosePoints", "Tests SDL_EnclosePoints without clipping", TEST_ENABLED };
  1.1622 +
  1.1623 +static const SDLTest_TestCaseReference rectTest19 =
  1.1624 +		{ (SDLTest_TestCaseFp)rect_testEnclosePointsWithClipping, "rect_testEnclosePointsWithClipping", "Tests SDL_EnclosePoints with clipping", TEST_ENABLED };
  1.1625 +
  1.1626 +static const SDLTest_TestCaseReference rectTest20 =
  1.1627 +		{ (SDLTest_TestCaseFp)rect_testEnclosePointsRepeatedInput, "rect_testEnclosePointsRepeatedInput", "Tests SDL_EnclosePoints with repeated input", TEST_ENABLED };
  1.1628 +
  1.1629 +static const SDLTest_TestCaseReference rectTest21 =
  1.1630 +		{ (SDLTest_TestCaseFp)rect_testEnclosePointsParam, "rect_testEnclosePointsParam", "Negative tests against SDL_EnclosePoints with invalid parameters", TEST_ENABLED };
  1.1631 +
  1.1632 +/* SDL_UnionRect */
  1.1633 +static const SDLTest_TestCaseReference rectTest22 =
  1.1634 +		{ (SDLTest_TestCaseFp)rect_testUnionRectInside, "rect_testUnionRectInside", "Tests SDL_UnionRect where rect B is inside rect A", TEST_ENABLED };
  1.1635 +
  1.1636 +static const SDLTest_TestCaseReference rectTest23 =
  1.1637 +		{ (SDLTest_TestCaseFp)rect_testUnionRectOutside, "rect_testUnionRectOutside", "Tests SDL_UnionRect where rect B is outside rect A", TEST_ENABLED };
  1.1638 +
  1.1639 +static const SDLTest_TestCaseReference rectTest24 =
  1.1640 +		{ (SDLTest_TestCaseFp)rect_testUnionRectEmpty, "rect_testUnionRectEmpty", "Tests SDL_UnionRect where rect A or rect B are empty", TEST_ENABLED };
  1.1641 +
  1.1642 +static const SDLTest_TestCaseReference rectTest25 =
  1.1643 +		{ (SDLTest_TestCaseFp)rect_testUnionRectParam, "rect_testUnionRectParam", "Negative tests against SDL_UnionRect with invalid parameters", TEST_ENABLED };
  1.1644 +
  1.1645 +/* SDL_RectEmpty */
  1.1646 +static const SDLTest_TestCaseReference rectTest26 =
  1.1647 +		{ (SDLTest_TestCaseFp)rect_testRectEmpty, "rect_testRectEmpty", "Tests SDL_RectEmpty with various inputs", TEST_ENABLED };
  1.1648 +
  1.1649 +static const SDLTest_TestCaseReference rectTest27 =
  1.1650 +		{ (SDLTest_TestCaseFp)rect_testRectEmptyParam, "rect_testRectEmptyParam", "Negative tests against SDL_RectEmpty with invalid parameters", TEST_ENABLED };
  1.1651 +
  1.1652 +/* SDL_RectEquals */
  1.1653 +
  1.1654 +static const SDLTest_TestCaseReference rectTest28 =
  1.1655 +		{ (SDLTest_TestCaseFp)rect_testRectEquals, "rect_testRectEquals", "Tests SDL_RectEquals with various inputs", TEST_ENABLED };
  1.1656 +
  1.1657 +static const SDLTest_TestCaseReference rectTest29 =
  1.1658 +		{ (SDLTest_TestCaseFp)rect_testRectEqualsParam, "rect_testRectEqualsParam", "Negative tests against SDL_RectEquals with invalid parameters", TEST_ENABLED };
  1.1659 +
  1.1660 +
  1.1661 +/*!
  1.1662 + * \brief Sequence of Rect test cases; functions that handle simple rectangles including overlaps and merges.
  1.1663 + *
  1.1664 + * \sa
  1.1665 + * http://wiki.libsdl.org/moin.cgi/CategoryRect
  1.1666 + */
  1.1667 +static const SDLTest_TestCaseReference *rectTests[] =  {
  1.1668 +	&rectTest1, &rectTest2, &rectTest3, &rectTest4, &rectTest5, &rectTest6, &rectTest7, &rectTest8, &rectTest9, &rectTest10, &rectTest11, &rectTest12, &rectTest13, &rectTest14, 
  1.1669 +	&rectTest15, &rectTest16, &rectTest17, &rectTest18, &rectTest19, &rectTest20, &rectTest21, &rectTest22, &rectTest23, &rectTest24, &rectTest25, &rectTest26, &rectTest27,
  1.1670 +	&rectTest28, &rectTest29, NULL
  1.1671 +};
  1.1672 +
  1.1673 +
  1.1674 +/* Rect test suite (global) */
  1.1675 +SDLTest_TestSuiteReference rectTestSuite = {
  1.1676 +	"Rect",
  1.1677 +	NULL,
  1.1678 +	rectTests,
  1.1679 +	NULL
  1.1680 +};