Hash :
5690f02e
Author :
Date :
2008-12-31T15:35:36
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
#include "test_lib.h"
#include "fileops.h"
static char path_buffer[GIT_PATH_MAX];
static int state_loc;
static const char* names[] = {
"./a",
"./asdf",
"./pack-foo.pack",
NULL
};
static int one_entry(void *state, char *path)
{
const char **c;
must_be_true(state == &state_loc);
must_be_true(path == path_buffer);
for (c = names; *c; c++) {
if (!strcmp(*c, path)) {
*c = "";
return 0;
}
}
test_die("unexpected path \"%s\"", path);
}
BEGIN_TEST(setup)
const char **c;
for (c = names; *c; c++) {
git_file fd = gitfo_creat(*c, 0600);
must_be_true(fd >= 0);
gitfo_close(fd);
}
END_TEST
BEGIN_TEST(direent_walk)
const char **c;
strcpy(path_buffer, ".");
must_pass(gitfo_dirent(path_buffer,
sizeof(path_buffer),
one_entry,
&state_loc));
for (c = names; *c; c++)
must_pass(strcmp("", *c));
END_TEST