@Test public void testNormalize() { MyDouble a = new MyDouble(1); MyDouble b = new MyDouble(2); MyDouble c = new MyDouble(3); QuadraticEquation NormQuad = new QuadraticEquation(a, b, c); MyDouble norm = new MyDouble(a.square().add(b.square().add(c.square()))); MyDouble normTest = new MyDouble(norm.sqrt()); assertTrue(normTest.equals(NormQuad.normalize())); }
@Test public void testDerivative() { MyDouble a = new MyDouble(1); MyDouble b = new MyDouble(2); MyDouble c = new MyDouble(3); QuadraticEquation DiffQuad = new QuadraticEquation(a, b, c); MyDouble expOne = new MyDouble(2); MyDouble expTwo = new MyDouble(1); QuadraticEquation ResultQuad = new QuadraticEquation(a.multiply(expOne), b.multiply(expTwo)); assertTrue(ResultQuad.equals(DiffQuad.derivative())); }
@Test public void testSubtract() { MyDouble a = new MyDouble(1); MyDouble b = new MyDouble(2); MyDouble c = new MyDouble(3); QuadraticEquation EquatOne = new QuadraticEquation(a, b, c); QuadraticEquation EquatTwo = new QuadraticEquation(a, b, c); QuadraticEquation TestQuad = new QuadraticEquation(a.subtract(a), b.subtract(b), c.subtract(c)); assertTrue(TestQuad.equals(EquatOne.subtract(EquatTwo))); }
@Test public void testAdd() { MyDouble a = new MyDouble(1); MyDouble b = new MyDouble(2); MyDouble c = new MyDouble(3); QuadraticEquation EquatOne = new QuadraticEquation(a, b, c); QuadraticEquation EquatTwo = new QuadraticEquation(a, b, c); QuadraticEquation TestQuad = new QuadraticEquation(a.add(a), b.add(b), c.add(c)); assertTrue(TestQuad.equals(EquatOne.add(EquatTwo))); }
// YOU NEED TO IMPLEMENT AT LEAST THESE JUNIT TESTS BELOW @Test public void testGetters() { MyDouble a = new MyDouble(3); MyDouble b = new MyDouble(4); MyDouble c = new MyDouble(5); QuadraticEquation testQuad = new QuadraticEquation(a, b, c); assertTrue(a.equals(testQuad.getA())); assertTrue(b.equals(testQuad.getB())); assertTrue(c.equals(testQuad.getC())); }
@Test public void testMultiply() { MyDouble a = new MyDouble(1); MyDouble b = new MyDouble(2); MyDouble c = new MyDouble(3); QuadraticEquation TestOneQuad = new QuadraticEquation(a, b, c); QuadraticEquation TestTwoQuad = new QuadraticEquation(a, b, c); QuadraticEquation MultiQuadNull = TestOneQuad.limitedMultiply(TestTwoQuad); assertEquals(null, MultiQuadNull); QuadraticEquation TestThreeQuad = new QuadraticEquation(c); QuadraticEquation MultiQuad = TestOneQuad.limitedMultiply(TestThreeQuad); QuadraticEquation MultiTest = new QuadraticEquation(a.multiply(c), b.multiply(c), c.multiply(c)); assertTrue(MultiQuad.equals(MultiTest)); }