diff options
author | Esteban Manchado Velázquez <emanchado@demiurgo.org> | 2012-02-11 22:44:25 +0100 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2012-03-08 20:49:26 -0500 |
commit | 8d62e42fd31e292328adfc67257fb7b936b37c46 (patch) | |
tree | 8e52b9693b5a956eeec09c305e27d161788cb1a2 | |
parent | 9ae7d511f4d55cf47f0d28bc121bb0460067793a (diff) | |
download | tor-8d62e42fd31e292328adfc67257fb7b936b37c46.tar tor-8d62e42fd31e292328adfc67257fb7b936b37c46.tar.gz |
Add extra tests for wrap_string
-rw-r--r-- | src/test/test_util.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/test/test_util.c b/src/test/test_util.c index 600bdd5b4..3efe617ed 100644 --- a/src/test/test_util.c +++ b/src/test/test_util.c @@ -747,7 +747,24 @@ test_util_strmisc(void) test_streq(cp, "### A\n# test\n# of\n# stri\n# ng\n# wrap\n# ping\n# ...\n"); tor_free(cp); SMARTLIST_FOREACH(sl, char *, cp, tor_free(cp)); + smartlist_clear(sl); + + wrap_string(sl, "Wrapping test", 6, "#### ", "# "); + cp = smartlist_join_strings(sl, "", 0, NULL); + test_streq(cp, "#### W\n# rapp\n# ing\n# test\n"); + tor_free(cp); + SMARTLIST_FOREACH(sl, char *, cp, tor_free(cp)); + smartlist_clear(sl); + + wrap_string(sl, "Small test", 6, "### ", "#### "); + cp = smartlist_join_strings(sl, "", 0, NULL); + test_streq(cp, "### Sm\n#### a\n#### l\n#### l\n#### t\n#### e\n#### s\n#### t\n"); + tor_free(cp); + SMARTLIST_FOREACH(sl, char *, cp, tor_free(cp)); smartlist_free(sl); + + /* Can't test prefixes that have the same length as the line width, because + the function has an assert */ } /* Test hex_str */ |