@@ -0,0 +1,1989 @@
+package com.github.davidmoten.ar;%0A%0Aimport static org.junit.Assert.assertEquals;%0A%0Aimport org.junit.Test;%0A%0Apublic class ComplexTest %7B%0A%0A%09private static final double PRECISION = 0.00001;%0A%09private static Complex a = new Complex(5.0, 6.0);%0A%09private static Complex b = new Complex(-3.0, 4.0);%0A%0A%09// System.out.println(%22a            = %22 + a);%0A%09// System.out.println(%22b            = %22 + b);%0A%09// System.out.println(%22Re(a)        = %22 + a.re());%0A%09// System.out.println(%22Im(a)        = %22 + a.im());%0A%09// System.out.println(%22b + a        = %22 + b.plus(a));%0A%09// System.out.println(%22a - b        = %22 + a.minus(b));%0A%09// System.out.println(%22a * b        = %22 + a.times(b));%0A%09// System.out.println(%22b * a        = %22 + b.times(a));%0A%09// System.out.println(%22a / b        = %22 + a.divides(b));%0A%09// System.out.println(%22(a / b) * b  = %22 + a.divides(b).times(b));%0A%09// System.out.println(%22conj(a)      = %22 + a.conjugate());%0A%09// System.out.println(%22%7Ca%7C          = %22 + a.abs());%0A%09// System.out.println(%22tan(a)       = %22 + a.tan());%0A%0A%09@Test%0A%09public void testConstructor() %7B%0A%09%09assertEquals(5.0, a.re(), PRECISION);%0A%09%09assertEquals(6.0, a.im(), PRECISION);%0A%09%7D%0A%0A%09@Test%0A%09public void testAddition() %7B%0A%09%09Complex c = a.plus(b);%0A%09%09assertEquals(2.0, c.re(), PRECISION);%0A%09%09assertEquals(10.0, c.im(), PRECISION);%0A%09%7D%0A%0A%09@Test%0A%09public void testSubtraction() %7B%0A%09%09Complex c = a.minus(b);%0A%09%09assertEquals(8.0, c.re(), PRECISION);%0A%09%09assertEquals(2.0, c.im(), PRECISION);%0A%09%7D%0A%0A%09@Test%0A%09public void testMultiplication() %7B%0A%09%09Complex c = a.times(b);%0A%09%09assertEquals(-39.0, c.re(), PRECISION);%0A%09%09assertEquals(2.0, c.im(), PRECISION);%0A%09%7D%0A%0A%09@Test%0A%09public void testDivision() %7B%0A%09%09Complex c = a.times(b).divides(b);%0A%09%09assertEquals(5.0, c.re(), PRECISION);%0A%09%09assertEquals(6.0, c.im(), PRECISION);%0A%09%7D%0A%0A%09@Test%0A%09public void testConjugate() %7B%0A%09%09Complex c = a.conjugate();%0A%09%09assertEquals(5.0, c.re(), PRECISION);%0A%09%09assertEquals(-6.0, c.im(), PRECISION);%0A%09%7D%0A%0A%09@Test%0A%09public void testAbsoluteValue() %7B%0A%09%09assertEquals(Math.sqrt(25 + 36), a.abs(), PRECISION);%0A%09%7D%0A%0A%7D%0A

add tests