From 22c5dadb41b03657c39685f52f547a25ef17ded6 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Sun, 11 Mar 2012 01:19:49 +0100 Subject: TEST: Add a test case for MemoryReadStream::eos handling. --- test/common/memoryreadstream.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'test') diff --git a/test/common/memoryreadstream.h b/test/common/memoryreadstream.h index a476f12a2f..adef861a5e 100644 --- a/test/common/memoryreadstream.h +++ b/test/common/memoryreadstream.h @@ -84,4 +84,20 @@ class MemoryReadStreamTestSuite : public CxxTest::TestSuite { TS_ASSERT_EQUALS(ms.pos(), 7); TS_ASSERT(!ms.eos()); } + + void test_eos() { + byte contents[] = { 1, 2, 3, 4, 5, 6, 7 }; + Common::MemoryReadStream ms(contents, sizeof(contents)); + + // Read after the end of the stream + for (int32 i = 0; i <= ms.size(); ++i) + ms.readByte(); + + // The eos flag should be set here + TS_ASSERT(ms.eos()); + + // Seeking should reset the eos flag + ms.seek(0, SEEK_SET); + TS_ASSERT(!ms.eos()); + } }; -- cgit v1.2.3