@@ -110,20 +110,19 @@ TORRENT_TEST(magnet)
110
110
s->save_state (session_state);
111
111
112
112
// test magnet link parsing
113
- error_code ec;
114
113
add_torrent_params p = parse_magnet_uri (" magnet:?xt=urn:btih:cdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcd"
115
114
" &tr=http://1"
116
115
" &tr=http://2"
117
116
" &tr=http://3"
118
117
" &tr=http://3"
119
118
" &dn=foo"
120
- " &dht=127.0.0.1:43" , ec );
119
+ " &dht=127.0.0.1:43" );
121
120
122
121
p.flags &= ~torrent_flags::paused;
123
122
p.flags &= ~torrent_flags::auto_managed;
124
123
p.save_path = " ." ;
125
124
126
- TEST_CHECK (!ec) ;
125
+ error_code ec ;
127
126
torrent_handle t = s->add_torrent (p, ec);
128
127
TEST_CHECK (!ec);
129
128
if (ec) std::printf (" %s\n " , ec.message ().c_str ());
@@ -144,8 +143,7 @@ TORRENT_TEST(magnet)
144
143
" &tr=http://2"
145
144
" &dn=foo"
146
145
" &dht=127.0.0.1:43"
147
- " &xt=urn:btih:c352cdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcd" , ec);
148
- TEST_CHECK (!ec);
146
+ " &xt=urn:btih:c352cdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcd" );
149
147
p.flags &= ~torrent_flags::paused;
150
148
p.flags &= ~torrent_flags::auto_managed;
151
149
p.save_path = " ." ;
@@ -163,8 +161,7 @@ TORRENT_TEST(magnet)
163
161
" &tr=udp%3A%2F%2Ftracker.publicbt.com%3A80"
164
162
" &tr=udp%3A%2F%2Ftracker.ccc.de%3A80"
165
163
" &xt=urn:btih:a38d02c287893842a32825aa866e00828a318f07"
166
- " &dn=Ubuntu+11.04+%28Final%29" , ec);
167
- TEST_CHECK (!ec);
164
+ " &dn=Ubuntu+11.04+%28Final%29" );
168
165
p.flags &= ~torrent_flags::paused;
169
166
p.flags &= ~torrent_flags::auto_managed;
170
167
p.save_path = " ." ;
@@ -229,17 +226,13 @@ TORRENT_TEST(magnet)
229
226
230
227
TORRENT_TEST (parse_escaped_hash_parameter)
231
228
{
232
- error_code ec;
233
- add_torrent_params p = parse_magnet_uri (" magnet:?xt=urn%3Abtih%3Acdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcd" , ec);
234
- TEST_CHECK (!ec);
229
+ add_torrent_params p = parse_magnet_uri (" magnet:?xt=urn%3Abtih%3Acdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcd" );
235
230
TEST_EQUAL (aux::to_hex (p.info_hash ), " cdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcd" );
236
231
}
237
232
238
233
TORRENT_TEST (parse_escaped_hash_parameter_in_hex)
239
234
{
240
- error_code ec;
241
- add_torrent_params p = parse_magnet_uri (" magnet:?xt=urn:btih:cdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdc%64" , ec);
242
- TEST_CHECK (!ec);
235
+ add_torrent_params p = parse_magnet_uri (" magnet:?xt=urn:btih:cdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdc%64" );
243
236
TEST_EQUAL (aux::to_hex (p.info_hash ), " cdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcd" );
244
237
}
245
238
@@ -261,70 +254,57 @@ TORRENT_TEST(parse_missing_hash)
261
254
error_code ec;
262
255
add_torrent_params p = parse_magnet_uri (" magnet:?dn=foo&dht=127.0.0.1:43" , ec);
263
256
TEST_EQUAL (ec, error_code (errors::missing_info_hash_in_uri));
264
- ec.clear ();
265
257
}
266
258
267
259
TORRENT_TEST (parse_base32_hash)
268
260
{
269
261
// parse_magnet_uri
270
- error_code ec;
271
- add_torrent_params p = parse_magnet_uri (" magnet:?xt=urn:btih:MFRGCYTBMJQWEYLCMFRGCYTBMJQWEYLC" , ec);
272
- TEST_CHECK (!ec);
262
+ add_torrent_params p = parse_magnet_uri (" magnet:?xt=urn:btih:MFRGCYTBMJQWEYLCMFRGCYTBMJQWEYLC" );
273
263
TEST_EQUAL (p.info_hash , sha1_hash (" abababababababababab" ));
274
- ec.clear ();
275
264
}
276
265
277
266
TORRENT_TEST (parse_web_seeds)
278
267
{
279
268
// parse_magnet_uri
280
- error_code ec;
281
269
add_torrent_params p = parse_magnet_uri (" magnet:?xt=urn:btih:cdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcd"
282
- " &ws=http://foo.com/bar&ws=http://bar.com/foo" , ec);
283
- TEST_CHECK (!ec);
270
+ " &ws=http://foo.com/bar&ws=http://bar.com/foo" );
284
271
TEST_EQUAL (p.url_seeds .size (), 2 );
285
272
TEST_EQUAL (p.url_seeds [0 ], " http://foo.com/bar" );
286
273
TEST_EQUAL (p.url_seeds [1 ], " http://bar.com/foo" );
287
- ec.clear ();
288
274
}
289
275
290
276
TORRENT_TEST (parse_missing_hash2)
291
277
{
292
278
error_code ec;
293
279
add_torrent_params p = parse_magnet_uri (" magnet:?xt=blah&dn=foo&dht=127.0.0.1:43" , ec);
294
280
TEST_EQUAL (ec, error_code (errors::missing_info_hash_in_uri));
295
- ec.clear ();
296
281
}
297
282
298
283
TORRENT_TEST (parse_short_hash)
299
284
{
300
285
error_code ec;
301
286
add_torrent_params p = parse_magnet_uri (" magnet:?xt=urn:btih:abababab" , ec);
302
287
TEST_EQUAL (ec, error_code (errors::invalid_info_hash));
303
- ec.clear ();
304
288
}
305
289
306
290
TORRENT_TEST (parse_long_hash)
307
291
{
308
292
error_code ec;
309
293
add_torrent_params p = parse_magnet_uri (" magnet:?xt=urn:btih:ababababababababababab" , ec);
310
294
TEST_EQUAL (ec, error_code (errors::invalid_info_hash));
311
- ec.clear ();
312
295
}
313
296
314
297
TORRENT_TEST (parse_space_hash)
315
298
{
316
299
error_code ec;
317
300
add_torrent_params p = parse_magnet_uri (" magnet:?xt=urn:btih: abababababababababab" , ec);
318
301
TEST_EQUAL (ec, error_code (errors::invalid_info_hash));
319
- ec.clear ();
320
302
}
321
303
322
304
TORRENT_TEST (parse_peer)
323
305
{
324
- error_code ec;
325
306
add_torrent_params p = parse_magnet_uri (" magnet:?xt=urn:btih:cdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcd"
326
- " &dn=foo&x.pe=127.0.0.1:43&x.pe=<invalid1>&x.pe=<invalid2>:100&x.pe=[::1]:45" , ec);
327
- TEST_CHECK (!ec);
307
+ " &dn=foo&x.pe=127.0.0.1:43&x.pe=<invalid1>&x.pe=<invalid2>:100&x.pe=[::1]:45" );
328
308
#if TORRENT_USE_IPV6
329
309
TEST_EQUAL (p.peers .size (), 2 );
330
310
TEST_EQUAL (p.peers [0 ], ep (" 127.0.0.1" , 43 ));
@@ -333,18 +313,13 @@ TORRENT_TEST(parse_peer)
333
313
TEST_EQUAL (p.peers .size (), 1 );
334
314
TEST_EQUAL (p.peers [0 ], ep (" 127.0.0.1" , 43 ));
335
315
#endif
336
- ec.clear ();
337
316
}
338
317
339
318
#ifndef TORRENT_DISABLE_DHT
340
319
TORRENT_TEST (parse_dht_node)
341
320
{
342
- error_code ec;
343
321
add_torrent_params p = parse_magnet_uri (" magnet:?xt=urn:btih:cdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcd"
344
- " &dn=foo&dht=127.0.0.1:43&dht=10.0.0.1:1337" , ec);
345
- TEST_CHECK (!ec);
346
- if (ec) std::printf (" %s\n " , ec.message ().c_str ());
347
- ec.clear ();
322
+ " &dn=foo&dht=127.0.0.1:43&dht=10.0.0.1:1337" );
348
323
349
324
TEST_EQUAL (p.dht_nodes .size (), 2 );
350
325
TEST_EQUAL (p.dht_nodes [0 ].first , " 127.0.0.1" );
@@ -452,9 +427,8 @@ TORRENT_TEST(trailing_whitespace)
452
427
TEST_THROW (ses.add_torrent (p));
453
428
454
429
ec.clear ();
455
- p = parse_magnet_uri (" magnet:?xt=urn:btih:abaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" , ec );
430
+ p = parse_magnet_uri (" magnet:?xt=urn:btih:abaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" );
456
431
p.save_path = " ." ;
457
- TEST_CHECK (!ec);
458
432
// now it's valid, because there's no trailing whitespace
459
433
torrent_handle h = ses.add_torrent (p);
460
434
TEST_CHECK (h.is_valid ());
@@ -481,9 +455,7 @@ auto const no = dont_download;
481
455
482
456
void test_select_only (string_view uri, std::vector<download_priority_t > expected)
483
457
{
484
- error_code ec;
485
- add_torrent_params p = parse_magnet_uri (uri, ec);
486
- TEST_CHECK (!ec);
458
+ add_torrent_params p = parse_magnet_uri (uri);
487
459
TEST_CHECK (p.file_priorities == expected);
488
460
}
489
461
0 commit comments