diff options
author | Mike Perry <mikeperry-git@fscked.org> | 2009-08-09 18:23:53 -0700 |
---|---|---|
committer | Mike Perry <mikeperry-git@fscked.org> | 2009-08-09 18:23:53 -0700 |
commit | cb477f9cc0c9d8d3fa50b06e9d3e0e057f41b75d (patch) | |
tree | 491470fa55f8c6fcae0ceb6a6f90f2b48b22df99 /src/or/test.c | |
parent | 1060b4d82429c743b6209f7e0a5a2c6bca0a6450 (diff) | |
parent | 3886467f386732598647a2d3209777ba8d8d7baa (diff) | |
download | tor-cb477f9cc0c9d8d3fa50b06e9d3e0e057f41b75d.tar.gz tor-cb477f9cc0c9d8d3fa50b06e9d3e0e057f41b75d.zip |
Merge commit 'nickm/strtok' into mp-voting-final
Diffstat (limited to 'src/or/test.c')
-rw-r--r-- | src/or/test.c | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/src/or/test.c b/src/or/test.c index 03351dcb79..b0273db2ef 100644 --- a/src/or/test.c +++ b/src/or/test.c @@ -4361,6 +4361,39 @@ test_util_datadir(void) tor_free(f); } +static void +test_util_strtok(void) +{ + char buf[128]; + char buf2[128]; + char *cp1, *cp2; + strlcpy(buf, "Graved on the dark in gestures of descent", sizeof(buf)); + strlcpy(buf2, "they.seemed;their!own;most.perfect;monument", sizeof(buf2)); + /* -- "Year's End", Richard Wilbur */ + + test_streq("Graved", tor_strtok_r_impl(buf, " ", &cp1)); + test_streq("they", tor_strtok_r_impl(buf2, ".!..;!", &cp2)); +#define S1() tor_strtok_r_impl(NULL, " ", &cp1) +#define S2() tor_strtok_r_impl(NULL, ".!..;!", &cp2) + test_streq("on", S1()); + test_streq("the", S1()); + test_streq("dark", S1()); + test_streq("seemed", S2()); + test_streq("their", S2()); + test_streq("own", S2()); + test_streq("in", S1()); + test_streq("gestures", S1()); + test_streq("of", S1()); + test_streq("most", S2()); + test_streq("perfect", S2()); + test_streq("descent", S1()); + test_streq("monument", S2()); + test_assert(NULL == S1()); + test_assert(NULL == S2()); + done: + ; +} + /** Test AES-CTR encryption and decryption with IV. */ static void test_crypto_aes_iv(void) @@ -4769,6 +4802,7 @@ static struct { SUBENT(util, threads), SUBENT(util, order_functions), SUBENT(util, sscanf), + SUBENT(util, strtok), ENT(onion_handshake), ENT(dir_format), ENT(dirutil), |