mirror of
https://github.com/uutils/diffutils.git
synced 2026-06-10 15:48:59 -07:00
Ed diff: compact ranges of lines where possible (fixes #21)
This commit is contained in:
committed by
Sylvestre Ledru
parent
0a67bf9fb8
commit
a89f30afa0
@@ -122,6 +122,7 @@ pub fn diff(expected: &[u8], actual: &[u8]) -> Result<Vec<u8>, DiffError> {
|
||||
expected_count + line_number_expected - 1
|
||||
)
|
||||
.unwrap(),
|
||||
(1, _) => writeln!(&mut output, "{}c", line_number_expected).unwrap(),
|
||||
_ => writeln!(
|
||||
&mut output,
|
||||
"{},{}c",
|
||||
@@ -156,6 +157,15 @@ mod tests {
|
||||
Ok(output)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_basic() {
|
||||
let from = b"a\n";
|
||||
let to = b"b\n";
|
||||
let diff = diff(from, to).unwrap();
|
||||
let expected = vec!["1c", "b", ".", ""].join("\n");
|
||||
assert_eq!(diff, expected.as_bytes());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_permutations() {
|
||||
let target = "target/ed-diff/";
|
||||
|
||||
Reference in New Issue
Block a user