org.testng.Assert.checkRefEqualityAndLength()方法的使用及代码示例

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

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

Assert.checkRefEqualityAndLength介绍

[英]This methods check referential equality of given arguments as well as references length (assuming they are arrays). Successful execution of this method guaranties arrays length equality.
[中]此方法检查给定参数的引用相等性以及引用长度(假设它们是数组)。成功执行此方法可确保数组长度相等。

代码示例

代码示例来源:origin: org.testng/testng

/**
 * Asserts that two arrays contain the same elements in the same order. If they do not,
 * an AssertionError, with the given message, is thrown.
 *
 * @param actual   the actual value
 * @param expected the expected value
 * @param message  the assertion error message
 */
public static void assertEquals(byte[] actual, byte[] expected, String message) {
 if (checkRefEqualityAndLength(actual, expected, message)) return;
 for (int i = 0; i < expected.length; i++) {
  if (expected[i] != actual[i]) {
   fail(String.format(ARRAY_MISMATCH_TEMPLATE, i, Byte.toString(expected[i]), Byte.toString(actual[i]), message));
  }
 }
}

代码示例来源:origin: org.testng/testng

/**
 * Asserts that two arrays contain the same elements in the same order. If they do not,
 * an AssertionError, with the given message, is thrown.
 *
 * @param actual   the actual value
 * @param expected the expected value
 * @param message  the assertion error message
 */
public static void assertEquals(long[] actual, long[] expected, String message) {
 if (checkRefEqualityAndLength(actual, expected, message)) return;
 for (int i = 0; i < expected.length; i++) {
  if (expected[i] != actual[i]) {
   fail(String.format(ARRAY_MISMATCH_TEMPLATE, i, Long.toString(expected[i]), Long.toString(actual[i]), message));
  }
 }
}

代码示例来源:origin: org.testng/testng

/**
 * Asserts that two arrays contain the same elements in the same order. If they do not,
 * an AssertionError, with the given message, is thrown.
 *
 * @param actual   the actual value
 * @param expected the expected value
 * @param message  the assertion error message
 */
public static void assertEquals(int[] actual, int[] expected, String message) {
 if (checkRefEqualityAndLength(actual, expected, message)) return;
 for (int i = 0; i < expected.length; i++) {
  if (expected[i] != actual[i]) {
   fail(String.format(ARRAY_MISMATCH_TEMPLATE, i, Integer.toString(expected[i]), Integer.toString(actual[i]),
     message));
  }
 }
}

代码示例来源:origin: org.testng/testng

/**
 * Asserts that two arrays contain the same elements in the same order. If they do not,
 * an AssertionError, with the given message, is thrown.
 *
 * @param actual   the actual value
 * @param expected the expected value
 * @param message  the assertion error message
 */
public static void assertEquals(short[] actual, short[] expected, String message) {
 if (checkRefEqualityAndLength(actual, expected, message)) return;
 for (int i = 0; i < expected.length; i++) {
  if (expected[i] != actual[i]) {
   fail(String.format(ARRAY_MISMATCH_TEMPLATE, i, Short.toString(expected[i]), Short.toString(actual[i]),
     message));
  }
 }
}

代码示例来源:origin: org.testng/testng

/**
 * Asserts that two arrays contain the same elements in the same order. If they do not,
 * an AssertionError, with the given message, is thrown.
 *
 * @param actual   the actual value
 * @param expected the expected value
 * @param message  the assertion error message
 */
public static void assertEquals(float[] actual, float[] expected, String message) {
 if (checkRefEqualityAndLength(actual, expected, message)) return;
 for (int i = 0; i < expected.length; i++) {
  if (expected[i] != actual[i]) {
   fail(String.format(ARRAY_MISMATCH_TEMPLATE, i, Float.toString(expected[i]), Float.toString(actual[i]),
     message));
  }
 }
}

代码示例来源:origin: org.testng/testng

/**
 * Asserts that two arrays contain the same elements in the same order. If they do not,
 * an AssertionError, with the given message, is thrown.
 *
 * @param actual   the actual value
 * @param expected the expected value
 * @param message  the assertion error message
 */
public static void assertEquals(double[] actual, double[] expected, String message) {
 if (checkRefEqualityAndLength(actual, expected, message)) return;
 for (int i = 0; i < expected.length; i++) {
  if (expected[i] != actual[i]) {
   fail(String.format(ARRAY_MISMATCH_TEMPLATE, i, Double.toString(expected[i]), Double.toString(actual[i]),
     message));
  }
 }
}

代码示例来源:origin: org.testng/testng

/**
 * Asserts that two arrays contain the same elements in the same order. If they do not,
 * an AssertionError, with the given message, is thrown.
 *
 * @param actual   the actual value
 * @param expected the expected value
 * @param message  the assertion error message
 */
public static void assertEquals(boolean[] actual, boolean[] expected, String message) {
 if (checkRefEqualityAndLength(actual, expected, message)) return;
 for (int i = 0; i < expected.length; i++) {
  if (expected[i] != actual[i]) {
   fail(String.format(ARRAY_MISMATCH_TEMPLATE, i, Boolean.toString(expected[i]), Boolean.toString(actual[i]),
     message));
  }
 }
}

代码示例来源:origin: org.testng/testng

/**
 * Asserts that two arrays contain the same elements in the same order. If they do not,
 * an AssertionError, with the given message, is thrown.
 *
 * @param actual   the actual value
 * @param expected the expected value
 * @param message  the assertion error message
 */
public static void assertEquals(char[] actual, char[] expected, String message) {
 if (checkRefEqualityAndLength(actual, expected, message)) return;
 for (int i = 0; i < expected.length; i++) {
  if (expected[i] != actual[i]) {
   fail(String.format(ARRAY_MISMATCH_TEMPLATE, i, Character.toString(expected[i]), Character.toString(actual[i]),
     message));
  }
 }
}

代码示例来源:origin: cbeust/testng

/**
 * Asserts that two arrays contain the same elements in the same order. If they do not, an
 * AssertionError, with the given message, is thrown.
 *
 * @param actual the actual value
 * @param expected the expected value
 * @param message the assertion error message
 */
public static void assertEquals(int[] actual, int[] expected, String message) {
 if (checkRefEqualityAndLength(actual, expected, message)) return;
 for (int i = 0; i < expected.length; i++) {
  if (expected[i] != actual[i]) {
   fail(
     String.format(
       ARRAY_MISMATCH_TEMPLATE,
       i,
       Integer.toString(expected[i]),
       Integer.toString(actual[i]),
       message));
  }
 }
}

代码示例来源:origin: cbeust/testng

/**
 * Asserts that two arrays contain the same elements in the same order. If they do not, an
 * AssertionError, with the given message, is thrown.
 *
 * @param actual the actual value
 * @param expected the expected value
 * @param message the assertion error message
 */
public static void assertEquals(boolean[] actual, boolean[] expected, String message) {
 if (checkRefEqualityAndLength(actual, expected, message)) return;
 for (int i = 0; i < expected.length; i++) {
  if (expected[i] != actual[i]) {
   fail(
     String.format(
       ARRAY_MISMATCH_TEMPLATE,
       i,
       Boolean.toString(expected[i]),
       Boolean.toString(actual[i]),
       message));
  }
 }
}

代码示例来源:origin: cbeust/testng

/**
 * Asserts that two arrays contain the same elements in the same order. If they do not, an
 * AssertionError, with the given message, is thrown.
 *
 * @param actual the actual value
 * @param expected the expected value
 * @param message the assertion error message
 */
public static void assertEquals(float[] actual, float[] expected, String message) {
 if (checkRefEqualityAndLength(actual, expected, message)) return;
 for (int i = 0; i < expected.length; i++) {
  assertEquals(actual[i], expected[i],
      String.format(
          ARRAY_MISMATCH_TEMPLATE,
          i,
          Float.toString(expected[i]),
          Float.toString(actual[i]),
          message));
  }
}

代码示例来源:origin: cbeust/testng

/**
 * Asserts that two arrays contain the same elements in the same order. If they do not, an
 * AssertionError, with the given message, is thrown.
 *
 * @param actual the actual value
 * @param expected the expected value
 * @param message the assertion error message
 */
public static void assertEquals(double[] actual, double[] expected, String message) {
 if (checkRefEqualityAndLength(actual, expected, message)) return;
 for (int i = 0; i < expected.length; i++) {
  assertEquals(actual[i], expected[i],
      String.format(
          ARRAY_MISMATCH_TEMPLATE,
          i,
          Double.toString(expected[i]),
          Double.toString(actual[i]),
          message));
 }
}

代码示例来源:origin: cbeust/testng

/**
 * Asserts that two arrays contain the same elements in the same order. If they do not, an
 * AssertionError, with the given message, is thrown.
 *
 * @param actual the actual value
 * @param expected the expected value
 * @param message the assertion error message
 */
public static void assertEquals(byte[] actual, byte[] expected, String message) {
 if (checkRefEqualityAndLength(actual, expected, message)) return;
 for (int i = 0; i < expected.length; i++) {
  if (expected[i] != actual[i]) {
   fail(
     String.format(
       ARRAY_MISMATCH_TEMPLATE,
       i,
       Byte.toString(expected[i]),
       Byte.toString(actual[i]),
       message));
  }
 }
}

代码示例来源:origin: cbeust/testng

/**
 * Asserts that two arrays contain the same elements in the same order. If they do not, an
 * AssertionError, with the given message, is thrown.
 *
 * @param actual the actual value
 * @param expected the expected value
 * @param message the assertion error message
 */
public static void assertEquals(char[] actual, char[] expected, String message) {
 if (checkRefEqualityAndLength(actual, expected, message)) return;
 for (int i = 0; i < expected.length; i++) {
  if (expected[i] != actual[i]) {
   fail(
     String.format(
       ARRAY_MISMATCH_TEMPLATE,
       i,
       Character.toString(expected[i]),
       Character.toString(actual[i]),
       message));
  }
 }
}

代码示例来源:origin: cbeust/testng

/**
 * Asserts that two arrays contain the equal elements concerning a delta in the same order. If they do not, an
 * AssertionError, with the given message, is thrown.
 *
 * @param actual the actual value
 * @param expected the expected value
 * @param delta the absolute tolerable difference between the actual and expected values
 * @param message the assertion error message
 */
public static void assertEquals(double[] actual, double[] expected, double delta, String message) {
 if (checkRefEqualityAndLength(actual, expected, message)) {
  return;
 }
 for (int i = 0; i < expected.length; i++) {
  assertEquals(actual[i], expected[i], delta,
      String.format(
          ARRAY_MISMATCH_TEMPLATE,
          i,
          Double.toString(expected[i]),
          Double.toString(actual[i]),
          message));
 }
}

代码示例来源:origin: cbeust/testng

/**
 * Asserts that two arrays contain the same elements in the same order. If they do not, an
 * AssertionError, with the given message, is thrown.
 *
 * @param actual the actual value
 * @param expected the expected value
 * @param message the assertion error message
 */
public static void assertEquals(short[] actual, short[] expected, String message) {
 if (checkRefEqualityAndLength(actual, expected, message)) return;
 for (int i = 0; i < expected.length; i++) {
  if (expected[i] != actual[i]) {
   fail(
     String.format(
       ARRAY_MISMATCH_TEMPLATE,
       i,
       Short.toString(expected[i]),
       Short.toString(actual[i]),
       message));
  }
 }
}

代码示例来源:origin: cbeust/testng

/**
 * Asserts that two arrays contain the same elements in the same order. If they do not, an
 * AssertionError, with the given message, is thrown.
 *
 * @param actual the actual value
 * @param expected the expected value
 * @param message the assertion error message
 */
public static void assertEquals(long[] actual, long[] expected, String message) {
 if (checkRefEqualityAndLength(actual, expected, message)) return;
 for (int i = 0; i < expected.length; i++) {
  if (expected[i] != actual[i]) {
   fail(
     String.format(
       ARRAY_MISMATCH_TEMPLATE,
       i,
       Long.toString(expected[i]),
       Long.toString(actual[i]),
       message));
  }
 }
}

代码示例来源:origin: cbeust/testng

/**
 * Asserts that two arrays contain the equal elements concerning a delta in the same order. If
 * they do not, an
 * AssertionError is thrown.
 *
 * @param actual the actual value
 * @param expected the expected value
 * @param delta the absolute tolerable difference between the actual and expected values
 * @param message the assertion error message
 */
public static void assertEquals(float[] actual, float[] expected, float delta, String message) {
 if (checkRefEqualityAndLength(actual, expected, message)) {
  return;
 }
 for (int i = 0; i < expected.length; i++) {
  assertEquals(actual[i], expected[i], delta,
      String.format(
          ARRAY_MISMATCH_TEMPLATE,
          i,
          Float.toString(expected[i]),
          Float.toString(actual[i]),
          message));
 }
}

相关文章