Commit 8cd767ef52ad35331f082394ec93df8e57757120

Carlos Martín Nieto 2011-04-04T17:07:47

config: test for a variable on its own If a variable is on its own, truth should be assumed. Check this is true in our code. Signed-off-by: Carlos Martín Nieto <cmn@elego.de>

diff --git a/tests/resources/config/config4 b/tests/resources/config/config4
new file mode 100644
index 0000000..741fa0f
--- /dev/null
+++ b/tests/resources/config/config4
@@ -0,0 +1,3 @@
+# A variable name on its own is valid
+[some.section]
+		variable
diff --git a/tests/t14-config.c b/tests/t14-config.c
index 6428cea..2cbd058 100644
--- a/tests/t14-config.c
+++ b/tests/t14-config.c
@@ -112,10 +112,27 @@ BEGIN_TEST(config3, "parse a [section.subsection] header")
 	git_config_free(cfg);
 END_TEST
 
+BEGIN_TEST(config4, "a variable name on its own is valid")
+	git_config *cfg;
+const char *str;
+int i;
+
+	must_pass(git_config_open(&cfg, CONFIG_BASE "/config4"));
+
+	must_pass(git_config_get_string(cfg, "some.section.variable", &str));
+	must_be_true(str == NULL);
+
+	must_pass(git_config_get_bool(cfg, "some.section.variable", &i));
+	must_be_true(i == 1);
+
+
+	git_config_free(cfg);
+END_TEST
 
 BEGIN_SUITE(config)
 	 ADD_TEST(config0);
 	 ADD_TEST(config1);
 	 ADD_TEST(config2);
 	 ADD_TEST(config3);
+	 ADD_TEST(config4);
 END_SUITE