Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Swap inconsistent assert_eq! argument order in testing chapter #3497

Merged
merged 2 commits into from
Jun 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,9 @@ test tests::it_adds_two ... FAILED
failures:

---- tests::it_adds_two stdout ----
thread 'tests::it_adds_two' panicked at src/lib.rs:11:9:
assertion `left == right` failed
left: 4
right: 5
left: 5
right: 4
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ mod tests {

#[test]
fn it_adds_two() {
assert_eq!(4, add_two(2));
assert_eq!(add_two(2), 4);
}
}
2 changes: 1 addition & 1 deletion src/ch11-01-writing-tests.md
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ assertion functions are called `expected` and `actual`, and the order in which
we specify the arguments matters. However, in Rust, they’re called `left` and
`right`, and the order in which we specify the value we expect and the value
the code produces doesn’t matter. We could write the assertion in this test as
`assert_eq!(add_two(2), 4)`, which would result in the same failure message
`assert_eq!(4, add_two(2))`, which would result in the same failure message
that displays `` assertion failed: `(left == right)` ``.

The `assert_ne!` macro will pass if the two values we give it are not equal and
Expand Down