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>
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 40 41
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