| 24 | CPPUNIT_TEST_SUITE_REGISTRATION(SingleFileAllocationIteratorTest); |
| 25 | |
| 26 | void 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 |
nothing calls this directly
no test coverage detected