Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- cpc () {
- if (($# > 5)); then
- echo "Function cpc() takes at most 5 parameters."
- echo "Usage: cpc src_1 src_2 test_generator test_from test_to"
- return
- fi
- echo "Compiling default solution $1."
- echo "======================================================================"
- g++ -O2 -std=gnu++14 -Wall -Wextra -Wshadow -Wnon-virtual-dtor -pedantic "$1" -o a
- echo "======================================================================"
- echo "Default solution compiled.\n"
- if (($# >= 2)); then
- echo "Compiling alternative solution $2."
- echo "======================================================================"
- g++ -O2 -std=gnu++14 -Wall -Wextra -Wshadow -Wnon-virtual-dtor -pedantic "$2" -o b
- echo "======================================================================"
- echo "Alternative solution compiled.\n"
- fi
- if (($# >= 3)); then
- echo "Compiling test generator $3."
- echo "======================================================================"
- g++ -O2 -std=gnu++14 -Wall -Wextra -Wshadow -Wnon-virtual-dtor -pedantic "$3" -o c
- echo "======================================================================"
- echo "Test generator compiled.\n"
- for i in `seq -w $4 $5`; do
- ./c >> $i.in
- done
- fi
- echo "Checking test cases."
- echo "======================================================================"
- for i in *.in; do
- ./a < $i >> ${i%in}re
- if (($# >= 2)); then
- ./b < $i >> ${i%in}ok
- fi
- diff -u ${i%in}re ${i%in}ok
- if [ $? -ne 0 ]; then
- echo "Test ${i%.in} failed."
- # return
- else
- echo "Test ${i%.in} passed."
- fi
- done
- echo "======================================================================"
- rm *.re
- rm -f a b c
- }
Add Comment
Please, Sign In to add comment