diff --git a/examples/client_test.cpp b/examples/client_test.cpp index 8f2f2394e..57c9258cc 100644 --- a/examples/client_test.cpp +++ b/examples/client_test.cpp @@ -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 diff --git a/test/test_http_parser.cpp b/test/test_http_parser.cpp index eeed8544a..17ef4c043 100644 --- a/test/test_http_parser.cpp +++ b/test/test_http_parser.cpp @@ -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; } diff --git a/test/test_piece_picker.cpp b/test/test_piece_picker.cpp index eef7e93bb..8235b7758 100644 --- a/test/test_piece_picker.cpp +++ b/test/test_piece_picker.cpp @@ -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); diff --git a/test/test_string.cpp b/test/test_string.cpp index 3834436ea..b5de90f27 100644 --- a/test/test_string.cpp +++ b/test/test_string.cpp @@ -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);