mirror of
https://git.proxmox.com/git/libgit2
synced 2025-08-06 18:03:32 +00:00
Changed test files to use tabs instead of spaces
Signed-off-by: Vicent Marti <tanoku@gmail.com>
This commit is contained in:
parent
52f2390b43
commit
3e590fb222
@ -8,25 +8,25 @@
|
|||||||
|
|
||||||
static const char *odb_dir = "../t0501-objects";
|
static const char *odb_dir = "../t0501-objects";
|
||||||
static const char *commit_ids[] = {
|
static const char *commit_ids[] = {
|
||||||
"a4a7dce85cf63874e984719f4fdd239f5145052f", /* 0 */
|
"a4a7dce85cf63874e984719f4fdd239f5145052f", /* 0 */
|
||||||
"9fd738e8f7967c078dceed8190330fc8648ee56a", /* 1 */
|
"9fd738e8f7967c078dceed8190330fc8648ee56a", /* 1 */
|
||||||
"4a202b346bb0fb0db7eff3cffeb3c70babbd2045", /* 2 */
|
"4a202b346bb0fb0db7eff3cffeb3c70babbd2045", /* 2 */
|
||||||
"c47800c7266a2be04c571c04d5a6614691ea99bd", /* 3 */
|
"c47800c7266a2be04c571c04d5a6614691ea99bd", /* 3 */
|
||||||
"8496071c1b46c854b31185ea97743be6a8774479", /* 4 */
|
"8496071c1b46c854b31185ea97743be6a8774479", /* 4 */
|
||||||
"5b5b025afb0b4c913b4c338a42934a3863bf3644", /* 5 */
|
"5b5b025afb0b4c913b4c338a42934a3863bf3644", /* 5 */
|
||||||
};
|
};
|
||||||
|
|
||||||
BEGIN_TEST(query_details_test)
|
BEGIN_TEST(query_details_test)
|
||||||
const size_t commit_count = sizeof(commit_ids) / sizeof(const char *);
|
const size_t commit_count = sizeof(commit_ids) / sizeof(const char *);
|
||||||
|
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
git_odb *db;
|
git_odb *db;
|
||||||
git_revpool *pool;
|
git_revpool *pool;
|
||||||
|
|
||||||
must_pass(git_odb_open(&db, odb_dir));
|
must_pass(git_odb_open(&db, odb_dir));
|
||||||
|
|
||||||
pool = gitrp_alloc(db);
|
pool = gitrp_alloc(db);
|
||||||
must_be_true(pool != NULL);
|
must_be_true(pool != NULL);
|
||||||
|
|
||||||
for (i = 0; i < commit_count; ++i) {
|
for (i = 0; i < commit_count; ++i) {
|
||||||
git_oid id;
|
git_oid id;
|
||||||
@ -56,6 +56,6 @@ BEGIN_TEST(query_details_test)
|
|||||||
must_be_true(commit_time > 0);
|
must_be_true(commit_time > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
gitrp_free(pool);
|
gitrp_free(pool);
|
||||||
git_odb_close(db);
|
git_odb_close(db);
|
||||||
END_TEST
|
END_TEST
|
||||||
|
@ -6,51 +6,51 @@
|
|||||||
|
|
||||||
BEGIN_TEST(list_timesort_test)
|
BEGIN_TEST(list_timesort_test)
|
||||||
|
|
||||||
git_commit_list list;
|
git_commit_list list;
|
||||||
git_commit_node *n;
|
git_commit_node *n;
|
||||||
int i, t;
|
int i, t;
|
||||||
time_t previous_time;
|
time_t previous_time;
|
||||||
|
|
||||||
#define TEST_SORTED() \
|
#define TEST_SORTED() \
|
||||||
previous_time = INT_MAX;\
|
previous_time = INT_MAX;\
|
||||||
for (n = list.head; n != NULL; n = n->next) {\
|
for (n = list.head; n != NULL; n = n->next) {\
|
||||||
must_be_true(n->commit->commit_time <= previous_time);\
|
must_be_true(n->commit->commit_time <= previous_time);\
|
||||||
previous_time = n->commit->commit_time;\
|
previous_time = n->commit->commit_time;\
|
||||||
}
|
}
|
||||||
|
|
||||||
memset(&list, 0x0, sizeof(git_commit_list));
|
memset(&list, 0x0, sizeof(git_commit_list));
|
||||||
srand((unsigned int)time(NULL));
|
srand((unsigned int)time(NULL));
|
||||||
|
|
||||||
for (t = 0; t < 20; ++t) {
|
for (t = 0; t < 20; ++t) {
|
||||||
const int test_size = rand() % 500 + 500;
|
const int test_size = rand() % 500 + 500;
|
||||||
|
|
||||||
/* Purely random sorting test */
|
/* Purely random sorting test */
|
||||||
for (i = 0; i < test_size; ++i) {
|
for (i = 0; i < test_size; ++i) {
|
||||||
git_commit *c = git__malloc(sizeof(git_commit));
|
git_commit *c = git__malloc(sizeof(git_commit));
|
||||||
c->commit_time = (time_t)rand();
|
c->commit_time = (time_t)rand();
|
||||||
|
|
||||||
git_commit_list_push_back(&list, c);
|
git_commit_list_push_back(&list, c);
|
||||||
}
|
}
|
||||||
|
|
||||||
git_commit_list_timesort(&list);
|
git_commit_list_timesort(&list);
|
||||||
TEST_SORTED();
|
TEST_SORTED();
|
||||||
git_commit_list_clear(&list, 1);
|
git_commit_list_clear(&list, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Try to sort list with all dates equal. */
|
/* Try to sort list with all dates equal. */
|
||||||
for (i = 0; i < 200; ++i) {
|
for (i = 0; i < 200; ++i) {
|
||||||
git_commit *c = git__malloc(sizeof(git_commit));
|
git_commit *c = git__malloc(sizeof(git_commit));
|
||||||
c->commit_time = 0;
|
c->commit_time = 0;
|
||||||
|
|
||||||
git_commit_list_push_back(&list, c);
|
git_commit_list_push_back(&list, c);
|
||||||
}
|
}
|
||||||
|
|
||||||
git_commit_list_timesort(&list);
|
git_commit_list_timesort(&list);
|
||||||
TEST_SORTED();
|
TEST_SORTED();
|
||||||
git_commit_list_clear(&list, 1);
|
git_commit_list_clear(&list, 1);
|
||||||
|
|
||||||
/* Try to sort empty list */
|
/* Try to sort empty list */
|
||||||
git_commit_list_timesort(&list);
|
git_commit_list_timesort(&list);
|
||||||
TEST_SORTED();
|
TEST_SORTED();
|
||||||
|
|
||||||
END_TEST
|
END_TEST
|
||||||
|
@ -8,25 +8,25 @@
|
|||||||
|
|
||||||
static const char *odb_dir = "../t0501-objects";
|
static const char *odb_dir = "../t0501-objects";
|
||||||
/*
|
/*
|
||||||
$ git log --oneline --graph --decorate
|
$ git log --oneline --graph --decorate
|
||||||
* a4a7dce (HEAD, br2) Merge branch 'master' into br2
|
* a4a7dce (HEAD, br2) Merge branch 'master' into br2
|
||||||
|\
|
|\
|
||||||
| * 9fd738e (master) a fourth commit
|
| * 9fd738e (master) a fourth commit
|
||||||
| * 4a202b3 a third commit
|
| * 4a202b3 a third commit
|
||||||
* | c47800c branch commit one
|
* | c47800c branch commit one
|
||||||
|/
|
|/
|
||||||
* 5b5b025 another commit
|
* 5b5b025 another commit
|
||||||
* 8496071 testing
|
* 8496071 testing
|
||||||
*/
|
*/
|
||||||
static const char *commit_head = "a4a7dce85cf63874e984719f4fdd239f5145052f";
|
static const char *commit_head = "a4a7dce85cf63874e984719f4fdd239f5145052f";
|
||||||
|
|
||||||
static const char *commit_ids[] = {
|
static const char *commit_ids[] = {
|
||||||
"a4a7dce85cf63874e984719f4fdd239f5145052f", /* 0 */
|
"a4a7dce85cf63874e984719f4fdd239f5145052f", /* 0 */
|
||||||
"9fd738e8f7967c078dceed8190330fc8648ee56a", /* 1 */
|
"9fd738e8f7967c078dceed8190330fc8648ee56a", /* 1 */
|
||||||
"4a202b346bb0fb0db7eff3cffeb3c70babbd2045", /* 2 */
|
"4a202b346bb0fb0db7eff3cffeb3c70babbd2045", /* 2 */
|
||||||
"c47800c7266a2be04c571c04d5a6614691ea99bd", /* 3 */
|
"c47800c7266a2be04c571c04d5a6614691ea99bd", /* 3 */
|
||||||
"8496071c1b46c854b31185ea97743be6a8774479", /* 4 */
|
"8496071c1b46c854b31185ea97743be6a8774479", /* 4 */
|
||||||
"5b5b025afb0b4c913b4c338a42934a3863bf3644", /* 5 */
|
"5b5b025afb0b4c913b4c338a42934a3863bf3644", /* 5 */
|
||||||
};
|
};
|
||||||
|
|
||||||
static const int commit_sorting_topo[] = {0, 1, 2, 3, 5, 4};
|
static const int commit_sorting_topo[] = {0, 1, 2, 3, 5, 4};
|
||||||
@ -36,42 +36,42 @@ static const int commit_sorting_time_reverse[] = {4, 5, 2, 1, 3, 0};
|
|||||||
static const int commit_sorting_topo_time[] = {0};
|
static const int commit_sorting_topo_time[] = {0};
|
||||||
|
|
||||||
BEGIN_TEST(simple_walk_test)
|
BEGIN_TEST(simple_walk_test)
|
||||||
git_odb *db;
|
git_odb *db;
|
||||||
git_oid id;
|
git_oid id;
|
||||||
git_revpool *pool;
|
git_revpool *pool;
|
||||||
git_commit *head = NULL;
|
git_commit *head = NULL;
|
||||||
|
|
||||||
must_pass(git_odb_open(&db, odb_dir));
|
must_pass(git_odb_open(&db, odb_dir));
|
||||||
|
|
||||||
pool = gitrp_alloc(db);
|
pool = gitrp_alloc(db);
|
||||||
must_be_true(pool != NULL);
|
must_be_true(pool != NULL);
|
||||||
|
|
||||||
git_oid_mkstr(&id, commit_head);
|
git_oid_mkstr(&id, commit_head);
|
||||||
|
|
||||||
head = git_commit_parse(pool, &id);
|
head = git_commit_parse(pool, &id);
|
||||||
must_be_true(head != NULL);
|
must_be_true(head != NULL);
|
||||||
|
|
||||||
gitrp_push(pool, head);
|
gitrp_push(pool, head);
|
||||||
|
|
||||||
#define TEST_WALK(sort_flags, result_array) {\
|
#define TEST_WALK(sort_flags, result_array) {\
|
||||||
char oid[40]; int i = 0;\
|
char oid[40]; int i = 0;\
|
||||||
git_commit *commit = NULL;\
|
git_commit *commit = NULL;\
|
||||||
gitrp_sorting(pool, sort_flags);\
|
gitrp_sorting(pool, sort_flags);\
|
||||||
while ((commit = gitrp_next(pool)) != NULL) {\
|
while ((commit = gitrp_next(pool)) != NULL) {\
|
||||||
git_oid_fmt(oid, &commit->object.id);\
|
git_oid_fmt(oid, &commit->object.id);\
|
||||||
must_be_true(memcmp(oid, commit_ids[result_array[i++]], 40) == 0);\
|
must_be_true(memcmp(oid, commit_ids[result_array[i++]], 40) == 0);\
|
||||||
}\
|
}\
|
||||||
must_be_true(i == sizeof(result_array)/sizeof(int));\
|
must_be_true(i == sizeof(result_array)/sizeof(int));\
|
||||||
gitrp_reset(pool);\
|
gitrp_reset(pool);\
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_WALK(GIT_RPSORT_TIME, commit_sorting_time);
|
TEST_WALK(GIT_RPSORT_TIME, commit_sorting_time);
|
||||||
TEST_WALK(GIT_RPSORT_TOPOLOGICAL, commit_sorting_topo);
|
TEST_WALK(GIT_RPSORT_TOPOLOGICAL, commit_sorting_topo);
|
||||||
TEST_WALK(GIT_RPSORT_TIME | GIT_RPSORT_REVERSE, commit_sorting_time_reverse);
|
TEST_WALK(GIT_RPSORT_TIME | GIT_RPSORT_REVERSE, commit_sorting_time_reverse);
|
||||||
TEST_WALK(GIT_RPSORT_TOPOLOGICAL | GIT_RPSORT_REVERSE, commit_sorting_topo_reverse);
|
TEST_WALK(GIT_RPSORT_TOPOLOGICAL | GIT_RPSORT_REVERSE, commit_sorting_topo_reverse);
|
||||||
|
|
||||||
#undef TEST_WALK
|
#undef TEST_WALK
|
||||||
|
|
||||||
gitrp_free(pool);
|
gitrp_free(pool);
|
||||||
git_odb_close(db);
|
git_odb_close(db);
|
||||||
END_TEST
|
END_TEST
|
||||||
|
Loading…
Reference in New Issue
Block a user