コード例 #1
0
ファイル: TestTest.java プロジェクト: danmueller/gradle
 @org.junit.Test
 public void testUnmanagedClasspath() {
   List<Object> list1 = WrapUtil.toList("a", new Object());
   assertSame(test, test.unmanagedClasspath(list1.toArray(new Object[list1.size()])));
   assertEquals(list1, test.getUnmanagedClasspath());
   List list2 = WrapUtil.toList(WrapUtil.toList("b", "c"));
   test.unmanagedClasspath(list2.toArray(new Object[list2.size()]));
   assertEquals(GUtil.addLists(list1, GUtil.flatten(list2)), test.getUnmanagedClasspath());
 }
コード例 #2
0
ファイル: BTreeMapTest.java プロジェクト: hangum/mapdb
  @Test
  public void test_find_children_2() {
    for (boolean left : new boolean[] {true, false}) {
      for (boolean right : new boolean[] {true, false}) {
        List keys = new ArrayList();
        for (int i = 0; i < 100; i += 10) {
          keys.add(i);
        }

        int[] child = new int[keys.size() + (right ? 1 : 0) + (left ? 1 : 0)];
        Arrays.fill(child, 11);
        if (right) child[child.length - 1] = 0;

        BTreeMap.BNode n = new BTreeMap.DirNode(keys.toArray(), left, right, false, mkchild(child));

        for (int i = -10; i < 110; i++) {
          int pos = BTreeKeySerializer.BASIC.findChildren(n, i);
          int expected = (i + (left ? 19 : 9)) / 10;
          expected = Math.max(left ? 1 : 0, expected);
          expected = Math.min(left ? 11 : 10, expected);
          assertEquals("i:" + i + " - l:" + left + " - r:" + right, expected, pos);
        }
      }
    }
  }
コード例 #3
0
  @Test
  public void fetchItems() {
    itemProvider.addItems(FIRST_ITEM, SECOND_ITEM);

    List<Item> actual = itemProvider.fetchItems(null, 2);

    assertArrayEquals(new Item[] {SECOND_ITEM, FIRST_ITEM}, actual.toArray(new Item[2]));
  }
コード例 #4
0
ファイル: ModelAssert.java プロジェクト: CloudMetal/MPS
  private static <C> void assertListsEqual(
      List<C> expectedList, List<C> actualList, Comparator<C> comparator, String name) {
    List<C> notFoundExpected = new ArrayList<C>();
    List<C> notFoundActual = new ArrayList<C>();
    for (C expected : expectedList) {
      boolean found = false;
      for (C actual : actualList) {
        if (comparator.compare(actual, expected) == 0) {
          found = true;
          break;
        }
      }
      if (!found) {
        notFoundExpected.add(expected);
      }
    }

    for (C actual : actualList) {
      boolean found = false;
      for (C expected : expectedList) {
        if (comparator.compare(actual, expected) == 0) {
          found = true;
          break;
        }
      }
      if (!found) {
        notFoundActual.add(actual);
      }
    }

    if (!notFoundExpected.isEmpty()) {
      fail("Not found expected " + name + " " + Arrays.toString(notFoundExpected.toArray()));
    }

    if (!notFoundActual.isEmpty()) {
      fail("Not expected " + name + " " + Arrays.toString(notFoundActual.toArray()));
    }
  }
コード例 #5
0
  @Test
  public void testUUID() throws IOException {
    List<java.util.UUID> ids = new ArrayList<java.util.UUID>();
    for (int i = 0; i < 100; i++) ids.add(java.util.UUID.randomUUID());

    long[] vv = (long[]) Serializer.UUID.valueArrayFromArray(ids.toArray());

    int i = 0;
    for (java.util.UUID u : ids) {
      assertEquals(u.getMostSignificantBits(), vv[i++]);
      assertEquals(u.getLeastSignificantBits(), vv[i++]);
    }

    // clone
    DataOutput2 out = new DataOutput2();
    Serializer.UUID.valueArraySerialize(out, vv);

    DataInput2 in = new DataInput2.ByteArray(out.copyBytes());
    long[] nn = (long[]) Serializer.UUID.valueArrayDeserialize(in, ids.size());

    assertArrayEquals(vv, nn);

    // test key addition
    java.util.UUID r = java.util.UUID.randomUUID();
    ids.add(10, r);
    long[] vv2 = (long[]) Serializer.UUID.valueArrayPut(vv, 10, r);
    i = 0;
    for (java.util.UUID u : ids) {
      assertEquals(u.getMostSignificantBits(), vv2[i++]);
      assertEquals(u.getLeastSignificantBits(), vv2[i++]);
    }

    vv2 = (long[]) Serializer.UUID.valueArrayDeleteValue(vv2, 10 + 1);

    assertArrayEquals(vv, vv2);
  }
コード例 #6
0
 public IsTuple(List<InternalFactHandle> tupleAsList) {
   expected = tupleAsList.toArray(new InternalFactHandle[tupleAsList.size()]);
 }