Fix infinite loop when size of downloadResults_ exceeds maxDownloadResult_

This commit is contained in:
Tatsuhiro Tsujikawa 2013-02-25 21:42:54 +09:00
parent 2aeb7137d0
commit a49397ed19
5 changed files with 43 additions and 20 deletions

View file

@ -34,6 +34,7 @@ class RequestGroupManTest : public CppUnit::TestFixture {
CPPUNIT_TEST(testFillRequestGroupFromReserver);
CPPUNIT_TEST(testFillRequestGroupFromReserver_uriParser);
CPPUNIT_TEST(testInsertReservedGroup);
CPPUNIT_TEST(testAddDownloadResult);
CPPUNIT_TEST_SUITE_END();
private:
SharedHandle<DownloadEngine> e_;
@ -64,6 +65,7 @@ public:
void testFillRequestGroupFromReserver();
void testFillRequestGroupFromReserver_uriParser();
void testInsertReservedGroup();
void testAddDownloadResult();
};
@ -289,4 +291,17 @@ void RequestGroupManTest::testInsertReservedGroup()
CPPUNIT_ASSERT_EQUAL(rgs2[1]->getGID(), (*itr++).second->getGID());
}
void RequestGroupManTest::testAddDownloadResult()
{
std::string uri = "http://example.org";
rgman_->setMaxDownloadResult(3);
rgman_->addDownloadResult(createDownloadResult(error_code::TIME_OUT, uri));
rgman_->addDownloadResult(createDownloadResult(error_code::FINISHED, uri));
rgman_->addDownloadResult(createDownloadResult(error_code::FINISHED, uri));
rgman_->addDownloadResult(createDownloadResult(error_code::FINISHED, uri));
rgman_->addDownloadResult(createDownloadResult(error_code::FINISHED, uri));
CPPUNIT_ASSERT_EQUAL(error_code::TIME_OUT,
rgman_->getDownloadStat().getLastErrorResult());
}
} // namespace aria2