Skip to content

Commit c0290e2

Browse files
committed
filter: add a crlf blob test
Add a LF->CRLF conversion test to the blob filter.
1 parent 9085819 commit c0290e2

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

tests/filter/blob.c

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,34 @@ void test_filter_blob__all_crlf(void)
4848
git_blob_free(blob);
4949
}
5050

51+
void test_filter_blob__from_lf(void)
52+
{
53+
git_blob *blob;
54+
git_buf buf = { 0 };
55+
56+
cl_git_pass(git_revparse_single(
57+
(git_object **)&blob, g_repo, "799770d")); /* all-lf */
58+
59+
cl_assert_equal_s(ALL_LF_TEXT_RAW, git_blob_rawcontent(blob));
60+
61+
cl_git_pass(git_blob_filtered_content(&buf, blob, "file.bin", 1));
62+
63+
cl_assert_equal_s(ALL_LF_TEXT_RAW, buf.ptr);
64+
65+
cl_git_pass(git_blob_filtered_content(&buf, blob, "file.crlf", 1));
66+
67+
/* in this case, raw content has crlf in it already */
68+
cl_assert_equal_s(ALL_LF_TEXT_AS_CRLF, buf.ptr);
69+
70+
cl_git_pass(git_blob_filtered_content(&buf, blob, "file.lf", 1));
71+
72+
/* we never convert CRLF -> LF on platforms that have LF */
73+
cl_assert_equal_s(ALL_LF_TEXT_AS_LF, buf.ptr);
74+
75+
git_buf_dispose(&buf);
76+
git_blob_free(blob);
77+
}
78+
5179
void test_filter_blob__sanitizes(void)
5280
{
5381
git_blob *blob;

0 commit comments

Comments
 (0)