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
450610b7
Commit
450610b7
authored
Jun 02, 2011
by
Markus Kauppila
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Ported testrect from original automation code, updated AssertEquals, added AssertTrue
parent
75691b7b
Changes
9
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
731 additions
and
15 deletions
+731
-15
Makefile.am
test/test-automation/Makefile.am
+3
-1
SDL_test.c
test/test-automation/SDL_test.c
+42
-9
SDL_test.h
test/test-automation/SDL_test.h
+3
-1
configure.ac
test/test-automation/configure.ac
+1
-1
runner.c
test/test-automation/runner.c
+1
-1
Makefile.am
test/test-automation/testrect/Makefile.am
+9
-0
Makefile.in
test/test-automation/testrect/Makefile.in
+533
-0
testrect.c
test/test-automation/testrect/testrect.c
+137
-0
test.c
test/test-automation/tests/test.c
+2
-2
No files found.
test/test-automation/Makefile.am
View file @
450610b7
ACLOCAL_AMFLAGS
=
-I
acinclude
-I
build-scripts
ACLOCAL_AMFLAGS
=
-I
acinclude
-I
build-scripts
SUBDIRS
=
tests
SUBDIRS
=
tests
testrect
bin_PROGRAMS
=
runner
bin_PROGRAMS
=
runner
runner_SOURCES
=
runner.c SDL_test.c
runner_SOURCES
=
runner.c SDL_test.c
...
@@ -11,6 +11,8 @@ install: install-tests
...
@@ -11,6 +11,8 @@ install: install-tests
install-tests
:
install-tests
:
-
cp
-f
tests/.libs/
*
.dylib tests/ 2> /dev/null
-
cp
-f
tests/.libs/
*
.dylib tests/ 2> /dev/null
-
cp
-f
tests/.libs/
*
.so tests/ 2> /dev/null
-
cp
-f
tests/.libs/
*
.so tests/ 2> /dev/null
-
cp
-f
testrect/.libs/
*
.dylib tests/ 2> /dev/null
-
cp
-f
testrect/.libs/
*
.so tests/ 2> /dev/null
distclean-local
:
distclean-local
:
-
rm
-Rf
docs/
-
rm
-Rf
docs/
...
...
test/test-automation/SDL_test.c
View file @
450610b7
...
@@ -21,34 +21,67 @@
...
@@ -21,34 +21,67 @@
#ifndef _SDL_TEST_C
#ifndef _SDL_TEST_C
#define _SDL_TEST_C
#define _SDL_TEST_C
#include <stdio.h>
/* printf/fprintf */
#include <stdarg.h>
/* va_list */
#include "SDL_test.h"
#include "SDL_test.h"
/*! \brief return value of test case. Non-zero value means that the test failed */
/*! \brief return value of test case. Non-zero value means that the test failed */
static
int
_testReturnValue
;
static
int
_testReturnValue
;
static
int
_testAssertsFailed
;
static
int
_testAssertsPassed
;
void
void
TestCaseInit
()
TestCaseInit
()
{
{
_testReturnValue
=
0
;
_testReturnValue
=
0
;
_testAssertsFailed
=
0
;
_testAssertsPassed
=
0
;
}
}
int
int
TestCaseQuit
()
TestCaseQuit
()
{
{
printf
(
"Asserts: passed %d, failed %d
\n
"
,
_testAssertsPassed
,
_testAssertsFailed
);
return
_testReturnValue
;
return
_testReturnValue
;
}
}
void
void
AssertEquals
(
char
*
message
,
Uint32
expected
,
Uint32
actual
)
AssertEquals
(
Uint32
expected
,
Uint32
actual
,
char
*
message
,
...
)
{
{
va_list
args
;
char
buf
[
256
];
if
(
expected
!=
actual
)
{
if
(
expected
!=
actual
)
{
printf
(
"===============================
\n
"
);
va_start
(
args
,
message
);
printf
(
"Assert failed: %s
\n
"
,
message
);
SDL_vsnprintf
(
buf
,
sizeof
(
buf
),
message
,
args
);
printf
(
"Expected %d, got %d
\n
"
,
expected
,
actual
);
va_end
(
args
);
printf
(
"===============================
\n
"
);
printf
(
"Assert Equals failed: expected %d, got %d; %s
\n
"
,
expected
,
actual
,
buf
);
_testReturnValue
=
1
;
_testReturnValue
=
1
;
_testAssertsFailed
++
;
}
else
{
_testAssertsPassed
++
;
}
}
}
}
void
AssertTrue
(
int
condition
,
char
*
message
,
...)
{
va_list
args
;
char
buf
[
256
];
if
(
!
condition
)
{
va_start
(
args
,
message
);
SDL_vsnprintf
(
buf
,
sizeof
(
buf
),
message
,
args
);
va_end
(
args
);
printf
(
"Assert IsTrue failed: %s
\n
"
,
buf
);
_testReturnValue
=
1
;
_testAssertsFailed
++
;
}
else
{
_testAssertsPassed
++
;
}
}
#endif
#endif
test/test-automation/SDL_test.h
View file @
450610b7
...
@@ -53,6 +53,8 @@ void TestCaseInit();
...
@@ -53,6 +53,8 @@ void TestCaseInit();
int
TestCaseQuit
();
int
TestCaseQuit
();
void
AssertEquals
(
char
*
message
,
Uint32
expected
,
Uint32
actual
);
void
AssertEquals
(
Uint32
expected
,
Uint32
actual
,
char
*
message
,
...);
void
AssertTrue
(
int
condition
,
char
*
message
,
...);
#endif
#endif
test/test-automation/configure.ac
View file @
450610b7
...
@@ -33,7 +33,7 @@ CFLAGS="-g"
...
@@ -33,7 +33,7 @@ CFLAGS="-g"
AC_FUNC_FORK
AC_FUNC_FORK
AC_CONFIG_FILES([Makefile
AC_CONFIG_FILES([Makefile
tests/Makefile])
tests/Makefile
testrect/Makefile
])
AC_OUTPUT
AC_OUTPUT
echo ""
echo ""
...
...
test/test-automation/runner.c
View file @
450610b7
...
@@ -48,7 +48,7 @@ ScanForTestSuites() {
...
@@ -48,7 +48,7 @@ ScanForTestSuites() {
#if defined(linux) || defined( __linux)
#if defined(linux) || defined( __linux)
char
*
libName
=
"tests/libtest.so"
;
char
*
libName
=
"tests/libtest.so"
;
#else
#else
char
*
libName
=
"tests/libtest.dylib"
;
char
*
libName
=
"tests/libtest
rect
.dylib"
;
#endif
#endif
return
libName
;
return
libName
;
}
}
...
...
test/test-automation/testrect/Makefile.am
0 → 100644
View file @
450610b7
lib_LTLIBRARIES
=
libtestrect.la
libtestrect_la_SOURCES
=
testrect.c ../SDL_test.c
libtestrect_la_CLAGS
=
-fPIC
-g
libtestrect_la_LDFLAGS
=
`
sdl-config
--libs
`
distclean-local
:
-
rm
*
.dylib
-
rm
*
.so
test/test-automation/testrect/Makefile.in
0 → 100644
View file @
450610b7
This diff is collapsed.
Click to expand it.
test/test-automation/testrect/testrect.c
0 → 100644
View file @
450610b7
/**
* Original code: automated SDL rect test written by Edgar Simo "bobbens"
*/
#include <stdio.h>
#include <SDL/SDL.h>
#include "../SDL_test.h"
/* Test cases */
static
const
TestCaseReference
test1
=
(
TestCaseReference
){
"rect_testIntersectRectAndLine"
,
"description"
,
TEST_ENABLED
,
0
};
/* Test suite */
extern
const
TestCaseReference
*
testSuite
[]
=
{
&
test1
,
NULL
};
TestCaseReference
**
QueryTestSuite
()
{
return
(
TestCaseReference
**
)
testSuite
;
}
/**
* @brief Tests SDL_IntersectRectAndLine()
*/
int
rect_testIntersectRectAndLine
(
void
*
arg
)
{
SDL_Rect
rect
=
{
0
,
0
,
32
,
32
};
int
x1
,
y1
;
int
x2
,
y2
;
SDL_bool
clipped
;
TestCaseInit
();
x1
=
-
10
;
y1
=
0
;
x2
=
-
10
;
y2
=
31
;
clipped
=
SDL_IntersectRectAndLine
(
&
rect
,
&
x1
,
&
y1
,
&
x2
,
&
y2
);
AssertTrue
(
!
clipped
&&
x1
==
-
10
&&
y1
==
0
&&
x2
==
-
10
&&
y2
==
31
,
"line outside to the left was incorrectly clipped: %d,%d - %d,%d"
,
x1
,
y1
,
x2
,
y2
);
x1
=
40
;
y1
=
0
;
x2
=
40
;
y2
=
31
;
clipped
=
SDL_IntersectRectAndLine
(
&
rect
,
&
x1
,
&
y1
,
&
x2
,
&
y2
);
AssertTrue
(
!
clipped
&&
x1
==
40
&&
y1
==
0
&&
x2
==
40
&&
y2
==
31
,
"line outside to the right was incorrectly clipped: %d,%d - %d,%d"
,
x1
,
y1
,
x2
,
y2
);
x1
=
0
;
y1
=
-
10
;
x2
=
31
;
y2
=
-
10
;
clipped
=
SDL_IntersectRectAndLine
(
&
rect
,
&
x1
,
&
y1
,
&
x2
,
&
y2
);
AssertTrue
(
!
clipped
&&
x1
==
0
&&
y1
==
-
10
&&
x2
==
31
&&
y2
==
-
10
,
"line outside above was incorrectly clipped: %d,%d - %d,%d"
,
x1
,
y1
,
x2
,
y2
);
x1
=
0
;
y1
=
40
;
x2
=
31
;
y2
=
40
;
clipped
=
SDL_IntersectRectAndLine
(
&
rect
,
&
x1
,
&
y1
,
&
x2
,
&
y2
);
AssertTrue
(
!
clipped
&&
x1
==
0
&&
y1
==
40
&&
x2
==
31
&&
y2
==
40
,
"line outside below was incorrectly clipped: %d,%d - %d,%d"
,
x1
,
y1
,
x2
,
y2
);
x1
=
0
;
y1
=
0
;
x2
=
31
;
y2
=
31
;
clipped
=
SDL_IntersectRectAndLine
(
&
rect
,
&
x1
,
&
y1
,
&
x2
,
&
y2
);
AssertTrue
(
clipped
&&
x1
==
0
&&
y1
==
0
&&
x2
==
31
&&
y2
==
31
,
"line fully inside rect was clipped: %d,%d - %d,%d"
,
x1
,
y1
,
x2
,
y2
);
x1
=
-
10
;
y1
=
15
;
x2
=
40
;
y2
=
15
;
clipped
=
SDL_IntersectRectAndLine
(
&
rect
,
&
x1
,
&
y1
,
&
x2
,
&
y2
);
AssertTrue
(
clipped
&&
x1
==
0
&&
y1
==
15
&&
x2
==
31
&&
y2
==
15
,
"horizontal line rect was incorrectly clipped: %d,%d - %d,%d"
,
x1
,
y1
,
x2
,
y2
);
x1
=
-
32
;
y1
=
-
32
;
x2
=
63
;
y2
=
63
;
clipped
=
SDL_IntersectRectAndLine
(
&
rect
,
&
x1
,
&
y1
,
&
x2
,
&
y2
);
AssertTrue
(
clipped
&&
x1
==
0
&&
y1
==
0
&&
x2
==
31
&&
y2
==
31
,
"diagonal line to lower right was incorrectly clipped: %d,%d - %d,%d"
,
x1
,
y1
,
x2
,
y2
);
x1
=
63
;
y1
=
63
;
x2
=
-
32
;
y2
=
-
32
;
clipped
=
SDL_IntersectRectAndLine
(
&
rect
,
&
x1
,
&
y1
,
&
x2
,
&
y2
);
AssertTrue
(
clipped
&&
x1
==
31
&&
y1
==
31
&&
x2
==
0
&&
y2
==
0
,
"diagonal line to upper left was incorrectly clipped: %d,%d - %d,%d"
,
x1
,
y1
,
x2
,
y2
);
x1
=
63
;
y1
=
-
32
;
x2
=
-
32
;
y2
=
63
;
clipped
=
SDL_IntersectRectAndLine
(
&
rect
,
&
x1
,
&
y1
,
&
x2
,
&
y2
);
AssertTrue
(
clipped
&&
x1
==
31
&&
y1
==
0
&&
x2
==
0
&&
y2
==
31
,
"diagonal line to lower left was incorrectly clipped: %d,%d - %d,%d"
,
x1
,
y1
,
x2
,
y2
);
x1
=
-
32
;
y1
=
63
;
x2
=
63
;
y2
=
-
32
;
clipped
=
SDL_IntersectRectAndLine
(
&
rect
,
&
x1
,
&
y1
,
&
x2
,
&
y2
);
AssertTrue
(
clipped
&&
x1
==
0
&&
y1
==
31
&&
x2
==
31
&&
y2
==
0
,
"diagonal line to upper right was incorrectly clipped: %d,%d - %d,%d"
,
x1
,
y1
,
x2
,
y2
);
return
TestCaseQuit
();
}
test/test-automation/tests/test.c
View file @
450610b7
...
@@ -55,7 +55,7 @@ int hello(void *arg)
...
@@ -55,7 +55,7 @@ int hello(void *arg)
const
char
*
revision
=
SDL_GetRevision
();
const
char
*
revision
=
SDL_GetRevision
();
printf
(
"Revision is %s
\n
"
,
revision
);
printf
(
"Revision is %s
\n
"
,
revision
);
AssertEquals
(
"will fail"
,
3
,
5
);
AssertEquals
(
3
,
5
,
"fails"
);
return
TestCaseQuit
();
return
TestCaseQuit
();
}
}
...
@@ -75,7 +75,7 @@ int hello3(void *arg)
...
@@ -75,7 +75,7 @@ int hello3(void *arg)
TestCaseInit
();
TestCaseInit
();
printf
(
"hello3
\n
"
);
printf
(
"hello3
\n
"
);
AssertEquals
(
"passes"
,
3
,
3
);
AssertEquals
(
3
,
3
,
"passes"
);
return
TestCaseQuit
();
return
TestCaseQuit
();
}
}
...
...
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