summaryrefslogtreecommitdiff
path: root/src/or/test.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2006-12-15 21:26:23 +0000
committerNick Mathewson <nickm@torproject.org>2006-12-15 21:26:23 +0000
commit078aab810b7410086685d648b4d3328b140ddea5 (patch)
treed2f60647cad33c30c2c1adc1b97558a9bbde4c6a /src/or/test.c
parentab2fc7bd62f2a91dfe003f2a99b7cf223762fec8 (diff)
downloadtor-078aab810b7410086685d648b4d3328b140ddea5.tar.gz
tor-078aab810b7410086685d648b4d3328b140ddea5.zip
r11597@Kushana: nickm | 2006-12-15 15:49:27 -0500
Add a rudimentary line-wrapping function for use in dumping comments in config files. svn:r9132
Diffstat (limited to 'src/or/test.c')
-rw-r--r--src/or/test.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/or/test.c b/src/or/test.c
index 7dec2a5daf..d7b02f0c19 100644
--- a/src/or/test.c
+++ b/src/or/test.c
@@ -778,6 +778,30 @@ test_util(void)
test_streq("\"abcd\"", escaped("abcd"));
test_streq("\"\\\\\\n\\r\\t\\\"\\'\"", escaped("\\\n\r\t\"\'"));
test_streq("\"z\\001abc\\277d\"", escaped("z\001abc\277d"));
+
+ /* Test wrap_string */
+ {
+ smartlist_t *sl = smartlist_create();
+ wrap_string(sl, "This is a test of string wrapping functionality: woot.",
+ 10, "", "");
+ cp = smartlist_join_strings(sl, "", 0, NULL);
+ test_streq(cp,
+ "This is a\ntest of\nstring\nwrapping\nfunctional\nity: woot.\n");
+ tor_free(cp);
+ SMARTLIST_FOREACH(sl, char *, cp, tor_free(cp));
+ smartlist_clear(sl);
+
+ wrap_string(sl, "This is a test of string wrapping functionality: woot.",
+ 16, "### ", "# ");
+ cp = smartlist_join_strings(sl, "", 0, NULL);
+ test_streq(cp,
+ "### This is a\n# test of string\n# wrapping\n# functionality:\n"
+ "# woot.\n");
+
+ tor_free(cp);
+ SMARTLIST_FOREACH(sl, char *, cp, tor_free(cp));
+ smartlist_clear(sl);
+ }
}
static void