diff --git a/listings/ch11-writing-automated-tests/listing-11-03/src/lib.rs b/listings/ch11-writing-automated-tests/listing-11-03/src/lib.rs index 866f0238ba..336ea081a1 100644 --- a/listings/ch11-writing-automated-tests/listing-11-03/src/lib.rs +++ b/listings/ch11-writing-automated-tests/listing-11-03/src/lib.rs @@ -1,4 +1,4 @@ -pub fn add(left: usize, right: usize) -> usize { +pub fn add(left: u64, right: u64) -> u64 { left + right } diff --git a/listings/ch11-writing-automated-tests/no-listing-01-changing-test-name/src/lib.rs b/listings/ch11-writing-automated-tests/no-listing-01-changing-test-name/src/lib.rs index 5be58b93fc..5014a76f2b 100644 --- a/listings/ch11-writing-automated-tests/no-listing-01-changing-test-name/src/lib.rs +++ b/listings/ch11-writing-automated-tests/no-listing-01-changing-test-name/src/lib.rs @@ -1,4 +1,4 @@ -pub fn add(left: usize, right: usize) -> usize { +pub fn add(left: u64, right: u64) -> u64 { left + right } diff --git a/listings/ch11-writing-automated-tests/no-listing-10-result-in-tests/src/lib.rs b/listings/ch11-writing-automated-tests/no-listing-10-result-in-tests/src/lib.rs index c31cdcae45..06b1a03e1f 100644 --- a/listings/ch11-writing-automated-tests/no-listing-10-result-in-tests/src/lib.rs +++ b/listings/ch11-writing-automated-tests/no-listing-10-result-in-tests/src/lib.rs @@ -1,4 +1,4 @@ -pub fn add(left: usize, right: usize) -> usize { +pub fn add(left: u64, right: u64) -> u64 { left + right } diff --git a/listings/ch11-writing-automated-tests/no-listing-11-ignore-a-test/src/lib.rs b/listings/ch11-writing-automated-tests/no-listing-11-ignore-a-test/src/lib.rs index 0c8b38defd..05fbe1af0a 100644 --- a/listings/ch11-writing-automated-tests/no-listing-11-ignore-a-test/src/lib.rs +++ b/listings/ch11-writing-automated-tests/no-listing-11-ignore-a-test/src/lib.rs @@ -1,4 +1,4 @@ -pub fn add(left: usize, right: usize) -> usize { +pub fn add(left: u64, right: u64) -> u64 { left + right } diff --git a/src/ch11-01-writing-tests.md b/src/ch11-01-writing-tests.md index 93009f4d09..b04f0c2fee 100644 --- a/src/ch11-01-writing-tests.md +++ b/src/ch11-01-writing-tests.md @@ -62,6 +62,9 @@ cd ../../.. +The file starts with an example `add` function, so that we have something +to test. + 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 @@ -69,9 +72,9 @@ functions in the `tests` module to help set up common scenarios or perform common operations, so we always need to indicate which functions are tests. The example function body uses the `assert_eq!` macro to assert that `result`, -which contains the result of adding 2 and 2, equals 4. This assertion serves as -an example of the format for a typical test. Let’s run it to see that this test -passes. +which contains the result of calling `add` with 2 and 2, equals 4. This +assertion serves as an example of the format for a typical test. Let’s run it +to see that this test passes. The `cargo test` command runs all tests in our project, as shown in Listing 11-2.