2007-10-11 16:58:24 +00:00
|
|
|
#include "GrowSegment.h"
|
|
|
|
#include "Piece.h"
|
|
|
|
#include <cppunit/extensions/HelperMacros.h>
|
|
|
|
|
2008-02-08 15:53:45 +00:00
|
|
|
namespace aria2 {
|
2007-10-11 16:58:24 +00:00
|
|
|
|
|
|
|
class GrowSegmentTest : public CppUnit::TestFixture {
|
|
|
|
|
|
|
|
CPPUNIT_TEST_SUITE(GrowSegmentTest);
|
|
|
|
CPPUNIT_TEST(testUpdateWrittenLength);
|
2007-10-12 15:11:37 +00:00
|
|
|
CPPUNIT_TEST(testClear);
|
2007-10-11 16:58:24 +00:00
|
|
|
CPPUNIT_TEST_SUITE_END();
|
|
|
|
private:
|
|
|
|
|
|
|
|
public:
|
|
|
|
void setUp() {}
|
|
|
|
|
|
|
|
void testUpdateWrittenLength();
|
2007-10-12 15:11:37 +00:00
|
|
|
void testClear();
|
2007-10-11 16:58:24 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
CPPUNIT_TEST_SUITE_REGISTRATION( GrowSegmentTest );
|
|
|
|
|
|
|
|
void GrowSegmentTest::testUpdateWrittenLength()
|
|
|
|
{
|
2013-06-21 16:10:38 +00:00
|
|
|
GrowSegment segment(std::shared_ptr<Piece>(new Piece()));
|
2007-10-11 16:58:24 +00:00
|
|
|
segment.updateWrittenLength(32*1024);
|
2012-10-01 14:52:22 +00:00
|
|
|
|
2012-06-25 14:35:24 +00:00
|
|
|
CPPUNIT_ASSERT_EQUAL((int64_t)32*1024, segment.getPositionToWrite());
|
2007-10-11 16:58:24 +00:00
|
|
|
CPPUNIT_ASSERT(!segment.complete());
|
|
|
|
CPPUNIT_ASSERT(segment.getPiece()->pieceComplete());
|
|
|
|
}
|
2007-10-12 15:11:37 +00:00
|
|
|
|
|
|
|
void GrowSegmentTest::testClear()
|
|
|
|
{
|
2013-06-21 16:10:38 +00:00
|
|
|
GrowSegment segment(std::shared_ptr<Piece>(new Piece()));
|
2007-10-12 15:11:37 +00:00
|
|
|
segment.updateWrittenLength(32*1024);
|
2014-05-24 20:42:23 +00:00
|
|
|
CPPUNIT_ASSERT_EQUAL((int64_t)32*1024, segment.getWrittenLength());
|
2013-08-20 16:57:17 +00:00
|
|
|
segment.clear(nullptr);
|
2014-05-24 20:42:23 +00:00
|
|
|
CPPUNIT_ASSERT_EQUAL((int64_t)0, segment.getWrittenLength());
|
2007-10-12 15:11:37 +00:00
|
|
|
}
|
2008-02-08 15:53:45 +00:00
|
|
|
|
|
|
|
} // namespace aria2
|