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

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

(trunk libT) API cleanup of the tr_address functions to make them more consistent.

This is loosely related to #2910, but only in the sense of laying the groundwork for #2910's fix...

File size: 1.6 KB
Line 
1#include <stdio.h>
2#include "transmission.h"
3#include "net.h"
4#include "peer-msgs.h"
5#include "utils.h"
6
7#undef VERBOSE
8
9#ifdef VERBOSE
10  #define check( A ) \
11    { \
12        ++test; \
13        if( A ){ \
14            fprintf( stderr, "PASS test #%d (%s, %d)\n", test, __FILE__, __LINE__ ); \
15        } else { \
16            fprintf( stderr, "FAIL test #%d (%s, %d)\n", test, __FILE__, __LINE__ ); \
17            return test; \
18        } \
19    }
20#else
21  #define check( A ) \
22    { \
23        ++test; \
24        if( !( A ) ){ \
25            fprintf( stderr, "FAIL test #%d (%s, %d)\n", test, __FILE__, __LINE__ ); \
26            return test; \
27        } \
28    }
29#endif
30
31int
32main( void )
33{
34#if 0
35    uint32_t           i;
36    int                test = 0;
37    uint8_t            infohash[SHA_DIGEST_LENGTH];
38    struct tr_address  addr;
39    tr_piece_index_t   pieceCount = 1313;
40    size_t             numwant;
41    size_t             numgot;
42    tr_piece_index_t pieces[] = { 1059, 431, 808, 1217, 287, 376, 1188, 353, 508 };
43    tr_piece_index_t buf[16];
44
45    for( i = 0; i < SHA_DIGEST_LENGTH; ++i )
46        infohash[i] = 0xaa;
47    tr_address_from_string( &addr, "80.4.4.200" );
48
49    numwant = 7;
50    numgot = tr_generateAllowedSet( buf, numwant, pieceCount, infohash, &addr );
51    check( numgot == numwant );
52    for( i=0; i<numgot; ++i )
53        check( buf[i] == pieces[i] );
54
55    numwant = 9;
56    numgot = tr_generateAllowedSet( buf, numwant, pieceCount, infohash, &addr );
57    check( numgot == numwant );
58    for( i=0; i<numgot; ++i )
59        check( buf[i] == pieces[i] );
60#endif
61
62    return 0;
63}
64
Note: See TracBrowser for help on using the repository browser.