Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/libgit2.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'tests/commit/commit.c')
-rw-r--r--tests/commit/commit.c37
1 files changed, 37 insertions, 0 deletions
diff --git a/tests/commit/commit.c b/tests/commit/commit.c
index 8f071ff94..fa181b703 100644
--- a/tests/commit/commit.c
+++ b/tests/commit/commit.c
@@ -1,4 +1,6 @@
#include "clar_libgit2.h"
+#include "commit.h"
+#include "git2/commit.h"
static git_repository *_repo;
@@ -36,6 +38,10 @@ void test_commit_commit__create_unexisting_update_ref(void)
cl_git_pass(git_commit_create(&oid, _repo, "refs/heads/foo/bar", s, s,
NULL, "some msg", tree, 1, (const git_commit **) &commit));
+ /* fail because the parent isn't the tip of the branch anymore */
+ cl_git_fail(git_commit_create(&oid, _repo, "refs/heads/foo/bar", s, s,
+ NULL, "some msg", tree, 1, (const git_commit **) &commit));
+
cl_git_pass(git_reference_lookup(&ref, _repo, "refs/heads/foo/bar"));
cl_assert(!git_oid_cmp(&oid, git_reference_target(ref)));
@@ -44,3 +50,34 @@ void test_commit_commit__create_unexisting_update_ref(void)
git_signature_free(s);
git_reference_free(ref);
}
+
+void assert_commit_summary(const char *expected, const char *given)
+{
+ git_commit *dummy;
+
+ cl_assert(dummy = git__calloc(1, sizeof(struct git_commit)));
+
+ dummy->raw_message = git__strdup(given);
+ cl_assert_equal_s(expected, git_commit_summary(dummy));
+
+ git_commit__free(dummy);
+}
+
+void test_commit_commit__summary(void)
+{
+ assert_commit_summary("One-liner with no trailing newline", "One-liner with no trailing newline");
+ assert_commit_summary("One-liner with trailing newline", "One-liner with trailing newline\n");
+ assert_commit_summary("Trimmed leading&trailing newlines", "\n\nTrimmed leading&trailing newlines\n\n");
+ assert_commit_summary("First paragraph only", "\nFirst paragraph only\n\n(There are more!)");
+ assert_commit_summary("First paragraph with unwrapped trailing\tlines", "\nFirst paragraph\nwith unwrapped\ntrailing\tlines\n\n(Yes, unwrapped!)");
+ assert_commit_summary("\tLeading \ttabs", "\tLeading\n\ttabs\n\nis preserved");
+ assert_commit_summary(" Leading Spaces", " Leading\n Spaces\n\nare preserved");
+ assert_commit_summary("Trailing tabs\tare removed", "Trailing tabs\tare removed\t\t");
+ assert_commit_summary("Trailing spaces are removed", "Trailing spaces are removed ");
+ assert_commit_summary("Trailing tabs", "Trailing tabs\t\n\nare removed");
+ assert_commit_summary("Trailing spaces", "Trailing spaces \n\nare removed");
+ assert_commit_summary("", "");
+ assert_commit_summary("", " ");
+ assert_commit_summary("", "\n");
+ assert_commit_summary("", "\n \n");
+}