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
9ffc5e8e
Commit
9ffc5e8e
authored
Aug 11, 2011
by
Markus Kauppila
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Cleaned up the rwops test suite.
parent
8e4d7085
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
39 additions
and
50 deletions
+39
-50
testdummy.c
test/test-automation/tests/testdummy/testdummy.c
+1
-1
Makefile.am
test/test-automation/tests/testrwops/Makefile.am
+1
-1
TestSupportRWops_Generic.c
...est-automation/tests/testrwops/TestSupportRWops_Generic.c
+0
-31
testrwops.c
test/test-automation/tests/testrwops/testrwops.c
+37
-17
No files found.
test/test-automation/tests/testdummy/testdummy.c
View file @
9ffc5e8e
...
@@ -100,7 +100,7 @@ dummycase1(void *arg)
...
@@ -100,7 +100,7 @@ dummycase1(void *arg)
//Log(0, "uint8 (same value): %d", RandomUint8BoundaryValue(200, 200, SDL_TRUE));
//Log(0, "uint8 (same value): %d", RandomUint8BoundaryValue(200, 200, SDL_TRUE));
for
(;
0
1
;
)
for
(;
0
;
)
printf
(
"%d
\n
"
,
RandomSint16
());
printf
(
"%d
\n
"
,
RandomSint16
());
for
(
;
0
;
)
{
for
(
;
0
;
)
{
...
...
test/test-automation/tests/testrwops/Makefile.am
View file @
9ffc5e8e
lib_LTLIBRARIES
=
libtestrwops.la
lib_LTLIBRARIES
=
libtestrwops.la
libtestrwops_la_SOURCES
=
testrwops.c
TestSupportRWops_Generic.c
libtestrwops_la_SOURCES
=
testrwops.c
libtestrwops_la_CLAGS
=
-fPIC
-g
libtestrwops_la_CLAGS
=
-fPIC
-g
libtestrwops_la_LDFLAGS
=
`
sdl-config
--libs
`
-I
../../src/libSDLtest/.libs/libSDLtest.la
libtestrwops_la_LDFLAGS
=
`
sdl-config
--libs
`
-I
../../src/libSDLtest/.libs/libSDLtest.la
test/test-automation/tests/testrwops/TestSupportRWops_Generic.c
deleted
100644 → 0
View file @
8e4d7085
/* Generic implementation for file opening routines.
* Customizations for specific platforms should go in alternative files.
*/
// quiet windows compiler warnings
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <SDL/SDL.h>
#include "TestSupportRWops.h"
FILE
*
TestSupportRWops_OpenFPFromReadDir
(
const
char
*
file
,
const
char
*
mode
)
{
return
fopen
(
file
,
mode
);
}
FILE
*
TestSupportRWops_OpenFPFromWriteDir
(
const
char
*
file
,
const
char
*
mode
)
{
return
fopen
(
file
,
mode
);
}
SDL_RWops
*
TestSupportRWops_OpenRWopsFromReadDir
(
const
char
*
file
,
const
char
*
mode
)
{
return
SDL_RWFromFile
(
file
,
mode
);
}
SDL_RWops
*
TestSupportRWops_OpenRWopsFromWriteDir
(
const
char
*
file
,
const
char
*
mode
)
{
return
SDL_RWFromFile
(
file
,
mode
);
}
test/test-automation/tests/testrwops/testrwops.c
View file @
9ffc5e8e
...
@@ -13,12 +13,9 @@
...
@@ -13,12 +13,9 @@
#include "../../include/SDL_test.h"
#include "../../include/SDL_test.h"
#include "TestSupportRWops.h"
const
char
*
RWOPS_READ
=
"tests/testrwops/read"
;
const
char
*
RWOPS_READ
=
"tests/testrwops/read"
;
const
char
*
RWOPS_WRITE
=
"tests/testrwops/write"
;
const
char
*
RWOPS_WRITE
=
"tests/testrwops/write"
;
static
const
char
hello_world
[]
=
"Hello World!"
;
static
const
char
hello_world
[]
=
"Hello World!"
;
static
const
char
const_mem
[]
=
"Hello World!"
;
static
const
char
const_mem
[]
=
"Hello World!"
;
...
@@ -51,6 +48,11 @@ TestCaseReference **QueryTestSuite() {
...
@@ -51,6 +48,11 @@ TestCaseReference **QueryTestSuite() {
/**
/**
* @brief Makes sure parameters work properly. Helper function
* @brief Makes sure parameters work properly. Helper function
*
* \sa
* http://wiki.libsdl.org/moin.cgi/SDL_RWseek
* http://wiki.libsdl.org/moin.cgi/SDL_RWread
*
*/
*/
int
_testGeneric
(
SDL_RWops
*
rw
,
int
write
)
int
_testGeneric
(
SDL_RWops
*
rw
,
int
write
)
{
{
...
@@ -59,41 +61,45 @@ int _testGeneric( SDL_RWops *rw, int write )
...
@@ -59,41 +61,45 @@ int _testGeneric( SDL_RWops *rw, int write )
/* Set to start. */
/* Set to start. */
i
=
SDL_RWseek
(
rw
,
0
,
RW_SEEK_SET
);
i
=
SDL_RWseek
(
rw
,
0
,
RW_SEEK_SET
);
AssertEquals
(
i
,
0
,
"Seeking with SDL_RWseek (RW_SEEK_SET)
: got %d, expected %d
"
);
AssertEquals
(
i
,
0
,
"Seeking with SDL_RWseek (RW_SEEK_SET)"
);
/* Test write. */
/* Test write. */
i
=
SDL_RWwrite
(
rw
,
hello_world
,
sizeof
(
hello_world
)
-
1
,
1
);
i
=
SDL_RWwrite
(
rw
,
hello_world
,
sizeof
(
hello_world
)
-
1
,
1
);
if
(
write
)
{
if
(
write
)
{
AssertEquals
(
i
,
1
,
"Writing with SDL_RWwrite (failed to write)"
);
AssertEquals
(
i
,
1
,
"Writing with SDL_RWwrite (failed to write)"
);
}
}
else
{
else
{
AssertTrue
(
i
<=
0
,
"Writing with SDL_RWwrite (wrote when shouldn't have)
"
);
AssertTrue
(
i
<=
0
,
"Writing with SDL_RWwrite (wrote when shouldn't have)
: %d <= 0"
,
i
);
}
}
/* Test seek. */
/* Test seek. */
i
=
SDL_RWseek
(
rw
,
6
,
RW_SEEK_SET
);
i
=
SDL_RWseek
(
rw
,
6
,
RW_SEEK_SET
);
AssertEquals
(
i
,
6
,
"Seeking with SDL_RWseek (RW_SEEK_SET)
: got %d, expected %d"
,
i
,
0
);
AssertEquals
(
i
,
6
,
"Seeking with SDL_RWseek (RW_SEEK_SET)
"
);
/* Test seek. */
/* Test seek. */
i
=
SDL_RWseek
(
rw
,
0
,
RW_SEEK_SET
);
i
=
SDL_RWseek
(
rw
,
0
,
RW_SEEK_SET
);
AssertEquals
(
i
,
0
,
"Seeking with SDL_RWseek (RW_SEEK_SET)
: got %d, expected %d"
,
i
,
0
);
AssertEquals
(
i
,
0
,
"Seeking with SDL_RWseek (RW_SEEK_SET)
"
);
/* Test read. */
/* Test read. */
i
=
SDL_RWread
(
rw
,
buf
,
1
,
sizeof
(
hello_world
)
-
1
);
i
=
SDL_RWread
(
rw
,
buf
,
1
,
sizeof
(
hello_world
)
-
1
);
Assert
True
(
i
==
sizeof
(
hello_world
)
-
1
,
"Reading with SDL_RWread"
);
Assert
Equals
(
i
,
sizeof
(
hello_world
)
-
1
,
"Reading with SDL_RWread"
);
Assert
True
(
SDL_memcmp
(
buf
,
hello_world
,
sizeof
(
hello_world
)
-
1
)
==
0
,
"Memory read does not match memory written"
);
Assert
Equals
(
SDL_memcmp
(
buf
,
hello_world
,
sizeof
(
hello_world
)
-
1
),
0
,
"Memory read does not match memory written"
);
/* More seek tests. */
/* More seek tests. */
i
=
SDL_RWseek
(
rw
,
-
4
,
RW_SEEK_CUR
);
i
=
SDL_RWseek
(
rw
,
-
4
,
RW_SEEK_CUR
);
Assert
True
(
i
==
sizeof
(
hello_world
)
-
5
,
"Seeking with SDL_RWseek (RW_SEEK_CUR): got %d, expected %d
"
);
Assert
Equals
(
i
,
sizeof
(
hello_world
)
-
5
,
"Seeking with SDL_RWseek (RW_SEEK_CUR))
"
);
i
=
SDL_RWseek
(
rw
,
-
1
,
RW_SEEK_END
);
i
=
SDL_RWseek
(
rw
,
-
1
,
RW_SEEK_END
);
Assert
True
(
i
==
sizeof
(
hello_world
)
-
2
,
"Seeking with SDL_RWseek (RW_SEEK_END): got %d, expected %d"
,
i
,
sizeof
(
hello_world
)
-
2
);
Assert
Equals
(
i
,
sizeof
(
hello_world
)
-
2
,
"Seeking with SDL_RWseek (RW_SEEK_END)"
);
}
}
/*!
* Tests rwops parameters
*
* \sa http://wiki.libsdl.org/moin.cgi/SDL_RWFromFile
*/
void
rwops_testParam
(
void
)
void
rwops_testParam
(
void
)
{
{
SDL_RWops
*
rwops
;
SDL_RWops
*
rwops
;
...
@@ -124,8 +130,11 @@ void rwops_testParam (void)
...
@@ -124,8 +130,11 @@ void rwops_testParam (void)
* @param write Test writing also.
* @param write Test writing also.
* @return 1 if an assert is failed.
* @return 1 if an assert is failed.
*/
*/
/**
/**
* @brief Tests opening from memory.
* @brief Tests opening from memory.
*
* \sa http://wiki.libsdl.org/moin.cgi/SDL_RWFromMem
*/
*/
void
rwops_testMem
(
void
)
void
rwops_testMem
(
void
)
{
{
...
@@ -146,6 +155,9 @@ void rwops_testMem (void)
...
@@ -146,6 +155,9 @@ void rwops_testMem (void)
/**
/**
* @brief Tests opening from memory.
* @brief Tests opening from memory.
*
* \sa
* http://wiki.libsdl.org/moin.cgi/SDL_RWFromConstMem
*/
*/
void
rwops_testConstMem
(
void
)
void
rwops_testConstMem
(
void
)
{
{
...
@@ -165,13 +177,17 @@ void rwops_testConstMem (void)
...
@@ -165,13 +177,17 @@ void rwops_testConstMem (void)
/**
/**
* @brief Tests opening from memory.
* @brief Tests opening from memory.
*
* \sa
* http://wiki.libsdl.org/moin.cgi/SDL_RWFromFile
* http://wiki.libsdl.org/moin.cgi/SDL_FreeRW
*/
*/
void
rwops_testFile
(
void
)
void
rwops_testFile
(
void
)
{
{
SDL_RWops
*
rw
;
SDL_RWops
*
rw
;
/* Read test. */
/* Read test. */
rw
=
TestSupportRWops_OpenRWopsFromReadDir
(
RWOPS_READ
,
"r"
);
rw
=
SDL_RWFromFile
(
RWOPS_READ
,
"r"
);
AssertTrue
(
rw
!=
NULL
,
"Opening memory with SDL_RWFromFile RWOPS_READ"
);
AssertTrue
(
rw
!=
NULL
,
"Opening memory with SDL_RWFromFile RWOPS_READ"
);
_testGeneric
(
rw
,
0
);
_testGeneric
(
rw
,
0
);
...
@@ -179,7 +195,7 @@ void rwops_testFile (void)
...
@@ -179,7 +195,7 @@ void rwops_testFile (void)
SDL_FreeRW
(
rw
);
SDL_FreeRW
(
rw
);
/* Write test. */
/* Write test. */
rw
=
TestSupportRWops_OpenRWopsFromWriteDir
(
RWOPS_WRITE
,
"w+"
);
rw
=
SDL_RWFromFile
(
RWOPS_WRITE
,
"w+"
);
AssertTrue
(
rw
!=
NULL
,
"Opening memory with SDL_RWFromFile RWOPS_WRITE"
);
AssertTrue
(
rw
!=
NULL
,
"Opening memory with SDL_RWFromFile RWOPS_WRITE"
);
_testGeneric
(
rw
,
1
);
_testGeneric
(
rw
,
1
);
...
@@ -190,6 +206,10 @@ void rwops_testFile (void)
...
@@ -190,6 +206,10 @@ void rwops_testFile (void)
/**
/**
* @brief Tests opening from stdio
* @brief Tests opening from stdio
*
* \sa
* http://wiki.libsdl.org/moin.cgi/SDL_RWFromFP
* http://wiki.libsdl.org/moin.cgi/SDL_FreeRW
*/
*/
void
rwops_testFP
(
void
)
void
rwops_testFP
(
void
)
{
{
...
@@ -197,7 +217,7 @@ void rwops_testFP (void)
...
@@ -197,7 +217,7 @@ void rwops_testFP (void)
SDL_RWops
*
rw
;
SDL_RWops
*
rw
;
/* Run read tests. */
/* Run read tests. */
fp
=
TestSupportRWops_OpenFPFromReadDir
(
RWOPS_READ
,
"r"
);
fp
=
fopen
(
RWOPS_READ
,
"r"
);
AssertTrue
(
fp
!=
NULL
,
"Failed to open file %s,"
,
RWOPS_READ
);
AssertTrue
(
fp
!=
NULL
,
"Failed to open file %s,"
,
RWOPS_READ
);
rw
=
SDL_RWFromFP
(
fp
,
1
);
rw
=
SDL_RWFromFP
(
fp
,
1
);
...
@@ -208,7 +228,7 @@ void rwops_testFP (void)
...
@@ -208,7 +228,7 @@ void rwops_testFP (void)
SDL_FreeRW
(
rw
);
SDL_FreeRW
(
rw
);
/* Run write tests. */
/* Run write tests. */
fp
=
TestSupportRWops_OpenFPFromWriteDir
(
RWOPS_WRITE
,
"w+"
);
fp
=
fopen
(
RWOPS_WRITE
,
"w+"
);
AssertTrue
(
fp
!=
NULL
,
"Failed to open file %s"
,
RWOPS_WRITE
);
AssertTrue
(
fp
!=
NULL
,
"Failed to open file %s"
,
RWOPS_WRITE
);
rw
=
SDL_RWFromFP
(
fp
,
1
);
rw
=
SDL_RWFromFP
(
fp
,
1
);
...
...
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