本文整理汇总了Java中com.google.common.collect.testing.features.ListFeature类的典型用法代码示例。如果您正苦于以下问题:Java ListFeature类的具体用法?Java ListFeature怎么用?Java ListFeature使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ListFeature类属于com.google.common.collect.testing.features包,在下文中一共展示了ListFeature类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testsForArraysAsList
import com.google.common.collect.testing.features.ListFeature; //导入依赖的package包/类
public Test testsForArraysAsList() {
return ListTestSuiteBuilder.using(
new TestStringListGenerator() {
@Override
public List<String> create(String[] elements) {
return Arrays.asList(elements.clone());
}
})
.named("Arrays.asList")
.withFeatures(
ListFeature.SUPPORTS_SET,
CollectionFeature.SERIALIZABLE,
CollectionFeature.ALLOWS_NULL_VALUES,
CollectionSize.ANY)
.suppressing(suppressForArraysAsList())
.createTestSuite();
}
示例2: testsForArrayList
import com.google.common.collect.testing.features.ListFeature; //导入依赖的package包/类
public Test testsForArrayList() {
return ListTestSuiteBuilder.using(
new TestStringListGenerator() {
@Override
public List<String> create(String[] elements) {
return new ArrayList<String>(MinimalCollection.of(elements));
}
})
.named("ArrayList")
.withFeatures(
ListFeature.GENERAL_PURPOSE,
CollectionFeature.SERIALIZABLE,
CollectionFeature.ALLOWS_NULL_VALUES,
CollectionFeature.FAILS_FAST_ON_CONCURRENT_MODIFICATION,
CollectionSize.ANY)
.suppressing(suppressForArrayList())
.createTestSuite();
}
示例3: testsForCopyOnWriteArrayList
import com.google.common.collect.testing.features.ListFeature; //导入依赖的package包/类
public Test testsForCopyOnWriteArrayList() {
return ListTestSuiteBuilder.using(
new TestStringListGenerator() {
@Override
public List<String> create(String[] elements) {
return new CopyOnWriteArrayList<String>(MinimalCollection.of(elements));
}
})
.named("CopyOnWriteArrayList")
.withFeatures(
ListFeature.SUPPORTS_ADD_WITH_INDEX,
ListFeature.SUPPORTS_REMOVE_WITH_INDEX,
ListFeature.SUPPORTS_SET,
CollectionFeature.SUPPORTS_ADD,
CollectionFeature.SUPPORTS_REMOVE,
CollectionFeature.SERIALIZABLE,
CollectionFeature.ALLOWS_NULL_VALUES,
CollectionSize.ANY)
.suppressing(suppressForCopyOnWriteArrayList())
.createTestSuite();
}
示例4: testsForCheckedList
import com.google.common.collect.testing.features.ListFeature; //导入依赖的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();
}
示例5: testsForVector
import com.google.common.collect.testing.features.ListFeature; //导入依赖的package包/类
private Test testsForVector() {
return ListTestSuiteBuilder
.using(new TestStringListGenerator() {
@Override
protected List<String> create(String[] elements) {
return new Vector<String>(MinimalCollection.of(elements));
}
})
.named("Vector")
.withFeatures(
ListFeature.GENERAL_PURPOSE,
CollectionFeature.ALLOWS_NULL_VALUES,
CollectionFeature.FAILS_FAST_ON_CONCURRENT_MODIFICATION,
CollectionFeature.SERIALIZABLE,
CollectionSize.ANY)
.createTestSuite();
}
示例6: testsForLinkedList
import com.google.common.collect.testing.features.ListFeature; //导入依赖的package包/类
public Test testsForLinkedList() {
return ListTestSuiteBuilder.using(
new TestStringListGenerator() {
@Override
public List<String> create(String[] elements) {
return new LinkedList<String>(MinimalCollection.of(elements));
}
})
.named("LinkedList")
.withFeatures(
ListFeature.GENERAL_PURPOSE,
CollectionFeature.SERIALIZABLE,
CollectionFeature.ALLOWS_NULL_VALUES,
CollectionFeature.FAILS_FAST_ON_CONCURRENT_MODIFICATION,
CollectionSize.ANY)
.suppressing(suppressForLinkedList())
.createTestSuite();
}
示例7: testAddAllAtIndex_end
import com.google.common.collect.testing.features.ListFeature; //导入依赖的package包/类
@ListFeature.Require(SUPPORTS_ADD_WITH_INDEX)
@CollectionSize.Require(absent = ZERO)
public void testAddAllAtIndex_end() {
assertTrue(
"addAll(end, disjoint) should return true",
getList().addAll(getNumElements(), createDisjointCollection()));
expectAdded(getNumElements(), createDisjointCollection());
}
示例8: computeMultimapGetFeatures
import com.google.common.collect.testing.features.ListFeature; //导入依赖的package包/类
@Override
Set<Feature<?>> computeMultimapGetFeatures(Set<Feature<?>> multimapFeatures) {
Set<Feature<?>> derivedFeatures = super.computeMultimapGetFeatures(multimapFeatures);
if (derivedFeatures.contains(CollectionFeature.SUPPORTS_ADD)) {
derivedFeatures.add(ListFeature.SUPPORTS_ADD_WITH_INDEX);
}
if (derivedFeatures.contains(CollectionFeature.GENERAL_PURPOSE)) {
derivedFeatures.add(ListFeature.GENERAL_PURPOSE);
}
return derivedFeatures;
}
示例9: testRemoveAtIndex_unsupported
import com.google.common.collect.testing.features.ListFeature; //导入依赖的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();
}
示例10: testRemoveAtIndex_negative
import com.google.common.collect.testing.features.ListFeature; //导入依赖的package包/类
@ListFeature.Require(SUPPORTS_REMOVE_WITH_INDEX)
public void testRemoveAtIndex_negative() {
try {
getList().remove(-1);
fail("remove(-1) should throw");
} catch (IndexOutOfBoundsException expected) {
}
expectUnchanged();
}
示例11: testRemoveAtIndex_tooLarge
import com.google.common.collect.testing.features.ListFeature; //导入依赖的package包/类
@ListFeature.Require(SUPPORTS_REMOVE_WITH_INDEX)
public void testRemoveAtIndex_tooLarge() {
try {
getList().remove(getNumElements());
fail("remove(size) should throw");
} catch (IndexOutOfBoundsException expected) {
}
expectUnchanged();
}
示例12: testRemoveAtIndexConcurrentWithIteration
import com.google.common.collect.testing.features.ListFeature; //导入依赖的package包/类
@CollectionFeature.Require(FAILS_FAST_ON_CONCURRENT_MODIFICATION)
@ListFeature.Require(SUPPORTS_REMOVE_WITH_INDEX)
@CollectionSize.Require(absent = ZERO)
public void testRemoveAtIndexConcurrentWithIteration() {
try {
Iterator<E> iterator = collection.iterator();
getList().remove(getNumElements() / 2);
iterator.next();
fail("Expected ConcurrentModificationException");
} catch (ConcurrentModificationException expected) {
// success
}
}
示例13: testReplaceAll_unsupported
import com.google.common.collect.testing.features.ListFeature; //导入依赖的package包/类
@CollectionSize.Require(absent = ZERO)
@ListFeature.Require(absent = SUPPORTS_SET)
public void testReplaceAll_unsupported() {
try {
getList().replaceAll(e -> e);
fail("replaceAll() should throw UnsupportedOperationException");
} catch (UnsupportedOperationException expected) {
}
expectUnchanged();
}
示例14: testAddAtIndex_unsupportedPresent
import com.google.common.collect.testing.features.ListFeature; //导入依赖的package包/类
@ListFeature.Require(absent = SUPPORTS_ADD_WITH_INDEX)
@CollectionSize.Require(absent = ZERO)
/*
* absent = ZERO isn't required, since unmodList.add() must
* throw regardless, but it keeps the method name accurate.
*/
public void testAddAtIndex_unsupportedPresent() {
try {
getList().add(0, e0());
fail("add(n, present) should throw");
} catch (UnsupportedOperationException expected) {
}
expectUnchanged();
}
示例15: testAddAllAtIndex_negative
import com.google.common.collect.testing.features.ListFeature; //导入依赖的package包/类
@ListFeature.Require(SUPPORTS_ADD_WITH_INDEX)
public void testAddAllAtIndex_negative() {
try {
getList().addAll(-1, MinimalCollection.of(e3()));
fail("addAll(-1, e) should throw");
} catch (IndexOutOfBoundsException expected) {
}
expectUnchanged();
expectMissing(e3());
}