tests: add multivar read test
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
diff --git a/tests-clar/config/multivar.c b/tests-clar/config/multivar.c
new file mode 100644
index 0000000..dbb7c8a
--- /dev/null
+++ b/tests-clar/config/multivar.c
@@ -0,0 +1,24 @@
+#include "clar_libgit2.h"
+
+static int mv_read_cb(const char *name, const char *GIT_UNUSED(value), void *data)
+{
+ int *n = (int *) data;
+
+ if (!strcmp(name, "remote.fancy.fetch"))
+ (*n)++;
+
+ return 0;
+}
+
+void test_config_multivar__foreach(void)
+{
+ git_config *cfg;
+ int n = 0;
+
+ cl_git_pass(git_config_open_ondisk(&cfg, cl_fixture("config/config11")));
+
+ cl_git_pass(git_config_foreach(cfg, mv_read_cb, &n));
+ cl_assert(n == 2);
+
+ git_config_free(cfg);
+}
diff --git a/tests/resources/config/config11 b/tests/resources/config/config11
new file mode 100644
index 0000000..bda653b
--- /dev/null
+++ b/tests/resources/config/config11
@@ -0,0 +1,3 @@
+[remote "fancy"]
+ fetch = git://github.com/libgit2/libgit2
+ fetch = git://git.example.com/libgit2