List of usage examples for com.google.common.collect.testing.features CollectionFeature SUPPORTS_ITERATOR_REMOVE
CollectionFeature SUPPORTS_ITERATOR_REMOVE
To view the source code for com.google.common.collect.testing.features CollectionFeature SUPPORTS_ITERATOR_REMOVE.
Click Source Link
From source file:org.java0.collection.ArraySetSuite.java
public static TestSuite suite() { TestStringSetGenerator generator = new TestStringSetGenerator() { @Override/*from w w w. java 2 s . c o m*/ protected Set<String> create(String[] elements) { Set<String> set = new ArraySet<String>(); set.addAll(Arrays.asList(elements)); return set; } }; TestSuite suite = SetTestSuiteBuilder.using(generator).named("ArraySetTest") .withFeatures(SetFeature.GENERAL_PURPOSE, CollectionFeature.SUPPORTS_ADD, CollectionFeature.SUPPORTS_REMOVE, CollectionFeature.SUPPORTS_ITERATOR_REMOVE, CollectionFeature.GENERAL_PURPOSE, CollectionSize.ANY) .createTestSuite(); return suite; }
From source file:com.github.benmanes.caffeine.cache.MapTestFactory.java
/** * Returns a test suite./* w ww .j a va 2 s. com*/ * * @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 www. jav a 2 s.co m*/ 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.ArrayBufferSuite.java
public static TestSuite suite() { TestStringListGenerator listGenerator = new TestStringListGenerator() { @Override//from w ww. j a v a2s . c o m protected List<String> create(String[] elements) { List<String> buffer = new ArrayBuffer<String>(1000); buffer.addAll(Arrays.asList(elements)); return buffer; } }; TestStringQueueGenerator queueGenerator = new TestStringQueueGenerator() { @Override protected Queue<String> create(String[] elements) { Queue<String> buffer = new ArrayBuffer<String>(1000); buffer.addAll(Arrays.asList(elements)); return buffer; } }; TestSuite listSuite = ListTestSuiteBuilder.using(listGenerator).named("ArrayBufferSuite") .withFeatures(CollectionFeature.ALLOWS_NULL_VALUES, ListFeature.SUPPORTS_SET, CollectionFeature.SUPPORTS_ADD, CollectionFeature.SUPPORTS_REMOVE, CollectionFeature.SUPPORTS_ITERATOR_REMOVE, CollectionSize.ANY) .createTestSuite(); TestSuite queueSuite = QueueTestSuiteBuilder.using(queueGenerator).named("ArrayBufferSuite") .withFeatures(CollectionFeature.ALLOWS_NULL_VALUES, CollectionFeature.SUPPORTS_ADD, CollectionFeature.SUPPORTS_REMOVE, CollectionFeature.SUPPORTS_ITERATOR_REMOVE, CollectionSize.ANY) .createTestSuite(); for (int i = 0; i < queueSuite.testCount(); ++i) { listSuite.addTest(queueSuite.testAt(i)); } return listSuite; }
From source file:org.java0.collection.HashRowSetSuite.java
public static TestSuite suite() { TestSetGenerator<Tuple> generator = new TestSetGenerator<Tuple>() { @Override/* ww w . ja va 2 s . co m*/ public SampleElements<Tuple> samples() { return new SampleElements<Tuple>(new FourTuple<>("hello", 1, true, "world"), new FourTuple<>("hello1", 1, true, "world"), new FourTuple<>("hello2", 1, true, "world"), new FourTuple<>("hello", 1, true, "world1"), new FourTuple<>("hello", 1, true, "world2")); } @Override public Tuple[] createArray(int length) { return new Tuple[length]; } @Override public Iterable<Tuple> order(List<Tuple> insertionOrder) { return insertionOrder; } @SuppressWarnings({ "unchecked", "rawtypes" }) @Override public Set<Tuple> create(Object... elements) { Set<Tuple> set = new HashRowSet(); set.addAll((Collection) Arrays.asList(elements)); return set; } }; TestSuite suite = SetTestSuiteBuilder.using(generator).named("HashRowSetSuite") .withFeatures(SetFeature.GENERAL_PURPOSE, CollectionFeature.SUPPORTS_ADD, CollectionFeature.SUPPORTS_REMOVE, CollectionFeature.SUPPORTS_ITERATOR_REMOVE, CollectionFeature.GENERAL_PURPOSE, 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 ww. j a va 2 s. 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; }