summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/t0401-parse.c3
-rw-r--r--tests/t0402-details.c6
-rw-r--r--tests/t0403-write.c21
-rw-r--r--tests/t0501-walk.c10
-rw-r--r--tests/t0601-read.c15
-rw-r--r--tests/t0602-write.c3
-rw-r--r--tests/t0603-sort.c7
-rw-r--r--tests/t0801-readtag.c6
-rw-r--r--tests/t0802-write.c6
-rw-r--r--tests/t0901-readtree.c15
-rw-r--r--tests/t0902-modify.c13
11 files changed, 36 insertions, 69 deletions
diff --git a/tests/t0401-parse.c b/tests/t0401-parse.c
index 1a2806bf1..0ce59fc30 100644
--- a/tests/t0401-parse.c
+++ b/tests/t0401-parse.c
@@ -224,8 +224,7 @@ BEGIN_TEST(parse_buffer_test)
int i;
git_repository *repo;
- repo = git_repository_open(REPOSITORY_FOLDER);
- must_be_true(repo != NULL);
+ must_pass(git_repository_open(&repo, REPOSITORY_FOLDER));
for (i = 0; i < broken_commit_count; ++i) {
git_commit *commit;
diff --git a/tests/t0402-details.c b/tests/t0402-details.c
index d60b6481b..22d1f8eba 100644
--- a/tests/t0402-details.c
+++ b/tests/t0402-details.c
@@ -22,8 +22,7 @@ BEGIN_TEST(query_details_test)
unsigned int i;
git_repository *repo;
- repo = git_repository_open(REPOSITORY_FOLDER);
- must_be_true(repo != NULL);
+ must_pass(git_repository_open(&repo, REPOSITORY_FOLDER));
for (i = 0; i < commit_count; ++i) {
git_oid id;
@@ -35,8 +34,7 @@ BEGIN_TEST(query_details_test)
git_oid_mkstr(&id, commit_ids[i]);
- commit = git_commit_lookup(repo, &id);
- must_be_true(commit != NULL);
+ must_pass(git_commit_lookup(&commit, repo, &id));
message = git_commit_message(commit);
message_short = git_commit_message_short(commit);
diff --git a/tests/t0403-write.c b/tests/t0403-write.c
index 60133c409..4bd659730 100644
--- a/tests/t0403-write.c
+++ b/tests/t0403-write.c
@@ -26,17 +26,14 @@ BEGIN_TEST(writenew_test)
git_oid id;
/* char hex_oid[41]; */
- repo = git_repository_open(REPOSITORY_FOLDER);
- must_be_true(repo != NULL);
+ must_pass(git_repository_open(&repo, REPOSITORY_FOLDER));
/* Create commit in memory */
- commit = git_commit_new(repo);
- must_be_true(commit != NULL);
+ must_pass(git_commit_new(&commit, repo));
/* Add new parent */
git_oid_mkstr(&id, commit_ids[4]);
- parent = git_commit_lookup(repo, &id);
- must_be_true(parent != NULL);
+ must_pass(git_commit_lookup(&parent, repo, &id));
git_commit_add_parent(commit, parent);
@@ -49,8 +46,7 @@ This is a commit created in memory and it will be written back to disk\n");
/* add new tree */
git_oid_mkstr(&id, tree_oid);
- tree = git_tree_lookup(repo, &id);
- must_be_true(tree != NULL);
+ must_pass(git_tree_lookup(&tree, repo, &id));
git_commit_set_tree(commit, tree);
@@ -82,13 +78,11 @@ BEGIN_TEST(writeback_test)
const char *message;
/* char hex_oid[41]; */
- repo = git_repository_open(REPOSITORY_FOLDER);
- must_be_true(repo != NULL);
+ must_pass(git_repository_open(&repo, REPOSITORY_FOLDER));
git_oid_mkstr(&id, commit_ids[0]);
- commit = git_commit_lookup(repo, &id);
- must_be_true(commit != NULL);
+ must_pass(git_commit_lookup(&commit, repo, &id));
message = git_commit_message(commit);
@@ -101,8 +95,7 @@ BEGIN_TEST(writeback_test)
git_commit_set_message(commit, "This is a new test message. Cool!\n");
git_oid_mkstr(&id, commit_ids[4]);
- parent = git_commit_lookup(repo, &id);
- must_be_true(parent != NULL);
+ must_pass(git_commit_lookup(&parent, repo, &id));
git_commit_add_parent(commit, parent);
diff --git a/tests/t0501-walk.c b/tests/t0501-walk.c
index 55ae936d2..8dd7990d4 100644
--- a/tests/t0501-walk.c
+++ b/tests/t0501-walk.c
@@ -95,17 +95,13 @@ BEGIN_TEST(simple_walk_test)
git_revwalk *walk;
git_commit *head = NULL;
- repo = git_repository_open(REPOSITORY_FOLDER);
- must_be_true(repo != NULL);
+ must_pass(git_repository_open(&repo, REPOSITORY_FOLDER));
- walk = git_revwalk_alloc(repo);
- must_be_true(walk != NULL);
+ must_pass(git_revwalk_new(&walk, repo));
git_oid_mkstr(&id, commit_head);
- head = git_commit_lookup(repo, &id);
- must_be_true(head != NULL);
-
+ must_pass(git_commit_lookup(&head, repo, &id));
must_pass(test_walk(walk, head,
GIT_SORT_TIME,
diff --git a/tests/t0601-read.c b/tests/t0601-read.c
index 345e5b534..133a26679 100644
--- a/tests/t0601-read.c
+++ b/tests/t0601-read.c
@@ -29,8 +29,7 @@ struct test_entry TEST_ENTRIES[] = {
BEGIN_TEST(index_loadempty_test)
git_index *index;
- index = git_index_alloc("in-memory-index", NULL);
- must_be_true(index != NULL);
+ must_pass(git_index_open(&index, "in-memory-index", NULL));
must_be_true(index->on_disk == 0);
must_pass(git_index_read(index));
@@ -46,8 +45,7 @@ BEGIN_TEST(index_load_test)
git_index *index;
unsigned int i;
- index = git_index_alloc(TEST_INDEX_PATH, NULL);
- must_be_true(index != NULL);
+ must_pass(git_index_open(&index, TEST_INDEX_PATH, NULL));
must_be_true(index->on_disk);
must_pass(git_index_read(index));
@@ -70,8 +68,7 @@ END_TEST
BEGIN_TEST(index2_load_test)
git_index *index;
- index = git_index_alloc(TEST_INDEX2_PATH, NULL);
- must_be_true(index != NULL);
+ must_pass(git_index_open(&index, TEST_INDEX2_PATH, NULL));
must_be_true(index->on_disk);
must_pass(git_index_read(index));
@@ -88,8 +85,7 @@ BEGIN_TEST(index_find_test)
git_index *index;
unsigned int i;
- index = git_index_alloc(TEST_INDEX_PATH, NULL);
- must_be_true(index != NULL);
+ must_pass(git_index_open(&index, TEST_INDEX_PATH, NULL));
must_pass(git_index_read(index));
for (i = 0; i < ARRAY_SIZE(TEST_ENTRIES); ++i) {
@@ -104,8 +100,7 @@ BEGIN_TEST(index_findempty_test)
git_index *index;
unsigned int i;
- index = git_index_alloc("fake-index", NULL);
- must_be_true(index != NULL);
+ must_pass(git_index_open(&index, "fake-index", NULL));
for (i = 0; i < ARRAY_SIZE(TEST_ENTRIES); ++i) {
int idx = git_index_find(index, TEST_ENTRIES[i].path);
diff --git a/tests/t0602-write.c b/tests/t0602-write.c
index d232193b7..415183f94 100644
--- a/tests/t0602-write.c
+++ b/tests/t0602-write.c
@@ -35,8 +35,7 @@ BEGIN_TEST(index_load_test)
git_index *index;
git_filelock out_file;
- index = git_index_alloc(TEST_INDEX_PATH, NULL);
- must_be_true(index != NULL);
+ must_pass(git_index_open(&index, TEST_INDEX_PATH, NULL));
must_pass(git_index_read(index));
must_be_true(index->on_disk);
diff --git a/tests/t0603-sort.c b/tests/t0603-sort.c
index dfbb6e175..0ee14d713 100644
--- a/tests/t0603-sort.c
+++ b/tests/t0603-sort.c
@@ -36,8 +36,7 @@ BEGIN_TEST(index_sort_test)
git_index *index;
unsigned int i;
- index = git_index_alloc(TEST_INDEX_PATH, NULL);
- must_be_true(index != NULL);
+ must_pass(git_index_open(&index, TEST_INDEX_PATH, NULL));
must_pass(git_index_read(index));
randomize_entries(index);
@@ -54,8 +53,8 @@ END_TEST
BEGIN_TEST(index_sort_empty_test)
git_index *index;
- index = git_index_alloc("fake-index", NULL);
- must_be_true(index != NULL);
+
+ must_pass(git_index_open(&index, "fake-index", NULL));
git_index__sort(index);
must_be_true(index->sorted);
diff --git a/tests/t0801-readtag.c b/tests/t0801-readtag.c
index 798fa8f49..8314304bd 100644
--- a/tests/t0801-readtag.c
+++ b/tests/t0801-readtag.c
@@ -16,15 +16,13 @@ BEGIN_TEST(readtag)
git_commit *commit;
git_oid id1, id2, id_commit;
- repo = git_repository_open(REPOSITORY_FOLDER);
- must_be_true(repo != NULL);
+ must_pass(git_repository_open(&repo, REPOSITORY_FOLDER));
git_oid_mkstr(&id1, tag1_id);
git_oid_mkstr(&id2, tag2_id);
git_oid_mkstr(&id_commit, tagged_commit);
- tag1 = git_tag_lookup(repo, &id1);
- must_be_true(tag1 != NULL);
+ must_pass(git_tag_lookup(&tag1, repo, &id1));
must_be_true(strcmp(git_tag_name(tag1), "test") == 0);
must_be_true(git_tag_type(tag1) == GIT_OBJ_TAG);
diff --git a/tests/t0802-write.c b/tests/t0802-write.c
index 20c1eab0a..8dd8de5ea 100644
--- a/tests/t0802-write.c
+++ b/tests/t0802-write.c
@@ -14,13 +14,11 @@ BEGIN_TEST(tag_writeback_test)
git_tag *tag;
/* char hex_oid[41]; */
- repo = git_repository_open(REPOSITORY_FOLDER);
- must_be_true(repo != NULL);
+ must_pass(git_repository_open(&repo, REPOSITORY_FOLDER));
git_oid_mkstr(&id, tag_id);
- tag = git_tag_lookup(repo, &id);
- must_be_true(tag != NULL);
+ must_pass(git_tag_lookup(&tag, repo, &id));
git_tag_set_name(tag, "This is a different tag LOL");
diff --git a/tests/t0901-readtree.c b/tests/t0901-readtree.c
index e3a85c52d..c14f5fd1f 100644
--- a/tests/t0901-readtree.c
+++ b/tests/t0901-readtree.c
@@ -13,13 +13,11 @@ BEGIN_TEST(tree_entry_access_test)
git_repository *repo;
git_tree *tree;
- repo = git_repository_open(REPOSITORY_FOLDER);
- must_be_true(repo != NULL);
+ must_pass(git_repository_open(&repo, REPOSITORY_FOLDER));
git_oid_mkstr(&id, tree_oid);
- tree = git_tree_lookup(repo, &id);
- must_be_true(tree != NULL);
+ must_pass(git_tree_lookup(&tree, repo, &id));
must_be_true(git_tree_entry_byname(tree, "README") != NULL);
must_be_true(git_tree_entry_byname(tree, "NOTEXISTS") == NULL);
@@ -37,14 +35,13 @@ BEGIN_TEST(tree_read_test)
git_repository *repo;
git_tree *tree;
git_tree_entry *entry;
+ git_object *obj;
- repo = git_repository_open(REPOSITORY_FOLDER);
- must_be_true(repo != NULL);
+ must_pass(git_repository_open(&repo, REPOSITORY_FOLDER));
git_oid_mkstr(&id, tree_oid);
- tree = git_tree_lookup(repo, &id);
- must_be_true(tree != NULL);
+ must_pass(git_tree_lookup(&tree, repo, &id));
must_be_true(git_tree_entrycount(tree) == 3);
@@ -53,7 +50,7 @@ BEGIN_TEST(tree_read_test)
must_be_true(strcmp(git_tree_entry_name(entry), "README") == 0);
- must_be_true(git_tree_entry_2object(entry) != NULL);
+ must_pass(git_tree_entry_2object(&obj, entry));
git_repository_free(repo);
END_TEST
diff --git a/tests/t0902-modify.c b/tests/t0902-modify.c
index 23fc03cb2..a83349df9 100644
--- a/tests/t0902-modify.c
+++ b/tests/t0902-modify.c
@@ -16,11 +16,8 @@ BEGIN_TEST(tree_in_memory_add_test)
unsigned int i;
git_oid entry_id;
- repo = git_repository_open(REPOSITORY_FOLDER);
- must_be_true(repo != NULL);
-
- tree = git_tree_new(repo);
- must_be_true(tree != NULL);
+ must_pass(git_repository_open(&repo, REPOSITORY_FOLDER));
+ must_pass(git_tree_new(&tree, repo));
git_oid_mkstr(&entry_id, tree_oid);
for (i = 0; i < entry_count; ++i) {
@@ -46,13 +43,11 @@ BEGIN_TEST(tree_add_entry_test)
unsigned int i;
/* char hex_oid[41]; */
- repo = git_repository_open(REPOSITORY_FOLDER);
- must_be_true(repo != NULL);
+ must_pass(git_repository_open(&repo, REPOSITORY_FOLDER));
git_oid_mkstr(&id, tree_oid);
- tree = git_tree_lookup(repo, &id);
- must_be_true(tree != NULL);
+ must_pass(git_tree_lookup(&tree, repo, &id));
must_be_true(git_tree_entrycount(tree) == 3);