mirror of
https://github.com/aria2/aria2.git
synced 2025-01-08 11:01:38 +00:00
8b73c2843f
Reduced copying/std::string instantiation in sending/receiving BitTorrent messages. * src/BtBitfieldMessage.cc * src/BtBitfieldMessage.h * src/BtExtendedMessage.cc * src/BtExtendedMessage.h * src/BtHandshakeMessage.cc * src/BtHandshakeMessage.h * src/BtKeepAliveMessage.cc * src/BtKeepAliveMessage.h * src/BtPieceMessage.cc * src/BtPieceMessage.h * src/BtPortMessage.cc * src/BtPortMessage.h * src/BtUnchokeMessage.h * src/DefaultBtMessageReceiver.cc * src/IndexBtMessage.cc * src/IndexBtMessage.h * src/PeerConnection.cc * src/PeerConnection.h * src/RangeBtMessage.cc * src/RangeBtMessage.h * src/SimpleBtMessage.cc * src/SimpleBtMessage.h * src/SocketBuffer.cc * src/SocketBuffer.h * src/ZeroBtMessage.cc * src/ZeroBtMessage.h * test/BtAllowedFastMessageTest.cc * test/BtBitfieldMessageTest.cc * test/BtCancelMessageTest.cc * test/BtChokeMessageTest.cc * test/BtExtendedMessageTest.cc * test/BtHandshakeMessageTest.cc * test/BtHaveAllMessageTest.cc * test/BtHaveMessageTest.cc * test/BtHaveNoneMessageTest.cc * test/BtInterestedMessageTest.cc * test/BtKeepAliveMessageTest.cc * test/BtNotInterestedMessageTest.cc * test/BtPieceMessageTest.cc * test/BtPortMessageTest.cc * test/BtRejectMessageTest.cc * test/BtRequestMessageTest.cc * test/BtSuggestPieceMessageTest.cc * test/BtUnchokeMessageTest.cc
42 lines
1000 B
C++
42 lines
1000 B
C++
#include "BtKeepAliveMessage.h"
|
|
#include <cstring>
|
|
#include <cppunit/extensions/HelperMacros.h>
|
|
|
|
namespace aria2 {
|
|
|
|
class BtKeepAliveMessageTest:public CppUnit::TestFixture {
|
|
|
|
CPPUNIT_TEST_SUITE(BtKeepAliveMessageTest);
|
|
CPPUNIT_TEST(testCreateMessage);
|
|
CPPUNIT_TEST(testToString);
|
|
CPPUNIT_TEST_SUITE_END();
|
|
private:
|
|
|
|
public:
|
|
void setUp() {
|
|
}
|
|
|
|
void testCreateMessage();
|
|
void testToString();
|
|
};
|
|
|
|
CPPUNIT_TEST_SUITE_REGISTRATION(BtKeepAliveMessageTest);
|
|
|
|
void BtKeepAliveMessageTest::testCreateMessage() {
|
|
char data[4];
|
|
memset(data, 0, sizeof(data));
|
|
BtKeepAliveMessage message;
|
|
CPPUNIT_ASSERT_EQUAL((uint8_t)99, message.getId());
|
|
CPPUNIT_ASSERT_EQUAL((size_t)4, message.getMessageLength());
|
|
unsigned char* rawmsg = message.createMessage();
|
|
CPPUNIT_ASSERT(memcmp(rawmsg, data, 4) == 0);
|
|
delete [] rawmsg;
|
|
}
|
|
|
|
void BtKeepAliveMessageTest::testToString() {
|
|
BtKeepAliveMessage msg;
|
|
CPPUNIT_ASSERT_EQUAL(std::string("keep alive"), msg.toString());
|
|
}
|
|
|
|
} // namespace aria2
|