Commit f6f7537cfd8041d407a4f3b6c350b012975be116

Ben Straub 2013-11-12T15:24:05

Add some failing blame test cases

diff --git a/tests-clar/blame/buffer.c b/tests-clar/blame/buffer.c
index 69b2d54..5da0046 100644
--- a/tests-clar/blame/buffer.c
+++ b/tests-clar/blame/buffer.c
@@ -19,6 +19,8 @@ void test_blame_buffer__cleanup(void)
 
 void test_blame_buffer__added_line(void)
 {
+	git_blame_hunk *hunk;
+
 	const char *buffer = "\
 EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE\n\
 EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE\n\
@@ -39,6 +41,10 @@ CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
 	cl_git_pass(git_blame_buffer(&g_bufferblame, g_fileblame, buffer, strlen(buffer)));
 	cl_assert_equal_i(5, git_blame_get_hunk_count(g_bufferblame));
 	check_blame_hunk_index(g_repo, g_bufferblame, 2, 6, 1, 0, "000000", "b.txt");
+
+	hunk = git_blame_get_hunk_byline(g_bufferblame, 16);
+	cl_assert(hunk);
+	cl_assert_equal_s("Ben Straub", hunk->final_signature->name);
 }
 
 void test_blame_buffer__deleted_line(void)
@@ -128,3 +134,33 @@ CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
 	check_blame_hunk_index(g_repo, g_bufferblame, 3, 7, 1, 0, "00000000", "b.txt");
 	check_blame_hunk_index(g_repo, g_bufferblame, 4, 8, 3, 0, "63d671eb", "b.txt");
 }
+
+void test_blame_buffer__add_line_at_end(void)
+{
+	const char *buffer = "\
+EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE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g_bufferblame, g_fileblame, buffer, strlen(buffer)));
+
+	cl_assert_equal_i(5, git_blame_get_hunk_count(g_bufferblame));
+	check_blame_hunk_index(g_repo, g_bufferblame, 0,  1, 4, 0, "da237394", "b.txt");
+	check_blame_hunk_index(g_repo, g_bufferblame, 1,  5, 1, 1, "b99f7ac0", "b.txt");
+	check_blame_hunk_index(g_repo, g_bufferblame, 2,  6, 5, 0, "63d671eb", "b.txt");
+	check_blame_hunk_index(g_repo, g_bufferblame, 3, 11, 5, 0, "aa06ecca", "b.txt");
+	check_blame_hunk_index(g_repo, g_bufferblame, 4, 16, 1, 0, "00000000", "b.txt");
+
+}