diff options
author | George Kadianakis <desnacked@riseup.net> | 2013-02-09 18:46:10 +0000 |
---|---|---|
committer | George Kadianakis <desnacked@riseup.net> | 2013-02-09 18:46:10 +0000 |
commit | b5dceab1751dfa12b27b3042a49d90e0b02c2e0c (patch) | |
tree | d5ccc5d775d7ac6833a2b4d3ae5fe59dc91b9203 /src/test/test_util.c | |
parent | d54efda869ee522d81bc0ccb80820f46c4f1439e (diff) | |
download | tor-b5dceab1751dfa12b27b3042a49d90e0b02c2e0c.tar.gz tor-b5dceab1751dfa12b27b3042a49d90e0b02c2e0c.zip |
Fix various issues pointed out by Nick and Andrea.
- Document the key=value format.
- Constify equal_sign_pos.
- Pass some strings that are about to be logged to escape().
- Update documentation and fix some bugs in tor_escape_str_for_socks_arg().
- Use string_is_key_value() in parse_bridge_line().
- Parenthesize a forgotten #define
- Add some more comments.
- Add some more unit test cases.
Diffstat (limited to 'src/test/test_util.c')
-rw-r--r-- | src/test/test_util.c | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/src/test/test_util.c b/src/test/test_util.c index b41f23571b..a307a79c80 100644 --- a/src/test/test_util.c +++ b/src/test/test_util.c @@ -813,9 +813,11 @@ test_util_escape_string_socks(void) test_streq(escaped_string, "First rule: Do not use \\;"); tor_free(escaped_string); - /** Ilegal: Empty string. */ + /** Empty string. */ escaped_string = tor_escape_str_for_socks_arg(""); - test_assert(!escaped_string); + test_assert(escaped_string); + test_streq(escaped_string, ""); + tor_free(escaped_string); /** Escape all characters. */ escaped_string = tor_escape_str_for_socks_arg(";\\;\\"); @@ -823,6 +825,11 @@ test_util_escape_string_socks(void) test_streq(escaped_string, "\\;\\\\\\;\\\\"); tor_free(escaped_string); + escaped_string = tor_escape_str_for_socks_arg(";"); + test_assert(escaped_string); + test_streq(escaped_string, "\\;"); + tor_free(escaped_string); + done: tor_free(escaped_string); } @@ -834,7 +841,10 @@ test_util_string_is_key_value(void *ptr) test_assert(string_is_key_value("key=value")); test_assert(string_is_key_value("k=v")); test_assert(string_is_key_value("key=")); + test_assert(string_is_key_value("x=")); + test_assert(string_is_key_value("xx=")); test_assert(!string_is_key_value("=value")); + test_assert(!string_is_key_value("=x")); test_assert(!string_is_key_value("=")); /* ??? */ |