]>
Commit | Line | Data |
---|---|---|
507523c3 | 1 | #include "clar_libgit2.h" |
83cc70d9 RB |
2 | #include "git2/odb_backend.h" |
3 | ||
507523c3 CMN |
4 | #include "pack_data_one.h" |
5 | #include "pack.h" | |
6 | ||
7 | static git_odb *_odb; | |
8 | ||
9 | void test_odb_packed_one__initialize(void) | |
10 | { | |
11 | git_odb_backend *backend = NULL; | |
12 | ||
13 | cl_git_pass(git_odb_new(&_odb)); | |
14 | cl_git_pass(git_odb_backend_one_pack(&backend, cl_fixture("testrepo.git/objects/pack/pack-a81e489679b7d3418f9ab594bda8ceb37dd4c695.idx"))); | |
15 | cl_git_pass(git_odb_add_backend(_odb, backend, 1)); | |
16 | } | |
17 | ||
18 | void test_odb_packed_one__cleanup(void) | |
19 | { | |
20 | git_odb_free(_odb); | |
9094d30b | 21 | _odb = NULL; |
507523c3 CMN |
22 | } |
23 | ||
24 | void test_odb_packed_one__mass_read(void) | |
25 | { | |
26 | unsigned int i; | |
27 | ||
28 | for (i = 0; i < ARRAY_SIZE(packed_objects_one); ++i) { | |
29 | git_oid id; | |
30 | git_odb_object *obj; | |
31 | ||
32 | cl_git_pass(git_oid_fromstr(&id, packed_objects_one[i])); | |
33 | cl_assert(git_odb_exists(_odb, &id) == 1); | |
34 | cl_git_pass(git_odb_read(&obj, _odb, &id)); | |
35 | ||
36 | git_odb_object_free(obj); | |
37 | } | |
38 | } | |
39 | ||
40 | void test_odb_packed_one__read_header_0(void) | |
41 | { | |
42 | unsigned int i; | |
43 | ||
44 | for (i = 0; i < ARRAY_SIZE(packed_objects_one); ++i) { | |
45 | git_oid id; | |
46 | git_odb_object *obj; | |
47 | size_t len; | |
ac3d33df | 48 | git_object_t type; |
507523c3 CMN |
49 | |
50 | cl_git_pass(git_oid_fromstr(&id, packed_objects_one[i])); | |
51 | ||
52 | cl_git_pass(git_odb_read(&obj, _odb, &id)); | |
53 | cl_git_pass(git_odb_read_header(&len, &type, _odb, &id)); | |
54 | ||
8842c75f VM |
55 | cl_assert(obj->cached.size == len); |
56 | cl_assert(obj->cached.type == type); | |
507523c3 CMN |
57 | |
58 | git_odb_object_free(obj); | |
59 | } | |
60 | } |