#include "lib.h"
#include "buffer.h"
#include "istream.h"
-#include "istream-hash.h"
+#include "iostream-temp.h"
#include "ostream.h"
#include "sha1.h"
#include "randgen.h"
#define RANDOMNESS_SIZE (1024*1024)
unsigned char *randomness;
struct istream *input, *dec_input;
- struct ostream *buf_output, *output;
- buffer_t *buf;
+ struct ostream *temp_output, *output;
const unsigned char *data;
size_t size;
int ret;
/* write 1 MB of randomness to buffer */
input = i_stream_create_from_data(randomness, RANDOMNESS_SIZE);
- buf = buffer_create_dynamic(default_pool, 1024);
- buf_output = o_stream_create_buffer(buf);
- output = handler->create_ostream(buf_output, i_rand_minmax(1, 6));
+ temp_output = iostream_temp_create(".temp.", 0);
+ output = handler->create_ostream(temp_output, i_rand_minmax(1, 6));
switch (o_stream_send_istream(output, input)) {
case OSTREAM_SEND_ISTREAM_RESULT_ERROR_INPUT:
}
test_assert(output->offset == RANDOMNESS_SIZE);
test_assert(output->stream_errno == 0);
- o_stream_unref(&buf_output);
- o_stream_unref(&output);
i_stream_unref(&input);
+ input = iostream_temp_finish(&temp_output, SIZE_MAX);
+
/* verify that reading the input works */
- input = i_stream_create_from_data(buf->data, buf->used);
dec_input = handler->create_istream(input, FALSE);
while ((ret = i_stream_read_more(dec_input, &data, &size)) > 0) {
i_stream_unref(&dec_input);
i_stream_unref(&input);
- buffer_free(&buf);
i_free(randomness);
test_end();
}