微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

com.google.common.collect.testing.MinimalCollection的实例源码

项目:guava-mock    文件CollectionRetainAllTester.java    @H_404_5@
@Override
public void setUp() throws Exception {
  super.setUp();

  empty = new Target(emptyCollection(),"empty");
  /*
   * We test that nullSingleton.retainAll(disjointList) does NOT throw a
   * NullPointerException when disjointList does not,so we can't use
   * MinimalCollection,which throws NullPointerException on calls to
   * contains(null).
   */
  List<E> disjointList = Arrays.asList(e3(),e4());
  disjoint = new Target(disjointList,"disjoint");
  superset = new Target(MinimalCollection.of(e0(),e1(),e2(),e3(),e4()),"superset");
  nonEmptyProperSubset = new Target(MinimalCollection.of(e1()),"subset");
  sameElements = new Target(Arrays.asList(createSamplesArray()),"sameElements");
  containsDuplicates =
      new Target(MinimalCollection.of(e0(),e0(),e3()),"containsDuplicates");
  partialoverlap = new Target(MinimalCollection.of(e2(),"partialoverlap");
  nullSingleton = new Target(Collections.<E>singleton(null),"nullSingleton");
}
@H_404_5@ @H_404_5@
项目:googles-monorepo-demo    文件CollectionRetainAllTester.java    @H_404_5@
@Override
public void setUp() throws Exception {
  super.setUp();

  empty = new Target(emptyCollection(),"nullSingleton");
}
@H_404_5@ @H_404_5@
项目:googles-monorepo-demo    文件ListAddAllAtIndexTester.java    @H_404_5@
@ListFeature.Require(absent = SUPPORTS_ADD_WITH_INDEX)
@CollectionSize.Require(absent = ZERO)
public void testAddAllAtIndex_unsupportedAllPresent() {
  try {
    getList().addAll(0,MinimalCollection.of(e0()));
    fail("addAll(n,allPresent) should throw");
  } catch (UnsupportedOperationException expected) {
  }
  expectUnchanged();
}
@H_404_5@ @H_404_5@
项目:googles-monorepo-demo    文件ListAddAllAtIndexTester.java    @H_404_5@
@ListFeature.Require(SUPPORTS_ADD_WITH_INDEX)
@CollectionSize.Require(absent = ZERO)
public void testAddAllAtIndex_supportedSomePresent() {
  assertTrue(
      "addAll(n,allPresent) should return true",getList().addAll(0,MinimalCollection.of(e0(),e3())));
  expectAdded(0,e3());
}
@H_404_5@ @H_404_5@
项目:guava-mock    文件CollectionContainsAllTester.java    @H_404_5@
@CollectionFeature.Require(absent = ALLOWS_NULL_QUERIES)
public void testContainsAll_nullNotAllowed() {
  try {
    assertFalse(collection.containsAll(MinimalCollection.of((E) null)));
  } catch (NullPointerException tolerated) {
  }
}
@H_404_5@ @H_404_5@
项目:googles-monorepo-demo    文件ImmutableListTest.java    @H_404_5@
public void testcopyOf_collectionContainingNull() {
  Collection<String> c = MinimalCollection.of("a",null,"b");
  try {
    ImmutableList.copyOf(c);
    fail();
  } catch (NullPointerException expected) {
  }
}
@H_404_5@ @H_404_5@
项目:googles-monorepo-demo    文件AbstractImmutableSetTest.java    @H_404_5@
public void testcopyOf_collection_general() {
  Collection<String> c = MinimalCollection.of("a","b","a");
  Set<String> set = copyOf(c);
  assertEquals(2,set.size());
  assertTrue(set.contains("a"));
  assertTrue(set.contains("b"));
}
@H_404_5@ @H_404_5@
项目:guava-mock    文件ListRemoveAllTester.java    @H_404_5@
@CollectionFeature.Require(SUPPORTS_REMOVE)
@CollectionSize.Require(absent = {ZERO,ONE})
public void testRemoveAll_duplicate() {
  ArrayWithDuplicate<E> arrayAndDuplicate = createArrayWithDuplicateElement();
  collection = getSubjectGenerator().create(arrayAndDuplicate.elements);
  E duplicate = arrayAndDuplicate.duplicate;

  assertTrue(
      "removeAll(intersectingCollection) should return true",getList().removeAll(MinimalCollection.of(duplicate)));
  assertFalse(
      "after removeAll(e),a collection should not contain e even "
          + "if it initially contained e more than once.",getList().contains(duplicate));
}
@H_404_5@ @H_404_5@
项目:guava-mock    文件CollectionRemoveAllTester.java    @H_404_5@
@CollectionFeature.Require(SUPPORTS_REMOVE)
public void testRemoveAll_emptyCollection() {
  assertFalse(
      "removeAll(emptyCollection) should return false",collection.removeAll(MinimalCollection.of()));
  expectUnchanged();
}
@H_404_5@ @H_404_5@
项目:googles-monorepo-demo    文件ListRetainAllTester.java    @H_404_5@
@SuppressWarnings("unchecked")
@CollectionFeature.Require(SUPPORTS_REMOVE)
@CollectionSize.Require(SEVERAL)
public void testRetainAll_duplicatesRemoved() {
  E[] array = createSamplesArray();
  array[1] = e0();
  collection = getSubjectGenerator().create(array);
  assertTrue(
      "containsDuplicates.retainAll(subset) should return true",collection.retainAll(MinimalCollection.of(e2())));
  expectContents(e2());
}
@H_404_5@ @H_404_5@
项目:guava-mock    文件CollectionRemoveAllTester.java    @H_404_5@
@CollectionFeature.Require(SUPPORTS_REMOVE)
@CollectionSize.Require(absent = ZERO)
public void testRemoveAll_allPresent() {
  assertTrue(
      "removeAll(intersectingCollection) should return true",collection.removeAll(MinimalCollection.of(e0())));
  expectMissing(e0());
}
@H_404_5@ @H_404_5@
项目:guava-mock    文件CollectionRemoveAllTester.java    @H_404_5@
@CollectionFeature.Require({SUPPORTS_REMOVE,FAILS_FAST_ON_CONCURRENT_MODIFICATION})
@CollectionSize.Require(SEVERAL)
public void testRemoveAllSomePresentConcurrentWithIteration() {
  try {
    Iterator<E> iterator = collection.iterator();
    assertTrue(collection.removeAll(MinimalCollection.of(e0(),e3())));
    iterator.next();
    fail("Expected ConcurrentModificationException");
  } catch (ConcurrentModificationException expected) {
    // success
  }
}
@H_404_5@ @H_404_5@
项目:guava-mock    文件CollectionRemoveAllTester.java    @H_404_5@
/** Trigger the {@code other.size() >= this.size()} case in {@link AbstractSet#removeAll()}. */
@CollectionFeature.Require(SUPPORTS_REMOVE)
@CollectionSize.Require(absent = ZERO)
public void testRemoveAll_somePresentLargeCollectionToRemove() {
  assertTrue(
      "removeAll(largeIntersectingCollection) should return true",collection.removeAll(MinimalCollection.of(e0(),e3())));
  expectMissing(e0());
}
@H_404_5@ @H_404_5@
项目:googles-monorepo-demo    文件ListAddAllAtIndexTester.java    @H_404_5@
@ListFeature.Require(SUPPORTS_ADD_WITH_INDEX)
public void testAddAllAtIndex_negative() {
  try {
    getList().addAll(-1,MinimalCollection.of(e3()));
    fail("addAll(-1,e) should throw");
  } catch (indexoutofboundsexception expected) {
  }
  expectUnchanged();
  expectMissing(e3());
}
@H_404_5@ @H_404_5@
项目:guava-mock    文件CollectionRemoveAllTester.java    @H_404_5@
@CollectionFeature.Require(absent = SUPPORTS_REMOVE)
public void testRemoveAll_unsupportednonePresent() {
  try {
    assertFalse(
        "removeAll(disjointCollection) should return false or throw "
            + "UnsupportedOperationException",collection.removeAll(MinimalCollection.of(e3())));
  } catch (UnsupportedOperationException tolerated) {
  }
  expectUnchanged();
}
@H_404_5@ @H_404_5@
项目:guava-mock    文件CollectionRemoveAllTester.java    @H_404_5@
@CollectionFeature.Require(absent = SUPPORTS_REMOVE)
@CollectionSize.Require(absent = ZERO)
public void testRemoveAll_unsupportedPresent() {
  try {
    collection.removeAll(MinimalCollection.of(e0()));
    fail("removeAll(intersectingCollection) should throw UnsupportedOperationException");
  } catch (UnsupportedOperationException expected) {
  }
  expectUnchanged();
  assertTrue(collection.contains(e0()));
}
@H_404_5@ @H_404_5@
项目:guava-mock    文件CollectionRemoveAllTester.java    @H_404_5@
@CollectionFeature.Require(value = SUPPORTS_REMOVE,absent = ALLOWS_NULL_QUERIES)
public void testRemoveAll_containsNullNo() {
  MinimalCollection<?> containsNull = MinimalCollection.of((Object) null);
  try {
    assertFalse(
        "removeAll(containsNull) should return false or throw",collection.removeAll(containsNull));
  } catch (NullPointerException tolerated) {
  }
  expectUnchanged();
}
@H_404_5@ @H_404_5@
项目:guava-mock    文件CollectionRemoveAllTester.java    @H_404_5@
@CollectionFeature.Require(SUPPORTS_REMOVE)
public void testRemoveAll_containsWrongType() {
  try {
    assertFalse(
        "removeAll(containsWrongType) should return false or throw",collection.removeAll(MinimalCollection.of(WrongType.VALUE)));
  } catch (ClassCastException tolerated) {
  }
  expectUnchanged();
}
@H_404_5@ @H_404_5@
项目:guava-mock    文件ListAddAllTester.java    @H_404_5@
@CollectionFeature.Require(SUPPORTS_ADD)
@CollectionSize.Require(absent = ZERO)
public void testAddAll_supportedAllPresent() {
  assertTrue(
      "addAll(allPresent) should return true",getList().addAll(MinimalCollection.of(e0())));
  expectAdded(e0());
}
@H_404_5@ @H_404_5@
项目:googles-monorepo-demo    文件ListAddAllAtIndexTester.java    @H_404_5@
@ListFeature.Require(absent = SUPPORTS_ADD_WITH_INDEX)
@CollectionSize.Require(absent = ZERO)
public void testAddAllAtIndex_unsupportedSomePresent() {
  try {
    getList().addAll(0,e3()));
    fail("addAll(n,allPresent) should throw");
  } catch (UnsupportedOperationException expected) {
  }
  expectUnchanged();
  expectMissing(e3());
}
@H_404_5@ @H_404_5@
项目:googles-monorepo-demo    文件ListAddAllAtIndexTester.java    @H_404_5@
@ListFeature.Require(SUPPORTS_ADD_WITH_INDEX)
@CollectionSize.Require(absent = ZERO)
public void testAddAllAtIndex_supportedAllPresent() {
  assertTrue(
      "addAll(n,MinimalCollection.of(e0())));
  expectAdded(0,e0());
}
@H_404_5@ @H_404_5@
项目:googles-monorepo-demo    文件CollectionAddAllTester.java    @H_404_5@
@CollectionFeature.Require({SUPPORTS_ADD,FAILS_FAST_ON_CONCURRENT_MODIFICATION})
@CollectionSize.Require(absent = ZERO)
public void testAddAllConcurrentWithIteration() {
  try {
    Iterator<E> iterator = collection.iterator();
    assertTrue(collection.addAll(MinimalCollection.of(e3(),e0())));
    iterator.next();
    fail("Expected ConcurrentModificationException");
  } catch (ConcurrentModificationException expected) {
    // success
  }
}
@H_404_5@ @H_404_5@
项目:guava-mock    文件MapPutAllTester.java    @H_404_5@
@MapFeature.Require(absent = SUPPORTS_PUT)
@CollectionSize.Require(absent = ZERO)
public void testPutAll_unsupportedSomePresent() {
  try {
    putAll(MinimalCollection.of(e3(),e0()));
    fail("putAll(somePresent) should throw");
  } catch (UnsupportedOperationException expected) {
  }
  expectUnchanged();
}
@H_404_5@ @H_404_5@
项目:guava-mock    文件MapPutAllTester.java    @H_404_5@
@MapFeature.Require(absent = SUPPORTS_PUT)
@CollectionSize.Require(absent = ZERO)
public void testPutAll_unsupportedAllPresent() {
  try {
    putAll(MinimalCollection.of(e0()));
  } catch (UnsupportedOperationException tolerated) {
  }
  expectUnchanged();
}
@H_404_5@ @H_404_5@
项目:guava-mock    文件ListRetainAllTester.java    @H_404_5@
@CollectionFeature.Require(SUPPORTS_REMOVE)
@CollectionSize.Require(absent = {ZERO,ONE})
public void testRetainAll_duplicatesKept() {
  E[] array = createSamplesArray();
  array[1] = e0();
  collection = getSubjectGenerator().create(array);
  assertFalse(
      "containsDuplicates.retainAll(superset) should return false",collection.retainAll(MinimalCollection.of(createSamplesArray())));
  expectContents(array);
}
@H_404_5@ @H_404_5@
项目:googles-monorepo-demo    文件AbstractImmutableSetTest.java    @H_404_5@
public void testcopyOf_collectionContainingNull() {
  Collection<String> c = MinimalCollection.of("a","b");
  try {
    copyOf(c);
    fail();
  } catch (NullPointerException expected) {
  }
}
@H_404_5@ @H_404_5@
项目:guava-mock    文件ListAddAllAtIndexTester.java    @H_404_5@
@ListFeature.Require(SUPPORTS_ADD_WITH_INDEX)
@CollectionSize.Require(absent = ZERO)
public void testAddAllAtIndex_supportedAllPresent() {
  assertTrue(
      "addAll(n,e0());
}
@H_404_5@ @H_404_5@
项目:guava-mock    文件ListAddAllAtIndexTester.java    @H_404_5@
@ListFeature.Require(absent = SUPPORTS_ADD_WITH_INDEX)
@CollectionSize.Require(absent = ZERO)
public void testAddAllAtIndex_unsupportedAllPresent() {
  try {
    getList().addAll(0,allPresent) should throw");
  } catch (UnsupportedOperationException expected) {
  }
  expectUnchanged();
}
@H_404_5@ @H_404_5@
项目:guava-mock    文件ListAddAllAtIndexTester.java    @H_404_5@
@ListFeature.Require(SUPPORTS_ADD_WITH_INDEX)
@CollectionSize.Require(absent = ZERO)
public void testAddAllAtIndex_supportedSomePresent() {
  assertTrue(
      "addAll(n,e3());
}
@H_404_5@ @H_404_5@
项目:guava-mock    文件ListAddAllAtIndexTester.java    @H_404_5@
@ListFeature.Require(absent = SUPPORTS_ADD_WITH_INDEX)
@CollectionSize.Require(absent = ZERO)
public void testAddAllAtIndex_unsupportedSomePresent() {
  try {
    getList().addAll(0,allPresent) should throw");
  } catch (UnsupportedOperationException expected) {
  }
  expectUnchanged();
  expectMissing(e3());
}
@H_404_5@ @H_404_5@
项目:guava-mock    文件ListAddAllAtIndexTester.java    @H_404_5@
@ListFeature.Require(SUPPORTS_ADD_WITH_INDEX)
public void testAddAllAtIndex_negative() {
  try {
    getList().addAll(-1,e) should throw");
  } catch (indexoutofboundsexception expected) {
  }
  expectUnchanged();
  expectMissing(e3());
}
@H_404_5@ @H_404_5@
项目:guava-mock    文件ListAddAllAtIndexTester.java    @H_404_5@
@ListFeature.Require(SUPPORTS_ADD_WITH_INDEX)
public void testAddAllAtIndex_tooLarge() {
  try {
    getList().addAll(getNumElements() + 1,MinimalCollection.of(e3()));
    fail("addAll(size + 1,e) should throw");
  } catch (indexoutofboundsexception expected) {
  }
  expectUnchanged();
  expectMissing(e3());
}
@H_404_5@ @H_404_5@
项目:googles-monorepo-demo    文件ListAddAllAtIndexTester.java    @H_404_5@
@ListFeature.Require(SUPPORTS_ADD_WITH_INDEX)
public void testAddAllAtIndex_tooLarge() {
  try {
    getList().addAll(getNumElements() + 1,e) should throw");
  } catch (indexoutofboundsexception expected) {
  }
  expectUnchanged();
  expectMissing(e3());
}
@H_404_5@ @H_404_5@
项目:guava-mock    文件CollectionAddAllTester.java    @H_404_5@
@CollectionFeature.Require(absent = SUPPORTS_ADD)
@CollectionSize.Require(absent = ZERO)
public void testAddAll_unsupportedSomePresent() {
  try {
    collection.addAll(MinimalCollection.of(e3(),e0()));
    fail("addAll(somePresent) should throw");
  } catch (UnsupportedOperationException expected) {
  }
  expectUnchanged();
}
@H_404_5@ @H_404_5@
项目:guava-mock    文件CollectionAddAllTester.java    @H_404_5@
@CollectionFeature.Require({SUPPORTS_ADD,e0())));
    iterator.next();
    fail("Expected ConcurrentModificationException");
  } catch (ConcurrentModificationException expected) {
    // success
  }
}
@H_404_5@ @H_404_5@
项目:guava-mock    文件CollectionAddAllTester.java    @H_404_5@
@CollectionFeature.Require(absent = SUPPORTS_ADD)
@CollectionSize.Require(absent = ZERO)
public void testAddAll_unsupportedAllPresent() {
  try {
    assertFalse(
        "addAll(allPresent) should return false or throw",collection.addAll(MinimalCollection.of(e0())));
  } catch (UnsupportedOperationException tolerated) {
  }
  expectUnchanged();
}
@H_404_5@ @H_404_5@
项目:guava-mock    文件ImmutableMultisetTest.java    @H_404_5@
public void testcopyOf_collectionContainingNull() {
  Collection<String> c = MinimalCollection.of("a","b");
  try {
    ImmutableMultiset.copyOf(c);
    fail();
  } catch (NullPointerException expected) {}
}
@H_404_5@ @H_404_5@
项目:guava-mock    文件ImmutableListTest.java    @H_404_5@
public void testcopyOf_collectionContainingNull() {
  Collection<String> c = MinimalCollection.of("a","b");
  try {
    ImmutableList.copyOf(c);
    fail();
  } catch (NullPointerException expected) {
  }
}
@H_404_5@ @H_404_5@
项目:guava-mock    文件ImmutableListTest.java    @H_404_5@
public void testSortedcopyOf_natural_containsNull() {
  Collection<Integer> c = MinimalCollection.of(1,3,2);
  try {
    ImmutableList.sortedcopyOf(c);
    fail("Expected NPE");
  } catch (NullPointerException expected) {
  }
}
@H_404_5@ @H_404_5@
项目:guava-mock    文件ImmutableListTest.java    @H_404_5@
public void testSortedcopyOf_containsNull() {
  Collection<String> c = MinimalCollection.of("a","A","c");
  try {
    ImmutableList.sortedcopyOf(String.CASE_INSENSITIVE_ORDER,c);
    fail("Expected NPE");
  } catch (NullPointerException expected) {
  }
}
@H_404_5@ @H_404_5@

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。