Mercurial > dedupe
view TestBitDecoder.cpp @ 31:bf3dce7fedcb
Remove all references to QDebug
| author | Tom Fredrik Blenning Klaussen <bfg@blenning.no> |
|---|---|
| date | Thu, 06 Sep 2012 19:14:58 +0200 |
| parents | b2c2c2bf2bbd |
| children | 7348d4efa4f6 |
line wrap: on
line source
#include "BitDecoder.hpp" #include "TestFramework.hpp" #include "Exception/InvalidDataException.hpp" QBitArray bitsFromString(const QString& str) { QBitArray bits(str.size()); for (int i = 0; i < str.size(); ++i) { if (str[i] == '1') bits[i] = true; else if (str[i] == '0') bits[i] = false; else throw InvalidDataException(); } return bits; } BOOST_AUTO_TEST_CASE( TestSimple ) { BitDecoder* up = new BitDecoder("a"); BitDecoder* down = new BitDecoder("b"); BitDecoder* full = BitDecoder::merge(down, up); BOOST_REQUIRE(full->data().isNull()); BOOST_REQUIRE_EQUAL(up->data(), "a"); BOOST_REQUIRE_EQUAL(down->data(), "b"); BOOST_REQUIRE_EQUAL(full->decode(bitsFromString("1")), "a"); BOOST_REQUIRE_EQUAL(full->decode(bitsFromString("0")), "b"); BOOST_REQUIRE_EQUAL(full->decode(bitsFromString("1111")), "aaaa"); BOOST_REQUIRE_EQUAL(full->decode(bitsFromString("0000")), "bbbb"); BOOST_REQUIRE_EQUAL(full->decode(bitsFromString("1101")), "aaba"); BOOST_REQUIRE_EQUAL(full->decode(bitsFromString("1111")), "aaaa"); }
