#!/bin/sh
# This script compiles the main modules of Huffman project,
# runs them on sample files, and validates output

echo \* Making huffman \& chopmerge...
./makeunix huffman chopmerge

cd bin
cp ./huff ./_huff
echo \* Compressing '_huff' to 'huff.huf' in tree-style 2...
./huff -a _huff -o huff.huf -s2 > out.txt

echo
echo \* Viewing content of Huffman-archive 'huff.huf'...
./huff -v huff.huf >> out.txt

echo
echo \* Extracting content of 'huff.huf' to original name '_huff'
./huff -e huff.huf >> out.txt

echo The differences between the extracted and the original files:
diff -s ./_huff ./huff

echo
echo \* Chopping 'huff.huf' to 'huff.hed' and 'huff.dat'...
./chopmerg -c -l huff.huf -h huff.hed -d huff.dat >> out.txt

echo
echo \* Merging 'huff.hed' and 'huff.dat' to 'huff.mrg'...
./chopmerg -m -h huff.hed -d huff.dat -l huff.mrg >> out.txt

echo The differences between the stdout the expected output:
diff -s out.txt ../test_expected

cd ..
