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:
Tatsuhiro Tsujikawa 2008-02-08 15:53:45 +00:00
parent d82e183d34
commit 1b7c198289
801 changed files with 12024 additions and 8627 deletions

View file

@ -4,8 +4,11 @@
#include "MockBtContext.h"
#include "MockPeerStorage.h"
#include "BtRegistry.h"
#include "FileEntry.h"
#include <cppunit/extensions/HelperMacros.h>
namespace aria2 {
class DHTPeerAnnounceEntryTest:public CppUnit::TestFixture {
CPPUNIT_TEST_SUITE(DHTPeerAnnounceEntryTest);
@ -49,9 +52,9 @@ void DHTPeerAnnounceEntryTest::testRemoveStalePeerAddrEntry()
CPPUNIT_ASSERT_EQUAL((size_t)2, entry.countPeerAddrEntry());
const PeerAddrEntries& peerAdderEntries = entry.getPeerAddrEntries();
CPPUNIT_ASSERT_EQUAL(string("192.168.0.1"), peerAdderEntries[0].getIPAddress());
CPPUNIT_ASSERT_EQUAL(string("192.168.0.3"), peerAdderEntries[1].getIPAddress());
const std::deque<PeerAddrEntry>& peerAddrEntries = entry.getPeerAddrEntries();
CPPUNIT_ASSERT_EQUAL(std::string("192.168.0.1"), peerAddrEntries[0].getIPAddress());
CPPUNIT_ASSERT_EQUAL(std::string("192.168.0.3"), peerAddrEntries[1].getIPAddress());
}
@ -97,20 +100,20 @@ void DHTPeerAnnounceEntryTest::testGetPeers()
unsigned char infohash[DHT_ID_LENGTH];
memset(infohash, 0xff, DHT_ID_LENGTH);
MockBtContextHandle ctx = new MockBtContext();
SharedHandle<MockBtContext> ctx = new MockBtContext();
ctx->setInfoHash(infohash);
MockPeerStorageHandle peerStorage = new MockPeerStorage();
SharedHandle<MockPeerStorage> peerStorage = new MockPeerStorage();
{
PeerHandle activePeers[] = { new Peer("192.168.0.3", 6883),
SharedHandle<Peer> activePeers[] = { new Peer("192.168.0.3", 6883),
new Peer("192.168.0.4", 6884) };
peerStorage->setActivePeers(Peers(&activePeers[0],
&activePeers[2]));
peerStorage->setActivePeers(std::deque<SharedHandle<Peer> >(&activePeers[0],
&activePeers[2]));
}
BtRegistry::registerPeerStorage(ctx->getInfoHashAsString(), peerStorage);
DHTPeerAnnounceEntry entry(infohash);
{
Peers peers = entry.getPeers();
std::deque<SharedHandle<Peer> > peers = entry.getPeers();
CPPUNIT_ASSERT_EQUAL((size_t)0, peers.size());
}
@ -118,24 +121,26 @@ void DHTPeerAnnounceEntryTest::testGetPeers()
entry.addPeerAddrEntry(PeerAddrEntry("192.168.0.2", 6882));
{
Peers peers = entry.getPeers();
std::deque<SharedHandle<Peer> > peers = entry.getPeers();
CPPUNIT_ASSERT_EQUAL((size_t)2, peers.size());
CPPUNIT_ASSERT_EQUAL(string("192.168.0.1"), peers[0]->ipaddr);
CPPUNIT_ASSERT_EQUAL(std::string("192.168.0.1"), peers[0]->ipaddr);
CPPUNIT_ASSERT_EQUAL((uint16_t)6881, peers[0]->port);
CPPUNIT_ASSERT_EQUAL(string("192.168.0.2"), peers[1]->ipaddr);
CPPUNIT_ASSERT_EQUAL(std::string("192.168.0.2"), peers[1]->ipaddr);
CPPUNIT_ASSERT_EQUAL((uint16_t)6882, peers[1]->port);
}
entry.setBtContext(ctx);
{
Peers peers = entry.getPeers();
std::deque<SharedHandle<Peer> > peers = entry.getPeers();
CPPUNIT_ASSERT_EQUAL((size_t)4, peers.size());
CPPUNIT_ASSERT_EQUAL(string("192.168.0.1"), peers[0]->ipaddr);
CPPUNIT_ASSERT_EQUAL(std::string("192.168.0.1"), peers[0]->ipaddr);
CPPUNIT_ASSERT_EQUAL((uint16_t)6881, peers[0]->port);
CPPUNIT_ASSERT_EQUAL(string("192.168.0.2"), peers[1]->ipaddr);
CPPUNIT_ASSERT_EQUAL(std::string("192.168.0.2"), peers[1]->ipaddr);
CPPUNIT_ASSERT_EQUAL((uint16_t)6882, peers[1]->port);
CPPUNIT_ASSERT_EQUAL(string("192.168.0.3"), peers[2]->ipaddr);
CPPUNIT_ASSERT_EQUAL(std::string("192.168.0.3"), peers[2]->ipaddr);
CPPUNIT_ASSERT_EQUAL((uint16_t)6883, peers[2]->port);
CPPUNIT_ASSERT_EQUAL(string("192.168.0.4"), peers[3]->ipaddr);
CPPUNIT_ASSERT_EQUAL(std::string("192.168.0.4"), peers[3]->ipaddr);
CPPUNIT_ASSERT_EQUAL((uint16_t)6884, peers[3]->port);
}
}
} // namespace aria2