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-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;
|
|
|
|
|
2008-09-23 19:11:04 +00:00
|
|
|
for( i = 0; i < 100000; ++i )
|
2008-01-07 17:52:50 +00:00
|
|
|
{
|
2008-09-23 19:11:04 +00:00
|
|
|
int j;
|
|
|
|
int val = 0;
|
2008-01-07 17:52:50 +00:00
|
|
|
uint8_t * pch = tr_peerIdNew( );
|
|
|
|
|
|
|
|
check( strlen( (char*)pch ) == 20 );
|
|
|
|
check( !memcmp( pch, PEERID_PREFIX, 8 ) );
|
|
|
|
|
2008-09-23 19:11:04 +00:00
|
|
|
for( j = 8; j < 20; ++j )
|
|
|
|
{
|
2008-01-07 17:52:50 +00:00
|
|
|
char tmp[2] = { pch[j], '\0' };
|
|
|
|
val += strtoul( tmp, NULL, 36 );
|
|
|
|
}
|
|
|
|
|
|
|
|
check( ( val % 36 ) == 0 );
|
|
|
|
|
|
|
|
tr_free( pch );
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2008-09-23 19:11:04 +00:00
|
|
|
|