mirror of
https://github.com/aria2/aria2.git
synced 2025-04-05 21:47:37 +03:00
2008-02-08 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Removed "using namespace std;" from all sources. Appended std:: prefix to c++ standard classes. Included string.h where mem* function are used.
This commit is contained in:
parent
d82e183d34
commit
1b7c198289
801 changed files with 12024 additions and 8627 deletions
|
@ -2,9 +2,13 @@
|
|||
#include "DefaultBtContext.h"
|
||||
#include "Util.h"
|
||||
#include "Exception.h"
|
||||
#include "Peer.h"
|
||||
#include "Option.h"
|
||||
#include "BtRuntime.h"
|
||||
#include <algorithm>
|
||||
#include <cppunit/extensions/HelperMacros.h>
|
||||
|
||||
using namespace std;
|
||||
namespace aria2 {
|
||||
|
||||
class DefaultPeerStorageTest:public CppUnit::TestFixture {
|
||||
|
||||
|
@ -20,17 +24,17 @@ class DefaultPeerStorageTest:public CppUnit::TestFixture {
|
|||
CPPUNIT_TEST(testOnErasingPeer);
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
private:
|
||||
BtContextHandle btContext;
|
||||
BtRuntimeHandle btRuntime;
|
||||
SharedHandle<BtContext> btContext;
|
||||
SharedHandle<BtRuntime> btRuntime;
|
||||
Option* option;
|
||||
public:
|
||||
DefaultPeerStorageTest():btContext(0) {}
|
||||
|
||||
void setUp() {
|
||||
btContext = BtContextHandle(new DefaultBtContext());
|
||||
btContext = new DefaultBtContext();
|
||||
btContext->load("test.torrent");
|
||||
option = new Option();
|
||||
btRuntime = BtRuntimeHandle(new BtRuntime());
|
||||
btRuntime = SharedHandle<BtRuntime>(new BtRuntime());
|
||||
}
|
||||
|
||||
void testCountPeer();
|
||||
|
@ -53,7 +57,7 @@ void DefaultPeerStorageTest::testCountPeer() {
|
|||
CPPUNIT_ASSERT_EQUAL((int32_t)0,
|
||||
ps.countPeer());
|
||||
|
||||
PeerHandle peer(new Peer("192.168.0.1", 6889));
|
||||
SharedHandle<Peer> peer(new Peer("192.168.0.1", 6889));
|
||||
|
||||
ps.addPeer(peer);
|
||||
CPPUNIT_ASSERT_EQUAL((int32_t)1,
|
||||
|
@ -63,9 +67,9 @@ void DefaultPeerStorageTest::testCountPeer() {
|
|||
void DefaultPeerStorageTest::testDeleteUnusedPeer() {
|
||||
DefaultPeerStorage ps(btContext, option);
|
||||
|
||||
PeerHandle peer1(new Peer("192.168.0.1", 6889));
|
||||
PeerHandle peer2(new Peer("192.168.0.2", 6889));
|
||||
PeerHandle peer3(new Peer("192.168.0.3", 6889));
|
||||
SharedHandle<Peer> peer1(new Peer("192.168.0.1", 6889));
|
||||
SharedHandle<Peer> peer2(new Peer("192.168.0.2", 6889));
|
||||
SharedHandle<Peer> peer3(new Peer("192.168.0.3", 6889));
|
||||
|
||||
ps.addPeer(peer1);
|
||||
ps.addPeer(peer2);
|
||||
|
@ -74,7 +78,7 @@ void DefaultPeerStorageTest::testDeleteUnusedPeer() {
|
|||
ps.deleteUnusedPeer(2);
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL((int32_t)1, ps.countPeer());
|
||||
CPPUNIT_ASSERT_EQUAL(string("192.168.0.3"),
|
||||
CPPUNIT_ASSERT_EQUAL(std::string("192.168.0.3"),
|
||||
ps.getPeer("192.168.0.3", 6889)->ipaddr);
|
||||
|
||||
ps.addPeer(peer1);
|
||||
|
@ -86,7 +90,7 @@ void DefaultPeerStorageTest::testDeleteUnusedPeer() {
|
|||
|
||||
// peer2 has been in use, so it did't deleted.
|
||||
CPPUNIT_ASSERT_EQUAL((int32_t)1, ps.countPeer());
|
||||
CPPUNIT_ASSERT_EQUAL(string("192.168.0.2"),
|
||||
CPPUNIT_ASSERT_EQUAL(std::string("192.168.0.2"),
|
||||
ps.getPeer("192.168.0.2", 6889)->ipaddr);
|
||||
|
||||
}
|
||||
|
@ -94,9 +98,9 @@ void DefaultPeerStorageTest::testDeleteUnusedPeer() {
|
|||
void DefaultPeerStorageTest::testAddPeer() {
|
||||
DefaultPeerStorage ps(btContext, option);
|
||||
|
||||
PeerHandle peer1(new Peer("192.168.0.1", 6889));
|
||||
PeerHandle peer2(new Peer("192.168.0.2", 6889));
|
||||
PeerHandle peer3(new Peer("192.168.0.3", 6889));
|
||||
SharedHandle<Peer> peer1(new Peer("192.168.0.1", 6889));
|
||||
SharedHandle<Peer> peer2(new Peer("192.168.0.2", 6889));
|
||||
SharedHandle<Peer> peer3(new Peer("192.168.0.3", 6889));
|
||||
|
||||
ps.addPeer(peer1);
|
||||
ps.addPeer(peer2);
|
||||
|
@ -111,15 +115,15 @@ void DefaultPeerStorageTest::testAddPeer() {
|
|||
|
||||
ps.setMaxPeerListSize(3);
|
||||
|
||||
PeerHandle peer4(new Peer("192.168.0.4", 6889));
|
||||
SharedHandle<Peer> peer4(new Peer("192.168.0.4", 6889));
|
||||
|
||||
peer1->cuid = 1;
|
||||
CPPUNIT_ASSERT(ps.addPeer(peer4));
|
||||
// peer2 was deleted. While peer1 is oldest, its cuid is not 0.
|
||||
CPPUNIT_ASSERT_EQUAL((int32_t)3, ps.countPeer());
|
||||
CPPUNIT_ASSERT(find(ps.getPeers().begin(), ps.getPeers().end(), peer2) == ps.getPeers().end());
|
||||
CPPUNIT_ASSERT(std::find(ps.getPeers().begin(), ps.getPeers().end(), peer2) == ps.getPeers().end());
|
||||
|
||||
PeerHandle peer5(new Peer("192.168.0.4", 0));
|
||||
SharedHandle<Peer> peer5(new Peer("192.168.0.4", 0));
|
||||
|
||||
peer5->port = 6889;
|
||||
|
||||
|
@ -131,11 +135,11 @@ void DefaultPeerStorageTest::testGetUnusedPeer() {
|
|||
DefaultPeerStorage ps(btContext, option);
|
||||
ps.setBtRuntime(btRuntime);
|
||||
|
||||
PeerHandle peer1(new Peer("192.168.0.1", 6889));
|
||||
SharedHandle<Peer> peer1(new Peer("192.168.0.1", 6889));
|
||||
|
||||
ps.addPeer(peer1);
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(string("192.168.0.1"),
|
||||
CPPUNIT_ASSERT_EQUAL(std::string("192.168.0.1"),
|
||||
ps.getUnusedPeer()->ipaddr);
|
||||
|
||||
peer1->cuid = 1;
|
||||
|
@ -154,7 +158,7 @@ void DefaultPeerStorageTest::testIsPeerAvailable() {
|
|||
|
||||
CPPUNIT_ASSERT_EQUAL(false, ps.isPeerAvailable());
|
||||
|
||||
PeerHandle peer1(new Peer("192.168.0.1", 6889));
|
||||
SharedHandle<Peer> peer1(new Peer("192.168.0.1", 6889));
|
||||
|
||||
ps.addPeer(peer1);
|
||||
|
||||
|
@ -176,11 +180,11 @@ void DefaultPeerStorageTest::testActivatePeer() {
|
|||
|
||||
CPPUNIT_ASSERT_EQUAL((size_t)0, ps.getActivePeers().size());
|
||||
|
||||
PeerHandle peer1(new Peer("192.168.0.1", 6889));
|
||||
SharedHandle<Peer> peer1(new Peer("192.168.0.1", 6889));
|
||||
|
||||
ps.addPeer(peer1);
|
||||
|
||||
Peers activePeer = ps.getActivePeers();
|
||||
std::deque<SharedHandle<Peer> > activePeer = ps.getActivePeers();
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL((size_t)0, ps.getActivePeers().size());
|
||||
|
||||
|
@ -196,24 +200,26 @@ void DefaultPeerStorageTest::testReturnPeer()
|
|||
{
|
||||
DefaultPeerStorage ps(btContext, option);
|
||||
|
||||
PeerHandle peer1(new Peer("192.168.0.1", 0));
|
||||
PeerHandle peer2(new Peer("192.168.0.2", 6889));
|
||||
PeerHandle peer3(new Peer("192.168.0.1", 6889));
|
||||
SharedHandle<Peer> peer1(new Peer("192.168.0.1", 0));
|
||||
SharedHandle<Peer> peer2(new Peer("192.168.0.2", 6889));
|
||||
SharedHandle<Peer> peer3(new Peer("192.168.0.1", 6889));
|
||||
ps.addPeer(peer1);
|
||||
ps.addPeer(peer2);
|
||||
ps.addPeer(peer3);
|
||||
|
||||
ps.returnPeer(peer2);
|
||||
// peer2 is moved to the end of container
|
||||
CPPUNIT_ASSERT_EQUAL(string("192.168.0.2"),
|
||||
CPPUNIT_ASSERT_EQUAL(std::string("192.168.0.2"),
|
||||
ps.getPeers().back()->ipaddr);
|
||||
|
||||
ps.returnPeer(peer1); // peer1 is removed from the container
|
||||
CPPUNIT_ASSERT_EQUAL((size_t)2, ps.getPeers().size());
|
||||
CPPUNIT_ASSERT(find(ps.getPeers().begin(), ps.getPeers().end(), peer1) == ps.getPeers().end());
|
||||
CPPUNIT_ASSERT(std::find(ps.getPeers().begin(), ps.getPeers().end(), peer1) == ps.getPeers().end());
|
||||
}
|
||||
|
||||
void DefaultPeerStorageTest::testOnErasingPeer()
|
||||
{
|
||||
// test this
|
||||
}
|
||||
|
||||
} // namespace aria2
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue