aria2/test/a2algoTest.cc
Tatsuhiro Tsujikawa f15d22b619 2010-03-25 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Added vbegin() and vend() for fixed sized array.
	* src/DownloadHandlerConstants.cc
	* src/FeatureConfig.cc
	* src/OptionHandlerFactory.cc
	* src/ServerStat.cc
	* src/TimeA2.cc
	* src/XmlRpcMethod.cc
	* src/array_fun.h
	* src/download_helper.cc
	* src/messageDigest.cc
	* src/util.cc
	* test/BittorrentHelperTest.cc
	* test/DHTRoutingTableDeserializerTest.cc
	* test/DHTRoutingTableSerializerTest.cc
	* test/DefaultBtAnnounceTest.cc
	* test/DefaultBtProgressInfoFileTest.cc
	* test/DownloadContextTest.cc
	* test/DownloadHelperTest.cc
	* test/FeatureConfigTest.cc
	* test/FeedbackURISelectorTest.cc
	* test/HttpRequestTest.cc
	* test/InOrderURISelectorTest.cc
	* test/MSEHandshakeTest.cc
	* test/MultiDiskAdaptorTest.cc
	* test/MultiFileAllocationIteratorTest.cc
	* test/PriorityPieceSelectorTest.cc
	* test/RequestGroupManTest.cc
	* test/UtilTest.cc
	* test/XmlRpcMethodTest.cc
	* test/a2algoTest.cc
	* test/array_funTest.cc
2010-03-25 13:51:10 +00:00

45 lines
884 B
C++

#include "a2algo.h"
#include <cppunit/extensions/HelperMacros.h>
#include "array_fun.h"
namespace aria2 {
class a2algoTest:public CppUnit::TestFixture {
CPPUNIT_TEST_SUITE(a2algoTest);
CPPUNIT_TEST(testSelect);
CPPUNIT_TEST_SUITE_END();
public:
void setUp() {}
void tearDown() {}
void testSelect();
};
CPPUNIT_TEST_SUITE_REGISTRATION(a2algoTest);
void a2algoTest::testSelect()
{
size_t A[] = { 1,2,3,4,7,10,11,12,13,14,15,100,112,113,114 };
std::pair<size_t*, size_t> p = max_sequence(vbegin(A), vend(A));
CPPUNIT_ASSERT_EQUAL(&A[5], p.first);
CPPUNIT_ASSERT_EQUAL((size_t)6, p.second);
p = max_sequence(&A[0], &A[0]);
CPPUNIT_ASSERT_EQUAL(&A[0], p.first);
CPPUNIT_ASSERT_EQUAL((size_t)0, p.second);
p = max_sequence(&A[0], &A[4]);
CPPUNIT_ASSERT_EQUAL(&A[0], p.first);
CPPUNIT_ASSERT_EQUAL((size_t)4, p.second);
}
} // namespace aria2