Skip to content
This repository has been archived by the owner on Feb 11, 2021. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
Fixed AssertEquals.
  • Loading branch information
mkauppila committed Jul 14, 2011
1 parent bbe8e9c commit 82ab9fd
Show file tree
Hide file tree
Showing 9 changed files with 30 additions and 35 deletions.
2 changes: 1 addition & 1 deletion test/test-automation/Makefile.am
Expand Up @@ -3,7 +3,7 @@ ACLOCAL_AMFLAGS = -I acinclude -I build-scripts
SUBDIRS = testdummy testrect testplatform testaudio testsurface

bin_PROGRAMS = runner
runner_SOURCES = runner.c SDL_test.c logger.c xml_logger.c plain_logger.c xml.c logger_helpers.c
runner_SOURCES = runner.c SDL_test.c xml_logger.c plain_logger.c xml.c logger_helpers.c
runner_CLAGS = -W -Wall -Wextra -g `sdl-config --cflags` -DSDL_NO_COMPAT
runner_LDFLAGS = `sdl-config --libs`

Expand Down
2 changes: 1 addition & 1 deletion test/test-automation/SDL_test.c
Expand Up @@ -72,7 +72,7 @@ AssertEquals(int expected, int actual, char *message, ...)
SDL_vsnprintf( buf, sizeof(buf), message, args );
va_end( args );

if(expected != expected) {
if(expected != actual) {
AssertWithValues("AssertEquals", 0, buf, actual, expected, time(0));

_testReturnValue = TEST_RESULT_FAILURE;
Expand Down
2 changes: 1 addition & 1 deletion test/test-automation/SDL_test.h
Expand Up @@ -90,7 +90,7 @@ int _CountFailedAsserts();
* \param actual The actual value of tested variable
* \param message Message that will be printed
*/
void AssertEquals(const int expected, const int actual, char *message, ...);
void AssertEquals(int expected, int actual, char *message, ...);

/*!
* Assert function. Tests if the given condition is true. True in
Expand Down
13 changes: 0 additions & 13 deletions test/test-automation/logger.c

This file was deleted.

2 changes: 1 addition & 1 deletion test/test-automation/logger.h
Expand Up @@ -45,7 +45,7 @@ typedef void (*AssertFp)(const char *assertName, int assertResult,
const char *assertMessage, time_t eventTime);

typedef void (*AssertWithValuesFp)(const char *assertName, int assertResult,
const char *assertMessage, int actualValue, int excpected,
const char *assertMessage, int actualValue, int expected,
time_t eventTime);

typedef void (*AssertSummaryFp)(int numAsserts, int numAssertsFailed,
Expand Down
27 changes: 17 additions & 10 deletions test/test-automation/plain_logger.c
Expand Up @@ -15,22 +15,29 @@ static int indentLevel;
/*!
* Prints out the output of the logger
*
* \param currentIdentLevel The currently used indentation level
* \param currentIndentLevel The currently used indentation level
* \param message The message to be printed out
*/
int
Output(const int currentIdentLevel, const char *message, ...)
Output(const int currentIndentLevel, const char *message, ...)
{
va_list list;
va_start(list, message);

int ident = 0;
for( ; ident < currentIdentLevel; ++ident) {
for( ; ident < currentIndentLevel; ++ident) {
fprintf(stdout, " "); // \todo make configurable?
}

char buffer[1024];
SDL_vsnprintf(buffer, sizeof(buffer), message, list);

char buffer[1024];
memset(buffer, 0, 1024);

va_list list;
va_start(list, message);

SDL_vsnprintf(buffer, 1024, message, list);

va_end(list);


fprintf(stdout, "%s\n", buffer);
fflush(stdout);
Expand Down Expand Up @@ -121,11 +128,11 @@ PlainAssert(const char *assertName, int assertResult, const char *assertMessage,

void
PlainAssertWithValues(const char *assertName, int assertResult, const char *assertMessage,
int actualValue, int expected, time_t eventTime)
int actualValue, int expectedValue, time_t eventTime)
{
const char *result = (assertResult) ? "passed" : "failed";
Output(indentLevel, "%s: %s (expected %d, actualValue &d) - %s",
assertName, result, expected, actualValue, assertMessage);
Output(indentLevel, "%s: %s (expected %d, actualValue %d) - %s",
assertName, result, expectedValue, actualValue, assertMessage);
}

void
Expand Down
8 changes: 5 additions & 3 deletions test/test-automation/runner.c
Expand Up @@ -586,9 +586,11 @@ LoadCountFailedAssertsFunction(void *suite) {


/*
* Execute the test
* Execute a test. Loads the test, executes it and
* returns the tests return value to the caller.
*
* \param testItem Test to be executed
* \param test result
*/
int
RunTest(TestCase *testItem) {
Expand Down Expand Up @@ -629,8 +631,8 @@ void KillHungTest(int signum) {
}

/*!
* Executes a test case. Loads the test, executes it and
* returns the tests return value to the caller.
* Sets up a test case. Decideds wheter the test will
* be executed in-proc or out-of-proc.
*
* \param testItem The test case that will be executed
* \return The return value of the test. Zero means success, non-zero failure.
Expand Down
3 changes: 1 addition & 2 deletions test/test-automation/testdummy/testdummy.c
Expand Up @@ -88,8 +88,7 @@ TearDown(void *arg)
void
dummycase1(void *arg)
{
//AssertEquals(5, 5, "Assert message");
while(1);
AssertEquals(5, 5, "Assert message");
}

void
Expand Down
6 changes: 3 additions & 3 deletions test/test-automation/xml_logger.c
Expand Up @@ -76,18 +76,18 @@ static int prevEOL = YES;
*
* \todo Make the destination of the output changeable (defaults to stdout)
*
* \param identLevel the indent level of the message
* \param currentIndentLevel the indent level of the message
* \param EOL will it print end of line character or not
* \param the XML element itself
*
*/
void
XMLOutputter(const int currentIdentLevel,
XMLOutputter(const int currentIndentLevel,
int EOL, const char *message)
{
if(ValidateString(message)) {
int ident = 0;
for( ; ident < currentIdentLevel && prevEOL; ++ident) {
for( ; ident < currentIndentLevel && prevEOL; ++ident) {
fprintf(stdout, " "); // \todo make configurable?
}

Expand Down

0 comments on commit 82ab9fd

Please sign in to comment.