Add tests for ex17-ec

This commit is contained in:
Dan Buch 2016-04-13 10:36:55 -04:00
parent 1970801db8
commit 5d2b2e8e8e
3 changed files with 40 additions and 4 deletions

View File

@ -1,8 +1,6 @@
CFLAGS=-Wall -g
EXERCISES := \
ex1 ex3 ex4 ex5 ex6 ex7 ex8 ex9 ex9-ec \
ex10 ex11 ex12 ex13 ex14 ex15 ex16 ex17 ex17-ec
EXERCISES := $(shell ./list-exercises)
all: $(EXERCISES)
@ -10,4 +8,7 @@ clean:
$(RM) $(EXERCISES)
test:
./runtests
@./runtests
exercises:
@echo $(EXERCISES)

View File

@ -0,0 +1,5 @@
#!/usr/bin/env bash
for f in *.c ; do
echo "${f/.c/}"
done

View File

@ -1 +1,31 @@
#!/usr/bin/env bash
set -e
[[ $DEBUG ]] && set -x
test_ex17-ec() {
local testdb=$(mktemp /var/tmp/XXXXXXX.dat)
trap "rm ${testdb}" EXIT INT TERM
./ex17-ec "${testdb}" c
./ex17-ec "${testdb}" l &>/dev/null
./ex17-ec "${testdb}" s 1 nancy pwnr@dungeon.info "Dark corner"
./ex17-ec "${testdb}" s 2 fran eagleeye16@hotmail.com "Falcon's nest"
./ex17-ec "${testdb}" l &>/dev/null
./ex17-ec "${testdb}" d 1
./ex17-ec "${testdb}" s 1 portia wanda@aeromar.mx "Fancy town"
./ex17-ec "${testdb}" f nest &>/dev/null
echo "OK"
}
main() {
for ex in $(./list-exercises) ; do
func_name="test_${ex}"
if type "${func_name}" &>/dev/null ; then
echo -en "---> ${ex}: "
"${func_name}"
fi
done
}
main "$@"