mirror of
https://github.com/libevent/libevent.git
synced 2025-01-31 09:12:55 +08:00
test/evbuffer_peek: add regress in case we have first buffer greater
This commit is contained in:
parent
ba59923ab8
commit
e2d139dd7e
@ -1843,6 +1843,34 @@ end:
|
||||
|
||||
}
|
||||
|
||||
static void
|
||||
test_evbuffer_peek_first_gt(void *info)
|
||||
{
|
||||
struct evbuffer *buf = NULL, *tmp_buf = NULL;
|
||||
struct evbuffer_ptr ptr;
|
||||
struct evbuffer_iovec v[2];
|
||||
|
||||
buf = evbuffer_new();
|
||||
tmp_buf = evbuffer_new();
|
||||
evbuffer_add_printf(tmp_buf, "Contents of chunk 100\n");
|
||||
evbuffer_add_buffer(buf, tmp_buf);
|
||||
evbuffer_add_printf(tmp_buf, "Contents of chunk 1\n");
|
||||
evbuffer_add_buffer(buf, tmp_buf);
|
||||
|
||||
evbuffer_ptr_set(buf, &ptr, 0, EVBUFFER_PTR_SET);
|
||||
|
||||
/** The only case that matters*/
|
||||
tt_int_op(evbuffer_peek(buf, -1, &ptr, NULL, 0), ==, 2);
|
||||
/** Just in case */
|
||||
tt_int_op(evbuffer_peek(buf, -1, &ptr, v, 2), ==, 2);
|
||||
|
||||
end:
|
||||
if (buf)
|
||||
evbuffer_free(buf);
|
||||
if (tmp_buf)
|
||||
evbuffer_free(tmp_buf);
|
||||
}
|
||||
|
||||
static void
|
||||
test_evbuffer_peek(void *info)
|
||||
{
|
||||
@ -2210,6 +2238,7 @@ struct testcase_t evbuffer_testcases[] = {
|
||||
{ "multicast_drain", test_evbuffer_multicast_drain, 0, NULL, NULL },
|
||||
{ "prepend", test_evbuffer_prepend, TT_FORK, NULL, NULL },
|
||||
{ "peek", test_evbuffer_peek, 0, NULL, NULL },
|
||||
{ "peek_first_gt", test_evbuffer_peek_first_gt, 0, NULL, NULL },
|
||||
{ "freeze_start", test_evbuffer_freeze, 0, &nil_setup, (void*)"start" },
|
||||
{ "freeze_end", test_evbuffer_freeze, 0, &nil_setup, (void*)"end" },
|
||||
{ "add_iovec", test_evbuffer_add_iovec, 0, NULL, NULL},
|
||||
|
Loading…
x
Reference in New Issue
Block a user