source: trunk/libtransmission/magnet-test.c

Last change on this file was 14241, checked in by jordan, 7 years ago

Copyedit the license's revised text: (1) remove unnecessary repitition use of the word 'license' from the top of the header and source files (2) add the standard 'we hope it's useful, but no warranty' clause to COPYING (3) make explicit that linking OpenSSL is allowed (see https://people.gnome.org/~markmc/openssl-and-the-gpl.html for background) (4) sync the Qt and GTK+ clients' license popups with COPYING's revised text

  • Property svn:keywords set to Date Rev Author Id
File size: 2.3 KB
Line 
1/*
2 * This file Copyright (C) 2010-2014 Mnemosyne LLC
3 *
4 * It may be used under the GNU GPL versions 2 or 3
5 * or any future license endorsed by Mnemosyne LLC.
6 *
7 * $Id: magnet-test.c 14241 2014-01-21 03:10:30Z mikedld $
8 */
9
10#include "transmission.h"
11#include "magnet.h"
12#include "utils.h"
13
14#include "libtransmission-test.h"
15
16static int
17test1 (void)
18{
19    int i;
20    const char * uri;
21    tr_magnet_info * info;
22    const int dec[] = { 210, 53, 64, 16, 163, 202, 74, 222, 91, 116,
23                        39, 187, 9, 58, 98, 163, 137, 159, 243, 129 };
24
25    uri = "magnet:?xt=urn:btih:"
26          "d2354010a3ca4ade5b7427bb093a62a3899ff381"
27          "&dn=Display%20Name"
28          "&tr=http%3A%2F%2Ftracker.openbittorrent.com%2Fannounce"
29          "&tr=http%3A%2F%2Ftracker.opentracker.org%2Fannounce"
30          "&ws=http%3A%2F%2Fserver.webseed.org%2Fpath%2Fto%2Ffile";
31    info = tr_magnetParse (uri);
32    check (info != NULL);
33    check_int_eq (2, info->trackerCount);
34    check_streq (info->trackers[0], "http://tracker.openbittorrent.com/announce");
35    check_streq (info->trackers[1], "http://tracker.opentracker.org/announce");
36    check_int_eq (1, info->webseedCount);
37    check_streq ("http://server.webseed.org/path/to/file", info->webseeds[0]);
38    check_streq ("Display Name", info->displayName);
39    for (i=0; i<20; ++i)
40        check (info->hash[i] == dec[i]);
41    tr_magnetFree (info);
42    info = NULL;
43
44    /* same thing but in base32 encoding */
45    uri = "magnet:?xt=urn:btih:"
46          "2I2UAEFDZJFN4W3UE65QSOTCUOEZ744B"
47          "&dn=Display%20Name"
48          "&tr=http%3A%2F%2Ftracker.openbittorrent.com%2Fannounce"
49          "&ws=http%3A%2F%2Fserver.webseed.org%2Fpath%2Fto%2Ffile"
50          "&tr=http%3A%2F%2Ftracker.opentracker.org%2Fannounce";
51    info = tr_magnetParse (uri);
52    check (info != NULL);
53    check_int_eq (2, info->trackerCount);
54    check_streq ("http://tracker.openbittorrent.com/announce", info->trackers[0]);
55    check_streq ("http://tracker.opentracker.org/announce", info->trackers[1]);
56    check_int_eq (1, info->webseedCount);
57    check_streq ("http://server.webseed.org/path/to/file", info->webseeds[0]);
58    check_streq ("Display Name", info->displayName);
59    for (i=0; i<20; ++i)
60        check (info->hash[i] == dec[i]);
61    tr_magnetFree (info);
62    info = NULL;
63
64    return 0;
65}
66
67MAIN_SINGLE_TEST (test1)
68
Note: See TracBrowser for help on using the repository browser.