expand unit tests

This commit is contained in:
Arvid Norberg 2015-02-14 06:14:15 +00:00
parent 1e9e8e5f26
commit e15e5fd80a
4 changed files with 39 additions and 0 deletions

View File

@ -921,6 +921,7 @@ bool handle_alert(libtorrent::session& ses, libtorrent::alert* a
{
dht_active_requests.swap(p->active_requests);
dht_routing_table.swap(p->routing_table);
return true;
}
#endif

View File

@ -391,6 +391,20 @@ int test_main()
TEST_EQUAL(resolve_redirect_location("http://example.com/a/b", "http://test.com/d")
, "http://test.com/d");
TEST_EQUAL(is_ok_status(200), true);
TEST_EQUAL(is_ok_status(206), true);
TEST_EQUAL(is_ok_status(299), false);
TEST_EQUAL(is_ok_status(300), true);
TEST_EQUAL(is_ok_status(399), true);
TEST_EQUAL(is_ok_status(400), false);
TEST_EQUAL(is_ok_status(299), false);
TEST_EQUAL(is_redirect(299), false);
TEST_EQUAL(is_redirect(100), false);
TEST_EQUAL(is_redirect(300), true);
TEST_EQUAL(is_redirect(399), true);
TEST_EQUAL(is_redirect(400), false);
return 0;
}

View File

@ -1626,6 +1626,27 @@ int test_main()
TEST_CHECK(std::find_if(downloads.begin(), downloads.end()
, boost::bind(&piece_picker::downloading_piece::index, _1) == 3) != downloads.end());
// ========================================================
print_title("test get_download_queue_size");
p = setup_picker("1111111", " ", "1111111", "0327ff0");
TEST_EQUAL(p->get_download_queue_size(), 5);
p->set_piece_priority(1, 0);
int partial;
int full;
int finished;
int zero_prio;
p->get_download_queue_sizes(&partial, &full, &finished, &zero_prio);
TEST_EQUAL(partial, 2);
TEST_EQUAL(full, 0);
TEST_EQUAL(finished, 2);
TEST_EQUAL(zero_prio, 1);
/*
p.pick_pieces(peer1, picked, 1, false, 0, true);

View File

@ -130,6 +130,9 @@ int test_main()
TEST_CHECK(base32decode("MZXW6YTBOI") == "foobar");
TEST_CHECK(base32decode("mZXw6yTBO1======") == "foobar");
// make sure invalid encoding returns the empty string
TEST_CHECK(base32decode("mZXw6yTBO1{#&*()=") == "");
std::string test;
for (int i = 0; i < 255; ++i)
test += char(i);