diff options
author | Vicent Martà <vicent@github.com> | 2013-05-24 12:13:48 +0400 |
---|---|---|
committer | Vicent Martà <vicent@github.com> | 2013-05-24 12:13:48 +0400 |
commit | 30caf0cf2942412981b7662e50a2e9242afa2cce (patch) | |
tree | cbfb8e0a543dbce5f11230dad85e8309bf90037c /tests-clar/object | |
parent | 87a56fe015d263e592242157fa6c88badf46fa18 (diff) | |
parent | 49f70f2c370e649c3a0970b6aadd6f5cdf4f2701 (diff) |
Merge pull request #1595 from arrbee/even-more-rename-fixes
Even more rename detection fixes
Diffstat (limited to 'tests-clar/object')
-rw-r--r-- | tests-clar/object/raw/convert.c | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/tests-clar/object/raw/convert.c b/tests-clar/object/raw/convert.c index 74442c153..88b1380a4 100644 --- a/tests-clar/object/raw/convert.c +++ b/tests-clar/object/raw/convert.c @@ -73,3 +73,40 @@ void test_object_raw_convert__succeed_on_oid_to_string_conversion_big(void) cl_assert(str && str == big && *(str+GIT_OID_HEXSZ+2) == 'Y'); cl_assert(str && str == big && *(str+GIT_OID_HEXSZ+3) == 'Z'); } + +static void check_partial_oid( + char *buffer, size_t count, const git_oid *oid, const char *expected) +{ + git_oid_nfmt(buffer, count, oid); + buffer[count] = '\0'; + cl_assert_equal_s(expected, buffer); +} + +void test_object_raw_convert__convert_oid_partially(void) +{ + const char *exp = "16a0123456789abcdef4b775213c23a8bd74f5e0"; + git_oid in; + char big[GIT_OID_HEXSZ + 1 + 3]; /* note + 4 => big buffer */ + + cl_git_pass(git_oid_fromstr(&in, exp)); + + git_oid_nfmt(big, sizeof(big), &in); + cl_assert_equal_s(exp, big); + + git_oid_nfmt(big, GIT_OID_HEXSZ + 1, &in); + cl_assert_equal_s(exp, big); + + check_partial_oid(big, 1, &in, "1"); + check_partial_oid(big, 2, &in, "16"); + check_partial_oid(big, 3, &in, "16a"); + check_partial_oid(big, 4, &in, "16a0"); + check_partial_oid(big, 5, &in, "16a01"); + + check_partial_oid(big, GIT_OID_HEXSZ, &in, exp); + check_partial_oid( + big, GIT_OID_HEXSZ - 1, &in, "16a0123456789abcdef4b775213c23a8bd74f5e"); + check_partial_oid( + big, GIT_OID_HEXSZ - 2, &in, "16a0123456789abcdef4b775213c23a8bd74f5"); + check_partial_oid( + big, GIT_OID_HEXSZ - 3, &in, "16a0123456789abcdef4b775213c23a8bd74f"); +} |