OSDN Git Service

cf0c17212db9866420b397e08eb1a9ddf20ed260
[ccunit/ccunit.git] / doc / cookbook.dox
1 /* -*- Indented-Text -*- */
2 /* Copyright (C) 2003, 2010 TSUTSUMI Kikuo.
3    This file is part of the CCUnit Library.
4
5    The CCUnit Library is free software; you can redistribute it and/or
6    modify it under the terms of the GNU Lesser General Public License
7    as published by the Free Software Foundation; either version 2.1 of
8    the License, or (at your option) any later version.
9
10    The CCUnit Library is distributed in the hope that it will be
11    useful, but WITHOUT ANY WARRANTY; without even the implied warranty
12    of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13    GNU Lesser General Public License for more details.
14
15    You should have received a copy of the GNU Lesser General Public
16    License along with the CCUnit Library; see the file COPYING.LESSER.
17    If not, see <http://www.gnu.org/licenses/>
18 */
19 /* $Id$ */
20 /**
21 @english
22 @page cookbook CCUnit Cookbook
23 @japanese
24 @page cookbook CCUnit ¥¯¥Ã¥¯¥Ö¥Ã¥¯
25 @endif
26
27 @~english
28 Here is a short cookbook to help you get started.
29 @~japanese
30 ¤³¤ì¤Ï CCUnit ¤ò»È¤¤»Ï¤á¤ë¤Ë¤¢¤¿¤Ã¤Æ¡¢
31 Íý²ò¤Î½õ¤±¤È¤Ê¤ë¤è¤¦¤Êû¤¤¥¯¥Ã¥¯¥Ö¥Ã¥¯¤Ç¤¹¡£
32 @~
33 @english
34 [see also <a href="../ja/cookbook.html">Japanese</a> documents]
35 @japanese
36 [see also <a href="../../cookbook.html">English</a> documents]
37 @endif
38
39 @english
40 @section simple_test_case Simple Test Case
41 @japanese
42 @section simple_test_case ¥·¥ó¥×¥ë¤Ê¥Æ¥¹¥È¥±¡¼¥¹
43 @endif
44
45 @~english
46 Tests in <b>CCUnit</b> can be run automatically.  They are
47 easy to set up and once you have written them, they are
48 always there to help you keep confidence in the quality of
49 your code.
50 @~japanese
51 CCUnit¤ò»È¤Ã¤¿¥Æ¥¹¥È¤Ï¼«Æ°Åª¤Ë¼Â¹Ô¤¹¤ë¤³¤È¤¬¤Ç¤­¤Þ¤¹¡£
52 CCUnit ¤Î¥Æ¥¹¥È¤Ï´Êñ¤Ë¥»¥Ã¥È¥¢¥Ã¥×¤¹¤ë¤³¤È¤¬¤Ç¤­¡¢
53 °ìÅ٥ƥ¹¥È¤ò½ñ¤¤¤Æ¤·¤Þ¤¨¤Ð¡¢
54 ¤¤¤Ä¤Ç¤â¥×¥í¥°¥é¥à¤ÎÉʼÁ¤ò¿®Íê¤Ç¤­¤ë¤â¤Î¤ËÊݤĤ³¤È¤¬¤Ç¤­¤ë¤Ç¤·¤ç¤¦¡£
55 @~
56
57 @~english
58 To make a simple test, here is what you do:
59 @~japanese
60 ñ½ã¤Ê¥Æ¥¹¥È¤òºî¤ë¤Ë¤Ï¡¢¼¡¤Î¤è¤¦¤Ë¤·¤Þ¤¹¡£
61 @~
62
63 <ol>
64 <li> @english Create a test function
65      @japanese ¥Æ¥¹¥È´Ø¿ô¤òºî¤ê¤Þ¤¹¡£
66      @endif
67 </li>
68 <li> @english When you want to check a value, call
69      @link CCUNIT_ASSERT() CCUNIT_ASSERT(bool) @endlink
70      and pass a bool that is true if the test succeeds
71
72      ASSERT macro is listed in others as well in
73      @link Assertions Making assertions @endlink.
74      @japanese
75      Ãͤò¥Á¥§¥Ã¥¯¤·¤¿¤¤¾ì¹ç¤Ï¡¢
76      @link CCUNIT_ASSERT() CCUNIT_ASSERT(bool) @endlink
77      ¤ò¸Æ¤Ó½Ð¤·¤Æ¡¢
78      ¥Æ¥¹¥È¤¬À®¸ù¤¹¤ë¤Ê¤é¿¿¤òÊÖ¤¹¤è¤¦¤Ê¿¿µ¶ÃͤòÅϤ·¤Þ¤¹¡£
79
80      ASSERT ´Ø·¸¤Î¥Þ¥¯¥í¤Ï¾¤Ë¤â
81      @link Assertions ¥¢¥µ¡¼¥È¤ÎÀë¸À @endlink
82      ¤Ë¥ê¥¹¥È¤·¤Æ¤¢¤ê¤Þ¤¹¡£
83      @endif
84 </li>
85 </ol>
86
87 @~english
88 For example, to test that the sum of two complex number
89 which is the sum of the values of two complex numbers,
90 write (This sample program is in the @c examples/complex directory):
91 @~japanese
92 Î㤨¤Ð¡¢´Êñ¤ÊÊ£ÁÇ¿ô¤Î¥é¥¤¥Ö¥é¥ê¤ò¥Æ¥¹¥È¤¹¤ë¤³¤È¤òÎã¤Ë¤È¤Ã¤Æ¤ß¤Þ¤·¤ç¤¦¡£
93 ¡Ê¤³¤³¤Ç»ÈÍѤ¹¤ë@ref sample_programs¤Ï
94 examples/complex ¥Ç¥£¥ì¥¯¥È¥ê¤Ë¤¢¤ê¤Þ¤¹¡£¡Ë
95 Ê£ÁÇ¿ô¤ò½é´ü²½¤¹¤ë¤³¤È¤¬¤Ç¤­¤¿¤«¤ò¥Æ¥¹¥È¤·¤¿¤ê¡¢
96 Æó¤Ä¤ÎÊ£ÁÇ¿ô¤¬Åù¤·¤¤¤«¤ò¥Æ¥¹¥È¤¹¤ë¤È¤·¤Þ¤¹¡£
97 @~
98
99 @dontinclude complex/testComplex.c
100
101 @skip test_complex_new
102 @until }
103 @skip test_complex_equals
104 @until }
105
106 @english
107 @japanese
108 ¤³¤ÎÆó¤Ä¤Î¥Æ¥¹¥È´Ø¿ô¤ò¤Þ¤È¤á¤Æ¤Ò¤È¤Ä¤Î¥Æ¥¹¥È¥±¡¼¥¹¤Ë¤·¤Æ¼Â¹Ô¤¹¤ë¤³¤È¤¬¤Ç¤­¤Þ¤¹¡£
109 @endif
110
111 @dontinclude complex/runTestCase.c
112
113 @skip CCUnitTestCase.h
114 @until CCUnitTestResult.h
115
116 @english
117 @japanese
118 ɬÍפʥإåÀ¥Õ¥¡¥¤¥ë¤ò¥¤¥ó¥¯¥ë¡¼¥É¤·¤Þ¤¹¡£
119 @endif
120
121 @until main
122 @until ccunit_newTestCase
123
124 @english
125 @japanese
126 ¤Þ¤º¥Æ¥¹¥È¥±¡¼¥¹¤Ë¥á¥â¥ê¤ò³ä¤êÅö¤Æ¤Þ¤¹¡£
127 @endif
128
129 @until test_complex_equals);
130
131 @english
132 @japanese
133 ¤½¤·¤Æ¥Æ¥¹¥È¥±¡¼¥¹¤Ë¥Æ¥¹¥È´Ø¿ô¤òÅÐÏ¿¤·¤Þ¤¹¡£
134 ɽÌÀ (ASSERT) ¤¬¼ºÇÔ¤·¤¿»þ¤Ëɽ¼¨¤¹¤ë¤¿¤á¤Î´Ø¿ô̾¤È´Ø¿ô¤ÎÀâÌÀ¤ò°ì½ï¤Ë»ØÄꤷ¤Æ¤¤¤Þ¤¹¡£
135 @endif
136
137 @until wasSuccessful
138
139 @english
140 @japanese
141 ¥Æ¥¹¥È¥±¡¼¥¹¤ò¼Â¹Ô¤·¡¢
142 ·ë²Ì¤ò¼è¤ê½Ð¤·¤Þ¤¹¡£
143 @endif
144
145 @until }
146
147 @english
148 @japanese
149 ³ä¤êÅö¤Æ¤¿¥á¥â¥ê¤ò²òÊü¤·¡¢
150 ·ë²Ì¤òÊÖ¤·¤Þ¤¹¡£
151 @endif
152
153 @english
154 The sample code made in the above is in the directory <code>examples/complex</code>,
155 the files are @c testComplex.c and <code>runTestCase.c</code>.
156 @japanese
157 ¤³¤³¤Þ¤Ç¤Î¥µ¥ó¥×¥ë¥³¡¼¥É¤Ï¡¢@c examples/complex ¥Ç¥£¥ì¥¯¥È¥ê¤Î
158 <code>testComplex.c, runTestCase.c</code> ¤Ë¤¢¤ê¤Þ¤¹¡£
159
160 ¥³¥ó¥Ñ¥¤¥ë¤ª¤è¤Ó¼Â¹Ô¤¹¤ë¤Ë¤Ï¡¢¼¡¤Î¤è¤¦¤Ë¤·¤Þ¤¹¡£
161 @endif
162
163 @code
164 $ gcc -o runTestCase runTestCase.c testComplex.c complex.c -lccunit
165 $ ./runTestCase
166 $ echo $?
167 0
168 @endcode
169
170 @~english
171 When the test case is run, that specific test functions
172 will be run.  This is not a useful thing to do, however, as
173 no diagnostics will be displayed.  One will normally use a
174 @link ExecutingTest TestRunner @endlink to
175 display the results.
176 @~japanese
177 ¥Æ¥¹¥È¥±¡¼¥¹¤¬¼Â¹Ô¤µ¤ì¤ë¤È¡¢
178 »ØÄꤷ¤¿¥Æ¥¹¥È´Ø¿ô¤¬¸Æ¤Ó½Ð¤µ¤ì¤Þ¤¹¡£
179 ¤³¤ì¤Ï¤Þ¤À¤¢¤Þ¤êÊØÍø¤Ç¤Ï¤¢¤ê¤Þ¤»¤ó¡¢
180 ¤Ê¤¼¤Ê¤é¡¢¿ÇÃǤ¬É½¼¨¤µ¤ì¤Ê¤¤¤«¤é¤Ç¤¹¡£
181 Ä̾ï¤Ï @link ExecutingTest TestRunner @endlink
182 ¤Ç·ë²Ì¤òɽ¼¨¤·¤Þ¤¹¡£
183 @~
184
185 @english
186 @section test_runner TestRunner
187 @japanese
188 @section test_runner ¥Æ¥¹¥È¥é¥ó¥Ê¡¼
189 @endif
190
191 @english
192 How do you run your tests and collect their results?
193 The TestCase store result of own tests into
194 the @link CCUnitTestResult TestResult @endlink.
195 @japanese
196 ¥Æ¥¹¥È¤ò¼Â¹Ô¤·¤¿¤È¤­¤Ë¡¢¤É¤¦¤ä¤Ã¤Æ¤½¤Î·ë²Ì¤ò½¸¤á¤¿¤éÎɤ¤¤Ç¤·¤ç¤¦¤«¡£
197 ¥Æ¥¹¥È¥±¡¼¥¹¤Ï¥Æ¥¹¥È´Ø¿ô¤Î¼Â¹Ô·ë²Ì
198 @link CCUnitTestFailure TestFailure @endlink ¤ò
199 @link CCUnitTestResult TestResult @endlink ¤Ë³ÊǼ¤·¤Þ¤¹¡£
200 Ʊ»þ¤Ë¥Æ¥¹¥È¤Î¼Â¹Ô¾õ¶·¤ò @link CCUnitTestRunner TestRunner @endlink
201 ¤ËÄÌÃΤ·¤Þ¤¹¡£
202 @endif
203
204 @dot
205 digraph TestResult {
206   node [ fontsize=9, fontname=Helvetica ]
207   TestRunner
208   { rank=same;
209     edge [ fontsize=9, fontname=Courier ]
210     TestCase -> TestResult [ label="TestFailure", style=dotted, arrowhead=vee ];
211   }
212   edge [ fontsize=9, dir=back ]
213   TestRunner -> TestCase [ label="Notify", fontname=Times, 
214                            style=dotted, arrowhead=vee ];
215   TestRunner -> TestResult [ arrowtail=none ];
216   TestCase -> "TestFunc 1..n";
217   TestResult -> "TestFailure 0..m" [ arrowtail=diamond ];
218 }
219 @enddot
220
221 @~english
222 Once you have a test suite, you'll want to run it. %CCUnit
223 provides @link ExecutingTest TestRunner @endlink
224 to define the suite to be run and to display
225 its results.
226 @~japanese
227 °ì¤Ä¥Æ¥¹¥È¥±¡¼¥¹¤ò½ñ¤¤¤¿¤é¡¢
228 ¤½¤ì¤ò¼Â¹Ô¤·¤¿¤¤¤Ç¤·¤ç¤¦¡£
229 CCUnit ¤Ï¥Æ¥¹¥È¥±¡¼¥¹¤ò¥Æ¥¹¥È¥¹¡¼¥Ä¤Ë¤Þ¤È¤á¤Æ¤ë¤³¤È¤Ç¤³¤ì¤é¤ò¼Â¹Ô¤·¡¢
230 ·ë²Ì¤òɽ¼¨¤¹¤ë¤¿¤á¤Î @link ExecutingTest TestRunner @endlink ¤òÄ󶡤·¤Þ¤¹¡£
231 @~
232
233 @~english
234 To use the @link CCUnitTestRunner TestRunner @endlink,
235 include the header files for the tests in runTestCaseRunner.c:
236 @~japanese
237 @link CCUnitTestRunner TestRunner @endlink ¤ò»ÈÍѤ¹¤ë¤Ë¤Ï¡¢
238 Î㤨¤Ð runTestCaseRunner.c ¤Ç¥Æ¥¹¥È¤Î¤¿¤á¤Î¥Õ¥¡¥¤¥ë¤Î¥Ø¥Ã¥À¤ò¥¤¥ó¥¯¥ë¡¼¥É¤·¤Þ¤¹¡£
239 @~
240
241 @dontinclude complex/runTestCaseRunner.c
242
243 @skipline #include
244 @until CCUnitTestRunner.h
245
246 @until ccunit_addTestCase
247
248 @english
249 @japanese
250 ¤Þ¤º TestSuite ¤òºîÀ®¤·¡¢
251 ¤½¤ì¤Ë TestCase ¤òÅÐÏ¿¤·¤Þ¤¹¡£
252 @endif
253
254 @until runTestRunner
255
256 @~english
257 And call to
258 @link ccunit_runTestRunner()
259 ccunit_runTestRunner (CCUnitTestRunner*, CCUnitTestSuite *) @endlink
260 in the <code>main()</code> function:
261 @~japanese
262 ¤½¤·¤Æ @link ccunit_runTestRunner()
263 ccunit_runTestRunner (CCUnitTestRunner*, CCUnitTestSuite *) @endlink
264 ¤ò¼Â¹Ô¤·¤Þ¤¹¡£
265 @~
266
267 @until deleteTestCase
268
269 @english
270 @japanese
271 ³ä¤êÅö¤Æ¤¿¥á¥â¥ê¤ò²òÊü¤·¤Þ¤¹¡£
272 ¤¿¤À¤·¡¢@c testCase ¤Ï @c suite ¤ËÅÐÏ¿¤·¤Æ¤¢¤ë¤Î¤Ç¡¢
273 @c suite ¤ò²òÊü¤¹¤ë»þ¤Ë°ì½ï¤Ë²òÊü¤µ¤ì¤Þ¤¹¡£
274 ¤½¤Î¤¿¤á @c testCase ¤Ï¤³¤³¤Ç²òÊü¤¹¤ëɬÍפ¬¤¢¤ê¤Þ¤»¤ó¡£
275 ²òÊü¤·¤è¤¦¤È¤¹¤ë¤È Bus error ¤Ê¤É¤Ë¤Ê¤ê¤Þ¤¹¤Î¤ÇÃí°Õ¤·¤Æ¤¯¤À¤µ¤¤¡£
276
277 @until }
278
279 @english
280 The sample code made in the above is in the directory <code>examples/complex</code>,
281 the files <code>testComplex.c, complexTestSuite.c</code> and <code>runTestRunner.c</code>.
282 @japanese
283 ¤³¤³¤Þ¤Ç¤Î¥µ¥ó¥×¥ë¥³¡¼¥É¤Ï¡¢<code>examples/complex</code> ¥Ç¥£¥ì¥¯¥È¥ê¤Î
284 <code>runTestCaseRunner.c</code>
285 ¤Ë¤¢¤ê¤Þ¤¹¡£
286
287 ¥³¥ó¥Ñ¥¤¥ë¤ª¤è¤Ó¼Â¹Ô¤¹¤ë¤Ë¤Ï¡¢¼¡¤Î¤è¤¦¤Ë¤·¤Þ¤¹¡£
288 @endif
289
290 @code
291 $ gcc -I. -o runTestCaseRunner runTestCaseRunner.c testComplex.c complex.c -lccunit
292 $ ./runTestCaseRunner
293 ..
294 Time: 0.000027 sec
295
296 OK (2 tests)
297 @endcode
298
299 @~english
300 The @link ExecutingTest TestRunner @endlink will run the tests.
301 If all the tests pass, you'll get an informative message.
302 If any fail, you'll get the following information:
303 @~japanese
304 @link ExecutingTest TestRunner @endlink ¤Ï¥Æ¥¹¥È¤ò¼Â¹Ô¤·¤Þ¤¹¡£
305 ¤â¤·¤¹¤Ù¤Æ¤Î¥Æ¥¹¥È¤¬¥Ñ¥¹¤¹¤ì¤Ð¡¢¤½¤Î¾ðÊó¤Î¥á¥Ã¥»¡¼¥¸¤¬É½¼¨¤µ¤ì¤Þ¤¹¡£
306 ¾å¤ÎÎã¤Ç¤Ï¡¢ºÇ½é¤Î¡Ö<code>..</code>¡×¤Ï¼Â¹Ô¤·¤¿¥Æ¥¹¥È¥±¡¼¥¹¤Ç¤¹¡£
307 ¼Â¹Ô¤¹¤ëľÁ°¤Ë¡Ö<code>.</code>¡×¤¬½ÐÎϤµ¤ì¤Þ¤¹¡£
308 Á´¤Æ¤Î¥Æ¥¹¥È¥±¡¼¥¹¤Î¼Â¹Ô¤¬½ªÎ»¤¹¤ë¤È¡¢
309 ¼Â¹Ô¤Ë¤«¤«¤Ã¤¿»þ´Ö¤È¼Â¹Ô¤·¤¿¥Æ¥¹¥È¥±¡¼¥¹¤Î¿ô¤¬É½¼¨¤µ¤ì¤Þ¤¹¡£
310
311 ¤É¤ì¤«¤¬¼ºÇÔ¤¹¤ì¤Ð¡¢¤½¤ì¤Ë¤Ä¤¤¤Æ°Ê²¼¤Î¤è¤¦¤Ê¾ðÊó¤¬É½¼¨¤µ¤ì¤Þ¤¹¡£
312 @~
313
314 <ul>
315 <li>@~english
316     The name of the source file that contains the test
317     @~japanese
318     ¥Æ¥¹¥È¤ò´Þ¤ó¤Ç¤¤¤ë¥½¡¼¥¹¥Õ¥¡¥¤¥ë̾
319     @~
320 </li>
321 <li>@~english
322     The line number where the failure occurred
323     @~japanese
324     ¼ºÇÔ¤¬µ¯¤³¤Ã¤¿¹ÔÈÖ¹æ
325     @~
326 </li>
327 <li>@~english
328     The name of the test case that failed
329     @~japanese
330     ¼ºÇÔ¤·¤¿¥Æ¥¹¥È¥±¡¼¥¹¤Î̾Á°
331     @~
332 </li>
333 <li>@~english
334     All of the text inside the call to
335     <code>CCUNIT_ASSERT ()</code> which detected the failure
336     @~japanese
337     ¼ºÇÔ¤ò¸¡ÃΤ·¤¿<code>CCUNIT_ASSERT ()</code>¤¬¸Æ¤Ó½Ð¤µ¤ì¤¿»þ¤Î¾ò·ï¤Îʸ»úÎó¡£
338     @~
339 </li>
340 </ul>
341
342 @english
343 @japanese
344 »î¤·¤Ë @c testComplex.c ¤Î¥Æ¥¹¥È¥±¡¼¥¹¤Ç¤ï¤¶¤È´Ö°ã¤¨¤Æ¤ß¤Þ¤·¤ç¤¦¡£
345 @endif
346
347 @code
348 void test_complex_equals ()
349 {
350   ...
351   CCUNIT_ASSERT (complex_equals (c10_1, c10_1_2));
352 /*CCUNIT_ASSERT (complex_equals (c10_1, c1_1) == 0);*/
353   CCUNIT_ASSERT (complex_equals (c10_1, c1_1) != 0);
354   ...
355 }
356 @endcode
357
358 @code
359 $ gcc -I. -o runTestCaseRunner runTestCaseRunner.c testComplex.c complex.c -lccunit
360 $ ./runTestRunner
361 ..F
362 Time: 0.000036 sec
363
364 FAILURES!!!
365 Test Results: 
366 Run 2, Failures 1
367 There was 1 failure:
368 testComplex.c:46: complex equals test:
369         complex_equals (c10_1, c1_1) != 0
370 @endcode
371
372 @english
373 @japanese
374 ¤³¤ÎÎã¤Ç¤Ï¥Æ¥¹¥È¥±¡¼¥¹¤ò 2 ¸Ä¼Â¹Ô¤·¤Æ¡¢
375 ¤Ò¤È¤Ä¤Î¥Æ¥¹¥È¥±¡¼¥¹¤Ç¼ºÇÔ¤·¤Æ¤¤¤ë¤³¤È¤¬¤ï¤«¤ê¤Þ¤¹¡£
376 ºÇ½é¤Î¡Ö<code>..F</code>¡×¤Ç¤Ï¡¢
377 ¤Õ¤¿¤ÄÌܤΥƥ¹¥È¥±¡¼¥¹¤¬¼ºÇÔ¤·¤Æ¤¤¤ë¤³¤È¤ò¤¢¤é¤ï¤·¤Æ¤¤¤Þ¤¹¡£
378
379 ¤Þ¤¿¾å½Ò¤Î¤è¤¦¤Ë¡¢
380 ¼ºÇÔ¤·¤¿¥Õ¥¡¥¤¥ë̾¡¢¹ÔÈֹ桢¥Æ¥¹¥È¥±¡¼¥¹¤Î̾Á° (<code>complex equals test</code>)¡¢
381 ɽÌÀ¤·¤¿¾ò·ï¤Îʸ»úÎó (<code>complex_equals (c10_1, c1_1) != 0</code>) ¤¬É½¼¨¤µ¤ì¤Þ¤¹¡£
382 @endif
383
384 @~english
385 That was a very simple test. Ordinarily, you'll have many
386 little test cases that you'll want to run on the same set of
387 objects. To do this, use global variables.
388 @~japanese
389 ¤³¤ì¤ÏÂçÊÑñ½ã¤Ê¥Æ¥¹¥È¤Ç¤¹¡£
390 Ä̾
391 ¤¿¤¯¤µ¤ó¤Î¾®¤µ¤Ê¥Æ¥¹¥È´Ø¿ô¤òºî¤Ã¤Æ¡¢
392 Ʊ¤¸¤è¤¦¤Ê¥Ç¡¼¥¿¤Î½¸¤Þ¤ê¤ò»È¤Ã¤Æ¥Æ¥¹¥È¤ò¹Ô¤¦¤Ç¤·¤ç¤¦¡£
393 ¤Ä¤Þ¤ê³Æ¥Æ¥¹¥È´Ø¿ô¶¦Ä̤Υ°¥í¡¼¥Ð¥ëÊÑ¿ô¤ò»È¤¦¤³¤È¤Ë¤Ê¤ê¤Þ¤¹¡£
394 @~
395
396 @english
397 @section setUp_and_tearDown setUp and tearDown
398 @japanese
399 @section setUp_and_tearDown setUp ¤È tearDown
400 @endif
401
402 @~english
403 What if you have two or more tests that operate on the same
404 similar set of objects?
405 @~japanese
406 ¤â¤·Ê£¿ô¤Î¥Æ¥¹¥È´Ø¿ô¤¬¤¢¤ë¤Ê¤é¡¢
407 Ʊ¤¸¥Ç¡¼¥¿¤Î½¸¤Þ¤ê¤ò¤¤¤¯¤Ä¤«»È¤¦¤Î¤Ç¤Ï¤Ê¤¤¤Ç¤·¤ç¤¦¤«¡£
408 @~
409
410 @dot
411 digraph TestCase {
412   node [ fontsize=9, fontname=Helvetica ]
413   edge [ fontsize=9, dir=back, arrowtail=vee ]
414   gv [ label="Global Variables", shape=box ]
415   { rank=same;
416     tc1 [ label="Test case 1" ];
417     tc2 [ label="Test case 2" ];
418     tcn [ label="Test case n" ];
419   }
420   gv -> tc1;
421   gv -> tc2 [ weight=8 ];
422   gv -> tcn;
423   tc2 -> tcn [ label="...", dir=none, color=white ];
424 }
425 @enddot
426
427 @~english
428 Tests need to run against the background of a known set of
429 objects. This set of objects is called a test fixture. When
430 you are writing tests you will often find that you spend
431 more time writing the code to set up the fixture than you do
432 in actually testing values.
433 @~japanese
434 ¥Æ¥¹¥È¤ÏÃæ¿È¤Î¤ï¤«¤Ã¤Æ¤¤¤ë¥Ç¡¼¥¿¤Î½¸¤Þ¤ê¤òÁ°Äó¤È¤·¤Æ¼Â¹Ô¤µ¤ì¤ëɬÍפ¬¤¢¤ê¤Þ¤¹¡£
435 ¥Æ¥¹¥È¤ò½ñ¤¤¤Æ¤¤¤ë¤È¡¢
436 ¼ÂºÝ¤Ë¥Æ¥¹¥È¤¹¤ëÃͤò¥»¥Ã¥È¥¢¥Ã¥×¤¹¤ë¥³¡¼¥É¤ò½ñ¤¯Êý¤Ë¡¢
437 ¤è¤ê»þ´Ö¤ò¤«¤±¤Æ¤¤¤ë¤³¤È¤Ëµ¤¤Å¤¯¤³¤È¤¬¤è¤¯¤¢¤ê¤Þ¤¹¡£
438 @~
439
440 @english
441 @japanese
442 Î㤨¤ÐÁ°Àá¤Î¥µ¥ó¥×¥ë¥³¡¼¥É¤Ç¤Ï¡¢
443 ¤¤¤¯¤Ä¤«¤ÎÊ£ÁÇ¿ô¤ò³ä¤êÅö¤Æ¤¿¤ê²òÊü¤·¤¿¤ê¤·¤Æ¤¤¤Þ¤¹¡£
444 @endif
445
446 @~english
447 Often, you will be able to use the same fixture for several
448 different tests. Each case will send slightly different
449 messages or parameters to the fixture and will check for
450 different results.
451 @~japanese
452 ¿¤¯¤Î¾ì¹ç¡¢¤¤¤¯¤Ä¤«¤Î°Û¤Ê¤Ã¤¿¥Æ¥¹¥È¤Î¤¿¤á¤ËƱ¤¸¥°¥í¡¼¥Ð¥ëÊÑ¿ô¤ò»È¤¦¤³¤È¤¬¤Ç¤­¤Þ¤¹¡£
453 ¤½¤ì¤¾¤ì¤Î¥Æ¥¹¥È´Ø¿ô¤ò¼Â¹Ô¤¹¤ëÁ°¤ËÊÑ¿ô¤ò½é´ü²½¤·¡¢
454 ÃͤòÄ´¤Ù¤ë¤³¤È¤Ë¤Ê¤ë¤Ç¤·¤ç¤¦¡£
455 ¤½¤·¤Æ¥Æ¥¹¥È¤¬½ª¤ï¤Ã¤¿¤é¸å»ÏËö¤¹¤ë¤³¤È¤Ë¤Ê¤ê¤Þ¤¹¡£
456 @~
457
458 @dot
459 digraph TestFixture {
460   node [ fontsize=9, fontname=Helvetica ]
461   edge [ fontsize=9, dir=back, arrowtail=vee ]
462   rankdir=TB;
463   gv [ label="Global Variables", shape=box ]
464   { rank=same;
465     su [ label="setUp" ];
466     tc [ label="TestCase" ];
467     td [ label="tearDown" ];
468   }
469   gv -> su [ label="initialize" ];
470   gv -> tc [ label="access" ];
471   gv -> td [ label="clean-up" ];
472 }
473 @enddot
474
475 @~english
476 When you have a common fixture, here is what you do:
477 @~japanese
478 ¤â¤·³Æ¥Æ¥¹¥È¤Ë¶¦Ä̤Υ°¥í¡¼¥Ð¥ëÊÑ¿ô¤¬¤¢¤ì¤Ð¡¢
479 ¼¡¤Î¤è¤¦¤Ë¤¹¤ë¤³¤È¤Ç¤·¤ç¤¦¡£
480 @~
481
482 @english
483 For example, to write several test cases, first create a
484 fixture:
485 @japanese
486 @endif
487
488 @dontinclude complex/testComplexSetup.c
489
490 @skipline complex.h
491 @until c10_1;
492
493 @english
494 @japanese
495 ¥°¥í¡¼¥Ð¥ëÊÑ¿ô¤òÄêµÁ¤·¤Þ¤¹¡£
496 @endif
497
498 @until }
499
500 @english
501 @japanese
502 Ê£ÁÇ¿ô¤ò³ä¤êÅö¤Æ¤ë @c setUp ´Ø¿ô¤ò½ñ¤­¤Þ¤¹¡£
503 @endif
504
505 @until }
506
507 @english
508 @japanese
509 ³ä¤êÅö¤Æ¤¿¥á¥â¥ê¤ò²òÊü¤¹¤ë @c tearDown ´Ø¿ô¤ò½ñ¤­¤Þ¤¹¡£
510 @endif
511
512 @until test_complex_equals
513 @until }
514
515 @english
516 @japanese
517 ¥Æ¥¹¥È´Ø¿ô¤ò½ñ¤­¤Þ¤¹¡£
518 @endif
519
520 @dontinclude complex/runTestCaseSetup.c
521 @skip int main
522 @until setUp_test_complex);
523 @until tearDown_test_complex);
524
525 @english
526 @japanese
527 @c setUp() ¤È @c tearDown() ¤òÅÐÏ¿¤·¤Þ¤¹¡£
528 ¤³¤Î»þ¡¢´Ø¿ô¤Î̾Á°¤¬ @c setUp/tearDown ¤Ç»Ï¤Þ¤Ã¤Æ¤¤¤Ê¤±¤ì¤Ð¤Ê¤ê¤Þ¤»¤ó¡£
529 @endif
530
531 @until }
532
533 @english
534 @japanese
535 ¥Æ¥¹¥È¥±¡¼¥¹¤ò¼Â¹Ô¤·¡¢
536 ·ë²Ì¤òÊÖ¤·¤Þ¤¹¡£
537 @endif
538
539 @english
540 The sample code made in the above is in the directory <code>examples/complex</code>,
541 the files are @c testComplexSetup.c and <code>runTestCaseSetup.c</code>.
542 @japanese
543 ¤³¤³¤Þ¤Ç¤Î¥µ¥ó¥×¥ë¥³¡¼¥É¤Ï¡¢@c examples/complex ¥Ç¥£¥ì¥¯¥È¥ê¤Î
544 <code>testComplexSetup.c, runTestCaseSetup.c</code> ¤Ë¤¢¤ê¤Þ¤¹¡£
545
546 ¥³¥ó¥Ñ¥¤¥ë¤ª¤è¤Ó¼Â¹Ô¤¹¤ë¤Ë¤Ï¡¢¼¡¤Î¤è¤¦¤Ë¤·¤Þ¤¹¡£
547 @endif
548
549 @code
550 $ gcc -o runTestCaseSetup runTestCaseSetup.c testComplexSetup.c complex.c -lccunit
551 $ ./runTestCaseSetup
552 ..
553 Time: 0.000048 sec
554
555 OK (2 tests)
556 @endcode
557
558 @english
559 @section one_time_setUp_tearDown setUp/tearDown of only one time
560 @japanese
561 @section one_time_setUp_tearDown °ì²ó¤À¤±¤Î setUp/tearDown
562 @endif
563
564 @english
565 @japanese
566 Á°¤ÎÀá¤Ç¤Ï¥Æ¥¹¥È¤´¤È¤ËËè²ó½é´ü²½¤ò¹Ô¤Ã¤Æ¤¤¤Þ¤·¤¿¡£
567 °ì²ó¤À¤±½é´ü²½¤ò¹Ô¤Ã¤Æ¡¢
568 Ê£¿ô¤Î¥Æ¥¹¥È¤ò¼Â¹Ô¤·¤¿¤¤¾ì¹ç¤¬¤¢¤ê¤Þ¤¹¡£
569 ¤½¤·¤Æ¥Æ¥¹¥È¤¬Á´¤Æ½ª¤ï¤Ã¤¿¤È¤­¤À¤±¸å»ÏËö¤Î¥³¡¼¥É¤ò¼Â¹Ô¤¹¤ë¤è¤¦¤Ê¾ì¹ç¤¬¤¢¤ê¤Þ¤¹¡£
570
571 ¤½¤Î¤¿¤á¤Ë¤Ï¥Æ¥¹¥È¥±¡¼¥¹¤Ë
572 @c setup_setUp/setup_tearDown ´Ø¿ô¤òÅÐÏ¿¤·¤Þ¤¹¡£
573 ¤¹¤ë¤È¼¡¤Î¤è¤¦¤Ê½ç½ø¤Ç¥Æ¥¹¥È´Ø¿ô¤¬¼Â¹Ô¤µ¤ì¤Þ¤¹¡£
574 @endif
575
576 @dot
577 digraph TestCaseCallingSequence {
578   node [ fontsize=9, fontname=Helvetica ]
579   edge [ fontsize=9 ]
580   rankdir = LR;
581   { rank=same;
582     setUp;
583     setUp2 [ label="setUp" ];
584   }
585   setup_setUp -> setUp [ weight=8 ];
586   setup_setUp -> setUp2 [ style=invis ];
587   setUp -> "TestFunc 1" [ weight=8 ];
588   "TestFunc 1" -> tearDown [ weight=8 ];
589   setUp2 -> "TestFunc n" [ weight=8 ];
590   tearDown2 [ label="tearDown" ];
591   "TestFunc n" -> tearDown2;
592   tearDown2 -> setup_tearDown;
593   tearDown -> setUp2;
594 }
595 @enddot
596
597
598 @english
599 @section suite Suite
600 @japanese
601 @section suite ¥¹¡¼¥Ä
602 @endif
603
604 @~english
605 How do you set up your tests so that you can run them all at once?
606 Once you have several tests, organize them into a suite.
607 @~japanese
608 Ê£¿ô¤Î¥Æ¥¹¥È¤òÁ´Éô°ìÅ٤˼¹Ԥ¹¤ë¤³¤È¤¬¤Ç¤­¤ë¤è¤¦¤Ë½àÈ÷¤¹¤ë¤Ë¤Ï¡¢
609 ¤É¤Î¤è¤¦¤Ë¤·¤¿¤é¤¤¤¤¤Ç¤·¤ç¤¦¤«¡©
610 ¤¤¤¯¤Ä¤«¤Î¥Æ¥¹¥È¤òºî¤Ã¤¿¤é¡¢
611 ¤½¤ì¤é¤ò¥¹¡¼¥Ä (¥¹¥¤¡¼¥È) ¤ËÀ°Íý¤·¤Þ¤¹¡£
612 @~
613
614 @dot
615 digraph TestStructure {
616   node [ fontsize=9, fontname=Helvetica ];
617   edge [ dir=back, fontsize=9 ];
618   TestSuite -> TestSuite [ label="1..n" ];
619   TestCase;
620   TestSuite -> TestCase [ label="1..n" ];
621   TestCase -> setup_setUp [ label="0..1" ];
622   TestCase -> setUp [ label="0..1" ];
623   TestFunc;
624   TestCase -> TestFunc [ label="1..n" ];
625   TestCase -> tearDown [ label="0..1" ];
626   TestCase -> setup_tearDown [ label="0..1" ];
627 }
628 @enddot
629
630 @~english
631 CCUnit provides a @link CCUnitTestSuite TestSuite @endlink
632 module that runs any number of TestFuncs together.
633 You saw, above, how to run test suite.
634 @~japanese
635 CCUnit ¤Ï¤¤¤¯¤Ä¤â¤Î @link CCUnitTestFunc TestFuncs @endlink
636 ¤ò°ì½ï¤Ë¼Â¹Ô¤¹¤ë
637 @link CCUnitTestSuite TestSuite @endlink ¥â¥¸¥å¡¼¥ë¤òÄ󶡤·¤Þ¤¹¡£
638 ¥Æ¥¹¥È¥¹¡¼¥Ä¤ò¼Â¹Ô¤¹¤ëÊýË¡¤Ï¤¹¤Ç¤ËÁ°¤ÎÊý¤Ç¼¨¤·¤Æ¤¢¤ê¤Þ¤¹¡£
639 @~
640
641 @~english
642 To create a suite of two or more tests, you do the following:
643 @~japanese
644 Æó¤Ä°Ê¾å¤Î¥Æ¥¹¥È¤ò´Þ¤à°ì¤Ä¤Î¥¹¡¼¥Ä¤òºî¤ë¤Ë¤Ï¡¢¼¡¤Î¤è¤¦¤Ë¤·¤Þ¤¹¡£
645 @~
646
647 @dontinclude complex/runTestSuite.c
648
649 @skip main
650 @until test_complex_div);
651
652 @english
653 @japanese
654 ¥Æ¥¹¥È¥±¡¼¥¹¤òÆó¤ÄÀ¸À®¤·¡¢¤½¤ì¤¾¤ì¤Ë¥Æ¥¹¥È´Ø¿ô¤òÅÐÏ¿¤·¤Þ¤¹¡£
655 @endif
656
657 @until testArith);
658
659 @english
660 @japanese
661 ¥Æ¥¹¥È¥¹¡¼¥Ä¤òÀ¸À®¤·¡¢
662 ¥Æ¥¹¥È¥±¡¼¥¹¤òÅÐÏ¿¤·¤Þ¤¹¡£
663 @endif
664
665 @until }
666
667 @english
668 @japanese
669 ¥Æ¥¹¥È¥é¥ó¥Ê¡¼¤òÀ¸À®¤·¥Æ¥¹¥È¤ò¼Â¹Ô¤·¤Þ¤¹¡£
670 @endif
671
672 @english
673 The sample code made in the above is in the directory <code>examples/complex</code>,
674 the files are <code>runTestSuite.c</code>, <code>testComplexSetup.c</code>
675 and <code>testComplexArith.c</code>.
676 @japanese
677 ¤³¤³¤Þ¤Ç¤Î¥µ¥ó¥×¥ë¥³¡¼¥É¤Ï¡¢<code>examples/complex</code> ¥Ç¥£¥ì¥¯¥È¥ê¤Î
678 <code>runTestSuite.c, testComplexSetup.c, testComplexArith.c</code>
679 ¤Ë¤¢¤ê¤Þ¤¹¡£
680
681 ¥³¥ó¥Ñ¥¤¥ë¤ª¤è¤Ó¼Â¹Ô¤¹¤ë¤Ë¤Ï¡¢¼¡¤Î¤è¤¦¤Ë¤·¤Þ¤¹¡£
682 @endif
683
684 @code
685 $ gcc -I. -o runTestSuite runTestSuite.c testComplexSetup.c testComplexArith.c complex.c -lccunit
686 $ ./runTestSuite
687 ......
688 Time: 0.000061 sec
689
690 OK (6 tests)
691 @endcode
692
693 @english
694 @link CCUnitTestSuite TestSuites @endlink don't only have to
695 contain @link CCUnitTestCase TestCases @endlink.  They
696 can contain any object that implements the @link CCUnitTest
697 Test @endlink interface.  For example, you can create a
698 @link CCUnitTestSuite TestSuite @endlink
699 in your code and I
700 can create one in mine, and we can run them together by
701 creating a @link CCUnitTestSuite TestSuite @endlink that
702 contains both:
703 @japanese
704 @link CCUnitTestSuite TestSuites @endlink ¤Ï
705 @link CCUnitTestCase TestCases @endlink
706 ¤ò´Þ¤à¤À¤±¤Ç¤Ï¤¢¤ê¤Þ¤»¤ó¡£
707 @link CCUnitTestSuite TestSuites @endlink ¼«¿È¤ò´Þ¤à¤³¤È¤â¤Ç¤­¤Þ¤¹¡£
708 Î㤨¤Ð¡¢¤¢¤Ê¤¿¤Ï¤¢¤Ê¤¿¤Î¥³¡¼¥É¤Ë @link CCUnitTestSuite TestSuite @endlink
709 ¤òºî¤ë¤³¤È¤¬¤Ç¤­¡¢
710 ¤½¤·¤Æ»ä¤Ï»ä¤Î¥¹¡¼¥Ä
711 ¤òºî¤ë¤³¤È¤¬¤Ç¤­¤Þ¤¹¡¢
712 ¤½¤·¤Æ»äã¤ÏξÊý¤È¤â¤ò´Þ¤ó¤Ç¤¤¤ë @link CCUnitTestSuite TestSuite @endlink
713 ¤òºî¤Ã¤Æ¡¢
714 °ì½ï¤Ë¤½¤ì¤¾¤ì¤Î¥¹¡¼¥Ä¤òÆ°¤«¤¹¤³¤È¤¬¤Ç¤­¤ë¤Î¤Ç¤¹¡£
715 @endif
716
717 @code
718   CCUnitTestSuite* suite;
719   CCUnitTestSuite* suite_a;
720   CCUnitTestSuite* suite_b;
721
722   ...
723
724   suite = ccunit_newTestSuite ("complex all test suite");
725   suite_a = ccunit_newTestSuite ("complex test suite A");
726   suite_b = ccunit_newTestSuite ("complex test suite B");
727
728   ...
729
730   ccunit_addTestSuite (suite, suite_a);
731   ccunit_addTestSuite (suite, suite_b);
732 @endcode
733
734 @english
735 @section helper_tool Helper Tool
736 @japanese
737 @section helper_tool ¥Ø¥ë¥Ñ¡¼¥Ä¡¼¥ë
738 @endif
739
740 @english
741 As you might have noticed, implementing the <code>suite
742 ()</code> function of testCase is a repetitive and error
743 prone task. A @ref CreatingTestSuite set of functions and
744 command have been created to automatically implements the
745 <code>suite()</code> function.
746 @japanese
747 ¤ªµ¤¤Å¤­¤Î¤è¤¦¤Ë¡¢
748 ¥Æ¥¹¥È¥±¡¼¥¹¤Ë¥Æ¥¹¥È´Ø¿ô¤òÅÐÏ¿¤·¤¿¤ê¡¢
749 ¥Æ¥¹¥È¥¹¡¼¥Ä¤Ë¥Æ¥¹¥È¥±¡¼¥¹¤òÅÐÏ¿¤·¤¿¤ê¤¹¤ëºî¶È¤Ï¡¢
750 È¿ÉüŪ¤Ç´Ö°ã¤¤¤ä¤¹¤¤¤â¤Î¤Ç¤¹¡£
751 Î㤨¤Ð @c testComplexSetup.c ¤Ë¤Ï
752 @c test_complex_to_string() ¤È¤¤¤¦¥Æ¥¹¥È´Ø¿ô¤¬ÄêµÁ¤µ¤ì¤Æ¤¤¤Þ¤¹¤¬¡¢
753 º£¤Þ¤Ç¤ÎÀâÌÀ¤Ç¤Ï̵»ë¤µ¤ì¤Æ¤¤¤Æ¥Æ¥¹¥È¥±¡¼¥¹¤Ë¤ÏÅÐÏ¿¤µ¤ì¤Þ¤»¤ó¤Ç¤·¤¿¡£
754 ¤³¤Î¤è¤¦¤ÊÅÐϿϳ¤ì¤ò¤Ê¤¯¤¹¤¿¤á¤Ë
755 @ref CreatingTestSuite ¤Î´Ø¿ô¤Î½¸¤Þ¤ê¤È¥³¥Þ¥ó¥É¤Ï¡¢
756 ¥Æ¥¹¥È¥±¡¼¥¹¤ä¥Æ¥¹¥È¥¹¡¼¥Ä¤òÅÐÏ¿¤¹¤ë´Ø¿ô¤Î¼ÂÁõ¤ò¡¢
757 ¼«Æ°Åª¤ËºîÀ®¤¹¤ë¤³¤È¤¬¤Ç¤­¤Þ¤¹¡£
758 @endif
759
760 @english
761 @japanese
762 ¥Æ¥¹¥È¥±¡¼¥¹¤ò½ñ¤¯¥Õ¥¡¥¤¥ë¤Ï¼¡¤Î¤è¤¦¤Ëºî¤ê¤Þ¤¹¡£
763
764 ºÇ½é¤Ë¡¢¥Æ¥¹¥È¥¹¡¼¥Ä¤òÀë¸À¤·¤Þ¤¹¡£
765 ¤³¤ì¤Ï javaDoc ¥¹¥¿¥¤¥ë¤Î¥³¥á¥ó¥ÈÆâ¤Ë¥Æ¥¹¥È¥¹¡¼¥Ä¤Î̾Á°¤òµ­½Ò¤·¤Þ¤¹¡£
766 javaDoc¥¹¥¿¥¤¥ë¤Î¥³¥á¥ó¥È¤È¤Ï C ¥¹¥¿¥¤¥ë¤Î¥³¥á¥ó¥È¥Ö¥í¥Ã¥¯¤Î³«»Ï¤¬
767 Æó¤Ä¤Î¥¢¥¹¥¿¥ê¥¹¥¯ <tt>**</tt> ¤Ë¤Ê¤Ã¤Æ¤¤¤ë¤â¤Î¤Ç¤¹¡£
768 @endif
769
770 @code
771 //** test suite: complex test suite *\/
772 @endcode
773
774 @english
775 @japanese
776 ¼¡¤Ë¡¢
777 ¥Æ¥¹¥È¥±¡¼¥¹¤òÄêµÁ¤·¤Þ¤¹¡£
778 ¥Æ¥¹¥È¥±¡¼¥¹¤Ï javaDoc ¥¹¥¿¥¤¥ë¤Î¥³¥á¥ó¥È¤Ë½ñ¤«¤ì¤¿¥Æ¥¹¥È¥±¡¼¥¹¤Î̾Á°¤ÎÀë¸À¤È¡¢
779 ¥Æ¥¹¥È¥±¡¼¥¹¤Î½ªÎ»¤ÎÀë¸À¤Ç°Ï¤Þ¤ì¤¿¥°¥í¡¼¥Ð¥ëÊÑ¿ô¤È´Ø¿ô¤Î½¸¤Þ¤ê¤Ç¤¹¡£
780 ¤Ò¤È¤Ä¤Î¥Õ¥¡¥¤¥ë¤ËÊ£¿ô¤Î¥Æ¥¹¥È¥±¡¼¥¹¤òÄêµÁ¤Ç¤­¤Þ¤¹¡£
781 @endif
782
783 @code
784 //** test case: complex test case *\/
785
786 static complex_t* c10_1;
787
788 //** test new *\/
789 void test_complex_new ()
790 {
791   ...
792 }
793
794 ...
795
796 //** end test case *\/
797 //** test case: complex arith test case *\/
798 ...
799 //* end test case *\/
800 //* end test suite *\/
801 //* test suite: ... *\/
802 ...
803 //* end test suite *\/
804 @endcode
805
806 @english
807 @japanese
808 ¥Æ¥¹¥È´Ø¿ô¤Ï̾Á°¤¬ @c test ¤Ç»Ï¤Þ¤Ã¤Æ¤¤¤Ê¤±¤ì¤Ð¤Ê¤ê¤Þ¤»¤ó¡£
809 ¤Þ¤¿³Æ¥Æ¥¹¥È´Ø¿ô¤ÎÁ°¤Ë¤Ï
810 javaDoc ¥¹¥¿¥¤¥ë¤Î¥³¥á¥ó¥È¤ÎÃæ¤Ë¥Æ¥¹¥È´Ø¿ô¤ÎÀâÌÀ¤ò½ñ¤¯¤³¤È¤¬¤Ç¤­¤Þ¤¹¡£
811 ¥³¥á¥ó¥È¤¬½ñ¤«¤ì¤Æ¤¤¤Ê¤±¤ì¤Ð¡¢
812 ¥Æ¥¹¥È´Ø¿ô¤Î̾Á°¤¬´Ø¿ô¤ÎÀâÌÀ¤È¤·¤ÆÅÐÏ¿¤µ¤ì¤Þ¤¹¡£
813
814 ÆÃÊ̤ʥƥ¹¥È´Ø¿ô¤È¤·¤Æ @c setUp, @c tearDown, @c setup_setUp, @c setup_tearDown
815 ¤¬¤¢¤ê¤Þ¤¹¡£
816 ¤½¤Î̾Á°¤«¤é¤ï¤«¤ë¤è¤¦¤Ë¡¢
817 °ÊÁ°¤ËÀâÌÀ¤·¤¿¥Æ¥¹¥È¥±¡¼¥¹¤Îµ¡Ç½¤Î´Ø¿ô¤È¤·¤ÆƯ¤­¤Þ¤¹¡£
818 ¤½¤ì¤¾¤ì¤½¤Î¤è¤¦¤Ê̾Á°¤ÇÄêµÁ¤·¤Æ¤¯¤À¤µ¤¤¡£
819 @endif
820
821 @english
822 To generate creating suite function code, run
823 <code>ccunit_makeSuite</code> tool.
824 @japanese
825 ¥¹¡¼¥ÄºîÀ®´Ø¿ô¤Î¥³¡¼¥É¤òÀ¸À®¤¹¤ë¤Ë¤Ï¡¢
826 <code>ccunit_makeSuite</code>¥Ä¡¼¥ë¤ò¼Â¹Ô¤·¤Þ¤¹¡£
827 @endif
828
829 @english
830 The function to make @link CCUnitTestSuite TestSuite
831 @endlink is <code>ccunit_suite</code>.
832 But, it can be changed to another
833 name by the <code>-f</code> option of the
834 <code>ccunit_makeSuite</code> command, too.
835 @japanese
836 ¼«Æ°Åª¤ËºîÀ®¤µ¤ì¤ë
837 @link CCUnitTestSuite TestSuite @endlink
838 ¤òºîÀ®¤¹¤ë´Ø¿ô¤Ï¡¢
839 ¥Ç¥Õ¥©¥ë¥È¤Ç¤Ï <code>ccunit_suite</code> ¤Ç¤¹¡¢
840 ¤·¤«¤· <code>ccunit_makeSuite</code> ¥³¥Þ¥ó¥É¤Î
841 <code>-f</code> ¥ª¥×¥·¥ç¥ó¤ÇÊ̤Î̾Á°¤ËÊѤ¨¤ë¤³¤È¤â¤Ç¤­¤Þ¤¹¡£
842 @endif
843
844 @code
845 $ ccunit_makeSuite -f suite_test_complex -o suiteTestComplex.c testComplexSetup.c testComplexArith.c
846 @endcode
847
848 @english
849 @japanese
850 ¼«Æ°À¸À®¤·¤¿¥³¡¼¥É¤òÍøÍѤ¹¤ë¤Ë¤Ï¼¡¤Î¤è¤¦¤Ë¤·¤Þ¤¹¡£
851 @endif
852
853 @dontinclude complex/runTestSuiteAuto.c
854
855 @skip include
856 @until extern
857
858 @english
859 @japanese
860 À¸À®¤·¤¿´Ø¿ô¤Î¥×¥í¥È¥¿¥¤¥×¤òÀë¸À¤·¤Þ¤¹¡£
861 °ú¿ô¤Î <code>char* name</code> ¤ò˺¤ì¤Ê¤¤¤è¤¦¤Ë¤·¤Æ¤¯¤À¤µ¤¤¡£
862 @endif
863
864 @skip main
865 @until suite_test_complex
866
867 @english
868 @japanese
869 À¸À®¤·¤¿´Ø¿ô¤ò¸Æ¤Ó½Ð¤·¤Æ¥Æ¥¹¥È¥¹¡¼¥Ä¤ò¼è¤ê½Ð¤·¤Þ¤¹¡£
870 @endif
871
872 @until }
873
874 @english
875 @japanese
876 ¥Æ¥¹¥È¥é¥ó¥Ê¡¼¤Ç¼Â¹Ô¤·¤Þ¤¹¡£
877 @endif
878
879
880 @english
881 The sample code made in the above is in the directory <code>examples/complex</code>,
882 the files are <code>runTestSuite.c</code>, <code>testComplex.c</code>
883 and <code>testComplexArith.c</code>.
884 @japanese
885 ¤³¤³¤Þ¤Ç¤Î¥µ¥ó¥×¥ë¥³¡¼¥É¤Ï¡¢<code>examples/complex</code> ¥Ç¥£¥ì¥¯¥È¥ê¤Î
886 <code>runTestSuiteAuto.c, testComplexSetup.c</code>
887 ¤Ë¤¢¤ê¤Þ¤¹¡£
888
889 ¥³¥ó¥Ñ¥¤¥ë¤ª¤è¤Ó¼Â¹Ô¤¹¤ë¤Ë¤Ï¡¢¼¡¤Î¤è¤¦¤Ë¤·¤Þ¤¹¡£
890 @endif
891
892 @code
893 $ ccunit_makeSuite -f suite_test_complex -o suiteTestComplex.c testComplexSetup.c testComplexArith.c
894 $ gcc -I. -o runTestSuiteAuto runTestSuiteAuto.c testComplexSetup.c testComplexArith.c suiteTestComplex.c complex.c -lccunit
895 $ ./runTestSuiteAuto
896 .......
897 Time: 0.000060 sec
898
899 OK (7 tests)
900 @endcode
901
902 @copydetails CCUnitMakeSuite
903
904 @english
905 @section sample_programs Sample Programs
906 @japanese
907 @section sample_programs ¥µ¥ó¥×¥ë¥×¥í¥°¥é¥à
908 @endif
909
910 @english
911 The sample program made in the above is in the @c examples/complex directory.
912 @japanese
913 °Ê¾å¤ÇºîÀ®¤·¤¿¥µ¥ó¥×¥ë¥×¥í¥°¥é¥à¤Ï @c examples/complex ¥Ç¥£¥ì¥¯¥È¥ê¤Ë¤¢¤ê¤Þ¤¹¡£
914 @endif
915
916 @copydetails examples
917
918 */