add test to make sure magnet links that fail to be parsed report errors
This commit is contained in:
parent
a12bfe3164
commit
f01801339c
|
@ -161,5 +161,13 @@ extern int EXPORT _g_test_failures;
|
|||
TEST_ERROR("Exception thrown: " #x); \
|
||||
}
|
||||
|
||||
#define TEST_THROW(x) \
|
||||
try \
|
||||
{ \
|
||||
x; \
|
||||
TEST_ERROR("No exception thrown: " #x); \
|
||||
} \
|
||||
catch (...) {}
|
||||
|
||||
#endif // TEST_HPP
|
||||
|
||||
|
|
|
@ -395,3 +395,18 @@ TORRENT_TEST(make_magnet_uri2)
|
|||
TEST_CHECK(magnet.find("&ws=http%3a%2f%2ffoo.com%2fbar") != std::string::npos);
|
||||
}
|
||||
|
||||
TORRENT_TEST(trailing_whitespace)
|
||||
{
|
||||
session ses(settings());
|
||||
add_torrent_params p;
|
||||
p.save_path = ".";
|
||||
p.url = "magnet:?xt=urn:btih:abaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n";
|
||||
// invalid hash
|
||||
TEST_THROW(ses.add_torrent(p));
|
||||
|
||||
p.url = "magnet:?xt=urn:btih:abaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
|
||||
// now it's valid, because there's no trailing whitespace
|
||||
torrent_handle h = ses.add_torrent(p);
|
||||
TEST_CHECK(h.is_valid());
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue