2009-11-15 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>

Use dynamic_pointer_cast
	* test/BtPieceMessageTest.cc
	* test/BtRequestMessageTest.cc
	* test/DefaultBtRequestFactoryTest.cc
pull/1/head
Tatsuhiro Tsujikawa 2009-11-15 13:25:44 +00:00
parent f11adceba7
commit 7b63e121c7
4 changed files with 23 additions and 13 deletions

View File

@ -1,3 +1,10 @@
2009-11-15 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Use dynamic_pointer_cast
* test/BtPieceMessageTest.cc
* test/BtRequestMessageTest.cc
* test/DefaultBtRequestFactoryTest.cc
2009-11-15 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Added testSetUrl20()

View File

@ -171,8 +171,9 @@ void BtPieceMessageTest::testChokingEvent_allowedFastEnabled() {
CPPUNIT_ASSERT(msg->isInvalidate());
CPPUNIT_ASSERT_EQUAL((size_t)1, btMessageDispatcher->messageQueue.size());
MockBtMessage2* rej =
(MockBtMessage2*)btMessageDispatcher->messageQueue.front().get();
SharedHandle<MockBtMessage2> rej =
dynamic_pointer_cast<MockBtMessage2>
(btMessageDispatcher->messageQueue.front());
CPPUNIT_ASSERT_EQUAL((size_t)1, rej->index);
CPPUNIT_ASSERT_EQUAL((uint32_t)1024, rej->begin);
CPPUNIT_ASSERT_EQUAL((size_t)16*1024, rej->length);
@ -257,8 +258,9 @@ void BtPieceMessageTest::testCancelSendingPieceEvent_allowedFastEnabled() {
CPPUNIT_ASSERT(msg->isInvalidate());
CPPUNIT_ASSERT_EQUAL((size_t)1, btMessageDispatcher->messageQueue.size());
MockBtMessage2* rej = (MockBtMessage2*)btMessageDispatcher->
messageQueue.front().get();
SharedHandle<MockBtMessage2> rej =
dynamic_pointer_cast<MockBtMessage2>
(btMessageDispatcher->messageQueue.front());
CPPUNIT_ASSERT_EQUAL((size_t)1, rej->index);
CPPUNIT_ASSERT_EQUAL((uint32_t)1024, rej->begin);
CPPUNIT_ASSERT_EQUAL((size_t)16*1024, rej->length);

View File

@ -174,8 +174,8 @@ void BtRequestMessageTest::testDoReceivedAction_hasPieceAndAmNotChoking() {
msg->doReceivedAction();
CPPUNIT_ASSERT_EQUAL((size_t)1, _dispatcher->messageQueue.size());
MockBtMessage2* pieceMsg =
(MockBtMessage2*)_dispatcher->messageQueue.front().get();
SharedHandle<MockBtMessage2> pieceMsg =
dynamic_pointer_cast<MockBtMessage2>(_dispatcher->messageQueue.front());
CPPUNIT_ASSERT_EQUAL(std::string("piece"), pieceMsg->type);
CPPUNIT_ASSERT_EQUAL((size_t)1, pieceMsg->index);
CPPUNIT_ASSERT_EQUAL((uint32_t)16, pieceMsg->begin);
@ -188,8 +188,8 @@ void BtRequestMessageTest::testDoReceivedAction_hasPieceAndAmChokingAndFastExten
msg->doReceivedAction();
CPPUNIT_ASSERT_EQUAL((size_t)1, _dispatcher->messageQueue.size());
MockBtMessage2* pieceMsg =
(MockBtMessage2*)_dispatcher->messageQueue.front().get();
SharedHandle<MockBtMessage2> pieceMsg =
dynamic_pointer_cast<MockBtMessage2>(_dispatcher->messageQueue.front());
CPPUNIT_ASSERT_EQUAL(std::string("reject"), pieceMsg->type);
CPPUNIT_ASSERT_EQUAL((size_t)1, pieceMsg->index);
CPPUNIT_ASSERT_EQUAL((uint32_t)16, pieceMsg->begin);
@ -210,8 +210,8 @@ void BtRequestMessageTest::testDoReceivedAction_doesntHavePieceAndFastExtensionE
msg->doReceivedAction();
CPPUNIT_ASSERT_EQUAL((size_t)1, _dispatcher->messageQueue.size());
MockBtMessage2* pieceMsg =
(MockBtMessage2*)_dispatcher->messageQueue.front().get();
SharedHandle<MockBtMessage2> pieceMsg =
dynamic_pointer_cast<MockBtMessage2>(_dispatcher->messageQueue.front());
CPPUNIT_ASSERT_EQUAL(std::string("reject"), pieceMsg->type);
CPPUNIT_ASSERT_EQUAL((size_t)2, pieceMsg->index);
CPPUNIT_ASSERT_EQUAL((uint32_t)16, pieceMsg->begin);

View File

@ -147,15 +147,16 @@ void DefaultBtRequestFactoryTest::testCreateRequestMessages() {
CPPUNIT_ASSERT_EQUAL((size_t)3, msgs.size());
std::deque<SharedHandle<BtMessage> >::iterator itr = msgs.begin();
MockBtRequestMessage* msg = (MockBtRequestMessage*)itr->get();
SharedHandle<MockBtRequestMessage> msg =
dynamic_pointer_cast<MockBtRequestMessage>(*itr);
CPPUNIT_ASSERT_EQUAL((size_t)0, msg->index);
CPPUNIT_ASSERT_EQUAL((size_t)0, msg->blockIndex);
++itr;
msg = (MockBtRequestMessage*)itr->get();
msg = dynamic_pointer_cast<MockBtRequestMessage>(*itr);
CPPUNIT_ASSERT_EQUAL((size_t)0, msg->index);
CPPUNIT_ASSERT_EQUAL((size_t)1, msg->blockIndex);
++itr;
msg = (MockBtRequestMessage*)itr->get();
msg = dynamic_pointer_cast<MockBtRequestMessage>(*itr);
CPPUNIT_ASSERT_EQUAL((size_t)1, msg->index);
CPPUNIT_ASSERT_EQUAL((size_t)0, msg->blockIndex);