コード例 #1
0
ファイル: TestUtils.java プロジェクト: ddrummond/ojAlgo
  public static void assertEquals(
      final String message,
      final double expected,
      final double actual,
      final NumberContext context) {
    // TestUtils.assertEquals(message, Double.valueOf(expected), Double.valueOf(actual), context);
    if (Double.isNaN(expected) && Double.isNaN(actual)) {

    } else if (context.isDifferent(expected, actual)) {
      Assert.fail(Assert.format(message, expected, actual));
    }
  }
コード例 #2
0
ファイル: TestUtils.java プロジェクト: ddrummond/ojAlgo
  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);
      }
    }
  }