]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Add extra tests for wrap_string
authorEsteban Manchado Velázquez <emanchado@demiurgo.org>
Sat, 11 Feb 2012 21:44:25 +0000 (22:44 +0100)
committerNick Mathewson <nickm@torproject.org>
Fri, 9 Mar 2012 01:49:26 +0000 (20:49 -0500)
src/test/test_util.c

index 600bdd5b47cff33fd1ca1f154727d93ab6539265..3efe617ed5e018fdb3f47ba37dcb797466d97f9f 100644 (file)
@@ -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 */