diff options
| author | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2016-05-22 20:57:33 +0900 |
|---|---|---|
| committer | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2016-05-22 20:57:33 +0900 |
| commit | 9d40c47799bbec12bb02f7579736fbc1fcc35c08 (patch) | |
| tree | 0ef02a9f17d6550667aa745829ff5146b1ccf6a6 /test/BtHandshakeMessageTest.cc | |
| parent | 9727b5b256bb12cff42e6aa230ba2020a933562f (diff) | |
| parent | 0b906f40f1204e79cb43af3867468ab02a371075 (diff) | |
Merge branch 'master' into dynamic-select-file
Diffstat (limited to 'test/BtHandshakeMessageTest.cc')
| -rw-r--r-- | test/BtHandshakeMessageTest.cc | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/test/BtHandshakeMessageTest.cc b/test/BtHandshakeMessageTest.cc index a86ae54a..b8569d73 100644 --- a/test/BtHandshakeMessageTest.cc +++ b/test/BtHandshakeMessageTest.cc @@ -73,23 +73,23 @@ void BtHandshakeMessageTest::testCreate() void BtHandshakeMessageTest::testCreateMessage() { - unsigned char infoHash[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; - unsigned char peerId[] = {0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, - 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, - 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0}; - - std::shared_ptr<BtHandshakeMessage> msg(new BtHandshakeMessage()); + constexpr unsigned char infoHash[] = { + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; + constexpr unsigned char peerId[] = {0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, + 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, + 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0}; + + auto msg = std::make_shared<BtHandshakeMessage>(); msg->setInfoHash(infoHash); msg->setPeerId(peerId); unsigned char data[68]; createHandshakeMessageData(data); - unsigned char* rawmsg = msg->createMessage(); + auto rawmsg = msg->createMessage(); + CPPUNIT_ASSERT_EQUAL((size_t)68, rawmsg.size()); CPPUNIT_ASSERT_EQUAL(util::toHex((const unsigned char*)data, 68), - util::toHex(rawmsg, 68)); - delete[] rawmsg; + util::toHex(rawmsg.data(), 68)); } void BtHandshakeMessageTest::testToString() |
