forked from aria2/aria2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGrowSegmentTest.cc
44 lines (33 loc) · 1.05 KB
/
GrowSegmentTest.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#include "GrowSegment.h"
#include "Piece.h"
#include <cppunit/extensions/HelperMacros.h>
namespace aria2 {
class GrowSegmentTest : public CppUnit::TestFixture {
CPPUNIT_TEST_SUITE(GrowSegmentTest);
CPPUNIT_TEST(testUpdateWrittenLength);
CPPUNIT_TEST(testClear);
CPPUNIT_TEST_SUITE_END();
private:
public:
void setUp() {}
void testUpdateWrittenLength();
void testClear();
};
CPPUNIT_TEST_SUITE_REGISTRATION( GrowSegmentTest );
void GrowSegmentTest::testUpdateWrittenLength()
{
GrowSegment segment(SharedHandle<Piece>(new Piece()));
segment.updateWrittenLength(32*1024);
CPPUNIT_ASSERT_EQUAL((off_t)32*1024, segment.getPositionToWrite());
CPPUNIT_ASSERT(!segment.complete());
CPPUNIT_ASSERT(segment.getPiece()->pieceComplete());
}
void GrowSegmentTest::testClear()
{
GrowSegment segment(SharedHandle<Piece>(new Piece()));
segment.updateWrittenLength(32*1024);
CPPUNIT_ASSERT_EQUAL((size_t)32*1024, segment.getWrittenLength());
segment.clear();
CPPUNIT_ASSERT_EQUAL((size_t)0, segment.getWrittenLength());
}
} // namespace aria2