Updated tests and fixed inconsistent message on assert_eq

This commit is contained in:
Giles Cope 2017-06-13 14:17:59 +01:00
parent de8bbd2b16
commit 87cfb5431e
3 changed files with 30 additions and 9 deletions

View file

@ -117,8 +117,8 @@ macro_rules! assert_eq {
(left_val, right_val) => {
if !(*left_val == *right_val) {
panic!(r#"assertion failed: `(left == right)`
left: `{:?}`
right: `{:?}`"#, left_val, right_val)
left: `{:?}`
right: `{:?}`"#, left_val, right_val)
}
}
}
@ -128,8 +128,8 @@ right: `{:?}`"#, left_val, right_val)
(left_val, right_val) => {
if !(*left_val == *right_val) {
panic!(r#"assertion failed: `(left == right)`
left: `{:?}`
right: `{:?}`: {}"#, left_val, right_val,
left: `{:?}`
right: `{:?}`: {}"#, left_val, right_val,
format_args!($($arg)+))
}
}
@ -164,8 +164,9 @@ macro_rules! assert_ne {
match (&$left, &$right) {
(left_val, right_val) => {
if *left_val == *right_val {
panic!("assertion failed: `(left != right)` \
(left: `{:?}`, right: `{:?}`)", left_val, right_val)
panic!(r#"assertion failed: `(left != right)`
left: `{:?}`
right: `{:?}`"#, left_val, right_val)
}
}
}
@ -174,8 +175,9 @@ macro_rules! assert_ne {
match (&($left), &($right)) {
(left_val, right_val) => {
if *left_val == *right_val {
panic!("assertion failed: `(left != right)` \
(left: `{:?}`, right: `{:?}`): {}", left_val, right_val,
panic!(r#"assertion failed: `(left != right)`
left: `{:?}`
right: `{:?}`: {}"#, left_val, right_val,
format_args!($($arg)+))
}
}

View file

@ -8,7 +8,9 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// error-pattern:assertion failed: `(left == right)` (left: `14`, right: `15`)
// error-pattern:assertion failed: `(left == right)`
// error-pattern: left: `14`
// error-pattern:right: `15`
fn main() {
assert_eq!(14, 15);

View file

@ -0,0 +1,17 @@
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// error-pattern:assertion failed: `(left != right)`
// error-pattern: left: `14`
// error-pattern:right: `14`
fn main() {
assert_ne!(14, 14);
}