Add tests for SDL_RectEquals and empty rectangle cases
authorAndreas Schiffler
Sat, 17 Sep 2011 22:37:31 -0700
changeset 5951b4c936b80652
parent 5950 36fa6d12784b
child 5953 fecf71a834ed
Add tests for SDL_RectEquals and empty rectangle cases
test/test-automation/tests/testrect/testrect.c
     1.1 --- a/test/test-automation/tests/testrect/testrect.c	Sat Sep 17 22:35:57 2011 -0700
     1.2 +++ b/test/test-automation/tests/testrect/testrect.c	Sat Sep 17 22:37:31 2011 -0700
     1.3 @@ -17,74 +17,93 @@
     1.4  		(TestCaseReference){ "rect_testIntersectRectAndLineInside", "Tests SDL_IntersectRectAndLine with line fully contained in rect", TEST_ENABLED, 0, 0 };
     1.5  
     1.6  static const TestCaseReference test3 =
     1.7 -		(TestCaseReference){ "rect_testIntersectRectAndLineOutside", "Tests SDL_IntersectRectAndLine with line fully contained in rect", TEST_ENABLED, 0, 0 };
     1.8 +		(TestCaseReference){ "rect_testIntersectRectAndLineOutside", "Tests SDL_IntersectRectAndLine with line fully outside of rect", TEST_ENABLED, 0, 0 };
     1.9  
    1.10  static const TestCaseReference test4 =
    1.11 +		(TestCaseReference){ "rect_testIntersectRectAndLineEmpty", "Tests SDL_IntersectRectAndLine with empty rectangle ", TEST_ENABLED, 0, 0 };
    1.12 +
    1.13 +static const TestCaseReference test5 =
    1.14  		(TestCaseReference){ "rect_testIntersectRectAndLineParam", "Negative tests against SDL_IntersectRectAndLine with invalid parameters", TEST_ENABLED, 0, 0 };
    1.15  
    1.16  /* SDL_IntersectRect */
    1.17 -static const TestCaseReference test5 =
    1.18 +static const TestCaseReference test6 =
    1.19  		(TestCaseReference){ "rect_testIntersectRectInside", "Tests SDL_IntersectRect with B fully contained in A", TEST_ENABLED, 0, 0 };
    1.20  
    1.21 -static const TestCaseReference test6 =
    1.22 -		(TestCaseReference){ "rect_testIntersectRectOutside", "Tests SDL_IntersectRect with B fully outside of A", TEST_ENABLED, 0, 0 };
    1.23 -
    1.24  static const TestCaseReference test7 =
    1.25 -		(TestCaseReference){ "rect_testIntersectRectPartial", "Tests SDL_IntersectRect with B partially intersecting A", TEST_ENABLED, 0, 0 };
    1.26 +		(TestCaseReference){ "rect_testIntersectRectOutside", "Tests SDL_IntersectRect with B fully outside of A", TEST_ENABLED, 0, 0 };
    1.27  
    1.28  static const TestCaseReference test8 =
    1.29 +		(TestCaseReference){ "rect_testIntersectRectPartial", "Tests SDL_IntersectRect with B partially intersecting A", TEST_ENABLED, 0, 0 };
    1.30 +
    1.31 +static const TestCaseReference test9 =
    1.32  		(TestCaseReference){ "rect_testIntersectRectPoint", "Tests SDL_IntersectRect with 1x1 sized rectangles", TEST_ENABLED, 0, 0 };
    1.33  
    1.34 -static const TestCaseReference test9 =
    1.35 +static const TestCaseReference test10 =
    1.36 +		(TestCaseReference){ "rect_testIntersectRectEmpty", "Tests SDL_IntersectRect with empty rectangles", TEST_ENABLED, 0, 0 };
    1.37 +
    1.38 +static const TestCaseReference test11 =
    1.39  		(TestCaseReference){ "rect_testIntersectRectParam", "Negative tests against SDL_IntersectRect with invalid parameters", TEST_ENABLED, 0, 0 };
    1.40  
    1.41  /* SDL_HasIntersection */
    1.42 -static const TestCaseReference test10 =
    1.43 +static const TestCaseReference test12 =
    1.44  		(TestCaseReference){ "rect_testHasIntersectionInside", "Tests SDL_HasIntersection with B fully contained in A", TEST_ENABLED, 0, 0 };
    1.45  
    1.46 -static const TestCaseReference test11 =
    1.47 +static const TestCaseReference test13 =
    1.48  		(TestCaseReference){ "rect_testHasIntersectionOutside", "Tests SDL_HasIntersection with B fully outside of A", TEST_ENABLED, 0, 0 };
    1.49  
    1.50 -static const TestCaseReference test12 =
    1.51 +static const TestCaseReference test14 =
    1.52  		(TestCaseReference){ "rect_testHasIntersectionPartial", "Tests SDL_HasIntersection with B partially intersecting A", TEST_ENABLED, 0, 0 };
    1.53  
    1.54 -static const TestCaseReference test13 =
    1.55 +static const TestCaseReference test15 =
    1.56  		(TestCaseReference){ "rect_testHasIntersectionPoint", "Tests SDL_HasIntersection with 1x1 sized rectangles", TEST_ENABLED, 0, 0 };
    1.57  
    1.58 -static const TestCaseReference test14 =
    1.59 +static const TestCaseReference test16 =
    1.60 +		(TestCaseReference){ "rect_testHasIntersectionEmpty", "Tests SDL_HasIntersection with empty rectangles", TEST_ENABLED, 0, 0 };
    1.61 +
    1.62 +static const TestCaseReference test17 =
    1.63  		(TestCaseReference){ "rect_testHasIntersectionParam", "Negative tests against SDL_HasIntersection with invalid parameters", TEST_ENABLED, 0, 0 };
    1.64  
    1.65  /* SDL_EnclosePoints */
    1.66 -static const TestCaseReference test15 =
    1.67 +static const TestCaseReference test18 =
    1.68  		(TestCaseReference){ "rect_testEnclosePoints", "Tests SDL_EnclosePoints without clipping", TEST_ENABLED, 0, 0 };
    1.69  
    1.70 -static const TestCaseReference test16 =
    1.71 +static const TestCaseReference test19 =
    1.72  		(TestCaseReference){ "rect_testEnclosePointsWithClipping", "Tests SDL_EnclosePoints with clipping", TEST_ENABLED, 0, 0 };
    1.73  
    1.74 -static const TestCaseReference test17 =
    1.75 +static const TestCaseReference test20 =
    1.76  		(TestCaseReference){ "rect_testEnclosePointsRepeatedInput", "Tests SDL_EnclosePoints with repeated input", TEST_ENABLED, 0, 0 };
    1.77  
    1.78 -static const TestCaseReference test18 =
    1.79 +static const TestCaseReference test21 =
    1.80  		(TestCaseReference){ "rect_testEnclosePointsParam", "Negative tests against SDL_EnclosePoints with invalid parameters", TEST_ENABLED, 0, 0 };
    1.81  
    1.82  /* SDL_UnionRect */
    1.83 -static const TestCaseReference test19 =
    1.84 +static const TestCaseReference test22 =
    1.85  		(TestCaseReference){ "rect_testUnionRectInside", "Tests SDL_UnionRect where rect B is inside rect A", TEST_ENABLED, 0, 0 };
    1.86  
    1.87 -static const TestCaseReference test20 =
    1.88 +static const TestCaseReference test23 =
    1.89  		(TestCaseReference){ "rect_testUnionRectOutside", "Tests SDL_UnionRect where rect B is outside rect A", TEST_ENABLED, 0, 0 };
    1.90  
    1.91 -static const TestCaseReference test21 =
    1.92 +static const TestCaseReference test24 =
    1.93 +		(TestCaseReference){ "rect_testUnionRectEmpty", "Tests SDL_UnionRect where rect A or rect B are empty", TEST_ENABLED, 0, 0 };
    1.94 +
    1.95 +static const TestCaseReference test25 =
    1.96  		(TestCaseReference){ "rect_testUnionRectParam", "Negative tests against SDL_UnionRect with invalid parameters", TEST_ENABLED, 0, 0 };
    1.97  
    1.98  /* SDL_RectEmpty */
    1.99 -static const TestCaseReference test22 =
   1.100 +static const TestCaseReference test26 =
   1.101  		(TestCaseReference){ "rect_testRectEmpty", "Tests SDL_RectEmpty with various inputs", TEST_ENABLED, 0, 0 };
   1.102  
   1.103 -static const TestCaseReference test23 =
   1.104 +static const TestCaseReference test27 =
   1.105  		(TestCaseReference){ "rect_testRectEmptyParam", "Negative tests against SDL_RectEmpty with invalid parameters", TEST_ENABLED, 0, 0 };
   1.106  
   1.107 -/* TODO: SDL_RectEquals */
   1.108 +/* SDL_RectEquals */
   1.109 +
   1.110 +static const TestCaseReference test28 =
   1.111 +		(TestCaseReference){ "rect_testRectEquals", "Tests SDL_RectEquals with various inputs", TEST_ENABLED, 0, 0 };
   1.112 +
   1.113 +static const TestCaseReference test29 =
   1.114 +		(TestCaseReference){ "rect_testRectEqualsParam", "Negative tests against SDL_RectEquals with invalid parameters", TEST_ENABLED, 0, 0 };
   1.115 +
   1.116  
   1.117  /*!
   1.118   * \brief Test suite for functions that handle simple rectangles including overlaps and merges.
   1.119 @@ -94,7 +113,8 @@
   1.120   */
   1.121  extern const TestCaseReference *testSuite[] =  {
   1.122  	&test1, &test2, &test3, &test4, &test5, &test6, &test7, &test8, &test9, &test10, &test11, &test12, &test13, &test14, 
   1.123 -	&test15, &test16, &test17, &test18, &test19, &test20, &test21, &test22, &test23, NULL
   1.124 +	&test15, &test16, &test17, &test18, &test19, &test20, &test21, &test22, &test23, &test24, &test25, &test26, &test27,
   1.125 +	&test28, &test29, NULL
   1.126  };
   1.127  
   1.128  TestCaseReference **QueryTestSuite() {
   1.129 @@ -312,6 +332,38 @@
   1.130  }
   1.131  
   1.132  /*!
   1.133 + * \brief Tests SDL_IntersectRectAndLine() with empty rectangle
   1.134 + *
   1.135 + * \sa
   1.136 + * http://wiki.libsdl.org/moin.cgi/SDL_IntersectRectAndLine
   1.137 + */
   1.138 +int rect_testIntersectRectAndLineEmpty (void *arg)
   1.139 +{
   1.140 +    SDL_Rect refRect;
   1.141 +    SDL_Rect rect;
   1.142 +    int x1, y1, x1Ref, y1Ref;
   1.143 +    int x2, y2, x2Ref, y2Ref;
   1.144 +    SDL_bool intersected;
   1.145 +        
   1.146 +    refRect.x = RandomIntegerInRange(1, 1024);
   1.147 +    refRect.y = RandomIntegerInRange(1, 1024);
   1.148 +    refRect.w = 0;
   1.149 +    refRect.h = 0;
   1.150 +    x1Ref = refRect.x;
   1.151 +    y1Ref = refRect.y;
   1.152 +    x2Ref = RandomIntegerInRange(1, 1024);
   1.153 +    y2Ref = RandomIntegerInRange(1, 1024);
   1.154 +
   1.155 +    x1 = x1Ref;
   1.156 +    y1 = y1Ref;
   1.157 +    x2 = x2Ref;
   1.158 +    y2 = y2Ref;
   1.159 +    rect = refRect;
   1.160 +    intersected = SDL_IntersectRectAndLine(&rect, &x1, &y1, &x2, &y2);
   1.161 +    _validateIntersectRectAndLineResults(intersected, SDL_FALSE, &rect, &refRect, x1, y1, x2, y2, x1Ref, y1Ref, x2Ref, y2Ref);
   1.162 +}
   1.163 +
   1.164 +/*!
   1.165   * \brief Negative tests against SDL_IntersectRectAndLine() with invalid parameters
   1.166   *
   1.167   * \sa
   1.168 @@ -427,6 +479,29 @@
   1.169  }
   1.170  
   1.171  /*!
   1.172 + * \brief Private helper to check SDL_RectEquals results
   1.173 + */
   1.174 +void _validateRectEqualsResults(
   1.175 +    SDL_bool equals, SDL_bool expectedEquals, 
   1.176 +    SDL_Rect *rectA, SDL_Rect *rectB, SDL_Rect *refRectA, SDL_Rect *refRectB)
   1.177 +{
   1.178 +    AssertTrue(equals == expectedEquals, 
   1.179 +        "Incorrect equals result: expected %s, got %s testing (%d,%d,%d,%d) and (%d,%d,%d,%d) \n",
   1.180 +        (expectedEquals == SDL_TRUE) ? "true" : "false",
   1.181 +        (equals == SDL_TRUE) ? "true" : "false",
   1.182 +        rectA->x, rectA->y, rectA->w, rectA->h,
   1.183 +        rectB->x, rectB->y, rectB->w, rectB->h);
   1.184 +    AssertTrue(rectA->x == refRectA->x && rectA->y == refRectA->y && rectA->w == refRectA->w && rectA->h == refRectA->h,
   1.185 +        "Source rectangle A was modified: got (%d,%d,%d,%d) expected (%d,%d,%d,%d)",
   1.186 +        rectA->x, rectA->y, rectA->w, rectA->h,
   1.187 +        refRectA->x, refRectA->y, refRectA->w, refRectA->h);
   1.188 +    AssertTrue(rectB->x == refRectB->x && rectB->y == refRectB->y && rectB->w == refRectB->w && rectB->h == refRectB->h,
   1.189 +        "Source rectangle B was modified: got (%d,%d,%d,%d) expected (%d,%d,%d,%d)",
   1.190 +        rectB->x, rectB->y, rectB->w, rectB->h,
   1.191 +        refRectB->x, refRectB->y, refRectB->w, refRectB->h);
   1.192 +}
   1.193 +
   1.194 +/*!
   1.195   * \brief Tests SDL_IntersectRect() with B fully inside A
   1.196   *
   1.197   * \sa
   1.198 @@ -611,6 +686,63 @@
   1.199  }
   1.200  
   1.201  /*!
   1.202 + * \brief Tests SDL_IntersectRect() with empty rectangles
   1.203 + *
   1.204 + * \sa
   1.205 + * http://wiki.libsdl.org/moin.cgi/SDL_IntersectRect
   1.206 + */
   1.207 +int rect_testIntersectRectEmpty (void *arg)
   1.208 +{
   1.209 +    SDL_Rect refRectA;
   1.210 +    SDL_Rect refRectB;
   1.211 +    SDL_Rect rectA;
   1.212 +    SDL_Rect rectB;
   1.213 +    SDL_Rect result;
   1.214 +    SDL_bool intersection;
   1.215 +
   1.216 +    // Rect A empty
   1.217 +    refRectA.x = RandomIntegerInRange(1, 100);
   1.218 +    refRectA.y = RandomIntegerInRange(1, 100);
   1.219 +    refRectA.w = RandomIntegerInRange(1, 100);
   1.220 +    refRectA.h = RandomIntegerInRange(1, 100);
   1.221 +    refRectB = refRectA;
   1.222 +    refRectA.w = 0;
   1.223 +    refRectA.h = 0;
   1.224 +    rectA = refRectA;
   1.225 +    rectB = refRectB;
   1.226 +    intersection = SDL_IntersectRect(&rectA, &rectB, &result);
   1.227 +    _validateIntersectRectResults(intersection, SDL_FALSE, &rectA, &rectB, &refRectA, &refRectB, (SDL_Rect *)NULL, (SDL_Rect *)NULL);
   1.228 +
   1.229 +    // Rect B empty
   1.230 +    refRectA.x = RandomIntegerInRange(1, 100);
   1.231 +    refRectA.y = RandomIntegerInRange(1, 100);
   1.232 +    refRectA.w = RandomIntegerInRange(1, 100);
   1.233 +    refRectA.h = RandomIntegerInRange(1, 100);
   1.234 +    refRectB = refRectA;
   1.235 +    refRectB.w = 0;
   1.236 +    refRectB.h = 0;
   1.237 +    rectA = refRectA;
   1.238 +    rectB = refRectB;
   1.239 +    intersection = SDL_IntersectRect(&rectA, &rectB, &result);
   1.240 +    _validateIntersectRectResults(intersection, SDL_FALSE, &rectA, &rectB, &refRectA, &refRectB, (SDL_Rect *)NULL, (SDL_Rect *)NULL);
   1.241 +
   1.242 +    // Rect A and B empty
   1.243 +    refRectA.x = RandomIntegerInRange(1, 100);
   1.244 +    refRectA.y = RandomIntegerInRange(1, 100);
   1.245 +    refRectA.w = RandomIntegerInRange(1, 100);
   1.246 +    refRectA.h = RandomIntegerInRange(1, 100);
   1.247 +    refRectB = refRectA;
   1.248 +    refRectA.w = 0;
   1.249 +    refRectA.h = 0;
   1.250 +    refRectB.w = 0;
   1.251 +    refRectB.h = 0;
   1.252 +    rectA = refRectA;
   1.253 +    rectB = refRectB;
   1.254 +    intersection = SDL_IntersectRect(&rectA, &rectB, &result);
   1.255 +    _validateIntersectRectResults(intersection, SDL_FALSE, &rectA, &rectB, &refRectA, &refRectB, (SDL_Rect *)NULL, (SDL_Rect *)NULL);
   1.256 +}
   1.257 +
   1.258 +/*!
   1.259   * \brief Negative tests against SDL_IntersectRect() with invalid parameters
   1.260   *
   1.261   * \sa
   1.262 @@ -799,6 +931,62 @@
   1.263  }
   1.264  
   1.265  /*!
   1.266 + * \brief Tests SDL_HasIntersection() with empty rectangles
   1.267 + *
   1.268 + * \sa
   1.269 + * http://wiki.libsdl.org/moin.cgi/SDL_HasIntersection
   1.270 + */
   1.271 +int rect_testHasIntersectionEmpty (void *arg)
   1.272 +{
   1.273 +    SDL_Rect refRectA;
   1.274 +    SDL_Rect refRectB;
   1.275 +    SDL_Rect rectA;
   1.276 +    SDL_Rect rectB;
   1.277 +    SDL_bool intersection;
   1.278 +
   1.279 +    // Rect A empty
   1.280 +    refRectA.x = RandomIntegerInRange(1, 100);
   1.281 +    refRectA.y = RandomIntegerInRange(1, 100);
   1.282 +    refRectA.w = RandomIntegerInRange(1, 100);
   1.283 +    refRectA.h = RandomIntegerInRange(1, 100);
   1.284 +    refRectB = refRectA;
   1.285 +    refRectA.w = 0;
   1.286 +    refRectA.h = 0;
   1.287 +    rectA = refRectA;
   1.288 +    rectB = refRectB;
   1.289 +    intersection = SDL_HasIntersection(&rectA, &rectB);
   1.290 +    _validateHasIntersectionResults(intersection, SDL_FALSE, &rectA, &rectB, &refRectA, &refRectB);
   1.291 +
   1.292 +    // Rect B empty
   1.293 +    refRectA.x = RandomIntegerInRange(1, 100);
   1.294 +    refRectA.y = RandomIntegerInRange(1, 100);
   1.295 +    refRectA.w = RandomIntegerInRange(1, 100);
   1.296 +    refRectA.h = RandomIntegerInRange(1, 100);
   1.297 +    refRectB = refRectA;
   1.298 +    refRectB.w = 0;
   1.299 +    refRectB.h = 0;
   1.300 +    rectA = refRectA;
   1.301 +    rectB = refRectB;
   1.302 +    intersection = SDL_HasIntersection(&rectA, &rectB);
   1.303 +    _validateHasIntersectionResults(intersection, SDL_FALSE, &rectA, &rectB, &refRectA, &refRectB);
   1.304 +
   1.305 +    // Rect A and B empty
   1.306 +    refRectA.x = RandomIntegerInRange(1, 100);
   1.307 +    refRectA.y = RandomIntegerInRange(1, 100);
   1.308 +    refRectA.w = RandomIntegerInRange(1, 100);
   1.309 +    refRectA.h = RandomIntegerInRange(1, 100);
   1.310 +    refRectB = refRectA;
   1.311 +    refRectA.w = 0;
   1.312 +    refRectA.h = 0;
   1.313 +    refRectB.w = 0;
   1.314 +    refRectB.h = 0;
   1.315 +    rectA = refRectA;
   1.316 +    rectB = refRectB;
   1.317 +    intersection = SDL_HasIntersection(&rectA, &rectB);
   1.318 +    _validateHasIntersectionResults(intersection, SDL_FALSE, &rectA, &rectB, &refRectA, &refRectB);
   1.319 +}
   1.320 +
   1.321 +/*!
   1.322   * \brief Negative tests against SDL_HasIntersection() with invalid parameters
   1.323   *
   1.324   * \sa
   1.325 @@ -1037,6 +1225,15 @@
   1.326              "Resulting enclosing rectangle incorrect: expected (%i,%i - %i,%i), actual (%i,%i - %i,%i)",
   1.327              minx, miny, maxx, maxy, result.x, result.y, result.x + result.w - 1, result.y + result.h - 1);
   1.328      }    
   1.329 +    
   1.330 +    /* Empty clipping rectangle */
   1.331 +    clip.w = 0;
   1.332 +    clip.h = 0;
   1.333 +    expectedEnclosed = SDL_FALSE;
   1.334 +    anyEnclosed = SDL_EnclosePoints((const SDL_Point *)points, numPoints, (const SDL_Rect *)&clip, &result);
   1.335 +    AssertTrue(expectedEnclosed==anyEnclosed, 
   1.336 +        "Expected return value %s, got %s", 
   1.337 +        (expectedEnclosed==SDL_TRUE) ? "true" : "false", (anyEnclosed==SDL_TRUE) ? "true" : "false");    
   1.338  }
   1.339  
   1.340  /*!
   1.341 @@ -1136,6 +1333,69 @@
   1.342  }
   1.343  
   1.344  /*!
   1.345 + * \brief Tests SDL_UnionRect() where rect A or rect B are empty
   1.346 + *
   1.347 + * \sa
   1.348 + * http://wiki.libsdl.org/moin.cgi/SDL_UnionRect
   1.349 + */
   1.350 +int rect_testUnionRectEmpty(void *arg)
   1.351 +{
   1.352 +    SDL_Rect refRectA, refRectB;
   1.353 +    SDL_Rect rectA, rectB;
   1.354 +    SDL_Rect expectedResult;
   1.355 +    SDL_Rect result;
   1.356 +
   1.357 +    /* A empty */    
   1.358 +    refRectA.x=RandomIntegerInRange(-1024, 1024);
   1.359 +    refRectA.y=RandomIntegerInRange(-1024, 1024);
   1.360 +    refRectA.w=0;
   1.361 +    refRectA.h=0;
   1.362 +    refRectB.x=RandomIntegerInRange(-1024, 1024);
   1.363 +    refRectB.y=RandomIntegerInRange(-1024, 1024);
   1.364 +    refRectB.w=RandomIntegerInRange(1, 1024);
   1.365 +    refRectB.h=RandomIntegerInRange(1, 1024);
   1.366 +    expectedResult = refRectB;
   1.367 +    rectA = refRectA;
   1.368 +    rectB = refRectB;
   1.369 +    SDL_UnionRect(&rectA, &rectB, &result);
   1.370 +    _validateUnionRectResults(&rectA, &rectB, &refRectA, &refRectB, &result, &expectedResult);
   1.371 +    
   1.372 +    /* B empty */    
   1.373 +    refRectA.x=RandomIntegerInRange(-1024, 1024);
   1.374 +    refRectA.y=RandomIntegerInRange(-1024, 1024);
   1.375 +    refRectA.w=RandomIntegerInRange(1, 1024);
   1.376 +    refRectA.h=RandomIntegerInRange(1, 1024);
   1.377 +    refRectB.x=RandomIntegerInRange(-1024, 1024);
   1.378 +    refRectB.y=RandomIntegerInRange(-1024, 1024);
   1.379 +    refRectB.w=0;
   1.380 +    refRectB.h=0;
   1.381 +    expectedResult = refRectA;
   1.382 +    rectA = refRectA;
   1.383 +    rectB = refRectB;
   1.384 +    SDL_UnionRect(&rectA, &rectB, &result);
   1.385 +    _validateUnionRectResults(&rectA, &rectB, &refRectA, &refRectB, &result, &expectedResult);
   1.386 +
   1.387 +    /* A and B empty */    
   1.388 +    refRectA.x=RandomIntegerInRange(-1024, 1024);
   1.389 +    refRectA.y=RandomIntegerInRange(-1024, 1024);
   1.390 +    refRectA.w=0;
   1.391 +    refRectA.h=0;
   1.392 +    refRectB.x=RandomIntegerInRange(-1024, 1024);
   1.393 +    refRectB.y=RandomIntegerInRange(-1024, 1024);
   1.394 +    refRectB.w=0;
   1.395 +    refRectB.h=0;
   1.396 +    result.x=0;
   1.397 +    result.y=0;
   1.398 +    result.w=0;
   1.399 +    result.h=0;
   1.400 +    expectedResult = result;
   1.401 +    rectA = refRectA;
   1.402 +    rectB = refRectB;
   1.403 +    SDL_UnionRect(&rectA, &rectB, &result);
   1.404 +    _validateUnionRectResults(&rectA, &rectB, &refRectA, &refRectB, &result, &expectedResult);
   1.405 +}
   1.406 +
   1.407 +/*!
   1.408   * \brief Tests SDL_UnionRect() where rect B is inside rect A
   1.409   *
   1.410   * \sa
   1.411 @@ -1273,10 +1533,68 @@
   1.412   */
   1.413  int rect_testRectEmptyParam(void *arg)
   1.414  {
   1.415 -    SDL_Rect rect;
   1.416      SDL_bool result;
   1.417  
   1.418      // invalid parameter combinations
   1.419      result = SDL_RectEmpty((const SDL_Rect *)NULL);
   1.420 -    AssertTrue(result = SDL_TRUE, "Function did not return TRUE when 1st parameter was NULL"); 
   1.421 +    AssertTrue(result == SDL_TRUE, "Function did not return TRUE when 1st parameter was NULL"); 
   1.422 +}
   1.423 +
   1.424 +/*!
   1.425 + * \brief Tests SDL_RectEquals() with various inputs
   1.426 + *
   1.427 + * \sa
   1.428 + * http://wiki.libsdl.org/moin.cgi/SDL_RectEquals
   1.429 + */
   1.430 +int rect_testRectEquals(void *arg)
   1.431 +{
   1.432 +    SDL_Rect refRectA;
   1.433 +    SDL_Rect refRectB;
   1.434 +    SDL_Rect rectA;
   1.435 +    SDL_Rect rectB;
   1.436 +    SDL_bool expectedResult;
   1.437 +    SDL_bool result;
   1.438 +
   1.439 +    // Equals
   1.440 +    refRectA.x=RandomIntegerInRange(-1024, 1024);
   1.441 +    refRectA.y=RandomIntegerInRange(-1024, 1024);
   1.442 +    refRectA.w=RandomIntegerInRange(1, 1024);
   1.443 +    refRectA.h=RandomIntegerInRange(1, 1024);
   1.444 +    refRectB = refRectA;    
   1.445 +    expectedResult = SDL_TRUE;
   1.446 +    rectA = refRectA;
   1.447 +    rectB = refRectB;
   1.448 +    result = SDL_RectEquals((const SDL_Rect *)&rectA, (const SDL_Rect *)&rectB);
   1.449 +    _validateRectEqualsResults(result, expectedResult, &rectA, &rectB, &refRectA, &refRectB);
   1.450  }
   1.451 +
   1.452 +/*!
   1.453 + * \brief Negative tests against SDL_RectEquals() with invalid parameters
   1.454 + *
   1.455 + * \sa
   1.456 + * http://wiki.libsdl.org/moin.cgi/SDL_RectEquals
   1.457 + */
   1.458 +int rect_testRectEqualsParam(void *arg)
   1.459 +{
   1.460 +    SDL_Rect rectA;
   1.461 +    SDL_Rect rectB;
   1.462 +    SDL_bool result;
   1.463 +
   1.464 +    /* data setup */
   1.465 +    rectA.x=RandomIntegerInRange(-1024, 1024);
   1.466 +    rectA.y=RandomIntegerInRange(-1024, 1024);
   1.467 +    rectA.w=RandomIntegerInRange(1, 1024);
   1.468 +    rectA.h=RandomIntegerInRange(1, 1024);
   1.469 +    rectB.x=RandomIntegerInRange(-1024, 1024);
   1.470 +    rectB.y=RandomIntegerInRange(-1024, 1024);
   1.471 +    rectB.w=RandomIntegerInRange(1, 1024);
   1.472 +    rectB.h=RandomIntegerInRange(1, 1024);
   1.473 +
   1.474 +    // invalid parameter combinations
   1.475 +    result = SDL_RectEquals((const SDL_Rect *)NULL, (const SDL_Rect *)&rectB);
   1.476 +    AssertTrue(result == SDL_FALSE, "Function did not return FALSE when 1st parameter was NULL"); 
   1.477 +    result = SDL_RectEquals((const SDL_Rect *)&rectA, (const SDL_Rect *)NULL);
   1.478 +    AssertTrue(result == SDL_FALSE, "Function did not return FALSE when 2nd parameter was NULL"); 
   1.479 +    result = SDL_RectEquals((const SDL_Rect *)NULL, (const SDL_Rect *)NULL);
   1.480 +    AssertTrue(result == SDL_FALSE, "Function did not return FALSE when 1st and 2nd parameter were NULL"); 
   1.481 +}