diff options
author | Edward Thomson <ethomson@edwardthomson.com> | 2019-06-23 23:52:52 +0100 |
---|---|---|
committer | Edward Thomson <ethomson@edwardthomson.com> | 2019-07-21 14:18:21 +0100 |
commit | c0290e27cc61b8110f1d5565ac4c1eb276217015 (patch) | |
tree | 09b39002b3edf5afb28674a186a7847c359eb843 | |
parent | 9085819232934bc9b666d4669957ac0ab0398ec6 (diff) | |
download | libgit2-c0290e27cc61b8110f1d5565ac4c1eb276217015.tar.gz |
filter: add a crlf blob test
Add a LF->CRLF conversion test to the blob filter.
-rw-r--r-- | tests/filter/blob.c | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/tests/filter/blob.c b/tests/filter/blob.c index 22f350325..ff8ac1e24 100644 --- a/tests/filter/blob.c +++ b/tests/filter/blob.c @@ -48,6 +48,34 @@ void test_filter_blob__all_crlf(void) git_blob_free(blob); } +void test_filter_blob__from_lf(void) +{ + git_blob *blob; + git_buf buf = { 0 }; + + cl_git_pass(git_revparse_single( + (git_object **)&blob, g_repo, "799770d")); /* all-lf */ + + cl_assert_equal_s(ALL_LF_TEXT_RAW, git_blob_rawcontent(blob)); + + cl_git_pass(git_blob_filtered_content(&buf, blob, "file.bin", 1)); + + cl_assert_equal_s(ALL_LF_TEXT_RAW, buf.ptr); + + cl_git_pass(git_blob_filtered_content(&buf, blob, "file.crlf", 1)); + + /* in this case, raw content has crlf in it already */ + cl_assert_equal_s(ALL_LF_TEXT_AS_CRLF, buf.ptr); + + cl_git_pass(git_blob_filtered_content(&buf, blob, "file.lf", 1)); + + /* we never convert CRLF -> LF on platforms that have LF */ + cl_assert_equal_s(ALL_LF_TEXT_AS_LF, buf.ptr); + + git_buf_dispose(&buf); + git_blob_free(blob); +} + void test_filter_blob__sanitizes(void) { git_blob *blob; |