Created
December 14, 2016 17:47
-
-
Save dsouzadyn/1eba8f5f7bad1aa486e5972762a51a1f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import unittest | |
from complex import Complex | |
class ClockTest(unittest.TestCase): | |
# Test creating a complex number | |
def test_creating_complex_one(self): | |
self.assertEqual('58.00-1.00i', str(Complex(58, -1))) | |
def test_creating_complex_two(self): | |
self.assertEqual('2.00-17.00i', str(Complex(2, -17))) | |
def test_creating_complex_three(self): | |
self.assertEqual('6.00+3.00i', str(Complex(6, 3))) | |
def test_creating_complex_four(self): | |
self.assertEqual('-32.00+12.00i', str(Complex(-32, 12))) | |
def test_creating_complex_five(self): | |
self.assertEqual('-36.00-78.00i', str(Complex(-36, -78))) | |
# Test addition of two complex numbers | |
def test_adding_complex_one(self): | |
self.assertEqual('2.00+3.00i', str(Complex(3, 1) + Complex(-1, 2))) | |
def test_adding_complex_two(self): | |
self.assertEqual('2.00+5.00i', str(Complex(3, 4) + Complex(-1, 1))) | |
def test_adding_complex_three(self): | |
self.assertEqual('6.00+2.00i', str(Complex(2, 5) + Complex(4, -3))) | |
def test_adding_complex_four(self): | |
self.assertEqual('255.00-49.00i', str(Complex(175, -34) + Complex(80, -15))) | |
def test_adding_complex_five(self): | |
self.assertEqual('-16.00+92.00i', str(Complex(-36, 10) + Complex(20, 82))) | |
# Test subtraction of two complex numbers | |
def test_subtrating_complex_one(self): | |
self.assertEqual('4.00-1.00i', str(Complex(3, 1) - Complex(-1, 2))) | |
def test_subtracting_complex_two(self): | |
self.assertEqual('4.00+3.00i', str(Complex(3, 4) - Complex(-1, 1))) | |
def test_subtracting_complex_three(self): | |
self.assertEqual('-2.00+8.00i', str(Complex(2, 5) - Complex(4, -3))) | |
def test_subtracting_complex_four(self): | |
self.assertEqual('95.00-19.00i', str(Complex(175, -34) - Complex(80, -15))) | |
def test_subtracting_complex_five(self): | |
self.assertEqual('-56.00-72.00i', str(Complex(-36, 10) - Complex(20, 82))) | |
# Test multiplication of two numbers | |
def test_multiplying_complex_one(self): | |
self.assertEqual('36.00+78.00i', str(Complex(6, 3) * Complex(10, 8))) | |
def test_multiplying_complex_two(self): | |
self.assertEqual('20.00+0.00i', str(Complex(4, 2) * Complex(4, -2))) | |
def test_multiplying_complex_three(self): | |
self.assertEqual('-5.00+14.00i', str(Complex(3, 2) * Complex(1, 4))) | |
if __name__ == '__main__': | |
unittest.main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import unittest | |
from complex import Complex | |
class ClockTest(unittest.TestCase): | |
# Test creating a complex number | |
def test_creating_complex_one(self): | |
self.assertEqual('58.00-1.00i', str(Complex(58, -1))) | |
def test_creating_complex_two(self): | |
self.assertEqual('2.00-17.00i', str(Complex(2, -17))) | |
def test_creating_complex_three(self): | |
self.assertEqual('6.00+3.00i', str(Complex(6, 3))) | |
def test_creating_complex_four(self): | |
self.assertEqual('-32.00+12.00i', str(Complex(-32, 12))) | |
def test_creating_complex_five(self): | |
self.assertEqual('-36.00-78.00i', str(Complex(-36, -78))) | |
# Test addition of two complex numbers | |
def test_adding_complex_one(self): | |
self.assertEqual('2.00+3.00i', str(Complex(3, 1) + Complex(-1, 2))) | |
def test_adding_complex_two(self): | |
self.assertEqual('2.00+5.00i', str(Complex(3, 4) + Complex(-1, 1))) | |
def test_adding_complex_three(self): | |
self.assertEqual('6.00+2.00i', str(Complex(2, 5) + Complex(4, -3))) | |
def test_adding_complex_four(self): | |
self.assertEqual('255.00-49.00i', str(Complex(175, -34) + Complex(80, -15))) | |
def test_adding_complex_five(self): | |
self.assertEqual('-16.00+92.00i', str(Complex(-36, 10) + Complex(20, 82))) | |
# Test subtraction of two complex numbers | |
def test_subtrating_complex_one(self): | |
self.assertEqual('4.00-1.00i', str(Complex(3, 1) - Complex(-1, 2))) | |
def test_subtracting_complex_two(self): | |
self.assertEqual('4.00+3.00i', str(Complex(3, 4) - Complex(-1, 1))) | |
def test_subtracting_complex_three(self): | |
self.assertEqual('-2.00+8.00i', str(Complex(2, 5) - Complex(4, -3))) | |
def test_subtracting_complex_four(self): | |
self.assertEqual('95.00-19.00i', str(Complex(175, -34) - Complex(80, -15))) | |
def test_subtracting_complex_five(self): | |
self.assertEqual('-56.00-72.00i', str(Complex(-36, 10) - Complex(20, 82))) | |
# Test multiplication of two numbers | |
def test_multiplying_complex_one(self): | |
self.assertEqual('36.00+78.00i', str(Complex(6, 3) * Complex(10, 8))) | |
def test_multiplying_complex_two(self): | |
self.assertEqual('20.00+0.00i', str(Complex(4, 2) * Complex(4, -2))) | |
def test_multiplying_complex_three(self): | |
self.assertEqual('-5.00+14.00i', str(Complex(3, 2) * Complex(1, 4))) | |
if __name__ == '__main__': | |
unittest.main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment