A C Unit Test Library for C language.
Revisión | 0140b47bac399709da9842d474825a2aca5b46fc (tree) |
---|---|
Tiempo | 2003-10-24 04:34:14 |
Autor | tsntsumi <tsntsumi@user...> |
Commiter | tsntsumi |
add japanese documents
@@ -1,28 +1,70 @@ | ||
1 | 1 | /* -*- Indented-Text -*- */ |
2 | 2 | /* $Id$ */ |
3 | -/** @page cookbook CCUnit Cookbook | |
4 | - | |
3 | +/** | |
4 | +@english | |
5 | +@page cookbook CCUnit Cookbook | |
6 | +@endif | |
7 | +@japanese | |
8 | +@page cookbook CCUnit クックブック | |
9 | +@endif | |
10 | + | |
11 | +@~english | |
5 | 12 | Here is a short cookbook to help you get started. |
6 | - | |
13 | +@~japanese | |
14 | +これは CCUnit を使い始めるにあたって、 | |
15 | +理解の助けとなるような短いクックブックです。 | |
16 | +@~ | |
17 | +@english | |
18 | +[see also <a href="../ja/cookbook.html">Japanese</a> documents] | |
19 | +@endif | |
20 | +@japanese | |
21 | +[see also <a href="../../cookbook.html">English</a> documents] | |
22 | +@endif | |
23 | + | |
24 | +@english | |
7 | 25 | @section simple_test_case Simple Test Case |
26 | +@endif | |
27 | +@japanese | |
28 | +@section simple_test_case シンプルなテストケース | |
29 | +@endif | |
8 | 30 | |
31 | +@~english | |
9 | 32 | Tests in <b>CCUnit</b> can be run automatically. They are |
10 | 33 | easy to set up and once you have written them, they are |
11 | 34 | always there to help you keep confidence in the quality of |
12 | 35 | your code. |
13 | - | |
36 | +@~japanese | |
37 | +CCUnitを使ったテストは自動的に実行することができます。 | |
38 | +CCUnit のテストは簡単にセットアップすることができ、 | |
39 | +一度テストを書いてしまえば、 | |
40 | +いつでもプログラムの品質を信頼できるものに保つことができるでしょう。 | |
41 | +@~ | |
42 | + | |
43 | +@~english | |
14 | 44 | To make a simple test, here is what you do: |
45 | +@~japanese | |
46 | +単純なテストを作るには、次のようにします。 | |
47 | +@~ | |
15 | 48 | |
16 | 49 | <ol> |
17 | -<li> Create a test function</li> | |
18 | -<li> When you want to check a value, call | |
50 | +<li> @~english Create a test function | |
51 | + @~japanese テスト関数を作る</li> | |
52 | +<li> @~english When you want to check a value, call | |
53 | + @~japanese 値をチェックしたい場合は、@~ | |
19 | 54 | @link CCUNIT_ASSERT() CCUNIT_ASSERT(bool) @endlink |
20 | - and pass a bool that is true if the test succeeds</li> | |
55 | + @~english and pass a bool that is true if the test succeeds | |
56 | + @~japanese を呼び出して、 | |
57 | + もしテストが成功するのであれば真を返すような真偽値を渡します</li> | |
21 | 58 | </ol> |
22 | 59 | |
60 | +@~english | |
23 | 61 | For example, to test that the sum of two complex number |
24 | 62 | which is the sum of the values of two complex numbers, |
25 | 63 | write: |
64 | +@~japanese | |
65 | +例えば、二つの複素数の合計が、 | |
66 | +二つの複素数の値を加算した値と同じであることをテストするとします。 | |
67 | +@~ | |
26 | 68 | |
27 | 69 | @code |
28 | 70 | void test_complex_add () |
@@ -35,40 +77,111 @@ void test_complex_add () | ||
35 | 77 | } |
36 | 78 | @endcode |
37 | 79 | |
80 | +@~english | |
38 | 81 | That was a very simple test. Ordinarily, you'll have many |
39 | 82 | little test cases that you'll want to run on the same set of |
40 | 83 | objects. To do this, use a fixture. |
41 | - | |
84 | +@~japanese | |
85 | +これは大変単純なテストです。 | |
86 | +通常、同じデータのセットで走らせるために、 | |
87 | +たくさんの小さなテストケースを作らなければならないでしょう。 | |
88 | +そうするにはフィクスチャ(備品)を使います。 | |
89 | +@~ | |
90 | + | |
91 | +@english | |
42 | 92 | @section fixture Fixture |
93 | +@endif | |
94 | +@japanese | |
95 | +@section fixture フィクスチャ | |
96 | +@endif | |
43 | 97 | |
98 | +@~english | |
44 | 99 | What if you have two or more tests that operate on the same |
45 | 100 | similar set of objects? |
101 | +@~japanese | |
102 | +もし二つ以上のテストがあるなら、 | |
103 | +同じ類似のデータのセットで操作するのではないでしょうか。 | |
104 | +@~ | |
46 | 105 | |
106 | +@~english | |
47 | 107 | Tests need to run against the background of a known set of |
48 | 108 | objects. This set of objects is called a test fixture. When |
49 | 109 | you are writing tests you will often find that you spend |
50 | 110 | more time writing the code to set up the fixture than you do |
51 | 111 | in actually testing values. |
52 | - | |
53 | -Often, you will be able to use the same fixture for sevral | |
112 | +@~japanese | |
113 | +テストは周知のデータのセットを背景にして実行される必要があります。 | |
114 | +このデータのセットをフィクスチャと呼ぶことにします。 | |
115 | +テストを書いていると、 | |
116 | +実際のテストする値をフィクスチャにセットアップするコードを書く方に、 | |
117 | +もっと時間をかけていることに気づくことがよくあります。 | |
118 | +@~ | |
119 | + | |
120 | +@~english | |
121 | +Often, you will be able to use the same fixture for several | |
54 | 122 | different tests. Each case will send slightly different |
55 | -messages or parameteres to the fixture and will check for | |
123 | +messages or parameters to the fixture and will check for | |
56 | 124 | different results. |
57 | - | |
125 | +@~japanese | |
126 | +多くの場合、いくつかの異なったテストのために同じフィクスチャを使うことができます。 | |
127 | +それぞれのテストケースは少し異なったメッセージ、 | |
128 | +あるいはパラメータをフィクスチャに送り、 | |
129 | +異なる結果を調べます。 | |
130 | +@~ | |
131 | + | |
132 | +@~english | |
58 | 133 | When you have a common fixture, here is what you do: |
134 | +@~japanese | |
135 | +もし共通するフィクスチャがあれば、こんなふうにすることになり | |
136 | +ます。 | |
137 | +@~ | |
59 | 138 | |
60 | 139 | <ol> |
61 | -<li>Create a @link CCUnitTestCase TestCase @endlink object</li> | |
62 | -<li>Add an global variable for each part of the fixture</li> | |
63 | -<li>Write <code>setUp()</code> function to initialize the valiables</li> | |
64 | -<li>Write <code>tearDown()</code> to release any permanent | |
65 | - resources you allocated in <code>setUp</code></li> | |
66 | -<li>Create a @link CCUnitTestFixture TestFixture @endlink object</li> | |
67 | -<li>Add test case objects to fixture object</li> | |
140 | +<li>@~english | |
141 | + Create a @link CCUnitTestCase TestCase @endlink object | |
142 | + @~japanese | |
143 | + @link CCUnitTestCase TestCase @endlink 構造体にメモリを割り当てます | |
144 | + (以降、構造体に割り当てたメモリを、オブジェクトと呼ぶことにします) | |
145 | +</li> | |
146 | +<li>@~english | |
147 | + Add an global variable for each part of the fixture | |
148 | + @~japanese | |
149 | + フィクスチャのそれぞれの部分に大域変数を追加します | |
150 | +</li> | |
151 | +<li>@~english | |
152 | + Write <code>setUp()</code> function to initialize the valiables | |
153 | + @~japanese | |
154 | + <code>setUp()</code> 関数を書いて変数を初期化します | |
155 | +</li> | |
156 | +<li>@~english | |
157 | + Write <code>tearDown()</code> to release any permanent | |
158 | + resources you allocated in <code>setUp</code> | |
159 | + @~japanese | |
160 | + <code>tearDown()</code> 関数を書いて<code>setUp</code> | |
161 | + で割り当てた永続的リソースを解放します | |
162 | +</li> | |
163 | +<li>@~english | |
164 | + Create a @link CCUnitTestFixture TestFixture @endlink object | |
165 | + @~japanese | |
166 | + @link CCUnitTestFixture CCUnitTestFixture @endlink | |
167 | + 構造体にメモリを割り当てます | |
168 | +</li> | |
169 | +<li>@~english | |
170 | + Add @link GGUnitTestCase TestCase @endlink objects to fixture object | |
171 | + @~japanese | |
172 | + @link CCUnitTestCase TestCase @endlink | |
173 | + オブジェクトを@link CCUnitTestFixture TestFixture @endlink | |
174 | + フィクスチャオブジェクトに登録します。 | |
175 | +</li> | |
68 | 176 | </ol> |
69 | 177 | |
178 | +@~english | |
70 | 179 | For example, to write several test cases, first create a |
71 | 180 | fixture: |
181 | +@~japanese | |
182 | +例えば、いくつかのテストケースを書く場合、 | |
183 | +最初にフィクスチャを作成します。 | |
184 | +@~ | |
72 | 185 | |
73 | 186 | @code |
74 | 187 | //** TEST CASE: complex number test *\/ |
@@ -85,7 +198,7 @@ void setUp_ComplexTest () | ||
85 | 198 | s1_1 = complex_new (1, 1); |
86 | 199 | s11_2 = complex_new (11, 2); |
87 | 200 | } |
88 | - | |
201 | + | |
89 | 202 | void tearDown_ComplexTest () |
90 | 203 | { |
91 | 204 | complex_delete (s10_1); |
@@ -101,16 +214,36 @@ void tearDown_ComplexTest () | ||
101 | 214 | CCUNIT_NEWTESTFUNC(tearDown_ComplexTest)); |
102 | 215 | @endcode |
103 | 216 | |
217 | +@~english | |
104 | 218 | Once you have the Fixture in place, you can write as complex |
105 | 219 | Test Cases as you'd like. |
220 | +@~japanese | |
221 | +一度決まったところにフィクスチャを書いてしまえば、 | |
222 | +あなたが好きなように複素数のテストケースを書くことができます。 | |
223 | +@~ | |
106 | 224 | |
225 | +@english | |
107 | 226 | @section test_case Test Case |
227 | +@endif | |
228 | +@japanese | |
229 | +@section test_case テストケース | |
230 | +@endif | |
108 | 231 | |
232 | +@~english | |
109 | 233 | How do you write and invoke an individual test case when you |
110 | 234 | have a Fixture? |
235 | +@~japanese | |
236 | +フィクスチャを一つ書いたとして、 | |
237 | +どうやって個々のテストケースを書いて実行すれば良いでしょうか。 | |
238 | +@~ | |
111 | 239 | |
240 | +@~english | |
112 | 241 | For example, to test the equality of two complex number, |
113 | 242 | write: |
243 | +@~japanese | |
244 | +例えば、二つの複素数が等しい(または等しくない)ことをテストするには、 | |
245 | +次のように書きます。 | |
246 | +@~ | |
114 | 247 | |
115 | 248 | @code |
116 | 249 | void test_complex_equals () |
@@ -121,48 +254,89 @@ void test_complex_equals () | ||
121 | 254 | |
122 | 255 | ... |
123 | 256 | |
124 | - ccunit_addNewTestCase (fixture, | |
257 | + ccunit_addNewTestCase (fixture, | |
125 | 258 | "test_complex_equals", |
126 | 259 | "complex equals test", |
127 | 260 | test_complex_equals); |
128 | - ccunit_addNewTestCase (fixture, | |
129 | - "test_complex_add", | |
130 | - "complex add test", | |
131 | - test_complex_add); | |
132 | -@endcode | |
261 | +@endcode | |
133 | 262 | |
263 | +@~english | |
134 | 264 | One may create and run objects for each test case like this: |
265 | +@~japanese | |
266 | +一つには次のように、 | |
267 | +フィクスチャを作成してそれぞれのテストケースを実行させること | |
268 | +ができます。 | |
269 | +@~ | |
135 | 270 | |
136 | 271 | @code |
137 | 272 | CCUnitTestResult* result; |
138 | 273 | result = ccunit_runTestFixture (fixture); |
139 | 274 | @endcode |
140 | 275 | |
276 | +@~english | |
141 | 277 | When the test fixture is run, that specific test functions |
142 | 278 | will be run. This is not a useful thing to do, however, as |
143 | 279 | no diagnostics will be displayed. One will normally use a |
144 | 280 | @link ExecutingTest TestRunner @endlink (see below) to |
145 | 281 | display the results. |
146 | - | |
282 | +@~japanese | |
283 | +テストフィクスチャが実行されると、 | |
284 | +特定のテスト関数が呼び出されます。 | |
285 | +これはあまり便利ではありません、 | |
286 | +なぜなら、診断が表示されないからです。 | |
287 | +通常は @link ExecutingTest TestRunner @endlink | |
288 | +(@ref test_runner 後述) | |
289 | +で結果を表示します。 | |
290 | +@~ | |
291 | + | |
292 | +@~english | |
147 | 293 | Once you have several tests, organize them into a suite. |
294 | +@~japanese | |
295 | +一度いくつかのテストを作ったら、 | |
296 | +それらをスイートに整理します。 | |
297 | +@~ | |
148 | 298 | |
299 | +@english | |
149 | 300 | @section suite Suite |
301 | +@endif | |
302 | +@japanese | |
303 | +@section suite スイート | |
304 | +@endif | |
150 | 305 | |
306 | +@~english | |
151 | 307 | How do you set up your tests so that you can run them all at once? |
308 | +@~japanese | |
309 | +どのようにして、一度にテストを実行することができるよう、 | |
310 | +準備したらいいでしょうか? | |
311 | +@~ | |
152 | 312 | |
313 | +@~english | |
153 | 314 | %CCUnit provides a @link CCUnitTestSuite TestSuite @endlink |
154 | 315 | module that runs any number of TestCases together. |
316 | +@~japanese | |
317 | +CCUnit はいくつもの @link CCUnitTestCase TestCases @endlink | |
318 | +を一緒に実行する | |
319 | +@link CCUnitTestSuite TestSuite @endlink モジュールを提供します。 | |
320 | +@~ | |
155 | 321 | |
322 | +@~english | |
156 | 323 | You saw, above, how to run test fixture. |
324 | +@~japanese | |
325 | +テストフィクスチャを実行する方法は上述しました。 | |
326 | +@~ | |
157 | 327 | |
328 | +@~english | |
158 | 329 | To create a suite of two or more tests, you do the following: |
330 | +@~japanese | |
331 | +二つ以上のテストを含む一つのスイートを作るには、次のようにします。 | |
332 | +@~ | |
159 | 333 | |
160 | 334 | @code |
161 | 335 | CCUnitTestSuite* suite; |
162 | 336 | CCUnitTestFixture* fixture; |
163 | 337 | CCUnitTestResult* result; |
164 | 338 | suite = ccunit_newTestSuite ("Complex test suite"); |
165 | -fixture = ccunit_newTestFixture ("Complex Tests", | |
339 | +fixture = ccunit_newTestFixture ("Complex Tests", | |
166 | 340 | CCUNIT_NEWTESTFUNC(setUp_complex_test), |
167 | 341 | CCUNIT_NEWTESTFUNC(tearDown_complex_test)); |
168 | 342 | ccunit_addNewTestCase (fixture, "test_complex_equals", "complex equals test", |
@@ -173,8 +347,9 @@ ccunit_addNewTestCase (fixture, "test_complex_sub", "complex sub test", | ||
173 | 347 | test_complex_sub); |
174 | 348 | ccunit_addTestFixture (suite, fixtuer); |
175 | 349 | result = ccunit_runTestSuite (suite, NULL); |
176 | -@endcode | |
350 | +@endcode | |
177 | 351 | |
352 | +@~english | |
178 | 353 | @link CCUnitTestSuite TestSuites @endlink don't only have to |
179 | 354 | contain @link CCUnitTestFixture TestFixtures @endlink. They |
180 | 355 | can contain any object that implements the @link CCUnitTest |
@@ -183,6 +358,17 @@ Test @endlink interface. For example, you can create a | ||
183 | 358 | can create one in mine, and we can run them together by |
184 | 359 | creating a @link CCUnitTestSuite TestSuite @endlink that |
185 | 360 | contains both: |
361 | +@~japanese | |
362 | +@link CCUnitTestSuite TestSuites @endlink は | |
363 | +@link CCUnitTestFixture TestFixtures @endlink | |
364 | +を含むだけではありません。 | |
365 | +それらは @link CCUnitTest Test @endlink | |
366 | +インタフェースを実装するどんなオブジェクトでも含められます。 | |
367 | +例えば、あなたはあなたのコードに@link CCUnitTestSuite TestSuite @endlink | |
368 | +を作ることができ、そして私は私のスイートを作ることができます、 | |
369 | +そして私達は両方ともを含んでいる @link CCUnitTestSuite TestSuite @endlink | |
370 | +を作って一緒に個々のスイートを動かすことができるのです。 | |
371 | +@~ | |
186 | 372 | |
187 | 373 | @code |
188 | 374 | CCUnitTestSuite* suite; |
@@ -194,37 +380,74 @@ result = ccunit_runTestSuite(suite, NULL); | ||
194 | 380 | @endcode |
195 | 381 | |
196 | 382 | |
383 | +@english | |
197 | 384 | @section test_runner TestRunner |
385 | +@endif | |
386 | +@japanese | |
387 | +@section test_runner テストランナー | |
388 | +@endif | |
198 | 389 | |
390 | +@~english | |
199 | 391 | How do you run your tests and collect their results? |
392 | +@~japanese | |
393 | +どうやってテストを実行し、その結果を集めたら良いでしょうか。 | |
394 | +@~ | |
200 | 395 | |
396 | +@~english | |
201 | 397 | Once you have a test suite, you'll want to run it. %CCUnit |
202 | 398 | provides tools to define the suite to be run and to display |
203 | 399 | its results. You make your suite accessible to a @link |
204 | 400 | CreatingTestSuite ccunit_makeSuite @endlink tool that generate a |
205 | 401 | creating test suite code. |
206 | - | |
207 | -For example, to make a ComplexTest suite available to a | |
208 | -@link CreatingTestSuite ccunit_makeSuite @endlink, | |
209 | -excute the following tool to | |
402 | +@~japanese | |
403 | +一つテストスイートを書いたら、 | |
404 | +それを実行したいでしょう。 | |
405 | +CCUnit はスイートを実行するために定義し、 | |
406 | +結果を表示するためのツールを提供します。 | |
407 | +スーツを@link CreatingTestSuite ccunit_makeSuite @endlink | |
408 | +ツールに入力できるような形式で書くことで、 | |
409 | +テストスーツを作成するコードを自動的に生成することができます。 | |
410 | +@~ | |
411 | + | |
412 | +@~english | |
413 | +For example, to make a ComplexTest suite available to a | |
414 | +@link CreatingTestSuite ccunit_makeSuite @endlink, | |
415 | +excute the following tool to | |
210 | 416 | ComplexTest.c: |
417 | +@~japanese | |
418 | +例えば、ComplexTest スイートを | |
419 | +@link CreatingTestSuite ccunit_makeSuite @endlink | |
420 | +を使って使用できるようにするには、 | |
421 | +以下のツールを ComplexTest.c に実行します。 | |
422 | +@~ | |
211 | 423 | |
212 | 424 | @code |
213 | 425 | $ ccunit_makeSuite -f complex_suite -o suiteComplex.c ComplexTest.c |
214 | 426 | @endcode |
215 | 427 | |
216 | 428 | @anchor test_runner_code |
429 | +@~english | |
217 | 430 | To use the TestRunner, include the header files for the tests in Main.c: |
431 | +@~japanese | |
432 | +TestRunner を使用するには、 | |
433 | +Main.cでテストのためのファイルのヘッダをインクルードします。 | |
434 | +@~ | |
218 | 435 | |
219 | 436 | @code |
220 | 437 | #include <ccunit/CCUnitTestRunner.h> |
221 | 438 | #include <ccunit/CCUnitTestSuite.h> |
222 | 439 | @endcode |
223 | 440 | |
441 | +@~english | |
224 | 442 | And call to |
225 | 443 | @link ccunit_runTestRunner() |
226 | -ccunit_runTestRunner (CCUnitTestRunner*, CCUnitTestSuite *) @endlink | |
444 | +ccunit_runTestRunner (CCUnitTestRunner*, CCUnitTestSuite *) @endlink | |
227 | 445 | in the <code>main()</code> function: |
446 | +@~japanese | |
447 | +そして@link ccunit_runTestRunner() | |
448 | +ccunit_runTestRunner (CCUnitTestRunner*, CCUnitTestSuite *) @endlink | |
449 | +を<code>main()</code>関数で実行します。 | |
450 | +@~ | |
228 | 451 | |
229 | 452 | @code |
230 | 453 | extern CCUnitTestSuite* complex_suite(const char* name); |
@@ -239,45 +462,106 @@ int main( int argc, char **argv) | ||
239 | 462 | } |
240 | 463 | @endcode |
241 | 464 | |
242 | -The @link ExecutingTest TestRunner @endlink will run the tests. | |
243 | -If all the tests pass, you'll get an informative message. | |
465 | +@~english | |
466 | +The @link ExecutingTest TestRunner @endlink will run the tests. | |
467 | +If all the tests pass, you'll get an informative message. | |
244 | 468 | If any fail, you'll get the following information: |
469 | +@~japanese | |
470 | +@link ExecutingTest TestRunner @endlink はテストを実行します。 | |
471 | +もしすべてのテストがパスすれば、その情報のメッセージが表示されます。 | |
472 | +もしどれかが失敗すれば、それについて以下のような情報が表示されます。 | |
473 | +@~ | |
245 | 474 | |
246 | 475 | <ul> |
247 | -<li> The name of the source file that contains the test</li> | |
248 | -<li> The line number where the failure occurred</li> | |
249 | -<li> The name of the test case that failed</li> | |
250 | -<li> All of the text inside the call to | |
251 | - <code>CCUNIT_ASSERT ()</code> which detected the failure</li> | |
476 | +<li>@~english | |
477 | + The name of the source file that contains the test | |
478 | + @~japanese | |
479 | + テストを含んでいるソースファイル名 | |
480 | +</li> | |
481 | +<li>@~english | |
482 | + The line number where the failure occurred | |
483 | + @~japanese | |
484 | + 失敗が怒った行番号 | |
485 | +</li> | |
486 | +<li>@~english | |
487 | + The name of the test case that failed | |
488 | + @~japanese | |
489 | + 失敗したテストケースの名前 | |
490 | +</li> | |
491 | +<li>@~english | |
492 | + All of the text inside the call to | |
493 | + <code>CCUNIT_ASSERT ()</code> which detected the failure | |
494 | + @~japanese | |
495 | + 失敗を検知した<code>CCUNIT_ASSERT ()</code>が呼び出された時の条件の文字列。 | |
496 | +</li> | |
252 | 497 | </ul> |
253 | 498 | |
499 | +@english | |
254 | 500 | @section helper_macros Helper Tool |
255 | - | |
256 | -As you might have noticed, implementing the fixture | |
257 | -<code>suite ()</code> function is a repetitive and error | |
501 | +@endif | |
502 | +@japanese | |
503 | +@section helper_macros ヘルパーツール | |
504 | +@endif | |
505 | + | |
506 | +@~english | |
507 | +As you might have noticed, implementing the <code>suite | |
508 | +()</code> function of fixture is a repetitive and error | |
258 | 509 | prone task. A @ref CreatingTestSuite set of functions and |
259 | 510 | command have been created to automatically implements the |
260 | -<code>suite()</code> method. | |
511 | +<code>suite()</code> function. | |
512 | +@~japanese | |
513 | +お気づきのように、フィクスチャの <code>suite ()</code>関数を実装するのは、 | |
514 | +反復的で間違いやすい作業です。 | |
515 | +@ref CreatingTestSuite の関数のセットとコマンドは<code>suite ()</code> | |
516 | +関数の実装を自動的に作成することができます。 | |
517 | +@~ | |
518 | + | |
519 | +@dontinclude complex/testComplex.c | |
261 | 520 | |
521 | +@~english | |
262 | 522 | The following code is a rewrite of ComplexTest using those command: |
523 | +@~japanese | |
524 | +以下のコードはそれらのコマンドが使うようにComplexTestを書換えたものです。 | |
525 | +@~ | |
263 | 526 | |
264 | 527 | @code |
265 | 528 | #include <cppunit/CCUnitAssert.h> |
266 | 529 | @endcode |
267 | 530 | |
531 | +@~english | |
268 | 532 | First, you declare the fixture, passing the test fixture |
269 | 533 | name to the javaDoc style comment, which consist of a |
270 | 534 | C-style comment block starting with two <tt>*</tt>'s: |
535 | +@~japanese | |
536 | +最初に、フィクスチャを宣言します。 | |
537 | +これはjavaDocスタイルのコメント内にフィクスチャの名前を記述します。 | |
538 | +javaDocスタイルのコメントとは C スタイルのコメントブロックの開始が | |
539 | +二つのアスタリスク<tt>*</tt>になっているものです。 | |
540 | +@~ | |
271 | 541 | |
272 | 542 | @code |
273 | 543 | //** test case: complex number test *\/ |
274 | 544 | @endcode |
275 | 545 | |
276 | -The suite created by the <code>ccunit_suite()</code> | |
277 | -function is specified <code>-f</code> option of command | |
278 | -<code>ccunit_makeSuite</code>. Then, you define each test | |
279 | -case of the fixture with prefix <code>test</code>, | |
280 | -<code>setUp</code>, <code>tearDown</code>: | |
546 | +@~english | |
547 | +The function to make @link CCUnitTestSuite TestSuite | |
548 | +@endlink is <code>ccunit_suite</code>. | |
549 | +But, it can be changed to another | |
550 | +name by the <code>-f</code> option of the | |
551 | +<code>ccunit_makeSuite</code> command, too. | |
552 | +Then, you define each test case of the fixture with prefix | |
553 | +<code>test</code>, <code>setUp</code>, | |
554 | +<code>tearDown</code>: | |
555 | + | |
556 | +@~japanese | |
557 | +@link CCUnitTestSuite TestSuite @endlink | |
558 | +を作成する関数は <code>ccunit_suite</code> です、 | |
559 | +しかし <code>ccunit_makeSuite</code> コマンドの | |
560 | +<code>-f</code> オプションで別の名前に変えることもできます。 | |
561 | +そして、フィクスチャのテストケースにはそれぞれ名前の先頭に、 | |
562 | +<code>test</code>, <code>setUp</code>, | |
563 | +<code>tearDown</code> をつけてください。 | |
564 | +@~ | |
281 | 565 | |
282 | 566 | @code |
283 | 567 | #include <complex.h> |
@@ -292,7 +576,7 @@ void setUp_complex_test () | ||
292 | 576 | s1_1 = complex_new (1, 1); |
293 | 577 | s11_2 = complex_new (11, 2); |
294 | 578 | } |
295 | - | |
579 | + | |
296 | 580 | void tearDown_complex_test () |
297 | 581 | { |
298 | 582 | complex_delete (s10_1); |
@@ -328,17 +612,27 @@ void test_complex_sub () | ||
328 | 612 | } |
329 | 613 | @endcode |
330 | 614 | |
615 | +@~english | |
331 | 616 | Finally, you end the fixture declaration: |
617 | +@~japanese | |
618 | +最後に、フィクスチャの終りを宣言します。 | |
619 | +@~ | |
332 | 620 | |
333 | 621 | @code |
334 | 622 | //** end test case *\/ |
335 | 623 | @endcode |
336 | 624 | |
625 | +@~english | |
337 | 626 | To generate creating suite function code, run |
338 | 627 | <code>ccunit_makeSuite</code> tool. |
628 | +@~japanese | |
629 | +スイート作成関数のコードを生成するには、 | |
630 | +<code>ccunit_makeSuite</code>ツールを実行します。 | |
631 | +@~ | |
339 | 632 | |
340 | 633 | @code |
341 | -$ ccunit_makeSuite testComplex.c | |
634 | +$ ccunit_makeSuite -f complex_suite -o suiteComplex.c testComplex.c | |
635 | +$ cat suiteComplex.c | |
342 | 636 | |
343 | 637 | #include <ccunit/CCUnitTestSuite.h> |
344 | 638 | #include <ccunit/CCUnitTestFixture.h> |
@@ -356,6 +650,26 @@ extern void test_complex_add (); | ||
356 | 650 | //* test_complex_sub *\/ |
357 | 651 | extern void test_complex_sub (); |
358 | 652 | |
653 | +static CCUnitTestFunc fx_001_cases[] = { | |
654 | + { | |
655 | + "test_complex_equals", | |
656 | + "test equals", | |
657 | + test_complex_equals | |
658 | + }, | |
659 | + { | |
660 | + "test_complex_add", | |
661 | + "test add", | |
662 | + test_complex_add | |
663 | + }, | |
664 | + { | |
665 | + "test_complex_sub", | |
666 | + "test sub", | |
667 | + test_complex_sub | |
668 | + }, | |
669 | + { | |
670 | + NULL, NULL, NULL | |
671 | + }, | |
672 | +}; | |
359 | 673 | |
360 | 674 | static CCUnitTestFixtureDfn fx_001 = { |
361 | 675 | { ccunitTypeFixture }, |
@@ -370,38 +684,22 @@ static CCUnitTestFixtureDfn fx_001 = { | ||
370 | 684 | "tearDown_complex_test", |
371 | 685 | tearDown_complex_test |
372 | 686 | }, |
373 | - { | |
374 | - { | |
375 | - "test_complex_equals", | |
376 | - "test equals", | |
377 | - test_complex_equals | |
378 | - }, | |
379 | - { | |
380 | - "test_complex_add", | |
381 | - "test add", | |
382 | - test_complex_add | |
383 | - }, | |
384 | - { | |
385 | - "test_complex_sub", | |
386 | - "test sub", | |
387 | - test_complex_sub | |
388 | - }, | |
389 | - { | |
390 | - NULL, NULL, NULL | |
391 | - }, | |
392 | - } | |
687 | + fx_001_cases, | |
688 | +}; | |
689 | + | |
690 | +static CCUnitTestDfn* suite_001_test[] = { | |
691 | + &fx_001.test, | |
692 | + NULL, | |
393 | 693 | }; |
394 | 694 | |
395 | 695 | static CCUnitTestSuiteDfn suite_001 = { |
396 | 696 | { ccunitTypeSuite }, |
397 | 697 | "", |
398 | - { | |
399 | - &suite_002.test, | |
400 | - NULL, | |
401 | - }, | |
698 | + suite_001_test | |
402 | 699 | }; |
403 | 700 | |
404 | -CCUnitTestSuite* ccunit_suite (const char* name) | |
701 | + | |
702 | +CCUnitTestSuite* complex_suite (const char* name) | |
405 | 703 | { |
406 | 704 | if (!suite_001.name[0]) |
407 | 705 | suite_001.name = name; |
@@ -410,18 +708,44 @@ CCUnitTestSuite* ccunit_suite (const char* name) | ||
410 | 708 | $ |
411 | 709 | @endcode |
412 | 710 | |
711 | +@english | |
413 | 712 | @section post_build_check Post-build check |
713 | +@endif | |
714 | +@japanese | |
715 | +@section post_build_check ビルド後のチェック | |
716 | +@endif | |
414 | 717 | |
718 | +@~english | |
415 | 719 | Now that we have our unit tests running, how about |
416 | 720 | integrating unit testing to our build process ? |
721 | +@~japanese | |
722 | +さあユニットテストを実行する準備ができました。 | |
723 | +ではビルドプロセスにユニットテストを統合するにはどうしたらい | |
724 | +いでしょう。 | |
725 | +@~ | |
417 | 726 | |
727 | +@~english | |
418 | 728 | To do that, the application must returns a value different than 0 to indicate that |
419 | 729 | there was an error. |
730 | +@~japanese | |
731 | +そうするには、アプリケーションは、エラーが発生したことを示す | |
732 | +0以外の値を返さなければなりません。 | |
733 | +@~ | |
420 | 734 | |
421 | -@link ccunit_runTestRunner() ccunit_runTestRunner() @endlink returns | |
735 | +@~english | |
736 | +@link ccunit_runTestRunner() ccunit_runTestRunner() @endlink returns | |
422 | 737 | a integer indicating if the run was successful. |
738 | +@~japanese | |
739 | +@link ccunit_runTestRunner() ccunit_runTestRunner() @endlink | |
740 | +は、実行が成功したかどうかを示す整数を返します。 | |
741 | +@~ | |
423 | 742 | |
743 | +@~english | |
424 | 744 | Updating our main programm, we obtains: |
745 | +@~japanese | |
746 | +次のようにメインプログラムを更新します。 | |
747 | +@~ | |
748 | + | |
425 | 749 | @code |
426 | 750 | #include <ccunit/CCUnitTestRunner.h> |
427 | 751 |
@@ -437,6 +761,14 @@ int main (int argc, char** argv) | ||
437 | 761 | } |
438 | 762 | @endcode |
439 | 763 | |
764 | +@~english | |
440 | 765 | Now, you need to run your application after compilation. |
766 | +The sample program made in the above is in the example/complex directory. | |
767 | +@~japanese | |
768 | +それではアプリケーションをコンパイルした後に実行してみましょ | |
769 | +う。 | |
770 | +以上で作成したサンプルプログラムは example/complex ディレク | |
771 | +トリにあります。 | |
772 | +@~ | |
441 | 773 | |
442 | 774 | */ |
@@ -2,44 +2,111 @@ | ||
2 | 2 | /* $Id$ */ |
3 | 3 | /** @mainpage |
4 | 4 | |
5 | +@~english | |
5 | 6 | CCUnit is a simple framework to write repeatable tests with C language. |
6 | - | |
7 | +@~japanese | |
8 | +CCUnit は C 言語で繰り返し可能なテストを書くための簡単なフレ | |
9 | +ームワークです。 | |
10 | +@~ | |
11 | +@english | |
12 | +[see also <a href="../ja/index.html">Japanese</a> documents] | |
13 | +@endif | |
14 | +@japanese | |
15 | +[see also <a href="../../index.html">English</a> documents] | |
16 | +@endif | |
17 | + | |
18 | +@english | |
7 | 19 | @section _installation Installation |
20 | +@endif | |
21 | +@japanese | |
22 | +@section _installation インストール | |
23 | +@endif | |
8 | 24 | |
25 | +@~english | |
9 | 26 | Below are the installation steps for installing CCUnit: |
27 | +@~japanese | |
28 | +以下に CCUnitをインストールする手順を示します。 | |
10 | 29 | |
30 | +@if English | |
11 | 31 | <ol> |
12 | 32 | <li>expand the archive file.</li> |
13 | -<li>cd to expanded dir.</li> | |
14 | -<li>run the `<code>./configure</code>' file.</li> | |
33 | +<li>cd to expanded dir. </li> | |
34 | +<li>run the `<code>./configure</code>' file. </li> | |
15 | 35 | <li>type <code>make</code> to create ccunit library. </li> |
16 | 36 | <li>type <code>make install</code> to install.</li> |
17 | 37 | </ol> |
38 | +@endif | |
39 | + | |
40 | +@japanese | |
41 | +<ol> | |
42 | +<li>アーカイブファイルを展開します。</li> | |
43 | +<li>展開したディレクトリにcdします。</li> | |
44 | +<li>`<code>./configure</code>' ファイルを実行します。</li> | |
45 | +<li><code>make</code> とタイプして ccunit ライブラリを作成します。</li> | |
46 | +<li><code>make install</code> としてインストールします。</li> | |
47 | +</ol> | |
48 | +@endif | |
18 | 49 | |
50 | +@english | |
19 | 51 | @section _usage Getting Started |
52 | +@endif | |
53 | +@japanese | |
54 | +@section _usage さあ始めましょう | |
55 | +@endif | |
20 | 56 | |
57 | +@~english | |
21 | 58 | <a href="modules.html">Modules</a> give |
22 | 59 | you a organized view of %CCUnit modules. |
60 | +@~japanese | |
61 | +<a href="modules.html">モジュール</a> | |
62 | +セクションは CCUnit のモジュールを整理して表示しています。 | |
23 | 63 | |
24 | -<!-- | |
64 | +@~english | |
25 | 65 | You find additional samples in the examples directory. |
66 | +@~japanese | |
67 | +examples ディレクトリにはサンプルファイルがあります。 | |
26 | 68 | |
27 | -- SimpleTest.c - some simple test cases | |
28 | -- ArrayTest.c - test case for array. | |
29 | ---> | |
69 | +@~english | |
70 | +- ComplexTest.c - some complex number library test cases | |
71 | +@~japanese | |
72 | +- ComplexTest.c - 複素数ライブラリのいき塚のテストケースです | |
73 | +@~ | |
30 | 74 | |
75 | +@english | |
31 | 76 | @section _documentation Documentation |
77 | +@endif | |
78 | +@japanese | |
79 | +@section _documentation ドキュメント | |
80 | +@endif | |
32 | 81 | |
33 | 82 | <dl> |
34 | 83 | <dt>CCUnit Cookbook</dt> |
35 | -<dd>A <a href="cookbook.html">cookbook</a> for implementing tests with CCUnit. | |
84 | +<dd>@~english | |
85 | + A <a href="cookbook.html">cookbook</a> for implementing | |
86 | + tests with CCUnit. (and <a | |
87 | + href="../ja/cookbook.html">cookbook in | |
88 | + japanese</a>) | |
89 | + @~japanese | |
90 | + CCUnitでテストを実装するための<a href="cookbook.html">クックブック</a> | |
91 | + (see also <a | |
92 | + href="../../cookbook.html">Cookbook in | |
93 | + English</a> Edition) | |
36 | 94 | </dl> |
37 | 95 | |
96 | +@english | |
38 | 97 | @section _license Lincense |
98 | +@endif | |
99 | +@japanese | |
100 | +@section _license ライセンス | |
101 | +@endif | |
39 | 102 | |
103 | +@~english | |
40 | 104 | This library is released under the GNU |
41 | 105 | <a href="http://www.gnu.org/copyleft/lesser.html" |
42 | 106 | >Lesser General Public License</a>. |
107 | +@~japanese | |
108 | +このライブラリは、GNU <a href="http://www.gnu.org/copyleft/lesser.html" | |
109 | +>Lesser General Public License</a> の元で配布しています。 | |
43 | 110 | |
44 | 111 | */ |
45 | 112 |