aria2/test/SequentialPickerTest.cc
Tatsuhiro Tsujikawa 8ca9db9f3e 2009-01-24 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Replaced FileAllocationMan with
	SequentialPicker<FileAllocationEntry>.
	* src/BtCheckIntegrityEntry.cc
	* src/ConsoleStatCalc.cc
	* src/DownloadEngine.cc
	* src/DownloadEngine.h
	* src/DownloadEngineFactory.cc
	* src/FileAllocationCommand.cc
	* src/FileAllocationDispatcherCommand.cc
	* src/FileAllocationMan.h
	* src/Makefile.am
	* src/SequentialPicker.h
	* src/StatCalc.h
	* src/StreamCheckIntegrityEntry.cc
	* test/Makefile.am
	* test/SequentialPickerTest.cc
2009-01-24 09:00:36 +00:00

52 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