bcb4e51a409d94ae670de96afb8483a4f7855294Stephan Bosch/* Copyright (c) 2015-2018 Dovecot authors, see the included COPYING file */
289bb39856d74484c1622d096922acf126dd90fcTimo Sirainen#define TEST_ERRMSG "test-istream-failure-at error triggered"
289bb39856d74484c1622d096922acf126dd90fcTimo Sirainen unsigned int i;
289bb39856d74484c1622d096922acf126dd90fcTimo Sirainen for (i = 0; i < sizeof(test_data); i++)
289bb39856d74484c1622d096922acf126dd90fcTimo Sirainen data_input = i_stream_create_from_data(test_data, sizeof(test_data));
289bb39856d74484c1622d096922acf126dd90fcTimo Sirainen for (i = 0; i < TEST_DATA_LENGTH; i++) {
a4985564b81d51caaddd38376792432428fd449bStephan Bosch input = i_stream_create_failure_at(data_input, i, EIO, TEST_ERRMSG);
289bb39856d74484c1622d096922acf126dd90fcTimo Sirainen test_assert_idx(ret == -1 && input->v_offset == i &&
289bb39856d74484c1622d096922acf126dd90fcTimo Sirainen strcmp(i_stream_get_error(input), TEST_ERRMSG) == 0, i);
289bb39856d74484c1622d096922acf126dd90fcTimo Sirainen /* shouldn't fail */
a4985564b81d51caaddd38376792432428fd449bStephan Bosch input = i_stream_create_failure_at(data_input, TEST_DATA_LENGTH, EIO, TEST_ERRMSG);
289bb39856d74484c1622d096922acf126dd90fcTimo Sirainen test_assert(ret == -1 && input->stream_errno == 0);
289bb39856d74484c1622d096922acf126dd90fcTimo Sirainen /* fail at EOF */
a4985564b81d51caaddd38376792432428fd449bStephan Bosch input = i_stream_create_failure_at_eof(data_input, EIO, TEST_ERRMSG);
289bb39856d74484c1622d096922acf126dd90fcTimo Sirainen test_assert_idx(ret == -1 && input->v_offset == TEST_DATA_LENGTH &&