forked from premiere/premiere-libtorrent
made some tests rely less on deprecated functions
This commit is contained in:
parent
e0e253a2a4
commit
53acf4349e
|
@ -1014,7 +1014,9 @@ int test_main()
|
|||
entry torrent;
|
||||
torrent["info"] = info;
|
||||
|
||||
torrent_info ti(torrent);
|
||||
std::vector<char> buf;
|
||||
bencode(std::back_inserter(buf), torrent);
|
||||
torrent_info ti(&buf[0], buf.size(), ec);
|
||||
std::cerr << ti.name() << std::endl;
|
||||
TEST_CHECK(ti.name() == "test1");
|
||||
|
||||
|
@ -1024,7 +1026,9 @@ int test_main()
|
|||
info["name.utf-8"] = "/test1/test2/test3";
|
||||
#endif
|
||||
torrent["info"] = info;
|
||||
torrent_info ti2(torrent);
|
||||
buf.clear();
|
||||
bencode(std::back_inserter(buf), torrent);
|
||||
torrent_info ti2(&buf[0], buf.size(), ec);
|
||||
std::cerr << ti2.name() << std::endl;
|
||||
#ifdef TORRENT_WINDOWS
|
||||
TEST_CHECK(ti2.name() == "test1\\test2\\test3");
|
||||
|
@ -1034,7 +1038,9 @@ int test_main()
|
|||
|
||||
info["name.utf-8"] = "test2/../test3/.././../../test4";
|
||||
torrent["info"] = info;
|
||||
torrent_info ti3(torrent);
|
||||
buf.clear();
|
||||
bencode(std::back_inserter(buf), torrent);
|
||||
torrent_info ti3(&buf[0], buf.size(), ec);
|
||||
std::cerr << ti3.name() << std::endl;
|
||||
#ifdef TORRENT_WINDOWS
|
||||
TEST_CHECK(ti3.name() == "test2\\test3\\test4");
|
||||
|
|
|
@ -555,11 +555,14 @@ void test_remove(std::string const& test_path, bool unbuffered)
|
|||
fs.add_file("temp_storage/_folder3/subfolder/test5.tmp", 8);
|
||||
libtorrent::create_torrent t(fs, 4, -1, 0);
|
||||
|
||||
char buf[4] = {0, 0, 0, 0};
|
||||
sha1_hash h = hasher(buf, 4).final();
|
||||
char buf_[4] = {0, 0, 0, 0};
|
||||
sha1_hash h = hasher(buf_, 4).final();
|
||||
for (int i = 0; i < 6; ++i) t.set_hash(i, h);
|
||||
|
||||
boost::intrusive_ptr<torrent_info> info(new torrent_info(t.generate()));
|
||||
std::vector<char> buf;
|
||||
bencode(std::back_inserter(buf), t.generate());
|
||||
error_code ec;
|
||||
boost::intrusive_ptr<torrent_info> info(new torrent_info(&buf[0], buf.size(), ec));
|
||||
|
||||
session_settings set;
|
||||
set.disk_io_write_mode = set.disk_io_read_mode
|
||||
|
@ -642,7 +645,10 @@ void test_check_files(std::string const& test_path
|
|||
f.write(piece2, sizeof(piece2));
|
||||
f.close();
|
||||
|
||||
info = new torrent_info(t.generate());
|
||||
std::vector<char> buf;
|
||||
error_code ec;
|
||||
bencode(std::back_inserter(buf), t.generate());
|
||||
info = new torrent_info(&buf[0], buf.size(), ec);
|
||||
|
||||
file_pool fp;
|
||||
libtorrent::asio::io_service ios;
|
||||
|
@ -705,7 +711,10 @@ void run_test(std::string const& test_path, bool unbuffered)
|
|||
t.set_hash(1, hasher(piece1, piece_size).final());
|
||||
t.set_hash(2, hasher(piece2, piece_size).final());
|
||||
|
||||
info = new torrent_info(t.generate());
|
||||
std::vector<char> buf;
|
||||
bencode(std::back_inserter(buf), t.generate());
|
||||
error_code ec;
|
||||
info = new torrent_info(&buf[0], buf.size(), ec);
|
||||
std::cerr << "=== test 1 ===" << std::endl;
|
||||
|
||||
run_storage_tests(info, fs, test_path, storage_mode_compact, unbuffered);
|
||||
|
@ -736,7 +745,10 @@ void run_test(std::string const& test_path, bool unbuffered)
|
|||
t.set_hash(1, hasher(piece1, piece_size).final());
|
||||
t.set_hash(2, hasher(piece2, piece_size).final());
|
||||
|
||||
info = new torrent_info(t.generate());
|
||||
std::vector<char> buf;
|
||||
bencode(std::back_inserter(buf), t.generate());
|
||||
error_code ec;
|
||||
info = new torrent_info(&buf[0], buf.size(), ec);
|
||||
|
||||
std::cerr << "=== test 3 ===" << std::endl;
|
||||
|
||||
|
|
|
@ -180,7 +180,10 @@ int test_main()
|
|||
|
||||
// calculate the hash for all pieces
|
||||
set_piece_hashes(t, "./tmp1_web_seed", ec);
|
||||
boost::intrusive_ptr<torrent_info> torrent_file(new torrent_info(t.generate()));
|
||||
std::vector<char> buf;
|
||||
error_code ec;
|
||||
bencode(std::back_inserter(buf), t.generate());
|
||||
boost::intrusive_ptr<torrent_info> torrent_file(new torrent_info(&buf[0], buf.size(), ec));
|
||||
|
||||
for (int i = 0; i < 6; ++i)
|
||||
test_transfer(torrent_file, i, port);
|
||||
|
|
Loading…
Reference in New Issue