source: trunk/libtransmission/session-test.c

Last change on this file was 14721, checked in by jordan, 5 years ago

fix a handful of minor compiler warnings, mostly in the unit tests, eg field width shortening or implicit signed/unsigned conversions

  • Property svn:keywords set to Date Rev Author Id
File size: 925 bytes
Line 
1/*
2 * This file Copyright (C) 2013-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: session-test.c 14721 2016-03-29 03:04:54Z mikedld $
8 */
9
10#include <stdio.h>
11#include <stdlib.h>
12#include <string.h>
13#include "transmission.h"
14#include "session.h"
15#include "utils.h"
16#include "version.h"
17
18#undef VERBOSE
19#include "libtransmission-test.h"
20
21static int
22testPeerId (void)
23{
24    int i;
25    uint8_t peer_id[PEER_ID_LEN+1];
26
27    for (i = 0; i < 100000; ++i)
28    {
29        int j;
30        int val = 0;
31
32        tr_peerIdInit (peer_id);
33
34        check (strlen ((char*)peer_id) == PEER_ID_LEN);
35        check (memcmp (peer_id, PEERID_PREFIX, 8) == 0);
36
37        for (j = 8; j < PEER_ID_LEN; ++j)
38        {
39            char tmp[2] = { (char)peer_id[j], '\0' };
40            val += strtoul (tmp, NULL, 36);
41        }
42
43        check ((val % 36) == 0);
44    }
45
46    return 0;
47}
48
49MAIN_SINGLE_TEST (testPeerId)
Note: See TracBrowser for help on using the repository browser.