Ejemplo n.º 1
0
  private void assertMatchEquals(List<Completion> res, String... expected) {
    String[] result = new String[res.size()];
    for (int i = 0; i < res.size(); i++) {
      result[i] = res.get(i).toString();
    }

    if (!Arrays.equals(stripScore(expected), stripScore(result))) {
      int colLen = Math.max(maxLen(expected), maxLen(result));

      StringBuilder b = new StringBuilder();
      String format = "%" + colLen + "s  " + "%" + colLen + "s\n";
      b.append(String.format(Locale.ROOT, format, "Expected", "Result"));
      for (int i = 0; i < Math.max(result.length, expected.length); i++) {
        b.append(
            String.format(
                Locale.ROOT,
                format,
                i < expected.length ? expected[i] : "--",
                i < result.length ? result[i] : "--"));
      }

      System.err.println(b.toString());
      fail("Expected different output:\n" + b.toString());
    }
  }
 public static void sortAndDedup(final ObjectArrayList<byte[]> array) {
   int len = array.size();
   if (len > 1) {
     sort(array);
     int uniqueCount = 1;
     for (int i = 1; i < len; ++i) {
       if (!Arrays.equals(array.get(i), array.get(i - 1))) {
         array.set(uniqueCount++, array.get(i));
       }
     }
     array.elementsCount = uniqueCount;
   }
 }