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
|
@ -27,7 +27,7 @@
|
|||
|
||||
namespace aria2 {
|
||||
|
||||
class DefaultExtensionMessageFactoryTest:public CppUnit::TestFixture {
|
||||
class DefaultExtensionMessageFactoryTest : public CppUnit::TestFixture {
|
||||
|
||||
CPPUNIT_TEST_SUITE(DefaultExtensionMessageFactoryTest);
|
||||
CPPUNIT_TEST(testCreateMessage_unknown);
|
||||
|
@ -37,6 +37,7 @@ class DefaultExtensionMessageFactoryTest:public CppUnit::TestFixture {
|
|||
CPPUNIT_TEST(testCreateMessage_UTMetadataData);
|
||||
CPPUNIT_TEST(testCreateMessage_UTMetadataReject);
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
private:
|
||||
std::unique_ptr<MockPeerStorage> peerStorage_;
|
||||
std::shared_ptr<Peer> peer_;
|
||||
|
@ -46,6 +47,7 @@ private:
|
|||
std::unique_ptr<MockBtMessageFactory> messageFactory_;
|
||||
std::shared_ptr<DownloadContext> dctx_;
|
||||
std::unique_ptr<RequestGroup> requestGroup_;
|
||||
|
||||
public:
|
||||
void setUp()
|
||||
{
|
||||
|
@ -74,17 +76,17 @@ public:
|
|||
|
||||
std::string getExtensionMessageID(int key)
|
||||
{
|
||||
unsigned char id[1] = { registry_->getExtensionMessageID(key) };
|
||||
unsigned char id[1] = {registry_->getExtensionMessageID(key)};
|
||||
return std::string(&id[0], &id[1]);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
template <typename T>
|
||||
std::shared_ptr<T> createMessage(const std::string& data)
|
||||
{
|
||||
auto m = factory_->createMessage
|
||||
(reinterpret_cast<const unsigned char*>(data.c_str()), data.size());
|
||||
return std::dynamic_pointer_cast<T>(std::shared_ptr<T>
|
||||
{static_cast<T*>(m.release())});
|
||||
auto m = factory_->createMessage(
|
||||
reinterpret_cast<const unsigned char*>(data.c_str()), data.size());
|
||||
return std::dynamic_pointer_cast<T>(
|
||||
std::shared_ptr<T>{static_cast<T*>(m.release())});
|
||||
}
|
||||
|
||||
void testCreateMessage_unknown();
|
||||
|
@ -101,24 +103,25 @@ void DefaultExtensionMessageFactoryTest::testCreateMessage_unknown()
|
|||
{
|
||||
peer_->setExtension(ExtensionMessageRegistry::UT_PEX, 255);
|
||||
|
||||
unsigned char id[1] = { 255 };
|
||||
unsigned char id[1] = {255};
|
||||
|
||||
std::string data = std::string(&id[0], &id[1]);
|
||||
try {
|
||||
// this test fails because localhost doesn't have extension id = 255.
|
||||
factory_->createMessage
|
||||
(reinterpret_cast<const unsigned char*>(data.c_str()), data.size());
|
||||
factory_->createMessage(
|
||||
reinterpret_cast<const unsigned char*>(data.c_str()), data.size());
|
||||
CPPUNIT_FAIL("exception must be thrown.");
|
||||
} catch(Exception& e) {
|
||||
}
|
||||
catch (Exception& e) {
|
||||
std::cerr << e.stackTrace() << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
void DefaultExtensionMessageFactoryTest::testCreateMessage_Handshake()
|
||||
{
|
||||
char id[1] = { 0 };
|
||||
char id[1] = {0};
|
||||
|
||||
std::string data = std::string(&id[0], &id[1])+"d1:v5:aria2e";
|
||||
std::string data = std::string(&id[0], &id[1]) + "d1:v5:aria2e";
|
||||
auto m = createMessage<HandshakeExtensionMessage>(data);
|
||||
CPPUNIT_ASSERT_EQUAL(std::string("aria2"), m->getClientVersion());
|
||||
}
|
||||
|
@ -132,30 +135,29 @@ void DefaultExtensionMessageFactoryTest::testCreateMessage_UTPex()
|
|||
bittorrent::packcompact(c1, "192.168.0.1", 6881);
|
||||
bittorrent::packcompact(c2, "10.1.1.2", 9999);
|
||||
bittorrent::packcompact(c3, "192.168.0.2", 6882);
|
||||
bittorrent::packcompact(c4, "10.1.1.3",10000);
|
||||
bittorrent::packcompact(c4, "10.1.1.3", 10000);
|
||||
|
||||
registry_->setExtensionMessageID(ExtensionMessageRegistry::UT_PEX, 1);
|
||||
|
||||
std::string data = getExtensionMessageID(ExtensionMessageRegistry::UT_PEX)
|
||||
+"d5:added12:"+
|
||||
std::string(&c1[0], &c1[6])+std::string(&c2[0], &c2[6])+
|
||||
"7:added.f2:207:dropped12:"+
|
||||
std::string(&c3[0], &c3[6])+std::string(&c4[0], &c4[6])+
|
||||
"e";
|
||||
std::string data = getExtensionMessageID(ExtensionMessageRegistry::UT_PEX) +
|
||||
"d5:added12:" + std::string(&c1[0], &c1[6]) +
|
||||
std::string(&c2[0], &c2[6]) + "7:added.f2:207:dropped12:" +
|
||||
std::string(&c3[0], &c3[6]) + std::string(&c4[0], &c4[6]) +
|
||||
"e";
|
||||
|
||||
auto m = createMessage<UTPexExtensionMessage>(data);
|
||||
CPPUNIT_ASSERT_EQUAL(registry_->getExtensionMessageID
|
||||
(ExtensionMessageRegistry::UT_PEX),
|
||||
m->getExtensionMessageID());
|
||||
CPPUNIT_ASSERT_EQUAL(
|
||||
registry_->getExtensionMessageID(ExtensionMessageRegistry::UT_PEX),
|
||||
m->getExtensionMessageID());
|
||||
}
|
||||
|
||||
void DefaultExtensionMessageFactoryTest::testCreateMessage_UTMetadataRequest()
|
||||
{
|
||||
registry_->setExtensionMessageID(ExtensionMessageRegistry::UT_METADATA, 1);
|
||||
|
||||
std::string data = getExtensionMessageID
|
||||
(ExtensionMessageRegistry::UT_METADATA)+
|
||||
"d8:msg_typei0e5:piecei1ee";
|
||||
std::string data =
|
||||
getExtensionMessageID(ExtensionMessageRegistry::UT_METADATA) +
|
||||
"d8:msg_typei0e5:piecei1ee";
|
||||
auto m = createMessage<UTMetadataRequestExtensionMessage>(data);
|
||||
CPPUNIT_ASSERT_EQUAL((size_t)1, m->getIndex());
|
||||
}
|
||||
|
@ -164,9 +166,9 @@ void DefaultExtensionMessageFactoryTest::testCreateMessage_UTMetadataData()
|
|||
{
|
||||
registry_->setExtensionMessageID(ExtensionMessageRegistry::UT_METADATA, 1);
|
||||
|
||||
std::string data = getExtensionMessageID
|
||||
(ExtensionMessageRegistry::UT_METADATA)+
|
||||
"d8:msg_typei1e5:piecei1e10:total_sizei300ee0000000000";
|
||||
std::string data =
|
||||
getExtensionMessageID(ExtensionMessageRegistry::UT_METADATA) +
|
||||
"d8:msg_typei1e5:piecei1e10:total_sizei300ee0000000000";
|
||||
auto m = createMessage<UTMetadataDataExtensionMessage>(data);
|
||||
CPPUNIT_ASSERT_EQUAL((size_t)1, m->getIndex());
|
||||
CPPUNIT_ASSERT_EQUAL((size_t)300, m->getTotalSize());
|
||||
|
@ -177,9 +179,9 @@ void DefaultExtensionMessageFactoryTest::testCreateMessage_UTMetadataReject()
|
|||
{
|
||||
registry_->setExtensionMessageID(ExtensionMessageRegistry::UT_METADATA, 1);
|
||||
|
||||
std::string data = getExtensionMessageID
|
||||
(ExtensionMessageRegistry::UT_METADATA)+
|
||||
"d8:msg_typei2e5:piecei1ee";
|
||||
std::string data =
|
||||
getExtensionMessageID(ExtensionMessageRegistry::UT_METADATA) +
|
||||
"d8:msg_typei2e5:piecei1ee";
|
||||
auto m = createMessage<UTMetadataRejectExtensionMessage>(data);
|
||||
CPPUNIT_ASSERT_EQUAL((size_t)1, m->getIndex());
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue