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

@ -3,7 +3,7 @@
#include "Exception.h"
#include "Util.h"
#include "DHTNode.h"
#include "a2functional.h"
#include "array_fun.h"
#include "DHTConstants.h"
#include "PeerMessageUtil.h"
#include <arpa/inet.h>
@ -11,6 +11,8 @@
#include <sstream>
#include <cppunit/extensions/HelperMacros.h>
namespace aria2 {
class DHTRoutingTableDeserializerTest:public CppUnit::TestFixture {
CPPUNIT_TEST_SUITE(DHTRoutingTableDeserializerTest);
@ -29,22 +31,22 @@ CPPUNIT_TEST_SUITE_REGISTRATION(DHTRoutingTableDeserializerTest);
void DHTRoutingTableDeserializerTest::testDeserialize()
{
DHTNodeHandle localNode = new DHTNode();
SharedHandle<DHTNode> localNode = new DHTNode();
DHTNodeHandle nodesSrc[] = { 0, 0, 0 };
SharedHandle<DHTNode> nodesSrc[] = { 0, 0, 0 };
for(size_t i = 0; i < arrayLength(nodesSrc); ++i) {
nodesSrc[i] = new DHTNode();
nodesSrc[i]->setIPAddress("192.168.0."+Util::uitos(i+1));
nodesSrc[i]->setPort(6881+i);
}
nodesSrc[1]->setIPAddress("non-numerical-name");
DHTNodes nodes(&nodesSrc[0], &nodesSrc[arrayLength(nodesSrc)]);
std::deque<SharedHandle<DHTNode> > nodes(&nodesSrc[0], &nodesSrc[arrayLength(nodesSrc)]);
DHTRoutingTableSerializer s;
s.setLocalNode(localNode);
s.setNodes(nodes);
stringstream ss;
std::stringstream ss;
s.serialize(ss);
DHTRoutingTableDeserializer d;
@ -53,14 +55,16 @@ void DHTRoutingTableDeserializerTest::testDeserialize()
CPPUNIT_ASSERT(memcmp(localNode->getID(), d.getLocalNode()->getID(),
DHT_ID_LENGTH) == 0);
cout << d.getSerializedTime().getTime() << endl;
std::cout << d.getSerializedTime().getTime() << std::endl;
CPPUNIT_ASSERT_EQUAL((size_t)2, d.getNodes().size());
const DHTNodes& dsnodes = d.getNodes();
CPPUNIT_ASSERT_EQUAL(string("192.168.0.1"), dsnodes[0]->getIPAddress());
const std::deque<SharedHandle<DHTNode> >& dsnodes = d.getNodes();
CPPUNIT_ASSERT_EQUAL(std::string("192.168.0.1"), dsnodes[0]->getIPAddress());
CPPUNIT_ASSERT_EQUAL((uint16_t)6881, dsnodes[0]->getPort());
CPPUNIT_ASSERT(memcmp(nodes[0]->getID(), dsnodes[0]->getID(), DHT_ID_LENGTH) == 0);
CPPUNIT_ASSERT_EQUAL(string("192.168.0.3"), dsnodes[1]->getIPAddress());
CPPUNIT_ASSERT_EQUAL(std::string("192.168.0.3"), dsnodes[1]->getIPAddress());
CPPUNIT_ASSERT_EQUAL((uint16_t)6883, dsnodes[1]->getPort());
CPPUNIT_ASSERT(memcmp(nodes[2]->getID(), dsnodes[1]->getID(), DHT_ID_LENGTH) == 0);
}
} // namespace aria2