Esempio n. 1
0
void test_refs_branches_delete__can_not_delete_a_branch_pointed_at_by_HEAD(void)
{
	git_reference *head;
	git_reference *branch;

	/* Ensure HEAD targets the local master branch */
	cl_git_pass(git_reference_lookup(&head, repo, GIT_HEAD_FILE));
	cl_assert_equal_s("refs/heads/master", git_reference_symbolic_target(head));
	git_reference_free(head);

	cl_git_pass(git_branch_lookup(&branch, repo, "master", GIT_BRANCH_LOCAL));
	cl_git_fail(git_branch_delete(branch));
	git_reference_free(branch);
}
Esempio n. 2
0
void test_diff_stats__numstat(void)
{
	git_buf buf = GIT_BUF_INIT;
	const char *stat =
	"3       2       file2.txt\n"
	"4       2       file3.txt\n";

	diff_stats_from_commit_oid(
		&_stats, "cd471f0d8770371e1bc78bcbb38db4c7e4106bd2", false);

	cl_git_pass(git_diff_stats_to_buf(&buf, _stats, GIT_DIFF_STATS_NUMBER, 0));
	cl_assert_equal_s(stat, git_buf_cstr(&buf));
	git_buf_free(&buf);
}
Esempio n. 3
0
void test_refs_branches_move__moving_the_branch_pointed_at_by_HEAD_updates_HEAD(void)
{
	git_reference *branch;
	git_reference *new_branch;

	cl_git_pass(git_reference_lookup(&branch, repo, "refs/heads/master"));
	cl_git_pass(git_branch_move(&new_branch, branch, "master2", 0));
	git_reference_free(branch);
	git_reference_free(new_branch);

	cl_git_pass(git_repository_head(&branch, repo));
	cl_assert_equal_s("refs/heads/master2", git_reference_name(branch));
	git_reference_free(branch);
}
Esempio n. 4
0
void test_odb_backend_nobackend__write_fails_gracefully(void)
{
	git_oid id;
	git_odb *odb;
	const git_error *err;

	git_repository_odb(&odb, _repo);
	cl_git_fail(git_odb_write(&id, odb, "Hello world!\n", 13, GIT_OBJ_BLOB));

	err = giterr_last();
	cl_assert_equal_s(err->message, "cannot write object - unsupported in the loaded odb backends");

	git_odb_free(odb);
}
Esempio n. 5
0
void test_repo_init__can_reinit_an_initialized_repository(void)
{
	git_repository *reinit;

	cl_git_pass(git_futils_mkdir("extended", NULL, 0775, 0));
	cl_git_pass(git_repository_init(&_repo, "extended", false));

	cl_git_pass(git_repository_init(&reinit, "extended", false));

	cl_assert_equal_s(git_repository_path(_repo), git_repository_path(reinit));

	git_repository_free(reinit);
	cleanup_repository("extended");
}
Esempio n. 6
0
static int confirm_submodule_status(
	const char *path, unsigned int status_flags, void *payload)
{
	submodule_expectations *exp = payload;

	while (git__suffixcmp(exp->paths[exp->counter], "/") == 0)
		exp->counter++;

	cl_assert_equal_s(exp->paths[exp->counter++], path);

	GIT_UNUSED(status_flags);

	return 0;
}
Esempio n. 7
0
static void check_fromurl(const char *expected_result, const char *input, int should_fail)
{
	git_buf buf = GIT_BUF_INIT;

	assert(should_fail || expected_result);

	if (!should_fail) {
		cl_git_pass(git_path_fromurl(&buf, input));
		cl_assert_equal_s(expected_result, git_buf_cstr(&buf));
	} else
		cl_git_fail(git_path_fromurl(&buf, input));

	git_buf_dispose(&buf);
}
Esempio n. 8
0
void test_refs_read__loose_first(void)
{
   // assure that a loose reference is looked up before a packed reference
	git_reference *reference;

	cl_git_pass(git_reference_lookup(&reference, g_repo, packed_head_name));
	git_reference_free(reference);
	cl_git_pass(git_reference_lookup(&reference, g_repo, packed_test_head_name));
	cl_assert(git_reference_type(reference) & GIT_REF_OID);
	cl_assert(git_reference_is_packed(reference) == 0);
	cl_assert_equal_s(reference->name, packed_test_head_name);

	git_reference_free(reference);
}
Esempio n. 9
0
void test_rebase_merge__finish_with_ids(void)
{
	git_rebase *rebase;
	git_reference *head_ref;
	git_oid branch_id, upstream_id;
	git_annotated_commit *branch_head, *upstream_head;
	git_rebase_operation *rebase_operation;
	git_oid commit_id;
	git_reflog *reflog;
	const git_reflog_entry *reflog_entry;
	int error;

	cl_git_pass(git_oid_fromstr(&branch_id, "d616d97082eb7bb2dc6f180a7cca940993b7a56f"));
	cl_git_pass(git_oid_fromstr(&upstream_id, "f87d14a4a236582a0278a916340a793714256864"));

	cl_git_pass(git_annotated_commit_lookup(&branch_head, repo, &branch_id));
	cl_git_pass(git_annotated_commit_lookup(&upstream_head, repo, &upstream_id));

	cl_git_pass(git_rebase_init(&rebase, repo, branch_head, upstream_head, NULL, NULL));

	cl_git_pass(git_rebase_next(&rebase_operation, rebase));
	cl_git_pass(git_rebase_commit(&commit_id, rebase, NULL, signature,
		NULL, NULL));

	cl_git_fail(error = git_rebase_next(&rebase_operation, rebase));
	cl_assert_equal_i(GIT_ITEROVER, error);

	cl_git_pass(git_rebase_finish(rebase, signature));

	cl_assert_equal_i(GIT_REPOSITORY_STATE_NONE, git_repository_state(repo));

	cl_git_pass(git_reference_lookup(&head_ref, repo, "HEAD"));
	cl_assert_equal_i(GIT_REF_OID, git_reference_type(head_ref));
	cl_assert_equal_oid(&commit_id, git_reference_target(head_ref));

	/* reflogs are not updated as if we were operating on proper
	 * branches.  check that the last reflog entry is the rebase.
	 */
	cl_git_pass(git_reflog_read(&reflog, repo, "HEAD"));
	cl_assert(reflog_entry = git_reflog_entry_byindex(reflog, 0));
	cl_assert_equal_oid(&commit_id, git_reflog_entry_id_new(reflog_entry));
	cl_assert_equal_s("rebase: Modification 3 to gravy", git_reflog_entry_message(reflog_entry));
	git_reflog_free(reflog);

	git_annotated_commit_free(branch_head);
	git_annotated_commit_free(upstream_head);
	git_reference_free(head_ref);
	git_rebase_free(rebase);
}
Esempio n. 10
0
void test_reset_hard__resetting_reverts_modified_files(void)
{
    git_buf path = GIT_BUF_INIT, content = GIT_BUF_INIT;
    int i;
    static const char *files[4] = {
        "current_file",
        "modified_file",
        "staged_new_file",
        "staged_changes_modified_file"
    };
    static const char *before[4] = {
        "current_file\n",
        "modified_file\nmodified_file\n",
        "staged_new_file\n",
        "staged_changes_modified_file\nstaged_changes_modified_file\nstaged_changes_modified_file\n"
    };
    static const char *after[4] = {
        "current_file\n",
        "modified_file\n",
        NULL,
        "staged_changes_modified_file\n"
    };
    const char *wd = git_repository_workdir(repo);

    cl_assert(wd);

    for (i = 0; i < 4; ++i) {
        cl_git_pass(git_buf_joinpath(&path, wd, files[i]));
        cl_git_pass(git_futils_readbuffer(&content, path.ptr));
        cl_assert_equal_s(before[i], content.ptr);
    }

    cl_git_pass(git_revparse_single(&target, repo, "26a125e"));

    cl_git_pass(git_reset(repo, target, GIT_RESET_HARD, NULL));

    for (i = 0; i < 4; ++i) {
        cl_git_pass(git_buf_joinpath(&path, wd, files[i]));
        if (after[i]) {
            cl_git_pass(git_futils_readbuffer(&content, path.ptr));
            cl_assert(strequal_ignore_eol(after[i], content.ptr));
        } else {
            cl_assert(!git_path_exists(path.ptr));
        }
    }

    git_buf_free(&content);
    git_buf_free(&path);
}
Esempio n. 11
0
static void index_iterator_test(
	const char *sandbox,
	const char *start,
	const char *end,
	git_iterator_flag_t flags,
	int expected_count,
	const char **expected_names,
	const char **expected_oids)
{
	git_index *index;
	git_iterator *i;
	const git_index_entry *entry;
	int error, count = 0, caps;
	git_repository *repo = cl_git_sandbox_init(sandbox);
	git_iterator_options iter_opts = GIT_ITERATOR_OPTIONS_INIT;

	cl_git_pass(git_repository_index(&index, repo));
	caps = git_index_caps(index);

	iter_opts.flags = flags;
	iter_opts.start = start;
	iter_opts.end = end;

	cl_git_pass(git_iterator_for_index(&i, repo, index, &iter_opts));

	while (!(error = git_iterator_advance(&entry, i))) {
		cl_assert(entry);

		if (expected_names != NULL)
			cl_assert_equal_s(expected_names[count], entry->path);

		if (expected_oids != NULL) {
			git_oid oid;
			cl_git_pass(git_oid_fromstr(&oid, expected_oids[count]));
			cl_assert_equal_oid(&oid, &entry->id);
		}

		count++;
	}

	cl_assert_equal_i(GIT_ITEROVER, error);
	cl_assert(!entry);
	cl_assert_equal_i(expected_count, count);

	git_iterator_free(i);

	cl_assert(caps == git_index_caps(index));
	git_index_free(index);
}
Esempio n. 12
0
void test_online_clone__empty_repository(void)
{
	git_reference *head;

	cl_git_pass(git_clone(&g_repo, LIVE_EMPTYREPO_URL, "./foo", &g_options));

	cl_assert_equal_i(true, git_repository_is_empty(g_repo));
	cl_assert_equal_i(true, git_repository_head_unborn(g_repo));

	cl_git_pass(git_reference_lookup(&head, g_repo, GIT_HEAD_FILE));
	cl_assert_equal_i(GIT_REF_SYMBOLIC, git_reference_type(head));
	cl_assert_equal_s("refs/heads/master", git_reference_symbolic_target(head));

	git_reference_free(head);
}
Esempio n. 13
0
void test_network_remote_remotes__pushurl(void)
{
	const char *name = git_remote_name(_remote);
	git_remote *mod;

	cl_git_pass(git_remote_set_pushurl(_repo, name, "git://github.com/libgit2/notlibgit2"));
	cl_git_pass(git_remote_lookup(&mod, _repo, name));
	cl_assert_equal_s(git_remote_pushurl(mod), "git://github.com/libgit2/notlibgit2");
	git_remote_free(mod);

	cl_git_pass(git_remote_set_pushurl(_repo, name, NULL));
	cl_git_pass(git_remote_lookup(&mod, _repo, name));
	cl_assert(git_remote_pushurl(mod) == NULL);
	git_remote_free(mod);
}
Esempio n. 14
0
void test_object_shortid__select(void)
{
	git_oid full;
	git_object *obj;
	git_buf shorty = {0};

	git_oid_fromstr(&full, "ce013625030ba8dba906f756967f9e9ca394464a");
	cl_git_pass(git_object_lookup(&obj, _repo, &full, GIT_OBJ_ANY));
	cl_git_pass(git_object_short_id(&shorty, obj));
	cl_assert_equal_i(7, shorty.size);
	cl_assert_equal_s("ce01362", shorty.ptr);
	git_object_free(obj);

	git_oid_fromstr(&full, "038d718da6a1ebbc6a7780a96ed75a70cc2ad6e2");
	cl_git_pass(git_object_lookup(&obj, _repo, &full, GIT_OBJ_ANY));
	cl_git_pass(git_object_short_id(&shorty, obj));
	cl_assert_equal_i(7, shorty.size);
	cl_assert_equal_s("038d718", shorty.ptr);
	git_object_free(obj);

	git_oid_fromstr(&full, "dea509d097ce692e167dfc6a48a7a280cc5e877e");
	cl_git_pass(git_object_lookup(&obj, _repo, &full, GIT_OBJ_ANY));
	cl_git_pass(git_object_short_id(&shorty, obj));
	cl_assert_equal_i(9, shorty.size);
	cl_assert_equal_s("dea509d09", shorty.ptr);
	git_object_free(obj);

	git_oid_fromstr(&full, "dea509d0b3cb8ee0650f6ca210bc83f4678851ba");
	cl_git_pass(git_object_lookup(&obj, _repo, &full, GIT_OBJ_ANY));
	cl_git_pass(git_object_short_id(&shorty, obj));
	cl_assert_equal_i(9, shorty.size);
	cl_assert_equal_s("dea509d0b", shorty.ptr);
	git_object_free(obj);

	git_buf_free(&shorty);
}
Esempio n. 15
0
void test_diff_stats__mode_change(void)
{
	git_buf buf = GIT_BUF_INIT;
	const char *stat =
	" file1.txt.renamed | 0\n" \
	" 1 file changed, 0 insertions(+), 0 deletions(-)\n" \
		" mode change 100644 => 100755 file1.txt.renamed\n";

	diff_stats_from_commit_oid(
		&_stats, "7ade76dd34bba4733cf9878079f9fd4a456a9189", false);

	cl_git_pass(git_diff_stats_to_buf(&buf, _stats, GIT_DIFF_STATS_FULL | GIT_DIFF_STATS_INCLUDE_SUMMARY, 0));
	cl_assert_equal_s(stat, git_buf_cstr(&buf));
	git_buf_free(&buf);
}
Esempio n. 16
0
void test_config_read__case_sensitive(void)
{
	git_config *cfg;
	int i;

	cl_git_pass(git_config_open_ondisk(&cfg, cl_fixture("config/config1")));

	cl_git_pass(git_config_get_string_buf(&buf, cfg, "this.that.other"));
	cl_assert_equal_s("true", git_buf_cstr(&buf));
	git_buf_clear(&buf);

	cl_git_pass(git_config_get_string_buf(&buf, cfg, "this.That.other"));
	cl_assert_equal_s("yes", git_buf_cstr(&buf));

	cl_git_pass(git_config_get_bool(&i, cfg, "this.that.other"));
	cl_assert(i == 1);
	cl_git_pass(git_config_get_bool(&i, cfg, "this.That.other"));
	cl_assert(i == 1);

	/* This one doesn't exist */
	cl_must_fail(git_config_get_bool(&i, cfg, "this.thaT.other"));

	git_config_free(cfg);
}
Esempio n. 17
0
File: nav.c Progetto: nvdnkpr/ssm
void test_nav__nav_it_theta_opts_no_diff(void)
{
    int i;

    ssm_options_t *opts_nd = ssm_options_new();
    opts_nd->noises_off = SSM_NO_DIFF;
    ssm_nav_t *nav_nd = ssm_nav_new(jparameters, opts_nd);

    cl_check(nav_nd->theta_no_icsv_no_icdiff->length == 7);
    cl_check(nav_nd->theta_icsv_icdiff->length == 3);

    char *expected_names[] = {"pr_I_nyc", "pr_I_paris", "pr_S_paris"};
    for(i=0; i<nav_nd->theta_icsv_icdiff->length; i++) {
        cl_assert_equal_s(nav_nd->theta_icsv_icdiff->p[i]->name, expected_names[i]);
    }

    char *expected_names_no[] = {"r0_nyc", "r0_paris", "pr_v", "rep_all_CDC_inc", "rep_all_google_inc", "rep_nyc_CDC_inc", "rep_paris_CDC_prev"};
    for(i=0; i<nav_nd->theta_no_icsv_no_icdiff->length; i++) {
        cl_assert_equal_s(nav_nd->theta_no_icsv_no_icdiff->p[i]->name, expected_names_no[i]);
    }

    ssm_options_free(opts_nd);
    ssm_nav_free(nav_nd);
}
Esempio n. 18
0
static void assert_correct_reflog(const char *name)
{
	git_reflog *log;
	const git_reflog_entry *entry;
	char expected_log_message[128] = {0};

	sprintf(expected_log_message, "clone: from %s", cl_git_fixture_url("testrepo.git"));

	cl_git_pass(git_reflog_read(&log, g_repo, name));
	cl_assert_equal_i(1, git_reflog_entrycount(log));
	entry = git_reflog_entry_byindex(log, 0);
	cl_assert_equal_s(expected_log_message, git_reflog_entry_message(entry));

	git_reflog_free(log);
}
Esempio n. 19
0
void test_index_reuc__write(void)
{
	git_oid ancestor_oid, our_oid, their_oid;
	const git_index_reuc_entry *reuc;

	git_index_clear(repo_index);

	/* Write out of order to ensure sorting is correct */
	git_oid_fromstr(&ancestor_oid, TWO_ANCESTOR_OID);
	git_oid_fromstr(&our_oid, TWO_OUR_OID);
	git_oid_fromstr(&their_oid, TWO_THEIR_OID);

	cl_git_pass(git_index_reuc_add(repo_index, "two.txt",
		0100644, &ancestor_oid,
		0100644, &our_oid,
		0100644, &their_oid));

	git_oid_fromstr(&ancestor_oid, ONE_ANCESTOR_OID);
	git_oid_fromstr(&our_oid, ONE_OUR_OID);
	git_oid_fromstr(&their_oid, ONE_THEIR_OID);

	cl_git_pass(git_index_reuc_add(repo_index, "one.txt",
		0100644, &ancestor_oid,
		0100644, &our_oid,
		0100644, &their_oid));

	cl_git_pass(git_index_write(repo_index));
	cl_assert_equal_i(2, git_index_reuc_entrycount(repo_index));

	/* ensure sort order was round-tripped correct */
	cl_assert(reuc = git_index_reuc_get_byindex(repo_index, 0));
	cl_assert_equal_s("one.txt", reuc->path);

	cl_assert(reuc = git_index_reuc_get_byindex(repo_index, 1));
	cl_assert_equal_s("two.txt", reuc->path);
}
Esempio n. 20
0
void test_core_buffer__base64(void)
{
	git_buf buf = GIT_BUF_INIT;

	/*     t  h  i  s
	 * 0x 74 68 69 73
     * 0b 01110100 01101000 01101001 01110011
	 * 0b 011101 000110 100001 101001 011100 110000
	 * 0x 1d 06 21 29 1c 30
	 *     d  G  h  p  c  w
	 */
	cl_git_pass(git_buf_put_base64(&buf, "this", 4));
	cl_assert_equal_s("dGhpcw==", buf.ptr);

	git_buf_clear(&buf);
	cl_git_pass(git_buf_put_base64(&buf, "this!", 5));
	cl_assert_equal_s("dGhpcyE=", buf.ptr);

	git_buf_clear(&buf);
	cl_git_pass(git_buf_put_base64(&buf, "this!\n", 6));
	cl_assert_equal_s("dGhpcyEK", buf.ptr);

	git_buf_free(&buf);
}
Esempio n. 21
0
static void
check_joinbuf_n_4(
	const char *a,
	const char *b,
	const char *c,
	const char *d,
	const char *expected)
{
	char sep = ';';
	git_buf buf = GIT_BUF_INIT;
	git_buf_join_n(&buf, sep, 4, a, b, c, d);
	cl_assert(git_buf_oom(&buf) == 0);
	cl_assert_equal_s(expected, git_buf_cstr(&buf));
	git_buf_free(&buf);
}
Esempio n. 22
0
static int notify_cb(
	const char *skipped_file,
	const git_oid *blob_oid,
	int file_mode,
	void *payload)
{
	struct notify_data *expectations = (struct notify_data *)payload;

	GIT_UNUSED(file_mode);

	cl_assert_equal_s(expectations->file, skipped_file);
	cl_assert_equal_i(0, git_oid_streq(blob_oid, expectations->sha));

	return 0;
}
Esempio n. 23
0
/* Test that we can read a note */
void test_notes_notes__can_read_a_note(void)
{
	git_oid note_oid, target_oid;
	git_note *note;

	create_note(&note_oid, "refs/notes/i-can-see-dead-notes", "4a202b346bb0fb0db7eff3cffeb3c70babbd2045", "I decorate 4a20\n");

	cl_git_pass(git_oid_fromstr(&target_oid, "4a202b346bb0fb0db7eff3cffeb3c70babbd2045"));

	cl_git_pass(git_note_read(&note, _repo, "refs/notes/i-can-see-dead-notes", &target_oid));

	cl_assert_equal_s(git_note_message(note), "I decorate 4a20\n");

	git_note_free(note);
}
Esempio n. 24
0
void test_core_buffer__decode_base85_fails_gracefully(void)
{
	git_buf buf = GIT_BUF_INIT;

	git_buf_puts(&buf, "foobar");

	cl_git_fail(git_buf_decode_base85(&buf, "invalid charsZZ", 15, 42));
	cl_git_fail(git_buf_decode_base85(&buf, "invalidchars__ ", 15, 42));
	cl_git_fail(git_buf_decode_base85(&buf, "overflowZZ~~~~~", 15, 42));
	cl_git_fail(git_buf_decode_base85(&buf, "truncated", 9, 42));
	cl_assert_equal_sz(6, buf.size);
	cl_assert_equal_s("foobar", buf.ptr);

	git_buf_free(&buf);
}
Esempio n. 25
0
static void assert_submodule_url(const char* name, const char *url)
{
	git_config *cfg;
	const char *s;
	git_buf key = GIT_BUF_INIT;

	cl_git_pass(git_repository_config(&cfg, g_repo));

	cl_git_pass(git_buf_printf(&key, "submodule.%s.url", name));
	cl_git_pass(git_config_get_string(&s, cfg, git_buf_cstr(&key)));
	cl_assert_equal_s(s, url);

	git_config_free(cfg);
	git_buf_free(&key);
}
Esempio n. 26
0
/* Ensures that custom shortnames are included: creates a GIT~1 so that the
 * .git folder itself will have to be named GIT~2
 */
void test_repo_reservedname__custom_shortname_recognized(void)
{
#ifdef GIT_WIN32
	git_repository *repo;
	git_buf *reserved;
	size_t reserved_len;

	if (!cl_sandbox_supports_8dot3())
		clar__skip();

	repo = cl_git_sandbox_init("nasty");

	cl_must_pass(p_rename("nasty/.git", "nasty/_temp"));
	cl_git_write2file("nasty/git~1", "", 0, O_RDWR|O_CREAT, 0666);
	cl_must_pass(p_rename("nasty/_temp", "nasty/.git"));

	cl_assert(git_repository__reserved_names(&reserved, &reserved_len, repo, true));

	cl_assert_equal_i(3, reserved_len);
	cl_assert_equal_s(".git", reserved[0].ptr);
	cl_assert_equal_s("GIT~1", reserved[1].ptr);
	cl_assert_equal_s("GIT~2", reserved[2].ptr);
#endif
}
Esempio n. 27
0
/*
 * This kind of subsection declaration is case-insensitive
 */
void test_config_read__subsection_header(void)
{
	git_config *cfg;
	const char *str;

	cl_git_pass(git_config_open_ondisk(&cfg, cl_fixture("config/config3")));

	cl_git_pass(git_config_get_string(&str, cfg, "section.subsection.var"));
	cl_assert_equal_s(str, "hello");

	/* The subsection is transformed to lower-case */
	cl_must_fail(git_config_get_string(&str, cfg, "section.subSectIon.var"));

	git_config_free(cfg);
}
Esempio n. 28
0
void test_config_read__lone_variable(void)
{
	git_config *cfg;
	int i;

	cl_git_pass(git_config_open_ondisk(&cfg, cl_fixture("config/config4")));

	cl_git_fail(git_config_get_int32(&i, cfg, "some.section.variable"));

	cl_git_pass(git_config_get_string_buf(&buf, cfg, "some.section.variable"));
	cl_assert_equal_s("", git_buf_cstr(&buf));
	git_buf_clear(&buf);

	cl_git_pass(git_config_get_bool(&i, cfg, "some.section.variable"));
	cl_assert(i == 1);

	cl_git_pass(git_config_get_string_buf(&buf, cfg, "some.section.variableeq"));
	cl_assert_equal_s("", git_buf_cstr(&buf));

	cl_git_pass(git_config_get_bool(&i, cfg, "some.section.variableeq"));
	cl_assert(i == 0);

	git_config_free(cfg);
}
Esempio n. 29
0
static void assert_commit_parses(const char *data, size_t datalen,
	const char *expected_treeid,
	const char *expected_author,
	const char *expected_committer,
	const char *expected_encoding,
	const char *expected_message,
	size_t expected_parents)
{
	git_commit *commit;
	if (!datalen)
		datalen = strlen(data);
	cl_git_pass(git_object__from_raw((git_object **) &commit, data, datalen, GIT_OBJECT_COMMIT));

	if (expected_author) {
		git_signature *author;
		cl_git_pass(git_signature_from_buffer(&author, expected_author));
		cl_assert(git_signature__equal(author, commit->author));
		cl_assert_equal_s(author->name, commit->author->name);
		cl_assert_equal_s(author->email, commit->author->email);
		cl_assert_equal_i(author->when.time, commit->author->when.time);
		cl_assert_equal_i(author->when.offset, commit->author->when.offset);
		cl_assert_equal_i(author->when.sign, commit->author->when.sign);
		git_signature_free(author);
	}

	if (expected_committer) {
		git_signature *committer;
		cl_git_pass(git_signature_from_buffer(&committer, expected_committer));
		cl_assert_equal_s(committer->name, commit->committer->name);
		cl_assert_equal_s(committer->email, commit->committer->email);
		cl_assert_equal_i(committer->when.time, commit->committer->when.time);
		cl_assert_equal_i(committer->when.offset, commit->committer->when.offset);
		cl_assert_equal_i(committer->when.sign, commit->committer->when.sign);
		git_signature_free(committer);
	}

	if (expected_encoding)
		cl_assert_equal_s(commit->message_encoding, expected_encoding);
	else
		cl_assert_equal_p(commit->message_encoding, NULL);

	if (expected_message)
		cl_assert_equal_s(commit->raw_message, expected_message);
	else
		cl_assert_equal_p(commit->message_encoding, NULL);

	if (expected_treeid) {
		git_oid tree_oid;
		cl_git_pass(git_oid_fromstr(&tree_oid, expected_treeid));
		cl_assert_equal_oid(&tree_oid, &commit->tree_id);
	}

	cl_assert_equal_i(commit->parent_ids.size, expected_parents);

	git_object__free(&commit->object);
}
Esempio n. 30
0
File: nav.c Progetto: nvdnkpr/ssm
void test_nav__nav_it_theta(void)
{
    int i;

    cl_check(nav->theta_all->length == 10);
    cl_check(nav->theta_no_icsv_no_icdiff->length == 5);
    cl_check(nav->theta_icsv_icdiff->length == 5);

    char *expected_names[] = {"pr_I_nyc", "pr_I_paris", "pr_S_paris", "r0_nyc", "r0_paris", "pr_v", "rep_all_CDC_inc", "rep_all_google_inc", "rep_nyc_CDC_inc", "rep_paris_CDC_prev"};
    for(i=0; i<nav->theta_all->length; i++) {
        cl_assert_equal_s(nav->theta_all->p[i]->name, expected_names[i]);
    }

    char *expected_names_ic[] = {"pr_I_nyc", "pr_I_paris", "pr_S_paris", "r0_nyc", "r0_paris"};
    for(i=0; i<nav->theta_icsv_icdiff->length; i++) {
        cl_assert_equal_s(nav->theta_icsv_icdiff->p[i]->name, expected_names_ic[i]);
    }

    char *expected_names_no[] = {"pr_v", "rep_all_CDC_inc", "rep_all_google_inc", "rep_nyc_CDC_inc", "rep_paris_CDC_prev"};
    for(i=0; i<nav->theta_no_icsv_no_icdiff->length; i++) {
        cl_assert_equal_s(nav->theta_no_icsv_no_icdiff->p[i]->name, expected_names_no[i]);
    }

}