make clang-format using clang-format-3.6

This commit is contained in:
Tatsuhiro Tsujikawa 2015-12-27 18:39:47 +09:00
parent 4abad2f64c
commit b1132d6b10
1095 changed files with 30423 additions and 33770 deletions

View file

@ -14,7 +14,7 @@
namespace aria2 {
class HandshakeExtensionMessageTest:public CppUnit::TestFixture {
class HandshakeExtensionMessageTest : public CppUnit::TestFixture {
CPPUNIT_TEST_SUITE(HandshakeExtensionMessageTest);
CPPUNIT_TEST(testGetExtensionMessageID);
@ -25,6 +25,7 @@ class HandshakeExtensionMessageTest:public CppUnit::TestFixture {
CPPUNIT_TEST(testCreate);
CPPUNIT_TEST(testCreate_stringnum);
CPPUNIT_TEST_SUITE_END();
public:
void setUp() {}
@ -39,7 +40,6 @@ public:
void testCreate_stringnum();
};
CPPUNIT_TEST_SUITE_REGISTRATION(HandshakeExtensionMessageTest);
void HandshakeExtensionMessageTest::testGetExtensionMessageID()
@ -63,17 +63,16 @@ void HandshakeExtensionMessageTest::testGetBencodedData()
msg.setExtension(ExtensionMessageRegistry::UT_PEX, 1);
msg.setExtension(ExtensionMessageRegistry::UT_METADATA, 2);
msg.setMetadataSize(1_k);
CPPUNIT_ASSERT_EQUAL
(std::string("d"
"1:md11:ut_metadatai2e6:ut_pexi1ee"
"13:metadata_sizei1024e"
"1:pi6889e"
"1:v5:aria2"
"e"), msg.getPayload());
CPPUNIT_ASSERT_EQUAL(std::string("d"
"1:md11:ut_metadatai2e6:ut_pexi1ee"
"13:metadata_sizei1024e"
"1:pi6889e"
"1:v5:aria2"
"e"),
msg.getPayload());
msg.setMetadataSize(0);
CPPUNIT_ASSERT
(msg.getPayload().find("metadata_size") == std::string::npos);
CPPUNIT_ASSERT(msg.getPayload().find("metadata_size") == std::string::npos);
}
void HandshakeExtensionMessageTest::testToString()
@ -84,9 +83,10 @@ void HandshakeExtensionMessageTest::testToString()
msg.setExtension(ExtensionMessageRegistry::UT_PEX, 1);
msg.setExtension(ExtensionMessageRegistry::UT_METADATA, 2);
msg.setMetadataSize(1_k);
CPPUNIT_ASSERT_EQUAL
(std::string("handshake client=aria2, tcpPort=6889, metadataSize=1024,"
" ut_metadata=2, ut_pex=1"), msg.toString());
CPPUNIT_ASSERT_EQUAL(
std::string("handshake client=aria2, tcpPort=6889, metadataSize=1024,"
" ut_metadata=2, ut_pex=1"),
msg.toString());
}
void HandshakeExtensionMessageTest::testDoReceivedAction()
@ -113,12 +113,10 @@ void HandshakeExtensionMessageTest::testDoReceivedAction()
msg.doReceivedAction();
CPPUNIT_ASSERT_EQUAL((uint16_t)6889, peer->getPort());
CPPUNIT_ASSERT_EQUAL((uint8_t)1,
peer->getExtensionMessageID
(ExtensionMessageRegistry::UT_PEX));
CPPUNIT_ASSERT_EQUAL((uint8_t)3,
peer->getExtensionMessageID
(ExtensionMessageRegistry::UT_METADATA));
CPPUNIT_ASSERT_EQUAL((uint8_t)1, peer->getExtensionMessageID(
ExtensionMessageRegistry::UT_PEX));
CPPUNIT_ASSERT_EQUAL((uint8_t)3, peer->getExtensionMessageID(
ExtensionMessageRegistry::UT_METADATA));
CPPUNIT_ASSERT(peer->isSeeder());
auto attrs = bittorrent::getTorrentAttrs(dctx);
CPPUNIT_ASSERT_EQUAL((size_t)1_k, attrs->metadataSize);
@ -136,42 +134,43 @@ void HandshakeExtensionMessageTest::testDoReceivedAction()
void HandshakeExtensionMessageTest::testCreate()
{
std::string in =
"0d1:pi6881e1:v5:aria21:md5:a2dhti2e6:ut_pexi1ee13:metadata_sizei1024ee";
std::shared_ptr<HandshakeExtensionMessage> m
(HandshakeExtensionMessage::create
(reinterpret_cast<const unsigned char*>(in.c_str()),
in.size()));
"0d1:pi6881e1:v5:aria21:md5:a2dhti2e6:ut_pexi1ee13:metadata_sizei1024ee";
std::shared_ptr<HandshakeExtensionMessage> m(
HandshakeExtensionMessage::create(
reinterpret_cast<const unsigned char*>(in.c_str()), in.size()));
CPPUNIT_ASSERT_EQUAL(std::string("aria2"), m->getClientVersion());
CPPUNIT_ASSERT_EQUAL((uint16_t)6881, m->getTCPPort());
CPPUNIT_ASSERT_EQUAL((uint8_t)1,
m->getExtensionMessageID
(ExtensionMessageRegistry::UT_PEX));
CPPUNIT_ASSERT_EQUAL(
(uint8_t)1, m->getExtensionMessageID(ExtensionMessageRegistry::UT_PEX));
CPPUNIT_ASSERT_EQUAL((size_t)1_k, m->getMetadataSize());
try {
// bad payload format
std::string in = "011:hello world";
HandshakeExtensionMessage::create(reinterpret_cast<const unsigned char*>(in.c_str()),
in.size());
HandshakeExtensionMessage::create(
reinterpret_cast<const unsigned char*>(in.c_str()), in.size());
CPPUNIT_FAIL("exception must be thrown.");
} catch(Exception& e) {
}
catch (Exception& e) {
std::cerr << e.stackTrace() << std::endl;
}
try {
// malformed dencoded message
std::string in = "011:hello";
HandshakeExtensionMessage::create(reinterpret_cast<const unsigned char*>(in.c_str()),
in.size());
HandshakeExtensionMessage::create(
reinterpret_cast<const unsigned char*>(in.c_str()), in.size());
CPPUNIT_FAIL("exception must be thrown.");
} catch(Exception& e) {
}
catch (Exception& e) {
std::cerr << e.stackTrace() << std::endl;
}
try {
// 0 length data
std::string in = "";
HandshakeExtensionMessage::create(reinterpret_cast<const unsigned char*>(in.c_str()),
in.size());
HandshakeExtensionMessage::create(
reinterpret_cast<const unsigned char*>(in.c_str()), in.size());
CPPUNIT_FAIL("exception must be thrown.");
} catch(Exception& e) {
}
catch (Exception& e) {
std::cerr << e.stackTrace() << std::endl;
}
}
@ -179,17 +178,15 @@ void HandshakeExtensionMessageTest::testCreate()
void HandshakeExtensionMessageTest::testCreate_stringnum()
{
std::string in = "0d1:p4:68811:v5:aria21:md6:ut_pex1:1ee";
std::shared_ptr<HandshakeExtensionMessage> m
(HandshakeExtensionMessage::create
(reinterpret_cast<const unsigned char*>(in.c_str()),
in.size()));
std::shared_ptr<HandshakeExtensionMessage> m(
HandshakeExtensionMessage::create(
reinterpret_cast<const unsigned char*>(in.c_str()), in.size()));
CPPUNIT_ASSERT_EQUAL(std::string("aria2"), m->getClientVersion());
// port number in string is not allowed
CPPUNIT_ASSERT_EQUAL((uint16_t)0, m->getTCPPort());
// extension ID in string is not allowed
CPPUNIT_ASSERT_EQUAL((uint8_t)0,
m->getExtensionMessageID
(ExtensionMessageRegistry::UT_PEX));
CPPUNIT_ASSERT_EQUAL(
(uint8_t)0, m->getExtensionMessageID(ExtensionMessageRegistry::UT_PEX));
}
} // namespace aria2