Mercurial > dedupe
diff TestBitArray.cpp @ 47:b23f04d4a276
Test a custom BitArray.
| author | Tom Fredrik Blenning Klaussen <bfg@blenning.no> |
|---|---|
| date | Mon, 10 Sep 2012 23:59:05 +0200 |
| parents | |
| children | 0bd3c1c46251 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/TestBitArray.cpp Mon Sep 10 23:59:05 2012 +0200 @@ -0,0 +1,52 @@ +#include "BitArray.hpp" +#include "TestFramework.hpp" + +#include <QtCore/QDebug> + +BOOST_AUTO_TEST_CASE( TestBasic ) +{ + { + BitArray tbits(16, true); + BitArray fbits(16, false); + for (uint i = 0; i < tbits.size(); ++i) { + BOOST_REQUIRE_EQUAL(tbits.testBit(i), true); + BOOST_REQUIRE_EQUAL(fbits.testBit(i), false); + } + } + + { + BitArray tbits(9, true); + BitArray fbits(9, false); + for (uint i = 0; i < tbits.size(); ++i) { + BOOST_REQUIRE_EQUAL(tbits.testBit(i), true); + BOOST_REQUIRE_EQUAL(fbits.testBit(i), false); + } + } + + { + BitArray tbits(13, true); + BitArray fbits(13, false); + for (uint i = 0; i < tbits.size(); ++i) { + BOOST_REQUIRE_EQUAL(tbits.testBit(i), true); + BOOST_REQUIRE_EQUAL(fbits.testBit(i), false); + } + } + +} + + +BOOST_AUTO_TEST_CASE( TestSetBit ) +{ + + for (uint i = 0; i < 13; ++i) { + BitArray tbits(13, true); + BitArray fbits(13, false); + tbits.setBit(i, false); + fbits.setBit(i, true); + for (uint j = 0; j < tbits.size(); ++j) { + BOOST_REQUIRE_EQUAL(tbits.testBit(j), i != j); + BOOST_REQUIRE_EQUAL(fbits.testBit(j), i == j); + } + } + +}
