mirror of
https://github.com/aria2/aria2.git
synced 2025-04-04 21:17:41 +03:00
make clang-format using clang-format-3.6
This commit is contained in:
parent
4abad2f64c
commit
b1132d6b10
1095 changed files with 30423 additions and 33770 deletions
|
@ -36,10 +36,12 @@ class RequestGroupManTest : public CppUnit::TestFixture {
|
|||
CPPUNIT_TEST(testInsertReservedGroup);
|
||||
CPPUNIT_TEST(testAddDownloadResult);
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
private:
|
||||
std::unique_ptr<DownloadEngine> e_;
|
||||
std::shared_ptr<Option> option_;
|
||||
RequestGroupMan* rgman_;
|
||||
|
||||
public:
|
||||
void setUp()
|
||||
{
|
||||
|
@ -50,8 +52,8 @@ public:
|
|||
File(option_->get(PREF_DIR)).mkdirs();
|
||||
e_ = make_unique<DownloadEngine>(make_unique<SelectEventPoll>());
|
||||
e_->setOption(option_.get());
|
||||
auto rgman = make_unique<RequestGroupMan>
|
||||
(std::vector<std::shared_ptr<RequestGroup>>{}, 3, option_.get());
|
||||
auto rgman = make_unique<RequestGroupMan>(
|
||||
std::vector<std::shared_ptr<RequestGroup>>{}, 3, option_.get());
|
||||
rgman_ = rgman.get();
|
||||
e_->setRequestGroupMan(std::move(rgman));
|
||||
}
|
||||
|
@ -67,25 +69,24 @@ public:
|
|||
void testAddDownloadResult();
|
||||
};
|
||||
|
||||
|
||||
CPPUNIT_TEST_SUITE_REGISTRATION( RequestGroupManTest );
|
||||
CPPUNIT_TEST_SUITE_REGISTRATION(RequestGroupManTest);
|
||||
|
||||
void RequestGroupManTest::testIsSameFileBeingDownloaded()
|
||||
{
|
||||
std::shared_ptr<RequestGroup> rg1(new RequestGroup(GroupId::create(),
|
||||
util::copy(option_)));
|
||||
std::shared_ptr<RequestGroup> rg2(new RequestGroup(GroupId::create(),
|
||||
util::copy(option_)));
|
||||
std::shared_ptr<RequestGroup> rg1(
|
||||
new RequestGroup(GroupId::create(), util::copy(option_)));
|
||||
std::shared_ptr<RequestGroup> rg2(
|
||||
new RequestGroup(GroupId::create(), util::copy(option_)));
|
||||
|
||||
std::shared_ptr<DownloadContext> dctx1
|
||||
(new DownloadContext(0, 0, "aria2.tar.bz2"));
|
||||
std::shared_ptr<DownloadContext> dctx2
|
||||
(new DownloadContext(0, 0, "aria2.tar.bz2"));
|
||||
std::shared_ptr<DownloadContext> dctx1(
|
||||
new DownloadContext(0, 0, "aria2.tar.bz2"));
|
||||
std::shared_ptr<DownloadContext> dctx2(
|
||||
new DownloadContext(0, 0, "aria2.tar.bz2"));
|
||||
|
||||
rg1->setDownloadContext(dctx1);
|
||||
rg2->setDownloadContext(dctx2);
|
||||
|
||||
RequestGroupMan gm(std::vector<std::shared_ptr<RequestGroup> >(), 1,
|
||||
RequestGroupMan gm(std::vector<std::shared_ptr<RequestGroup>>(), 1,
|
||||
option_.get());
|
||||
|
||||
gm.addRequestGroup(rg1);
|
||||
|
@ -96,7 +97,6 @@ void RequestGroupManTest::testIsSameFileBeingDownloaded()
|
|||
dctx2->getFirstFileEntry()->setPath("aria2.tar.gz");
|
||||
|
||||
CPPUNIT_ASSERT(!gm.isSameFileBeingDownloaded(rg1.get()));
|
||||
|
||||
}
|
||||
|
||||
void RequestGroupManTest::testGetInitialCommands()
|
||||
|
@ -106,12 +106,12 @@ void RequestGroupManTest::testGetInitialCommands()
|
|||
|
||||
void RequestGroupManTest::testSaveServerStat()
|
||||
{
|
||||
RequestGroupMan rm
|
||||
(std::vector<std::shared_ptr<RequestGroup> >(),0,option_.get());
|
||||
RequestGroupMan rm(std::vector<std::shared_ptr<RequestGroup>>(), 0,
|
||||
option_.get());
|
||||
std::shared_ptr<ServerStat> ss_localhost(new ServerStat("localhost", "http"));
|
||||
rm.addServerStat(ss_localhost);
|
||||
File f(A2_TEST_OUT_DIR"/aria2_RequestGroupManTest_testSaveServerStat");
|
||||
if(f.exists()) {
|
||||
File f(A2_TEST_OUT_DIR "/aria2_RequestGroupManTest_testSaveServerStat");
|
||||
if (f.exists()) {
|
||||
f.remove();
|
||||
}
|
||||
CPPUNIT_ASSERT(rm.saveServerStat(f.getPath()));
|
||||
|
@ -124,87 +124,72 @@ void RequestGroupManTest::testSaveServerStat()
|
|||
|
||||
void RequestGroupManTest::testLoadServerStat()
|
||||
{
|
||||
File f(A2_TEST_OUT_DIR"/aria2_RequestGroupManTest_testLoadServerStat");
|
||||
File f(A2_TEST_OUT_DIR "/aria2_RequestGroupManTest_testLoadServerStat");
|
||||
std::ofstream o(f.getPath().c_str(), std::ios::binary);
|
||||
o << "host=localhost, protocol=http, dl_speed=0, last_updated=1219505257,"
|
||||
<< "status=OK";
|
||||
o.close();
|
||||
|
||||
RequestGroupMan rm
|
||||
(std::vector<std::shared_ptr<RequestGroup> >(),0,option_.get());
|
||||
RequestGroupMan rm(std::vector<std::shared_ptr<RequestGroup>>(), 0,
|
||||
option_.get());
|
||||
std::cerr << "testLoadServerStat" << std::endl;
|
||||
CPPUNIT_ASSERT(rm.loadServerStat(f.getPath()));
|
||||
std::shared_ptr<ServerStat> ss_localhost = rm.findServerStat("localhost",
|
||||
"http");
|
||||
std::shared_ptr<ServerStat> ss_localhost =
|
||||
rm.findServerStat("localhost", "http");
|
||||
CPPUNIT_ASSERT(ss_localhost);
|
||||
CPPUNIT_ASSERT_EQUAL(std::string("localhost"), ss_localhost->getHostname());
|
||||
}
|
||||
|
||||
void RequestGroupManTest::testChangeReservedGroupPosition()
|
||||
{
|
||||
std::vector<std::shared_ptr<RequestGroup>> gs {
|
||||
std::make_shared<RequestGroup>(GroupId::create(), util::copy(option_)),
|
||||
std::make_shared<RequestGroup>(GroupId::create(), util::copy(option_)),
|
||||
std::make_shared<RequestGroup>(GroupId::create(), util::copy(option_)),
|
||||
std::make_shared<RequestGroup>(GroupId::create(), util::copy(option_))
|
||||
};
|
||||
std::vector<std::shared_ptr<RequestGroup>> gs{
|
||||
std::make_shared<RequestGroup>(GroupId::create(), util::copy(option_)),
|
||||
std::make_shared<RequestGroup>(GroupId::create(), util::copy(option_)),
|
||||
std::make_shared<RequestGroup>(GroupId::create(), util::copy(option_)),
|
||||
std::make_shared<RequestGroup>(GroupId::create(), util::copy(option_))};
|
||||
RequestGroupMan rm(gs, 0, option_.get());
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL
|
||||
((size_t)0, rm.changeReservedGroupPosition(gs[0]->getGID(),
|
||||
0, OFFSET_MODE_SET));
|
||||
CPPUNIT_ASSERT_EQUAL
|
||||
((size_t)1, rm.changeReservedGroupPosition(gs[0]->getGID(),
|
||||
1, OFFSET_MODE_SET));
|
||||
CPPUNIT_ASSERT_EQUAL
|
||||
((size_t)3, rm.changeReservedGroupPosition(gs[0]->getGID(),
|
||||
10,OFFSET_MODE_SET));
|
||||
CPPUNIT_ASSERT_EQUAL
|
||||
((size_t)0, rm.changeReservedGroupPosition(gs[0]->getGID(),
|
||||
-10, OFFSET_MODE_SET));
|
||||
CPPUNIT_ASSERT_EQUAL((size_t)0, rm.changeReservedGroupPosition(
|
||||
gs[0]->getGID(), 0, OFFSET_MODE_SET));
|
||||
CPPUNIT_ASSERT_EQUAL((size_t)1, rm.changeReservedGroupPosition(
|
||||
gs[0]->getGID(), 1, OFFSET_MODE_SET));
|
||||
CPPUNIT_ASSERT_EQUAL((size_t)3, rm.changeReservedGroupPosition(
|
||||
gs[0]->getGID(), 10, OFFSET_MODE_SET));
|
||||
CPPUNIT_ASSERT_EQUAL((size_t)0, rm.changeReservedGroupPosition(
|
||||
gs[0]->getGID(), -10, OFFSET_MODE_SET));
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL
|
||||
((size_t)1, rm.changeReservedGroupPosition(gs[1]->getGID(),
|
||||
0, OFFSET_MODE_CUR));
|
||||
CPPUNIT_ASSERT_EQUAL
|
||||
((size_t)2, rm.changeReservedGroupPosition(gs[1]->getGID(),
|
||||
1, OFFSET_MODE_CUR));
|
||||
CPPUNIT_ASSERT_EQUAL
|
||||
((size_t)1, rm.changeReservedGroupPosition(gs[1]->getGID(),
|
||||
-1,OFFSET_MODE_CUR));
|
||||
CPPUNIT_ASSERT_EQUAL
|
||||
((size_t)0, rm.changeReservedGroupPosition(gs[1]->getGID(),
|
||||
-10, OFFSET_MODE_CUR));
|
||||
CPPUNIT_ASSERT_EQUAL
|
||||
((size_t)1, rm.changeReservedGroupPosition(gs[1]->getGID(),
|
||||
1, OFFSET_MODE_CUR));
|
||||
CPPUNIT_ASSERT_EQUAL
|
||||
((size_t)3, rm.changeReservedGroupPosition(gs[1]->getGID(),
|
||||
10, OFFSET_MODE_CUR));
|
||||
CPPUNIT_ASSERT_EQUAL
|
||||
((size_t)1, rm.changeReservedGroupPosition(gs[1]->getGID(),
|
||||
-2,OFFSET_MODE_CUR));
|
||||
CPPUNIT_ASSERT_EQUAL((size_t)1, rm.changeReservedGroupPosition(
|
||||
gs[1]->getGID(), 0, OFFSET_MODE_CUR));
|
||||
CPPUNIT_ASSERT_EQUAL((size_t)2, rm.changeReservedGroupPosition(
|
||||
gs[1]->getGID(), 1, OFFSET_MODE_CUR));
|
||||
CPPUNIT_ASSERT_EQUAL((size_t)1, rm.changeReservedGroupPosition(
|
||||
gs[1]->getGID(), -1, OFFSET_MODE_CUR));
|
||||
CPPUNIT_ASSERT_EQUAL((size_t)0, rm.changeReservedGroupPosition(
|
||||
gs[1]->getGID(), -10, OFFSET_MODE_CUR));
|
||||
CPPUNIT_ASSERT_EQUAL((size_t)1, rm.changeReservedGroupPosition(
|
||||
gs[1]->getGID(), 1, OFFSET_MODE_CUR));
|
||||
CPPUNIT_ASSERT_EQUAL((size_t)3, rm.changeReservedGroupPosition(
|
||||
gs[1]->getGID(), 10, OFFSET_MODE_CUR));
|
||||
CPPUNIT_ASSERT_EQUAL((size_t)1, rm.changeReservedGroupPosition(
|
||||
gs[1]->getGID(), -2, OFFSET_MODE_CUR));
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL
|
||||
((size_t)3, rm.changeReservedGroupPosition(gs[3]->getGID(),
|
||||
0, OFFSET_MODE_END));
|
||||
CPPUNIT_ASSERT_EQUAL
|
||||
((size_t)2, rm.changeReservedGroupPosition(gs[3]->getGID(),
|
||||
-1,OFFSET_MODE_END));
|
||||
CPPUNIT_ASSERT_EQUAL
|
||||
((size_t)0, rm.changeReservedGroupPosition(gs[3]->getGID(),
|
||||
-10, OFFSET_MODE_END));
|
||||
CPPUNIT_ASSERT_EQUAL
|
||||
((size_t)3, rm.changeReservedGroupPosition(gs[3]->getGID(),
|
||||
10, OFFSET_MODE_END));
|
||||
CPPUNIT_ASSERT_EQUAL((size_t)3, rm.changeReservedGroupPosition(
|
||||
gs[3]->getGID(), 0, OFFSET_MODE_END));
|
||||
CPPUNIT_ASSERT_EQUAL((size_t)2, rm.changeReservedGroupPosition(
|
||||
gs[3]->getGID(), -1, OFFSET_MODE_END));
|
||||
CPPUNIT_ASSERT_EQUAL((size_t)0, rm.changeReservedGroupPosition(
|
||||
gs[3]->getGID(), -10, OFFSET_MODE_END));
|
||||
CPPUNIT_ASSERT_EQUAL((size_t)3, rm.changeReservedGroupPosition(
|
||||
gs[3]->getGID(), 10, OFFSET_MODE_END));
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL((size_t)4, rm.getReservedGroups().size());
|
||||
|
||||
try {
|
||||
rm.changeReservedGroupPosition(GroupId::create()->getNumericId(),
|
||||
0, OFFSET_MODE_CUR);
|
||||
rm.changeReservedGroupPosition(GroupId::create()->getNumericId(), 0,
|
||||
OFFSET_MODE_CUR);
|
||||
CPPUNIT_FAIL("exception must be thrown.");
|
||||
} catch(RecoverableException& e) {
|
||||
}
|
||||
catch (RecoverableException& e) {
|
||||
// success
|
||||
}
|
||||
}
|
||||
|
@ -212,17 +197,18 @@ void RequestGroupManTest::testChangeReservedGroupPosition()
|
|||
void RequestGroupManTest::testFillRequestGroupFromReserver()
|
||||
{
|
||||
std::shared_ptr<RequestGroup> rgs[] = {
|
||||
createRequestGroup(0, 0, "foo1", "http://host/foo1", util::copy(option_)),
|
||||
createRequestGroup(0, 0, "foo2", "http://host/foo2", util::copy(option_)),
|
||||
createRequestGroup(0, 0, "foo3", "http://host/foo3", util::copy(option_)),
|
||||
// Intentionally same path/URI for first RequestGroup and set
|
||||
// length explicitly to do duplicate filename check.
|
||||
createRequestGroup(0, 10, "foo1", "http://host/foo1", util::copy(option_)),
|
||||
createRequestGroup(0, 0, "foo4", "http://host/foo4", util::copy(option_)),
|
||||
createRequestGroup(0, 0, "foo5", "http://host/foo5", util::copy(option_))
|
||||
};
|
||||
createRequestGroup(0, 0, "foo1", "http://host/foo1", util::copy(option_)),
|
||||
createRequestGroup(0, 0, "foo2", "http://host/foo2", util::copy(option_)),
|
||||
createRequestGroup(0, 0, "foo3", "http://host/foo3", util::copy(option_)),
|
||||
// Intentionally same path/URI for first RequestGroup and set
|
||||
// length explicitly to do duplicate filename check.
|
||||
createRequestGroup(0, 10, "foo1", "http://host/foo1",
|
||||
util::copy(option_)),
|
||||
createRequestGroup(0, 0, "foo4", "http://host/foo4", util::copy(option_)),
|
||||
createRequestGroup(0, 0, "foo5", "http://host/foo5",
|
||||
util::copy(option_))};
|
||||
rgs[1]->setPauseRequested(true);
|
||||
for(const auto& i : rgs) {
|
||||
for (const auto& i : rgs) {
|
||||
rgman_->addReservedGroup(i);
|
||||
}
|
||||
rgman_->fillRequestGroupFromReserver(e_.get());
|
||||
|
@ -233,16 +219,16 @@ void RequestGroupManTest::testFillRequestGroupFromReserver()
|
|||
void RequestGroupManTest::testFillRequestGroupFromReserver_uriParser()
|
||||
{
|
||||
std::shared_ptr<RequestGroup> rgs[] = {
|
||||
createRequestGroup(0, 0, "mem1", "http://mem1", util::copy(option_)),
|
||||
createRequestGroup(0, 0, "mem2", "http://mem2", util::copy(option_)),
|
||||
createRequestGroup(0, 0, "mem1", "http://mem1", util::copy(option_)),
|
||||
createRequestGroup(0, 0, "mem2", "http://mem2", util::copy(option_)),
|
||||
};
|
||||
rgs[0]->setPauseRequested(true);
|
||||
for(const auto& i : rgs) {
|
||||
for (const auto& i : rgs) {
|
||||
rgman_->addReservedGroup(i);
|
||||
}
|
||||
|
||||
std::shared_ptr<UriListParser> flp
|
||||
(new UriListParser(A2_TEST_DIR"/filelist2.txt"));
|
||||
std::shared_ptr<UriListParser> flp(
|
||||
new UriListParser(A2_TEST_DIR "/filelist2.txt"));
|
||||
rgman_->setUriListParser(flp);
|
||||
|
||||
rgman_->fillRequestGroupFromReserver(e_.get());
|
||||
|
@ -256,18 +242,16 @@ void RequestGroupManTest::testFillRequestGroupFromReserver_uriParser()
|
|||
|
||||
void RequestGroupManTest::testInsertReservedGroup()
|
||||
{
|
||||
std::vector<std::shared_ptr<RequestGroup>> rgs1 {
|
||||
std::shared_ptr<RequestGroup>(new RequestGroup(GroupId::create(),
|
||||
util::copy(option_))),
|
||||
std::shared_ptr<RequestGroup>(new RequestGroup(GroupId::create(),
|
||||
util::copy(option_)))
|
||||
};
|
||||
std::vector<std::shared_ptr<RequestGroup>> rgs2 {
|
||||
std::shared_ptr<RequestGroup>(new RequestGroup(GroupId::create(),
|
||||
util::copy(option_))),
|
||||
std::shared_ptr<RequestGroup>(new RequestGroup(GroupId::create(),
|
||||
util::copy(option_)))
|
||||
};
|
||||
std::vector<std::shared_ptr<RequestGroup>> rgs1{
|
||||
std::shared_ptr<RequestGroup>(
|
||||
new RequestGroup(GroupId::create(), util::copy(option_))),
|
||||
std::shared_ptr<RequestGroup>(
|
||||
new RequestGroup(GroupId::create(), util::copy(option_)))};
|
||||
std::vector<std::shared_ptr<RequestGroup>> rgs2{
|
||||
std::shared_ptr<RequestGroup>(
|
||||
new RequestGroup(GroupId::create(), util::copy(option_))),
|
||||
std::shared_ptr<RequestGroup>(
|
||||
new RequestGroup(GroupId::create(), util::copy(option_)))};
|
||||
rgman_->insertReservedGroup(0, rgs1);
|
||||
CPPUNIT_ASSERT_EQUAL((size_t)2, rgman_->getReservedGroups().size());
|
||||
RequestGroupList::const_iterator itr;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue