]> git.proxmox.com Git - libgit2.git/blame - tests/object/shortid.c
New upstream version 1.4.3+dfsg.1
[libgit2.git] / tests / object / shortid.c
CommitLineData
13f7ecd7
RB
1#include "clar_libgit2.h"
2
3git_repository *_repo;
4
5void test_object_shortid__initialize(void)
6{
7 cl_git_pass(git_repository_open(&_repo, cl_fixture("duplicate.git")));
8}
9
10void test_object_shortid__cleanup(void)
11{
12 git_repository_free(_repo);
13 _repo = NULL;
14}
15
16void 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");
ac3d33df 23 cl_git_pass(git_object_lookup(&obj, _repo, &full, GIT_OBJECT_ANY));
13f7ecd7
RB
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
eb46fb2b 29 git_oid_fromstr(&full, "038d718da6a1ebbc6a7780a96ed75a70cc2ad6e2");
ac3d33df 30 cl_git_pass(git_object_lookup(&obj, _repo, &full, GIT_OBJECT_ANY));
eb46fb2b
JP
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
13f7ecd7 36 git_oid_fromstr(&full, "dea509d097ce692e167dfc6a48a7a280cc5e877e");
ac3d33df 37 cl_git_pass(git_object_lookup(&obj, _repo, &full, GIT_OBJECT_ANY));
13f7ecd7
RB
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");
ac3d33df 44 cl_git_pass(git_object_lookup(&obj, _repo, &full, GIT_OBJECT_ANY));
13f7ecd7
RB
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
ac3d33df 50 git_buf_dispose(&shorty);
13f7ecd7 51}