transmission/libtransmission/session-test.c

50 lines
915 B
C
Raw Normal View History

/*
* This file Copyright (C) 2013-2014 Mnemosyne LLC
*
* It may be used under the GNU GPL versions 2 or 3
* or any future license endorsed by Mnemosyne LLC.
*
* $Id$
*/
2008-01-07 17:52:50 +00:00
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "transmission.h"
#include "session.h"
2008-01-07 17:52:50 +00:00
#include "utils.h"
#include "version.h"
2008-01-07 17:52:50 +00:00
#undef VERBOSE
#include "libtransmission-test.h"
2008-01-07 17:52:50 +00:00
static int
testPeerId (void)
2008-01-07 17:52:50 +00:00
{
int i;
uint8_t peer_id[PEER_ID_LEN+1];
2008-01-07 17:52:50 +00:00
for (i = 0; i < 100000; ++i)
2008-01-07 17:52:50 +00:00
{
int j;
int val = 0;
2008-01-07 17:52:50 +00:00
tr_peerIdInit (peer_id);
2008-01-07 17:52:50 +00:00
check (strlen ((char*)peer_id) == PEER_ID_LEN);
check (!memcmp (peer_id, PEERID_PREFIX, 8));
for (j = 8; j < PEER_ID_LEN; ++j)
{
char tmp[2] = { peer_id[j], '\0' };
val += strtoul (tmp, NULL, 36);
2008-01-07 17:52:50 +00:00
}
check ((val % 36) == 0);
2008-01-07 17:52:50 +00:00
}
return 0;
}
MAIN_SINGLE_TEST (testPeerId)