mirror of
https://github.com/aria2/aria2.git
synced 2025-04-05 13:37:40 +03:00
make clang-format using clang-format-3.6
This commit is contained in:
parent
4abad2f64c
commit
b1132d6b10
1095 changed files with 30423 additions and 33770 deletions
|
@ -13,13 +13,14 @@
|
|||
|
||||
namespace aria2 {
|
||||
|
||||
class DHTRoutingTableTest:public CppUnit::TestFixture {
|
||||
class DHTRoutingTableTest : public CppUnit::TestFixture {
|
||||
|
||||
CPPUNIT_TEST_SUITE(DHTRoutingTableTest);
|
||||
CPPUNIT_TEST(testAddNode);
|
||||
CPPUNIT_TEST(testAddNode_localNode);
|
||||
CPPUNIT_TEST(testGetClosestKNodes);
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
public:
|
||||
void setUp() {}
|
||||
|
||||
|
@ -30,7 +31,6 @@ public:
|
|||
void testGetClosestKNodes();
|
||||
};
|
||||
|
||||
|
||||
CPPUNIT_TEST_SUITE_REGISTRATION(DHTRoutingTableTest);
|
||||
|
||||
void DHTRoutingTableTest::testAddNode()
|
||||
|
@ -42,8 +42,8 @@ void DHTRoutingTableTest::testAddNode()
|
|||
auto taskQueue = make_unique<MockDHTTaskQueue>();
|
||||
table.setTaskQueue(taskQueue.get());
|
||||
uint32_t count = 0;
|
||||
for(int i = 0; i < 100; ++i) {
|
||||
if(table.addNode(std::make_shared<DHTNode>())) {
|
||||
for (int i = 0; i < 100; ++i) {
|
||||
if (table.addNode(std::make_shared<DHTNode>())) {
|
||||
++count;
|
||||
}
|
||||
}
|
||||
|
@ -64,11 +64,12 @@ void DHTRoutingTableTest::testAddNode_localNode()
|
|||
}
|
||||
|
||||
namespace {
|
||||
void createID(unsigned char* id, unsigned char firstChar, unsigned char lastChar)
|
||||
void createID(unsigned char* id, unsigned char firstChar,
|
||||
unsigned char lastChar)
|
||||
{
|
||||
memset(id, 0, DHT_ID_LENGTH);
|
||||
id[0] = firstChar;
|
||||
id[DHT_ID_LENGTH-1] = lastChar;
|
||||
id[DHT_ID_LENGTH - 1] = lastChar;
|
||||
}
|
||||
} // namespace
|
||||
|
||||
|
@ -83,17 +84,17 @@ void DHTRoutingTableTest::testGetClosestKNodes()
|
|||
std::shared_ptr<DHTNode> nodes1[8];
|
||||
std::shared_ptr<DHTNode> nodes2[8];
|
||||
std::shared_ptr<DHTNode> nodes3[8];
|
||||
for(size_t i = 0; i < DHTBucket::K; ++i) {
|
||||
for (size_t i = 0; i < DHTBucket::K; ++i) {
|
||||
createID(id, 0xf0, i);
|
||||
nodes1[i] = std::make_shared<DHTNode>(id);
|
||||
CPPUNIT_ASSERT(table.addNode(nodes1[i]));
|
||||
}
|
||||
for(size_t i = 0; i < DHTBucket::K; ++i) {
|
||||
for (size_t i = 0; i < DHTBucket::K; ++i) {
|
||||
createID(id, 0x80, i);
|
||||
nodes2[i] = std::make_shared<DHTNode>(id);
|
||||
CPPUNIT_ASSERT(table.addNode(nodes2[i]));
|
||||
}
|
||||
for(size_t i = 0; i < DHTBucket::K; ++i) {
|
||||
for (size_t i = 0; i < DHTBucket::K; ++i) {
|
||||
createID(id, 0x70, i);
|
||||
nodes3[i] = std::make_shared<DHTNode>(id);
|
||||
CPPUNIT_ASSERT(table.addNode(nodes3[i]));
|
||||
|
@ -103,9 +104,9 @@ void DHTRoutingTableTest::testGetClosestKNodes()
|
|||
std::vector<std::shared_ptr<DHTNode>> nodes;
|
||||
table.getClosestKNodes(nodes, id);
|
||||
CPPUNIT_ASSERT_EQUAL((size_t)8, nodes.size());
|
||||
for(size_t i = 0; i < nodes.size(); ++i) {
|
||||
CPPUNIT_ASSERT(memcmp(nodes2[0]->getID(), nodes[0]->getID(),
|
||||
DHT_ID_LENGTH) == 0);
|
||||
for (size_t i = 0; i < nodes.size(); ++i) {
|
||||
CPPUNIT_ASSERT(
|
||||
memcmp(nodes2[0]->getID(), nodes[0]->getID(), DHT_ID_LENGTH) == 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue