Changeset 6522


Ignore:
Timestamp:
Aug 14, 2008, 2:38:13 PM (13 years ago)
Author:
charles
Message:

(libT) add unit tests for tr_bitfieldAddRange()

File:
1 edited

Legend:

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

    r6506 r6522  
    6464        check( tr_bitfieldHas( field, i ) == ( ( i < 4 ) || ( i >= 5 ) ) );
    6565
     66    /* test tr_bitfieldAddRange */
     67    tr_bitfieldRemRange( field, 0, 64 );
     68    tr_bitfieldAddRange( field, 4, 21 );
     69    for( i=0; i<64; ++i )
     70        check( tr_bitfieldHas( field, i ) == ( ( 4 <= i ) && ( i < 21 ) ) );
     71
     72    /* test tr_bitfieldAddRange on the boundaries */
     73    tr_bitfieldRemRange( field, 0, 64 );
     74    tr_bitfieldAddRange( field, 8, 24 );
     75    for( i=0; i<64; ++i )
     76        check( tr_bitfieldHas( field, i ) == ( ( 8 <= i ) && ( i < 24 ) ) );
     77
     78    /* test tr_bitfieldAddRange when begin & end is on the same word */
     79    tr_bitfieldRemRange( field, 0, 64 );
     80    tr_bitfieldAddRange( field, 4, 5 );
     81    for( i=0; i<64; ++i )
     82        check( tr_bitfieldHas( field, i ) == ( ( 4 <= i ) && ( i < 5 ) ) );
     83
    6684    tr_bitfieldFree( field );
    6785    return 0;
Note: See TracChangeset for help on using the changeset viewer.