diff options
author | Carlos Martín Nieto <cmn@dwim.me> | 2013-08-09 11:05:19 +0400 |
---|---|---|
committer | Carlos Martín Nieto <cmn@dwim.me> | 2013-08-12 13:40:57 +0400 |
commit | 5880962d90958bc37c08c21d37c9da480ef20e7f (patch) | |
tree | 2e710422d0012d078a278ff2fd2a7d410b7fa193 /tests-clar/config | |
parent | a319ffaead9290bfe35a0f105ff17dacaf7b6e7f (diff) |
config: introduce _iterator_new()
As the name suggests, it iterates over all the entries
Diffstat (limited to 'tests-clar/config')
-rw-r--r-- | tests-clar/config/read.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/tests-clar/config/read.c b/tests-clar/config/read.c index a18dca89b..2fb511d9d 100644 --- a/tests-clar/config/read.c +++ b/tests-clar/config/read.c @@ -245,6 +245,36 @@ void test_config_read__foreach(void) git_config_free(cfg); } +void test_config_read__iterator(void) +{ + git_config *cfg; + git_config_iterator *iter; + git_config_entry *entry; + int count, ret; + + cl_git_pass(git_config_new(&cfg)); + cl_git_pass(git_config_add_file_ondisk(cfg, cl_fixture("config/config9"), + GIT_CONFIG_LEVEL_SYSTEM, 0)); + cl_git_pass(git_config_add_file_ondisk(cfg, cl_fixture("config/config15"), + GIT_CONFIG_LEVEL_GLOBAL, 0)); + + count = 0; + cl_git_pass(git_config_iterator_new(&iter, cfg)); + + while ((ret = git_config_next(&entry, iter)) == 0) { + count++; + } + + cl_assert_equal_i(GIT_ITEROVER, ret); + cl_assert_equal_i(7, count); + + count = 3; + cl_git_pass(git_config_iterator_new(&iter, cfg)); + + git_config_iterator_free(iter); + git_config_free(cfg); +} + static int count_cfg_entries(const git_config_entry *entry, void *payload) { int *count = payload; |