|
|
|
@ -5,65 +5,50 @@ IFS='
|
|
|
|
|
script_dirS=$(cd -P "$(dirname "$BASH_SOURCE")" &>/dev/null && pwd) |
|
|
|
|
|
|
|
|
|
challenge() { |
|
|
|
|
args=$1 |
|
|
|
|
input=$2 |
|
|
|
|
|
|
|
|
|
declare -a equals=("Student1 90" "Student2 70" "Student3 50") |
|
|
|
|
declare -a differents=("Student1 92" "Student2 75" "Student3 55" "Student4 25") |
|
|
|
|
|
|
|
|
|
for e in "${equals[@]}"; do |
|
|
|
|
name=$(echo "$e" | awk '{print $1}') |
|
|
|
|
grade=$(echo "$e" | awk '{print $2}') |
|
|
|
|
submitted=$(echo -e "$name $grade" | bash -c ""$script_dirS"/student/grades.sh 1") |
|
|
|
|
expected=$(echo -e "$name $grade" | bash -c ""$script_dirS"/solutions/grades.sh 1") |
|
|
|
|
diff <(echo "$submitted") <(echo "$expected") |
|
|
|
|
done |
|
|
|
|
for d in "${differents[@]}"; do |
|
|
|
|
name=$(echo "$d" | awk '{print $1}') |
|
|
|
|
grade=$(echo "$d" | awk '{print $2}') |
|
|
|
|
submitted=$(echo -e "$name $grade" | bash -c ""$script_dirS"/student/grades.sh 1") |
|
|
|
|
expected=$(echo -e "$name $grade" | bash -c ""$script_dirS"/solutions/grades.sh 1") |
|
|
|
|
diff <(echo "$submitted") <(echo "$expected") |
|
|
|
|
done |
|
|
|
|
|
|
|
|
|
# Testing multiple students |
|
|
|
|
submitted=$( |
|
|
|
|
bash -c ""$script_dirS"/student/grades.sh 3" <<EOF |
|
|
|
|
Bob |
|
|
|
|
90 |
|
|
|
|
Alice |
|
|
|
|
75 |
|
|
|
|
Eve |
|
|
|
|
55 |
|
|
|
|
bash -c ""$script_dirS"/student/grades.sh $args" <<EOF |
|
|
|
|
$input |
|
|
|
|
EOF |
|
|
|
|
) |
|
|
|
|
expected=$( |
|
|
|
|
bash -c ""$script_dirS"/solutions/grades.sh 3" <<EOF |
|
|
|
|
Bob |
|
|
|
|
90 |
|
|
|
|
Alice |
|
|
|
|
75 |
|
|
|
|
Eve |
|
|
|
|
55 |
|
|
|
|
bash -c ""$script_dirS"/solutions/grades.sh $args" <<EOF |
|
|
|
|
$input |
|
|
|
|
EOF |
|
|
|
|
) |
|
|
|
|
diff <(echo "$submitted") <(echo "$expected") |
|
|
|
|
|
|
|
|
|
submitted=$( |
|
|
|
|
bash -c ""$script_dirS"/student/grades.sh 5" <<EOF |
|
|
|
|
Bob |
|
|
|
|
} |
|
|
|
|
challenge 1 "Student1 |
|
|
|
|
90 |
|
|
|
|
" |
|
|
|
|
challenge 1 "Student2 |
|
|
|
|
70 |
|
|
|
|
" |
|
|
|
|
challenge 1 "Student3 |
|
|
|
|
50 |
|
|
|
|
" |
|
|
|
|
challenge 1 "Student4 |
|
|
|
|
92 |
|
|
|
|
" |
|
|
|
|
challenge 1 "Student5 |
|
|
|
|
75 |
|
|
|
|
" |
|
|
|
|
challenge 1 "Student6 |
|
|
|
|
55 |
|
|
|
|
" |
|
|
|
|
challenge 1 "Student7 |
|
|
|
|
25 |
|
|
|
|
" |
|
|
|
|
challenge 3 "Bob |
|
|
|
|
90 |
|
|
|
|
Alice |
|
|
|
|
75 |
|
|
|
|
Eve |
|
|
|
|
55 |
|
|
|
|
john |
|
|
|
|
49 |
|
|
|
|
Eric |
|
|
|
|
65 |
|
|
|
|
EOF |
|
|
|
|
) |
|
|
|
|
expected=$( |
|
|
|
|
bash -c ""$script_dirS"/solutions/grades.sh 5" <<EOF |
|
|
|
|
Bob |
|
|
|
|
" |
|
|
|
|
challenge 5 "Bob |
|
|
|
|
90 |
|
|
|
|
Alice |
|
|
|
|
75 |
|
|
|
@ -73,32 +58,11 @@ john
|
|
|
|
|
49 |
|
|
|
|
Eric |
|
|
|
|
65 |
|
|
|
|
EOF |
|
|
|
|
) |
|
|
|
|
diff <(echo "$submitted") <(echo "$expected") |
|
|
|
|
|
|
|
|
|
# Checking if it fails with invallid grades |
|
|
|
|
submitted=$( |
|
|
|
|
bash -c ""$script_dirS"/student/grades.sh 3" <<EOF |
|
|
|
|
Bob |
|
|
|
|
" |
|
|
|
|
challenge 3 "Bob |
|
|
|
|
90 |
|
|
|
|
Alice |
|
|
|
|
150 |
|
|
|
|
Eve |
|
|
|
|
55 |
|
|
|
|
EOF |
|
|
|
|
) |
|
|
|
|
expected=$( |
|
|
|
|
bash -c ""$script_dirS"/solutions/grades.sh 3" <<EOF |
|
|
|
|
Bob |
|
|
|
|
90 |
|
|
|
|
Alice |
|
|
|
|
150 |
|
|
|
|
Eve |
|
|
|
|
55 |
|
|
|
|
EOF |
|
|
|
|
) |
|
|
|
|
diff <(echo "$submitted") <(echo "$expected") |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
challenge |
|
|
|
|
" |
|
|
|
|