mirror of
https://github.com/aria2/aria2.git
synced 2025-01-01 15:44:55 +00:00
c1730aeea9
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
73 lines
1.6 KiB
C++
73 lines
1.6 KiB
C++
#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
|