def test_MultiplyTwoComplexNumbers(self): p=Complex(3,2) o=Complex(2,3) r=Complex(0,13) self.assertEqual(p.MultiplyTwoComplexNumbers(o).getReal(),r.getReal()) self.assertEqual(p.MultiplyTwoComplexNumbers(o).getImaginary(), r.getImaginary()) p=Complex(0,2) o=Complex(2,3) r=Complex(-6,4) self.assertEqual(p.MultiplyTwoComplexNumbers(o).getReal(),r.getReal()) self.assertEqual(p.MultiplyTwoComplexNumbers(o).getImaginary(), r.getImaginary()) p=Complex(0,2) o=Complex(2,0) r=Complex(0,4) self.assertEqual(p.MultiplyTwoComplexNumbers(o).getReal(),r.getReal()) self.assertEqual(p.MultiplyTwoComplexNumbers(o).getImaginary(), r.getImaginary()) p=Complex() o=Complex() r=Complex() self.assertEqual(p.MultiplyTwoComplexNumbers(o).getReal(),r.getReal()) self.assertEqual(p.MultiplyTwoComplexNumbers(o).getImaginary(), r.getImaginary()) p=Complex(2) o=Complex(3) r=Complex(6,0) self.assertEqual(p.MultiplyTwoComplexNumbers(o).getReal(),r.getReal()) self.assertEqual(p.MultiplyTwoComplexNumbers(o).getImaginary(), r.getImaginary())
def test_AddTwoComplexNumbers(self): p=Complex(3,2) o=Complex(2,3) r=Complex(5,5) self.assertEqual(p.AddTwoComplexNumbers(o).getReal(),r.getReal()) self.assertEqual(p.AddTwoComplexNumbers(o).getImaginary(), r.getImaginary()) p=Complex(0,2) o=Complex(2,3) r=Complex(2,5) self.assertEqual(p.AddTwoComplexNumbers(o).getReal(),r.getReal()) self.assertEqual(p.AddTwoComplexNumbers(o).getImaginary(), r.getImaginary()) p=Complex(0,2) o=Complex(2,0) r=Complex(2,2) self.assertEqual(p.AddTwoComplexNumbers(o).getReal(),r.getReal()) self.assertEqual(p.AddTwoComplexNumbers(o).getImaginary(), r.getImaginary()) p=Complex() o=Complex() r=Complex() self.assertEqual(p.AddTwoComplexNumbers(o).getReal(),r.getReal()) self.assertEqual(p.AddTwoComplexNumbers(o).getImaginary(), r.getImaginary()) p=Complex(2) o=Complex(3) r=Complex(5) self.assertEqual(p.AddTwoComplexNumbers(o).getReal(),r.getReal()) self.assertEqual(p.AddTwoComplexNumbers(o).getImaginary(), r.getImaginary())
def test_getImaginary(self): p=Complex(3,4) self.assertEqual(p.getImaginary(),4) p=Complex(5) self.assertEqual(p.getImaginary(),0) p=Complex() self.assertEqual(p.getImaginary(),0) p=Complex(0,0) self.assertEqual(p.getImaginary(),0) p=Complex(5,0) self.assertEqual(p.getImaginary(),0)
def test_getConjugate(self): p=Complex(3,4) q=Complex(3,-4) self.assertEqual(p.getConjugate().getImaginary(),q.getImaginary()) p=Complex(2,-4) q=Complex(2,4) self.assertEqual(p.getConjugate().getImaginary(),q.getImaginary()) p=Complex() q=Complex() self.assertEqual(p.getConjugate().getImaginary(),q.getImaginary()) p=Complex(5,0) q=Complex(5,0) self.assertEqual(p.getConjugate().getImaginary(),q.getImaginary()) p=Complex(-3) q=Complex(-3) self.assertEqual(p.getConjugate().getImaginary(),q.getImaginary())
def test_setImaginary(self): p=Complex(3,4) p.setImaginary(5) self.assertEqual(p.getImaginary(),5) p=Complex(3,4) p.setImaginary(0) self.assertEqual(p.getImaginary(),0) p=Complex(3,4) p.setImaginary(-5) self.assertEqual(p.getImaginary(),-5) p=Complex(3,4) p.setImaginary(13) self.assertEqual(p.getImaginary(),13) p=Complex(3,4) p.setImaginary(-9) self.assertEqual(p.getImaginary(),-9)
def test_MultiplyByImaginary(self): p=Complex(3,4) q=Complex(-16,12) self.assertEqual(p.MultiplyByImaginary(4).getReal(),q.getReal()) self.assertEqual(p.MultiplyByImaginary(4).getImaginary(),q.getImaginary()) p=Complex(2,-4) q=Complex(-8,-4) self.assertEqual(p.MultiplyByImaginary(-2).getReal(),q.getReal()) self.assertEqual(p.MultiplyByImaginary(-2).getImaginary(),q.getImaginary()) p=Complex() q=Complex() self.assertEqual(p.MultiplyByImaginary(7).getReal(),q.getReal()) self.assertEqual(p.MultiplyByImaginary(7).getImaginary(),q.getImaginary()) p=Complex(5,0) q=Complex(0,10) self.assertEqual(p.MultiplyByImaginary(2).getReal(),q.getReal()) self.assertEqual(p.MultiplyByImaginary(2).getImaginary(),q.getImaginary()) p=Complex(-3) q=Complex(0,-6) self.assertEqual(p.MultiplyByImaginary(2).getReal(),q.getReal()) self.assertEqual(p.MultiplyByImaginary(2).getImaginary(),q.getImaginary())
def test_MultiplyByReal(self): p=Complex(3,4) q=Complex(6,8) self.assertEqual(p.MultiplyByReal(2).getReal(),q.getReal()) self.assertEqual(p.MultiplyByReal(2).getImaginary(),q.getImaginary()) p=Complex(2,-4) q=Complex(-2,4) self.assertEqual(p.MultiplyByReal(-1).getReal(),q.getReal()) self.assertEqual(p.MultiplyByReal(-1).getImaginary(),q.getImaginary()) p=Complex() q=Complex() self.assertEqual(p.MultiplyByReal(7).getReal(),q.getReal()) self.assertEqual(p.MultiplyByReal(7).getImaginary(),q.getImaginary()) p=Complex(5,0) q=Complex(0,0) self.assertEqual(p.MultiplyByReal(0).getReal(),q.getReal()) self.assertEqual(p.MultiplyByReal(0).getImaginary(),q.getImaginary()) p=Complex(-3) q=Complex(-3) self.assertEqual(p.MultiplyByReal(1).getReal(),q.getReal()) self.assertEqual(p.MultiplyByReal(1).getImaginary(),q.getImaginary())