Merged Ross's patch to test code.

This commit is contained in:
Tatsuhiro Tsujikawa 2007-07-23 14:09:46 +00:00
parent 8d84d9f97c
commit 19ef788023
30 changed files with 173 additions and 107 deletions

View file

@ -132,9 +132,9 @@ void BtRequestMessageTest::testCreate() {
PeerMessageUtil::setIntParam(&msg[13], 1024);
BtRequestMessageHandle pm = BtRequestMessage::create(&msg[4], 13);
CPPUNIT_ASSERT_EQUAL((int8_t)6, pm->getId());
CPPUNIT_ASSERT_EQUAL(12345, pm->getIndex());
CPPUNIT_ASSERT_EQUAL(256, pm->getBegin());
CPPUNIT_ASSERT_EQUAL(1024, pm->getLength());
CPPUNIT_ASSERT_EQUAL((int32_t)12345, pm->getIndex());
CPPUNIT_ASSERT_EQUAL((int32_t)256, pm->getBegin());
CPPUNIT_ASSERT_EQUAL((int32_t)1024, pm->getLength());
// case: payload size is wrong
try {
@ -174,9 +174,9 @@ void BtRequestMessageTest::testDoReceivedAction_hasPieceAndAmNotChoking() {
CPPUNIT_ASSERT_EQUAL((size_t)1, dispatcher->messageQueue.size());
MockBtMessage2* pieceMsg = (MockBtMessage2*)dispatcher->messageQueue.front().get();
CPPUNIT_ASSERT_EQUAL(string("piece"), pieceMsg->type);
CPPUNIT_ASSERT_EQUAL(1, pieceMsg->index);
CPPUNIT_ASSERT_EQUAL(16, pieceMsg->begin);
CPPUNIT_ASSERT_EQUAL(32, pieceMsg->length);
CPPUNIT_ASSERT_EQUAL((int32_t)1, pieceMsg->index);
CPPUNIT_ASSERT_EQUAL((int32_t)16, pieceMsg->begin);
CPPUNIT_ASSERT_EQUAL((int32_t)32, pieceMsg->length);
}
void BtRequestMessageTest::testDoReceivedAction_hasPieceAndAmChokingAndFastExtensionEnabled() {
@ -187,9 +187,9 @@ void BtRequestMessageTest::testDoReceivedAction_hasPieceAndAmChokingAndFastExten
CPPUNIT_ASSERT_EQUAL((size_t)1, dispatcher->messageQueue.size());
MockBtMessage2* pieceMsg = (MockBtMessage2*)dispatcher->messageQueue.front().get();
CPPUNIT_ASSERT_EQUAL(string("reject"), pieceMsg->type);
CPPUNIT_ASSERT_EQUAL(1, pieceMsg->index);
CPPUNIT_ASSERT_EQUAL(16, pieceMsg->begin);
CPPUNIT_ASSERT_EQUAL(32, pieceMsg->length);
CPPUNIT_ASSERT_EQUAL((int32_t)1, pieceMsg->index);
CPPUNIT_ASSERT_EQUAL((int32_t)16, pieceMsg->begin);
CPPUNIT_ASSERT_EQUAL((int32_t)32, pieceMsg->length);
}
void BtRequestMessageTest::testDoReceivedAction_hasPieceAndAmChokingAndFastExtensionDisabled() {
@ -208,9 +208,9 @@ void BtRequestMessageTest::testDoReceivedAction_doesntHavePieceAndFastExtensionE
CPPUNIT_ASSERT_EQUAL((size_t)1, dispatcher->messageQueue.size());
MockBtMessage2* pieceMsg = (MockBtMessage2*)dispatcher->messageQueue.front().get();
CPPUNIT_ASSERT_EQUAL(string("reject"), pieceMsg->type);
CPPUNIT_ASSERT_EQUAL(2, pieceMsg->index);
CPPUNIT_ASSERT_EQUAL(16, pieceMsg->begin);
CPPUNIT_ASSERT_EQUAL(32, pieceMsg->length);
CPPUNIT_ASSERT_EQUAL((int32_t)2, pieceMsg->index);
CPPUNIT_ASSERT_EQUAL((int32_t)16, pieceMsg->begin);
CPPUNIT_ASSERT_EQUAL((int32_t)32, pieceMsg->length);
}
void BtRequestMessageTest::testDoReceivedAction_doesntHavePieceAndFastExtensionDisabled() {