diff options
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() |
