pub fn equal_file_contents<R>(a: &R, path: &str)
Expand description
Asserts that the value is equal to the contents of the file. Works for anything that implements AsRef<u8>. This is useful for testing against large fixtures. The file is read into memory and compared against the value.
The file is not read until the assertion is run, preventing side effects from reading the file during test setup or teardown, or from affecting assertions earlier in the test.
ยงExample
use common_testing::assert;
#[test]
fn test_1() {
let result1 = "some file contents";
assert::equal_file_contents(&result, "./fixtures/test_file1");
// Works for anything that implements AsRef<[u8]>
let result2 = vec![0x01, 0x0E, 0xF3];
assert::equal_file_contents(&result, "./fixtures/test_file2");
}