...
CCUnitTestFixture* fixture;
- fixture = ccunit_newTestFixture ("MoneyTest",
- setUp_moneyTest,
- tearDown_moneyTest);
+ fixture = ccunit_newTestFixture ("MoneyTest",
+ CCUNIT_NEWTESTFUNC(setUp_MoneyTest),
+ CCUNIT_NEWTESTFUNC(tearDown_MoneyTest));
@endcode
Once you have the Fixture in place, you can write as many
CCUnitTestFixture* fixture;
CCUnitTestResult* result;
suite = ccunit_newTestSuite ("Money test suite");
-fixture = ccunit_newTestFixture ("Money Tests", setUp_moneyTest, tearDown_moneyTest);
+fixture = ccunit_newTestFixture ("Money Tests",
+ CCUNIT_NEWTESTFUNC(setUp_moneyTest),
+ CCUNIT_NEWTESTFUNC(tearDown_moneyTest));
ccunit_addNewTestCase (fixture,
"testSimpleAdd", "simple add test", testSympleAdd);
ccunit_addNewTestCase (fixture,
$ ccunit_makeSuite MoneyTest.c
#include <ccunit/CCUnitTestSuite.h>
+#include <ccunit/CCUnitTestFixture.h>
+#include <ccunit/CCUnitTestCase.h>
-static CCUnitTestSuite* newSuite_001 (const char* name);
//* test fixture: Money test *\/
//* setUp_MathTest *\/
extern void setUp_MathTest ();
//* money bug test *\/
extern void test_moneyBag ();
-static CCUnitTestSuite* newSuite_001 (const char* name)
-{
- CCUnitTestSuite* suite;
- suite = ccunit_newTestSuite (name);
+static CCUnitTestFixtureDfn fx_001 = {
+ { ccunitTypeFixture },
+ "Money test",
+ {
+ "setUp_MathTest", "setUp_MathTest", setUp_MathTest,
+ },
+ {
+ "tearDown_Mathtest", "tearDown_Mathtest", tearDown_Mathtest,
+ },
{
- CCUnitTestFixture* testFixture;
- testFixture = ccunit_newTestFixture ("Money test",
- setUp_MathTest,
- tearDown_Mathtest);
- if (testFixture != NULL)
- ccunit_addTestFixture (suite, testFixture);
{
- CCUnitTestCase* newCase;
- newCase = ccunit_newTestCase ("test_simpleAdd",
- "simple add test",
- test_simpleAdd);
- if (newCase != NULL)
- ccunit_addTestCase (testFixture, newCase);
- }
+ "test_simpleAdd", "simple add test", test_simpleAdd,
+ },
{
- CCUnitTestCase* newCase;
- newCase = ccunit_newTestCase ("test_moneyBag",
- "money bug test",
- test_moneyBag);
- if (newCase != NULL)
- ccunit_addTestCase (testFixture, newCase);
- }
+ "test_moneyBag", "money bug test", test_moneyBag,
+ },
+ {
+ NULL, NULL, NULL
+ },
}
+};
- return suite;
-}
-
+static CCUnitTestSuiteDfn suite_001 = {
+ { ccunitTypeSuite },
+ "",
+ {
+ &fx_001.test,
+ NULL,
+ },
+};
CCUnitTestSuite* ccunit_suite (const char* name)
{
- return newSuite_001 (name);
+ if (!suite_001.name[0])
+ suite_001.name = name;
+ return ccunit_newTestSuiteFromDfn (&suite_001);
}
$
@endcode