diff options
author | Vicent Martà <vicent@github.com> | 2013-11-10 19:33:11 +0400 |
---|---|---|
committer | Vicent Martà <vicent@github.com> | 2013-11-10 19:33:11 +0400 |
commit | b9cb72c28a937a887676a553fef8e21bbc7be3f0 (patch) | |
tree | e1f69ec17a1f64e0fecf7164fda4c2b9a083db42 /tests-clar | |
parent | 0df96f2b05f45e62047fc592ded37c0ef18ec27b (diff) | |
parent | 590c5efb3bab80b3e52cf68b705ef461d7388874 (diff) |
Merge pull request #1950 from csware/quote-config-values
Correctly quote config values while saving
Diffstat (limited to 'tests-clar')
-rw-r--r-- | tests-clar/config/write.c | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/tests-clar/config/write.c b/tests-clar/config/write.c index 309fef65a..15f750dc0 100644 --- a/tests-clar/config/write.c +++ b/tests-clar/config/write.c @@ -229,6 +229,37 @@ void test_config_write__add_value_at_file_with_no_clrf_at_the_end(void) git_config_free(cfg); } +void test_config_write__add_value_which_needs_quotes(void) +{ + git_config *cfg; + const char* str1; + const char* str2; + const char* str3; + const char* str4; + const char* str5; + + cl_git_pass(git_config_open_ondisk(&cfg, "config17")); + cl_git_pass(git_config_set_string(cfg, "core.startwithspace", " Something")); + cl_git_pass(git_config_set_string(cfg, "core.endwithspace", "Something ")); + cl_git_pass(git_config_set_string(cfg, "core.containscommentchar1", "some#thing")); + cl_git_pass(git_config_set_string(cfg, "core.containscommentchar2", "some;thing")); + cl_git_pass(git_config_set_string(cfg, "core.startwhithsapceandcontainsdoublequote", " some\"thing")); + git_config_free(cfg); + + cl_git_pass(git_config_open_ondisk(&cfg, "config17")); + cl_git_pass(git_config_get_string(&str1, cfg, "core.startwithspace")); + cl_assert_equal_s(" Something", str1); + cl_git_pass(git_config_get_string(&str2, cfg, "core.endwithspace")); + cl_assert_equal_s("Something ", str2); + cl_git_pass(git_config_get_string(&str3, cfg, "core.containscommentchar1")); + cl_assert_equal_s("some#thing", str3); + cl_git_pass(git_config_get_string(&str4, cfg, "core.containscommentchar2")); + cl_assert_equal_s("some;thing", str4); + cl_git_pass(git_config_get_string(&str5, cfg, "core.startwhithsapceandcontainsdoublequote")); + cl_assert_equal_s(" some\"thing", str5); + git_config_free(cfg); +} + void test_config_write__can_set_a_value_to_NULL(void) { git_repository *repository; |