Skip to content

Commit

Permalink
fix(grades): fix and add more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
MSilva95 committed Feb 2, 2023
1 parent 8182d37 commit 1f9b277
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
17 changes: 17 additions & 0 deletions sh/tests/grades_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ $input
EOF
)
diff <(echo "$submitted") <(echo "$expected")

if [ $? != 0 ]; then
exit 1
fi
echo $submitted
echo $expected
}
challenge 1 "Student1
90
Expand All @@ -41,6 +47,11 @@ challenge 1 "Student6
challenge 1 "Student7
25
"
challenge 2 "Student1
0
Alice
100
"
challenge 3 "Bob
90
Alice
Expand All @@ -66,3 +77,9 @@ Alice
Eve
55
"
challenge 1 "Student1
not_good
"
challenge 1 "Student1
-75
"
7 changes: 6 additions & 1 deletion subjects/devops/grades/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ $ ./grades.sh 1
Student Name #1: Sara
Student Grade #1: 90
Sara: You did an excellent job!
$
```

- If the student grade is anything equal or greater than 70 you will return the string `"<name>: You did a good job!"`:
Expand All @@ -24,6 +25,7 @@ $ ./grades.sh 1
Student Name #1: Sara
Student Grade #1: 75
Sara: You did a good job!
$
```

- If the student grade is anything equal or greater than 50 you will return the string `"<name>: You need a bit more effort!"`:
Expand All @@ -33,6 +35,7 @@ $ ./grades.sh 1
Student Name #1: Sara
Student Grade #1: 51
Sara: You need a bit more effort!
$
```

- If the student grade is anything lower than 50 you will return the string `"<name>: You had a poor performance!"`:
Expand All @@ -42,6 +45,7 @@ $ ./grades.sh 1
Student Name #1: Sara
Student Grade #1: 34
Sara: You had a poor performance!
$
```

### Error handling
Expand All @@ -57,7 +61,7 @@ $ ./grades.sh 2
Student Name #1: Sara
Student Grade #1: 101
Error: The grade '101' is not a valid input. Only numerical grades between 0 and 100 are accepted.
./grades.sh 2
$ ./grades.sh 2
Student Name #1: Bob
Student Grade #1: ten
Error: The grade 'ten' is not a valid input. Only numerical grades between 0 and 100 are accepted.
Expand All @@ -82,6 +86,7 @@ Sara: You had a poor performance!
Norman: You need a bit more effort!
James: You did a good job!
Albert: You did an excellent job!
$
```

### Hints
Expand Down

0 comments on commit 1f9b277

Please sign in to comment.