diff_match_patch_rs/
fuzz.rs1use crate::{Compat, DiffMatchPatch, Efficient, Error, PatchInput};
2
3pub fn fuzz(old: &str, new: &str) -> Result<(), Error> {
4 let dmp = DiffMatchPatch::new();
5
6 let diffs = dmp.diff_main::<Efficient>(old, new)?;
7 let patches = dmp.patch_make(PatchInput::new_diffs(&diffs))?;
8
9 assert_eq!(new, dmp.patch_apply(&patches, old)?.0);
10
11 let dmp = DiffMatchPatch::new();
12
13 let diffs = dmp.diff_main::<Compat>(old, new)?;
14 let patches = dmp.patch_make(PatchInput::new_diffs(&diffs))?;
15
16 assert_eq!(new, dmp.patch_apply(&patches, old)?.0);
17
18 Ok(())
19}