mirror of
https://github.com/aria2/aria2.git
synced 2025-04-05 13:37:40 +03:00
gcc 3.4.4 support: * src/DefaultBtContext.cc: int32_t -> int * src/main.cc: int -> int32_t, int32_t -> int * src/messageDigest.h: uint32_t -> unsigned int * src/NameResolver.h: int32_t -> int * src/PeerConnection.cc: int -> int32_t * src/SpeedCalc.cc: int32_t -> int * src/TrackerUpdateCommand.h: int -> int32_t * src/Util.cc: int32_t -> int * src/Util.h: int32_t -> int * src/Xml2MetalinkProcessor.cc: int -> uint32_t, int64_t -> uint64_t * test/AnnounceListTest.cc: int -> int32_t * test/ChunkedEncodingTest.cc: int -> int32_t * test/DataTest.cc: int -> int32_t * test/DefaultBtRequestFactoryTest.cc: int -> int32_t * test/DefaultPeerListProcessorTest.cc: int -> int32_t * test/DefaultPieceStorageTest.cc: int -> int32_t * test/FeatureConfigTest.cc: int -> int32_t * test/MetalinkEntryTest.cc: int -> int32_t * test/MockBtRequestFactory.h: int -> int32_t * test/MockPieceStorage.h: int -> int32_t * test/OptionTest.cc: int -> int32_t * test/RequestTest.cc: int -> int32_t * test/SegmentManTest.cc: int -> int32_t * test/Xml2MetalinkProcessorTest.cc: int -> int32_t
57 lines
1.9 KiB
C++
57 lines
1.9 KiB
C++
#include "DefaultPeerListProcessor.h"
|
|
#include "MetaFileUtil.h"
|
|
#include "Exception.h"
|
|
#include <cppunit/extensions/HelperMacros.h>
|
|
|
|
using namespace std;
|
|
|
|
class DefaultPeerListProcessorTest:public CppUnit::TestFixture {
|
|
|
|
CPPUNIT_TEST_SUITE(DefaultPeerListProcessorTest);
|
|
CPPUNIT_TEST(testExtractPeer);
|
|
CPPUNIT_TEST(testExtract2Peers);
|
|
CPPUNIT_TEST_SUITE_END();
|
|
private:
|
|
|
|
public:
|
|
void setUp() {
|
|
}
|
|
|
|
void testExtractPeer();
|
|
void testExtract2Peers();
|
|
};
|
|
|
|
|
|
CPPUNIT_TEST_SUITE_REGISTRATION( DefaultPeerListProcessorTest );
|
|
|
|
void DefaultPeerListProcessorTest::testExtractPeer() {
|
|
DefaultPeerListProcessor proc(1024*1024, 10*1024*1024);
|
|
string peersString = "d5:peersld2:ip11:192.168.0.17:peer id20:aria2-000000000000004:porti2006eeee";
|
|
|
|
Dictionary* dic = (Dictionary*)MetaFileUtil::bdecoding(peersString.c_str(), peersString.size());
|
|
|
|
CPPUNIT_ASSERT(proc.canHandle(dic->get("peers")));
|
|
|
|
Peers peers = proc.extractPeer(dic->get("peers"));
|
|
CPPUNIT_ASSERT_EQUAL((size_t)1, peers.size());
|
|
PeerHandle peer = *peers.begin();
|
|
CPPUNIT_ASSERT_EQUAL(string("192.168.0.1"), peer->ipaddr);
|
|
CPPUNIT_ASSERT_EQUAL((int32_t)2006, peer->port);
|
|
}
|
|
|
|
void DefaultPeerListProcessorTest::testExtract2Peers() {
|
|
DefaultPeerListProcessor proc(1024*1024, 10*1024*1024);
|
|
string peersString = "d5:peersld2:ip11:192.168.0.17:peer id20:aria2-000000000000004:porti2006eed2:ip11:192.168.0.27:peer id20:aria2-000000000000004:porti2007eeee";
|
|
|
|
Dictionary* dic = (Dictionary*)MetaFileUtil::bdecoding(peersString.c_str(), peersString.size());
|
|
|
|
Peers peers = proc.extractPeer(dic->get("peers"));
|
|
CPPUNIT_ASSERT_EQUAL((size_t)2, peers.size());
|
|
PeerHandle peer = *peers.begin();
|
|
CPPUNIT_ASSERT_EQUAL(string("192.168.0.1"), peer->ipaddr);
|
|
CPPUNIT_ASSERT_EQUAL((int32_t)2006, peer->port);
|
|
|
|
peer = *(peers.begin()+1);
|
|
CPPUNIT_ASSERT_EQUAL(string("192.168.0.2"), peer->ipaddr);
|
|
CPPUNIT_ASSERT_EQUAL((int32_t)2007, peer->port);
|
|
}
|