-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_mathUtil.py
54 lines (42 loc) · 1.5 KB
/
test_mathUtil.py
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
import unittest
from mathUtil import calcPermutation, calcCombination
from error import PermutationError, CombinationError
class MathUtilTest(unittest.TestCase):
def setUp(self):
"""
setup function
"""
pass
def tearDown(self):
"""
tearDown function
"""
pass
def test_permutation_success(self):
self.assertEqual(calcPermutation(3, 2), 6)
def test_permutation_pos_pos(self):
with self.assertRaises(PermutationError):
calcPermutation(2, 3)
def test_permutation_neg_neg(self):
with self.assertRaises(PermutationError):
calcPermutation(-2, -3)
def test_permutation_pos_neg(self):
with self.assertRaises(PermutationError):
calcPermutation(2, -3)
def test_permutation_neg_pos(self):
with self.assertRaises(PermutationError):
calcPermutation(-2, 3)
def test_combination_success(self):
self.assertEqual(calcCombination(3, 2), 3)
def test_combination_pos_pos(self):
with self.assertRaises(CombinationError):
calcCombination(2, 3)
def test_combination_neg_neg(self):
with self.assertRaises(CombinationError):
calcCombination(-2, -3)
def test_combination_pos_neg(self):
with self.assertRaises(CombinationError):
calcCombination(2, -3)
def test_combination_neg_pos(self):
with self.assertRaises(CombinationError):
calcCombination(-2, 3)