2006-11-13 22:06:27 +00:00
|
|
|
#include <cxxtest/TestSuite.h>
|
|
|
|
|
|
|
|
#include "common/stream.h"
|
|
|
|
|
2008-07-29 17:42:19 +00:00
|
|
|
class SubReadStreamTestSuite : public CxxTest::TestSuite {
|
2006-11-13 22:06:27 +00:00
|
|
|
public:
|
2009-04-20 19:26:50 +00:00
|
|
|
void test_traverse() {
|
2006-11-13 22:06:27 +00:00
|
|
|
byte contents[10] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
|
2008-07-29 17:42:19 +00:00
|
|
|
Common::MemoryReadStream ms(contents, 10);
|
2006-11-13 22:06:27 +00:00
|
|
|
|
|
|
|
int end = 5;
|
|
|
|
|
2008-07-29 17:42:19 +00:00
|
|
|
Common::SubReadStream srs(&ms, end);
|
2006-11-13 22:06:27 +00:00
|
|
|
|
|
|
|
int i;
|
|
|
|
byte b;
|
2008-07-29 17:42:19 +00:00
|
|
|
for (i = 0; i < end; ++i) {
|
2006-11-13 22:06:27 +00:00
|
|
|
TS_ASSERT( !srs.eos() );
|
|
|
|
|
2008-07-29 17:42:19 +00:00
|
|
|
b = srs.readByte();
|
2006-11-13 22:06:27 +00:00
|
|
|
TS_ASSERT_EQUALS( i, b );
|
|
|
|
}
|
|
|
|
|
2008-09-14 22:28:53 +00:00
|
|
|
TS_ASSERT( !srs.eos() );
|
|
|
|
b = srs.readByte();
|
2006-11-13 22:06:27 +00:00
|
|
|
TS_ASSERT( srs.eos() );
|
|
|
|
}
|
|
|
|
};
|