本文整理汇总了Java中com.google.common.collect.testing.Helpers类的典型用法代码示例。如果您正苦于以下问题:Java Helpers类的具体用法?Java Helpers怎么用?Java Helpers使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Helpers类属于com.google.common.collect.testing包,在下文中一共展示了Helpers类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: computeMultimapGetFeatures
import com.google.common.collect.testing.Helpers; //导入依赖的package包/类
Set<Feature<?>> computeMultimapGetFeatures(Set<Feature<?>> multimapFeatures) {
Set<Feature<?>> derivedFeatures = Helpers.copyToSet(multimapFeatures);
for (Map.Entry<Feature<?>, Feature<?>> entry : GET_FEATURE_MAP.entries()) {
if (derivedFeatures.contains(entry.getKey())) {
derivedFeatures.add(entry.getValue());
}
}
if (derivedFeatures.remove(MultimapFeature.VALUE_COLLECTIONS_SUPPORT_ITERATOR_REMOVE)) {
derivedFeatures.add(CollectionFeature.SUPPORTS_ITERATOR_REMOVE);
}
if (!derivedFeatures.contains(CollectionFeature.SERIALIZABLE_INCLUDING_VIEWS)) {
derivedFeatures.remove(CollectionFeature.SERIALIZABLE);
}
derivedFeatures.removeAll(GET_FEATURE_MAP.keySet());
return derivedFeatures;
}
开发者ID:paul-hammant,项目名称:googles-monorepo-demo,代码行数:17,代码来源:MultimapTestSuiteBuilder.java
示例2: testRemovePropagatesToAsMap
import com.google.common.collect.testing.Helpers; //导入依赖的package包/类
@MapFeature.Require(SUPPORTS_REMOVE)
@CollectionSize.Require(absent = ZERO)
public void testRemovePropagatesToAsMap() {
List<Entry<K, V>> entries = Helpers.copyToList(multimap().entries());
for (Entry<K, V> entry : entries) {
resetContainer();
K key = entry.getKey();
V value = entry.getValue();
Collection<V> collection = multimap().asMap().get(key);
assertNotNull(collection);
Collection<V> expectedCollection = Helpers.copyToList(collection);
multimap().remove(key, value);
expectedCollection.remove(value);
assertEqualIgnoringOrder(expectedCollection, collection);
assertEquals(!expectedCollection.isEmpty(), multimap().containsKey(key));
}
}
开发者ID:zugzug90,项目名称:guava-mock,代码行数:21,代码来源:MultimapRemoveEntryTester.java
示例3: testArbitrary_withCollisions
import com.google.common.collect.testing.Helpers; //导入依赖的package包/类
public void testArbitrary_withCollisions() {
List<Integer> list = Lists.newArrayList();
for (int i = 0; i < 50; i++) {
list.add(i);
}
Ordering<Object> arbitrary = new ArbitraryOrdering() {
@Override int identityHashCode(Object object) {
return ((Integer) object) % 5; // fake tons of collisions!
}
};
// Don't let the elements be in such a predictable order
list = shuffledCopy(list, new Random(1));
Collections.sort(list, arbitrary);
// Now we don't care what order it's put the list in, only that
// comparing any pair of elements gives the answer we expect.
Helpers.testComparator(arbitrary, list);
}
开发者ID:paul-hammant,项目名称:googles-monorepo-demo,代码行数:22,代码来源:OrderingTest.java
示例4: testPutPresentKeyPropagatesToAsMapGet
import com.google.common.collect.testing.Helpers; //导入依赖的package包/类
@MapFeature.Require(SUPPORTS_PUT)
@CollectionSize.Require(absent = ZERO)
public void testPutPresentKeyPropagatesToAsMapGet() {
List<K> keys = Helpers.copyToList(multimap().keySet());
for (K key : keys) {
resetContainer();
int size = getNumElements();
Collection<V> collection = multimap().asMap().get(key);
assertNotNull(collection);
Collection<V> expectedCollection = Helpers.copyToList(collection);
multimap().put(key, v3());
expectedCollection.add(v3());
assertEqualIgnoringOrder(expectedCollection, collection);
assertEquals(size + 1, multimap().size());
}
}
开发者ID:paul-hammant,项目名称:googles-monorepo-demo,代码行数:20,代码来源:MultimapPutTester.java
示例5: testOrderingDoesntAffectEqualsComparisons
import com.google.common.collect.testing.Helpers; //导入依赖的package包/类
@CollectionSize.Require(SEVERAL)
public void testOrderingDoesntAffectEqualsComparisons() {
SetMultimap<K, V> multimap1 =
getSubjectGenerator()
.create(
Helpers.mapEntry(k0(), v0()),
Helpers.mapEntry(k0(), v1()),
Helpers.mapEntry(k0(), v4()));
SetMultimap<K, V> multimap2 =
getSubjectGenerator()
.create(
Helpers.mapEntry(k0(), v1()),
Helpers.mapEntry(k0(), v0()),
Helpers.mapEntry(k0(), v4()));
new EqualsTester().addEqualityGroup(multimap1, multimap2).testEquals();
}
开发者ID:paul-hammant,项目名称:googles-monorepo-demo,代码行数:17,代码来源:SetMultimapEqualsTester.java
示例6: testLexicographical
import com.google.common.collect.testing.Helpers; //导入依赖的package包/类
@SuppressWarnings("unchecked") // dang varargs
public void testLexicographical() {
Comparator<String> comparator = Ordering.natural();
Comparator<Iterable<String>> lexy = Comparators.lexicographical(comparator);
ImmutableList<String> empty = ImmutableList.of();
ImmutableList<String> a = ImmutableList.of("a");
ImmutableList<String> aa = ImmutableList.of("a", "a");
ImmutableList<String> ab = ImmutableList.of("a", "b");
ImmutableList<String> b = ImmutableList.of("b");
Helpers.testComparator(lexy, empty, a, aa, ab, b);
new EqualsTester()
.addEqualityGroup(lexy, Comparators.lexicographical(comparator))
.addEqualityGroup(Comparators.lexicographical(String.CASE_INSENSITIVE_ORDER))
.addEqualityGroup(Ordering.natural())
.testEquals();
}
开发者ID:paul-hammant,项目名称:googles-monorepo-demo,代码行数:20,代码来源:ComparatorsTest.java
示例7: verifyThreadSafe
import com.google.common.collect.testing.Helpers; //导入依赖的package包/类
/**
* Verify thread safety by using a collection whose size() may be inconsistent
* with the actual number of elements. Tests using this method might fail in
* GWT because the GWT emulations might count on size() during copy. It is
* safe to do so in GWT because javascript is single-threaded.
*/
// TODO(benyu): turn this into a test once all copyOf(Collection) are
// thread-safe
@GwtIncompatible // GWT is single threaded
void verifyThreadSafe() {
List<String> sample = Lists.newArrayList("a", "b", "c");
for (int delta : new int[] {-1, 0, 1}) {
for (int i = 0; i < sample.size(); i++) {
Collection<String> misleading = Helpers.misleadingSizeCollection(delta);
List<String> expected = sample.subList(0, i);
misleading.addAll(expected);
assertEquals("delta: " + delta + " sample size: " + i,
Sets.newHashSet(expected), copyOf(misleading));
}
}
}
开发者ID:zugzug90,项目名称:guava-mock,代码行数:22,代码来源:AbstractImmutableSetTest.java
示例8: setUp
import com.google.common.collect.testing.Helpers; //导入依赖的package包/类
@Override
public void setUp() throws Exception {
super.setUp();
navigableSet = (NavigableSet<E>) getSet();
values =
Helpers.copyToList(
getSubjectGenerator()
.getSampleElements(getSubjectGenerator().getCollectionSize().getNumElements()));
Collections.sort(values, navigableSet.comparator());
// some tests assume SEVERAL == 3
if (values.size() >= 1) {
a = values.get(0);
if (values.size() >= 3) {
b = values.get(1);
c = values.get(2);
}
}
}
开发者ID:paul-hammant,项目名称:googles-monorepo-demo,代码行数:20,代码来源:NavigableSetNavigationTester.java
示例9: testIteratorRemovePropagatesToMultimap
import com.google.common.collect.testing.Helpers; //导入依赖的package包/类
@CollectionSize.Require(ONE)
@CollectionFeature.Require(SUPPORTS_ITERATOR_REMOVE)
public void testIteratorRemovePropagatesToMultimap() {
Iterator<Entry<K, V>> iterator = multimap().entries().iterator();
assertEquals(Helpers.mapEntry(k0(), v0()), iterator.next());
iterator.remove();
assertTrue(multimap().isEmpty());
}
开发者ID:paul-hammant,项目名称:googles-monorepo-demo,代码行数:9,代码来源:MultimapEntriesTester.java
示例10: testLexicographicalComparator
import com.google.common.collect.testing.Helpers; //导入依赖的package包/类
public void testLexicographicalComparator() {
List<double[]> ordered = Arrays.asList(
new double[] {},
new double[] {LEAST},
new double[] {LEAST, LEAST},
new double[] {LEAST, (double) 1},
new double[] {(double) 1},
new double[] {(double) 1, LEAST},
new double[] {GREATEST, Double.MAX_VALUE},
new double[] {GREATEST, GREATEST},
new double[] {GREATEST, GREATEST, GREATEST});
Comparator<double[]> comparator = Doubles.lexicographicalComparator();
Helpers.testComparator(comparator, ordered);
}
开发者ID:paul-hammant,项目名称:googles-monorepo-demo,代码行数:16,代码来源:DoublesTest.java
示例11: testForEachEntry
import com.google.common.collect.testing.Helpers; //导入依赖的package包/类
public void testForEachEntry() {
List<Entry<E>> expected = new ArrayList<>(getMultiset().entrySet());
List<Entry<E>> actual = new ArrayList<>();
getMultiset()
.forEachEntry((element, count) -> actual.add(Multisets.immutableEntry(element, count)));
Helpers.assertEqualIgnoringOrder(expected, actual);
}
开发者ID:zugzug90,项目名称:guava-mock,代码行数:8,代码来源:MultisetForEachEntryTester.java
示例12: testArbitrary_withoutCollisions
import com.google.common.collect.testing.Helpers; //导入依赖的package包/类
public void testArbitrary_withoutCollisions() {
List<Object> list = Lists.newArrayList();
for (int i = 0; i < 50; i++) {
list.add(new Object());
}
Ordering<Object> arbitrary = Ordering.arbitrary();
Collections.sort(list, arbitrary);
// Now we don't care what order it's put the list in, only that
// comparing any pair of elements gives the answer we expect.
Helpers.testComparator(arbitrary, list);
assertEquals("Ordering.arbitrary()", arbitrary.toString());
}
开发者ID:zugzug90,项目名称:guava-mock,代码行数:16,代码来源:OrderingTest.java
示例13: testPutPresentKeyPropagatesToAsMapEntrySet
import com.google.common.collect.testing.Helpers; //导入依赖的package包/类
@MapFeature.Require(SUPPORTS_PUT)
@CollectionSize.Require(absent = ZERO)
public void testPutPresentKeyPropagatesToAsMapEntrySet() {
List<K> keys = Helpers.copyToList(multimap().keySet());
for (K key : keys) {
resetContainer();
int size = getNumElements();
Iterator<Entry<K, Collection<V>>> asMapItr = multimap().asMap().entrySet().iterator();
Collection<V> collection = null;
while (asMapItr.hasNext()) {
Entry<K, Collection<V>> asMapEntry = asMapItr.next();
if (key.equals(asMapEntry.getKey())) {
collection = asMapEntry.getValue();
break;
}
}
assertNotNull(collection);
Collection<V> expectedCollection = Helpers.copyToList(collection);
multimap().put(key, v3());
expectedCollection.add(v3());
assertEqualIgnoringOrder(expectedCollection, collection);
assertEquals(size + 1, multimap().size());
}
}
开发者ID:paul-hammant,项目名称:googles-monorepo-demo,代码行数:28,代码来源:MultimapPutTester.java
示例14: testLexicographicalComparator
import com.google.common.collect.testing.Helpers; //导入依赖的package包/类
public void testLexicographicalComparator() {
List<long[]> ordered = Arrays.asList(
new long[] {},
new long[] {MIN_VALUE},
new long[] {MIN_VALUE, MIN_VALUE},
new long[] {MIN_VALUE, (long) 1},
new long[] {(long) 1},
new long[] {(long) 1, MIN_VALUE},
new long[] {MAX_VALUE, MAX_VALUE - (long) 1},
new long[] {MAX_VALUE, MAX_VALUE},
new long[] {MAX_VALUE, MAX_VALUE, MAX_VALUE});
Comparator<long[]> comparator = Longs.lexicographicalComparator();
Helpers.testComparator(comparator, ordered);
}
开发者ID:paul-hammant,项目名称:googles-monorepo-demo,代码行数:16,代码来源:LongsTest.java
示例15: testToArray_threadSafe
import com.google.common.collect.testing.Helpers; //导入依赖的package包/类
public void testToArray_threadSafe() {
for (int delta : new int[] { +1, 0, -1 }) {
for (int i = 0; i < VALUES.length; i++) {
List<Long> list = Longs.asList(VALUES).subList(0, i);
Collection<Long> misleadingSize =
Helpers.misleadingSizeCollection(delta);
misleadingSize.addAll(list);
long[] arr = Longs.toArray(misleadingSize);
assertEquals(i, arr.length);
for (int j = 0; j < i; j++) {
assertEquals(VALUES[j], arr[j]);
}
}
}
}
开发者ID:paul-hammant,项目名称:googles-monorepo-demo,代码行数:16,代码来源:LongsTest.java
示例16: getTesters
import com.google.common.collect.testing.Helpers; //导入依赖的package包/类
@Override
protected List<Class<? extends AbstractTester>> getTesters() {
List<Class<? extends AbstractTester>> testers = Helpers.copyToList(super.getTesters());
testers.add(ListMultimapAsMapTester.class);
testers.add(ListMultimapEqualsTester.class);
testers.add(ListMultimapPutTester.class);
testers.add(ListMultimapPutAllTester.class);
testers.add(ListMultimapRemoveTester.class);
testers.add(ListMultimapReplaceValuesTester.class);
return testers;
}
开发者ID:zugzug90,项目名称:guava-mock,代码行数:12,代码来源:ListMultimapTestSuiteBuilder.java
示例17: samples
import com.google.common.collect.testing.Helpers; //导入依赖的package包/类
@Override
public SampleElements<Map.Entry<String, String>> samples() {
return new SampleElements<Map.Entry<String, String>>(
Helpers.mapEntry("one", "January"),
Helpers.mapEntry("two", "February"),
Helpers.mapEntry("three", "March"),
Helpers.mapEntry("four", "April"),
Helpers.mapEntry("five", "May"));
}
开发者ID:zugzug90,项目名称:guava-mock,代码行数:10,代码来源:TestStringListMultimapGenerator.java
示例18: testStreamToArrayUnknownOrder
import com.google.common.collect.testing.Helpers; //导入依赖的package包/类
@CollectionFeature.Require(absent = KNOWN_ORDER)
public void testStreamToArrayUnknownOrder() {
synchronized (collection) { // to allow Collections.synchronized* tests to pass
Helpers.assertEqualIgnoringOrder(
getSampleElements(), Arrays.asList(collection.stream().toArray()));
}
}
开发者ID:paul-hammant,项目名称:googles-monorepo-demo,代码行数:8,代码来源:CollectionStreamTester.java
示例19: testPutPresentKeyPropagatesToEntries
import com.google.common.collect.testing.Helpers; //导入依赖的package包/类
@CollectionSize.Require(absent = ZERO)
@MapFeature.Require(SUPPORTS_PUT)
public void testPutPresentKeyPropagatesToEntries() {
Collection<Entry<K, V>> entries = multimap().entries();
assertFalse(entries.contains(Helpers.mapEntry(k0(), v3())));
multimap().put(k0(), v3());
assertContains(entries, Helpers.mapEntry(k0(), v3()));
}
开发者ID:paul-hammant,项目名称:googles-monorepo-demo,代码行数:9,代码来源:MultimapPutTester.java
示例20: testNullsLast
import com.google.common.collect.testing.Helpers; //导入依赖的package包/类
public void testNullsLast() {
Ordering<Integer> ordering = Ordering.natural().nullsLast();
Helpers.testComparator(ordering, 0, 1, Integer.MAX_VALUE, null);
new EqualsTester()
.addEqualityGroup(ordering, Ordering.natural().nullsLast())
.addEqualityGroup(numberOrdering.nullsLast())
.addEqualityGroup(Ordering.natural())
.testEquals();
}
开发者ID:zugzug90,项目名称:guava-mock,代码行数:11,代码来源:OrderingTest.java
注:本文中的com.google.common.collect.testing.Helpers类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论