45 lines
1.4 KiB
Bash
Executable File
45 lines
1.4 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
# Exit immediately if any command below fails.
|
|
set -e
|
|
|
|
make
|
|
|
|
|
|
echo "Generating a test_files directory.."
|
|
mkdir -p test_files
|
|
rm -f test_files/*
|
|
|
|
|
|
echo "Generating test files.."
|
|
printf "Hello, World\x04!\n" > test_files/ascii.input
|
|
printf "Hello, World!" > test_files/ascii2.input
|
|
printf "Test file\nTest\nThis is a test file\n\n\n\n" > test_files/ascii3.input
|
|
printf "Hello,\x00World!\n" > test_files/data.input
|
|
printf "Hello,\x00World!\n" > test_files/data2.input
|
|
printf "Hello,\xa0World!\n" > test_files/iso1.input
|
|
printf "Hello,\xa1\xbbWorld!\n" > test_files/iso2.input
|
|
printf "Hello, \xaaWorld!\n" > test_files/iso3.input
|
|
printf "\x24\xe0\xa4\xb9\xf0\x90\x8d\x88\n" > test_files/utf81.input
|
|
printf "مرحبا عالمي\n" > test_files/utf82.input
|
|
printf "Hello, World or should I say, 안녕하세요 세계!\n" > test_files/utf83.input
|
|
printf "" > test_files/empty.input
|
|
|
|
echo "Running the tests.."
|
|
exitcode=0
|
|
for f in test_files/*.input # For loop
|
|
do
|
|
echo ">>> Testing ${f}.." # print
|
|
file "${f}" | sed 's/ASCII text.*/ASCII text/' > "${f}.expected" # fjerner tekst der kun bliver givet ved ASCII filer og gemmer svaret i ".expected" filen.
|
|
./file "${f}" > "${f}.actual" # giver vores *egen* kodes svar i ".actual" filen.
|
|
|
|
if ! diff -u "${f}.expected" "${f}.actual" # sammenligner vores egen kodes svar og "file" kommandoens svar
|
|
then
|
|
echo ">>> Failed :-("
|
|
exitcode=1
|
|
else
|
|
echo ">>> Success :-)"
|
|
fi
|
|
done
|
|
exit $exitcodeASCII
|