diff options
author | Jérémy Zurcher <jeremy@asynk.ch> | 2016-11-13 19:06:14 +0100 |
---|---|---|
committer | Jérémy Zurcher <jeremy@asynk.ch> | 2016-11-13 20:30:08 +0100 |
commit | e72410168143db1b79ee30e47d68cca2d730f740 (patch) | |
tree | 9aa348a93d9d55e8935587eea7c45e0562d73c4c /01-algorithmic_toolbox/02-greedy_algorithms/check | |
parent | 0f13a35dee0df21f4c1a387b50582a958c7bc439 (diff) | |
download | coursera-e72410168143db1b79ee30e47d68cca2d730f740.zip coursera-e72410168143db1b79ee30e47d68cca2d730f740.tar.gz |
Algorithms : add 01-algorithmic_toolbox 02-greedy_algorithms
Diffstat (limited to '01-algorithmic_toolbox/02-greedy_algorithms/check')
-rwxr-xr-x | 01-algorithmic_toolbox/02-greedy_algorithms/check | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/01-algorithmic_toolbox/02-greedy_algorithms/check b/01-algorithmic_toolbox/02-greedy_algorithms/check new file mode 100755 index 0000000..8bdb3d4 --- /dev/null +++ b/01-algorithmic_toolbox/02-greedy_algorithms/check @@ -0,0 +1,38 @@ +#! /bin/bash + +RESET="\033[0m" +BLACK="\033[0;30m" +RED="\033[0;31m" +GREEN="\033[0;32m" +BROWN="\033[0;33m" + +BIN=/tmp/bin +OUTA=/tmp/_outa +OUTB=/tmp/_outb +GPP_OPTS="-std=c++11 -O2" + +for path in $(find -name \*.cpp | sort); do + src=${path##*/} + dir=${path%/*} + echo -e "${RED}validate $BROWN$dir$RESET/$GREEN$src$RESET" + pushd $dir >/dev/null || exit 1 + echo -e " ${RED}compile $GREEN$src$RESET" && g++ $GPP_OPTS $src -o $BIN || exit 1 + if [ -d tests ]; then + echo -e " ${RED}check $GREEN$src$RESET" + for t in $(find ./tests -name "*[^a~]"|sort); do + if [ -f $t -a -f "$t.a" ]; then + cat $t | $BIN > $OUTA + cat $t.a > $OUTB + cmp $OUTA $OUTB >/dev/null + if [ $? -ne 0 ]; then + echo -e " $BROWN$t$RESET is ${RED}KO$RESET" + else + echo -e " $BROWN$t$RESET is ${GREEN}ok$RESET" + fi + fi + done + else + echo -e " ${RED}no tests$RESET" + fi + popd > /dev/null +done |