Macro assertables::assert_fs_read_to_string_ge

source ·
macro_rules! assert_fs_read_to_string_ge {
    ($a_path:expr, $b_path:expr $(,)?) => { ... };
    ($a_path:expr, $b_path:expr, $($message:tt)+) => { ... };
}
Expand description

Assert a std::fs::read_to_string() value is greater than or equal to another.

  • If true, return ().

  • Otherwise, call panic! with a message and the values of the expressions with their debug representations.

§Examples

use std::io::Read;

// Return Ok
let a ="alfa.txt";
let b ="bravo.txt";
assert_fs_read_to_string_ge!(b, a);
//-> ()

// Panic with error message
let result = panic::catch_unwind(|| {
let a ="alfa.txt";
let b ="bravo.txt";
assert_fs_read_to_string_ge!(&a, &b);
//-> panic!
});
assert!(result.is_err());
let actual = result.unwrap_err().downcast::<String>().unwrap().to_string();
let expect = concat!(
    "assertion failed: `assert_fs_read_to_string_ge!(left_path, right_path)`\n",
    "  left_path label: `&a`,\n",
    "  left_path debug: `\"alfa.txt\"`,\n",
    " right_path label: `&b`,\n",
    " right_path debug: `\"bravo.txt\"`,\n",
    "             left: `\"alfa\\n\"`,\n",
    "            right: `\"bravo\\n\"`"
);
assert_eq!(actual, expect);

§Module macros