summaryrefslogtreecommitdiff
path: root/tests/filter
diff options
context:
space:
mode:
authorEdward Thomson <ethomson@microsoft.com>2014-01-08 10:07:30 -0800
committerEdward Thomson <ethomson@microsoft.com>2014-01-08 10:08:23 -0800
commit6adcaab70cdd6ced307a71945a1f80833ec9670f (patch)
tree4d10a5a2d7aa1cc16299c1bbcb006b371f8f8129 /tests/filter
parent32309b5d82d95402852cfcd478abec5d116eba86 (diff)
downloadlibgit2-6adcaab70cdd6ced307a71945a1f80833ec9670f.tar.gz
Handle git_buf's from users more liberally
Diffstat (limited to 'tests/filter')
-rw-r--r--tests/filter/blob.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/tests/filter/blob.c b/tests/filter/blob.c
index 9600a9779..8dce6470a 100644
--- a/tests/filter/blob.c
+++ b/tests/filter/blob.c
@@ -47,6 +47,38 @@ void test_filter_blob__all_crlf(void)
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;