From 457575405772a6215cc2068e306f9e42e207d1f4 Mon Sep 17 00:00:00 2001 From: eslopfer Date: Thu, 5 Jan 2023 11:27:25 +0000 Subject: [PATCH] test(division): add tests for exercise --- sh/tests/division_test.sh | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 sh/tests/division_test.sh diff --git a/sh/tests/division_test.sh b/sh/tests/division_test.sh new file mode 100644 index 00000000..3fbb318f --- /dev/null +++ b/sh/tests/division_test.sh @@ -0,0 +1,23 @@ +#!/usr/bin/env bash + +# Unofficial Bash Strict Mode +set -euo pipefail +IFS=' +' + +script_dirS=$(cd -P "$(dirname "$BASH_SOURCE")" &>/dev/null && pwd) + +challenge() { + submitted=$(bash "$script_dirS"/student/division.sh $1 $2) + expected=$(bash "$script_dirS"/solutions/division.sh $1 $2) + + diff <(echo "$submitted") <(echo "$expected") +} + +challenge "10 2" "5" +challenge "4 2" "2" +challenge "0.5 0.5" "1" +challenge "0.5" "Error: two numbers must be provided" +challenge "foo bar" "Error: both arguments must be numeric" +challenge "1 0" "Error: division by zero is not allowed" +challenge "10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 2" "5000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"