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_getReal(self): p=Complex(3,4) self.assertEqual(p.getReal(),3) p=Complex(5) self.assertEqual(p.getReal(),5) p=Complex() self.assertEqual(p.getReal(),0) p=Complex(0,0) self.assertEqual(p.getReal(),0) p=Complex(5,0) self.assertEqual(p.getReal(),5)
def test_setReal(self): p=Complex(3,4) p.setReal(4) self.assertEqual(p.getReal(),4) p=Complex(3,4) p.setReal(0) self.assertEqual(p.getReal(),0) p=Complex(3,4) p.setReal(-5) self.assertEqual(p.getReal(),-5) p=Complex(3,4) p.setReal(13) self.assertEqual(p.getReal(),13) p=Complex(3,4) p.setReal(-9) self.assertEqual(p.getReal(),-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())