2008-01-07 17:52:50 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include "transmission.h"
|
2008-12-23 17:27:15 +00:00
|
|
|
#include "session.h"
|
2008-01-07 17:52:50 +00:00
|
|
|
#include "utils.h"
|
2009-04-13 19:04:21 +00:00
|
|
|
#include "version.h"
|
2008-01-07 17:52:50 +00:00
|
|
|
|
2009-01-23 18:44:15 +00:00
|
|
|
#undef VERBOSE
|
2008-01-07 17:52:50 +00:00
|
|
|
|
2009-01-23 18:44:15 +00:00
|
|
|
#ifdef VERBOSE
|
|
|
|
#define check( A ) \
|
2008-09-23 19:11:04 +00:00
|
|
|
{ \
|
|
|
|
++test; \
|
|
|
|
if( A ){ \
|
2009-01-23 18:44:15 +00:00
|
|
|
fprintf( stderr, "PASS test #%d (%s, %d)\n", test, __FILE__, __LINE__ ); \
|
2008-09-23 19:11:04 +00:00
|
|
|
} else { \
|
2009-01-23 18:44:15 +00:00
|
|
|
fprintf( stderr, "FAIL test #%d (%s, %d)\n", test, __FILE__, __LINE__ ); \
|
2008-09-23 19:11:04 +00:00
|
|
|
return test; \
|
|
|
|
} \
|
|
|
|
}
|
2009-01-23 18:44:15 +00:00
|
|
|
#else
|
|
|
|
#define check( A ) \
|
|
|
|
{ \
|
|
|
|
++test; \
|
|
|
|
if( !( A ) ){ \
|
|
|
|
fprintf( stderr, "FAIL test #%d (%s, %d)\n", test, __FILE__, __LINE__ ); \
|
|
|
|
return test; \
|
|
|
|
} \
|
|
|
|
}
|
|
|
|
#endif
|
2008-01-07 17:52:50 +00:00
|
|
|
|
|
|
|
int
|
|
|
|
main( void )
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
int test = 0;
|
2011-03-10 12:35:23 +00:00
|
|
|
uint8_t peer_id[PEER_ID_LEN+1];
|
2008-01-07 17:52:50 +00:00
|
|
|
|
2008-09-23 19:11:04 +00:00
|
|
|
for( i = 0; i < 100000; ++i )
|
2008-01-07 17:52:50 +00:00
|
|
|
{
|
2011-03-10 12:35:23 +00:00
|
|
|
int j;
|
|
|
|
int val = 0;
|
2008-01-07 17:52:50 +00:00
|
|
|
|
2011-03-10 12:35:23 +00:00
|
|
|
tr_peerIdInit( peer_id );
|
2008-01-07 17:52:50 +00:00
|
|
|
|
2011-03-10 12:35:23 +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 )
|
2008-09-23 19:11:04 +00:00
|
|
|
{
|
2011-03-10 12:35:23 +00:00
|
|
|
char tmp[2] = { peer_id[j], '\0' };
|
2008-01-07 17:52:50 +00:00
|
|
|
val += strtoul( tmp, NULL, 36 );
|
|
|
|
}
|
|
|
|
|
|
|
|
check( ( val % 36 ) == 0 );
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2008-09-23 19:11:04 +00:00
|
|
|
|