Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env bash
- # example of usage: algotest C cpp;
- # all tests are Ai1, Ai2, ...
- # all test results are Aa1, Aa2, ...
- # program is A.cpp or A.py
- name=$1
- ext=$2
- RED='\033[0;31m' # Red Color
- GREEN='\033[0;32m' # Green Color
- NC='\033[0m' # No Color
- if [[ "$ext" == "cpp" ]]; then
- g++ $name.$ext -o $name
- prog=$name
- else
- prog="${name}.py"
- fi
- testfiles="${name}i*"
- echo $testfiles
- echo
- for input in `ls $testfiles`; do
- n=`echo $input | grep -o -E '[0-9]+'`
- ans=${name}a${n}
- text1=`cat $input | "./$prog" | awk 1`
- text2=`awk 1 $ans`
- if [[ $text1 == $text2 ]]; then
- printf "${GREEN}${input}${NC}\n";
- else
- printf "${RED}${input}${NC}\n"
- echo $text1
- echo $text2
- fi
- echo
- done
Advertisement
Add Comment
Please, Sign In to add comment