diff options
author | Edward Thomson <ethomson@microsoft.com> | 2015-09-22 18:54:10 -0400 |
---|---|---|
committer | Edward Thomson <ethomson@github.com> | 2016-05-26 13:01:05 -0500 |
commit | 42b3442823c45e83ce8eb67607e1b90c3ea7f3af (patch) | |
tree | 459ff2ce0f64e182079540e406f5efa2ee80f181 /tests/patch/parse.c | |
parent | bc6a31c9fbc3fc48d6a44bb752afd43fcb60ebef (diff) | |
download | libgit2-42b3442823c45e83ce8eb67607e1b90c3ea7f3af.tar.gz |
patch_parse: ensure we can parse a patch
Diffstat (limited to 'tests/patch/parse.c')
-rw-r--r-- | tests/patch/parse.c | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/tests/patch/parse.c b/tests/patch/parse.c new file mode 100644 index 000000000..3191c8c3f --- /dev/null +++ b/tests/patch/parse.c @@ -0,0 +1,31 @@ +#include "clar_libgit2.h" + +#include "patch_common.h" + +void test_patch_parse__original_to_change_middle(void) +{ + git_patch *patch; + const git_diff_delta *delta; + char idstr[GIT_OID_HEXSZ+1] = {0}; + + cl_git_pass(git_patch_from_patchfile(&patch, PATCH_ORIGINAL_TO_CHANGE_MIDDLE, strlen(PATCH_ORIGINAL_TO_CHANGE_MIDDLE))); + + cl_assert((delta = git_patch_get_delta(patch)) != NULL); + cl_assert_equal_i(2, delta->nfiles); + + cl_assert_equal_s(delta->old_file.path, "a/file.txt"); + cl_assert(delta->old_file.mode == GIT_FILEMODE_BLOB); + cl_assert_equal_i(7, delta->old_file.id_abbrev); + git_oid_nfmt(idstr, delta->old_file.id_abbrev, &delta->old_file.id); + cl_assert_equal_s(idstr, "9432026"); + cl_assert_equal_i(0, delta->old_file.size); + + cl_assert_equal_s(delta->new_file.path, "b/file.txt"); + cl_assert(delta->new_file.mode == GIT_FILEMODE_BLOB); + cl_assert_equal_i(7, delta->new_file.id_abbrev); + git_oid_nfmt(idstr, delta->new_file.id_abbrev, &delta->new_file.id); + cl_assert_equal_s(idstr, "cd8fd12"); + cl_assert_equal_i(0, delta->new_file.size); + + git_patch_free(patch); +} |