2015-06-21 18:33:46 +03:00
/**
* Original code : automated SDL rect test written by Edgar Simo " bobbens "
* New / updated tests : aschiffler at ferzkopp dot net
*/
2022-11-27 07:43:38 +03:00
# include <SDL3/SDL.h>
# include <SDL3/SDL_test.h>
2023-03-08 18:12:45 +03:00
# include "testautomation_suites.h"
2015-06-21 18:33:46 +03:00
/* ================= Test Case Implementation ================== */
/* Helper functions */
2023-02-02 02:21:53 +03:00
/**
2022-12-27 22:01:11 +03:00
* \ brief Private helper to check SDL_GetRectAndLineIntersection results
2015-06-21 18:33:46 +03:00
*/
2022-12-30 00:58:16 +03:00
static void validateIntersectRectAndLineResults (
2015-06-21 18:33:46 +03:00
SDL_bool intersection , SDL_bool expectedIntersection ,
2022-11-30 23:51:59 +03:00
SDL_Rect * rect , SDL_Rect * refRect ,
2015-06-21 18:33:46 +03:00
int x1 , int y1 , int x2 , int y2 ,
int x1Ref , int y1Ref , int x2Ref , int y2Ref )
{
SDLTest_AssertCheck ( intersection = = expectedIntersection ,
2022-11-30 23:51:59 +03:00
" Check for correct intersection result: expected %s, got %s intersecting rect (%d,%d,%d,%d) with line (%d,%d - %d,%d) " ,
( expectedIntersection = = SDL_TRUE ) ? " SDL_TRUE " : " SDL_FALSE " ,
( intersection = = SDL_TRUE ) ? " SDL_TRUE " : " SDL_FALSE " ,
refRect - > x , refRect - > y , refRect - > w , refRect - > h ,
x1Ref , y1Ref , x2Ref , y2Ref ) ;
2015-06-21 18:33:46 +03:00
SDLTest_AssertCheck ( rect - > x = = refRect - > x & & rect - > y = = refRect - > y & & rect - > w = = refRect - > w & & rect - > h = = refRect - > h ,
2022-11-30 23:51:59 +03:00
" Check that source rectangle was not modified: got (%d,%d,%d,%d) expected (%d,%d,%d,%d) " ,
rect - > x , rect - > y , rect - > w , rect - > h ,
refRect - > x , refRect - > y , refRect - > w , refRect - > h ) ;
2015-06-21 18:33:46 +03:00
SDLTest_AssertCheck ( x1 = = x1Ref & & y1 = = y1Ref & & x2 = = x2Ref & & y2 = = y2Ref ,
2022-11-30 23:51:59 +03:00
" Check if line was incorrectly clipped or modified: got (%d,%d - %d,%d) expected (%d,%d - %d,%d) " ,
x1 , y1 , x2 , y2 ,
x1Ref , y1Ref , x2Ref , y2Ref ) ;
2015-06-21 18:33:46 +03:00
}
/* Test case functions */
2023-02-02 02:21:53 +03:00
/**
2022-12-27 22:01:11 +03:00
* \ brief Tests SDL_GetRectAndLineIntersection ( ) clipping cases
2015-06-21 18:33:46 +03:00
*
2023-02-02 02:21:53 +03:00
* \ sa SDL_GetRectAndLineIntersection
2015-06-21 18:33:46 +03:00
*/
2023-03-08 18:12:45 +03:00
static int rect_testIntersectRectAndLine ( void * arg )
2015-06-21 18:33:46 +03:00
{
SDL_Rect refRect = { 0 , 0 , 32 , 32 } ;
SDL_Rect rect ;
int x1 , y1 ;
int x2 , y2 ;
SDL_bool intersected ;
int xLeft = - SDLTest_RandomIntegerInRange ( 1 , refRect . w ) ;
int xRight = refRect . w + SDLTest_RandomIntegerInRange ( 1 , refRect . w ) ;
int yTop = - SDLTest_RandomIntegerInRange ( 1 , refRect . h ) ;
int yBottom = refRect . h + SDLTest_RandomIntegerInRange ( 1 , refRect . h ) ;
x1 = xLeft ;
y1 = 15 ;
x2 = xRight ;
y2 = 15 ;
rect = refRect ;
2022-12-27 22:01:11 +03:00
intersected = SDL_GetRectAndLineIntersection ( & rect , & x1 , & y1 , & x2 , & y2 ) ;
2022-12-30 00:58:16 +03:00
validateIntersectRectAndLineResults ( intersected , SDL_TRUE , & rect , & refRect , x1 , y1 , x2 , y2 , 0 , 15 , 31 , 15 ) ;
2015-06-21 18:33:46 +03:00
x1 = 15 ;
y1 = yTop ;
x2 = 15 ;
y2 = yBottom ;
rect = refRect ;
2022-12-27 22:01:11 +03:00
intersected = SDL_GetRectAndLineIntersection ( & rect , & x1 , & y1 , & x2 , & y2 ) ;
2022-12-30 00:58:16 +03:00
validateIntersectRectAndLineResults ( intersected , SDL_TRUE , & rect , & refRect , x1 , y1 , x2 , y2 , 15 , 0 , 15 , 31 ) ;
2015-06-21 18:33:46 +03:00
x1 = - refRect . w ;
y1 = - refRect . h ;
2022-11-30 23:51:59 +03:00
x2 = 2 * refRect . w ;
y2 = 2 * refRect . h ;
2015-06-21 18:33:46 +03:00
rect = refRect ;
2022-12-27 22:01:11 +03:00
intersected = SDL_GetRectAndLineIntersection ( & rect , & x1 , & y1 , & x2 , & y2 ) ;
2022-12-30 00:58:16 +03:00
validateIntersectRectAndLineResults ( intersected , SDL_TRUE , & rect , & refRect , x1 , y1 , x2 , y2 , 0 , 0 , 31 , 31 ) ;
2015-06-21 18:33:46 +03:00
2022-11-30 23:51:59 +03:00
x1 = 2 * refRect . w ;
y1 = 2 * refRect . h ;
2015-06-21 18:33:46 +03:00
x2 = - refRect . w ;
y2 = - refRect . h ;
rect = refRect ;
2022-12-27 22:01:11 +03:00
intersected = SDL_GetRectAndLineIntersection ( & rect , & x1 , & y1 , & x2 , & y2 ) ;
2022-12-30 00:58:16 +03:00
validateIntersectRectAndLineResults ( intersected , SDL_TRUE , & rect , & refRect , x1 , y1 , x2 , y2 , 31 , 31 , 0 , 0 ) ;
2015-06-21 18:33:46 +03:00
x1 = - 1 ;
y1 = 32 ;
x2 = 32 ;
y2 = - 1 ;
rect = refRect ;
2022-12-27 22:01:11 +03:00
intersected = SDL_GetRectAndLineIntersection ( & rect , & x1 , & y1 , & x2 , & y2 ) ;
2022-12-30 00:58:16 +03:00
validateIntersectRectAndLineResults ( intersected , SDL_TRUE , & rect , & refRect , x1 , y1 , x2 , y2 , 0 , 31 , 31 , 0 ) ;
2015-06-21 18:33:46 +03:00
x1 = 32 ;
y1 = - 1 ;
x2 = - 1 ;
y2 = 32 ;
rect = refRect ;
2022-12-27 22:01:11 +03:00
intersected = SDL_GetRectAndLineIntersection ( & rect , & x1 , & y1 , & x2 , & y2 ) ;
2022-12-30 00:58:16 +03:00
validateIntersectRectAndLineResults ( intersected , SDL_TRUE , & rect , & refRect , x1 , y1 , x2 , y2 , 31 , 0 , 0 , 31 ) ;
2015-06-21 18:33:46 +03:00
return TEST_COMPLETED ;
}
2023-02-02 02:21:53 +03:00
/**
2022-12-27 22:01:11 +03:00
* \ brief Tests SDL_GetRectAndLineIntersection ( ) non - clipping case line inside
2015-06-21 18:33:46 +03:00
*
2023-02-02 02:21:53 +03:00
* \ sa SDL_GetRectAndLineIntersection
2015-06-21 18:33:46 +03:00
*/
2023-03-08 18:12:45 +03:00
static int rect_testIntersectRectAndLineInside ( void * arg )
2015-06-21 18:33:46 +03:00
{
SDL_Rect refRect = { 0 , 0 , 32 , 32 } ;
SDL_Rect rect ;
int x1 , y1 ;
int x2 , y2 ;
SDL_bool intersected ;
int xmin = refRect . x ;
int xmax = refRect . x + refRect . w - 1 ;
int ymin = refRect . y ;
int ymax = refRect . y + refRect . h - 1 ;
int x1Ref = SDLTest_RandomIntegerInRange ( xmin + 1 , xmax - 1 ) ;
int y1Ref = SDLTest_RandomIntegerInRange ( ymin + 1 , ymax - 1 ) ;
int x2Ref = SDLTest_RandomIntegerInRange ( xmin + 1 , xmax - 1 ) ;
int y2Ref = SDLTest_RandomIntegerInRange ( ymin + 1 , ymax - 1 ) ;
x1 = x1Ref ;
y1 = y1Ref ;
x2 = x2Ref ;
y2 = y2Ref ;
rect = refRect ;
2022-12-27 22:01:11 +03:00
intersected = SDL_GetRectAndLineIntersection ( & rect , & x1 , & y1 , & x2 , & y2 ) ;
2022-12-30 00:58:16 +03:00
validateIntersectRectAndLineResults ( intersected , SDL_TRUE , & rect , & refRect , x1 , y1 , x2 , y2 , x1Ref , y1Ref , x2Ref , y2Ref ) ;
2015-06-21 18:33:46 +03:00
x1 = x1Ref ;
y1 = y1Ref ;
x2 = xmax ;
y2 = ymax ;
rect = refRect ;
2022-12-27 22:01:11 +03:00
intersected = SDL_GetRectAndLineIntersection ( & rect , & x1 , & y1 , & x2 , & y2 ) ;
2022-12-30 00:58:16 +03:00
validateIntersectRectAndLineResults ( intersected , SDL_TRUE , & rect , & refRect , x1 , y1 , x2 , y2 , x1Ref , y1Ref , xmax , ymax ) ;
2015-06-21 18:33:46 +03:00
x1 = xmin ;
y1 = ymin ;
x2 = x2Ref ;
y2 = y2Ref ;
rect = refRect ;
2022-12-27 22:01:11 +03:00
intersected = SDL_GetRectAndLineIntersection ( & rect , & x1 , & y1 , & x2 , & y2 ) ;
2022-12-30 00:58:16 +03:00
validateIntersectRectAndLineResults ( intersected , SDL_TRUE , & rect , & refRect , x1 , y1 , x2 , y2 , xmin , ymin , x2Ref , y2Ref ) ;
2015-06-21 18:33:46 +03:00
x1 = xmin ;
y1 = ymin ;
x2 = xmax ;
y2 = ymax ;
rect = refRect ;
2022-12-27 22:01:11 +03:00
intersected = SDL_GetRectAndLineIntersection ( & rect , & x1 , & y1 , & x2 , & y2 ) ;
2022-12-30 00:58:16 +03:00
validateIntersectRectAndLineResults ( intersected , SDL_TRUE , & rect , & refRect , x1 , y1 , x2 , y2 , xmin , ymin , xmax , ymax ) ;
2015-06-21 18:33:46 +03:00
x1 = xmin ;
y1 = ymax ;
x2 = xmax ;
y2 = ymin ;
rect = refRect ;
2022-12-27 22:01:11 +03:00
intersected = SDL_GetRectAndLineIntersection ( & rect , & x1 , & y1 , & x2 , & y2 ) ;
2022-12-30 00:58:16 +03:00
validateIntersectRectAndLineResults ( intersected , SDL_TRUE , & rect , & refRect , x1 , y1 , x2 , y2 , xmin , ymax , xmax , ymin ) ;
2015-06-21 18:33:46 +03:00
return TEST_COMPLETED ;
}
2023-02-02 02:21:53 +03:00
/**
2022-12-27 22:01:11 +03:00
* \ brief Tests SDL_GetRectAndLineIntersection ( ) non - clipping cases outside
2015-06-21 18:33:46 +03:00
*
2023-02-02 02:21:53 +03:00
* \ sa SDL_GetRectAndLineIntersection
2015-06-21 18:33:46 +03:00
*/
2023-03-08 18:12:45 +03:00
static int rect_testIntersectRectAndLineOutside ( void * arg )
2015-06-21 18:33:46 +03:00
{
SDL_Rect refRect = { 0 , 0 , 32 , 32 } ;
SDL_Rect rect ;
int x1 , y1 ;
int x2 , y2 ;
SDL_bool intersected ;
int xLeft = - SDLTest_RandomIntegerInRange ( 1 , refRect . w ) ;
int xRight = refRect . w + SDLTest_RandomIntegerInRange ( 1 , refRect . w ) ;
int yTop = - SDLTest_RandomIntegerInRange ( 1 , refRect . h ) ;
int yBottom = refRect . h + SDLTest_RandomIntegerInRange ( 1 , refRect . h ) ;
x1 = xLeft ;
y1 = 0 ;
x2 = xLeft ;
y2 = 31 ;
rect = refRect ;
2022-12-27 22:01:11 +03:00
intersected = SDL_GetRectAndLineIntersection ( & rect , & x1 , & y1 , & x2 , & y2 ) ;
2022-12-30 00:58:16 +03:00
validateIntersectRectAndLineResults ( intersected , SDL_FALSE , & rect , & refRect , x1 , y1 , x2 , y2 , xLeft , 0 , xLeft , 31 ) ;
2015-06-21 18:33:46 +03:00
x1 = xRight ;
y1 = 0 ;
x2 = xRight ;
y2 = 31 ;
rect = refRect ;
2022-12-27 22:01:11 +03:00
intersected = SDL_GetRectAndLineIntersection ( & rect , & x1 , & y1 , & x2 , & y2 ) ;
2022-12-30 00:58:16 +03:00
validateIntersectRectAndLineResults ( intersected , SDL_FALSE , & rect , & refRect , x1 , y1 , x2 , y2 , xRight , 0 , xRight , 31 ) ;
2015-06-21 18:33:46 +03:00
x1 = 0 ;
y1 = yTop ;
x2 = 31 ;
y2 = yTop ;
rect = refRect ;
2022-12-27 22:01:11 +03:00
intersected = SDL_GetRectAndLineIntersection ( & rect , & x1 , & y1 , & x2 , & y2 ) ;
2022-12-30 00:58:16 +03:00
validateIntersectRectAndLineResults ( intersected , SDL_FALSE , & rect , & refRect , x1 , y1 , x2 , y2 , 0 , yTop , 31 , yTop ) ;
2015-06-21 18:33:46 +03:00
x1 = 0 ;
y1 = yBottom ;
x2 = 31 ;
y2 = yBottom ;
rect = refRect ;
2022-12-27 22:01:11 +03:00
intersected = SDL_GetRectAndLineIntersection ( & rect , & x1 , & y1 , & x2 , & y2 ) ;
2022-12-30 00:58:16 +03:00
validateIntersectRectAndLineResults ( intersected , SDL_FALSE , & rect , & refRect , x1 , y1 , x2 , y2 , 0 , yBottom , 31 , yBottom ) ;
2015-06-21 18:33:46 +03:00
return TEST_COMPLETED ;
}
2023-02-02 02:21:53 +03:00
/**
2022-12-27 22:01:11 +03:00
* \ brief Tests SDL_GetRectAndLineIntersection ( ) with empty rectangle
2015-06-21 18:33:46 +03:00
*
2023-02-02 02:21:53 +03:00
* \ sa SDL_GetRectAndLineIntersection
2015-06-21 18:33:46 +03:00
*/
2023-03-08 18:12:45 +03:00
static int rect_testIntersectRectAndLineEmpty ( void * arg )
2015-06-21 18:33:46 +03:00
{
SDL_Rect refRect ;
SDL_Rect rect ;
int x1 , y1 , x1Ref , y1Ref ;
int x2 , y2 , x2Ref , y2Ref ;
SDL_bool intersected ;
refRect . x = SDLTest_RandomIntegerInRange ( 1 , 1024 ) ;
refRect . y = SDLTest_RandomIntegerInRange ( 1 , 1024 ) ;
refRect . w = 0 ;
refRect . h = 0 ;
x1Ref = refRect . x ;
y1Ref = refRect . y ;
x2Ref = SDLTest_RandomIntegerInRange ( 1 , 1024 ) ;
y2Ref = SDLTest_RandomIntegerInRange ( 1 , 1024 ) ;
x1 = x1Ref ;
y1 = y1Ref ;
x2 = x2Ref ;
y2 = y2Ref ;
rect = refRect ;
2022-12-27 22:01:11 +03:00
intersected = SDL_GetRectAndLineIntersection ( & rect , & x1 , & y1 , & x2 , & y2 ) ;
2022-12-30 00:58:16 +03:00
validateIntersectRectAndLineResults ( intersected , SDL_FALSE , & rect , & refRect , x1 , y1 , x2 , y2 , x1Ref , y1Ref , x2Ref , y2Ref ) ;
2015-06-21 18:33:46 +03:00
return TEST_COMPLETED ;
}
2023-02-02 02:21:53 +03:00
/**
2022-12-27 22:01:11 +03:00
* \ brief Negative tests against SDL_GetRectAndLineIntersection ( ) with invalid parameters
2015-06-21 18:33:46 +03:00
*
2023-02-02 02:21:53 +03:00
* \ sa SDL_GetRectAndLineIntersection
2015-06-21 18:33:46 +03:00
*/
2023-03-08 18:12:45 +03:00
static int rect_testIntersectRectAndLineParam ( void * arg )
2015-06-21 18:33:46 +03:00
{
SDL_Rect rect = { 0 , 0 , 32 , 32 } ;
int x1 = rect . w / 2 ;
int y1 = rect . h / 2 ;
int x2 = x1 ;
int y2 = 2 * rect . h ;
SDL_bool intersected ;
2022-12-27 22:01:11 +03:00
intersected = SDL_GetRectAndLineIntersection ( & rect , & x1 , & y1 , & x2 , & y2 ) ;
2015-06-21 18:33:46 +03:00
SDLTest_AssertCheck ( intersected = = SDL_TRUE , " Check that intersection result was SDL_TRUE " ) ;
2022-12-27 22:01:11 +03:00
intersected = SDL_GetRectAndLineIntersection ( ( SDL_Rect * ) NULL , & x1 , & y1 , & x2 , & y2 ) ;
2015-06-21 18:33:46 +03:00
SDLTest_AssertCheck ( intersected = = SDL_FALSE , " Check that function returns SDL_FALSE when 1st parameter is NULL " ) ;
2022-12-27 22:01:11 +03:00
intersected = SDL_GetRectAndLineIntersection ( & rect , ( int * ) NULL , & y1 , & x2 , & y2 ) ;
2015-06-21 18:33:46 +03:00
SDLTest_AssertCheck ( intersected = = SDL_FALSE , " Check that function returns SDL_FALSE when 2nd parameter is NULL " ) ;
2022-12-27 22:01:11 +03:00
intersected = SDL_GetRectAndLineIntersection ( & rect , & x1 , ( int * ) NULL , & x2 , & y2 ) ;
2015-06-21 18:33:46 +03:00
SDLTest_AssertCheck ( intersected = = SDL_FALSE , " Check that function returns SDL_FALSE when 3rd parameter is NULL " ) ;
2022-12-27 22:01:11 +03:00
intersected = SDL_GetRectAndLineIntersection ( & rect , & x1 , & y1 , ( int * ) NULL , & y2 ) ;
2015-06-21 18:33:46 +03:00
SDLTest_AssertCheck ( intersected = = SDL_FALSE , " Check that function returns SDL_FALSE when 4th parameter is NULL " ) ;
2022-12-27 22:01:11 +03:00
intersected = SDL_GetRectAndLineIntersection ( & rect , & x1 , & y1 , & x2 , ( int * ) NULL ) ;
2015-06-21 18:33:46 +03:00
SDLTest_AssertCheck ( intersected = = SDL_FALSE , " Check that function returns SDL_FALSE when 5th parameter is NULL " ) ;
2022-12-27 22:01:11 +03:00
intersected = SDL_GetRectAndLineIntersection ( ( SDL_Rect * ) NULL , ( int * ) NULL , ( int * ) NULL , ( int * ) NULL , ( int * ) NULL ) ;
2015-06-21 18:33:46 +03:00
SDLTest_AssertCheck ( intersected = = SDL_FALSE , " Check that function returns SDL_FALSE when all parameters are NULL " ) ;
return TEST_COMPLETED ;
}
2023-02-02 02:21:53 +03:00
/**
2022-12-27 22:01:11 +03:00
* \ brief Private helper to check SDL_HasRectIntersection results
2015-06-21 18:33:46 +03:00
*/
2022-12-30 00:58:16 +03:00
static void validateHasIntersectionResults (
2015-06-21 18:33:46 +03:00
SDL_bool intersection , SDL_bool expectedIntersection ,
SDL_Rect * rectA , SDL_Rect * rectB , SDL_Rect * refRectA , SDL_Rect * refRectB )
{
SDLTest_AssertCheck ( intersection = = expectedIntersection ,
2022-11-30 23:51:59 +03:00
" Check intersection result: expected %s, got %s intersecting A (%d,%d,%d,%d) with B (%d,%d,%d,%d) " ,
( expectedIntersection = = SDL_TRUE ) ? " SDL_TRUE " : " SDL_FALSE " ,
( intersection = = SDL_TRUE ) ? " SDL_TRUE " : " SDL_FALSE " ,
rectA - > x , rectA - > y , rectA - > w , rectA - > h ,
rectB - > x , rectB - > y , rectB - > w , rectB - > h ) ;
2015-06-21 18:33:46 +03:00
SDLTest_AssertCheck ( rectA - > x = = refRectA - > x & & rectA - > y = = refRectA - > y & & rectA - > w = = refRectA - > w & & rectA - > h = = refRectA - > h ,
2022-11-30 23:51:59 +03:00
" Check that source rectangle A was not modified: got (%d,%d,%d,%d) expected (%d,%d,%d,%d) " ,
rectA - > x , rectA - > y , rectA - > w , rectA - > h ,
refRectA - > x , refRectA - > y , refRectA - > w , refRectA - > h ) ;
2015-06-21 18:33:46 +03:00
SDLTest_AssertCheck ( rectB - > x = = refRectB - > x & & rectB - > y = = refRectB - > y & & rectB - > w = = refRectB - > w & & rectB - > h = = refRectB - > h ,
2022-11-30 23:51:59 +03:00
" Check that source rectangle B was not modified: got (%d,%d,%d,%d) expected (%d,%d,%d,%d) " ,
rectB - > x , rectB - > y , rectB - > w , rectB - > h ,
refRectB - > x , refRectB - > y , refRectB - > w , refRectB - > h ) ;
2015-06-21 18:33:46 +03:00
}
2023-02-02 02:21:53 +03:00
/**
2022-12-27 22:01:11 +03:00
* \ brief Private helper to check SDL_GetRectIntersection results
2015-06-21 18:33:46 +03:00
*/
2022-12-30 00:58:16 +03:00
static void validateIntersectRectResults (
2015-06-21 18:33:46 +03:00
SDL_bool intersection , SDL_bool expectedIntersection ,
SDL_Rect * rectA , SDL_Rect * rectB , SDL_Rect * refRectA , SDL_Rect * refRectB ,
SDL_Rect * result , SDL_Rect * expectedResult )
{
2022-12-30 00:58:16 +03:00
validateHasIntersectionResults ( intersection , expectedIntersection , rectA , rectB , refRectA , refRectB ) ;
2015-06-21 18:33:46 +03:00
if ( result & & expectedResult ) {
SDLTest_AssertCheck ( result - > x = = expectedResult - > x & & result - > y = = expectedResult - > y & & result - > w = = expectedResult - > w & & result - > h = = expectedResult - > h ,
2022-11-30 23:51:59 +03:00
" 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) " ,
rectA - > x , rectA - > y , rectA - > w , rectA - > h ,
rectB - > x , rectB - > y , rectB - > w , rectB - > h ,
result - > x , result - > y , result - > w , result - > h ,
expectedResult - > x , expectedResult - > y , expectedResult - > w , expectedResult - > h ) ;
2015-06-21 18:33:46 +03:00
}
}
2023-02-02 02:21:53 +03:00
/**
2022-12-27 22:01:11 +03:00
* \ brief Private helper to check SDL_GetRectUnion results
2015-06-21 18:33:46 +03:00
*/
2022-12-30 00:58:16 +03:00
static void validateUnionRectResults (
2015-06-21 18:33:46 +03:00
SDL_Rect * rectA , SDL_Rect * rectB , SDL_Rect * refRectA , SDL_Rect * refRectB ,
SDL_Rect * result , SDL_Rect * expectedResult )
{
SDLTest_AssertCheck ( rectA - > x = = refRectA - > x & & rectA - > y = = refRectA - > y & & rectA - > w = = refRectA - > w & & rectA - > h = = refRectA - > h ,
2022-11-30 23:51:59 +03:00
" Check that source rectangle A was not modified: got (%d,%d,%d,%d) expected (%d,%d,%d,%d) " ,
rectA - > x , rectA - > y , rectA - > w , rectA - > h ,
refRectA - > x , refRectA - > y , refRectA - > w , refRectA - > h ) ;
2015-06-21 18:33:46 +03:00
SDLTest_AssertCheck ( rectB - > x = = refRectB - > x & & rectB - > y = = refRectB - > y & & rectB - > w = = refRectB - > w & & rectB - > h = = refRectB - > h ,
2022-11-30 23:51:59 +03:00
" Check that source rectangle B was not modified: got (%d,%d,%d,%d) expected (%d,%d,%d,%d) " ,
rectB - > x , rectB - > y , rectB - > w , rectB - > h ,
refRectB - > x , refRectB - > y , refRectB - > w , refRectB - > h ) ;
2015-06-21 18:33:46 +03:00
SDLTest_AssertCheck ( result - > x = = expectedResult - > x & & result - > y = = expectedResult - > y & & result - > w = = expectedResult - > w & & result - > h = = expectedResult - > h ,
2022-11-30 23:51:59 +03:00
" 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) " ,
rectA - > x , rectA - > y , rectA - > w , rectA - > h ,
rectB - > x , rectB - > y , rectB - > w , rectB - > h ,
result - > x , result - > y , result - > w , result - > h ,
expectedResult - > x , expectedResult - > y , expectedResult - > w , expectedResult - > h ) ;
2015-06-21 18:33:46 +03:00
}
2023-02-02 02:21:53 +03:00
/**
2022-12-29 06:34:01 +03:00
* \ brief Private helper to check SDL_RectEmpty results
2015-06-21 18:33:46 +03:00
*/
2022-12-30 00:58:16 +03:00
static void validateRectEmptyResults (
2015-06-21 18:33:46 +03:00
SDL_bool empty , SDL_bool expectedEmpty ,
SDL_Rect * rect , SDL_Rect * refRect )
{
SDLTest_AssertCheck ( empty = = expectedEmpty ,
2022-11-30 23:51:59 +03:00
" Check for correct empty result: expected %s, got %s testing (%d,%d,%d,%d) " ,
( expectedEmpty = = SDL_TRUE ) ? " SDL_TRUE " : " SDL_FALSE " ,
( empty = = SDL_TRUE ) ? " SDL_TRUE " : " SDL_FALSE " ,
rect - > x , rect - > y , rect - > w , rect - > h ) ;
2015-06-21 18:33:46 +03:00
SDLTest_AssertCheck ( rect - > x = = refRect - > x & & rect - > y = = refRect - > y & & rect - > w = = refRect - > w & & rect - > h = = refRect - > h ,
2022-11-30 23:51:59 +03:00
" Check that source rectangle was not modified: got (%d,%d,%d,%d) expected (%d,%d,%d,%d) " ,
rect - > x , rect - > y , rect - > w , rect - > h ,
refRect - > x , refRect - > y , refRect - > w , refRect - > h ) ;
2015-06-21 18:33:46 +03:00
}
2023-02-02 02:21:53 +03:00
/**
2022-12-29 06:34:01 +03:00
* \ brief Private helper to check SDL_RectsEqual results
2015-06-21 18:33:46 +03:00
*/
2022-12-30 00:58:16 +03:00
static void validateRectEqualsResults (
2015-06-21 18:33:46 +03:00
SDL_bool equals , SDL_bool expectedEquals ,
SDL_Rect * rectA , SDL_Rect * rectB , SDL_Rect * refRectA , SDL_Rect * refRectB )
{
SDLTest_AssertCheck ( equals = = expectedEquals ,
2022-11-30 23:51:59 +03:00
" Check for correct equals result: expected %s, got %s testing (%d,%d,%d,%d) and (%d,%d,%d,%d) " ,
( expectedEquals = = SDL_TRUE ) ? " SDL_TRUE " : " SDL_FALSE " ,
( equals = = SDL_TRUE ) ? " SDL_TRUE " : " SDL_FALSE " ,
rectA - > x , rectA - > y , rectA - > w , rectA - > h ,
rectB - > x , rectB - > y , rectB - > w , rectB - > h ) ;
2015-06-21 18:33:46 +03:00
SDLTest_AssertCheck ( rectA - > x = = refRectA - > x & & rectA - > y = = refRectA - > y & & rectA - > w = = refRectA - > w & & rectA - > h = = refRectA - > h ,
2022-11-30 23:51:59 +03:00
" Check that source rectangle A was not modified: got (%d,%d,%d,%d) expected (%d,%d,%d,%d) " ,
rectA - > x , rectA - > y , rectA - > w , rectA - > h ,
refRectA - > x , refRectA - > y , refRectA - > w , refRectA - > h ) ;
2015-06-21 18:33:46 +03:00
SDLTest_AssertCheck ( rectB - > x = = refRectB - > x & & rectB - > y = = refRectB - > y & & rectB - > w = = refRectB - > w & & rectB - > h = = refRectB - > h ,
2022-11-30 23:51:59 +03:00
" Check that source rectangle B was not modified: got (%d,%d,%d,%d) expected (%d,%d,%d,%d) " ,
rectB - > x , rectB - > y , rectB - > w , rectB - > h ,
refRectB - > x , refRectB - > y , refRectB - > w , refRectB - > h ) ;
2015-06-21 18:33:46 +03:00
}
2023-02-02 02:21:53 +03:00
/**
2022-12-30 01:50:55 +03:00
* \ brief Private helper to check SDL_RectsEqualFloat results
2022-04-20 16:53:25 +03:00
*/
2022-12-30 00:58:16 +03:00
static void validateFRectEqualsResults (
2022-04-20 16:53:25 +03:00
SDL_bool equals , SDL_bool expectedEquals ,
SDL_FRect * rectA , SDL_FRect * rectB , SDL_FRect * refRectA , SDL_FRect * refRectB )
{
int cmpRes ;
SDLTest_AssertCheck ( equals = = expectedEquals ,
2022-11-30 23:51:59 +03:00
" Check for correct equals result: expected %s, got %s testing (%f,%f,%f,%f) and (%f,%f,%f,%f) " ,
( expectedEquals = = SDL_TRUE ) ? " SDL_TRUE " : " SDL_FALSE " ,
( equals = = SDL_TRUE ) ? " SDL_TRUE " : " SDL_FALSE " ,
rectA - > x , rectA - > y , rectA - > w , rectA - > h ,
rectB - > x , rectB - > y , rectB - > w , rectB - > h ) ;
2022-04-20 16:53:25 +03:00
cmpRes = SDL_memcmp ( rectA , refRectA , sizeof ( * rectA ) ) ;
SDLTest_AssertCheck ( cmpRes = = 0 ,
2022-11-30 23:51:59 +03:00
" Check that source rectangle A was not modified: got (%f,%f,%f,%f) expected (%f,%f,%f,%f) " ,
rectA - > x , rectA - > y , rectA - > w , rectA - > h ,
refRectA - > x , refRectA - > y , refRectA - > w , refRectA - > h ) ;
2022-04-20 16:53:25 +03:00
cmpRes = SDL_memcmp ( rectB , refRectB , sizeof ( * rectB ) ) ;
SDLTest_AssertCheck ( cmpRes = = 0 ,
2022-11-30 23:51:59 +03:00
" Check that source rectangle B was not modified: got (%f,%f,%f,%f) expected (%f,%f,%f,%f) " ,
rectB - > x , rectB - > y , rectB - > w , rectB - > h ,
refRectB - > x , refRectB - > y , refRectB - > w , refRectB - > h ) ;
2022-04-20 16:53:25 +03:00
}
2023-02-02 02:21:53 +03:00
/**
2022-12-27 22:01:11 +03:00
* \ brief Tests SDL_GetRectIntersection ( ) with B fully inside A
2015-06-21 18:33:46 +03:00
*
2023-02-02 02:21:53 +03:00
* \ sa SDL_GetRectIntersection
2015-06-21 18:33:46 +03:00
*/
2023-03-08 18:12:45 +03:00
static int rect_testIntersectRectInside ( void * arg )
2015-06-21 18:33:46 +03:00
{
SDL_Rect refRectA = { 0 , 0 , 32 , 32 } ;
SDL_Rect refRectB ;
SDL_Rect rectA ;
SDL_Rect rectB ;
SDL_Rect result ;
SDL_bool intersection ;
/* rectB fully contained in rectA */
refRectB . x = 0 ;
refRectB . y = 0 ;
refRectB . w = SDLTest_RandomIntegerInRange ( refRectA . x + 1 , refRectA . x + refRectA . w - 1 ) ;
refRectB . h = SDLTest_RandomIntegerInRange ( refRectA . y + 1 , refRectA . y + refRectA . h - 1 ) ;
rectA = refRectA ;
rectB = refRectB ;
2022-12-27 22:01:11 +03:00
intersection = SDL_GetRectIntersection ( & rectA , & rectB , & result ) ;
2022-12-30 00:58:16 +03:00
validateIntersectRectResults ( intersection , SDL_TRUE , & rectA , & rectB , & refRectA , & refRectB , & result , & refRectB ) ;
2015-06-21 18:33:46 +03:00
return TEST_COMPLETED ;
}
2023-02-02 02:21:53 +03:00
/**
2022-12-27 22:01:11 +03:00
* \ brief Tests SDL_GetRectIntersection ( ) with B fully outside A
2015-06-21 18:33:46 +03:00
*
2023-02-02 02:21:53 +03:00
* \ sa SDL_GetRectIntersection
2015-06-21 18:33:46 +03:00
*/
2023-03-08 18:12:45 +03:00
static int rect_testIntersectRectOutside ( void * arg )
2015-06-21 18:33:46 +03:00
{
SDL_Rect refRectA = { 0 , 0 , 32 , 32 } ;
SDL_Rect refRectB ;
SDL_Rect rectA ;
SDL_Rect rectB ;
SDL_Rect result ;
SDL_bool intersection ;
/* rectB fully outside of rectA */
refRectB . x = refRectA . x + refRectA . w + SDLTest_RandomIntegerInRange ( 1 , 10 ) ;
refRectB . y = refRectA . y + refRectA . h + SDLTest_RandomIntegerInRange ( 1 , 10 ) ;
refRectB . w = refRectA . w ;
refRectB . h = refRectA . h ;
rectA = refRectA ;
rectB = refRectB ;
2022-12-27 22:01:11 +03:00
intersection = SDL_GetRectIntersection ( & rectA , & rectB , & result ) ;
2022-12-30 00:58:16 +03:00
validateIntersectRectResults ( intersection , SDL_FALSE , & rectA , & rectB , & refRectA , & refRectB , ( SDL_Rect * ) NULL , ( SDL_Rect * ) NULL ) ;
2015-06-21 18:33:46 +03:00
return TEST_COMPLETED ;
}
2023-02-02 02:21:53 +03:00
/**
2022-12-27 22:01:11 +03:00
* \ brief Tests SDL_GetRectIntersection ( ) with B partially intersecting A
2015-06-21 18:33:46 +03:00
*
2023-02-02 02:21:53 +03:00
* \ sa SDL_GetRectIntersection
2015-06-21 18:33:46 +03:00
*/
2023-03-08 18:12:45 +03:00
static int rect_testIntersectRectPartial ( void * arg )
2015-06-21 18:33:46 +03:00
{
SDL_Rect refRectA = { 0 , 0 , 32 , 32 } ;
SDL_Rect refRectB ;
SDL_Rect rectA ;
SDL_Rect rectB ;
SDL_Rect result ;
SDL_Rect expectedResult ;
SDL_bool intersection ;
/* rectB partially contained in rectA */
refRectB . x = SDLTest_RandomIntegerInRange ( refRectA . x + 1 , refRectA . x + refRectA . w - 1 ) ;
refRectB . y = SDLTest_RandomIntegerInRange ( refRectA . y + 1 , refRectA . y + refRectA . h - 1 ) ;
refRectB . w = refRectA . w ;
refRectB . h = refRectA . h ;
rectA = refRectA ;
rectB = refRectB ;
expectedResult . x = refRectB . x ;
expectedResult . y = refRectB . y ;
expectedResult . w = refRectA . w - refRectB . x ;
expectedResult . h = refRectA . h - refRectB . y ;
2022-12-27 22:01:11 +03:00
intersection = SDL_GetRectIntersection ( & rectA , & rectB , & result ) ;
2022-12-30 00:58:16 +03:00
validateIntersectRectResults ( intersection , SDL_TRUE , & rectA , & rectB , & refRectA , & refRectB , & result , & expectedResult ) ;
2015-06-21 18:33:46 +03:00
/* rectB right edge */
refRectB . x = rectA . w - 1 ;
refRectB . y = rectA . y ;
refRectB . w = SDLTest_RandomIntegerInRange ( 1 , refRectA . w - 1 ) ;
refRectB . h = SDLTest_RandomIntegerInRange ( 1 , refRectA . h - 1 ) ;
rectA = refRectA ;
rectB = refRectB ;
expectedResult . x = refRectB . x ;
expectedResult . y = refRectB . y ;
expectedResult . w = 1 ;
expectedResult . h = refRectB . h ;
2022-12-27 22:01:11 +03:00
intersection = SDL_GetRectIntersection ( & rectA , & rectB , & result ) ;
2022-12-30 00:58:16 +03:00
validateIntersectRectResults ( intersection , SDL_TRUE , & rectA , & rectB , & refRectA , & refRectB , & result , & expectedResult ) ;
2015-06-21 18:33:46 +03:00
/* rectB left edge */
refRectB . x = 1 - rectA . w ;
refRectB . y = rectA . y ;
refRectB . w = refRectA . w ;
refRectB . h = SDLTest_RandomIntegerInRange ( 1 , refRectA . h - 1 ) ;
rectA = refRectA ;
rectB = refRectB ;
expectedResult . x = 0 ;
expectedResult . y = refRectB . y ;
expectedResult . w = 1 ;
expectedResult . h = refRectB . h ;
2022-12-27 22:01:11 +03:00
intersection = SDL_GetRectIntersection ( & rectA , & rectB , & result ) ;
2022-12-30 00:58:16 +03:00
validateIntersectRectResults ( intersection , SDL_TRUE , & rectA , & rectB , & refRectA , & refRectB , & result , & expectedResult ) ;
2015-06-21 18:33:46 +03:00
/* rectB bottom edge */
refRectB . x = rectA . x ;
refRectB . y = rectA . h - 1 ;
refRectB . w = SDLTest_RandomIntegerInRange ( 1 , refRectA . w - 1 ) ;
refRectB . h = SDLTest_RandomIntegerInRange ( 1 , refRectA . h - 1 ) ;
rectA = refRectA ;
rectB = refRectB ;
expectedResult . x = refRectB . x ;
expectedResult . y = refRectB . y ;
expectedResult . w = refRectB . w ;
expectedResult . h = 1 ;
2022-12-27 22:01:11 +03:00
intersection = SDL_GetRectIntersection ( & rectA , & rectB , & result ) ;
2022-12-30 00:58:16 +03:00
validateIntersectRectResults ( intersection , SDL_TRUE , & rectA , & rectB , & refRectA , & refRectB , & result , & expectedResult ) ;
2015-06-21 18:33:46 +03:00
/* rectB top edge */
refRectB . x = rectA . x ;
refRectB . y = 1 - rectA . h ;
refRectB . w = SDLTest_RandomIntegerInRange ( 1 , refRectA . w - 1 ) ;
refRectB . h = rectA . h ;
rectA = refRectA ;
rectB = refRectB ;
expectedResult . x = refRectB . x ;
expectedResult . y = 0 ;
expectedResult . w = refRectB . w ;
expectedResult . h = 1 ;
2022-12-27 22:01:11 +03:00
intersection = SDL_GetRectIntersection ( & rectA , & rectB , & result ) ;
2022-12-30 00:58:16 +03:00
validateIntersectRectResults ( intersection , SDL_TRUE , & rectA , & rectB , & refRectA , & refRectB , & result , & expectedResult ) ;
2015-06-21 18:33:46 +03:00
return TEST_COMPLETED ;
}
2023-02-02 02:21:53 +03:00
/**
2022-12-27 22:01:11 +03:00
* \ brief Tests SDL_GetRectIntersection ( ) with 1 x1 pixel sized rectangles
2015-06-21 18:33:46 +03:00
*
2023-02-02 02:21:53 +03:00
* \ sa SDL_GetRectIntersection
2015-06-21 18:33:46 +03:00
*/
2023-03-08 18:12:45 +03:00
static int rect_testIntersectRectPoint ( void * arg )
2015-06-21 18:33:46 +03:00
{
SDL_Rect refRectA = { 0 , 0 , 1 , 1 } ;
SDL_Rect refRectB = { 0 , 0 , 1 , 1 } ;
SDL_Rect rectA ;
SDL_Rect rectB ;
SDL_Rect result ;
SDL_bool intersection ;
int offsetX , offsetY ;
/* intersecting pixels */
refRectA . x = SDLTest_RandomIntegerInRange ( 1 , 100 ) ;
refRectA . y = SDLTest_RandomIntegerInRange ( 1 , 100 ) ;
refRectB . x = refRectA . x ;
refRectB . y = refRectA . y ;
rectA = refRectA ;
rectB = refRectB ;
2022-12-27 22:01:11 +03:00
intersection = SDL_GetRectIntersection ( & rectA , & rectB , & result ) ;
2022-12-30 00:58:16 +03:00
validateIntersectRectResults ( intersection , SDL_TRUE , & rectA , & rectB , & refRectA , & refRectB , & result , & refRectA ) ;
2015-06-21 18:33:46 +03:00
/* non-intersecting pixels cases */
for ( offsetX = - 1 ; offsetX < = 1 ; offsetX + + ) {
for ( offsetY = - 1 ; offsetY < = 1 ; offsetY + + ) {
if ( offsetX ! = 0 | | offsetY ! = 0 ) {
refRectA . x = SDLTest_RandomIntegerInRange ( 1 , 100 ) ;
refRectA . y = SDLTest_RandomIntegerInRange ( 1 , 100 ) ;
refRectB . x = refRectA . x ;
refRectB . y = refRectA . y ;
refRectB . x + = offsetX ;
refRectB . y + = offsetY ;
rectA = refRectA ;
rectB = refRectB ;
2022-12-27 22:01:11 +03:00
intersection = SDL_GetRectIntersection ( & rectA , & rectB , & result ) ;
2022-12-30 00:58:16 +03:00
validateIntersectRectResults ( intersection , SDL_FALSE , & rectA , & rectB , & refRectA , & refRectB , ( SDL_Rect * ) NULL , ( SDL_Rect * ) NULL ) ;
2015-06-21 18:33:46 +03:00
}
}
}
return TEST_COMPLETED ;
}
2023-02-02 02:21:53 +03:00
/**
2022-12-27 22:01:11 +03:00
* \ brief Tests SDL_GetRectIntersection ( ) with empty rectangles
2015-06-21 18:33:46 +03:00
*
2023-02-02 02:21:53 +03:00
* \ sa SDL_GetRectIntersection
2015-06-21 18:33:46 +03:00
*/
2023-03-08 18:12:45 +03:00
static int rect_testIntersectRectEmpty ( void * arg )
2015-06-21 18:33:46 +03:00
{
SDL_Rect refRectA ;
SDL_Rect refRectB ;
SDL_Rect rectA ;
SDL_Rect rectB ;
SDL_Rect result ;
SDL_bool intersection ;
SDL_bool empty ;
/* Rect A empty */
result . w = SDLTest_RandomIntegerInRange ( 1 , 100 ) ;
result . h = SDLTest_RandomIntegerInRange ( 1 , 100 ) ;
refRectA . x = SDLTest_RandomIntegerInRange ( 1 , 100 ) ;
refRectA . y = SDLTest_RandomIntegerInRange ( 1 , 100 ) ;
refRectA . w = SDLTest_RandomIntegerInRange ( 1 , 100 ) ;
refRectA . h = SDLTest_RandomIntegerInRange ( 1 , 100 ) ;
refRectB = refRectA ;
refRectA . w = 0 ;
refRectA . h = 0 ;
rectA = refRectA ;
rectB = refRectB ;
2022-12-27 22:01:11 +03:00
intersection = SDL_GetRectIntersection ( & rectA , & rectB , & result ) ;
2022-12-30 00:58:16 +03:00
validateIntersectRectResults ( intersection , SDL_FALSE , & rectA , & rectB , & refRectA , & refRectB , ( SDL_Rect * ) NULL , ( SDL_Rect * ) NULL ) ;
2022-12-29 06:34:01 +03:00
empty = SDL_RectEmpty ( & result ) ;
2015-06-21 18:33:46 +03:00
SDLTest_AssertCheck ( empty = = SDL_TRUE , " Validate result is empty Rect; got: %s " , ( empty = = SDL_TRUE ) ? " SDL_TRUE " : " SDL_FALSE " ) ;
/* Rect B empty */
result . w = SDLTest_RandomIntegerInRange ( 1 , 100 ) ;
result . h = SDLTest_RandomIntegerInRange ( 1 , 100 ) ;
refRectA . x = SDLTest_RandomIntegerInRange ( 1 , 100 ) ;
refRectA . y = SDLTest_RandomIntegerInRange ( 1 , 100 ) ;
refRectA . w = SDLTest_RandomIntegerInRange ( 1 , 100 ) ;
refRectA . h = SDLTest_RandomIntegerInRange ( 1 , 100 ) ;
refRectB = refRectA ;
refRectB . w = 0 ;
refRectB . h = 0 ;
rectA = refRectA ;
rectB = refRectB ;
2022-12-27 22:01:11 +03:00
intersection = SDL_GetRectIntersection ( & rectA , & rectB , & result ) ;
2022-12-30 00:58:16 +03:00
validateIntersectRectResults ( intersection , SDL_FALSE , & rectA , & rectB , & refRectA , & refRectB , ( SDL_Rect * ) NULL , ( SDL_Rect * ) NULL ) ;
2022-12-29 06:34:01 +03:00
empty = SDL_RectEmpty ( & result ) ;
2015-06-21 18:33:46 +03:00
SDLTest_AssertCheck ( empty = = SDL_TRUE , " Validate result is empty Rect; got: %s " , ( empty = = SDL_TRUE ) ? " SDL_TRUE " : " SDL_FALSE " ) ;
/* Rect A and B empty */
result . w = SDLTest_RandomIntegerInRange ( 1 , 100 ) ;
result . h = SDLTest_RandomIntegerInRange ( 1 , 100 ) ;
refRectA . x = SDLTest_RandomIntegerInRange ( 1 , 100 ) ;
refRectA . y = SDLTest_RandomIntegerInRange ( 1 , 100 ) ;
refRectA . w = SDLTest_RandomIntegerInRange ( 1 , 100 ) ;
refRectA . h = SDLTest_RandomIntegerInRange ( 1 , 100 ) ;
refRectB = refRectA ;
refRectA . w = 0 ;
refRectA . h = 0 ;
refRectB . w = 0 ;
refRectB . h = 0 ;
rectA = refRectA ;
rectB = refRectB ;
2022-12-27 22:01:11 +03:00
intersection = SDL_GetRectIntersection ( & rectA , & rectB , & result ) ;
2022-12-30 00:58:16 +03:00
validateIntersectRectResults ( intersection , SDL_FALSE , & rectA , & rectB , & refRectA , & refRectB , ( SDL_Rect * ) NULL , ( SDL_Rect * ) NULL ) ;
2022-12-29 06:34:01 +03:00
empty = SDL_RectEmpty ( & result ) ;
2015-06-21 18:33:46 +03:00
SDLTest_AssertCheck ( empty = = SDL_TRUE , " Validate result is empty Rect; got: %s " , ( empty = = SDL_TRUE ) ? " SDL_TRUE " : " SDL_FALSE " ) ;
return TEST_COMPLETED ;
}
2023-02-02 02:21:53 +03:00
/**
2022-12-27 22:01:11 +03:00
* \ brief Negative tests against SDL_GetRectIntersection ( ) with invalid parameters
2015-06-21 18:33:46 +03:00
*
2023-02-02 02:21:53 +03:00
* \ sa SDL_GetRectIntersection
2015-06-21 18:33:46 +03:00
*/
2023-03-08 18:12:45 +03:00
static int rect_testIntersectRectParam ( void * arg )
2015-06-21 18:33:46 +03:00
{
SDL_Rect rectA ;
2022-11-30 23:51:59 +03:00
SDL_Rect rectB = { 0 } ;
2015-06-21 18:33:46 +03:00
SDL_Rect result ;
SDL_bool intersection ;
/* invalid parameter combinations */
2022-12-27 22:01:11 +03:00
intersection = SDL_GetRectIntersection ( ( SDL_Rect * ) NULL , & rectB , & result ) ;
2015-06-21 18:33:46 +03:00
SDLTest_AssertCheck ( intersection = = SDL_FALSE , " Check that function returns SDL_FALSE when 1st parameter is NULL " ) ;
2022-12-27 22:01:11 +03:00
intersection = SDL_GetRectIntersection ( & rectA , ( SDL_Rect * ) NULL , & result ) ;
2015-06-21 18:33:46 +03:00
SDLTest_AssertCheck ( intersection = = SDL_FALSE , " Check that function returns SDL_FALSE when 2st parameter is NULL " ) ;
2022-12-27 22:01:11 +03:00
intersection = SDL_GetRectIntersection ( & rectA , & rectB , ( SDL_Rect * ) NULL ) ;
2015-06-21 18:33:46 +03:00
SDLTest_AssertCheck ( intersection = = SDL_FALSE , " Check that function returns SDL_FALSE when 3st parameter is NULL " ) ;
2022-12-27 22:01:11 +03:00
intersection = SDL_GetRectIntersection ( ( SDL_Rect * ) NULL , ( SDL_Rect * ) NULL , & result ) ;
2015-06-21 18:33:46 +03:00
SDLTest_AssertCheck ( intersection = = SDL_FALSE , " Check that function returns SDL_FALSE when 1st and 2nd parameters are NULL " ) ;
2022-12-27 22:01:11 +03:00
intersection = SDL_GetRectIntersection ( ( SDL_Rect * ) NULL , & rectB , ( SDL_Rect * ) NULL ) ;
2015-06-21 18:33:46 +03:00
SDLTest_AssertCheck ( intersection = = SDL_FALSE , " Check that function returns SDL_FALSE when 1st and 3rd parameters are NULL " ) ;
2022-12-27 22:01:11 +03:00
intersection = SDL_GetRectIntersection ( ( SDL_Rect * ) NULL , ( SDL_Rect * ) NULL , ( SDL_Rect * ) NULL ) ;
2015-06-21 18:33:46 +03:00
SDLTest_AssertCheck ( intersection = = SDL_FALSE , " Check that function returns SDL_FALSE when all parameters are NULL " ) ;
return TEST_COMPLETED ;
}
2023-02-02 02:21:53 +03:00
/**
2022-12-27 22:01:11 +03:00
* \ brief Tests SDL_HasRectIntersection ( ) with B fully inside A
2015-06-21 18:33:46 +03:00
*
2023-02-02 02:21:53 +03:00
* \ sa SDL_HasRectIntersection
2015-06-21 18:33:46 +03:00
*/
2023-03-08 18:12:45 +03:00
static int rect_testHasIntersectionInside ( void * arg )
2015-06-21 18:33:46 +03:00
{
SDL_Rect refRectA = { 0 , 0 , 32 , 32 } ;
SDL_Rect refRectB ;
SDL_Rect rectA ;
SDL_Rect rectB ;
SDL_bool intersection ;
/* rectB fully contained in rectA */
refRectB . x = 0 ;
refRectB . y = 0 ;
refRectB . w = SDLTest_RandomIntegerInRange ( refRectA . x + 1 , refRectA . x + refRectA . w - 1 ) ;
refRectB . h = SDLTest_RandomIntegerInRange ( refRectA . y + 1 , refRectA . y + refRectA . h - 1 ) ;
rectA = refRectA ;
rectB = refRectB ;
2022-12-27 22:01:11 +03:00
intersection = SDL_HasRectIntersection ( & rectA , & rectB ) ;
2022-12-30 00:58:16 +03:00
validateHasIntersectionResults ( intersection , SDL_TRUE , & rectA , & rectB , & refRectA , & refRectB ) ;
2015-06-21 18:33:46 +03:00
return TEST_COMPLETED ;
}
2023-02-02 02:21:53 +03:00
/**
2022-12-27 22:01:11 +03:00
* \ brief Tests SDL_HasRectIntersection ( ) with B fully outside A
2015-06-21 18:33:46 +03:00
*
2023-02-02 02:21:53 +03:00
* \ sa SDL_HasRectIntersection
2015-06-21 18:33:46 +03:00
*/
2023-03-08 18:12:45 +03:00
static int rect_testHasIntersectionOutside ( void * arg )
2015-06-21 18:33:46 +03:00
{
SDL_Rect refRectA = { 0 , 0 , 32 , 32 } ;
SDL_Rect refRectB ;
SDL_Rect rectA ;
SDL_Rect rectB ;
SDL_bool intersection ;
/* rectB fully outside of rectA */
refRectB . x = refRectA . x + refRectA . w + SDLTest_RandomIntegerInRange ( 1 , 10 ) ;
refRectB . y = refRectA . y + refRectA . h + SDLTest_RandomIntegerInRange ( 1 , 10 ) ;
refRectB . w = refRectA . w ;
refRectB . h = refRectA . h ;
rectA = refRectA ;
rectB = refRectB ;
2022-12-27 22:01:11 +03:00
intersection = SDL_HasRectIntersection ( & rectA , & rectB ) ;
2022-12-30 00:58:16 +03:00
validateHasIntersectionResults ( intersection , SDL_FALSE , & rectA , & rectB , & refRectA , & refRectB ) ;
2015-06-21 18:33:46 +03:00
return TEST_COMPLETED ;
}
2023-02-02 02:21:53 +03:00
/**
2022-12-27 22:01:11 +03:00
* \ brief Tests SDL_HasRectIntersection ( ) with B partially intersecting A
2015-06-21 18:33:46 +03:00
*
2023-02-02 02:21:53 +03:00
* \ sa SDL_HasRectIntersection
2015-06-21 18:33:46 +03:00
*/
2023-03-08 18:12:45 +03:00
static int rect_testHasIntersectionPartial ( void * arg )
2015-06-21 18:33:46 +03:00
{
SDL_Rect refRectA = { 0 , 0 , 32 , 32 } ;
SDL_Rect refRectB ;
SDL_Rect rectA ;
SDL_Rect rectB ;
SDL_bool intersection ;
/* rectB partially contained in rectA */
refRectB . x = SDLTest_RandomIntegerInRange ( refRectA . x + 1 , refRectA . x + refRectA . w - 1 ) ;
refRectB . y = SDLTest_RandomIntegerInRange ( refRectA . y + 1 , refRectA . y + refRectA . h - 1 ) ;
refRectB . w = refRectA . w ;
refRectB . h = refRectA . h ;
rectA = refRectA ;
rectB = refRectB ;
2022-12-27 22:01:11 +03:00
intersection = SDL_HasRectIntersection ( & rectA , & rectB ) ;
2022-12-30 00:58:16 +03:00
validateHasIntersectionResults ( intersection , SDL_TRUE , & rectA , & rectB , & refRectA , & refRectB ) ;
2015-06-21 18:33:46 +03:00
/* rectB right edge */
refRectB . x = rectA . w - 1 ;
refRectB . y = rectA . y ;
refRectB . w = SDLTest_RandomIntegerInRange ( 1 , refRectA . w - 1 ) ;
refRectB . h = SDLTest_RandomIntegerInRange ( 1 , refRectA . h - 1 ) ;
rectA = refRectA ;
rectB = refRectB ;
2022-12-27 22:01:11 +03:00
intersection = SDL_HasRectIntersection ( & rectA , & rectB ) ;
2022-12-30 00:58:16 +03:00
validateHasIntersectionResults ( intersection , SDL_TRUE , & rectA , & rectB , & refRectA , & refRectB ) ;
2015-06-21 18:33:46 +03:00
/* rectB left edge */
refRectB . x = 1 - rectA . w ;
refRectB . y = rectA . y ;
refRectB . w = refRectA . w ;
refRectB . h = SDLTest_RandomIntegerInRange ( 1 , refRectA . h - 1 ) ;
rectA = refRectA ;
rectB = refRectB ;
2022-12-27 22:01:11 +03:00
intersection = SDL_HasRectIntersection ( & rectA , & rectB ) ;
2022-12-30 00:58:16 +03:00
validateHasIntersectionResults ( intersection , SDL_TRUE , & rectA , & rectB , & refRectA , & refRectB ) ;
2015-06-21 18:33:46 +03:00
/* rectB bottom edge */
refRectB . x = rectA . x ;
refRectB . y = rectA . h - 1 ;
refRectB . w = SDLTest_RandomIntegerInRange ( 1 , refRectA . w - 1 ) ;
refRectB . h = SDLTest_RandomIntegerInRange ( 1 , refRectA . h - 1 ) ;
rectA = refRectA ;
rectB = refRectB ;
2022-12-27 22:01:11 +03:00
intersection = SDL_HasRectIntersection ( & rectA , & rectB ) ;
2022-12-30 00:58:16 +03:00
validateHasIntersectionResults ( intersection , SDL_TRUE , & rectA , & rectB , & refRectA , & refRectB ) ;
2015-06-21 18:33:46 +03:00
/* rectB top edge */
refRectB . x = rectA . x ;
refRectB . y = 1 - rectA . h ;
refRectB . w = SDLTest_RandomIntegerInRange ( 1 , refRectA . w - 1 ) ;
refRectB . h = rectA . h ;
rectA = refRectA ;
rectB = refRectB ;
2022-12-27 22:01:11 +03:00
intersection = SDL_HasRectIntersection ( & rectA , & rectB ) ;
2022-12-30 00:58:16 +03:00
validateHasIntersectionResults ( intersection , SDL_TRUE , & rectA , & rectB , & refRectA , & refRectB ) ;
2015-06-21 18:33:46 +03:00
return TEST_COMPLETED ;
}
2023-02-02 02:21:53 +03:00
/**
2022-12-27 22:01:11 +03:00
* \ brief Tests SDL_HasRectIntersection ( ) with 1 x1 pixel sized rectangles
2015-06-21 18:33:46 +03:00
*
2023-02-02 02:21:53 +03:00
* \ sa SDL_HasRectIntersection
2015-06-21 18:33:46 +03:00
*/
2023-03-08 18:12:45 +03:00
static int rect_testHasIntersectionPoint ( void * arg )
2015-06-21 18:33:46 +03:00
{
SDL_Rect refRectA = { 0 , 0 , 1 , 1 } ;
SDL_Rect refRectB = { 0 , 0 , 1 , 1 } ;
SDL_Rect rectA ;
SDL_Rect rectB ;
SDL_bool intersection ;
int offsetX , offsetY ;
/* intersecting pixels */
refRectA . x = SDLTest_RandomIntegerInRange ( 1 , 100 ) ;
refRectA . y = SDLTest_RandomIntegerInRange ( 1 , 100 ) ;
refRectB . x = refRectA . x ;
refRectB . y = refRectA . y ;
rectA = refRectA ;
rectB = refRectB ;
2022-12-27 22:01:11 +03:00
intersection = SDL_HasRectIntersection ( & rectA , & rectB ) ;
2022-12-30 00:58:16 +03:00
validateHasIntersectionResults ( intersection , SDL_TRUE , & rectA , & rectB , & refRectA , & refRectB ) ;
2015-06-21 18:33:46 +03:00
/* non-intersecting pixels cases */
for ( offsetX = - 1 ; offsetX < = 1 ; offsetX + + ) {
for ( offsetY = - 1 ; offsetY < = 1 ; offsetY + + ) {
if ( offsetX ! = 0 | | offsetY ! = 0 ) {
refRectA . x = SDLTest_RandomIntegerInRange ( 1 , 100 ) ;
refRectA . y = SDLTest_RandomIntegerInRange ( 1 , 100 ) ;
refRectB . x = refRectA . x ;
refRectB . y = refRectA . y ;
refRectB . x + = offsetX ;
refRectB . y + = offsetY ;
rectA = refRectA ;
rectB = refRectB ;
2022-12-27 22:01:11 +03:00
intersection = SDL_HasRectIntersection ( & rectA , & rectB ) ;
2022-12-30 00:58:16 +03:00
validateHasIntersectionResults ( intersection , SDL_FALSE , & rectA , & rectB , & refRectA , & refRectB ) ;
2015-06-21 18:33:46 +03:00
}
}
}
return TEST_COMPLETED ;
}
2023-02-02 02:21:53 +03:00
/**
2022-12-27 22:01:11 +03:00
* \ brief Tests SDL_HasRectIntersection ( ) with empty rectangles
2015-06-21 18:33:46 +03:00
*
2023-02-02 02:21:53 +03:00
* \ sa SDL_HasRectIntersection
2015-06-21 18:33:46 +03:00
*/
2023-03-08 18:12:45 +03:00
static int rect_testHasIntersectionEmpty ( void * arg )
2015-06-21 18:33:46 +03:00
{
SDL_Rect refRectA ;
SDL_Rect refRectB ;
SDL_Rect rectA ;
SDL_Rect rectB ;
SDL_bool intersection ;
/* Rect A empty */
refRectA . x = SDLTest_RandomIntegerInRange ( 1 , 100 ) ;
refRectA . y = SDLTest_RandomIntegerInRange ( 1 , 100 ) ;
refRectA . w = SDLTest_RandomIntegerInRange ( 1 , 100 ) ;
refRectA . h = SDLTest_RandomIntegerInRange ( 1 , 100 ) ;
refRectB = refRectA ;
refRectA . w = 0 ;
refRectA . h = 0 ;
rectA = refRectA ;
rectB = refRectB ;
2022-12-27 22:01:11 +03:00
intersection = SDL_HasRectIntersection ( & rectA , & rectB ) ;
2022-12-30 00:58:16 +03:00
validateHasIntersectionResults ( intersection , SDL_FALSE , & rectA , & rectB , & refRectA , & refRectB ) ;
2015-06-21 18:33:46 +03:00
/* Rect B empty */
refRectA . x = SDLTest_RandomIntegerInRange ( 1 , 100 ) ;
refRectA . y = SDLTest_RandomIntegerInRange ( 1 , 100 ) ;
refRectA . w = SDLTest_RandomIntegerInRange ( 1 , 100 ) ;
refRectA . h = SDLTest_RandomIntegerInRange ( 1 , 100 ) ;
refRectB = refRectA ;
refRectB . w = 0 ;
refRectB . h = 0 ;
rectA = refRectA ;
rectB = refRectB ;
2022-12-27 22:01:11 +03:00
intersection = SDL_HasRectIntersection ( & rectA , & rectB ) ;
2022-12-30 00:58:16 +03:00
validateHasIntersectionResults ( intersection , SDL_FALSE , & rectA , & rectB , & refRectA , & refRectB ) ;
2015-06-21 18:33:46 +03:00
/* Rect A and B empty */
refRectA . x = SDLTest_RandomIntegerInRange ( 1 , 100 ) ;
refRectA . y = SDLTest_RandomIntegerInRange ( 1 , 100 ) ;
refRectA . w = SDLTest_RandomIntegerInRange ( 1 , 100 ) ;
refRectA . h = SDLTest_RandomIntegerInRange ( 1 , 100 ) ;
refRectB = refRectA ;
refRectA . w = 0 ;
refRectA . h = 0 ;
refRectB . w = 0 ;
refRectB . h = 0 ;
rectA = refRectA ;
rectB = refRectB ;
2022-12-27 22:01:11 +03:00
intersection = SDL_HasRectIntersection ( & rectA , & rectB ) ;
2022-12-30 00:58:16 +03:00
validateHasIntersectionResults ( intersection , SDL_FALSE , & rectA , & rectB , & refRectA , & refRectB ) ;
2015-06-21 18:33:46 +03:00
return TEST_COMPLETED ;
}
2023-02-02 02:21:53 +03:00
/**
2022-12-27 22:01:11 +03:00
* \ brief Negative tests against SDL_HasRectIntersection ( ) with invalid parameters
2015-06-21 18:33:46 +03:00
*
2023-02-02 02:21:53 +03:00
* \ sa SDL_HasRectIntersection
2015-06-21 18:33:46 +03:00
*/
2023-03-08 18:12:45 +03:00
static int rect_testHasIntersectionParam ( void * arg )
2015-06-21 18:33:46 +03:00
{
SDL_Rect rectA ;
2022-11-30 23:51:59 +03:00
SDL_Rect rectB = { 0 } ;
2015-06-21 18:33:46 +03:00
SDL_bool intersection ;
/* invalid parameter combinations */
2022-12-27 22:01:11 +03:00
intersection = SDL_HasRectIntersection ( ( SDL_Rect * ) NULL , & rectB ) ;
2015-06-21 18:33:46 +03:00
SDLTest_AssertCheck ( intersection = = SDL_FALSE , " Check that function returns SDL_FALSE when 1st parameter is NULL " ) ;
2022-12-27 22:01:11 +03:00
intersection = SDL_HasRectIntersection ( & rectA , ( SDL_Rect * ) NULL ) ;
2015-06-21 18:33:46 +03:00
SDLTest_AssertCheck ( intersection = = SDL_FALSE , " Check that function returns SDL_FALSE when 2st parameter is NULL " ) ;
2022-12-27 22:01:11 +03:00
intersection = SDL_HasRectIntersection ( ( SDL_Rect * ) NULL , ( SDL_Rect * ) NULL ) ;
2015-06-21 18:33:46 +03:00
SDLTest_AssertCheck ( intersection = = SDL_FALSE , " Check that function returns SDL_FALSE when all parameters are NULL " ) ;
return TEST_COMPLETED ;
}
2023-02-02 02:21:53 +03:00
/**
2022-12-27 22:01:11 +03:00
* \ brief Test SDL_GetRectEnclosingPoints ( ) without clipping
2015-06-21 18:33:46 +03:00
*
2023-02-02 02:21:53 +03:00
* \ sa SDL_GetRectEnclosingPoints
2015-06-21 18:33:46 +03:00
*/
2023-03-08 18:12:45 +03:00
static int rect_testEnclosePoints ( void * arg )
2015-06-21 18:33:46 +03:00
{
const int numPoints = 16 ;
SDL_Point refPoints [ 16 ] ;
SDL_Point points [ 16 ] ;
SDL_Rect result ;
SDL_bool anyEnclosed ;
SDL_bool anyEnclosedNoResult ;
SDL_bool expectedEnclosed = SDL_TRUE ;
int newx , newy ;
int minx = 0 , maxx = 0 , miny = 0 , maxy = 0 ;
int i ;
/* Create input data, tracking result */
2022-11-30 23:51:59 +03:00
for ( i = 0 ; i < numPoints ; i + + ) {
2015-06-21 18:33:46 +03:00
newx = SDLTest_RandomIntegerInRange ( - 1024 , 1024 ) ;
newy = SDLTest_RandomIntegerInRange ( - 1024 , 1024 ) ;
refPoints [ i ] . x = newx ;
refPoints [ i ] . y = newy ;
points [ i ] . x = newx ;
points [ i ] . y = newy ;
2022-11-30 23:51:59 +03:00
if ( i = = 0 ) {
2015-06-21 18:33:46 +03:00
minx = newx ;
maxx = newx ;
miny = newy ;
maxy = newy ;
} else {
2022-11-27 19:38:43 +03:00
if ( newx < minx ) {
minx = newx ;
}
if ( newx > maxx ) {
maxx = newx ;
}
if ( newy < miny ) {
miny = newy ;
}
if ( newy > maxy ) {
maxy = newy ;
}
2015-06-21 18:33:46 +03:00
}
}
/* Call function and validate - special case: no result requested */
2022-12-27 22:01:11 +03:00
anyEnclosedNoResult = SDL_GetRectEnclosingPoints ( ( const SDL_Point * ) points , numPoints , ( const SDL_Rect * ) NULL , ( SDL_Rect * ) NULL ) ;
2022-11-30 23:51:59 +03:00
SDLTest_AssertCheck ( expectedEnclosed = = anyEnclosedNoResult ,
" Check expected return value %s, got %s " ,
( expectedEnclosed = = SDL_TRUE ) ? " SDL_TRUE " : " SDL_FALSE " ,
( anyEnclosedNoResult = = SDL_TRUE ) ? " SDL_TRUE " : " SDL_FALSE " ) ;
for ( i = 0 ; i < numPoints ; i + + ) {
SDLTest_AssertCheck ( refPoints [ i ] . x = = points [ i ] . x & & refPoints [ i ] . y = = points [ i ] . y ,
" Check that source point %i was not modified: expected (%i,%i) actual (%i,%i) " ,
i , refPoints [ i ] . x , refPoints [ i ] . y , points [ i ] . x , points [ i ] . y ) ;
2015-06-21 18:33:46 +03:00
}
/* Call function and validate */
2022-12-27 22:01:11 +03:00
anyEnclosed = SDL_GetRectEnclosingPoints ( ( const SDL_Point * ) points , numPoints , ( const SDL_Rect * ) NULL , & result ) ;
2022-11-30 23:51:59 +03:00
SDLTest_AssertCheck ( expectedEnclosed = = anyEnclosed ,
" Check return value %s, got %s " ,
( expectedEnclosed = = SDL_TRUE ) ? " SDL_TRUE " : " SDL_FALSE " ,
( anyEnclosed = = SDL_TRUE ) ? " SDL_TRUE " : " SDL_FALSE " ) ;
for ( i = 0 ; i < numPoints ; i + + ) {
SDLTest_AssertCheck ( refPoints [ i ] . x = = points [ i ] . x & & refPoints [ i ] . y = = points [ i ] . y ,
" Check that source point %i was not modified: expected (%i,%i) actual (%i,%i) " ,
i , refPoints [ i ] . x , refPoints [ i ] . y , points [ i ] . x , points [ i ] . y ) ;
2015-06-21 18:33:46 +03:00
}
2022-11-30 23:51:59 +03:00
SDLTest_AssertCheck ( result . x = = minx & & result . y = = miny & & result . w = = ( maxx - minx + 1 ) & & result . h = = ( maxy - miny + 1 ) ,
" Resulting enclosing rectangle incorrect: expected (%i,%i - %i,%i), actual (%i,%i - %i,%i) " ,
minx , miny , maxx , maxy , result . x , result . y , result . x + result . w - 1 , result . y + result . h - 1 ) ;
2015-06-21 18:33:46 +03:00
return TEST_COMPLETED ;
}
2023-02-02 02:21:53 +03:00
/**
2022-12-27 22:01:11 +03:00
* \ brief Test SDL_GetRectEnclosingPoints ( ) with repeated input points
2015-06-21 18:33:46 +03:00
*
2023-02-02 02:21:53 +03:00
* \ sa SDL_GetRectEnclosingPoints
2015-06-21 18:33:46 +03:00
*/
2023-03-08 18:12:45 +03:00
static int rect_testEnclosePointsRepeatedInput ( void * arg )
2015-06-21 18:33:46 +03:00
{
const int numPoints = 8 ;
const int halfPoints = 4 ;
SDL_Point refPoints [ 8 ] ;
SDL_Point points [ 8 ] ;
SDL_Rect result ;
SDL_bool anyEnclosed ;
SDL_bool anyEnclosedNoResult ;
SDL_bool expectedEnclosed = SDL_TRUE ;
int newx , newy ;
int minx = 0 , maxx = 0 , miny = 0 , maxy = 0 ;
int i ;
/* Create input data, tracking result */
2022-11-30 23:51:59 +03:00
for ( i = 0 ; i < numPoints ; i + + ) {
2015-06-21 18:33:46 +03:00
if ( i < halfPoints ) {
newx = SDLTest_RandomIntegerInRange ( - 1024 , 1024 ) ;
newy = SDLTest_RandomIntegerInRange ( - 1024 , 1024 ) ;
} else {
2022-11-30 23:51:59 +03:00
newx = refPoints [ i - halfPoints ] . x ;
newy = refPoints [ i - halfPoints ] . y ;
2015-06-21 18:33:46 +03:00
}
refPoints [ i ] . x = newx ;
refPoints [ i ] . y = newy ;
points [ i ] . x = newx ;
points [ i ] . y = newy ;
2022-11-30 23:51:59 +03:00
if ( i = = 0 ) {
2015-06-21 18:33:46 +03:00
minx = newx ;
maxx = newx ;
miny = newy ;
maxy = newy ;
} else {
2022-11-27 19:38:43 +03:00
if ( newx < minx ) {
minx = newx ;
}
if ( newx > maxx ) {
maxx = newx ;
}
if ( newy < miny ) {
miny = newy ;
}
if ( newy > maxy ) {
maxy = newy ;
}
2015-06-21 18:33:46 +03:00
}
}
/* Call function and validate - special case: no result requested */
2022-12-27 22:01:11 +03:00
anyEnclosedNoResult = SDL_GetRectEnclosingPoints ( ( const SDL_Point * ) points , numPoints , ( const SDL_Rect * ) NULL , ( SDL_Rect * ) NULL ) ;
2022-11-30 23:51:59 +03:00
SDLTest_AssertCheck ( expectedEnclosed = = anyEnclosedNoResult ,
" Check return value %s, got %s " ,
( expectedEnclosed = = SDL_TRUE ) ? " SDL_TRUE " : " SDL_FALSE " ,
( anyEnclosedNoResult = = SDL_TRUE ) ? " SDL_TRUE " : " SDL_FALSE " ) ;
for ( i = 0 ; i < numPoints ; i + + ) {
SDLTest_AssertCheck ( refPoints [ i ] . x = = points [ i ] . x & & refPoints [ i ] . y = = points [ i ] . y ,
" Check that source point %i was not modified: expected (%i,%i) actual (%i,%i) " ,
i , refPoints [ i ] . x , refPoints [ i ] . y , points [ i ] . x , points [ i ] . y ) ;
2015-06-21 18:33:46 +03:00
}
/* Call function and validate */
2022-12-27 22:01:11 +03:00
anyEnclosed = SDL_GetRectEnclosingPoints ( ( const SDL_Point * ) points , numPoints , ( const SDL_Rect * ) NULL , & result ) ;
2022-11-30 23:51:59 +03:00
SDLTest_AssertCheck ( expectedEnclosed = = anyEnclosed ,
" Check return value %s, got %s " ,
( expectedEnclosed = = SDL_TRUE ) ? " SDL_TRUE " : " SDL_FALSE " ,
( anyEnclosed = = SDL_TRUE ) ? " SDL_TRUE " : " SDL_FALSE " ) ;
for ( i = 0 ; i < numPoints ; i + + ) {
SDLTest_AssertCheck ( refPoints [ i ] . x = = points [ i ] . x & & refPoints [ i ] . y = = points [ i ] . y ,
" Check that source point %i was not modified: expected (%i,%i) actual (%i,%i) " ,
i , refPoints [ i ] . x , refPoints [ i ] . y , points [ i ] . x , points [ i ] . y ) ;
2015-06-21 18:33:46 +03:00
}
2022-11-30 23:51:59 +03:00
SDLTest_AssertCheck ( result . x = = minx & & result . y = = miny & & result . w = = ( maxx - minx + 1 ) & & result . h = = ( maxy - miny + 1 ) ,
" Check resulting enclosing rectangle: expected (%i,%i - %i,%i), actual (%i,%i - %i,%i) " ,
minx , miny , maxx , maxy , result . x , result . y , result . x + result . w - 1 , result . y + result . h - 1 ) ;
2015-06-21 18:33:46 +03:00
return TEST_COMPLETED ;
}
2023-02-02 02:21:53 +03:00
/**
2022-12-27 22:01:11 +03:00
* \ brief Test SDL_GetRectEnclosingPoints ( ) with clipping
2015-06-21 18:33:46 +03:00
*
2023-02-02 02:21:53 +03:00
* \ sa SDL_GetRectEnclosingPoints
2015-06-21 18:33:46 +03:00
*/
2023-03-08 18:12:45 +03:00
static int rect_testEnclosePointsWithClipping ( void * arg )
2015-06-21 18:33:46 +03:00
{
const int numPoints = 16 ;
SDL_Point refPoints [ 16 ] ;
SDL_Point points [ 16 ] ;
SDL_Rect refClip ;
SDL_Rect clip ;
SDL_Rect result ;
SDL_bool anyEnclosed ;
SDL_bool anyEnclosedNoResult ;
SDL_bool expectedEnclosed = SDL_FALSE ;
int newx , newy ;
int minx = 0 , maxx = 0 , miny = 0 , maxy = 0 ;
int i ;
/* Setup clipping rectangle */
refClip . x = SDLTest_RandomIntegerInRange ( - 1024 , 1024 ) ;
refClip . y = SDLTest_RandomIntegerInRange ( - 1024 , 1024 ) ;
refClip . w = SDLTest_RandomIntegerInRange ( 1 , 1024 ) ;
refClip . h = SDLTest_RandomIntegerInRange ( 1 , 1024 ) ;
/* Create input data, tracking result */
2022-11-30 23:51:59 +03:00
for ( i = 0 ; i < numPoints ; i + + ) {
2015-06-21 18:33:46 +03:00
newx = SDLTest_RandomIntegerInRange ( - 1024 , 1024 ) ;
newy = SDLTest_RandomIntegerInRange ( - 1024 , 1024 ) ;
refPoints [ i ] . x = newx ;
refPoints [ i ] . y = newy ;
points [ i ] . x = newx ;
points [ i ] . y = newy ;
2022-11-30 23:51:59 +03:00
if ( ( newx > = refClip . x ) & & ( newx < ( refClip . x + refClip . w ) ) & &
( newy > = refClip . y ) & & ( newy < ( refClip . y + refClip . h ) ) ) {
if ( expectedEnclosed = = SDL_FALSE ) {
2015-06-21 18:33:46 +03:00
minx = newx ;
maxx = newx ;
miny = newy ;
maxy = newy ;
} else {
2022-11-27 19:38:43 +03:00
if ( newx < minx ) {
minx = newx ;
}
if ( newx > maxx ) {
maxx = newx ;
}
if ( newy < miny ) {
miny = newy ;
}
if ( newy > maxy ) {
maxy = newy ;
}
2015-06-21 18:33:46 +03:00
}
expectedEnclosed = SDL_TRUE ;
}
}
/* Call function and validate - special case: no result requested */
clip = refClip ;
2022-12-27 22:01:11 +03:00
anyEnclosedNoResult = SDL_GetRectEnclosingPoints ( ( const SDL_Point * ) points , numPoints , ( const SDL_Rect * ) & clip , ( SDL_Rect * ) NULL ) ;
2022-11-30 23:51:59 +03:00
SDLTest_AssertCheck ( expectedEnclosed = = anyEnclosedNoResult ,
" Expected return value %s, got %s " ,
( expectedEnclosed = = SDL_TRUE ) ? " SDL_TRUE " : " SDL_FALSE " ,
( anyEnclosedNoResult = = SDL_TRUE ) ? " SDL_TRUE " : " SDL_FALSE " ) ;
for ( i = 0 ; i < numPoints ; i + + ) {
SDLTest_AssertCheck ( refPoints [ i ] . x = = points [ i ] . x & & refPoints [ i ] . y = = points [ i ] . y ,
" Check that source point %i was not modified: expected (%i,%i) actual (%i,%i) " ,
i , refPoints [ i ] . x , refPoints [ i ] . y , points [ i ] . x , points [ i ] . y ) ;
2015-06-21 18:33:46 +03:00
}
2022-11-30 23:51:59 +03:00
SDLTest_AssertCheck ( refClip . x = = clip . x & & refClip . y = = clip . y & & refClip . w = = clip . w & & refClip . h = = clip . h ,
" Check that source clipping rectangle was not modified " ) ;
2015-06-21 18:33:46 +03:00
/* Call function and validate */
2022-12-27 22:01:11 +03:00
anyEnclosed = SDL_GetRectEnclosingPoints ( ( const SDL_Point * ) points , numPoints , ( const SDL_Rect * ) & clip , & result ) ;
2022-11-30 23:51:59 +03:00
SDLTest_AssertCheck ( expectedEnclosed = = anyEnclosed ,
" Check return value %s, got %s " ,
( expectedEnclosed = = SDL_TRUE ) ? " SDL_TRUE " : " SDL_FALSE " ,
( anyEnclosed = = SDL_TRUE ) ? " SDL_TRUE " : " SDL_FALSE " ) ;
for ( i = 0 ; i < numPoints ; i + + ) {
SDLTest_AssertCheck ( refPoints [ i ] . x = = points [ i ] . x & & refPoints [ i ] . y = = points [ i ] . y ,
" Check that source point %i was not modified: expected (%i,%i) actual (%i,%i) " ,
i , refPoints [ i ] . x , refPoints [ i ] . y , points [ i ] . x , points [ i ] . y ) ;
2015-06-21 18:33:46 +03:00
}
2022-11-30 23:51:59 +03:00
SDLTest_AssertCheck ( refClip . x = = clip . x & & refClip . y = = clip . y & & refClip . w = = clip . w & & refClip . h = = clip . h ,
" Check that source clipping rectangle was not modified " ) ;
if ( expectedEnclosed = = SDL_TRUE ) {
SDLTest_AssertCheck ( result . x = = minx & & result . y = = miny & & result . w = = ( maxx - minx + 1 ) & & result . h = = ( maxy - miny + 1 ) ,
" Check resulting enclosing rectangle: expected (%i,%i - %i,%i), actual (%i,%i - %i,%i) " ,
minx , miny , maxx , maxy , result . x , result . y , result . x + result . w - 1 , result . y + result . h - 1 ) ;
2015-06-21 18:33:46 +03:00
}
/* Empty clipping rectangle */
clip . w = 0 ;
clip . h = 0 ;
expectedEnclosed = SDL_FALSE ;
2022-12-27 22:01:11 +03:00
anyEnclosed = SDL_GetRectEnclosingPoints ( ( const SDL_Point * ) points , numPoints , ( const SDL_Rect * ) & clip , & result ) ;
2022-11-30 23:51:59 +03:00
SDLTest_AssertCheck ( expectedEnclosed = = anyEnclosed ,
" Check return value %s, got %s " ,
( expectedEnclosed = = SDL_TRUE ) ? " SDL_TRUE " : " SDL_FALSE " ,
( anyEnclosed = = SDL_TRUE ) ? " SDL_TRUE " : " SDL_FALSE " ) ;
2015-06-21 18:33:46 +03:00
return TEST_COMPLETED ;
}
2023-02-02 02:21:53 +03:00
/**
2022-12-27 22:01:11 +03:00
* \ brief Negative tests against SDL_GetRectEnclosingPoints ( ) with invalid parameters
2015-06-21 18:33:46 +03:00
*
2023-02-02 02:21:53 +03:00
* \ sa SDL_GetRectEnclosingPoints
2015-06-21 18:33:46 +03:00
*/
2023-03-08 18:12:45 +03:00
static int rect_testEnclosePointsParam ( void * arg )
2015-06-21 18:33:46 +03:00
{
SDL_Point points [ 1 ] ;
int count ;
2022-06-05 09:53:15 +03:00
SDL_Rect clip = { 0 } ;
2015-06-21 18:33:46 +03:00
SDL_Rect result ;
SDL_bool anyEnclosed ;
/* invalid parameter combinations */
2022-12-27 22:01:11 +03:00
anyEnclosed = SDL_GetRectEnclosingPoints ( ( SDL_Point * ) NULL , 1 , ( const SDL_Rect * ) & clip , & result ) ;
2015-06-21 18:33:46 +03:00
SDLTest_AssertCheck ( anyEnclosed = = SDL_FALSE , " Check that functions returns SDL_FALSE when 1st parameter is NULL " ) ;
2022-12-27 22:01:11 +03:00
anyEnclosed = SDL_GetRectEnclosingPoints ( ( const SDL_Point * ) points , 0 , ( const SDL_Rect * ) & clip , & result ) ;
2015-06-21 18:33:46 +03:00
SDLTest_AssertCheck ( anyEnclosed = = SDL_FALSE , " Check that functions returns SDL_FALSE when 2nd parameter is 0 " ) ;
count = SDLTest_RandomIntegerInRange ( - 100 , - 1 ) ;
2022-12-27 22:01:11 +03:00
anyEnclosed = SDL_GetRectEnclosingPoints ( ( const SDL_Point * ) points , count , ( const SDL_Rect * ) & clip , & result ) ;
2015-06-21 18:33:46 +03:00
SDLTest_AssertCheck ( anyEnclosed = = SDL_FALSE , " Check that functions returns SDL_FALSE when 2nd parameter is %i (negative) " , count ) ;
2022-12-27 22:01:11 +03:00
anyEnclosed = SDL_GetRectEnclosingPoints ( ( SDL_Point * ) NULL , 0 , ( const SDL_Rect * ) & clip , & result ) ;
2015-06-21 18:33:46 +03:00
SDLTest_AssertCheck ( anyEnclosed = = SDL_FALSE , " Check that functions returns SDL_FALSE when 1st parameter is NULL and 2nd parameter was 0 " ) ;
return TEST_COMPLETED ;
}
2023-02-02 02:21:53 +03:00
/**
2022-12-27 22:01:11 +03:00
* \ brief Tests SDL_GetRectUnion ( ) where rect B is outside rect A
2015-06-21 18:33:46 +03:00
*
2023-02-02 02:21:53 +03:00
* \ sa SDL_GetRectUnion
2015-06-21 18:33:46 +03:00
*/
2023-03-08 18:12:45 +03:00
static int rect_testUnionRectOutside ( void * arg )
2015-06-21 18:33:46 +03:00
{
SDL_Rect refRectA , refRectB ;
SDL_Rect rectA , rectB ;
SDL_Rect expectedResult ;
SDL_Rect result ;
int minx , maxx , miny , maxy ;
int dx , dy ;
/* Union 1x1 outside */
for ( dx = - 1 ; dx < 2 ; dx + + ) {
for ( dy = - 1 ; dy < 2 ; dy + + ) {
if ( ( dx ! = 0 ) | | ( dy ! = 0 ) ) {
2022-11-30 23:51:59 +03:00
refRectA . x = SDLTest_RandomIntegerInRange ( - 1024 , 1024 ) ;
refRectA . y = SDLTest_RandomIntegerInRange ( - 1024 , 1024 ) ;
refRectA . w = 1 ;
refRectA . h = 1 ;
refRectB . x = SDLTest_RandomIntegerInRange ( - 1024 , 1024 ) + dx * 2048 ;
refRectB . y = SDLTest_RandomIntegerInRange ( - 1024 , 1024 ) + dx * 2048 ;
refRectB . w = 1 ;
refRectB . h = 1 ;
minx = ( refRectA . x < refRectB . x ) ? refRectA . x : refRectB . x ;
maxx = ( refRectA . x > refRectB . x ) ? refRectA . x : refRectB . x ;
miny = ( refRectA . y < refRectB . y ) ? refRectA . y : refRectB . y ;
maxy = ( refRectA . y > refRectB . y ) ? refRectA . y : refRectB . y ;
2015-06-21 18:33:46 +03:00
expectedResult . x = minx ;
expectedResult . y = miny ;
expectedResult . w = maxx - minx + 1 ;
expectedResult . h = maxy - miny + 1 ;
rectA = refRectA ;
rectB = refRectB ;
2022-12-27 22:01:11 +03:00
SDL_GetRectUnion ( & rectA , & rectB , & result ) ;
2022-12-30 00:58:16 +03:00
validateUnionRectResults ( & rectA , & rectB , & refRectA , & refRectB , & result , & expectedResult ) ;
2015-06-21 18:33:46 +03:00
}
}
}
/* Union outside overlap */
for ( dx = - 1 ; dx < 2 ; dx + + ) {
for ( dy = - 1 ; dy < 2 ; dy + + ) {
if ( ( dx ! = 0 ) | | ( dy ! = 0 ) ) {
2022-11-30 23:51:59 +03:00
refRectA . x = SDLTest_RandomIntegerInRange ( - 1024 , 1024 ) ;
refRectA . y = SDLTest_RandomIntegerInRange ( - 1024 , 1024 ) ;
refRectA . w = SDLTest_RandomIntegerInRange ( 256 , 512 ) ;
refRectA . h = SDLTest_RandomIntegerInRange ( 256 , 512 ) ;
refRectB . x = refRectA . x + 1 + dx * 2 ;
refRectB . y = refRectA . y + 1 + dy * 2 ;
refRectB . w = refRectA . w - 2 ;
refRectB . h = refRectA . h - 2 ;
2015-06-21 18:33:46 +03:00
expectedResult = refRectA ;
2022-11-27 19:38:43 +03:00
if ( dx = = - 1 ) {
expectedResult . x - - ;
}
if ( dy = = - 1 ) {
expectedResult . y - - ;
}
if ( ( dx = = 1 ) | | ( dx = = - 1 ) ) {
expectedResult . w + + ;
}
if ( ( dy = = 1 ) | | ( dy = = - 1 ) ) {
expectedResult . h + + ;
}
2015-06-21 18:33:46 +03:00
rectA = refRectA ;
rectB = refRectB ;
2022-12-27 22:01:11 +03:00
SDL_GetRectUnion ( & rectA , & rectB , & result ) ;
2022-12-30 00:58:16 +03:00
validateUnionRectResults ( & rectA , & rectB , & refRectA , & refRectB , & result , & expectedResult ) ;
2015-06-21 18:33:46 +03:00
}
}
}
return TEST_COMPLETED ;
}
2023-02-02 02:21:53 +03:00
/**
2022-12-27 22:01:11 +03:00
* \ brief Tests SDL_GetRectUnion ( ) where rect A or rect B are empty
2015-06-21 18:33:46 +03:00
*
2023-02-02 02:21:53 +03:00
* \ sa SDL_GetRectUnion
2015-06-21 18:33:46 +03:00
*/
2023-03-08 18:12:45 +03:00
static int rect_testUnionRectEmpty ( void * arg )
2015-06-21 18:33:46 +03:00
{
SDL_Rect refRectA , refRectB ;
SDL_Rect rectA , rectB ;
SDL_Rect expectedResult ;
SDL_Rect result ;
/* A empty */
2022-11-30 23:51:59 +03:00
refRectA . x = SDLTest_RandomIntegerInRange ( - 1024 , 1024 ) ;
refRectA . y = SDLTest_RandomIntegerInRange ( - 1024 , 1024 ) ;
refRectA . w = 0 ;
refRectA . h = 0 ;
refRectB . x = SDLTest_RandomIntegerInRange ( - 1024 , 1024 ) ;
refRectB . y = SDLTest_RandomIntegerInRange ( - 1024 , 1024 ) ;
refRectB . w = SDLTest_RandomIntegerInRange ( 1 , 1024 ) ;
refRectB . h = SDLTest_RandomIntegerInRange ( 1 , 1024 ) ;
2015-06-21 18:33:46 +03:00
expectedResult = refRectB ;
rectA = refRectA ;
rectB = refRectB ;
2022-12-27 22:01:11 +03:00
SDL_GetRectUnion ( & rectA , & rectB , & result ) ;
2022-12-30 00:58:16 +03:00
validateUnionRectResults ( & rectA , & rectB , & refRectA , & refRectB , & result , & expectedResult ) ;
2015-06-21 18:33:46 +03:00
/* B empty */
2022-11-30 23:51:59 +03:00
refRectA . x = SDLTest_RandomIntegerInRange ( - 1024 , 1024 ) ;
refRectA . y = SDLTest_RandomIntegerInRange ( - 1024 , 1024 ) ;
refRectA . w = SDLTest_RandomIntegerInRange ( 1 , 1024 ) ;
refRectA . h = SDLTest_RandomIntegerInRange ( 1 , 1024 ) ;
refRectB . x = SDLTest_RandomIntegerInRange ( - 1024 , 1024 ) ;
refRectB . y = SDLTest_RandomIntegerInRange ( - 1024 , 1024 ) ;
refRectB . w = 0 ;
refRectB . h = 0 ;
2015-06-21 18:33:46 +03:00
expectedResult = refRectA ;
rectA = refRectA ;
rectB = refRectB ;
2022-12-27 22:01:11 +03:00
SDL_GetRectUnion ( & rectA , & rectB , & result ) ;
2022-12-30 00:58:16 +03:00
validateUnionRectResults ( & rectA , & rectB , & refRectA , & refRectB , & result , & expectedResult ) ;
2015-06-21 18:33:46 +03:00
/* A and B empty */
2022-11-30 23:51:59 +03:00
refRectA . x = SDLTest_RandomIntegerInRange ( - 1024 , 1024 ) ;
refRectA . y = SDLTest_RandomIntegerInRange ( - 1024 , 1024 ) ;
refRectA . w = 0 ;
refRectA . h = 0 ;
refRectB . x = SDLTest_RandomIntegerInRange ( - 1024 , 1024 ) ;
refRectB . y = SDLTest_RandomIntegerInRange ( - 1024 , 1024 ) ;
refRectB . w = 0 ;
refRectB . h = 0 ;
result . x = 0 ;
result . y = 0 ;
result . w = 0 ;
result . h = 0 ;
2015-06-21 18:33:46 +03:00
expectedResult = result ;
rectA = refRectA ;
rectB = refRectB ;
2022-12-27 22:01:11 +03:00
SDL_GetRectUnion ( & rectA , & rectB , & result ) ;
2022-12-30 00:58:16 +03:00
validateUnionRectResults ( & rectA , & rectB , & refRectA , & refRectB , & result , & expectedResult ) ;
2015-06-21 18:33:46 +03:00
return TEST_COMPLETED ;
}
2023-02-02 02:21:53 +03:00
/**
2022-12-27 22:01:11 +03:00
* \ brief Tests SDL_GetRectUnion ( ) where rect B is inside rect A
2015-06-21 18:33:46 +03:00
*
2023-02-02 02:21:53 +03:00
* \ sa SDL_GetRectUnion
2015-06-21 18:33:46 +03:00
*/
2023-03-08 18:12:45 +03:00
static int rect_testUnionRectInside ( void * arg )
2015-06-21 18:33:46 +03:00
{
SDL_Rect refRectA , refRectB ;
SDL_Rect rectA , rectB ;
SDL_Rect expectedResult ;
SDL_Rect result ;
int dx , dy ;
/* Union 1x1 with itself */
2022-11-30 23:51:59 +03:00
refRectA . x = SDLTest_RandomIntegerInRange ( - 1024 , 1024 ) ;
refRectA . y = SDLTest_RandomIntegerInRange ( - 1024 , 1024 ) ;
refRectA . w = 1 ;
refRectA . h = 1 ;
2015-06-21 18:33:46 +03:00
expectedResult = refRectA ;
rectA = refRectA ;
2022-12-27 22:01:11 +03:00
SDL_GetRectUnion ( & rectA , & rectA , & result ) ;
2022-12-30 00:58:16 +03:00
validateUnionRectResults ( & rectA , & rectA , & refRectA , & refRectA , & result , & expectedResult ) ;
2015-06-21 18:33:46 +03:00
/* Union 1x1 somewhere inside */
2022-11-30 23:51:59 +03:00
refRectA . x = SDLTest_RandomIntegerInRange ( - 1024 , 1024 ) ;
refRectA . y = SDLTest_RandomIntegerInRange ( - 1024 , 1024 ) ;
refRectA . w = SDLTest_RandomIntegerInRange ( 256 , 1024 ) ;
refRectA . h = SDLTest_RandomIntegerInRange ( 256 , 1024 ) ;
refRectB . x = refRectA . x + 1 + SDLTest_RandomIntegerInRange ( 1 , refRectA . w - 2 ) ;
refRectB . y = refRectA . y + 1 + SDLTest_RandomIntegerInRange ( 1 , refRectA . h - 2 ) ;
refRectB . w = 1 ;
refRectB . h = 1 ;
2015-06-21 18:33:46 +03:00
expectedResult = refRectA ;
rectA = refRectA ;
rectB = refRectB ;
2022-12-27 22:01:11 +03:00
SDL_GetRectUnion ( & rectA , & rectB , & result ) ;
2022-12-30 00:58:16 +03:00
validateUnionRectResults ( & rectA , & rectB , & refRectA , & refRectB , & result , & expectedResult ) ;
2015-06-21 18:33:46 +03:00
/* Union inside with edges modified */
for ( dx = - 1 ; dx < 2 ; dx + + ) {
for ( dy = - 1 ; dy < 2 ; dy + + ) {
if ( ( dx ! = 0 ) | | ( dy ! = 0 ) ) {
2022-11-30 23:51:59 +03:00
refRectA . x = SDLTest_RandomIntegerInRange ( - 1024 , 1024 ) ;
refRectA . y = SDLTest_RandomIntegerInRange ( - 1024 , 1024 ) ;
refRectA . w = SDLTest_RandomIntegerInRange ( 256 , 1024 ) ;
refRectA . h = SDLTest_RandomIntegerInRange ( 256 , 1024 ) ;
2015-06-21 18:33:46 +03:00
refRectB = refRectA ;
2022-11-27 19:38:43 +03:00
if ( dx = = - 1 ) {
refRectB . x + + ;
}
if ( ( dx = = 1 ) | | ( dx = = - 1 ) ) {
refRectB . w - - ;
}
if ( dy = = - 1 ) {
refRectB . y + + ;
}
if ( ( dy = = 1 ) | | ( dy = = - 1 ) ) {
refRectB . h - - ;
}
2015-06-21 18:33:46 +03:00
expectedResult = refRectA ;
rectA = refRectA ;
rectB = refRectB ;
2022-12-27 22:01:11 +03:00
SDL_GetRectUnion ( & rectA , & rectB , & result ) ;
2022-12-30 00:58:16 +03:00
validateUnionRectResults ( & rectA , & rectB , & refRectA , & refRectB , & result , & expectedResult ) ;
2015-06-21 18:33:46 +03:00
}
}
}
return TEST_COMPLETED ;
}
2023-02-02 02:21:53 +03:00
/**
2022-12-27 22:01:11 +03:00
* \ brief Negative tests against SDL_GetRectUnion ( ) with invalid parameters
2015-06-21 18:33:46 +03:00
*
2023-02-02 02:21:53 +03:00
* \ sa SDL_GetRectUnion
2015-06-21 18:33:46 +03:00
*/
2023-03-08 18:12:45 +03:00
static int rect_testUnionRectParam ( void * arg )
2015-06-21 18:33:46 +03:00
{
2022-06-05 09:53:15 +03:00
SDL_Rect rectA , rectB = { 0 } ;
2015-06-21 18:33:46 +03:00
SDL_Rect result ;
/* invalid parameter combinations */
2022-12-27 22:01:11 +03:00
SDL_GetRectUnion ( ( SDL_Rect * ) NULL , & rectB , & result ) ;
2015-06-21 18:33:46 +03:00
SDLTest_AssertPass ( " Check that function returns when 1st parameter is NULL " ) ;
2022-12-27 22:01:11 +03:00
SDL_GetRectUnion ( & rectA , ( SDL_Rect * ) NULL , & result ) ;
2015-06-21 18:33:46 +03:00
SDLTest_AssertPass ( " Check that function returns when 2nd parameter is NULL " ) ;
2022-12-27 22:01:11 +03:00
SDL_GetRectUnion ( & rectA , & rectB , ( SDL_Rect * ) NULL ) ;
2015-06-21 18:33:46 +03:00
SDLTest_AssertPass ( " Check that function returns when 3rd parameter is NULL " ) ;
2022-12-27 22:01:11 +03:00
SDL_GetRectUnion ( ( SDL_Rect * ) NULL , & rectB , ( SDL_Rect * ) NULL ) ;
2015-06-21 18:33:46 +03:00
SDLTest_AssertPass ( " Check that function returns when 1st and 3rd parameter are NULL " ) ;
2022-12-27 22:01:11 +03:00
SDL_GetRectUnion ( & rectA , ( SDL_Rect * ) NULL , ( SDL_Rect * ) NULL ) ;
2015-06-21 18:33:46 +03:00
SDLTest_AssertPass ( " Check that function returns when 2nd and 3rd parameter are NULL " ) ;
2022-12-27 22:01:11 +03:00
SDL_GetRectUnion ( ( SDL_Rect * ) NULL , ( SDL_Rect * ) NULL , ( SDL_Rect * ) NULL ) ;
2015-06-21 18:33:46 +03:00
SDLTest_AssertPass ( " Check that function returns when all parameters are NULL " ) ;
return TEST_COMPLETED ;
}
2023-02-02 02:21:53 +03:00
/**
2022-12-29 06:34:01 +03:00
* \ brief Tests SDL_RectEmpty ( ) with various inputs
2015-06-21 18:33:46 +03:00
*
2023-02-02 02:21:53 +03:00
* \ sa SDL_RectEmpty
2015-06-21 18:33:46 +03:00
*/
2023-03-08 18:12:45 +03:00
static int rect_testRectEmpty ( void * arg )
2015-06-21 18:33:46 +03:00
{
SDL_Rect refRect ;
SDL_Rect rect ;
SDL_bool expectedResult ;
SDL_bool result ;
int w , h ;
/* Non-empty case */
2022-11-30 23:51:59 +03:00
refRect . x = SDLTest_RandomIntegerInRange ( - 1024 , 1024 ) ;
refRect . y = SDLTest_RandomIntegerInRange ( - 1024 , 1024 ) ;
refRect . w = SDLTest_RandomIntegerInRange ( 256 , 1024 ) ;
refRect . h = SDLTest_RandomIntegerInRange ( 256 , 1024 ) ;
2015-06-21 18:33:46 +03:00
expectedResult = SDL_FALSE ;
rect = refRect ;
2022-12-29 06:34:01 +03:00
result = SDL_RectEmpty ( & rect ) ;
2022-12-30 00:58:16 +03:00
validateRectEmptyResults ( result , expectedResult , & rect , & refRect ) ;
2015-06-21 18:33:46 +03:00
/* Empty case */
2022-11-30 23:51:59 +03:00
for ( w = - 1 ; w < 2 ; w + + ) {
for ( h = - 1 ; h < 2 ; h + + ) {
2015-06-21 18:33:46 +03:00
if ( ( w ! = 1 ) | | ( h ! = 1 ) ) {
2022-11-30 23:51:59 +03:00
refRect . x = SDLTest_RandomIntegerInRange ( - 1024 , 1024 ) ;
refRect . y = SDLTest_RandomIntegerInRange ( - 1024 , 1024 ) ;
refRect . w = w ;
refRect . h = h ;
2015-06-21 18:33:46 +03:00
expectedResult = SDL_TRUE ;
rect = refRect ;
2022-12-29 06:34:01 +03:00
result = SDL_RectEmpty ( & rect ) ;
2022-12-30 00:58:16 +03:00
validateRectEmptyResults ( result , expectedResult , & rect , & refRect ) ;
2015-06-21 18:33:46 +03:00
}
}
}
return TEST_COMPLETED ;
}
2023-02-02 02:21:53 +03:00
/**
2022-12-29 06:34:01 +03:00
* \ brief Negative tests against SDL_RectEmpty ( ) with invalid parameters
2015-06-21 18:33:46 +03:00
*
2023-02-02 02:21:53 +03:00
* \ sa SDL_RectEmpty
2015-06-21 18:33:46 +03:00
*/
2023-03-08 18:12:45 +03:00
static int rect_testRectEmptyParam ( void * arg )
2015-06-21 18:33:46 +03:00
{
SDL_bool result ;
/* invalid parameter combinations */
2022-12-29 06:34:01 +03:00
result = SDL_RectEmpty ( NULL ) ;
2015-06-21 18:33:46 +03:00
SDLTest_AssertCheck ( result = = SDL_TRUE , " Check that function returns TRUE when 1st parameter is NULL " ) ;
return TEST_COMPLETED ;
}
2023-02-02 02:21:53 +03:00
/**
2022-12-29 06:34:01 +03:00
* \ brief Tests SDL_RectsEqual ( ) with various inputs
2015-06-21 18:33:46 +03:00
*
2023-02-02 02:21:53 +03:00
* \ sa SDL_RectsEqual
2015-06-21 18:33:46 +03:00
*/
2023-03-08 18:12:45 +03:00
static int rect_testRectEquals ( void * arg )
2015-06-21 18:33:46 +03:00
{
SDL_Rect refRectA ;
SDL_Rect refRectB ;
SDL_Rect rectA ;
SDL_Rect rectB ;
SDL_bool expectedResult ;
SDL_bool result ;
/* Equals */
2022-11-30 23:51:59 +03:00
refRectA . x = SDLTest_RandomIntegerInRange ( - 1024 , 1024 ) ;
refRectA . y = SDLTest_RandomIntegerInRange ( - 1024 , 1024 ) ;
refRectA . w = SDLTest_RandomIntegerInRange ( 1 , 1024 ) ;
refRectA . h = SDLTest_RandomIntegerInRange ( 1 , 1024 ) ;
2015-06-21 18:33:46 +03:00
refRectB = refRectA ;
expectedResult = SDL_TRUE ;
rectA = refRectA ;
rectB = refRectB ;
2022-12-29 06:34:01 +03:00
result = SDL_RectsEqual ( & rectA , & rectB ) ;
2022-12-30 00:58:16 +03:00
validateRectEqualsResults ( result , expectedResult , & rectA , & rectB , & refRectA , & refRectB ) ;
2015-06-21 18:33:46 +03:00
return TEST_COMPLETED ;
}
2023-02-02 02:21:53 +03:00
/**
2022-12-29 06:34:01 +03:00
* \ brief Negative tests against SDL_RectsEqual ( ) with invalid parameters
2015-06-21 18:33:46 +03:00
*
2023-02-02 02:21:53 +03:00
* \ sa SDL_RectsEqual
2015-06-21 18:33:46 +03:00
*/
2023-03-08 18:12:45 +03:00
static int rect_testRectEqualsParam ( void * arg )
2015-06-21 18:33:46 +03:00
{
SDL_Rect rectA ;
SDL_Rect rectB ;
SDL_bool result ;
/* data setup */
2022-11-30 23:51:59 +03:00
rectA . x = SDLTest_RandomIntegerInRange ( - 1024 , 1024 ) ;
rectA . y = SDLTest_RandomIntegerInRange ( - 1024 , 1024 ) ;
rectA . w = SDLTest_RandomIntegerInRange ( 1 , 1024 ) ;
rectA . h = SDLTest_RandomIntegerInRange ( 1 , 1024 ) ;
rectB . x = SDLTest_RandomIntegerInRange ( - 1024 , 1024 ) ;
rectB . y = SDLTest_RandomIntegerInRange ( - 1024 , 1024 ) ;
rectB . w = SDLTest_RandomIntegerInRange ( 1 , 1024 ) ;
rectB . h = SDLTest_RandomIntegerInRange ( 1 , 1024 ) ;
2015-06-21 18:33:46 +03:00
/* invalid parameter combinations */
2022-12-29 06:34:01 +03:00
result = SDL_RectsEqual ( NULL , & rectB ) ;
2015-06-21 18:33:46 +03:00
SDLTest_AssertCheck ( result = = SDL_FALSE , " Check that function returns SDL_FALSE when 1st parameter is NULL " ) ;
2022-12-29 06:34:01 +03:00
result = SDL_RectsEqual ( & rectA , NULL ) ;
2015-06-21 18:33:46 +03:00
SDLTest_AssertCheck ( result = = SDL_FALSE , " Check that function returns SDL_FALSE when 2nd parameter is NULL " ) ;
2022-12-29 06:34:01 +03:00
result = SDL_RectsEqual ( NULL , NULL ) ;
2015-06-21 18:33:46 +03:00
SDLTest_AssertCheck ( result = = SDL_FALSE , " Check that function returns SDL_FALSE when 1st and 2nd parameter are NULL " ) ;
return TEST_COMPLETED ;
}
2023-02-02 02:21:53 +03:00
/**
2022-12-30 01:50:55 +03:00
* \ brief Tests SDL_RectsEqualFloat ( ) with various inputs
2022-04-20 16:53:25 +03:00
*
2023-02-02 02:21:53 +03:00
* \ sa SDL_RectsEqualFloat
2022-04-20 16:53:25 +03:00
*/
2023-03-08 18:12:45 +03:00
static int rect_testFRectEquals ( void * arg )
2022-04-20 16:53:25 +03:00
{
SDL_FRect refRectA ;
SDL_FRect refRectB ;
SDL_FRect rectA ;
SDL_FRect rectB ;
SDL_bool expectedResult ;
SDL_bool result ;
/* Equals */
2022-11-30 23:51:59 +03:00
refRectA . x = ( float ) SDLTest_RandomIntegerInRange ( - 1024 , 1024 ) ;
refRectA . y = ( float ) SDLTest_RandomIntegerInRange ( - 1024 , 1024 ) ;
refRectA . w = ( float ) SDLTest_RandomIntegerInRange ( 1 , 1024 ) ;
refRectA . h = ( float ) SDLTest_RandomIntegerInRange ( 1 , 1024 ) ;
2022-04-20 16:53:25 +03:00
refRectB = refRectA ;
expectedResult = SDL_TRUE ;
rectA = refRectA ;
rectB = refRectB ;
2022-12-30 01:50:55 +03:00
result = SDL_RectsEqualFloat ( & rectA , & rectB ) ;
2022-12-30 00:58:16 +03:00
validateFRectEqualsResults ( result , expectedResult , & rectA , & rectB , & refRectA , & refRectB ) ;
2022-04-20 16:53:25 +03:00
return TEST_COMPLETED ;
}
2023-02-02 02:21:53 +03:00
/**
2022-12-30 01:50:55 +03:00
* \ brief Negative tests against SDL_RectsEqualFloat ( ) with invalid parameters
2022-04-20 16:53:25 +03:00
*
2023-02-02 02:21:53 +03:00
* \ sa SDL_RectsEqualFloat
2022-04-20 16:53:25 +03:00
*/
2023-03-08 18:12:45 +03:00
static int rect_testFRectEqualsParam ( void * arg )
2022-04-20 16:53:25 +03:00
{
SDL_FRect rectA ;
SDL_FRect rectB ;
SDL_bool result ;
/* data setup -- For the purpose of this test, the values don't matter. */
2022-11-30 23:51:59 +03:00
rectA . x = SDLTest_RandomFloat ( ) ;
rectA . y = SDLTest_RandomFloat ( ) ;
rectA . w = SDLTest_RandomFloat ( ) ;
rectA . h = SDLTest_RandomFloat ( ) ;
rectB . x = SDLTest_RandomFloat ( ) ;
rectB . y = SDLTest_RandomFloat ( ) ;
rectB . w = SDLTest_RandomFloat ( ) ;
rectB . h = SDLTest_RandomFloat ( ) ;
2022-04-20 16:53:25 +03:00
/* invalid parameter combinations */
2022-12-30 01:50:55 +03:00
result = SDL_RectsEqualFloat ( NULL , & rectB ) ;
2022-04-20 16:53:25 +03:00
SDLTest_AssertCheck ( result = = SDL_FALSE , " Check that function returns SDL_FALSE when 1st parameter is NULL " ) ;
2022-12-30 01:50:55 +03:00
result = SDL_RectsEqualFloat ( & rectA , NULL ) ;
2022-04-20 16:53:25 +03:00
SDLTest_AssertCheck ( result = = SDL_FALSE , " Check that function returns SDL_FALSE when 2nd parameter is NULL " ) ;
2022-12-30 01:50:55 +03:00
result = SDL_RectsEqualFloat ( NULL , NULL ) ;
2022-04-20 16:53:25 +03:00
SDLTest_AssertCheck ( result = = SDL_FALSE , " Check that function returns SDL_FALSE when 1st and 2nd parameter are NULL " ) ;
return TEST_COMPLETED ;
}
2015-06-21 18:33:46 +03:00
/* ================= Test References ================== */
/* Rect test cases */
2022-12-27 22:01:11 +03:00
/* SDL_GetRectAndLineIntersection */
2022-11-30 23:51:59 +03:00
static const SDLTest_TestCaseReference rectTest1 = {
2022-12-27 22:01:11 +03:00
( SDLTest_TestCaseFp ) rect_testIntersectRectAndLine , " rect_testIntersectRectAndLine " , " Tests SDL_GetRectAndLineIntersection clipping cases " , TEST_ENABLED
2022-11-30 23:51:59 +03:00
} ;
2015-06-21 18:33:46 +03:00
2022-11-30 23:51:59 +03:00
static const SDLTest_TestCaseReference rectTest2 = {
2022-12-27 22:01:11 +03:00
( SDLTest_TestCaseFp ) rect_testIntersectRectAndLineInside , " rect_testIntersectRectAndLineInside " , " Tests SDL_GetRectAndLineIntersection with line fully contained in rect " , TEST_ENABLED
2022-11-30 23:51:59 +03:00
} ;
2015-06-21 18:33:46 +03:00
2022-11-30 23:51:59 +03:00
static const SDLTest_TestCaseReference rectTest3 = {
2022-12-27 22:01:11 +03:00
( SDLTest_TestCaseFp ) rect_testIntersectRectAndLineOutside , " rect_testIntersectRectAndLineOutside " , " Tests SDL_GetRectAndLineIntersection with line fully outside of rect " , TEST_ENABLED
2022-11-30 23:51:59 +03:00
} ;
2015-06-21 18:33:46 +03:00
2022-11-30 23:51:59 +03:00
static const SDLTest_TestCaseReference rectTest4 = {
2022-12-27 22:01:11 +03:00
( SDLTest_TestCaseFp ) rect_testIntersectRectAndLineEmpty , " rect_testIntersectRectAndLineEmpty " , " Tests SDL_GetRectAndLineIntersection with empty rectangle " , TEST_ENABLED
2022-11-30 23:51:59 +03:00
} ;
2015-06-21 18:33:46 +03:00
2022-11-30 23:51:59 +03:00
static const SDLTest_TestCaseReference rectTest5 = {
2022-12-27 22:01:11 +03:00
( SDLTest_TestCaseFp ) rect_testIntersectRectAndLineParam , " rect_testIntersectRectAndLineParam " , " Negative tests against SDL_GetRectAndLineIntersection with invalid parameters " , TEST_ENABLED
2022-11-30 23:51:59 +03:00
} ;
2015-06-21 18:33:46 +03:00
2022-12-27 22:01:11 +03:00
/* SDL_GetRectIntersection */
2022-11-30 23:51:59 +03:00
static const SDLTest_TestCaseReference rectTest6 = {
2022-12-27 22:01:11 +03:00
( SDLTest_TestCaseFp ) rect_testIntersectRectInside , " rect_testIntersectRectInside " , " Tests SDL_GetRectIntersection with B fully contained in A " , TEST_ENABLED
2022-11-30 23:51:59 +03:00
} ;
2015-06-21 18:33:46 +03:00
2022-11-30 23:51:59 +03:00
static const SDLTest_TestCaseReference rectTest7 = {
2022-12-27 22:01:11 +03:00
( SDLTest_TestCaseFp ) rect_testIntersectRectOutside , " rect_testIntersectRectOutside " , " Tests SDL_GetRectIntersection with B fully outside of A " , TEST_ENABLED
2022-11-30 23:51:59 +03:00
} ;
2015-06-21 18:33:46 +03:00
2022-11-30 23:51:59 +03:00
static const SDLTest_TestCaseReference rectTest8 = {
2022-12-27 22:01:11 +03:00
( SDLTest_TestCaseFp ) rect_testIntersectRectPartial , " rect_testIntersectRectPartial " , " Tests SDL_GetRectIntersection with B partially intersecting A " , TEST_ENABLED
2022-11-30 23:51:59 +03:00
} ;
2015-06-21 18:33:46 +03:00
2022-11-30 23:51:59 +03:00
static const SDLTest_TestCaseReference rectTest9 = {
2022-12-27 22:01:11 +03:00
( SDLTest_TestCaseFp ) rect_testIntersectRectPoint , " rect_testIntersectRectPoint " , " Tests SDL_GetRectIntersection with 1x1 sized rectangles " , TEST_ENABLED
2022-11-30 23:51:59 +03:00
} ;
2015-06-21 18:33:46 +03:00
2022-11-30 23:51:59 +03:00
static const SDLTest_TestCaseReference rectTest10 = {
2022-12-27 22:01:11 +03:00
( SDLTest_TestCaseFp ) rect_testIntersectRectEmpty , " rect_testIntersectRectEmpty " , " Tests SDL_GetRectIntersection with empty rectangles " , TEST_ENABLED
2022-11-30 23:51:59 +03:00
} ;
2015-06-21 18:33:46 +03:00
2022-11-30 23:51:59 +03:00
static const SDLTest_TestCaseReference rectTest11 = {
2022-12-27 22:01:11 +03:00
( SDLTest_TestCaseFp ) rect_testIntersectRectParam , " rect_testIntersectRectParam " , " Negative tests against SDL_GetRectIntersection with invalid parameters " , TEST_ENABLED
2022-11-30 23:51:59 +03:00
} ;
2015-06-21 18:33:46 +03:00
2022-12-27 22:01:11 +03:00
/* SDL_HasRectIntersection */
2022-11-30 23:51:59 +03:00
static const SDLTest_TestCaseReference rectTest12 = {
2022-12-27 22:01:11 +03:00
( SDLTest_TestCaseFp ) rect_testHasIntersectionInside , " rect_testHasIntersectionInside " , " Tests SDL_HasRectIntersection with B fully contained in A " , TEST_ENABLED
2022-11-30 23:51:59 +03:00
} ;
2015-06-21 18:33:46 +03:00
2022-11-30 23:51:59 +03:00
static const SDLTest_TestCaseReference rectTest13 = {
2022-12-27 22:01:11 +03:00
( SDLTest_TestCaseFp ) rect_testHasIntersectionOutside , " rect_testHasIntersectionOutside " , " Tests SDL_HasRectIntersection with B fully outside of A " , TEST_ENABLED
2022-11-30 23:51:59 +03:00
} ;
2015-06-21 18:33:46 +03:00
2022-11-30 23:51:59 +03:00
static const SDLTest_TestCaseReference rectTest14 = {
2022-12-27 22:01:11 +03:00
( SDLTest_TestCaseFp ) rect_testHasIntersectionPartial , " rect_testHasIntersectionPartial " , " Tests SDL_HasRectIntersection with B partially intersecting A " , TEST_ENABLED
2022-11-30 23:51:59 +03:00
} ;
2015-06-21 18:33:46 +03:00
2022-11-30 23:51:59 +03:00
static const SDLTest_TestCaseReference rectTest15 = {
2022-12-27 22:01:11 +03:00
( SDLTest_TestCaseFp ) rect_testHasIntersectionPoint , " rect_testHasIntersectionPoint " , " Tests SDL_HasRectIntersection with 1x1 sized rectangles " , TEST_ENABLED
2022-11-30 23:51:59 +03:00
} ;
2015-06-21 18:33:46 +03:00
2022-11-30 23:51:59 +03:00
static const SDLTest_TestCaseReference rectTest16 = {
2022-12-27 22:01:11 +03:00
( SDLTest_TestCaseFp ) rect_testHasIntersectionEmpty , " rect_testHasIntersectionEmpty " , " Tests SDL_HasRectIntersection with empty rectangles " , TEST_ENABLED
2022-11-30 23:51:59 +03:00
} ;
2015-06-21 18:33:46 +03:00
2022-11-30 23:51:59 +03:00
static const SDLTest_TestCaseReference rectTest17 = {
2022-12-27 22:01:11 +03:00
( SDLTest_TestCaseFp ) rect_testHasIntersectionParam , " rect_testHasIntersectionParam " , " Negative tests against SDL_HasRectIntersection with invalid parameters " , TEST_ENABLED
2022-11-30 23:51:59 +03:00
} ;
2015-06-21 18:33:46 +03:00
2022-12-27 22:01:11 +03:00
/* SDL_GetRectEnclosingPoints */
2022-11-30 23:51:59 +03:00
static const SDLTest_TestCaseReference rectTest18 = {
2022-12-27 22:01:11 +03:00
( SDLTest_TestCaseFp ) rect_testEnclosePoints , " rect_testEnclosePoints " , " Tests SDL_GetRectEnclosingPoints without clipping " , TEST_ENABLED
2022-11-30 23:51:59 +03:00
} ;
2015-06-21 18:33:46 +03:00
2022-11-30 23:51:59 +03:00
static const SDLTest_TestCaseReference rectTest19 = {
2022-12-27 22:01:11 +03:00
( SDLTest_TestCaseFp ) rect_testEnclosePointsWithClipping , " rect_testEnclosePointsWithClipping " , " Tests SDL_GetRectEnclosingPoints with clipping " , TEST_ENABLED
2022-11-30 23:51:59 +03:00
} ;
2015-06-21 18:33:46 +03:00
2022-11-30 23:51:59 +03:00
static const SDLTest_TestCaseReference rectTest20 = {
2022-12-27 22:01:11 +03:00
( SDLTest_TestCaseFp ) rect_testEnclosePointsRepeatedInput , " rect_testEnclosePointsRepeatedInput " , " Tests SDL_GetRectEnclosingPoints with repeated input " , TEST_ENABLED
2022-11-30 23:51:59 +03:00
} ;
2015-06-21 18:33:46 +03:00
2022-11-30 23:51:59 +03:00
static const SDLTest_TestCaseReference rectTest21 = {
2022-12-27 22:01:11 +03:00
( SDLTest_TestCaseFp ) rect_testEnclosePointsParam , " rect_testEnclosePointsParam " , " Negative tests against SDL_GetRectEnclosingPoints with invalid parameters " , TEST_ENABLED
2022-11-30 23:51:59 +03:00
} ;
2015-06-21 18:33:46 +03:00
2022-12-27 22:01:11 +03:00
/* SDL_GetRectUnion */
2022-11-30 23:51:59 +03:00
static const SDLTest_TestCaseReference rectTest22 = {
2022-12-27 22:01:11 +03:00
( SDLTest_TestCaseFp ) rect_testUnionRectInside , " rect_testUnionRectInside " , " Tests SDL_GetRectUnion where rect B is inside rect A " , TEST_ENABLED
2022-11-30 23:51:59 +03:00
} ;
2015-06-21 18:33:46 +03:00
2022-11-30 23:51:59 +03:00
static const SDLTest_TestCaseReference rectTest23 = {
2022-12-27 22:01:11 +03:00
( SDLTest_TestCaseFp ) rect_testUnionRectOutside , " rect_testUnionRectOutside " , " Tests SDL_GetRectUnion where rect B is outside rect A " , TEST_ENABLED
2022-11-30 23:51:59 +03:00
} ;
2015-06-21 18:33:46 +03:00
2022-11-30 23:51:59 +03:00
static const SDLTest_TestCaseReference rectTest24 = {
2022-12-27 22:01:11 +03:00
( SDLTest_TestCaseFp ) rect_testUnionRectEmpty , " rect_testUnionRectEmpty " , " Tests SDL_GetRectUnion where rect A or rect B are empty " , TEST_ENABLED
2022-11-30 23:51:59 +03:00
} ;
2015-06-21 18:33:46 +03:00
2022-11-30 23:51:59 +03:00
static const SDLTest_TestCaseReference rectTest25 = {
2022-12-27 22:01:11 +03:00
( SDLTest_TestCaseFp ) rect_testUnionRectParam , " rect_testUnionRectParam " , " Negative tests against SDL_GetRectUnion with invalid parameters " , TEST_ENABLED
2022-11-30 23:51:59 +03:00
} ;
2015-06-21 18:33:46 +03:00
2022-12-29 06:34:01 +03:00
/* SDL_RectEmpty */
2022-11-30 23:51:59 +03:00
static const SDLTest_TestCaseReference rectTest26 = {
2022-12-29 06:34:01 +03:00
( SDLTest_TestCaseFp ) rect_testRectEmpty , " rect_testRectEmpty " , " Tests SDL_RectEmpty with various inputs " , TEST_ENABLED
2022-11-30 23:51:59 +03:00
} ;
2015-06-21 18:33:46 +03:00
2022-11-30 23:51:59 +03:00
static const SDLTest_TestCaseReference rectTest27 = {
2022-12-29 06:34:01 +03:00
( SDLTest_TestCaseFp ) rect_testRectEmptyParam , " rect_testRectEmptyParam " , " Negative tests against SDL_RectEmpty with invalid parameters " , TEST_ENABLED
2022-11-30 23:51:59 +03:00
} ;
2015-06-21 18:33:46 +03:00
2022-12-29 06:34:01 +03:00
/* SDL_RectsEqual */
2015-06-21 18:33:46 +03:00
2022-11-30 23:51:59 +03:00
static const SDLTest_TestCaseReference rectTest28 = {
2022-12-29 06:34:01 +03:00
( SDLTest_TestCaseFp ) rect_testRectEquals , " rect_testRectEquals " , " Tests SDL_RectsEqual with various inputs " , TEST_ENABLED
2022-11-30 23:51:59 +03:00
} ;
2015-06-21 18:33:46 +03:00
2022-11-30 23:51:59 +03:00
static const SDLTest_TestCaseReference rectTest29 = {
2022-12-29 06:34:01 +03:00
( SDLTest_TestCaseFp ) rect_testRectEqualsParam , " rect_testRectEqualsParam " , " Negative tests against SDL_RectsEqual with invalid parameters " , TEST_ENABLED
2022-11-30 23:51:59 +03:00
} ;
2015-06-21 18:33:46 +03:00
2022-12-30 01:50:55 +03:00
/* SDL_RectsEqualFloat */
2022-04-20 16:53:25 +03:00
2022-11-30 23:51:59 +03:00
static const SDLTest_TestCaseReference rectTest30 = {
2022-12-30 01:50:55 +03:00
( SDLTest_TestCaseFp ) rect_testFRectEquals , " rect_testFRectEquals " , " Tests SDL_RectsEqualFloat with various inputs " , TEST_ENABLED
2022-11-30 23:51:59 +03:00
} ;
2022-04-20 16:53:25 +03:00
2022-11-30 23:51:59 +03:00
static const SDLTest_TestCaseReference rectTest31 = {
2022-12-30 01:50:55 +03:00
( SDLTest_TestCaseFp ) rect_testFRectEqualsParam , " rect_testFRectEqualsParam " , " Negative tests against SDL_RectsEqualFloat with invalid parameters " , TEST_ENABLED
2022-11-30 23:51:59 +03:00
} ;
2015-06-21 18:33:46 +03:00
2023-02-02 02:21:53 +03:00
/**
2015-06-21 18:33:46 +03:00
* \ brief Sequence of Rect test cases ; functions that handle simple rectangles including overlaps and merges .
*/
2022-11-30 23:51:59 +03:00
static const SDLTest_TestCaseReference * rectTests [ ] = {
2015-06-21 18:33:46 +03:00
& rectTest1 , & rectTest2 , & rectTest3 , & rectTest4 , & rectTest5 , & rectTest6 , & rectTest7 , & rectTest8 , & rectTest9 , & rectTest10 , & rectTest11 , & rectTest12 , & rectTest13 , & rectTest14 ,
& rectTest15 , & rectTest16 , & rectTest17 , & rectTest18 , & rectTest19 , & rectTest20 , & rectTest21 , & rectTest22 , & rectTest23 , & rectTest24 , & rectTest25 , & rectTest26 , & rectTest27 ,
2022-04-20 16:53:25 +03:00
& rectTest28 , & rectTest29 , & rectTest30 , & rectTest31 , NULL
2015-06-21 18:33:46 +03:00
} ;
/* Rect test suite (global) */
SDLTest_TestSuiteReference rectTestSuite = {
" Rect " ,
NULL ,
rectTests ,
NULL
} ;