Hash :
5dca2010
Author :
Date :
2012-08-03T17:08:01
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
#include "clar_libgit2.h"
#include "odb.h"
#include "git2/odb_backend.h"
#include "pack.h"
static git_odb *_odb;
static git_repository *_repo;
static int nobj;
void test_odb_foreach__initialize(void)
{
cl_git_pass(git_repository_open(&_repo, cl_fixture("testrepo.git")));
git_repository_odb(&_odb, _repo);
}
void test_odb_foreach__cleanup(void)
{
git_odb_free(_odb);
git_repository_free(_repo);
}
static int foreach_cb(git_oid *oid, void *data)
{
GIT_UNUSED(data);
GIT_UNUSED(oid);
nobj++;
return 0;
}
void test_odb_foreach__foreach(void)
{
nobj = 0;
cl_git_pass(git_odb_foreach(_odb, foreach_cb, NULL));
cl_assert(nobj == 1683);
}
static int foreach_stop_cb(git_oid *oid, void *data)
{
GIT_UNUSED(data);
GIT_UNUSED(oid);
nobj++;
return (nobj == 1000);
}
void test_odb_foreach__interrupt_foreach(void)
{
nobj = 0;
cl_assert_equal_i(GIT_EUSER, git_odb_foreach(_odb, foreach_stop_cb, NULL));
cl_assert(nobj == 1000);
}