fixes to unit tests

This commit is contained in:
Arvid Norberg 2008-11-30 06:10:37 +00:00
parent 6027f9f20c
commit 490ad37c43
2 changed files with 14 additions and 14 deletions

View File

@ -56,9 +56,9 @@ int test_main()
{
file_storage fs;
size_type file_size = 1 * 1024 * 1024 * 1024;
fs.add_file("test_torrent/tmp1", file_size);
fs.add_file("test_torrent/tmp2", file_size);
fs.add_file("test_torrent/tmp3", file_size);
fs.add_file("test_torrent_dir2/tmp1", file_size);
fs.add_file("test_torrent_dir2/tmp2", file_size);
fs.add_file("test_torrent_dir2/tmp3", file_size);
libtorrent::create_torrent t(fs, 4 * 1024 * 1024);
t.add_tracker("http://non-existing.com/announce");
@ -83,7 +83,7 @@ int test_main()
{
file_storage fs;
fs.add_file("test_torrent/tmp1", 0);
fs.add_file("test_torrent_dir2/tmp1", 0);
libtorrent::create_torrent t(fs, 4 * 1024 * 1024);
t.add_tracker("http://non-existing.com/announce");

View File

@ -133,22 +133,22 @@ int test_main()
using namespace boost::filesystem;
try {
create_directory("test_torrent");
create_directory("test_torrent_dir");
} catch (std::exception&) {}
char random_data[300000];
std::srand(std::time(0));
std::generate(random_data, random_data + sizeof(random_data), &std::rand);
std::ofstream("./test_torrent/test1").write(random_data, 35);
std::ofstream("./test_torrent/test2").write(random_data, 16536 - 35);
std::ofstream("./test_torrent/test3").write(random_data, 16536);
std::ofstream("./test_torrent/test4").write(random_data, 17);
std::ofstream("./test_torrent/test5").write(random_data, 16536);
std::ofstream("./test_torrent/test6").write(random_data, 300000);
std::ofstream("./test_torrent/test7").write(random_data, 300000);
std::ofstream("./test_torrent_dir/test1").write(random_data, 35);
std::ofstream("./test_torrent_dir/test2").write(random_data, 16536 - 35);
std::ofstream("./test_torrent_dir/test3").write(random_data, 16536);
std::ofstream("./test_torrent_dir/test4").write(random_data, 17);
std::ofstream("./test_torrent_dir/test5").write(random_data, 16536);
std::ofstream("./test_torrent_dir/test6").write(random_data, 300000);
std::ofstream("./test_torrent_dir/test7").write(random_data, 300000);
file_storage fs;
add_files(fs, path("test_torrent"));
add_files(fs, path("test_torrent_dir"));
libtorrent::create_torrent t(fs, 16 * 1024);
t.add_url_seed("http://127.0.0.1:8000/");
@ -176,7 +176,7 @@ int test_main()
test_transfer(torrent_file, i);
stop_web_server(8000);
remove_all("./test_torrent");
remove_all("./test_torrent_dir");
return 0;
}