Mercurial > dedupe
view TestFastBitDecoder.cpp @ 97:34f11b2a1178
Script to extract duplicates directly to the commandline.
| author | Tom Fredrik Blenning Klaussen <bfg@bfgconsult.no> |
|---|---|
| date | Thu, 13 Feb 2014 14:51:06 +0100 |
| parents | f9fa7ea71d37 |
| children |
line wrap: on
line source
#include "FastBitDecoder.hpp" #include "TestFramework.hpp" #include "BitDecoder.hpp" BOOST_AUTO_TEST_CASE( TestSimple ) { BitDecoder* up = new BitDecoder("a"); BitDecoder* down = new BitDecoder("b"); std::auto_ptr<BitDecoder> full(BitDecoder::merge(down, up)); BOOST_REQUIRE(full->data().isNull()); BOOST_REQUIRE_EQUAL(up->data(), "a"); BOOST_REQUIRE_EQUAL(down->data(), "b"); FastBitDecoder fast(full->createEncoder()); BOOST_REQUIRE_EQUAL(fast.decode("1"), "a"); BOOST_REQUIRE_EQUAL(fast.decode("0"), "b"); BOOST_REQUIRE_EQUAL(fast.decode("1111"), "aaaa"); BOOST_REQUIRE_EQUAL(fast.decode("0000"), "bbbb"); BOOST_REQUIRE_EQUAL(fast.decode("1101"), "aaba"); BOOST_REQUIRE_EQUAL(fast.decode("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)); } std::auto_ptr<BitDecoder> full(BitDecoder::merge(down, up)); BOOST_REQUIRE(full->data().isNull()); FastBitDecoder fast(full->createEncoder()); BOOST_REQUIRE_EQUAL(fast.decode("1"), "n"); BOOST_REQUIRE_EQUAL(fast.decode("01"), "m"); BOOST_REQUIRE_EQUAL(fast.decode("001"), "l"); BOOST_REQUIRE_EQUAL(fast.decode("0001"), "k"); BOOST_REQUIRE_EQUAL(fast.decode("00001"), "j"); BOOST_REQUIRE_EQUAL(fast.decode("000001"), "i"); BOOST_REQUIRE_EQUAL(fast.decode("0000001"), "h"); BOOST_REQUIRE_EQUAL(fast.decode("00000001"), "g"); BOOST_REQUIRE_EQUAL(fast.decode("000000001"), "f"); BOOST_REQUIRE_EQUAL(fast.decode("0000000001"), "e"); BOOST_REQUIRE_EQUAL(fast.decode("00000000001"), "d"); BOOST_REQUIRE_EQUAL(fast.decode("000000000001"), "c"); BOOST_REQUIRE_EQUAL(fast.decode("0000000000001"), "b"); BOOST_REQUIRE_EQUAL(fast.decode("0000000000000"), "a"); }
