Ignore:
Timestamp:
Mar 4, 2008, 7:29:51 PM (14 years ago)
Author:
charles
Message:

new function: tr_bencSaveAsSerializedPHP()

File:
1 edited

Legend:

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

    r5127 r5198  
    267267
    268268static int
     269testPHPSnippet( const char * benc_str, const char * expected )
     270{
     271    tr_benc top;
     272    char * serialized;
     273    tr_bencLoad( benc_str, strlen( benc_str ), &top, NULL );
     274    serialized = tr_bencSaveAsSerializedPHP( &top, NULL );
     275    check( !strcmp( serialized, expected ) );
     276    tr_free( serialized );
     277    tr_bencFree( &top );
     278    return 0;
     279}
     280
     281static int
     282testPHP( void )
     283{
     284    int val;
     285    const char * benc_str;
     286    const char * expected;
     287
     288    benc_str = "i6e";
     289    expected = "i:6;";
     290    if(( val = testPHPSnippet( benc_str, expected )))
     291        return val;
     292
     293    benc_str = "d3:cow3:moo4:spam4:eggse";
     294    expected = "a:2:{s:3:\"cow\";s:3:\"moo\";s:4:\"spam\";s:4:\"eggs\";}";
     295    if(( val = testPHPSnippet( benc_str, expected )))
     296        return val;
     297
     298    benc_str = "l3:cow3:moo4:spam4:eggse";
     299    expected = "a:4:{i:0;s:3:\"cow\";i:1;s:3:\"moo\";i:2;s:4:\"spam\";i:3;s:4:\"eggs\";}";
     300    if(( val = testPHPSnippet( benc_str, expected )))
     301        return val;
     302
     303    return 0;
     304}
     305
     306static int
    269307testStackSmash( void )
    270308{
     
    312350        return i;
    313351
     352    if(( i = testPHP( )))
     353        return i;
     354
    314355    if(( i = testStackSmash( )))
    315356        return i;
Note: See TracChangeset for help on using the changeset viewer.