Blame tests/odb/packed.c

Packit Service 20376f
#include "clar_libgit2.h"
Packit Service 20376f
#include "odb.h"
Packit Service 20376f
#include "pack_data.h"
Packit Service 20376f
Packit Service 20376f
static git_odb *_odb;
Packit Service 20376f
Packit Service 20376f
void test_odb_packed__initialize(void)
Packit Service 20376f
{
Packit Service 20376f
    cl_git_pass(git_odb_open(&_odb, cl_fixture("testrepo.git/objects")));
Packit Service 20376f
}
Packit Service 20376f
Packit Service 20376f
void test_odb_packed__cleanup(void)
Packit Service 20376f
{
Packit Service 20376f
	git_odb_free(_odb);
Packit Service 20376f
	_odb = NULL;
Packit Service 20376f
}
Packit Service 20376f
Packit Service 20376f
void test_odb_packed__mass_read(void)
Packit Service 20376f
{
Packit Service 20376f
	unsigned int i;
Packit Service 20376f
Packit Service 20376f
	for (i = 0; i < ARRAY_SIZE(packed_objects); ++i) {
Packit Service 20376f
		git_oid id;
Packit Service 20376f
		git_odb_object *obj;
Packit Service 20376f
Packit Service 20376f
		cl_git_pass(git_oid_fromstr(&id, packed_objects[i]));
Packit Service 20376f
		cl_assert(git_odb_exists(_odb, &id) == 1);
Packit Service 20376f
		cl_git_pass(git_odb_read(&obj, _odb, &id));
Packit Service 20376f
Packit Service 20376f
		git_odb_object_free(obj);
Packit Service 20376f
	}
Packit Service 20376f
}
Packit Service 20376f
Packit Service 20376f
void test_odb_packed__read_header_0(void)
Packit Service 20376f
{
Packit Service 20376f
	unsigned int i;
Packit Service 20376f
Packit Service 20376f
	for (i = 0; i < ARRAY_SIZE(packed_objects); ++i) {
Packit Service 20376f
		git_oid id;
Packit Service 20376f
		git_odb_object *obj;
Packit Service 20376f
		size_t len;
Packit Service 20376f
		git_otype type;
Packit Service 20376f
Packit Service 20376f
		cl_git_pass(git_oid_fromstr(&id, packed_objects[i]));
Packit Service 20376f
Packit Service 20376f
		cl_git_pass(git_odb_read(&obj, _odb, &id));
Packit Service 20376f
		cl_git_pass(git_odb_read_header(&len, &type, _odb, &id));
Packit Service 20376f
Packit Service 20376f
		cl_assert(obj->cached.size == len);
Packit Service 20376f
		cl_assert(obj->cached.type == type);
Packit Service 20376f
Packit Service 20376f
		git_odb_object_free(obj);
Packit Service 20376f
	}
Packit Service 20376f
}
Packit Service 20376f
Packit Service 20376f
void test_odb_packed__read_header_1(void)
Packit Service 20376f
{
Packit Service 20376f
	unsigned int i;
Packit Service 20376f
Packit Service 20376f
	for (i = 0; i < ARRAY_SIZE(loose_objects); ++i) {
Packit Service 20376f
		git_oid id;
Packit Service 20376f
		git_odb_object *obj;
Packit Service 20376f
		size_t len;
Packit Service 20376f
		git_otype type;
Packit Service 20376f
Packit Service 20376f
		cl_git_pass(git_oid_fromstr(&id, loose_objects[i]));
Packit Service 20376f
Packit Service 20376f
		cl_assert(git_odb_exists(_odb, &id) == 1);
Packit Service 20376f
Packit Service 20376f
		cl_git_pass(git_odb_read(&obj, _odb, &id));
Packit Service 20376f
		cl_git_pass(git_odb_read_header(&len, &type, _odb, &id));
Packit Service 20376f
Packit Service 20376f
		cl_assert(obj->cached.size == len);
Packit Service 20376f
		cl_assert(obj->cached.type == type);
Packit Service 20376f
Packit Service 20376f
		git_odb_object_free(obj);
Packit Service 20376f
	}
Packit Service 20376f
}
Packit Service 20376f