diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/patch/parse.c | 14 | ||||
-rw-r--r-- | tests/patch/patch_common.h | 10 |
2 files changed, 24 insertions, 0 deletions
diff --git a/tests/patch/parse.c b/tests/patch/parse.c index a40ad7b23..8c29e311a 100644 --- a/tests/patch/parse.c +++ b/tests/patch/parse.c @@ -102,6 +102,20 @@ void test_patch_parse__invalid_patches_fails(void) strlen(PATCH_CORRUPT_MISSING_HUNK_HEADER), NULL)); } +void test_patch_parse__no_newline_at_end_of_new_file(void) +{ + git_patch *patch; + cl_git_pass(git_patch_from_buffer(&patch, PATCH_APPEND_NO_NL, strlen(PATCH_APPEND_NO_NL), NULL)); + git_patch_free(patch); +} + +void test_patch_parse__no_newline_at_end_of_old_file(void) +{ + git_patch *patch; + cl_git_pass(git_patch_from_buffer(&patch, PATCH_APPEND_NO_NL_IN_OLD_FILE, strlen(PATCH_APPEND_NO_NL_IN_OLD_FILE), NULL)); + git_patch_free(patch); +} + void test_patch_parse__files_with_whitespaces_succeeds(void) { git_patch *patch; diff --git a/tests/patch/patch_common.h b/tests/patch/patch_common.h index 291ece9eb..2db8d933f 100644 --- a/tests/patch/patch_common.h +++ b/tests/patch/patch_common.h @@ -681,6 +681,16 @@ "+added line with no nl\n" \ "\\ No newline at end of file\n" +#define PATCH_APPEND_NO_NL_IN_OLD_FILE \ + "diff --git a/file.txt b/file.txt\n" \ + "index 9432026..83759c0 100644\n" \ + "--- a/file.txt\n" \ + "+++ b/file.txt\n" \ + "@@ -1,1 +1,1 @@\n" \ + "-foo\n" \ + "\\ No newline at end of file\n" \ + "+foo\n" + #define PATCH_NAME_WHITESPACE \ "diff --git a/file with spaces.txt b/file with spaces.txt\n" \ "index 9432026..83759c0 100644\n" \ |