/*
* $Id$
*/
-
-/**
- * @file
- * implements Test case class.
+/**@file
+ * TestCase module implementation.
*/
#include <stdlib.h>
-#include <assert.h>
-#include <setjmp.h>
-#include <ccunit/CCUnitTest.h>
-#include <ccunit/CCUnitTestResult.h>
-#include <ccunit/CCUnitTestCase.h>
-#include <ccunit/CCUnitTestFixture.h>
-
-/**
- * run test cases exception.
- */
-jmp_buf _ccunit_run_env;
-
-/**
- * run tests exception.
- */
-jmp_buf _ccunit_runTest_env;
-
-extern void _ccunit_runTestCase (CCUnitTestResult* result,
- CCUnitTestCase* testCase);
-
-inline void ccunit_addTestFixture (CCUnitTestCase* testCase,
- CCUnitTestFixture* fixture)
-{
- ccunit_addList (&testCase->fixtures, fixture);
-}
+#include <CCUnit/CCUnitConfig.h>
+#include <CCUnit/CCUnitTestCase.h>
/**
- * Runs the test case and collects the results in CCUnitTestResult.
- * @param test A test to run.
- * @param result A result container.
+ * @addtogroup CCUnitTestCase
+ * @{
*/
-static void run (CCUnitTest* test, CCUnitTestResult* result)
-{
- assert (test->type == ccunitTypeCase);
- _ccunit_runTestCase (result, (CCUnitTestCase*)test);
-}
-
-/**
- * Destruct test case.
- * @param test destruct test.
- */
-static void destroy (CCUnitTest* test)
-{
- CCUnitTestCase* testCase;
- assert (test->type == ccunitTypeCase);
- testCase = (CCUnitTestCase*)test;
- safe_free ((char*)testCase->name);
- safe_free ((char*)testCase->desc);
- ccunit_deleteList (&testCase->fixtures,
- (void (*)(void*))ccunit_deleteTestFixture);
-}
CCUnitTestCase* ccunit_newTestCase (const char* name,
const char* desc,
- void (*setUp)(),
- void (*tearDown)())
+ void (*runTest)())
{
CCUnitTestCase* testCase = calloc (1, sizeof (*testCase));
- ccunit_initTest (&testCase->test, ccunitTypeCase, run, destroy);
testCase->name = safe_strdup (name);
- testCase->desc = safe_strdup (desc);
- ccunit_initList (&testCase->fixtures);
- testCase->setUp = setUp;
- testCase->tearDown = tearDown;
+ testCase->desc = !desc ? safe_strdup (name) : strdup (desc);
+ testCase->runTest = runTest;
return testCase;
}
-void ccunit_runBare (CCUnitTestCase* testCase, void (*runTest) ())
+void ccunit_deleteTestCase (CCUnitTestCase* testCase)
{
- int failure;
- assert (testCase->test.type == ccunitTypeCase);
- if (testCase->setUp)
- testCase->setUp ();
- if ((failure = setjmp (_ccunit_runTest_env)) == 0)
- {
- runTest ();
- }
- if (testCase->tearDown)
- testCase->tearDown ();
- if (failure != 0)
- longjmp (_ccunit_run_env, failure);
+ if (!testCase)
+ return;
+ safe_free ((char*)testCase->name);
+ safe_free ((char*)testCase->desc);
+ free (testCase);
}
+
+/** @} */
* $Id$
*/
-/**
- * @file
- * Test case class.
+/** @file
+ * TestCase module.
*/
+
#ifndef CCUNITTESTCASE_H
#define CCUNITTESTCASE_H
-#include <ccunit/CCUnitConfig.h>
-#include <ccunit/CCUnitList.h>
-#include <ccunit/CCUnitTest.h>
-#include <ccunit/CCUnitTestFixture.h>
+/**
+ * @ingroup CCUnitTestFixture
+ * @defgroup CCUnitTestCase TestCase
+ *
+ * A single test object.
+ *
+ * This class is used to implement a simple test case.
+ *
+ * @{
+ */
/**
- * A test case defines the fixture to run multiple tests. To define a
- * test case:
- * <ol>
- * <li>define static variable that store the state of the fixture.
- * <li>initialize the fixture state by <code>setUp</code> function.
- * <li>clean-up after a test by <code>tearDown</code>.
- * </ol>
- * <p>
- * Each test runs in its own fixture so there can be no side effects
- * among test runs. Here is an example:
- * </p>
- * <pre>
- * /<!-- -->** test case: MathTest *<!-- -->/
- * static double value1;
- * static double value2;
- *
- * void setUp_MathTest()
- * {
- * value1 = 2.0;
- * value2 = 3.0;
- * }
- * </pre>
- * <p>
- * For each test implement a function which interacts with the
- * fixture. Verify the expected results with assertions specified by
- * calling <code>CCUNIT_ASSERT</code><var>_XXX</var> with a boolean.
- * </p>
- * <pre>
- * /<!-- -->** add test *<!-- -->/
- * void testAdd()
- * {
- * double result = fValue1 + fValue2;
- * CCUNIT_ASSERT_EQ_DOUBLE(5.0, result);
- * }
- * </pre>
- * <p>
- * Once the functions are defined you can run them.
- * <pre>
- * int main ()
- * {
- * CCUnitTestRunner* runner = ccunit_newTestRunner (stdout);
- * CCUnitTestSuite* suite = ccunit_newTestSuite ("suite");
- * CCUnitTestCase* testCase = ccunit_newTestCase ("MathTest",
- * setUp_MathTest,
- * tearDown_MathTest);
- * ccunit_addTestFunc (testCase, "testAdd", testAdd, "add test");
- * ccunit_addTestCase (suite, testCase);
- * runner->run (runner, suite);
- * return ccunit_wasSuccessful (runner->result) ? 0 : -1;
- * }
- * </pre>
- * @see CCUnitTestResult
- * @see CCUnitTestSuite
- * @see CCUnitMakeSuite
+ * A single test object.
*/
typedef struct CCUnitTestCase
{
- CCUnitTest test; /**< super class */
const char* name; /**< test case name */
const char* desc; /**< test description */
- CCUnitList fixtures; /**< test fixtures */
- void (*setUp) (); /**< setUp function */
- void (*tearDown) (); /**< tearDown function */
+ void (*runTest) (); /**< run test function */
} CCUnitTestCase;
/**
* create new test case.
- *
- * @param name test case name.
- * @param desc test case description.
- * @param setUp test fixture setUp function.
- * @param tearDown test fixture tearDown function.
- * @return new test case.
+ * @param name case name.
+ * @param desc case description.
+ * @param runTest run test function.
+ * @return new test case
*/
extern CCUnitTestCase* ccunit_newTestCase (const char* name,
const char* desc,
- void (*setUp)(),
- void (*tearDown)());
-
-struct CCUnitTestFixture;
+ void (*runTest)());
/**
- * add test fixture
- * @param testCase test case.
- * @param fixture test fixture
+ * delete test case.
+ * @param testCase deleting case.
*/
-extern inline void ccunit_addTestFixture (CCUnitTestCase* testCase,
- CCUnitTestFixture* fixture);
+extern void ccunit_deleteTestCase (CCUnitTestCase* testCase);
-/**
- * Runs the bare test sequence.
- * @param testCase test case to run.
- * @param runTest test run function.
- * @throws _ccunit_runResult_env by longjmp.
- */
-extern void ccunit_runBare (CCUnitTestCase* testCase, void (*runTest)());
+/** @} */
-#endif
+#endif /* !CCUNITTESTCASE_H */
* $Id$
*/
+/**
+ * @file
+ * TestFixture module implementation.
+ */
+
#include <stdlib.h>
-#include <CCUnit/CCUnitConfig.h>
-#include <CCUnit/CCUnitTestFixture.h>
+#include <assert.h>
+#include <setjmp.h>
+#include <ccunit/CCUnitTest.h>
+#include <ccunit/CCUnitTestResult.h>
+#include <ccunit/CCUnitTestFixture.h>
+#include <ccunit/CCUnitTestCase.h>
+
+/**
+ * run test fixtures exception.
+ */
+jmp_buf _ccunit_run_env;
+
+/**
+ * run tests exception.
+ */
+jmp_buf _ccunit_runTest_env;
+
+extern void _ccunit_runTestFixture (CCUnitTestResult* result,
+ CCUnitTestFixture* fixture);
+
+inline void ccunit_addTestCase (CCUnitTestFixture* fixture,
+ CCUnitTestCase* testCase)
+{
+ ccunit_addList (&fixture->testCases, testCase);
+}
+
+CCUnitTestCase* ccunit_addNewTestCase (CCUnitTestFixture* fixture,
+ const char* name,
+ const char* desc,
+ void (*runTest)())
+{
+ CCUnitTestCase* c = ccunit_newTestCase (name, desc, runTest);
+ if (!c)
+ return NULL;
+ ccunit_addTestCase (fixture, c);
+ return c;
+}
+
+/**
+ * Runs the test fixture and collects the results in CCUnitTestResult.
+ * @param test A test to run.
+ * @param result A result container.
+ */
+static void run (CCUnitTest* test, CCUnitTestResult* result)
+{
+ assert (test->type == ccunitTypeFixture);
+ _ccunit_runTestFixture (result, (CCUnitTestFixture*)test);
+}
+
+/**
+ * Destruct test fixture.
+ * @param test destruct test.
+ */
+static void destroy (CCUnitTest* test)
+{
+ CCUnitTestFixture* fixture;
+ assert (test->type == ccunitTypeFixture);
+ fixture = (CCUnitTestFixture*)test;
+ safe_free ((char*)fixture->name);
+ ccunit_deleteList (&fixture->testCases,
+ (void (*)(void*))ccunit_deleteTestCase);
+}
CCUnitTestFixture* ccunit_newTestFixture (const char* name,
- const char* desc,
- void (*runTest)())
+ void (*setUp)(),
+ void (*tearDown)())
{
CCUnitTestFixture* fixture = calloc (1, sizeof (*fixture));
+ ccunit_initTest (&fixture->test, ccunitTypeFixture, run, destroy);
fixture->name = safe_strdup (name);
- fixture->desc = !desc ? safe_strdup (name) : strdup (desc);
- fixture->runTest = runTest;
+ ccunit_initList (&fixture->testCases);
+ fixture->setUp = setUp;
+ fixture->tearDown = tearDown;
return fixture;
}
-void ccunit_deleteTestFixture (CCUnitTestFixture* fixture)
+void ccunit_runBare (CCUnitTestFixture* fixture, void (*runTest) ())
{
- if (!fixture)
- return;
- safe_free ((char*)fixture->name);
- safe_free ((char*)fixture->desc);
- free (fixture);
+ int failure;
+ assert (fixture->test.type == ccunitTypeFixture);
+ if (fixture->setUp)
+ fixture->setUp ();
+ if ((failure = setjmp (_ccunit_runTest_env)) == 0)
+ {
+ runTest ();
+ }
+ if (fixture->tearDown)
+ fixture->tearDown ();
+ if (failure != 0)
+ longjmp (_ccunit_run_env, failure);
}
* $Id$
*/
-#ifndef TESTFIXTURE_H
-#define TESTFIXTURE_H
+/**
+ * @file
+ * TestFixture module.
+ */
+#ifndef CCUNITTESTFIXTURE_H
+#define CCUNITTESTFIXTURE_H
+
+#include <ccunit/CCUnitConfig.h>
+#include <ccunit/CCUnitList.h>
+#include <ccunit/CCUnitTest.h>
+#include <ccunit/CCUnitTestCase.h>
/**
- * test fixture
+ * @ingroup CCUnitTest
+ * @defgroup CCUnitTestFixture TestFixture
+ *
+ * Wraps a test case with setUp and tearDown methods.
+ *
+ * A TestCase is used to provide a common environment for a set
+ * of test cases.
+ *
+ * To define a test case, do the following:
+ * - the case is defined by static variables
+ * - initialize the case state by setUp function
+ * - clean-up after a test by tearDown function
+ *
+ * Each test runs in its own case so there
+ * can be no side effects among test runs.
+ * Here is an example:
+ *
+ * @code
+ * static int value1, value2;
+ *
+ * void setUp_MathTest ()
+ * {
+ * value1 = 2;
+ * value2 = 3;
+ * }
+ *
+ * ...
+ *
+ * CCUnitTestFixture* MathTest_newTestFixture ()
+ * {
+ * return ccunit_newTestFixture ("MathTest", setUp_MathTest, NULL);
+ * }
+ * @endcode
+ *
+ * For each test implement a method which interacts with the
+ * case. Verify the expected results with assertions specified by
+ * calling CPPUNIT_ASSERT on the expression you want to test:
+ *
+ * @code
+ * void testAdd ()
+ * {
+ * int result = value1 + value2;
+ * CCUNIT_ASSERT (result == 5);
+ * }
+ *
+ * ...
+ *
+ * void MathTest_newTestCase_testAdd ()
+ * {
+ * return ccunit_newTestCase ("addTest", "add test", addTest);
+ * }
+ * @endcode
+ *
+ * The tests to be run can be collected into a TestSuite.
+ *
+ * @code
+ * CCUintTestSuite* MathTest_suite ()
+ * {
+ * CCUnitTestSuite* suite = ccunit_newTestSuite ("MathTest");
+ * CCUnitTestFixture* fixture = MathTest_newTestFixture ();
+ * ccunit_addTestFixture (suite, fixture);
+ * ccunit_addTestCase (fixture, MathTest_newTestCase_testAdd ());
+ * ccunit_addTestCase (fixture, MathTest_newTestCase_testDivZero ())
+ * return suite;
+ * }
+ * @endcode
+ *
+ * Once the functions are defined you can run them. To do this, use a
+ * TestRunner.
+ *
+ * @code
+ * CCUnitTestRunner *runner = ccunit_newTestRunner (stdout);
+ * CCUnitTestSuite *suite = MathTest_suite ();
+ * runner->run (runner, suite);
+ * @endcode
+ *
+ * A command line tool have been created for convenience. It is located
+ * in src/tools/ccunit_makeSuite.c.
+ *
+ * @see CCUnitTestResult, CCUnitTestSuite, CCUnitMakeSuite,
+ * @{
+ */
+
+/**
+ * A test fixture defines the fixture to run multiple tests.
+ *
+ * @see CCUnitTestResult, CCUnitTestSuite, CCUnitMakeSuite.
*/
typedef struct CCUnitTestFixture
{
- const char* name; /**< test case name */
- const char* desc; /**< test description */
- void (*runTest) (); /**< run test function */
+ CCUnitTest test; /**< super class */
+ const char* name; /**< test fixture name */
+ CCUnitList testCases; /**< test cases */
+ void (*setUp) (); /**< setUp function */
+ void (*tearDown) (); /**< tearDown function */
} CCUnitTestFixture;
/**
* create new test fixture.
- * @param name fixture name.
- * @param desc fixture description.
- * @param runTest run test function.
- * @return new test fixture
+ *
+ * @param name test fixture name.
+ * @param setUp test fixture setUp function.
+ * @param tearDown test fixture tearDown function.
+ * @return new test fixture.
*/
extern CCUnitTestFixture* ccunit_newTestFixture (const char* name,
- const char* desc,
- void (*runTest)());
+ void (*setUp)(),
+ void (*tearDown)());
+
+/**
+ * add test case to test fixture.
+ *
+ * @param fixture test fixture.
+ * @param testCase test case
+ */
+extern inline void ccunit_addTestCase (CCUnitTestFixture* fixture,
+ CCUnitTestCase* testCase);
+
+/**
+ * add new test case to test fixture.
+ *
+ * @param fixture test fixture.
+ * @param name test case name.
+ * @param desc test case description.
+ * @param runTest run test function.
+ * @return new test case
+ */
+extern CCUnitTestCase* ccunit_addNewTestCase (CCUnitTestFixture* fixture,
+ const char* name,
+ const char* desc,
+ void (*runTest)());
/**
- * delete test fixture.
- * @param fixture deleting fixture.
+ * Runs the bare test sequence.
+ *
+ * @param testFixture test fixture to run.
+ * @param runTest test run function.
+ * @throws _ccunit_runResult_env by longjmp.
*/
-extern void ccunit_deleteTestFixture (CCUnitTestFixture* fixture);
+extern void ccunit_runBare (CCUnitTestFixture* testFixture, void (*runTest)());
-#endif /* !TESTFIXTURE_H */
+/** @} */
+#endif
/*
* $Id$
*/
+/**@file
+ * TestResult module implementation.
+ */
#include <stdio.h>
#include <setjmp.h>
#include <ccunit/CCUnitTestCase.h>
#include <ccunit/CCUnitTestResult.h>
#include <ccunit/CCUnitTestRunner.h>
-#include <ccunit/CCUnitFailure.h>
+#include <ccunit/CCUnitTestFailure.h>
#include <ccunit/CCUnitList.h>
#include <ccunit/CCUnitTestFixture.h>
+/** @addtogroup CCUnitTestResult
+ * @{
+ */
+
extern jmp_buf _ccunit_run_env;
/**
* Informs the result that a test will be started.
*/
-static void startTest (CCUnitTestResult* result, struct CCUnitTestFixture* test)
+static void startTest (CCUnitTestResult* result, struct CCUnitTestCase* test)
{
CCUnitListIterator itor;
CCUnitTestListener* listener;
/**
* Informs the result that a test was completed.
*/
-static void endTest (CCUnitTestResult* result, struct CCUnitTestFixture* test)
+static void endTest (CCUnitTestResult* result, struct CCUnitTestCase* test)
{
CCUnitListIterator itor;
CCUnitTestListener* listener;
* Runs a TestCase.
*
* @param result result container.
- * @param testCase test case to be run.
+ * @param fixture test case to be run.
*/
-void _ccunit_runTestCase (CCUnitTestResult* result, CCUnitTestCase* testCase)
+void _ccunit_runTestFixture (CCUnitTestResult* result, CCUnitTestFixture* fixture)
{
int failure;
CCUnitListIterator itor;
- CCUnitTestFixture* fixture;
- ccunit_initListIterator (&testCase->fixtures, &itor);
- while ((fixture = ccunit_nextListIterator (&itor)) != NULL)
+ CCUnitTestCase* testCase;
+ ccunit_initListIterator (&fixture->testCases, &itor);
+ while ((testCase = ccunit_nextListIterator (&itor)) != NULL)
{
- startTest (result, fixture);
+ startTest (result, testCase);
if ((failure = setjmp (_ccunit_run_env)) == 0)
- ccunit_runBare (testCase, fixture->runTest);
+ ccunit_runBare (fixture, testCase->runTest);
else
- ccunit_addFailure (result, (CCUnitFailure*)failure);
- endTest (result, fixture);
+ ccunit_addFailure (result, (CCUnitTestFailure*)failure);
+ endTest (result, testCase);
}
}
{
if (!result)
return;
- ccunit_deleteList (&result->failures, (void(*)(void*))ccunit_deleteFailure);
+ ccunit_deleteList (&result->failures, (void(*)(void*))ccunit_deleteTestFailure);
ccunit_deleteList (&result->listeners, NULL);
free (result);
}
ccunit_addList (&result->listeners, listener);
}
-void ccunit_addFailure (CCUnitTestResult* result, struct CCUnitFailure* failure)
+void ccunit_addFailure (CCUnitTestResult* result, struct CCUnitTestFailure* failure)
{
CCUnitListIterator itor;
CCUnitTestListener* listener;
{
return ccunit_newListIterator (&result->failures);
}
+
+/** @} */
/*
* $Id$
*/
+/**@file
+ * TestRunner module implementation.
+ */
#include <stdio.h>
#include <ccunit/CCUnitTestSuite.h>
#include <ccunit/CCUnitTestRunner.h>
#include <sys/time.h>
#endif
+/** @addtogroup CCUnitTestRunner
+ * @{
+ */
+
/**
* receive startTest notification.
* @param listener notification listener.
* @param fixture starting test fixture
*/
-static void startTest (CCUnitTestListener* listener, CCUnitTestFixture* fixture)
+static void startTest (CCUnitTestListener* listener, CCUnitTestCase* test)
{
CCUnitTestRunner* runner = (CCUnitTestRunner*)listener;
fputc ('.', runner->ofp);
* @param listener notification listener.
* @param fixture end test fixture
*/
-static void endTest (CCUnitTestListener* listener, CCUnitTestFixture* fixture)
+static void endTest (CCUnitTestListener* listener, CCUnitTestCase* test)
{
}
* @param listener notification listener.
* @param failure failure information.
*/
-static void addFailure (CCUnitTestListener* listener, CCUnitFailure* failure)
+static void addFailure (CCUnitTestListener* listener, CCUnitTestFailure* failure)
{
CCUnitTestRunner* runner = (CCUnitTestRunner*)listener;
fputc ('F', runner->ofp);
static void printFailures (CCUnitTestRunner* runner, CCUnitTestResult* result)
{
CCUnitListIterator* itor;
- CCUnitFailure* f;
+ CCUnitTestFailure* f;
unsigned long num;
if (!runner || !result)
return;
if (!num)
return;
if (num == 1)
- fprintf (runner->ofp, "There was %lu failure:", num);
+ fprintf (runner->ofp, "There was %lu failure:\n", num);
else
- fprintf (runner->ofp, "There was %lu failures:", num);
+ fprintf (runner->ofp, "There was %lu failures:\n", num);
itor = ccunit_failures (result);
while ((f = ccunit_nextListIterator (itor)) != NULL)
{
return runner;
}
-void ccunit_deleteTestRunner (struct CCUnitTestRunner* runner)
+void ccunit_deleteTestRunner (CCUnitTestRunner* runner)
{
if (!runner)
return;
ccunit_deleteTestResult (runner->result);
free (runner);
}
+
+/** @} */
/*
* $Id$
*/
-/**
- * @file
- * implements Test suite class.
+/** @file
+ * TestSuite module implementation.
*/
#include <assert.h>
#include <ccunit/CCUnitList.h>
#include <ccunit/CCUnitTestResult.h>
#include <ccunit/CCUnitTestSuite.h>
+/** @addtogroup CCUnitTestSuite
+ * @{
+ */
+
/**
* Runs a test.
* @param test test to run.
ccunit_addTest (suite, &testSuite->test);
}
-inline void ccunit_addTestCase (CCUnitTestSuite* suite,
- CCUnitTestCase* testCase)
+inline void ccunit_addTestFixture (CCUnitTestSuite* suite,
+ CCUnitTestFixture* fixture)
{
- ccunit_addTest (suite, &testCase->test);
+ ccunit_addTest (suite, &fixture->test);
}
+
+/** @} */
/*
* $Id$
*/
-/**
- * @file
- * Test suite class.
+/** @file
+ * TestSuite module.
*/
#ifndef CCUNITTESTSUITE_H
#define CCUNITTESTSUITE_H
#include <ccunit/CCUnitConfig.h>
#include <ccunit/CCUnitList.h>
#include <ccunit/CCUnitTest.h>
-#include <ccunit/CCUnitTestCase.h>
+#include <ccunit/CCUnitTestFixture.h>
/**
+ * @ingroup CCUnitTest
+ * @defgroup CCUnitTestSuite TestSuite
+ *
* A <code>Composite</code> class of Tests.
* It runs a collection of test cases. Here is an example.
* <pre>
* CCUnitTestSuite* suite = ccunit_newTestSuite ();
- * ccunit_addTestCase (suite, CREATE_TESTCASE_1 ());
- * ccunit_addTestCase (suite, CREATE_TESTCASE_2 ());
+ * ccunit_addTestCase (suite, <var>TESTCASE_1</var>);
+ * ccunit_addTestCase (suite, <var>TESTCASE_2</var>);
* </pre>
- *
- * @see CCUnitTest
- * @see CCUnitTestCase
+ * @{
+ */
+
+/**
+ * A <code>Composite</code> class of Tests.
+ * It runs a collection of test cases.
+ * @see CCUnitTest, CCUnitTestCase.
*/
typedef struct CCUnitTestSuite
{
CCUnitTestSuite* testSuite);
/**
- * Adds a test case to the suite.
+ * Adds a test fixture to the suite.
* @param suite test suite.
- * @param testCase test to add.
+ * @param fixture test to add.
*/
-extern inline void ccunit_addTestCase (CCUnitTestSuite* suite,
- CCUnitTestCase* testCase);
+extern inline void ccunit_addTestFixture (CCUnitTestSuite* suite,
+ CCUnitTestFixture* fixture);
/**
* Create a test suite from test source file.
*/
extern CCUnitTestSuite* ccunit_suite (const char* name);
+/** @} */
#endif
/*
* $Id$
*/
+/**@file
+ * WriteSuite module implementation.
+ */
#include <ccunit/CCUnitMakeSuite.h>
#include <ccunit/CCUnitLogMessage.h>
#include <stdio.h>
/**
- * print test case prototypes.
+ * @addtogroup CCUnitWriteSuite
+ * @{
+ */
+
+/**
+ * print test fixture prototypes.
*
* @param ofp output stream.
* @param suite test suite object to print.
{
CCUnitListIterator itor;
CCUnitTestDef* test;
- CCUnitTestFixtureDef* fixture;
+ CCUnitTestCaseDef* testCase;
static unsigned suiteid = 0;
char sname[32];
sprintf (sname, "newSuite_%03u", ++ suiteid);
{
printPrototypes (ofp, (CCUnitTestSuiteDef*)test);
}
- else if (test->type == ccunitTypeCase)
+ else if (test->type == ccunitTypeFixture)
{
- CCUnitTestCaseDef* testCase = (CCUnitTestCaseDef*)test;
+ CCUnitTestFixtureDef* testFixture = (CCUnitTestFixtureDef*)test;
CCUnitListIterator fitor;
- ccunit_log ("testCase: %s '%s'",
- testCase->testdef.name, testCase->desc);
- if (testCase->desc)
- fprintf (ofp, "/** test case: %s */\n", testCase->desc);
- if (testCase->setUp)
+ ccunit_log ("testFixture: %s", testFixture->testdef.name);
+ if (testFixture->testdef.name)
+ fprintf (ofp, "/** test fixture: %s */\n", testFixture->testdef.name);
+ if (testFixture->setUp)
{
fprintf (ofp,
"/** %s */\n"
"extern %s %s ();\n",
- testCase->setUp->desc,
- testCase->setUp->type,
- testCase->setUp->name);
+ testFixture->setUp->desc,
+ testFixture->setUp->type,
+ testFixture->setUp->name);
ccunit_log ("setUp: %s %s",
- testCase->setUp->type, testCase->setUp->name);
+ testFixture->setUp->type, testFixture->setUp->name);
}
- if (testCase->tearDown)
+ if (testFixture->tearDown)
{
fprintf (ofp,
"/** %s */\n"
"extern %s %s ();\n",
- testCase->tearDown->desc,
- testCase->tearDown->type,
- testCase->tearDown->name);
+ testFixture->tearDown->desc,
+ testFixture->tearDown->type,
+ testFixture->tearDown->name);
ccunit_log ("tearDown: %s %s",
- testCase->tearDown->type, testCase->tearDown->name);
+ testFixture->tearDown->type, testFixture->tearDown->name);
}
- ccunit_initListIterator (&testCase->fixtures, &fitor);
- while ((fixture = ccunit_nextListIterator (&fitor)) != NULL)
+ ccunit_initListIterator (&testFixture->testCases, &fitor);
+ while ((testCase = ccunit_nextListIterator (&fitor)) != NULL)
{
fprintf (ofp,
"/** %s */\n"
"extern %s %s ();\n",
- fixture->desc,
- fixture->type,
- fixture->name);
- ccunit_log ("runTest: %s %s", fixture->type, fixture->name);
+ testCase->desc,
+ testCase->type,
+ testCase->name);
+ ccunit_log ("runTest: %s %s", testCase->type, testCase->name);
}
}
}
" }\n",
callid);
}
- else if (testdef->type == ccunitTypeCase)
+ else if (testdef->type == ccunitTypeFixture)
{
CCUnitListIterator fitor;
- CCUnitTestFixtureDef* fixture;
- CCUnitTestCaseDef* testCase = (CCUnitTestCaseDef*)testdef;
+ CCUnitTestCaseDef* testCase;
+ CCUnitTestFixtureDef* testFixture = (CCUnitTestFixtureDef*)testdef;
fprintf (ofp,
" {\n"
- " CCUnitTestCase* testCase;\n"
- " testCase = ccunit_newTestCase (\"%s\",\n"
- " \"%s\",\n"
- " %s,\n"
- " %s);\n"
- " if (testCase != NULL)\n"
- " ccunit_addTestCase (suite, testCase);\n",
+ " CCUnitTestFixture* testFixture;\n"
+ " testFixture = ccunit_newTestFixture (\"%s\",\n"
+ " %s,\n"
+ " %s);\n"
+ " if (testFixture != NULL)\n"
+ " ccunit_addTestFixture (suite, testFixture);\n",
testdef->name,
- testCase->desc,
- !testCase->setUp ? "NULL" : testCase->setUp->name,
- !testCase->tearDown ? "NULL" : testCase->tearDown->name);
- ccunit_initListIterator (&testCase->fixtures, &fitor);
- while ((fixture = ccunit_nextListIterator (&fitor)) != NULL)
+ !testFixture->setUp ? "NULL" : testFixture->setUp->name,
+ !testFixture->tearDown ? "NULL" : testFixture->tearDown->name);
+ ccunit_initListIterator (&testFixture->testCases, &fitor);
+ while ((testCase = ccunit_nextListIterator (&fitor)) != NULL)
{
fprintf (ofp,
" {\n"
- " CCUnitTestFixture* newFixture;\n"
- " newFixture = ccunit_newTestFixture (\"%s\",\n"
- " \"%s\",\n"
- " %s);\n"
- " if (newFixture != NULL)\n"
- " ccunit_addTestFixture (testCase, newFixture);\n"
+ " CCUnitTestCase* newCase;\n"
+ " newCase = ccunit_newTestCase (\"%s\",\n"
+ " \"%s\",\n"
+ " %s);\n"
+ " if (newCase != NULL)\n"
+ " ccunit_addTestCase (testFixture, newCase);\n"
" }\n",
- fixture->name, fixture->desc, fixture->name);
+ testCase->name, testCase->desc, testCase->name);
}
fprintf (ofp, " }\n");
}
"}\n",
name);
}
+
+/** @} */