Fixed AssertEquals.
authorMarkus Kauppila
Thu, 14 Jul 2011 20:33:18 +0300
changeset 575959615ddece72
parent 5758 e497802a71b4
child 5760 735407c0bda3
Fixed AssertEquals.
test/test-automation/Makefile.am
test/test-automation/SDL_test.c
test/test-automation/SDL_test.h
test/test-automation/logger.c
test/test-automation/logger.h
test/test-automation/plain_logger.c
test/test-automation/runner.c
test/test-automation/testdummy/testdummy.c
test/test-automation/xml_logger.c
     1.1 --- a/test/test-automation/Makefile.am	Wed Jul 13 19:51:25 2011 +0300
     1.2 +++ b/test/test-automation/Makefile.am	Thu Jul 14 20:33:18 2011 +0300
     1.3 @@ -3,7 +3,7 @@
     1.4  SUBDIRS = testdummy testrect testplatform testaudio testsurface
     1.5  
     1.6  bin_PROGRAMS = runner
     1.7 -runner_SOURCES = runner.c SDL_test.c logger.c xml_logger.c plain_logger.c xml.c logger_helpers.c
     1.8 +runner_SOURCES = runner.c SDL_test.c xml_logger.c plain_logger.c xml.c logger_helpers.c
     1.9  runner_CLAGS = -W -Wall -Wextra -g `sdl-config --cflags` -DSDL_NO_COMPAT
    1.10  runner_LDFLAGS = `sdl-config --libs` 
    1.11  
     2.1 --- a/test/test-automation/SDL_test.c	Wed Jul 13 19:51:25 2011 +0300
     2.2 +++ b/test/test-automation/SDL_test.c	Thu Jul 14 20:33:18 2011 +0300
     2.3 @@ -72,7 +72,7 @@
     2.4     SDL_vsnprintf( buf, sizeof(buf), message, args );
     2.5     va_end( args );
     2.6  
     2.7 -   if(expected != expected) {
     2.8 +   if(expected != actual) {
     2.9        AssertWithValues("AssertEquals", 0, buf, actual, expected, time(0));
    2.10  
    2.11        _testReturnValue = TEST_RESULT_FAILURE;
     3.1 --- a/test/test-automation/SDL_test.h	Wed Jul 13 19:51:25 2011 +0300
     3.2 +++ b/test/test-automation/SDL_test.h	Thu Jul 14 20:33:18 2011 +0300
     3.3 @@ -90,7 +90,7 @@
     3.4   * \param actual The actual value of tested variable
     3.5   * \param message Message that will be printed
     3.6   */
     3.7 -void AssertEquals(const int expected, const int actual, char *message, ...);
     3.8 +void AssertEquals(int expected, int actual, char *message, ...);
     3.9  
    3.10  /*!
    3.11   *  Assert function. Tests if the given condition is true. True in
     4.1 --- a/test/test-automation/logger.c	Wed Jul 13 19:51:25 2011 +0300
     4.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.3 @@ -1,13 +0,0 @@
     4.4 -
     4.5 -#include <stdio.h>
     4.6 -#include <stdlib.h>
     4.7 -#include <string.h>
     4.8 -#include <stdarg.h>
     4.9 -
    4.10 -#include <SDL/SDL.h>
    4.11 -
    4.12 -#include "logger.h"
    4.13 -#include "xml_logger.h"
    4.14 -#include "plain_logger.h"
    4.15 -
    4.16 -
     5.1 --- a/test/test-automation/logger.h	Wed Jul 13 19:51:25 2011 +0300
     5.2 +++ b/test/test-automation/logger.h	Thu Jul 14 20:33:18 2011 +0300
     5.3 @@ -45,7 +45,7 @@
     5.4  						 const char *assertMessage, time_t eventTime);
     5.5  
     5.6  typedef	void (*AssertWithValuesFp)(const char *assertName, int assertResult,
     5.7 -						 const char *assertMessage, int actualValue, int excpected,
     5.8 +						 const char *assertMessage, int actualValue, int expected,
     5.9  						 time_t eventTime);
    5.10  
    5.11  typedef	void (*AssertSummaryFp)(int numAsserts, int numAssertsFailed,
     6.1 --- a/test/test-automation/plain_logger.c	Wed Jul 13 19:51:25 2011 +0300
     6.2 +++ b/test/test-automation/plain_logger.c	Thu Jul 14 20:33:18 2011 +0300
     6.3 @@ -15,22 +15,29 @@
     6.4  /*!
     6.5   * Prints out the output of the logger
     6.6   *
     6.7 - * \param currentIdentLevel The currently used indentation level
     6.8 + * \param currentIndentLevel The currently used indentation level
     6.9   * \param message The message to be printed out
    6.10   */
    6.11  int
    6.12 -Output(const int currentIdentLevel, const char *message, ...)
    6.13 +Output(const int currentIndentLevel, const char *message, ...)
    6.14  {
    6.15 +
    6.16 +	int ident = 0;
    6.17 +	for( ; ident < currentIndentLevel; ++ident) {
    6.18 +		fprintf(stdout, "  "); // \todo make configurable?
    6.19 +	}
    6.20 +
    6.21 +
    6.22 +    char buffer[1024];
    6.23 +	memset(buffer, 0, 1024);
    6.24 +
    6.25  	va_list list;
    6.26  	va_start(list, message);
    6.27  
    6.28 -	int ident = 0;
    6.29 -	for( ; ident < currentIdentLevel; ++ident) {
    6.30 -		fprintf(stdout, "  "); // \todo make configurable?
    6.31 -	}
    6.32 +	SDL_vsnprintf(buffer, 1024, message, list);
    6.33  
    6.34 -	char buffer[1024];
    6.35 -	SDL_vsnprintf(buffer, sizeof(buffer), message, list);
    6.36 +	va_end(list);
    6.37 +
    6.38  
    6.39  	fprintf(stdout, "%s\n", buffer);
    6.40  	fflush(stdout);
    6.41 @@ -121,11 +128,11 @@
    6.42  
    6.43  void
    6.44  PlainAssertWithValues(const char *assertName, int assertResult, const char *assertMessage,
    6.45 -		int actualValue, int expected, time_t eventTime)
    6.46 +		int actualValue, int expectedValue, time_t eventTime)
    6.47  {
    6.48  	const char *result = (assertResult) ? "passed" : "failed";
    6.49 -	Output(indentLevel, "%s: %s (expected %d, actualValue &d) - %s",
    6.50 -			assertName, result, expected, actualValue, assertMessage);
    6.51 +	Output(indentLevel, "%s: %s (expected %d, actualValue %d) - %s",
    6.52 +			assertName, result, expectedValue, actualValue, assertMessage);
    6.53  }
    6.54  
    6.55  void
     7.1 --- a/test/test-automation/runner.c	Wed Jul 13 19:51:25 2011 +0300
     7.2 +++ b/test/test-automation/runner.c	Thu Jul 14 20:33:18 2011 +0300
     7.3 @@ -586,9 +586,11 @@
     7.4  
     7.5  
     7.6  /*
     7.7 - * Execute the test
     7.8 + * Execute a test. Loads the test, executes it and
     7.9 + * returns the tests return value to the caller.
    7.10   *
    7.11   * \param testItem Test to be executed
    7.12 + * \param test result
    7.13   */
    7.14  int
    7.15  RunTest(TestCase *testItem) {
    7.16 @@ -629,8 +631,8 @@
    7.17  }
    7.18  
    7.19  /*!
    7.20 - * Executes a test case. Loads the test, executes it and
    7.21 - * returns the tests return value to the caller.
    7.22 + * Sets up a test case. Decideds wheter the test will
    7.23 + * be executed in-proc or out-of-proc.
    7.24   *
    7.25   * \param testItem The test case that will be executed
    7.26   * \return The return value of the test. Zero means success, non-zero failure.
     8.1 --- a/test/test-automation/testdummy/testdummy.c	Wed Jul 13 19:51:25 2011 +0300
     8.2 +++ b/test/test-automation/testdummy/testdummy.c	Thu Jul 14 20:33:18 2011 +0300
     8.3 @@ -88,8 +88,7 @@
     8.4  void
     8.5  dummycase1(void *arg)
     8.6  {
     8.7 -	//AssertEquals(5, 5, "Assert message");
     8.8 -	while(1);
     8.9 +	AssertEquals(5, 5, "Assert message");
    8.10  }
    8.11  
    8.12  void
     9.1 --- a/test/test-automation/xml_logger.c	Wed Jul 13 19:51:25 2011 +0300
     9.2 +++ b/test/test-automation/xml_logger.c	Thu Jul 14 20:33:18 2011 +0300
     9.3 @@ -76,18 +76,18 @@
     9.4   *
     9.5   * \todo Make the destination of the output changeable (defaults to stdout)
     9.6   *
     9.7 - * \param  identLevel the indent level of the message
     9.8 + * \param currentIndentLevel the indent level of the message
     9.9   * \param EOL will it print end of line character or not
    9.10   * \param the XML element itself
    9.11   *
    9.12   */
    9.13  void
    9.14 -XMLOutputter(const int currentIdentLevel,
    9.15 +XMLOutputter(const int currentIndentLevel,
    9.16  			 int EOL, const char *message)
    9.17  {
    9.18  	if(ValidateString(message)) {
    9.19  		int ident = 0;
    9.20 -		for( ; ident < currentIdentLevel && prevEOL; ++ident) {
    9.21 +		for( ; ident < currentIndentLevel && prevEOL; ++ident) {
    9.22  			fprintf(stdout, "  "); // \todo make configurable?
    9.23  		}
    9.24