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


Java CollectionSize类代码示例

本文整理汇总了Java中com.google.common.collect.testing.features.CollectionSize的典型用法代码示例。如果您正苦于以下问题:Java CollectionSize类的具体用法?Java CollectionSize怎么用?Java CollectionSize使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


CollectionSize类属于com.google.common.collect.testing.features包,在下文中一共展示了CollectionSize类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testsForSingletonSet

import com.google.common.collect.testing.features.CollectionSize; //导入依赖的package包/类
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();
}
 
开发者ID:zugzug90,项目名称:guava-mock,代码行数:17,代码来源:TestsForSetsInJavaUtil.java

示例2: testsForCheckedList

import com.google.common.collect.testing.features.CollectionSize; //导入依赖的package包/类
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();
}
 
开发者ID:paul-hammant,项目名称:googles-monorepo-demo,代码行数:21,代码来源:TestsForListsInJavaUtil.java

示例3: testIterator_removeAffectsBackingCollection

import com.google.common.collect.testing.features.CollectionSize; //导入依赖的package包/类
@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());
}
 
开发者ID:paul-hammant,项目名称:googles-monorepo-demo,代码行数:17,代码来源:CollectionIteratorTester.java

示例4: testsForSingletonList

import com.google.common.collect.testing.features.CollectionSize; //导入依赖的package包/类
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();
}
 
开发者ID:paul-hammant,项目名称:googles-monorepo-demo,代码行数:17,代码来源:TestsForListsInJavaUtil.java

示例5: testsForTreeMapWithComparator

import com.google.common.collect.testing.features.CollectionSize; //导入依赖的package包/类
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();
}
 
开发者ID:zugzug90,项目名称:guava-mock,代码行数:24,代码来源:TestsForMapsInJavaUtil.java

示例6: suite

import com.google.common.collect.testing.features.CollectionSize; //导入依赖的package包/类
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();
}
 
开发者ID:zugzug90,项目名称:guava-mock,代码行数:21,代码来源:SynchronizedSetTest.java

示例7: testsForConcurrentSkipListMapWithComparator

import com.google.common.collect.testing.features.CollectionSize; //导入依赖的package包/类
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();
}
 
开发者ID:zugzug90,项目名称:guava-mock,代码行数:21,代码来源:TestsForMapsInJavaUtil.java

示例8: testsForArrayDeque

import com.google.common.collect.testing.features.CollectionSize; //导入依赖的package包/类
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();
}
 
开发者ID:paul-hammant,项目名称:googles-monorepo-demo,代码行数:17,代码来源:TestsForQueuesInJavaUtil.java

示例9: testsForFilter

import com.google.common.collect.testing.features.CollectionSize; //导入依赖的package包/类
@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();
}
 
开发者ID:paul-hammant,项目名称:googles-monorepo-demo,代码行数:21,代码来源:SetsTest.java

示例10: testsForEnumSet

import com.google.common.collect.testing.features.CollectionSize; //导入依赖的package包/类
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();
}
 
开发者ID:paul-hammant,项目名称:googles-monorepo-demo,代码行数:21,代码来源:TestsForSetsInJavaUtil.java

示例11: testCompute_presentToAbsent

import com.google.common.collect.testing.features.CollectionSize; //导入依赖的package包/类
@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());
}
 
开发者ID:paul-hammant,项目名称:googles-monorepo-demo,代码行数:19,代码来源:MapComputeTester.java

示例12: testsForLinkedList

import com.google.common.collect.testing.features.CollectionSize; //导入依赖的package包/类
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();
}
 
开发者ID:paul-hammant,项目名称:googles-monorepo-demo,代码行数:19,代码来源:TestsForQueuesInJavaUtil.java

示例13: testComputeIfPresent_nullKeySupportedPresent

import com.google.common.collect.testing.features.CollectionSize; //导入依赖的package包/类
@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);
}
 
开发者ID:paul-hammant,项目名称:googles-monorepo-demo,代码行数:21,代码来源:MapComputeIfPresentTester.java

示例14: testSubList_subListRemoveAffectsOriginal

import com.google.common.collect.testing.features.CollectionSize; //导入依赖的package包/类
@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);
}
 
开发者ID:paul-hammant,项目名称:googles-monorepo-demo,代码行数:9,代码来源:ListSubListTester.java

示例15: testInversePut

import com.google.common.collect.testing.features.CollectionSize; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@MapFeature.Require(SUPPORTS_PUT)
@CollectionSize.Require(ZERO)
public void testInversePut() {
  getMap().put(k0(), v0());
  getMap().inverse().put(v1(), k1());
  expectAdded(e0(), e1());
}
 
开发者ID:paul-hammant,项目名称:googles-monorepo-demo,代码行数:9,代码来源:BiMapPutTester.java


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