Mercurial > dedupe
comparison 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 |
comparison
equal
deleted
inserted
replaced
| 46:877327e9061a | 47:b23f04d4a276 |
|---|---|
| 1 #include "BitArray.hpp" | |
| 2 #include "TestFramework.hpp" | |
| 3 | |
| 4 #include <QtCore/QDebug> | |
| 5 | |
| 6 BOOST_AUTO_TEST_CASE( TestBasic ) | |
| 7 { | |
| 8 { | |
| 9 BitArray tbits(16, true); | |
| 10 BitArray fbits(16, false); | |
| 11 for (uint i = 0; i < tbits.size(); ++i) { | |
| 12 BOOST_REQUIRE_EQUAL(tbits.testBit(i), true); | |
| 13 BOOST_REQUIRE_EQUAL(fbits.testBit(i), false); | |
| 14 } | |
| 15 } | |
| 16 | |
| 17 { | |
| 18 BitArray tbits(9, true); | |
| 19 BitArray fbits(9, false); | |
| 20 for (uint i = 0; i < tbits.size(); ++i) { | |
| 21 BOOST_REQUIRE_EQUAL(tbits.testBit(i), true); | |
| 22 BOOST_REQUIRE_EQUAL(fbits.testBit(i), false); | |
| 23 } | |
| 24 } | |
| 25 | |
| 26 { | |
| 27 BitArray tbits(13, true); | |
| 28 BitArray fbits(13, false); | |
| 29 for (uint i = 0; i < tbits.size(); ++i) { | |
| 30 BOOST_REQUIRE_EQUAL(tbits.testBit(i), true); | |
| 31 BOOST_REQUIRE_EQUAL(fbits.testBit(i), false); | |
| 32 } | |
| 33 } | |
| 34 | |
| 35 } | |
| 36 | |
| 37 | |
| 38 BOOST_AUTO_TEST_CASE( TestSetBit ) | |
| 39 { | |
| 40 | |
| 41 for (uint i = 0; i < 13; ++i) { | |
| 42 BitArray tbits(13, true); | |
| 43 BitArray fbits(13, false); | |
| 44 tbits.setBit(i, false); | |
| 45 fbits.setBit(i, true); | |
| 46 for (uint j = 0; j < tbits.size(); ++j) { | |
| 47 BOOST_REQUIRE_EQUAL(tbits.testBit(j), i != j); | |
| 48 BOOST_REQUIRE_EQUAL(fbits.testBit(j), i == j); | |
| 49 } | |
| 50 } | |
| 51 | |
| 52 } |
