Commit 78d65f390f031d18ce698a24e1f83b99cc8cf699

Carlos Martín Nieto 2012-02-01T17:47:17

tests: add multivar read test

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