OSDN Git Service

revised the helper_tool section.
authortsntsumi <tsntsumi@users.sourceforge.jp>
Sat, 21 Aug 2010 13:34:11 +0000 (13:34 +0000)
committertsntsumi <tsntsumi@users.sourceforge.jp>
Sat, 21 Aug 2010 13:34:11 +0000 (13:34 +0000)
doc/cookbook.dox

index 433ba31..8751594 100644 (file)
@@ -732,254 +732,171 @@ contains both:
 @endcode
 
 @english
-@section helper_macros Helper Tool
+@section helper_tool Helper Tool
 @japanese
-@section helper_macros ¥Ø¥ë¥Ñ¡¼¥Ä¡¼¥ë
+@section helper_tool ¥Ø¥ë¥Ñ¡¼¥Ä¡¼¥ë
 @endif
 
-@~english
+@english
 As you might have noticed, implementing the <code>suite
 ()</code> function of testCase is a repetitive and error
 prone task. A @ref CreatingTestSuite set of functions and
 command have been created to automatically implements the
 <code>suite()</code> function.
-@~japanese
-¤ªµ¤¤Å¤­¤Î¤è¤¦¤Ë¡¢¥Õ¥£¥¯¥¹¥Á¥ã¤Î <code>suite ()</code>´Ø¿ô¤ò¼ÂÁõ¤¹¤ë¤Î¤Ï¡¢
-È¿ÉüŪ¤Ç´Ö°ã¤¤¤ä¤¹¤¤ºî¶È¤Ç¤¹¡£
-@ref CreatingTestSuite ¤Î´Ø¿ô¤Î½¸¤Þ¤ê¤È¥³¥Þ¥ó¥É¤Ï<code>suite ()</code>
-´Ø¿ô¤Î¼ÂÁõ¤ò¼«Æ°Åª¤ËºîÀ®¤¹¤ë¤³¤È¤¬¤Ç¤­¤Þ¤¹¡£
-@~
+@japanese
+¤ªµ¤¤Å¤­¤Î¤è¤¦¤Ë¡¢
+¥Æ¥¹¥È¥±¡¼¥¹¤Ë¥Æ¥¹¥È´Ø¿ô¤òÅÐÏ¿¤·¤¿¤ê¡¢
+¥Æ¥¹¥È¥¹¡¼¥Ä¤Ë¥Æ¥¹¥È¥±¡¼¥¹¤òÅÐÏ¿¤·¤¿¤ê¤¹¤ëºî¶È¤Ï¡¢
+È¿ÉüŪ¤Ç´Ö°ã¤¤¤ä¤¹¤¤¤â¤Î¤Ç¤¹¡£
+Î㤨¤Ð @c testComplexSetup.c ¤Ë¤Ï
+@c test_complex_to_string() ´Ø¿ô¤¬ÄêµÁ¤µ¤ì¤Æ¤¤¤Þ¤¹¤¬¡¢
+º£¤Þ¤Ç¤ÎÀâÌÀ¤Ç¤Ï̵»ë¤µ¤ì¤Æ¤¤¤Æ¥Æ¥¹¥È¥±¡¼¥¹¤ËÅÐÏ¿¤µ¤ì¤Þ¤»¤ó¤Ç¤·¤¿¡£
 
-@dontinclude complex/testComplex.c
+@ref CreatingTestSuite ¤Î´Ø¿ô¤Î½¸¤Þ¤ê¤È¥³¥Þ¥ó¥É¤Ï¡¢
+¥Æ¥¹¥È¥±¡¼¥¹¤ä¥Æ¥¹¥È¥¹¡¼¥Ä¤òÅÐÏ¿¤¹¤ë´Ø¿ô¤Î¼ÂÁõ¤ò¡¢
+¼«Æ°Åª¤ËºîÀ®¤¹¤ë¤³¤È¤¬¤Ç¤­¤Þ¤¹¡£
+@endif
 
-@~english
-The following code is a rewrite of ComplexTest using those command:
-@~japanese
-°Ê²¼¤Î¥³¡¼¥É¤Ï¤½¤ì¤é¤Î¥³¥Þ¥ó¥É¤¬»È¤¦¤è¤¦¤Ë testComplex.c ¤ò½ñ´¹¤¨¤¿¤â¤Î¤Ç¤¹¡£
-@~
+@english
+@japanese
+¥Æ¥¹¥È¥±¡¼¥¹¤ò½ñ¤¯¥Õ¥¡¥¤¥ë¤Ï¼¡¤Î¤è¤¦¤Ëºî¤ê¤Þ¤¹¡£
 
-@~english
-First, you declare the testCase, passing the test testCase
-name to the javaDoc style comment, which consist of a
-C-style comment block starting with two <tt>*</tt>'s:
-@~japanese
-ºÇ½é¤Ë¡¢¥Õ¥£¥¯¥¹¥Á¥ã¤òÀë¸À¤·¤Þ¤¹¡£
-¤³¤ì¤ÏjavaDoc¥¹¥¿¥¤¥ë¤Î¥³¥á¥ó¥ÈÆâ¤Ë¥Õ¥£¥¯¥¹¥Á¥ã¤Î̾Á°¤òµ­½Ò¤·¤Þ¤¹¡£
+ºÇ½é¤Ë¡¢¥Æ¥¹¥È¥¹¡¼¥Ä¤òÀë¸À¤·¤Þ¤¹¡£
+¤³¤ì¤Ï javaDoc ¥¹¥¿¥¤¥ë¤Î¥³¥á¥ó¥ÈÆâ¤Ë¥Æ¥¹¥È¥¹¡¼¥Ä¤Î̾Á°¤òµ­½Ò¤·¤Þ¤¹¡£
 javaDoc¥¹¥¿¥¤¥ë¤Î¥³¥á¥ó¥È¤È¤Ï C ¥¹¥¿¥¤¥ë¤Î¥³¥á¥ó¥È¥Ö¥í¥Ã¥¯¤Î³«»Ï¤¬
 Æó¤Ä¤Î¥¢¥¹¥¿¥ê¥¹¥¯ <tt>**</tt> ¤Ë¤Ê¤Ã¤Æ¤¤¤ë¤â¤Î¤Ç¤¹¡£
-@~
+@endif
+
+@code
+//** test suite: complex test suite *\/
+@endcode
+
+@english
+@japanese
+¼¡¤Ë¡¢
+¥Æ¥¹¥È¥±¡¼¥¹¤òÄêµÁ¤·¤Þ¤¹¡£
+¥Æ¥¹¥È¥±¡¼¥¹¤Ï javaDoc ¥¹¥¿¥¤¥ë¤Î¥³¥á¥ó¥È¤Ë½ñ¤«¤ì¤¿¥Æ¥¹¥È¥±¡¼¥¹¤Î̾Á°¤ÎÀë¸À¤È¡¢
+¥Æ¥¹¥È¥±¡¼¥¹¤Î½ªÎ»¤ÎÀë¸À¤Ç°Ï¤Þ¤ì¤¿¥°¥í¡¼¥Ð¥ëÊÑ¿ô¤È´Ø¿ô¤Î½¸¤Þ¤ê¤Ç¤¹¡£
+¤Ò¤È¤Ä¤Î¥Õ¥¡¥¤¥ë¤ËÊ£¿ô¤Î¥Æ¥¹¥È¥±¡¼¥¹¤òÄêµÁ¤Ç¤­¤Þ¤¹¡£
+@endif
 
 @code
-#include <ccunit/CCUnitAssert.h>
+//** test case: complex test case *\/
+
+static complex_t* c10_1;
+
+//** test new *\/
+void test_complex_new ()
+{
+  ...
+}
 
-//** test case: complex number test *\/
+...
+
+//** end test case *\/
+//** test case: complex arith test case *\/
+...
+//* end test case *\/
+//* end test suite *\/
+//* test suite: ... *\/
+...
+//* end test suite *\/
 @endcode
 
-@~english
+@english
+@japanese
+¥Æ¥¹¥È´Ø¿ô¤Ï̾Á°¤¬ @c test ¤Ç»Ï¤Þ¤Ã¤Æ¤¤¤Ê¤±¤ì¤Ð¤Ê¤ê¤Þ¤»¤ó¡£
+¤Þ¤¿³Æ¥Æ¥¹¥È´Ø¿ô¤ÎÁ°¤Ë¤Ï
+javaDoc ¥¹¥¿¥¤¥ë¤Î¥³¥á¥ó¥È¤ÎÃæ¤Ë¥Æ¥¹¥È´Ø¿ô¤ÎÀâÌÀ¤ò½ñ¤¯¤³¤È¤¬¤Ç¤­¤Þ¤¹¡£
+¥³¥á¥ó¥È¤¬½ñ¤«¤ì¤Æ¤¤¤Ê¤±¤ì¤Ð¡¢
+¥Æ¥¹¥È´Ø¿ô¤Î̾Á°¤¬´Ø¿ô¤ÎÀâÌÀ¤È¤·¤ÆÅÐÏ¿¤µ¤ì¤Þ¤¹¡£
+
+ÆÃÊ̤ʥƥ¹¥È´Ø¿ô¤È¤·¤Æ @c setUp, @c tearDown, @c setup_setUp, @c setup_tearDown
+¤¬¤¢¤ê¤Þ¤¹¡£
+¤½¤Î̾Á°¤«¤é¤ï¤«¤ë¤è¤¦¤Ë¡¢
+°ÊÁ°¤ËÀâÌÀ¤·¤¿¥Æ¥¹¥È¥±¡¼¥¹¤Îµ¡Ç½¤Î´Ø¿ô¤È¤·¤ÆƯ¤­¤Þ¤¹¡£
+¤½¤ì¤¾¤ì¤½¤Î¤è¤¦¤Ê̾Á°¤ÇÄêµÁ¤·¤Æ¤¯¤À¤µ¤¤¡£
+@endif
+
+@english
+To generate creating suite function code, run
+<code>ccunit_makeSuite</code> tool.
+@japanese
+¥¹¡¼¥ÄºîÀ®´Ø¿ô¤Î¥³¡¼¥É¤òÀ¸À®¤¹¤ë¤Ë¤Ï¡¢
+<code>ccunit_makeSuite</code>¥Ä¡¼¥ë¤ò¼Â¹Ô¤·¤Þ¤¹¡£
+@endif
+
+@english
 The function to make @link CCUnitTestSuite TestSuite
 @endlink is <code>ccunit_suite</code>.
 But, it can be changed to another
 name by the <code>-f</code> option of the
 <code>ccunit_makeSuite</code> command, too.
-Then, you define each test case of the testCase with prefix
-<code>test</code>, <code>setUp</code>,
-<code>tearDown</code>:
-@~japanese
+@japanese
+¼«Æ°Åª¤ËºîÀ®¤µ¤ì¤ë
 @link CCUnitTestSuite TestSuite @endlink
-¤òºîÀ®¤¹¤ë´Ø¿ô¤Ï <code>ccunit_suite</code> ¤Ç¤¹¡¢
+¤òºîÀ®¤¹¤ë´Ø¿ô¤Ï¡¢
+¥Ç¥Õ¥©¥ë¥È¤Ç¤Ï <code>ccunit_suite</code> ¤Ç¤¹¡¢
 ¤·¤«¤· <code>ccunit_makeSuite</code> ¥³¥Þ¥ó¥É¤Î
 <code>-f</code> ¥ª¥×¥·¥ç¥ó¤ÇÊ̤Î̾Á°¤ËÊѤ¨¤ë¤³¤È¤â¤Ç¤­¤Þ¤¹¡£
-¤½¤·¤Æ¡¢¥Õ¥£¥¯¥¹¥Á¥ã¤Î¥Æ¥¹¥È¥±¡¼¥¹¤Ë¤Ï¤½¤ì¤¾¤ì̾Á°¤ÎÀèƬ¤Ë¡¢
-<code>test</code>, <code>setUp</code>,
-<code>tearDown</code> ¤ò¤Ä¤±¤Æ¤¯¤À¤µ¤¤¡£
-@~
+@endif
 
 @code
-#include <complex.h>
-
-static complex_t* s10_1;
-static complex_t* s1_1;
-static complex_t* s11_2;
-static complex_t* sc;
-
-void setup_setUp_complex_test ()
-{
-  sc = complex_new (1, 1);
-}
-
-void setup_tearDown_complex_test ()
-{
-  complex_delete (sc);
-}
+$ ccunit_makeSuite -f suite_test_complex -o suiteTestComplex.c testComplexSetup.c testComplexArith.c
+@endcode
 
-void setUp_complex_test ()
-{
-  s10_1 = complex_new (10, 1);
-  s1_1 = complex_new (1, 1);
-  s11_2 = complex_new (11, 2);
-}
+@english
+@japanese
+¼«Æ°À¸À®¤·¤¿¥³¡¼¥É¤òÍøÍѤ¹¤ë¤Ë¤Ï¼¡¤Î¤è¤¦¤Ë¤·¤Þ¤¹¡£
+@endif
 
-void tearDown_complex_test ()
-{
-  complex_delete (s10_1);
-  complex_delete (s1_1);
-  complex_delete (s11_2);
-}
+@dontinclude complex/runTestSuiteAuto.c
 
-//** test equals *\/
-void test_complex_equals ()
-{
-  CCUNIT_ASSERT_TEST_OBJ (s10_1, complex_equals, s10_1, complex_to_string);
-  CCUNIT_ASSERT_TEST_OBJ (s10_1, !complex_equals, s1_1, complex_to_string);
-}
+@skip include
+@until extern
 
-//** test add *\/
-void test_complex_add ()
-{
-  complex_t c10_1 = { 10.0, 1.0 };
-  complex_t c1_1 = { 1.0, 1.0 };
-  complex_t result;
-  complex_t c11_2 = { 11.0, 2.0 };
-  CCUNIT_ASSERT (complex_equals (&c11_2, complex_add (&result, &c10_1, &c1_1)));
-}
+@english
+@japanese
+À¸À®¤·¤¿´Ø¿ô¤Î¥×¥í¥È¥¿¥¤¥×¤òÀë¸À¤·¤Þ¤¹¡£
+°ú¿ô¤Î <code>char* name</code> ¤ò˺¤ì¤Ê¤¤¤è¤¦¤Ë¤·¤Æ¤¯¤À¤µ¤¤¡£
+@endif
 
-//** test sub *\/
-void test_complex_sub ()
-{
-  complex_t c9_0 = { 9, 0 };
-  complex_t result;
-  CCUNIT_ASSERT_TEST_OBJ (&c9_0, complex_equals,
-                         complex_sub (&result, s10_1, s1_1),
-                         complex_to_string);
-}
-@endcode
+@skip main
+@until suite_test_complex
 
-@~english
-Finally, you end the testCase declaration:
-@~japanese
-ºÇ¸å¤Ë¡¢¥Õ¥£¥¯¥¹¥Á¥ã¤Î½ª¤ê¤òÀë¸À¤·¤Þ¤¹¡£
-@~
+@english
+@japanese
+À¸À®¤·¤¿´Ø¿ô¤ò¸Æ¤Ó½Ð¤·¤Æ¥Æ¥¹¥È¥¹¡¼¥Ä¤ò¼è¤ê½Ð¤·¤Þ¤¹¡£
+@endif
 
-@code
-//** end test case *\/
-@endcode
+@until }
 
 @english
 @japanese
-¤Ò¤È¤Ä¤Î¥Õ¥¡¥¤¥ë¤ÎÃæ¤ËÊ£¿ô¤Î¥Õ¥£¥¯¥¹¥Á¥ã¤òÄêµÁ¤¹¤ë¤³¤È¤â¤Ç¤­¤Þ¤¹¡£
-¤½¤Î¾ì¹ç¤Ï¡¢¥Õ¥£¥¯¥¹¥Á¥ã¤Î½ª¤ï¤ê¤ÎÀë¸À¤Î¸å¤Ë³¤±¤Æ¥Õ¥£¥¯¥¹¥Á¥ã¤òÄêµÁ¤·¤Æ¤¯¤À¤µ¤¤¡£
+¥Æ¥¹¥È¥é¥ó¥Ê¡¼¤Ç¼Â¹Ô¤·¤Þ¤¹¡£
 @endif
 
-@~english
-To generate creating suite function code, run
-<code>ccunit_makeSuite</code> tool.
-@~japanese
-¥¹¡¼¥ÄºîÀ®´Ø¿ô¤Î¥³¡¼¥É¤òÀ¸À®¤¹¤ë¤Ë¤Ï¡¢
-<code>ccunit_makeSuite</code>¥Ä¡¼¥ë¤ò¼Â¹Ô¤·¤Þ¤¹¡£
-@~
-
-@code
-$ ccunit_makeSuite -f complex_suite -o suiteComplex.c testComplex.c
-$ cat suiteComplex.c
-
-#include <ccunit/CCUnitTestSuite.h>
-#include <ccunit/CCUnitTestCase.h>
-#include <ccunit/CCUnitTestFunc.h>
-
-//* test testCase: complex number test *\/
-//* setUp_complex_test *\/
-extern void setUp_complex_test ();
-//* tearDown_complex_test *\/
-extern void tearDown_complex_test ();
-//* test_complex_equals *\/
-extern void test_complex_equals ();
-//* test_complex_add *\/
-extern void test_complex_add ();
-//* test_complex_sub *\/
-extern void test_complex_sub ();
-
-static CCUnitTestFunc fx_001_cases[] = {
-  {
-    "test_complex_equals",
-    "test equals",
-    test_complex_equals
-  },
-  {
-    "test_complex_add",
-    "test add",
-    test_complex_add
-  },
-  {
-    "test_complex_sub",
-    "test sub",
-    test_complex_sub
-  },
-  {
-    NULL, NULL, NULL
-  },
-};
-
-static CCUnitTestCaseDfn fx_001 = {
-  { ccunitTypeTestCase },
-  "complex number test",
-  {
-    "setup_setUp_complex_test",
-    "setup_setUp_complex_test",
-    setup_setUp_complex_test
-  },
-  {
-    "setup_tearDown_complex_test",
-    "setup_tearDown_complex_test",
-    setup_tearDown_complex_test
-  },
-  {
-    "setUp_complex_test",
-    "setUp_complex_test",
-    setUp_complex_test
-  },
-  {
-    "tearDown_complex_test",
-    "tearDown_complex_test",
-    tearDown_complex_test
-  },
-  fx_001_cases,
-};
-
-static CCUnitTestDfn* suite_001_test[] = {
-    &fx_001.test,
-    NULL,
-};
-
-static CCUnitTestSuiteDfn suite_001 = {
-  { ccunitTypeSuite },
-  "",
-  suite_001_test
-};
-
-
-CCUnitTestSuite* complex_suite (const char* name)
-{
-  if (!suite_001.name[0])
-    suite_001.name = name;
-  return ccunit_newTestSuiteFromDfn (&suite_001);
-}
-$
-@endcode
 
 @english
-TestCases can be packaged into test suite.
-You declare the suite before testCases.
+The sample code made in the above is in the directory <code>examples/complex</code>,
+the files are <code>runTestSuite.c</code>, <code>testComplex.c</code>
+and <code>testComplexArith.c</code>.
 @japanese
-¤Ê¤ª¡¢¤¤¤¯¤Ä¤«¤Î¥Õ¥£¥¯¥¹¥Á¥ã¤ò¥Æ¥¹¥È¥¹¡¼¥Ä¤Ë¤Þ¤È¤á¤ë¤³¤È¤â¤Ç¤­¤Þ¤¹¡£
-¤½¤Î¤¿¤á¤Ë¤Ï¡¢¥Õ¥£¥¯¥¹¥Á¥ã¤ÎÄêµÁ¤ÎÁ°¤Ë¥Æ¥¹¥È¥¹¡¼¥Ä¤òÀë¸À¤·¤Þ¤¹¡£
+¤³¤³¤Þ¤Ç¤Î¥µ¥ó¥×¥ë¥³¡¼¥É¤Ï¡¢<code>examples/complex</code> ¥Ç¥£¥ì¥¯¥È¥ê¤Î
+<code>runTestSuiteAuto.c, testComplexSetup.c</code>
+¤Ë¤¢¤ê¤Þ¤¹¡£
+
+¥³¥ó¥Ñ¥¤¥ë¤ª¤è¤Ó¼Â¹Ô¤¹¤ë¤Ë¤Ï¡¢¼¡¤Î¤è¤¦¤Ë¤·¤Þ¤¹¡£
 @endif
 
 @code
-//** test suite: complex number test suite *\/
-//** test case: complex number equality test *\/
-...
-//** test case: complex number compute test *\/
-...
+$ ccunit_makeSuite -f suite_test_complex -o suiteTestComplex.c testComplexSetup.c testComplexArith.c
+$ gcc -I. -o runTestSuiteAuto runTestSuiteAuto.c testComplexSetup.c testComplexArith.c suiteTestComplex.c complex.c -lccunit
+$ ./runTestSuiteAuto
+.......
+Time: 0.000060 sec
+
+OK (7 tests)
 @endcode
 
 @copydetails CCUnitMakeSuite