2006-12-24 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>

Rewritten a portion of bittorrent implementation:
	
	* src/BtMessageValidator.h: New class.
	* src/BtBitfieldMessageValidator.h: New class.
	* src/BtHandshakeMessageValidator.h: New class.
	* src/BtRequestMessageValidator.h: New class.
	* src/BtSuggestPieceMessageValidator.h: New class.
	* src/BtAllowedFastMessageValidator.h: New class.
	* src/BtRejectMessageValidator.h: New class.
	* src/BtCancelMessageValidator.h: New class.
	* src/BtPieceMessageValidator.h: New class.
	* src/BtHaveMessageValidator.h: New class.
	* src/BtEventListener.h: New class.
	* src/AbstractBtEventListener.h: New class.
	* src/BtEvent.h: New class.
	* src/BtChokingEvent.h: New class.
	* src/BtChokedEvent.h: New class.
	* src/BtCancelSendingPieceEvent.h: New class.
	* src/BtAbortOutstandingRequestEvent.h: New class.
	* src/Randomizer.h: New class.
	* src/SimpleRandomizer.h: New class.
	* src/BtMessage.h: New class.
	* src/AbstractBtMessage.h: New class.
	* src/SimpleBtMessage.h: New class.
	* src/BtHaveMessage.h: New class.
	* src/BtInterestedMessage.h: New class.
	* src/BtAllowedFastMessage.h: New class.
	* src/BtUnchokeMessage.h: New class.
	* src/BtCancelMessage.h: New class.
	* src/BtNotInterestedMessage.h: New class.
	* src/BtChokeMessage.h: New class.
	* src/BtHaveNoneMessage.h: New class.
	* src/BtHandshakeMessage.h: New class.
	* src/BtSuggestPieceMessage.h: New class.
	* src/BtHaveMessage.h: New class.
	* src/BtPieceMessage.h: New class.
	* src/BtHaveAllMessage.h: New class.
	* src/BtKeepAliveMessage.h: New class.
	* src/BtPortMessage.h: New class.
	* src/BtRejectMessage.h: New class.
	* src/BtBitfieldMessage.h: New class.
	* src/BtRequestMessage.h: New class.
	* src/DefaultBtRequestFactory.h: New class.
	* src/DefaultBtMessageReceiver.h: New class.
	* src/BtInteractive.h: New class.
	* src/BtMessageDispatcher.h: New class.
	* src/DefaultBtMessageDispatcher.h: New class.
	* src/DefaultBtInteractive.h: New class.
	* src/BitfieldManFactory.h: New class.
	* src/HandleRegistry.h: New class.
	* src/BtMessageFactory.h: New class.
	* src/BtMessageReceiver.h: New class.
	* src/DefaultBtMessageFactory.h: New class.
	* src/PeerObject.h: New class.
	* src/BtRequestFactory.h: New class.
This commit is contained in:
Tatsuhiro Tsujikawa 2006-12-24 06:25:21 +00:00
parent 458cc27462
commit 9c3e8fbd9c
162 changed files with 11207 additions and 663 deletions

45
test/PeerTest.cc Normal file
View file

@ -0,0 +1,45 @@
#include "Peer.h"
#include <cppunit/extensions/HelperMacros.h>
using namespace std;
class PeerTest:public CppUnit::TestFixture {
CPPUNIT_TEST_SUITE(PeerTest);
CPPUNIT_TEST(testPeerAllowedIndexSet);
CPPUNIT_TEST(testAmAllowedIndexSet);
CPPUNIT_TEST(testGetId);
CPPUNIT_TEST_SUITE_END();
private:
PeerHandle peer;
public:
PeerTest():peer(0) {}
void setUp() {
peer = new Peer("localhost", 6969, 16*1024, 256*1024*1024);
}
void testPeerAllowedIndexSet();
void testAmAllowedIndexSet();
void testGetId();
};
CPPUNIT_TEST_SUITE_REGISTRATION(PeerTest);
void PeerTest::testPeerAllowedIndexSet() {
CPPUNIT_ASSERT(!peer->isInPeerAllowedIndexSet(0));
peer->addPeerAllowedIndex(0);
CPPUNIT_ASSERT(peer->isInPeerAllowedIndexSet(0));
}
void PeerTest::testAmAllowedIndexSet() {
CPPUNIT_ASSERT(!peer->isInAmAllowedIndexSet(0));
peer->addAmAllowedIndex(0);
CPPUNIT_ASSERT(peer->isInAmAllowedIndexSet(0));
}
void PeerTest::testGetId() {
CPPUNIT_ASSERT_EQUAL(string("f05897fc14a41cb3400e283e189158656d7184da"),
peer->getId());
}