From 2da4fecacd1b61e9e090e93c33394712fa7f066c Mon Sep 17 00:00:00 2001 From: Roy Frostig Date: Fri, 20 Aug 2010 12:57:38 -0700 Subject: Test the buffered reader and writer in _io. --- src/test/run-pass/lib-io.rs | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 src/test/run-pass/lib-io.rs (limited to 'src/test') diff --git a/src/test/run-pass/lib-io.rs b/src/test/run-pass/lib-io.rs new file mode 100644 index 00000000..66394435 --- /dev/null +++ b/src/test/run-pass/lib-io.rs @@ -0,0 +1,26 @@ +// -*- rust -*- + +use std; +import std._io; +import std._str; + +fn test_simple(str tmpfilebase) { + let str tmpfile = tmpfilebase + ".tmp"; + log tmpfile; + let str frood = "A hoopy frood who really knows where his towel is."; + log frood; + + { + let _io.buf_writer out = _io.new_buf_writer(tmpfile, vec(_io.create())); + out.write(_str.bytes(frood)); + } + + let _io.buf_reader inp = _io.new_buf_reader(tmpfile); + let str frood2 = _str.from_bytes(inp.read()); + log frood2; + check (_str.eq(frood, frood2)); +} + +fn main(vec[str] argv) { + test_simple(argv.(0)); +} -- cgit v1.2.3