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:
authorRussell Belfer <rb@github.com>2013-05-09 17:45:06 +0400
committerRussell Belfer <rb@github.com>2013-05-09 17:45:06 +0400
commit3d1c9f612d78c6c235a3f38af226300fb6dd7dd6 (patch)
tree70715be871f0845757c58abe674109d9ec6d0a4d /tests-clar
parent503dd0f3c4f798b02e0173dde7e3631d6e860c42 (diff)
Fix git_repository_message docs
This clarifies the docs for git_repository_message and also adds to the tests to explicitly check NUL termination of data when the output buffer is smaller than the message size. There is a minor behavior change so that a non-NULL output buffer will always be NUL terminated (at length zero) if an error occurs.
Diffstat (limited to 'tests-clar')
-rw-r--r--tests-clar/repo/message.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/tests-clar/repo/message.c b/tests-clar/repo/message.c
index 59487d51b..629d40c12 100644
--- a/tests-clar/repo/message.c
+++ b/tests-clar/repo/message.c
@@ -35,13 +35,18 @@ void test_repo_message__message(void)
len = git_repository_message(NULL, 0, _repo);
cl_assert(len > 0);
+
_actual = git__malloc(len + 1);
cl_assert(_actual != NULL);
+ /* Test non truncation */
cl_assert(git_repository_message(_actual, len, _repo) > 0);
- _actual[len] = '\0';
cl_assert_equal_s(expected, _actual);
+ /* Test truncation and that trailing NUL is inserted */
+ cl_assert(git_repository_message(_actual, 6, _repo) > 0);
+ cl_assert_equal_s("Test\n", _actual);
+
cl_git_pass(p_unlink(git_buf_cstr(&_path)));
cl_assert_equal_i(GIT_ENOTFOUND, git_repository_message(NULL, 0, _repo));
}