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

If any assert in SetUp function fails that test will be skipped.

  • Loading branch information
mkauppila committed Jul 11, 2011
1 parent f089d2a commit dd3d8891b23c1ff2de880a4605f89a77d480753f
@@ -36,7 +36,7 @@ int _testAssertsFailed;
int _testAssertsPassed;

void
_InitTestEnvironment() // InitTestEnvironment
_InitTestEnvironment()
{
_testReturnValue = 0;
_testAssertsFailed = 0;
@@ -56,8 +56,13 @@ _QuitTestEnvironment()
return _testReturnValue;
}

int
_CountFailedAsserts() {
return _testAssertsFailed;
}

void
AssertEquals(const int expected, const int actual, char *message, ...)
AssertEquals(int expected, int actual, char *message, ...)
{
va_list args;
char buf[256];
@@ -69,13 +69,19 @@ void _InitTestEnvironment();
*/
int _QuitTestEnvironment();

/*!
* Can be used to query the number of failed asserts
* \return Returns the failed assert count.
*/
int _CountFailedAsserts();

/*!
* Assert function. Tests if the expected value equals the actual value, then
* the test assert succeeds, otherwise it fails and warns about it.
*
* \param expected Value user expects to have
* \param actual The actual value of tested variable
* \param message Message that will be printed if assert fails
* \param message Message that will be printed
*/
void AssertEquals(const int expected, const int actual, char *message, ...);

@@ -85,18 +91,22 @@ void AssertEquals(const int expected, const int actual, char *message, ...);
* assert passes, otherwise it fails.
*
* \param condition Condition which will be evaluated
* \param message Message that will be printed if assert fails
* \param message Message that will be printed
*/
void AssertTrue(int condition, char *message, ...);

/*!
\todo add markup
*/
* Assert function which will always fail
*
* \param message Message that will be printed
*/
void AssertFail(char *message, ...);

/*!
\todo add markup
*/
* Assert function which will always pass
*
* \param message Message that will be printed
*/
void AssertPass(char *message, ...);

#endif
@@ -30,7 +30,7 @@
*/
typedef void (*RunStartedFp)(int parameterCount, char *runnerParameters[], time_t eventTime, void *data);
typedef void (*RunEndedFp)(int testCount, int suiteCount, int testPassCount, int testFailCount,
time_t endTime, double totalRuntime);
int testSkippedCount, time_t endTime, double totalRuntime);

typedef void (*SuiteStartedFp)(const char *suiteName, time_t eventTime);
typedef void (*SuiteEndedFp)(int testsPassed, int testsFailed, int testsSkipped,
@@ -54,13 +54,14 @@ PlainRunStarted(int parameterCount, char *runnerParameters[], time_t eventTime,

void
PlainRunEnded(int testCount, int suiteCount, int testPassCount, int testFailCount,
time_t endTime, double totalRuntime)
int testSkippedCount, time_t endTime, double totalRuntime)
{
Output(indentLevel, "Ran %d tests in %0.5f seconds from %d suites.",
testCount, totalRuntime, suiteCount);

Output(indentLevel, "%d tests passed", testPassCount);
Output(indentLevel, "%d tests failed", testFailCount);
Output(indentLevel, "%d tests skipped", testSkippedCount);
}

void
@@ -91,6 +92,9 @@ PlainTestEnded(const char *testName, const char *suiteName,
if(testResult) {
if(testResult == 2) {
Output(--indentLevel, "%s: failed -> no assert", testName);
}
else if(testResult == 3) {
Output(--indentLevel, "%s: skipped", testName);
} else {
Output(--indentLevel, "%s: failed", testName);
}
@@ -104,15 +108,15 @@ PlainAssert(const char *assertName, int assertResult, const char *assertMessage,
time_t eventTime)
{
const char *result = (assertResult) ? "passed" : "failed";
Output(indentLevel, "%s: %s; %s", assertName, result, assertMessage);
Output(indentLevel, "%s: %s - %s", assertName, result, assertMessage);
}

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

@@ -26,7 +26,7 @@ void PlainRunStarted(int parameterCount, char *runnerParameters[], time_t eventT
* \param totalRuntime How long the execution took
*/
void PlainRunEnded(int testCount, int suiteCount, int testPassCount, int testFailCount,
time_t endTime, double totalRuntime);
int testSkippedCount, time_t endTime, double totalRuntime);

/*!
* Prints the data about the test suite that'll be executed next

0 comments on commit dd3d889

Please sign in to comment.