diff options
author | nulltoken <emeric.fermas@gmail.com> | 2013-01-07 03:20:13 +0400 |
---|---|---|
committer | Carlos MartÃn Nieto <cmn@dwim.me> | 2014-04-30 09:24:20 +0400 |
commit | 48ebea662a33a3b918143c014dde88e58e6d0a75 (patch) | |
tree | 7ab8c1933ce33617117b8e8c210b1d850556e01c /tests | |
parent | 892778ee84e741f111b103570854ff37b110f74d (diff) |
tests: Introduce count_config_entries_match() helper
Diffstat (limited to 'tests')
-rw-r--r-- | tests/config/config_helpers.c | 28 | ||||
-rw-r--r-- | tests/config/config_helpers.h | 4 |
2 files changed, 32 insertions, 0 deletions
diff --git a/tests/config/config_helpers.c b/tests/config/config_helpers.c index 53bd945a0..35da720e0 100644 --- a/tests/config/config_helpers.c +++ b/tests/config/config_helpers.c @@ -35,3 +35,31 @@ void assert_config_entry_value( cl_assert_equal_s(expected_value, out); } + +static int count_config_entries_cb( + const git_config_entry *entry, + void *payload) +{ + int *how_many = (int *)payload; + + GIT_UNUSED(entry); + + (*how_many)++; + + return 0; +} + +int count_config_entries_match(git_repository *repo, const char *pattern) +{ + git_config *config; + int how_many = 0; + + cl_git_pass(git_repository_config(&config, repo)); + + cl_assert_equal_i(0, git_config_foreach_match( + config, pattern, count_config_entries_cb, &how_many)); + + git_config_free(config); + + return how_many; +} diff --git a/tests/config/config_helpers.h b/tests/config/config_helpers.h index b887b3d38..440645730 100644 --- a/tests/config/config_helpers.h +++ b/tests/config/config_helpers.h @@ -7,3 +7,7 @@ extern void assert_config_entry_value( git_repository *repo, const char *name, const char *expected_value); + +extern int count_config_entries_match( + git_repository *repo, + const char *pattern); |