aboutsummaryrefslogtreecommitdiff
path: root/src/test/test_util.c
diff options
context:
space:
mode:
authorEsteban Manchado Velázquez <emanchado@demiurgo.org>2012-02-08 23:28:21 +0100
committerNick Mathewson <nickm@torproject.org>2012-03-08 20:49:24 -0500
commit667f5ea409a8f3950aedd60e85d23bddeb8ad9b6 (patch)
treef41ffcb74d7591444442e3fb0f055724299a7ee7 /src/test/test_util.c
parentee317256bb80c832f4a826b2520df72f679f2390 (diff)
downloadtor-667f5ea409a8f3950aedd60e85d23bddeb8ad9b6.tar
tor-667f5ea409a8f3950aedd60e85d23bddeb8ad9b6.tar.gz
Improve/extend strtok_r unit tests
* Add several failing tests (embedded in an "#if 0" block) for behaviour that doesn't match strtok_r * Add another, passing, more interesting test * Use test_eq_ptr(NULL, ...) instead of test_assert(NULL == ...)
Diffstat (limited to 'src/test/test_util.c')
-rw-r--r--src/test/test_util.c24
1 files changed, 22 insertions, 2 deletions
diff --git a/src/test/test_util.c b/src/test/test_util.c
index f0603f765..732712b8e 100644
--- a/src/test/test_util.c
+++ b/src/test/test_util.c
@@ -1478,8 +1478,28 @@ test_util_strtok(void)
test_streq("perfect", S2());
test_streq("descent", S1());
test_streq("monument", S2());
- test_assert(NULL == S1());
- test_assert(NULL == S2());
+ test_eq_ptr(NULL, S1());
+ test_eq_ptr(NULL, S2());
+
+#if 0
+ buf[0] = 0;
+ test_eq_ptr(NULL, tor_strtok_r_impl(buf, " ", &cp1));
+ test_eq_ptr(NULL, tor_strtok_r_impl(buf, "!", &cp1));
+
+ strlcpy(buf, "Howdy!", sizeof(buf));
+ test_streq("Howdy", tor_strtok_r_impl(buf, "!", &cp1));
+ test_eq_ptr(NULL, tor_strtok_r_impl(NULL, "!", &cp1));
+
+ strlcpy(buf, " ", sizeof(buf));
+ test_eq_ptr(NULL, tor_strtok_r_impl(buf, " ", &cp1));
+ strlcpy(buf, " ", sizeof(buf));
+ test_eq_ptr(NULL, tor_strtok_r_impl(buf, " ", &cp1));
+#endif
+
+ strlcpy(buf, "something ", sizeof(buf));
+ test_streq("something", tor_strtok_r_impl(buf, " ", &cp1));
+ test_streq(" ", tor_strtok_r_impl(NULL, ";", &cp1));
+ test_eq_ptr(NULL, tor_strtok_r_impl(NULL, " ", &cp1));
done:
;
}