#!/bin/sh
#/* Author    : Rick van der Zwet
# * S-number  : 0433373
# * Version   : $Id: HOWTO.txt 325 2007-11-23 21:17:22Z rick $
# * Copyright : FreeBSD Licence
# */

TMPFILE="`dirname $0`/testing"

rm -f $TMPFILE
numbers="97 98 97 10 99 256 261 257 258 342 10"
echo -n "Odd: "
in=`./write12 $TMPFILE $numbers | tr -d '\n'`
out=`./read12 $TMPFILE | tr -d '\n'`
if [ "$in" = "$out" ]; then
    rm -f $TMPFILE
    echo "PASS"
else
    echo "FAILED"
    exit 1
fi

rm -f $TMPFILE
numbers="97 98 97 10 99 256 261 257 258 342 10 230 19"
echo -n "Even: "
in=`./write12 $TMPFILE $numbers | tr -d '\n'`
out=`./read12 $TMPFILE | tr -d '\n'`
if [ "$in" = "$out" ]; then
    rm -f $TMPFILE
    echo "PASS"
else
    echo "FAILED"
    exit 1
fi

rm -f "$TMPFILE.com" "$TMPFILE.dec" $TMPFILE
string="abaabcabababaaad"
echo "$string" > $TMPFILE
./compressie $TMPFILE "$TMPFILE.com"
./decompressie "$TMPFILE.com" "$TMPFILE.dec"
out=`cat $TMPFILE.dec`

echo -n "Com/de '$string': "
if [ "$string" = "$out" ]; then
    rm -f $TMPFILE "$TMPFILE.com" "$TMPFILE.dec"
    echo "PASS"
else
    echo "FAILED"
    exit 1
fi

FILE='./trie07.ps'
rm -f "$TMPFILE.com" "$TMPFILE.dec" $TMPFILE
./compressie $FILE "$TMPFILE.com"
./decompressie "$TMPFILE.com" "$TMPFILE.dec"
diff -q $FILE "$TMPFILE.dec"
if [ $? -eq 0 ]; then
    rm -f $TMPFILE "$TMPFILE.com" "$TMPFILE.dec"
    echo "echo Com/de '$FILE' PASS"
else
    echo "echo Com/de '$FILE' PASS"
    exit 1
fi


