|
@@ -11,6 +11,7 @@ class BitfieldManTest:public CppUnit::TestFixture {
|
|
|
CPPUNIT_TEST(testGetFirstMissingUnusedIndex);
|
|
|
CPPUNIT_TEST(testIsAllBitSet);
|
|
|
CPPUNIT_TEST(testFilter);
|
|
|
+ CPPUNIT_TEST(testGetMissingIndex);
|
|
|
CPPUNIT_TEST_SUITE_END();
|
|
|
private:
|
|
|
|
|
@@ -22,6 +23,7 @@ public:
|
|
|
void testGetFirstMissingUnusedIndex();
|
|
|
void testIsAllBitSet();
|
|
|
void testFilter();
|
|
|
+ void testGetMissingIndex();
|
|
|
};
|
|
|
|
|
|
|
|
@@ -136,3 +138,74 @@ void BitfieldManTest::testFilter() {
|
|
|
btman2.enableFilter();
|
|
|
CPPUNIT_ASSERT_EQUAL((long long int)31, btman2.getFilteredTotalLength());
|
|
|
}
|
|
|
+
|
|
|
+void BitfieldManTest::testGetMissingIndex() {
|
|
|
+ srandom(100);
|
|
|
+
|
|
|
+ BitfieldMan bt1(1024, 1024*256);
|
|
|
+
|
|
|
+ unsigned char bitArray[] = {
|
|
|
+ 0xff, 0xff, 0xff, 0xff,
|
|
|
+ 0xff, 0xff, 0xff, 0xff,
|
|
|
+ 0xff, 0xff, 0xff, 0xff,
|
|
|
+ 0xff, 0xff, 0xff, 0xff,
|
|
|
+ 0xff, 0xff, 0xff, 0xff,
|
|
|
+ 0xff, 0xff, 0xff, 0xff,
|
|
|
+ 0xff, 0xff, 0xff, 0xff,
|
|
|
+ 0xff, 0xff, 0xff, 0xff,
|
|
|
+ };
|
|
|
+ CPPUNIT_ASSERT_EQUAL(80, bt1.getMissingIndex(bitArray, 32));
|
|
|
+
|
|
|
+ unsigned char bitArray2[] = {
|
|
|
+ 0xff, 0xff, 0xff, 0xff,
|
|
|
+ 0xff, 0xff, 0xff, 0xff,
|
|
|
+ 0xff, 0x00, 0xff, 0xff,
|
|
|
+ 0xff, 0xff, 0xff, 0xff,
|
|
|
+ 0xff, 0xff, 0xff, 0xff,
|
|
|
+ 0xff, 0xff, 0xff, 0xff,
|
|
|
+ 0xff, 0xff, 0xff, 0xff,
|
|
|
+ 0xff, 0xff, 0xff, 0xff,
|
|
|
+ };
|
|
|
+
|
|
|
+ CPPUNIT_ASSERT_EQUAL(80, bt1.getMissingIndex(bitArray2, 32));
|
|
|
+
|
|
|
+ unsigned char bitArray3[] = {
|
|
|
+ 0xff, 0xff, 0xff, 0xff,
|
|
|
+ 0xff, 0xff, 0xff, 0x0f,
|
|
|
+ 0xff, 0xff, 0xff, 0xff,
|
|
|
+ 0xff, 0xff, 0xff, 0xff,
|
|
|
+ 0xff, 0xff, 0xff, 0xff,
|
|
|
+ 0xff, 0xff, 0xff, 0xff,
|
|
|
+ 0xff, 0xff, 0xff, 0xff,
|
|
|
+ 0xff, 0xff, 0xff, 0xff,
|
|
|
+ };
|
|
|
+
|
|
|
+ CPPUNIT_ASSERT_EQUAL(60, bt1.getMissingIndex(bitArray3, 32));
|
|
|
+
|
|
|
+ unsigned char bitArray4[] = {
|
|
|
+ 0xff, 0xff, 0xff, 0xff,
|
|
|
+ 0xff, 0xff, 0xff, 0xff,
|
|
|
+ 0xff, 0xff, 0xff, 0xff,
|
|
|
+ 0xff, 0xff, 0xff, 0x00,
|
|
|
+ 0x00, 0x00, 0x00, 0x00,
|
|
|
+ 0x00, 0x00, 0x00, 0x00,
|
|
|
+ 0x00, 0x00, 0x00, 0x00,
|
|
|
+ 0x00, 0x00, 0x00, 0x00,
|
|
|
+ };
|
|
|
+
|
|
|
+ CPPUNIT_ASSERT_EQUAL(0, bt1.getMissingIndex(bitArray4, 32));
|
|
|
+
|
|
|
+ unsigned char bitArray5[] = {
|
|
|
+ 0x00, 0x00, 0x00, 0x00,
|
|
|
+ 0x00, 0x00, 0x00, 0x00,
|
|
|
+ 0x00, 0x00, 0x00, 0x00,
|
|
|
+ 0x00, 0x00, 0x00, 0x00,
|
|
|
+ 0x00, 0x00, 0x00, 0x00,
|
|
|
+ 0x00, 0x00, 0x00, 0x00,
|
|
|
+ 0x00, 0x00, 0x00, 0x00,
|
|
|
+ 0x00, 0x00, 0x00, 0x00,
|
|
|
+ };
|
|
|
+
|
|
|
+ CPPUNIT_ASSERT_EQUAL(-1, bt1.getMissingIndex(bitArray5, 32));
|
|
|
+
|
|
|
+}
|