summaryrefslogtreecommitdiff
path: root/tests-clar/diff
diff options
context:
space:
mode:
Diffstat (limited to 'tests-clar/diff')
-rw-r--r--tests-clar/diff/blob.c31
-rw-r--r--tests-clar/diff/diff_helpers.c1
-rw-r--r--tests-clar/diff/diff_helpers.h1
-rw-r--r--tests-clar/diff/tree.c18
4 files changed, 42 insertions, 9 deletions
diff --git a/tests-clar/diff/blob.c b/tests-clar/diff/blob.c
index 1bcb1f8e7..cceb00d25 100644
--- a/tests-clar/diff/blob.c
+++ b/tests-clar/diff/blob.c
@@ -173,6 +173,37 @@ void test_diff_blob__can_compare_against_null_blobs(void)
cl_assert(exp.lines == 0);
}
+void assert_identical_blobs_comparison(diff_expects exp)
+{
+ cl_assert(exp.files == 1);
+ cl_assert(exp.file_unmodified == 1);
+ cl_assert(exp.hunks == 0);
+ cl_assert(exp.lines == 0);
+}
+
+void test_diff_blob__can_compare_identical_blobs(void)
+{
+ cl_git_pass(git_diff_blobs(
+ d, d, &opts, &exp, diff_file_fn, diff_hunk_fn, diff_line_fn));
+
+ cl_assert(exp.at_least_one_of_them_is_binary == false);
+ assert_identical_blobs_comparison(exp);
+
+ memset(&exp, 0, sizeof(exp));
+ cl_git_pass(git_diff_blobs(
+ NULL, NULL, &opts, &exp, diff_file_fn, diff_hunk_fn, diff_line_fn));
+
+ cl_assert(exp.at_least_one_of_them_is_binary == false);
+ assert_identical_blobs_comparison(exp);
+
+ memset(&exp, 0, sizeof(exp));
+ cl_git_pass(git_diff_blobs(
+ alien, alien, &opts, &exp, diff_file_fn, diff_hunk_fn, diff_line_fn));
+
+ cl_assert(exp.at_least_one_of_them_is_binary == true);
+ assert_identical_blobs_comparison(exp);
+}
+
void assert_binary_blobs_comparison(diff_expects exp)
{
cl_assert(exp.at_least_one_of_them_is_binary == true);
diff --git a/tests-clar/diff/diff_helpers.c b/tests-clar/diff/diff_helpers.c
index b12d88868..8587be9b1 100644
--- a/tests-clar/diff/diff_helpers.c
+++ b/tests-clar/diff/diff_helpers.c
@@ -39,6 +39,7 @@ int diff_file_fn(
case GIT_DELTA_MODIFIED: e->file_mods++; break;
case GIT_DELTA_IGNORED: e->file_ignored++; break;
case GIT_DELTA_UNTRACKED: e->file_untracked++; break;
+ case GIT_DELTA_UNMODIFIED: e->file_unmodified++; break;
default: break;
}
return 0;
diff --git a/tests-clar/diff/diff_helpers.h b/tests-clar/diff/diff_helpers.h
index 994af0f76..0aaa6c111 100644
--- a/tests-clar/diff/diff_helpers.h
+++ b/tests-clar/diff/diff_helpers.h
@@ -11,6 +11,7 @@ typedef struct {
int file_mods;
int file_ignored;
int file_untracked;
+ int file_unmodified;
int hunks;
int hunk_new_lines;
diff --git a/tests-clar/diff/tree.c b/tests-clar/diff/tree.c
index 06f51a16b..b932fa10e 100644
--- a/tests-clar/diff/tree.c
+++ b/tests-clar/diff/tree.c
@@ -113,16 +113,16 @@ void test_diff_tree__options(void)
*/
diff_expects test_expects[] = {
/* a vs b tests */
- { 5, 3, 0, 2, 0, 0, 4, 0, 0, 51, 2, 46, 3 },
- { 5, 3, 0, 2, 0, 0, 4, 0, 0, 53, 4, 46, 3 },
- { 5, 0, 3, 2, 0, 0, 4, 0, 0, 52, 3, 3, 46 },
- { 5, 3, 0, 2, 0, 0, 5, 0, 0, 54, 3, 48, 3 },
+ { 5, 3, 0, 2, 0, 0, 0, 4, 0, 0, 51, 2, 46, 3 },
+ { 5, 3, 0, 2, 0, 0, 0, 4, 0, 0, 53, 4, 46, 3 },
+ { 5, 0, 3, 2, 0, 0, 0, 4, 0, 0, 52, 3, 3, 46 },
+ { 5, 3, 0, 2, 0, 0, 0, 5, 0, 0, 54, 3, 48, 3 },
/* c vs d tests */
- { 1, 0, 0, 1, 0, 0, 1, 0, 0, 22, 9, 10, 3 },
- { 1, 0, 0, 1, 0, 0, 1, 0, 0, 19, 12, 7, 0 },
- { 1, 0, 0, 1, 0, 0, 1, 0, 0, 20, 11, 8, 1 },
- { 1, 0, 0, 1, 0, 0, 1, 0, 0, 20, 11, 8, 1 },
- { 1, 0, 0, 1, 0, 0, 1, 0, 0, 18, 11, 0, 7 },
+ { 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 22, 9, 10, 3 },
+ { 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 19, 12, 7, 0 },
+ { 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 20, 11, 8, 1 },
+ { 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 20, 11, 8, 1 },
+ { 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 18, 11, 0, 7 },
{ 0 },
};
diff_expects *expected;