Java Code Examples for com.google.common.collect.testing.features.CollectionSize

The following are top voted examples for showing how to use com.google.common.collect.testing.features.CollectionSize. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: guava-mock   File: TestsForSetsInJavaUtil.java   Source Code and License 6 votes vote down vote up
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();
}
 
Example 2
Project: googles-monorepo-demo   File: TestsForListsInJavaUtil.java   Source Code and License 6 votes vote down vote up
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();
}
 
Example 3
Project: googles-monorepo-demo   File: CollectionIteratorTester.java   Source Code and License 6 votes vote down vote up
@CollectionFeature.Require(SUPPORTS_ITERATOR_REMOVE)
@CollectionSize.Require(absent = ZERO)
public void testIterator_removeAffectsBackingCollection() {
  int originalSize = collection.size();
  Iterator<E> iterator = collection.iterator();
  Object element = iterator.next();
  // If it's an Entry, it may become invalid once it's removed from the Map. Copy it.
  if (element instanceof Entry) {
    Entry<?, ?> entry = (Entry<?, ?>) element;
    element = mapEntry(entry.getKey(), entry.getValue());
  }
  assertTrue(collection.contains(element)); // sanity check
  iterator.remove();
  assertFalse(collection.contains(element));
  assertEquals(originalSize - 1, collection.size());
}
 
Example 4
Project: googles-monorepo-demo   File: TestsForListsInJavaUtil.java   Source Code and License 6 votes vote down vote up
public Test testsForSingletonList() {
  return ListTestSuiteBuilder.using(
          new TestStringListGenerator() {
            @Override
            public List<String> create(String[] elements) {
              return Collections.singletonList(elements[0]);
            }
          })
      .named("singletonList")
      .withFeatures(
          CollectionFeature.SERIALIZABLE,
          CollectionFeature.ALLOWS_NULL_VALUES,
          CollectionSize.ONE)
      .suppressing(suppressForSingletonList())
      .createTestSuite();
}
 
Example 5
Project: guava-mock   File: TestsForMapsInJavaUtil.java   Source Code and License 6 votes vote down vote up
public Test testsForTreeMapWithComparator() {
  return NavigableMapTestSuiteBuilder.using(
          new TestStringSortedMapGenerator() {
            @Override
            protected SortedMap<String, String> create(Entry<String, String>[] entries) {
              return populate(
                  new TreeMap<String, String>(arbitraryNullFriendlyComparator()), entries);
            }
          })
      .named("TreeMap, with comparator")
      .withFeatures(
          MapFeature.GENERAL_PURPOSE,
          MapFeature.ALLOWS_NULL_KEYS,
          MapFeature.ALLOWS_NULL_VALUES,
          MapFeature.ALLOWS_ANY_NULL_QUERIES,
          MapFeature.FAILS_FAST_ON_CONCURRENT_MODIFICATION,
          CollectionFeature.SUPPORTS_ITERATOR_REMOVE,
          CollectionFeature.KNOWN_ORDER,
          CollectionFeature.SERIALIZABLE,
          CollectionSize.ANY)
      .suppressing(suppressForTreeMapWithComparator())
      .createTestSuite();
}
 
Example 6
Project: guava-mock   File: SynchronizedSetTest.java   Source Code and License 6 votes vote down vote up
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();
}
 
Example 7
Project: guava-mock   File: TestsForMapsInJavaUtil.java   Source Code and License 6 votes vote down vote up
public Test testsForConcurrentSkipListMapWithComparator() {
  return NavigableMapTestSuiteBuilder.using(
          new TestStringSortedMapGenerator() {
            @Override
            protected SortedMap<String, String> create(Entry<String, String>[] entries) {
              return populate(
                  new ConcurrentSkipListMap<String, String>(arbitraryNullFriendlyComparator()),
                  entries);
            }
          })
      .named("ConcurrentSkipListMap, with comparator")
      .withFeatures(
          MapFeature.GENERAL_PURPOSE,
          CollectionFeature.SUPPORTS_ITERATOR_REMOVE,
          CollectionFeature.KNOWN_ORDER,
          CollectionFeature.SERIALIZABLE,
          CollectionSize.ANY)
      .suppressing(suppressForConcurrentSkipListMap())
      .createTestSuite();
}
 
Example 8
Project: googles-monorepo-demo   File: TestsForQueuesInJavaUtil.java   Source Code and License 6 votes vote down vote up
public Test testsForArrayDeque() {
  return QueueTestSuiteBuilder.using(
          new TestStringQueueGenerator() {
            @Override
            public Queue<String> create(String[] elements) {
              return new ArrayDeque<String>(MinimalCollection.of(elements));
            }
          })
      .named("ArrayDeque")
      .withFeatures(
          CollectionFeature.GENERAL_PURPOSE,
          CollectionFeature.KNOWN_ORDER,
          CollectionSize.ANY)
      .suppressing(suppressForArrayDeque())
      .createTestSuite();
}
 
Example 9
Project: googles-monorepo-demo   File: SetsTest.java   Source Code and License 6 votes vote down vote up
@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();
}
 
Example 10
Project: googles-monorepo-demo   File: TestsForSetsInJavaUtil.java   Source Code and License 6 votes vote down vote up
public Test testsForEnumSet() {
  return SetTestSuiteBuilder.using(
          new TestEnumSetGenerator() {
            @Override
            public Set<AnEnum> create(AnEnum[] elements) {
              return (elements.length == 0)
                  ? EnumSet.noneOf(AnEnum.class)
                  : EnumSet.copyOf(MinimalCollection.of(elements));
            }
          })
      .named("EnumSet")
      .withFeatures(
          SetFeature.GENERAL_PURPOSE,
          CollectionFeature.SERIALIZABLE,
          CollectionFeature.KNOWN_ORDER,
          CollectionFeature.RESTRICTS_ELEMENTS,
          CollectionSize.ANY)
      .suppressing(suppressForEnumSet())
      .createTestSuite();
}
 
Example 11
Project: googles-monorepo-demo   File: MapComputeTester.java   Source Code and License 6 votes vote down vote up
@MapFeature.Require({SUPPORTS_PUT, SUPPORTS_REMOVE})
@CollectionSize.Require(absent = ZERO)
public void testCompute_presentToAbsent() {
  assertNull(
      "Map.compute(present, functionReturningNull) should return null",
      getMap()
          .compute(
              k0(),
              (k, v)
                  -> {
                    assertEquals(k0(), k);
                    assertEquals(v0(), v);
                    return null;
                  }));
  expectMissing(e0());
  expectMissingKeys(k0());
  assertEquals(getNumElements() - 1, getMap().size());
}
 
Example 12
Project: googles-monorepo-demo   File: TestsForQueuesInJavaUtil.java   Source Code and License 6 votes vote down vote up
public Test testsForLinkedList() {
  return QueueTestSuiteBuilder.using(
          new TestStringQueueGenerator() {
            @Override
            public Queue<String> create(String[] elements) {
              return new LinkedList<String>(MinimalCollection.of(elements));
            }
          })
      .named("LinkedList")
      .withFeatures(
          CollectionFeature.GENERAL_PURPOSE,
          CollectionFeature.ALLOWS_NULL_VALUES,
          CollectionFeature.KNOWN_ORDER,
          CollectionSize.ANY)
      .skipCollectionTests() // already covered in TestsForListsInJavaUtil
      .suppressing(suppressForLinkedList())
      .createTestSuite();
}
 
Example 13
Project: googles-monorepo-demo   File: SynchronizedSetTest.java   Source Code and License 6 votes vote down vote up
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();
}
 
Example 14
Project: googles-monorepo-demo   File: MapComputeIfPresentTester.java   Source Code and License 6 votes vote down vote up
@MapFeature.Require({SUPPORTS_PUT, ALLOWS_NULL_KEYS})
@CollectionSize.Require(absent = ZERO)
public void testComputeIfPresent_nullKeySupportedPresent() {
  initMapWithNullKey();
  assertEquals(
      "computeIfPresent(null, function) should return new value",
      v3(),
      getMap()
          .computeIfPresent(
              null,
              (k, v) -> {
                assertNull(k);
                assertEquals(getValueForNullKey(), v);
                return v3();
              }));

  Entry<K, V>[] expected = createArrayWithNullKey();
  expected[getNullLocation()] = entry(null, v3());
  expectContents(expected);
}
 
Example 15
Project: googles-monorepo-demo   File: ListSubListTester.java   Source Code and License 5 votes vote down vote up
@ListFeature.Require(SUPPORTS_REMOVE_WITH_INDEX)
@CollectionSize.Require(absent = ZERO)
public void testSubList_subListRemoveAffectsOriginal() {
  List<E> subList = getList().subList(0, 1);
  subList.remove(0);
  List<E> expected = Arrays.asList(createSamplesArray()).subList(1, getNumElements());
  expectContents(expected);
}
 
Example 16
Project: googles-monorepo-demo   File: BiMapPutTester.java   Source Code and License 5 votes vote down vote up
@SuppressWarnings("unchecked")
@MapFeature.Require(SUPPORTS_PUT)
@CollectionSize.Require(ZERO)
public void testInversePut() {
  getMap().put(k0(), v0());
  getMap().inverse().put(v1(), k1());
  expectAdded(e0(), e1());
}
 
Example 17
Project: guava-mock   File: MapClearTester.java   Source Code and License 5 votes vote down vote up
@MapFeature.Require({FAILS_FAST_ON_CONCURRENT_MODIFICATION, SUPPORTS_REMOVE})
@CollectionSize.Require(SEVERAL)
public void testClearConcurrentWithEntrySetIteration() {
  try {
    Iterator<Entry<K, V>> iterator = getMap().entrySet().iterator();
    getMap().clear();
    iterator.next();
    fail("Expected ConcurrentModificationException");
  } catch (ConcurrentModificationException expected) {
    // success
  }
}
 
Example 18
Project: guava-mock   File: BiMapPutTester.java   Source Code and License 5 votes vote down vote up
@SuppressWarnings("unchecked")
@MapFeature.Require(SUPPORTS_PUT)
@CollectionSize.Require(ZERO)
public void testForcePutOverwritesOldValueEntry() {
  getMap().put(k0(), v0());
  getMap().forcePut(k1(), v0());
  // verify that the bimap is unchanged
  expectAdded(Helpers.mapEntry(k1(), v0()));
}
 
Example 19
Project: guava-mock   File: ListIndexOfTester.java   Source Code and License 5 votes vote down vote up
@CollectionFeature.Require(absent = REJECTS_DUPLICATES_AT_CREATION)
@CollectionSize.Require(absent = {ZERO, ONE})
public void testIndexOf_duplicate() {
  E[] array = createSamplesArray();
  array[getNumElements() / 2] = e0();
  collection = getSubjectGenerator().create(array);
  assertEquals(
      "indexOf(duplicate) should return index of first occurrence", 0, getList().indexOf(e0()));
}
 
Example 20
Project: googles-monorepo-demo   File: MultisetEntrySetTester.java   Source Code and License 5 votes vote down vote up
@CollectionSize.Require(SEVERAL)
@CollectionFeature.Require(SUPPORTS_REMOVE)
@MultisetFeature.Require(ENTRIES_ARE_VIEWS)
public void testEntryReflectsClear() {
  initThreeCopies();
  assertEquals(3, getMultiset().count(e0()));
  Multiset.Entry<E> entry = Iterables.getOnlyElement(getMultiset().entrySet());
  assertEquals(3, entry.getCount());
  getMultiset().clear();
  assertEquals(0, entry.getCount());
}
 
Example 21
Project: googles-monorepo-demo   File: MultisetEntrySetTester.java   Source Code and License 5 votes vote down vote up
@CollectionSize.Require(SEVERAL)
@CollectionFeature.Require(SUPPORTS_REMOVE)
@MultisetFeature.Require(ENTRIES_ARE_VIEWS)
public void testEntryReflectsEntrySetClear() {
  initThreeCopies();
  assertEquals(3, getMultiset().count(e0()));
  Multiset.Entry<E> entry = Iterables.getOnlyElement(getMultiset().entrySet());
  assertEquals(3, entry.getCount());
  getMultiset().entrySet().clear();
  assertEquals(0, entry.getCount());
}
 
Example 22
Project: guava-mock   File: MultimapClearTester.java   Source Code and License 5 votes vote down vote up
@MapFeature.Require(SUPPORTS_REMOVE)
@CollectionSize.Require(absent = ZERO)
public void testClearPropagatesToGet() {
  for (K key : sampleKeys()) {
    resetContainer();
    Collection<V> collection = multimap().get(key);
    multimap().clear();
    assertEmpty(collection);
  }
}
 
Example 23
Project: guava-mock   File: MultisetEntrySetTester.java   Source Code and License 5 votes vote down vote up
@CollectionSize.Require(absent = ZERO)
@CollectionFeature.Require(SUPPORTS_REMOVE)
public void testEntrySet_removeAllAbsent() {
  assertFalse(
      "multiset.entrySet.remove(missingEntry) returned true",
      getMultiset()
          .entrySet()
          .removeAll(Collections.singleton(Multisets.immutableEntry(e0(), 2))));
  assertTrue(
      "multiset didn't contain element after removing a missing entry",
      getMultiset().contains(e0()));
}
 
Example 24
Project: googles-monorepo-demo   File: ListAddAllAtIndexTester.java   Source Code and License 5 votes vote down vote up
@ListFeature.Require(absent = SUPPORTS_ADD_WITH_INDEX)
@CollectionSize.Require(absent = ZERO)
public void testAddAllAtIndex_unsupportedSomePresent() {
  try {
    getList().addAll(0, MinimalCollection.of(e0(), e3()));
    fail("addAll(n, allPresent) should throw");
  } catch (UnsupportedOperationException expected) {
  }
  expectUnchanged();
  expectMissing(e3());
}
 
Example 25
Project: googles-monorepo-demo   File: MapReplaceEntryTester.java   Source Code and License 5 votes vote down vote up
@MapFeature.Require(value = SUPPORTS_PUT, absent = ALLOWS_NULL_VALUES)
@CollectionSize.Require(absent = ZERO)
public void testReplaceEntry_presentNullValueUnsupported() {
  try {
    getMap().replace(k0(), v0(), null);
    fail("Expected NullPointerException");
  } catch (NullPointerException expected) {}
  expectUnchanged();
}
 
Example 26
Project: googles-monorepo-demo   File: SetCreationTester.java   Source Code and License 5 votes vote down vote up
@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);
}
 
Example 27
Project: googles-monorepo-demo   File: MultimapToStringTester.java   Source Code and License 5 votes vote down vote up
@CollectionSize.Require(absent = ZERO)
@CollectionFeature.Require(absent = NON_STANDARD_TOSTRING)
@MapFeature.Require(ALLOWS_NULL_VALUES)
public void testToStringWithNullValue() {
  initMultimapWithNullValue();
  testToStringMatchesAsMap();
}
 
Example 28
Project: googles-monorepo-demo   File: ListRetainAllTester.java   Source Code and License 5 votes vote down vote up
@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());
}
 
Example 29
Project: googles-monorepo-demo   File: MultimapEqualsTester.java   Source Code and License 5 votes vote down vote up
@CollectionSize.Require(absent = ZERO)
@MapFeature.Require(ALLOWS_NULL_VALUES)
public void testEqualsMultimapWithNullValue() {
  Multimap<K, V> original = multimap();
  initMultimapWithNullValue();
  Multimap<K, V> withNull = multimap();
  new EqualsTester()
      .addEqualityGroup(original)
      .addEqualityGroup(
          withNull, getSubjectGenerator().create((Object[]) createArrayWithNullValue()))
      .testEquals();
}
 
Example 30
Project: guava-mock   File: MapReplaceEntryTester.java   Source Code and License 5 votes vote down vote up
@MapFeature.Require(absent = SUPPORTS_PUT)
@CollectionSize.Require(absent = ZERO)
public void testReplaceEntry_unsupportedPresent() {
  try {
    getMap().replace(k0(), v0(), v3());
    fail("Expected UnsupportedOperationException");
  } catch (UnsupportedOperationException expected) {}
  expectUnchanged();
}
 
Example 31
Project: googles-monorepo-demo   File: MapPutAllTester.java   Source Code and License 5 votes vote down vote up
@MapFeature.Require({FAILS_FAST_ON_CONCURRENT_MODIFICATION, SUPPORTS_PUT})
@CollectionSize.Require(absent = ZERO)
public void testPutAllSomePresentConcurrentWithEntrySetIteration() {
  try {
    Iterator<Entry<K, V>> iterator = getMap().entrySet().iterator();
    putAll(MinimalCollection.of(e3(), e0()));
    iterator.next();
    fail("Expected ConcurrentModificationException");
  } catch (ConcurrentModificationException expected) {
    // success
  }
}
 
Example 32
Project: googles-monorepo-demo   File: TestsForSetsInJavaUtil.java   Source Code and License 5 votes vote down vote up
public Test testsForEmptyNavigableSet() {
  return SetTestSuiteBuilder.using(
      new TestStringSortedSetGenerator() {
        @Override
        public NavigableSet<String> create(String[] elements) {
          return Collections.emptyNavigableSet();
        }
      })
      .named("emptyNavigableSet")
      .withFeatures(CollectionFeature.SERIALIZABLE, CollectionSize.ZERO)
      .suppressing(suppressForEmptyNavigableSet())
      .createTestSuite();
}
 
Example 33
Project: googles-monorepo-demo   File: MultisetNavigationTester.java   Source Code and License 5 votes vote down vote up
@CollectionSize.Require(SEVERAL)
public void testLower() {
  resetWithHole();
  assertEquals(null, sortedMultiset.headMultiset(a.getElement(), OPEN).lastEntry());
  assertEquals(a, sortedMultiset.headMultiset(b.getElement(), OPEN).lastEntry());
  assertEquals(a, sortedMultiset.headMultiset(c.getElement(), OPEN).lastEntry());
}
 
Example 34
Project: googles-monorepo-demo   File: ConcurrentMapReplaceEntryTester.java   Source Code and License 5 votes vote down vote up
@MapFeature.Require(value = SUPPORTS_PUT, absent = ALLOWS_NULL_VALUE_QUERIES)
@CollectionSize.Require(absent = ZERO)
public void testReplaceEntry_wrongValueNullValueUnsupported() {
  try {
    assertFalse(getMap().replace(k0(), v3(), null));
  } catch (NullPointerException tolerated) {
    // the operation would be a no-op, so exceptions are allowed but not required
  }
  expectUnchanged();
}
 
Example 35
Project: guava-mock   File: MultisetNavigationTester.java   Source Code and License 5 votes vote down vote up
@CollectionSize.Require(SEVERAL)
public void testLower() {
  resetWithHole();
  assertEquals(null, sortedMultiset.headMultiset(a.getElement(), OPEN).lastEntry());
  assertEquals(a, sortedMultiset.headMultiset(b.getElement(), OPEN).lastEntry());
  assertEquals(a, sortedMultiset.headMultiset(c.getElement(), OPEN).lastEntry());
}
 
Example 36
Project: googles-monorepo-demo   File: MultimapRemoveAllTester.java   Source Code and License 5 votes vote down vote up
@CollectionSize.Require(absent = ZERO)
@MapFeature.Require(SUPPORTS_REMOVE)
public void testRemoveAllPropagatesToGet() {
  Collection<V> getResult = multimap().get(k0());

  multimap().removeAll(k0());

  assertEmpty(getResult);
  expectMissing(e0());
}
 
Example 37
Project: googles-monorepo-demo   File: ListMultimapRemoveTester.java   Source Code and License 5 votes vote down vote up
@SuppressWarnings("unchecked")
@MapFeature.Require(SUPPORTS_REMOVE)
@CollectionSize.Require(SEVERAL)
public void testMultimapRemoveDeletesFirstOccurrence() {
  resetContainer(mapEntry(k0(), v0()), mapEntry(k0(), v1()), mapEntry(k0(), v0()));

  List<V> list = multimap().get(k0());
  multimap().remove(k0(), v0());
  assertContentsInOrder(list, v1(), v0());
}
 
Example 38
Project: googles-monorepo-demo   File: MultimapKeysTester.java   Source Code and License 5 votes vote down vote up
@CollectionSize.Require(SEVERAL)
@MapFeature.Require(SUPPORTS_REMOVE)
public void testKeysEntrySetRemove() {
  resetContainer(
      Helpers.mapEntry(k0(), v0()), Helpers.mapEntry(k0(), v1()), Helpers.mapEntry(k1(), v0()));
  assertTrue(multimap().keys().entrySet().remove(Multisets.immutableEntry(k0(), 2)));
  assertEquals(1, multimap().size());
  assertTrue(multimap().containsEntry(k1(), v0()));
}
 
Example 39
Project: guava-mock   File: TestsForSetsInJavaUtil.java   Source Code and License 5 votes vote down vote up
public Test testsForEmptySet() {
  return SetTestSuiteBuilder.using(
          new TestStringSetGenerator() {
            @Override
            public Set<String> create(String[] elements) {
              return Collections.emptySet();
            }
          })
      .named("emptySet")
      .withFeatures(CollectionFeature.SERIALIZABLE, CollectionSize.ZERO)
      .suppressing(suppressForEmptySet())
      .createTestSuite();
}
 
Example 40
Project: googles-monorepo-demo   File: MultisetEntrySetTester.java   Source Code and License 5 votes vote down vote up
@CollectionSize.Require(absent = ZERO)
@CollectionFeature.Require(SUPPORTS_REMOVE)
public void testEntrySet_removeAllAbsent() {
  assertFalse(
      "multiset.entrySet.remove(missingEntry) returned true",
      getMultiset()
          .entrySet()
          .removeAll(Collections.singleton(Multisets.immutableEntry(e0(), 2))));
  assertTrue(
      "multiset didn't contain element after removing a missing entry",
      getMultiset().contains(e0()));
}