Rewritten DHTRoutingTableDeserializer using stdio instead of stream.

This commit is contained in:
Tatsuhiro Tsujikawa 2011-08-05 20:17:19 +09:00
parent 5eb338ad87
commit f141cd4228
4 changed files with 49 additions and 65 deletions

View file

@ -54,11 +54,13 @@ void DHTRoutingTableDeserializerTest::testDeserialize()
s.setLocalNode(localNode);
s.setNodes(nodes);
std::stringstream ss;
s.serialize(ss);
std::string filename = A2_TEST_OUT_DIR"/aria2_DHTRoutingTableDeserializerTest_testDeserialize";
std::ofstream outfile(filename.c_str(), std::ios::binary);
s.serialize(outfile);
outfile.close();
DHTRoutingTableDeserializer d(AF_INET);
d.deserialize(ss);
d.deserialize(filename);
CPPUNIT_ASSERT(memcmp(localNode->getID(), d.getLocalNode()->getID(),
DHT_ID_LENGTH) == 0);
@ -93,11 +95,13 @@ void DHTRoutingTableDeserializerTest::testDeserialize6()
s.setLocalNode(localNode);
s.setNodes(nodes);
std::stringstream ss;
s.serialize(ss);
std::string filename = A2_TEST_OUT_DIR"/aria2_DHTRoutingTableDeserializerTest_testDeserialize6";
std::ofstream outfile(filename.c_str(), std::ios::binary);
s.serialize(outfile);
outfile.close();
DHTRoutingTableDeserializer d(AF_INET6);
d.deserialize(ss);
d.deserialize(filename);
CPPUNIT_ASSERT(memcmp(localNode->getID(), d.getLocalNode()->getID(),
DHT_ID_LENGTH) == 0);