# HG changeset patch # User Tom Fredrik Blenning Klaussen # Date 1347297510 -7200 # Node ID 7348d4efa4f6f6f07656bdca6bff57904279a0fd # Parent 1334d1417c0bf54db92391efef01955871822d51 More testing for BitDecoder. diff -r 1334d1417c0b -r 7348d4efa4f6 TestBitDecoder.cpp --- 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"); + +}