/// Asserts that `expected` and `actual` strings are equal. If they differ only
/// in trailing or leading whitespace the test won't fail and
/// the contents of `actual` will be written to the file located at `path`.
Asserts that `expected` and `actual` strings are equal. If they differ only
in trailing or leading whitespace the test won't fail and
the contents of `actual` will be written to the file located at `path`.
Asserts that ` expected ` and ` actual ` strings are equal . If they differ only in trailing or leading whitespace the test won ' t fail and the contents of ` actual ` will be written to the file located at ` path ` .
fn assert_equal_text(expected: &str, actual: &str, path: &Path) {
    if expected == actual {
        return;
    }
    let dir = project_dir();
    let pretty_path = path.strip_prefix(&dir).unwrap_or_else(|_| path);
    if expected.trim() == actual.trim() {
        println!("whitespace difference, rewriting");
        println!("file: {}\n", pretty_path.display());
        fs::write(path, actual).unwrap();
        return;
    }
    if REWRITE {
        println!("rewriting {}", pretty_path.display());
        fs::write(path, actual).unwrap();
        return;
    }
    assert_eq_text!(expected, actual, "file: {}", pretty_path.display());
}
fn assert_equal_text ( expected : & str , actual : & str , path : & Path ) { if expected == actual { return ; } let dir = project_dir ( ) ; let pretty_path = path . strip_prefix ( & dir ) . unwrap_or_else ( | _ | path ) ; if expected . trim ( ) == actual . trim ( ) { println ! ( " " ) ; println ! ( " \n " pretty_path display ( ) ) ; fs :: write ( path , actual ) . unwrap ( ) ; return ; } if REWRITE { println ! ( " " pretty_path display ( ) ) ; fs :: write ( path , actual ) . unwrap ( ) ; return ; } assert_eq_text ! ( expected actual " " pretty_path display ( ) ) ; }
Asserts that `expected` and `actual` strings are equal.
Asserts that ` expected ` and ` actual ` strings are equal .
expected
&str
actual
&str
path
&Path