--- a/test/buffer_tests.c Wed Oct 10 13:58:51 2012 +0200 +++ b/test/buffer_tests.c Wed Oct 10 14:18:06 2012 +0200 @@ -145,6 +145,30 @@ free(buffer); } +UCX_TEST_IMPLEMENT(test_ucx_buffer_write_ax) { + char *buffer = malloc(4); + + UcxBuffer *b = ucx_buffer_new(buffer, 16, + UCX_BUFFER_AUTOEXTEND | UCX_BUFFER_AUTOFREE); + int r; + + UCX_TEST_BEGIN + + char* teststring = "this is way too much"; + r = ucx_buffer_write(teststring, 1, 20, b); + buffer = b->space; /* autoextend is enabled, so we MUST retrieve pointer */ + UCX_TEST_ASSERT(r == 20, "not all characters written"); + UCX_TEST_ASSERT(b->size == 32, "buffer not properly extended"); + UCX_TEST_ASSERT(b->pos == 20, "position incorrect"); + UCX_TEST_ASSERT(memcmp(buffer, + "this is way too much\0\0\0\0\0\0\0\0\0\0\0\0", 32) == 0, + "incorrect buffer content"); + + UCX_TEST_END + + ucx_buffer_free(b); +} + UCX_TEST_IMPLEMENT(test_ucx_buffer_read) { char *buffer = malloc(16); memset(buffer, 56, 8);