summaryrefslogtreecommitdiff
path: root/run_tests.sh
blob: b8088f06055f1ff62695c91c877e2979833f21b7 (plain)
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
(( FAIL = 0 ))
(( PASS = 0 ))


run_test () {
  echo "Running $1"
  `$1 &>/dev/null`
  if [ $? -eq 1 ]; then
    echo "Failed"
    (( FAIL++ ))
  else
    echo "Passed"
    (( PASS++ ))
  fi
}

################################################################################
#Integer Add                                                                   #
################################################################################

#Test random add
run_test "./math-int add 1 2 3"
#Same as above with arguments reversed
run_test "./math-int add 2 1 3"
#Test negative plus positive
run_test "./math-int add -5 10 5"
#Test negative plus negative
run_test "./math-int add -1 -4 -5"

################################################################################
#Integer Multiply                                                              #
################################################################################

#Test random multiply
run_test "./math-int mul 4 5 20"
#Test multiply by 0
run_test "./math-int mul 8 0 0"
#Test multiply negative by positive
run_test "./math-int mul -3 8 -24"
#Test multiply negative by negative
run_test "./math-int mul -12 -6 72"

################################################################################
#Integer divide                                                                #
################################################################################

#Test even divide
run_test "./math-int div 20 5 4"
#Test divide with remainder
run_test "./math-int div 23 5 4"
#Test divide by 1
run_test "./math-int div 30 1 30"
#Test divide by -1
run_test "./math-int div 57 -1 -57"
#Test divide by a negative number
run_test "./math-int div 10 -2 -5"
#Test divide by a negative number with remainder
run_test "./math-int div 17 -3 -5"
#Test divide a negative number
run_test "./math-int div -28 2 -14"
#Test divide a negative number with remainder
run_test "./math-int div -8 3 -2"
#Two negative args
run_test "./math-int div -25 -5 5"
#Two nefative args with remainder
run_test "./math-int div -24 -5 4"

echo "$PASS passes, $FAIL fails"