List of usage examples for com.google.common.collect.testing.features MapFeature GENERAL_PURPOSE
MapFeature GENERAL_PURPOSE
To view the source code for com.google.common.collect.testing.features MapFeature GENERAL_PURPOSE.
Click Source Link
From source file:com.github.benmanes.caffeine.cache.MapTestFactory.java
/** * Returns a test suite./*from ww w .ja v a 2 s .c o m*/ * * @param name the name of the cache type under test * @param supplier the cache as a map * @return a suite of tests */ protected static Test suite(String name, Supplier<Map<String, String>> supplier) { return MapTestSuiteBuilder.using(new TestStringMapGenerator() { @Override protected Map<String, String> create(Entry<String, String>[] entries) { Map<String, String> map = supplier.get(); for (Entry<String, String> entry : entries) { map.put(entry.getKey(), entry.getValue()); } return map; } }).named(name).withFeatures(MapFeature.GENERAL_PURPOSE, MapFeature.ALLOWS_NULL_ENTRY_QUERIES, CollectionFeature.SUPPORTS_ITERATOR_REMOVE, CollectionSize.ANY).createTestSuite(); }
From source file:org.java0.collection.ArrayMapSuite.java
public static TestSuite suite() { TestStringMapGenerator generator = new TestStringMapGenerator() { @Override//from ww w.j a va 2 s . com protected Map<String, String> create(Entry<String, String>[] entries) { Map<String, String> map = new ArrayMap<>(); for (Entry<String, String> entry : entries) { map.put(entry.getKey(), entry.getValue()); } return map; } }; TestSuite suite = MapTestSuiteBuilder.using(generator).named("ArrayMapSuite") .withFeatures(MapFeature.GENERAL_PURPOSE, MapFeature.ALLOWS_NULL_VALUES, CollectionFeature.SUPPORTS_ITERATOR_REMOVE, CollectionSize.ANY) .createTestSuite(); return suite; }
From source file:org.java0.collection.HashSetMapSuite.java
public static TestSuite suite() { TestMapGenerator<String, Set<String>> generator = new TestMapGenerator<String, Set<String>>() { @Override/*from w w w. j av a2s . c o m*/ public SampleElements<Map.Entry<String, Set<String>>> samples() { return new SampleElements<Map.Entry<String, Set<String>>>( Helpers.mapEntry("AAA", (Set<String>) new HashSet<String>(Arrays.asList(new String[] { "111", "222" }))), Helpers.mapEntry("BBB", (Set<String>) new HashSet<String>(Arrays.asList(new String[] { "333", "444" }))), Helpers.mapEntry("CCC", (Set<String>) new HashSet<String>(Arrays.asList(new String[] { "555", "666" }))), Helpers.mapEntry("DDD", (Set<String>) new HashSet<String>(Arrays.asList(new String[] { "777", "888" }))), Helpers.mapEntry("EEE", (Set<String>) new HashSet<String>(Arrays.asList(new String[] { "999", "000" })))); } @Override public Map<String, Set<String>> create(Object... entries) { Map<String, Set<String>> map = new HashSetMap<String, String>(); for (Object o : entries) { @SuppressWarnings("unchecked") Entry<String, Set<String>> entry = (Entry<String, Set<String>>) o; map.put(entry.getKey(), entry.getValue()); } return map; } @Override @SuppressWarnings("unchecked") public final Entry<String, Set<String>>[] createArray(int length) { return new Entry[length]; } @Override public final String[] createKeyArray(int length) { return new String[length]; } @SuppressWarnings("unchecked") @Override public final HashSet<String>[] createValueArray(int length) { return new HashSet[length]; } /** Returns the original element list, unchanged. */ @Override public Iterable<Entry<String, Set<String>>> order(List<Entry<String, Set<String>>> insertionOrder) { return insertionOrder; } }; TestSuite suite = MapTestSuiteBuilder.using(generator).named("HashSetMapSuite") .withFeatures(MapFeature.GENERAL_PURPOSE, MapFeature.FAILS_FAST_ON_CONCURRENT_MODIFICATION, MapFeature.SUPPORTS_PUT, MapFeature.SUPPORTS_REMOVE, MapFeature.ALLOWS_NULL_KEYS, MapFeature.ALLOWS_NULL_VALUES, CollectionFeature.SUPPORTS_ITERATOR_REMOVE, CollectionSize.ANY) .createTestSuite(); return suite; }