bcalc

cli bitcoin unit calculator
git clone git://jb55.com/bcalc
Log | Files | Refs | README | LICENSE

run (598B)


      1 #!/usr/bin/env bash
      2 
      3 process () {
      4     tail -n+2 "$1" | sed -n '/^--- failing/q;p'
      5 }
      6 
      7 n=1
      8 c=$(($(process tests.csv | wc -l)))
      9 
     10 printf "1..%d\n" "$c"
     11 
     12 process tests.csv | \
     13 (fail=0
     14 while IFS=, read -r description args input expected
     15 do
     16     output=$(../bcalc $args <<<"$input" 2>&1)
     17     if [ "$description" == "" ] || [ "$output" != "$expected" ]; then
     18         printf "not ok %d - %s\n" "$n" "$description"
     19         printf "#\n#    got '%s', expected '%s'\n#\n" "$output" "$expected"
     20         fail=1
     21     else
     22         printf "ok %d - %s\n" "$n" "$description"
     23     fi
     24     n=$((n + 1))
     25 done
     26  exit $fail
     27 )
     28