mirror of
https://github.com/aria2/aria2.git
synced 2025-04-05 05:27:38 +03:00
2010-02-27 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Supported name attribute of metalink::metaurl element and multi-file torrent with Metalink4. Files with same metaurl are grouped and downloaded in one RequestGroup. * src/BtDependency.cc * src/FileEntry.h * src/Metalink2RequestGroup.cc * src/Metalink2RequestGroup.h * src/MetalinkEntry.cc * src/MetalinkEntry.h * src/MetalinkHelper.cc * src/MetalinkHelper.h * src/MetalinkMetaurl.cc * src/MetalinkMetaurl.h * src/MetalinkParserController.cc * src/RequestGroup.cc * src/RequestGroup.h * src/bittorrent_helper.cc * test/BittorrentHelperTest.cc * test/BtDependencyTest.cc * test/MetalinkHelperTest.cc
This commit is contained in:
parent
5032394c6a
commit
2a6775e80b
18 changed files with 500 additions and 157 deletions
|
@ -1,8 +1,11 @@
|
|||
#include "MetalinkHelper.h"
|
||||
|
||||
#include <cppunit/extensions/HelperMacros.h>
|
||||
|
||||
#include "MetalinkEntry.h"
|
||||
#include "Option.h"
|
||||
#include "prefs.h"
|
||||
#include <cppunit/extensions/HelperMacros.h>
|
||||
#include "MetalinkMetaurl.h"
|
||||
|
||||
namespace aria2 {
|
||||
|
||||
|
@ -11,16 +14,14 @@ class MetalinkHelperTest:public CppUnit::TestFixture {
|
|||
CPPUNIT_TEST_SUITE(MetalinkHelperTest);
|
||||
CPPUNIT_TEST(testParseAndQuery);
|
||||
CPPUNIT_TEST(testParseAndQuery_version);
|
||||
CPPUNIT_TEST(testGroupEntryByMetaurlName);
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
private:
|
||||
|
||||
public:
|
||||
void setUp() {}
|
||||
|
||||
void tearDown() {}
|
||||
|
||||
void testParseAndQuery();
|
||||
void testParseAndQuery_version();
|
||||
void testGroupEntryByMetaurlName();
|
||||
};
|
||||
|
||||
|
||||
|
@ -45,4 +46,70 @@ void MetalinkHelperTest::testParseAndQuery_version()
|
|||
CPPUNIT_ASSERT_EQUAL(std::string("aria2-0.5.1.tar.bz2"), entry->getPath());
|
||||
}
|
||||
|
||||
void MetalinkHelperTest::testGroupEntryByMetaurlName()
|
||||
{
|
||||
std::vector<SharedHandle<MetalinkEntry> > entries;
|
||||
|
||||
SharedHandle<MetalinkEntry> e1(new MetalinkEntry());
|
||||
e1->version = "1";
|
||||
e1->sizeKnown = true;
|
||||
// no name
|
||||
e1->metaurls.push_back
|
||||
(SharedHandle<MetalinkMetaurl>
|
||||
(new MetalinkMetaurl("http://meta1", "torrent", "", 1)));
|
||||
|
||||
SharedHandle<MetalinkEntry> e2(new MetalinkEntry());
|
||||
e2->version = "2";
|
||||
e2->sizeKnown = true;
|
||||
|
||||
SharedHandle<MetalinkEntry> e3(new MetalinkEntry());
|
||||
e3->version = "3";
|
||||
e3->sizeKnown = true;
|
||||
e3->metaurls.push_back
|
||||
(SharedHandle<MetalinkMetaurl>
|
||||
(new MetalinkMetaurl("http://meta2", "torrent", "f3", 1)));
|
||||
|
||||
SharedHandle<MetalinkEntry> e4(new MetalinkEntry());
|
||||
e4->version = "4";
|
||||
e4->sizeKnown = true;
|
||||
e4->metaurls.push_back
|
||||
(SharedHandle<MetalinkMetaurl>
|
||||
(new MetalinkMetaurl("http://meta1", "torrent", "f4", 1)));
|
||||
|
||||
SharedHandle<MetalinkEntry> e5(new MetalinkEntry());
|
||||
e5->version = "5";
|
||||
// no size
|
||||
e5->metaurls.push_back
|
||||
(SharedHandle<MetalinkMetaurl>
|
||||
(new MetalinkMetaurl("http://meta1", "torrent", "f5", 1)));
|
||||
|
||||
SharedHandle<MetalinkEntry> e6(new MetalinkEntry());
|
||||
e6->version = "6";
|
||||
e6->sizeKnown = true;
|
||||
e6->metaurls.push_back
|
||||
(SharedHandle<MetalinkMetaurl>
|
||||
(new MetalinkMetaurl("http://meta1", "torrent", "f6", 1)));
|
||||
|
||||
entries.push_back(e1);
|
||||
entries.push_back(e2);
|
||||
entries.push_back(e3);
|
||||
entries.push_back(e4);
|
||||
entries.push_back(e5);
|
||||
entries.push_back(e6);
|
||||
|
||||
std::vector<std::pair<std::string,
|
||||
std::vector<SharedHandle<MetalinkEntry> > > > result;
|
||||
MetalinkHelper::groupEntryByMetaurlName(result, entries);
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(std::string("http://meta1"), result[0].first);
|
||||
CPPUNIT_ASSERT_EQUAL(std::string("1"), result[0].second[0]->version);
|
||||
CPPUNIT_ASSERT_EQUAL(std::string(""), result[1].first);
|
||||
CPPUNIT_ASSERT_EQUAL(std::string("2"), result[1].second[0]->version);
|
||||
CPPUNIT_ASSERT_EQUAL(std::string("http://meta2"), result[2].first);
|
||||
CPPUNIT_ASSERT_EQUAL(std::string("3"), result[2].second[0]->version);
|
||||
CPPUNIT_ASSERT_EQUAL(std::string("http://meta1"), result[3].first);
|
||||
CPPUNIT_ASSERT_EQUAL(std::string("4"), result[3].second[0]->version);
|
||||
CPPUNIT_ASSERT_EQUAL(std::string("6"), result[3].second[1]->version);
|
||||
}
|
||||
|
||||
} // namespace aria2
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue