source: trunk/libtransmission/clients-test.c @ 12918

Last change on this file since 12918 was 12223, checked in by jordan, 11 years ago

(trunk) copyediting: remove some unneeded #includes, and annotate some needed ones

File size: 1.5 KB
Line 
1#include <stdio.h>
2#include <string.h>
3#include "transmission.h"
4#include "clients.h"
5
6#undef VERBOSE
7
8#ifdef VERBOSE
9  #define check( A ) \
10    { \
11        ++test; \
12        if( A ){ \
13            fprintf( stderr, "PASS test #%d (%s, %d)\n", test, __FILE__, __LINE__ ); \
14        } else { \
15            fprintf( stderr, "FAIL test #%d (%s, %d)\n", test, __FILE__, __LINE__ ); \
16            return test; \
17        } \
18    }
19#else
20  #define check( A ) \
21    { \
22        ++test; \
23        if( !( A ) ){ \
24            fprintf( stderr, "FAIL test #%d (%s, %d)\n", test, __FILE__, __LINE__ ); \
25            return test; \
26        } \
27    }
28#endif
29
30#define TEST_CLIENT( A, B ) \
31    tr_clientForId( buf, sizeof( buf ), A ); \
32    check( !strcmp( buf, B ) );
33
34int
35main( void )
36{
37    int  test = 0;
38    char buf[128];
39
40    TEST_CLIENT( "-FC1013-", "FileCroc 1.0.1.3" );
41    TEST_CLIENT( "-MR1100-", "Miro 1.1.0.0" );
42    TEST_CLIENT( "-TR0006-", "Transmission 0.6" );
43    TEST_CLIENT( "-TR0072-", "Transmission 0.72" );
44    TEST_CLIENT( "-TR111Z-", "Transmission 1.11+" );
45    TEST_CLIENT( "O1008132", "Osprey 1.0.0" );
46
47    /* gobbledygook */
48    TEST_CLIENT( "-IIO\x10\x2D\x04-", "-IIO%10-%04-" );
49    TEST_CLIENT( "-I\05O\x08\x03\x01-", "-I%05O%08%03%01-" );
50
51    TEST_CLIENT(
52        "\x65\x78\x62\x63\x00\x38\x7A\x44\x63\x10\x2D\x6E\x9A\xD6\x72\x3B\x33\x9F\x35\xA9",
53        "BitComet 0.56" );
54    TEST_CLIENT(
55        "\x65\x78\x62\x63\x00\x38\x4C\x4F\x52\x44\x32\x00\x04\x8E\xCE\xD5\x7B\xD7\x10\x28",
56        "BitLord 0.56" );
57
58    /* cleanup */
59    return 0;
60}
61
Note: See TracBrowser for help on using the repository browser.