test/testautomation_rect.c
changeset 6769 b49778d885cd
parent 6757 9935f71c8c81
child 6772 5229a117ef97
equal deleted inserted replaced
6768:22c37bf0afbc 6769:b49778d885cd
       
     1 /**
       
     2  * Original code: automated SDL rect test written by Edgar Simo "bobbens"
       
     3  * New/updated tests: aschiffler at ferzkopp dot net
       
     4  */
       
     5 
       
     6 #include <stdio.h>
       
     7 
       
     8 #include "SDL.h"
       
     9 #include "SDL_test.h"
       
    10 
       
    11 /* ================= Test Case Implementation ================== */
       
    12 
       
    13 /* Helper functions */
       
    14 
       
    15 /*!
       
    16  * \brief Private helper to check SDL_IntersectRectAndLine results
       
    17  */
       
    18 void _validateIntersectRectAndLineResults(
       
    19     SDL_bool intersection, SDL_bool expectedIntersection,
       
    20     SDL_Rect *rect, SDL_Rect * refRect,
       
    21     int x1, int y1, int x2, int y2,
       
    22     int x1Ref, int y1Ref, int x2Ref, int y2Ref)
       
    23 {
       
    24     SDLTest_AssertCheck(intersection == expectedIntersection, 
       
    25         "Check for correct intersection result: expected %s, got %s intersecting rect (%d,%d,%d,%d) with line (%d,%d - %d,%d)",
       
    26         (expectedIntersection == SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE",
       
    27         (intersection == SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE",
       
    28         refRect->x, refRect->y, refRect->w, refRect->h,
       
    29         x1Ref, y1Ref, x2Ref, y2Ref);
       
    30     SDLTest_AssertCheck(rect->x == refRect->x && rect->y == refRect->y && rect->w == refRect->w && rect->h == refRect->h,
       
    31         "Check that source rectangle was not modified: got (%d,%d,%d,%d) expected (%d,%d,%d,%d)",
       
    32         rect->x, rect->y, rect->w, rect->h,
       
    33         refRect->x, refRect->y, refRect->w, refRect->h);
       
    34     SDLTest_AssertCheck(x1 == x1Ref && y1 == y1Ref && x2 == x2Ref && y2 == y2Ref,
       
    35         "Check if line was incorrectly clipped or modified: got (%d,%d - %d,%d) expected (%d,%d - %d,%d)",
       
    36         x1, y1, x2, y2,
       
    37         x1Ref, y1Ref, x2Ref, y2Ref);
       
    38 }
       
    39 
       
    40 /* Test case functions */
       
    41 
       
    42 /*!
       
    43  * \brief Tests SDL_IntersectRectAndLine() clipping cases
       
    44  *
       
    45  * \sa
       
    46  * http://wiki.libsdl.org/moin.cgi/SDL_IntersectRectAndLine
       
    47  */
       
    48 int 
       
    49 rect_testIntersectRectAndLine (void *arg)
       
    50 {
       
    51     SDL_Rect refRect = { 0, 0, 32, 32 };
       
    52     SDL_Rect rect;
       
    53     int x1, y1;
       
    54     int x2, y2;
       
    55     SDL_bool intersected;
       
    56 
       
    57     int xLeft = -SDLTest_RandomIntegerInRange(1, refRect.w);
       
    58     int xRight = refRect.w + SDLTest_RandomIntegerInRange(1, refRect.w);
       
    59     int yTop = -SDLTest_RandomIntegerInRange(1, refRect.h);
       
    60     int yBottom = refRect.h + SDLTest_RandomIntegerInRange(1, refRect.h);
       
    61 
       
    62     x1 = xLeft;
       
    63     y1 = 15;
       
    64     x2 = xRight;
       
    65     y2 = 15;
       
    66     rect = refRect;
       
    67     intersected = SDL_IntersectRectAndLine(&rect, &x1, &y1, &x2, &y2);
       
    68     _validateIntersectRectAndLineResults(intersected, SDL_TRUE, &rect, &refRect, x1, y1, x2, y2, 0, 15, 31, 15);
       
    69 
       
    70     x1 = 15;
       
    71     y1 = yTop;
       
    72     x2 = 15;
       
    73     y2 = yBottom;
       
    74     rect = refRect;
       
    75     intersected = SDL_IntersectRectAndLine(&rect, &x1, &y1, &x2, &y2);
       
    76     _validateIntersectRectAndLineResults(intersected, SDL_TRUE, &rect, &refRect, x1, y1, x2, y2, 15, 0, 15, 31);
       
    77 
       
    78     x1 = -refRect.w;
       
    79     y1 = -refRect.h;
       
    80     x2 = 2*refRect.w;
       
    81     y2 = 2*refRect.h;
       
    82     rect = refRect;
       
    83     intersected = SDL_IntersectRectAndLine(&rect, &x1, &y1, &x2, &y2);
       
    84      _validateIntersectRectAndLineResults(intersected, SDL_TRUE, &rect, &refRect, x1, y1, x2, y2, 0, 0, 31, 31);
       
    85 
       
    86     x1 = 2*refRect.w;
       
    87     y1 = 2*refRect.h;
       
    88     x2 = -refRect.w;
       
    89     y2 = -refRect.h;
       
    90     rect = refRect;
       
    91     intersected = SDL_IntersectRectAndLine(&rect, &x1, &y1, &x2, &y2);
       
    92     _validateIntersectRectAndLineResults(intersected, SDL_TRUE, &rect, &refRect, x1, y1, x2, y2, 31, 31, 0, 0);
       
    93 
       
    94     x1 = -1;
       
    95     y1 = 32;
       
    96     x2 = 32;
       
    97     y2 = -1;
       
    98     rect = refRect;
       
    99     intersected = SDL_IntersectRectAndLine(&rect, &x1, &y1, &x2, &y2);
       
   100     _validateIntersectRectAndLineResults(intersected, SDL_TRUE, &rect, &refRect, x1, y1, x2, y2, 0, 31, 31, 0);
       
   101 
       
   102     x1 = 32;
       
   103     y1 = -1;
       
   104     x2 = -1;
       
   105     y2 = 32;
       
   106     rect = refRect;
       
   107     intersected = SDL_IntersectRectAndLine(&rect, &x1, &y1, &x2, &y2);
       
   108     _validateIntersectRectAndLineResults(intersected, SDL_TRUE, &rect, &refRect, x1, y1, x2, y2, 31, 0, 0, 31);
       
   109 
       
   110 	return TEST_COMPLETED;
       
   111 }
       
   112 
       
   113 /*!
       
   114  * \brief Tests SDL_IntersectRectAndLine() non-clipping case line inside
       
   115  *
       
   116  * \sa
       
   117  * http://wiki.libsdl.org/moin.cgi/SDL_IntersectRectAndLine
       
   118  */
       
   119 int 
       
   120 rect_testIntersectRectAndLineInside (void *arg)
       
   121 {
       
   122     SDL_Rect refRect = { 0, 0, 32, 32 };
       
   123     SDL_Rect rect;
       
   124     int x1, y1;
       
   125     int x2, y2;
       
   126     SDL_bool intersected;
       
   127 
       
   128     int xmin = refRect.x;
       
   129     int xmax = refRect.x + refRect.w - 1;
       
   130     int ymin = refRect.y;
       
   131     int ymax = refRect.y + refRect.h - 1;
       
   132     int x1Ref = SDLTest_RandomIntegerInRange(xmin + 1, xmax - 1);
       
   133     int y1Ref = SDLTest_RandomIntegerInRange(ymin + 1, ymax - 1);
       
   134     int x2Ref = SDLTest_RandomIntegerInRange(xmin + 1, xmax - 1);
       
   135     int y2Ref = SDLTest_RandomIntegerInRange(ymin + 1, ymax - 1);
       
   136 
       
   137     x1 = x1Ref;
       
   138     y1 = y1Ref;
       
   139     x2 = x2Ref;
       
   140     y2 = y2Ref;
       
   141     rect = refRect;
       
   142     intersected = SDL_IntersectRectAndLine(&rect, &x1, &y1, &x2, &y2);
       
   143     _validateIntersectRectAndLineResults(intersected, SDL_TRUE, &rect, &refRect, x1, y1, x2, y2, x1Ref, y1Ref, x2Ref, y2Ref);
       
   144 
       
   145     x1 = x1Ref;
       
   146     y1 = y1Ref;
       
   147     x2 = xmax;
       
   148     y2 = ymax;
       
   149     rect = refRect;
       
   150     intersected = SDL_IntersectRectAndLine(&rect, &x1, &y1, &x2, &y2);
       
   151     _validateIntersectRectAndLineResults(intersected, SDL_TRUE, &rect, &refRect, x1, y1, x2, y2, x1Ref, y1Ref, xmax, ymax);
       
   152 
       
   153     x1 = xmin;
       
   154     y1 = ymin;
       
   155     x2 = x2Ref;
       
   156     y2 = y2Ref;
       
   157     rect = refRect;
       
   158     intersected = SDL_IntersectRectAndLine(&rect, &x1, &y1, &x2, &y2);
       
   159     _validateIntersectRectAndLineResults(intersected, SDL_TRUE, &rect, &refRect, x1, y1, x2, y2, xmin, ymin, x2Ref, y2Ref);
       
   160 
       
   161     x1 = xmin;
       
   162     y1 = ymin;
       
   163     x2 = xmax;
       
   164     y2 = ymax;
       
   165     rect = refRect;
       
   166     intersected = SDL_IntersectRectAndLine(&rect, &x1, &y1, &x2, &y2);
       
   167     _validateIntersectRectAndLineResults(intersected, SDL_TRUE, &rect, &refRect, x1, y1, x2, y2, xmin, ymin, xmax, ymax);
       
   168 
       
   169     x1 = xmin;
       
   170     y1 = ymax;
       
   171     x2 = xmax;
       
   172     y2 = ymin;
       
   173     rect = refRect;
       
   174     intersected = SDL_IntersectRectAndLine(&rect, &x1, &y1, &x2, &y2);
       
   175     _validateIntersectRectAndLineResults(intersected, SDL_TRUE, &rect, &refRect, x1, y1, x2, y2, xmin, ymax, xmax, ymin);
       
   176 
       
   177 	return TEST_COMPLETED;
       
   178 }
       
   179 
       
   180 /*!
       
   181  * \brief Tests SDL_IntersectRectAndLine() non-clipping cases outside
       
   182  *
       
   183  * \sa
       
   184  * http://wiki.libsdl.org/moin.cgi/SDL_IntersectRectAndLine
       
   185  */
       
   186 int 
       
   187 rect_testIntersectRectAndLineOutside (void *arg)
       
   188 {
       
   189     SDL_Rect refRect = { 0, 0, 32, 32 };
       
   190     SDL_Rect rect;
       
   191     int x1, y1;
       
   192     int x2, y2;
       
   193     SDL_bool intersected;
       
   194 
       
   195     int xLeft = -SDLTest_RandomIntegerInRange(1, refRect.w);
       
   196     int xRight = refRect.w + SDLTest_RandomIntegerInRange(1, refRect.w);
       
   197     int yTop = -SDLTest_RandomIntegerInRange(1, refRect.h);
       
   198     int yBottom = refRect.h + SDLTest_RandomIntegerInRange(1, refRect.h);
       
   199 
       
   200     x1 = xLeft;
       
   201     y1 = 0;
       
   202     x2 = xLeft;
       
   203     y2 = 31;
       
   204     rect = refRect;
       
   205     intersected = SDL_IntersectRectAndLine(&rect, &x1, &y1, &x2, &y2);
       
   206     _validateIntersectRectAndLineResults(intersected, SDL_FALSE, &rect, &refRect, x1, y1, x2, y2, xLeft, 0, xLeft, 31);
       
   207 
       
   208     x1 = xRight;
       
   209     y1 = 0;
       
   210     x2 = xRight;
       
   211     y2 = 31;
       
   212     rect = refRect;
       
   213     intersected = SDL_IntersectRectAndLine(&rect, &x1, &y1, &x2, &y2);
       
   214     _validateIntersectRectAndLineResults(intersected, SDL_FALSE, &rect, &refRect, x1, y1, x2, y2, xRight, 0, xRight, 31);
       
   215 
       
   216     x1 = 0;
       
   217     y1 = yTop;
       
   218     x2 = 31;
       
   219     y2 = yTop;
       
   220     rect = refRect;
       
   221     intersected = SDL_IntersectRectAndLine(&rect, &x1, &y1, &x2, &y2);
       
   222     _validateIntersectRectAndLineResults(intersected, SDL_FALSE, &rect, &refRect, x1, y1, x2, y2, 0, yTop, 31, yTop);
       
   223 
       
   224     x1 = 0;
       
   225     y1 = yBottom;
       
   226     x2 = 31;
       
   227     y2 = yBottom;
       
   228     rect = refRect;
       
   229     intersected = SDL_IntersectRectAndLine(&rect, &x1, &y1, &x2, &y2);
       
   230     _validateIntersectRectAndLineResults(intersected, SDL_FALSE, &rect, &refRect, x1, y1, x2, y2, 0, yBottom, 31, yBottom);
       
   231 
       
   232 	return TEST_COMPLETED;
       
   233 }
       
   234 
       
   235 /*!
       
   236  * \brief Tests SDL_IntersectRectAndLine() with empty rectangle
       
   237  *
       
   238  * \sa
       
   239  * http://wiki.libsdl.org/moin.cgi/SDL_IntersectRectAndLine
       
   240  */
       
   241 int 
       
   242 rect_testIntersectRectAndLineEmpty (void *arg)
       
   243 {
       
   244     SDL_Rect refRect;
       
   245     SDL_Rect rect;
       
   246     int x1, y1, x1Ref, y1Ref;
       
   247     int x2, y2, x2Ref, y2Ref;
       
   248     SDL_bool intersected;
       
   249         
       
   250     refRect.x = SDLTest_RandomIntegerInRange(1, 1024);
       
   251     refRect.y = SDLTest_RandomIntegerInRange(1, 1024);
       
   252     refRect.w = 0;
       
   253     refRect.h = 0;
       
   254     x1Ref = refRect.x;
       
   255     y1Ref = refRect.y;
       
   256     x2Ref = SDLTest_RandomIntegerInRange(1, 1024);
       
   257     y2Ref = SDLTest_RandomIntegerInRange(1, 1024);
       
   258 
       
   259     x1 = x1Ref;
       
   260     y1 = y1Ref;
       
   261     x2 = x2Ref;
       
   262     y2 = y2Ref;
       
   263     rect = refRect;
       
   264     intersected = SDL_IntersectRectAndLine(&rect, &x1, &y1, &x2, &y2);
       
   265     _validateIntersectRectAndLineResults(intersected, SDL_FALSE, &rect, &refRect, x1, y1, x2, y2, x1Ref, y1Ref, x2Ref, y2Ref);
       
   266 
       
   267 	return TEST_COMPLETED;
       
   268 }
       
   269 
       
   270 /*!
       
   271  * \brief Negative tests against SDL_IntersectRectAndLine() with invalid parameters
       
   272  *
       
   273  * \sa
       
   274  * http://wiki.libsdl.org/moin.cgi/SDL_IntersectRectAndLine
       
   275  */
       
   276 int 
       
   277 rect_testIntersectRectAndLineParam (void *arg)
       
   278 {
       
   279     SDL_Rect rect = { 0, 0, 32, 32 };
       
   280     int x1 = rect.w / 2;
       
   281     int y1 = rect.h / 2;
       
   282     int x2 = x1;
       
   283     int y2 = 2 * rect.h;
       
   284     SDL_bool intersected;
       
   285     
       
   286     intersected = SDL_IntersectRectAndLine(&rect, &x1, &y1, &x2, &y2);
       
   287     SDLTest_AssertCheck(intersected == SDL_TRUE, "Check that intersection result was SDL_TRUE");
       
   288     
       
   289     intersected = SDL_IntersectRectAndLine((SDL_Rect *)NULL, &x1, &y1, &x2, &y2);
       
   290     SDLTest_AssertCheck(intersected == SDL_FALSE, "Check that function returns SDL_FALSE when 1st parameter is NULL");
       
   291     intersected = SDL_IntersectRectAndLine(&rect, (int *)NULL, &y1, &x2, &y2);
       
   292     SDLTest_AssertCheck(intersected == SDL_FALSE, "Check that function returns SDL_FALSE when 2nd parameter is NULL");
       
   293     intersected = SDL_IntersectRectAndLine(&rect, &x1, (int *)NULL, &x2, &y2);
       
   294     SDLTest_AssertCheck(intersected == SDL_FALSE, "Check that function returns SDL_FALSE when 3rd parameter is NULL");
       
   295     intersected = SDL_IntersectRectAndLine(&rect, &x1, &y1, (int *)NULL, &y2);
       
   296     SDLTest_AssertCheck(intersected == SDL_FALSE, "Check that function returns SDL_FALSE when 4th parameter is NULL");
       
   297     intersected = SDL_IntersectRectAndLine(&rect, &x1, &y1, &x2, (int *)NULL);
       
   298     SDLTest_AssertCheck(intersected == SDL_FALSE, "Check that function returns SDL_FALSE when 5th parameter is NULL");
       
   299     intersected = SDL_IntersectRectAndLine((SDL_Rect *)NULL, (int *)NULL, (int *)NULL, (int *)NULL, (int *)NULL);
       
   300     SDLTest_AssertCheck(intersected == SDL_FALSE, "Check that function returns SDL_FALSE when all parameters are NULL");
       
   301 
       
   302 	return TEST_COMPLETED;
       
   303 }
       
   304 
       
   305 /*!
       
   306  * \brief Private helper to check SDL_HasIntersection results
       
   307  */
       
   308 void _validateHasIntersectionResults(
       
   309     SDL_bool intersection, SDL_bool expectedIntersection, 
       
   310     SDL_Rect *rectA, SDL_Rect *rectB, SDL_Rect *refRectA, SDL_Rect *refRectB)
       
   311 {
       
   312     SDLTest_AssertCheck(intersection == expectedIntersection, 
       
   313         "Check intersection result: expected %s, got %s intersecting A (%d,%d,%d,%d) with B (%d,%d,%d,%d)",
       
   314         (expectedIntersection == SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE",
       
   315         (intersection == SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE",
       
   316         rectA->x, rectA->y, rectA->w, rectA->h, 
       
   317         rectB->x, rectB->y, rectB->w, rectB->h);
       
   318     SDLTest_AssertCheck(rectA->x == refRectA->x && rectA->y == refRectA->y && rectA->w == refRectA->w && rectA->h == refRectA->h,
       
   319         "Check that source rectangle A was not modified: got (%d,%d,%d,%d) expected (%d,%d,%d,%d)",
       
   320         rectA->x, rectA->y, rectA->w, rectA->h,
       
   321         refRectA->x, refRectA->y, refRectA->w, refRectA->h);
       
   322     SDLTest_AssertCheck(rectB->x == refRectB->x && rectB->y == refRectB->y && rectB->w == refRectB->w && rectB->h == refRectB->h,
       
   323         "Check that source rectangle B was not modified: got (%d,%d,%d,%d) expected (%d,%d,%d,%d)",
       
   324         rectB->x, rectB->y, rectB->w, rectB->h,
       
   325         refRectB->x, refRectB->y, refRectB->w, refRectB->h);
       
   326 }
       
   327 
       
   328 /*!
       
   329  * \brief Private helper to check SDL_IntersectRect results
       
   330  */
       
   331 void _validateIntersectRectResults(
       
   332     SDL_bool intersection, SDL_bool expectedIntersection, 
       
   333     SDL_Rect *rectA, SDL_Rect *rectB, SDL_Rect *refRectA, SDL_Rect *refRectB, 
       
   334     SDL_Rect *result, SDL_Rect *expectedResult)
       
   335 {
       
   336     _validateHasIntersectionResults(intersection, expectedIntersection, rectA, rectB, refRectA, refRectB);
       
   337     if (result && expectedResult) {
       
   338         SDLTest_AssertCheck(result->x == expectedResult->x && result->y == expectedResult->y && result->w == expectedResult->w && result->h == expectedResult->h,
       
   339             "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)",
       
   340             rectA->x, rectA->y, rectA->w, rectA->h, 
       
   341             rectB->x, rectB->y, rectB->w, rectB->h,
       
   342             result->x, result->y, result->w, result->h,
       
   343             expectedResult->x, expectedResult->y, expectedResult->w, expectedResult->h);
       
   344     }
       
   345 }
       
   346 
       
   347 /*!
       
   348  * \brief Private helper to check SDL_UnionRect results
       
   349  */
       
   350 void _validateUnionRectResults(
       
   351     SDL_Rect *rectA, SDL_Rect *rectB, SDL_Rect *refRectA, SDL_Rect *refRectB, 
       
   352     SDL_Rect *result, SDL_Rect *expectedResult)
       
   353 {
       
   354     SDLTest_AssertCheck(rectA->x == refRectA->x && rectA->y == refRectA->y && rectA->w == refRectA->w && rectA->h == refRectA->h,
       
   355         "Check that source rectangle A was not modified: got (%d,%d,%d,%d) expected (%d,%d,%d,%d)",
       
   356         rectA->x, rectA->y, rectA->w, rectA->h,
       
   357         refRectA->x, refRectA->y, refRectA->w, refRectA->h);
       
   358     SDLTest_AssertCheck(rectB->x == refRectB->x && rectB->y == refRectB->y && rectB->w == refRectB->w && rectB->h == refRectB->h,
       
   359         "Check that source rectangle B was not modified: got (%d,%d,%d,%d) expected (%d,%d,%d,%d)",
       
   360         rectB->x, rectB->y, rectB->w, rectB->h,
       
   361         refRectB->x, refRectB->y, refRectB->w, refRectB->h);
       
   362     SDLTest_AssertCheck(result->x == expectedResult->x && result->y == expectedResult->y && result->w == expectedResult->w && result->h == expectedResult->h,
       
   363         "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)",
       
   364         rectA->x, rectA->y, rectA->w, rectA->h, 
       
   365         rectB->x, rectB->y, rectB->w, rectB->h,
       
   366         result->x, result->y, result->w, result->h,
       
   367         expectedResult->x, expectedResult->y, expectedResult->w, expectedResult->h);
       
   368 }
       
   369 
       
   370 /*!
       
   371  * \brief Private helper to check SDL_RectEmpty results
       
   372  */
       
   373 void _validateRectEmptyResults(
       
   374     SDL_bool empty, SDL_bool expectedEmpty, 
       
   375     SDL_Rect *rect, SDL_Rect *refRect)
       
   376 {
       
   377     SDLTest_AssertCheck(empty == expectedEmpty, 
       
   378         "Check for correct empty result: expected %s, got %s testing (%d,%d,%d,%d)",
       
   379         (expectedEmpty == SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE",
       
   380         (empty == SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE",
       
   381         rect->x, rect->y, rect->w, rect->h);
       
   382     SDLTest_AssertCheck(rect->x == refRect->x && rect->y == refRect->y && rect->w == refRect->w && rect->h == refRect->h,
       
   383         "Check that source rectangle was not modified: got (%d,%d,%d,%d) expected (%d,%d,%d,%d)",
       
   384         rect->x, rect->y, rect->w, rect->h,
       
   385         refRect->x, refRect->y, refRect->w, refRect->h);
       
   386 }
       
   387 
       
   388 /*!
       
   389  * \brief Private helper to check SDL_RectEquals results
       
   390  */
       
   391 void _validateRectEqualsResults(
       
   392     SDL_bool equals, SDL_bool expectedEquals, 
       
   393     SDL_Rect *rectA, SDL_Rect *rectB, SDL_Rect *refRectA, SDL_Rect *refRectB)
       
   394 {
       
   395     SDLTest_AssertCheck(equals == expectedEquals, 
       
   396         "Check for correct equals result: expected %s, got %s testing (%d,%d,%d,%d) and (%d,%d,%d,%d)",
       
   397         (expectedEquals == SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE",
       
   398         (equals == SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE",
       
   399         rectA->x, rectA->y, rectA->w, rectA->h,
       
   400         rectB->x, rectB->y, rectB->w, rectB->h);
       
   401     SDLTest_AssertCheck(rectA->x == refRectA->x && rectA->y == refRectA->y && rectA->w == refRectA->w && rectA->h == refRectA->h,
       
   402         "Check that source rectangle A was not modified: got (%d,%d,%d,%d) expected (%d,%d,%d,%d)",
       
   403         rectA->x, rectA->y, rectA->w, rectA->h,
       
   404         refRectA->x, refRectA->y, refRectA->w, refRectA->h);
       
   405     SDLTest_AssertCheck(rectB->x == refRectB->x && rectB->y == refRectB->y && rectB->w == refRectB->w && rectB->h == refRectB->h,
       
   406         "Check that source rectangle B was not modified: got (%d,%d,%d,%d) expected (%d,%d,%d,%d)",
       
   407         rectB->x, rectB->y, rectB->w, rectB->h,
       
   408         refRectB->x, refRectB->y, refRectB->w, refRectB->h);
       
   409 }
       
   410 
       
   411 /*!
       
   412  * \brief Tests SDL_IntersectRect() with B fully inside A
       
   413  *
       
   414  * \sa
       
   415  * http://wiki.libsdl.org/moin.cgi/SDL_IntersectRect
       
   416  */
       
   417 int rect_testIntersectRectInside (void *arg)
       
   418 {
       
   419     SDL_Rect refRectA = { 0, 0, 32, 32 };
       
   420     SDL_Rect refRectB;
       
   421     SDL_Rect rectA;
       
   422     SDL_Rect rectB;
       
   423     SDL_Rect result;
       
   424     SDL_bool intersection;
       
   425 
       
   426     // rectB fully contained in rectA
       
   427     refRectB.x = 0;
       
   428     refRectB.y = 0;
       
   429     refRectB.w = SDLTest_RandomIntegerInRange(refRectA.x + 1, refRectA.x + refRectA.w - 1);
       
   430     refRectB.h = SDLTest_RandomIntegerInRange(refRectA.y + 1, refRectA.y + refRectA.h - 1);
       
   431     rectA = refRectA;
       
   432     rectB = refRectB;
       
   433     intersection = SDL_IntersectRect(&rectA, &rectB, &result);
       
   434     _validateIntersectRectResults(intersection, SDL_TRUE, &rectA, &rectB, &refRectA, &refRectB, &result, &refRectB);
       
   435 
       
   436 	return TEST_COMPLETED;
       
   437 }
       
   438 
       
   439 /*!
       
   440  * \brief Tests SDL_IntersectRect() with B fully outside A
       
   441  *
       
   442  * \sa
       
   443  * http://wiki.libsdl.org/moin.cgi/SDL_IntersectRect
       
   444  */
       
   445 int rect_testIntersectRectOutside (void *arg)
       
   446 {
       
   447     SDL_Rect refRectA = { 0, 0, 32, 32 };
       
   448     SDL_Rect refRectB;
       
   449     SDL_Rect rectA;
       
   450     SDL_Rect rectB;
       
   451     SDL_Rect result;
       
   452     SDL_bool intersection;
       
   453 
       
   454     // rectB fully outside of rectA
       
   455     refRectB.x = refRectA.x + refRectA.w + SDLTest_RandomIntegerInRange(1, 10);
       
   456     refRectB.y = refRectA.y + refRectA.h + SDLTest_RandomIntegerInRange(1, 10);
       
   457     refRectB.w = refRectA.w;
       
   458     refRectB.h = refRectA.h;
       
   459     rectA = refRectA;
       
   460     rectB = refRectB;
       
   461     intersection = SDL_IntersectRect(&rectA, &rectB, &result);
       
   462     _validateIntersectRectResults(intersection, SDL_FALSE, &rectA, &rectB, &refRectA, &refRectB, (SDL_Rect *)NULL, (SDL_Rect *)NULL);    
       
   463 
       
   464 	return TEST_COMPLETED;
       
   465 }
       
   466 
       
   467 /*!
       
   468  * \brief Tests SDL_IntersectRect() with B partially intersecting A
       
   469  *
       
   470  * \sa
       
   471  * http://wiki.libsdl.org/moin.cgi/SDL_IntersectRect
       
   472  */
       
   473 int rect_testIntersectRectPartial (void *arg)
       
   474 {
       
   475     SDL_Rect refRectA = { 0, 0, 32, 32 };
       
   476     SDL_Rect refRectB;
       
   477     SDL_Rect rectA;
       
   478     SDL_Rect rectB;
       
   479     SDL_Rect result;
       
   480     SDL_Rect expectedResult;
       
   481     SDL_bool intersection;
       
   482 
       
   483     // rectB partially contained in rectA
       
   484     refRectB.x = SDLTest_RandomIntegerInRange(refRectA.x + 1, refRectA.x + refRectA.w - 1);
       
   485     refRectB.y = SDLTest_RandomIntegerInRange(refRectA.y + 1, refRectA.y + refRectA.h - 1);
       
   486     refRectB.w = refRectA.w;
       
   487     refRectB.h = refRectA.h;
       
   488     rectA = refRectA;
       
   489     rectB = refRectB;
       
   490     expectedResult.x = refRectB.x;
       
   491     expectedResult.y = refRectB.y;
       
   492     expectedResult.w = refRectA.w - refRectB.x;
       
   493     expectedResult.h = refRectA.h - refRectB.y;    
       
   494     intersection = SDL_IntersectRect(&rectA, &rectB, &result);
       
   495     _validateIntersectRectResults(intersection, SDL_TRUE, &rectA, &rectB, &refRectA, &refRectB, &result, &expectedResult);
       
   496 
       
   497     // rectB right edge
       
   498     refRectB.x = rectA.w - 1;
       
   499     refRectB.y = rectA.y;
       
   500     refRectB.w = SDLTest_RandomIntegerInRange(1, refRectA.w - 1);
       
   501     refRectB.h = SDLTest_RandomIntegerInRange(1, refRectA.h - 1);
       
   502     rectA = refRectA;
       
   503     rectB = refRectB;
       
   504     expectedResult.x = refRectB.x;
       
   505     expectedResult.y = refRectB.y;
       
   506     expectedResult.w = 1;
       
   507     expectedResult.h = refRectB.h;    
       
   508     intersection = SDL_IntersectRect(&rectA, &rectB, &result);
       
   509     _validateIntersectRectResults(intersection, SDL_TRUE, &rectA, &rectB, &refRectA, &refRectB, &result, &expectedResult);
       
   510 
       
   511     // rectB left edge
       
   512     refRectB.x = 1 - rectA.w;
       
   513     refRectB.y = rectA.y;
       
   514     refRectB.w = refRectA.w;
       
   515     refRectB.h = SDLTest_RandomIntegerInRange(1, refRectA.h - 1);
       
   516     rectA = refRectA;
       
   517     rectB = refRectB;
       
   518     expectedResult.x = 0;
       
   519     expectedResult.y = refRectB.y;
       
   520     expectedResult.w = 1;
       
   521     expectedResult.h = refRectB.h;    
       
   522     intersection = SDL_IntersectRect(&rectA, &rectB, &result);
       
   523     _validateIntersectRectResults(intersection, SDL_TRUE, &rectA, &rectB, &refRectA, &refRectB, &result, &expectedResult);
       
   524 
       
   525     // rectB bottom edge
       
   526     refRectB.x = rectA.x;
       
   527     refRectB.y = rectA.h - 1;
       
   528     refRectB.w = SDLTest_RandomIntegerInRange(1, refRectA.w - 1);
       
   529     refRectB.h = SDLTest_RandomIntegerInRange(1, refRectA.h - 1);
       
   530     rectA = refRectA;
       
   531     rectB = refRectB;
       
   532     expectedResult.x = refRectB.x;
       
   533     expectedResult.y = refRectB.y;
       
   534     expectedResult.w = refRectB.w;
       
   535     expectedResult.h = 1;    
       
   536     intersection = SDL_IntersectRect(&rectA, &rectB, &result);
       
   537     _validateIntersectRectResults(intersection, SDL_TRUE, &rectA, &rectB, &refRectA, &refRectB, &result, &expectedResult);
       
   538 
       
   539     // rectB top edge
       
   540     refRectB.x = rectA.x;
       
   541     refRectB.y = 1 - rectA.h;
       
   542     refRectB.w = SDLTest_RandomIntegerInRange(1, refRectA.w - 1);
       
   543     refRectB.h = rectA.h;
       
   544     rectA = refRectA;
       
   545     rectB = refRectB;
       
   546     expectedResult.x = refRectB.x;
       
   547     expectedResult.y = 0;
       
   548     expectedResult.w = refRectB.w;
       
   549     expectedResult.h = 1;    
       
   550     intersection = SDL_IntersectRect(&rectA, &rectB, &result);
       
   551     _validateIntersectRectResults(intersection, SDL_TRUE, &rectA, &rectB, &refRectA, &refRectB, &result, &expectedResult);
       
   552 
       
   553 	return TEST_COMPLETED;
       
   554 }
       
   555 
       
   556 /*!
       
   557  * \brief Tests SDL_IntersectRect() with 1x1 pixel sized rectangles
       
   558  *
       
   559  * \sa
       
   560  * http://wiki.libsdl.org/moin.cgi/SDL_IntersectRect
       
   561  */
       
   562 int rect_testIntersectRectPoint (void *arg)
       
   563 {
       
   564     SDL_Rect refRectA = { 0, 0, 1, 1 };
       
   565     SDL_Rect refRectB = { 0, 0, 1, 1 };
       
   566     SDL_Rect rectA;
       
   567     SDL_Rect rectB;
       
   568     SDL_Rect result;
       
   569     SDL_bool intersection;
       
   570     int offsetX, offsetY;
       
   571 
       
   572     // intersecting pixels
       
   573     refRectA.x = SDLTest_RandomIntegerInRange(1, 100);
       
   574     refRectA.y = SDLTest_RandomIntegerInRange(1, 100);
       
   575     refRectB.x = refRectA.x;
       
   576     refRectB.y = refRectA.y;
       
   577     rectA = refRectA;
       
   578     rectB = refRectB;
       
   579     intersection = SDL_IntersectRect(&rectA, &rectB, &result);
       
   580     _validateIntersectRectResults(intersection, SDL_TRUE, &rectA, &rectB, &refRectA, &refRectB, &result, &refRectA);
       
   581 
       
   582     // non-intersecting pixels cases
       
   583     for (offsetX = -1; offsetX <= 1; offsetX++) {
       
   584         for (offsetY = -1; offsetY <= 1; offsetY++) {
       
   585             if (offsetX != 0 || offsetY != 0) {
       
   586                 refRectA.x = SDLTest_RandomIntegerInRange(1, 100);
       
   587                 refRectA.y = SDLTest_RandomIntegerInRange(1, 100);
       
   588                 refRectB.x = refRectA.x;
       
   589                 refRectB.y = refRectA.y;    
       
   590                 refRectB.x += offsetX;
       
   591                 refRectB.y += offsetY;
       
   592                 rectA = refRectA;
       
   593                 rectB = refRectB;
       
   594                 intersection = SDL_IntersectRect(&rectA, &rectB, &result);
       
   595                 _validateIntersectRectResults(intersection, SDL_FALSE, &rectA, &rectB, &refRectA, &refRectB, (SDL_Rect *)NULL, (SDL_Rect *)NULL);
       
   596             }
       
   597         }
       
   598     }
       
   599 
       
   600 	return TEST_COMPLETED;
       
   601 }
       
   602 
       
   603 /*!
       
   604  * \brief Tests SDL_IntersectRect() with empty rectangles
       
   605  *
       
   606  * \sa
       
   607  * http://wiki.libsdl.org/moin.cgi/SDL_IntersectRect
       
   608  */
       
   609 int rect_testIntersectRectEmpty (void *arg)
       
   610 {
       
   611     SDL_Rect refRectA;
       
   612     SDL_Rect refRectB;
       
   613     SDL_Rect rectA;
       
   614     SDL_Rect rectB;
       
   615     SDL_Rect result;
       
   616     SDL_bool intersection;
       
   617 
       
   618     // Rect A empty
       
   619     refRectA.x = SDLTest_RandomIntegerInRange(1, 100);
       
   620     refRectA.y = SDLTest_RandomIntegerInRange(1, 100);
       
   621     refRectA.w = SDLTest_RandomIntegerInRange(1, 100);
       
   622     refRectA.h = SDLTest_RandomIntegerInRange(1, 100);
       
   623     refRectB = refRectA;
       
   624     refRectA.w = 0;
       
   625     refRectA.h = 0;
       
   626     rectA = refRectA;
       
   627     rectB = refRectB;
       
   628     intersection = SDL_IntersectRect(&rectA, &rectB, &result);
       
   629     _validateIntersectRectResults(intersection, SDL_FALSE, &rectA, &rectB, &refRectA, &refRectB, (SDL_Rect *)NULL, (SDL_Rect *)NULL);
       
   630 
       
   631     // Rect B empty
       
   632     refRectA.x = SDLTest_RandomIntegerInRange(1, 100);
       
   633     refRectA.y = SDLTest_RandomIntegerInRange(1, 100);
       
   634     refRectA.w = SDLTest_RandomIntegerInRange(1, 100);
       
   635     refRectA.h = SDLTest_RandomIntegerInRange(1, 100);
       
   636     refRectB = refRectA;
       
   637     refRectB.w = 0;
       
   638     refRectB.h = 0;
       
   639     rectA = refRectA;
       
   640     rectB = refRectB;
       
   641     intersection = SDL_IntersectRect(&rectA, &rectB, &result);
       
   642     _validateIntersectRectResults(intersection, SDL_FALSE, &rectA, &rectB, &refRectA, &refRectB, (SDL_Rect *)NULL, (SDL_Rect *)NULL);
       
   643 
       
   644     // Rect A and B empty
       
   645     refRectA.x = SDLTest_RandomIntegerInRange(1, 100);
       
   646     refRectA.y = SDLTest_RandomIntegerInRange(1, 100);
       
   647     refRectA.w = SDLTest_RandomIntegerInRange(1, 100);
       
   648     refRectA.h = SDLTest_RandomIntegerInRange(1, 100);
       
   649     refRectB = refRectA;
       
   650     refRectA.w = 0;
       
   651     refRectA.h = 0;
       
   652     refRectB.w = 0;
       
   653     refRectB.h = 0;
       
   654     rectA = refRectA;
       
   655     rectB = refRectB;
       
   656     intersection = SDL_IntersectRect(&rectA, &rectB, &result);
       
   657     _validateIntersectRectResults(intersection, SDL_FALSE, &rectA, &rectB, &refRectA, &refRectB, (SDL_Rect *)NULL, (SDL_Rect *)NULL);
       
   658 
       
   659 	return TEST_COMPLETED;
       
   660 }
       
   661 
       
   662 /*!
       
   663  * \brief Negative tests against SDL_IntersectRect() with invalid parameters
       
   664  *
       
   665  * \sa
       
   666  * http://wiki.libsdl.org/moin.cgi/SDL_IntersectRect
       
   667  */
       
   668 int rect_testIntersectRectParam(void *arg)
       
   669 {
       
   670     SDL_Rect rectA;
       
   671     SDL_Rect rectB;
       
   672     SDL_Rect result;
       
   673     SDL_bool intersection;
       
   674 
       
   675     // invalid parameter combinations
       
   676     intersection = SDL_IntersectRect((SDL_Rect *)NULL, &rectB, &result);
       
   677     SDLTest_AssertCheck(intersection == SDL_FALSE, "Check that function returns SDL_FALSE when 1st parameter is NULL"); 
       
   678     intersection = SDL_IntersectRect(&rectA, (SDL_Rect *)NULL, &result);
       
   679     SDLTest_AssertCheck(intersection == SDL_FALSE, "Check that function returns SDL_FALSE when 2st parameter is NULL"); 
       
   680     intersection = SDL_IntersectRect(&rectA, &rectB, (SDL_Rect *)NULL);
       
   681     SDLTest_AssertCheck(intersection == SDL_FALSE, "Check that function returns SDL_FALSE when 3st parameter is NULL"); 
       
   682     intersection = SDL_IntersectRect((SDL_Rect *)NULL, (SDL_Rect *)NULL, &result);
       
   683     SDLTest_AssertCheck(intersection == SDL_FALSE, "Check that function returns SDL_FALSE when 1st and 2nd parameters are NULL"); 
       
   684     intersection = SDL_IntersectRect((SDL_Rect *)NULL, &rectB, (SDL_Rect *)NULL);
       
   685     SDLTest_AssertCheck(intersection == SDL_FALSE, "Check that function returns SDL_FALSE when 1st and 3rd parameters are NULL "); 
       
   686     intersection = SDL_IntersectRect((SDL_Rect *)NULL, (SDL_Rect *)NULL, (SDL_Rect *)NULL);
       
   687     SDLTest_AssertCheck(intersection == SDL_FALSE, "Check that function returns SDL_FALSE when all parameters are NULL");     
       
   688 
       
   689 	return TEST_COMPLETED;
       
   690 }
       
   691 
       
   692 /*!
       
   693  * \brief Tests SDL_HasIntersection() with B fully inside A
       
   694  *
       
   695  * \sa
       
   696  * http://wiki.libsdl.org/moin.cgi/SDL_HasIntersection
       
   697  */
       
   698 int rect_testHasIntersectionInside (void *arg)
       
   699 {
       
   700     SDL_Rect refRectA = { 0, 0, 32, 32 };
       
   701     SDL_Rect refRectB;
       
   702     SDL_Rect rectA;
       
   703     SDL_Rect rectB;
       
   704     SDL_bool intersection;
       
   705 
       
   706     // rectB fully contained in rectA
       
   707     refRectB.x = 0;
       
   708     refRectB.y = 0;
       
   709     refRectB.w = SDLTest_RandomIntegerInRange(refRectA.x + 1, refRectA.x + refRectA.w - 1);
       
   710     refRectB.h = SDLTest_RandomIntegerInRange(refRectA.y + 1, refRectA.y + refRectA.h - 1);
       
   711     rectA = refRectA;
       
   712     rectB = refRectB;
       
   713     intersection = SDL_HasIntersection(&rectA, &rectB);
       
   714     _validateHasIntersectionResults(intersection, SDL_TRUE, &rectA, &rectB, &refRectA, &refRectB);
       
   715 
       
   716 	return TEST_COMPLETED;
       
   717 }
       
   718 
       
   719 /*!
       
   720  * \brief Tests SDL_HasIntersection() with B fully outside A
       
   721  *
       
   722  * \sa
       
   723  * http://wiki.libsdl.org/moin.cgi/SDL_HasIntersection
       
   724  */
       
   725 int rect_testHasIntersectionOutside (void *arg)
       
   726 {
       
   727     SDL_Rect refRectA = { 0, 0, 32, 32 };
       
   728     SDL_Rect refRectB;
       
   729     SDL_Rect rectA;
       
   730     SDL_Rect rectB;
       
   731     SDL_bool intersection;
       
   732 
       
   733     // rectB fully outside of rectA
       
   734     refRectB.x = refRectA.x + refRectA.w + SDLTest_RandomIntegerInRange(1, 10);
       
   735     refRectB.y = refRectA.y + refRectA.h + SDLTest_RandomIntegerInRange(1, 10);
       
   736     refRectB.w = refRectA.w;
       
   737     refRectB.h = refRectA.h;
       
   738     rectA = refRectA;
       
   739     rectB = refRectB;
       
   740     intersection = SDL_HasIntersection(&rectA, &rectB);
       
   741     _validateHasIntersectionResults(intersection, SDL_FALSE, &rectA, &rectB, &refRectA, &refRectB);
       
   742 
       
   743 	return TEST_COMPLETED;
       
   744 }
       
   745 
       
   746 /*!
       
   747  * \brief Tests SDL_HasIntersection() with B partially intersecting A
       
   748  *
       
   749  * \sa
       
   750  * http://wiki.libsdl.org/moin.cgi/SDL_HasIntersection
       
   751  */
       
   752 int rect_testHasIntersectionPartial (void *arg)
       
   753 {
       
   754     SDL_Rect refRectA = { 0, 0, 32, 32 };
       
   755     SDL_Rect refRectB;
       
   756     SDL_Rect rectA;
       
   757     SDL_Rect rectB;
       
   758     SDL_bool intersection;
       
   759 
       
   760     // rectB partially contained in rectA
       
   761     refRectB.x = SDLTest_RandomIntegerInRange(refRectA.x + 1, refRectA.x + refRectA.w - 1);
       
   762     refRectB.y = SDLTest_RandomIntegerInRange(refRectA.y + 1, refRectA.y + refRectA.h - 1);
       
   763     refRectB.w = refRectA.w;
       
   764     refRectB.h = refRectA.h;
       
   765     rectA = refRectA;
       
   766     rectB = refRectB;
       
   767     intersection = SDL_HasIntersection(&rectA, &rectB);
       
   768     _validateHasIntersectionResults(intersection, SDL_TRUE, &rectA, &rectB, &refRectA, &refRectB);
       
   769 
       
   770     // rectB right edge
       
   771     refRectB.x = rectA.w - 1;
       
   772     refRectB.y = rectA.y;
       
   773     refRectB.w = SDLTest_RandomIntegerInRange(1, refRectA.w - 1);
       
   774     refRectB.h = SDLTest_RandomIntegerInRange(1, refRectA.h - 1);
       
   775     rectA = refRectA;
       
   776     rectB = refRectB;
       
   777     intersection = SDL_HasIntersection(&rectA, &rectB);
       
   778     _validateHasIntersectionResults(intersection, SDL_TRUE, &rectA, &rectB, &refRectA, &refRectB);
       
   779 
       
   780     // rectB left edge
       
   781     refRectB.x = 1 - rectA.w;
       
   782     refRectB.y = rectA.y;
       
   783     refRectB.w = refRectA.w;
       
   784     refRectB.h = SDLTest_RandomIntegerInRange(1, refRectA.h - 1);
       
   785     rectA = refRectA;
       
   786     rectB = refRectB;
       
   787     intersection = SDL_HasIntersection(&rectA, &rectB);
       
   788     _validateHasIntersectionResults(intersection, SDL_TRUE, &rectA, &rectB, &refRectA, &refRectB);
       
   789 
       
   790     // rectB bottom edge
       
   791     refRectB.x = rectA.x;
       
   792     refRectB.y = rectA.h - 1;
       
   793     refRectB.w = SDLTest_RandomIntegerInRange(1, refRectA.w - 1);
       
   794     refRectB.h = SDLTest_RandomIntegerInRange(1, refRectA.h - 1);
       
   795     rectA = refRectA;
       
   796     rectB = refRectB;
       
   797     intersection = SDL_HasIntersection(&rectA, &rectB);
       
   798     _validateHasIntersectionResults(intersection, SDL_TRUE, &rectA, &rectB, &refRectA, &refRectB);
       
   799 
       
   800     // rectB top edge
       
   801     refRectB.x = rectA.x;
       
   802     refRectB.y = 1 - rectA.h;
       
   803     refRectB.w = SDLTest_RandomIntegerInRange(1, refRectA.w - 1);
       
   804     refRectB.h = rectA.h;
       
   805     rectA = refRectA;
       
   806     rectB = refRectB;
       
   807     intersection = SDL_HasIntersection(&rectA, &rectB);
       
   808     _validateHasIntersectionResults(intersection, SDL_TRUE, &rectA, &rectB, &refRectA, &refRectB);
       
   809 
       
   810 	return TEST_COMPLETED;
       
   811 }
       
   812 
       
   813 /*!
       
   814  * \brief Tests SDL_HasIntersection() with 1x1 pixel sized rectangles
       
   815  *
       
   816  * \sa
       
   817  * http://wiki.libsdl.org/moin.cgi/SDL_HasIntersection
       
   818  */
       
   819 int rect_testHasIntersectionPoint (void *arg)
       
   820 {
       
   821     SDL_Rect refRectA = { 0, 0, 1, 1 };
       
   822     SDL_Rect refRectB = { 0, 0, 1, 1 };
       
   823     SDL_Rect rectA;
       
   824     SDL_Rect rectB;
       
   825     SDL_bool intersection;
       
   826     int offsetX, offsetY;
       
   827 
       
   828     // intersecting pixels
       
   829     refRectA.x = SDLTest_RandomIntegerInRange(1, 100);
       
   830     refRectA.y = SDLTest_RandomIntegerInRange(1, 100);
       
   831     refRectB.x = refRectA.x;
       
   832     refRectB.y = refRectA.y;
       
   833     rectA = refRectA;
       
   834     rectB = refRectB;
       
   835     intersection = SDL_HasIntersection(&rectA, &rectB);
       
   836     _validateHasIntersectionResults(intersection, SDL_TRUE, &rectA, &rectB, &refRectA, &refRectB);
       
   837 
       
   838     // non-intersecting pixels cases
       
   839     for (offsetX = -1; offsetX <= 1; offsetX++) {
       
   840         for (offsetY = -1; offsetY <= 1; offsetY++) {
       
   841             if (offsetX != 0 || offsetY != 0) {
       
   842                 refRectA.x = SDLTest_RandomIntegerInRange(1, 100);
       
   843                 refRectA.y = SDLTest_RandomIntegerInRange(1, 100);
       
   844                 refRectB.x = refRectA.x;
       
   845                 refRectB.y = refRectA.y;    
       
   846                 refRectB.x += offsetX;
       
   847                 refRectB.y += offsetY;
       
   848                 rectA = refRectA;
       
   849                 rectB = refRectB;
       
   850                 intersection = SDL_HasIntersection(&rectA, &rectB);
       
   851                 _validateHasIntersectionResults(intersection, SDL_FALSE, &rectA, &rectB, &refRectA, &refRectB);
       
   852             }
       
   853         }
       
   854     }
       
   855 
       
   856 	return TEST_COMPLETED;
       
   857 }
       
   858 
       
   859 /*!
       
   860  * \brief Tests SDL_HasIntersection() with empty rectangles
       
   861  *
       
   862  * \sa
       
   863  * http://wiki.libsdl.org/moin.cgi/SDL_HasIntersection
       
   864  */
       
   865 int rect_testHasIntersectionEmpty (void *arg)
       
   866 {
       
   867     SDL_Rect refRectA;
       
   868     SDL_Rect refRectB;
       
   869     SDL_Rect rectA;
       
   870     SDL_Rect rectB;
       
   871     SDL_bool intersection;
       
   872 
       
   873     // Rect A empty
       
   874     refRectA.x = SDLTest_RandomIntegerInRange(1, 100);
       
   875     refRectA.y = SDLTest_RandomIntegerInRange(1, 100);
       
   876     refRectA.w = SDLTest_RandomIntegerInRange(1, 100);
       
   877     refRectA.h = SDLTest_RandomIntegerInRange(1, 100);
       
   878     refRectB = refRectA;
       
   879     refRectA.w = 0;
       
   880     refRectA.h = 0;
       
   881     rectA = refRectA;
       
   882     rectB = refRectB;
       
   883     intersection = SDL_HasIntersection(&rectA, &rectB);
       
   884     _validateHasIntersectionResults(intersection, SDL_FALSE, &rectA, &rectB, &refRectA, &refRectB);
       
   885 
       
   886     // Rect B empty
       
   887     refRectA.x = SDLTest_RandomIntegerInRange(1, 100);
       
   888     refRectA.y = SDLTest_RandomIntegerInRange(1, 100);
       
   889     refRectA.w = SDLTest_RandomIntegerInRange(1, 100);
       
   890     refRectA.h = SDLTest_RandomIntegerInRange(1, 100);
       
   891     refRectB = refRectA;
       
   892     refRectB.w = 0;
       
   893     refRectB.h = 0;
       
   894     rectA = refRectA;
       
   895     rectB = refRectB;
       
   896     intersection = SDL_HasIntersection(&rectA, &rectB);
       
   897     _validateHasIntersectionResults(intersection, SDL_FALSE, &rectA, &rectB, &refRectA, &refRectB);
       
   898 
       
   899     // Rect A and B empty
       
   900     refRectA.x = SDLTest_RandomIntegerInRange(1, 100);
       
   901     refRectA.y = SDLTest_RandomIntegerInRange(1, 100);
       
   902     refRectA.w = SDLTest_RandomIntegerInRange(1, 100);
       
   903     refRectA.h = SDLTest_RandomIntegerInRange(1, 100);
       
   904     refRectB = refRectA;
       
   905     refRectA.w = 0;
       
   906     refRectA.h = 0;
       
   907     refRectB.w = 0;
       
   908     refRectB.h = 0;
       
   909     rectA = refRectA;
       
   910     rectB = refRectB;
       
   911     intersection = SDL_HasIntersection(&rectA, &rectB);
       
   912     _validateHasIntersectionResults(intersection, SDL_FALSE, &rectA, &rectB, &refRectA, &refRectB);
       
   913 
       
   914 	return TEST_COMPLETED;
       
   915 }
       
   916 
       
   917 /*!
       
   918  * \brief Negative tests against SDL_HasIntersection() with invalid parameters
       
   919  *
       
   920  * \sa
       
   921  * http://wiki.libsdl.org/moin.cgi/SDL_HasIntersection
       
   922  */
       
   923 int rect_testHasIntersectionParam(void *arg)
       
   924 {
       
   925     SDL_Rect rectA;
       
   926     SDL_Rect rectB;
       
   927     SDL_bool intersection;
       
   928 
       
   929     // invalid parameter combinations
       
   930     intersection = SDL_HasIntersection((SDL_Rect *)NULL, &rectB);
       
   931     SDLTest_AssertCheck(intersection == SDL_FALSE, "Check that function returns SDL_FALSE when 1st parameter is NULL"); 
       
   932     intersection = SDL_HasIntersection(&rectA, (SDL_Rect *)NULL);
       
   933     SDLTest_AssertCheck(intersection == SDL_FALSE, "Check that function returns SDL_FALSE when 2st parameter is NULL"); 
       
   934     intersection = SDL_HasIntersection((SDL_Rect *)NULL, (SDL_Rect *)NULL);
       
   935     SDLTest_AssertCheck(intersection == SDL_FALSE, "Check that function returns SDL_FALSE when all parameters are NULL");     
       
   936 
       
   937 	return TEST_COMPLETED;
       
   938 }
       
   939 
       
   940 /*!
       
   941  * \brief Test SDL_EnclosePoints() without clipping
       
   942  *
       
   943  * \sa
       
   944  * http://wiki.libsdl.org/moin.cgi/SDL_EnclosePoints
       
   945  */
       
   946 int rect_testEnclosePoints(void *arg)
       
   947 {
       
   948     const int numPoints = 16;
       
   949     SDL_Point refPoints[16];
       
   950     SDL_Point points[16];
       
   951     SDL_Rect result;
       
   952     SDL_bool anyEnclosed;
       
   953     SDL_bool anyEnclosedNoResult;
       
   954 
       
   955     // Create input data, tracking result
       
   956     SDL_bool expectedEnclosed = SDL_TRUE;
       
   957     int newx, newy;
       
   958     int minx, maxx, miny, maxy;
       
   959     int i;
       
   960     for (i=0; i<numPoints; i++) {
       
   961         newx = SDLTest_RandomIntegerInRange(-1024, 1024);
       
   962         newy = SDLTest_RandomIntegerInRange(-1024, 1024);
       
   963         refPoints[i].x = newx;
       
   964         refPoints[i].y = newy;
       
   965         points[i].x = newx;
       
   966         points[i].y = newy;
       
   967         if (i==0) {
       
   968             minx=maxx=newx;
       
   969             miny=maxy=newy;
       
   970         } else {
       
   971             if (newx<minx) minx=newx;
       
   972             if (newx>maxx) maxx=newx;
       
   973             if (newy<miny) miny=newy;
       
   974             if (newy>maxy) maxy=newy;
       
   975         }
       
   976     }
       
   977     
       
   978     // Call function and validate - special case: no result requested
       
   979     anyEnclosedNoResult = SDL_EnclosePoints((const SDL_Point *)points, numPoints, (const SDL_Rect *)NULL, (SDL_Rect *)NULL);
       
   980     SDLTest_AssertCheck(expectedEnclosed==anyEnclosedNoResult, 
       
   981         "Check expected return value %s, got %s", 
       
   982         (expectedEnclosed==SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE", 
       
   983 		(anyEnclosedNoResult==SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE");
       
   984     for (i=0; i<numPoints; i++) {
       
   985         SDLTest_AssertCheck(refPoints[i].x==points[i].x && refPoints[i].y==points[i].y,
       
   986             "Check that source point %i was not modified: expected (%i,%i) actual (%i,%i)", 
       
   987             i, refPoints[i].x, refPoints[i].y, points[i].x, points[i].y);
       
   988     }
       
   989 
       
   990     // Call function and validate
       
   991     anyEnclosed = SDL_EnclosePoints((const SDL_Point *)points, numPoints, (const SDL_Rect *)NULL, &result);
       
   992     SDLTest_AssertCheck(expectedEnclosed==anyEnclosed, 
       
   993         "Check return value %s, got %s", 
       
   994         (expectedEnclosed==SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE", 
       
   995 		(anyEnclosed==SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE");
       
   996     for (i=0; i<numPoints; i++) {
       
   997         SDLTest_AssertCheck(refPoints[i].x==points[i].x && refPoints[i].y==points[i].y,
       
   998             "Check that source point %i was not modified: expected (%i,%i) actual (%i,%i)", 
       
   999             i, refPoints[i].x, refPoints[i].y, points[i].x, points[i].y);
       
  1000     }
       
  1001     SDLTest_AssertCheck(result.x==minx && result.y==miny && result.w==(maxx - minx + 1) && result.h==(maxy - miny + 1),
       
  1002         "Resulting enclosing rectangle incorrect: expected (%i,%i - %i,%i), actual (%i,%i - %i,%i)",
       
  1003         minx, miny, maxx, maxy, result.x, result.y, result.x + result.w - 1, result.y + result.h - 1);
       
  1004 
       
  1005 	return TEST_COMPLETED;
       
  1006 }
       
  1007 
       
  1008 /*!
       
  1009  * \brief Test SDL_EnclosePoints() with repeated input points
       
  1010  *
       
  1011  * \sa
       
  1012  * http://wiki.libsdl.org/moin.cgi/SDL_EnclosePoints
       
  1013  */
       
  1014 int rect_testEnclosePointsRepeatedInput(void *arg)
       
  1015 {
       
  1016     const int numPoints = 8;
       
  1017     const int halfPoints = 4;
       
  1018     SDL_Point refPoints[8];
       
  1019     SDL_Point points[8];
       
  1020     SDL_Rect result;
       
  1021     SDL_bool anyEnclosed;
       
  1022     SDL_bool anyEnclosedNoResult;
       
  1023 
       
  1024     // Create input data, tracking result
       
  1025     SDL_bool expectedEnclosed = SDL_TRUE;
       
  1026     int newx, newy;
       
  1027     int minx, maxx, miny, maxy;
       
  1028     int i;
       
  1029     for (i=0; i<numPoints; i++) {
       
  1030         if (i < halfPoints) {
       
  1031             newx = SDLTest_RandomIntegerInRange(-1024, 1024);
       
  1032             newy = SDLTest_RandomIntegerInRange(-1024, 1024);
       
  1033         } else {
       
  1034             newx = refPoints[i-halfPoints].x;
       
  1035             newy = refPoints[i-halfPoints].y;
       
  1036         }
       
  1037         refPoints[i].x = newx;
       
  1038         refPoints[i].y = newy;
       
  1039         points[i].x = newx;
       
  1040         points[i].y = newy;
       
  1041         if (i==0) {
       
  1042             minx=maxx=newx;
       
  1043             miny=maxy=newy;
       
  1044         } else {
       
  1045             if (newx<minx) minx=newx;
       
  1046             if (newx>maxx) maxx=newx;
       
  1047             if (newy<miny) miny=newy;
       
  1048             if (newy>maxy) maxy=newy;
       
  1049         }
       
  1050     }
       
  1051 
       
  1052     // Call function and validate - special case: no result requested
       
  1053     anyEnclosedNoResult = SDL_EnclosePoints((const SDL_Point *)points, numPoints, (const SDL_Rect *)NULL, (SDL_Rect *)NULL);
       
  1054     SDLTest_AssertCheck(expectedEnclosed==anyEnclosedNoResult, 
       
  1055         "Check return value %s, got %s", 
       
  1056         (expectedEnclosed==SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE", 
       
  1057 		(anyEnclosedNoResult==SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE");
       
  1058     for (i=0; i<numPoints; i++) {
       
  1059         SDLTest_AssertCheck(refPoints[i].x==points[i].x && refPoints[i].y==points[i].y,
       
  1060             "Check that source point %i was not modified: expected (%i,%i) actual (%i,%i)", 
       
  1061             i, refPoints[i].x, refPoints[i].y, points[i].x, points[i].y);
       
  1062     }
       
  1063     
       
  1064     // Call function and validate
       
  1065     anyEnclosed = SDL_EnclosePoints((const SDL_Point *)points, numPoints, (const SDL_Rect *)NULL, &result);
       
  1066     SDLTest_AssertCheck(expectedEnclosed==anyEnclosed, 
       
  1067         "Check return value %s, got %s", 
       
  1068         (expectedEnclosed==SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE", 
       
  1069 		(anyEnclosed==SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE");
       
  1070     for (i=0; i<numPoints; i++) {
       
  1071         SDLTest_AssertCheck(refPoints[i].x==points[i].x && refPoints[i].y==points[i].y,
       
  1072             "Check that source point %i was not modified: expected (%i,%i) actual (%i,%i)", 
       
  1073             i, refPoints[i].x, refPoints[i].y, points[i].x, points[i].y);
       
  1074     }
       
  1075     SDLTest_AssertCheck(result.x==minx && result.y==miny && result.w==(maxx - minx + 1) && result.h==(maxy - miny + 1),
       
  1076         "Check resulting enclosing rectangle: expected (%i,%i - %i,%i), actual (%i,%i - %i,%i)",
       
  1077         minx, miny, maxx, maxy, result.x, result.y, result.x + result.w - 1, result.y + result.h - 1);
       
  1078 
       
  1079 	return TEST_COMPLETED;
       
  1080 }
       
  1081 
       
  1082 /*!
       
  1083  * \brief Test SDL_EnclosePoints() with clipping
       
  1084  *
       
  1085  * \sa
       
  1086  * http://wiki.libsdl.org/moin.cgi/SDL_EnclosePoints
       
  1087  */
       
  1088 int rect_testEnclosePointsWithClipping(void *arg)
       
  1089 {
       
  1090     const int numPoints = 16;
       
  1091     SDL_Point refPoints[16];
       
  1092     SDL_Point points[16];
       
  1093     SDL_Rect refClip;
       
  1094     SDL_Rect clip;
       
  1095     SDL_Rect result;
       
  1096     SDL_bool anyEnclosed;
       
  1097     SDL_bool anyEnclosedNoResult;
       
  1098     SDL_bool expectedEnclosed = SDL_FALSE;
       
  1099     int newx, newy;
       
  1100     int minx, maxx, miny, maxy;
       
  1101     int i;
       
  1102 
       
  1103     // Setup clipping rectangle
       
  1104     refClip.x = SDLTest_RandomIntegerInRange(-1024, 1024);
       
  1105     refClip.y = SDLTest_RandomIntegerInRange(-1024, 1024);
       
  1106     refClip.w = SDLTest_RandomIntegerInRange(1, 1024);
       
  1107     refClip.h = SDLTest_RandomIntegerInRange(1, 1024);
       
  1108 
       
  1109     // Create input data, tracking result
       
  1110     for (i=0; i<numPoints; i++) {
       
  1111         newx = SDLTest_RandomIntegerInRange(-1024, 1024);
       
  1112         newy = SDLTest_RandomIntegerInRange(-1024, 1024);
       
  1113         refPoints[i].x = newx;
       
  1114         refPoints[i].y = newy;
       
  1115         points[i].x = newx;
       
  1116         points[i].y = newy;
       
  1117         if ((newx>=refClip.x) && (newx<(refClip.x + refClip.w)) &&
       
  1118             (newy>=refClip.y) && (newy<(refClip.y + refClip.h))) {
       
  1119             if (expectedEnclosed==SDL_FALSE) {
       
  1120                 minx=maxx=newx;
       
  1121                 miny=maxy=newy;
       
  1122             } else {
       
  1123                 if (newx<minx) minx=newx;
       
  1124                 if (newx>maxx) maxx=newx;
       
  1125                 if (newy<miny) miny=newy;
       
  1126                 if (newy>maxy) maxy=newy;
       
  1127             }
       
  1128             expectedEnclosed = SDL_TRUE;
       
  1129         }
       
  1130     }
       
  1131 
       
  1132     // Call function and validate - special case: no result requested
       
  1133     clip = refClip;
       
  1134     anyEnclosedNoResult = SDL_EnclosePoints((const SDL_Point *)points, numPoints, (const SDL_Rect *)&clip, (SDL_Rect *)NULL);
       
  1135     SDLTest_AssertCheck(expectedEnclosed==anyEnclosedNoResult, 
       
  1136         "Expected return value %s, got %s", 
       
  1137         (expectedEnclosed==SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE", 
       
  1138 		(anyEnclosedNoResult==SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE");
       
  1139     for (i=0; i<numPoints; i++) {
       
  1140         SDLTest_AssertCheck(refPoints[i].x==points[i].x && refPoints[i].y==points[i].y,
       
  1141             "Check that source point %i was not modified: expected (%i,%i) actual (%i,%i)", 
       
  1142             i, refPoints[i].x, refPoints[i].y, points[i].x, points[i].y);
       
  1143     }
       
  1144     SDLTest_AssertCheck(refClip.x==clip.x && refClip.y==clip.y && refClip.w==clip.w && refClip.h==clip.h,
       
  1145         "Check that source clipping rectangle was not modified");
       
  1146     
       
  1147     // Call function and validate
       
  1148     anyEnclosed = SDL_EnclosePoints((const SDL_Point *)points, numPoints, (const SDL_Rect *)&clip, &result);
       
  1149     SDLTest_AssertCheck(expectedEnclosed==anyEnclosed, 
       
  1150         "Check return value %s, got %s", 
       
  1151         (expectedEnclosed==SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE", 
       
  1152 		(anyEnclosed==SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE");
       
  1153     for (i=0; i<numPoints; i++) {
       
  1154         SDLTest_AssertCheck(refPoints[i].x==points[i].x && refPoints[i].y==points[i].y,
       
  1155             "Check that source point %i was not modified: expected (%i,%i) actual (%i,%i)", 
       
  1156             i, refPoints[i].x, refPoints[i].y, points[i].x, points[i].y);
       
  1157     }
       
  1158     SDLTest_AssertCheck(refClip.x==clip.x && refClip.y==clip.y && refClip.w==clip.w && refClip.h==clip.h,
       
  1159         "Check that source clipping rectangle was not modified");
       
  1160     if (expectedEnclosed==SDL_TRUE) {
       
  1161         SDLTest_AssertCheck(result.x==minx && result.y==miny && result.w==(maxx - minx + 1) && result.h==(maxy - miny + 1),
       
  1162             "Check resulting enclosing rectangle: expected (%i,%i - %i,%i), actual (%i,%i - %i,%i)",
       
  1163             minx, miny, maxx, maxy, result.x, result.y, result.x + result.w - 1, result.y + result.h - 1);
       
  1164     }    
       
  1165     
       
  1166     /* Empty clipping rectangle */
       
  1167     clip.w = 0;
       
  1168     clip.h = 0;
       
  1169     expectedEnclosed = SDL_FALSE;
       
  1170     anyEnclosed = SDL_EnclosePoints((const SDL_Point *)points, numPoints, (const SDL_Rect *)&clip, &result);
       
  1171     SDLTest_AssertCheck(expectedEnclosed==anyEnclosed, 
       
  1172         "Check return value %s, got %s", 
       
  1173         (expectedEnclosed==SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE", 
       
  1174 		(anyEnclosed==SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE");    
       
  1175 
       
  1176 	return TEST_COMPLETED;
       
  1177 }
       
  1178 
       
  1179 /*!
       
  1180  * \brief Negative tests against SDL_EnclosePoints() with invalid parameters
       
  1181  *
       
  1182  * \sa
       
  1183  * http://wiki.libsdl.org/moin.cgi/SDL_EnclosePoints
       
  1184  */
       
  1185 int rect_testEnclosePointsParam(void *arg)
       
  1186 {
       
  1187     SDL_Point points[1];
       
  1188     int count;
       
  1189     SDL_Rect clip;
       
  1190     SDL_Rect result;
       
  1191     SDL_bool anyEnclosed;
       
  1192 
       
  1193     // invalid parameter combinations
       
  1194     anyEnclosed = SDL_EnclosePoints((SDL_Point *)NULL, 1, (const SDL_Rect *)&clip, &result);
       
  1195     SDLTest_AssertCheck(anyEnclosed == SDL_FALSE, "Check that functions returns SDL_FALSE when 1st parameter is NULL"); 
       
  1196     anyEnclosed = SDL_EnclosePoints((const SDL_Point *)points, 0, (const SDL_Rect *)&clip, &result);
       
  1197     SDLTest_AssertCheck(anyEnclosed == SDL_FALSE, "Check that functions returns SDL_FALSE when 2nd parameter is 0");
       
  1198     count = SDLTest_RandomIntegerInRange(-100, -1);
       
  1199     anyEnclosed = SDL_EnclosePoints((const SDL_Point *)points, count, (const SDL_Rect *)&clip, &result);
       
  1200     SDLTest_AssertCheck(anyEnclosed == SDL_FALSE, "Check that functions returns SDL_FALSE when 2nd parameter is %i (negative)", count); 
       
  1201     anyEnclosed = SDL_EnclosePoints((SDL_Point *)NULL, 0, (const SDL_Rect *)&clip, &result);
       
  1202     SDLTest_AssertCheck(anyEnclosed == SDL_FALSE, "Check that functions returns SDL_FALSE when 1st parameter is NULL and 2nd parameter was 0"); 
       
  1203 
       
  1204 	return TEST_COMPLETED;
       
  1205 }
       
  1206 
       
  1207 /*!
       
  1208  * \brief Tests SDL_UnionRect() where rect B is outside rect A
       
  1209  *
       
  1210  * \sa
       
  1211  * http://wiki.libsdl.org/moin.cgi/SDL_UnionRect
       
  1212  */
       
  1213 int rect_testUnionRectOutside(void *arg)
       
  1214 {
       
  1215     SDL_Rect refRectA, refRectB;
       
  1216     SDL_Rect rectA, rectB;
       
  1217     SDL_Rect expectedResult;
       
  1218     SDL_Rect result;
       
  1219     int minx, maxx, miny, maxy;
       
  1220     int dx, dy;
       
  1221     
       
  1222     /* Union 1x1 outside */
       
  1223     for (dx = -1; dx < 2; dx++) {     
       
  1224         for (dy = -1; dy < 2; dy++) {
       
  1225             if ((dx != 0) || (dy != 0)) {
       
  1226                 refRectA.x=SDLTest_RandomIntegerInRange(-1024, 1024);
       
  1227                 refRectA.y=SDLTest_RandomIntegerInRange(-1024, 1024);
       
  1228                 refRectA.w=1;
       
  1229                 refRectA.h=1;
       
  1230                 refRectB.x=SDLTest_RandomIntegerInRange(-1024, 1024) + dx*2048;
       
  1231                 refRectB.y=SDLTest_RandomIntegerInRange(-1024, 1024) + dx*2048;
       
  1232                 refRectB.w=1;
       
  1233                 refRectB.h=1;
       
  1234                 minx = (refRectA.x<refRectB.x) ? refRectA.x : refRectB.x;
       
  1235                 maxx = (refRectA.x>refRectB.x) ? refRectA.x : refRectB.x;
       
  1236                 miny = (refRectA.y<refRectB.y) ? refRectA.y : refRectB.y;
       
  1237                 maxy = (refRectA.y>refRectB.y) ? refRectA.y : refRectB.y;                
       
  1238                 expectedResult.x = minx;
       
  1239                 expectedResult.y = miny;
       
  1240                 expectedResult.w = maxx - minx + 1;
       
  1241                 expectedResult.h = maxy - miny + 1;
       
  1242                 rectA = refRectA;
       
  1243                 rectB = refRectB;
       
  1244                 SDL_UnionRect(&rectA, &rectB, &result);
       
  1245                 _validateUnionRectResults(&rectA, &rectB, &refRectA, &refRectB, &result, &expectedResult);
       
  1246             }
       
  1247         }
       
  1248     }
       
  1249 
       
  1250     /* Union outside overlap */
       
  1251     for (dx = -1; dx < 2; dx++) {     
       
  1252         for (dy = -1; dy < 2; dy++) {
       
  1253             if ((dx != 0) || (dy != 0)) {
       
  1254                 refRectA.x=SDLTest_RandomIntegerInRange(-1024, 1024);
       
  1255                 refRectA.y=SDLTest_RandomIntegerInRange(-1024, 1024);
       
  1256                 refRectA.w=SDLTest_RandomIntegerInRange(256, 512);
       
  1257                 refRectA.h=SDLTest_RandomIntegerInRange(256, 512);
       
  1258                 refRectB.x=refRectA.x + 1 + dx*2;
       
  1259                 refRectB.y=refRectA.y + 1 + dy*2;
       
  1260                 refRectB.w=refRectA.w - 2;
       
  1261                 refRectB.h=refRectA.h - 2;
       
  1262                 expectedResult = refRectA;
       
  1263                 if (dx == -1) expectedResult.x--;
       
  1264                 if (dy == -1) expectedResult.y--;
       
  1265                 if ((dx == 1) || (dx == -1)) expectedResult.w++;
       
  1266                 if ((dy == 1) || (dy == -1)) expectedResult.h++;
       
  1267                 rectA = refRectA;
       
  1268                 rectB = refRectB;
       
  1269                 SDL_UnionRect(&rectA, &rectB, &result);
       
  1270                 _validateUnionRectResults(&rectA, &rectB, &refRectA, &refRectB, &result, &expectedResult);
       
  1271             }
       
  1272         }
       
  1273     }
       
  1274 
       
  1275 	return TEST_COMPLETED;
       
  1276 }
       
  1277 
       
  1278 /*!
       
  1279  * \brief Tests SDL_UnionRect() where rect A or rect B are empty
       
  1280  *
       
  1281  * \sa
       
  1282  * http://wiki.libsdl.org/moin.cgi/SDL_UnionRect
       
  1283  */
       
  1284 int rect_testUnionRectEmpty(void *arg)
       
  1285 {
       
  1286     SDL_Rect refRectA, refRectB;
       
  1287     SDL_Rect rectA, rectB;
       
  1288     SDL_Rect expectedResult;
       
  1289     SDL_Rect result;
       
  1290 
       
  1291     /* A empty */    
       
  1292     refRectA.x=SDLTest_RandomIntegerInRange(-1024, 1024);
       
  1293     refRectA.y=SDLTest_RandomIntegerInRange(-1024, 1024);
       
  1294     refRectA.w=0;
       
  1295     refRectA.h=0;
       
  1296     refRectB.x=SDLTest_RandomIntegerInRange(-1024, 1024);
       
  1297     refRectB.y=SDLTest_RandomIntegerInRange(-1024, 1024);
       
  1298     refRectB.w=SDLTest_RandomIntegerInRange(1, 1024);
       
  1299     refRectB.h=SDLTest_RandomIntegerInRange(1, 1024);
       
  1300     expectedResult = refRectB;
       
  1301     rectA = refRectA;
       
  1302     rectB = refRectB;
       
  1303     SDL_UnionRect(&rectA, &rectB, &result);
       
  1304     _validateUnionRectResults(&rectA, &rectB, &refRectA, &refRectB, &result, &expectedResult);
       
  1305     
       
  1306     /* B empty */    
       
  1307     refRectA.x=SDLTest_RandomIntegerInRange(-1024, 1024);
       
  1308     refRectA.y=SDLTest_RandomIntegerInRange(-1024, 1024);
       
  1309     refRectA.w=SDLTest_RandomIntegerInRange(1, 1024);
       
  1310     refRectA.h=SDLTest_RandomIntegerInRange(1, 1024);
       
  1311     refRectB.x=SDLTest_RandomIntegerInRange(-1024, 1024);
       
  1312     refRectB.y=SDLTest_RandomIntegerInRange(-1024, 1024);
       
  1313     refRectB.w=0;
       
  1314     refRectB.h=0;
       
  1315     expectedResult = refRectA;
       
  1316     rectA = refRectA;
       
  1317     rectB = refRectB;
       
  1318     SDL_UnionRect(&rectA, &rectB, &result);
       
  1319     _validateUnionRectResults(&rectA, &rectB, &refRectA, &refRectB, &result, &expectedResult);
       
  1320 
       
  1321     /* A and B empty */    
       
  1322     refRectA.x=SDLTest_RandomIntegerInRange(-1024, 1024);
       
  1323     refRectA.y=SDLTest_RandomIntegerInRange(-1024, 1024);
       
  1324     refRectA.w=0;
       
  1325     refRectA.h=0;
       
  1326     refRectB.x=SDLTest_RandomIntegerInRange(-1024, 1024);
       
  1327     refRectB.y=SDLTest_RandomIntegerInRange(-1024, 1024);
       
  1328     refRectB.w=0;
       
  1329     refRectB.h=0;
       
  1330     result.x=0;
       
  1331     result.y=0;
       
  1332     result.w=0;
       
  1333     result.h=0;
       
  1334     expectedResult = result;
       
  1335     rectA = refRectA;
       
  1336     rectB = refRectB;
       
  1337     SDL_UnionRect(&rectA, &rectB, &result);
       
  1338     _validateUnionRectResults(&rectA, &rectB, &refRectA, &refRectB, &result, &expectedResult);
       
  1339 
       
  1340 	return TEST_COMPLETED;
       
  1341 }
       
  1342 
       
  1343 /*!
       
  1344  * \brief Tests SDL_UnionRect() where rect B is inside rect A
       
  1345  *
       
  1346  * \sa
       
  1347  * http://wiki.libsdl.org/moin.cgi/SDL_UnionRect
       
  1348  */
       
  1349 int rect_testUnionRectInside(void *arg)
       
  1350 {
       
  1351     SDL_Rect refRectA, refRectB;
       
  1352     SDL_Rect rectA, rectB;
       
  1353     SDL_Rect expectedResult;
       
  1354     SDL_Rect result;
       
  1355     int dx, dy;
       
  1356     
       
  1357     /* Union 1x1 with itself */
       
  1358     refRectA.x=SDLTest_RandomIntegerInRange(-1024, 1024);
       
  1359     refRectA.y=SDLTest_RandomIntegerInRange(-1024, 1024);
       
  1360     refRectA.w=1;
       
  1361     refRectA.h=1;
       
  1362     expectedResult = refRectA;
       
  1363     rectA = refRectA;
       
  1364     SDL_UnionRect(&rectA, &rectA, &result);
       
  1365     _validateUnionRectResults(&rectA, &rectA, &refRectA, &refRectA, &result, &expectedResult);
       
  1366 
       
  1367     /* Union 1x1 somewhere inside */
       
  1368     refRectA.x=SDLTest_RandomIntegerInRange(-1024, 1024);
       
  1369     refRectA.y=SDLTest_RandomIntegerInRange(-1024, 1024);
       
  1370     refRectA.w=SDLTest_RandomIntegerInRange(256, 1024);
       
  1371     refRectA.h=SDLTest_RandomIntegerInRange(256, 1024);
       
  1372     refRectB.x=refRectA.x + 1 + SDLTest_RandomIntegerInRange(1, refRectA.w - 2);
       
  1373     refRectB.y=refRectA.y + 1 + SDLTest_RandomIntegerInRange(1, refRectA.h - 2);
       
  1374     refRectB.w=1;
       
  1375     refRectB.h=1;
       
  1376     expectedResult = refRectA;
       
  1377     rectA = refRectA;
       
  1378     rectB = refRectB;
       
  1379     SDL_UnionRect(&rectA, &rectB, &result);
       
  1380     _validateUnionRectResults(&rectA, &rectB, &refRectA, &refRectB, &result, &expectedResult);
       
  1381 
       
  1382     /* Union inside with edges modified */
       
  1383     for (dx = -1; dx < 2; dx++) {     
       
  1384         for (dy = -1; dy < 2; dy++) {
       
  1385             if ((dx != 0) || (dy != 0)) {
       
  1386                 refRectA.x=SDLTest_RandomIntegerInRange(-1024, 1024);
       
  1387                 refRectA.y=SDLTest_RandomIntegerInRange(-1024, 1024);
       
  1388                 refRectA.w=SDLTest_RandomIntegerInRange(256, 1024);
       
  1389                 refRectA.h=SDLTest_RandomIntegerInRange(256, 1024);
       
  1390                 refRectB = refRectA;
       
  1391                 if (dx == -1) refRectB.x++;
       
  1392                 if ((dx == 1) || (dx == -1)) refRectB.w--;
       
  1393                 if (dy == -1) refRectB.y++;
       
  1394                 if ((dy == 1) || (dy == -1)) refRectB.h--;                
       
  1395                 expectedResult = refRectA;
       
  1396                 rectA = refRectA;
       
  1397                 rectB = refRectB;
       
  1398                 SDL_UnionRect(&rectA, &rectB, &result);
       
  1399                 _validateUnionRectResults(&rectA, &rectB, &refRectA, &refRectB, &result, &expectedResult);
       
  1400             }
       
  1401         }
       
  1402     }
       
  1403 
       
  1404 	return TEST_COMPLETED;
       
  1405 }
       
  1406 
       
  1407 /*!
       
  1408  * \brief Negative tests against SDL_UnionRect() with invalid parameters
       
  1409  *
       
  1410  * \sa
       
  1411  * http://wiki.libsdl.org/moin.cgi/SDL_UnionRect
       
  1412  */
       
  1413 int rect_testUnionRectParam(void *arg)
       
  1414 {
       
  1415     SDL_Rect rectA, rectB;
       
  1416     SDL_Rect result;
       
  1417 
       
  1418     // invalid parameter combinations
       
  1419     SDL_UnionRect((SDL_Rect *)NULL, &rectB, &result);
       
  1420     SDLTest_AssertPass("Check that function returns when 1st parameter is NULL"); 
       
  1421     SDL_UnionRect(&rectA, (SDL_Rect *)NULL, &result);
       
  1422     SDLTest_AssertPass("Check that function returns  when 2nd parameter is NULL"); 
       
  1423     SDL_UnionRect(&rectA, &rectB, (SDL_Rect *)NULL);
       
  1424     SDLTest_AssertPass("Check that function returns  when 3rd parameter is NULL"); 
       
  1425     SDL_UnionRect((SDL_Rect *)NULL, &rectB, (SDL_Rect *)NULL);
       
  1426     SDLTest_AssertPass("Check that function returns  when 1st and 3rd parameter are NULL"); 
       
  1427     SDL_UnionRect(&rectA, (SDL_Rect *)NULL, (SDL_Rect *)NULL);
       
  1428     SDLTest_AssertPass("Check that function returns  when 2nd and 3rd parameter are NULL"); 
       
  1429     SDL_UnionRect((SDL_Rect *)NULL, (SDL_Rect *)NULL, (SDL_Rect *)NULL);
       
  1430     SDLTest_AssertPass("Check that function returns  when all parameters are NULL"); 
       
  1431 
       
  1432 	return TEST_COMPLETED;
       
  1433 }
       
  1434 
       
  1435 /*!
       
  1436  * \brief Tests SDL_RectEmpty() with various inputs
       
  1437  *
       
  1438  * \sa
       
  1439  * http://wiki.libsdl.org/moin.cgi/SDL_RectEmpty
       
  1440  */
       
  1441 int rect_testRectEmpty(void *arg)
       
  1442 {
       
  1443     SDL_Rect refRect;
       
  1444     SDL_Rect rect;
       
  1445     SDL_bool expectedResult;
       
  1446     SDL_bool result;
       
  1447     int w, h;
       
  1448 
       
  1449     // Non-empty case
       
  1450     refRect.x=SDLTest_RandomIntegerInRange(-1024, 1024);
       
  1451     refRect.y=SDLTest_RandomIntegerInRange(-1024, 1024);
       
  1452     refRect.w=SDLTest_RandomIntegerInRange(256, 1024);
       
  1453     refRect.h=SDLTest_RandomIntegerInRange(256, 1024);
       
  1454     expectedResult = SDL_FALSE;
       
  1455     rect = refRect;
       
  1456     result = (SDL_bool)SDL_RectEmpty((const SDL_Rect *)&rect);
       
  1457     _validateRectEmptyResults(result, expectedResult, &rect, &refRect);
       
  1458     
       
  1459     // Empty case
       
  1460     for (w=-1; w<2; w++) {
       
  1461         for (h=-1; h<2; h++) {
       
  1462             if ((w != 1) || (h != 1)) {
       
  1463                 refRect.x=SDLTest_RandomIntegerInRange(-1024, 1024);
       
  1464                 refRect.y=SDLTest_RandomIntegerInRange(-1024, 1024);
       
  1465                 refRect.w=w;
       
  1466                 refRect.h=h;
       
  1467                 expectedResult = SDL_TRUE;
       
  1468                 rect = refRect;
       
  1469                 result = (SDL_bool)SDL_RectEmpty((const SDL_Rect *)&rect);
       
  1470                 _validateRectEmptyResults(result, expectedResult, &rect, &refRect);
       
  1471             }
       
  1472         }
       
  1473     }
       
  1474 
       
  1475 	return TEST_COMPLETED;
       
  1476 }
       
  1477 
       
  1478 /*!
       
  1479  * \brief Negative tests against SDL_RectEmpty() with invalid parameters
       
  1480  *
       
  1481  * \sa
       
  1482  * http://wiki.libsdl.org/moin.cgi/SDL_RectEmpty
       
  1483  */
       
  1484 int rect_testRectEmptyParam(void *arg)
       
  1485 {
       
  1486     SDL_bool result;
       
  1487 
       
  1488     // invalid parameter combinations
       
  1489     result = (SDL_bool)SDL_RectEmpty((const SDL_Rect *)NULL);
       
  1490     SDLTest_AssertCheck(result == SDL_TRUE, "Check that function returns TRUE when 1st parameter is NULL"); 
       
  1491 
       
  1492 	return TEST_COMPLETED;
       
  1493 }
       
  1494 
       
  1495 /*!
       
  1496  * \brief Tests SDL_RectEquals() with various inputs
       
  1497  *
       
  1498  * \sa
       
  1499  * http://wiki.libsdl.org/moin.cgi/SDL_RectEquals
       
  1500  */
       
  1501 int rect_testRectEquals(void *arg)
       
  1502 {
       
  1503     SDL_Rect refRectA;
       
  1504     SDL_Rect refRectB;
       
  1505     SDL_Rect rectA;
       
  1506     SDL_Rect rectB;
       
  1507     SDL_bool expectedResult;
       
  1508     SDL_bool result;
       
  1509 
       
  1510     // Equals
       
  1511     refRectA.x=SDLTest_RandomIntegerInRange(-1024, 1024);
       
  1512     refRectA.y=SDLTest_RandomIntegerInRange(-1024, 1024);
       
  1513     refRectA.w=SDLTest_RandomIntegerInRange(1, 1024);
       
  1514     refRectA.h=SDLTest_RandomIntegerInRange(1, 1024);
       
  1515     refRectB = refRectA;    
       
  1516     expectedResult = SDL_TRUE;
       
  1517     rectA = refRectA;
       
  1518     rectB = refRectB;
       
  1519     result = (SDL_bool)SDL_RectEquals((const SDL_Rect *)&rectA, (const SDL_Rect *)&rectB);
       
  1520     _validateRectEqualsResults(result, expectedResult, &rectA, &rectB, &refRectA, &refRectB);
       
  1521 
       
  1522 	return TEST_COMPLETED;
       
  1523 }
       
  1524 
       
  1525 /*!
       
  1526  * \brief Negative tests against SDL_RectEquals() with invalid parameters
       
  1527  *
       
  1528  * \sa
       
  1529  * http://wiki.libsdl.org/moin.cgi/SDL_RectEquals
       
  1530  */
       
  1531 int rect_testRectEqualsParam(void *arg)
       
  1532 {
       
  1533     SDL_Rect rectA;
       
  1534     SDL_Rect rectB;
       
  1535     SDL_bool result;
       
  1536 
       
  1537     /* data setup */
       
  1538     rectA.x=SDLTest_RandomIntegerInRange(-1024, 1024);
       
  1539     rectA.y=SDLTest_RandomIntegerInRange(-1024, 1024);
       
  1540     rectA.w=SDLTest_RandomIntegerInRange(1, 1024);
       
  1541     rectA.h=SDLTest_RandomIntegerInRange(1, 1024);
       
  1542     rectB.x=SDLTest_RandomIntegerInRange(-1024, 1024);
       
  1543     rectB.y=SDLTest_RandomIntegerInRange(-1024, 1024);
       
  1544     rectB.w=SDLTest_RandomIntegerInRange(1, 1024);
       
  1545     rectB.h=SDLTest_RandomIntegerInRange(1, 1024);
       
  1546 
       
  1547     // invalid parameter combinations
       
  1548     result = (SDL_bool)SDL_RectEquals((const SDL_Rect *)NULL, (const SDL_Rect *)&rectB);
       
  1549     SDLTest_AssertCheck(result == SDL_FALSE, "Check that function returns SDL_FALSE when 1st parameter is NULL"); 
       
  1550     result = (SDL_bool)SDL_RectEquals((const SDL_Rect *)&rectA, (const SDL_Rect *)NULL);
       
  1551     SDLTest_AssertCheck(result == SDL_FALSE, "Check that function returns SDL_FALSE when 2nd parameter is NULL"); 
       
  1552     result = (SDL_bool)SDL_RectEquals((const SDL_Rect *)NULL, (const SDL_Rect *)NULL);
       
  1553     SDLTest_AssertCheck(result == SDL_FALSE, "Check that function returns SDL_FALSE when 1st and 2nd parameter are NULL"); 
       
  1554 
       
  1555 	return TEST_COMPLETED;
       
  1556 }
       
  1557 
       
  1558 /* ================= Test References ================== */
       
  1559 
       
  1560 /* Rect test cases */
       
  1561 
       
  1562 /* SDL_IntersectRectAndLine */
       
  1563 static const SDLTest_TestCaseReference rectTest1 =
       
  1564 		{ (SDLTest_TestCaseFp)rect_testIntersectRectAndLine,"rect_testIntersectRectAndLine",  "Tests SDL_IntersectRectAndLine clipping cases", TEST_ENABLED };
       
  1565 
       
  1566 static const SDLTest_TestCaseReference rectTest2 =
       
  1567 		{ (SDLTest_TestCaseFp)rect_testIntersectRectAndLineInside, "rect_testIntersectRectAndLineInside", "Tests SDL_IntersectRectAndLine with line fully contained in rect", TEST_ENABLED };
       
  1568 
       
  1569 static const SDLTest_TestCaseReference rectTest3 =
       
  1570 		{ (SDLTest_TestCaseFp)rect_testIntersectRectAndLineOutside, "rect_testIntersectRectAndLineOutside", "Tests SDL_IntersectRectAndLine with line fully outside of rect", TEST_ENABLED };
       
  1571 
       
  1572 static const SDLTest_TestCaseReference rectTest4 =
       
  1573 		{ (SDLTest_TestCaseFp)rect_testIntersectRectAndLineEmpty, "rect_testIntersectRectAndLineEmpty", "Tests SDL_IntersectRectAndLine with empty rectangle ", TEST_ENABLED };
       
  1574 
       
  1575 static const SDLTest_TestCaseReference rectTest5 =
       
  1576 		{ (SDLTest_TestCaseFp)rect_testIntersectRectAndLineParam, "rect_testIntersectRectAndLineParam", "Negative tests against SDL_IntersectRectAndLine with invalid parameters", TEST_ENABLED };
       
  1577 
       
  1578 /* SDL_IntersectRect */
       
  1579 static const SDLTest_TestCaseReference rectTest6 =
       
  1580 		{ (SDLTest_TestCaseFp)rect_testIntersectRectInside, "rect_testIntersectRectInside", "Tests SDL_IntersectRect with B fully contained in A", TEST_ENABLED };
       
  1581 
       
  1582 static const SDLTest_TestCaseReference rectTest7 =
       
  1583 		{ (SDLTest_TestCaseFp)rect_testIntersectRectOutside, "rect_testIntersectRectOutside", "Tests SDL_IntersectRect with B fully outside of A", TEST_ENABLED };
       
  1584 
       
  1585 static const SDLTest_TestCaseReference rectTest8 =
       
  1586 		{ (SDLTest_TestCaseFp)rect_testIntersectRectPartial, "rect_testIntersectRectPartial", "Tests SDL_IntersectRect with B partially intersecting A", TEST_ENABLED };
       
  1587 
       
  1588 static const SDLTest_TestCaseReference rectTest9 =
       
  1589 		{ (SDLTest_TestCaseFp)rect_testIntersectRectPoint, "rect_testIntersectRectPoint", "Tests SDL_IntersectRect with 1x1 sized rectangles", TEST_ENABLED };
       
  1590 
       
  1591 static const SDLTest_TestCaseReference rectTest10 =
       
  1592 		{ (SDLTest_TestCaseFp)rect_testIntersectRectEmpty, "rect_testIntersectRectEmpty", "Tests SDL_IntersectRect with empty rectangles", TEST_ENABLED };
       
  1593 
       
  1594 static const SDLTest_TestCaseReference rectTest11 =
       
  1595 		{ (SDLTest_TestCaseFp)rect_testIntersectRectParam, "rect_testIntersectRectParam", "Negative tests against SDL_IntersectRect with invalid parameters", TEST_ENABLED };
       
  1596 
       
  1597 /* SDL_HasIntersection */
       
  1598 static const SDLTest_TestCaseReference rectTest12 =
       
  1599 		{ (SDLTest_TestCaseFp)rect_testHasIntersectionInside, "rect_testHasIntersectionInside", "Tests SDL_HasIntersection with B fully contained in A", TEST_ENABLED };
       
  1600 
       
  1601 static const SDLTest_TestCaseReference rectTest13 =
       
  1602 		{ (SDLTest_TestCaseFp)rect_testHasIntersectionOutside, "rect_testHasIntersectionOutside", "Tests SDL_HasIntersection with B fully outside of A", TEST_ENABLED };
       
  1603 
       
  1604 static const SDLTest_TestCaseReference rectTest14 =
       
  1605 		{ (SDLTest_TestCaseFp)rect_testHasIntersectionPartial,"rect_testHasIntersectionPartial",  "Tests SDL_HasIntersection with B partially intersecting A", TEST_ENABLED };
       
  1606 
       
  1607 static const SDLTest_TestCaseReference rectTest15 =
       
  1608 		{ (SDLTest_TestCaseFp)rect_testHasIntersectionPoint, "rect_testHasIntersectionPoint", "Tests SDL_HasIntersection with 1x1 sized rectangles", TEST_ENABLED };
       
  1609 
       
  1610 static const SDLTest_TestCaseReference rectTest16 =
       
  1611 		{ (SDLTest_TestCaseFp)rect_testHasIntersectionEmpty, "rect_testHasIntersectionEmpty", "Tests SDL_HasIntersection with empty rectangles", TEST_ENABLED };
       
  1612 
       
  1613 static const SDLTest_TestCaseReference rectTest17 =
       
  1614 		{ (SDLTest_TestCaseFp)rect_testHasIntersectionParam, "rect_testHasIntersectionParam", "Negative tests against SDL_HasIntersection with invalid parameters", TEST_ENABLED };
       
  1615 
       
  1616 /* SDL_EnclosePoints */
       
  1617 static const SDLTest_TestCaseReference rectTest18 =
       
  1618 		{ (SDLTest_TestCaseFp)rect_testEnclosePoints, "rect_testEnclosePoints", "Tests SDL_EnclosePoints without clipping", TEST_ENABLED };
       
  1619 
       
  1620 static const SDLTest_TestCaseReference rectTest19 =
       
  1621 		{ (SDLTest_TestCaseFp)rect_testEnclosePointsWithClipping, "rect_testEnclosePointsWithClipping", "Tests SDL_EnclosePoints with clipping", TEST_ENABLED };
       
  1622 
       
  1623 static const SDLTest_TestCaseReference rectTest20 =
       
  1624 		{ (SDLTest_TestCaseFp)rect_testEnclosePointsRepeatedInput, "rect_testEnclosePointsRepeatedInput", "Tests SDL_EnclosePoints with repeated input", TEST_ENABLED };
       
  1625 
       
  1626 static const SDLTest_TestCaseReference rectTest21 =
       
  1627 		{ (SDLTest_TestCaseFp)rect_testEnclosePointsParam, "rect_testEnclosePointsParam", "Negative tests against SDL_EnclosePoints with invalid parameters", TEST_ENABLED };
       
  1628 
       
  1629 /* SDL_UnionRect */
       
  1630 static const SDLTest_TestCaseReference rectTest22 =
       
  1631 		{ (SDLTest_TestCaseFp)rect_testUnionRectInside, "rect_testUnionRectInside", "Tests SDL_UnionRect where rect B is inside rect A", TEST_ENABLED };
       
  1632 
       
  1633 static const SDLTest_TestCaseReference rectTest23 =
       
  1634 		{ (SDLTest_TestCaseFp)rect_testUnionRectOutside, "rect_testUnionRectOutside", "Tests SDL_UnionRect where rect B is outside rect A", TEST_ENABLED };
       
  1635 
       
  1636 static const SDLTest_TestCaseReference rectTest24 =
       
  1637 		{ (SDLTest_TestCaseFp)rect_testUnionRectEmpty, "rect_testUnionRectEmpty", "Tests SDL_UnionRect where rect A or rect B are empty", TEST_ENABLED };
       
  1638 
       
  1639 static const SDLTest_TestCaseReference rectTest25 =
       
  1640 		{ (SDLTest_TestCaseFp)rect_testUnionRectParam, "rect_testUnionRectParam", "Negative tests against SDL_UnionRect with invalid parameters", TEST_ENABLED };
       
  1641 
       
  1642 /* SDL_RectEmpty */
       
  1643 static const SDLTest_TestCaseReference rectTest26 =
       
  1644 		{ (SDLTest_TestCaseFp)rect_testRectEmpty, "rect_testRectEmpty", "Tests SDL_RectEmpty with various inputs", TEST_ENABLED };
       
  1645 
       
  1646 static const SDLTest_TestCaseReference rectTest27 =
       
  1647 		{ (SDLTest_TestCaseFp)rect_testRectEmptyParam, "rect_testRectEmptyParam", "Negative tests against SDL_RectEmpty with invalid parameters", TEST_ENABLED };
       
  1648 
       
  1649 /* SDL_RectEquals */
       
  1650 
       
  1651 static const SDLTest_TestCaseReference rectTest28 =
       
  1652 		{ (SDLTest_TestCaseFp)rect_testRectEquals, "rect_testRectEquals", "Tests SDL_RectEquals with various inputs", TEST_ENABLED };
       
  1653 
       
  1654 static const SDLTest_TestCaseReference rectTest29 =
       
  1655 		{ (SDLTest_TestCaseFp)rect_testRectEqualsParam, "rect_testRectEqualsParam", "Negative tests against SDL_RectEquals with invalid parameters", TEST_ENABLED };
       
  1656 
       
  1657 
       
  1658 /*!
       
  1659  * \brief Sequence of Rect test cases; functions that handle simple rectangles including overlaps and merges.
       
  1660  *
       
  1661  * \sa
       
  1662  * http://wiki.libsdl.org/moin.cgi/CategoryRect
       
  1663  */
       
  1664 static const SDLTest_TestCaseReference *rectTests[] =  {
       
  1665 	&rectTest1, &rectTest2, &rectTest3, &rectTest4, &rectTest5, &rectTest6, &rectTest7, &rectTest8, &rectTest9, &rectTest10, &rectTest11, &rectTest12, &rectTest13, &rectTest14, 
       
  1666 	&rectTest15, &rectTest16, &rectTest17, &rectTest18, &rectTest19, &rectTest20, &rectTest21, &rectTest22, &rectTest23, &rectTest24, &rectTest25, &rectTest26, &rectTest27,
       
  1667 	&rectTest28, &rectTest29, NULL
       
  1668 };
       
  1669 
       
  1670 
       
  1671 /* Rect test suite (global) */
       
  1672 SDLTest_TestSuiteReference rectTestSuite = {
       
  1673 	"Rect",
       
  1674 	NULL,
       
  1675 	rectTests,
       
  1676 	NULL
       
  1677 };