summaryrefslogtreecommitdiff
path: root/tests-clar
diff options
context:
space:
mode:
authoryorah <yoram.harmelin@gmail.com>2012-07-12 16:31:59 +0200
committeryorah <yoram.harmelin@gmail.com>2012-07-24 14:03:07 +0200
commit02a0d651d79b2108dd6b894b9a43f7682270ac51 (patch)
treee90cbe5dccf69913f226799860a541ab31df29c3 /tests-clar
parent944d250f964698b33d9fa09e2e6af74b1dd84de2 (diff)
downloadlibgit2-02a0d651d79b2108dd6b894b9a43f7682270ac51.tar.gz
Add git_buf_unescape and git__unescape to unescape all characters in a string (in-place)
Diffstat (limited to 'tests-clar')
-rw-r--r--tests-clar/core/buffer.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/tests-clar/core/buffer.c b/tests-clar/core/buffer.c
index 21aaaed7e..b6274b012 100644
--- a/tests-clar/core/buffer.c
+++ b/tests-clar/core/buffer.c
@@ -658,3 +658,23 @@ void test_core_buffer__puts_escaped(void)
git_buf_free(&a);
}
+
+static void assert_unescape(char *expected, char *to_unescape) {
+ git_buf buf = GIT_BUF_INIT;
+
+ cl_git_pass(git_buf_sets(&buf, to_unescape));
+ git_buf_unescape(&buf);
+ cl_assert_equal_s(expected, buf.ptr);
+ cl_assert_equal_i(strlen(expected), buf.size);
+
+ git_buf_free(&buf);
+}
+
+void test_core_buffer__unescape(void)
+{
+ assert_unescape("Escaped\\", "Es\\ca\\ped\\");
+ assert_unescape("Es\\caped\\", "Es\\\\ca\\ped\\\\");
+ assert_unescape("\\", "\\");
+ assert_unescape("\\", "\\\\");
+ assert_unescape("", "");
+}