summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarlos Martín Nieto <cmn@dwim.me>2017-10-30 06:21:55 +0100
committerCarlos Martín Nieto <cmn@dwim.me>2017-10-30 06:21:55 +0100
commitbb8bc4b852aaf72508c4ae7904a928c30da4f360 (patch)
tree569bb2a2c83e4d0dcf2451e1572ed11d46bf45d3
parent9e3fb594d644955decd3ce815e94a8e627acf83d (diff)
downloadlibgit2-bb8bc4b852aaf72508c4ae7904a928c30da4f360.tar.gz
config: add failing test for preserving case when writing keys
While most parts of a configuration key are case-insensitive, we should still be case-preserving and write down whatever string the caller provided.
-rw-r--r--tests/config/write.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/tests/config/write.c b/tests/config/write.c
index 56ef2e9fb..01b018b12 100644
--- a/tests/config/write.c
+++ b/tests/config/write.c
@@ -722,3 +722,26 @@ void test_config_write__repeated(void)
git_config_free(cfg);
}
+
+void test_config_write__preserve_case(void)
+{
+ const char *filename = "config-preserve-case";
+ git_config *cfg;
+ git_buf result = GIT_BUF_INIT;
+ const char *expected = "[sOMe]\n" \
+ "\tThInG = foo\n" \
+ "\tOtheR = thing\n";
+
+ cl_git_pass(git_config_open_ondisk(&cfg, filename));
+ cl_git_pass(git_config_set_string(cfg, "sOMe.ThInG", "foo"));
+ cl_git_pass(git_config_set_string(cfg, "SomE.OtheR", "thing"));
+ git_config_free(cfg);
+
+ cl_git_pass(git_config_open_ondisk(&cfg, filename));
+
+ cl_git_pass(git_futils_readbuffer(&result, filename));
+ cl_assert_equal_s(expected, result.ptr);
+ git_buf_free(&result);
+
+ git_config_free(cfg);
+}