Check method (unit test).
@@ -58,56 +58,66 @@ public class FieldParametricTest {
public void testAdditionAssociativity() {
final Object r1 = field.add(field.add(a, b), c);
final Object r2 = field.add(a, field.add(b, c));
- Assert.assertTrue(r1.equals(r2));
+ assertEquals(r1, r2);
}
@Test
public void testAdditionCommutativity() {
final Object r1 = field.add(a, b);
final Object r2 = field.add(b, a);
- Assert.assertTrue(r1.equals(r2));
+ assertEquals(r1, r2);
}
@Test
public void testAdditiveIdentity() {
final Object r1 = field.add(a, field.zero());
final Object r2 = a;
- Assert.assertTrue(r1.equals(r2));
+ assertEquals(r1, r2);
}
@Test
public void testAdditiveInverse() {
final Object r1 = field.add(a, field.negate(a));
final Object r2 = field.zero();
- Assert.assertTrue(r1.equals(r2));
+ assertEquals(r1, r2);
}
@Test
public void testMultiplicationAssociativity() {
final Object r1 = field.multiply(field.multiply(a, b), c);
final Object r2 = field.multiply(a, field.multiply(b, c));
- Assert.assertTrue(r1.equals(r2));
+ assertEquals(r1, r2);
}
@Test
public void testMultiplicationCommutativity() {
final Object r1 = field.multiply(a, b);
final Object r2 = field.multiply(b, a);
- Assert.assertTrue(r1.equals(r2));
+ assertEquals(r1, r2);
}
@Test
public void testMultiplicativeIdentity() {
final Object r1 = field.multiply(a, field.one());
final Object r2 = a;
- Assert.assertTrue(r1.equals(r2));
+ assertEquals(r1, r2);
}
@Test
public void testMultiplicativeInverse() {
final Object r1 = field.multiply(a, field.reciprocal(a));
final Object r2 = field.one();
- Assert.assertTrue(r1.equals(r2));
+ assertEquals(r1, r2);
}
@Test
public void testDistributivity() {
final Object r1 = field.multiply(a, field.add(b, c));
final Object r2 = field.add(field.multiply(a, b), field.multiply(a, c));
- Assert.assertTrue(r1.equals(r2));
+ assertEquals(r1, r2);
+ }
+
+ /**
+ * @param a Instance.
+ * @param b Instance.
+ */
+ private void assertEquals(Object a,
+ Object b) {
+ Assert.assertTrue(a + " != " + b,
+ a.equals(b));
}
}
