Commit 65d12df5 by nulltoken

message: reorganize tests

parent 8bba3c95
......@@ -128,68 +128,3 @@ void test_object_commit_commitstagedfile__generate_predictable_object_ids(void)
git_tree_free(tree);
git_index_free(index);
}
void test_object_commit_commitstagedfile__message_prettify(void)
{
char buffer[100];
cl_assert(git_message_prettify(buffer, sizeof(buffer), "", 0) == 1);
cl_assert_equal_s(buffer, "");
cl_assert(git_message_prettify(buffer, sizeof(buffer), "", 1) == 1);
cl_assert_equal_s(buffer, "");
cl_assert_equal_i(7, git_message_prettify(buffer, sizeof(buffer), "Short", 0));
cl_assert_equal_s("Short\n", buffer);
cl_assert_equal_i(7, git_message_prettify(buffer, sizeof(buffer), "Short", 1));
cl_assert_equal_s("Short\n", buffer);
cl_assert(git_message_prettify(buffer, sizeof(buffer), "This is longer\nAnd multiline\n# with some comments still in\n", 0) > 0);
cl_assert_equal_s(buffer, "This is longer\nAnd multiline\n# with some comments still in\n");
cl_assert(git_message_prettify(buffer, sizeof(buffer), "This is longer\nAnd multiline\n# with some comments still in\n", 1) > 0);
cl_assert_equal_s(buffer, "This is longer\nAnd multiline\n");
/* try out overflow */
cl_assert(git_message_prettify(buffer, sizeof(buffer),
"1234567890" "1234567890" "1234567890" "1234567890" "1234567890"
"1234567890" "1234567890" "1234567890" "1234567890" "12345678",
0) > 0);
cl_assert_equal_s(buffer,
"1234567890" "1234567890" "1234567890" "1234567890" "1234567890"
"1234567890" "1234567890" "1234567890" "1234567890" "12345678\n");
cl_assert(git_message_prettify(buffer, sizeof(buffer),
"1234567890" "1234567890" "1234567890" "1234567890" "1234567890"
"1234567890" "1234567890" "1234567890" "1234567890" "12345678\n",
0) > 0);
cl_assert_equal_s(buffer,
"1234567890" "1234567890" "1234567890" "1234567890" "1234567890"
"1234567890" "1234567890" "1234567890" "1234567890" "12345678\n");
cl_git_fail(git_message_prettify(buffer, sizeof(buffer),
"1234567890" "1234567890" "1234567890" "1234567890" "1234567890"
"1234567890" "1234567890" "1234567890" "1234567890" "123456789",
0));
cl_git_fail(git_message_prettify(buffer, sizeof(buffer),
"1234567890" "1234567890" "1234567890" "1234567890" "1234567890"
"1234567890" "1234567890" "1234567890" "1234567890" "123456789\n",
0));
cl_git_fail(git_message_prettify(buffer, sizeof(buffer),
"1234567890" "1234567890" "1234567890" "1234567890" "1234567890"
"1234567890" "1234567890" "1234567890" "1234567890" "1234567890",
0));
cl_git_fail(git_message_prettify(buffer, sizeof(buffer),
"1234567890" "1234567890" "1234567890" "1234567890" "1234567890"
"1234567890" "1234567890" "1234567890" "1234567890" "1234567890""x",
0));
cl_assert(git_message_prettify(buffer, sizeof(buffer),
"1234567890" "1234567890" "1234567890" "1234567890" "1234567890\n"
"# 1234567890" "1234567890" "1234567890" "1234567890" "1234567890\n"
"1234567890",
1) > 0);
cl_assert(git_message_prettify(NULL, 0, "", 0) == 1);
cl_assert(git_message_prettify(NULL, 0, "Short test", 0) == 12);
cl_assert(git_message_prettify(NULL, 0, "Test\n# with\nComments", 1) == 15);
}
......@@ -169,3 +169,68 @@ void test_object_message__keep_comments(void)
assert_message_prettifying("# comment\n" ttt "\n", "# comment\n" ttt "\n", 0);
assert_message_prettifying(ttt "\n" "# comment\n" ttt "\n", ttt "\n" "# comment\n" ttt "\n", 0);
}
void test_object_message__message_prettify(void)
{
char buffer[100];
cl_assert(git_message_prettify(buffer, sizeof(buffer), "", 0) == 1);
cl_assert_equal_s(buffer, "");
cl_assert(git_message_prettify(buffer, sizeof(buffer), "", 1) == 1);
cl_assert_equal_s(buffer, "");
cl_assert_equal_i(7, git_message_prettify(buffer, sizeof(buffer), "Short", 0));
cl_assert_equal_s("Short\n", buffer);
cl_assert_equal_i(7, git_message_prettify(buffer, sizeof(buffer), "Short", 1));
cl_assert_equal_s("Short\n", buffer);
cl_assert(git_message_prettify(buffer, sizeof(buffer), "This is longer\nAnd multiline\n# with some comments still in\n", 0) > 0);
cl_assert_equal_s(buffer, "This is longer\nAnd multiline\n# with some comments still in\n");
cl_assert(git_message_prettify(buffer, sizeof(buffer), "This is longer\nAnd multiline\n# with some comments still in\n", 1) > 0);
cl_assert_equal_s(buffer, "This is longer\nAnd multiline\n");
/* try out overflow */
cl_assert(git_message_prettify(buffer, sizeof(buffer),
"1234567890" "1234567890" "1234567890" "1234567890" "1234567890"
"1234567890" "1234567890" "1234567890" "1234567890" "12345678",
0) > 0);
cl_assert_equal_s(buffer,
"1234567890" "1234567890" "1234567890" "1234567890" "1234567890"
"1234567890" "1234567890" "1234567890" "1234567890" "12345678\n");
cl_assert(git_message_prettify(buffer, sizeof(buffer),
"1234567890" "1234567890" "1234567890" "1234567890" "1234567890"
"1234567890" "1234567890" "1234567890" "1234567890" "12345678\n",
0) > 0);
cl_assert_equal_s(buffer,
"1234567890" "1234567890" "1234567890" "1234567890" "1234567890"
"1234567890" "1234567890" "1234567890" "1234567890" "12345678\n");
cl_git_fail(git_message_prettify(buffer, sizeof(buffer),
"1234567890" "1234567890" "1234567890" "1234567890" "1234567890"
"1234567890" "1234567890" "1234567890" "1234567890" "123456789",
0));
cl_git_fail(git_message_prettify(buffer, sizeof(buffer),
"1234567890" "1234567890" "1234567890" "1234567890" "1234567890"
"1234567890" "1234567890" "1234567890" "1234567890" "123456789\n",
0));
cl_git_fail(git_message_prettify(buffer, sizeof(buffer),
"1234567890" "1234567890" "1234567890" "1234567890" "1234567890"
"1234567890" "1234567890" "1234567890" "1234567890" "1234567890",
0));
cl_git_fail(git_message_prettify(buffer, sizeof(buffer),
"1234567890" "1234567890" "1234567890" "1234567890" "1234567890"
"1234567890" "1234567890" "1234567890" "1234567890" "1234567890""x",
0));
cl_assert(git_message_prettify(buffer, sizeof(buffer),
"1234567890" "1234567890" "1234567890" "1234567890" "1234567890\n"
"# 1234567890" "1234567890" "1234567890" "1234567890" "1234567890\n"
"1234567890",
1) > 0);
cl_assert(git_message_prettify(NULL, 0, "", 0) == 1);
cl_assert(git_message_prettify(NULL, 0, "Short test", 0) == 12);
cl_assert(git_message_prettify(NULL, 0, "Test\n# with\nComments", 1) == 15);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment