-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.sh
83 lines (78 loc) · 1.88 KB
/
test.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#start of the test script
echo ----------Start testing script----------
#compiling java file
javac Dec2Hex.java/src/Dec2Hex.java
#move into java file directory
cd Dec2Hex.java/src
echo ""
echo ----------handle program fail----------
echo ""
#this test will run the program with no argument
echo ----------test with no argument----------
java Dec2Hex
STATUS="${?}"
if [ "${STATUS}" -eq 0 ]
then
echo test is passed
else
set -e
echo -e "the program failed"
fi
echo ""
#this test will run the program giving an integer as input
echo ----------test with integer argument supplied----------
java Dec2Hex 15683
STATUS="${?}"
if [ "${STATUS}" -eq 0 ]
then
echo test is passed
else
set -e
echo -e "the program failed"
fi
echo ""
#this test will run the program with a negative integer as input
echo ----------test with a negative number----------
java Dec2Hex -895 || STATUS=1
if [ "${STATUS}" -eq 0 ]
then
echo test is passed
else
set +e
echo -e "the program failed"
fi
echo ""
#this test will run the program with a number bigger than integer
echo ----------test with a number bigger than the supported one----------
java Dec2Hex 2147483649
STATUS="${?}"
if [ "${STATUS}" -eq 0 ]
then
echo test is passed
else
set -e
echo -e "the program failed"
fi
echo ""
#this test will run the program with more than one argument supplied
echo ----------test with more than one value entered----------
java Dec2Hex 85 78999 four 89 || STATUS=1
if [ "${STATUS}" -eq 0 ]
then
echo test is passed
else
set -e
echo -e "the program failed"
fi
echo ""
#this test will run the program with a string value input
echo ----------test with String argument----------
java Dec2Hex 4hundred || STATUS=1
if [ "${STATUS}" -eq 0 ]
then
echo test is passed
else
set -e
echo -e "the program failed"
fi
echo ""