diff options
author | Nick Mathewson <nickm@torproject.org> | 2004-10-14 19:51:47 +0000 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2004-10-14 19:51:47 +0000 |
commit | c5964d67389aea3c7c740e8021a4b31a5c120dd7 (patch) | |
tree | ddd71ba15a3d0a9dc7dc2ee17e08bf16f007ce14 /src/or/test.c | |
parent | 9e8e006c1eb3c2c79188ca55322c7a49686d37dc (diff) | |
download | tor-c5964d67389aea3c7c740e8021a4b31a5c120dd7.tar.gz tor-c5964d67389aea3c7c740e8021a4b31a5c120dd7.zip |
Basic string-join functionality
svn:r2521
Diffstat (limited to 'src/or/test.c')
-rw-r--r-- | src/or/test.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/or/test.c b/src/or/test.c index 1bac5648c3..a7b1e51eae 100644 --- a/src/or/test.c +++ b/src/or/test.c @@ -581,6 +581,22 @@ test_util() { test_streq("a", smartlist_get(sl, 1)); test_streq("bc", smartlist_get(sl, 2)); test_streq("", smartlist_get(sl, 3)); + cp = smartlist_join_strings(sl, "", 0); + test_streq(cp, "abcabc"); + tor_free(cp); + cp = smartlist_join_strings(sl, "!", 0); + test_streq(cp, "abc!a!bc!"); + tor_free(cp); + cp = smartlist_join_strings(sl, "XY", 0); + test_streq(cp, "abcXYaXYbcXY"); + tor_free(cp); + cp = smartlist_join_strings(sl, "XY", 1); + test_streq(cp, "abcXYaXYbcXYXY"); + tor_free(cp); + cp = smartlist_join_strings(sl, "", 1); + test_streq(cp, "abcabc"); + tor_free(cp); + smartlist_split_string(sl, "/def/ /ghijk", "/", 0, 0); test_eq(8, smartlist_len(sl)); test_streq("", smartlist_get(sl, 4)); @@ -615,6 +631,9 @@ test_util() { test_eq(5, smartlist_len(sl)); test_streq("z", smartlist_get(sl, 3)); test_streq("zhasd <> <> bnud<>", smartlist_get(sl, 4)); + SMARTLIST_FOREACH(sl, char *, cp, tor_free(cp)); + smartlist_clear(sl); + /* Test tor_strstrip() */ strcpy(buf, "Testing 1 2 3"); |