diff options
author | Nick Mathewson <nickm@torproject.org> | 2005-07-15 19:31:11 +0000 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2005-07-15 19:31:11 +0000 |
commit | f8b48176ede5012ff21c67fa4d9a8c13c0e12860 (patch) | |
tree | 46f264c15e45d3b00ac35b5590b0cbb37c8159e0 /src/or/test.c | |
parent | 61f2ea0df0f30ca37f6e60676f6f6d2a957b8022 (diff) | |
download | tor-f8b48176ede5012ff21c67fa4d9a8c13c0e12860.tar.gz tor-f8b48176ede5012ff21c67fa4d9a8c13c0e12860.zip |
Fix several bugs in read_escaped_data; add a unit test and a few docs
svn:r4580
Diffstat (limited to 'src/or/test.c')
-rw-r--r-- | src/or/test.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/or/test.c b/src/or/test.c index c365113df1..2e3e764e57 100644 --- a/src/or/test.c +++ b/src/or/test.c @@ -33,6 +33,8 @@ void add_fingerprint_to_dir(const char *nickname, const char *fp, smartlist_t *list); void get_platform_str(char *platform, size_t len); int is_obsolete_version(const char *myversion, const char *start); +size_t read_escaped_data(const char *data, size_t len, int translate_newlines, + char **out); static char temp_dir[256]; @@ -1018,6 +1020,21 @@ test_strmap(void) } static void +test_control_formats(void) +{ + char *out; + const char *inp = + "..This is a test\r\nof the emergency \nbroadcast\r\n..system.\r\nZ.\r\n"; + size_t sz; + + sz = read_escaped_data(inp, strlen(inp), 1, &out); + test_streq(out, + ".This is a test\nof the emergency \nbroadcast\n.system.\nZ.\n"); + + tor_free(out); +} + +static void test_onion(void) { #if 0 @@ -1521,6 +1538,7 @@ main(int c, char**v) test_gzip(); test_util(); test_strmap(); + test_control_formats(); puts("\n========================= Onion Skins ====================="); test_onion(); test_onion_handshake(); |