mirror of https://github.com/aria2/aria2
2009-06-14 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Throw an exception if position is less than 0. * src/XmlRpcMethodImpl.cc * test/XmlRpcMethodTest.ccpull/1/head
parent
daf0c5ee73
commit
a28f19befb
|
@ -1,3 +1,9 @@
|
|||
2009-06-14 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
|
||||
|
||||
Throw an exception if position is less than 0.
|
||||
* src/XmlRpcMethodImpl.cc
|
||||
* test/XmlRpcMethodTest.cc
|
||||
|
||||
2009-06-14 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
|
||||
|
||||
Use writeFilePath() in ConsoleStatCalc.cc
|
||||
|
|
|
@ -102,8 +102,12 @@ static void getPosParam(const BDE& params, size_t posParamIndex,
|
|||
bool& posGiven, size_t& pos)
|
||||
{
|
||||
if(params.size() > posParamIndex && params[posParamIndex].isInteger()) {
|
||||
if(params[posParamIndex].i() >= 0) {
|
||||
pos = params[posParamIndex].i();
|
||||
posGiven = true;
|
||||
} else {
|
||||
throw DL_ABORT_EX("Position must be greater than or equal to 0.");
|
||||
}
|
||||
} else {
|
||||
posGiven = false;
|
||||
}
|
||||
|
|
|
@ -30,6 +30,7 @@ class XmlRpcMethodTest:public CppUnit::TestFixture {
|
|||
CPPUNIT_TEST(testAddUri_notUri);
|
||||
CPPUNIT_TEST(testAddUri_withBadOption);
|
||||
CPPUNIT_TEST(testAddUri_withPosition);
|
||||
CPPUNIT_TEST(testAddUri_withBadPosition);
|
||||
#ifdef ENABLE_BITTORRENT
|
||||
CPPUNIT_TEST(testAddTorrent);
|
||||
CPPUNIT_TEST(testAddTorrent_withoutTorrent);
|
||||
|
@ -73,6 +74,7 @@ public:
|
|||
void testAddUri_notUri();
|
||||
void testAddUri_withBadOption();
|
||||
void testAddUri_withPosition();
|
||||
void testAddUri_withBadPosition();
|
||||
#ifdef ENABLE_BITTORRENT
|
||||
void testAddTorrent();
|
||||
void testAddTorrent_withoutTorrent();
|
||||
|
@ -178,6 +180,18 @@ void XmlRpcMethodTest::testAddUri_withPosition()
|
|||
CPPUNIT_ASSERT_EQUAL(std::string("http://uri2"), uri);
|
||||
}
|
||||
|
||||
void XmlRpcMethodTest::testAddUri_withBadPosition()
|
||||
{
|
||||
AddUriXmlRpcMethod m;
|
||||
XmlRpcRequest req("aria2.addUri", BDE::list());
|
||||
req._params << BDE::list();
|
||||
req._params[0] << BDE("http://localhost/");
|
||||
req._params << BDE::dict();
|
||||
req._params << BDE((int64_t)-1);
|
||||
XmlRpcResponse res = m.execute(req, _e.get());
|
||||
CPPUNIT_ASSERT_EQUAL(1, res._code);
|
||||
}
|
||||
|
||||
#ifdef ENABLE_BITTORRENT
|
||||
void XmlRpcMethodTest::testAddTorrent()
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue