diff options
author | Carlos Martín Nieto <cmn@dwim.me> | 2013-08-09 12:29:11 +0400 |
---|---|---|
committer | Carlos Martín Nieto <cmn@dwim.me> | 2013-08-12 13:40:57 +0400 |
commit | 54f3a572b4fac419008afa83da56c1b0daee1257 (patch) | |
tree | 5a89bdbb596c65128646b42b02a17096beadafae /tests-clar/config | |
parent | 5880962d90958bc37c08c21d37c9da480ef20e7f (diff) |
config: introduce a regex-filtering iterator
Diffstat (limited to 'tests-clar/config')
-rw-r--r-- | tests-clar/config/read.c | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/tests-clar/config/read.c b/tests-clar/config/read.c index 2fb511d9d..395f1cfdb 100644 --- a/tests-clar/config/read.c +++ b/tests-clar/config/read.c @@ -265,6 +265,7 @@ void test_config_read__iterator(void) count++; } + git_config_iterator_free(iter); cl_assert_equal_i(GIT_ITEROVER, ret); cl_assert_equal_i(7, count); @@ -318,6 +319,38 @@ void test_config_read__foreach_match(void) git_config_free(cfg); } +static void check_glob_iter(git_config *cfg, const char *regexp, int expected) +{ + git_config_iterator *iter; + git_config_entry *entry; + int count, error; + + cl_git_pass(git_config_iterator_glob_new(&iter, cfg, regexp)); + + count = 0; + while ((error = git_config_next(&entry, iter)) == 0) + count++; + + cl_assert_equal_i(GIT_ITEROVER, error); + cl_assert_equal_i(expected, count); + git_config_iterator_free(iter); +} + +void test_config_read__iterator_glob(void) +{ + git_config *cfg; + + cl_git_pass(git_config_open_ondisk(&cfg, cl_fixture("config/config9"))); + + check_glob_iter(cfg, "core.*", 3); + check_glob_iter(cfg, "remote\\.ab.*", 2); + check_glob_iter(cfg, ".*url$", 2); + check_glob_iter(cfg, ".*dummy.*", 2); + check_glob_iter(cfg, ".*nomatch.*", 0); + + git_config_free(cfg); +} + void test_config_read__whitespace_not_required_around_assignment(void) { git_config *cfg; |