From dd7aeba978af68c839a3f0ba312aa5d028072787 Mon Sep 17 00:00:00 2001 From: Arvid Norberg Date: Sun, 19 Nov 2006 15:25:02 +0000 Subject: [PATCH] added some more checks --- test/test_metadata_extension.cpp | 4 ++-- test/test_storage.cpp | 17 ++++++++++------- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/test/test_metadata_extension.cpp b/test/test_metadata_extension.cpp index adf547d23..2c7d17600 100644 --- a/test/test_metadata_extension.cpp +++ b/test/test_metadata_extension.cpp @@ -64,13 +64,13 @@ int test_main() using namespace boost::filesystem; // test to disconnect one client prematurely -// test_transfer(true, true); + test_transfer(true, true); // test where one has data and one doesn't test_transfer(true); // test where both have data (to trigger the file check) -// test_transfer(false); + test_transfer(false); remove_all("./tmp1"); remove_all("./tmp2"); diff --git a/test/test_storage.cpp b/test/test_storage.cpp index 2687082aa..79d179b78 100644 --- a/test/test_storage.cpp +++ b/test/test_storage.cpp @@ -1,4 +1,5 @@ #include "libtorrent/storage.hpp" +#include "libtorrent/file_pool.hpp" #include "libtorrent/hasher.hpp" #include "libtorrent/session.hpp" #include "libtorrent/aux_/session_impl.hpp" @@ -51,14 +52,15 @@ int test_main() char piece[piece_size]; { // avoid having two storages use the same files - storage s(info, initial_path()); + file_pool fp; + storage s(info, initial_path(), fp); // write piece 1 (in slot 0) s.write(piece1, 0, 0, half); s.write(piece1 + half, 0, half, half); // verify piece 1 - s.read(piece, 0, 0, piece_size); + TEST_CHECK(s.read(piece, 0, 0, piece_size) == piece_size); TEST_CHECK(std::equal(piece, piece + piece_size, piece1)); // do the same with piece 0 and 2 (in slot 1 and 2) @@ -66,7 +68,7 @@ int test_main() s.write(piece2, 2, 0, piece_size); // verify piece 0 and 2 - s.read(piece, 1, 0, piece_size); + TEST_CHECK(s.read(piece, 1, 0, piece_size) == piece_size); TEST_CHECK(std::equal(piece, piece + piece_size, piece0)); s.read(piece, 2, 0, piece_size); @@ -79,7 +81,8 @@ int test_main() } // make sure the piece_manager can identify the pieces - piece_manager pm(info, initial_path()); + file_pool fp; + piece_manager pm(info, initial_path(), fp); boost::mutex lock; libtorrent::aux::piece_checker_data d; @@ -95,13 +98,13 @@ int test_main() TEST_CHECK(num_pieces == std::count(pieces.begin(), pieces.end() , true)); - pm.read(piece, 0, 0, piece_size); + TEST_CHECK(pm.read(piece, 0, 0, piece_size) == piece_size); TEST_CHECK(std::equal(piece, piece + piece_size, piece0)); - pm.read(piece, 1, 0, piece_size); + TEST_CHECK(pm.read(piece, 1, 0, piece_size) == piece_size); TEST_CHECK(std::equal(piece, piece + piece_size, piece1)); - pm.read(piece, 2, 0, piece_size); + TEST_CHECK(pm.read(piece, 2, 0, piece_size) == piece_size); TEST_CHECK(std::equal(piece, piece + piece_size, piece2)); pm.release_files();