MCPcopy Create free account
hub / github.com/aria2/aria2 / testAllocate

Method testAllocate

test/SingleFileAllocationIteratorTest.cc:26–52  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

24CPPUNIT_TEST_SUITE_REGISTRATION(SingleFileAllocationIteratorTest);
25
26void SingleFileAllocationIteratorTest::testAllocate()
27{
28 std::string dir = A2_TEST_OUT_DIR;
29 std::string fname = "aria2_SingleFileAllocationIteratorTest_testAllocate";
30 std::string fn = dir + "/" + fname;
31 std::ofstream of(fn.c_str(), std::ios::binary);
32 of << "0123456789";
33 of.close();
34
35 File x(fn);
36 CPPUNIT_ASSERT_EQUAL((int64_t)10, x.size());
37
38 DefaultDiskWriter writer(fn);
39 int64_t offset = 10;
40 int64_t totalLength = 32_k + 8_k;
41
42 // we have to open file first.
43 writer.openExistingFile();
44 SingleFileAllocationIterator itr(&writer, offset, totalLength);
45 itr.init();
46
47 while (!itr.finished()) {
48 itr.allocateChunk();
49 }
50 File f(fn);
51 CPPUNIT_ASSERT_EQUAL((int64_t)40_k, f.size());
52}
53
54} // namespace aria2

Callers

nothing calls this directly

Calls 6

closeMethod · 0.45
sizeMethod · 0.45
openExistingFileMethod · 0.45
initMethod · 0.45
finishedMethod · 0.45
allocateChunkMethod · 0.45

Tested by

no test coverage detected