mirror of
https://github.com/aria2/aria2.git
synced 2025-04-05 13:37:40 +03:00
To match the behavior of friend operator functions in SharedHandle.h to std::tr1::shared_ptr, we intentionally broke these functions and modified code so that our code does not depend on old behavior. * src/AbstractCommand.cc * src/DHTAbstractNodeLookupTask.h * src/DHTBucket.cc * src/DHTMessageReceiver.cc * src/DHTNodeLookupEntry.cc * src/DHTRoutingTable.cc * src/DefaultBtRequestFactory.cc * src/DefaultPeerStorage.cc * src/DefaultPieceStorage.cc * src/DownloadContext.cc * src/EpollEventPoll.cc * src/Event.h * src/HttpConnection.cc * src/KqueueEventPoll.cc * src/MultiDiskAdaptor.cc * src/PeerAbstractCommand.cc * src/PieceStatMan.cc * src/PollEventPoll.cc * src/PortEventPoll.cc * src/SegmentMan.cc * src/SelectEventPoll.cc * src/SelectEventPoll.h * src/ServerStatMan.cc * src/SharedHandle.h * src/UnknownLengthPieceStorage.cc * src/a2functional.h * src/option_processing.cc * src/version_usage.cc * test/BNodeTest.cc * test/DHTAnnouncePeerMessageTest.cc * test/DHTBucketTest.cc * test/DHTFindNodeMessageTest.cc * test/DHTGetPeersMessageTest.cc * test/DHTIDCloserTest.cc * test/DHTMessageFactoryImplTest.cc * test/DHTPingMessageTest.cc * test/DefaultBtRequestFactoryTest.cc * test/DefaultPeerStorageTest.cc * test/SequentialPickerTest.cc * test/SingletonHolderTest.cc
51 lines
1.1 KiB
C++
51 lines
1.1 KiB
C++
#include "SequentialPicker.h"
|
|
|
|
#include <cppunit/extensions/HelperMacros.h>
|
|
|
|
namespace aria2 {
|
|
|
|
typedef SharedHandle<int> Integer;
|
|
|
|
class SequentialPickerTest:public CppUnit::TestFixture {
|
|
|
|
CPPUNIT_TEST_SUITE(SequentialPickerTest);
|
|
CPPUNIT_TEST(testPick);
|
|
CPPUNIT_TEST_SUITE_END();
|
|
public:
|
|
void testPick();
|
|
};
|
|
|
|
|
|
CPPUNIT_TEST_SUITE_REGISTRATION(SequentialPickerTest);
|
|
|
|
void SequentialPickerTest::testPick()
|
|
{
|
|
SequentialPicker<int> picker;
|
|
|
|
CPPUNIT_ASSERT(!picker.isPicked());
|
|
CPPUNIT_ASSERT(!picker.hasNext());
|
|
CPPUNIT_ASSERT_EQUAL((size_t)0, picker.countEntryInQueue());
|
|
|
|
picker.pushEntry(Integer(new int(1)));
|
|
picker.pushEntry(Integer(new int(2)));
|
|
|
|
CPPUNIT_ASSERT(picker.hasNext());
|
|
CPPUNIT_ASSERT_EQUAL((size_t)2, picker.countEntryInQueue());
|
|
|
|
picker.pickNext();
|
|
|
|
CPPUNIT_ASSERT(picker.isPicked());
|
|
CPPUNIT_ASSERT_EQUAL(*Integer(new int(1)), *picker.getPickedEntry());
|
|
|
|
picker.dropPickedEntry();
|
|
|
|
CPPUNIT_ASSERT(!picker.isPicked());
|
|
CPPUNIT_ASSERT(picker.hasNext());
|
|
|
|
picker.pickNext();
|
|
|
|
CPPUNIT_ASSERT_EQUAL(*Integer(new int(2)), *picker.getPickedEntry());
|
|
CPPUNIT_ASSERT(!picker.hasNext());
|
|
}
|
|
|
|
} // namespace aria2
|