simple test for file_progress::update
This commit is contained in:
parent
bcda184e59
commit
88d018bb67
|
@ -104,5 +104,37 @@ TORRENT_TEST(init2)
|
|||
}
|
||||
}
|
||||
|
||||
// TODO: test the update function too
|
||||
TORRENT_TEST(update_simple_sequential)
|
||||
{
|
||||
int const piece_size = 256;
|
||||
|
||||
file_storage fs;
|
||||
fs.add_file("torrent/1", 100000);
|
||||
fs.add_file("torrent/2", 100);
|
||||
fs.add_file("torrent/3", 45000);
|
||||
fs.set_piece_length(piece_size);
|
||||
fs.set_num_pieces((int(fs.total_size()) + piece_size - 1) / piece_size);
|
||||
|
||||
piece_picker picker(4, fs.total_size() % 4, fs.num_pieces());
|
||||
|
||||
aux::file_progress fp;
|
||||
|
||||
fp.init(picker, fs);
|
||||
|
||||
int count = 0;
|
||||
|
||||
for (auto const idx : fs.piece_range())
|
||||
{
|
||||
fp.update(fs, idx, [&](file_index_t const file_index)
|
||||
{
|
||||
count++;
|
||||
|
||||
aux::vector<std::int64_t, file_index_t> vec;
|
||||
fp.export_progress(vec);
|
||||
|
||||
TEST_EQUAL(vec[file_index], fs.file_size(file_index));
|
||||
});
|
||||
}
|
||||
|
||||
TEST_EQUAL(count, fs.num_files());
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue