diff options
| author | Roy Frostig <[email protected]> | 2010-08-20 12:57:38 -0700 |
|---|---|---|
| committer | Roy Frostig <[email protected]> | 2010-08-20 12:57:38 -0700 |
| commit | 2da4fecacd1b61e9e090e93c33394712fa7f066c (patch) | |
| tree | a8cfa1e04cd0c39d91441a71d3a4bcba0ef8cba7 /src/test | |
| parent | Allow every test to make a .tmp file that is cleaned up before execution. (diff) | |
| download | rust-2da4fecacd1b61e9e090e93c33394712fa7f066c.tar.xz rust-2da4fecacd1b61e9e090e93c33394712fa7f066c.zip | |
Test the buffered reader and writer in _io.
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/run-pass/lib-io.rs | 26 |
1 files changed, 26 insertions, 0 deletions
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)); +} |