本文整理汇总了Java中com.google.common.collect.testing.IteratorTester.test方法的典型用法代码示例。如果您正苦于以下问题:Java IteratorTester.test方法的具体用法?Java IteratorTester.test怎么用?Java IteratorTester.test使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.common.collect.testing.IteratorTester
的用法示例。
在下文中一共展示了IteratorTester.test方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: runIterator
import com.google.common.collect.testing.IteratorTester; //导入方法依赖的package包/类
private <T extends Comparable<T>> void runIterator(
final List<T> values, int steps) throws Exception {
IteratorTester<T> tester =
new IteratorTester<T>(
steps,
IteratorFeature.MODIFIABLE,
Lists.newLinkedList(values),
IteratorTester.KnownOrder.UNKNOWN_ORDER) {
private MinMaxPriorityQueue<T> mmHeap;
@Override protected Iterator<T> newTargetIterator() {
mmHeap = MinMaxPriorityQueue.create(values);
return mmHeap.iterator();
}
@Override protected void verify(List<T> elements) {
assertEquals(Sets.newHashSet(elements),
Sets.newHashSet(mmHeap.iterator()));
assertTrue("Invalid MinMaxHeap: " + mmHeap, mmHeap.isIntact());
}
};
tester.test();
}
示例2: testForMapGetIteration
import com.google.common.collect.testing.IteratorTester; //导入方法依赖的package包/类
public void testForMapGetIteration() {
IteratorTester<Integer> tester =
new IteratorTester<Integer>(4, MODIFIABLE, newHashSet(1),
IteratorTester.KnownOrder.KNOWN_ORDER) {
private Multimap<String, Integer> multimap;
@Override protected Iterator<Integer> newTargetIterator() {
Map<String, Integer> map = Maps.newHashMap();
map.put("foo", 1);
map.put("bar", 2);
multimap = Multimaps.forMap(map);
return multimap.get("foo").iterator();
}
@Override protected void verify(List<Integer> elements) {
assertEquals(newHashSet(elements), multimap.get("foo"));
}
};
tester.test();
}
示例3: runIterator
import com.google.common.collect.testing.IteratorTester; //导入方法依赖的package包/类
private <T extends Comparable<T>> void runIterator(final List<T> values, int steps)
throws Exception {
IteratorTester<T> tester =
new IteratorTester<T>(
steps,
IteratorFeature.MODIFIABLE,
Lists.newLinkedList(values),
IteratorTester.KnownOrder.UNKNOWN_ORDER) {
private MinMaxPriorityQueue<T> mmHeap;
@Override
protected Iterator<T> newTargetIterator() {
mmHeap = MinMaxPriorityQueue.create(values);
return mmHeap.iterator();
}
@Override
protected void verify(List<T> elements) {
assertEquals(Sets.newHashSet(elements), Sets.newHashSet(mmHeap.iterator()));
assertIntact(mmHeap);
}
};
tester.test();
}
示例4: testForMapGetIteration
import com.google.common.collect.testing.IteratorTester; //导入方法依赖的package包/类
public void testForMapGetIteration() {
IteratorTester<Integer> tester =
new IteratorTester<Integer>(
4, MODIFIABLE, newHashSet(1), IteratorTester.KnownOrder.KNOWN_ORDER) {
private Multimap<String, Integer> multimap;
@Override
protected Iterator<Integer> newTargetIterator() {
Map<String, Integer> map = Maps.newHashMap();
map.put("foo", 1);
map.put("bar", 2);
multimap = Multimaps.forMap(map);
return multimap.get("foo").iterator();
}
@Override
protected void verify(List<Integer> elements) {
assertEquals(newHashSet(elements), multimap.get("foo"));
}
};
tester.test();
}