mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 12:01:16 +00:00
Fix conversion if (int x = foo()). Initial stream api. Extended enumset.
This commit is contained in:
25
test/unit/stdlib/io/bytestream.c3
Normal file
25
test/unit/stdlib/io/bytestream.c3
Normal file
@@ -0,0 +1,25 @@
|
||||
module std::io @test;
|
||||
|
||||
fn void! bytestream()
|
||||
{
|
||||
ByteReader r;
|
||||
r.init("abc");
|
||||
Stream s = r.as_stream();
|
||||
assert(s.len()? == 3);
|
||||
char[5] buffer;
|
||||
assert('a' == s.read_byte()?);
|
||||
s.pushback_byte()?;
|
||||
usz len = s.read(&buffer)?;
|
||||
assert(buffer[:len] == "abc");
|
||||
ByteWriter w;
|
||||
w.init();
|
||||
Stream ws = w.as_stream();
|
||||
ws.write("helloworld")?;
|
||||
assert(w.as_str() == "helloworld");
|
||||
s.seek(0, SET)?;
|
||||
ws.read_from(&s)?;
|
||||
s.seek(1, SET)?;
|
||||
s.write_to(&ws)?;
|
||||
assert(w.as_str() == "helloworldabcbc");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user