2009-03-13 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>

Refactored BtMessage subclasses. BtCancelMessage,
	BtRequestMessage and BtRejectMessage are derived from
	RangeBtMessage class.
	BtAllowedFastMessage, BtHaveMessage and BtSuggestPieceMessage
	are derived from IndexBtMessage class. BtChokeMessage,
	BtHaveAllMessage, BtHaveNoneMessage, BtInterestedMessage,
	BtNotInterestedMessage and BtUnchokeMessage are derived from
	ZeroBtMessage class.
	* src/AbstractBtMessage.cc
	* src/AbstractBtMessage.h
	* src/BtAllowedFastMessage.cc
	* src/BtAllowedFastMessage.h
	* src/BtAllowedFastMessageValidator.h: Removed
	* src/BtBitfieldMessage.cc
	* src/BtBitfieldMessage.h
	* src/BtCancelMessage.cc
	* src/BtCancelMessage.h
	* src/BtCancelMessageValidator.h: Removed
	* src/BtChokeMessage.cc
	* src/BtChokeMessage.h
	* src/BtExtendedMessage.cc
	* src/BtExtendedMessage.h
	* src/BtHandshakeMessage.cc
	* src/BtHandshakeMessage.h
	* src/BtHaveAllMessage.cc
	* src/BtHaveAllMessage.h
	* src/BtHaveMessage.cc
	* src/BtHaveMessage.h
	* src/BtHaveMessageValidator.h: Removed
	* src/BtHaveNoneMessage.cc
	* src/BtHaveNoneMessage.h
	* src/BtInterestedMessage.cc
	* src/BtInterestedMessage.h
	* src/BtKeepAliveMessage.cc
	* src/BtKeepAliveMessage.h
	* src/BtNotInterestedMessage.cc
	* src/BtNotInterestedMessage.h
	* src/BtPieceMessage.cc
	* src/BtPieceMessage.h
	* src/BtPortMessage.cc
	* src/BtPortMessage.h
	* src/BtRejectMessage.cc
	* src/BtRejectMessage.h
	* src/BtRejectMessageValidator.h: Removed
	* src/BtRequestMessage.cc
	* src/BtRequestMessage.h
	* src/BtRequestMessageValidator.h: Removed
	* src/BtSuggestPieceMessage.cc
	* src/BtSuggestPieceMessage.h
	* src/BtSuggestPieceMessageValidator.h: Removed
	* src/BtUnchokeMessage.cc
	* src/BtUnchokeMessage.h
	* src/DefaultBtMessageFactory.cc
	* src/IndexBtMessage.cc
	* src/IndexBtMessage.h
	* src/IndexBtMessageValidator.h
	* src/Makefile.am
	* src/PeerMessageUtil.cc
	* src/PeerMessageUtil.h
	* src/RangeBtMessage.cc
	* src/RangeBtMessage.h
	* src/RangeBtMessageValidator.h
	* src/SimpleBtMessage.cc
	* src/SimpleBtMessage.h
	* src/ZeroBtMessage.cc
	* src/ZeroBtMessage.h
	* test/BtRequestMessageTest.cc
This commit is contained in:
Tatsuhiro Tsujikawa 2009-03-12 15:54:43 +00:00
parent 371ef954d5
commit 15582ed8cd
56 changed files with 849 additions and 1122 deletions

View file

@ -14,7 +14,7 @@
#include "Peer.h"
#include "FileEntry.h"
#include "BtHandshakeMessage.h"
#include "BtRequestMessageValidator.h"
#include "RangeBtMessageValidator.h"
namespace aria2 {
@ -144,7 +144,7 @@ void BtRequestMessageTest::testCreate() {
CPPUNIT_ASSERT_EQUAL((uint8_t)6, pm->getId());
CPPUNIT_ASSERT_EQUAL((size_t)12345, pm->getIndex());
CPPUNIT_ASSERT_EQUAL((uint32_t)256, pm->getBegin());
CPPUNIT_ASSERT_EQUAL((uint32_t)1024, pm->getLength());
CPPUNIT_ASSERT_EQUAL((size_t)1024, pm->getLength());
// case: payload size is wrong
try {
@ -289,7 +289,7 @@ void BtRequestMessageTest::testValidate() {
BtRequestMessage msg(0, 0, 16*1024);
msg.setBtMessageValidator
(SharedHandle<BtMessageValidator>
(new BtRequestMessageValidator(&msg, 1024, 256*1024)));
(new RangeBtMessageValidator(&msg, 1024, 256*1024)));
std::deque<std::string> errors;
msg.validate(errors);
@ -299,7 +299,7 @@ void BtRequestMessageTest::testValidate_lengthTooLong() {
BtRequestMessage msg(0, 0, 16*1024+1);
msg.setBtMessageValidator
(SharedHandle<BtMessageValidator>
(new BtRequestMessageValidator(&msg, 1024, 256*1024)));
(new RangeBtMessageValidator(&msg, 1024, 256*1024)));
std::deque<std::string> errors;
try {
msg.validate(errors);