com.google.common.collect.testing
Class Helpers

java.lang.Object
  extended by com.google.common.collect.testing.Helpers

@GwtCompatible
public class Helpers
extends Object


Nested Class Summary
static class Helpers.NullsBefore
          Compares strings in natural order except that null comes immediately before a given value.
static class Helpers.NullsBeforeB
           
static class Helpers.NullsBeforeTwo
           
 
Constructor Summary
Helpers()
           
 
Method Summary
static
<E> boolean
addAll(Collection<E> addTo, Iterable<? extends E> elementsToAdd)
           
static void assertContentsAnyOrder(Iterable<?> actual, Object... expected)
           
static void assertEqualIgnoringOrder(Iterable<?> expected, Iterable<?> actual)
           
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>
copyToSet(Iterable<? extends E> elements)
           
static
<K,V> Comparator<Map.Entry<K,V>>
entryComparator(Comparator<? super K> keyComparator)
           
static
<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)
           
static
<T> void
testComparator(Comparator<? super T> comparator, List<T> valuesInExpectedOrder)
           
static
<T> void
testComparator(Comparator<? super T> comparator, T... valuesInExpectedOrder)
           
static
<T extends Comparable<? super T>>
void
testCompareToAndEquals(List<T> valuesInExpectedOrder)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Helpers

public Helpers()
Method Detail

copyToList

public static <E> List<E> copyToList(Iterable<? extends E> elements)

copyToList

public static <E> List<E> copyToList(E[] elements)

copyToSet

public static <E> Set<E> copyToSet(Iterable<? extends E> elements)

copyToSet

public static <E> Set<E> copyToSet(E[] elements)

mapEntry

public static <K,V> Map.Entry<K,V> mapEntry(K key,
                                            V value)

assertEqualIgnoringOrder

public static void assertEqualIgnoringOrder(Iterable<?> expected,
                                            Iterable<?> actual)

assertContentsAnyOrder

public static void assertContentsAnyOrder(Iterable<?> actual,
                                          Object... expected)

addAll

public static <E> boolean addAll(Collection<E> addTo,
                                 Iterable<? extends E> elementsToAdd)

entryComparator

public static <K,V> Comparator<Map.Entry<K,V>> entryComparator(Comparator<? super K> keyComparator)

testComparator

public static <T> void testComparator(Comparator<? super T> comparator,
                                      T... valuesInExpectedOrder)

testComparator

public static <T> void testComparator(Comparator<? super T> comparator,
                                      List<T> valuesInExpectedOrder)

testCompareToAndEquals

public static <T extends Comparable<? super T>> void testCompareToAndEquals(List<T> valuesInExpectedOrder)

misleadingSizeCollection

public static <T> Collection<T> misleadingSizeCollection(int delta)
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

public 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. 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.


orderEntriesByKey

public static <K extends Comparable,V> Iterable<Map.Entry<K,V>> orderEntriesByKey(List<Map.Entry<K,V>> insertionOrder)


Copyright © 2010-2012. All Rights Reserved.