mirror of
https://github.com/aria2/aria2.git
synced 2025-04-05 13:37:40 +03:00
2009-11-23 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Fixed ut_metadata data handling. Implemented UTMetadataDataExtensionMessage::doReceivedAction(). Initialize PeerStorage in HandshakeExtensionMessage::doReceivedAction() when metadata_size is received. * src/DefaultExtensionMessageFactory.cc * src/DefaultExtensionMessageFactory.h * src/HandshakeExtensionMessage.cc * src/HandshakeExtensionMessage.h * src/UTMetadataDataExtensionMessage.cc * src/UTMetadataDataExtensionMessage.h * src/UTMetadataRequestExtensionMessage.cc * src/UTMetadataRequestFactory.cc * src/UTMetadataRequestFactory.h * src/UTMetadataRequestTracker.cc * src/UTMetadataRequestTracker.h * test/DefaultExtensionMessageFactoryTest.cc * test/HandshakeExtensionMessageTest.cc * test/MockBtMessage.h * test/UTMetadataDataExtensionMessageTest.cc * test/UTMetadataRequestExtensionMessageTest.cc * test/UTMetadataRequestFactoryTest.cc * test/UTMetadataRequestTrackerTest.cc * test/extension_message_test_helper.h
This commit is contained in:
parent
b563621dd1
commit
c1730aeea9
20 changed files with 813 additions and 64 deletions
72
test/UTMetadataRequestTrackerTest.cc
Normal file
72
test/UTMetadataRequestTrackerTest.cc
Normal file
|
@ -0,0 +1,72 @@
|
|||
#include "UTMetadataRequestTracker.h"
|
||||
|
||||
#include <cppunit/extensions/HelperMacros.h>
|
||||
|
||||
namespace aria2 {
|
||||
|
||||
class UTMetadataRequestTrackerTest:public CppUnit::TestFixture {
|
||||
|
||||
CPPUNIT_TEST_SUITE(UTMetadataRequestTrackerTest);
|
||||
CPPUNIT_TEST(testAdd);
|
||||
CPPUNIT_TEST(testRemove);
|
||||
CPPUNIT_TEST(testGetAllTrackedIndex);
|
||||
CPPUNIT_TEST(testCount);
|
||||
CPPUNIT_TEST(testAvail);
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
public:
|
||||
void testAdd();
|
||||
void testRemove();
|
||||
void testGetAllTrackedIndex();
|
||||
void testCount();
|
||||
void testAvail();
|
||||
};
|
||||
|
||||
|
||||
CPPUNIT_TEST_SUITE_REGISTRATION(UTMetadataRequestTrackerTest);
|
||||
|
||||
void UTMetadataRequestTrackerTest::testAdd()
|
||||
{
|
||||
UTMetadataRequestTracker tr;
|
||||
tr.add(1);
|
||||
CPPUNIT_ASSERT(tr.tracks(1));
|
||||
}
|
||||
|
||||
void UTMetadataRequestTrackerTest::testRemove()
|
||||
{
|
||||
UTMetadataRequestTracker tr;
|
||||
tr.add(1);
|
||||
tr.remove(1);
|
||||
CPPUNIT_ASSERT(!tr.tracks(1));
|
||||
}
|
||||
|
||||
void UTMetadataRequestTrackerTest::testGetAllTrackedIndex()
|
||||
{
|
||||
UTMetadataRequestTracker tr;
|
||||
tr.add(1);
|
||||
tr.add(2);
|
||||
|
||||
std::vector<size_t> indexes = tr.getAllTrackedIndex();
|
||||
CPPUNIT_ASSERT_EQUAL((size_t)2, indexes.size());
|
||||
CPPUNIT_ASSERT_EQUAL((size_t)1, indexes[0]);
|
||||
CPPUNIT_ASSERT_EQUAL((size_t)2, indexes[1]);
|
||||
}
|
||||
|
||||
void UTMetadataRequestTrackerTest::testCount()
|
||||
{
|
||||
UTMetadataRequestTracker tr;
|
||||
tr.add(1);
|
||||
tr.add(2);
|
||||
CPPUNIT_ASSERT_EQUAL((size_t)2, tr.count());
|
||||
}
|
||||
|
||||
void UTMetadataRequestTrackerTest::testAvail()
|
||||
{
|
||||
UTMetadataRequestTracker tr;
|
||||
CPPUNIT_ASSERT_EQUAL((size_t)1, tr.avail());
|
||||
tr.add(1);
|
||||
CPPUNIT_ASSERT_EQUAL((size_t)0, tr.avail());
|
||||
tr.add(2);
|
||||
CPPUNIT_ASSERT_EQUAL((size_t)0, tr.avail());
|
||||
}
|
||||
|
||||
} // namespace aria2
|
Loading…
Add table
Add a link
Reference in a new issue