From 175d4dda776c641765189d90e42f39cc590ed771 Mon Sep 17 00:00:00 2001 From: Joshua Scott Date: Fri, 26 Oct 2018 14:52:02 +0100 Subject: [PATCH] pclass: Add write and read to BitStream test --- test/samples/bitstream2.bin | 2 +- test/src/unit-bitstream.cpp | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/test/samples/bitstream2.bin b/test/samples/bitstream2.bin index 59961e8..5f6afee 100644 --- a/test/samples/bitstream2.bin +++ b/test/samples/bitstream2.bin @@ -1,2 +1,2 @@ - +  \ No newline at end of file diff --git a/test/src/unit-bitstream.cpp b/test/src/unit-bitstream.cpp index a1eafde..a84c243 100644 --- a/test/src/unit-bitstream.cpp +++ b/test/src/unit-bitstream.cpp @@ -12,6 +12,7 @@ #define KI_TEST_BITSTREAM_BUI5 0b10101 #define KI_TEST_BITSTREAM_BUI6 0b101010 #define KI_TEST_BITSTREAM_BUI7 0b0101010 +#define KI_TEST_BITSTREAM_BOOL true #define KI_TEST_BITSTREAM_U8 0x01 #define KI_TEST_BITSTREAM_U16 0x0302 #define KI_TEST_BITSTREAM_U24 0x060504 @@ -117,6 +118,7 @@ TEST_CASE("BitStream Functionality", "[bit-stream]") SECTION("Writing values with a size greater than 8 bits") { // Write some values + bit_stream->write(KI_TEST_BITSTREAM_BOOL); bit_stream->write(KI_TEST_BITSTREAM_U8); bit_stream->write(KI_TEST_BITSTREAM_U16); bit_stream->write>(KI_TEST_BITSTREAM_U24); @@ -125,7 +127,7 @@ TEST_CASE("BitStream Functionality", "[bit-stream]") // Make sure tell is reporting the right position auto position = bit_stream->tell(); - if (position.get_byte() != 18 || position.get_bit() != 0) + if (position.get_byte() != 19 || position.get_bit() != 0) FAIL(); const auto size = position.get_byte(); @@ -197,6 +199,8 @@ TEST_CASE("BitStream Functionality", "[bit-stream]") sample.read((char *)bit_stream->data(), size); // Read the values and check they are what we are expecting + if (bit_stream->read() != KI_TEST_BITSTREAM_BOOL) + FAIL(); if (bit_stream->read() != KI_TEST_BITSTREAM_U8) FAIL(); if (bit_stream->read() != KI_TEST_BITSTREAM_U16)