Files
c3c/test/unit/stdlib/io/multiwriter.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

18 lines
412 B
Plaintext

module std::io @test;
fn void! test_multiwriter()
{
ByteWriter w1, w2;
MultiWriter mw;
mw.temp_init(w1.temp_init(), w2.temp_init());
defer mw.free();
String want = "foobar";
io::copy_to(ByteReader{}.init(want), &mw)!;
assert(w1.str_view() == want,
"invalid write; got: %s, want: %s", w1.str_view(), want);
assert(w2.str_view() == want,
"invalid write; got: %s, want: %s", w2.str_view(), want);
}