minor improvements to test_checking

This commit is contained in:
Arvid Norberg 2018-06-10 13:13:33 +02:00 committed by Arvid Norberg
parent e7fe7f1b89
commit 1b62aff9d1
2 changed files with 7 additions and 1 deletions

View File

@ -653,10 +653,11 @@ void create_random_files(std::string const& path, const int file_sizes[], int nu
std::string full_path = combine_path(path, dirname);
lt::create_directories(full_path, ec);
if (ec) fprintf(stderr, "create_directory(%s) failed: (%d) %s\n"
if (ec) std::printf("create_directory(%s) failed: (%d) %s\n"
, full_path.c_str(), ec.value(), ec.message().c_str());
full_path = combine_path(full_path, filename);
std::printf("creating file: %s\n", full_path.c_str());
int to_write = file_sizes[i];
if (fs) fs->add_file(full_path, to_write);

View File

@ -320,6 +320,8 @@ TORRENT_TEST(discrete_checking)
file_storage fs;
create_random_files("test_torrent_dir", file_sizes, num_files, &fs);
TEST_EQUAL(fs.num_files(), 2);
lt::create_torrent t(fs, piece_size, 1, lt::create_torrent::optimize_alignment);
set_piece_hashes(t, ".", ec);
if (ec) printf("ERROR: set_piece_hashes: (%d) %s\n", ec.value(), ec.message().c_str());
@ -328,7 +330,10 @@ TORRENT_TEST(discrete_checking)
bencode(std::back_inserter(buf), t.generate());
auto ti = std::make_shared<torrent_info>(buf, ec, from_span);
printf("generated torrent: %s test_torrent_dir\n", aux::to_hex(ti->info_hash().to_string()).c_str());
// we have two files, but there's a padfile now too
TEST_EQUAL(ti->num_files(), 3);
{
session ses1(settings());
add_torrent_params p;