Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

test and bench: assert return values of *_init functions in tests

  • Loading branch information...
erickt authored and bnoordhuis committed Sep 10, 2011
1 parent 905fe71 commit 533418d4dab34e4df90a7c3d500ef92ceedd4db3
@@ -273,10 +273,12 @@ static void connection_cb(uv_stream_t* s, int status) {

if (type == TCP) {
stream = (uv_stream_t*)malloc(sizeof(uv_tcp_t));
uv_tcp_init(loop, (uv_tcp_t*)stream);
r = uv_tcp_init(loop, (uv_tcp_t*)stream);
ASSERT(r == 0);
} else {
stream = (uv_stream_t*)malloc(sizeof(uv_pipe_t));
uv_pipe_init(loop, (uv_pipe_t*)stream);
r = uv_pipe_init(loop, (uv_pipe_t*)stream);
ASSERT(r == 0);
}

r = uv_accept(s, stream);
@@ -272,7 +272,8 @@ static void on_connection(uv_stream_t* server, int status) {
handle->state.prevbuf_pos = 0;
handle->state.prevbuf_rem = 0;

uv_tcp_init(loop, (uv_tcp_t*)handle);
r = uv_tcp_init(loop, (uv_tcp_t*)handle);
ASSERT(r == 0);

r = uv_accept(server, (uv_stream_t*)handle);
ASSERT(r == 0);
@@ -144,13 +144,15 @@ static void on_connection(uv_stream_t* server, int status) {
case TCP:
stream = malloc(sizeof(uv_tcp_t));
ASSERT(stream != NULL);
uv_tcp_init(loop, (uv_tcp_t*)stream);
r = uv_tcp_init(loop, (uv_tcp_t*)stream);
ASSERT(r == 0);
break;

case PIPE:
stream = malloc(sizeof(uv_pipe_t));
ASSERT(stream != NULL);
uv_pipe_init(loop, (uv_pipe_t*)stream);
r = uv_pipe_init(loop, (uv_pipe_t*)stream);
ASSERT(r == 0);
break;

default:
@@ -134,7 +134,10 @@ TEST_IMPL(connection_fail) {
* attempt.
*/
TEST_IMPL(connection_fail_doesnt_auto_close) {
uv_timer_init(uv_default_loop(), &timer);
int r;

r = uv_timer_init(uv_default_loop(), &timer);
ASSERT(r == 0);

connection_fail(on_connect_without_close);

@@ -57,7 +57,8 @@ static void do_accept(uv_timer_t* timer_handle, int status) {
ASSERT(status == 0);
ASSERT(accepted_handle != NULL);

uv_tcp_init(uv_default_loop(), accepted_handle);
r = uv_tcp_init(uv_default_loop(), accepted_handle);
ASSERT(r == 0);

/* Test to that uv_default_loop()->counters.tcp_init does not increase across the uv_accept. */
tcpcnt = uv_default_loop()->counters.tcp_init;
@@ -117,7 +117,8 @@ static void on_connection(uv_stream_t* server, int status) {
handle = (uv_handle_t*) malloc(sizeof(uv_tcp_t));
ASSERT(handle != NULL);

uv_tcp_init(loop, (uv_tcp_t*)handle);
r = uv_tcp_init(loop, (uv_tcp_t*)handle);
ASSERT(r == 0);

/* associate server with stream */
handle->data = server;
@@ -156,7 +156,9 @@ TEST_IMPL(shutdown_eof) {
qbuf.base = "Q";
qbuf.len = 1;

uv_timer_init(uv_default_loop(), &timer);
r = uv_timer_init(uv_default_loop(), &timer);
ASSERT(r == 0);

uv_timer_start(&timer, timer_cb, 100, 0);

server_addr = uv_ip4_addr("127.0.0.1", TEST_PORT);

0 comments on commit 533418d

Please sign in to comment.
You can’t perform that action at this time.