]> git.proxmox.com Git - libgit2.git/commitdiff
binary diff: test that the diff and patch otputs are the same
authorCarlos Martín Nieto <cmn@dwim.me>
Wed, 24 Jun 2015 12:25:36 +0000 (14:25 +0200)
committerCarlos Martín Nieto <cmn@dwim.me>
Wed, 24 Jun 2015 12:33:02 +0000 (14:33 +0200)
We test the generation of the textual patch via the patch function,
which are just one of two possibilities to get the output.

Add a second patch generation via the diff function to make sure both
outputs are in sync.

tests/diff/binary.c

index 424a53e5f098a74718dc77c0e20cf3ededd7f29e..90f2d5a061c136bf9c6b422fbb1948b2b02604d6 100644 (file)
@@ -1,5 +1,7 @@
 #include "clar_libgit2.h"
 
+#include "git2/sys/diff.h"
+
 #include "buffer.h"
 #include "filebuf.h"
 
@@ -49,6 +51,11 @@ void test_patch(
 
        cl_assert_equal_s(expected, actual.ptr);
 
+       git_buf_clear(&actual);
+       cl_git_pass(git_diff_print(diff, GIT_DIFF_FORMAT_PATCH, git_diff_print_callback__to_buf, &actual));
+
+       cl_assert_equal_s(expected, actual.ptr);
+
        git_buf_free(&actual);
        git_patch_free(patch);
        git_diff_free(diff);