Java 类com.google.common.collect.testing.features.CollectionFeature 实例源码

项目:guava-mock    文件:TestsForListsInJavaUtil.java   
public Test testsForArraysAsList() {
  return ListTestSuiteBuilder.using(
          new TestStringListGenerator() {
            @Override
            public List<String> create(String[] elements) {
              return Arrays.asList(elements.clone());
            }
          })
      .named("Arrays.asList")
      .withFeatures(
          ListFeature.SUPPORTS_SET,
          CollectionFeature.SERIALIZABLE,
          CollectionFeature.ALLOWS_NULL_VALUES,
          CollectionSize.ANY)
      .suppressing(suppressForArraysAsList())
      .createTestSuite();
}
项目:googles-monorepo-demo    文件:SetHashCodeTester.java   
@CollectionSize.Require(absent = CollectionSize.ZERO)
@CollectionFeature.Require(ALLOWS_NULL_VALUES)
public void testHashCode_containingNull() {
  Collection<E> elements = getSampleElements(getNumElements() - 1);
  int expectedHashCode = 0;
  for (E element : elements) {
    expectedHashCode += ((element == null) ? 0 : element.hashCode());
  }

  elements.add(null);
  collection = getSubjectGenerator().create(elements.toArray());
  assertEquals(
      "A Set's hashCode() should be the sum of those of its elements (with "
          + "a null element counting as having a hash of zero).",
      expectedHashCode,
      getSet().hashCode());
}
项目:guava-mock    文件:MultisetNavigationTester.java   
@CollectionSize.Require(SEVERAL)
@CollectionFeature.Require(SUPPORTS_ADD)
public void testConflictingBounds() {
  testEmptyRangeSubMultiset(
      sortedMultiset.subMultiset(a.getElement(), CLOSED, a.getElement(), OPEN));
  testEmptyRangeSubMultiset(
      sortedMultiset.subMultiset(a.getElement(), OPEN, a.getElement(), OPEN));
  testEmptyRangeSubMultiset(
      sortedMultiset.subMultiset(a.getElement(), OPEN, a.getElement(), CLOSED));
  testEmptyRangeSubMultiset(
      sortedMultiset.subMultiset(b.getElement(), CLOSED, a.getElement(), CLOSED));
  testEmptyRangeSubMultiset(
      sortedMultiset.subMultiset(b.getElement(), CLOSED, a.getElement(), OPEN));
  testEmptyRangeSubMultiset(
      sortedMultiset.subMultiset(b.getElement(), OPEN, a.getElement(), OPEN));
}
项目:guava-mock    文件:TestsForSetsInJavaUtil.java   
public Test testsForConcurrentSkipListSetWithComparator() {
  return SetTestSuiteBuilder.using(
          new TestStringSortedSetGenerator() {
            @Override
            public SortedSet<String> create(String[] elements) {
              SortedSet<String> set =
                  new ConcurrentSkipListSet<String>(arbitraryNullFriendlyComparator());
              Collections.addAll(set, elements);
              return set;
            }
          })
      .named("ConcurrentSkipListSet, with comparator")
      .withFeatures(
          SetFeature.GENERAL_PURPOSE,
          CollectionFeature.SERIALIZABLE,
          CollectionFeature.KNOWN_ORDER,
          CollectionSize.ANY)
      .suppressing(suppressForConcurrentSkipListSetWithComparator())
      .createTestSuite();
}
项目:guava-mock    文件:TestsForMapsInJavaUtil.java   
public Test testsForCheckedNavigableMap() {
  return SortedMapTestSuiteBuilder.using(
      new TestStringSortedMapGenerator() {
        @Override
        protected NavigableMap<String, String> create(Entry<String, String>[] entries) {
          NavigableMap<String, String> map = populate(new TreeMap<String, String>(), entries);
          return Collections.checkedNavigableMap(map, String.class, String.class);
        }
      })
      .named("checkedNavigableMap/TreeMap, natural")
      .withFeatures(
          MapFeature.GENERAL_PURPOSE,
          MapFeature.ALLOWS_NULL_VALUES,
          MapFeature.FAILS_FAST_ON_CONCURRENT_MODIFICATION,
          MapFeature.RESTRICTS_KEYS,
          MapFeature.RESTRICTS_VALUES,
          CollectionFeature.KNOWN_ORDER,
          CollectionFeature.SUPPORTS_ITERATOR_REMOVE,
          CollectionFeature.SERIALIZABLE,
          CollectionSize.ANY)
      .suppressing(suppressForCheckedNavigableMap())
      .createTestSuite();
}
项目:guava-mock    文件:BiMapTestSuiteBuilder.java   
private static Set<Feature<?>> computeInverseFeatures(Set<Feature<?>> mapFeatures) {
  Set<Feature<?>> inverseFeatures = new HashSet<Feature<?>>(mapFeatures);

  boolean nullKeys = inverseFeatures.remove(MapFeature.ALLOWS_NULL_KEYS);
  boolean nullValues = inverseFeatures.remove(MapFeature.ALLOWS_NULL_VALUES);

  if (nullKeys) {
    inverseFeatures.add(MapFeature.ALLOWS_NULL_VALUES);
  }
  if (nullValues) {
    inverseFeatures.add(MapFeature.ALLOWS_NULL_KEYS);
  }

  inverseFeatures.add(NoRecurse.INVERSE);
  inverseFeatures.remove(CollectionFeature.KNOWN_ORDER);
  inverseFeatures.add(MapFeature.REJECTS_DUPLICATES_AT_CREATION);

  return inverseFeatures;
}
项目:googles-monorepo-demo    文件:SynchronizedSetTest.java   
public static Test suite() {
  return SetTestSuiteBuilder.using(
          new TestStringSetGenerator() {
            @Override
            protected Set<String> create(String[] elements) {
              TestSet<String> inner = new TestSet<String>(new HashSet<String>(), null);
              Set<String> outer = Synchronized.set(inner, null);
              inner.mutex = outer;
              Collections.addAll(outer, elements);
              return outer;
            }
          })
      .named("Synchronized.set")
      .withFeatures(
          CollectionFeature.GENERAL_PURPOSE,
          CollectionFeature.ALLOWS_NULL_VALUES,
          CollectionSize.ANY,
          CollectionFeature.SERIALIZABLE)
      .createTestSuite();
}
项目:googles-monorepo-demo    文件:MultisetEntrySetTester.java   
@CollectionSize.Require(ONE)
@CollectionFeature.Require(SUPPORTS_ITERATOR_REMOVE)
public void testEntrySet_iteratorRemovePropagates() {
  Iterator<Multiset.Entry<E>> iterator = getMultiset().entrySet().iterator();
  assertTrue(
      "non-empty multiset.entrySet() iterator.hasNext() returned false", iterator.hasNext());
  assertEquals(
      "multiset.entrySet() iterator.next() returned incorrect entry",
      Multisets.immutableEntry(e0(), 1),
      iterator.next());
  assertFalse(
      "size 1 multiset.entrySet() iterator.hasNext() returned true after next()",
      iterator.hasNext());
  iterator.remove();
  assertTrue(
      "multiset isn't empty after multiset.entrySet() iterator.remove()",
      getMultiset().isEmpty());
}
项目:guava-mock    文件:TestsForMapsInJavaUtil.java   
public Test testsForUnmodifiableMap() {
  return MapTestSuiteBuilder.using(
      new TestStringMapGenerator() {
        @Override
        protected Map<String, String> create(Entry<String, String>[] entries) {
          return Collections.unmodifiableMap(toHashMap(entries));
        }
      })
      .named("unmodifiableMap/HashMap")
      .withFeatures(
          MapFeature.ALLOWS_NULL_KEYS,
          MapFeature.ALLOWS_NULL_VALUES,
          MapFeature.ALLOWS_ANY_NULL_QUERIES,
          CollectionFeature.SERIALIZABLE,
          CollectionSize.ANY)
      .suppressing(suppressForUnmodifiableMap())
      .createTestSuite();
}
项目:guava-mock    文件:TestsForMapsInJavaUtil.java   
public Test testsForUnmodifiableNavigableMap() {
  return MapTestSuiteBuilder.using(
      new TestStringSortedMapGenerator() {
        @Override
        protected NavigableMap<String, String> create(Entry<String, String>[] entries) {
          return Collections.unmodifiableNavigableMap(populate(new TreeMap<>(), entries));
        }
      })
      .named("unmodifiableNavigableMap/TreeMap, natural")
      .withFeatures(
          MapFeature.ALLOWS_NULL_VALUES,
          CollectionFeature.KNOWN_ORDER,
          CollectionFeature.SERIALIZABLE,
          CollectionSize.ANY)
      .suppressing(suppressForUnmodifiableNavigableMap())
      .createTestSuite();
}
项目:guava-mock    文件:TestsForMapsInJavaUtil.java   
public Test testsForConcurrentSkipListMapNatural() {
  return NavigableMapTestSuiteBuilder.using(
          new TestStringSortedMapGenerator() {
            @Override
            protected SortedMap<String, String> create(Entry<String, String>[] entries) {
              return populate(new ConcurrentSkipListMap<String, String>(), entries);
            }
          })
      .named("ConcurrentSkipListMap, natural")
      .withFeatures(
          MapFeature.GENERAL_PURPOSE,
          CollectionFeature.SUPPORTS_ITERATOR_REMOVE,
          CollectionFeature.KNOWN_ORDER,
          CollectionFeature.SERIALIZABLE,
          CollectionSize.ANY)
      .suppressing(suppressForConcurrentSkipListMap())
      .createTestSuite();
}
项目:googles-monorepo-demo    文件:MinimalCollectionTest.java   
public static Test suite() {
  return CollectionTestSuiteBuilder
      .using(new TestStringCollectionGenerator() {
          @Override public Collection<String> create(String[] elements) {
            // TODO: MinimalCollection should perhaps throw
            for (Object element : elements) {
              if (element == null) {
                throw new NullPointerException();
              }
            }
            return MinimalCollection.of(elements);
          }
        })
      .named("MinimalCollection")
      .withFeatures(
          CollectionFeature.NONE,
          CollectionSize.ANY)
      .createTestSuite();
}
项目:guava-mock    文件:SetHashCodeTester.java   
@CollectionSize.Require(absent = CollectionSize.ZERO)
@CollectionFeature.Require(ALLOWS_NULL_VALUES)
public void testHashCode_containingNull() {
  Collection<E> elements = getSampleElements(getNumElements() - 1);
  int expectedHashCode = 0;
  for (E element : elements) {
    expectedHashCode += ((element == null) ? 0 : element.hashCode());
  }

  elements.add(null);
  collection = getSubjectGenerator().create(elements.toArray());
  assertEquals(
      "A Set's hashCode() should be the sum of those of its elements (with "
          + "a null element counting as having a hash of zero).",
      expectedHashCode,
      getSet().hashCode());
}
项目:googles-monorepo-demo    文件:TestsForMapsInJavaUtil.java   
/**
 * Tests regular NavigableMap behavior of synchronizedNavigableMap(treeMap);
 * does not test the fact that it's synchronized.
 */
public Test testsForSynchronizedNavigableMap() {
  return NavigableMapTestSuiteBuilder.using(
          new TestStringSortedMapGenerator() {
            @Override
            protected SortedMap<String, String> create(Entry<String, String>[] entries) {
              NavigableMap<String, String> delegate = populate(new TreeMap<>(), entries);
              return Collections.synchronizedNavigableMap(delegate);
            }
          })
      .named("synchronizedNavigableMap/TreeMap, natural")
      .withFeatures(
          MapFeature.GENERAL_PURPOSE,
          MapFeature.ALLOWS_NULL_VALUES,
          MapFeature.FAILS_FAST_ON_CONCURRENT_MODIFICATION,
          CollectionFeature.SUPPORTS_ITERATOR_REMOVE,
          CollectionFeature.KNOWN_ORDER,
          CollectionFeature.SERIALIZABLE,
          CollectionSize.ANY)
      .suppressing(suppressForSynchronizedNavigableMap())
      .createTestSuite();
}
项目:googles-monorepo-demo    文件:TestsForListsInJavaUtil.java   
public Test testsForCheckedList() {
  return ListTestSuiteBuilder.using(
          new TestStringListGenerator() {
            @Override
            public List<String> create(String[] elements) {
              List<String> innerList = new ArrayList<String>();
              Collections.addAll(innerList, elements);
              return Collections.checkedList(innerList, String.class);
            }
          })
      .named("checkedList/ArrayList")
      .withFeatures(
          ListFeature.GENERAL_PURPOSE,
          CollectionFeature.SERIALIZABLE,
          CollectionFeature.RESTRICTS_ELEMENTS,
          CollectionFeature.ALLOWS_NULL_VALUES,
          CollectionSize.ANY)
      .suppressing(suppressForCheckedList())
      .createTestSuite();
}
项目:googles-monorepo-demo    文件:TestsForSetsInJavaUtil.java   
public Test testsForCheckedSet() {
  return SetTestSuiteBuilder.using(
          new TestStringSetGenerator() {
            @Override
            public Set<String> create(String[] elements) {
              Set<String> innerSet = new HashSet<String>();
              Collections.addAll(innerSet, elements);
              return Collections.checkedSet(innerSet, String.class);
            }
          })
      .named("checkedSet/HashSet")
      .withFeatures(
          SetFeature.GENERAL_PURPOSE,
          CollectionFeature.SERIALIZABLE,
          CollectionFeature.ALLOWS_NULL_VALUES,
          CollectionFeature.RESTRICTS_ELEMENTS,
          CollectionSize.ANY)
      .suppressing(suppressForCheckedSet())
      .createTestSuite();
}
项目:googles-monorepo-demo    文件:SetsTest.java   
@GwtIncompatible // suite
private static Test testsForFilter() {
  return SetTestSuiteBuilder.using(new TestStringSetGenerator() {
        @Override public Set<String> create(String[] elements) {
          Set<String> unfiltered = Sets.newLinkedHashSet();
          unfiltered.add("yyy");
          Collections.addAll(unfiltered, elements);
          unfiltered.add("zzz");
          return Sets.filter(unfiltered, Collections2Test.NOT_YYY_ZZZ);
        }
      })
      .named("Sets.filter")
      .withFeatures(
          CollectionFeature.SUPPORTS_ADD,
          CollectionFeature.SUPPORTS_REMOVE,
          CollectionFeature.ALLOWS_NULL_VALUES,
          CollectionFeature.KNOWN_ORDER,
          CollectionSize.ANY)
      .createTestSuite();
}
项目:googles-monorepo-demo    文件:MultisetEntrySetTester.java   
@CollectionSize.Require(SEVERAL)
@CollectionFeature.Require(SUPPORTS_ITERATOR_REMOVE)
@MultisetFeature.Require(ENTRIES_ARE_VIEWS)
public void testEntryReflectsIteratorRemove() {
  initThreeCopies();
  assertEquals(3, getMultiset().count(e0()));
  Multiset.Entry<E> entry = Iterables.getOnlyElement(getMultiset().entrySet());
  assertEquals(3, entry.getCount());
  Iterator<E> itr = getMultiset().iterator();
  itr.next();
  itr.remove();
  assertEquals(2, entry.getCount());
  itr.next();
  itr.remove();
  itr.next();
  itr.remove();
  assertEquals(0, entry.getCount());
}
项目:googles-monorepo-demo    文件:Collections2Test.java   
@GwtIncompatible // suite
private static Test testsForFilter() {
  return CollectionTestSuiteBuilder.using(
      new TestStringCollectionGenerator() {
        @Override public Collection<String> create(String[] elements) {
          List<String> unfiltered = newArrayList();
          unfiltered.add("yyy");
          Collections.addAll(unfiltered, elements);
          unfiltered.add("zzz");
          return Collections2.filter(unfiltered, NOT_YYY_ZZZ);
        }
      })
      .named("Collections2.filter")
      .withFeatures(
          CollectionFeature.SUPPORTS_ADD,
          CollectionFeature.SUPPORTS_REMOVE,
          CollectionFeature.ALLOWS_NULL_VALUES,
          CollectionFeature.KNOWN_ORDER,
          CollectionSize.ANY)
      .createTestSuite();
}
项目:guava-mock    文件:TestsForSetsInJavaUtil.java   
public Test testsForSingletonSet() {
  return SetTestSuiteBuilder.using(
          new TestStringSetGenerator() {
            @Override
            public Set<String> create(String[] elements) {
              return Collections.singleton(elements[0]);
            }
          })
      .named("singleton")
      .withFeatures(
          CollectionFeature.SERIALIZABLE,
          CollectionFeature.ALLOWS_NULL_VALUES,
          CollectionSize.ONE)
      .suppressing(suppressForSingletonSet())
      .createTestSuite();
}
项目:googles-monorepo-demo    文件:TestsForListsInJavaUtil.java   
public Test testsForLinkedList() {
  return ListTestSuiteBuilder.using(
          new TestStringListGenerator() {
            @Override
            public List<String> create(String[] elements) {
              return new LinkedList<String>(MinimalCollection.of(elements));
            }
          })
      .named("LinkedList")
      .withFeatures(
          ListFeature.GENERAL_PURPOSE,
          CollectionFeature.SERIALIZABLE,
          CollectionFeature.ALLOWS_NULL_VALUES,
          CollectionFeature.FAILS_FAST_ON_CONCURRENT_MODIFICATION,
          CollectionSize.ANY)
      .suppressing(suppressForLinkedList())
      .createTestSuite();
}
项目:guava-mock    文件:Collections2Test.java   
@GwtIncompatible // suite
private static Test testsForFilter() {
  return CollectionTestSuiteBuilder.using(
      new TestStringCollectionGenerator() {
        @Override public Collection<String> create(String[] elements) {
          List<String> unfiltered = newArrayList();
          unfiltered.add("yyy");
          Collections.addAll(unfiltered, elements);
          unfiltered.add("zzz");
          return Collections2.filter(unfiltered, NOT_YYY_ZZZ);
        }
      })
      .named("Collections2.filter")
      .withFeatures(
          CollectionFeature.SUPPORTS_ADD,
          CollectionFeature.SUPPORTS_REMOVE,
          CollectionFeature.ALLOWS_NULL_VALUES,
          CollectionFeature.KNOWN_ORDER,
          CollectionSize.ANY)
      .createTestSuite();
}
项目:googles-monorepo-demo    文件:MultisetEntrySetTester.java   
@CollectionSize.Require(absent = ZERO)
@CollectionFeature.Require(SUPPORTS_REMOVE)
public void testEntrySet_removeAllPresent() {
  assertTrue(
      "multiset.entrySet.removeAll(presentEntry) returned false",
      getMultiset()
          .entrySet()
          .removeAll(Collections.singleton(Multisets.immutableEntry(e0(), 1))));
  assertFalse("multiset contains element after removing its entry", getMultiset().contains(e0()));
}
项目:guava-mock    文件:CollectionClearTester.java   
@CollectionFeature.Require(SUPPORTS_REMOVE)
public void testClear() {
  collection.clear();
  assertTrue("After clear(), a collection should be empty.", collection.isEmpty());
  assertEquals(0, collection.size());
  assertFalse(collection.iterator().hasNext());
}
项目:guava-mock    文件:MultisetIteratorTester.java   
@SuppressWarnings("unchecked")
@CollectionFeature.Require(absent = {SUPPORTS_ITERATOR_REMOVE, KNOWN_ORDER})
public void testIteratorUnknownOrder() {
  new IteratorTester<E>(
      4,
      UNMODIFIABLE,
      Arrays.asList(e0(), e1(), e1(), e2()),
      IteratorTester.KnownOrder.UNKNOWN_ORDER) {
    @Override
    protected Iterator<E> newTargetIterator() {
      return getSubjectGenerator().create(e0(), e1(), e1(), e2()).iterator();
    }
  }.test();
}
项目:googles-monorepo-demo    文件:MultisetForEachEntryTester.java   
@CollectionFeature.Require(KNOWN_ORDER)
public void testForEachEntryOrdered() {
  List<Entry<E>> expected = new ArrayList<>(getMultiset().entrySet());
  List<Entry<E>> actual = new ArrayList<>();
  getMultiset()
      .forEachEntry((element, count) -> actual.add(Multisets.immutableEntry(element, count)));
  assertEquals(expected, actual);
}
项目:guava-mock    文件:CollectionRemoveAllTester.java   
@CollectionFeature.Require({SUPPORTS_REMOVE, ALLOWS_NULL_VALUES})
@CollectionSize.Require(absent = ZERO)
public void testRemoveAll_containsNullYes() {
  initCollectionWithNullElement();
  assertTrue(
      "removeAll(containsNull) should return true",
      collection.removeAll(Collections.singleton(null)));
  // TODO: make this work with MinimalCollection
}
项目:googles-monorepo-demo    文件:MultisetIteratorTester.java   
@SuppressWarnings("unchecked")
@CollectionFeature.Require(absent = {SUPPORTS_ITERATOR_REMOVE, KNOWN_ORDER})
public void testIteratorUnknownOrder() {
  new IteratorTester<E>(
      4,
      UNMODIFIABLE,
      Arrays.asList(e0(), e1(), e1(), e2()),
      IteratorTester.KnownOrder.UNKNOWN_ORDER) {
    @Override
    protected Iterator<E> newTargetIterator() {
      return getSubjectGenerator().create(e0(), e1(), e1(), e2()).iterator();
    }
  }.test();
}
项目:googles-monorepo-demo    文件:CollectionAddTester.java   
@CollectionFeature.Require({SUPPORTS_ADD, FAILS_FAST_ON_CONCURRENT_MODIFICATION})
@CollectionSize.Require(absent = ZERO)
public void testAddConcurrentWithIteration() {
  try {
    Iterator<E> iterator = collection.iterator();
    assertTrue(collection.add(e3()));
    iterator.next();
    fail("Expected ConcurrentModificationException");
  } catch (ConcurrentModificationException expected) {
    // success
  }
}
项目:googles-monorepo-demo    文件:CollectionToStringTester.java   
@CollectionSize.Require(ONE)
@CollectionFeature.Require(absent = NON_STANDARD_TOSTRING)
public void testToString_size1() {
  assertEquals(
      "size1Collection.toString should return [{element}]",
      "[" + e0() + "]",
      collection.toString());
}
项目:guava-mock    文件:ListRemoveAllTester.java   
@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));
}
项目:guava-mock    文件:MultisetRemoveTester.java   
@CollectionSize.Require(SEVERAL)
@CollectionFeature.Require(SUPPORTS_REMOVE)
public void testRemoveAllIgnoresCount() {
  initThreeCopies();
  assertTrue(getMultiset().removeAll(Collections.singleton(e0())));
  assertEmpty(getMultiset());
}
项目:guava-mock    文件:SetAddTester.java   
@CollectionFeature.Require(value = {SUPPORTS_ADD, ALLOWS_NULL_VALUES})
@CollectionSize.Require(absent = ZERO)
public void testAdd_supportedNullPresent() {
  E[] array = createArrayWithNullElement();
  collection = getSubjectGenerator().create(array);
  assertFalse("add(nullPresent) should return false", getSet().add(null));
  expectContents(array);
}
项目:googles-monorepo-demo    文件:AbstractMultisetSetCountTester.java   
@CollectionSize.Require(absent = ZERO)
@CollectionFeature.Require(ALLOWS_NULL_VALUES)
public void testSetCount_existingNoNopNull_nullSupported() {
  initCollectionWithNullElement();
  try {
    assertSetCount(null, 1);
  } catch (UnsupportedOperationException tolerated) {
  }
}
项目:guava-mock    文件:CollectionSpliteratorTester.java   
@CollectionFeature.Require(SUPPORTS_REMOVE)
public void testSpliteratorNotImmutable_CollectionAllowsRemove() {
  // If remove is supported, verify that IMMUTABLE is not reported.
  synchronized (collection) { // for Collections.synchronized
    assertFalse(collection.spliterator().hasCharacteristics(Spliterator.IMMUTABLE));
  }
}
项目:googles-monorepo-demo    文件:SetCreationTester.java   
@CollectionFeature.Require(absent = REJECTS_DUPLICATES_AT_CREATION)
@CollectionSize.Require(absent = {ZERO, ONE})
public void testCreateWithDuplicates_nonNullDuplicatesNotRejected() {
  E[] array = createSamplesArray();
  array[1] = e0();
  collection = getSubjectGenerator().create(array);

  List<E> expectedWithDuplicateRemoved = Arrays.asList(array).subList(1, getNumElements());
  expectContents(expectedWithDuplicateRemoved);
}
项目:guava-mock    文件:MultisetElementSetTester.java   
@CollectionSize.Require(absent = ZERO)
@CollectionFeature.Require(SUPPORTS_REMOVE)
public void testElementSetRemovePropagatesToMultiset() {
  Set<E> elementSet = getMultiset().elementSet();
  assertTrue(elementSet.remove(e0()));
  assertFalse(getMultiset().contains(e0()));
}
项目:googles-monorepo-demo    文件:MultimapKeySetTester.java   
@CollectionSize.Require(absent = ZERO)
@CollectionFeature.Require(SUPPORTS_ITERATOR_REMOVE)
public void testKeySetIteratorRemove() {
  int key0Count = multimap().get(k0()).size();
  Iterator<K> keyItr = multimap().keySet().iterator();
  while (keyItr.hasNext()) {
    if (keyItr.next().equals(k0())) {
      keyItr.remove();
    }
  }
  assertEquals(getNumElements() - key0Count, multimap().size());
  assertGet(k0());
}
项目:guava-mock    文件:MultisetNavigationTester.java   
@CollectionSize.Require(SEVERAL)
@CollectionFeature.Require(SUPPORTS_REMOVE)
public void testClearTailClosed() {
  List<Entry<E>> expected =
      copyToList(sortedMultiset.headMultiset(b.getElement(), OPEN).entrySet());
  sortedMultiset.tailMultiset(b.getElement(), CLOSED).clear();
  assertEquals(expected, copyToList(sortedMultiset.entrySet()));
}
项目:googles-monorepo-demo    文件:SetCreationTester.java   
@CollectionFeature.Require(value = ALLOWS_NULL_VALUES, absent = REJECTS_DUPLICATES_AT_CREATION)
@CollectionSize.Require(absent = {ZERO, ONE})
public void testCreateWithDuplicates_nullDuplicatesNotRejected() {
  E[] array = createArrayWithNullElement();
  array[0] = null;
  collection = getSubjectGenerator().create(array);

  List<E> expectedWithDuplicateRemoved = Arrays.asList(array).subList(1, getNumElements());
  expectContents(expectedWithDuplicateRemoved);
}