summaryrefslogtreecommitdiff
path: root/test.sh
blob: 016738166d703a9448f7525250460215db2da081 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#!/usr/bin/env bash
total=0
correct=0
for inf in tests/*.in; do
	base="${inf//.in}"
	outf="$base.out"
	tmpf="$base.tmp"
	if ! ./solve <"$inf" >"$tmpf" 2>/dev/null; then
		echo "\x1B[33mERROR\x1B[0m solve returned $?"
	fi
	total=$((total+1))
	if ! diff "$tmpf" "$outf" >/dev/null; then
		echo "failure on $inf"
	else
		rm "$tmpf"
		correct=$((correct+1))
	fi
done
if test $correct -eq $total; then printf "\x1B[33mOK"; else printf "\x1B[31mFAILURE"; fi
printf "\x1B[0m: %d/%d\n" "$correct" "$total"