Files
c3c/test/unit/stdlib/io/multireader.c3
konimarti f3304acc93 Add io stream primitives (#1626)
* io: implement MultiReader struct

Implement a MultiReader (InStream) which sequentially read from the
provided readers (InStreams). Return IoError.EOF when all of the readers
are read.

* io: implement MultiWriter struct

Implement a MultiWriter (OutStream). The MultiWriter duplicates its
writes to all the provided writers (OutStream).

* io: implement TeeReader struct

Implement a TeeReader (InStream) which reads from a wrapped reader
(InStream) and writes data to the provided writer (OutStream).
2024-11-15 23:18:29 +01:00

22 lines
371 B
Plaintext

module std::io @test;
fn void! test_multireader()
{
MultiReader mr;
mr.temp_init(
&&wrap_bytes("foo"),
&&wrap_bytes(" "),
&&wrap_bytes("bar"),
&&wrap_bytes("!"),
);
defer mr.free();
ByteWriter w;
io::copy_to(&mr, w.temp_init())!;
String want = "foo bar!";
assert(w.str_view() == want,
"invalid data read; got: %s, want: %s", w.str_view(), want);
}