source: trunk/libtransmission/peer-msgs-test.c @ 12545

Last change on this file since 12545 was 12230, checked in by jordan, 11 years ago

(trunk libT) copyediting: yes, removing more unnecessary #includes

File size: 1.5 KB
Line 
1#include <stdio.h>
2#include "transmission.h"
3#include "peer-msgs.h"
4#include "utils.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
30int
31main( void )
32{
33#if 0
34    uint32_t           i;
35    int                test = 0;
36    uint8_t            infohash[SHA_DIGEST_LENGTH];
37    struct tr_address  addr;
38    tr_piece_index_t   pieceCount = 1313;
39    size_t             numwant;
40    size_t             numgot;
41    tr_piece_index_t pieces[] = { 1059, 431, 808, 1217, 287, 376, 1188, 353, 508 };
42    tr_piece_index_t buf[16];
43
44    for( i = 0; i < SHA_DIGEST_LENGTH; ++i )
45        infohash[i] = 0xaa;
46    tr_address_from_string( &addr, "80.4.4.200" );
47
48    numwant = 7;
49    numgot = tr_generateAllowedSet( buf, numwant, pieceCount, infohash, &addr );
50    check( numgot == numwant );
51    for( i=0; i<numgot; ++i )
52        check( buf[i] == pieces[i] );
53
54    numwant = 9;
55    numgot = tr_generateAllowedSet( buf, numwant, pieceCount, infohash, &addr );
56    check( numgot == numwant );
57    for( i=0; i<numgot; ++i )
58        check( buf[i] == pieces[i] );
59#endif
60
61    return 0;
62}
63
Note: See TracBrowser for help on using the repository browser.