Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
libSDL
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
PocketInsanity
libSDL
Commits
9d8f2b69
Commit
9d8f2b69
authored
Sep 16, 2011
by
Andreas Schiffler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add test cases for SDL_RectEmpty
parent
6e3ff8fd
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
83 additions
and
2 deletions
+83
-2
testrect.c
test/test-automation/tests/testrect/testrect.c
+83
-2
No files found.
test/test-automation/tests/testrect/testrect.c
View file @
9d8f2b69
...
@@ -77,7 +77,13 @@ static const TestCaseReference test20 =
...
@@ -77,7 +77,13 @@ static const TestCaseReference test20 =
static
const
TestCaseReference
test21
=
static
const
TestCaseReference
test21
=
(
TestCaseReference
){
"rect_testUnionRectParam"
,
"Negative tests against SDL_UnionRect with invalid parameters"
,
TEST_ENABLED
,
0
,
0
};
(
TestCaseReference
){
"rect_testUnionRectParam"
,
"Negative tests against SDL_UnionRect with invalid parameters"
,
TEST_ENABLED
,
0
,
0
};
/* TODO: SDL_RectEmpty */
/* SDL_RectEmpty */
static
const
TestCaseReference
test22
=
(
TestCaseReference
){
"rect_testRectEmpty"
,
"Tests SDL_RectEmpty with various inputs"
,
TEST_ENABLED
,
0
,
0
};
static
const
TestCaseReference
test23
=
(
TestCaseReference
){
"rect_testRectEmptyParam"
,
"Negative tests against SDL_RectEmpty with invalid parameters"
,
TEST_ENABLED
,
0
,
0
};
/* TODO: SDL_RectEquals */
/* TODO: SDL_RectEquals */
/*!
/*!
...
@@ -88,7 +94,7 @@ static const TestCaseReference test21 =
...
@@ -88,7 +94,7 @@ static const TestCaseReference test21 =
*/
*/
extern
const
TestCaseReference
*
testSuite
[]
=
{
extern
const
TestCaseReference
*
testSuite
[]
=
{
&
test1
,
&
test2
,
&
test3
,
&
test4
,
&
test5
,
&
test6
,
&
test7
,
&
test8
,
&
test9
,
&
test10
,
&
test11
,
&
test12
,
&
test13
,
&
test14
,
&
test1
,
&
test2
,
&
test3
,
&
test4
,
&
test5
,
&
test6
,
&
test7
,
&
test8
,
&
test9
,
&
test10
,
&
test11
,
&
test12
,
&
test13
,
&
test14
,
&
test15
,
&
test16
,
&
test17
,
&
test18
,
&
test19
,
&
test20
,
&
test21
,
NULL
&
test15
,
&
test16
,
&
test17
,
&
test18
,
&
test19
,
&
test20
,
&
test21
,
&
test22
,
&
test23
,
NULL
};
};
TestCaseReference
**
QueryTestSuite
()
{
TestCaseReference
**
QueryTestSuite
()
{
...
@@ -402,6 +408,24 @@ void _validateUnionRectResults(
...
@@ -402,6 +408,24 @@ void _validateUnionRectResults(
expectedResult
->
x
,
expectedResult
->
y
,
expectedResult
->
w
,
expectedResult
->
h
);
expectedResult
->
x
,
expectedResult
->
y
,
expectedResult
->
w
,
expectedResult
->
h
);
}
}
/*!
* \brief Private helper to check SDL_RectEmpty results
*/
void
_validateRectEmptyResults
(
SDL_bool
empty
,
SDL_bool
expectedEmpty
,
SDL_Rect
*
rect
,
SDL_Rect
*
refRect
)
{
AssertTrue
(
empty
==
expectedEmpty
,
"Incorrect empty result: expected %s, got %s testing (%d,%d,%d,%d)
\n
"
,
(
expectedEmpty
==
SDL_TRUE
)
?
"true"
:
"false"
,
(
empty
==
SDL_TRUE
)
?
"true"
:
"false"
,
rect
->
x
,
rect
->
y
,
rect
->
w
,
rect
->
h
);
AssertTrue
(
rect
->
x
==
refRect
->
x
&&
rect
->
y
==
refRect
->
y
&&
rect
->
w
==
refRect
->
w
&&
rect
->
h
==
refRect
->
h
,
"Source rectangle was 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
);
}
/*!
/*!
* \brief Tests SDL_IntersectRect() with B fully inside A
* \brief Tests SDL_IntersectRect() with B fully inside A
*
*
...
@@ -1199,3 +1223,60 @@ int rect_testUnionRectParam(void *arg)
...
@@ -1199,3 +1223,60 @@ int rect_testUnionRectParam(void *arg)
SDL_UnionRect
((
SDL_Rect
*
)
NULL
,
(
SDL_Rect
*
)
NULL
,
(
SDL_Rect
*
)
NULL
);
SDL_UnionRect
((
SDL_Rect
*
)
NULL
,
(
SDL_Rect
*
)
NULL
,
(
SDL_Rect
*
)
NULL
);
AssertPass
(
"Function did return when all parameters were NULL"
);
AssertPass
(
"Function did return when all parameters were NULL"
);
}
}
/*!
* \brief Tests SDL_RectEmpty() with various inputs
*
* \sa
* http://wiki.libsdl.org/moin.cgi/SDL_RectEmpty
*/
int
rect_testRectEmpty
(
void
*
arg
)
{
SDL_Rect
refRect
;
SDL_Rect
rect
;
SDL_bool
expectedResult
;
SDL_bool
result
;
int
w
,
h
;
// Non-empty case
refRect
.
x
=
RandomIntegerInRange
(
-
1024
,
1024
);
refRect
.
y
=
RandomIntegerInRange
(
-
1024
,
1024
);
refRect
.
w
=
RandomIntegerInRange
(
256
,
1024
);
refRect
.
h
=
RandomIntegerInRange
(
256
,
1024
);
expectedResult
=
SDL_FALSE
;
rect
=
refRect
;
result
=
SDL_RectEmpty
((
const
SDL_Rect
*
)
&
rect
);
_validateRectEmptyResults
(
result
,
expectedResult
,
&
rect
,
&
refRect
);
// Empty case
for
(
w
=-
1
;
w
<
2
;
w
++
)
{
for
(
h
=-
1
;
h
<
2
;
h
++
)
{
if
((
w
!=
1
)
||
(
h
!=
1
))
{
refRect
.
x
=
RandomIntegerInRange
(
-
1024
,
1024
);
refRect
.
y
=
RandomIntegerInRange
(
-
1024
,
1024
);
refRect
.
w
=
w
;
refRect
.
h
=
h
;
expectedResult
=
SDL_TRUE
;
rect
=
refRect
;
result
=
SDL_RectEmpty
((
const
SDL_Rect
*
)
&
rect
);
_validateRectEmptyResults
(
result
,
expectedResult
,
&
rect
,
&
refRect
);
}
}
}
}
/*!
* \brief Negative tests against SDL_RectEmpty() with invalid parameters
*
* \sa
* http://wiki.libsdl.org/moin.cgi/SDL_RectEmpty
*/
int
rect_testRectEmptyParam
(
void
*
arg
)
{
SDL_Rect
rect
;
SDL_bool
result
;
// invalid parameter combinations
result
=
SDL_RectEmpty
((
const
SDL_Rect
*
)
NULL
);
AssertTrue
(
result
=
SDL_TRUE
,
"Function did not return TRUE when 1st parameter was NULL"
);
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment