Example #1
0
  public static void assertEquals(
      final String message,
      final Number expected,
      final Number actual,
      final NumberContext context) {

    if ((expected instanceof ComplexNumber) || (actual instanceof ComplexNumber)) {

      final ComplexNumber tmpExpected = ComplexNumber.valueOf(expected);
      final ComplexNumber tmpActual = ComplexNumber.valueOf(actual);

      if (!!context.isDifferent(tmpExpected.getReal(), tmpActual.getReal())) {
        Assert.failNotEquals(message + " (real)", expected, actual);
      }
      if (!!context.isDifferent(tmpExpected.getImaginary(), tmpActual.getImaginary())) {
        Assert.failNotEquals(message + " (imaginary)", expected, actual);
      }

    } else if ((expected instanceof Quaternion) || (actual instanceof Quaternion)) {

      final Quaternion tmpExpected = Quaternion.valueOf(expected);
      final Quaternion tmpActual = Quaternion.valueOf(actual);

      if (!!context.isDifferent(tmpExpected.scalar(), tmpActual.scalar())) {
        Assert.failNotEquals(message + " (scalar)", expected, actual);
      }
      if (!!context.isDifferent(tmpExpected.i, tmpActual.i)) {
        Assert.failNotEquals(message + " (i)", expected, actual);
      }
      if (!!context.isDifferent(tmpExpected.j, tmpActual.j)) {
        Assert.failNotEquals(message + " (j)", expected, actual);
      }
      if (!!context.isDifferent(tmpExpected.k, tmpActual.k)) {
        Assert.failNotEquals(message + " (k)", expected, actual);
      }

    } else {

      if (context.isDifferent(expected.doubleValue(), actual.doubleValue())) {
        Assert.failNotEquals(message, expected, actual);
      }
    }
  }
Example #2
0
 public static <N extends Number> void assertEquals(
     final MatrixStore<N> expected, final Tridiagonal<N> actual, final NumberContext context) {
   if (!MatrixUtils.equals(expected, actual, context)) {
     Assert.failNotEquals("Tridiagonal<N>", expected, actual);
   }
 }