Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

Ported testrect from original automation code, updated AssertEquals, …

…added AssertTrue
  • Loading branch information
mkauppila committed Jun 2, 2011
1 parent 71428f8 commit 343e28c84a4344d4adcb1f7b7ea185c1e9f0a501
@@ -1,6 +1,6 @@
ACLOCAL_AMFLAGS = -I acinclude -I build-scripts

SUBDIRS = tests
SUBDIRS = tests testrect

bin_PROGRAMS = runner
runner_SOURCES = runner.c SDL_test.c
@@ -11,6 +11,8 @@ install: install-tests
install-tests:
-cp -f tests/.libs/*.dylib 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:
-rm -Rf docs/
@@ -21,34 +21,67 @@
#ifndef _SDL_TEST_C
#define _SDL_TEST_C

#include <stdio.h> /* printf/fprintf */
#include <stdarg.h> /* va_list */

#include "SDL_test.h"

/*! \brief return value of test case. Non-zero value means that the test failed */
static int _testReturnValue;

static int _testAssertsFailed;
static int _testAssertsPassed;

void
TestCaseInit()
{
_testReturnValue = 0;
_testAssertsFailed = 0;
_testAssertsPassed = 0;
}

int
TestCaseQuit()
{
printf("Asserts: passed %d, failed %d\n", _testAssertsPassed, _testAssertsFailed);
return _testReturnValue;
}

void
AssertEquals(char *message, Uint32 expected, Uint32 actual)
void
AssertEquals(Uint32 expected, Uint32 actual, char* message, ...)
{
if(expected != actual) {
printf("===============================\n");
printf("Assert failed: %s\n", message);
printf("Expected %d, got %d\n", expected, actual);
printf("===============================\n");
_testReturnValue = 1;
}
va_list args;
char buf[256];

if(expected != actual) {
va_start( args, message );
SDL_vsnprintf( buf, sizeof(buf), message, args );
va_end( args );
printf("Assert Equals failed: expected %d, got %d; %s\n", expected, actual, buf);
_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
@@ -53,6 +53,8 @@ void TestCaseInit();
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
@@ -33,7 +33,7 @@ CFLAGS="-g"
AC_FUNC_FORK

AC_CONFIG_FILES([Makefile
tests/Makefile])
tests/Makefile testrect/Makefile])
AC_OUTPUT

echo ""
@@ -48,7 +48,7 @@ ScanForTestSuites() {
#if defined(linux) || defined( __linux)
char *libName = "tests/libtest.so";
#else
char *libName = "tests/libtest.dylib";
char *libName = "tests/libtestrect.dylib";
#endif
return libName;
}
@@ -0,0 +1,9 @@
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

0 comments on commit 343e28c

Please sign in to comment.