mirror of
https://github.com/aria2/aria2.git
synced 2025-02-24 08:01:33 +00:00

* src/Xml2MetalinkProcessor.h (xpathExists): New function. * src/Xml2MetalinkProcessor.cc (xpathExists): New function. Not to send HEAD request if filename and size are available in Metalink file: * src/UrlRequestInfo.h (filename): New variable. (totalLength): New variable. (setTotalLength): New function. (setFilename): New function. * src/MetalinkRequestInfo.cc (execute): Set filename and size to UrlRequestInfo. * src/MetalinkEntry.cc (MetalinkEntry): Initialize size with 0. * src/UrlRequestInfo.cc (execute): Set filename and size to SegmentMan. Not to download rest of the files after selected files are downloaded in BitTorrent: * src/PieceStorage.h (allDownloadFinished): New function. * src/DefaultBtAnnounce.cc (isCompleteAnnounceReady): Use allDownloadFinished instead of downloadFinished. (getAnnounceUrl): Use allDownloadFinished instead of downloadFinished. * src/DefaultPieceStorage.cc (completePiece): Use allDownloadFinished instead of downloadFinished. Commented out the call to finishSelectiveDownloadingMode(). (downloadFinished): Call isFilteredAllBitSet() instead of isAllBitSet(). (allDownloadFinished): New function. * src/DefaultBtInteractive.cc (addBitfieldMessageToQueue): Call allDownloadFinished() instead of downloadFinished(). (checkHave): Call allDownloadFinished() instead of downloadFinished(). * src/TorrentDownloadEngine.cc (onEndOfRun): Call allDownloadFinished() instead of downloadFinished(). * src/BitfieldMan.h (isFilteredAllBitSet): New function. * src/ShareRatioSeedCriteria.h (PieceStorage.h): New include. (pieceStorage): New variable. (evaluate): btContext->getTotalLength() -> pieceStorage->getCompletedLength() * src/BitfieldMan.cc (isFilteredAllBitSet): New function. (isAllBitSet): Filter is not took into account. Rename --force-truncate as --allow-overwrite: * src/TorrentRequestInfo.cc (execute): PREF_FORCE_TRUNCATE -> PREF_ALLOW_OVERWRITE * src/main.cc (showUsage): --force-truncate -> --allow-overwrite * src/message.h (EX_FILE_ALREADY_EXISTS): --force-truncate -> --allow-overwrite * src/prefs.h (PREF_FORCE_TRUNCATE): Removed. (PREF_ALLOW_OVERWRITE): New definition. * src/SegmentMan.cc (shouldCancelDownloadForSafety): --force-truncate -> --allow-overwrite * src/MetalinkRequestInfo.cc (execute): Queueing message are now logged in info level. * src/common.h (LONG_LONG_MAX): Removed. (LONG_LONG_MIN): Removed. * src/HttpResponseCommand.cc (handleDefaultEncoding): LONG_LONG_MAX -> INT64_MAX * src/FtpNegotiateCommand.cc (recvSize): LONG_LONG_MAX -> INT64_MAX * src/main.cc (showUsage): Added --check-integiry and --realtime-chunk-checksum command-line option. (main): Added --check-integiry and --realtime-chunk-checksum command-line option. --force-truncate -> --allow-overwrite Set initial value of --check-integrity option to false. Don't show usage when error occurs while persing command-line options. Removed deprecated --upload-limit option.
56 lines
1.4 KiB
C++
56 lines
1.4 KiB
C++
#include "BtPortMessage.h"
|
|
#include "PeerMessageUtil.h"
|
|
#include "Util.h"
|
|
#include <cppunit/extensions/HelperMacros.h>
|
|
|
|
using namespace std;
|
|
|
|
class BtPortMessageTest:public CppUnit::TestFixture {
|
|
|
|
CPPUNIT_TEST_SUITE(BtPortMessageTest);
|
|
CPPUNIT_TEST(testCreate);
|
|
CPPUNIT_TEST(testToString);
|
|
CPPUNIT_TEST_SUITE_END();
|
|
private:
|
|
|
|
public:
|
|
void setUp() {
|
|
}
|
|
|
|
void testCreate();
|
|
void testToString();
|
|
};
|
|
|
|
|
|
CPPUNIT_TEST_SUITE_REGISTRATION(BtPortMessageTest);
|
|
|
|
void BtPortMessageTest::testCreate() {
|
|
unsigned char msg[7];
|
|
PeerMessageUtil::createPeerMessageString(msg, sizeof(msg), 3, 9);
|
|
PeerMessageUtil::setShortIntParam(&msg[5], 12345);
|
|
BtPortMessageHandle pm = BtPortMessage::create(&msg[4], 3);
|
|
CPPUNIT_ASSERT_EQUAL((int8_t)9, pm->getId());
|
|
CPPUNIT_ASSERT_EQUAL((int16_t)12345, pm->getPort());
|
|
|
|
// case: payload size is wrong
|
|
try {
|
|
unsigned char msg[8];
|
|
PeerMessageUtil::createPeerMessageString(msg, sizeof(msg), 4, 9);
|
|
BtPortMessage::create(&msg[4], 4);
|
|
CPPUNIT_FAIL("exception must be threw.");
|
|
} catch(...) {
|
|
}
|
|
// case: id is wrong
|
|
try {
|
|
unsigned char msg[7];
|
|
PeerMessageUtil::createPeerMessageString(msg, sizeof(msg), 3, 10);
|
|
BtPortMessage::create(&msg[4], 3);
|
|
CPPUNIT_FAIL("exception must be threw.");
|
|
} catch(...) {
|
|
}
|
|
}
|
|
void BtPortMessageTest::testToString() {
|
|
BtPortMessage msg(1);
|
|
CPPUNIT_ASSERT_EQUAL(string("port port=1"), msg.toString());
|
|
}
|