コード例 #1
0
ファイル: frompath.c プロジェクト: 0CV0/libgit2
void test_object_tree_frompath__fail_when_processing_an_invalid_path(void)
{
	git_tree_entry *e;

	cl_must_fail(git_tree_entry_bypath(&e, tree, "/"));
	cl_must_fail(git_tree_entry_bypath(&e, tree, "/ab"));
	cl_must_fail(git_tree_entry_bypath(&e, tree, "/ab/de"));
	cl_must_fail(git_tree_entry_bypath(&e, tree, "ab//de"));
}
コード例 #2
0
ファイル: read.c プロジェクト: CodeSmithyIDE/libgit2
/*
 * This kind of subsection declaration is case-insensitive
 */
void test_config_read__subsection_header(void)
{
	git_config *cfg;

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

	cl_git_pass(git_config_get_string_buf(&buf, cfg, "section.subsection.var"));
	cl_assert_equal_s("hello", git_buf_cstr(&buf));

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

	git_config_free(cfg);
}
コード例 #3
0
ファイル: workdir.c プロジェクト: DavidMolinari/sonic-pi
/* git reset --hard 5acdc74af27172ec491d213ee36cea7eb9ef2579
 * git revert HEAD */
void test_revert_workdir__merge_fails_without_mainline_specified(void)
{
	git_commit *head;
	git_oid head_oid;

	git_oid_fromstr(&head_oid, "5acdc74af27172ec491d213ee36cea7eb9ef2579");
	cl_git_pass(git_commit_lookup(&head, repo, &head_oid));
	cl_git_pass(git_reset(repo, (git_object *)head, GIT_RESET_HARD, NULL));

	cl_must_fail(git_revert(repo, head, NULL));
	cl_assert(!git_path_exists(TEST_REPO_PATH "/.git/MERGE_MSG"));
	cl_assert(!git_path_exists(TEST_REPO_PATH "/.git/REVERT_HEAD"));

	git_commit_free(head);
}
コード例 #4
0
ファイル: workdir.c プロジェクト: DavidMolinari/sonic-pi
void test_revert_workdir__nonmerge_fails_mainline_specified(void)
{
	git_reference *head;
	git_commit *commit;
	git_revert_options opts = GIT_REVERT_OPTIONS_INIT;

	cl_git_pass(git_repository_head(&head, repo));
	cl_git_pass(git_reference_peel((git_object **)&commit, head, GIT_OBJ_COMMIT));

	opts.mainline = 1;
	cl_must_fail(git_revert(repo, commit, &opts));
	cl_assert(!git_path_exists(TEST_REPO_PATH "/.git/MERGE_MSG"));
	cl_assert(!git_path_exists(TEST_REPO_PATH "/.git/REVERT_HEAD"));

	git_reference_free(head);
	git_commit_free(commit);
}
コード例 #5
0
ファイル: workdir.c プロジェクト: CodeSmithyIDE/libgit2
/* git reset --hard cfc4f0999a8367568e049af4f72e452d40828a15
 * git cherry-pick abe4603bc7cd5b8167a267e0e2418fd2348f8cff
 */
void test_cherrypick_workdir__merge_fails_without_mainline_specified(void)
{
	git_commit *head, *commit;
	git_oid head_oid, cherry_oid;

	git_oid_fromstr(&head_oid, "cfc4f0999a8367568e049af4f72e452d40828a15");
	cl_git_pass(git_commit_lookup(&head, repo, &head_oid));
	cl_git_pass(git_reset(repo, (git_object *)head, GIT_RESET_HARD, NULL));

	git_oid_fromstr(&cherry_oid, "abe4603bc7cd5b8167a267e0e2418fd2348f8cff");
	cl_git_pass(git_commit_lookup(&commit, repo, &cherry_oid));

	cl_must_fail(git_cherrypick(repo, commit, NULL));
	cl_assert(!git_path_exists(TEST_REPO_PATH "/.git/CHERRY_PICK_HEAD"));
	cl_assert(!git_path_exists(TEST_REPO_PATH "/.git/MERGE_MSG"));

	git_commit_free(commit);
	git_commit_free(head);
}
コード例 #6
0
void test_config_read__case_sensitive(void)
{
	git_config *cfg;
	int i;
	const char *str;

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

	cl_git_pass(git_config_get_string(&str, cfg, "this.that.other"));
	cl_assert_equal_s(str, "true");
	cl_git_pass(git_config_get_string(&str, cfg, "this.That.other"));
	cl_assert_equal_s(str, "yes");

	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);
}
コード例 #7
0
ファイル: write.c プロジェクト: Angolier/sonic-pi
void test_config_write__replace_value(void)
{
	git_config *cfg;
	int i;
	int64_t l, expected = +9223372036854775803;

	/* By freeing the config, we make sure we flush the values  */
	cl_git_pass(git_config_open_ondisk(&cfg, "config9"));
	cl_git_pass(git_config_set_int32(cfg, "core.dummy", 5));
	git_config_free(cfg);

	cl_git_pass(git_config_open_ondisk(&cfg, "config9"));
	cl_git_pass(git_config_get_int32(&i, cfg, "core.dummy"));
	cl_assert(i == 5);
	git_config_free(cfg);

	cl_git_pass(git_config_open_ondisk(&cfg, "config9"));
	cl_git_pass(git_config_set_int32(cfg, "core.dummy", 1));
	git_config_free(cfg);

	cl_git_pass(git_config_open_ondisk(&cfg, "config9"));
	cl_git_pass(git_config_set_int64(cfg, "core.verylong", expected));
	git_config_free(cfg);

	cl_git_pass(git_config_open_ondisk(&cfg, "config9"));
	cl_git_pass(git_config_get_int64(&l, cfg, "core.verylong"));
	cl_assert(l == expected);
	git_config_free(cfg);

	cl_git_pass(git_config_open_ondisk(&cfg, "config9"));
	cl_must_fail(git_config_get_int32(&i, cfg, "core.verylong"));
	git_config_free(cfg);

	cl_git_pass(git_config_open_ondisk(&cfg, "config9"));
	cl_git_pass(git_config_set_int64(cfg, "core.verylong", 1));
	git_config_free(cfg);
}
コード例 #8
0
ファイル: read.c プロジェクト: CodeSmithyIDE/libgit2
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);
}
コード例 #9
0
ファイル: read.c プロジェクト: CodeSmithyIDE/libgit2
void test_config_read__invalid_ext_headers(void)
{
	git_config *cfg;
	cl_must_fail(git_config_open_ondisk(&cfg, cl_fixture("config/config7")));
}
コード例 #10
0
ファイル: sample.c プロジェクト: phkelley/clar
void test_sample__1(void)
{
	cl_assert(1);
	cl_must_pass(0);  /* 0 == success */
	cl_must_fail(-1); /* <0 == failure */
}