diff options
Diffstat (limited to 'tests/graph')
| -rw-r--r-- | tests/graph/commit_graph.c | 37 | ||||
| -rw-r--r-- | tests/graph/reachable_from_any.c | 10 |
2 files changed, 24 insertions, 23 deletions
diff --git a/tests/graph/commit_graph.c b/tests/graph/commit_graph.c index 5926dca6f..83f53f1d4 100644 --- a/tests/graph/commit_graph.c +++ b/tests/graph/commit_graph.c @@ -12,12 +12,12 @@ void test_graph_commit_graph__parse(void) struct git_commit_graph_file *file; struct git_commit_graph_entry e, parent; git_oid id; - git_buf commit_graph_path = GIT_BUF_INIT; + git_str commit_graph_path = GIT_STR_INIT; cl_git_pass(git_repository_open(&repo, cl_fixture("testrepo.git"))); - cl_git_pass(git_buf_joinpath(&commit_graph_path, git_repository_path(repo), "objects/info/commit-graph")); - cl_git_pass(git_commit_graph_file_open(&file, git_buf_cstr(&commit_graph_path))); - cl_assert_equal_i(git_commit_graph_file_needs_refresh(file, git_buf_cstr(&commit_graph_path)), 0); + cl_git_pass(git_str_joinpath(&commit_graph_path, git_repository_path(repo), "objects/info/commit-graph")); + cl_git_pass(git_commit_graph_file_open(&file, git_str_cstr(&commit_graph_path))); + cl_assert_equal_i(git_commit_graph_file_needs_refresh(file, git_str_cstr(&commit_graph_path)), 0); cl_git_pass(git_oid_fromstr(&id, "5001298e0c09ad9c34e4249bc5801c75e9754fa5")); cl_git_pass(git_commit_graph_entry_find(&e, file, &id, GIT_OID_HEXSZ)); @@ -47,7 +47,7 @@ void test_graph_commit_graph__parse(void) git_commit_graph_file_free(file); git_repository_free(repo); - git_buf_dispose(&commit_graph_path); + git_str_dispose(&commit_graph_path); } void test_graph_commit_graph__parse_octopus_merge(void) @@ -56,11 +56,11 @@ void test_graph_commit_graph__parse_octopus_merge(void) struct git_commit_graph_file *file; struct git_commit_graph_entry e, parent; git_oid id; - git_buf commit_graph_path = GIT_BUF_INIT; + git_str commit_graph_path = GIT_STR_INIT; cl_git_pass(git_repository_open(&repo, cl_fixture("merge-recursive/.gitted"))); - cl_git_pass(git_buf_joinpath(&commit_graph_path, git_repository_path(repo), "objects/info/commit-graph")); - cl_git_pass(git_commit_graph_file_open(&file, git_buf_cstr(&commit_graph_path))); + cl_git_pass(git_str_joinpath(&commit_graph_path, git_repository_path(repo), "objects/info/commit-graph")); + cl_git_pass(git_commit_graph_file_open(&file, git_str_cstr(&commit_graph_path))); cl_git_pass(git_oid_fromstr(&id, "d71c24b3b113fd1d1909998c5bfe33b86a65ee03")); cl_git_pass(git_commit_graph_entry_find(&e, file, &id, GIT_OID_HEXSZ)); @@ -88,7 +88,7 @@ void test_graph_commit_graph__parse_octopus_merge(void) git_commit_graph_file_free(file); git_repository_free(repo); - git_buf_dispose(&commit_graph_path); + git_str_dispose(&commit_graph_path); } void test_graph_commit_graph__writer(void) @@ -97,12 +97,13 @@ void test_graph_commit_graph__writer(void) git_commit_graph_writer *w = NULL; git_revwalk *walk; git_commit_graph_writer_options opts = GIT_COMMIT_GRAPH_WRITER_OPTIONS_INIT; - git_buf cgraph = GIT_BUF_INIT, expected_cgraph = GIT_BUF_INIT, path = GIT_BUF_INIT; + git_buf cgraph = GIT_BUF_INIT; + git_str expected_cgraph = GIT_STR_INIT, path = GIT_STR_INIT; cl_git_pass(git_repository_open(&repo, cl_fixture("testrepo.git"))); - cl_git_pass(git_buf_joinpath(&path, git_repository_path(repo), "objects/info")); - cl_git_pass(git_commit_graph_writer_new(&w, git_buf_cstr(&path))); + cl_git_pass(git_str_joinpath(&path, git_repository_path(repo), "objects/info")); + cl_git_pass(git_commit_graph_writer_new(&w, git_str_cstr(&path))); /* This is equivalent to `git commit-graph write --reachable`. */ cl_git_pass(git_revwalk_new(&walk, repo)); @@ -111,15 +112,15 @@ void test_graph_commit_graph__writer(void) git_revwalk_free(walk); cl_git_pass(git_commit_graph_writer_dump(&cgraph, w, &opts)); - cl_git_pass(git_buf_joinpath(&path, git_repository_path(repo), "objects/info/commit-graph")); - cl_git_pass(git_futils_readbuffer(&expected_cgraph, git_buf_cstr(&path))); + cl_git_pass(git_str_joinpath(&path, git_repository_path(repo), "objects/info/commit-graph")); + cl_git_pass(git_futils_readbuffer(&expected_cgraph, git_str_cstr(&path))); - cl_assert_equal_i(git_buf_len(&cgraph), git_buf_len(&expected_cgraph)); - cl_assert_equal_i(memcmp(git_buf_cstr(&cgraph), git_buf_cstr(&expected_cgraph), git_buf_len(&cgraph)), 0); + cl_assert_equal_i(cgraph.size, git_str_len(&expected_cgraph)); + cl_assert_equal_i(memcmp(cgraph.ptr, git_str_cstr(&expected_cgraph), cgraph.size), 0); git_buf_dispose(&cgraph); - git_buf_dispose(&expected_cgraph); - git_buf_dispose(&path); + git_str_dispose(&expected_cgraph); + git_str_dispose(&path); git_commit_graph_writer_free(w); git_repository_free(repo); } diff --git a/tests/graph/reachable_from_any.c b/tests/graph/reachable_from_any.c index 5c8416499..9693d7d67 100644 --- a/tests/graph/reachable_from_any.c +++ b/tests/graph/reachable_from_any.c @@ -200,12 +200,12 @@ void test_graph_reachable_from_any__exhaustive(void) descendants, n_descendants); if (actual_reachable != expected_reachable) { - git_buf error_message_buf = GIT_BUF_INIT; + git_str error_message_buf = GIT_STR_INIT; char parent_oidbuf[9] = {0}, child_oidbuf[9] = {0}; cl_git_pass(git_oid_nfmt( parent_oidbuf, 8, git_commit_id(parent_commit))); - git_buf_printf(&error_message_buf, + git_str_printf(&error_message_buf, "git_graph_reachable_from_any(\"%s\", %zu, " "{", parent_oidbuf, @@ -216,14 +216,14 @@ void test_graph_reachable_from_any__exhaustive(void) git_oid_nfmt(child_oidbuf, 8, &descendants[descendant_i])); - git_buf_printf(&error_message_buf, " \"%s\"", child_oidbuf); + git_str_printf(&error_message_buf, " \"%s\"", child_oidbuf); } - git_buf_printf(&error_message_buf, + git_str_printf(&error_message_buf, " }) = %d, expected = %d", actual_reachable, expected_reachable); cl_check_(actual_reachable == expected_reachable, - git_buf_cstr(&error_message_buf)); + git_str_cstr(&error_message_buf)); } } } |
