From f0aef1d381e0764c3362d48281e265673ef61531 Mon Sep 17 00:00:00 2001 From: tsntsumi Date: Sat, 21 Aug 2010 18:46:24 +0000 Subject: [PATCH] Moved the code of the suite_test_complex function into the main function. Because the explanation is easy to give this by the document. --- examples/complex/runTestSuite.c | 47 +++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 25 deletions(-) diff --git a/examples/complex/runTestSuite.c b/examples/complex/runTestSuite.c index 38adfe6..48c674c 100644 --- a/examples/complex/runTestSuite.c +++ b/examples/complex/runTestSuite.c @@ -22,6 +22,7 @@ */ #include +#include /* test case testComplex.c */ extern void setUp_test_complex (); @@ -38,11 +39,13 @@ extern void test_complex_sub (); extern void test_complex_mul (); extern void test_complex_div (); -CCUnitTestSuite* suite_test_complex () +int main () { + CCUnitTestCase* testCase, * testArith; CCUnitTestSuite* suite; - CCUnitTestCase* testCase, * testCase2; - suite = ccunit_newTestSuite ("complex test suite"); + CCUnitTestRunner* runner; + int ret; + /* test complex */ testCase = ccunit_newTestCase ("test complex"); ccunit_addNewTestFunc (testCase, "setUp_test_complex", @@ -60,44 +63,38 @@ CCUnitTestSuite* suite_test_complex () "test_complex_equals", "complex equals test", test_complex_equals); - ccunit_addTestCase (suite, testCase); - // - testCase2 = ccunit_newTestCase ("test complex arith"); - ccunit_addNewTestFunc (testCase2, + /* test complex arith */ + testArith = ccunit_newTestCase ("test complex arith"); + ccunit_addNewTestFunc (testArith, "setUp_test_complex_arith", "setUp_test_complex_arith", setUp_test_complex_arith); - ccunit_addNewTestFunc (testCase2, + ccunit_addNewTestFunc (testArith, "tearDown_test_complex_arith", "tearDown_test_complex_arith", tearDown_test_complex_arith); - ccunit_addNewTestFunc (testCase2, + ccunit_addNewTestFunc (testArith, "test_complex_add", "test add", test_complex_add); - ccunit_addNewTestFunc (testCase2, + ccunit_addNewTestFunc (testArith, "test_complex_sub", "test sub", test_complex_sub); - ccunit_addNewTestFunc (testCase2, + ccunit_addNewTestFunc (testArith, "test_complex_mul", "test mul", test_complex_mul); - ccunit_addNewTestFunc (testCase2, + ccunit_addNewTestFunc (testArith, "test_complex_div", "test div", test_complex_div); - ccunit_addTestCase (suite, testCase2); - return suite; -} - -int main () -{ - CCUnitTestSuite* suite; - CCUnitTestResult* result; - size_t num; - suite = suite_test_complex (); - result = ccunit_runTestSuite (suite, NULL); - num = ccunit_failureCount (result); - return num; + suite = ccunit_newTestSuite ("complex test suite"); + ccunit_addTestCase (suite, testCase); + ccunit_addTestCase (suite, testArith); + runner = ccunit_newTestRunner (stdout); + ret = ccunit_runTestRunner (runner, suite); + ccunit_deleteTestRunner (runner); + ccunit_deleteTestSuite (suite); + return ret; } -- 2.11.0