mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-27 22:03:31 +01:00
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 == ...)
This commit is contained in:
parent
ee317256bb
commit
667f5ea409
@ -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:
|
||||
;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user