Skip to content

Commit 2598f25

Browse files
authored
Merge pull request #134 from kdnakt/translate-cargo-test
Translate untranslated lines in cargo/test.md
2 parents e0cccea + c209a8d commit 2598f25

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

src/cargo/test.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,11 @@ crate.
3838
`tests`内の各ファイルは個別の[統合テスト](https://doc.rust-lang.org/book/ch11-03-test-organization.html#integration-tests)です。
3939
これはライブラリを依存クレートから呼ばれたかのようにテストできます。
4040

41+
<!--
4142
The [Testing][testing] chapter elaborates on the three different testing styles:
4243
[Unit][unit_testing], [Doc][doc_testing], and [Integration][integration_testing].
44+
-->
45+
[テスト][testing]の章は3つの異なるテストスタイルについて解説しています:[単体テスト][unit_testing][ドキュメンテーションテスト][doc_testing]、そして[結合テスト][integration_testing]です。
4346

4447
<!--
4548
`cargo` naturally provides an easy way to run all of your tests!
@@ -98,44 +101,54 @@ that they don't race with each other.
98101
-->
99102
注意:Cargoは複数のテストを並列で実行することがありますので、それらが互いに競合しないようにしてください。
100103

104+
<!--
101105
One example of this concurrency causing issues is if two tests output to a
102106
file, such as below:
107+
-->
108+
並行性が問題を引き起こす一例として、以下のように、2つのテストが1つのファイルに出力するケースがあります。
103109

104110
```rust
105111
#[cfg(test)]
106112
mod tests {
107113
// Import the necessary modules
114+
// 必要なモジュールをインポートする。
108115
use std::fs::OpenOptions;
109116
use std::io::Write;
110117

111118
// This test writes to a file
119+
// ファイルに書き込むテスト。
112120
#[test]
113121
fn test_file() {
114122
// Opens the file ferris.txt or creates one if it doesn't exist.
123+
// ferris.txtというファイルを開くか、存在しない場合は作成する。
115124
let mut file = OpenOptions::new()
116125
.append(true)
117126
.create(true)
118127
.open("ferris.txt")
119128
.expect("Failed to open ferris.txt");
120129

121130
// Print "Ferris" 5 times.
131+
// "Ferris"と5回書き込む。
122132
for _ in 0..5 {
123133
file.write_all("Ferris\n".as_bytes())
124134
.expect("Could not write to ferris.txt");
125135
}
126136
}
127137

128138
// This test tries to write to the same file
139+
// 同じファイルに書き込むテスト。
129140
#[test]
130141
fn test_file_also() {
131142
// Opens the file ferris.txt or creates one if it doesn't exist.
143+
// ferris.txtというファイルを開くか、存在しない場合は作成する。
132144
let mut file = OpenOptions::new()
133145
.append(true)
134146
.create(true)
135147
.open("ferris.txt")
136148
.expect("Failed to open ferris.txt");
137149

138150
// Print "Corro" 5 times.
151+
// "Corro"と5回書き込む。
139152
for _ in 0..5 {
140153
file.write_all("Corro\n".as_bytes())
141154
.expect("Could not write to ferris.txt");
@@ -144,7 +157,10 @@ mod tests {
144157
}
145158
```
146159

160+
<!--
147161
Although the intent is to get the following:
162+
-->
163+
以下のような結果を得ようと意図しています。
148164
```shell
149165
$ cat ferris.txt
150166
Ferris
@@ -158,7 +174,10 @@ Corro
158174
Corro
159175
Corro
160176
```
177+
<!--
161178
What actually gets put into `ferris.txt` is this:
179+
-->
180+
しかし、実際に`ferris.txt`に出力されるのは、以下の通りです。
162181
```shell
163182
$ cargo test test_foo
164183
Corro

0 commit comments

Comments
 (0)