aboutsummaryrefslogtreecommitdiff
path: root/src/or/test.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2008-01-02 06:59:15 +0000
committerNick Mathewson <nickm@torproject.org>2008-01-02 06:59:15 +0000
commit58de695f9062576f74d3713e8dcb66e8b8a48a09 (patch)
treec550a418aec59e91398d62d921eda0f27d97678f /src/or/test.c
parent86f5180853e4054c6a14dda69253bccf6ea50a4c (diff)
downloadtor-58de695f9062576f74d3713e8dcb66e8b8a48a09.tar
tor-58de695f9062576f74d3713e8dcb66e8b8a48a09.tar.gz
r15787@tombo: nickm | 2008-01-02 01:59:07 -0500
Allow config values in quotes to contain special characters, with full C escape syntax. With tests. Addresses bug 557. svn:r13021
Diffstat (limited to 'src/or/test.c')
-rw-r--r--src/or/test.c21
1 files changed, 18 insertions, 3 deletions
diff --git a/src/or/test.c b/src/or/test.c
index 20bbc4910..5a1d317ef 100644
--- a/src/or/test.c
+++ b/src/or/test.c
@@ -826,14 +826,17 @@ test_util(void)
strlcpy(buf, "k v\n" " key value with spaces \n" "keykey val\n"
"k2\n"
"k3 \n" "\n" " \n" "#comment\n"
- "k4#a\n" "k5#abc\n" "k6 val #with comment\n", sizeof(buf));
+ "k4#a\n" "k5#abc\n" "k6 val #with comment\n"
+ "kseven \"a quoted 'string\"\n"
+ "k8 \"a \\x71uoted\\n\\\"str\\\\ing\\t\\001\\01\\1\\\"\"\n"
+ , sizeof(buf));
str = buf;
str = parse_config_line_from_str(str, &k, &v);
test_streq(k, "k");
test_streq(v, "v");
tor_free(k); tor_free(v);
- test_assert(!strcmpstart(str, " key value with"));
+ test_assert(!strcmpstart(str, "key value with"));
str = parse_config_line_from_str(str, &k, &v);
test_streq(k, "key");
@@ -857,7 +860,7 @@ test_util(void)
test_streq(k, "k3");
test_streq(v, "");
tor_free(k); tor_free(v);
- test_assert(!strcmpstart(str, "\n \n"));
+ test_assert(!strcmpstart(str, "#comment"));
str = parse_config_line_from_str(str, &k, &v);
test_streq(k, "k4");
@@ -875,6 +878,18 @@ test_util(void)
test_streq(k, "k6");
test_streq(v, "val");
tor_free(k); tor_free(v);
+ test_assert(!strcmpstart(str, "kseven"));
+
+ str = parse_config_line_from_str(str, &k, &v);
+ test_streq(k, "kseven");
+ test_streq(v, "a quoted 'string");
+ tor_free(k); tor_free(v);
+ test_assert(!strcmpstart(str, "k8 "));
+
+ str = parse_config_line_from_str(str, &k, &v);
+ test_streq(k, "k8");
+ test_streq(v, "a quoted\n\"str\\ing\t\x01\x01\x01\"");
+ tor_free(k); tor_free(v);
test_streq(str, "");
/* Test for strcmpstart and strcmpend. */