本文整理汇总了C++中cl_assert_equal_sz函数的典型用法代码示例。如果您正苦于以下问题:C++ cl_assert_equal_sz函数的具体用法?C++ cl_assert_equal_sz怎么用?C++ cl_assert_equal_sz使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了cl_assert_equal_sz函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: test_repo_pathspec__workdir3
void test_repo_pathspec__workdir3(void)
{
git_strarray s;
git_pathspec *ps;
git_pathspec_match_list *m;
/* { "!subdir", "*_file", "new_file" } */
s.strings = str3; s.count = ARRAY_SIZE(str3);
cl_git_pass(git_pathspec_new(&ps, &s));
cl_git_pass(git_pathspec_match_workdir(&m, g_repo, 0, ps));
cl_assert_equal_sz(7, git_pathspec_match_list_entrycount(m));
git_pathspec_match_list_free(m);
cl_git_pass(git_pathspec_match_workdir(&m, g_repo,
GIT_PATHSPEC_FIND_FAILURES, ps));
cl_assert_equal_sz(7, git_pathspec_match_list_entrycount(m));
cl_assert_equal_sz(0, git_pathspec_match_list_failed_entrycount(m));
cl_assert_equal_s("current_file", git_pathspec_match_list_entry(m, 0));
cl_assert_equal_s("modified_file", git_pathspec_match_list_entry(m, 1));
cl_assert_equal_s("new_file", git_pathspec_match_list_entry(m, 2));
cl_assert_equal_s("staged_changes_modified_file", git_pathspec_match_list_entry(m, 3));
cl_assert_equal_s("staged_delete_modified_file", git_pathspec_match_list_entry(m, 4));
cl_assert_equal_s("staged_new_file", git_pathspec_match_list_entry(m, 5));
cl_assert_equal_s("staged_new_file_modified_file", git_pathspec_match_list_entry(m, 6));
cl_assert_equal_s(NULL, git_pathspec_match_list_entry(m, 7));
git_pathspec_match_list_free(m);
git_pathspec_free(ps);
}
示例2: test_checkout_crlf__autocrlf_true_index_size_is_filtered_size
void test_checkout_crlf__autocrlf_true_index_size_is_filtered_size(void)
{
git_index *index;
const git_index_entry *entry;
git_checkout_options opts = GIT_CHECKOUT_OPTIONS_INIT;
opts.checkout_strategy = GIT_CHECKOUT_FORCE;
cl_repo_set_bool(g_repo, "core.autocrlf", true);
git_checkout_head(g_repo, &opts);
git_repository_index(&index, g_repo);
cl_assert((entry = git_index_get_bypath(index, "all-lf", 0)) != NULL);
if (GIT_EOL_NATIVE == GIT_EOL_LF)
cl_assert_equal_sz(strlen(ALL_LF_TEXT_RAW), entry->file_size);
else
cl_assert_equal_sz(strlen(ALL_LF_TEXT_AS_CRLF), entry->file_size);
cl_assert((entry = git_index_get_bypath(index, "all-crlf", 0)) != NULL);
cl_assert_equal_sz(strlen(ALL_CRLF_TEXT_RAW), entry->file_size);
git_index_free(index);
}
示例3: test_filter_blob__sanitizes
void test_filter_blob__sanitizes(void)
{
git_blob *blob;
git_buf buf;
cl_git_pass(git_revparse_single(
(git_object **)&blob, g_repo, "e69de29")); /* zero-byte */
cl_assert_equal_i(0, git_blob_rawsize(blob));
cl_assert_equal_s("", git_blob_rawcontent(blob));
memset(&buf, 0, sizeof(git_buf));
cl_git_pass(git_blob_filtered_content(&buf, blob, "file.bin", 1));
cl_assert_equal_sz(0, buf.size);
cl_assert_equal_s("", buf.ptr);
git_buf_free(&buf);
memset(&buf, 0, sizeof(git_buf));
cl_git_pass(git_blob_filtered_content(&buf, blob, "file.crlf", 1));
cl_assert_equal_sz(0, buf.size);
cl_assert_equal_s("", buf.ptr);
git_buf_free(&buf);
memset(&buf, 0, sizeof(git_buf));
cl_git_pass(git_blob_filtered_content(&buf, blob, "file.lf", 1));
cl_assert_equal_sz(0, buf.size);
cl_assert_equal_s("", buf.ptr);
git_buf_free(&buf);
git_blob_free(blob);
}
示例4: assert_patch_matches_blobs
static void assert_patch_matches_blobs(
git_patch *p, git_blob *a, git_blob *b,
int hunks, int l0, int l1, int ctxt, int adds, int dels)
{
const git_diff_delta *delta;
size_t tc, ta, td;
cl_assert(p != NULL);
delta = git_patch_get_delta(p);
cl_assert(delta != NULL);
cl_assert_equal_i(GIT_DELTA_MODIFIED, delta->status);
cl_assert_equal_oid(git_blob_id(a), &delta->old_file.id);
cl_assert_equal_sz(git_blob_rawsize(a), delta->old_file.size);
cl_assert_equal_oid(git_blob_id(b), &delta->new_file.id);
cl_assert_equal_sz(git_blob_rawsize(b), delta->new_file.size);
cl_assert_equal_i(hunks, (int)git_patch_num_hunks(p));
if (hunks > 0)
cl_assert_equal_i(l0, git_patch_num_lines_in_hunk(p, 0));
if (hunks > 1)
cl_assert_equal_i(l1, git_patch_num_lines_in_hunk(p, 1));
cl_git_pass(git_patch_line_stats(&tc, &ta, &td, p));
cl_assert_equal_i(ctxt, (int)tc);
cl_assert_equal_i(adds, (int)ta);
cl_assert_equal_i(dels, (int)td);
}
示例5: test_repo_pathspec__workdir2
void test_repo_pathspec__workdir2(void)
{
git_strarray s;
git_pathspec *ps;
git_pathspec_match_list *m;
/* { "staged_*" } */
s.strings = str2; s.count = ARRAY_SIZE(str2);
cl_git_pass(git_pathspec_new(&ps, &s));
cl_git_pass(git_pathspec_match_workdir(&m, g_repo, 0, ps));
cl_assert_equal_sz(5, git_pathspec_match_list_entrycount(m));
git_pathspec_match_list_free(m);
cl_git_pass(git_pathspec_match_workdir(&m, g_repo,
GIT_PATHSPEC_FIND_FAILURES, ps));
cl_assert_equal_sz(5, git_pathspec_match_list_entrycount(m));
cl_assert_equal_sz(0, git_pathspec_match_list_failed_entrycount(m));
git_pathspec_match_list_free(m);
cl_git_fail(git_pathspec_match_workdir(&m, g_repo,
GIT_PATHSPEC_NO_GLOB | GIT_PATHSPEC_NO_MATCH_ERROR, ps));
cl_git_pass(git_pathspec_match_workdir(&m, g_repo,
GIT_PATHSPEC_NO_GLOB | GIT_PATHSPEC_FIND_FAILURES, ps));
cl_assert_equal_sz(0, git_pathspec_match_list_entrycount(m));
cl_assert_equal_sz(1, git_pathspec_match_list_failed_entrycount(m));
git_pathspec_match_list_free(m);
git_pathspec_free(ps);
}
示例6: test_repo_pathspec__tree0
void test_repo_pathspec__tree0(void)
{
git_object *tree;
git_strarray s;
git_pathspec *ps;
git_pathspec_match_list *m;
/* { "*_file", "new_file", "garbage" } */
s.strings = str0; s.count = ARRAY_SIZE(str0);
cl_git_pass(git_pathspec_new(&ps, &s));
cl_git_pass(git_revparse_single(&tree, g_repo, "HEAD~2^{tree}"));
cl_git_pass(git_pathspec_match_tree(&m, (git_tree *)tree,
GIT_PATHSPEC_FIND_FAILURES, ps));
cl_assert_equal_sz(4, git_pathspec_match_list_entrycount(m));
cl_assert_equal_s("current_file", git_pathspec_match_list_entry(m, 0));
cl_assert_equal_s("modified_file", git_pathspec_match_list_entry(m, 1));
cl_assert_equal_s("staged_changes_modified_file", git_pathspec_match_list_entry(m, 2));
cl_assert_equal_s("staged_delete_modified_file", git_pathspec_match_list_entry(m, 3));
cl_assert_equal_s(NULL, git_pathspec_match_list_entry(m, 4));
cl_assert_equal_sz(2, git_pathspec_match_list_failed_entrycount(m));
cl_assert_equal_s("new_file", git_pathspec_match_list_failed_entry(m, 0));
cl_assert_equal_s("garbage", git_pathspec_match_list_failed_entry(m, 1));
cl_assert_equal_s(NULL, git_pathspec_match_list_failed_entry(m, 2));
git_pathspec_match_list_free(m);
git_object_free(tree);
cl_git_pass(git_revparse_single(&tree, g_repo, "HEAD^{tree}"));
cl_git_pass(git_pathspec_match_tree(&m, (git_tree *)tree,
GIT_PATHSPEC_FIND_FAILURES, ps));
cl_assert_equal_sz(7, git_pathspec_match_list_entrycount(m));
cl_assert_equal_s("current_file", git_pathspec_match_list_entry(m, 0));
cl_assert_equal_s("modified_file", git_pathspec_match_list_entry(m, 1));
cl_assert_equal_s("staged_changes_modified_file", git_pathspec_match_list_entry(m, 2));
cl_assert_equal_s("staged_delete_modified_file", git_pathspec_match_list_entry(m, 3));
cl_assert_equal_s("subdir/current_file", git_pathspec_match_list_entry(m, 4));
cl_assert_equal_s("subdir/deleted_file", git_pathspec_match_list_entry(m, 5));
cl_assert_equal_s("subdir/modified_file", git_pathspec_match_list_entry(m, 6));
cl_assert_equal_s(NULL, git_pathspec_match_list_entry(m, 7));
cl_assert_equal_sz(2, git_pathspec_match_list_failed_entrycount(m));
cl_assert_equal_s("new_file", git_pathspec_match_list_failed_entry(m, 0));
cl_assert_equal_s("garbage", git_pathspec_match_list_failed_entry(m, 1));
cl_assert_equal_s(NULL, git_pathspec_match_list_failed_entry(m, 2));
git_pathspec_match_list_free(m);
git_object_free(tree);
git_pathspec_free(ps);
}
示例7: test_refs_reflog_drop__can_persist_deletion_on_disk
void test_refs_reflog_drop__can_persist_deletion_on_disk(void)
{
cl_assert(entrycount > 2);
cl_git_pass(git_reflog_drop(g_reflog, 0, 1));
cl_assert_equal_sz(entrycount - 1, git_reflog_entrycount(g_reflog));
cl_git_pass(git_reflog_write(g_reflog));
git_reflog_free(g_reflog);
git_reflog_read(&g_reflog, g_repo, "HEAD");
cl_assert_equal_sz(entrycount - 1, git_reflog_entrycount(g_reflog));
}
示例8: test_index_tests__reload_from_disk
void test_index_tests__reload_from_disk(void)
{
git_repository *repo;
git_index *read_index;
git_index *write_index;
cl_set_cleanup(&cleanup_myrepo, NULL);
cl_git_pass(git_futils_mkdir("./myrepo", NULL, 0777, GIT_MKDIR_PATH));
cl_git_mkfile("./myrepo/a.txt", "a\n");
cl_git_mkfile("./myrepo/b.txt", "b\n");
cl_git_pass(git_repository_init(&repo, "./myrepo", 0));
cl_git_pass(git_repository_index(&write_index, repo));
cl_assert_equal_i(false, write_index->on_disk);
cl_git_pass(git_index_open(&read_index, write_index->index_file_path));
cl_assert_equal_i(false, read_index->on_disk);
/* Stage two new files against the write_index */
cl_git_pass(git_index_add_bypath(write_index, "a.txt"));
cl_git_pass(git_index_add_bypath(write_index, "b.txt"));
cl_assert_equal_sz(2, git_index_entrycount(write_index));
/* Persist the index changes to disk */
cl_git_pass(git_index_write(write_index));
cl_assert_equal_i(true, write_index->on_disk);
/* Sync the changes back into the read_index */
cl_assert_equal_sz(0, git_index_entrycount(read_index));
cl_git_pass(git_index_read(read_index, true));
cl_assert_equal_i(true, read_index->on_disk);
cl_assert_equal_sz(2, git_index_entrycount(read_index));
/* Remove the index file from the filesystem */
cl_git_pass(p_unlink(write_index->index_file_path));
/* Sync the changes back into the read_index */
cl_git_pass(git_index_read(read_index, true));
cl_assert_equal_i(false, read_index->on_disk);
cl_assert_equal_sz(0, git_index_entrycount(read_index));
git_index_free(read_index);
git_index_free(write_index);
git_repository_free(repo);
}
示例9: test_stash_drop__dropping_an_entry_rewrites_reflog_history
void test_stash_drop__dropping_an_entry_rewrites_reflog_history(void)
{
git_reference *stash;
git_reflog *reflog;
const git_reflog_entry *entry;
git_oid oid;
size_t count;
push_three_states();
cl_git_pass(git_reference_lookup(&stash, repo, GIT_REFS_STASH_FILE));
cl_git_pass(git_reflog_read(&reflog, stash));
entry = git_reflog_entry_byindex(reflog, 1);
git_oid_cpy(&oid, git_reflog_entry_id_old(entry));
count = git_reflog_entrycount(reflog);
git_reflog_free(reflog);
cl_git_pass(git_stash_drop(repo, 1));
cl_git_pass(git_reflog_read(&reflog, stash));
entry = git_reflog_entry_byindex(reflog, 0);
cl_assert_equal_i(0, git_oid_cmp(&oid, git_reflog_entry_id_old(entry)));
cl_assert_equal_sz(count - 1, git_reflog_entrycount(reflog));
git_reflog_free(reflog);
git_reference_free(stash);
}
示例10: test_refs_reflog_drop__can_drop_an_entry
void test_refs_reflog_drop__can_drop_an_entry(void)
{
cl_assert(entrycount > 4);
cl_git_pass(git_reflog_drop(g_reflog, 2, 0));
cl_assert_equal_sz(entrycount - 1, git_reflog_entrycount(g_reflog));
}
示例11: test_diff_drivers__long_lines
void test_diff_drivers__long_lines(void)
{
const char *base = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed non nisi ligula. Ut viverra enim sed lobortis suscipit.\nPhasellus eget erat odio. Praesent at est iaculis, ultricies augue vel, dignissim risus. Suspendisse at nisi quis turpis fringilla rutrum id sit amet nulla.\nNam eget dolor fermentum, aliquet nisl at, convallis tellus. Pellentesque rhoncus erat enim, id porttitor elit euismod quis.\nMauris sollicitudin magna odio, non egestas libero vehicula ut. Etiam et quam velit. Fusce eget libero rhoncus, ultricies felis sit amet, egestas purus.\nAliquam in semper tellus. Pellentesque adipiscing rutrum velit, quis malesuada lacus consequat eget.\n";
git_index *idx;
git_diff_list *diff;
git_diff_patch *patch;
char *actual;
const char *expected = "diff --git a/longlines.txt b/longlines.txt\nindex c1ce6ef..0134431 100644\n--- a/longlines.txt\n+++ b/longlines.txt\[email protected]@ -3,3 +3,5 @@ Phasellus eget erat odio. Praesent at est iaculis, ultricies augue vel, dignissi\n Nam eget dolor fermentum, aliquet nisl at, convallis tellus. Pellentesque rhoncus erat enim, id porttitor elit euismod quis.\n Mauris sollicitudin magna odio, non egestas libero vehicula ut. Etiam et quam velit. Fusce eget libero rhoncus, ultricies felis sit amet, egestas purus.\n Aliquam in semper tellus. Pellentesque adipiscing rutrum velit, quis malesuada lacus consequat eget.\n+newline\n+newline\n";
g_repo = cl_git_sandbox_init("empty_standard_repo");
cl_git_mkfile("empty_standard_repo/longlines.txt", base);
cl_git_pass(git_repository_index(&idx, g_repo));
cl_git_pass(git_index_add_bypath(idx, "longlines.txt"));
cl_git_pass(git_index_write(idx));
git_index_free(idx);
cl_git_append2file("empty_standard_repo/longlines.txt", "newline\nnewline\n");
cl_git_pass(git_diff_index_to_workdir(&diff, g_repo, NULL, NULL));
cl_assert_equal_sz(1, git_diff_num_deltas(diff));
cl_git_pass(git_diff_get_patch(&patch, NULL, diff, 0));
cl_git_pass(git_diff_patch_to_str(&actual, patch));
cl_assert_equal_s(expected, actual);
free(actual);
git_diff_patch_free(patch);
git_diff_list_free(diff);
}
示例12: test_refs_reflog_messages__creating_a_direct_reference
void test_refs_reflog_messages__creating_a_direct_reference(void)
{
git_reference *reference;
git_oid id;
git_reflog *reflog;
const git_reflog_entry *entry;
const char *name = "refs/heads/new-head";
const char *message = "You've been logged, mate!";
cl_git_pass(git_reference_name_to_id(&id, g_repo, "HEAD"));
cl_git_pass(git_reference_create(&reference, g_repo, name, &id, 0, message));
cl_git_pass(git_reflog_read(&reflog, g_repo, name));
cl_assert_equal_sz(1, git_reflog_entrycount(reflog));
entry = git_reflog_entry_byindex(reflog, 0);
cl_assert(git_oid_streq(&entry->oid_old, GIT_OID_HEX_ZERO) == 0);
cl_assert_equal_oid(&id, &entry->oid_cur);
cl_assert_equal_s(message, entry->msg);
git_reflog_free(reflog);
git_reference_free(reference);
}
示例13: test_status_worktree__at_head_parent
void test_status_worktree__at_head_parent(void)
{
git_repository *repo = cl_git_sandbox_init("empty_standard_repo");
git_status_options opts = GIT_STATUS_OPTIONS_INIT;
git_status_list *statuslist;
git_tree *parent_tree;
const git_status_entry *status;
cl_git_mkfile("empty_standard_repo/file1", "ping");
stage_and_commit(repo, "file1");
cl_git_pass(git_repository_head_tree(&parent_tree, repo));
cl_git_mkfile("empty_standard_repo/file2", "pong");
stage_and_commit(repo, "file2");
cl_git_rewritefile("empty_standard_repo/file2", "pyng");
opts.show = GIT_STATUS_SHOW_INDEX_AND_WORKDIR;
opts.baseline = parent_tree;
cl_git_pass(git_status_list_new(&statuslist, repo, &opts));
cl_assert_equal_sz(1, git_status_list_entrycount(statuslist));
status = git_status_byindex(statuslist, 0);
cl_assert(status != NULL);
cl_assert_equal_s("file2", status->index_to_workdir->old_file.path);
cl_assert_equal_i(GIT_STATUS_WT_MODIFIED | GIT_STATUS_INDEX_NEW, status->status);
git_tree_free(parent_tree);
git_status_list_free(statuslist);
}
示例14: test_revwalk_mergebase__two_way_merge
void test_revwalk_mergebase__two_way_merge(void)
{
git_oid one, two;
size_t ahead, behind;
cl_git_pass(git_oid_fromstr(&one, "9b219343610c88a1187c996d0dc58330b55cee28"));
cl_git_pass(git_oid_fromstr(&two, "a953a018c5b10b20c86e69fef55ebc8ad4c5a417"));
cl_git_pass(git_graph_ahead_behind(&ahead, &behind, _repo2, &one, &two));
cl_assert_equal_sz(ahead, 2);
cl_assert_equal_sz(behind, 8);
cl_git_pass(git_graph_ahead_behind(&ahead, &behind, _repo2, &two, &one));
cl_assert_equal_sz(ahead, 8);
cl_assert_equal_sz(behind, 2);
}
示例15: test_diff_stats__shortstat
void test_diff_stats__shortstat(void)
{
git_buf buf = GIT_BUF_INIT;
const char *stat =
" 1 file changed, 5 insertions(+), 3 deletions(-)\n";
diff_stats_from_commit_oid(
&_stats, "9264b96c6d104d0e07ae33d3007b6a48246c6f92", false);
cl_assert_equal_sz(1, git_diff_stats_files_changed(_stats));
cl_assert_equal_sz(5, git_diff_stats_insertions(_stats));
cl_assert_equal_sz(3, git_diff_stats_deletions(_stats));
cl_git_pass(git_diff_stats_to_buf(&buf, _stats, GIT_DIFF_STATS_SHORT, 0));
cl_assert_equal_s(stat, git_buf_cstr(&buf));
git_buf_free(&buf);
}