/* -*- Indented-Text -*- */
/* $Id$ */
-/** @page cookbook CCUnit Cookbook
-
+/**
+@english
+@page cookbook CCUnit Cookbook
+@endif
+@japanese
+@page cookbook CCUnit ¥¯¥Ã¥¯¥Ö¥Ã¥¯
+@endif
+
+@~english
Here is a short cookbook to help you get started.
-
+@~japanese
+¤³¤ì¤Ï CCUnit ¤ò»È¤¤»Ï¤á¤ë¤Ë¤¢¤¿¤Ã¤Æ¡¢
+Íý²ò¤Î½õ¤±¤È¤Ê¤ë¤è¤¦¤Êû¤¤¥¯¥Ã¥¯¥Ö¥Ã¥¯¤Ç¤¹¡£
+@~
+@english
+[see also <a href="../ja/cookbook.html">Japanese</a> documents]
+@endif
+@japanese
+[see also <a href="../../cookbook.html">English</a> documents]
+@endif
+
+@english
@section simple_test_case Simple Test Case
+@endif
+@japanese
+@section simple_test_case ¥·¥ó¥×¥ë¤Ê¥Æ¥¹¥È¥±¡¼¥¹
+@endif
+@~english
Tests in <b>CCUnit</b> can be run automatically. They are
easy to set up and once you have written them, they are
always there to help you keep confidence in the quality of
your code.
-
+@~japanese
+CCUnit¤ò»È¤Ã¤¿¥Æ¥¹¥È¤Ï¼«Æ°Åª¤Ë¼Â¹Ô¤¹¤ë¤³¤È¤¬¤Ç¤¤Þ¤¹¡£
+CCUnit ¤Î¥Æ¥¹¥È¤Ï´Êñ¤Ë¥»¥Ã¥È¥¢¥Ã¥×¤¹¤ë¤³¤È¤¬¤Ç¤¡¢
+°ìÅ٥ƥ¹¥È¤ò½ñ¤¤¤Æ¤·¤Þ¤¨¤Ð¡¢
+¤¤¤Ä¤Ç¤â¥×¥í¥°¥é¥à¤ÎÉʼÁ¤ò¿®Íê¤Ç¤¤ë¤â¤Î¤ËÊݤĤ³¤È¤¬¤Ç¤¤ë¤Ç¤·¤ç¤¦¡£
+@~
+
+@~english
To make a simple test, here is what you do:
+@~japanese
+ñ½ã¤Ê¥Æ¥¹¥È¤òºî¤ë¤Ë¤Ï¡¢¼¡¤Î¤è¤¦¤Ë¤·¤Þ¤¹¡£
+@~
<ol>
-<li> Create a test function</li>
-<li> When you want to check a value, call
+<li> @~english Create a test function
+ @~japanese ¥Æ¥¹¥È´Ø¿ô¤òºî¤ë</li>
+<li> @~english When you want to check a value, call
+ @~japanese Ãͤò¥Á¥§¥Ã¥¯¤·¤¿¤¤¾ì¹ç¤Ï¡¢@~
@link CCUNIT_ASSERT() CCUNIT_ASSERT(bool) @endlink
- and pass a bool that is true if the test succeeds</li>
+ @~english and pass a bool that is true if the test succeeds
+ @~japanese ¤ò¸Æ¤Ó½Ð¤·¤Æ¡¢
+ ¤â¤·¥Æ¥¹¥È¤¬À®¸ù¤¹¤ë¤Î¤Ç¤¢¤ì¤Ð¿¿¤òÊÖ¤¹¤è¤¦¤Ê¿¿µ¶ÃͤòÅϤ·¤Þ¤¹</li>
</ol>
+@~english
For example, to test that the sum of two complex number
which is the sum of the values of two complex numbers,
write:
+@~japanese
+Î㤨¤Ð¡¢Æó¤Ä¤ÎÊ£ÁÇ¿ô¤Î¹ç·×¤¬¡¢
+Æó¤Ä¤ÎÊ£ÁÇ¿ô¤ÎÃͤò²Ã»»¤·¤¿ÃͤÈƱ¤¸¤Ç¤¢¤ë¤³¤È¤ò¥Æ¥¹¥È¤¹¤ë¤È¤·¤Þ¤¹¡£
+@~
@code
void test_complex_add ()
}
@endcode
+@~english
That was a very simple test. Ordinarily, you'll have many
little test cases that you'll want to run on the same set of
objects. To do this, use a fixture.
-
+@~japanese
+¤³¤ì¤ÏÂçÊÑñ½ã¤Ê¥Æ¥¹¥È¤Ç¤¹¡£
+Ä̾Ʊ¤¸¥Ç¡¼¥¿¤Î¥»¥Ã¥È¤ÇÁö¤é¤»¤ë¤¿¤á¤Ë¡¢
+¤¿¤¯¤µ¤ó¤Î¾®¤µ¤Ê¥Æ¥¹¥È¥±¡¼¥¹¤òºî¤é¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤¤Ç¤·¤ç¤¦¡£
+¤½¤¦¤¹¤ë¤Ë¤Ï¥Õ¥£¥¯¥¹¥Á¥ã¡ÊÈ÷Éʡˤò»È¤¤¤Þ¤¹¡£
+@~
+
+@english
@section fixture Fixture
+@endif
+@japanese
+@section fixture ¥Õ¥£¥¯¥¹¥Á¥ã
+@endif
+@~english
What if you have two or more tests that operate on the same
similar set of objects?
+@~japanese
+¤â¤·Æó¤Ä°Ê¾å¤Î¥Æ¥¹¥È¤¬¤¢¤ë¤Ê¤é¡¢
+Ʊ¤¸Îà»÷¤Î¥Ç¡¼¥¿¤Î¥»¥Ã¥È¤ÇÁàºî¤¹¤ë¤Î¤Ç¤Ï¤Ê¤¤¤Ç¤·¤ç¤¦¤«¡£
+@~
+@~english
Tests need to run against the background of a known set of
objects. This set of objects is called a test fixture. When
you are writing tests you will often find that you spend
more time writing the code to set up the fixture than you do
in actually testing values.
-
-Often, you will be able to use the same fixture for sevral
+@~japanese
+¥Æ¥¹¥È¤Ï¼þÃΤΥǡ¼¥¿¤Î¥»¥Ã¥È¤òÇطʤˤ·¤Æ¼Â¹Ô¤µ¤ì¤ëɬÍפ¬¤¢¤ê¤Þ¤¹¡£
+¤³¤Î¥Ç¡¼¥¿¤Î¥»¥Ã¥È¤ò¥Õ¥£¥¯¥¹¥Á¥ã¤È¸Æ¤Ö¤³¤È¤Ë¤·¤Þ¤¹¡£
+¥Æ¥¹¥È¤ò½ñ¤¤¤Æ¤¤¤ë¤È¡¢
+¼ÂºÝ¤Î¥Æ¥¹¥È¤¹¤ëÃͤò¥Õ¥£¥¯¥¹¥Á¥ã¤Ë¥»¥Ã¥È¥¢¥Ã¥×¤¹¤ë¥³¡¼¥É¤ò½ñ¤¯Êý¤Ë¡¢
+¤â¤Ã¤È»þ´Ö¤ò¤«¤±¤Æ¤¤¤ë¤³¤È¤Ëµ¤¤Å¤¯¤³¤È¤¬¤è¤¯¤¢¤ê¤Þ¤¹¡£
+@~
+
+@~english
+Often, you will be able to use the same fixture for several
different tests. Each case will send slightly different
-messages or parameteres to the fixture and will check for
+messages or parameters to the fixture and will check for
different results.
-
+@~japanese
+¿¤¯¤Î¾ì¹ç¡¢¤¤¤¯¤Ä¤«¤Î°Û¤Ê¤Ã¤¿¥Æ¥¹¥È¤Î¤¿¤á¤ËƱ¤¸¥Õ¥£¥¯¥¹¥Á¥ã¤ò»È¤¦¤³¤È¤¬¤Ç¤¤Þ¤¹¡£
+¤½¤ì¤¾¤ì¤Î¥Æ¥¹¥È¥±¡¼¥¹¤Ï¾¯¤·°Û¤Ê¤Ã¤¿¥á¥Ã¥»¡¼¥¸¡¢
+¤¢¤ë¤¤¤Ï¥Ñ¥é¥á¡¼¥¿¤ò¥Õ¥£¥¯¥¹¥Á¥ã¤ËÁ÷¤ê¡¢
+°Û¤Ê¤ë·ë²Ì¤òÄ´¤Ù¤Þ¤¹¡£
+@~
+
+@~english
When you have a common fixture, here is what you do:
+@~japanese
+¤â¤·¶¦Ä̤¹¤ë¥Õ¥£¥¯¥¹¥Á¥ã¤¬¤¢¤ì¤Ð¡¢¤³¤ó¤Ê¤Õ¤¦¤Ë¤¹¤ë¤³¤È¤Ë¤Ê¤ê
+¤Þ¤¹¡£
+@~
<ol>
-<li>Create a @link CCUnitTestCase TestCase @endlink object</li>
-<li>Add an global variable for each part of the fixture</li>
-<li>Write <code>setUp()</code> function to initialize the valiables</li>
-<li>Write <code>tearDown()</code> to release any permanent
- resources you allocated in <code>setUp</code></li>
-<li>Create a @link CCUnitTestFixture TestFixture @endlink object</li>
-<li>Add test case objects to fixture object</li>
+<li>@~english
+ Create a @link CCUnitTestCase TestCase @endlink object
+ @~japanese
+ @link CCUnitTestCase TestCase @endlink ¹½Â¤ÂΤ˥á¥â¥ê¤ò³ä¤êÅö¤Æ¤Þ¤¹
+ ¡Ê°Ê¹ß¡¢¹½Â¤ÂΤ˳ä¤êÅö¤Æ¤¿¥á¥â¥ê¤ò¡¢¥ª¥Ö¥¸¥§¥¯¥È¤È¸Æ¤Ö¤³¤È¤Ë¤·¤Þ¤¹¡Ë
+</li>
+<li>@~english
+ Add an global variable for each part of the fixture
+ @~japanese
+ ¥Õ¥£¥¯¥¹¥Á¥ã¤Î¤½¤ì¤¾¤ì¤ÎÉôʬ¤ËÂç°èÊÑ¿ô¤òÄɲä·¤Þ¤¹
+</li>
+<li>@~english
+ Write <code>setUp()</code> function to initialize the valiables
+ @~japanese
+ <code>setUp()</code> ´Ø¿ô¤ò½ñ¤¤¤ÆÊÑ¿ô¤ò½é´ü²½¤·¤Þ¤¹
+</li>
+<li>@~english
+ Write <code>tearDown()</code> to release any permanent
+ resources you allocated in <code>setUp</code>
+ @~japanese
+ <code>tearDown()</code> ´Ø¿ô¤ò½ñ¤¤¤Æ<code>setUp</code>
+ ¤Ç³ä¤êÅö¤Æ¤¿±Ê³Ū¥ê¥½¡¼¥¹¤ò²òÊü¤·¤Þ¤¹
+</li>
+<li>@~english
+ Create a @link CCUnitTestFixture TestFixture @endlink object
+ @~japanese
+ @link CCUnitTestFixture CCUnitTestFixture @endlink
+ ¹½Â¤ÂΤ˥á¥â¥ê¤ò³ä¤êÅö¤Æ¤Þ¤¹
+</li>
+<li>@~english
+ Add @link GGUnitTestCase TestCase @endlink objects to fixture object
+ @~japanese
+ @link CCUnitTestCase TestCase @endlink
+ ¥ª¥Ö¥¸¥§¥¯¥È¤ò@link CCUnitTestFixture TestFixture @endlink
+ ¥Õ¥£¥¯¥¹¥Á¥ã¥ª¥Ö¥¸¥§¥¯¥È¤ËÅÐÏ¿¤·¤Þ¤¹¡£
+</li>
</ol>
+@~english
For example, to write several test cases, first create a
fixture:
+@~japanese
+Î㤨¤Ð¡¢¤¤¤¯¤Ä¤«¤Î¥Æ¥¹¥È¥±¡¼¥¹¤ò½ñ¤¯¾ì¹ç¡¢
+ºÇ½é¤Ë¥Õ¥£¥¯¥¹¥Á¥ã¤òºîÀ®¤·¤Þ¤¹¡£
+@~
@code
//** TEST CASE: complex number test *\/
s1_1 = complex_new (1, 1);
s11_2 = complex_new (11, 2);
}
-
+
void tearDown_ComplexTest ()
{
complex_delete (s10_1);
CCUNIT_NEWTESTFUNC(tearDown_ComplexTest));
@endcode
+@~english
Once you have the Fixture in place, you can write as complex
Test Cases as you'd like.
+@~japanese
+°ìÅÙ·è¤Þ¤Ã¤¿¤È¤³¤í¤Ë¥Õ¥£¥¯¥¹¥Á¥ã¤ò½ñ¤¤¤Æ¤·¤Þ¤¨¤Ð¡¢
+¤¢¤Ê¤¿¤¬¹¥¤¤Ê¤è¤¦¤ËÊ£ÁÇ¿ô¤Î¥Æ¥¹¥È¥±¡¼¥¹¤ò½ñ¤¯¤³¤È¤¬¤Ç¤¤Þ¤¹¡£
+@~
+@english
@section test_case Test Case
+@endif
+@japanese
+@section test_case ¥Æ¥¹¥È¥±¡¼¥¹
+@endif
+@~english
How do you write and invoke an individual test case when you
have a Fixture?
+@~japanese
+¥Õ¥£¥¯¥¹¥Á¥ã¤ò°ì¤Ä½ñ¤¤¤¿¤È¤·¤Æ¡¢
+¤É¤¦¤ä¤Ã¤Æ¸Ä¡¹¤Î¥Æ¥¹¥È¥±¡¼¥¹¤ò½ñ¤¤¤Æ¼Â¹Ô¤¹¤ì¤ÐÎɤ¤¤Ç¤·¤ç¤¦¤«¡£
+@~
+@~english
For example, to test the equality of two complex number,
write:
+@~japanese
+Î㤨¤Ð¡¢Æó¤Ä¤ÎÊ£ÁÇ¿ô¤¬Åù¤·¤¤¡Ê¤Þ¤¿¤ÏÅù¤·¤¯¤Ê¤¤¡Ë¤³¤È¤ò¥Æ¥¹¥È¤¹¤ë¤Ë¤Ï¡¢
+¼¡¤Î¤è¤¦¤Ë½ñ¤¤Þ¤¹¡£
+@~
@code
void test_complex_equals ()
...
- ccunit_addNewTestCase (fixture,
+ ccunit_addNewTestCase (fixture,
"test_complex_equals",
"complex equals test",
test_complex_equals);
- ccunit_addNewTestCase (fixture,
- "test_complex_add",
- "complex add test",
- test_complex_add);
-@endcode
+@endcode
+@~english
One may create and run objects for each test case like this:
+@~japanese
+°ì¤Ä¤Ë¤Ï¼¡¤Î¤è¤¦¤Ë¡¢
+¥Õ¥£¥¯¥¹¥Á¥ã¤òºîÀ®¤·¤Æ¤½¤ì¤¾¤ì¤Î¥Æ¥¹¥È¥±¡¼¥¹¤ò¼Â¹Ô¤µ¤»¤ë¤³¤È
+¤¬¤Ç¤¤Þ¤¹¡£
+@~
@code
CCUnitTestResult* result;
result = ccunit_runTestFixture (fixture);
@endcode
+@~english
When the test fixture is run, that specific test functions
will be run. This is not a useful thing to do, however, as
no diagnostics will be displayed. One will normally use a
@link ExecutingTest TestRunner @endlink (see below) to
display the results.
-
+@~japanese
+¥Æ¥¹¥È¥Õ¥£¥¯¥¹¥Á¥ã¤¬¼Â¹Ô¤µ¤ì¤ë¤È¡¢
+ÆÃÄê¤Î¥Æ¥¹¥È´Ø¿ô¤¬¸Æ¤Ó½Ð¤µ¤ì¤Þ¤¹¡£
+¤³¤ì¤Ï¤¢¤Þ¤êÊØÍø¤Ç¤Ï¤¢¤ê¤Þ¤»¤ó¡¢
+¤Ê¤¼¤Ê¤é¡¢¿ÇÃǤ¬É½¼¨¤µ¤ì¤Ê¤¤¤«¤é¤Ç¤¹¡£
+Ä̾ï¤Ï @link ExecutingTest TestRunner @endlink
+(@ref test_runner ¸å½Ò)
+¤Ç·ë²Ì¤òɽ¼¨¤·¤Þ¤¹¡£
+@~
+
+@~english
Once you have several tests, organize them into a suite.
+@~japanese
+°ìÅÙ¤¤¤¯¤Ä¤«¤Î¥Æ¥¹¥È¤òºî¤Ã¤¿¤é¡¢
+¤½¤ì¤é¤ò¥¹¥¤¡¼¥È¤ËÀ°Íý¤·¤Þ¤¹¡£
+@~
+@english
@section suite Suite
+@endif
+@japanese
+@section suite ¥¹¥¤¡¼¥È
+@endif
+@~english
How do you set up your tests so that you can run them all at once?
+@~japanese
+¤É¤Î¤è¤¦¤Ë¤·¤Æ¡¢°ìÅ٤˥ƥ¹¥È¤ò¼Â¹Ô¤¹¤ë¤³¤È¤¬¤Ç¤¤ë¤è¤¦¡¢
+½àÈ÷¤·¤¿¤é¤¤¤¤¤Ç¤·¤ç¤¦¤«¡©
+@~
+@~english
%CCUnit provides a @link CCUnitTestSuite TestSuite @endlink
module that runs any number of TestCases together.
+@~japanese
+CCUnit ¤Ï¤¤¤¯¤Ä¤â¤Î @link CCUnitTestCase TestCases @endlink
+¤ò°ì½ï¤Ë¼Â¹Ô¤¹¤ë
+@link CCUnitTestSuite TestSuite @endlink ¥â¥¸¥å¡¼¥ë¤òÄ󶡤·¤Þ¤¹¡£
+@~
+@~english
You saw, above, how to run test fixture.
+@~japanese
+¥Æ¥¹¥È¥Õ¥£¥¯¥¹¥Á¥ã¤ò¼Â¹Ô¤¹¤ëÊýË¡¤Ï¾å½Ò¤·¤Þ¤·¤¿¡£
+@~
+@~english
To create a suite of two or more tests, you do the following:
+@~japanese
+Æó¤Ä°Ê¾å¤Î¥Æ¥¹¥È¤ò´Þ¤à°ì¤Ä¤Î¥¹¥¤¡¼¥È¤òºî¤ë¤Ë¤Ï¡¢¼¡¤Î¤è¤¦¤Ë¤·¤Þ¤¹¡£
+@~
@code
CCUnitTestSuite* suite;
CCUnitTestFixture* fixture;
CCUnitTestResult* result;
suite = ccunit_newTestSuite ("Complex test suite");
-fixture = ccunit_newTestFixture ("Complex Tests",
+fixture = ccunit_newTestFixture ("Complex Tests",
CCUNIT_NEWTESTFUNC(setUp_complex_test),
CCUNIT_NEWTESTFUNC(tearDown_complex_test));
ccunit_addNewTestCase (fixture, "test_complex_equals", "complex equals test",
test_complex_sub);
ccunit_addTestFixture (suite, fixtuer);
result = ccunit_runTestSuite (suite, NULL);
-@endcode
+@endcode
+@~english
@link CCUnitTestSuite TestSuites @endlink don't only have to
contain @link CCUnitTestFixture TestFixtures @endlink. They
can contain any object that implements the @link CCUnitTest
can create one in mine, and we can run them together by
creating a @link CCUnitTestSuite TestSuite @endlink that
contains both:
+@~japanese
+@link CCUnitTestSuite TestSuites @endlink ¤Ï
+@link CCUnitTestFixture TestFixtures @endlink
+¤ò´Þ¤à¤À¤±¤Ç¤Ï¤¢¤ê¤Þ¤»¤ó¡£
+¤½¤ì¤é¤Ï @link CCUnitTest Test @endlink
+¥¤¥ó¥¿¥Õ¥§¡¼¥¹¤ò¼ÂÁõ¤¹¤ë¤É¤ó¤Ê¥ª¥Ö¥¸¥§¥¯¥È¤Ç¤â´Þ¤á¤é¤ì¤Þ¤¹¡£
+Î㤨¤Ð¡¢¤¢¤Ê¤¿¤Ï¤¢¤Ê¤¿¤Î¥³¡¼¥É¤Ë@link CCUnitTestSuite TestSuite @endlink
+¤òºî¤ë¤³¤È¤¬¤Ç¤¡¢¤½¤·¤Æ»ä¤Ï»ä¤Î¥¹¥¤¡¼¥È¤òºî¤ë¤³¤È¤¬¤Ç¤¤Þ¤¹¡¢
+¤½¤·¤Æ»äã¤ÏξÊý¤È¤â¤ò´Þ¤ó¤Ç¤¤¤ë @link CCUnitTestSuite TestSuite @endlink
+¤òºî¤Ã¤Æ°ì½ï¤Ë¸Ä¡¹¤Î¥¹¥¤¡¼¥È¤òÆ°¤«¤¹¤³¤È¤¬¤Ç¤¤ë¤Î¤Ç¤¹¡£
+@~
@code
CCUnitTestSuite* suite;
@endcode
+@english
@section test_runner TestRunner
+@endif
+@japanese
+@section test_runner ¥Æ¥¹¥È¥é¥ó¥Ê¡¼
+@endif
+@~english
How do you run your tests and collect their results?
+@~japanese
+¤É¤¦¤ä¤Ã¤Æ¥Æ¥¹¥È¤ò¼Â¹Ô¤·¡¢¤½¤Î·ë²Ì¤ò½¸¤á¤¿¤éÎɤ¤¤Ç¤·¤ç¤¦¤«¡£
+@~
+@~english
Once you have a test suite, you'll want to run it. %CCUnit
provides tools to define the suite to be run and to display
its results. You make your suite accessible to a @link
CreatingTestSuite ccunit_makeSuite @endlink tool that generate a
creating test suite code.
-
-For example, to make a ComplexTest suite available to a
-@link CreatingTestSuite ccunit_makeSuite @endlink,
-excute the following tool to
+@~japanese
+°ì¤Ä¥Æ¥¹¥È¥¹¥¤¡¼¥È¤ò½ñ¤¤¤¿¤é¡¢
+¤½¤ì¤ò¼Â¹Ô¤·¤¿¤¤¤Ç¤·¤ç¤¦¡£
+CCUnit ¤Ï¥¹¥¤¡¼¥È¤ò¼Â¹Ô¤¹¤ë¤¿¤á¤ËÄêµÁ¤·¡¢
+·ë²Ì¤òɽ¼¨¤¹¤ë¤¿¤á¤Î¥Ä¡¼¥ë¤òÄ󶡤·¤Þ¤¹¡£
+¥¹¡¼¥Ä¤ò@link CreatingTestSuite ccunit_makeSuite @endlink
+¥Ä¡¼¥ë¤ËÆþÎϤǤ¤ë¤è¤¦¤Ê·Á¼°¤Ç½ñ¤¯¤³¤È¤Ç¡¢
+¥Æ¥¹¥È¥¹¡¼¥Ä¤òºîÀ®¤¹¤ë¥³¡¼¥É¤ò¼«Æ°Åª¤ËÀ¸À®¤¹¤ë¤³¤È¤¬¤Ç¤¤Þ¤¹¡£
+@~
+
+@~english
+For example, to make a ComplexTest suite available to a
+@link CreatingTestSuite ccunit_makeSuite @endlink,
+excute the following tool to
ComplexTest.c:
+@~japanese
+Î㤨¤Ð¡¢ComplexTest ¥¹¥¤¡¼¥È¤ò
+@link CreatingTestSuite ccunit_makeSuite @endlink
+¤ò»È¤Ã¤Æ»ÈÍѤǤ¤ë¤è¤¦¤Ë¤¹¤ë¤Ë¤Ï¡¢
+°Ê²¼¤Î¥Ä¡¼¥ë¤ò ComplexTest.c ¤Ë¼Â¹Ô¤·¤Þ¤¹¡£
+@~
@code
$ ccunit_makeSuite -f complex_suite -o suiteComplex.c ComplexTest.c
@endcode
@anchor test_runner_code
+@~english
To use the TestRunner, include the header files for the tests in Main.c:
+@~japanese
+TestRunner ¤ò»ÈÍѤ¹¤ë¤Ë¤Ï¡¢
+Main.c¤Ç¥Æ¥¹¥È¤Î¤¿¤á¤Î¥Õ¥¡¥¤¥ë¤Î¥Ø¥Ã¥À¤ò¥¤¥ó¥¯¥ë¡¼¥É¤·¤Þ¤¹¡£
+@~
@code
#include <ccunit/CCUnitTestRunner.h>
#include <ccunit/CCUnitTestSuite.h>
@endcode
+@~english
And call to
@link ccunit_runTestRunner()
-ccunit_runTestRunner (CCUnitTestRunner*, CCUnitTestSuite *) @endlink
+ccunit_runTestRunner (CCUnitTestRunner*, CCUnitTestSuite *) @endlink
in the <code>main()</code> function:
+@~japanese
+¤½¤·¤Æ@link ccunit_runTestRunner()
+ccunit_runTestRunner (CCUnitTestRunner*, CCUnitTestSuite *) @endlink
+¤ò<code>main()</code>´Ø¿ô¤Ç¼Â¹Ô¤·¤Þ¤¹¡£
+@~
@code
extern CCUnitTestSuite* complex_suite(const char* name);
}
@endcode
-The @link ExecutingTest TestRunner @endlink will run the tests.
-If all the tests pass, you'll get an informative message.
+@~english
+The @link ExecutingTest TestRunner @endlink will run the tests.
+If all the tests pass, you'll get an informative message.
If any fail, you'll get the following information:
+@~japanese
+@link ExecutingTest TestRunner @endlink ¤Ï¥Æ¥¹¥È¤ò¼Â¹Ô¤·¤Þ¤¹¡£
+¤â¤·¤¹¤Ù¤Æ¤Î¥Æ¥¹¥È¤¬¥Ñ¥¹¤¹¤ì¤Ð¡¢¤½¤Î¾ðÊó¤Î¥á¥Ã¥»¡¼¥¸¤¬É½¼¨¤µ¤ì¤Þ¤¹¡£
+¤â¤·¤É¤ì¤«¤¬¼ºÇÔ¤¹¤ì¤Ð¡¢¤½¤ì¤Ë¤Ä¤¤¤Æ°Ê²¼¤Î¤è¤¦¤Ê¾ðÊó¤¬É½¼¨¤µ¤ì¤Þ¤¹¡£
+@~
<ul>
-<li> The name of the source file that contains the test</li>
-<li> The line number where the failure occurred</li>
-<li> The name of the test case that failed</li>
-<li> All of the text inside the call to
- <code>CCUNIT_ASSERT ()</code> which detected the failure</li>
+<li>@~english
+ The name of the source file that contains the test
+ @~japanese
+ ¥Æ¥¹¥È¤ò´Þ¤ó¤Ç¤¤¤ë¥½¡¼¥¹¥Õ¥¡¥¤¥ë̾
+</li>
+<li>@~english
+ The line number where the failure occurred
+ @~japanese
+ ¼ºÇÔ¤¬Åܤ俹ÔÈÖ¹æ
+</li>
+<li>@~english
+ The name of the test case that failed
+ @~japanese
+ ¼ºÇÔ¤·¤¿¥Æ¥¹¥È¥±¡¼¥¹¤Î̾Á°
+</li>
+<li>@~english
+ All of the text inside the call to
+ <code>CCUNIT_ASSERT ()</code> which detected the failure
+ @~japanese
+ ¼ºÇÔ¤ò¸¡ÃΤ·¤¿<code>CCUNIT_ASSERT ()</code>¤¬¸Æ¤Ó½Ð¤µ¤ì¤¿»þ¤Î¾ò·ï¤Îʸ»úÎó¡£
+</li>
</ul>
+@english
@section helper_macros Helper Tool
-
-As you might have noticed, implementing the fixture
-<code>suite ()</code> function is a repetitive and error
+@endif
+@japanese
+@section helper_macros ¥Ø¥ë¥Ñ¡¼¥Ä¡¼¥ë
+@endif
+
+@~english
+As you might have noticed, implementing the <code>suite
+()</code> function of fixture 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> method.
+<code>suite()</code> function.
+@~japanese
+¤ªµ¤¤Å¤¤Î¤è¤¦¤Ë¡¢¥Õ¥£¥¯¥¹¥Á¥ã¤Î <code>suite ()</code>´Ø¿ô¤ò¼ÂÁõ¤¹¤ë¤Î¤Ï¡¢
+È¿ÉüŪ¤Ç´Ö°ã¤¤¤ä¤¹¤¤ºî¶È¤Ç¤¹¡£
+@ref CreatingTestSuite ¤Î´Ø¿ô¤Î¥»¥Ã¥È¤È¥³¥Þ¥ó¥É¤Ï<code>suite ()</code>
+´Ø¿ô¤Î¼ÂÁõ¤ò¼«Æ°Åª¤ËºîÀ®¤¹¤ë¤³¤È¤¬¤Ç¤¤Þ¤¹¡£
+@~
+
+@dontinclude complex/testComplex.c
+@~english
The following code is a rewrite of ComplexTest using those command:
+@~japanese
+°Ê²¼¤Î¥³¡¼¥É¤Ï¤½¤ì¤é¤Î¥³¥Þ¥ó¥É¤¬»È¤¦¤è¤¦¤ËComplexTest¤ò½ñ´¹¤¨¤¿¤â¤Î¤Ç¤¹¡£
+@~
@code
#include <cppunit/CCUnitAssert.h>
@endcode
+@~english
First, you declare the fixture, passing the test fixture
name to the javaDoc style comment, which consist of a
C-style comment block starting with two <tt>*</tt>'s:
+@~japanese
+ºÇ½é¤Ë¡¢¥Õ¥£¥¯¥¹¥Á¥ã¤òÀë¸À¤·¤Þ¤¹¡£
+¤³¤ì¤ÏjavaDoc¥¹¥¿¥¤¥ë¤Î¥³¥á¥ó¥ÈÆâ¤Ë¥Õ¥£¥¯¥¹¥Á¥ã¤Î̾Á°¤òµ½Ò¤·¤Þ¤¹¡£
+javaDoc¥¹¥¿¥¤¥ë¤Î¥³¥á¥ó¥È¤È¤Ï C ¥¹¥¿¥¤¥ë¤Î¥³¥á¥ó¥È¥Ö¥í¥Ã¥¯¤Î³«»Ï¤¬
+Æó¤Ä¤Î¥¢¥¹¥¿¥ê¥¹¥¯<tt>*</tt>¤Ë¤Ê¤Ã¤Æ¤¤¤ë¤â¤Î¤Ç¤¹¡£
+@~
@code
//** test case: complex number test *\/
@endcode
-The suite created by the <code>ccunit_suite()</code>
-function is specified <code>-f</code> option of command
-<code>ccunit_makeSuite</code>. Then, you define each test
-case of the fixture with prefix <code>test</code>,
-<code>setUp</code>, <code>tearDown</code>:
+@~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 fixture with prefix
+<code>test</code>, <code>setUp</code>,
+<code>tearDown</code>:
+
+@~japanese
+@link CCUnitTestSuite TestSuite @endlink
+¤òºîÀ®¤¹¤ë´Ø¿ô¤Ï <code>ccunit_suite</code> ¤Ç¤¹¡¢
+¤·¤«¤· <code>ccunit_makeSuite</code> ¥³¥Þ¥ó¥É¤Î
+<code>-f</code> ¥ª¥×¥·¥ç¥ó¤ÇÊ̤Î̾Á°¤ËÊѤ¨¤ë¤³¤È¤â¤Ç¤¤Þ¤¹¡£
+¤½¤·¤Æ¡¢¥Õ¥£¥¯¥¹¥Á¥ã¤Î¥Æ¥¹¥È¥±¡¼¥¹¤Ë¤Ï¤½¤ì¤¾¤ì̾Á°¤ÎÀèƬ¤Ë¡¢
+<code>test</code>, <code>setUp</code>,
+<code>tearDown</code> ¤ò¤Ä¤±¤Æ¤¯¤À¤µ¤¤¡£
+@~
@code
#include <complex.h>
s1_1 = complex_new (1, 1);
s11_2 = complex_new (11, 2);
}
-
+
void tearDown_complex_test ()
{
complex_delete (s10_1);
}
@endcode
+@~english
Finally, you end the fixture declaration:
+@~japanese
+ºÇ¸å¤Ë¡¢¥Õ¥£¥¯¥¹¥Á¥ã¤Î½ª¤ê¤òÀë¸À¤·¤Þ¤¹¡£
+@~
@code
//** end test case *\/
@endcode
+@~english
To generate creating suite function code, run
<code>ccunit_makeSuite</code> tool.
+@~japanese
+¥¹¥¤¡¼¥ÈºîÀ®´Ø¿ô¤Î¥³¡¼¥É¤òÀ¸À®¤¹¤ë¤Ë¤Ï¡¢
+<code>ccunit_makeSuite</code>¥Ä¡¼¥ë¤ò¼Â¹Ô¤·¤Þ¤¹¡£
+@~
@code
-$ ccunit_makeSuite testComplex.c
+$ ccunit_makeSuite -f complex_suite -o suiteComplex.c testComplex.c
+$ cat suiteComplex.c
#include <ccunit/CCUnitTestSuite.h>
#include <ccunit/CCUnitTestFixture.h>
//* 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 CCUnitTestFixtureDfn fx_001 = {
{ ccunitTypeFixture },
"tearDown_complex_test",
tearDown_complex_test
},
- {
- {
- "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
- },
- }
+ fx_001_cases,
+};
+
+static CCUnitTestDfn* suite_001_test[] = {
+ &fx_001.test,
+ NULL,
};
static CCUnitTestSuiteDfn suite_001 = {
{ ccunitTypeSuite },
"",
- {
- &suite_002.test,
- NULL,
- },
+ suite_001_test
};
-CCUnitTestSuite* ccunit_suite (const char* name)
+
+CCUnitTestSuite* complex_suite (const char* name)
{
if (!suite_001.name[0])
suite_001.name = name;
$
@endcode
+@english
@section post_build_check Post-build check
+@endif
+@japanese
+@section post_build_check ¥Ó¥ë¥É¸å¤Î¥Á¥§¥Ã¥¯
+@endif
+@~english
Now that we have our unit tests running, how about
integrating unit testing to our build process ?
+@~japanese
+¤µ¤¢¥æ¥Ë¥Ã¥È¥Æ¥¹¥È¤ò¼Â¹Ô¤¹¤ë½àÈ÷¤¬¤Ç¤¤Þ¤·¤¿¡£
+¤Ç¤Ï¥Ó¥ë¥É¥×¥í¥»¥¹¤Ë¥æ¥Ë¥Ã¥È¥Æ¥¹¥È¤òÅý¹ç¤¹¤ë¤Ë¤Ï¤É¤¦¤·¤¿¤é¤¤
+¤¤¤Ç¤·¤ç¤¦¡£
+@~
+@~english
To do that, the application must returns a value different than 0 to indicate that
there was an error.
+@~japanese
+¤½¤¦¤¹¤ë¤Ë¤Ï¡¢¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤Ï¡¢¥¨¥é¡¼¤¬È¯À¸¤·¤¿¤³¤È¤ò¼¨¤¹
+£°°Ê³°¤ÎÃͤòÊÖ¤µ¤Ê¤±¤ì¤Ð¤Ê¤ê¤Þ¤»¤ó¡£
+@~
-@link ccunit_runTestRunner() ccunit_runTestRunner() @endlink returns
+@~english
+@link ccunit_runTestRunner() ccunit_runTestRunner() @endlink returns
a integer indicating if the run was successful.
+@~japanese
+@link ccunit_runTestRunner() ccunit_runTestRunner() @endlink
+¤Ï¡¢¼Â¹Ô¤¬À®¸ù¤·¤¿¤«¤É¤¦¤«¤ò¼¨¤¹À°¿ô¤òÊÖ¤·¤Þ¤¹¡£
+@~
+@~english
Updating our main programm, we obtains:
+@~japanese
+¼¡¤Î¤è¤¦¤Ë¥á¥¤¥ó¥×¥í¥°¥é¥à¤ò¹¹¿·¤·¤Þ¤¹¡£
+@~
+
@code
#include <ccunit/CCUnitTestRunner.h>
}
@endcode
+@~english
Now, you need to run your application after compilation.
+The sample program made in the above is in the example/complex directory.
+@~japanese
+¤½¤ì¤Ç¤Ï¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤ò¥³¥ó¥Ñ¥¤¥ë¤·¤¿¸å¤Ë¼Â¹Ô¤·¤Æ¤ß¤Þ¤·¤ç
+¤¦¡£
+°Ê¾å¤ÇºîÀ®¤·¤¿¥µ¥ó¥×¥ë¥×¥í¥°¥é¥à¤Ï example/complex ¥Ç¥£¥ì¥¯
+¥È¥ê¤Ë¤¢¤ê¤Þ¤¹¡£
+@~
*/