In the following test case, the middle line should have &mut actual_result and file.reopen().unwrap() highlighted on the middle changed line, and nothing else.
I think highlighting fully changed lines has no value, that's why the first and last lines should not be highlighted.
git show af2c3de7840bf6307b34076eb4db782e3fcb0c42 src/main.rs | tail -13
@@ -442,9 +438,9 @@ mod tests {
println!("Evaluating example file <{}>...", diff.to_str().unwrap());
// Run highlighting on the file into a memory buffer
- let mut actual_result: Vec<u8> = Vec::new();
- highlight_diff(&mut fs::File::open(diff).unwrap(), &mut actual_result);
- let actual_result = str::from_utf8(&actual_result).unwrap();
+ let file = tempfile::NamedTempFile::new().unwrap();
+ highlight_diff(&mut fs::File::open(diff).unwrap(), file.reopen().unwrap());
+ let actual_result = fs::read_to_string(file.path()).unwrap();
// Load the corresponding .riff-output file into a string
let basename = diff.file_stem().unwrap().to_str().unwrap();
In the following test case, the middle line should have
&mut actual_result
andfile.reopen().unwrap()
highlighted on the middle changed line, and nothing else.I think highlighting fully changed lines has no value, that's why the first and last lines should not be highlighted.