Skip to content

Commit

Permalink
update original
Browse files Browse the repository at this point in the history
  • Loading branch information
funkill committed Apr 11, 2024
1 parent 356fe02 commit 82bf815
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ fn main() {
let hello = String::from("السلام عليكم");
let hello = String::from("Dobrý den");
let hello = String::from("Hello");
let hello = String::from("שָׁלוֹם");
let hello = String::from("שלום");
let hello = String::from("नमस्ते");
let hello = String::from("こんにちは");
let hello = String::from("안녕하세요");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
// ANCHOR: here
pub fn add(left: usize, right: usize) -> usize {
left + right
}

#[cfg(test)]
mod tests {
use super::*;

#[test]
fn exploration() {
assert_eq!(2 + 2, 4);
let result = add(2, 2);
assert_eq!(result, 4);
}

#[test]
fn another() {
panic!("Make this test fail");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
pub fn add(left: usize, right: usize) -> usize {
left + right
}

#[cfg(test)]
mod tests {
use super::*;

#[test]
fn exploration() {
assert_eq!(2 + 2, 4);
let result = add(2, 2);
assert_eq!(result, 4);
}
}
4 changes: 2 additions & 2 deletions rustbook-en/src/ch02-00-guessing-game-tutorial.md
Original file line number Diff line number Diff line change
Expand Up @@ -466,8 +466,8 @@ checked into source control with the rest of the code in your project.
When you *do* want to update a crate, Cargo provides the command `update`,
which will ignore the *Cargo.lock* file and figure out all the latest versions
that fit your specifications in *Cargo.toml*. Cargo will then write those
versions to the *Cargo.lock* file. Otherwise, by default, Cargo will only look
for versions greater than 0.8.5 and less than 0.9.0. If the `rand` crate has
versions to the *Cargo.lock* file. In this case, Cargo will only look for
versions greater than 0.8.5 and less than 0.9.0. If the `rand` crate has
released the two new versions 0.8.6 and 0.9.0, you would see the following if
you ran `cargo update`:

Expand Down
2 changes: 1 addition & 1 deletion rustbook-en/src/ch11-01-writing-tests.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ cd ../../..
<span class="caption">Listing 11-1: The test module and function generated
automatically by `cargo new`</span>

For now, let’s ignore the top two lines and focus on the function. Note the
For now, let’s focus solely on the `it_works()` function. Note the
`#[test]` annotation: this attribute indicates this is a test function, so the
test runner knows to treat this function as a test. We might also have non-test
functions in the `tests` module to help set up common scenarios or perform
Expand Down
2 changes: 1 addition & 1 deletion rustbook-en/src/ch11-03-test-organization.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ Note that the `internal_adder` function is not marked as `pub`. Tests are just
Rust code, and the `tests` module is just another module. As we discussed in
the [“Paths for Referring to an Item in the Module Tree”][paths]<!-- ignore -->
section, items in child modules can use the items in their ancestor modules. In
this test, we bring all of the `test` module’s parent’s items into scope with
this test, we bring all of the `tests` module’s parent’s items into scope with
`use super::*`, and then the test can call `internal_adder`. If you don’t think
private functions should be tested, there’s nothing in Rust that will compel
you to do so.
Expand Down

0 comments on commit 82bf815

Please sign in to comment.