本文整理汇总了Java中com.google.common.collect.testing.features.CollectionSize.ZERO属性的典型用法代码示例。如果您正苦于以下问题:Java CollectionSize.ZERO属性的具体用法?Java CollectionSize.ZERO怎么用?Java CollectionSize.ZERO使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类com.google.common.collect.testing.features.CollectionSize
的用法示例。
在下文中一共展示了CollectionSize.ZERO属性的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testHashCode_containingNull
@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());
}
示例2: testEquals_otherListWithDifferentElements
@CollectionSize.Require(absent = CollectionSize.ZERO)
public void testEquals_otherListWithDifferentElements() {
ArrayList<E> other = new ArrayList<E>(getSampleElements());
other.set(other.size() / 2, getSubjectGenerator().samples().e3());
assertFalse(
"A List should not equal another List containing different elements.",
getList().equals(other));
}
示例3: testEquals_containingNull
@CollectionSize.Require(absent = CollectionSize.ZERO)
@CollectionFeature.Require(ALLOWS_NULL_VALUES)
public void testEquals_containingNull() {
Collection<E> elements = getSampleElements(getNumElements() - 1);
elements.add(null);
collection = getSubjectGenerator().create(elements.toArray());
assertTrue(
"A Set should equal any other Set containing the same elements,"
+ " even if some elements are null.",
getSet().equals(MinimalSet.from(elements)));
}
示例4: testEquals_containingNull
@CollectionSize.Require(absent = CollectionSize.ZERO)
@CollectionFeature.Require(ALLOWS_NULL_VALUES)
public void testEquals_containingNull() {
ArrayList<E> elements = new ArrayList<E>(getSampleElements());
elements.set(elements.size() / 2, null);
collection = getSubjectGenerator().create(elements.toArray());
List<E> other = new ArrayList<E>(getSampleElements());
assertFalse(
"Two Lists should not be equal if exactly one of them has null at a given index.",
getList().equals(other));
}
示例5: testEquals_otherContainsNull
@CollectionSize.Require(absent = CollectionSize.ZERO)
public void testEquals_otherContainsNull() {
Collection<E> elements = getSampleElements(getNumElements() - 1);
elements.add(null);
Set<E> other = MinimalSet.from(elements);
assertFalse(
"Two Sets should not be equal if exactly one of them contains null.",
getSet().equals(other));
}
示例6: testEquals_smallerSet
@CollectionSize.Require(absent = CollectionSize.ZERO)
public void testEquals_smallerSet() {
Collection<E> fewerElements = getSampleElements(getNumElements() - 1);
assertFalse(
"Sets of different sizes should not be equal.",
getSet().equals(MinimalSet.from(fewerElements)));
}
示例7: testEquals_otherSetWithDifferentElements
@CollectionSize.Require(absent = CollectionSize.ZERO)
public void testEquals_otherSetWithDifferentElements() {
Collection<E> elements = getSampleElements(getNumElements() - 1);
elements.add(getSubjectGenerator().samples().e3());
assertFalse(
"A Set should not equal another Set containing different elements.",
getSet().equals(MinimalSet.from(elements)));
}
示例8: testEquals_containingNullKey
@CollectionSize.Require(absent = CollectionSize.ZERO)
@MapFeature.Require(ALLOWS_NULL_KEYS)
public void testEquals_containingNullKey() {
Collection<Map.Entry<K, V>> entries = getSampleEntries(getNumEntries() - 1);
entries.add(entry(null, v3()));
resetContainer(getSubjectGenerator().create(entries.toArray()));
assertTrue(
"A Map should equal any other Map containing the same entries,"
+ " even if some keys are null.",
getMap().equals(newHashMap(entries)));
}
示例9: testEquals_otherContainsNullValue
@CollectionSize.Require(absent = CollectionSize.ZERO)
public void testEquals_otherContainsNullValue() {
Collection<Map.Entry<K, V>> entries = getSampleEntries(getNumEntries() - 1);
entries.add(entry(k3(), null));
Map<K, V> other = newHashMap(entries);
assertFalse(
"Two Maps should not be equal if exactly one of them contains a null value.",
getMap().equals(other));
}
示例10: testEquals_containingNullValue
@CollectionSize.Require(absent = CollectionSize.ZERO)
@MapFeature.Require(ALLOWS_NULL_VALUES)
public void testEquals_containingNullValue() {
Collection<Map.Entry<K, V>> entries = getSampleEntries(getNumEntries() - 1);
entries.add(entry(k3(), null));
resetContainer(getSubjectGenerator().create(entries.toArray()));
assertTrue(
"A Map should equal any other Map containing the same entries,"
+ " even if some values are null.",
getMap().equals(newHashMap(entries)));
}
示例11: testEquals_otherContainsNullKey
@CollectionSize.Require(absent = CollectionSize.ZERO)
public void testEquals_otherContainsNullKey() {
Collection<Map.Entry<K, V>> entries = getSampleEntries(getNumEntries() - 1);
entries.add(entry(null, v3()));
Map<K, V> other = newHashMap(entries);
assertFalse(
"Two Maps should not be equal if exactly one of them contains a null key.",
getMap().equals(other));
}
示例12: testHashCode_containingNullKey
@CollectionSize.Require(absent = CollectionSize.ZERO)
@MapFeature.Require(ALLOWS_NULL_KEYS)
public void testHashCode_containingNullKey() {
Map.Entry<K, V> entryWithNull = entry(null, v3());
runEntryWithNullTest(entryWithNull);
}
示例13: testHashCode_containingNullValue
@CollectionSize.Require(absent = CollectionSize.ZERO)
@MapFeature.Require(ALLOWS_NULL_VALUES)
public void testHashCode_containingNullValue() {
Map.Entry<K, V> entryWithNull = entry(k3(), null);
runEntryWithNullTest(entryWithNull);
}
示例14: testEquals_smallerMap
@CollectionSize.Require(absent = CollectionSize.ZERO)
public void testEquals_smallerMap() {
Collection<Map.Entry<K, V>> fewerEntries = getSampleEntries(getNumEntries() - 1);
assertFalse(
"Maps of different sizes should not be equal.", getMap().equals(newHashMap(fewerEntries)));
}