Fixed AssertEquals.
authorMarkus Kauppila <markus.kauppila@gmail.com>
Thu, 14 Jul 2011 20:33:18 +0300
changeset 5759 59615ddece72
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
--- a/test/test-automation/Makefile.am	Wed Jul 13 19:51:25 2011 +0300
+++ b/test/test-automation/Makefile.am	Thu Jul 14 20:33:18 2011 +0300
@@ -3,7 +3,7 @@
 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` 
 
--- a/test/test-automation/SDL_test.c	Wed Jul 13 19:51:25 2011 +0300
+++ b/test/test-automation/SDL_test.c	Thu Jul 14 20:33:18 2011 +0300
@@ -72,7 +72,7 @@
    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;
--- a/test/test-automation/SDL_test.h	Wed Jul 13 19:51:25 2011 +0300
+++ b/test/test-automation/SDL_test.h	Thu Jul 14 20:33:18 2011 +0300
@@ -90,7 +90,7 @@
  * \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
--- a/test/test-automation/logger.c	Wed Jul 13 19:51:25 2011 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,13 +0,0 @@
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <stdarg.h>
-
-#include <SDL/SDL.h>
-
-#include "logger.h"
-#include "xml_logger.h"
-#include "plain_logger.h"
-
-
--- a/test/test-automation/logger.h	Wed Jul 13 19:51:25 2011 +0300
+++ b/test/test-automation/logger.h	Thu Jul 14 20:33:18 2011 +0300
@@ -45,7 +45,7 @@
 						 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,
--- a/test/test-automation/plain_logger.c	Wed Jul 13 19:51:25 2011 +0300
+++ b/test/test-automation/plain_logger.c	Thu Jul 14 20:33:18 2011 +0300
@@ -15,22 +15,29 @@
 /*!
  * 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, ...)
 {
+
+	int ident = 0;
+	for( ; ident < currentIndentLevel; ++ident) {
+		fprintf(stdout, "  "); // \todo make configurable?
+	}
+
+
+    char buffer[1024];
+	memset(buffer, 0, 1024);
+
 	va_list list;
 	va_start(list, message);
 
-	int ident = 0;
-	for( ; ident < currentIdentLevel; ++ident) {
-		fprintf(stdout, "  "); // \todo make configurable?
-	}
+	SDL_vsnprintf(buffer, 1024, message, list);
 
-	char buffer[1024];
-	SDL_vsnprintf(buffer, sizeof(buffer), message, list);
+	va_end(list);
+
 
 	fprintf(stdout, "%s\n", buffer);
 	fflush(stdout);
@@ -121,11 +128,11 @@
 
 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
--- a/test/test-automation/runner.c	Wed Jul 13 19:51:25 2011 +0300
+++ b/test/test-automation/runner.c	Thu Jul 14 20:33:18 2011 +0300
@@ -586,9 +586,11 @@
 
 
 /*
- * 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) {
@@ -629,8 +631,8 @@
 }
 
 /*!
- * 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.
--- a/test/test-automation/testdummy/testdummy.c	Wed Jul 13 19:51:25 2011 +0300
+++ b/test/test-automation/testdummy/testdummy.c	Thu Jul 14 20:33:18 2011 +0300
@@ -88,8 +88,7 @@
 void
 dummycase1(void *arg)
 {
-	//AssertEquals(5, 5, "Assert message");
-	while(1);
+	AssertEquals(5, 5, "Assert message");
 }
 
 void
--- a/test/test-automation/xml_logger.c	Wed Jul 13 19:51:25 2011 +0300
+++ b/test/test-automation/xml_logger.c	Thu Jul 14 20:33:18 2011 +0300
@@ -76,18 +76,18 @@
  *
  * \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?
 		}