Skip to content

Instantly share code, notes, and snippets.

@tomoki
Created December 15, 2013 03:58
Show Gist options
  • Save tomoki/7968689 to your computer and use it in GitHub Desktop.
Save tomoki/7968689 to your computer and use it in GitHub Desktop.
なんかテストするやつ
#!/bin/sh
INPUTS=`find . -type f -name "in*"`
PROG=$1
if [ $# -eq 0 ]
then
echo "Pass program as first argument."
exit 1
fi
for input in $INPUTS
do
body=`echo $input | sed -e "s/[0-9]*$//"`
index=`echo $input | cut -c $(expr ${#body} + 1)-${#input}`
output=./out$index
tmp=`mktemp`
echo "$input - $output"
$PROG < $input > $tmp
d=`diff $output $tmp -Z`
if [ ${#d} -eq 0 ]
then
echo -e "\033[0;32mCorrect\033[0;39m"
else
echo -e "\033[0;31mFailed\033[0;39m"
echo "Expected:"
cat $output
echo
echo "Output:"
cat $tmp
fi
rm $tmp
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment