]> git.proxmox.com Git - libgit2.git/blob - tests/libgit2/object/shortid.c
New upstream version 1.5.0+ds
[libgit2.git] / tests / libgit2 / object / shortid.c
1 #include "clar_libgit2.h"
2
3 git_repository *_repo;
4
5 void test_object_shortid__initialize(void)
6 {
7 cl_git_pass(git_repository_open(&_repo, cl_fixture("duplicate.git")));
8 }
9
10 void test_object_shortid__cleanup(void)
11 {
12 git_repository_free(_repo);
13 _repo = NULL;
14 }
15
16 void test_object_shortid__select(void)
17 {
18 git_oid full;
19 git_object *obj;
20 git_buf shorty = {0};
21
22 git_oid_fromstr(&full, "ce013625030ba8dba906f756967f9e9ca394464a");
23 cl_git_pass(git_object_lookup(&obj, _repo, &full, GIT_OBJECT_ANY));
24 cl_git_pass(git_object_short_id(&shorty, obj));
25 cl_assert_equal_i(7, shorty.size);
26 cl_assert_equal_s("ce01362", shorty.ptr);
27 git_object_free(obj);
28
29 git_oid_fromstr(&full, "038d718da6a1ebbc6a7780a96ed75a70cc2ad6e2");
30 cl_git_pass(git_object_lookup(&obj, _repo, &full, GIT_OBJECT_ANY));
31 cl_git_pass(git_object_short_id(&shorty, obj));
32 cl_assert_equal_i(7, shorty.size);
33 cl_assert_equal_s("038d718", shorty.ptr);
34 git_object_free(obj);
35
36 git_oid_fromstr(&full, "dea509d097ce692e167dfc6a48a7a280cc5e877e");
37 cl_git_pass(git_object_lookup(&obj, _repo, &full, GIT_OBJECT_ANY));
38 cl_git_pass(git_object_short_id(&shorty, obj));
39 cl_assert_equal_i(9, shorty.size);
40 cl_assert_equal_s("dea509d09", shorty.ptr);
41 git_object_free(obj);
42
43 git_oid_fromstr(&full, "dea509d0b3cb8ee0650f6ca210bc83f4678851ba");
44 cl_git_pass(git_object_lookup(&obj, _repo, &full, GIT_OBJECT_ANY));
45 cl_git_pass(git_object_short_id(&shorty, obj));
46 cl_assert_equal_i(9, shorty.size);
47 cl_assert_equal_s("dea509d0b", shorty.ptr);
48 git_object_free(obj);
49
50 git_buf_dispose(&shorty);
51 }