Skip to content

Commit 66a8e70

Browse files
authored
Merge pull request #218 from KeenS/1.9-testing
5.2 Testing (1.9)
2 parents ef5e47c + b904b4b commit 66a8e70

File tree

2 files changed

+14
-118
lines changed

2 files changed

+14
-118
lines changed

1.9/ja/book/testing.md

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ $ cd adder
3636
これが `src/lib.rs` の内容です。
3737

3838
```rust
39+
# fn main() {}
3940
#[test]
4041
fn it_works() {
4142
}
@@ -102,6 +103,7 @@ test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured
102103
テストを失敗させましょう。
103104

104105
```rust
106+
# fn main() {}
105107
#[test]
106108
fn it_works() {
107109
assert!(false);
@@ -183,6 +185,7 @@ Windowsでは、 `cmd` を使っていればこうです。
183185
もう1つのアトリビュート、 `should_panic` を使ってテストの失敗を反転させることができます。
184186

185187
```rust
188+
# fn main() {}
186189
#[test]
187190
#[should_panic]
188191
fn it_works() {
@@ -216,6 +219,7 @@ test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured
216219
Rustはもう1つのマクロ、 `assert_eq!` を提供しています。これは2つの引数の等価性を調べます。
217220

218221
```rust
222+
# fn main() {}
219223
#[test]
220224
#[should_panic]
221225
fn it_works() {
@@ -256,6 +260,7 @@ test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured
256260
前述の例のもっと安全なバージョンはこうなります。
257261

258262
```rust
263+
# fn main() {}
259264
#[test]
260265
#[should_panic(expected = "assertion failed")]
261266
fn it_works() {
@@ -268,6 +273,7 @@ fn it_works() {
268273
「リアルな」テストを書いてみましょう。
269274

270275
```rust,ignore
276+
# fn main() {}
271277
pub fn add_two(a: i32) -> i32 {
272278
a + 2
273279
}
@@ -291,6 +297,7 @@ fn it_works() {
291297
そのようなテストは、 `ignore` アトリビュートを使ってデフォルトでは無効にすることができます。
292298

293299
```rust
300+
# fn main() {}
294301
#[test]
295302
fn it_works() {
296303
assert_eq!(4, add_two(2));
@@ -360,6 +367,7 @@ test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured
360367
今までの例の慣用的な書き方はこのようになります。
361368

362369
```rust,ignore
370+
# fn main() {}
363371
pub fn add_two(a: i32) -> i32 {
364372
a + 2
365373
}
@@ -397,6 +405,7 @@ mod tests {
397405
`src/lib.rs` をグロブを使うように変更しましょう。
398406

399407
```rust,ignore
408+
# fn main() {}
400409
pub fn add_two(a: i32) -> i32 {
401410
a + 2
402411
}
@@ -438,11 +447,11 @@ test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured
438447
動きます!
439448

440449
<!--The current convention is to use the `tests` module to hold your "unit-style"-->
441-
<!--tests. Anything that just tests one small bit of functionality makes sense to-->
450+
<!--tests. Anything that tests one small bit of functionality makes sense to-->
442451
<!--go here. But what about "integration-style" tests instead? For that, we have-->
443452
<!--the `tests` directory.-->
444453
現在の慣習では、 `tests` モジュールは「ユニット」テストを入れるために使うことになっています。
445-
単一の小さな機能の単位をテストするだけのものは全て、ここに入れる意味があります。
454+
単一の小さな機能の単位をテストするものは全て、ここに入れる意味があります。
446455
しかし、「結合」テストはどうでしょうか。
447456
結合テストのためには、 `tests` ディレクトリがあります。
448457

@@ -456,6 +465,7 @@ test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured
456465
```rust,ignore
457466
extern crate adder;
458467
468+
# fn main() {}
459469
#[test]
460470
fn it_works() {
461471
assert_eq!(4, adder::add_two(2));
@@ -525,6 +535,7 @@ test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured
525535
これが例を付けた具体的な `src/lib.rs` です。
526536

527537
```rust,ignore
538+
# fn main() {}
528539
# //! The `adder` crate provides functions that add numbers to other numbers.
529540
//! `adder`クレートはある数値を数値に加える関数を提供する
530541
//!
@@ -605,12 +616,7 @@ test result: ok. 2 passed; 0 failed; 0 ignored; 0 measured
605616
例を追加するにつれて、それらの名前は `add_two_1` というような形で数値が増えていきます。
606617

607618
<!--We haven’t covered all of the details with writing documentation tests. For more,-->
608-
<!--please see the [Documentation chapter](documentation.html)-->
619+
<!-- please see the [Documentation chapter](documentation.html). -->
609620
まだドキュメンテーションテストの書き方の詳細について、全てをカバーしてはいません。
610621
詳しくは [ドキュメントの章](documentation.html) を見てください。
611622

612-
<!--One final note: documentation tests *cannot* be run on binary crates.-->
613-
<!--To see more on file arrangement see the [Crates and-->
614-
<!--Modules](crates-and-modules.html) section.-->
615-
最後の注意:バイナリクレート上のテストは実行 *できません*
616-
ファイルの配置についてもっと知りたい場合は [クレートとモジュール](crates-and-modules.html) セクションを見ましょう。

diff-1.6.0..1.9.0/src/doc/book/testing.md

Lines changed: 0 additions & 110 deletions
This file was deleted.

0 commit comments

Comments
 (0)