diff options
Diffstat (limited to 'files/testlab2.sh')
-rwxr-xr-x | files/testlab2.sh | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/files/testlab2.sh b/files/testlab2.sh new file mode 100755 index 0000000..7f79876 --- /dev/null +++ b/files/testlab2.sh | |||
@@ -0,0 +1,49 @@ | |||
1 | #/bin/sh | ||
2 | |||
3 | string1="Sunner" | ||
4 | string2="Richard Stallman" | ||
5 | string3="This is a very very long string!" | ||
6 | |||
7 | score1=10 | ||
8 | score2=10 | ||
9 | score3=10 | ||
10 | |||
11 | expected1="Sunner" | ||
12 | expected2="Richard Stallman" | ||
13 | expected3="Richard Stallman" | ||
14 | |||
15 | echo Testing string:$string1 | ||
16 | ./iam "$string1" | ||
17 | result=`./whoami` | ||
18 | if [ "$result" = "$expected1" ]; then | ||
19 | echo PASS. | ||
20 | else | ||
21 | score1=0 | ||
22 | echo FAILED. | ||
23 | fi | ||
24 | score=$score1 | ||
25 | |||
26 | echo Testing string:$string2 | ||
27 | ./iam "$string2" | ||
28 | result=`./whoami` | ||
29 | if [ "$result" = "$expected2" ]; then | ||
30 | echo PASS. | ||
31 | else | ||
32 | score2=0 | ||
33 | echo FAILED. | ||
34 | fi | ||
35 | score=$score+$score2 | ||
36 | |||
37 | echo Testing string:$string3 | ||
38 | ./iam "$string3" | ||
39 | result=`./whoami` | ||
40 | if [ "$result" = "$expected3" ]; then | ||
41 | echo PASS. | ||
42 | else | ||
43 | score3=0 | ||
44 | echo FAILED. | ||
45 | fi | ||
46 | score=$score+$score3 | ||
47 | |||
48 | let "totalscore=$score" | ||
49 | echo Score: $score = $totalscore% | ||