• Home
  • History
  • Annotate
  • Line#
  • Navigate
  • Raw
  • Download
  • only in /netgear-R7000-V1.0.7.12_1.2.5/ap/gpl/transmission/transmission-2.73/libtransmission/
1#include "transmission.h"
2#include "magnet.h"
3#include "utils.h"
4
5#undef VERBOSE
6#include "libtransmission-test.h"
7
8static int
9test1( void )
10{
11    int i;
12    const char * uri;
13    tr_magnet_info * info;
14    const int dec[] = { 210, 53, 64, 16, 163, 202, 74, 222, 91, 116,
15                        39, 187, 9, 58, 98, 163, 137, 159, 243, 129 };
16
17    uri = "magnet:?xt=urn:btih:"
18          "d2354010a3ca4ade5b7427bb093a62a3899ff381"
19          "&dn=Display%20Name"
20          "&tr=http%3A%2F%2Ftracker.openbittorrent.com%2Fannounce"
21          "&tr=http%3A%2F%2Ftracker.opentracker.org%2Fannounce"
22          "&ws=http%3A%2F%2Fserver.webseed.org%2Fpath%2Fto%2Ffile";
23    info = tr_magnetParse( uri );
24    check( info != NULL );
25    check_int_eq( 2, info->trackerCount );
26    check_streq( info->trackers[0], "http://tracker.openbittorrent.com/announce" );
27    check_streq( info->trackers[1], "http://tracker.opentracker.org/announce" );
28    check_int_eq( 1, info->webseedCount );
29    check_streq( "http://server.webseed.org/path/to/file", info->webseeds[0] );
30    check_streq( "Display Name", info->displayName );
31    for( i=0; i<20; ++i )
32        check( info->hash[i] == dec[i] );
33    tr_magnetFree( info );
34    info = NULL;
35
36    /* same thing but in base32 encoding */
37    uri = "magnet:?xt=urn:btih:"
38          "2I2UAEFDZJFN4W3UE65QSOTCUOEZ744B"
39          "&dn=Display%20Name"
40          "&tr=http%3A%2F%2Ftracker.openbittorrent.com%2Fannounce"
41          "&ws=http%3A%2F%2Fserver.webseed.org%2Fpath%2Fto%2Ffile"
42          "&tr=http%3A%2F%2Ftracker.opentracker.org%2Fannounce";
43    info = tr_magnetParse( uri );
44    check( info != NULL );
45    check_int_eq( 2, info->trackerCount );
46    check_streq( "http://tracker.openbittorrent.com/announce", info->trackers[0] );
47    check_streq( "http://tracker.opentracker.org/announce", info->trackers[1] );
48    check_int_eq( 1, info->webseedCount );
49    check_streq( "http://server.webseed.org/path/to/file", info->webseeds[0] );
50    check_streq( "Display Name", info->displayName );
51    for( i=0; i<20; ++i )
52        check( info->hash[i] == dec[i] );
53    tr_magnetFree( info );
54    info = NULL;
55
56    return 0;
57}
58
59MAIN_SINGLE_TEST(test1)
60
61