]> git.proxmox.com Git - libgit2.git/blob - tests/odb/packed.c
3d502ed6de301011a1f293e7810c62c433d5c519
[libgit2.git] / tests / odb / packed.c
1 #include "clar_libgit2.h"
2 #include "odb.h"
3 #include "pack_data.h"
4
5 static git_odb *_odb;
6
7 void test_odb_packed__initialize(void)
8 {
9 cl_git_pass(git_odb_open(&_odb, cl_fixture("testrepo.git/objects")));
10 }
11
12 void test_odb_packed__cleanup(void)
13 {
14 git_odb_free(_odb);
15 _odb = NULL;
16 }
17
18 void test_odb_packed__mass_read(void)
19 {
20 unsigned int i;
21
22 for (i = 0; i < ARRAY_SIZE(packed_objects); ++i) {
23 git_oid id;
24 git_odb_object *obj;
25
26 cl_git_pass(git_oid_fromstr(&id, packed_objects[i]));
27 cl_assert(git_odb_exists(_odb, &id) == 1);
28 cl_git_pass(git_odb_read(&obj, _odb, &id));
29
30 git_odb_object_free(obj);
31 }
32 }
33
34 void test_odb_packed__read_header_0(void)
35 {
36 unsigned int i;
37
38 for (i = 0; i < ARRAY_SIZE(packed_objects); ++i) {
39 git_oid id;
40 git_odb_object *obj;
41 size_t len;
42 git_object_t type;
43
44 cl_git_pass(git_oid_fromstr(&id, packed_objects[i]));
45
46 cl_git_pass(git_odb_read(&obj, _odb, &id));
47 cl_git_pass(git_odb_read_header(&len, &type, _odb, &id));
48
49 cl_assert(obj->cached.size == len);
50 cl_assert(obj->cached.type == type);
51
52 git_odb_object_free(obj);
53 }
54 }
55
56 void test_odb_packed__read_header_1(void)
57 {
58 unsigned int i;
59
60 for (i = 0; i < ARRAY_SIZE(loose_objects); ++i) {
61 git_oid id;
62 git_odb_object *obj;
63 size_t len;
64 git_object_t type;
65
66 cl_git_pass(git_oid_fromstr(&id, loose_objects[i]));
67
68 cl_assert(git_odb_exists(_odb, &id) == 1);
69
70 cl_git_pass(git_odb_read(&obj, _odb, &id));
71 cl_git_pass(git_odb_read_header(&len, &type, _odb, &id));
72
73 cl_assert(obj->cached.size == len);
74 cl_assert(obj->cached.type == type);
75
76 git_odb_object_free(obj);
77 }
78 }
79