bcb4e51a409d94ae670de96afb8483a4f7855294Stephan Bosch/* Copyright (c) 2014-2018 Dovecot authors, see the included COPYING file */
f5982bb5b0a704e88fa2b44b0b74e365d13103b9Timo Sirainen parent = test_istream_create_data("123456789", 9);
f5982bb5b0a704e88fa2b44b0b74e365d13103b9Timo Sirainen child1 = i_stream_create_limit(parent, (uoff_t)-1);
f5982bb5b0a704e88fa2b44b0b74e365d13103b9Timo Sirainen child2 = i_stream_create_limit(parent, (uoff_t)-1);
f5982bb5b0a704e88fa2b44b0b74e365d13103b9Timo Sirainen /* child1 read beginning */
f5982bb5b0a704e88fa2b44b0b74e365d13103b9Timo Sirainen test_assert(size == 3 && memcmp(data, "123", 3) == 0);
f5982bb5b0a704e88fa2b44b0b74e365d13103b9Timo Sirainen /* child1 read middle.. */
f5982bb5b0a704e88fa2b44b0b74e365d13103b9Timo Sirainen test_assert(size == 3 && memcmp(data, "456", 3) == 0);
f5982bb5b0a704e88fa2b44b0b74e365d13103b9Timo Sirainen /* child2 read beginning.. */
f5982bb5b0a704e88fa2b44b0b74e365d13103b9Timo Sirainen test_assert(size == 3 && memcmp(data, "123", 3) == 0);
f5982bb5b0a704e88fa2b44b0b74e365d13103b9Timo Sirainen /* child1 check middle again.. the parent has been modified,
f5982bb5b0a704e88fa2b44b0b74e365d13103b9Timo Sirainen so it can't return the original data (without some code changes). */
d47bd663deb1846980e6759c87297741a5459890Timo Sirainen test_assert(i_stream_get_data_size(child1) == 0);
f5982bb5b0a704e88fa2b44b0b74e365d13103b9Timo Sirainen /* child1 read end */
f5982bb5b0a704e88fa2b44b0b74e365d13103b9Timo Sirainen test_assert(size == 3 && memcmp(data, "789", 3) == 0);
f5982bb5b0a704e88fa2b44b0b74e365d13103b9Timo Sirainen /* child2 check beginning again.. */
d47bd663deb1846980e6759c87297741a5459890Timo Sirainen test_assert(i_stream_get_data_size(child1) == 0);
f5982bb5b0a704e88fa2b44b0b74e365d13103b9Timo Sirainen /* child2 read middle */
f5982bb5b0a704e88fa2b44b0b74e365d13103b9Timo Sirainen test_assert(size == 3 && memcmp(data, "456", 3) == 0);