diff options
author | Carlos Martín Nieto <cmn@elego.de> | 2012-06-11 16:57:02 +0200 |
---|---|---|
committer | Carlos Martín Nieto <cmn@elego.de> | 2012-06-13 23:26:00 +0200 |
commit | 67d334c1cd569d13b1709c3ef1864d630e608c95 (patch) | |
tree | 12184db67d225c0b11af5c4cf03ecf75957ef202 /tests-clar/config | |
parent | 49938cad9133dc6bb2120fc3e339cb0132ea71cb (diff) | |
download | libgit2-67d334c1cd569d13b1709c3ef1864d630e608c95.tar.gz |
config: add more tests for writing escaped chars
Diffstat (limited to 'tests-clar/config')
-rw-r--r-- | tests-clar/config/write.c | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/tests-clar/config/write.c b/tests-clar/config/write.c index 04811d7f0..13b669cb2 100644 --- a/tests-clar/config/write.c +++ b/tests-clar/config/write.c @@ -106,4 +106,33 @@ void test_config_write__value_containing_quotes(void) cl_git_pass(git_config_get_string(&str, cfg, "core.somevar")); cl_assert_equal_s(str, "this \"has\" quotes"); git_config_free(cfg); + + /* The code path for values that already exist is different, check that one as well */ + cl_git_pass(git_config_open_ondisk(&cfg, "config9")); + cl_git_pass(git_config_set_string(cfg, "core.somevar", "this also \"has\" quotes")); + cl_git_pass(git_config_get_string(&str, cfg, "core.somevar")); + cl_assert_equal_s(str, "this also \"has\" quotes"); + git_config_free(cfg); + + cl_git_pass(git_config_open_ondisk(&cfg, "config9")); + cl_git_pass(git_config_get_string(&str, cfg, "core.somevar")); + cl_assert_equal_s(str, "this also \"has\" quotes"); + git_config_free(cfg); +} + +void test_config_write__escape_value(void) +{ + git_config *cfg; + const char* str; + + cl_git_pass(git_config_open_ondisk(&cfg, "config9")); + cl_git_pass(git_config_set_string(cfg, "core.somevar", "this \"has\" quotes and \t")); + cl_git_pass(git_config_get_string(&str, cfg, "core.somevar")); + cl_assert_equal_s(str, "this \"has\" quotes and \t"); + git_config_free(cfg); + + cl_git_pass(git_config_open_ondisk(&cfg, "config9")); + cl_git_pass(git_config_get_string(&str, cfg, "core.somevar")); + cl_assert_equal_s(str, "this \"has\" quotes and \t"); + git_config_free(cfg); } |