diff options
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/config/read.c | 28 | ||||
| -rw-r--r-- | tests/config/write.c | 19 | ||||
| -rw-r--r-- | tests/resources/config/config22 | 10 |
3 files changed, 57 insertions, 0 deletions
diff --git a/tests/config/read.c b/tests/config/read.c index 3c96f8519..a2e668c20 100644 --- a/tests/config/read.c +++ b/tests/config/read.c @@ -209,6 +209,21 @@ void test_config_read__symbol_headers(void) { git_config *cfg; cl_git_pass(git_config_open_ondisk(&cfg, cl_fixture("config/config20"))); + cl_git_pass(git_config_get_string_buf(&buf, cfg, "valid.[subsection].something")); + cl_assert_equal_s("a", buf.ptr); + git_buf_dispose(&buf); + cl_git_pass(git_config_get_string_buf(&buf, cfg, "sec.[subsec]/child.parent")); + cl_assert_equal_s("grand", buf.ptr); + git_buf_dispose(&buf); + cl_git_pass(git_config_get_string_buf(&buf, cfg, "sec2.[subsec2]/child2.type")); + cl_assert_equal_s("dvcs", buf.ptr); + git_buf_dispose(&buf); + cl_git_pass(git_config_get_string_buf(&buf, cfg, "sec3.escape\"quote.vcs")); + cl_assert_equal_s("git", buf.ptr); + git_buf_dispose(&buf); + cl_git_pass(git_config_get_string_buf(&buf, cfg, "sec4.escaping\\slash.lib")); + cl_assert_equal_s("git2", buf.ptr); + git_buf_dispose(&buf); git_config_free(cfg); } @@ -219,6 +234,19 @@ void test_config_read__multiline_multiple_quoted_comment_chars(void) git_config_free(cfg); } +void test_config_read__multiline_multiple_quoted_quote_at_beginning_of_line(void) +{ + git_config* cfg; + cl_git_pass(git_config_open_ondisk(&cfg, cl_fixture("config/config22"))); + cl_git_pass(git_config_get_string_buf(&buf, cfg, "alias.m")); + cl_assert_equal_s("cmd ;; ;; bar", buf.ptr); + git_buf_dispose(&buf); + cl_git_pass(git_config_get_string_buf(&buf, cfg, "alias.m2")); + cl_assert_equal_s("'; ; something '", buf.ptr); + git_buf_dispose(&buf); + git_config_free(cfg); +} + void test_config_read__header_in_last_line(void) { git_config *cfg; diff --git a/tests/config/write.c b/tests/config/write.c index 4ee83833f..9d8c3fe94 100644 --- a/tests/config/write.c +++ b/tests/config/write.c @@ -8,6 +8,7 @@ void test_config_write__initialize(void) cl_fixture_sandbox("config/config9"); cl_fixture_sandbox("config/config15"); cl_fixture_sandbox("config/config17"); + cl_fixture_sandbox("config/config22"); } void test_config_write__cleanup(void) @@ -15,6 +16,7 @@ void test_config_write__cleanup(void) cl_fixture_cleanup("config9"); cl_fixture_cleanup("config15"); cl_fixture_cleanup("config17"); + cl_fixture_cleanup("config22"); } void test_config_write__replace_value(void) @@ -743,3 +745,20 @@ void test_config_write__preserve_case(void) git_config_free(cfg); } + +void test_config_write__write_config_file_with_multi_line_value(void) +{ + git_config* cfg; + git_buf buf = GIT_BUF_INIT; + + cl_git_pass(git_config_open_ondisk(&cfg, "config22")); + cl_git_pass(git_config_get_string_buf(&buf, cfg, "alias.m")); + cl_assert_equal_s("cmd ;; ;; bar", buf.ptr); + cl_git_pass(git_config_set_string(cfg, "sOMe.ThInG", "foo")); + git_buf_dispose(&buf); + cl_git_pass(git_config_get_string_buf(&buf, cfg, "alias.m")); + cl_assert_equal_s("cmd ;; ;; bar", buf.ptr); + git_buf_dispose(&buf); + + git_config_free(cfg); +} diff --git a/tests/resources/config/config22 b/tests/resources/config/config22 new file mode 100644 index 000000000..2a8e528ff --- /dev/null +++ b/tests/resources/config/config22 @@ -0,0 +1,10 @@ +[alias] + m = cmd \ +";;" \ +";;" \ +bar + m2 = '\ +";" \ +";" \ +something \ +' |
