my fork of dmp
Diffstat (limited to 'src/fuzz.rs')
| -rw-r--r-- | src/fuzz.rs | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/fuzz.rs b/src/fuzz.rs new file mode 100644 index 0000000..0beedb3 --- /dev/null +++ b/src/fuzz.rs @@ -0,0 +1,19 @@ +use crate::{Compat, DiffMatchPatch, Efficient, Error, PatchInput}; + +pub fn fuzz(old: &str, new: &str) -> Result<(), Error> { + let dmp = DiffMatchPatch::new(); + + let diffs = dmp.diff_main::<Efficient>(old, new)?; + let patches = dmp.patch_make(PatchInput::new_diffs(&diffs))?; + + assert_eq!(new, dmp.patch_apply(&patches, old)?.0); + + let dmp = DiffMatchPatch::new(); + + let diffs = dmp.diff_main::<Compat>(old, new)?; + let patches = dmp.patch_make(PatchInput::new_diffs(&diffs))?; + + assert_eq!(new, dmp.patch_apply(&patches, old)?.0); + + Ok(()) +} |