2009-02-11 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>

Fixed the bug that adding 0 length filter to BitfieldMan filters
	1 block. It should not filter anything.
	* src/BitfieldMan.cc
	* src/ConsoleStatCalc.cc
	* test/BitfieldManTest.cc
This commit is contained in:
Tatsuhiro Tsujikawa 2009-02-11 07:54:03 +00:00
parent a8376a5c4b
commit 0fc900c0ac
4 changed files with 40 additions and 10 deletions

View file

@ -1,8 +1,11 @@
#include "BitfieldMan.h"
#include "FixedNumberRandomizer.h"
#include <cstring>
#include <cppunit/extensions/HelperMacros.h>
#include "FixedNumberRandomizer.h"
namespace aria2 {
class BitfieldManTest:public CppUnit::TestFixture {
@ -13,6 +16,7 @@ class BitfieldManTest:public CppUnit::TestFixture {
CPPUNIT_TEST(testGetFirstMissingIndex);
CPPUNIT_TEST(testIsAllBitSet);
CPPUNIT_TEST(testFilter);
CPPUNIT_TEST(testAddFilter_zeroLength);
CPPUNIT_TEST(testGetMissingIndex);
CPPUNIT_TEST(testGetSparceMissingUnusedIndex);
CPPUNIT_TEST(testGetSparceMissingUnusedIndex_setBit);
@ -54,6 +58,7 @@ public:
void testIsAllBitSet();
void testFilter();
void testAddFilter_zeroLength();
void testGetSparceMissingUnusedIndex();
void testGetSparceMissingUnusedIndex_setBit();
void testIsBitSetOffsetRange();
@ -369,6 +374,15 @@ void BitfieldManTest::testFilter() {
}
void BitfieldManTest::testAddFilter_zeroLength()
{
BitfieldMan bits(1024, 1024*1024);
bits.addFilter(2048, 0);
bits.enableFilter();
CPPUNIT_ASSERT_EQUAL((size_t)0, bits.countMissingBlock());
CPPUNIT_ASSERT(bits.isFilteredAllBitSet());
}
void BitfieldManTest::testGetMissingIndex() {
BitfieldMan bt1(1024, 1024*256);
bt1.setRandomizer(fixedNumberRandomizer);