mirror of
https://github.com/aria2/aria2.git
synced 2025-04-05 21:47:37 +03:00
2007-02-06 Tatsuhiro Tsujikawa <tujikawa dot rednoah dot com>
To fix the bug that causes crash on Max OS X: * src/SimpleRandomizer.h (getInstance): Create new instance if the static variable is null. * src/SimpleRandomizer.cc (randomizer): Initialized to 0. * src/BitfieldManFactory.h (getNewFactory): Removed the call to setRandomizer(). To fix the miscalculation of the range of checksum: * src/BitfieldMan.h (isBitSetOffsetRange): New function. * src/BitfieldMan.cc (isBitSetOffsetRange): New function. * src/SegmentMan.cc (tryChunkChecksumValidation): Use BitfieldMan::isBitSetOffsetRange(). Use bitfield->getBlockLength() instead of segment.segmentLength.
This commit is contained in:
parent
a4e7bd7ec4
commit
5b2f8f036e
8 changed files with 90 additions and 8 deletions
|
@ -15,6 +15,7 @@ class BitfieldManTest:public CppUnit::TestFixture {
|
|||
CPPUNIT_TEST(testFilter);
|
||||
CPPUNIT_TEST(testGetMissingIndex);
|
||||
CPPUNIT_TEST(testGetSparceMissingUnusedIndex);
|
||||
CPPUNIT_TEST(testIsBitSetOffsetRange);
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
private:
|
||||
RandomizerHandle fixedNumberRandomizer;
|
||||
|
@ -35,6 +36,7 @@ public:
|
|||
void testFilter();
|
||||
void testGetMissingIndex();
|
||||
void testGetSparceMissingUnusedIndex();
|
||||
void testIsBitSetOffsetRange();
|
||||
};
|
||||
|
||||
|
||||
|
@ -233,3 +235,35 @@ void BitfieldManTest::testGetSparceMissingUnusedIndex() {
|
|||
bitfield.setBit(9);
|
||||
CPPUNIT_ASSERT_EQUAL(-1, bitfield.getSparseMissingUnusedIndex());
|
||||
}
|
||||
|
||||
void BitfieldManTest::testIsBitSetOffsetRange()
|
||||
{
|
||||
int64_t totalLength = (int64_t)4*1024*1024*1024;
|
||||
int32_t pieceLength = 4*1024*1024;
|
||||
BitfieldMan bitfield(pieceLength, totalLength);
|
||||
bitfield.setAllBit();
|
||||
|
||||
CPPUNIT_ASSERT(!bitfield.isBitSetOffsetRange(0, 0));
|
||||
CPPUNIT_ASSERT(!bitfield.isBitSetOffsetRange(0, -1));
|
||||
CPPUNIT_ASSERT(!bitfield.isBitSetOffsetRange(totalLength, 100));
|
||||
CPPUNIT_ASSERT(!bitfield.isBitSetOffsetRange(totalLength+1, 100));
|
||||
|
||||
CPPUNIT_ASSERT(bitfield.isBitSetOffsetRange(0, totalLength));
|
||||
CPPUNIT_ASSERT(bitfield.isBitSetOffsetRange(0, totalLength+1));
|
||||
|
||||
bitfield.clearAllBit();
|
||||
|
||||
bitfield.setBit(100);
|
||||
bitfield.setBit(101);
|
||||
|
||||
CPPUNIT_ASSERT(bitfield.isBitSetOffsetRange(pieceLength*100, pieceLength*2));
|
||||
CPPUNIT_ASSERT(!bitfield.isBitSetOffsetRange(pieceLength*100-10, pieceLength*2));
|
||||
CPPUNIT_ASSERT(!bitfield.isBitSetOffsetRange(pieceLength*100, pieceLength*2+1));
|
||||
|
||||
bitfield.clearAllBit();
|
||||
|
||||
bitfield.setBit(100);
|
||||
bitfield.setBit(102);
|
||||
|
||||
CPPUNIT_ASSERT(!bitfield.isBitSetOffsetRange(pieceLength*100, pieceLength*3));
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue