Skip to content

Commit 34314c1

Browse files
committed
Propagate ch11 tech review edits to src
1 parent 537905e commit 34314c1

File tree

5 files changed

+15
-14
lines changed

5 files changed

+15
-14
lines changed

listings/ch11-writing-automated-tests/listing-11-09/src/lib.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ pub struct Guess {
44

55
// ANCHOR: here
66
// --snip--
7+
78
impl Guess {
89
pub fn new(value: i32) -> Guess {
910
if value < 1 {
@@ -27,7 +28,7 @@ mod tests {
2728
use super::*;
2829

2930
#[test]
30-
#[should_panic(expected = "Guess value must be less than or equal to 100")]
31+
#[should_panic(expected = "less than or equal to 100")]
3132
fn greater_than_100() {
3233
Guess::new(200);
3334
}

listings/ch11-writing-automated-tests/no-listing-09-guess-with-panic-msg-bug/output.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ thread 'main' panicked at 'Guess value must be greater than or equal to 1, got 2
1313
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
1414
note: panic did not contain expected string
1515
panic message: `"Guess value must be greater than or equal to 1, got 200."`,
16-
expected substring: `"Guess value must be less than or equal to 100"`
16+
expected substring: `"less than or equal to 100"`
1717

1818
failures:
1919
tests::greater_than_100

listings/ch11-writing-automated-tests/no-listing-09-guess-with-panic-msg-bug/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ mod tests {
2727
use super::*;
2828

2929
#[test]
30-
#[should_panic(expected = "Guess value must be less than or equal to 100")]
30+
#[should_panic(expected = "less than or equal to 100")]
3131
fn greater_than_100() {
3232
Guess::new(200);
3333
}

src/ch11-01-writing-tests.md

+9-9
Original file line numberDiff line numberDiff line change
@@ -89,14 +89,14 @@ the result of running that test is `ok`. The overall summary `test result: ok.`
8989
means that all the tests passed, and the portion that reads `1 passed; 0
9090
failed` totals the number of tests that passed or failed.
9191

92-
It's possible to mark a test as ignored so it doesn't run in a particular
93-
instance; we'll cover that in the [“Ignoring Some Tests Unless Specifically
92+
Its possible to mark a test as ignored so it doesnt run in a particular
93+
instance; well cover that in the [“Ignoring Some Tests Unless Specifically
9494
Requested”][ignoring]<!-- ignore --> section later in this chapter. Because we
95-
haven't done that here, the summary shows `0 ignored`. We can also pass an
95+
havent done that here, the summary shows `0 ignored`. We can also pass an
9696
argument to the `cargo test` command to run only tests whose name matches a
97-
string; this is called filtering and we'll cover that in the [“Running a Subset
98-
of Tests by Name”][subset]<!-- ignore --> section. We also haven’t filtered the
99-
tests being run, so the end of the summary shows `0 filtered out`.
97+
string; this is called *filtering* and well cover that in the [“Running a
98+
Subset of Tests by Name”][subset]<!-- ignore --> section. We also haven’t
99+
filtered the tests being run, so the end of the summary shows `0 filtered out`.
100100

101101
The `0 measured` statistic is for benchmark tests that measure performance.
102102
Benchmark tests are, as of this writing, only available in nightly Rust. See
@@ -126,7 +126,7 @@ Then run `cargo test` again. The output now shows `exploration` instead of
126126
{{#include ../listings/ch11-writing-automated-tests/no-listing-01-changing-test-name/output.txt}}
127127
```
128128

129-
Now we'll add another test, but this time we’ll make a test that fails! Tests
129+
Now well add another test, but this time we’ll make a test that fails! Tests
130130
fail when something in the test function panics. Each test is run in a new
131131
thread, and when the main thread sees that a test thread has died, the test is
132132
marked as failed. In Chapter 9, we talked about how the simplest way to panic
@@ -470,8 +470,8 @@ too large.
470470
{{#rustdoc_include ../listings/ch11-writing-automated-tests/listing-11-09/src/lib.rs:here}}
471471
```
472472

473-
<span class="caption">Listing 11-9: Testing for a `panic!` with a particular
474-
panic message</span>
473+
<span class="caption">Listing 11-9: Testing for a `panic!` with a panic message
474+
containing a specified substring</span>
475475

476476
This test will pass because the value we put in the `should_panic` attribute’s
477477
`expected` parameter is a substring of the message that the `Guess::new`

src/ch11-02-running-tests.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ output from the test that failed, `I got the value 8`, appears in the section
7979
of the test summary output, which also shows the cause of the test failure.
8080

8181
If we want to see printed values for passing tests as well, we can tell Rust
82-
to also show the output of successful tests at the end with `--show-output`.
82+
to also show the output of successful tests with `--show-output`.
8383

8484
```console
8585
$ cargo test -- --show-output
@@ -127,7 +127,7 @@ We can pass the name of any test function to `cargo test` to run only that test:
127127
```
128128

129129
Only the test with the name `one_hundred` ran; the other two tests didn’t match
130-
that name. The test output lets us know we had more tests that didn't run by
130+
that name. The test output lets us know we had more tests that didnt run by
131131
displaying `2 filtered out` at the end.
132132

133133
We can’t specify the names of multiple tests in this way; only the first value

0 commit comments

Comments
 (0)