Plain logger refined.

This commit is contained in:
Markus Kauppila 2011-06-27 22:14:48 +03:00
parent fd3b97e2ff
commit 7494225e7b
7 changed files with 173 additions and 74 deletions

View file

@ -10,8 +10,9 @@
/*!
* Pritns out the output of the logger
* \return Possible error value (\todo)
* Prints out the output of the logger
*
* \param message The message to be printed out
*/
int
Output(const char *message, ...)
@ -22,22 +23,30 @@ Output(const char *message, ...)
char buffer[1024];
SDL_vsnprintf(buffer, sizeof(buffer), message, list);
fprintf(stderr, "%s\n", buffer);
fflush(stderr);
fprintf(stdout, "%s\n", buffer);
fflush(stdout);
}
void
PlainRunStarted(int parameterCount, char *runnerParameters[], time_t eventTime)
{
Output("Test run started");
Output("Given command line options: %s", "add options");
/*
Output("Test run started with following parameters\n");
int counter = 0;
for(counter = 0; counter < parameterCount; counter++) {
char *parameter = runnerParameters[counter];
Output("\t%s", parameter);
}
*/
}
void
PlainRunEnded(int testCount, int suiteCount, int testPassCount, int testFailCount,
time_t endTime, double totalRuntime)
{
Output("Ran %d tests in %0.5f seconds.", testCount, totalRuntime);
Output("\nRan %d tests in %0.5f seconds from %d suites.",
testCount, totalRuntime, suiteCount);
Output("%d tests passed", testPassCount);
Output("%d tests failed", testFailCount);
@ -46,7 +55,7 @@ PlainRunEnded(int testCount, int suiteCount, int testPassCount, int testFailCoun
void
PlainSuiteStarted(const char *suiteName, time_t eventTime)
{
Output("Executing tests in %s", suiteName);
Output("Executing tests from %s", suiteName);
}
void
@ -59,19 +68,35 @@ PlainSuiteEnded(int testsPassed, int testsFailed, int testsSkipped,
void
PlainTestStarted(const char *testName, const char *suiteName, const char *testDescription, time_t startTime)
{
Output("test %s (in %s) started", testName, suiteName);
Output("%s (in %s) started", testName, suiteName);
}
void
PlainTestEnded(const char *testName, const char *suiteName,
int testResult, time_t endTime, double totalRuntime)
{
Output("%s: ok", testName);
if(testResult) {
if(testResult == 2) {
Output("%s: failed -> no assert");
} else {
Output("%s: failed");
}
} else {
Output("%s: ok", testName);
}
}
void
PlainAssert(const char *assertName, int assertResult, const char *assertMessage,
time_t eventTime)
time_t eventTime)
{
const char *result = (assertResult) ? "passed" : "failed";
Output("%s: %s", assertName, assertMessage);
}
void
PlainAssertWithValues(const char *assertName, int assertResult, const char *assertMessage,
int actualValue, int excpected, time_t eventTime)
{
const char *result = (assertResult) ? "passed" : "failed";
Output("%s %d: %s", assertName, assertResult, assertMessage);
@ -80,7 +105,8 @@ PlainAssert(const char *assertName, int assertResult, const char *assertMessage,
void
PlainAssertSummary(int numAsserts, int numAssertsFailed, int numAssertsPass, time_t eventTime)
{
Output("Asserts:%d", numAsserts);
Output("Assert summary: %d failed, %d passed (total: %d)",
numAssertsFailed, numAssertsPass, numAsserts);
}
void