当前位置: 首页>>代码示例>>Java>>正文


Java CollectionSize.Require方法代码示例

本文整理汇总了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()));
}
 
开发者ID:paul-hammant,项目名称:googles-monorepo-demo,代码行数:11,代码来源:MultisetEntrySetTester.java

示例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();
}
 
开发者ID:paul-hammant,项目名称:googles-monorepo-demo,代码行数:8,代码来源:MultimapToStringTester.java

示例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);
}
 
开发者ID:zugzug90,项目名称:guava-mock,代码行数:12,代码来源:ListSubListTester.java

示例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();
}
 
开发者ID:paul-hammant,项目名称:googles-monorepo-demo,代码行数:11,代码来源:ConcurrentMapReplaceEntryTester.java

示例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));
}
 
开发者ID:paul-hammant,项目名称:googles-monorepo-demo,代码行数:11,代码来源:MultisetRemoveTester.java

示例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();
}
 
开发者ID:paul-hammant,项目名称:googles-monorepo-demo,代码行数:11,代码来源:ListRemoveAtIndexTester.java

示例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));
}
 
开发者ID:zugzug90,项目名称:guava-mock,代码行数:16,代码来源:MultimapKeysTester.java

示例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) {
  }
}
 
开发者ID:zugzug90,项目名称:guava-mock,代码行数:12,代码来源:SetCreationTester.java

示例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());
}
 
开发者ID:zugzug90,项目名称:guava-mock,代码行数:8,代码来源:MultimapSizeTester.java

示例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();
}
 
开发者ID:paul-hammant,项目名称:googles-monorepo-demo,代码行数:12,代码来源:ListMultimapAsMapTester.java

示例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()));
}
 
开发者ID:paul-hammant,项目名称:googles-monorepo-demo,代码行数:13,代码来源:MultisetEntrySetTester.java

示例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);
    }
  }
}
 
开发者ID:paul-hammant,项目名称:googles-monorepo-demo,代码行数:13,代码来源:MultimapClearTester.java

示例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());
}
 
开发者ID:paul-hammant,项目名称:googles-monorepo-demo,代码行数:8,代码来源:ListAddAllTester.java

示例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()));
}
 
开发者ID:zugzug90,项目名称:guava-mock,代码行数:9,代码来源:MultisetNavigationTester.java

示例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()));
}
 
开发者ID:zugzug90,项目名称:guava-mock,代码行数:7,代码来源:ConcurrentMapReplaceEntryTester.java


注:本文中的com.google.common.collect.testing.features.CollectionSize.Require方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。