diff options
author | Pixel <pixel@nobis-crew.org> | 2011-11-13 19:40:15 +0100 |
---|---|---|
committer | Pixel <pixel@nobis-crew.org> | 2011-11-13 14:54:13 -0700 |
commit | b3b38455482f2d15f07a33ecf00f9dea113e7968 (patch) | |
tree | d60d3b22a97dd4009a3e75f65621e72565cbf486 /tests | |
parent | e5619a3635dcec97afa2cddb0dc0344466324f6d (diff) |
Adding buffered streams; mainly for string parsing.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test-Handles.cc | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/tests/test-Handles.cc b/tests/test-Handles.cc index fd05c76..f185b60 100644 --- a/tests/test-Handles.cc +++ b/tests/test-Handles.cc @@ -2,6 +2,7 @@ #include <Input.h> #include <Output.h> #include <Buffer.h> +#include <BStream.h> #ifdef _WIN32 void ctime_r(const time_t * t, char * str) { @@ -69,18 +70,40 @@ void MainTask::Do() { Assert(s == 0); s = o->getSize(); Assert(s == 0); - o->write("foo\n", 4); + o->writeString("foo\n"); IO<Handle> b(new Buffer()); s = b->rtell(); Assert(s == 0); s = b->wtell(); Assert(s == 0); - b->write("foo\n", 4); + b->writeString("foo\n"); s = b->rtell(); Assert(s == 0); s = b->wtell(); Assert(s == 4); + b->writeString("bar\r\n"); + s = b->rtell(); + Assert(s == 0); + s = b->wtell(); + Assert(s == 9); + b->writeString("eof"); + s = b->rtell(); + Assert(s == 0); + s = b->wtell(); + Assert(s == 12); + + IO<BStream> strm(new BStream(b)); + String str; + str = strm->readString(); + Assert(str == "foo"); + str = strm->readString(); + Assert(str == "bar"); + str = strm->readString(); + Assert(str == "eof"); + s = b->rtell(); + Assert(s == 12); + Assert(b->isEOF()); Printer::log(M_STATUS, "Test::Handles passed."); } |