src/test/transport.h
author Tero Marttila <terom@fixme.fi>
Mon, 04 May 2009 20:55:04 +0300
branchnew-transport
changeset 168 a58ad50911fc
child 196 873796250c60
permissions -rw-r--r--
refactor test.c into tests/*
#ifndef TEST_TRANSPORT_H
#define TEST_TRANSPORT_H

/**
 * @file
 *
 * Functions for interacting with transports
 */
#include "../transport_test.h"

/**
 * Read strlen(str) bytes from the given transport, and assert that they match the given string.
 *
 * Note that this only performs one transport_read.
 */
void assert_transport_read (transport_t *transport, const char *str);

/**
 * Write strlen(str) bytes to the given transport, and assert that they all get written.
 *
 * Note that this only performs one transport_write.
 */
void assert_transport_write (transport_t *transport, const char *str);

/**
 * Attempt to read a single byte from the given transport, and assert that the attempt returns ERR_EOF.
 */
void assert_transport_eof (transport_t *transport);

/**
 * Compare the written data stored in the given transport_test with the string obtained using the given format and args.
 *
 * This will pull /all/ of the data in the transport.
 */
void assert_transport_data (struct transport_test *tp, const char *fmt, ...);

/**
 * Create an empty transport_test, with NULL callbacks.
 *
 * You must bind a new set of callbacks to the transport before pushing any data to it.
 */
struct transport_test* setup_transport_test (void);

#endif