Open Alpvax opened 6 months ago
Do you mean that the value which you are testing is a string containing a CRLF? In other words something like
use expect_test::expect;
#[test]
fn foo() {
let actual = "foo\r\n";
let expected = expect![[r#"
foo
"#]];
expected.assert_eq(&actual);
}
? Rust normalizes all strings from CRLF to LF, so expect_test will think that the test expectation is meant to use LF even if the source file contains CRLF. This then results in a mismatch between the actual (CRLF line endings) and expected (LF line endings) value. You can use .assert_debug_eq()
instead of .assert_eq()
to make the line endings get rendered as \r\n
in the test expectation to avoid this normalization:
use expect_test::expect;
#[test]
fn foo() {
let actual = "foo\r\n";
let expected = expect![[r#"
"foo\r\n"
"#]];
expected.assert_debug_eq(&actual);
}
I wish to test against a file with the line endings as CRLF, using expect_file When I use UPDATE_EXPECT, the test passes, but if I then re-run the test, it fails, with no highlighted error characters.