diff options
author | Jérémy Zurcher <jeremy@asynk.ch> | 2016-11-13 23:14:10 +0100 |
---|---|---|
committer | Jérémy Zurcher <jeremy@asynk.ch> | 2016-11-13 23:14:10 +0100 |
commit | 33d7d833615fee75b075e6bfb3a459cc02c4cc54 (patch) | |
tree | 47544957c0a2757e86d26efda6c2a64493f80e51 /03-algorithms_on_graphs/04-paths_in_graphs/check | |
parent | 0c0188d855ca9f452b7fe44d51f86661850ca892 (diff) | |
download | coursera-33d7d833615fee75b075e6bfb3a459cc02c4cc54.zip coursera-33d7d833615fee75b075e6bfb3a459cc02c4cc54.tar.gz |
Algorithms : add 03-algorithms_on_graphs 04-paths_in_graphs
Diffstat (limited to '03-algorithms_on_graphs/04-paths_in_graphs/check')
-rwxr-xr-x | 03-algorithms_on_graphs/04-paths_in_graphs/check | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/03-algorithms_on_graphs/04-paths_in_graphs/check b/03-algorithms_on_graphs/04-paths_in_graphs/check new file mode 100755 index 0000000..b73ff99 --- /dev/null +++ b/03-algorithms_on_graphs/04-paths_in_graphs/check @@ -0,0 +1,38 @@ +#! /bin/bash + +RESET="\033[0m" +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 + |