-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_complex_arithmetic.py
More file actions
36 lines (27 loc) · 1008 Bytes
/
test_complex_arithmetic.py
File metadata and controls
36 lines (27 loc) · 1008 Bytes
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
from unittest import TestCase, skip, skipIf
from complex import Complex
class TestComplexArithmetic(TestCase):
def setUp(self):
self.zero = Complex()
@skip("Sure that this is correct, and will never change")
def test_default_complex_value(self):
self.assertEqual(self.zero.r, 0)
self.assertEqual(self.zero.i, 0)
def test_add_complex(self):
one_onei = Complex(1, 1)
result = one_onei + self.zero
self.assertEqual(result.r, 1)
self.assertEqual(result.i, 1)
def test_sub_complex(self):
one_onei = Complex(1, 1)
result = self.zero - one_onei
self.assertEqual(result.r, -1)
self.assertEqual(result.i, -1)
@skipIf(Complex.__version__ < (1, 1), "Not supported by this library")
def test_equal_complex(self):
zero = Complex()
one = Complex(1)
self.assertTrue(zero == self.zero)
self.assertFalse(self.zero == one)
def tearDown(self):
del self.zero