summaryrefslogtreecommitdiff
path: root/tests/diff
diff options
context:
space:
mode:
authorEdward Thomson <ethomson@github.com>2016-10-09 16:05:48 +0100
committerEdward Thomson <ethomson@github.com>2016-10-09 16:05:48 +0100
commit610cff13a31964eeb2264a452424e1e3d49accc3 (patch)
treeb8066e39eb0048097f03c68174364be01611a85a /tests/diff
parent2468bf0615a581e67c69bd47b6862eabb1940e5e (diff)
parentdc5cfdbab957a08f3ddda9889f68c81011eb1900 (diff)
downloadlibgit2-610cff13a31964eeb2264a452424e1e3d49accc3.tar.gz
Merge branch 'pr/3809'
Diffstat (limited to 'tests/diff')
-rw-r--r--tests/diff/format_email.c4
-rw-r--r--tests/diff/stats.c36
2 files changed, 38 insertions, 2 deletions
diff --git a/tests/diff/format_email.c b/tests/diff/format_email.c
index 9f8fe3142..c3c04107b 100644
--- a/tests/diff/format_email.c
+++ b/tests/diff/format_email.c
@@ -113,7 +113,7 @@ void test_diff_format_email__with_message(void)
"Also test if new paragraphs are included correctly.\n" \
"---\n" \
" file3.txt | 1 +\n" \
- " 1 file changed, 1 insertion(+), 0 deletions(-)\n" \
+ " 1 file changed, 1 insertion(+)\n" \
"\n" \
"diff --git a/file3.txt b/file3.txt\n" \
"index 9a2d780..7309653 100644\n" \
@@ -156,7 +156,7 @@ void test_diff_format_email__multiple(void)
"---\n" \
" file2.txt | 5 +++++\n" \
" file3.txt | 5 +++++\n" \
- " 2 files changed, 10 insertions(+), 0 deletions(-)\n" \
+ " 2 files changed, 10 insertions(+)\n" \
" create mode 100644 file2.txt\n" \
" create mode 100644 file3.txt\n" \
"\n" \
diff --git a/tests/diff/stats.c b/tests/diff/stats.c
index 8f146e2a4..3171a4486 100644
--- a/tests/diff/stats.c
+++ b/tests/diff/stats.c
@@ -114,6 +114,42 @@ void test_diff_stats__shortstat(void)
git_buf_free(&buf);
}
+void test_diff_stats__shortstat_noinsertions(void)
+{
+ git_buf buf = GIT_BUF_INIT;
+ const char *stat =
+ " 1 file changed, 2 deletions(-)\n";
+
+ diff_stats_from_commit_oid(
+ &_stats, "06b7b69a62cbd1e53c6c4e0c3f16473dcfdb4af6", false);
+
+ cl_assert_equal_sz(1, git_diff_stats_files_changed(_stats));
+ cl_assert_equal_sz(0, git_diff_stats_insertions(_stats));
+ cl_assert_equal_sz(2, git_diff_stats_deletions(_stats));
+
+ cl_git_pass(git_diff_stats_to_buf(&buf, _stats, GIT_DIFF_STATS_SHORT, 0));
+ cl_assert_equal_s(stat, git_buf_cstr(&buf));
+ git_buf_free(&buf);
+}
+
+void test_diff_stats__shortstat_nodeletions(void)
+{
+ git_buf buf = GIT_BUF_INIT;
+ const char *stat =
+ " 1 file changed, 3 insertions(+)\n";
+
+ diff_stats_from_commit_oid(
+ &_stats, "5219b9784f9a92d7bd7cb567a6d6a21bfb86697e", false);
+
+ cl_assert_equal_sz(1, git_diff_stats_files_changed(_stats));
+ cl_assert_equal_sz(3, git_diff_stats_insertions(_stats));
+ cl_assert_equal_sz(0, git_diff_stats_deletions(_stats));
+
+ cl_git_pass(git_diff_stats_to_buf(&buf, _stats, GIT_DIFF_STATS_SHORT, 0));
+ cl_assert_equal_s(stat, git_buf_cstr(&buf));
+ git_buf_free(&buf);
+}
+
void test_diff_stats__rename(void)
{
git_buf buf = GIT_BUF_INIT;