7
#include <SDL3/SDL_test.h>
8
#include "testautomation_suites.h"
17
static void validateIntersectRectAndLineFloatResults(
18
SDL_bool intersection, SDL_bool expectedIntersection,
20
float x1, float y1, float x2, float y2,
21
float x1Ref, float y1Ref, float x2Ref, float y2Ref)
23
SDLTest_AssertCheck(intersection == expectedIntersection,
24
"Check for correct intersection result: expected %s, got %s intersecting rect (%.2f,%.2f,%.2f,%.2f) with line (%.2f,%.2f - %.2f,%.2f)",
25
(expectedIntersection == SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE",
26
(intersection == SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE",
27
rect->x, rect->y, rect->w, rect->h,
28
x1Ref, y1Ref, x2Ref, y2Ref);
29
SDLTest_AssertCheck(x1 == x1Ref && y1 == y1Ref && x2 == x2Ref && y2 == y2Ref,
30
"Check if line was incorrectly clipped or modified: got (%.2f,%.2f - %.2f,%.2f) expected (%.2f,%.2f - %.2f,%.2f)",
32
x1Ref, y1Ref, x2Ref, y2Ref);
38
static void validateIntersectRectAndLineResults(
39
SDL_bool intersection, SDL_bool expectedIntersection,
40
SDL_Rect *rect, SDL_Rect *refRect,
41
int x1, int y1, int x2, int y2,
42
int x1Ref, int y1Ref, int x2Ref, int y2Ref)
44
SDLTest_AssertCheck(intersection == expectedIntersection,
45
"Check for correct intersection result: expected %s, got %s intersecting rect (%d,%d,%d,%d) with line (%d,%d - %d,%d)",
46
(expectedIntersection == SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE",
47
(intersection == SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE",
48
refRect->x, refRect->y, refRect->w, refRect->h,
49
x1Ref, y1Ref, x2Ref, y2Ref);
50
SDLTest_AssertCheck(rect->x == refRect->x && rect->y == refRect->y && rect->w == refRect->w && rect->h == refRect->h,
51
"Check that source rectangle was not modified: got (%d,%d,%d,%d) expected (%d,%d,%d,%d)",
52
rect->x, rect->y, rect->w, rect->h,
53
refRect->x, refRect->y, refRect->w, refRect->h);
54
SDLTest_AssertCheck(x1 == x1Ref && y1 == y1Ref && x2 == x2Ref && y2 == y2Ref,
55
"Check if line was incorrectly clipped or modified: got (%d,%d - %d,%d) expected (%d,%d - %d,%d)",
57
x1Ref, y1Ref, x2Ref, y2Ref);
67
static int rect_testIntersectRectAndLineFloat(void *arg)
82
intersected = SDL_GetRectAndLineIntersectionFloat(&rect, &x1, &y1, &x2, &y2);
83
validateIntersectRectAndLineFloatResults(intersected, SDL_TRUE, &rect, x1, y1, x2, y2, 5.0f, 6.0f, 17.75f, 6.0f);
93
intersected = SDL_GetRectAndLineIntersectionFloat(&rect, &x1, &y1, &x2, &y2);
94
validateIntersectRectAndLineFloatResults(intersected, SDL_TRUE, &rect, x1, y1, x2, y2, 2.5f, 6.0f, 2.75f, 6.0f);
96
return TEST_COMPLETED;
104
static int rect_testIntersectRectAndLine(void *arg)
106
SDL_Rect refRect = { 0, 0, 32, 32 };
110
SDL_bool intersected;
112
int xLeft = -SDLTest_RandomIntegerInRange(1, refRect.w);
113
int xRight = refRect.w + SDLTest_RandomIntegerInRange(1, refRect.w);
114
int yTop = -SDLTest_RandomIntegerInRange(1, refRect.h);
115
int yBottom = refRect.h + SDLTest_RandomIntegerInRange(1, refRect.h);
122
intersected = SDL_GetRectAndLineIntersection(&rect, &x1, &y1, &x2, &y2);
123
validateIntersectRectAndLineResults(intersected, SDL_TRUE, &rect, &refRect, x1, y1, x2, y2, 0, 15, 31, 15);
130
intersected = SDL_GetRectAndLineIntersection(&rect, &x1, &y1, &x2, &y2);
131
validateIntersectRectAndLineResults(intersected, SDL_TRUE, &rect, &refRect, x1, y1, x2, y2, 15, 0, 15, 31);
138
intersected = SDL_GetRectAndLineIntersection(&rect, &x1, &y1, &x2, &y2);
139
validateIntersectRectAndLineResults(intersected, SDL_TRUE, &rect, &refRect, x1, y1, x2, y2, 0, 0, 31, 31);
146
intersected = SDL_GetRectAndLineIntersection(&rect, &x1, &y1, &x2, &y2);
147
validateIntersectRectAndLineResults(intersected, SDL_TRUE, &rect, &refRect, x1, y1, x2, y2, 31, 31, 0, 0);
154
intersected = SDL_GetRectAndLineIntersection(&rect, &x1, &y1, &x2, &y2);
155
validateIntersectRectAndLineResults(intersected, SDL_TRUE, &rect, &refRect, x1, y1, x2, y2, 0, 31, 31, 0);
162
intersected = SDL_GetRectAndLineIntersection(&rect, &x1, &y1, &x2, &y2);
163
validateIntersectRectAndLineResults(intersected, SDL_TRUE, &rect, &refRect, x1, y1, x2, y2, 31, 0, 0, 31);
166
refRect.x = INT_MAX - 4;
167
refRect.y = INT_MAX - 4;
173
intersected = SDL_GetRectAndLineIntersection(&rect, &x1, &y1, &x2, &y2);
174
validateIntersectRectAndLineResults(intersected, SDL_FALSE, &rect, &refRect, x1, y1, x2, y2, x1, y1, x2, y2);
176
return TEST_COMPLETED;
184
static int rect_testIntersectRectAndLineInside(void *arg)
186
SDL_Rect refRect = { 0, 0, 32, 32 };
190
SDL_bool intersected;
192
int xmin = refRect.x;
193
int xmax = refRect.x + refRect.w - 1;
194
int ymin = refRect.y;
195
int ymax = refRect.y + refRect.h - 1;
196
int x1Ref = SDLTest_RandomIntegerInRange(xmin + 1, xmax - 1);
197
int y1Ref = SDLTest_RandomIntegerInRange(ymin + 1, ymax - 1);
198
int x2Ref = SDLTest_RandomIntegerInRange(xmin + 1, xmax - 1);
199
int y2Ref = SDLTest_RandomIntegerInRange(ymin + 1, ymax - 1);
206
intersected = SDL_GetRectAndLineIntersection(&rect, &x1, &y1, &x2, &y2);
207
validateIntersectRectAndLineResults(intersected, SDL_TRUE, &rect, &refRect, x1, y1, x2, y2, x1Ref, y1Ref, x2Ref, y2Ref);
214
intersected = SDL_GetRectAndLineIntersection(&rect, &x1, &y1, &x2, &y2);
215
validateIntersectRectAndLineResults(intersected, SDL_TRUE, &rect, &refRect, x1, y1, x2, y2, x1Ref, y1Ref, xmax, ymax);
222
intersected = SDL_GetRectAndLineIntersection(&rect, &x1, &y1, &x2, &y2);
223
validateIntersectRectAndLineResults(intersected, SDL_TRUE, &rect, &refRect, x1, y1, x2, y2, xmin, ymin, x2Ref, y2Ref);
230
intersected = SDL_GetRectAndLineIntersection(&rect, &x1, &y1, &x2, &y2);
231
validateIntersectRectAndLineResults(intersected, SDL_TRUE, &rect, &refRect, x1, y1, x2, y2, xmin, ymin, xmax, ymax);
238
intersected = SDL_GetRectAndLineIntersection(&rect, &x1, &y1, &x2, &y2);
239
validateIntersectRectAndLineResults(intersected, SDL_TRUE, &rect, &refRect, x1, y1, x2, y2, xmin, ymax, xmax, ymin);
241
return TEST_COMPLETED;
249
static int rect_testIntersectRectAndLineOutside(void *arg)
251
SDL_Rect refRect = { 0, 0, 32, 32 };
255
SDL_bool intersected;
257
int xLeft = -SDLTest_RandomIntegerInRange(1, refRect.w);
258
int xRight = refRect.w + SDLTest_RandomIntegerInRange(1, refRect.w);
259
int yTop = -SDLTest_RandomIntegerInRange(1, refRect.h);
260
int yBottom = refRect.h + SDLTest_RandomIntegerInRange(1, refRect.h);
267
intersected = SDL_GetRectAndLineIntersection(&rect, &x1, &y1, &x2, &y2);
268
validateIntersectRectAndLineResults(intersected, SDL_FALSE, &rect, &refRect, x1, y1, x2, y2, xLeft, 0, xLeft, 31);
275
intersected = SDL_GetRectAndLineIntersection(&rect, &x1, &y1, &x2, &y2);
276
validateIntersectRectAndLineResults(intersected, SDL_FALSE, &rect, &refRect, x1, y1, x2, y2, xRight, 0, xRight, 31);
283
intersected = SDL_GetRectAndLineIntersection(&rect, &x1, &y1, &x2, &y2);
284
validateIntersectRectAndLineResults(intersected, SDL_FALSE, &rect, &refRect, x1, y1, x2, y2, 0, yTop, 31, yTop);
291
intersected = SDL_GetRectAndLineIntersection(&rect, &x1, &y1, &x2, &y2);
292
validateIntersectRectAndLineResults(intersected, SDL_FALSE, &rect, &refRect, x1, y1, x2, y2, 0, yBottom, 31, yBottom);
294
return TEST_COMPLETED;
302
static int rect_testIntersectRectAndLineEmpty(void *arg)
306
int x1, y1, x1Ref, y1Ref;
307
int x2, y2, x2Ref, y2Ref;
308
SDL_bool intersected;
310
refRect.x = SDLTest_RandomIntegerInRange(1, 1024);
311
refRect.y = SDLTest_RandomIntegerInRange(1, 1024);
316
x2Ref = SDLTest_RandomIntegerInRange(1, 1024);
317
y2Ref = SDLTest_RandomIntegerInRange(1, 1024);
324
intersected = SDL_GetRectAndLineIntersection(&rect, &x1, &y1, &x2, &y2);
325
validateIntersectRectAndLineResults(intersected, SDL_FALSE, &rect, &refRect, x1, y1, x2, y2, x1Ref, y1Ref, x2Ref, y2Ref);
327
return TEST_COMPLETED;
335
static int rect_testIntersectRectAndLineParam(void *arg)
337
SDL_Rect rect = { 0, 0, 32, 32 };
342
SDL_bool intersected;
344
intersected = SDL_GetRectAndLineIntersection(&rect, &x1, &y1, &x2, &y2);
345
SDLTest_AssertCheck(intersected == SDL_TRUE, "Check that intersection result was SDL_TRUE");
347
intersected = SDL_GetRectAndLineIntersection((SDL_Rect *)NULL, &x1, &y1, &x2, &y2);
348
SDLTest_AssertCheck(intersected == SDL_FALSE, "Check that function returns SDL_FALSE when 1st parameter is NULL");
349
intersected = SDL_GetRectAndLineIntersection(&rect, (int *)NULL, &y1, &x2, &y2);
350
SDLTest_AssertCheck(intersected == SDL_FALSE, "Check that function returns SDL_FALSE when 2nd parameter is NULL");
351
intersected = SDL_GetRectAndLineIntersection(&rect, &x1, (int *)NULL, &x2, &y2);
352
SDLTest_AssertCheck(intersected == SDL_FALSE, "Check that function returns SDL_FALSE when 3rd parameter is NULL");
353
intersected = SDL_GetRectAndLineIntersection(&rect, &x1, &y1, (int *)NULL, &y2);
354
SDLTest_AssertCheck(intersected == SDL_FALSE, "Check that function returns SDL_FALSE when 4th parameter is NULL");
355
intersected = SDL_GetRectAndLineIntersection(&rect, &x1, &y1, &x2, (int *)NULL);
356
SDLTest_AssertCheck(intersected == SDL_FALSE, "Check that function returns SDL_FALSE when 5th parameter is NULL");
357
intersected = SDL_GetRectAndLineIntersection((SDL_Rect *)NULL, (int *)NULL, (int *)NULL, (int *)NULL, (int *)NULL);
358
SDLTest_AssertCheck(intersected == SDL_FALSE, "Check that function returns SDL_FALSE when all parameters are NULL");
360
return TEST_COMPLETED;
366
static void validateHasIntersectionFloatResults(
367
SDL_bool intersection, SDL_bool expectedIntersection,
368
SDL_FRect *rectA, SDL_FRect *rectB)
370
SDLTest_AssertCheck(intersection == expectedIntersection,
371
"Check intersection result: expected %s, got %s intersecting A (%.2f,%.2f,%.2f,%.2f) with B (%.2f,%.2f,%.2f,%.2f)",
372
(expectedIntersection == SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE",
373
(intersection == SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE",
374
rectA->x, rectA->y, rectA->w, rectA->h,
375
rectB->x, rectB->y, rectB->w, rectB->h);
381
static void validateHasIntersectionResults(
382
SDL_bool intersection, SDL_bool expectedIntersection,
383
SDL_Rect *rectA, SDL_Rect *rectB, SDL_Rect *refRectA, SDL_Rect *refRectB)
385
SDLTest_AssertCheck(intersection == expectedIntersection,
386
"Check intersection result: expected %s, got %s intersecting A (%d,%d,%d,%d) with B (%d,%d,%d,%d)",
387
(expectedIntersection == SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE",
388
(intersection == SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE",
389
rectA->x, rectA->y, rectA->w, rectA->h,
390
rectB->x, rectB->y, rectB->w, rectB->h);
391
SDLTest_AssertCheck(rectA->x == refRectA->x && rectA->y == refRectA->y && rectA->w == refRectA->w && rectA->h == refRectA->h,
392
"Check that source rectangle A was not modified: got (%d,%d,%d,%d) expected (%d,%d,%d,%d)",
393
rectA->x, rectA->y, rectA->w, rectA->h,
394
refRectA->x, refRectA->y, refRectA->w, refRectA->h);
395
SDLTest_AssertCheck(rectB->x == refRectB->x && rectB->y == refRectB->y && rectB->w == refRectB->w && rectB->h == refRectB->h,
396
"Check that source rectangle B was not modified: got (%d,%d,%d,%d) expected (%d,%d,%d,%d)",
397
rectB->x, rectB->y, rectB->w, rectB->h,
398
refRectB->x, refRectB->y, refRectB->w, refRectB->h);
404
static void validateIntersectRectFloatResults(
405
SDL_bool intersection, SDL_bool expectedIntersection,
406
SDL_FRect *rectA, SDL_FRect *rectB,
407
SDL_FRect *result, SDL_FRect *expectedResult)
409
validateHasIntersectionFloatResults(intersection, expectedIntersection, rectA, rectB);
410
if (result && expectedResult) {
411
SDLTest_AssertCheck(result->x == expectedResult->x && result->y == expectedResult->y && result->w == expectedResult->w && result->h == expectedResult->h,
412
"Check that intersection of rectangles A (%.2f,%.2f, %.2fx%.2f) and B (%.2f,%.2f %.2fx%.2f) was correctly calculated, got (%.2f,%.2f %.2fx%.2f) expected (%.2f,%.2f,%.2f,%.2f)",
413
rectA->x, rectA->y, rectA->w, rectA->h,
414
rectB->x, rectB->y, rectB->w, rectB->h,
415
result->x, result->y, result->w, result->h,
416
expectedResult->x, expectedResult->y, expectedResult->w, expectedResult->h);
418
SDLTest_AssertCheck(intersection == SDL_HasRectIntersectionFloat(rectA, rectB),
419
"Check that intersection (%s) matches SDL_HasRectIntersectionFloat() result (%s)",
420
intersection ? "SDL_TRUE" : "SDL_FALSE",
421
SDL_HasRectIntersectionFloat(rectA, rectB) ? "SDL_TRUE" : "SDL_FALSE");
427
static void validateIntersectRectResults(
428
SDL_bool intersection, SDL_bool expectedIntersection,
429
SDL_Rect *rectA, SDL_Rect *rectB, SDL_Rect *refRectA, SDL_Rect *refRectB,
430
SDL_Rect *result, SDL_Rect *expectedResult)
432
validateHasIntersectionResults(intersection, expectedIntersection, rectA, rectB, refRectA, refRectB);
433
if (result && expectedResult) {
434
SDLTest_AssertCheck(result->x == expectedResult->x && result->y == expectedResult->y && result->w == expectedResult->w && result->h == expectedResult->h,
435
"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)",
436
rectA->x, rectA->y, rectA->w, rectA->h,
437
rectB->x, rectB->y, rectB->w, rectB->h,
438
result->x, result->y, result->w, result->h,
439
expectedResult->x, expectedResult->y, expectedResult->w, expectedResult->h);
446
static void validateUnionRectResults(
447
SDL_Rect *rectA, SDL_Rect *rectB, SDL_Rect *refRectA, SDL_Rect *refRectB,
448
SDL_Rect *result, SDL_Rect *expectedResult)
450
SDLTest_AssertCheck(rectA->x == refRectA->x && rectA->y == refRectA->y && rectA->w == refRectA->w && rectA->h == refRectA->h,
451
"Check that source rectangle A was not modified: got (%d,%d,%d,%d) expected (%d,%d,%d,%d)",
452
rectA->x, rectA->y, rectA->w, rectA->h,
453
refRectA->x, refRectA->y, refRectA->w, refRectA->h);
454
SDLTest_AssertCheck(rectB->x == refRectB->x && rectB->y == refRectB->y && rectB->w == refRectB->w && rectB->h == refRectB->h,
455
"Check that source rectangle B was not modified: got (%d,%d,%d,%d) expected (%d,%d,%d,%d)",
456
rectB->x, rectB->y, rectB->w, rectB->h,
457
refRectB->x, refRectB->y, refRectB->w, refRectB->h);
458
SDLTest_AssertCheck(result->x == expectedResult->x && result->y == expectedResult->y && result->w == expectedResult->w && result->h == expectedResult->h,
459
"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)",
460
rectA->x, rectA->y, rectA->w, rectA->h,
461
rectB->x, rectB->y, rectB->w, rectB->h,
462
result->x, result->y, result->w, result->h,
463
expectedResult->x, expectedResult->y, expectedResult->w, expectedResult->h);
469
static void validateRectEmptyFloatResults(
470
SDL_bool empty, SDL_bool expectedEmpty,
473
SDLTest_AssertCheck(empty == expectedEmpty,
474
"Check for correct empty result: expected %s, got %s testing (%.2f,%.2f,%.2f,%.2f)",
475
(expectedEmpty == SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE",
476
(empty == SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE",
477
rect->x, rect->y, rect->w, rect->h);
483
static void validateRectEmptyResults(
484
SDL_bool empty, SDL_bool expectedEmpty,
485
SDL_Rect *rect, SDL_Rect *refRect)
487
SDLTest_AssertCheck(empty == expectedEmpty,
488
"Check for correct empty result: expected %s, got %s testing (%d,%d,%d,%d)",
489
(expectedEmpty == SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE",
490
(empty == SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE",
491
rect->x, rect->y, rect->w, rect->h);
492
SDLTest_AssertCheck(rect->x == refRect->x && rect->y == refRect->y && rect->w == refRect->w && rect->h == refRect->h,
493
"Check that source rectangle was not modified: got (%d,%d,%d,%d) expected (%d,%d,%d,%d)",
494
rect->x, rect->y, rect->w, rect->h,
495
refRect->x, refRect->y, refRect->w, refRect->h);
501
static void validateRectEqualsResults(
502
SDL_bool equals, SDL_bool expectedEquals,
503
SDL_Rect *rectA, SDL_Rect *rectB, SDL_Rect *refRectA, SDL_Rect *refRectB)
505
SDLTest_AssertCheck(equals == expectedEquals,
506
"Check for correct equals result: expected %s, got %s testing (%d,%d,%d,%d) and (%d,%d,%d,%d)",
507
(expectedEquals == SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE",
508
(equals == SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE",
509
rectA->x, rectA->y, rectA->w, rectA->h,
510
rectB->x, rectB->y, rectB->w, rectB->h);
511
SDLTest_AssertCheck(rectA->x == refRectA->x && rectA->y == refRectA->y && rectA->w == refRectA->w && rectA->h == refRectA->h,
512
"Check that source rectangle A was not modified: got (%d,%d,%d,%d) expected (%d,%d,%d,%d)",
513
rectA->x, rectA->y, rectA->w, rectA->h,
514
refRectA->x, refRectA->y, refRectA->w, refRectA->h);
515
SDLTest_AssertCheck(rectB->x == refRectB->x && rectB->y == refRectB->y && rectB->w == refRectB->w && rectB->h == refRectB->h,
516
"Check that source rectangle B was not modified: got (%d,%d,%d,%d) expected (%d,%d,%d,%d)",
517
rectB->x, rectB->y, rectB->w, rectB->h,
518
refRectB->x, refRectB->y, refRectB->w, refRectB->h);
524
static void validateFRectEqualsResults(
525
SDL_bool equals, SDL_bool expectedEquals,
526
SDL_FRect *rectA, SDL_FRect *rectB, SDL_FRect *refRectA, SDL_FRect *refRectB)
529
SDLTest_AssertCheck(equals == expectedEquals,
530
"Check for correct equals result: expected %s, got %s testing (%f,%f,%f,%f) and (%f,%f,%f,%f)",
531
(expectedEquals == SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE",
532
(equals == SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE",
533
rectA->x, rectA->y, rectA->w, rectA->h,
534
rectB->x, rectB->y, rectB->w, rectB->h);
535
cmpRes = SDL_memcmp(rectA, refRectA, sizeof(*rectA));
536
SDLTest_AssertCheck(cmpRes == 0,
537
"Check that source rectangle A was not modified: got (%f,%f,%f,%f) expected (%f,%f,%f,%f)",
538
rectA->x, rectA->y, rectA->w, rectA->h,
539
refRectA->x, refRectA->y, refRectA->w, refRectA->h);
540
cmpRes = SDL_memcmp(rectB, refRectB, sizeof(*rectB));
541
SDLTest_AssertCheck(cmpRes == 0,
542
"Check that source rectangle B was not modified: got (%f,%f,%f,%f) expected (%f,%f,%f,%f)",
543
rectB->x, rectB->y, rectB->w, rectB->h,
544
refRectB->x, refRectB->y, refRectB->w, refRectB->h);
552
static int rect_testIntersectRectFloat(void *arg)
557
SDL_FRect expectedResult;
558
SDL_bool intersection;
568
expectedResult = rectA;
569
intersection = SDL_GetRectIntersectionFloat(&rectA, &rectB, &result);
570
validateIntersectRectFloatResults(intersection, SDL_TRUE, &rectA, &rectB, &result, &expectedResult);
580
expectedResult = rectB;
581
expectedResult.w = 0.0f;
582
intersection = SDL_GetRectIntersectionFloat(&rectA, &rectB, &result);
583
validateIntersectRectFloatResults(intersection, SDL_TRUE, &rectA, &rectB, &result, &expectedResult);
593
expectedResult = rectB;
594
expectedResult.w = 0.0f;
595
expectedResult.h = 0.0f;
596
intersection = SDL_GetRectIntersectionFloat(&rectA, &rectB, &result);
597
validateIntersectRectFloatResults(intersection, SDL_TRUE, &rectA, &rectB, &result, &expectedResult);
607
expectedResult = rectB;
608
expectedResult.w = -1.0f;
609
intersection = SDL_GetRectIntersectionFloat(&rectA, &rectB, &result);
610
validateIntersectRectFloatResults(intersection, SDL_FALSE, &rectA, &rectB, &result, &expectedResult);
612
return TEST_COMPLETED;
620
static int rect_testIntersectRectInside(void *arg)
622
SDL_Rect refRectA = { 0, 0, 32, 32 };
627
SDL_bool intersection;
632
refRectB.w = SDLTest_RandomIntegerInRange(refRectA.x + 1, refRectA.x + refRectA.w - 1);
633
refRectB.h = SDLTest_RandomIntegerInRange(refRectA.y + 1, refRectA.y + refRectA.h - 1);
636
intersection = SDL_GetRectIntersection(&rectA, &rectB, &result);
637
validateIntersectRectResults(intersection, SDL_TRUE, &rectA, &rectB, &refRectA, &refRectB, &result, &refRectB);
639
return TEST_COMPLETED;
647
static int rect_testIntersectRectOutside(void *arg)
649
SDL_Rect refRectA = { 0, 0, 32, 32 };
654
SDL_bool intersection;
657
refRectB.x = refRectA.x + refRectA.w + SDLTest_RandomIntegerInRange(1, 10);
658
refRectB.y = refRectA.y + refRectA.h + SDLTest_RandomIntegerInRange(1, 10);
659
refRectB.w = refRectA.w;
660
refRectB.h = refRectA.h;
663
intersection = SDL_GetRectIntersection(&rectA, &rectB, &result);
664
validateIntersectRectResults(intersection, SDL_FALSE, &rectA, &rectB, &refRectA, &refRectB, (SDL_Rect *)NULL, (SDL_Rect *)NULL);
666
return TEST_COMPLETED;
674
static int rect_testIntersectRectPartial(void *arg)
676
SDL_Rect refRectA = { 0, 0, 32, 32 };
681
SDL_Rect expectedResult;
682
SDL_bool intersection;
685
refRectB.x = SDLTest_RandomIntegerInRange(refRectA.x + 1, refRectA.x + refRectA.w - 1);
686
refRectB.y = SDLTest_RandomIntegerInRange(refRectA.y + 1, refRectA.y + refRectA.h - 1);
687
refRectB.w = refRectA.w;
688
refRectB.h = refRectA.h;
691
expectedResult.x = refRectB.x;
692
expectedResult.y = refRectB.y;
693
expectedResult.w = refRectA.w - refRectB.x;
694
expectedResult.h = refRectA.h - refRectB.y;
695
intersection = SDL_GetRectIntersection(&rectA, &rectB, &result);
696
validateIntersectRectResults(intersection, SDL_TRUE, &rectA, &rectB, &refRectA, &refRectB, &result, &expectedResult);
699
refRectB.x = rectA.w - 1;
700
refRectB.y = rectA.y;
701
refRectB.w = SDLTest_RandomIntegerInRange(1, refRectA.w - 1);
702
refRectB.h = SDLTest_RandomIntegerInRange(1, refRectA.h - 1);
705
expectedResult.x = refRectB.x;
706
expectedResult.y = refRectB.y;
707
expectedResult.w = 1;
708
expectedResult.h = refRectB.h;
709
intersection = SDL_GetRectIntersection(&rectA, &rectB, &result);
710
validateIntersectRectResults(intersection, SDL_TRUE, &rectA, &rectB, &refRectA, &refRectB, &result, &expectedResult);
713
refRectB.x = 1 - rectA.w;
714
refRectB.y = rectA.y;
715
refRectB.w = refRectA.w;
716
refRectB.h = SDLTest_RandomIntegerInRange(1, refRectA.h - 1);
719
expectedResult.x = 0;
720
expectedResult.y = refRectB.y;
721
expectedResult.w = 1;
722
expectedResult.h = refRectB.h;
723
intersection = SDL_GetRectIntersection(&rectA, &rectB, &result);
724
validateIntersectRectResults(intersection, SDL_TRUE, &rectA, &rectB, &refRectA, &refRectB, &result, &expectedResult);
727
refRectB.x = rectA.x;
728
refRectB.y = rectA.h - 1;
729
refRectB.w = SDLTest_RandomIntegerInRange(1, refRectA.w - 1);
730
refRectB.h = SDLTest_RandomIntegerInRange(1, refRectA.h - 1);
733
expectedResult.x = refRectB.x;
734
expectedResult.y = refRectB.y;
735
expectedResult.w = refRectB.w;
736
expectedResult.h = 1;
737
intersection = SDL_GetRectIntersection(&rectA, &rectB, &result);
738
validateIntersectRectResults(intersection, SDL_TRUE, &rectA, &rectB, &refRectA, &refRectB, &result, &expectedResult);
741
refRectB.x = rectA.x;
742
refRectB.y = 1 - rectA.h;
743
refRectB.w = SDLTest_RandomIntegerInRange(1, refRectA.w - 1);
744
refRectB.h = rectA.h;
747
expectedResult.x = refRectB.x;
748
expectedResult.y = 0;
749
expectedResult.w = refRectB.w;
750
expectedResult.h = 1;
751
intersection = SDL_GetRectIntersection(&rectA, &rectB, &result);
752
validateIntersectRectResults(intersection, SDL_TRUE, &rectA, &rectB, &refRectA, &refRectB, &result, &expectedResult);
754
return TEST_COMPLETED;
762
static int rect_testIntersectRectPoint(void *arg)
764
SDL_Rect refRectA = { 0, 0, 1, 1 };
765
SDL_Rect refRectB = { 0, 0, 1, 1 };
769
SDL_bool intersection;
770
int offsetX, offsetY;
773
refRectA.x = SDLTest_RandomIntegerInRange(1, 100);
774
refRectA.y = SDLTest_RandomIntegerInRange(1, 100);
775
refRectB.x = refRectA.x;
776
refRectB.y = refRectA.y;
779
intersection = SDL_GetRectIntersection(&rectA, &rectB, &result);
780
validateIntersectRectResults(intersection, SDL_TRUE, &rectA, &rectB, &refRectA, &refRectB, &result, &refRectA);
783
for (offsetX = -1; offsetX <= 1; offsetX++) {
784
for (offsetY = -1; offsetY <= 1; offsetY++) {
785
if (offsetX != 0 || offsetY != 0) {
786
refRectA.x = SDLTest_RandomIntegerInRange(1, 100);
787
refRectA.y = SDLTest_RandomIntegerInRange(1, 100);
788
refRectB.x = refRectA.x;
789
refRectB.y = refRectA.y;
790
refRectB.x += offsetX;
791
refRectB.y += offsetY;
794
intersection = SDL_GetRectIntersection(&rectA, &rectB, &result);
795
validateIntersectRectResults(intersection, SDL_FALSE, &rectA, &rectB, &refRectA, &refRectB, (SDL_Rect *)NULL, (SDL_Rect *)NULL);
800
return TEST_COMPLETED;
808
static int rect_testIntersectRectEmpty(void *arg)
815
SDL_bool intersection;
819
result.w = SDLTest_RandomIntegerInRange(1, 100);
820
result.h = SDLTest_RandomIntegerInRange(1, 100);
821
refRectA.x = SDLTest_RandomIntegerInRange(1, 100);
822
refRectA.y = SDLTest_RandomIntegerInRange(1, 100);
823
refRectA.w = SDLTest_RandomIntegerInRange(1, 100);
824
refRectA.h = SDLTest_RandomIntegerInRange(1, 100);
830
intersection = SDL_GetRectIntersection(&rectA, &rectB, &result);
831
validateIntersectRectResults(intersection, SDL_FALSE, &rectA, &rectB, &refRectA, &refRectB, (SDL_Rect *)NULL, (SDL_Rect *)NULL);
832
empty = SDL_RectEmpty(&result);
833
SDLTest_AssertCheck(empty == SDL_TRUE, "Validate result is empty Rect; got: %s", (empty == SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE");
836
result.w = SDLTest_RandomIntegerInRange(1, 100);
837
result.h = SDLTest_RandomIntegerInRange(1, 100);
838
refRectA.x = SDLTest_RandomIntegerInRange(1, 100);
839
refRectA.y = SDLTest_RandomIntegerInRange(1, 100);
840
refRectA.w = SDLTest_RandomIntegerInRange(1, 100);
841
refRectA.h = SDLTest_RandomIntegerInRange(1, 100);
847
intersection = SDL_GetRectIntersection(&rectA, &rectB, &result);
848
validateIntersectRectResults(intersection, SDL_FALSE, &rectA, &rectB, &refRectA, &refRectB, (SDL_Rect *)NULL, (SDL_Rect *)NULL);
849
empty = SDL_RectEmpty(&result);
850
SDLTest_AssertCheck(empty == SDL_TRUE, "Validate result is empty Rect; got: %s", (empty == SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE");
853
result.w = SDLTest_RandomIntegerInRange(1, 100);
854
result.h = SDLTest_RandomIntegerInRange(1, 100);
855
refRectA.x = SDLTest_RandomIntegerInRange(1, 100);
856
refRectA.y = SDLTest_RandomIntegerInRange(1, 100);
857
refRectA.w = SDLTest_RandomIntegerInRange(1, 100);
858
refRectA.h = SDLTest_RandomIntegerInRange(1, 100);
866
intersection = SDL_GetRectIntersection(&rectA, &rectB, &result);
867
validateIntersectRectResults(intersection, SDL_FALSE, &rectA, &rectB, &refRectA, &refRectB, (SDL_Rect *)NULL, (SDL_Rect *)NULL);
868
empty = SDL_RectEmpty(&result);
869
SDLTest_AssertCheck(empty == SDL_TRUE, "Validate result is empty Rect; got: %s", (empty == SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE");
871
return TEST_COMPLETED;
879
static int rect_testIntersectRectParam(void *arg)
882
SDL_Rect rectB = { 0 };
884
SDL_bool intersection;
887
intersection = SDL_GetRectIntersection((SDL_Rect *)NULL, &rectB, &result);
888
SDLTest_AssertCheck(intersection == SDL_FALSE, "Check that function returns SDL_FALSE when 1st parameter is NULL");
889
intersection = SDL_GetRectIntersection(&rectA, (SDL_Rect *)NULL, &result);
890
SDLTest_AssertCheck(intersection == SDL_FALSE, "Check that function returns SDL_FALSE when 2nd parameter is NULL");
891
intersection = SDL_GetRectIntersection(&rectA, &rectB, (SDL_Rect *)NULL);
892
SDLTest_AssertCheck(intersection == SDL_FALSE, "Check that function returns SDL_FALSE when 3rd parameter is NULL");
893
intersection = SDL_GetRectIntersection((SDL_Rect *)NULL, (SDL_Rect *)NULL, &result);
894
SDLTest_AssertCheck(intersection == SDL_FALSE, "Check that function returns SDL_FALSE when 1st and 2nd parameters are NULL");
895
intersection = SDL_GetRectIntersection((SDL_Rect *)NULL, &rectB, (SDL_Rect *)NULL);
896
SDLTest_AssertCheck(intersection == SDL_FALSE, "Check that function returns SDL_FALSE when 1st and 3rd parameters are NULL ");
897
intersection = SDL_GetRectIntersection((SDL_Rect *)NULL, (SDL_Rect *)NULL, (SDL_Rect *)NULL);
898
SDLTest_AssertCheck(intersection == SDL_FALSE, "Check that function returns SDL_FALSE when all parameters are NULL");
900
return TEST_COMPLETED;
908
static int rect_testHasIntersectionInside(void *arg)
910
SDL_Rect refRectA = { 0, 0, 32, 32 };
914
SDL_bool intersection;
919
refRectB.w = SDLTest_RandomIntegerInRange(refRectA.x + 1, refRectA.x + refRectA.w - 1);
920
refRectB.h = SDLTest_RandomIntegerInRange(refRectA.y + 1, refRectA.y + refRectA.h - 1);
923
intersection = SDL_HasRectIntersection(&rectA, &rectB);
924
validateHasIntersectionResults(intersection, SDL_TRUE, &rectA, &rectB, &refRectA, &refRectB);
926
return TEST_COMPLETED;
934
static int rect_testHasIntersectionOutside(void *arg)
936
SDL_Rect refRectA = { 0, 0, 32, 32 };
940
SDL_bool intersection;
943
refRectB.x = refRectA.x + refRectA.w + SDLTest_RandomIntegerInRange(1, 10);
944
refRectB.y = refRectA.y + refRectA.h + SDLTest_RandomIntegerInRange(1, 10);
945
refRectB.w = refRectA.w;
946
refRectB.h = refRectA.h;
949
intersection = SDL_HasRectIntersection(&rectA, &rectB);
950
validateHasIntersectionResults(intersection, SDL_FALSE, &rectA, &rectB, &refRectA, &refRectB);
952
return TEST_COMPLETED;
960
static int rect_testHasIntersectionPartial(void *arg)
962
SDL_Rect refRectA = { 0, 0, 32, 32 };
966
SDL_bool intersection;
969
refRectB.x = SDLTest_RandomIntegerInRange(refRectA.x + 1, refRectA.x + refRectA.w - 1);
970
refRectB.y = SDLTest_RandomIntegerInRange(refRectA.y + 1, refRectA.y + refRectA.h - 1);
971
refRectB.w = refRectA.w;
972
refRectB.h = refRectA.h;
975
intersection = SDL_HasRectIntersection(&rectA, &rectB);
976
validateHasIntersectionResults(intersection, SDL_TRUE, &rectA, &rectB, &refRectA, &refRectB);
979
refRectB.x = rectA.w - 1;
980
refRectB.y = rectA.y;
981
refRectB.w = SDLTest_RandomIntegerInRange(1, refRectA.w - 1);
982
refRectB.h = SDLTest_RandomIntegerInRange(1, refRectA.h - 1);
985
intersection = SDL_HasRectIntersection(&rectA, &rectB);
986
validateHasIntersectionResults(intersection, SDL_TRUE, &rectA, &rectB, &refRectA, &refRectB);
989
refRectB.x = 1 - rectA.w;
990
refRectB.y = rectA.y;
991
refRectB.w = refRectA.w;
992
refRectB.h = SDLTest_RandomIntegerInRange(1, refRectA.h - 1);
995
intersection = SDL_HasRectIntersection(&rectA, &rectB);
996
validateHasIntersectionResults(intersection, SDL_TRUE, &rectA, &rectB, &refRectA, &refRectB);
999
refRectB.x = rectA.x;
1000
refRectB.y = rectA.h - 1;
1001
refRectB.w = SDLTest_RandomIntegerInRange(1, refRectA.w - 1);
1002
refRectB.h = SDLTest_RandomIntegerInRange(1, refRectA.h - 1);
1005
intersection = SDL_HasRectIntersection(&rectA, &rectB);
1006
validateHasIntersectionResults(intersection, SDL_TRUE, &rectA, &rectB, &refRectA, &refRectB);
1009
refRectB.x = rectA.x;
1010
refRectB.y = 1 - rectA.h;
1011
refRectB.w = SDLTest_RandomIntegerInRange(1, refRectA.w - 1);
1012
refRectB.h = rectA.h;
1015
intersection = SDL_HasRectIntersection(&rectA, &rectB);
1016
validateHasIntersectionResults(intersection, SDL_TRUE, &rectA, &rectB, &refRectA, &refRectB);
1018
return TEST_COMPLETED;
1026
static int rect_testHasIntersectionPoint(void *arg)
1028
SDL_Rect refRectA = { 0, 0, 1, 1 };
1029
SDL_Rect refRectB = { 0, 0, 1, 1 };
1032
SDL_bool intersection;
1033
int offsetX, offsetY;
1036
refRectA.x = SDLTest_RandomIntegerInRange(1, 100);
1037
refRectA.y = SDLTest_RandomIntegerInRange(1, 100);
1038
refRectB.x = refRectA.x;
1039
refRectB.y = refRectA.y;
1042
intersection = SDL_HasRectIntersection(&rectA, &rectB);
1043
validateHasIntersectionResults(intersection, SDL_TRUE, &rectA, &rectB, &refRectA, &refRectB);
1046
for (offsetX = -1; offsetX <= 1; offsetX++) {
1047
for (offsetY = -1; offsetY <= 1; offsetY++) {
1048
if (offsetX != 0 || offsetY != 0) {
1049
refRectA.x = SDLTest_RandomIntegerInRange(1, 100);
1050
refRectA.y = SDLTest_RandomIntegerInRange(1, 100);
1051
refRectB.x = refRectA.x;
1052
refRectB.y = refRectA.y;
1053
refRectB.x += offsetX;
1054
refRectB.y += offsetY;
1057
intersection = SDL_HasRectIntersection(&rectA, &rectB);
1058
validateHasIntersectionResults(intersection, SDL_FALSE, &rectA, &rectB, &refRectA, &refRectB);
1063
return TEST_COMPLETED;
1071
static int rect_testHasIntersectionEmpty(void *arg)
1077
SDL_bool intersection;
1080
refRectA.x = SDLTest_RandomIntegerInRange(1, 100);
1081
refRectA.y = SDLTest_RandomIntegerInRange(1, 100);
1082
refRectA.w = SDLTest_RandomIntegerInRange(1, 100);
1083
refRectA.h = SDLTest_RandomIntegerInRange(1, 100);
1084
refRectB = refRectA;
1089
intersection = SDL_HasRectIntersection(&rectA, &rectB);
1090
validateHasIntersectionResults(intersection, SDL_FALSE, &rectA, &rectB, &refRectA, &refRectB);
1093
refRectA.x = SDLTest_RandomIntegerInRange(1, 100);
1094
refRectA.y = SDLTest_RandomIntegerInRange(1, 100);
1095
refRectA.w = SDLTest_RandomIntegerInRange(1, 100);
1096
refRectA.h = SDLTest_RandomIntegerInRange(1, 100);
1097
refRectB = refRectA;
1102
intersection = SDL_HasRectIntersection(&rectA, &rectB);
1103
validateHasIntersectionResults(intersection, SDL_FALSE, &rectA, &rectB, &refRectA, &refRectB);
1106
refRectA.x = SDLTest_RandomIntegerInRange(1, 100);
1107
refRectA.y = SDLTest_RandomIntegerInRange(1, 100);
1108
refRectA.w = SDLTest_RandomIntegerInRange(1, 100);
1109
refRectA.h = SDLTest_RandomIntegerInRange(1, 100);
1110
refRectB = refRectA;
1117
intersection = SDL_HasRectIntersection(&rectA, &rectB);
1118
validateHasIntersectionResults(intersection, SDL_FALSE, &rectA, &rectB, &refRectA, &refRectB);
1120
return TEST_COMPLETED;
1128
static int rect_testHasIntersectionParam(void *arg)
1131
SDL_Rect rectB = { 0 };
1132
SDL_bool intersection;
1135
intersection = SDL_HasRectIntersection((SDL_Rect *)NULL, &rectB);
1136
SDLTest_AssertCheck(intersection == SDL_FALSE, "Check that function returns SDL_FALSE when 1st parameter is NULL");
1137
intersection = SDL_HasRectIntersection(&rectA, (SDL_Rect *)NULL);
1138
SDLTest_AssertCheck(intersection == SDL_FALSE, "Check that function returns SDL_FALSE when 2nd parameter is NULL");
1139
intersection = SDL_HasRectIntersection((SDL_Rect *)NULL, (SDL_Rect *)NULL);
1140
SDLTest_AssertCheck(intersection == SDL_FALSE, "Check that function returns SDL_FALSE when all parameters are NULL");
1142
return TEST_COMPLETED;
1150
static int rect_testEnclosePointsFloat(void *arg)
1152
SDL_FPoint fpts[3] = { { 1.25f, 2.5f }, { 1.75f, 3.75f }, { 3.5f, 3.0f } };
1154
SDL_FRect clip = { 0.0f, 1.0f, 4.0f, 4.0f };
1157
SDL_GetRectEnclosingPointsFloat(fpts, count, &clip, &result);
1158
SDLTest_AssertCheck(result.x == 1.25f && result.y == 2.5f && result.w == 2.25f && result.h == 1.25f,
1159
"Resulting enclosing rectangle incorrect: expected (%.2f,%.2f - %.2fx%.2f), actual (%.2f,%.2f - %.2fx%.2f)",
1160
1.25f, 2.5f, 2.25f, 1.25f, result.x, result.y, result.w, result.h);
1161
for (i = 0; i != count; i++) {
1164
inside = SDL_PointInRectFloat(&fpts[i], &clip);
1165
SDLTest_AssertCheck(inside,
1166
"Expected point (%.2f,%.2f) to be inside clip rect (%.2f,%.2f - %.2fx%.2f)",
1167
fpts[i].x, fpts[i].y, clip.x, clip.y, clip.w, clip.h);
1169
inside = SDL_PointInRectFloat(&fpts[i], &result);
1170
SDLTest_AssertCheck(inside,
1171
"Expected point (%.2f,%.2f) to be inside result rect (%.2f,%.2f - %.2fx%.2f)",
1172
fpts[i].x, fpts[i].y, result.x, result.y, result.w, result.h);
1175
return TEST_COMPLETED;
1183
static int rect_testEnclosePoints(void *arg)
1185
const int numPoints = 16;
1186
SDL_Point refPoints[16];
1187
SDL_Point points[16];
1189
SDL_bool anyEnclosed;
1190
SDL_bool anyEnclosedNoResult;
1191
SDL_bool expectedEnclosed = SDL_TRUE;
1193
int minx = 0, maxx = 0, miny = 0, maxy = 0;
1197
for (i = 0; i < numPoints; i++) {
1198
newx = SDLTest_RandomIntegerInRange(-1024, 1024);
1199
newy = SDLTest_RandomIntegerInRange(-1024, 1024);
1200
refPoints[i].x = newx;
1201
refPoints[i].y = newy;
1226
anyEnclosedNoResult = SDL_GetRectEnclosingPoints(points, numPoints, NULL, (SDL_Rect *)NULL);
1227
SDLTest_AssertCheck(expectedEnclosed == anyEnclosedNoResult,
1228
"Check expected return value %s, got %s",
1229
(expectedEnclosed == SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE",
1230
(anyEnclosedNoResult == SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE");
1231
for (i = 0; i < numPoints; i++) {
1232
SDLTest_AssertCheck(refPoints[i].x == points[i].x && refPoints[i].y == points[i].y,
1233
"Check that source point %i was not modified: expected (%i,%i) actual (%i,%i)",
1234
i, refPoints[i].x, refPoints[i].y, points[i].x, points[i].y);
1238
anyEnclosed = SDL_GetRectEnclosingPoints(points, numPoints, NULL, &result);
1239
SDLTest_AssertCheck(expectedEnclosed == anyEnclosed,
1240
"Check return value %s, got %s",
1241
(expectedEnclosed == SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE",
1242
(anyEnclosed == SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE");
1243
for (i = 0; i < numPoints; i++) {
1244
SDLTest_AssertCheck(refPoints[i].x == points[i].x && refPoints[i].y == points[i].y,
1245
"Check that source point %i was not modified: expected (%i,%i) actual (%i,%i)",
1246
i, refPoints[i].x, refPoints[i].y, points[i].x, points[i].y);
1248
SDLTest_AssertCheck(result.x == minx && result.y == miny && result.w == (maxx - minx + 1) && result.h == (maxy - miny + 1),
1249
"Resulting enclosing rectangle incorrect: expected (%i,%i - %i,%i), actual (%i,%i - %i,%i)",
1250
minx, miny, maxx, maxy, result.x, result.y, result.x + result.w - 1, result.y + result.h - 1);
1252
return TEST_COMPLETED;
1260
static int rect_testEnclosePointsRepeatedInput(void *arg)
1262
const int numPoints = 8;
1263
const int halfPoints = 4;
1264
SDL_Point refPoints[8];
1265
SDL_Point points[8];
1267
SDL_bool anyEnclosed;
1268
SDL_bool anyEnclosedNoResult;
1269
SDL_bool expectedEnclosed = SDL_TRUE;
1271
int minx = 0, maxx = 0, miny = 0, maxy = 0;
1275
for (i = 0; i < numPoints; i++) {
1276
if (i < halfPoints) {
1277
newx = SDLTest_RandomIntegerInRange(-1024, 1024);
1278
newy = SDLTest_RandomIntegerInRange(-1024, 1024);
1280
newx = refPoints[i - halfPoints].x;
1281
newy = refPoints[i - halfPoints].y;
1283
refPoints[i].x = newx;
1284
refPoints[i].y = newy;
1309
anyEnclosedNoResult = SDL_GetRectEnclosingPoints(points, numPoints, NULL, (SDL_Rect *)NULL);
1310
SDLTest_AssertCheck(expectedEnclosed == anyEnclosedNoResult,
1311
"Check return value %s, got %s",
1312
(expectedEnclosed == SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE",
1313
(anyEnclosedNoResult == SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE");
1314
for (i = 0; i < numPoints; i++) {
1315
SDLTest_AssertCheck(refPoints[i].x == points[i].x && refPoints[i].y == points[i].y,
1316
"Check that source point %i was not modified: expected (%i,%i) actual (%i,%i)",
1317
i, refPoints[i].x, refPoints[i].y, points[i].x, points[i].y);
1321
anyEnclosed = SDL_GetRectEnclosingPoints(points, numPoints, NULL, &result);
1322
SDLTest_AssertCheck(expectedEnclosed == anyEnclosed,
1323
"Check return value %s, got %s",
1324
(expectedEnclosed == SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE",
1325
(anyEnclosed == SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE");
1326
for (i = 0; i < numPoints; i++) {
1327
SDLTest_AssertCheck(refPoints[i].x == points[i].x && refPoints[i].y == points[i].y,
1328
"Check that source point %i was not modified: expected (%i,%i) actual (%i,%i)",
1329
i, refPoints[i].x, refPoints[i].y, points[i].x, points[i].y);
1331
SDLTest_AssertCheck(result.x == minx && result.y == miny && result.w == (maxx - minx + 1) && result.h == (maxy - miny + 1),
1332
"Check resulting enclosing rectangle: expected (%i,%i - %i,%i), actual (%i,%i - %i,%i)",
1333
minx, miny, maxx, maxy, result.x, result.y, result.x + result.w - 1, result.y + result.h - 1);
1335
return TEST_COMPLETED;
1343
static int rect_testEnclosePointsWithClipping(void *arg)
1345
const int numPoints = 16;
1346
SDL_Point refPoints[16];
1347
SDL_Point points[16];
1351
SDL_bool anyEnclosed;
1352
SDL_bool anyEnclosedNoResult;
1353
SDL_bool expectedEnclosed = SDL_FALSE;
1355
int minx = 0, maxx = 0, miny = 0, maxy = 0;
1359
refClip.x = SDLTest_RandomIntegerInRange(-1024, 1024);
1360
refClip.y = SDLTest_RandomIntegerInRange(-1024, 1024);
1361
refClip.w = SDLTest_RandomIntegerInRange(1, 1024);
1362
refClip.h = SDLTest_RandomIntegerInRange(1, 1024);
1365
for (i = 0; i < numPoints; i++) {
1366
newx = SDLTest_RandomIntegerInRange(-1024, 1024);
1367
newy = SDLTest_RandomIntegerInRange(-1024, 1024);
1368
refPoints[i].x = newx;
1369
refPoints[i].y = newy;
1372
if ((newx >= refClip.x) && (newx < (refClip.x + refClip.w)) &&
1373
(newy >= refClip.y) && (newy < (refClip.y + refClip.h))) {
1374
if (expectedEnclosed == SDL_FALSE) {
1393
expectedEnclosed = SDL_TRUE;
1399
anyEnclosedNoResult = SDL_GetRectEnclosingPoints(points, numPoints, &clip, NULL);
1400
SDLTest_AssertCheck(expectedEnclosed == anyEnclosedNoResult,
1401
"Expected return value %s, got %s",
1402
(expectedEnclosed == SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE",
1403
(anyEnclosedNoResult == SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE");
1404
for (i = 0; i < numPoints; i++) {
1405
SDLTest_AssertCheck(refPoints[i].x == points[i].x && refPoints[i].y == points[i].y,
1406
"Check that source point %i was not modified: expected (%i,%i) actual (%i,%i)",
1407
i, refPoints[i].x, refPoints[i].y, points[i].x, points[i].y);
1409
SDLTest_AssertCheck(refClip.x == clip.x && refClip.y == clip.y && refClip.w == clip.w && refClip.h == clip.h,
1410
"Check that source clipping rectangle was not modified");
1413
anyEnclosed = SDL_GetRectEnclosingPoints(points, numPoints, &clip, &result);
1414
SDLTest_AssertCheck(expectedEnclosed == anyEnclosed,
1415
"Check return value %s, got %s",
1416
(expectedEnclosed == SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE",
1417
(anyEnclosed == SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE");
1418
for (i = 0; i < numPoints; i++) {
1419
SDLTest_AssertCheck(refPoints[i].x == points[i].x && refPoints[i].y == points[i].y,
1420
"Check that source point %i was not modified: expected (%i,%i) actual (%i,%i)",
1421
i, refPoints[i].x, refPoints[i].y, points[i].x, points[i].y);
1423
SDLTest_AssertCheck(refClip.x == clip.x && refClip.y == clip.y && refClip.w == clip.w && refClip.h == clip.h,
1424
"Check that source clipping rectangle was not modified");
1425
if (expectedEnclosed == SDL_TRUE) {
1426
SDLTest_AssertCheck(result.x == minx && result.y == miny && result.w == (maxx - minx + 1) && result.h == (maxy - miny + 1),
1427
"Check resulting enclosing rectangle: expected (%i,%i - %i,%i), actual (%i,%i - %i,%i)",
1428
minx, miny, maxx, maxy, result.x, result.y, result.x + result.w - 1, result.y + result.h - 1);
1434
expectedEnclosed = SDL_FALSE;
1435
anyEnclosed = SDL_GetRectEnclosingPoints(points, numPoints, &clip, &result);
1436
SDLTest_AssertCheck(expectedEnclosed == anyEnclosed,
1437
"Check return value %s, got %s",
1438
(expectedEnclosed == SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE",
1439
(anyEnclosed == SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE");
1441
return TEST_COMPLETED;
1449
static int rect_testEnclosePointsParam(void *arg)
1451
SDL_Point points[1];
1453
SDL_Rect clip = { 0 };
1455
SDL_bool anyEnclosed;
1458
anyEnclosed = SDL_GetRectEnclosingPoints((SDL_Point *)NULL, 1, &clip, &result);
1459
SDLTest_AssertCheck(anyEnclosed == SDL_FALSE, "Check that functions returns SDL_FALSE when 1st parameter is NULL");
1460
anyEnclosed = SDL_GetRectEnclosingPoints(points, 0, &clip, &result);
1461
SDLTest_AssertCheck(anyEnclosed == SDL_FALSE, "Check that functions returns SDL_FALSE when 2nd parameter is 0");
1462
count = SDLTest_RandomIntegerInRange(-100, -1);
1463
anyEnclosed = SDL_GetRectEnclosingPoints(points, count, &clip, &result);
1464
SDLTest_AssertCheck(anyEnclosed == SDL_FALSE, "Check that functions returns SDL_FALSE when 2nd parameter is %i (negative)", count);
1465
anyEnclosed = SDL_GetRectEnclosingPoints((SDL_Point *)NULL, 0, &clip, &result);
1466
SDLTest_AssertCheck(anyEnclosed == SDL_FALSE, "Check that functions returns SDL_FALSE when 1st parameter is NULL and 2nd parameter was 0");
1468
return TEST_COMPLETED;
1476
static int rect_testUnionRectOutside(void *arg)
1478
SDL_Rect refRectA, refRectB;
1479
SDL_Rect rectA, rectB;
1480
SDL_Rect expectedResult;
1482
int minx, maxx, miny, maxy;
1486
for (dx = -1; dx < 2; dx++) {
1487
for (dy = -1; dy < 2; dy++) {
1488
if ((dx != 0) || (dy != 0)) {
1489
refRectA.x = SDLTest_RandomIntegerInRange(-1024, 1024);
1490
refRectA.y = SDLTest_RandomIntegerInRange(-1024, 1024);
1493
refRectB.x = SDLTest_RandomIntegerInRange(-1024, 1024) + dx * 2048;
1494
refRectB.y = SDLTest_RandomIntegerInRange(-1024, 1024) + dx * 2048;
1497
minx = (refRectA.x < refRectB.x) ? refRectA.x : refRectB.x;
1498
maxx = (refRectA.x > refRectB.x) ? refRectA.x : refRectB.x;
1499
miny = (refRectA.y < refRectB.y) ? refRectA.y : refRectB.y;
1500
maxy = (refRectA.y > refRectB.y) ? refRectA.y : refRectB.y;
1501
expectedResult.x = minx;
1502
expectedResult.y = miny;
1503
expectedResult.w = maxx - minx + 1;
1504
expectedResult.h = maxy - miny + 1;
1507
SDL_GetRectUnion(&rectA, &rectB, &result);
1508
validateUnionRectResults(&rectA, &rectB, &refRectA, &refRectB, &result, &expectedResult);
1514
for (dx = -1; dx < 2; dx++) {
1515
for (dy = -1; dy < 2; dy++) {
1516
if ((dx != 0) || (dy != 0)) {
1517
refRectA.x = SDLTest_RandomIntegerInRange(-1024, 1024);
1518
refRectA.y = SDLTest_RandomIntegerInRange(-1024, 1024);
1519
refRectA.w = SDLTest_RandomIntegerInRange(256, 512);
1520
refRectA.h = SDLTest_RandomIntegerInRange(256, 512);
1521
refRectB.x = refRectA.x + 1 + dx * 2;
1522
refRectB.y = refRectA.y + 1 + dy * 2;
1523
refRectB.w = refRectA.w - 2;
1524
refRectB.h = refRectA.h - 2;
1525
expectedResult = refRectA;
1532
if ((dx == 1) || (dx == -1)) {
1535
if ((dy == 1) || (dy == -1)) {
1540
SDL_GetRectUnion(&rectA, &rectB, &result);
1541
validateUnionRectResults(&rectA, &rectB, &refRectA, &refRectB, &result, &expectedResult);
1546
return TEST_COMPLETED;
1554
static int rect_testUnionRectEmpty(void *arg)
1556
SDL_Rect refRectA, refRectB;
1557
SDL_Rect rectA, rectB;
1558
SDL_Rect expectedResult;
1562
refRectA.x = SDLTest_RandomIntegerInRange(-1024, 1024);
1563
refRectA.y = SDLTest_RandomIntegerInRange(-1024, 1024);
1566
refRectB.x = SDLTest_RandomIntegerInRange(-1024, 1024);
1567
refRectB.y = SDLTest_RandomIntegerInRange(-1024, 1024);
1568
refRectB.w = SDLTest_RandomIntegerInRange(1, 1024);
1569
refRectB.h = SDLTest_RandomIntegerInRange(1, 1024);
1570
expectedResult = refRectB;
1573
SDL_GetRectUnion(&rectA, &rectB, &result);
1574
validateUnionRectResults(&rectA, &rectB, &refRectA, &refRectB, &result, &expectedResult);
1577
refRectA.x = SDLTest_RandomIntegerInRange(-1024, 1024);
1578
refRectA.y = SDLTest_RandomIntegerInRange(-1024, 1024);
1579
refRectA.w = SDLTest_RandomIntegerInRange(1, 1024);
1580
refRectA.h = SDLTest_RandomIntegerInRange(1, 1024);
1581
refRectB.x = SDLTest_RandomIntegerInRange(-1024, 1024);
1582
refRectB.y = SDLTest_RandomIntegerInRange(-1024, 1024);
1585
expectedResult = refRectA;
1588
SDL_GetRectUnion(&rectA, &rectB, &result);
1589
validateUnionRectResults(&rectA, &rectB, &refRectA, &refRectB, &result, &expectedResult);
1592
refRectA.x = SDLTest_RandomIntegerInRange(-1024, 1024);
1593
refRectA.y = SDLTest_RandomIntegerInRange(-1024, 1024);
1596
refRectB.x = SDLTest_RandomIntegerInRange(-1024, 1024);
1597
refRectB.y = SDLTest_RandomIntegerInRange(-1024, 1024);
1604
expectedResult = result;
1607
SDL_GetRectUnion(&rectA, &rectB, &result);
1608
validateUnionRectResults(&rectA, &rectB, &refRectA, &refRectB, &result, &expectedResult);
1610
return TEST_COMPLETED;
1618
static int rect_testUnionRectInside(void *arg)
1620
SDL_Rect refRectA, refRectB;
1621
SDL_Rect rectA, rectB;
1622
SDL_Rect expectedResult;
1627
refRectA.x = SDLTest_RandomIntegerInRange(-1024, 1024);
1628
refRectA.y = SDLTest_RandomIntegerInRange(-1024, 1024);
1631
expectedResult = refRectA;
1633
SDL_GetRectUnion(&rectA, &rectA, &result);
1634
validateUnionRectResults(&rectA, &rectA, &refRectA, &refRectA, &result, &expectedResult);
1637
refRectA.x = SDLTest_RandomIntegerInRange(-1024, 1024);
1638
refRectA.y = SDLTest_RandomIntegerInRange(-1024, 1024);
1639
refRectA.w = SDLTest_RandomIntegerInRange(256, 1024);
1640
refRectA.h = SDLTest_RandomIntegerInRange(256, 1024);
1641
refRectB.x = refRectA.x + 1 + SDLTest_RandomIntegerInRange(1, refRectA.w - 2);
1642
refRectB.y = refRectA.y + 1 + SDLTest_RandomIntegerInRange(1, refRectA.h - 2);
1645
expectedResult = refRectA;
1648
SDL_GetRectUnion(&rectA, &rectB, &result);
1649
validateUnionRectResults(&rectA, &rectB, &refRectA, &refRectB, &result, &expectedResult);
1652
for (dx = -1; dx < 2; dx++) {
1653
for (dy = -1; dy < 2; dy++) {
1654
if ((dx != 0) || (dy != 0)) {
1655
refRectA.x = SDLTest_RandomIntegerInRange(-1024, 1024);
1656
refRectA.y = SDLTest_RandomIntegerInRange(-1024, 1024);
1657
refRectA.w = SDLTest_RandomIntegerInRange(256, 1024);
1658
refRectA.h = SDLTest_RandomIntegerInRange(256, 1024);
1659
refRectB = refRectA;
1663
if ((dx == 1) || (dx == -1)) {
1669
if ((dy == 1) || (dy == -1)) {
1672
expectedResult = refRectA;
1675
SDL_GetRectUnion(&rectA, &rectB, &result);
1676
validateUnionRectResults(&rectA, &rectB, &refRectA, &refRectB, &result, &expectedResult);
1681
return TEST_COMPLETED;
1689
static int rect_testUnionRectParam(void *arg)
1691
SDL_Rect rectA, rectB = { 0 };
1695
SDL_GetRectUnion((SDL_Rect *)NULL, &rectB, &result);
1696
SDLTest_AssertPass("Check that function returns when 1st parameter is NULL");
1697
SDL_GetRectUnion(&rectA, (SDL_Rect *)NULL, &result);
1698
SDLTest_AssertPass("Check that function returns when 2nd parameter is NULL");
1699
SDL_GetRectUnion(&rectA, &rectB, (SDL_Rect *)NULL);
1700
SDLTest_AssertPass("Check that function returns when 3rd parameter is NULL");
1701
SDL_GetRectUnion((SDL_Rect *)NULL, &rectB, (SDL_Rect *)NULL);
1702
SDLTest_AssertPass("Check that function returns when 1st and 3rd parameter are NULL");
1703
SDL_GetRectUnion(&rectA, (SDL_Rect *)NULL, (SDL_Rect *)NULL);
1704
SDLTest_AssertPass("Check that function returns when 2nd and 3rd parameter are NULL");
1705
SDL_GetRectUnion((SDL_Rect *)NULL, (SDL_Rect *)NULL, (SDL_Rect *)NULL);
1706
SDLTest_AssertPass("Check that function returns when all parameters are NULL");
1708
return TEST_COMPLETED;
1716
static int rect_testRectEmptyFloat(void *arg)
1725
result = SDL_RectEmptyFloat(&rect);
1726
validateRectEmptyFloatResults(result, SDL_FALSE, &rect);
1732
result = SDL_RectEmptyFloat(&rect);
1733
validateRectEmptyFloatResults(result, SDL_FALSE, &rect);
1739
result = SDL_RectEmptyFloat(&rect);
1740
validateRectEmptyFloatResults(result, SDL_TRUE, &rect);
1746
result = SDL_RectEmptyFloat(&rect);
1747
validateRectEmptyFloatResults(result, SDL_TRUE, &rect);
1750
return TEST_COMPLETED;
1758
static int rect_testRectEmpty(void *arg)
1762
SDL_bool expectedResult;
1767
refRect.x = SDLTest_RandomIntegerInRange(-1024, 1024);
1768
refRect.y = SDLTest_RandomIntegerInRange(-1024, 1024);
1769
refRect.w = SDLTest_RandomIntegerInRange(256, 1024);
1770
refRect.h = SDLTest_RandomIntegerInRange(256, 1024);
1771
expectedResult = SDL_FALSE;
1773
result = SDL_RectEmpty(&rect);
1774
validateRectEmptyResults(result, expectedResult, &rect, &refRect);
1777
for (w = -1; w < 2; w++) {
1778
for (h = -1; h < 2; h++) {
1779
if ((w != 1) || (h != 1)) {
1780
refRect.x = SDLTest_RandomIntegerInRange(-1024, 1024);
1781
refRect.y = SDLTest_RandomIntegerInRange(-1024, 1024);
1784
expectedResult = SDL_TRUE;
1786
result = SDL_RectEmpty(&rect);
1787
validateRectEmptyResults(result, expectedResult, &rect, &refRect);
1792
return TEST_COMPLETED;
1800
static int rect_testRectEmptyParam(void *arg)
1805
result = SDL_RectEmpty(NULL);
1806
SDLTest_AssertCheck(result == SDL_TRUE, "Check that function returns TRUE when 1st parameter is NULL");
1808
return TEST_COMPLETED;
1816
static int rect_testRectEquals(void *arg)
1822
SDL_bool expectedResult;
1826
refRectA.x = SDLTest_RandomIntegerInRange(-1024, 1024);
1827
refRectA.y = SDLTest_RandomIntegerInRange(-1024, 1024);
1828
refRectA.w = SDLTest_RandomIntegerInRange(1, 1024);
1829
refRectA.h = SDLTest_RandomIntegerInRange(1, 1024);
1830
refRectB = refRectA;
1831
expectedResult = SDL_TRUE;
1834
result = SDL_RectsEqual(&rectA, &rectB);
1835
validateRectEqualsResults(result, expectedResult, &rectA, &rectB, &refRectA, &refRectB);
1837
return TEST_COMPLETED;
1845
static int rect_testRectEqualsParam(void *arg)
1852
rectA.x = SDLTest_RandomIntegerInRange(-1024, 1024);
1853
rectA.y = SDLTest_RandomIntegerInRange(-1024, 1024);
1854
rectA.w = SDLTest_RandomIntegerInRange(1, 1024);
1855
rectA.h = SDLTest_RandomIntegerInRange(1, 1024);
1856
rectB.x = SDLTest_RandomIntegerInRange(-1024, 1024);
1857
rectB.y = SDLTest_RandomIntegerInRange(-1024, 1024);
1858
rectB.w = SDLTest_RandomIntegerInRange(1, 1024);
1859
rectB.h = SDLTest_RandomIntegerInRange(1, 1024);
1862
result = SDL_RectsEqual(NULL, &rectB);
1863
SDLTest_AssertCheck(result == SDL_FALSE, "Check that function returns SDL_FALSE when 1st parameter is NULL");
1864
result = SDL_RectsEqual(&rectA, NULL);
1865
SDLTest_AssertCheck(result == SDL_FALSE, "Check that function returns SDL_FALSE when 2nd parameter is NULL");
1866
result = SDL_RectsEqual(NULL, NULL);
1867
SDLTest_AssertCheck(result == SDL_FALSE, "Check that function returns SDL_FALSE when 1st and 2nd parameter are NULL");
1869
return TEST_COMPLETED;
1877
static int rect_testFRectEquals(void *arg)
1883
SDL_bool expectedResult;
1887
refRectA.x = (float)SDLTest_RandomIntegerInRange(-1024, 1024);
1888
refRectA.y = (float)SDLTest_RandomIntegerInRange(-1024, 1024);
1889
refRectA.w = (float)SDLTest_RandomIntegerInRange(1, 1024);
1890
refRectA.h = (float)SDLTest_RandomIntegerInRange(1, 1024);
1891
refRectB = refRectA;
1892
expectedResult = SDL_TRUE;
1895
result = SDL_RectsEqualFloat(&rectA, &rectB);
1896
validateFRectEqualsResults(result, expectedResult, &rectA, &rectB, &refRectA, &refRectB);
1898
return TEST_COMPLETED;
1906
static int rect_testFRectEqualsParam(void *arg)
1913
rectA.x = SDLTest_RandomFloat();
1914
rectA.y = SDLTest_RandomFloat();
1915
rectA.w = SDLTest_RandomFloat();
1916
rectA.h = SDLTest_RandomFloat();
1917
rectB.x = SDLTest_RandomFloat();
1918
rectB.y = SDLTest_RandomFloat();
1919
rectB.w = SDLTest_RandomFloat();
1920
rectB.h = SDLTest_RandomFloat();
1923
result = SDL_RectsEqualFloat(NULL, &rectB);
1924
SDLTest_AssertCheck(result == SDL_FALSE, "Check that function returns SDL_FALSE when 1st parameter is NULL");
1925
result = SDL_RectsEqualFloat(&rectA, NULL);
1926
SDLTest_AssertCheck(result == SDL_FALSE, "Check that function returns SDL_FALSE when 2nd parameter is NULL");
1927
result = SDL_RectsEqualFloat(NULL, NULL);
1928
SDLTest_AssertCheck(result == SDL_FALSE, "Check that function returns SDL_FALSE when 1st and 2nd parameter are NULL");
1930
return TEST_COMPLETED;
1938
static const SDLTest_TestCaseReference rectTestIntersectRectAndLineFloat = {
1939
(SDLTest_TestCaseFp)rect_testIntersectRectAndLineFloat, "rect_testIntersectRectAndLineFloat", "Tests SDL_GetRectAndLineIntersectionFloat", TEST_ENABLED
1943
static const SDLTest_TestCaseReference rectTestIntersectRectAndLine = {
1944
(SDLTest_TestCaseFp)rect_testIntersectRectAndLine, "rect_testIntersectRectAndLine", "Tests SDL_GetRectAndLineIntersection clipping cases", TEST_ENABLED
1947
static const SDLTest_TestCaseReference rectTestIntersectRectAndLineInside = {
1948
(SDLTest_TestCaseFp)rect_testIntersectRectAndLineInside, "rect_testIntersectRectAndLineInside", "Tests SDL_GetRectAndLineIntersection with line fully contained in rect", TEST_ENABLED
1951
static const SDLTest_TestCaseReference rectTestIntersectRectAndLineOutside = {
1952
(SDLTest_TestCaseFp)rect_testIntersectRectAndLineOutside, "rect_testIntersectRectAndLineOutside", "Tests SDL_GetRectAndLineIntersection with line fully outside of rect", TEST_ENABLED
1955
static const SDLTest_TestCaseReference rectTestIntersectRectAndLineEmpty = {
1956
(SDLTest_TestCaseFp)rect_testIntersectRectAndLineEmpty, "rect_testIntersectRectAndLineEmpty", "Tests SDL_GetRectAndLineIntersection with empty rectangle ", TEST_ENABLED
1959
static const SDLTest_TestCaseReference rectTestIntersectRectAndLineParam = {
1960
(SDLTest_TestCaseFp)rect_testIntersectRectAndLineParam, "rect_testIntersectRectAndLineParam", "Negative tests against SDL_GetRectAndLineIntersection with invalid parameters", TEST_ENABLED
1964
static const SDLTest_TestCaseReference rectTestIntersectRectFloat = {
1965
(SDLTest_TestCaseFp)rect_testIntersectRectFloat, "rect_testIntersectRectFloat", "Tests SDL_GetRectIntersectionFloat", TEST_ENABLED
1969
static const SDLTest_TestCaseReference rectTestIntersectRectInside = {
1970
(SDLTest_TestCaseFp)rect_testIntersectRectInside, "rect_testIntersectRectInside", "Tests SDL_GetRectIntersection with B fully contained in A", TEST_ENABLED
1973
static const SDLTest_TestCaseReference rectTestIntersectRectOutside = {
1974
(SDLTest_TestCaseFp)rect_testIntersectRectOutside, "rect_testIntersectRectOutside", "Tests SDL_GetRectIntersection with B fully outside of A", TEST_ENABLED
1977
static const SDLTest_TestCaseReference rectTestIntersectRectPartial = {
1978
(SDLTest_TestCaseFp)rect_testIntersectRectPartial, "rect_testIntersectRectPartial", "Tests SDL_GetRectIntersection with B partially intersecting A", TEST_ENABLED
1981
static const SDLTest_TestCaseReference rectTestIntersectRectPoint = {
1982
(SDLTest_TestCaseFp)rect_testIntersectRectPoint, "rect_testIntersectRectPoint", "Tests SDL_GetRectIntersection with 1x1 sized rectangles", TEST_ENABLED
1985
static const SDLTest_TestCaseReference rectTestIntersectRectEmpty = {
1986
(SDLTest_TestCaseFp)rect_testIntersectRectEmpty, "rect_testIntersectRectEmpty", "Tests SDL_GetRectIntersection with empty rectangles", TEST_ENABLED
1989
static const SDLTest_TestCaseReference rectTestIntersectRectParam = {
1990
(SDLTest_TestCaseFp)rect_testIntersectRectParam, "rect_testIntersectRectParam", "Negative tests against SDL_GetRectIntersection with invalid parameters", TEST_ENABLED
1994
static const SDLTest_TestCaseReference rectTestHasIntersectionInside = {
1995
(SDLTest_TestCaseFp)rect_testHasIntersectionInside, "rect_testHasIntersectionInside", "Tests SDL_HasRectIntersection with B fully contained in A", TEST_ENABLED
1998
static const SDLTest_TestCaseReference rectTestHasIntersectionOutside = {
1999
(SDLTest_TestCaseFp)rect_testHasIntersectionOutside, "rect_testHasIntersectionOutside", "Tests SDL_HasRectIntersection with B fully outside of A", TEST_ENABLED
2002
static const SDLTest_TestCaseReference rectTestHasIntersectionPartial = {
2003
(SDLTest_TestCaseFp)rect_testHasIntersectionPartial, "rect_testHasIntersectionPartial", "Tests SDL_HasRectIntersection with B partially intersecting A", TEST_ENABLED
2006
static const SDLTest_TestCaseReference rectTestHasIntersectionPoint = {
2007
(SDLTest_TestCaseFp)rect_testHasIntersectionPoint, "rect_testHasIntersectionPoint", "Tests SDL_HasRectIntersection with 1x1 sized rectangles", TEST_ENABLED
2010
static const SDLTest_TestCaseReference rectTestHasIntersectionEmpty = {
2011
(SDLTest_TestCaseFp)rect_testHasIntersectionEmpty, "rect_testHasIntersectionEmpty", "Tests SDL_HasRectIntersection with empty rectangles", TEST_ENABLED
2014
static const SDLTest_TestCaseReference rectTestHasIntersectionParam = {
2015
(SDLTest_TestCaseFp)rect_testHasIntersectionParam, "rect_testHasIntersectionParam", "Negative tests against SDL_HasRectIntersection with invalid parameters", TEST_ENABLED
2019
static const SDLTest_TestCaseReference rectTestEnclosePointsFloat = {
2020
(SDLTest_TestCaseFp)rect_testEnclosePointsFloat, "rect_testEnclosePointsFloat", "Tests SDL_GetRectEnclosingPointsFloat", TEST_ENABLED
2024
static const SDLTest_TestCaseReference rectTestEnclosePoints = {
2025
(SDLTest_TestCaseFp)rect_testEnclosePoints, "rect_testEnclosePoints", "Tests SDL_GetRectEnclosingPoints without clipping", TEST_ENABLED
2028
static const SDLTest_TestCaseReference rectTestEnclosePointsWithClipping = {
2029
(SDLTest_TestCaseFp)rect_testEnclosePointsWithClipping, "rect_testEnclosePointsWithClipping", "Tests SDL_GetRectEnclosingPoints with clipping", TEST_ENABLED
2032
static const SDLTest_TestCaseReference rectTestEnclosePointsRepeatedInput = {
2033
(SDLTest_TestCaseFp)rect_testEnclosePointsRepeatedInput, "rect_testEnclosePointsRepeatedInput", "Tests SDL_GetRectEnclosingPoints with repeated input", TEST_ENABLED
2036
static const SDLTest_TestCaseReference rectTestEnclosePointsParam = {
2037
(SDLTest_TestCaseFp)rect_testEnclosePointsParam, "rect_testEnclosePointsParam", "Negative tests against SDL_GetRectEnclosingPoints with invalid parameters", TEST_ENABLED
2041
static const SDLTest_TestCaseReference rectTestUnionRectInside = {
2042
(SDLTest_TestCaseFp)rect_testUnionRectInside, "rect_testUnionRectInside", "Tests SDL_GetRectUnion where rect B is inside rect A", TEST_ENABLED
2045
static const SDLTest_TestCaseReference rectTestUnionRectOutside = {
2046
(SDLTest_TestCaseFp)rect_testUnionRectOutside, "rect_testUnionRectOutside", "Tests SDL_GetRectUnion where rect B is outside rect A", TEST_ENABLED
2049
static const SDLTest_TestCaseReference rectTestUnionRectEmpty = {
2050
(SDLTest_TestCaseFp)rect_testUnionRectEmpty, "rect_testUnionRectEmpty", "Tests SDL_GetRectUnion where rect A or rect B are empty", TEST_ENABLED
2053
static const SDLTest_TestCaseReference rectTestUnionRectParam = {
2054
(SDLTest_TestCaseFp)rect_testUnionRectParam, "rect_testUnionRectParam", "Negative tests against SDL_GetRectUnion with invalid parameters", TEST_ENABLED
2058
static const SDLTest_TestCaseReference rectTestRectEmptyFloat = {
2059
(SDLTest_TestCaseFp)rect_testRectEmptyFloat, "rect_testRectEmptyFloat", "Tests SDL_RectEmptyFloat with various inputs", TEST_ENABLED
2063
static const SDLTest_TestCaseReference rectTestRectEmpty = {
2064
(SDLTest_TestCaseFp)rect_testRectEmpty, "rect_testRectEmpty", "Tests SDL_RectEmpty with various inputs", TEST_ENABLED
2067
static const SDLTest_TestCaseReference rectTestRectEmptyParam = {
2068
(SDLTest_TestCaseFp)rect_testRectEmptyParam, "rect_testRectEmptyParam", "Negative tests against SDL_RectEmpty with invalid parameters", TEST_ENABLED
2072
static const SDLTest_TestCaseReference rectTestRectEquals = {
2073
(SDLTest_TestCaseFp)rect_testRectEquals, "rect_testRectEquals", "Tests SDL_RectsEqual with various inputs", TEST_ENABLED
2076
static const SDLTest_TestCaseReference rectTestRectEqualsParam = {
2077
(SDLTest_TestCaseFp)rect_testRectEqualsParam, "rect_testRectEqualsParam", "Negative tests against SDL_RectsEqual with invalid parameters", TEST_ENABLED
2081
static const SDLTest_TestCaseReference rectTestFRectEquals = {
2082
(SDLTest_TestCaseFp)rect_testFRectEquals, "rect_testFRectEquals", "Tests SDL_RectsEqualFloat with various inputs", TEST_ENABLED
2085
static const SDLTest_TestCaseReference rectTestFRectEqualsParam = {
2086
(SDLTest_TestCaseFp)rect_testFRectEqualsParam, "rect_testFRectEqualsParam", "Negative tests against SDL_RectsEqualFloat with invalid parameters", TEST_ENABLED
2092
static const SDLTest_TestCaseReference *rectTests[] = {
2093
&rectTestIntersectRectAndLineFloat,
2094
&rectTestIntersectRectAndLine,
2095
&rectTestIntersectRectAndLineInside,
2096
&rectTestIntersectRectAndLineOutside,
2097
&rectTestIntersectRectAndLineEmpty,
2098
&rectTestIntersectRectAndLineParam,
2099
&rectTestIntersectRectFloat,
2100
&rectTestIntersectRectInside,
2101
&rectTestIntersectRectOutside,
2102
&rectTestIntersectRectPartial,
2103
&rectTestIntersectRectPoint,
2104
&rectTestIntersectRectEmpty,
2105
&rectTestIntersectRectParam,
2106
&rectTestHasIntersectionInside,
2107
&rectTestHasIntersectionOutside,
2108
&rectTestHasIntersectionPartial,
2109
&rectTestHasIntersectionPoint,
2110
&rectTestHasIntersectionEmpty,
2111
&rectTestHasIntersectionParam,
2112
&rectTestEnclosePointsFloat,
2113
&rectTestEnclosePoints,
2114
&rectTestEnclosePointsWithClipping,
2115
&rectTestEnclosePointsRepeatedInput,
2116
&rectTestEnclosePointsParam,
2117
&rectTestUnionRectInside,
2118
&rectTestUnionRectOutside,
2119
&rectTestUnionRectEmpty,
2120
&rectTestUnionRectParam,
2121
&rectTestRectEmptyFloat,
2123
&rectTestRectEmptyParam,
2124
&rectTestRectEquals,
2125
&rectTestRectEqualsParam,
2126
&rectTestFRectEquals,
2127
&rectTestFRectEqualsParam,
2132
SDLTest_TestSuiteReference rectTestSuite = {