test-istream-seekable.c revision 0536ccb51d41e3078c3a9fa33e509fb4b2420f95
/* Copyright (c) 2009-2011 Dovecot authors, see the included COPYING file */
#include "test-lib.h"
#include "istream-private.h"
#include "istream-seekable.h"
#include <stdlib.h>
#include <fcntl.h>
#include <unistd.h>
{
int fd;
*path_r = "test-lib.tmp";
if (fd == -1)
else
return fd;
}
static void test_istream_seekable_one(unsigned int buffer_size)
{
static const char *input_string = "xyz";
#define STREAM_COUNT 5
#define STREAM_BYTES 3
const unsigned char *data;
unsigned int i, j;
for (i = 0; i < STREAM_COUNT; i++) {
test_istream_set_size(streams[i], 0);
}
for (i = 0; i/STREAM_BYTES < STREAM_COUNT; i++) {
if (i < buffer_size) {
} else {
}
for (j = 0; j < size; j++) {
}
}
for (i = 0; i < STREAM_COUNT; i++)
i_stream_unref(&streams[i]);
}
static void test_istream_seekable_random(void)
{
const unsigned char *data;
unsigned char *w_data;
for (i = 0, offset = 0; i < stream_count; i++) {
for (j = 0; j < data_len; j++)
}
/* first read it through */
while (i_stream_read(input) > 0) {
}
i_stream_seek(input, 0);
for (i = 0; i < 100; i++) {
if (rand() % 3 == 0) {
} else {
test_assert(ret < 0);
else if (ret == -2) {
} else {
test_assert(ret > 0);
for (j = 0; j < size; j++) {
}
}
}
}
for (i = 0; i < stream_count; i++)
i_stream_unref(&streams[i]);
}
static void test_istream_seekable_eof(void)
{
static const char *in_str = "foo";
const unsigned char *data;
test_begin("istream seekable eof");
i_stream_unref(&streams[0]);
test_end();
}
void test_istream_seekable(void)
{
unsigned int i;
test_begin("istream seekable");
test_end();
test_begin("istream seekable random");
for (i = 0; i < 100; i++) T_BEGIN {
} T_END;
test_end();
}