Changeset 1684 for zzuf


Ignore:
Timestamp:
Jan 17, 2007, 3:35:12 PM (14 years ago)
Author:
Sam Hocevar
Message:
  • Allow -r 0.0 again. Fixed the testsuite accordingly.
Location:
zzuf/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • zzuf/trunk/src/fd.c

    r1672 r1684  
    7979void _zz_setratio(double r0, double r1)
    8080{
     81    if(r0 == 0.0 && r1 == 0.0)
     82    {
     83        maxratio = minratio = 0.0;
     84        return;
     85    }
     86
    8187    minratio = r0 < MIN_RATIO ? MIN_RATIO : r0 > MAX_RATIO ? MAX_RATIO : r0;
    8288    maxratio = r1 < MIN_RATIO ? MIN_RATIO : r1 > MAX_RATIO ? MAX_RATIO : r1;
     
    94100    uint16_t rate;
    95101    double min, max, cur;
     102
     103    if(minratio == maxratio)
     104        return minratio; /* this also takes care of 0.0 */
    96105
    97106    rate = shuffle[seed & 0xf] << 12;
  • zzuf/trunk/test/testsuite.sh

    r1640 r1684  
    1919    CMD="$2"
    2020    ALIAS="$3"
     21    CHECK="$4"
    2122    echo -n " $(echo "$ALIAS .............." | cut -b1-18) "
    2223    MD5="$(eval "$ZZUF -m $ZZOPTS $CMD" 2>/dev/null | cut -f2 -d' ')"
     24    if [ -n "$CHECK" ]; then
     25        REFMD5="$CHECK"
     26    fi
    2327    if [ -z "$REFMD5" ]; then
    2428        REFMD5="$MD5"
     
    7478
    7579for r in 0.0 0.00001 0.001 0.1 10.0; do
    76     for file in /tmp/zzuf-zero-$$ /tmp/zzuf-text-$$ /tmp/zzuf-random-$$; do
     80    for type in zero text random; do
     81        file=/tmp/zzuf-$type-$$
    7782        ZZOPTS="-s $seed -r $r"
    7883        case $file in
     
    8186        echo "*** file $file, ratio $r ***"
    8287        REFMD5=""
    83         check "$ZZOPTS" "< $file" "zzuf"
     88        if [ $r = 0.0 -a $type = zero ]; then
     89            check="bb7df04e1b0a2570657527a7e108ae23"
     90            echo "*** should be $check ***"
     91            check "$ZZOPTS" "< $file" "zzuf" "$check"
     92        else
     93            check "$ZZOPTS" "< $file" "zzuf"
     94        fi
    8495        check "$ZZOPTS" "$FDCAT $file" "fdcat"
    8596        check "$ZZOPTS" "$STREAMCAT $file" "streamcat"
Note: See TracChangeset for help on using the changeset viewer.