mirror of https://github.com/aria2/aria2
Merged Ross's patch to test code.
parent
8d84d9f97c
commit
19ef788023
|
@ -48,12 +48,12 @@ CPPUNIT_TEST_SUITE_REGISTRATION( BitfieldManTest );
|
|||
|
||||
void BitfieldManTest::testGetBlockSize() {
|
||||
BitfieldMan bt1(1024, 1024*10);
|
||||
CPPUNIT_ASSERT_EQUAL(1024, bt1.getBlockLength(9));
|
||||
CPPUNIT_ASSERT_EQUAL((int32_t)1024, bt1.getBlockLength(9));
|
||||
|
||||
BitfieldMan bt2(1024, 1024*10+1);
|
||||
CPPUNIT_ASSERT_EQUAL(1024, bt2.getBlockLength(9));
|
||||
CPPUNIT_ASSERT_EQUAL(1, bt2.getBlockLength(10));
|
||||
CPPUNIT_ASSERT_EQUAL(0, bt2.getBlockLength(11));
|
||||
CPPUNIT_ASSERT_EQUAL((int32_t)1024, bt2.getBlockLength(9));
|
||||
CPPUNIT_ASSERT_EQUAL((int32_t)1, bt2.getBlockLength(10));
|
||||
CPPUNIT_ASSERT_EQUAL((int32_t)0, bt2.getBlockLength(11));
|
||||
}
|
||||
|
||||
void BitfieldManTest::testGetFirstMissingUnusedIndex() {
|
||||
|
@ -61,22 +61,22 @@ void BitfieldManTest::testGetFirstMissingUnusedIndex() {
|
|||
unsigned char bitfield[2];
|
||||
memset(bitfield, 0xff, sizeof(bitfield));
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(0, bt1.getFirstMissingUnusedIndex(bitfield, sizeof(bitfield)));
|
||||
CPPUNIT_ASSERT_EQUAL((int32_t)0, bt1.getFirstMissingUnusedIndex(bitfield, sizeof(bitfield)));
|
||||
CPPUNIT_ASSERT(bt1.setUseBit(0));
|
||||
CPPUNIT_ASSERT_EQUAL(1, bt1.getFirstMissingUnusedIndex(bitfield, sizeof(bitfield)));
|
||||
CPPUNIT_ASSERT_EQUAL((int32_t)1, bt1.getFirstMissingUnusedIndex(bitfield, sizeof(bitfield)));
|
||||
CPPUNIT_ASSERT(bt1.unsetUseBit(0));
|
||||
CPPUNIT_ASSERT_EQUAL(0, bt1.getFirstMissingUnusedIndex(bitfield, sizeof(bitfield)));
|
||||
CPPUNIT_ASSERT_EQUAL((int32_t)0, bt1.getFirstMissingUnusedIndex(bitfield, sizeof(bitfield)));
|
||||
CPPUNIT_ASSERT(bt1.setBit(0));
|
||||
CPPUNIT_ASSERT_EQUAL(1, bt1.getFirstMissingUnusedIndex(bitfield, sizeof(bitfield)));
|
||||
CPPUNIT_ASSERT_EQUAL((int32_t)1, bt1.getFirstMissingUnusedIndex(bitfield, sizeof(bitfield)));
|
||||
|
||||
for(int i = 0; i < 8; i++) {
|
||||
CPPUNIT_ASSERT(bt1.setBit(i));
|
||||
}
|
||||
CPPUNIT_ASSERT_EQUAL(8, bt1.getFirstMissingUnusedIndex(bitfield, sizeof(bitfield)));
|
||||
CPPUNIT_ASSERT_EQUAL((int32_t)8, bt1.getFirstMissingUnusedIndex(bitfield, sizeof(bitfield)));
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(8, bt1.getFirstMissingUnusedIndex());
|
||||
CPPUNIT_ASSERT_EQUAL((int32_t)8, bt1.getFirstMissingUnusedIndex());
|
||||
CPPUNIT_ASSERT(bt1.setUseBit(8));
|
||||
CPPUNIT_ASSERT_EQUAL(9, bt1.getFirstMissingUnusedIndex());
|
||||
CPPUNIT_ASSERT_EQUAL((int32_t)9, bt1.getFirstMissingUnusedIndex());
|
||||
}
|
||||
|
||||
void BitfieldManTest::testIsAllBitSet() {
|
||||
|
@ -174,7 +174,7 @@ void BitfieldManTest::testGetMissingIndex() {
|
|||
0xff, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff,
|
||||
};
|
||||
CPPUNIT_ASSERT_EQUAL(0, bt1.getMissingIndex(bitArray, 32));
|
||||
CPPUNIT_ASSERT_EQUAL((int32_t)0, bt1.getMissingIndex(bitArray, 32));
|
||||
|
||||
unsigned char bitArray2[] = {
|
||||
0x0f, 0xff, 0xff, 0xff,
|
||||
|
@ -187,7 +187,7 @@ void BitfieldManTest::testGetMissingIndex() {
|
|||
0xff, 0xff, 0xff, 0xff,
|
||||
};
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(4, bt1.getMissingIndex(bitArray2, 32));
|
||||
CPPUNIT_ASSERT_EQUAL((int32_t)4, bt1.getMissingIndex(bitArray2, 32));
|
||||
|
||||
unsigned char bitArray3[] = {
|
||||
0x00, 0xff, 0xff, 0xff,
|
||||
|
@ -200,7 +200,7 @@ void BitfieldManTest::testGetMissingIndex() {
|
|||
0xff, 0xff, 0xff, 0xff,
|
||||
};
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(8, bt1.getMissingIndex(bitArray3, 32));
|
||||
CPPUNIT_ASSERT_EQUAL((int32_t)8, bt1.getMissingIndex(bitArray3, 32));
|
||||
|
||||
unsigned char bitArray4[] = {
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
|
@ -213,34 +213,34 @@ void BitfieldManTest::testGetMissingIndex() {
|
|||
0x00, 0x00, 0x00, 0x00,
|
||||
};
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(-1, bt1.getMissingIndex(bitArray4, 32));
|
||||
CPPUNIT_ASSERT_EQUAL((int32_t)-1, bt1.getMissingIndex(bitArray4, 32));
|
||||
|
||||
}
|
||||
|
||||
void BitfieldManTest::testGetSparceMissingUnusedIndex() {
|
||||
BitfieldMan bitfield(1024*1024, 10*1024*1024);
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(0, bitfield.getSparseMissingUnusedIndex());
|
||||
CPPUNIT_ASSERT_EQUAL((int32_t)0, bitfield.getSparseMissingUnusedIndex());
|
||||
bitfield.setBit(0);
|
||||
CPPUNIT_ASSERT_EQUAL(5, bitfield.getSparseMissingUnusedIndex());
|
||||
CPPUNIT_ASSERT_EQUAL((int32_t)5, bitfield.getSparseMissingUnusedIndex());
|
||||
bitfield.setUseBit(5);
|
||||
CPPUNIT_ASSERT_EQUAL(3, bitfield.getSparseMissingUnusedIndex());
|
||||
CPPUNIT_ASSERT_EQUAL((int32_t)3, bitfield.getSparseMissingUnusedIndex());
|
||||
bitfield.setBit(3);
|
||||
CPPUNIT_ASSERT_EQUAL(8, bitfield.getSparseMissingUnusedIndex());
|
||||
CPPUNIT_ASSERT_EQUAL((int32_t)8, bitfield.getSparseMissingUnusedIndex());
|
||||
bitfield.setBit(8);
|
||||
CPPUNIT_ASSERT_EQUAL(2, bitfield.getSparseMissingUnusedIndex());
|
||||
CPPUNIT_ASSERT_EQUAL((int32_t)2, bitfield.getSparseMissingUnusedIndex());
|
||||
bitfield.setBit(2);
|
||||
CPPUNIT_ASSERT_EQUAL(7, bitfield.getSparseMissingUnusedIndex());
|
||||
CPPUNIT_ASSERT_EQUAL((int32_t)7, bitfield.getSparseMissingUnusedIndex());
|
||||
bitfield.setBit(7);
|
||||
CPPUNIT_ASSERT_EQUAL(1, bitfield.getSparseMissingUnusedIndex());
|
||||
CPPUNIT_ASSERT_EQUAL((int32_t)1, bitfield.getSparseMissingUnusedIndex());
|
||||
bitfield.setBit(1);
|
||||
CPPUNIT_ASSERT_EQUAL(4, bitfield.getSparseMissingUnusedIndex());
|
||||
CPPUNIT_ASSERT_EQUAL((int32_t)4, bitfield.getSparseMissingUnusedIndex());
|
||||
bitfield.setBit(4);
|
||||
CPPUNIT_ASSERT_EQUAL(6, bitfield.getSparseMissingUnusedIndex());
|
||||
CPPUNIT_ASSERT_EQUAL((int32_t)6, bitfield.getSparseMissingUnusedIndex());
|
||||
bitfield.setBit(6);
|
||||
CPPUNIT_ASSERT_EQUAL(9, bitfield.getSparseMissingUnusedIndex());
|
||||
CPPUNIT_ASSERT_EQUAL((int32_t)9, bitfield.getSparseMissingUnusedIndex());
|
||||
bitfield.setBit(9);
|
||||
CPPUNIT_ASSERT_EQUAL(-1, bitfield.getSparseMissingUnusedIndex());
|
||||
CPPUNIT_ASSERT_EQUAL((int32_t)-1, bitfield.getSparseMissingUnusedIndex());
|
||||
}
|
||||
|
||||
void BitfieldManTest::testIsBitSetOffsetRange()
|
||||
|
|
|
@ -36,7 +36,7 @@ void BtAllowedFastMessageTest::testCreate() {
|
|||
PeerMessageUtil::setIntParam(&msg[5], 12345);
|
||||
BtAllowedFastMessageHandle pm = BtAllowedFastMessage::create(&msg[4], 5);
|
||||
CPPUNIT_ASSERT_EQUAL((int8_t)17, pm->getId());
|
||||
CPPUNIT_ASSERT_EQUAL(12345, pm->getIndex());
|
||||
CPPUNIT_ASSERT_EQUAL((int32_t)12345, pm->getIndex());
|
||||
|
||||
// case: payload size is wrong
|
||||
try {
|
||||
|
|
|
@ -37,7 +37,7 @@ void BtBitfieldMessageTest::testCreate() {
|
|||
BtBitfieldMessageHandle pm = BtBitfieldMessage::create(&msg[4], 3);
|
||||
CPPUNIT_ASSERT_EQUAL((int8_t)5, pm->getId());
|
||||
CPPUNIT_ASSERT(memcmp(bitfield, pm->getBitfield(), sizeof(bitfield)) == 0);
|
||||
CPPUNIT_ASSERT_EQUAL(2, pm->getBitfieldLength());
|
||||
CPPUNIT_ASSERT_EQUAL((int32_t)2, pm->getBitfieldLength());
|
||||
// case: payload size is wrong
|
||||
try {
|
||||
unsigned char msg[5];
|
||||
|
|
|
@ -66,9 +66,9 @@ void BtCancelMessageTest::testCreate() {
|
|||
PeerMessageUtil::setIntParam(&msg[13], 1024);
|
||||
BtCancelMessageHandle pm = BtCancelMessage::create(&msg[4], 13);
|
||||
CPPUNIT_ASSERT_EQUAL((int8_t)8, pm->getId());
|
||||
CPPUNIT_ASSERT_EQUAL(12345, pm->getIndex());
|
||||
CPPUNIT_ASSERT_EQUAL(256, pm->getBegin());
|
||||
CPPUNIT_ASSERT_EQUAL(1024, pm->getLength());
|
||||
CPPUNIT_ASSERT_EQUAL((int32_t)12345, pm->getIndex());
|
||||
CPPUNIT_ASSERT_EQUAL((int32_t)256, pm->getBegin());
|
||||
CPPUNIT_ASSERT_EQUAL((int32_t)1024, pm->getLength());
|
||||
|
||||
// case: payload size is wrong
|
||||
try {
|
||||
|
|
|
@ -33,7 +33,7 @@ void BtHaveMessageTest::testCreate() {
|
|||
PeerMessageUtil::setIntParam(&msg[5], 12345);
|
||||
BtHaveMessageHandle pm = BtHaveMessage::create(&msg[4], 5);
|
||||
CPPUNIT_ASSERT_EQUAL((int8_t)4, pm->getId());
|
||||
CPPUNIT_ASSERT_EQUAL(12345, pm->getIndex());
|
||||
CPPUNIT_ASSERT_EQUAL((int32_t)12345, pm->getIndex());
|
||||
|
||||
// case: payload size is wrong
|
||||
try {
|
||||
|
|
|
@ -26,7 +26,7 @@ void BtKeepAliveMessageTest::testGetMessage() {
|
|||
memset(msg, 0, sizeof(msg));
|
||||
BtKeepAliveMessage message;
|
||||
CPPUNIT_ASSERT_EQUAL((int8_t)99, message.getId());
|
||||
CPPUNIT_ASSERT_EQUAL(4, message.getMessageLength());
|
||||
CPPUNIT_ASSERT_EQUAL((int32_t)4, message.getMessageLength());
|
||||
CPPUNIT_ASSERT(memcmp(msg, message.getMessage(), 4) == 0);
|
||||
}
|
||||
|
||||
|
|
|
@ -112,10 +112,10 @@ void BtPieceMessageTest::testCreate() {
|
|||
memcpy(&msg[13], data, sizeof(data));
|
||||
BtPieceMessageHandle pm = BtPieceMessage::create(&msg[4], 11);
|
||||
CPPUNIT_ASSERT_EQUAL((int8_t)7, pm->getId());
|
||||
CPPUNIT_ASSERT_EQUAL(12345, pm->getIndex());
|
||||
CPPUNIT_ASSERT_EQUAL(256, pm->getBegin());
|
||||
CPPUNIT_ASSERT_EQUAL((int32_t)12345, pm->getIndex());
|
||||
CPPUNIT_ASSERT_EQUAL((int32_t)256, pm->getBegin());
|
||||
CPPUNIT_ASSERT(memcmp(data, pm->getBlock(), sizeof(data)) == 0);
|
||||
CPPUNIT_ASSERT_EQUAL(2, pm->getBlockLength());
|
||||
CPPUNIT_ASSERT_EQUAL((int32_t)2, pm->getBlockLength());
|
||||
|
||||
// case: payload size is wrong
|
||||
try {
|
||||
|
@ -172,9 +172,9 @@ void BtPieceMessageTest::testChokingEvent_allowedFastEnabled() {
|
|||
CPPUNIT_ASSERT(msg->isInvalidate());
|
||||
CPPUNIT_ASSERT_EQUAL((size_t)1, btMessageDispatcher->messageQueue.size());
|
||||
MockBtMessage2* rej = (MockBtMessage2*)btMessageDispatcher->messageQueue.front().get();
|
||||
CPPUNIT_ASSERT_EQUAL(1, rej->index);
|
||||
CPPUNIT_ASSERT_EQUAL(1024, rej->begin);
|
||||
CPPUNIT_ASSERT_EQUAL(16*1024, rej->length);
|
||||
CPPUNIT_ASSERT_EQUAL((int32_t)1, rej->index);
|
||||
CPPUNIT_ASSERT_EQUAL((int32_t)1024, rej->begin);
|
||||
CPPUNIT_ASSERT_EQUAL((int32_t)16*1024, rej->length);
|
||||
}
|
||||
|
||||
void BtPieceMessageTest::testChokingEvent_inAmAllowedIndexSet() {
|
||||
|
@ -257,9 +257,9 @@ void BtPieceMessageTest::testCancelSendingPieceEvent_allowedFastEnabled() {
|
|||
CPPUNIT_ASSERT(msg->isInvalidate());
|
||||
CPPUNIT_ASSERT_EQUAL((size_t)1, btMessageDispatcher->messageQueue.size());
|
||||
MockBtMessage2* rej = (MockBtMessage2*)btMessageDispatcher->messageQueue.front().get();
|
||||
CPPUNIT_ASSERT_EQUAL(1, rej->index);
|
||||
CPPUNIT_ASSERT_EQUAL(1024, rej->begin);
|
||||
CPPUNIT_ASSERT_EQUAL(16*1024, rej->length);
|
||||
CPPUNIT_ASSERT_EQUAL((int32_t)1, rej->index);
|
||||
CPPUNIT_ASSERT_EQUAL((int32_t)1024, rej->begin);
|
||||
CPPUNIT_ASSERT_EQUAL((int32_t)16*1024, rej->length);
|
||||
}
|
||||
|
||||
void BtPieceMessageTest::testCancelSendingPieceEvent_invalidate() {
|
||||
|
|
|
@ -98,9 +98,9 @@ void BtRejectMessageTest::testCreate() {
|
|||
PeerMessageUtil::setIntParam(&msg[13], 1024);
|
||||
BtRejectMessageHandle pm = BtRejectMessage::create(&msg[4], 13);
|
||||
CPPUNIT_ASSERT_EQUAL((int8_t)16, pm->getId());
|
||||
CPPUNIT_ASSERT_EQUAL(12345, pm->getIndex());
|
||||
CPPUNIT_ASSERT_EQUAL(256, pm->getBegin());
|
||||
CPPUNIT_ASSERT_EQUAL(1024, pm->getLength());
|
||||
CPPUNIT_ASSERT_EQUAL((int32_t)12345, pm->getIndex());
|
||||
CPPUNIT_ASSERT_EQUAL((int32_t)256, pm->getBegin());
|
||||
CPPUNIT_ASSERT_EQUAL((int32_t)1024, pm->getLength());
|
||||
|
||||
// case: payload size is wrong
|
||||
try {
|
||||
|
|
|
@ -132,9 +132,9 @@ void BtRequestMessageTest::testCreate() {
|
|||
PeerMessageUtil::setIntParam(&msg[13], 1024);
|
||||
BtRequestMessageHandle pm = BtRequestMessage::create(&msg[4], 13);
|
||||
CPPUNIT_ASSERT_EQUAL((int8_t)6, pm->getId());
|
||||
CPPUNIT_ASSERT_EQUAL(12345, pm->getIndex());
|
||||
CPPUNIT_ASSERT_EQUAL(256, pm->getBegin());
|
||||
CPPUNIT_ASSERT_EQUAL(1024, pm->getLength());
|
||||
CPPUNIT_ASSERT_EQUAL((int32_t)12345, pm->getIndex());
|
||||
CPPUNIT_ASSERT_EQUAL((int32_t)256, pm->getBegin());
|
||||
CPPUNIT_ASSERT_EQUAL((int32_t)1024, pm->getLength());
|
||||
|
||||
// case: payload size is wrong
|
||||
try {
|
||||
|
@ -174,9 +174,9 @@ void BtRequestMessageTest::testDoReceivedAction_hasPieceAndAmNotChoking() {
|
|||
CPPUNIT_ASSERT_EQUAL((size_t)1, dispatcher->messageQueue.size());
|
||||
MockBtMessage2* pieceMsg = (MockBtMessage2*)dispatcher->messageQueue.front().get();
|
||||
CPPUNIT_ASSERT_EQUAL(string("piece"), pieceMsg->type);
|
||||
CPPUNIT_ASSERT_EQUAL(1, pieceMsg->index);
|
||||
CPPUNIT_ASSERT_EQUAL(16, pieceMsg->begin);
|
||||
CPPUNIT_ASSERT_EQUAL(32, pieceMsg->length);
|
||||
CPPUNIT_ASSERT_EQUAL((int32_t)1, pieceMsg->index);
|
||||
CPPUNIT_ASSERT_EQUAL((int32_t)16, pieceMsg->begin);
|
||||
CPPUNIT_ASSERT_EQUAL((int32_t)32, pieceMsg->length);
|
||||
}
|
||||
|
||||
void BtRequestMessageTest::testDoReceivedAction_hasPieceAndAmChokingAndFastExtensionEnabled() {
|
||||
|
@ -187,9 +187,9 @@ void BtRequestMessageTest::testDoReceivedAction_hasPieceAndAmChokingAndFastExten
|
|||
CPPUNIT_ASSERT_EQUAL((size_t)1, dispatcher->messageQueue.size());
|
||||
MockBtMessage2* pieceMsg = (MockBtMessage2*)dispatcher->messageQueue.front().get();
|
||||
CPPUNIT_ASSERT_EQUAL(string("reject"), pieceMsg->type);
|
||||
CPPUNIT_ASSERT_EQUAL(1, pieceMsg->index);
|
||||
CPPUNIT_ASSERT_EQUAL(16, pieceMsg->begin);
|
||||
CPPUNIT_ASSERT_EQUAL(32, pieceMsg->length);
|
||||
CPPUNIT_ASSERT_EQUAL((int32_t)1, pieceMsg->index);
|
||||
CPPUNIT_ASSERT_EQUAL((int32_t)16, pieceMsg->begin);
|
||||
CPPUNIT_ASSERT_EQUAL((int32_t)32, pieceMsg->length);
|
||||
}
|
||||
|
||||
void BtRequestMessageTest::testDoReceivedAction_hasPieceAndAmChokingAndFastExtensionDisabled() {
|
||||
|
@ -208,9 +208,9 @@ void BtRequestMessageTest::testDoReceivedAction_doesntHavePieceAndFastExtensionE
|
|||
CPPUNIT_ASSERT_EQUAL((size_t)1, dispatcher->messageQueue.size());
|
||||
MockBtMessage2* pieceMsg = (MockBtMessage2*)dispatcher->messageQueue.front().get();
|
||||
CPPUNIT_ASSERT_EQUAL(string("reject"), pieceMsg->type);
|
||||
CPPUNIT_ASSERT_EQUAL(2, pieceMsg->index);
|
||||
CPPUNIT_ASSERT_EQUAL(16, pieceMsg->begin);
|
||||
CPPUNIT_ASSERT_EQUAL(32, pieceMsg->length);
|
||||
CPPUNIT_ASSERT_EQUAL((int32_t)2, pieceMsg->index);
|
||||
CPPUNIT_ASSERT_EQUAL((int32_t)16, pieceMsg->begin);
|
||||
CPPUNIT_ASSERT_EQUAL((int32_t)32, pieceMsg->length);
|
||||
}
|
||||
|
||||
void BtRequestMessageTest::testDoReceivedAction_doesntHavePieceAndFastExtensionDisabled() {
|
||||
|
|
|
@ -31,7 +31,7 @@ void BtSuggestPieceMessageTest::testCreate() {
|
|||
PeerMessageUtil::setIntParam(&msg[5], 12345);
|
||||
BtSuggestPieceMessageHandle pm = BtSuggestPieceMessage::create(&msg[4], 5);
|
||||
CPPUNIT_ASSERT_EQUAL((int8_t)13, pm->getId());
|
||||
CPPUNIT_ASSERT_EQUAL(12345, pm->getIndex());
|
||||
CPPUNIT_ASSERT_EQUAL((int32_t)12345, pm->getIndex());
|
||||
|
||||
// case: payload size is wrong
|
||||
try {
|
||||
|
|
|
@ -35,6 +35,7 @@ const char* ChunkChecksumValidatorTest::csArray[] = { "29b0e7878271645fffb7eec7d
|
|||
"0a4ea2f7dd7c52ddf2099a444ab2184b4d341bdb" };
|
||||
|
||||
void ChunkChecksumValidatorTest::testValidate() {
|
||||
#ifdef ENABLE_MESSAGE_DIGEST
|
||||
BitfieldMan bitfieldMan(100, 250);
|
||||
bitfieldMan.setAllBit();
|
||||
Strings checksums(&csArray[0], &csArray[3]);
|
||||
|
@ -56,9 +57,11 @@ void ChunkChecksumValidatorTest::testValidate() {
|
|||
CPPUNIT_ASSERT(bitfieldMan.isBitSet(0));
|
||||
CPPUNIT_ASSERT(!bitfieldMan.isBitSet(1));
|
||||
CPPUNIT_ASSERT(bitfieldMan.isBitSet(2));
|
||||
#endif /* ENABLE_MESSAGE_DIGEST */
|
||||
}
|
||||
|
||||
void ChunkChecksumValidatorTest::testValidate2() {
|
||||
#ifdef ENABLE_MESSAGE_DIGEST
|
||||
BitfieldMan bitfieldMan(50, 250);
|
||||
bitfieldMan.setAllBit();
|
||||
Strings checksums(&csArray[0], &csArray[3]);
|
||||
|
@ -81,9 +84,11 @@ void ChunkChecksumValidatorTest::testValidate2() {
|
|||
CPPUNIT_ASSERT(!bitfieldMan.isBitSet(2));
|
||||
CPPUNIT_ASSERT(!bitfieldMan.isBitSet(3));
|
||||
CPPUNIT_ASSERT(bitfieldMan.isBitSet(4));
|
||||
#endif /* ENABLE_MESSAGE_DIGEST */
|
||||
}
|
||||
|
||||
void ChunkChecksumValidatorTest::testValidate3() {
|
||||
#ifdef ENABLE_MESSAGE_DIGEST
|
||||
BitfieldMan bitfieldMan(50, 250);
|
||||
bitfieldMan.setAllBit();
|
||||
Strings checksums;
|
||||
|
@ -108,9 +113,11 @@ void ChunkChecksumValidatorTest::testValidate3() {
|
|||
CPPUNIT_ASSERT(!bitfieldMan.isBitSet(2));
|
||||
CPPUNIT_ASSERT(!bitfieldMan.isBitSet(3));
|
||||
CPPUNIT_ASSERT(!bitfieldMan.isBitSet(4));
|
||||
#endif /* ENABLE_MESSAGE_DIGEST */
|
||||
}
|
||||
|
||||
void ChunkChecksumValidatorTest::testValidate4() {
|
||||
#ifdef ENABLE_MESSAGE_DIGEST
|
||||
BitfieldMan bitfieldMan(70, 250);
|
||||
bitfieldMan.setAllBit();
|
||||
Strings checksums(&csArray[0], &csArray[3]);
|
||||
|
@ -132,4 +139,5 @@ void ChunkChecksumValidatorTest::testValidate4() {
|
|||
CPPUNIT_ASSERT(!bitfieldMan.isBitSet(1));
|
||||
CPPUNIT_ASSERT(!bitfieldMan.isBitSet(2));
|
||||
CPPUNIT_ASSERT(bitfieldMan.isBitSet(3));
|
||||
#endif /* ENABLE_MESSAGE_DIGEST */
|
||||
}
|
||||
|
|
|
@ -33,7 +33,7 @@ void CookieBoxFactoryTest::testLoadDefaultCookie()
|
|||
|
||||
Cookies cookies = factory.getDefaultCookies();
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(4, (int32_t)cookies.size());
|
||||
CPPUNIT_ASSERT_EQUAL((int32_t)4, (int32_t)cookies.size());
|
||||
|
||||
Cookie c = cookies[0];
|
||||
CPPUNIT_ASSERT_EQUAL(string("JSESSIONID"), c.name);
|
||||
|
@ -60,5 +60,5 @@ void CookieBoxFactoryTest::testCreateNewInstance()
|
|||
CookieBoxHandle box = factory.createNewInstance();
|
||||
Cookies cookies = box->criteriaFind("localhost", "/", 0, true);
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(4, (int32_t)cookies.size());
|
||||
CPPUNIT_ASSERT_EQUAL((int32_t)4, (int32_t)cookies.size());
|
||||
}
|
||||
|
|
|
@ -59,7 +59,7 @@ void CookieParserTest::testParse_file()
|
|||
|
||||
Cookies cookies = CookieParser().parse(f);
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(3, (int32_t)cookies.size());
|
||||
CPPUNIT_ASSERT_EQUAL((int32_t)3, (int32_t)cookies.size());
|
||||
|
||||
Cookie c = cookies[0];
|
||||
CPPUNIT_ASSERT_EQUAL(string("JSESSIONID"), c.name);
|
||||
|
|
|
@ -54,7 +54,7 @@ void DefaultBtContextTest::testGetInfoHash() {
|
|||
|
||||
string correctHash = "248d0a1cd08284299de78d5c1ed359bb46717d8c";
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(20, btContext.getInfoHashLength());
|
||||
CPPUNIT_ASSERT_EQUAL((int32_t)20, btContext.getInfoHashLength());
|
||||
CPPUNIT_ASSERT_EQUAL(correctHash, Util::toHex(btContext.getInfoHash(),
|
||||
btContext.getInfoHashLength()));
|
||||
}
|
||||
|
@ -208,7 +208,7 @@ void DefaultBtContextTest::testGetPieceLength() {
|
|||
DefaultBtContext btContext;
|
||||
btContext.load("test.torrent");
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(128,
|
||||
CPPUNIT_ASSERT_EQUAL((int32_t)128,
|
||||
btContext.getPieceLength());
|
||||
}
|
||||
|
||||
|
|
|
@ -370,7 +370,7 @@ void DefaultBtMessageDispatcherTest::testIsSendingInProgress() {
|
|||
void DefaultBtMessageDispatcherTest::testCountOutstandingRequest() {
|
||||
RequestSlot slot(0, 0, MY_PIECE_LENGTH, 0);
|
||||
btMessageDispatcher->addOutstandingRequest(slot);
|
||||
CPPUNIT_ASSERT_EQUAL(1, btMessageDispatcher->countOutstandingRequest());
|
||||
CPPUNIT_ASSERT_EQUAL((int32_t)1, btMessageDispatcher->countOutstandingRequest());
|
||||
}
|
||||
|
||||
void DefaultBtMessageDispatcherTest::testIsOutstandingRequest() {
|
||||
|
|
|
@ -22,6 +22,8 @@ public:
|
|||
CPPUNIT_TEST_SUITE_REGISTRATION( DefaultDiskWriterTest );
|
||||
|
||||
void DefaultDiskWriterTest::testMessageDigest() {
|
||||
#ifdef ENABLE_MESSAGE_DIGEST
|
||||
|
||||
DefaultDiskWriter dw;
|
||||
dw.openExistingFile("4096chunk.txt");
|
||||
|
||||
|
@ -32,4 +34,5 @@ void DefaultDiskWriterTest::testMessageDigest() {
|
|||
dw.messageDigest(5, 100, DIGEST_ALGO_SHA1));
|
||||
|
||||
dw.closeFile();
|
||||
#endif // ENABLE_MESSAGE_DIGEST
|
||||
}
|
||||
|
|
|
@ -53,13 +53,13 @@ CPPUNIT_TEST_SUITE_REGISTRATION(DefaultPeerStorageTest);
|
|||
void DefaultPeerStorageTest::testCountPeer() {
|
||||
DefaultPeerStorage ps(btContext, option);
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(0,
|
||||
CPPUNIT_ASSERT_EQUAL((int32_t)0,
|
||||
ps.countPeer());
|
||||
|
||||
PeerHandle peer(new Peer("192.168.0.1", 6889, btContext->getPieceLength(),
|
||||
btContext->getTotalLength()));
|
||||
ps.addPeer(peer);
|
||||
CPPUNIT_ASSERT_EQUAL(1,
|
||||
CPPUNIT_ASSERT_EQUAL((int32_t)1,
|
||||
ps.countPeer());
|
||||
}
|
||||
|
||||
|
@ -79,7 +79,7 @@ void DefaultPeerStorageTest::testDeleteUnusedPeer() {
|
|||
|
||||
ps.deleteUnusedPeer(2);
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(1, ps.countPeer());
|
||||
CPPUNIT_ASSERT_EQUAL((int32_t)1, ps.countPeer());
|
||||
CPPUNIT_ASSERT_EQUAL(string("192.168.0.3"),
|
||||
ps.getPeer("192.168.0.3", 6889)->ipaddr);
|
||||
|
||||
|
@ -91,7 +91,7 @@ void DefaultPeerStorageTest::testDeleteUnusedPeer() {
|
|||
ps.deleteUnusedPeer(3);
|
||||
|
||||
// peer2 has been in use, so it did't deleted.
|
||||
CPPUNIT_ASSERT_EQUAL(1, ps.countPeer());
|
||||
CPPUNIT_ASSERT_EQUAL((int32_t)1, ps.countPeer());
|
||||
CPPUNIT_ASSERT_EQUAL(string("192.168.0.2"),
|
||||
ps.getPeer("192.168.0.2", 6889)->ipaddr);
|
||||
|
||||
|
@ -111,13 +111,13 @@ void DefaultPeerStorageTest::testAddPeer() {
|
|||
ps.addPeer(peer2);
|
||||
ps.addPeer(peer3);
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(3, ps.countPeer());
|
||||
CPPUNIT_ASSERT_EQUAL((int32_t)3, ps.countPeer());
|
||||
|
||||
// this is true, because peer1 in the container has no errors and
|
||||
// it is replaced by peer1(self assignment).
|
||||
CPPUNIT_ASSERT_EQUAL(true, ps.addPeer(peer1));
|
||||
// the number of peers doesn't change.
|
||||
CPPUNIT_ASSERT_EQUAL(3, ps.countPeer());
|
||||
CPPUNIT_ASSERT_EQUAL((int32_t)3, ps.countPeer());
|
||||
|
||||
ps.setMaxPeerListSize(3);
|
||||
|
||||
|
@ -126,7 +126,7 @@ void DefaultPeerStorageTest::testAddPeer() {
|
|||
|
||||
CPPUNIT_ASSERT(ps.addPeer(peer4));
|
||||
// peer1 was deleted.
|
||||
CPPUNIT_ASSERT_EQUAL(3, ps.countPeer());
|
||||
CPPUNIT_ASSERT_EQUAL((int32_t)3, ps.countPeer());
|
||||
|
||||
peer4->startBadCondition();
|
||||
|
||||
|
|
|
@ -87,7 +87,11 @@ void FileTest::testRemove() {
|
|||
CPPUNIT_ASSERT(!f.remove());
|
||||
|
||||
string dir = "/tmp/aria2testdir";
|
||||
#ifdef __MINGW32__
|
||||
mkdir(dir.c_str());
|
||||
#else
|
||||
mkdir(dir.c_str(), 0777);
|
||||
#endif // __MINGW32__
|
||||
File d(dir);
|
||||
CPPUNIT_ASSERT(d.exists());
|
||||
CPPUNIT_ASSERT(d.remove());
|
||||
|
|
|
@ -61,7 +61,7 @@ void HttpHeaderProcessorTest::testGetPutBackDataLength()
|
|||
"\r\nputbackme";
|
||||
proc.update(hd1);
|
||||
CPPUNIT_ASSERT(proc.eoh());
|
||||
CPPUNIT_ASSERT_EQUAL(9, proc.getPutBackDataLength());
|
||||
CPPUNIT_ASSERT_EQUAL((int32_t)9, proc.getPutBackDataLength());
|
||||
|
||||
proc.clear();
|
||||
|
||||
|
@ -69,7 +69,7 @@ void HttpHeaderProcessorTest::testGetPutBackDataLength()
|
|||
"\nputbackme";
|
||||
proc.update(hd2);
|
||||
CPPUNIT_ASSERT(proc.eoh());
|
||||
CPPUNIT_ASSERT_EQUAL(9, proc.getPutBackDataLength());
|
||||
CPPUNIT_ASSERT_EQUAL((int32_t)9, proc.getPutBackDataLength());
|
||||
}
|
||||
|
||||
void HttpHeaderProcessorTest::testGetPutBackDataLength_nullChar()
|
||||
|
@ -79,7 +79,7 @@ void HttpHeaderProcessorTest::testGetPutBackDataLength_nullChar()
|
|||
"foo: foo\0bar\r\n"
|
||||
"\r\nputbackme", 35+7);
|
||||
CPPUNIT_ASSERT(proc.eoh());
|
||||
CPPUNIT_ASSERT_EQUAL(9, proc.getPutBackDataLength());
|
||||
CPPUNIT_ASSERT_EQUAL((int32_t)9, proc.getPutBackDataLength());
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -36,13 +36,9 @@ aria2c_SOURCES = AllTest.cc\
|
|||
DictionaryTest.cc\
|
||||
ListTest.cc\
|
||||
MetaFileUtilTest.cc\
|
||||
ShaVisitorTest.cc\
|
||||
PeerMessageUtilTest.cc\
|
||||
DefaultDiskWriterTest.cc\
|
||||
MultiDiskAdaptorTest.cc\
|
||||
Xml2MetalinkProcessorTest.cc\
|
||||
MetalinkerTest.cc\
|
||||
MetalinkEntryTest.cc\
|
||||
FeatureConfigTest.cc\
|
||||
ShareRatioSeedCriteriaTest.cc\
|
||||
TimeSeedCriteriaTest.cc\
|
||||
|
@ -50,17 +46,17 @@ aria2c_SOURCES = AllTest.cc\
|
|||
DefaultPeerListProcessorTest.cc\
|
||||
AnnounceListTest.cc\
|
||||
TrackerWatcherCommandTest.cc\
|
||||
DefaultBtContextTest.cc\
|
||||
DefaultPieceStorageTest.cc\
|
||||
DefaultBtAnnounceTest.cc\
|
||||
BtRegistryTest.cc\
|
||||
DefaultBtMessageDispatcherTest.cc\
|
||||
MockPeerStorage.h\
|
||||
DefaultBtRequestFactoryTest.cc\
|
||||
BtAllowedFastMessageTest.cc\
|
||||
FixedNumberRandomizer.h\
|
||||
ConsoleFileAllocationMonitorTest.cc\
|
||||
ChunkChecksumValidatorTest.cc
|
||||
|
||||
if ENABLE_BITTORRENT
|
||||
aria2c_SOURCES += BtAllowedFastMessageTest.cc\
|
||||
BtBitfieldMessageTest.cc\
|
||||
BtCancelMessageTest.cc\
|
||||
BtChokeMessageTest.cc\
|
||||
BtHandshakeMessageTest.cc\
|
||||
BtHaveAllMessageTest.cc\
|
||||
BtHaveMessageTest.cc\
|
||||
BtHaveNoneMessageTest.cc\
|
||||
|
@ -69,24 +65,37 @@ aria2c_SOURCES = AllTest.cc\
|
|||
BtNotInterestedMessageTest.cc\
|
||||
BtPieceMessageTest.cc\
|
||||
BtPortMessageTest.cc\
|
||||
BtRegistryTest.cc\
|
||||
BtRejectMessageTest.cc\
|
||||
BtRequestMessageTest.cc\
|
||||
BtSuggestPieceMessageTest.cc\
|
||||
BtUnchokeMessageTest.cc\
|
||||
BtHandshakeMessageTest.cc\
|
||||
MockBtMessageDispatcher.h\
|
||||
FixedNumberRandomizer.h\
|
||||
MockBtMessageFactory.h\
|
||||
DefaultBtAnnounceTest.cc\
|
||||
DefaultBtContextTest.cc\
|
||||
DefaultBtMessageDispatcherTest.cc\
|
||||
DefaultBtRequestFactoryTest.cc\
|
||||
DefaultPieceStorageTest.cc\
|
||||
MockBtMessage.h\
|
||||
ConsoleFileAllocationMonitorTest.cc\
|
||||
ChunkChecksumValidatorTest.cc
|
||||
MockBtMessageDispatcher.h\
|
||||
MockBtMessageFactory.h\
|
||||
ShaVisitorTest.cc
|
||||
endif # ENABLE_BITTORRENT
|
||||
|
||||
if ENABLE_METALINK
|
||||
aria2c_SOURCES += MetalinkerTest.cc\
|
||||
MetalinkEntryTest.cc\
|
||||
Xml2MetalinkProcessorTest.cc
|
||||
endif # ENABLE_METALINK
|
||||
|
||||
|
||||
#aria2c_CXXFLAGS = ${CPPUNIT_CFLAGS} -I../src -I../lib -Wall -D_FILE_OFFSET_BITS=64
|
||||
#aria2c_LDFLAGS = ${CPPUNIT_LIBS}
|
||||
|
||||
aria2c_LDADD = ../src/libaria2c.a\
|
||||
${CPPUNIT_LIBS} @LIBGNUTLS_LIBS@\
|
||||
@LIBGCRYPT_LIBS@ @OPENSSL_LIBS@ @XML_LIBS@\
|
||||
@LIBARES_LIBS@ @LIBCARES_LIBS@
|
||||
@LIBINTL@ @LIBGNUTLS_LIBS@\
|
||||
@LIBGCRYPT_LIBS@ @OPENSSL_LIBS@ @XML_LIBS@ @LIBARES_LIBS@\
|
||||
@LIBCARES_LIBS@ @WINSOCK_LIBS@\
|
||||
${CPPUNIT_LIBS}
|
||||
AM_CPPFLAGS = -Wall\
|
||||
${CPPUNIT_CFLAGS}\
|
||||
-I ../src\
|
||||
|
|
|
@ -9,7 +9,9 @@ class MultiDiskAdaptorTest:public CppUnit::TestFixture {
|
|||
CPPUNIT_TEST_SUITE(MultiDiskAdaptorTest);
|
||||
CPPUNIT_TEST(testWriteData);
|
||||
CPPUNIT_TEST(testReadData);
|
||||
#ifdef ENABLE_MESSAGE_DIGEST
|
||||
CPPUNIT_TEST(testMessageDigest);
|
||||
#endif // ENABLE_MESSAGE_DIGEST
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
private:
|
||||
Option* option;
|
||||
|
@ -30,7 +32,9 @@ public:
|
|||
|
||||
void testWriteData();
|
||||
void testReadData();
|
||||
#ifdef ENABLE_MESSAGE_DIGEST
|
||||
void testMessageDigest();
|
||||
#endif // ENABLE_MESSAGE_DIGEST
|
||||
};
|
||||
|
||||
|
||||
|
@ -134,6 +138,8 @@ void MultiDiskAdaptorTest::testReadData() {
|
|||
CPPUNIT_ASSERT_EQUAL(string("1234567890ABCDEFGHIJKLMNO"), string((char*)buf));
|
||||
}
|
||||
|
||||
#ifdef ENABLE_MESSAGE_DIGEST
|
||||
|
||||
void MultiDiskAdaptorTest::testMessageDigest() {
|
||||
FileEntryHandle entry1(new FileEntry("file1r.txt", 15, 0));
|
||||
FileEntryHandle entry2(new FileEntry("file2r.txt", 7, 15));
|
||||
|
@ -154,3 +160,5 @@ void MultiDiskAdaptorTest::testMessageDigest() {
|
|||
CPPUNIT_ASSERT_EQUAL(string("6238bf61dd8df8f77156b2378e9e39cd3939680c"), sha1sum);
|
||||
adaptor->closeFile();
|
||||
}
|
||||
|
||||
#endif // ENABLE_MESSAGE_DIGEST
|
||||
|
|
|
@ -1,7 +1,12 @@
|
|||
#include "common.h"
|
||||
#include "MultiDiskWriter.h"
|
||||
#include <string>
|
||||
#include <cppunit/extensions/HelperMacros.h>
|
||||
|
||||
#ifdef HAVE_IO_H
|
||||
# include <io.h>
|
||||
#endif // HAVE_IO_H
|
||||
|
||||
using namespace std;
|
||||
|
||||
class MultiDiskWriterTest:public CppUnit::TestFixture {
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
#include "common.h"
|
||||
#include "PeerMessageUtil.h"
|
||||
#ifdef HAVE_NETINET_IN_H
|
||||
#include <netinet/in.h>
|
||||
#endif // HAVE_NETINET_IN_H
|
||||
#include <cppunit/extensions/HelperMacros.h>
|
||||
|
||||
using namespace std;
|
||||
|
|
|
@ -146,7 +146,7 @@ void SegmentManTest::testMarkPieceDone_usedSegment()
|
|||
SegmentHandle segment = segmentMan.getSegment(0, 5);
|
||||
CPPUNIT_ASSERT(!segment.isNull());
|
||||
CPPUNIT_ASSERT_EQUAL(5, segment->index);
|
||||
CPPUNIT_ASSERT_EQUAL(pieceLength, segment->length);
|
||||
CPPUNIT_ASSERT_EQUAL(pieceLength, segment->segmentLength);
|
||||
CPPUNIT_ASSERT_EQUAL(pieceLength, (int32_t) segment->length);
|
||||
CPPUNIT_ASSERT_EQUAL(pieceLength, (int32_t) segment->segmentLength);
|
||||
CPPUNIT_ASSERT_EQUAL(100, segment->writtenLength);
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
#include "ShaVisitor.h"
|
||||
|
||||
#include "MetaFileUtil.h"
|
||||
#include <string>
|
||||
#include <cppunit/extensions/HelperMacros.h>
|
||||
|
@ -10,6 +11,7 @@ class ShaVisitorTest:public CppUnit::TestFixture {
|
|||
CPPUNIT_TEST_SUITE(ShaVisitorTest);
|
||||
CPPUNIT_TEST(testVisit);
|
||||
CPPUNIT_TEST(testVisitCompound);
|
||||
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
private:
|
||||
|
||||
|
|
|
@ -34,21 +34,21 @@ void SharedHandleTest::testSharedHandle() {
|
|||
cerr << "xh:" << endl;
|
||||
SharedHandle<int> xh = new int(1);
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(1, xh.getRefCount()->totalRefCount);
|
||||
CPPUNIT_ASSERT_EQUAL(1, xh.getRefCount()->strongRefCount);
|
||||
CPPUNIT_ASSERT_EQUAL((int32_t)1, xh.getRefCount()->totalRefCount);
|
||||
CPPUNIT_ASSERT_EQUAL((int32_t)1, xh.getRefCount()->strongRefCount);
|
||||
|
||||
cerr << "nullHandle:" << endl;
|
||||
SharedHandle<int> nullHandle = 0;
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(1, nullHandle.getRefCount()->totalRefCount);
|
||||
CPPUNIT_ASSERT_EQUAL(1, nullHandle.getRefCount()->strongRefCount);
|
||||
CPPUNIT_ASSERT_EQUAL((int32_t)1, nullHandle.getRefCount()->totalRefCount);
|
||||
CPPUNIT_ASSERT_EQUAL((int32_t)1, nullHandle.getRefCount()->strongRefCount);
|
||||
|
||||
cerr << "staticHandle:" << endl;
|
||||
CPPUNIT_ASSERT_EQUAL(1, staticHandle.getRefCount()->totalRefCount);
|
||||
CPPUNIT_ASSERT_EQUAL(1, staticHandle.getRefCount()->strongRefCount);
|
||||
CPPUNIT_ASSERT_EQUAL((int32_t)1, staticHandle.getRefCount()->totalRefCount);
|
||||
CPPUNIT_ASSERT_EQUAL((int32_t)1, staticHandle.getRefCount()->strongRefCount);
|
||||
|
||||
SharedHandle<int> localStaticHandle = getInstance();
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(2, localStaticHandle.getRefCount()->totalRefCount);
|
||||
CPPUNIT_ASSERT_EQUAL(2, localStaticHandle.getRefCount()->strongRefCount);
|
||||
CPPUNIT_ASSERT_EQUAL((int32_t)2, localStaticHandle.getRefCount()->totalRefCount);
|
||||
CPPUNIT_ASSERT_EQUAL((int32_t)2, localStaticHandle.getRefCount()->strongRefCount);
|
||||
}
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
#include <iostream>
|
||||
#include "SingletonHolder.h"
|
||||
#include "SharedHandle.h"
|
||||
#include <cppunit/extensions/HelperMacros.h>
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#include "TimeSeedCriteria.h"
|
||||
|
||||
#include <cppunit/extensions/HelperMacros.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
class TimeSeedCriteriaTest:public CppUnit::TestFixture {
|
||||
|
||||
|
@ -17,7 +18,11 @@ CPPUNIT_TEST_SUITE_REGISTRATION(TimeSeedCriteriaTest);
|
|||
|
||||
void TimeSeedCriteriaTest::testEvaluate() {
|
||||
TimeSeedCriteria cri(1);
|
||||
#ifdef HAVE_SLEEP
|
||||
sleep(1);
|
||||
#else
|
||||
_sleep(1);
|
||||
#endif
|
||||
CPPUNIT_ASSERT(cri.evaluate());
|
||||
cri.reset();
|
||||
cri.setDuration(10);
|
||||
|
|
|
@ -15,9 +15,13 @@ class UtilTest:public CppUnit::TestFixture {
|
|||
CPPUNIT_TEST(testStartsWith);
|
||||
// may be moved to other helper class in the future.
|
||||
CPPUNIT_TEST(testGetContentDispositionFilename);
|
||||
#ifdef ENABLE_BITTORRENT
|
||||
CPPUNIT_TEST(testComputeFastSet);
|
||||
#endif
|
||||
CPPUNIT_TEST(testRandomAlpha);
|
||||
#ifdef ENABLE_MESSAGE_DIGEST
|
||||
CPPUNIT_TEST(testFileChecksum);
|
||||
#endif
|
||||
CPPUNIT_TEST(testToUpper);
|
||||
CPPUNIT_TEST(testToLower);
|
||||
CPPUNIT_TEST(testUrldecode);
|
||||
|
@ -38,11 +42,15 @@ public:
|
|||
void testEndsWith();
|
||||
void testReplace();
|
||||
void testStartsWith();
|
||||
#ifdef ENABLE_BITTORRENT
|
||||
void testComputeFastSet();
|
||||
#endif
|
||||
// may be moved to other helper class in the future.
|
||||
void testGetContentDispositionFilename();
|
||||
void testRandomAlpha();
|
||||
#ifdef ENABLE_MESSAGE_DIGEST
|
||||
void testFileChecksum();
|
||||
#endif
|
||||
void testToUpper();
|
||||
void testToLower();
|
||||
void testUrldecode();
|
||||
|
@ -235,6 +243,8 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
#ifdef ENABLE_BITTORRENT
|
||||
|
||||
void UtilTest::testComputeFastSet() {
|
||||
string ipaddr = "192.168.0.1";
|
||||
unsigned char infoHash[20];
|
||||
|
@ -258,10 +268,14 @@ void UtilTest::testComputeFastSet() {
|
|||
CPPUNIT_ASSERT(equal(fastSet.begin(), fastSet.end(), ansSet2.begin()));
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
void UtilTest::testRandomAlpha() {
|
||||
CPPUNIT_ASSERT_EQUAL(string("rUopvKRn"), Util::randomAlpha(8));
|
||||
}
|
||||
|
||||
#ifdef ENABLE_MESSAGE_DIGEST
|
||||
|
||||
void UtilTest::testFileChecksum() {
|
||||
unsigned char buf[20];
|
||||
string filename = "4096chunk.txt";
|
||||
|
@ -276,6 +290,8 @@ void UtilTest::testFileChecksum() {
|
|||
md5);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
void UtilTest::testToUpper() {
|
||||
string src = "608cabc0f2fa18c260cafd974516865c772363d5";
|
||||
string upp = "608CABC0F2FA18C260CAFD974516865C772363D5";
|
||||
|
@ -314,8 +330,8 @@ void UtilTest::testUrldecode() {
|
|||
}
|
||||
|
||||
void UtilTest::testCountBit() {
|
||||
CPPUNIT_ASSERT_EQUAL(32, Util::countBit(UINT32_MAX));
|
||||
CPPUNIT_ASSERT_EQUAL(8, Util::countBit(255));
|
||||
CPPUNIT_ASSERT_EQUAL((int32_t)32, Util::countBit(UINT32_MAX));
|
||||
CPPUNIT_ASSERT_EQUAL((int32_t)8, Util::countBit(255));
|
||||
}
|
||||
|
||||
void UtilTest::testGetRealSize()
|
||||
|
|
|
@ -64,10 +64,12 @@ void Xml2MetalinkProcessorTest::testParseFile() {
|
|||
CPPUNIT_ASSERT_EQUAL(string("0.5.1"), entry2->version);
|
||||
CPPUNIT_ASSERT_EQUAL(string("ja-JP"), entry2->language);
|
||||
CPPUNIT_ASSERT_EQUAL(string("Linux-m68k"), entry2->os);
|
||||
#ifdef ENABLE_MESSAGE_DIGEST
|
||||
CPPUNIT_ASSERT_EQUAL(string("4c255b0ed130f5ea880f0aa061c3da0487e251cc"),
|
||||
entry2->checksum->getMessageDigest());
|
||||
#endif // ENABLE_MESSAGE_DIGEST
|
||||
CPPUNIT_ASSERT_EQUAL((int32_t)2, entry2->chunkChecksum->countChecksum());
|
||||
CPPUNIT_ASSERT_EQUAL(262144, entry2->chunkChecksum->getChecksumLength());
|
||||
CPPUNIT_ASSERT_EQUAL((int32_t)262144, entry2->chunkChecksum->getChecksumLength());
|
||||
CPPUNIT_ASSERT_EQUAL(string("179463a88d79cbf0b1923991708aead914f26142"),
|
||||
entry2->chunkChecksum->getChecksum(0));
|
||||
CPPUNIT_ASSERT_EQUAL(string("fecf8bc9a1647505fe16746f94e97a477597dbf3"),
|
||||
|
|
Loading…
Reference in New Issue