impl. tests
This commit is contained in:
parent
ffa552ea10
commit
ed4002ab3b
44
dhl.sh
44
dhl.sh
|
@ -38,17 +38,41 @@ iso3countrycode () {
|
||||||
fi
|
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 () {
|
testiso3 () {
|
||||||
# covering data in https://doku.ccc.de/index.php?title=Attribut:Chaostreff-Country&limit=500&offset=0
|
# covering data in https://doku.ccc.de/index.php?title=Attribut:Chaostreff-Country&limit=500&offset=0
|
||||||
iso3countrycode "Belgien"
|
testcmp "BEL" "iso3countrycode" "Belgien"
|
||||||
iso3countrycode "Deutschland"
|
testcmp "DEU" "iso3countrycode" "Deutschland"
|
||||||
iso3countrycode "England"
|
testcmp "GBR" "iso3countrycode" "England"
|
||||||
iso3countrycode "Luxembourg"
|
testcmp "LUX" "iso3countrycode" "Luxembourg" "Luxemburg"
|
||||||
iso3countrycode "Luxemburg"
|
testcmp "NLD" "iso3countrycode" "Niederlande"
|
||||||
iso3countrycode "Niederlande"
|
testcmp "AUT" "iso3countrycode" "Österreich"
|
||||||
iso3countrycode "Österreich"
|
testcmp "HUN" "iso3countrycode" "Ungarn"
|
||||||
iso3countrycode "Ungarn"
|
testcmp "CHE" "iso3countrycode" "Schweiz"
|
||||||
iso3countrycode "Schweiz"
|
testcmp "" "iso3countrycode" "Simbabwe" # should fail
|
||||||
iso3countrycode "Simbabwe" # should fail
|
|
||||||
}
|
}
|
||||||
testiso3
|
testiso3
|
||||||
|
|
Loading…
Reference in New Issue
Block a user