Ignore:
Timestamp:
Jun 2, 2009, 1:48:48 AM (13 years ago)
Author:
charles
Message:

(trunk) #2131: clean up benc read/write API

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/bencode-test.c

    r8414 r8588  
    174174#endif
    175175        check( end == (const uint8_t*)str + len );
    176         saved = tr_bencSave( &val, &savedLen );
     176        saved = tr_bencToStr( &val, TR_FMT_BENC, &savedLen );
    177177        check( !strcmp( saved, str ) );
    178178        check( len == (size_t)savedLen );
     
    215215    check( tr_bencGetInt( &val.val.l.vals[2], &i ) );
    216216    check( i == 16 );
    217     saved = tr_bencSave( &val, &len );
     217    saved = tr_bencToStr( &val, TR_FMT_BENC, &len );
    218218    check( !strcmp( saved, (char*)buf ) );
    219219    tr_free( saved );
     
    231231    check( !err );
    232232    check( end == buf + 2 );
    233     saved = tr_bencSave( &val, &len );
     233    saved = tr_bencToStr( &val, TR_FMT_BENC, &len );
    234234    check( !strcmp( saved, "le" ) );
    235235    tr_free( saved );
     
    274274    check( ( child = tr_bencListChild( &val, 0 ) ) );
    275275    check( ( child2 = tr_bencListChild( child, 0 ) ) );
    276     saved = tr_bencSave( &val, &len );
     276    saved = tr_bencToStr( &val, TR_FMT_BENC, &len );
    277277    check( !strcmp( saved, "lld1:ai64e1:bi32eeee" ) );
    278278    tr_free( saved );
     
    285285    check( !err );
    286286    check( end == buf + 2 );
    287     saved = tr_bencSave( &val, &len );
     287    saved = tr_bencToStr( &val, TR_FMT_BENC, &len );
    288288    check( !strcmp( saved, "le" ) );
    289289    tr_free( saved );
     
    325325
    326326    tr_bencLoad( benc_str, strlen( benc_str ), &top, NULL );
    327     serialized = tr_bencSaveAsJSON( &top, buf, TRUE );
     327    tr_bencToBuf( &top, TR_FMT_JSON, buf );
     328    serialized = (char*) EVBUFFER_DATA( buf );
    328329    stripWhitespace( serialized );
    329330#if 0
     
    444445    check( !err );
    445446    check( end == in + ( depth * 2 ) );
    446     saved = tr_bencSave( &val, &len );
     447    saved = tr_bencToStr( &val, TR_FMT_BENC, &len );
    447448    check( !strcmp( saved, (char*)in ) );
    448449    tr_free( in );
     
    505506    tr_bencDictAddStr( &top, "this-is-a-string", "this-is-a-string" );
    506507
    507     benc = tr_bencSave( &top, &len );
     508    benc = tr_bencToStr( &top, TR_FMT_BENC, &len );
    508509    check( !strcmp( benc, "d14:this-is-a-booli1e14:this-is-a-real8:0.50000016:this-is-a-string16:this-is-a-string14:this-is-an-inti1234ee" ) )
    509510    check( !tr_bencParse( benc, benc+len, &top2, &end ) )
Note: See TracChangeset for help on using the changeset viewer.