|
| 1 | +#include "clar_libgit2.h" |
| 2 | + |
| 3 | +#include "patch_common.h" |
| 4 | + |
| 5 | +void test_patch_parse__original_to_change_middle(void) |
| 6 | +{ |
| 7 | + git_patch *patch; |
| 8 | + const git_diff_delta *delta; |
| 9 | + char idstr[GIT_OID_HEXSZ+1] = {0}; |
| 10 | + |
| 11 | + cl_git_pass(git_patch_from_patchfile(&patch, PATCH_ORIGINAL_TO_CHANGE_MIDDLE, strlen(PATCH_ORIGINAL_TO_CHANGE_MIDDLE))); |
| 12 | + |
| 13 | + cl_assert((delta = git_patch_get_delta(patch)) != NULL); |
| 14 | + cl_assert_equal_i(2, delta->nfiles); |
| 15 | + |
| 16 | + cl_assert_equal_s(delta->old_file.path, "a/file.txt"); |
| 17 | + cl_assert(delta->old_file.mode == 0100644); |
| 18 | + cl_assert_equal_i(7, delta->old_file.id_abbrev); |
| 19 | + git_oid_nfmt(idstr, delta->old_file.id_abbrev, &delta->old_file.id); |
| 20 | + cl_assert_equal_s(idstr, "9432026"); |
| 21 | + cl_assert_equal_i(0, delta->old_file.size); |
| 22 | + |
| 23 | + cl_assert_equal_s(delta->new_file.path, "b/file.txt"); |
| 24 | + cl_assert(delta->new_file.mode == 0100644); |
| 25 | + cl_assert_equal_i(7, delta->new_file.id_abbrev); |
| 26 | + git_oid_nfmt(idstr, delta->new_file.id_abbrev, &delta->new_file.id); |
| 27 | + cl_assert_equal_s(idstr, "cd8fd12"); |
| 28 | + cl_assert_equal_i(0, delta->new_file.size); |
| 29 | + |
| 30 | + git_patch_free(patch); |
| 31 | +} |
0 commit comments