mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 12:01:16 +00:00
* 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).
22 lines
371 B
Plaintext
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);
|
|
}
|
|
|