summaryrefslogtreecommitdiff
path: root/test/BitfieldManTest.cc
diff options
context:
space:
mode:
authorTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2007-01-28 14:18:35 +0000
committerTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2007-01-28 14:18:35 +0000
commitcd91e2ea4ff5def508a425be18fc8e6aa7abec92 (patch)
tree6ade647832c688fe4aa84cce5a9f844bfcefc5c6 /test/BitfieldManTest.cc
parentcd9e35bc632dd4a4bb6a543266803e34376e7964 (diff)
2007-01-28 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
* 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.
Diffstat (limited to 'test/BitfieldManTest.cc')
-rw-r--r--test/BitfieldManTest.cc18
1 files changed, 9 insertions, 9 deletions
diff --git a/test/BitfieldManTest.cc b/test/BitfieldManTest.cc
index 479ffef3..814175b7 100644
--- a/test/BitfieldManTest.cc
+++ b/test/BitfieldManTest.cc
@@ -42,12 +42,12 @@ CPPUNIT_TEST_SUITE_REGISTRATION( BitfieldManTest );
void BitfieldManTest::testGetBlockSize() {
BitfieldMan bt1(1024, 1024*10);
- CPPUNIT_ASSERT_EQUAL((uint32_t)1024, bt1.getBlockLength(9));
+ CPPUNIT_ASSERT_EQUAL(1024, bt1.getBlockLength(9));
BitfieldMan bt2(1024, 1024*10+1);
- CPPUNIT_ASSERT_EQUAL((uint32_t)1024, bt2.getBlockLength(9));
- CPPUNIT_ASSERT_EQUAL((uint32_t)1, bt2.getBlockLength(10));
- CPPUNIT_ASSERT_EQUAL((uint32_t)0, bt2.getBlockLength(11));
+ CPPUNIT_ASSERT_EQUAL(1024, bt2.getBlockLength(9));
+ CPPUNIT_ASSERT_EQUAL(1, bt2.getBlockLength(10));
+ CPPUNIT_ASSERT_EQUAL(0, bt2.getBlockLength(11));
}
void BitfieldManTest::testGetFirstMissingUnusedIndex() {
@@ -84,7 +84,7 @@ void BitfieldManTest::testIsAllBitSet() {
}
CPPUNIT_ASSERT(!bt1.isAllBitSet());
- for(uint32_t i = 0; i < bt1.countBlock(); i++) {
+ for(int32_t i = 0; i < bt1.countBlock(); i++) {
CPPUNIT_ASSERT(bt1.setBit(i));
}
CPPUNIT_ASSERT(bt1.isAllBitSet());
@@ -122,7 +122,7 @@ void BitfieldManTest::testFilter() {
index = btman.getMissingUnusedIndex(peerBt, sizeof(peerBt));
btman.setUseBit(index);
CPPUNIT_ASSERT_EQUAL(-1, index);
- CPPUNIT_ASSERT_EQUAL((uint64_t)12, btman.getFilteredTotalLength());
+ CPPUNIT_ASSERT_EQUAL((int64_t)12, btman.getFilteredTotalLength());
// test offset=5, length=2
btman.clearAllBit();
@@ -141,13 +141,13 @@ void BitfieldManTest::testFilter() {
index = btman.getMissingUnusedIndex(peerBt, sizeof(peerBt));
btman.setUseBit(index);
CPPUNIT_ASSERT_EQUAL(-1, index);
- CPPUNIT_ASSERT_EQUAL((uint64_t)4, btman.getFilteredTotalLength());
- CPPUNIT_ASSERT(btman.isAllBitSet());
+ CPPUNIT_ASSERT_EQUAL((int64_t)4, btman.getFilteredTotalLength());
+ CPPUNIT_ASSERT(btman.isFilteredAllBitSet());
BitfieldMan btman2(2, 31);
btman2.addFilter(0, 31);
btman2.enableFilter();
- CPPUNIT_ASSERT_EQUAL((uint64_t)31, btman2.getFilteredTotalLength());
+ CPPUNIT_ASSERT_EQUAL((int64_t)31, btman2.getFilteredTotalLength());
}