#
# testall.sh,  1 Aug 26

TESTLOG="testall.log" ;			export TESLOG
NUMBERS="../numbers" ;			export NUMBERS
NDB_DIR="../ndb" ;			export NDB_DIR


function all_options()
{
echo -n > $1.log

echo "-allow" >> $1.log
$NUMBERS -ndb $1.ndb -allow space  $1.txt >> $1.log
$NUMBERS -ndb $1.ndb -allow space- $1.txt >> $1.log
$NUMBERS -ndb $1.ndb -allow space+ $1.txt >> $1.log

echo "-format" >> $1.log
$NUMBERS -ndb $1.ndb -format file "%s " $1.txt >> $1.log
$NUMBERS -ndb $1.ndb -format file "%s:" $1.txt >> $1.log
$NUMBERS -ndb $1.ndb -format file "" $1.txt >> $1.log
$NUMBERS -ndb $1.ndb -format line "%6d " $1.txt >> $1.log
$NUMBERS -ndb $1.ndb -format line "%1d " $1.txt >> $1.log
$NUMBERS -ndb $1.ndb -format line "" $1.txt >> $1.log
$NUMBERS -ndb $1.ndb -format path "%s " $1.txt >> $1.log
$NUMBERS -ndb $1.ndb -format path "%s/" $1.txt >> $1.log
$NUMBERS -ndb $1.ndb -format path "" $1.txt >> $1.log

echo "-fuzz" >> $1.log
$NUMBERS -ndb $1.ndb -fuzz 0.01 $1.txt >> $1.log
$NUMBERS -ndb $1.ndb -fuzz 0.02 $1.txt >> $1.log

echo "-levenshtein" >> $1.log
$NUMBERS -ndb $1.ndb -levenshtein 1 $1.txt >> $1.log
$NUMBERS -ndb $1.ndb -levenshtein 5 $1.txt >> $1.log

echo "-match mantissa" >> $1.log
$NUMBERS -ndb $1.ndb -match mantissa  < $1.txt >> $1.log
$NUMBERS -ndb $1.ndb -match mantissa- < $1.txt >> $1.log
$NUMBERS -ndb $1.ndb -match mantissa+ < $1.txt >> $1.log

echo "-match value" >> $1.log
$NUMBERS -ndb $1.ndb -match value < $1.txt >> $1.log
$NUMBERS -ndb $1.ndb -match value- < $1.txt >> $1.log
$NUMBERS -ndb $1.ndb -match value+ < $1.txt >> $1.log

echo "-match <number>" >> $1.log
$NUMBERS -ndb $1.ndb -match 2 < $1.txt >> $1.log
$NUMBERS -ndb $1.ndb -match 4 < $1.txt >> $1.log

echo "-mkndb" >> $1.log
$NUMBERS -ndb $1.ndb -mkndb all+ < $1.txt >> $1.log
$NUMBERS -ndb $1.ndb -mkndb all- < $1.txt >> $1.log
echo "-mkndb 3" >> $1.log
$NUMBERS -ndb $1.ndb -mkndb all  -mkndg 3 < $1.txt >> $1.log
$NUMBERS -ndb $1.ndb -mkndb all- -mkndg 3 < $1.txt >> $1.log
echo "-mkndb 10" >> $1.log
$NUMBERS -ndb $1.ndb -mkndb all  -mkndg 10 < $1.txt >> $1.log
$NUMBERS -ndb $1.ndb -mkndb all- -mkndg 10 < $1.txt >> $1.log

echo "-ndb" >> $1.log
$NUMBERS -ndb $1.ndb $1.txt >> $1.log

echo "-print" >> $1.log
$NUMBERS -ndb $1.ndb -print all < $1.txt >> $1.log
$NUMBERS -ndb $1.ndb -print all- < $1.txt >> $1.log
$NUMBERS -ndb $1.ndb -print all+ < $1.txt >> $1.log

echo "-print loc" >> $1.log
$NUMBERS -ndb $1.ndb -print loc  < $1.txt >> $1.log
$NUMBERS -ndb $1.ndb -print loc- < $1.txt >> $1.log
$NUMBERS -ndb $1.ndb -print loc+ < $1.txt >> $1.log

echo "-print mat" >> $1.log
$NUMBERS -ndb $1.ndb -print mat  < $1.txt >> $1.log
$NUMBERS -ndb $1.ndb -print mat- < $1.txt >> $1.log
$NUMBERS -ndb $1.ndb -print mat+ < $1.txt >> $1.log

echo "-print nop" >> $1.log
$NUMBERS -ndb $1.ndb -print nom  < $1.txt >> $1.log
$NUMBERS -ndb $1.ndb -print nom- < $1.txt >> $1.log
$NUMBERS -ndb $1.ndb -print nom+ < $1.txt >> $1.log

echo "-print val" >> $1.log
$NUMBERS -ndb $1.ndb -print val  < $1.txt >> $1.log
$NUMBERS -ndb $1.ndb -print val- < $1.txt >> $1.log
$NUMBERS -ndb $1.ndb -print val+ < $1.txt >> $1.log

echo "-print word" >> $1.log
$NUMBERS -ndb $1.ndb -print word  < $1.txt >> $1.log
$NUMBERS -ndb $1.ndb -print word- < $1.txt >> $1.log
$NUMBERS -ndb $1.ndb -print word+ < $1.txt >> $1.log

echo "-print 3" >> $1.log
$NUMBERS -ndb $1.ndb -print 3 < $1.txt >> $1.log
$NUMBERS -ndb $1.ndb -print 3 < $1.txt >> $1.log
echo "-print 10" >> $1.log
$NUMBERS -ndb $1.ndb -print 10 < $1.txt >> $1.log
$NUMBERS -ndb $1.ndb -print 10 < $1.txt >> $1.log

echo "-summary" >> $1.log
$NUMBERS -ndb $1.ndb -summary match < $1.txt >> $1.log
$NUMBERS -ndb $1.ndb -summary match- < $1.txt >> $1.log
$NUMBERS -ndb $1.ndb -summary match+ < $1.txt >> $1.log
$NUMBERS -ndb $1.ndb -summary nomatch < $1.txt >> $1.log
$NUMBERS -ndb $1.ndb -summary nomatch- < $1.txt >> $1.log
$NUMBERS -ndb $1.ndb -summary nomatch+ < $1.txt >> $1.log

echo "-wildcard" >> $1.log
$NUMBERS -ndb $1.ndb -wildcard "e*.txt" . >> $1.log

diff $1.log $1.$flt_suffix
}

date > $TESTLOG

if test `$NUMBERS -V | grep "long double" -c` = "1"
then
   flt_suffix="ldbl"
else
   flt_suffix="mult-prec"
fi

$NUMBERS -help >> $TESTLOG
$NUMBERS -V >> $TESTLOG
$NUMBERS -? >> $TESTLOG
$NUMBERS -fuzz 0.1 -lev 99 -match value- -V >> $TESTLOG
$NUMBERS -fuzz 1.1 -V >> $TESTLOG
$NUMBERS -fuzz xxx -match value- -V >> $TESTLOG
$NUMBERS -lev 99999 -match value- -V >> $TESTLOG
$NUMBERS -lev yyy -match value- -V >> $TESTLOG
$NUMBERS -match 99999 -V >> $TESTLOG
$NUMBERS -mkndn 99999 -V >> $TESTLOG
$NUMBERS -print 99999 -V >> $TESTLOG

echo "file does not exist" >> $TESTLOG
$NUMBERS file-does-not-exist >> $TESTLOG

echo "Binary file" >> $TESTLOG
$NUMBERS $NUMBERS >> $TESTLOG

all_options edge >> $TESTLOG
all_options numb-text >> $TESTLOG

$NUMBERS valtest.txt >> $TESTLOG

echo "-match mantissa" >> $TESTLOG
$NUMBERS valtest.txt -match mantissa- >> $TESTLOG
$NUMBERS valtest.txt -match mantissa+ >> $TESTLOG
echo "-match value" >> $TESTLOG
$NUMBERS valtest.txt -match value- >> $TESTLOG
$NUMBERS valtest.txt -match value+ >> $TESTLOG

echo "-fuzz" >> $TESTLOG
$NUMBERS valtest.txt -fuzz 0.01 >> $TESTLOG
$NUMBERS valtest.txt -fuzz 0.02 >> $TESTLOG

echo "-ignore comment" >> $TESTLOG
echo "c source" >> $TESTLOG
$NUMBERS comment.c -ignore comm- >> $TESTLOG
$NUMBERS comment.c -ignore comm+ >> $TESTLOG
echo "cpp source" >> $TESTLOG
$NUMBERS comment.cpp -ignore comm- >> $TESTLOG
$NUMBERS comment.cpp -ignore comm+ >> $TESTLOG
echo "R source" >> $TESTLOG
$NUMBERS comment.R -ignore comm- >> $TESTLOG
echo "Fortran source" >> $TESTLOG
$NUMBERS comment.for -ignore comm- >> $TESTLOG
$NUMBERS comment.for -ignore comm+ >> $TESTLOG

echo "-levenshtein" >> $TESTLOG
$NUMBERS levkey.txt -levenshtein 1 >> $TESTLOG
$NUMBERS levkey.txt -levenshtein 5 >> $TESTLOG

echo "myfloat" >> $TESTLOG
$NUMBERS myfloat.h -summ nom+ >> $TESTLOG

echo "bugs" >> $TESTLOG
$NUMBERS -ndb doinc.ndb bugs.txt >> $TESTLOG
$NUMBERS -ndb not_exist.ndb bugs.txt >> $TESTLOG

echo "need" >> $TESTLOG
$NUMBERS -ndb need.ndb need_1.c >> $TESTLOG
echo "-need perc 40" >> $TESTLOG
$NUMBERS -ndb need.ndb need_1.c -need perc 40 >> $TESTLOG
echo "-need perc 50" >> $TESTLOG
$NUMBERS -ndb need.ndb need_1.c -need perc 50 >> $TESTLOG
echo "-need perc 60" >> $TESTLOG
$NUMBERS -ndb need.ndb need_1.c -need perc 60 >> $TESTLOG

echo "-print loc" >> $TESTLOG
$NUMBERS location.c -print loc-  -ignore comm+ >> $TESTLOG
$NUMBERS location.c -print loc+  -ignore comm+ >> $TESTLOG
$NUMBERS location.c -print loc+  -ignore comm- >> $TESTLOG
$NUMBERS location.for -print loc-  -ignore comm+ >> $TESTLOG
$NUMBERS location.for -print loc+  -ignore comm+ >> $TESTLOG
$NUMBERS location.for -print loc+  -ignore comm- >> $TESTLOG

echo "file suffix" >> $TESTLOG
$NUMBERS -print nom+ filesuff.txt >> $TESTLOG

$NUMBERS -ndb warnings.ndb bugs.txt >> $TESTLOG

$NUMBERS numeast.txt >> $TESTLOG
$NUMBERS numeast.txt -match mantissa+ >> $TESTLOG

echo "3.14158 www 2.71828" | $NUMBERS -ndb pi-e.ndb >> $TESTLOG
echo "1.23456 www 2.34567" | $NUMBERS -ndb pi-e.ndb -print nom+ >> $TESTLOG
echo "1.23456 www 2.34567" | $NUMBERS -ndb pi-e.ndb -print all+ >> $TESTLOG

# Cut down on the volume of log output by only doing a trace once
echo "-trace" >> $TESTLOG
$NUMBERS -ndb edge.ndb -trace all edge.txt >> $TESTLOG
$NUMBERS -ndb edge.ndb -trace input edge.txt >> $TESTLOG
$NUMBERS -ndb edge.ndb -trace ndb edge.txt >> $TESTLOG

echo "-word" >> $TESTLOG
$NUMBERS myfloat.h -print word+ -word 5 >> $TESTLOG
$NUMBERS myfloat.h -print word+ -word 100 >> $TESTLOG

echo "Files containing faults that have been encountered" >> $TESTLOG
$NUMBERS bugs.txt -summ nom+ >> $TESTLOG
$NUMBERS RLDOCS.SHR >> $TESTLOG

echo "various exponents" >> $TESTLOG
$NUMBERS exponent.c >> $TESTLOG

echo "ndb directory" >> $TESTLOG
$NUMBERS -print nom+ -print mat- -summ mat- $NDB_DIR >> $TESTLOG

diff $TESTLOG testall.$flt_suffix

