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
a2c9c4d2
Commit
a2c9c4d2
authored
Jul 21, 2011
by
Andreas Schiffler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added test case for power management function; improved assertions in tests
parent
82d0a869
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
105 additions
and
1 deletion
+105
-1
testplatform.c
test/test-automation/testplatform/testplatform.c
+105
-1
No files found.
test/test-automation/testplatform/testplatform.c
View file @
a2c9c4d2
...
@@ -40,9 +40,12 @@ static const TestCaseReference test9 =
...
@@ -40,9 +40,12 @@ static const TestCaseReference test9 =
static
const
TestCaseReference
test10
=
static
const
TestCaseReference
test10
=
(
TestCaseReference
){
"platform_testSetErrorInvalidInput"
,
"Tests SDL_SetError with invalid input"
,
TEST_ENABLED
,
0
,
0
};
(
TestCaseReference
){
"platform_testSetErrorInvalidInput"
,
"Tests SDL_SetError with invalid input"
,
TEST_ENABLED
,
0
,
0
};
static
const
TestCaseReference
test11
=
(
TestCaseReference
){
"platform_testGetPowerInfo"
,
"Tests SDL_GetPowerInfo function"
,
TEST_ENABLED
,
0
,
0
};
/* Test suite */
/* Test suite */
extern
const
TestCaseReference
*
testSuite
[]
=
{
extern
const
TestCaseReference
*
testSuite
[]
=
{
&
test1
,
&
test2
,
&
test3
,
&
test4
,
&
test5
,
&
test6
,
&
test7
,
&
test8
,
&
test9
,
&
test10
,
NULL
&
test1
,
&
test2
,
&
test3
,
&
test4
,
&
test5
,
&
test6
,
&
test7
,
&
test8
,
&
test9
,
&
test10
,
&
test11
,
NULL
};
};
TestCaseReference
**
QueryTestSuite
()
{
TestCaseReference
**
QueryTestSuite
()
{
...
@@ -137,6 +140,10 @@ int platform_testEndianessAndSwap(void *arg)
...
@@ -137,6 +140,10 @@ int platform_testEndianessAndSwap(void *arg)
* \brief Tests SDL_GetXYZ() functions
* \brief Tests SDL_GetXYZ() functions
* \sa
* \sa
* http://wiki.libsdl.org/moin.cgi/SDL_GetPlatform
* http://wiki.libsdl.org/moin.cgi/SDL_GetPlatform
* http://wiki.libsdl.org/moin.cgi/SDL_GetCPUCount
* http://wiki.libsdl.org/moin.cgi/SDL_GetCPUCacheLineSize
* http://wiki.libsdl.org/moin.cgi/SDL_GetRevision
* http://wiki.libsdl.org/moin.cgi/SDL_GetRevisionNumber
*/
*/
int
platform_testGetFunctions
(
void
*
arg
)
int
platform_testGetFunctions
(
void
*
arg
)
{
{
...
@@ -158,6 +165,15 @@ int platform_testGetFunctions (void *arg)
...
@@ -158,6 +165,15 @@ int platform_testGetFunctions (void *arg)
ret
=
SDL_GetCPUCount
();
ret
=
SDL_GetCPUCount
();
AssertPass
(
"SDL_GetCPUCount()"
);
AssertPass
(
"SDL_GetCPUCount()"
);
AssertTrue
(
ret
>
0
,
"SDL_GetCPUCount(): expected count > 0, was: %i"
,
ret
);
ret
=
SDL_GetCPUCacheLineSize
();
AssertPass
(
"SDL_GetCPUCacheLineSize()"
);
AssertTrue
(
ret
>=
0
,
"SDL_GetCPUCacheLineSize(): expected size >= 0, was: %i"
,
ret
);
revision
=
(
char
*
)
SDL_GetRevision
();
revision
=
(
char
*
)
SDL_GetRevision
();
AssertPass
(
"SDL_GetRevision()"
);
AssertPass
(
"SDL_GetRevision()"
);
...
@@ -169,6 +185,16 @@ int platform_testGetFunctions (void *arg)
...
@@ -169,6 +185,16 @@ int platform_testGetFunctions (void *arg)
/*!
/*!
* \brief Tests SDL_HasXYZ() functions
* \brief Tests SDL_HasXYZ() functions
* \sa
* http://wiki.libsdl.org/moin.cgi/SDL_Has3DNow
* http://wiki.libsdl.org/moin.cgi/SDL_HasAltiVec
* http://wiki.libsdl.org/moin.cgi/SDL_HasMMX
* http://wiki.libsdl.org/moin.cgi/SDL_HasRDTSC
* http://wiki.libsdl.org/moin.cgi/SDL_HasSSE
* http://wiki.libsdl.org/moin.cgi/SDL_HasSSE2
* http://wiki.libsdl.org/moin.cgi/SDL_HasSSE3
* http://wiki.libsdl.org/moin.cgi/SDL_HasSSE41
* http://wiki.libsdl.org/moin.cgi/SDL_HasSSE42
*/
*/
int
platform_testHasFunctions
(
void
*
arg
)
int
platform_testHasFunctions
(
void
*
arg
)
{
{
...
@@ -206,6 +232,8 @@ int platform_testHasFunctions (void *arg)
...
@@ -206,6 +232,8 @@ int platform_testHasFunctions (void *arg)
/*!
/*!
* \brief Tests SDL_GetVersion
* \brief Tests SDL_GetVersion
* \sa
* http://wiki.libsdl.org/moin.cgi/SDL_GetVersion
*/
*/
int
platform_testGetVersion
(
void
*
arg
)
int
platform_testGetVersion
(
void
*
arg
)
{
{
...
@@ -402,3 +430,79 @@ int platform_testSetErrorInvalidInput(void *arg)
...
@@ -402,3 +430,79 @@ int platform_testSetErrorInvalidInput(void *arg)
// Clean up
// Clean up
SDL_ClearError
();
SDL_ClearError
();
}
}
/*!
* \brief Tests SDL_GetPowerInfo
* \sa
* http://wiki.libsdl.org/moin.cgi/SDL_GetPowerInfo
*/
int
platform_testGetPowerInfo
(
void
*
arg
)
{
SDL_PowerState
state
;
SDL_PowerState
stateAgain
;
int
secs
;
int
secsAgain
;
int
pct
;
int
pctAgain
;
state
=
SDL_GetPowerInfo
(
&
secs
,
&
pct
);
AssertPass
(
"SDL_GetPowerInfo()"
);
AssertTrue
(
state
==
SDL_POWERSTATE_UNKNOWN
||
state
==
SDL_POWERSTATE_ON_BATTERY
||
state
==
SDL_POWERSTATE_NO_BATTERY
||
state
==
SDL_POWERSTATE_CHARGING
||
state
==
SDL_POWERSTATE_CHARGED
,
"SDL_GetPowerInfo(): state %i is one of the expected values"
,
(
int
)
state
);
if
(
state
==
SDL_POWERSTATE_ON_BATTERY
)
{
AssertTrue
(
secs
>=
0
,
"SDL_GetPowerInfo(): on battery, secs >= 0, was: %i"
,
secs
);
AssertTrue
(
(
pct
>=
0
)
&&
(
pct
<=
100
),
"SDL_GetPowerInfo(): on battery, pct=[0,100], was: %i"
,
pct
);
}
if
(
state
==
SDL_POWERSTATE_UNKNOWN
||
state
==
SDL_POWERSTATE_NO_BATTERY
)
{
AssertTrue
(
secs
==
-
1
,
"SDL_GetPowerInfo(): no battery, secs == -1, was: %i"
,
secs
);
AssertTrue
(
pct
==
-
1
,
"SDL_GetPowerInfo(): no battery, pct == -1, was: %i"
,
pct
);
}
// Partial return value variations
stateAgain
=
SDL_GetPowerInfo
(
&
secsAgain
,
NULL
);
AssertTrue
(
state
==
stateAgain
,
"State %i returned when only 'secs' requested"
,
stateAgain
);
AssertTrue
(
secs
==
secsAgain
,
"Value %i matches when only 'secs' requested"
,
secsAgain
);
stateAgain
=
SDL_GetPowerInfo
(
NULL
,
&
pctAgain
);
AssertTrue
(
state
==
stateAgain
,
"State %i returned when only 'pct' requested"
,
stateAgain
);
AssertTrue
(
pct
==
pctAgain
,
"Value %i matches when only 'pct' requested"
,
pctAgain
);
stateAgain
=
SDL_GetPowerInfo
(
NULL
,
NULL
);
AssertTrue
(
state
==
stateAgain
,
"State %i returned when no value requested"
,
stateAgain
);
}
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