changeset 44:7348d4efa4f6

More testing for BitDecoder.
author Tom Fredrik Blenning Klaussen <bfg@blenning.no>
date Mon, 10 Sep 2012 19:18:30 +0200
parents 1334d1417c0b
children 41cc0d8ac77f
files TestBitDecoder.cpp
diffstat 1 files changed, 29 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/TestBitDecoder.cpp	Sun Sep 09 19:13:13 2012 +0200
+++ b/TestBitDecoder.cpp	Mon Sep 10 19:18:30 2012 +0200
@@ -36,3 +36,32 @@
   BOOST_REQUIRE_EQUAL(full->decode(bitsFromString("1101")), "aaba");
   BOOST_REQUIRE_EQUAL(full->decode(bitsFromString("1111")), "aaaa");
 }
+
+BOOST_AUTO_TEST_CASE( TestLong )
+{
+  BitDecoder* up = new BitDecoder("b");
+  BitDecoder* down = new BitDecoder("a");
+  for (int i = 0; i < 12; ++i) {
+    down = BitDecoder::merge(down, up);
+    up = new BitDecoder(QString('c' + i));
+  }
+
+  BitDecoder* full = BitDecoder::merge(down, up);
+
+  BOOST_REQUIRE(full->data().isNull());
+  BOOST_REQUIRE_EQUAL(full->decode(bitsFromString("1")), "n");
+  BOOST_REQUIRE_EQUAL(full->decode(bitsFromString("01")), "m");
+  BOOST_REQUIRE_EQUAL(full->decode(bitsFromString("001")), "l");
+  BOOST_REQUIRE_EQUAL(full->decode(bitsFromString("0001")), "k");
+  BOOST_REQUIRE_EQUAL(full->decode(bitsFromString("00001")), "j");
+  BOOST_REQUIRE_EQUAL(full->decode(bitsFromString("000001")), "i");
+  BOOST_REQUIRE_EQUAL(full->decode(bitsFromString("0000001")), "h");
+  BOOST_REQUIRE_EQUAL(full->decode(bitsFromString("00000001")), "g");
+  BOOST_REQUIRE_EQUAL(full->decode(bitsFromString("000000001")), "f");
+  BOOST_REQUIRE_EQUAL(full->decode(bitsFromString("0000000001")), "e");
+  BOOST_REQUIRE_EQUAL(full->decode(bitsFromString("00000000001")), "d");
+  BOOST_REQUIRE_EQUAL(full->decode(bitsFromString("000000000001")), "c");
+  BOOST_REQUIRE_EQUAL(full->decode(bitsFromString("0000000000001")), "b");
+  BOOST_REQUIRE_EQUAL(full->decode(bitsFromString("0000000000000")), "a");
+
+}