Class Helpers
java.lang.Object
com.google.common.collect.testing.Helpers
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static classprivate static @interfacePrivate replacement forcom.google.gwt.user.client.rpc.GwtTransientto work around build-system quirks.static classCompares strings in natural order except that null comes immediately before a given value.static final classstatic final class -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <E> booleanaddAll(Collection<E> addTo, Iterable<? extends E> elementsToAdd) static voidassertContains(Iterable<?> actual, Object expected) static voidassertContainsAllOf(Iterable<?> actual, Object... expected) static voidassertContentsAnyOrder(Iterable<?> actual, Object... expected) static voidassertContentsInOrder(Iterable<?> actual, Object... expected) static voidassertEmpty(Iterable<?> iterable) static voidassertEmpty(Map<?, ?> map) static voidassertEqualIgnoringOrder(Iterable<?> expected, Iterable<?> actual) static voidassertEqualInOrder(Iterable<?> expected, Iterable<?> actual) (package private) static <E> List<E>castOrCopyToList(Iterable<E> iterable) static <E> List<E>copyToList(E[] elements) static <E> List<E>copyToList(Iterable<? extends E> elements) static <E> Set<E>copyToSet(E[] elements) static <E> Set<E>(package private) static <T> Iterator<T>static <K,V> Comparator<Map.Entry<K, V>> entryComparator(Comparator<? super K> keyComparator) (package private) static boolean(package private) static void(package private) static <T> Tstatic Methodprivate static booleanstatic <K,V> Map.Entry<K, V> mapEntry(K key, V value) static <T> Collection<T>misleadingSizeCollection(int delta) Returns a collection that simulates concurrent modification by having its size method return incorrect values.static <K,V> Map.Entry<K, V> nefariousMapEntry(K key, V value) Returns a "nefarious" map entry with the specified key and value, meaning an entry that is suitable for testing that map entries cannot be modified via a nefarious implementation of equals.static <K extends Comparable,V>
Iterable<Map.Entry<K,V>> orderEntriesByKey(List<Map.Entry<K, V>> insertionOrder) (package private) static <T> Iterable<T>static <T> voidtestComparator(Comparator<? super T> comparator, List<T> valuesInExpectedOrder) Asserts that all pairs ofTvalues withinvaluesInExpectedOrderare ordered consistently between their order withinvaluesInExpectedOrderand the order implied by the givencomparator.static <T> voidtestComparator(Comparator<? super T> comparator, T... valuesInExpectedOrder) Asserts that all pairs ofTvalues withinvaluesInExpectedOrderare ordered consistently between their order withinvaluesInExpectedOrderand the order implied by the givencomparator.static <T extends Comparable<? super T>>
voidtestCompareToAndEquals(List<T> valuesInExpectedOrder)
-
Field Details
-
NATURAL_ORDER
-
-
Constructor Details
-
Helpers
public Helpers()
-
-
Method Details
-
equal
-
copyToList
-
copyToList
-
copyToSet
-
copyToSet
-
mapEntry
-
isEmpty
-
assertEmpty
-
assertEmpty
-
assertEqualInOrder
-
assertContentsInOrder
-
assertEqualIgnoringOrder
-
assertContentsAnyOrder
-
assertContains
-
assertContainsAllOf
-
addAll
-
reverse
-
cycle
-
get
-
fail
-
entryComparator
public static <K,V> Comparator<Map.Entry<K,V>> entryComparator(Comparator<? super K> keyComparator) -
testComparator
Asserts that all pairs ofTvalues withinvaluesInExpectedOrderare ordered consistently between their order withinvaluesInExpectedOrderand the order implied by the givencomparator.- See Also:
-
testComparator
public static <T> void testComparator(Comparator<? super T> comparator, List<T> valuesInExpectedOrder) Asserts that all pairs ofTvalues withinvaluesInExpectedOrderare ordered consistently between their order withinvaluesInExpectedOrderand the order implied by the givencomparator.In detail, this method asserts
- reflexivity:
comparator.compare(t, t) = 0for alltinvaluesInExpectedOrder; and - consistency:
comparator.compare(ti, tj) < 0andcomparator.compare(tj, ti) > 0fori < j, whereti = valuesInExpectedOrder.get(i)andtj = valuesInExpectedOrder.get(j).
- reflexivity:
-
testCompareToAndEquals
public static <T extends Comparable<? super T>> void testCompareToAndEquals(List<T> valuesInExpectedOrder) -
misleadingSizeCollection
Returns a collection that simulates concurrent modification by having its size method return incorrect values. This is useful for testing methods that must treat the return value from size() as a hint only.- Parameters:
delta- the difference between the true size of the collection and the values returned by the size method
-
nefariousMapEntry
Returns a "nefarious" map entry with the specified key and value, meaning an entry that is suitable for testing that map entries cannot be modified via a nefarious implementation of equals. This is used for testing unmodifiable collections of map entries; for example, it should not be possible to access the raw (modifiable) map entry via a nefarious equals method. -
castOrCopyToList
-
orderEntriesByKey
public static <K extends Comparable,V> Iterable<Map.Entry<K,V>> orderEntriesByKey(List<Map.Entry<K, V>> insertionOrder) -
getMethod
-