Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/libgit2.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEdward Thomson <ethomson@microsoft.com>2015-04-20 06:55:02 +0300
committerEdward Thomson <ethomson@microsoft.com>2015-04-20 07:25:44 +0300
commit7f2e61f3ee5a15b7232a898f2464fbd7cc23aef2 (patch)
tree1b6338f9eddb2156bd179680cfe7ceae0c4029ba /tests/config
parent4c02d393748d0db382450871ad9ef6898a2ce360 (diff)
config_file: parse multilines generously
Combine unquoting and multiline detection to avoid ambiguity when parsing.
Diffstat (limited to 'tests/config')
-rw-r--r--tests/config/read.c40
1 files changed, 34 insertions, 6 deletions
diff --git a/tests/config/read.c b/tests/config/read.c
index 6512fcbfa..f20a3769f 100644
--- a/tests/config/read.c
+++ b/tests/config/read.c
@@ -69,6 +69,40 @@ void test_config_read__multiline_value(void)
git_config_free(cfg);
}
+static void clean_test_config(void *unused)
+{
+ GIT_UNUSED(unused);
+ cl_fixture_cleanup("./testconfig");
+}
+
+void test_config_read__multiline_value_and_eof(void)
+{
+ git_config *cfg;
+
+ cl_set_cleanup(&clean_test_config, NULL);
+ cl_git_mkfile("./testconfig", "[header]\n key1 = foo\\\n");
+ cl_git_pass(git_config_open_ondisk(&cfg, "./testconfig"));
+
+ cl_git_pass(git_config_get_string_buf(&buf, cfg, "header.key1"));
+ cl_assert_equal_s("foo", git_buf_cstr(&buf));
+
+ git_config_free(cfg);
+}
+
+void test_config_read__multiline_eof(void)
+{
+ git_config *cfg;
+
+ cl_set_cleanup(&clean_test_config, NULL);
+ cl_git_mkfile("./testconfig", "[header]\n key1 = \\\n");
+ cl_git_pass(git_config_open_ondisk(&cfg, "./testconfig"));
+
+ cl_git_pass(git_config_get_string_buf(&buf, cfg, "header.key1"));
+ cl_assert_equal_s("", git_buf_cstr(&buf));
+
+ git_config_free(cfg);
+}
+
/*
* This kind of subsection declaration is case-insensitive
*/
@@ -520,12 +554,6 @@ void test_config_read__simple_read_from_specific_level(void)
git_config_free(cfg);
}
-static void clean_test_config(void *unused)
-{
- GIT_UNUSED(unused);
- cl_fixture_cleanup("./testconfig");
-}
-
void test_config_read__can_load_and_parse_an_empty_config_file(void)
{
git_config *cfg;