impl. tests

This commit is contained in:
vv01f 2019-11-16 22:25:41 +01:00
parent ffa552ea10
commit ed4002ab3b
Signed by untrusted user who does not match committer: vv01f
GPG Key ID: 02625A16AC1D1FF6
1 changed files with 34 additions and 10 deletions

44
dhl.sh
View File

@ -38,17 +38,41 @@ iso3countrycode () {
fi
}
testcmp () {
if test "$#" -eq 0 ; then
echo "arguments missing."; exit 1
fi
case $2 in
#whitelisted fn
iso3countrycode)
expected="$1"
shift
fn="$1"
shift
for a in "$@"; do
result=$("$fn" "$a")
if test "$result" = "$expected" ; then
echo "$fn passed for: $a."
else
echo "$fn failed for: $a."
fi
done
;;
*)
echo "no test performed"
esac
}
testiso3 () {
# covering data in https://doku.ccc.de/index.php?title=Attribut:Chaostreff-Country&limit=500&offset=0
iso3countrycode "Belgien"
iso3countrycode "Deutschland"
iso3countrycode "England"
iso3countrycode "Luxembourg"
iso3countrycode "Luxemburg"
iso3countrycode "Niederlande"
iso3countrycode "Österreich"
iso3countrycode "Ungarn"
iso3countrycode "Schweiz"
iso3countrycode "Simbabwe" # should fail
testcmp "BEL" "iso3countrycode" "Belgien"
testcmp "DEU" "iso3countrycode" "Deutschland"
testcmp "GBR" "iso3countrycode" "England"
testcmp "LUX" "iso3countrycode" "Luxembourg" "Luxemburg"
testcmp "NLD" "iso3countrycode" "Niederlande"
testcmp "AUT" "iso3countrycode" "Österreich"
testcmp "HUN" "iso3countrycode" "Ungarn"
testcmp "CHE" "iso3countrycode" "Schweiz"
testcmp "" "iso3countrycode" "Simbabwe" # should fail
}
testiso3