2008-04-29 16:57:16 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include "transmission.h"
|
|
|
|
#include "clients.h"
|
|
|
|
|
2009-01-23 18:44:15 +00:00
|
|
|
#undef VERBOSE
|
2008-04-29 16:57:16 +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-04-29 16:57:16 +00:00
|
|
|
|
2008-09-23 19:11:04 +00:00
|
|
|
#define TEST_CLIENT( A, B ) \
|
|
|
|
tr_clientForId( buf, sizeof( buf ), A ); \
|
|
|
|
check( !strcmp( buf, B ) );
|
2008-05-01 19:30:49 +00:00
|
|
|
|
2008-04-29 16:57:16 +00:00
|
|
|
int
|
|
|
|
main( void )
|
|
|
|
{
|
2008-09-23 19:11:04 +00:00
|
|
|
int test = 0;
|
2008-04-29 16:57:16 +00:00
|
|
|
char buf[128];
|
|
|
|
|
2008-05-01 19:30:49 +00:00
|
|
|
TEST_CLIENT( "-FC1013-", "FileCroc 1.0.1.3" );
|
|
|
|
TEST_CLIENT( "-MR1100-", "Miro 1.1.0.0" );
|
|
|
|
TEST_CLIENT( "-TR0006-", "Transmission 0.6" );
|
|
|
|
TEST_CLIENT( "-TR0072-", "Transmission 0.72" );
|
|
|
|
TEST_CLIENT( "-TR111Z-", "Transmission 1.11+" );
|
2008-10-01 18:11:28 +00:00
|
|
|
TEST_CLIENT( "O1008132", "Osprey 1.0.0" );
|
2008-04-29 16:57:16 +00:00
|
|
|
|
2009-05-29 19:17:12 +00:00
|
|
|
/* gobbledygook */
|
|
|
|
TEST_CLIENT( "-IIO\x10\x2D\x04-", "-IIO%10-%04-" );
|
|
|
|
TEST_CLIENT( "-I\05O\x08\x03\x01-", "-I%05O%08%03%01-" );
|
|
|
|
|
2008-09-23 19:11:04 +00:00
|
|
|
TEST_CLIENT(
|
|
|
|
"\x65\x78\x62\x63\x00\x38\x7A\x44\x63\x10\x2D\x6E\x9A\xD6\x72\x3B\x33\x9F\x35\xA9",
|
|
|
|
"BitComet 0.56" );
|
|
|
|
TEST_CLIENT(
|
|
|
|
"\x65\x78\x62\x63\x00\x38\x4C\x4F\x52\x44\x32\x00\x04\x8E\xCE\xD5\x7B\xD7\x10\x28",
|
|
|
|
"BitLord 0.56" );
|
2008-06-16 17:26:19 +00:00
|
|
|
|
2008-04-29 16:57:16 +00:00
|
|
|
/* cleanup */
|
|
|
|
return 0;
|
|
|
|
}
|
2008-09-23 19:11:04 +00:00
|
|
|
|