diff options
Diffstat (limited to 'tests/filter/blob.c')
-rw-r--r-- | tests/filter/blob.c | 35 |
1 files changed, 34 insertions, 1 deletions
diff --git a/tests/filter/blob.c b/tests/filter/blob.c index 9600a9779..48edb8405 100644 --- a/tests/filter/blob.c +++ b/tests/filter/blob.c @@ -41,12 +41,45 @@ void test_filter_blob__all_crlf(void) cl_git_pass(git_blob_filtered_content(&buf, blob, "file.lf", 1)); - cl_assert_equal_s(ALL_CRLF_TEXT_AS_LF, buf.ptr); + /* we never convert CRLF -> LF on platforms that have LF */ + cl_assert_equal_s(ALL_CRLF_TEXT_AS_CRLF, buf.ptr); git_buf_free(&buf); git_blob_free(blob); } +void test_filter_blob__sanitizes(void) +{ + git_blob *blob; + git_buf buf; + + cl_git_pass(git_revparse_single( + (git_object **)&blob, g_repo, "e69de29")); /* zero-byte */ + + cl_assert_equal_i(0, git_blob_rawsize(blob)); + cl_assert_equal_s("", git_blob_rawcontent(blob)); + + memset(&buf, 0, sizeof(git_buf)); + cl_git_pass(git_blob_filtered_content(&buf, blob, "file.bin", 1)); + cl_assert_equal_sz(0, buf.size); + cl_assert_equal_s("", buf.ptr); + git_buf_free(&buf); + + memset(&buf, 0, sizeof(git_buf)); + cl_git_pass(git_blob_filtered_content(&buf, blob, "file.crlf", 1)); + cl_assert_equal_sz(0, buf.size); + cl_assert_equal_s("", buf.ptr); + git_buf_free(&buf); + + memset(&buf, 0, sizeof(git_buf)); + cl_git_pass(git_blob_filtered_content(&buf, blob, "file.lf", 1)); + cl_assert_equal_sz(0, buf.size); + cl_assert_equal_s("", buf.ptr); + git_buf_free(&buf); + + git_blob_free(blob); +} + void test_filter_blob__ident(void) { git_oid id; |