1
2
3
4
5
6
7 package net.sourceforge.kamiwaai.geometricalgebra;
8
9 import junit.framework.TestCase;
10
11 /***
12 * @author Ginanjar Utama
13 *
14 * To change the template for this generated type comment go to Window -
15 * Preferences - Java - Code Generation - Code and Comments
16 */
17 public class ComplexNumberTest extends TestCase {
18 ComplexNumber fiveone = new ComplexNumber(5.0, 1.0);
19 ComplexNumber onefive = new ComplexNumber(1.0, 5.0);
20 public void testAddComplexNumberReturnNewComplexNumber() {
21 ComplexNumber sixsix = new ComplexNumber(6.0, 6.0);
22 assertEquals(sixsix, fiveone.add(onefive));
23 assertFalse(fiveone.equals(fiveone.add(onefive)));
24 }
25 public void testSubstractComplexNumberReturnNewComplexNumber() {
26 ComplexNumber fournegfour = new ComplexNumber(4.0, -4.0);
27 assertEquals(fournegfour, fiveone.sub(onefive));
28 assertFalse(fiveone.equals(fiveone.sub(onefive)));
29 }
30 public void testMultiplyComplexNumberReturnNewComplexNumber() {
31 ComplexNumber result = new ComplexNumber(0.0, 26.0);
32 assertEquals(result, fiveone.mult(onefive));
33 assertFalse(fiveone.equals(fiveone.mult(onefive)));
34 }
35 public void testMagnitude(){
36 assertEquals("magnitude should be the same", fiveone.Magnitude(), Math.sqrt(26.0), 0.000001);
37 assertEquals("magnitude should be the same", fiveone.Magnitude(), onefive.Magnitude(), 0.000001);
38 }
39 }