本文整理汇总了Java中com.google.common.collect.testing.features.CollectionSize.Require方法的典型用法代码示例。如果您正苦于以下问题:Java CollectionSize.Require方法的具体用法?Java CollectionSize.Require怎么用?Java CollectionSize.Require使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.common.collect.testing.features.CollectionSize
的用法示例。
在下文中一共展示了CollectionSize.Require方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testEntrySet_removeAllPresent
import com.google.common.collect.testing.features.CollectionSize; //导入方法依赖的package包/类
@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()));
}
示例2: testToStringWithNullKey
import com.google.common.collect.testing.features.CollectionSize; //导入方法依赖的package包/类
@CollectionSize.Require(absent = ZERO)
@CollectionFeature.Require(absent = NON_STANDARD_TOSTRING)
@MapFeature.Require(ALLOWS_NULL_KEYS)
public void testToStringWithNullKey() {
initMultimapWithNullKey();
testToStringMatchesAsMap();
}
示例3: testSubList_originalListSetAffectsSubList
import com.google.common.collect.testing.features.CollectionSize; //导入方法依赖的package包/类
@ListFeature.Require(SUPPORTS_SET)
@CollectionSize.Require(absent = ZERO)
public void testSubList_originalListSetAffectsSubList() {
List<E> subList = getList().subList(0, 1);
getList().set(0, e3());
assertEquals(
"A set() call to a list after a sublist has been created "
+ "should be reflected in the sublist",
Collections.singletonList(e3()),
subList);
}
示例4: testReplaceEntry_wrongValueNullValueUnsupported
import com.google.common.collect.testing.features.CollectionSize; //导入方法依赖的package包/类
@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();
}
示例5: testRemove_nullPresent
import com.google.common.collect.testing.features.CollectionSize; //导入方法依赖的package包/类
@CollectionSize.Require(absent = ZERO)
@CollectionFeature.Require({SUPPORTS_REMOVE, ALLOWS_NULL_VALUES})
public void testRemove_nullPresent() {
initCollectionWithNullElement();
assertEquals(1, getMultiset().remove(null, 2));
assertFalse(
"multiset contains present after multiset.remove(present, 2)",
getMultiset().contains(null));
assertEquals(0, getMultiset().count(null));
}
示例6: testRemoveAtIndex_unsupported
import com.google.common.collect.testing.features.CollectionSize; //导入方法依赖的package包/类
@ListFeature.Require(absent = SUPPORTS_REMOVE_WITH_INDEX)
@CollectionSize.Require(absent = ZERO)
public void testRemoveAtIndex_unsupported() {
try {
getList().remove(0);
fail("remove(i) should throw");
} catch (UnsupportedOperationException expected) {
}
expectUnchanged();
}
示例7: testKeysWithNullKey
import com.google.common.collect.testing.features.CollectionSize; //导入方法依赖的package包/类
@CollectionSize.Require(SEVERAL)
@MapFeature.Require(ALLOWS_NULL_KEYS)
public void testKeysWithNullKey() {
resetContainer(
Helpers.mapEntry((K) null, v0()),
Helpers.mapEntry((K) null, v1()),
Helpers.mapEntry(k1(), v0()));
Multiset<K> keys = multimap().keys();
assertEquals(2, keys.count(null));
assertEquals(1, keys.count(k1()));
assertEquals(3, keys.size());
assertContainsAllOf(keys, null, k1());
assertContainsAllOf(
keys.entrySet(), Multisets.immutableEntry((K) null, 2), Multisets.immutableEntry(k1(), 1));
}
示例8: testCreateWithDuplicates_nullDuplicatesRejected
import com.google.common.collect.testing.features.CollectionSize; //导入方法依赖的package包/类
@CollectionFeature.Require({ALLOWS_NULL_VALUES, REJECTS_DUPLICATES_AT_CREATION})
@CollectionSize.Require(absent = {ZERO, ONE})
public void testCreateWithDuplicates_nullDuplicatesRejected() {
E[] array = createArrayWithNullElement();
array[0] = null;
try {
collection = getSubjectGenerator().create(array);
fail("Should reject duplicate null elements at creation");
} catch (IllegalArgumentException expected) {
}
}
示例9: testSizeNullKey
import com.google.common.collect.testing.features.CollectionSize; //导入方法依赖的package包/类
@CollectionSize.Require(absent = ZERO)
@MapFeature.Require(ALLOWS_NULL_KEYS)
public void testSizeNullKey() {
initMultimapWithNullKey();
assertEquals(getNumElements(), multimap().size());
assertFalse(multimap().isEmpty());
}
示例10: testEquals
import com.google.common.collect.testing.features.CollectionSize; //导入方法依赖的package包/类
@CollectionSize.Require(SEVERAL)
public void testEquals() {
resetContainer(
Helpers.mapEntry(k0(), v0()),
Helpers.mapEntry(k1(), v0()),
Helpers.mapEntry(k0(), v3()));
Map<K, Collection<V>> expected = Maps.newHashMap();
expected.put(k0(), Lists.newArrayList(v0(), v3()));
expected.put(k1(), Lists.newArrayList(v0()));
new EqualsTester().addEqualityGroup(expected, multimap().asMap()).testEquals();
}
示例11: testEntrySet_retainAllPresent
import com.google.common.collect.testing.features.CollectionSize; //导入方法依赖的package包/类
@CollectionSize.Require(ONE)
@CollectionFeature.Require(SUPPORTS_REMOVE)
public void testEntrySet_retainAllPresent() {
assertFalse(
"multiset.entrySet.retainAll(presentEntry) returned false",
getMultiset()
.entrySet()
.retainAll(Collections.singleton(Multisets.immutableEntry(e0(), 1))));
assertTrue(
"multiset doesn't contains element after retaining its entry",
getMultiset().contains(e0()));
}
示例12: testClearPropagatesToAsMapGet
import com.google.common.collect.testing.features.CollectionSize; //导入方法依赖的package包/类
@MapFeature.Require(SUPPORTS_REMOVE)
@CollectionSize.Require(absent = ZERO)
public void testClearPropagatesToAsMapGet() {
for (K key : sampleKeys()) {
resetContainer();
Collection<V> collection = multimap().asMap().get(key);
if (collection != null) {
multimap().clear();
assertEmpty(collection);
}
}
}
示例13: testAddAll_supportedAllPresent
import com.google.common.collect.testing.features.CollectionSize; //导入方法依赖的package包/类
@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());
}
示例14: testClearHeadClosedEntrySet
import com.google.common.collect.testing.features.CollectionSize; //导入方法依赖的package包/类
@CollectionSize.Require(SEVERAL)
@CollectionFeature.Require(SUPPORTS_REMOVE)
public void testClearHeadClosedEntrySet() {
List<Entry<E>> expected =
copyToList(sortedMultiset.tailMultiset(b.getElement(), OPEN).entrySet());
sortedMultiset.headMultiset(b.getElement(), CLOSED).entrySet().clear();
assertEquals(expected, copyToList(sortedMultiset.entrySet()));
}
示例15: testReplaceEntry_supportedPresent
import com.google.common.collect.testing.features.CollectionSize; //导入方法依赖的package包/类
@MapFeature.Require(SUPPORTS_PUT)
@CollectionSize.Require(absent = ZERO)
public void testReplaceEntry_supportedPresent() {
assertTrue(getMap().replace(k0(), v0(), v3()));
expectReplacement(entry(k0(), v3()));
}