Something went wrong. Try again.
BSDIFF40 binary diff and patch in pure OCaml
Something went wrong. Try again.
1234567891011121314151617181920212223242526272829303132333435363738(** bsdiff interop test for ocaml-bsdiff.
[traces/patch.bsdiff] was produced by the reference [bsdiff] tool (the oracle version is recorded in [traces/bsdiff-version.txt]) from the committed [source.bin] and [target.bin]; our [apply] must reconstruct the target exactly. The other direction -- the reference [bspatch] applying our patches -- needs the tools at run time and lives in [bench/check_tools.ml]. Regenerate the traces with [REGEN=1 dune build @regen]. *)
let trace path = Filename.concat "traces" path
let read path = let ic = open_in_bin path in let n = in_channel_length ic in let data = really_input_string ic n in close_in ic; data
let test_apply_reference_patch () = let source = read (trace "source.bin") in let target = read (trace "target.bin") in let patch = read (trace "patch.bsdiff") in match Bsdiff.apply ~source patch with | Ok t -> Alcotest.(check string) "reconstructed target" target t | Error e -> Alcotest.failf "apply of reference patch failed: %s" (Loc.Error.to_string e)
let () = Alcotest.run "bsdiff-interop" [ ( "bsdiff", [ Alcotest.test_case "apply reference patch" `Quick test_apply_reference_patch; ] ); ]