Changeset 6376 for trunk/libtransmission/rpc-test.c
- Timestamp:
- Jul 21, 2008, 4:11:47 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/libtransmission/rpc-test.c
r6140 r6376 2 2 #include <string.h> /* strcmp */ 3 3 #include "transmission.h" 4 #include "bencode.h" 5 #include "rpc.h" 4 6 #include "utils.h" 5 7 … … 31 33 int ok; 32 34 char * str = cidrize( in ); 33 /* fprintf( stderr, "in [%s] out [%s] should be[%s]\n", in, str, expected ); */35 /* fprintf( stderr, "in [%s] out [%s] expected [%s]\n", in, str, expected ); */ 34 36 ok = expected ? !strcmp( expected, str ) : !str; 35 37 tr_free( str ); … … 47 49 check( testWildcard( "192.64.0.*", "192.64.0.0/24" ) ); 48 50 check( testWildcard( "192.64.0.1", "192.64.0.1/32" ) ); 49 check( testWildcard( "+192.*.*.*,-192.64.*.*", "+192.0.0.0/8,-192.64.0.0/16" ) ); 51 check( testWildcard( "+192.*.*.*,-192.64.*.*", 52 "+192.0.0.0/8,-192.64.0.0/16" ) ); 50 53 51 54 err = tr_rpcTestACL( NULL, "+192.*.*.*", &errmsg ); … … 64 67 } 65 68 69 static int 70 test_list( void ) 71 { 72 int64_t i; 73 const char * str; 74 tr_benc top; 75 76 tr_rpc_parse_list_str( &top, "12", -1 ); 77 check( tr_bencIsInt( &top ) ); 78 check( tr_bencGetInt( &top, &i ) ); 79 check( i == 12 ); 80 tr_bencFree( &top ); 81 82 tr_rpc_parse_list_str( &top, "12", 1 ); 83 check( tr_bencIsInt( &top ) ); 84 check( tr_bencGetInt( &top, &i ) ); 85 check( i == 1 ); 86 tr_bencFree( &top ); 87 88 tr_rpc_parse_list_str( &top, "6,7", -1 ); 89 check( tr_bencIsList( &top ) ); 90 check( tr_bencListSize( &top ) == 2 ); 91 check( tr_bencGetInt( tr_bencListChild( &top, 0 ), &i ) ); 92 check( i == 6 ); 93 check( tr_bencGetInt( tr_bencListChild( &top, 1 ), &i ) ); 94 check( i == 7 ); 95 tr_bencFree( &top ); 96 97 tr_rpc_parse_list_str( &top, "asdf", -1 ); 98 check( tr_bencIsString( &top ) ); 99 check( tr_bencGetStr( &top, &str ) ); 100 check( !strcmp( str, "asdf" ) ); 101 tr_bencFree( &top ); 102 103 tr_rpc_parse_list_str( &top, "1,3-5", -1 ); 104 check( tr_bencIsList( &top ) ); 105 check( tr_bencListSize( &top ) == 4 ); 106 check( tr_bencGetInt( tr_bencListChild( &top, 0 ), &i ) ); 107 check( i == 1 ); 108 check( tr_bencGetInt( tr_bencListChild( &top, 1 ), &i ) ); 109 check( i == 3 ); 110 check( tr_bencGetInt( tr_bencListChild( &top, 2 ), &i ) ); 111 check( i == 4 ); 112 check( tr_bencGetInt( tr_bencListChild( &top, 3 ), &i ) ); 113 check( i == 5 ); 114 tr_bencFree( &top ); 115 116 return 0; 117 } 118 66 119 int 67 120 main( void ) … … 71 124 if(( i = test_acl( ))) 72 125 return i; 126 if(( i = test_list( ))) 127 return i; 73 128 74 129 return 0;
Note: See TracChangeset
for help on using the changeset viewer.