diff options
| author | Sun He <sunheehnus@gmail.com> | 2014-03-06 11:16:36 +0800 |
|---|---|---|
| committer | Sun He <sunheehnus@gmail.com> | 2014-03-06 11:16:36 +0800 |
| commit | 6246de93b65fc74cba2e17ab031402adff84433f (patch) | |
| tree | 676fbb35641726736b0cc8053f73ec9f1ed03d0e /tests/object/shortid.c | |
| parent | 8384a50a2171f57cc1b8158777b124d2022db94e (diff) | |
| parent | a064dc2d0b6206116a35be4b62c58c3c1170d5de (diff) | |
| download | libgit2-6246de93b65fc74cba2e17ab031402adff84433f.tar.gz | |
Merge completed: resolve the conflict with the upstream
Diffstat (limited to 'tests/object/shortid.c')
| -rw-r--r-- | tests/object/shortid.c | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/tests/object/shortid.c b/tests/object/shortid.c new file mode 100644 index 000000000..fa1dac09a --- /dev/null +++ b/tests/object/shortid.c @@ -0,0 +1,44 @@ +#include "clar_libgit2.h" + +git_repository *_repo; + +void test_object_shortid__initialize(void) +{ + cl_git_pass(git_repository_open(&_repo, cl_fixture("duplicate.git"))); +} + +void test_object_shortid__cleanup(void) +{ + git_repository_free(_repo); + _repo = NULL; +} + +void test_object_shortid__select(void) +{ + git_oid full; + git_object *obj; + git_buf shorty = {0}; + + git_oid_fromstr(&full, "ce013625030ba8dba906f756967f9e9ca394464a"); + cl_git_pass(git_object_lookup(&obj, _repo, &full, GIT_OBJ_ANY)); + cl_git_pass(git_object_short_id(&shorty, obj)); + cl_assert_equal_i(7, shorty.size); + cl_assert_equal_s("ce01362", shorty.ptr); + git_object_free(obj); + + git_oid_fromstr(&full, "dea509d097ce692e167dfc6a48a7a280cc5e877e"); + cl_git_pass(git_object_lookup(&obj, _repo, &full, GIT_OBJ_ANY)); + cl_git_pass(git_object_short_id(&shorty, obj)); + cl_assert_equal_i(9, shorty.size); + cl_assert_equal_s("dea509d09", shorty.ptr); + git_object_free(obj); + + git_oid_fromstr(&full, "dea509d0b3cb8ee0650f6ca210bc83f4678851ba"); + cl_git_pass(git_object_lookup(&obj, _repo, &full, GIT_OBJ_ANY)); + cl_git_pass(git_object_short_id(&shorty, obj)); + cl_assert_equal_i(9, shorty.size); + cl_assert_equal_s("dea509d0b", shorty.ptr); + git_object_free(obj); + + git_buf_free(&shorty); +} |
