diff --git a/test/test_file_progress.cpp b/test/test_file_progress.cpp index 66b22d87a..df5f97de6 100644 --- a/test/test_file_progress.cpp +++ b/test/test_file_progress.cpp @@ -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 vec; + fp.export_progress(vec); + + TEST_EQUAL(vec[file_index], fs.file_size(file_index)); + }); + } + + TEST_EQUAL(count, fs.num_files()); +}