Ejemplo n.º 1
0
 @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)));
 }
Ejemplo n.º 2
0
 @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)));
 }
Ejemplo n.º 3
0
 @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()));
 }
Ejemplo n.º 4
0
 @Test
 public void testEqualsAndCompareTo() {
   MyDouble a = new MyDouble(1);
   MyDouble b = new MyDouble(2);
   MyDouble c = new MyDouble(3);
   QuadraticEquation TestQuadOne = new QuadraticEquation(a, b, c);
   QuadraticEquation TestQuadTwo = new QuadraticEquation(a, b, c);
   QuadraticEquation TestQuadThree = new QuadraticEquation(c, c, c);
   assertEquals(0, TestQuadOne.compareTo(TestQuadTwo));
   assertEquals(-1, TestQuadOne.compareTo(TestQuadThree));
   assertEquals(true, TestQuadOne.equals(TestQuadTwo));
 }
Ejemplo n.º 5
0
 @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));
 }