aboutsummaryrefslogtreecommitdiff
path: root/test/common
diff options
context:
space:
mode:
Diffstat (limited to 'test/common')
-rw-r--r--test/common/bitstream.h50
1 files changed, 47 insertions, 3 deletions
diff --git a/test/common/bitstream.h b/test/common/bitstream.h
index 0488169183..742f0c18b1 100644
--- a/test/common/bitstream.h
+++ b/test/common/bitstream.h
@@ -50,7 +50,7 @@ public:
private:
template<class MS, class BS>
void tmpl_skip() {
- byte contents[] = { 'a', 'b' };
+ byte contents[] = { 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j' };
MS ms(contents, sizeof(contents));
@@ -61,6 +61,8 @@ private:
bs.skip(4);
TS_ASSERT_EQUALS(bs.pos(), 9u);
TS_ASSERT_EQUALS(bs.getBits(3), 6u);
+ bs.skip(65);
+ TS_ASSERT_EQUALS(bs.pos(), 77u);
TS_ASSERT(!bs.eos());
}
public:
@@ -133,7 +135,7 @@ private:
TS_ASSERT_EQUALS(bs.pos(), 3u);
bs.skip(8);
TS_ASSERT_EQUALS(bs.pos(), 11u);
- TS_ASSERT_EQUALS(bs.peekBits(5), 2u);
+ TS_ASSERT_EQUALS(bs.peekBits(6), 4u);
TS_ASSERT(!bs.eos());
}
public:
@@ -203,7 +205,7 @@ private:
TS_ASSERT_EQUALS(bs.pos(), 3u);
bs.skip(8);
TS_ASSERT_EQUALS(bs.pos(), 11u);
- TS_ASSERT_EQUALS(bs.peekBits(5), 12u);
+ TS_ASSERT_EQUALS(bs.peekBits(20), 12u);
TS_ASSERT(!bs.eos());
}
public:
@@ -211,4 +213,46 @@ public:
tmpl_peek_bits_lsb<Common::MemoryReadStream, Common::BitStream8LSB>();
tmpl_peek_bits_lsb<Common::BitStreamMemoryStream, Common::BitStreamMemory8LSB>();
}
+
+private:
+ template<class MS, class BS>
+ void tmpl_align() {
+ byte contents[] = { 'a', 'b' };
+
+ MS ms(contents, sizeof(contents));
+
+ BS bs(ms);
+ TS_ASSERT_EQUALS(bs.pos(), 0u);
+ bs.align();
+ TS_ASSERT_EQUALS(bs.pos(), 0u);
+ bs.skip(3);
+ bs.align();
+ TS_ASSERT_EQUALS(bs.pos(), 8u);
+ }
+public:
+ void test_align() {
+ tmpl_align<Common::MemoryReadStream, Common::BitStream8LSB>();
+ tmpl_align<Common::BitStreamMemoryStream, Common::BitStreamMemory8LSB>();
+ }
+
+private:
+ template<class MS, class BS>
+ void tmpl_align_16() {
+ byte contents[] = { 'a', 'b' };
+
+ MS ms(contents, sizeof(contents));
+
+ BS bs(ms);
+ TS_ASSERT_EQUALS(bs.pos(), 0u);
+ bs.align();
+ TS_ASSERT_EQUALS(bs.pos(), 0u);
+ bs.skip(3);
+ bs.align();
+ TS_ASSERT_EQUALS(bs.pos(), 16u);
+ }
+public:
+ void test_align_16() {
+ tmpl_align_16<Common::MemoryReadStream, Common::BitStream16BELSB>();
+ tmpl_align_16<Common::BitStreamMemoryStream, Common::BitStreamMemory16BELSB>();
+ }
};