p = data;
pend = CONST_PTR_OFFSET(data, size);
- for (; p < pend && (size_t)(p-data)+2 < max_bytes; p++) {
+ for (; p < pend && ((size_t)(p - data) + 2) <= max_bytes; p++) {
char add = 0;
size = pend - p;
test_end();
}
+static void test_ostream_dot_parent_exact_fit(void)
+{
+ buffer_t *output_data;
+ struct ostream *test_output, *output;
+ ssize_t ret;
+
+ test_begin("dot ostream parent exact fit");
+ output_data = t_buffer_create(1024);
+ test_output = test_ostream_create_nonblocking(output_data, 2);
+ test_ostream_set_max_output_size(test_output, 2);
+
+ output = o_stream_create_dot(test_output, FALSE);
+ ret = o_stream_send(output, ".", 1);
+ test_assert(ret == 1);
+ test_assert_ucmp(output_data->used, ==, 2);
+ test_assert_memcmp(output_data->data, output_data->used, "..", 2);
+
+ o_stream_unref(&output);
+ o_stream_unref(&test_output);
+ test_end();
+}
+
int main(void)
{
static void (*const test_functions[])(void) = {
test_ostream_dot,
test_ostream_dot_parent_almost_full,
+ test_ostream_dot_parent_exact_fit,
NULL
};
return test_run(test_functions);