org.junit.Assert.equalsRegardingNull()方法的使用及代码示例

x33g5p2x  于2022-01-15 转载在 其他  
字(10.8k)|赞(0)|评价(0)|浏览(201)

本文整理了Java中org.junit.Assert.equalsRegardingNull()方法的一些代码示例,展示了Assert.equalsRegardingNull()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Assert.equalsRegardingNull()方法的具体详情如下:
包路径:org.junit.Assert
类名称:Assert
方法名:equalsRegardingNull

Assert.equalsRegardingNull介绍

暂无

代码示例

代码示例来源:origin: junit-team/junit4

/**
 * Asserts that two objects are <b>not</b> equals. If they are, an
 * {@link AssertionError} is thrown with the given message. If
 * <code>unexpected</code> and <code>actual</code> are <code>null</code>,
 * they are considered equal.
 *
 * @param message the identifying message for the {@link AssertionError} (<code>null</code>
 * okay)
 * @param unexpected unexpected value to check
 * @param actual the value to check against <code>unexpected</code>
 */
public static void assertNotEquals(String message, Object unexpected,
    Object actual) {
  if (equalsRegardingNull(unexpected, actual)) {
    failEquals(message, actual);
  }
}

代码示例来源:origin: google/j2objc

/**
 * Asserts that two objects are <b>not</b> equals. If they are, an
 * {@link AssertionError} is thrown with the given message. If
 * <code>first</code> and <code>second</code> are <code>null</code>,
 * they are considered equal.
 *
 * @param message the identifying message for the {@link AssertionError} (<code>null</code>
 * okay)
 * @param first first value to check
 * @param second the value to check against <code>first</code>
 */
static public void assertNotEquals(String message, Object first,
    Object second) {
  if (equalsRegardingNull(first, second)) {
    failEquals(message, first);
  }
}

代码示例来源:origin: junit-team/junit4

static String format(String message, Object expected, Object actual) {
  String formatted = "";
  if (message != null && !"".equals(message)) {
    formatted = message + " ";
  }
  String expectedString = String.valueOf(expected);
  String actualString = String.valueOf(actual);
  if (equalsRegardingNull(expectedString, actualString)) {
    return formatted + "expected: "
        + formatClassAndValue(expected, expectedString)
        + " but was: " + formatClassAndValue(actual, actualString);
  } else {
    return formatted + "expected:<" + expectedString + "> but was:<"
        + actualString + ">";
  }
}

代码示例来源:origin: google/j2objc

/**
 * Asserts that two objects are equal. If they are not, an
 * {@link AssertionError} is thrown with the given message. If
 * <code>expected</code> and <code>actual</code> are <code>null</code>,
 * they are considered equal.
 *
 * @param message the identifying message for the {@link AssertionError} (<code>null</code>
 * okay)
 * @param expected expected value
 * @param actual actual value
 */
static public void assertEquals(String message, Object expected,
    Object actual) {
  if (equalsRegardingNull(expected, actual)) {
    return;
  } else if (expected instanceof String && actual instanceof String) {
    String cleanMessage = message == null ? "" : message;
    throw new ComparisonFailure(cleanMessage, (String) expected,
        (String) actual);
  } else {
    failNotEquals(message, expected, actual);
  }
}

代码示例来源:origin: junit-team/junit4

/**
 * Asserts that two objects are equal. If they are not, an
 * {@link AssertionError} is thrown with the given message. If
 * <code>expected</code> and <code>actual</code> are <code>null</code>,
 * they are considered equal.
 *
 * @param message the identifying message for the {@link AssertionError} (<code>null</code>
 * okay)
 * @param expected expected value
 * @param actual actual value
 */
public static void assertEquals(String message, Object expected,
    Object actual) {
  if (equalsRegardingNull(expected, actual)) {
    return;
  }
  if (expected instanceof String && actual instanceof String) {
    String cleanMessage = message == null ? "" : message;
    throw new ComparisonFailure(cleanMessage, (String) expected,
        (String) actual);
  } else {
    failNotEquals(message, expected, actual);
  }
}

代码示例来源:origin: camunda/camunda-bpm-platform

/**
 * Asserts that two objects are <b>not</b> equals. If they are, an
 * {@link AssertionError} is thrown with the given message. If
 * <code>first</code> and <code>second</code> are <code>null</code>,
 * they are considered equal.
 *
 * @param message the identifying message for the {@link AssertionError} (<code>null</code>
 * okay)
 * @param first first value to check
 * @param second the value to check against <code>first</code>
 */
static public void assertNotEquals(String message, Object first,
    Object second) {
  if (equalsRegardingNull(first, second)) {
    failEquals(message, first);
  }
}

代码示例来源:origin: camunda/camunda-bpm-platform

/**
 * Asserts that two objects are equal. If they are not, an
 * {@link AssertionError} is thrown with the given message. If
 * <code>expected</code> and <code>actual</code> are <code>null</code>,
 * they are considered equal.
 *
 * @param message the identifying message for the {@link AssertionError} (<code>null</code>
 * okay)
 * @param expected expected value
 * @param actual actual value
 */
static public void assertEquals(String message, Object expected,
    Object actual) {
  if (equalsRegardingNull(expected, actual)) {
    return;
  } else if (expected instanceof String && actual instanceof String) {
    String cleanMessage = message == null ? "" : message;
    throw new ComparisonFailure(cleanMessage, (String) expected,
        (String) actual);
  } else {
    failNotEquals(message, expected, actual);
  }
}

代码示例来源:origin: com.impetus.fabric/fabric-jdbc-driver-shaded

/**
 * Asserts that two objects are <b>not</b> equals. If they are, an
 * {@link AssertionError} is thrown with the given message. If
 * <code>unexpected</code> and <code>actual</code> are <code>null</code>,
 * they are considered equal.
 *
 * @param message the identifying message for the {@link AssertionError} (<code>null</code>
 * okay)
 * @param unexpected unexpected value to check
 * @param actual the value to check against <code>unexpected</code>
 */
static public void assertNotEquals(String message, Object unexpected,
    Object actual) {
  if (equalsRegardingNull(unexpected, actual)) {
    failEquals(message, actual);
  }
}

代码示例来源:origin: org.junit/com.springsource.org.junit

/**
 * Asserts that two objects are <b>not</b> equals. If they are, an
 * {@link AssertionError} is thrown with the given message. If
 * <code>first</code> and <code>second</code> are <code>null</code>,
 * they are considered equal.
 *
 * @param message the identifying message for the {@link AssertionError} (<code>null</code>
 * okay)
 * @param first first value to check
 * @param second the value to check against <code>first</code>
 */
static public void assertNotEquals(String message, Object first,
    Object second) {
  if (equalsRegardingNull(first, second)) {
    failEquals(message, first);
  }
}

代码示例来源:origin: org.ops4j.pax.tipi/org.ops4j.pax.tipi.junit

/**
 * Asserts that two objects are <b>not</b> equals. If they are, an
 * {@link AssertionError} is thrown with the given message. If
 * <code>unexpected</code> and <code>actual</code> are <code>null</code>,
 * they are considered equal.
 *
 * @param message the identifying message for the {@link AssertionError} (<code>null</code>
 * okay)
 * @param unexpected unexpected value to check
 * @param actual the value to check against <code>unexpected</code>
 */
static public void assertNotEquals(String message, Object unexpected,
    Object actual) {
  if (equalsRegardingNull(unexpected, actual)) {
    failEquals(message, actual);
  }
}

代码示例来源:origin: com.oracle/truffle-tck

/**
 * Asserts that two objects are <b>not</b> equals. If they are, an
 * {@link AssertionError} is thrown with the given message. If
 * <code>first</code> and <code>second</code> are <code>null</code>,
 * they are considered equal.
 *
 * @param message the identifying message for the {@link AssertionError} (<code>null</code>
 * okay)
 * @param first first value to check
 * @param second the value to check against <code>first</code>
 */
static public void assertNotEquals(String message, Object first,
    Object second) {
  if (equalsRegardingNull(first, second)) {
    failEquals(message, first);
  }
}

代码示例来源:origin: org.junit/com.springsource.org.junit

/**
 * Asserts that two objects are equal. If they are not, an
 * {@link AssertionError} is thrown with the given message. If
 * <code>expected</code> and <code>actual</code> are <code>null</code>,
 * they are considered equal.
 *
 * @param message the identifying message for the {@link AssertionError} (<code>null</code>
 * okay)
 * @param expected expected value
 * @param actual actual value
 */
static public void assertEquals(String message, Object expected,
    Object actual) {
  if (equalsRegardingNull(expected, actual)) {
    return;
  } else if (expected instanceof String && actual instanceof String) {
    String cleanMessage = message == null ? "" : message;
    throw new ComparisonFailure(cleanMessage, (String) expected,
        (String) actual);
  } else {
    failNotEquals(message, expected, actual);
  }
}

代码示例来源:origin: org.ops4j.pax.tipi/org.ops4j.pax.tipi.junit

/**
 * Asserts that two objects are equal. If they are not, an
 * {@link AssertionError} is thrown with the given message. If
 * <code>expected</code> and <code>actual</code> are <code>null</code>,
 * they are considered equal.
 *
 * @param message the identifying message for the {@link AssertionError} (<code>null</code>
 * okay)
 * @param expected expected value
 * @param actual actual value
 */
static public void assertEquals(String message, Object expected,
    Object actual) {
  if (equalsRegardingNull(expected, actual)) {
    return;
  } else if (expected instanceof String && actual instanceof String) {
    String cleanMessage = message == null ? "" : message;
    throw new ComparisonFailure(cleanMessage, (String) expected,
        (String) actual);
  } else {
    failNotEquals(message, expected, actual);
  }
}

代码示例来源:origin: com.oracle/truffle-tck

/**
 * Asserts that two objects are equal. If they are not, an
 * {@link AssertionError} is thrown with the given message. If
 * <code>expected</code> and <code>actual</code> are <code>null</code>,
 * they are considered equal.
 *
 * @param message the identifying message for the {@link AssertionError} (<code>null</code>
 * okay)
 * @param expected expected value
 * @param actual actual value
 */
static public void assertEquals(String message, Object expected,
    Object actual) {
  if (equalsRegardingNull(expected, actual)) {
    return;
  } else if (expected instanceof String && actual instanceof String) {
    String cleanMessage = message == null ? "" : message;
    throw new ComparisonFailure(cleanMessage, (String) expected,
        (String) actual);
  } else {
    failNotEquals(message, expected, actual);
  }
}

代码示例来源:origin: com.impetus.fabric/fabric-jdbc-driver-shaded

/**
 * Asserts that two objects are equal. If they are not, an
 * {@link AssertionError} is thrown with the given message. If
 * <code>expected</code> and <code>actual</code> are <code>null</code>,
 * they are considered equal.
 *
 * @param message the identifying message for the {@link AssertionError} (<code>null</code>
 * okay)
 * @param expected expected value
 * @param actual actual value
 */
static public void assertEquals(String message, Object expected,
    Object actual) {
  if (equalsRegardingNull(expected, actual)) {
    return;
  } else if (expected instanceof String && actual instanceof String) {
    String cleanMessage = message == null ? "" : message;
    throw new ComparisonFailure(cleanMessage, (String) expected,
        (String) actual);
  } else {
    failNotEquals(message, expected, actual);
  }
}

相关文章