Skip to content

Commit

Permalink
global: Fix unit tests after reordering
Browse files Browse the repository at this point in the history
  • Loading branch information
vmg committed May 17, 2012
1 parent 29e948d commit 255c38c
Show file tree
Hide file tree
Showing 7 changed files with 82 additions and 82 deletions.
58 changes: 29 additions & 29 deletions tests-clar/attr/flags.c
Expand Up @@ -14,7 +14,7 @@ void test_attr_flags__bare(void)
cl_assert(git_repository_is_bare(repo));

cl_git_pass(git_attr_get(
repo, GIT_ATTR_CHECK_NO_SYSTEM, "README.md", "diff", &value));
&value, repo, GIT_ATTR_CHECK_NO_SYSTEM, "README.md", "diff"));
cl_assert(GIT_ATTR_UNSPECIFIED(value));
}

Expand All @@ -27,34 +27,34 @@ void test_attr_flags__index_vs_workdir(void)

/* wd then index */
cl_git_pass(git_attr_get(
repo, GIT_ATTR_CHECK_NO_SYSTEM | GIT_ATTR_CHECK_FILE_THEN_INDEX,
"README.md", "bar", &value));
&value, repo, GIT_ATTR_CHECK_NO_SYSTEM | GIT_ATTR_CHECK_FILE_THEN_INDEX,
"README.md", "bar"));
cl_assert(GIT_ATTR_FALSE(value));

cl_git_pass(git_attr_get(
repo, GIT_ATTR_CHECK_NO_SYSTEM | GIT_ATTR_CHECK_FILE_THEN_INDEX,
"README.md", "blargh", &value));
&value, repo, GIT_ATTR_CHECK_NO_SYSTEM | GIT_ATTR_CHECK_FILE_THEN_INDEX,
"README.md", "blargh"));
cl_assert_equal_s(value, "goop");

cl_git_pass(git_attr_get(
repo, GIT_ATTR_CHECK_NO_SYSTEM | GIT_ATTR_CHECK_FILE_THEN_INDEX,
"README.txt", "foo", &value));
&value, repo, GIT_ATTR_CHECK_NO_SYSTEM | GIT_ATTR_CHECK_FILE_THEN_INDEX,
"README.txt", "foo"));
cl_assert(GIT_ATTR_FALSE(value));

/* index then wd */
cl_git_pass(git_attr_get(
repo, GIT_ATTR_CHECK_NO_SYSTEM | GIT_ATTR_CHECK_INDEX_THEN_FILE,
"README.md", "bar", &value));
&value, repo, GIT_ATTR_CHECK_NO_SYSTEM | GIT_ATTR_CHECK_INDEX_THEN_FILE,
"README.md", "bar"));
cl_assert(GIT_ATTR_TRUE(value));

cl_git_pass(git_attr_get(
repo, GIT_ATTR_CHECK_NO_SYSTEM | GIT_ATTR_CHECK_INDEX_THEN_FILE,
"README.md", "blargh", &value));
&value, repo, GIT_ATTR_CHECK_NO_SYSTEM | GIT_ATTR_CHECK_INDEX_THEN_FILE,
"README.md", "blargh"));
cl_assert_equal_s(value, "garble");

cl_git_pass(git_attr_get(
repo, GIT_ATTR_CHECK_NO_SYSTEM | GIT_ATTR_CHECK_INDEX_THEN_FILE,
"README.txt", "foo", &value));
&value, repo, GIT_ATTR_CHECK_NO_SYSTEM | GIT_ATTR_CHECK_INDEX_THEN_FILE,
"README.txt", "foo"));
cl_assert(GIT_ATTR_TRUE(value));
}

Expand All @@ -65,44 +65,44 @@ void test_attr_flags__subdir(void)

/* wd then index */
cl_git_pass(git_attr_get(
repo, GIT_ATTR_CHECK_NO_SYSTEM | GIT_ATTR_CHECK_FILE_THEN_INDEX,
"sub/sub/README.md", "bar", &value));
&value, repo, GIT_ATTR_CHECK_NO_SYSTEM | GIT_ATTR_CHECK_FILE_THEN_INDEX,
"sub/sub/README.md", "bar"));
cl_assert_equal_s(value, "1234");

cl_git_pass(git_attr_get(
repo, GIT_ATTR_CHECK_NO_SYSTEM | GIT_ATTR_CHECK_FILE_THEN_INDEX,
"sub/sub/README.txt", "another", &value));
&value, repo, GIT_ATTR_CHECK_NO_SYSTEM | GIT_ATTR_CHECK_FILE_THEN_INDEX,
"sub/sub/README.txt", "another"));
cl_assert_equal_s(value, "one");

cl_git_pass(git_attr_get(
repo, GIT_ATTR_CHECK_NO_SYSTEM | GIT_ATTR_CHECK_FILE_THEN_INDEX,
"sub/sub/README.txt", "again", &value));
&value, repo, GIT_ATTR_CHECK_NO_SYSTEM | GIT_ATTR_CHECK_FILE_THEN_INDEX,
"sub/sub/README.txt", "again"));
cl_assert(GIT_ATTR_TRUE(value));

cl_git_pass(git_attr_get(
repo, GIT_ATTR_CHECK_NO_SYSTEM | GIT_ATTR_CHECK_FILE_THEN_INDEX,
"sub/sub/README.txt", "beep", &value));
&value, repo, GIT_ATTR_CHECK_NO_SYSTEM | GIT_ATTR_CHECK_FILE_THEN_INDEX,
"sub/sub/README.txt", "beep"));
cl_assert_equal_s(value, "10");

/* index then wd */
cl_git_pass(git_attr_get(
repo, GIT_ATTR_CHECK_NO_SYSTEM | GIT_ATTR_CHECK_INDEX_THEN_FILE,
"sub/sub/README.md", "bar", &value));
&value, repo, GIT_ATTR_CHECK_NO_SYSTEM | GIT_ATTR_CHECK_INDEX_THEN_FILE,
"sub/sub/README.md", "bar"));
cl_assert_equal_s(value, "1337");

cl_git_pass(git_attr_get(
repo, GIT_ATTR_CHECK_NO_SYSTEM | GIT_ATTR_CHECK_INDEX_THEN_FILE,
"sub/sub/README.txt", "another", &value));
&value, repo, GIT_ATTR_CHECK_NO_SYSTEM | GIT_ATTR_CHECK_INDEX_THEN_FILE,
"sub/sub/README.txt", "another"));
cl_assert_equal_s(value, "one");

cl_git_pass(git_attr_get(
repo, GIT_ATTR_CHECK_NO_SYSTEM | GIT_ATTR_CHECK_INDEX_THEN_FILE,
"sub/sub/README.txt", "again", &value));
&value, repo, GIT_ATTR_CHECK_NO_SYSTEM | GIT_ATTR_CHECK_INDEX_THEN_FILE,
"sub/sub/README.txt", "again"));
cl_assert(GIT_ATTR_TRUE(value));

cl_git_pass(git_attr_get(
repo, GIT_ATTR_CHECK_NO_SYSTEM | GIT_ATTR_CHECK_INDEX_THEN_FILE,
"sub/sub/README.txt", "beep", &value));
&value, repo, GIT_ATTR_CHECK_NO_SYSTEM | GIT_ATTR_CHECK_INDEX_THEN_FILE,
"sub/sub/README.txt", "beep"));
cl_assert_equal_s(value, "5");
}

26 changes: 13 additions & 13 deletions tests-clar/attr/repo.c
Expand Up @@ -64,7 +64,7 @@ void test_attr_repo__get_one(void)

for (scan = test_cases; scan->path != NULL; scan++) {
const char *value;
cl_git_pass(git_attr_get(g_repo, 0, scan->path, scan->attr, &value));
cl_git_pass(git_attr_get(&value, g_repo, 0, scan->path, scan->attr));
attr_check_expected(scan->expected, scan->expected_str, value);
}

Expand All @@ -78,21 +78,21 @@ void test_attr_repo__get_many(void)
const char *names[4] = { "repoattr", "rootattr", "missingattr", "subattr" };
const char *values[4];

cl_git_pass(git_attr_get_many(g_repo, 0, "root_test1", 4, names, values));
cl_git_pass(git_attr_get_many(values, g_repo, 0, "root_test1", 4, names));

cl_assert(GIT_ATTR_TRUE(values[0]));
cl_assert(GIT_ATTR_TRUE(values[1]));
cl_assert(GIT_ATTR_UNSPECIFIED(values[2]));
cl_assert(GIT_ATTR_UNSPECIFIED(values[3]));

cl_git_pass(git_attr_get_many(g_repo, 0, "root_test2", 4, names, values));
cl_git_pass(git_attr_get_many(values, g_repo, 0, "root_test2", 4, names));

cl_assert(GIT_ATTR_TRUE(values[0]));
cl_assert(GIT_ATTR_FALSE(values[1]));
cl_assert(GIT_ATTR_UNSPECIFIED(values[2]));
cl_assert(GIT_ATTR_UNSPECIFIED(values[3]));

cl_git_pass(git_attr_get_many(g_repo, 0, "sub/subdir_test1", 4, names, values));
cl_git_pass(git_attr_get_many(values, g_repo, 0, "sub/subdir_test1", 4, names));

cl_assert(GIT_ATTR_TRUE(values[0]));
cl_assert(GIT_ATTR_TRUE(values[1]));
Expand Down Expand Up @@ -137,19 +137,19 @@ void test_attr_repo__manpage_example(void)
{
const char *value;

cl_git_pass(git_attr_get(g_repo, 0, "sub/abc", "foo", &value));
cl_git_pass(git_attr_get(&value, g_repo, 0, "sub/abc", "foo"));
cl_assert(GIT_ATTR_TRUE(value));

cl_git_pass(git_attr_get(g_repo, 0, "sub/abc", "bar", &value));
cl_git_pass(git_attr_get(&value, g_repo, 0, "sub/abc", "bar"));
cl_assert(GIT_ATTR_UNSPECIFIED(value));

cl_git_pass(git_attr_get(g_repo, 0, "sub/abc", "baz", &value));
cl_git_pass(git_attr_get(&value, g_repo, 0, "sub/abc", "baz"));
cl_assert(GIT_ATTR_FALSE(value));

cl_git_pass(git_attr_get(g_repo, 0, "sub/abc", "merge", &value));
cl_git_pass(git_attr_get(&value, g_repo, 0, "sub/abc", "merge"));
cl_assert_equal_s("filfre", value);

cl_git_pass(git_attr_get(g_repo, 0, "sub/abc", "frotz", &value));
cl_git_pass(git_attr_get(&value, g_repo, 0, "sub/abc", "frotz"));
cl_assert(GIT_ATTR_UNSPECIFIED(value));
}

Expand All @@ -160,23 +160,23 @@ void test_attr_repo__macros(void)
const char *names3[3] = { "macro2", "multi2", "multi3" };
const char *values[5];

cl_git_pass(git_attr_get_many(g_repo, 0, "binfile", 5, names, values));
cl_git_pass(git_attr_get_many(values, g_repo, 0, "binfile", 5, names));

cl_assert(GIT_ATTR_TRUE(values[0]));
cl_assert(GIT_ATTR_TRUE(values[1]));
cl_assert(GIT_ATTR_FALSE(values[2]));
cl_assert(GIT_ATTR_FALSE(values[3]));
cl_assert(GIT_ATTR_UNSPECIFIED(values[4]));

cl_git_pass(git_attr_get_many(g_repo, 0, "macro_test", 5, names2, values));
cl_git_pass(git_attr_get_many(values, g_repo, 0, "macro_test", 5, names2));

cl_assert(GIT_ATTR_TRUE(values[0]));
cl_assert(GIT_ATTR_TRUE(values[1]));
cl_assert(GIT_ATTR_FALSE(values[2]));
cl_assert(GIT_ATTR_UNSPECIFIED(values[3]));
cl_assert_equal_s("77", values[4]);

cl_git_pass(git_attr_get_many(g_repo, 0, "macro_test", 3, names3, values));
cl_git_pass(git_attr_get_many(values, g_repo, 0, "macro_test", 3, names3));

cl_assert(GIT_ATTR_TRUE(values[0]));
cl_assert(GIT_ATTR_FALSE(values[1]));
Expand All @@ -189,7 +189,7 @@ void test_attr_repo__bad_macros(void)
"firstmacro", "secondmacro", "thirdmacro" };
const char *values[6];

cl_git_pass(git_attr_get_many(g_repo, 0, "macro_bad", 6, names, values));
cl_git_pass(git_attr_get_many(values, g_repo, 0, "macro_bad", 6, names));

/* these three just confirm that the "mymacro" rule ran */
cl_assert(GIT_ATTR_UNSPECIFIED(values[0]));
Expand Down
4 changes: 2 additions & 2 deletions tests-clar/config/add.c
Expand Up @@ -17,7 +17,7 @@ void test_config_add__to_existing_section(void)

cl_git_pass(git_config_open_ondisk(&cfg, "config10"));
cl_git_pass(git_config_set_int32(cfg, "empty.tmp", 5));
cl_git_pass(git_config_get_int32(cfg, "empty.tmp", &i));
cl_git_pass(git_config_get_int32(&i, cfg, "empty.tmp"));
cl_assert(i == 5);
cl_git_pass(git_config_delete(cfg, "empty.tmp"));
git_config_free(cfg);
Expand All @@ -30,7 +30,7 @@ void test_config_add__to_new_section(void)

cl_git_pass(git_config_open_ondisk(&cfg, "config10"));
cl_git_pass(git_config_set_int32(cfg, "section.tmp", 5));
cl_git_pass(git_config_get_int32(cfg, "section.tmp", &i));
cl_git_pass(git_config_get_int32(&i, cfg, "section.tmp"));
cl_assert(i == 5);
cl_git_pass(git_config_delete(cfg, "section.tmp"));
git_config_free(cfg);
Expand Down
4 changes: 2 additions & 2 deletions tests-clar/config/new.c
Expand Up @@ -25,9 +25,9 @@ void test_config_new__write_new_config(void)
cl_git_pass(git_config_new(&config));
cl_git_pass(git_config_add_file(config, file, 0));

cl_git_pass(git_config_get_string(config, "color.ui", &out));
cl_git_pass(git_config_get_string(&out, config, "color.ui"));
cl_assert_equal_s(out, "auto");
cl_git_pass(git_config_get_string(config, "core.editor", &out));
cl_git_pass(git_config_get_string(&out, config, "core.editor"));
cl_assert_equal_s(out, "ed");

git_config_free(config);
Expand Down
52 changes: 26 additions & 26 deletions tests-clar/config/read.c
Expand Up @@ -7,13 +7,13 @@ void test_config_read__simple_read(void)

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

cl_git_pass(git_config_get_int32(cfg, "core.repositoryformatversion", &i));
cl_git_pass(git_config_get_int32(&i, cfg, "core.repositoryformatversion"));
cl_assert(i == 0);
cl_git_pass(git_config_get_bool(cfg, "core.filemode", &i));
cl_git_pass(git_config_get_bool(&i, cfg, "core.filemode"));
cl_assert(i == 1);
cl_git_pass(git_config_get_bool(cfg, "core.bare", &i));
cl_git_pass(git_config_get_bool(&i, cfg, "core.bare"));
cl_assert(i == 0);
cl_git_pass(git_config_get_bool(cfg, "core.logallrefupdates", &i));
cl_git_pass(git_config_get_bool(&i, cfg, "core.logallrefupdates"));
cl_assert(i == 1);

git_config_free(cfg);
Expand All @@ -27,18 +27,18 @@ void test_config_read__case_sensitive(void)

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

cl_git_pass(git_config_get_string(cfg, "this.that.other", &str));
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(cfg, "this.That.other", &str));
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(cfg, "this.that.other", &i));
cl_git_pass(git_config_get_bool(&i, cfg, "this.that.other"));
cl_assert(i == 1);
cl_git_pass(git_config_get_bool(cfg, "this.That.other", &i));
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(cfg, "this.thaT.other", &i));
cl_must_fail(git_config_get_bool(&i, cfg, "this.thaT.other"));

git_config_free(cfg);
}
Expand All @@ -54,7 +54,7 @@ void test_config_read__multiline_value(void)

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

cl_git_pass(git_config_get_string(cfg, "this.That.and", &str));
cl_git_pass(git_config_get_string(&str, cfg, "this.That.and"));
cl_assert_equal_s(str, "one one one two two three three");

git_config_free(cfg);
Expand All @@ -70,11 +70,11 @@ void test_config_read__subsection_header(void)

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

cl_git_pass(git_config_get_string(cfg, "section.subsection.var", &str));
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(cfg, "section.subSectIon.var", &str));
cl_must_fail(git_config_get_string(&str, cfg, "section.subSectIon.var"));

git_config_free(cfg);
}
Expand All @@ -87,10 +87,10 @@ void test_config_read__lone_variable(void)

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

cl_git_pass(git_config_get_string(cfg, "some.section.variable", &str));
cl_git_pass(git_config_get_string(&str, cfg, "some.section.variable"));
cl_assert(str == NULL);

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

git_config_free(cfg);
Expand All @@ -103,25 +103,25 @@ void test_config_read__number_suffixes(void)

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

cl_git_pass(git_config_get_int64(cfg, "number.simple", &i));
cl_git_pass(git_config_get_int64(&i, cfg, "number.simple"));
cl_assert(i == 1);

cl_git_pass(git_config_get_int64(cfg, "number.k", &i));
cl_git_pass(git_config_get_int64(&i, cfg, "number.k"));
cl_assert(i == 1 * 1024);

cl_git_pass(git_config_get_int64(cfg, "number.kk", &i));
cl_git_pass(git_config_get_int64(&i, cfg, "number.kk"));
cl_assert(i == 1 * 1024);

cl_git_pass(git_config_get_int64(cfg, "number.m", &i));
cl_git_pass(git_config_get_int64(&i, cfg, "number.m"));
cl_assert(i == 1 * 1024 * 1024);

cl_git_pass(git_config_get_int64(cfg, "number.mm", &i));
cl_git_pass(git_config_get_int64(&i, cfg, "number.mm"));
cl_assert(i == 1 * 1024 * 1024);

cl_git_pass(git_config_get_int64(cfg, "number.g", &i));
cl_git_pass(git_config_get_int64(&i, cfg, "number.g"));
cl_assert(i == 1 * 1024 * 1024 * 1024);

cl_git_pass(git_config_get_int64(cfg, "number.gg", &i));
cl_git_pass(git_config_get_int64(&i, cfg, "number.gg"));
cl_assert(i == 1 * 1024 * 1024 * 1024);

git_config_free(cfg);
Expand All @@ -134,10 +134,10 @@ void test_config_read__blank_lines(void)

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

cl_git_pass(git_config_get_bool(cfg, "valid.subsection.something", &i));
cl_git_pass(git_config_get_bool(&i, cfg, "valid.subsection.something"));
cl_assert(i == 1);

cl_git_pass(git_config_get_bool(cfg, "something.else.something", &i));
cl_git_pass(git_config_get_bool(&i, cfg, "something.else.something"));
cl_assert(i == 0);

git_config_free(cfg);
Expand Down Expand Up @@ -170,10 +170,10 @@ void test_config_read__prefixes(void)
const char *str;

cl_git_pass(git_config_open_ondisk(&cfg, cl_fixture("config/config9")));
cl_git_pass(git_config_get_string(cfg, "remote.ab.url", &str));
cl_git_pass(git_config_get_string(&str, cfg, "remote.ab.url"));
cl_assert_equal_s(str, "http://example.com/git/ab");

cl_git_pass(git_config_get_string(cfg, "remote.abba.url", &str));
cl_git_pass(git_config_get_string(&str, cfg, "remote.abba.url"));
cl_assert_equal_s(str, "http://example.com/git/abba");

git_config_free(cfg);
Expand All @@ -185,7 +185,7 @@ void test_config_read__escaping_quotes(void)
const char *str;

cl_git_pass(git_config_open_ondisk(&cfg, cl_fixture("config/config13")));
cl_git_pass(git_config_get_string(cfg, "core.editor", &str));
cl_git_pass(git_config_get_string(&str, cfg, "core.editor"));
cl_assert(strcmp(str, "\"C:/Program Files/Nonsense/bah.exe\" \"--some option\"") == 0);

git_config_free(cfg);
Expand Down

0 comments on commit 255c38c

Please sign in to comment.