refactor(array-selector): refactor test

- make challenge a variadic function
- simplify test using challenge for all the test cases
This commit is contained in:
nprimo 2023-01-12 12:43:05 +00:00 committed by Niccolò Primo
parent c231898bca
commit ce6ef6d186
1 changed files with 3 additions and 6 deletions

View File

@ -9,8 +9,8 @@ IFS='
script_dirS=$(cd -P "$(dirname "$BASH_SOURCE")" &>/dev/null && pwd)
challenge() {
submitted=$(bash "$script_dirS"/student/array-selector.sh $1)
expected=$(bash "$script_dirS"/solutions/array-selector.sh $1)
submitted=$(bash "$script_dirS"/student/array-selector.sh "$@")
expected=$(bash "$script_dirS"/solutions/array-selector.sh "$@")
diff <(echo "$submitted") <(echo "$expected")
}
@ -27,7 +27,4 @@ challenge "abc"
# Test with wrong number of arguments
submitted=$(bash "$script_dirS"/student/array-selector.sh)
submitted=$(bash "$script_dirS"/solutions/array-selector.sh)
diff <(echo "$submitted") <(echo "$expected")
challenge