diff options
| author | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2007-11-21 16:14:40 +0000 |
|---|---|---|
| committer | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2007-11-21 16:14:40 +0000 |
| commit | c9e3d510547de63658c397060095d51b2c1b2c4b (patch) | |
| tree | 17c05e8798c9dfaee1a322146a5ccbf2c8f067e6 /test/MultiFileAllocationIteratorTest.cc | |
| parent | 59fb4066fb178163a34bb1e0b53fff59e1c187f2 (diff) | |
2007-11-20 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Preallocate non-requested file which is adjacent forward to
requested
file('requested' files means the files given in --select-file
option)
if they share a same piece.
This fixes long pause in the file system which doesn't support
sparse
files like FAT32 while downloading.
* src/MultiFileAllocationIterator.{h, cc}
* test/MultiFileAllocationIteratorTest.cc
* src/FileEntry.{h, cc}
Removed unused _option.
* src/MultiDiskAdaptor.h
* test/MultiDiskAdaptorTest.cc
* src/DefaultPieceStorage.cc
Set the default value of --seed-ratio to 1.0.
If 0.0 is given, then seeding continues regardless of share
ratio.
* src/version_usage.cc
* src/option_processing.cc
* src/BtSetup.cc
* doc/aria2c.1.txt
* doc/aria2c.1
Fixed: Selective download is not working in BitTorrent
* src/RequestGroup.cc
Introduced Sequence class. Use this instead of
Util::unfoldRange()
* src/PieceStorage.h
* test/MockPieceStorage.h
* src/UnknownLengthPieceStorage.h
* src/DefaultPieceStorage.{h, cc}
* src/Metalink2RequestGroup.cc
* src/RequestGroup.cc
* src/Sequence.h
* test/SequenceTest.cc
* src/IntSequence.h
* src/message.h
* src/Util.{h, cc}
* test/UtilTest.cc
Added new function 'parse' to catch exception thrown by
subclass's
parseArg
* src/OptionHandler.h
* src/OptionParser.cc
* src/NameMatchOptionHandler.h
* src/OptionHandlerImpl.h
* test/OptionHandlerTest.cc
Added IntegerRangeOptionHandler. Used for --listen-port and
--select-file. Now --listen-port accepts range of port.
* src/OptionHandlerFactory.cc
* src/version_usage.cc
* src/OptionHandlerImpl.h
* src/option_processing.cc
* src/BtSetup.cc
* src/PeerListenCommand.{h, cc}
* doc/aria2c.1.txt
* doc/aria2c.1
Implemented operator< for Exception class to provide easy way to
print
exception stack trace.
* src/Exception.{h, cc}
* src/main.cc
* src/option_processing.cc
Diffstat (limited to 'test/MultiFileAllocationIteratorTest.cc')
| -rw-r--r-- | test/MultiFileAllocationIteratorTest.cc | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/test/MultiFileAllocationIteratorTest.cc b/test/MultiFileAllocationIteratorTest.cc index e64fa225..1ce89acb 100644 --- a/test/MultiFileAllocationIteratorTest.cc +++ b/test/MultiFileAllocationIteratorTest.cc @@ -7,6 +7,7 @@ class MultiFileAllocationIteratorTest:public CppUnit::TestFixture { CPPUNIT_TEST_SUITE(MultiFileAllocationIteratorTest); CPPUNIT_TEST(testAllocate); + CPPUNIT_TEST(testMakeFileEntries); CPPUNIT_TEST_SUITE_END(); private: @@ -14,11 +15,54 @@ public: void setUp() {} void testAllocate(); + void testMakeFileEntries(); }; CPPUNIT_TEST_SUITE_REGISTRATION( MultiFileAllocationIteratorTest ); +void MultiFileAllocationIteratorTest::testMakeFileEntries() +{ + FileEntryHandle fs[] = { + new FileEntry("file1", 1536, 0), + new FileEntry("file2", 2048, 1536), + new FileEntry("file3", 1024, 3584), + new FileEntry("file4", 1024, 4608), + new FileEntry("file5", 1024, 5632), + new FileEntry("file6", 1024, 6656), + new FileEntry("file7", 256, 7680), + new FileEntry("file8", 768, 7936), + new FileEntry("file9", 256, 8704), + new FileEntry("fileA", 256, 8960), + }; + fs[1]->setRequested(false); + fs[3]->setRequested(false); + fs[4]->setRequested(false); + fs[5]->setRequested(false); + fs[6]->setRequested(false); + fs[8]->setRequested(false); + fs[9]->setRequested(false); + + MultiDiskAdaptorHandle diskAdaptor = new MultiDiskAdaptor(); + diskAdaptor->setFileEntries(FileEntries(&fs[0], &fs[10])); + diskAdaptor->setPieceLength(1024); + + MultiFileAllocationIteratorHandle itr = diskAdaptor->fileAllocationIterator(); + + FileEntries entries = itr->getFileEntries(); + + sort(entries.begin(), entries.end()); + + CPPUNIT_ASSERT_EQUAL((size_t)6, entries.size()); + + CPPUNIT_ASSERT_EQUAL(string("file1"), entries[0]->getPath()); + CPPUNIT_ASSERT_EQUAL(string("file2"), entries[1]->getPath()); + CPPUNIT_ASSERT_EQUAL(string("file3"), entries[2]->getPath()); + CPPUNIT_ASSERT_EQUAL(string("file6"), entries[3]->getPath()); + CPPUNIT_ASSERT_EQUAL(string("file7"), entries[4]->getPath()); + CPPUNIT_ASSERT_EQUAL(string("file8"), entries[5]->getPath()); +} + void MultiFileAllocationIteratorTest::testAllocate() { string dir = "/tmp"; |
