Ignore:
Timestamp:
Feb 9, 2009, 5:34:43 PM (13 years ago)
Author:
charles
Message:

(1.5x libT) backport #1671, #1798

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/1.5x/libtransmission/utils-test.c

    r7813 r7855  
    186186}
    187187
     188static int
     189test_numbers( void )
     190{
     191    int i;
     192    int count;
     193    int * numbers;
     194
     195    numbers = tr_parseNumberRange( "1-10,13,16-19", -1, &count );
     196    check( count == 15 );
     197    check( numbers != NULL );
     198    check( numbers[0] == 1 );
     199    check( numbers[5] == 6 );
     200    check( numbers[9] == 10 );
     201    check( numbers[10] == 13 );
     202    check( numbers[11] == 16 );
     203    check( numbers[14] == 19 );
     204    tr_free( numbers );
     205
     206    numbers = tr_parseNumberRange( "1-5,3-7,2-6", -1, &count );
     207    check( count == 7 );
     208    check( numbers != NULL );
     209    for( i=0; i<count; ++i )
     210        check( numbers[i] == i+1 );
     211    tr_free( numbers );
     212
     213    numbers = tr_parseNumberRange( "1-Hello", -1, &count );
     214    check( count == 0 );
     215    check( numbers == NULL );
     216
     217    numbers = tr_parseNumberRange( "1-", -1, &count );
     218    check( count == 0 );
     219    check( numbers == NULL );
     220
     221    numbers = tr_parseNumberRange( "Hello", -1, &count );
     222    check( count == 0 );
     223    check( numbers == NULL );
     224
     225    return 0;
     226}
     227
    188228int
    189229main( void )
     
    212252    if( ( i = test_utf8( ) ) )
    213253        return i;
     254    if( ( i = test_numbers( ) ) )
     255        return i;
    214256
    215257    /* test that tr_cryptoRandInt() stays in-bounds */
Note: See TracChangeset for help on using the changeset viewer.