diff options
author | Willem Jan Palenstijn | 2010-08-25 11:46:50 +0000 |
---|---|---|
committer | Willem Jan Palenstijn | 2010-08-25 11:46:50 +0000 |
commit | 8cd0cfe5eb5778e51d51d25494bf278b475f7092 (patch) | |
tree | 7bdcfe2f619f8021a7aff98a363ab8e858006c6c | |
parent | 3900aa96b67298bb50b3a1aaf4c7ac5a0b5cc35a (diff) | |
download | scummvm-rg350-8cd0cfe5eb5778e51d51d25494bf278b475f7092.tar.gz scummvm-rg350-8cd0cfe5eb5778e51d51d25494bf278b475f7092.tar.bz2 scummvm-rg350-8cd0cfe5eb5778e51d51d25494bf278b475f7092.zip |
COMMON: Add test for BufferedReadStream's eos
This test is currently failing.
svn-id: r52382
-rw-r--r-- | test/common/bufferedreadstream.h | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/test/common/bufferedreadstream.h b/test/common/bufferedreadstream.h index c171836466..0b2cda696c 100644 --- a/test/common/bufferedreadstream.h +++ b/test/common/bufferedreadstream.h @@ -27,4 +27,29 @@ class BufferedReadStreamTestSuite : public CxxTest::TestSuite { TS_ASSERT(srs.eos()); } + + void test_traverse2() { + byte contents[9] = { 0, 1, 2, 3, 4, 5, 6, 7, 8 }; + Common::MemoryReadStream ms(contents, 9); + + Common::BufferedReadStream brs(&ms, 4); + + // Traverse the stream with reads of 2 bytes. The size is not + // a multiple of 2, so we can test the final partial read. + + byte i, b[2]; + for (i = 0; i < 4; ++i) { + TS_ASSERT(!brs.eos()); + + int n = brs.read(b, 2); + TS_ASSERT_EQUALS(n, 2); + } + + TS_ASSERT(!brs.eos()); + + int n = brs.read(b, 2); + TS_ASSERT_EQUALS(n, 1); + + TS_ASSERT(brs.eos()); + } }; |