2011-06-11 12:49:09 +00:00
|
|
|
#include "InorderURISelector.h"
|
2009-06-29 08:42:58 +00:00
|
|
|
|
|
|
|
#include <cppunit/extensions/HelperMacros.h>
|
|
|
|
|
2008-08-04 17:06:47 +00:00
|
|
|
#include "Exception.h"
|
2009-10-22 15:35:33 +00:00
|
|
|
#include "util.h"
|
2008-08-04 17:06:47 +00:00
|
|
|
#include "array_fun.h"
|
2009-06-29 08:42:58 +00:00
|
|
|
#include "FileEntry.h"
|
2008-08-04 17:06:47 +00:00
|
|
|
|
|
|
|
namespace aria2 {
|
|
|
|
|
2011-06-11 12:49:09 +00:00
|
|
|
class InorderURISelectorTest:public CppUnit::TestFixture {
|
2008-08-04 17:06:47 +00:00
|
|
|
|
2011-06-11 12:49:09 +00:00
|
|
|
CPPUNIT_TEST_SUITE(InorderURISelectorTest);
|
2008-08-04 17:06:47 +00:00
|
|
|
CPPUNIT_TEST(testSelect);
|
|
|
|
CPPUNIT_TEST_SUITE_END();
|
|
|
|
private:
|
2010-06-21 13:51:56 +00:00
|
|
|
FileEntry fileEntry_;
|
2008-08-04 17:06:47 +00:00
|
|
|
|
2011-06-11 12:49:09 +00:00
|
|
|
SharedHandle<InorderURISelector> sel;
|
2012-10-01 14:52:22 +00:00
|
|
|
|
2008-08-04 17:06:47 +00:00
|
|
|
public:
|
|
|
|
void setUp()
|
|
|
|
{
|
|
|
|
static const char* urisSrc[] = {
|
|
|
|
"http://alpha/file",
|
|
|
|
"ftp://alpha/file",
|
|
|
|
"http://bravo/file"
|
|
|
|
};
|
2010-02-28 12:30:11 +00:00
|
|
|
std::vector<std::string> uris;
|
2010-03-25 13:51:10 +00:00
|
|
|
uris.assign(vbegin(urisSrc), vend(urisSrc));
|
2012-10-01 14:52:22 +00:00
|
|
|
|
2010-06-21 13:51:56 +00:00
|
|
|
fileEntry_.setUris(uris);
|
2009-06-29 08:42:58 +00:00
|
|
|
|
2011-06-11 12:49:09 +00:00
|
|
|
sel.reset(new InorderURISelector());
|
2008-08-04 17:06:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void tearDown() {}
|
|
|
|
|
|
|
|
void testSelect();
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2011-06-11 12:49:09 +00:00
|
|
|
CPPUNIT_TEST_SUITE_REGISTRATION(InorderURISelectorTest);
|
2008-08-04 17:06:47 +00:00
|
|
|
|
2011-06-11 12:49:09 +00:00
|
|
|
void InorderURISelectorTest::testSelect()
|
2008-08-04 17:06:47 +00:00
|
|
|
{
|
2010-07-15 13:49:02 +00:00
|
|
|
std::vector<std::pair<size_t, std::string> > usedHosts;
|
2009-06-29 08:42:58 +00:00
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string("http://alpha/file"),
|
2010-07-14 14:10:33 +00:00
|
|
|
sel->select(&fileEntry_, usedHosts));
|
2009-06-29 08:42:58 +00:00
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string("ftp://alpha/file"),
|
2010-07-14 14:10:33 +00:00
|
|
|
sel->select(&fileEntry_, usedHosts));
|
2009-06-29 08:42:58 +00:00
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string("http://bravo/file"),
|
2010-07-14 14:10:33 +00:00
|
|
|
sel->select(&fileEntry_, usedHosts));
|
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string(""), sel->select(&fileEntry_, usedHosts));
|
2008-08-04 17:06:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace aria2
|