use of com.google.common.collect.testing.TestStringCollectionGenerator in project guava by google.
the class ForwardingCollectionTest method suite.
public static Test suite() {
TestSuite suite = new TestSuite();
suite.addTestSuite(ForwardingCollectionTest.class);
suite.addTest(CollectionTestSuiteBuilder.using(new TestStringCollectionGenerator() {
@Override
protected Collection<String> create(String[] elements) {
return new StandardImplForwardingCollection<String>(Lists.newLinkedList(asList(elements)));
}
}).named("ForwardingCollection[LinkedList] with standard implementations").withFeatures(CollectionSize.ANY, CollectionFeature.ALLOWS_NULL_VALUES, CollectionFeature.GENERAL_PURPOSE).createTestSuite());
suite.addTest(CollectionTestSuiteBuilder.using(new TestStringCollectionGenerator() {
@Override
protected Collection<String> create(String[] elements) {
return new StandardImplForwardingCollection<String>(MinimalCollection.of(elements));
}
}).named("ForwardingCollection[MinimalCollection] with standard" + " implementations").withFeatures(CollectionSize.ANY, CollectionFeature.ALLOWS_NULL_VALUES).createTestSuite());
return suite;
}
use of com.google.common.collect.testing.TestStringCollectionGenerator in project guava by google.
the class TableCollectionTest method suite.
// suite
@GwtIncompatible
public static Test suite() {
TestSuite suite = new TestSuite();
suite.addTestSuite(ArrayRowTests.class);
suite.addTestSuite(HashRowTests.class);
suite.addTestSuite(TreeRowTests.class);
suite.addTestSuite(TransposeRowTests.class);
suite.addTestSuite(TransformValueRowTests.class);
suite.addTestSuite(UnmodifiableHashRowTests.class);
suite.addTestSuite(UnmodifiableTreeRowTests.class);
suite.addTestSuite(ArrayColumnTests.class);
suite.addTestSuite(HashColumnTests.class);
suite.addTestSuite(TreeColumnTests.class);
suite.addTestSuite(TransposeColumnTests.class);
suite.addTestSuite(TransformValueColumnTests.class);
suite.addTestSuite(UnmodifiableHashColumnTests.class);
suite.addTestSuite(UnmodifiableTreeColumnTests.class);
suite.addTestSuite(ArrayRowMapTests.class);
suite.addTestSuite(HashRowMapTests.class);
suite.addTestSuite(TreeRowMapTests.class);
suite.addTestSuite(TreeRowMapHeadMapTests.class);
suite.addTestSuite(TreeRowMapTailMapTests.class);
suite.addTestSuite(TreeRowMapSubMapTests.class);
suite.addTestSuite(TransformValueRowMapTests.class);
suite.addTestSuite(UnmodifiableHashRowMapTests.class);
suite.addTestSuite(UnmodifiableTreeRowMapTests.class);
suite.addTestSuite(ArrayColumnMapTests.class);
suite.addTestSuite(HashColumnMapTests.class);
suite.addTestSuite(TreeColumnMapTests.class);
suite.addTestSuite(TransformValueColumnMapTests.class);
suite.addTestSuite(UnmodifiableHashColumnMapTests.class);
suite.addTestSuite(UnmodifiableTreeColumnMapTests.class);
// Not testing rowKeySet() or columnKeySet() of Table.transformValues()
// since the transformation doesn't affect the row and column key sets.
suite.addTest(SetTestSuiteBuilder.using(new TestStringSetGenerator() {
@Override
protected Set<String> create(String[] elements) {
Table<String, Integer, Character> table = ArrayTable.create(ImmutableList.copyOf(elements), ImmutableList.of(1, 2));
populateForRowKeySet(table, elements);
return table.rowKeySet();
}
}).named("ArrayTable.rowKeySet").withFeatures(CollectionSize.ONE, CollectionSize.SEVERAL, CollectionFeature.KNOWN_ORDER, CollectionFeature.REJECTS_DUPLICATES_AT_CREATION, CollectionFeature.ALLOWS_NULL_QUERIES).createTestSuite());
suite.addTest(SetTestSuiteBuilder.using(new TestStringSetGenerator() {
@Override
protected Set<String> create(String[] elements) {
Table<String, Integer, Character> table = HashBasedTable.create();
populateForRowKeySet(table, elements);
return table.rowKeySet();
}
}).named("HashBasedTable.rowKeySet").withFeatures(COLLECTION_FEATURES_REMOVE).withFeatures(CollectionFeature.SUPPORTS_ITERATOR_REMOVE).createTestSuite());
suite.addTest(SortedSetTestSuiteBuilder.using(new TestStringSortedSetGenerator() {
@Override
protected SortedSet<String> create(String[] elements) {
TreeBasedTable<String, Integer, Character> table = TreeBasedTable.create();
populateForRowKeySet(table, elements);
return table.rowKeySet();
}
@Override
public List<String> order(List<String> insertionOrder) {
Collections.sort(insertionOrder);
return insertionOrder;
}
}).named("TreeBasedTable.rowKeySet").withFeatures(COLLECTION_FEATURES_REMOVE_ORDER).withFeatures(CollectionFeature.SUPPORTS_ITERATOR_REMOVE).createTestSuite());
suite.addTest(SetTestSuiteBuilder.using(new TestStringSetGenerator() {
@Override
protected Set<String> create(String[] elements) {
Table<String, Integer, Character> table = HashBasedTable.create();
populateForRowKeySet(table, elements);
return Tables.unmodifiableTable(table).rowKeySet();
}
}).named("unmodifiableTable[HashBasedTable].rowKeySet").withFeatures(COLLECTION_FEATURES).createTestSuite());
suite.addTest(SetTestSuiteBuilder.using(new TestStringSetGenerator() {
@Override
protected Set<String> create(String[] elements) {
RowSortedTable<String, Integer, Character> table = TreeBasedTable.create();
populateForRowKeySet(table, elements);
return Tables.unmodifiableRowSortedTable(table).rowKeySet();
}
@Override
public List<String> order(List<String> insertionOrder) {
Collections.sort(insertionOrder);
return insertionOrder;
}
}).named("unmodifiableRowSortedTable[TreeBasedTable].rowKeySet").withFeatures(COLLECTION_FEATURES_ORDER).createTestSuite());
suite.addTest(SetTestSuiteBuilder.using(new TestStringSetGenerator() {
@Override
protected Set<String> create(String[] elements) {
Table<Integer, String, Character> table = ArrayTable.create(ImmutableList.of(1, 2), ImmutableList.copyOf(elements));
populateForColumnKeySet(table, elements);
return table.columnKeySet();
}
}).named("ArrayTable.columnKeySet").withFeatures(CollectionSize.ONE, CollectionSize.SEVERAL, CollectionFeature.KNOWN_ORDER, CollectionFeature.REJECTS_DUPLICATES_AT_CREATION, CollectionFeature.ALLOWS_NULL_QUERIES).createTestSuite());
suite.addTest(SetTestSuiteBuilder.using(new TestStringSetGenerator() {
@Override
protected Set<String> create(String[] elements) {
Table<Integer, String, Character> table = HashBasedTable.create();
populateForColumnKeySet(table, elements);
return table.columnKeySet();
}
}).named("HashBasedTable.columnKeySet").withFeatures(COLLECTION_FEATURES_REMOVE).createTestSuite());
suite.addTest(SetTestSuiteBuilder.using(new TestStringSetGenerator() {
@Override
protected Set<String> create(String[] elements) {
Table<Integer, String, Character> table = TreeBasedTable.create();
populateForColumnKeySet(table, elements);
return table.columnKeySet();
}
@Override
public List<String> order(List<String> insertionOrder) {
Collections.sort(insertionOrder);
return insertionOrder;
}
}).named("TreeBasedTable.columnKeySet").withFeatures(COLLECTION_FEATURES_REMOVE_ORDER).createTestSuite());
suite.addTest(SetTestSuiteBuilder.using(new TestStringSetGenerator() {
@Override
protected Set<String> create(String[] elements) {
Table<Integer, String, Character> table = HashBasedTable.create();
populateForColumnKeySet(table, elements);
return Tables.unmodifiableTable(table).columnKeySet();
}
}).named("unmodifiableTable[HashBasedTable].columnKeySet").withFeatures(COLLECTION_FEATURES).createTestSuite());
suite.addTest(SetTestSuiteBuilder.using(new TestStringSetGenerator() {
@Override
protected Set<String> create(String[] elements) {
RowSortedTable<Integer, String, Character> table = TreeBasedTable.create();
populateForColumnKeySet(table, elements);
return Tables.unmodifiableRowSortedTable(table).columnKeySet();
}
@Override
public List<String> order(List<String> insertionOrder) {
Collections.sort(insertionOrder);
return insertionOrder;
}
}).named("unmodifiableRowSortedTable[TreeBasedTable].columnKeySet").withFeatures(COLLECTION_FEATURES_ORDER).createTestSuite());
suite.addTest(CollectionTestSuiteBuilder.using(new TestStringCollectionGenerator() {
@Override
protected Collection<String> create(String[] elements) {
List<Integer> rowKeys = Lists.newArrayList();
for (int i = 0; i < elements.length; i++) {
rowKeys.add(i);
}
Table<Integer, Character, String> table = ArrayTable.create(rowKeys, ImmutableList.of('a'));
populateForValues(table, elements);
return table.values();
}
}).named("ArrayTable.values").withFeatures(CollectionSize.ONE, CollectionSize.SEVERAL, CollectionFeature.ALLOWS_NULL_VALUES, CollectionFeature.KNOWN_ORDER).createTestSuite());
suite.addTest(CollectionTestSuiteBuilder.using(new TestStringCollectionGenerator() {
@Override
protected Collection<String> create(String[] elements) {
Table<Integer, Character, String> table = HashBasedTable.create();
table.put(1, 'a', "foo");
table.clear();
populateForValues(table, elements);
return table.values();
}
}).named("HashBasedTable.values").withFeatures(COLLECTION_FEATURES_REMOVE).withFeatures(CollectionFeature.SUPPORTS_ITERATOR_REMOVE).createTestSuite());
suite.addTest(CollectionTestSuiteBuilder.using(new TestStringCollectionGenerator() {
@Override
protected Collection<String> create(String[] elements) {
Table<Integer, Character, String> table = TreeBasedTable.create();
table.put(1, 'a', "foo");
table.clear();
populateForValues(table, elements);
return table.values();
}
}).named("TreeBasedTable.values").withFeatures(COLLECTION_FEATURES_REMOVE_ORDER).withFeatures(CollectionFeature.SUPPORTS_ITERATOR_REMOVE).createTestSuite());
final Function<String, String> removeFirstCharacter = new Function<String, String>() {
@Override
public String apply(String input) {
return input.substring(1);
}
};
suite.addTest(CollectionTestSuiteBuilder.using(new TestStringCollectionGenerator() {
@Override
protected Collection<String> create(String[] elements) {
Table<Integer, Character, String> table = HashBasedTable.create();
for (int i = 0; i < elements.length; i++) {
table.put(i, 'a', "x" + checkNotNull(elements[i]));
}
return Tables.transformValues(table, removeFirstCharacter).values();
}
}).named("TransformValues.values").withFeatures(COLLECTION_FEATURES_REMOVE).withFeatures(CollectionFeature.SUPPORTS_ITERATOR_REMOVE).createTestSuite());
suite.addTest(CollectionTestSuiteBuilder.using(new TestStringCollectionGenerator() {
@Override
protected Collection<String> create(String[] elements) {
Table<Integer, Character, String> table = HashBasedTable.create();
table.put(1, 'a', "foo");
table.clear();
populateForValues(table, elements);
return Tables.unmodifiableTable(table).values();
}
}).named("unmodifiableTable[HashBasedTable].values").withFeatures(COLLECTION_FEATURES).createTestSuite());
suite.addTest(CollectionTestSuiteBuilder.using(new TestStringCollectionGenerator() {
@Override
protected Collection<String> create(String[] elements) {
RowSortedTable<Integer, Character, String> table = TreeBasedTable.create();
table.put(1, 'a', "foo");
table.clear();
populateForValues(table, elements);
return Tables.unmodifiableRowSortedTable(table).values();
}
}).named("unmodifiableTable[TreeBasedTable].values").withFeatures(COLLECTION_FEATURES_ORDER).createTestSuite());
suite.addTest(SetTestSuiteBuilder.using(new TestCellSetGenerator() {
@Override
public SampleElements<Cell<String, Integer, Character>> samples() {
return new SampleElements<Cell<String, Integer, Character>>(Tables.immutableCell("bar", 1, 'a'), Tables.immutableCell("bar", 2, 'b'), Tables.immutableCell("bar", 3, (Character) null), Tables.immutableCell("bar", 4, 'b'), Tables.immutableCell("bar", 5, 'b'));
}
@Override
public Set<Cell<String, Integer, Character>> create(Object... elements) {
List<Integer> columnKeys = Lists.newArrayList();
for (Object element : elements) {
@SuppressWarnings("unchecked") Cell<String, Integer, Character> cell = (Cell<String, Integer, Character>) element;
columnKeys.add(cell.getColumnKey());
}
Table<String, Integer, Character> table = ArrayTable.create(ImmutableList.of("bar"), columnKeys);
for (Object element : elements) {
@SuppressWarnings("unchecked") Cell<String, Integer, Character> cell = (Cell<String, Integer, Character>) element;
table.put(cell.getRowKey(), cell.getColumnKey(), cell.getValue());
}
return table.cellSet();
}
@Override
Table<String, Integer, Character> createTable() {
throw new UnsupportedOperationException();
}
}).named("ArrayTable.cellSet").withFeatures(CollectionSize.ONE, CollectionSize.SEVERAL, CollectionFeature.KNOWN_ORDER, CollectionFeature.REJECTS_DUPLICATES_AT_CREATION, CollectionFeature.ALLOWS_NULL_QUERIES).createTestSuite());
suite.addTest(SetTestSuiteBuilder.using(new TestCellSetGenerator() {
@Override
Table<String, Integer, Character> createTable() {
return HashBasedTable.create();
}
}).named("HashBasedTable.cellSet").withFeatures(CollectionSize.ANY, CollectionFeature.REMOVE_OPERATIONS, CollectionFeature.ALLOWS_NULL_QUERIES).createTestSuite());
suite.addTest(SetTestSuiteBuilder.using(new TestCellSetGenerator() {
@Override
Table<String, Integer, Character> createTable() {
return TreeBasedTable.create();
}
}).named("TreeBasedTable.cellSet").withFeatures(CollectionSize.ANY, CollectionFeature.REMOVE_OPERATIONS, CollectionFeature.ALLOWS_NULL_QUERIES).createTestSuite());
suite.addTest(SetTestSuiteBuilder.using(new TestCellSetGenerator() {
@Override
Table<String, Integer, Character> createTable() {
Table<Integer, String, Character> original = TreeBasedTable.create();
return Tables.transpose(original);
}
}).named("TransposedTable.cellSet").withFeatures(CollectionSize.ANY, CollectionFeature.REMOVE_OPERATIONS, CollectionFeature.ALLOWS_NULL_QUERIES).createTestSuite());
suite.addTest(SetTestSuiteBuilder.using(new TestCellSetGenerator() {
@Override
Table<String, Integer, Character> createTable() {
return HashBasedTable.create();
}
@Override
public Set<Cell<String, Integer, Character>> create(Object... elements) {
Table<String, Integer, Character> table = createTable();
for (Object element : elements) {
@SuppressWarnings("unchecked") Cell<String, Integer, Character> cell = (Cell<String, Integer, Character>) element;
table.put(cell.getRowKey(), cell.getColumnKey(), cell.getValue());
}
return Tables.transformValues(table, Functions.<Character>identity()).cellSet();
}
}).named("TransformValues.cellSet").withFeatures(CollectionSize.ANY, CollectionFeature.ALLOWS_NULL_QUERIES, CollectionFeature.REMOVE_OPERATIONS).createTestSuite());
suite.addTest(SetTestSuiteBuilder.using(new TestCellSetGenerator() {
@Override
Table<String, Integer, Character> createTable() {
return Tables.unmodifiableTable(HashBasedTable.<String, Integer, Character>create());
}
@Override
public Set<Cell<String, Integer, Character>> create(Object... elements) {
Table<String, Integer, Character> table = HashBasedTable.create();
for (Object element : elements) {
@SuppressWarnings("unchecked") Cell<String, Integer, Character> cell = (Cell<String, Integer, Character>) element;
table.put(cell.getRowKey(), cell.getColumnKey(), cell.getValue());
}
return Tables.unmodifiableTable(table).cellSet();
}
}).named("unmodifiableTable[HashBasedTable].cellSet").withFeatures(CollectionSize.ANY, CollectionFeature.ALLOWS_NULL_QUERIES).createTestSuite());
suite.addTest(SetTestSuiteBuilder.using(new TestCellSetGenerator() {
@Override
RowSortedTable<String, Integer, Character> createTable() {
return Tables.unmodifiableRowSortedTable(TreeBasedTable.<String, Integer, Character>create());
}
@Override
public Set<Cell<String, Integer, Character>> create(Object... elements) {
RowSortedTable<String, Integer, Character> table = TreeBasedTable.create();
for (Object element : elements) {
@SuppressWarnings("unchecked") Cell<String, Integer, Character> cell = (Cell<String, Integer, Character>) element;
table.put(cell.getRowKey(), cell.getColumnKey(), cell.getValue());
}
return Tables.unmodifiableRowSortedTable(table).cellSet();
}
}).named("unmodifiableRowSortedTable[TreeBasedTable].cellSet").withFeatures(CollectionSize.ANY, CollectionFeature.ALLOWS_NULL_QUERIES).createTestSuite());
suite.addTest(SetTestSuiteBuilder.using(new TestStringSetGenerator() {
@Override
protected Set<String> create(String[] elements) {
Iterable<String> rowKeys = ImmutableSet.copyOf(elements);
Iterable<Integer> columnKeys = ImmutableList.of(1, 2, 3);
Table<String, Integer, Character> table = ArrayTable.create(rowKeys, columnKeys);
populateForRowKeySet(table, elements);
return table.column(1).keySet();
}
}).named("ArrayTable.column.keySet").withFeatures(CollectionSize.ONE, CollectionSize.SEVERAL, CollectionFeature.KNOWN_ORDER, CollectionFeature.ALLOWS_NULL_QUERIES).createTestSuite());
suite.addTest(SetTestSuiteBuilder.using(new TestStringSetGenerator() {
@Override
protected Set<String> create(String[] elements) {
Table<String, Integer, Character> table = HashBasedTable.create();
populateForRowKeySet(table, elements);
return table.column(1).keySet();
}
}).named("HashBasedTable.column.keySet").withFeatures(COLLECTION_FEATURES_REMOVE).createTestSuite());
suite.addTest(SetTestSuiteBuilder.using(new TestStringSetGenerator() {
@Override
protected Set<String> create(String[] elements) {
Table<String, Integer, Character> table = TreeBasedTable.create();
populateForRowKeySet(table, elements);
return table.column(1).keySet();
}
@Override
public List<String> order(List<String> insertionOrder) {
Collections.sort(insertionOrder);
return insertionOrder;
}
}).named("TreeBasedTable.column.keySet").withFeatures(COLLECTION_FEATURES_REMOVE_ORDER).createTestSuite());
suite.addTest(SetTestSuiteBuilder.using(new TestStringSetGenerator() {
@Override
protected Set<String> create(String[] elements) {
Table<String, Integer, Character> table = HashBasedTable.create();
populateForRowKeySet(table, elements);
return Tables.transformValues(table, Functions.toStringFunction()).column(1).keySet();
}
}).named("TransformValues.column.keySet").withFeatures(COLLECTION_FEATURES_REMOVE).createTestSuite());
suite.addTest(SetTestSuiteBuilder.using(new TestStringSetGenerator() {
@Override
protected Set<String> create(String[] elements) {
Table<String, Integer, Character> table = HashBasedTable.create();
populateForRowKeySet(table, elements);
return Tables.unmodifiableTable(table).column(1).keySet();
}
}).named("unmodifiableTable[HashBasedTable].column.keySet").withFeatures(COLLECTION_FEATURES).createTestSuite());
suite.addTest(SetTestSuiteBuilder.using(new TestStringSetGenerator() {
@Override
protected Set<String> create(String[] elements) {
RowSortedTable<String, Integer, Character> table = TreeBasedTable.create();
populateForRowKeySet(table, elements);
return Tables.unmodifiableRowSortedTable(table).column(1).keySet();
}
@Override
public List<String> order(List<String> insertionOrder) {
Collections.sort(insertionOrder);
return insertionOrder;
}
}).named("unmodifiableRowSortedTable[TreeBasedTable].column.keySet").withFeatures(COLLECTION_FEATURES_ORDER).createTestSuite());
return suite;
}
use of com.google.common.collect.testing.TestStringCollectionGenerator in project guava by hceylan.
the class MultimapCollectionTest method suite.
public static Test suite() {
TestSuite suite = new TestSuite();
suite.addTest(SetTestSuiteBuilder.using(new TestStringSetGenerator() {
@Override
protected Set<String> create(String[] elements) {
SetMultimap<Integer, String> multimap = HashMultimap.create();
populateMultimapForGet(multimap, elements);
return multimap.get(3);
}
}).named("HashMultimap.get").withFeatures(COLLECTION_FEATURES).createTestSuite());
suite.addTest(SetTestSuiteBuilder.using(new TestStringSetGenerator() {
@Override
protected Set<String> create(String[] elements) {
SetMultimap<Integer, String> multimap = LinkedHashMultimap.create();
populateMultimapForGet(multimap, elements);
return multimap.get(3);
}
}).named("LinkedHashMultimap.get").withFeatures(COLLECTION_FEATURES_ORDER).createTestSuite());
suite.addTest(SetTestSuiteBuilder.using(new TestStringSortedSetGenerator() {
@Override
protected SortedSet<String> create(String[] elements) {
SortedSetMultimap<Integer, String> multimap = TreeMultimap.create(Ordering.natural().nullsFirst(), Ordering.natural().nullsLast());
populateMultimapForGet(multimap, elements);
return multimap.get(3);
}
}).named("TreeMultimap.get").withFeatures(COLLECTION_FEATURES_ORDER).createTestSuite());
suite.addTest(ListTestSuiteBuilder.using(new TestStringListGenerator() {
@Override
protected List<String> create(String[] elements) {
ListMultimap<Integer, String> multimap = ArrayListMultimap.create();
populateMultimapForGet(multimap, elements);
return multimap.get(3);
}
}).named("ArrayListMultimap.get").withFeatures(LIST_FEATURES).createTestSuite());
suite.addTest(ListTestSuiteBuilder.using(new TestStringListGenerator() {
@Override
protected List<String> create(String[] elements) {
ListMultimap<Integer, String> multimap = Multimaps.synchronizedListMultimap(ArrayListMultimap.<Integer, String>create());
populateMultimapForGet(multimap, elements);
return multimap.get(3);
}
}).named("synchronized ArrayListMultimap.get").withFeatures(LIST_FEATURES).createTestSuite());
suite.addTest(ListTestSuiteBuilder.using(new TestStringListGenerator() {
@Override
protected List<String> create(String[] elements) {
ListMultimap<Integer, String> multimap = LinkedListMultimap.create();
populateMultimapForGet(multimap, elements);
return multimap.get(3);
}
}).named("LinkedListMultimap.get").withFeatures(LIST_FEATURES).createTestSuite());
suite.addTest(ListTestSuiteBuilder.using(new TestStringListGenerator() {
@Override
protected List<String> create(String[] elements) {
ImmutableListMultimap.Builder<Integer, String> builder = ImmutableListMultimap.builder();
ListMultimap<Integer, String> multimap = builder.put(2, "foo").putAll(3, elements).build();
return multimap.get(3);
}
}).named("ImmutableListMultimap.get").withFeatures(CollectionSize.ANY).createTestSuite());
suite.addTest(SetTestSuiteBuilder.using(new TestStringSetGenerator() {
@Override
protected Set<String> create(String[] elements) {
PopulatableMapAsMultimap<Integer, String> multimap = PopulatableMapAsMultimap.create();
populateMultimapForGet(multimap, elements);
return multimap.build().get(3);
}
}).named("Multimaps.forMap.get").withFeatures(FOR_MAP_FEATURES_ONE).createTestSuite());
suite.addTest(SetTestSuiteBuilder.using(new TestStringSetGenerator() {
@Override
protected Set<String> create(String[] elements) {
SetMultimap<Integer, String> multimap = LinkedHashMultimap.create();
populateMultimapForGet(multimap, elements);
multimap.put(3, "badvalue");
multimap.put(55556, "foo");
return (Set<String>) Multimaps.filterEntries(multimap, FILTER_GET_PREDICATE).get(3);
}
}).named("Multimaps.filterEntries.get").withFeatures(COLLECTION_FEATURES_ORDER).suppressing(CollectionIteratorTester.getIteratorKnownOrderRemoveSupportedMethod()).createTestSuite());
suite.addTest(SetTestSuiteBuilder.using(new TestStringSetGenerator() {
@Override
protected Set<String> create(String[] elements) {
Multimap<String, Integer> multimap = HashMultimap.create();
populateMultimapForKeySet(multimap, elements);
return multimap.keySet();
}
}).named("HashMultimap.keySet").withFeatures(COLLECTION_FEATURES_REMOVE).createTestSuite());
suite.addTest(SetTestSuiteBuilder.using(new TestStringSetGenerator() {
@Override
protected Set<String> create(String[] elements) {
Multimap<String, Integer> multimap = LinkedHashMultimap.create();
populateMultimapForKeySet(multimap, elements);
return multimap.keySet();
}
}).named("LinkedHashMultimap.keySet").withFeatures(COLLECTION_FEATURES_REMOVE_ORDER).createTestSuite());
suite.addTest(SetTestSuiteBuilder.using(new TestStringSortedSetGenerator() {
@Override
protected SortedSet<String> create(String[] elements) {
TreeMultimap<String, Integer> multimap = TreeMultimap.create(Ordering.natural().nullsFirst(), Ordering.natural().nullsLast());
populateMultimapForKeySet(multimap, elements);
return multimap.keySet();
}
}).named("TreeMultimap.keySet").withFeatures(COLLECTION_FEATURES_REMOVE_ORDER).createTestSuite());
suite.addTest(SetTestSuiteBuilder.using(new TestStringSetGenerator() {
@Override
protected Set<String> create(String[] elements) {
Multimap<String, Integer> multimap = ArrayListMultimap.create();
populateMultimapForKeySet(multimap, elements);
return multimap.keySet();
}
}).named("ArrayListMultimap.keySet").withFeatures(COLLECTION_FEATURES_REMOVE).createTestSuite());
suite.addTest(SetTestSuiteBuilder.using(new TestStringSetGenerator() {
@Override
protected Set<String> create(String[] elements) {
Multimap<String, Integer> multimap = LinkedListMultimap.create();
populateMultimapForKeySet(multimap, elements);
return multimap.keySet();
}
}).named("LinkedListMultimap.keySet").withFeatures(COLLECTION_FEATURES_REMOVE_ORDER).createTestSuite());
suite.addTest(SetTestSuiteBuilder.using(new TestStringSetGenerator() {
@Override
protected Set<String> create(String[] elements) {
ImmutableListMultimap.Builder<String, Integer> builder = ImmutableListMultimap.builder();
for (String element : elements) {
builder.put(element, 2);
builder.put(element, 3);
}
Multimap<String, Integer> multimap = builder.build();
return multimap.keySet();
}
}).named("ImmutableListMultimap.keySet").withFeatures(CollectionSize.ANY, CollectionFeature.KNOWN_ORDER).createTestSuite());
suite.addTest(SetTestSuiteBuilder.using(new TestStringSetGenerator() {
@Override
protected Set<String> create(String[] elements) {
PopulatableMapAsMultimap<String, Integer> multimap = PopulatableMapAsMultimap.create();
populateMultimapForKeySet(multimap, elements);
return multimap.build().keySet();
}
}).named("Multimaps.forMap.keySet").withFeatures(FOR_MAP_FEATURES_ANY).createTestSuite());
suite.addTest(SetTestSuiteBuilder.using(new TestStringSetGenerator() {
@Override
protected Set<String> create(String[] elements) {
SetMultimap<String, Integer> multimap = LinkedHashMultimap.create();
populateMultimapForKeySet(multimap, elements);
multimap.put("badkey", 3);
multimap.put("a", 55556);
return Multimaps.filterEntries(multimap, FILTER_KEYSET_PREDICATE).keySet();
}
}).named("Multimaps.filterEntries.keySet").withFeatures(COLLECTION_FEATURES_REMOVE_ORDER).suppressing(CollectionIteratorTester.getIteratorKnownOrderRemoveSupportedMethod()).createTestSuite());
suite.addTest(CollectionTestSuiteBuilder.using(new TestStringCollectionGenerator() {
@Override
public Collection<String> create(String[] elements) {
Multimap<Integer, String> multimap = HashMultimap.create();
populateMultimapForValues(multimap, elements);
return multimap.values();
}
}).named("HashMultimap.values").withFeatures(COLLECTION_FEATURES_REMOVE).createTestSuite());
suite.addTest(CollectionTestSuiteBuilder.using(new TestStringCollectionGenerator() {
@Override
public Collection<String> create(String[] elements) {
Multimap<Integer, String> multimap = LinkedHashMultimap.create();
populateMultimapForValues(multimap, elements);
return multimap.values();
}
}).named("LinkedHashMultimap.values").withFeatures(COLLECTION_FEATURES_REMOVE_ORDER).createTestSuite());
suite.addTest(CollectionTestSuiteBuilder.using(new TestStringCollectionGenerator() {
@Override
public Collection<String> create(String[] elements) {
Multimap<Integer, String> multimap = TreeMultimap.create(Ordering.natural().nullsFirst(), Ordering.natural().nullsLast());
populateMultimapForValues(multimap, elements);
return multimap.values();
}
}).named("TreeMultimap.values").withFeatures(COLLECTION_FEATURES_REMOVE).createTestSuite());
suite.addTest(CollectionTestSuiteBuilder.using(new TestStringCollectionGenerator() {
@Override
public Collection<String> create(String[] elements) {
Multimap<Integer, String> multimap = ArrayListMultimap.create();
populateMultimapForValues(multimap, elements);
return multimap.values();
}
}).named("ArrayListMultimap.values").withFeatures(COLLECTION_FEATURES_REMOVE).createTestSuite());
suite.addTest(ListTestSuiteBuilder.using(new TestStringListGenerator() {
@Override
public List<String> create(String[] elements) {
LinkedListMultimap<Integer, String> multimap = LinkedListMultimap.create();
populateMultimapForValues(multimap, elements);
return multimap.values();
}
}).named("LinkedListMultimap.values").withFeatures(LIST_FEATURES_REMOVE_SET).createTestSuite());
suite.addTest(CollectionTestSuiteBuilder.using(new TestStringCollectionGenerator() {
@Override
public Collection<String> create(String[] elements) {
ImmutableListMultimap.Builder<Integer, String> builder = ImmutableListMultimap.builder();
for (int i = 0; i < elements.length; i++) {
builder.put(i % 2, elements[i]);
}
return builder.build().values();
}
}).named("ImmutableListMultimap.values").withFeatures(CollectionSize.ANY).createTestSuite());
suite.addTest(CollectionTestSuiteBuilder.using(new TestStringCollectionGenerator() {
@Override
public Collection<String> create(String[] elements) {
Multimap<Integer, String> multimap = LinkedHashMultimap.create();
populateMultimapForValues(multimap, elements);
multimap.put(3, "badvalue");
multimap.put(55556, "foo");
return Multimaps.filterEntries(multimap, FILTER_GET_PREDICATE).values();
}
}).named("Multimaps.filterEntries.values").withFeatures(COLLECTION_FEATURES_REMOVE_ORDER).suppressing(CollectionIteratorTester.getIteratorKnownOrderRemoveSupportedMethod()).createTestSuite());
// TODO: use collection testers on Multimaps.forMap.values
suite.addTest(MultisetTestSuiteBuilder.using(new TestStringMultisetGenerator() {
@Override
protected Multiset<String> create(String[] elements) {
Multimap<String, Integer> multimap = HashMultimap.create();
populateMultimapForKeys(multimap, elements);
return multimap.keys();
}
}).named("HashMultimap.keys").withFeatures(COLLECTION_FEATURES_REMOVE).createTestSuite());
suite.addTest(MultisetTestSuiteBuilder.using(new TestStringMultisetGenerator() {
@Override
protected Multiset<String> create(String[] elements) {
Multimap<String, Integer> multimap = LinkedHashMultimap.create();
populateMultimapForKeys(multimap, elements);
return multimap.keys();
}
}).named("LinkedHashMultimap.keys").withFeatures(COLLECTION_FEATURES_REMOVE_ORDER).createTestSuite());
suite.addTest(MultisetTestSuiteBuilder.using(new TestStringMultisetGenerator() {
@Override
protected Multiset<String> create(String[] elements) {
Multimap<String, Integer> multimap = TreeMultimap.create(Ordering.natural().nullsFirst(), Ordering.natural().nullsLast());
populateMultimapForKeys(multimap, elements);
return multimap.keys();
}
@Override
public List<String> order(List<String> insertionOrder) {
Collections.sort(insertionOrder, Ordering.natural().nullsFirst());
return insertionOrder;
}
}).named("TreeMultimap.keys").withFeatures(COLLECTION_FEATURES_REMOVE_ORDER).createTestSuite());
suite.addTest(MultisetTestSuiteBuilder.using(new TestStringMultisetGenerator() {
@Override
protected Multiset<String> create(String[] elements) {
Multimap<String, Integer> multimap = ArrayListMultimap.create();
populateMultimapForKeys(multimap, elements);
return multimap.keys();
}
}).named("ArrayListMultimap.keys").withFeatures(COLLECTION_FEATURES_REMOVE).createTestSuite());
suite.addTest(MultisetTestSuiteBuilder.using(new TestStringMultisetGenerator() {
@Override
protected Multiset<String> create(String[] elements) {
Multimap<String, Integer> multimap = Multimaps.synchronizedListMultimap(ArrayListMultimap.<String, Integer>create());
populateMultimapForKeys(multimap, elements);
return multimap.keys();
}
}).named("synchronized ArrayListMultimap.keys").withFeatures(COLLECTION_FEATURES_REMOVE).createTestSuite());
suite.addTest(MultisetTestSuiteBuilder.using(new TestStringMultisetGenerator() {
@Override
protected Multiset<String> create(String[] elements) {
Multimap<String, Integer> multimap = LinkedListMultimap.create();
populateMultimapForKeys(multimap, elements);
return multimap.keys();
}
}).named("LinkedListMultimap.keys").withFeatures(COLLECTION_FEATURES_REMOVE_ORDER).createTestSuite());
suite.addTest(MultisetTestSuiteBuilder.using(new TestStringMultisetGenerator() {
@Override
protected Multiset<String> create(String[] elements) {
ImmutableListMultimap.Builder<String, Integer> builder = ImmutableListMultimap.builder();
for (int i = 0; i < elements.length; i++) {
builder.put(elements[i], i);
}
Multimap<String, Integer> multimap = builder.build();
return multimap.keys();
}
}).named("ImmutableListMultimap.keys").withFeatures(CollectionSize.ANY, CollectionFeature.KNOWN_ORDER).createTestSuite());
suite.addTest(MultisetTestSuiteBuilder.using(new TestStringMultisetGenerator() {
@Override
protected Multiset<String> create(String[] elements) {
PopulatableMapAsMultimap<String, Integer> multimap = PopulatableMapAsMultimap.create();
populateMultimapForKeys(multimap, elements);
return multimap.build().keys();
}
}).named("Multimaps.forMap.keys").withFeatures(FOR_MAP_FEATURES_ANY).suppressing(getReadsDuplicateInitializingMethods()).suppressing(getSetCountDuplicateInitializingMethods()).suppressing(getIteratorDuplicateInitializingMethods()).createTestSuite());
suite.addTest(MultisetTestSuiteBuilder.using(new TestStringMultisetGenerator() {
@Override
protected Multiset<String> create(String[] elements) {
SetMultimap<String, Integer> multimap = LinkedHashMultimap.create();
populateMultimapForKeys(multimap, elements);
multimap.put("badkey", 3);
multimap.put("a", 55556);
return Multimaps.filterEntries(multimap, FILTER_KEYSET_PREDICATE).keys();
}
}).named("Multimaps.filterEntries.keys").withFeatures(COLLECTION_FEATURES_REMOVE_ORDER).suppressing(CollectionIteratorTester.getIteratorKnownOrderRemoveSupportedMethod()).suppressing(MultisetWritesTester.getEntrySetIteratorMethod()).suppressing(getIteratorDuplicateInitializingMethods()).createTestSuite());
suite.addTest(CollectionTestSuiteBuilder.using(new TestEntrySetGenerator() {
@Override
SetMultimap<String, Integer> createMultimap() {
return HashMultimap.create();
}
}).named("HashMultimap.entries").withFeatures(CollectionSize.ANY, CollectionFeature.REMOVE_OPERATIONS).createTestSuite());
suite.addTest(CollectionTestSuiteBuilder.using(new TestEntrySetGenerator() {
@Override
SetMultimap<String, Integer> createMultimap() {
return LinkedHashMultimap.create();
}
}).named("LinkedHashMultimap.entries").withFeatures(CollectionSize.ANY, CollectionFeature.REMOVE_OPERATIONS, CollectionFeature.KNOWN_ORDER).createTestSuite());
suite.addTest(CollectionTestSuiteBuilder.using(new TestEntrySetGenerator() {
@Override
SetMultimap<String, Integer> createMultimap() {
return TreeMultimap.create(Ordering.natural().nullsFirst(), Ordering.natural().nullsLast());
}
}).named("TreeMultimap.entries").withFeatures(CollectionSize.ANY, CollectionFeature.REMOVE_OPERATIONS, CollectionFeature.KNOWN_ORDER).createTestSuite());
suite.addTest(CollectionTestSuiteBuilder.using(new TestEntriesGenerator() {
@Override
Multimap<String, Integer> createMultimap() {
return ArrayListMultimap.create();
}
}).named("ArrayListMultimap.entries").withFeatures(CollectionSize.ANY, CollectionFeature.REMOVE_OPERATIONS).createTestSuite());
suite.addTest(CollectionTestSuiteBuilder.using(new TestEntriesGenerator() {
@Override
Multimap<String, Integer> createMultimap() {
return Multimaps.synchronizedListMultimap(ArrayListMultimap.<String, Integer>create());
}
}).named("synchronized ArrayListMultimap.entries").withFeatures(CollectionSize.ANY, CollectionFeature.REMOVE_OPERATIONS).createTestSuite());
suite.addTest(ListTestSuiteBuilder.using(new TestEntriesListGenerator() {
@Override
Multimap<String, Integer> createMultimap() {
return LinkedListMultimap.create();
}
}).named("LinkedListMultimap.entries").withFeatures(CollectionSize.ANY, ListFeature.REMOVE_OPERATIONS, CollectionFeature.KNOWN_ORDER).createTestSuite());
suite.addTest(CollectionTestSuiteBuilder.using(new TestEntriesGenerator() {
@Override
Multimap<String, Integer> createMultimap() {
return ImmutableListMultimap.of();
}
@Override
public Collection<Entry<String, Integer>> create(Object... elements) {
ImmutableListMultimap.Builder<String, Integer> builder = ImmutableListMultimap.builder();
for (Object element : elements) {
@SuppressWarnings("unchecked") Entry<String, Integer> entry = (Entry<String, Integer>) element;
builder.put(entry.getKey(), entry.getValue());
}
return builder.build().entries();
}
}).named("ImmutableListMultimap.entries").withFeatures(CollectionSize.ANY, CollectionFeature.KNOWN_ORDER).createTestSuite());
suite.addTest(CollectionTestSuiteBuilder.using(new TestEntriesGenerator() {
@Override
Multimap<String, Integer> createMultimap() {
Multimap<String, Integer> multimap = LinkedHashMultimap.create();
multimap.put("badkey", 3);
multimap.put("a", 55556);
return Multimaps.filterEntries(multimap, FILTER_KEYSET_PREDICATE);
}
}).named("Multimap.filterEntries.entries").withFeatures(CollectionSize.ANY, CollectionFeature.REMOVE_OPERATIONS, CollectionFeature.KNOWN_ORDER).suppressing(CollectionIteratorTester.getIteratorKnownOrderRemoveSupportedMethod()).createTestSuite());
suite.addTest(ListTestSuiteBuilder.using(new TestStringListGenerator() {
@Override
protected List<String> create(String[] elements) {
ListMultimap<Integer, String> multimap = ArrayListMultimap.create();
populateMultimapForGet(multimap, elements);
return Multimaps.transformValues(multimap, Functions.<String>identity()).get(3);
}
}).named("Multimaps.transformValues[ListMultimap].get").withFeatures(CollectionSize.ANY, CollectionFeature.ALLOWS_NULL_VALUES, CollectionFeature.REMOVE_OPERATIONS, ListFeature.SUPPORTS_REMOVE_WITH_INDEX).createTestSuite());
suite.addTest(SetTestSuiteBuilder.using(new TestStringSetGenerator() {
@Override
protected Set<String> create(String[] elements) {
ListMultimap<String, Integer> multimap = ArrayListMultimap.create();
populateMultimapForKeySet(multimap, elements);
return Multimaps.transformValues(multimap, Functions.<Integer>identity()).keySet();
}
}).named("Multimaps.transformValues[ListMultimap].keySet").withFeatures(CollectionSize.ANY, CollectionFeature.ALLOWS_NULL_VALUES, CollectionFeature.REMOVE_OPERATIONS).createTestSuite());
suite.addTest(MultisetTestSuiteBuilder.using(new TestStringMultisetGenerator() {
@Override
protected Multiset<String> create(String[] elements) {
ListMultimap<String, Integer> multimap = ArrayListMultimap.create();
populateMultimapForKeys(multimap, elements);
return Multimaps.transformValues(multimap, Functions.<Integer>identity()).keys();
}
}).named("Multimaps.transform[ListMultimap].keys").withFeatures(COLLECTION_FEATURES_REMOVE).createTestSuite());
suite.addTest(CollectionTestSuiteBuilder.using(new TestStringCollectionGenerator() {
@Override
public Collection<String> create(String[] elements) {
ListMultimap<Integer, String> multimap = ArrayListMultimap.create();
populateMultimapForValues(multimap, elements);
return Multimaps.transformValues(multimap, Functions.<String>identity()).values();
}
}).named("Multimaps.transformValues[ListMultimap].values").withFeatures(COLLECTION_FEATURES_REMOVE).createTestSuite());
suite.addTest(CollectionTestSuiteBuilder.using(new TestEntriesGenerator() {
@Override
public Collection<Entry<String, Integer>> create(Object... elements) {
ListMultimap<String, Integer> multimap = ArrayListMultimap.create();
for (Object element : elements) {
@SuppressWarnings("unchecked") Entry<String, Integer> entry = (Entry<String, Integer>) element;
multimap.put(entry.getKey(), entry.getValue());
}
return Multimaps.transformValues(multimap, Functions.<Integer>identity()).entries();
}
@Override
Multimap<String, Integer> createMultimap() {
return Multimaps.transformValues(ArrayListMultimap.<String, Integer>create(), Functions.<Integer>identity());
}
}).named("Multimaps.transformValues[ListMultimap].entries").withFeatures(CollectionSize.ANY, CollectionFeature.REMOVE_OPERATIONS).createTestSuite());
suite.addTest(CollectionTestSuiteBuilder.using(new TestStringCollectionGenerator() {
@Override
protected Collection<String> create(String[] elements) {
Multimap<Integer, String> multimap = ArrayListMultimap.create();
populateMultimapForGet(multimap, elements);
return Multimaps.transformValues(multimap, Functions.<String>identity()).get(3);
}
}).named("Multimaps.transformValues[Multimap].get").withFeatures(CollectionSize.ANY, CollectionFeature.ALLOWS_NULL_VALUES, CollectionFeature.REMOVE_OPERATIONS).createTestSuite());
suite.addTest(SetTestSuiteBuilder.using(new TestStringSetGenerator() {
@Override
protected Set<String> create(String[] elements) {
Multimap<String, Integer> multimap = ArrayListMultimap.create();
populateMultimapForKeySet(multimap, elements);
return Multimaps.transformValues(multimap, Functions.<Integer>identity()).keySet();
}
}).named("Multimaps.transformValues[Multimap].keySet").withFeatures(COLLECTION_FEATURES_REMOVE).createTestSuite());
suite.addTest(MultisetTestSuiteBuilder.using(new TestStringMultisetGenerator() {
@Override
protected Multiset<String> create(String[] elements) {
Multimap<String, Integer> multimap = ArrayListMultimap.create();
populateMultimapForKeys(multimap, elements);
return Multimaps.transformValues(multimap, Functions.<Integer>identity()).keys();
}
}).named("Multimaps.transformValues[Multimap].keys").withFeatures(COLLECTION_FEATURES_REMOVE).createTestSuite());
suite.addTest(CollectionTestSuiteBuilder.using(new TestStringCollectionGenerator() {
@Override
public Collection<String> create(String[] elements) {
Multimap<Integer, String> multimap = ArrayListMultimap.create();
populateMultimapForValues(multimap, elements);
return Multimaps.transformValues(multimap, Functions.<String>identity()).values();
}
}).named("Multimaps.transformValues[Multimap].values").withFeatures(COLLECTION_FEATURES_REMOVE).createTestSuite());
suite.addTest(CollectionTestSuiteBuilder.using(new TestEntriesGenerator() {
@Override
public Collection<Entry<String, Integer>> create(Object... elements) {
Multimap<String, Integer> multimap = ArrayListMultimap.create();
for (Object element : elements) {
@SuppressWarnings("unchecked") Entry<String, Integer> entry = (Entry<String, Integer>) element;
multimap.put(entry.getKey(), entry.getValue());
}
return Multimaps.transformValues(multimap, Functions.<Integer>identity()).entries();
}
@Override
Multimap<String, Integer> createMultimap() {
return Multimaps.transformValues((Multimap<String, Integer>) ArrayListMultimap.<String, Integer>create(), Functions.<Integer>identity());
}
}).named("Multimaps.transformValues[Multimap].entries").withFeatures(CollectionSize.ANY, CollectionFeature.REMOVE_OPERATIONS).createTestSuite());
return suite;
}
use of com.google.common.collect.testing.TestStringCollectionGenerator in project guava by hceylan.
the class TableCollectionTest method suite.
@GwtIncompatible("suite")
public static Test suite() {
TestSuite suite = new TestSuite();
suite.addTestSuite(ArrayRowTests.class);
suite.addTestSuite(HashRowTests.class);
suite.addTestSuite(TreeRowTests.class);
suite.addTestSuite(TransposeRowTests.class);
suite.addTestSuite(TransformValueRowTests.class);
suite.addTestSuite(UnmodifiableHashRowTests.class);
suite.addTestSuite(UnmodifiableTreeRowTests.class);
suite.addTestSuite(ArrayColumnTests.class);
suite.addTestSuite(HashColumnTests.class);
suite.addTestSuite(TreeColumnTests.class);
suite.addTestSuite(TransposeColumnTests.class);
suite.addTestSuite(TransformValueColumnTests.class);
suite.addTestSuite(UnmodifiableHashColumnTests.class);
suite.addTestSuite(UnmodifiableTreeColumnTests.class);
suite.addTestSuite(ArrayRowMapTests.class);
suite.addTestSuite(HashRowMapTests.class);
suite.addTestSuite(TreeRowMapTests.class);
suite.addTestSuite(TreeRowMapHeadMapTests.class);
suite.addTestSuite(TreeRowMapTailMapTests.class);
suite.addTestSuite(TreeRowMapSubMapTests.class);
suite.addTestSuite(TransformValueRowMapTests.class);
suite.addTestSuite(UnmodifiableHashRowMapTests.class);
suite.addTestSuite(UnmodifiableTreeRowMapTests.class);
suite.addTestSuite(ArrayColumnMapTests.class);
suite.addTestSuite(HashColumnMapTests.class);
suite.addTestSuite(TreeColumnMapTests.class);
suite.addTestSuite(TransformValueColumnMapTests.class);
suite.addTestSuite(UnmodifiableHashColumnMapTests.class);
suite.addTestSuite(UnmodifiableTreeColumnMapTests.class);
// Not testing rowKeySet() or columnKeySet() of Table.transformValues()
// since the transformation doesn't affect the row and column key sets.
suite.addTest(SetTestSuiteBuilder.using(new TestStringSetGenerator() {
@Override
protected Set<String> create(String[] elements) {
Table<String, Integer, Character> table = ArrayTable.create(ImmutableList.copyOf(elements), ImmutableList.of(1, 2));
populateForRowKeySet(table, elements);
return table.rowKeySet();
}
}).named("ArrayTable.rowKeySet").withFeatures(CollectionSize.ONE, CollectionSize.SEVERAL, CollectionFeature.KNOWN_ORDER, CollectionFeature.REJECTS_DUPLICATES_AT_CREATION, CollectionFeature.ALLOWS_NULL_QUERIES).createTestSuite());
suite.addTest(SetTestSuiteBuilder.using(new TestStringSetGenerator() {
@Override
protected Set<String> create(String[] elements) {
Table<String, Integer, Character> table = HashBasedTable.create();
populateForRowKeySet(table, elements);
return table.rowKeySet();
}
}).named("HashBasedTable.rowKeySet").withFeatures(COLLECTION_FEATURES_REMOVE).createTestSuite());
suite.addTest(SetTestSuiteBuilder.using(new TestStringSetGenerator() {
@Override
protected Set<String> create(String[] elements) {
Table<String, Integer, Character> table = TreeBasedTable.create();
populateForRowKeySet(table, elements);
return table.rowKeySet();
}
@Override
public List<String> order(List<String> insertionOrder) {
Collections.sort(insertionOrder);
return insertionOrder;
}
}).named("TreeBasedTable.rowKeySet").withFeatures(COLLECTION_FEATURES_REMOVE_ORDER).createTestSuite());
suite.addTest(SetTestSuiteBuilder.using(new TestStringSetGenerator() {
@Override
protected Set<String> create(String[] elements) {
TreeBasedTable<String, Integer, Character> table = TreeBasedTable.create();
populateForRowKeySet(table, elements);
table.put("z", 1, 'a');
return table.rowKeySet().headSet("x");
}
@Override
public List<String> order(List<String> insertionOrder) {
Collections.sort(insertionOrder);
return insertionOrder;
}
}).named("TreeBasedTable.rowKeySet.headSet").withFeatures(COLLECTION_FEATURES_REMOVE_ORDER).createTestSuite());
suite.addTest(SetTestSuiteBuilder.using(new TestStringSetGenerator() {
@Override
protected Set<String> create(String[] elements) {
TreeBasedTable<String, Integer, Character> table = TreeBasedTable.create();
populateForRowKeySet(table, elements);
table.put("\0", 1, 'a');
return table.rowKeySet().tailSet("a");
}
@Override
public List<String> order(List<String> insertionOrder) {
Collections.sort(insertionOrder);
return insertionOrder;
}
}).named("TreeBasedTable.rowKeySet.tailSet").withFeatures(COLLECTION_FEATURES_REMOVE_ORDER).createTestSuite());
suite.addTest(SetTestSuiteBuilder.using(new TestStringSetGenerator() {
@Override
protected Set<String> create(String[] elements) {
TreeBasedTable<String, Integer, Character> table = TreeBasedTable.create();
populateForRowKeySet(table, elements);
table.put("\0", 1, 'a');
table.put("z", 1, 'a');
return table.rowKeySet().subSet("a", "x");
}
@Override
public List<String> order(List<String> insertionOrder) {
Collections.sort(insertionOrder);
return insertionOrder;
}
}).named("TreeBasedTable.rowKeySet.subSet").withFeatures(COLLECTION_FEATURES_REMOVE_ORDER).createTestSuite());
suite.addTest(SetTestSuiteBuilder.using(new TestStringSetGenerator() {
@Override
protected Set<String> create(String[] elements) {
Table<String, Integer, Character> table = HashBasedTable.create();
populateForRowKeySet(table, elements);
return Tables.unmodifiableTable(table).rowKeySet();
}
}).named("unmodifiableTable[HashBasedTable].rowKeySet").withFeatures(COLLECTION_FEATURES).createTestSuite());
suite.addTest(SetTestSuiteBuilder.using(new TestStringSetGenerator() {
@Override
protected Set<String> create(String[] elements) {
RowSortedTable<String, Integer, Character> table = TreeBasedTable.create();
populateForRowKeySet(table, elements);
return Tables.unmodifiableRowSortedTable(table).rowKeySet();
}
@Override
public List<String> order(List<String> insertionOrder) {
Collections.sort(insertionOrder);
return insertionOrder;
}
}).named("unmodifiableRowSortedTable[TreeBasedTable].rowKeySet").withFeatures(COLLECTION_FEATURES_ORDER).createTestSuite());
suite.addTest(SetTestSuiteBuilder.using(new TestStringSetGenerator() {
@Override
protected Set<String> create(String[] elements) {
Table<Integer, String, Character> table = ArrayTable.create(ImmutableList.of(1, 2), ImmutableList.copyOf(elements));
populateForColumnKeySet(table, elements);
return table.columnKeySet();
}
}).named("ArrayTable.columnKeySet").withFeatures(CollectionSize.ONE, CollectionSize.SEVERAL, CollectionFeature.KNOWN_ORDER, CollectionFeature.REJECTS_DUPLICATES_AT_CREATION, CollectionFeature.ALLOWS_NULL_QUERIES).createTestSuite());
suite.addTest(SetTestSuiteBuilder.using(new TestStringSetGenerator() {
@Override
protected Set<String> create(String[] elements) {
Table<Integer, String, Character> table = HashBasedTable.create();
populateForColumnKeySet(table, elements);
return table.columnKeySet();
}
}).named("HashBasedTable.columnKeySet").withFeatures(COLLECTION_FEATURES_REMOVE).suppressing(getIteratorUnknownOrderRemoveSupportedMethod()).createTestSuite());
suite.addTest(SetTestSuiteBuilder.using(new TestStringSetGenerator() {
@Override
protected Set<String> create(String[] elements) {
Table<Integer, String, Character> table = TreeBasedTable.create();
populateForColumnKeySet(table, elements);
return table.columnKeySet();
}
@Override
public List<String> order(List<String> insertionOrder) {
Collections.sort(insertionOrder);
return insertionOrder;
}
}).named("TreeBasedTable.columnKeySet").withFeatures(COLLECTION_FEATURES_REMOVE_ORDER).suppressing(getIteratorKnownOrderRemoveSupportedMethod()).createTestSuite());
suite.addTest(SetTestSuiteBuilder.using(new TestStringSetGenerator() {
@Override
protected Set<String> create(String[] elements) {
Table<Integer, String, Character> table = HashBasedTable.create();
populateForColumnKeySet(table, elements);
return Tables.unmodifiableTable(table).columnKeySet();
}
}).named("unmodifiableTable[HashBasedTable].columnKeySet").withFeatures(COLLECTION_FEATURES).suppressing(getIteratorUnknownOrderRemoveSupportedMethod()).createTestSuite());
suite.addTest(SetTestSuiteBuilder.using(new TestStringSetGenerator() {
@Override
protected Set<String> create(String[] elements) {
RowSortedTable<Integer, String, Character> table = TreeBasedTable.create();
populateForColumnKeySet(table, elements);
return Tables.unmodifiableRowSortedTable(table).columnKeySet();
}
@Override
public List<String> order(List<String> insertionOrder) {
Collections.sort(insertionOrder);
return insertionOrder;
}
}).named("unmodifiableRowSortedTable[TreeBasedTable].columnKeySet").withFeatures(COLLECTION_FEATURES_ORDER).suppressing(getIteratorKnownOrderRemoveSupportedMethod()).createTestSuite());
suite.addTest(CollectionTestSuiteBuilder.using(new TestStringCollectionGenerator() {
@Override
protected Collection<String> create(String[] elements) {
List<Integer> rowKeys = Lists.newArrayList();
for (int i = 0; i < elements.length; i++) {
rowKeys.add(i);
}
Table<Integer, Character, String> table = ArrayTable.create(rowKeys, ImmutableList.of('a'));
populateForValues(table, elements);
return table.values();
}
}).named("ArrayTable.values").withFeatures(CollectionSize.ONE, CollectionSize.SEVERAL, CollectionFeature.ALLOWS_NULL_VALUES, CollectionFeature.KNOWN_ORDER).createTestSuite());
suite.addTest(CollectionTestSuiteBuilder.using(new TestStringCollectionGenerator() {
@Override
protected Collection<String> create(String[] elements) {
Table<Integer, Character, String> table = HashBasedTable.create();
table.put(1, 'a', "foo");
table.clear();
populateForValues(table, elements);
return table.values();
}
}).named("HashBasedTable.values").withFeatures(COLLECTION_FEATURES_REMOVE).createTestSuite());
suite.addTest(CollectionTestSuiteBuilder.using(new TestStringCollectionGenerator() {
@Override
protected Collection<String> create(String[] elements) {
Table<Integer, Character, String> table = TreeBasedTable.create();
table.put(1, 'a', "foo");
table.clear();
populateForValues(table, elements);
return table.values();
}
}).named("TreeBasedTable.values").withFeatures(COLLECTION_FEATURES_REMOVE_ORDER).createTestSuite());
final Function<String, String> removeFirstCharacter = new Function<String, String>() {
@Override
public String apply(String input) {
return input.substring(1);
}
};
suite.addTest(CollectionTestSuiteBuilder.using(new TestStringCollectionGenerator() {
@Override
protected Collection<String> create(String[] elements) {
Table<Integer, Character, String> table = HashBasedTable.create();
for (int i = 0; i < elements.length; i++) {
table.put(i, 'a', "x" + checkNotNull(elements[i]));
}
return Tables.transformValues(table, removeFirstCharacter).values();
}
}).named("TransformValues.values").withFeatures(COLLECTION_FEATURES_REMOVE).createTestSuite());
suite.addTest(CollectionTestSuiteBuilder.using(new TestStringCollectionGenerator() {
@Override
protected Collection<String> create(String[] elements) {
Table<Integer, Character, String> table = HashBasedTable.create();
table.put(1, 'a', "foo");
table.clear();
populateForValues(table, elements);
return Tables.unmodifiableTable(table).values();
}
}).named("unmodifiableTable[HashBasedTable].values").withFeatures(COLLECTION_FEATURES).createTestSuite());
suite.addTest(CollectionTestSuiteBuilder.using(new TestStringCollectionGenerator() {
@Override
protected Collection<String> create(String[] elements) {
RowSortedTable<Integer, Character, String> table = TreeBasedTable.create();
table.put(1, 'a', "foo");
table.clear();
populateForValues(table, elements);
return Tables.unmodifiableRowSortedTable(table).values();
}
}).named("unmodifiableTable[TreeBasedTable].values").withFeatures(COLLECTION_FEATURES_ORDER).createTestSuite());
suite.addTest(SetTestSuiteBuilder.using(new TestCellSetGenerator() {
@Override
public SampleElements<Cell<String, Integer, Character>> samples() {
return new SampleElements<Cell<String, Integer, Character>>(Tables.immutableCell("bar", 1, 'a'), Tables.immutableCell("bar", 2, 'b'), Tables.immutableCell("bar", 3, (Character) null), Tables.immutableCell("bar", 4, 'b'), Tables.immutableCell("bar", 5, 'b'));
}
@Override
public Set<Cell<String, Integer, Character>> create(Object... elements) {
List<Integer> columnKeys = Lists.newArrayList();
for (Object element : elements) {
@SuppressWarnings("unchecked") Cell<String, Integer, Character> cell = (Cell<String, Integer, Character>) element;
columnKeys.add(cell.getColumnKey());
}
Table<String, Integer, Character> table = ArrayTable.create(ImmutableList.of("bar"), columnKeys);
for (Object element : elements) {
@SuppressWarnings("unchecked") Cell<String, Integer, Character> cell = (Cell<String, Integer, Character>) element;
table.put(cell.getRowKey(), cell.getColumnKey(), cell.getValue());
}
return table.cellSet();
}
@Override
Table<String, Integer, Character> createTable() {
throw new UnsupportedOperationException();
}
}).named("ArrayTable.cellSet").withFeatures(CollectionSize.ONE, CollectionSize.SEVERAL, CollectionFeature.KNOWN_ORDER, CollectionFeature.REJECTS_DUPLICATES_AT_CREATION, CollectionFeature.ALLOWS_NULL_QUERIES).createTestSuite());
suite.addTest(SetTestSuiteBuilder.using(new TestCellSetGenerator() {
@Override
Table<String, Integer, Character> createTable() {
return HashBasedTable.create();
}
}).named("HashBasedTable.cellSet").withFeatures(CollectionSize.ANY, CollectionFeature.REMOVE_OPERATIONS, CollectionFeature.ALLOWS_NULL_QUERIES).createTestSuite());
suite.addTest(SetTestSuiteBuilder.using(new TestCellSetGenerator() {
@Override
Table<String, Integer, Character> createTable() {
return TreeBasedTable.create();
}
}).named("TreeBasedTable.cellSet").withFeatures(CollectionSize.ANY, CollectionFeature.REMOVE_OPERATIONS, CollectionFeature.ALLOWS_NULL_QUERIES).createTestSuite());
suite.addTest(SetTestSuiteBuilder.using(new TestCellSetGenerator() {
@Override
Table<String, Integer, Character> createTable() {
Table<Integer, String, Character> original = TreeBasedTable.create();
return Tables.transpose(original);
}
}).named("TransposedTable.cellSet").withFeatures(CollectionSize.ANY, CollectionFeature.REMOVE_OPERATIONS, CollectionFeature.ALLOWS_NULL_QUERIES).createTestSuite());
suite.addTest(SetTestSuiteBuilder.using(new TestCellSetGenerator() {
@Override
Table<String, Integer, Character> createTable() {
return HashBasedTable.create();
}
@Override
public Set<Cell<String, Integer, Character>> create(Object... elements) {
Table<String, Integer, Character> table = createTable();
for (Object element : elements) {
@SuppressWarnings("unchecked") Cell<String, Integer, Character> cell = (Cell<String, Integer, Character>) element;
table.put(cell.getRowKey(), cell.getColumnKey(), cell.getValue());
}
return Tables.transformValues(table, Functions.<Character>identity()).cellSet();
}
}).named("TransformValues.cellSet").withFeatures(CollectionSize.ANY, CollectionFeature.ALLOWS_NULL_QUERIES, CollectionFeature.REMOVE_OPERATIONS).createTestSuite());
suite.addTest(SetTestSuiteBuilder.using(new TestCellSetGenerator() {
@Override
Table<String, Integer, Character> createTable() {
return Tables.unmodifiableTable(HashBasedTable.<String, Integer, Character>create());
}
@Override
public Set<Cell<String, Integer, Character>> create(Object... elements) {
Table<String, Integer, Character> table = HashBasedTable.create();
for (Object element : elements) {
@SuppressWarnings("unchecked") Cell<String, Integer, Character> cell = (Cell<String, Integer, Character>) element;
table.put(cell.getRowKey(), cell.getColumnKey(), cell.getValue());
}
return Tables.unmodifiableTable(table).cellSet();
}
}).named("unmodifiableTable[HashBasedTable].cellSet").withFeatures(CollectionSize.ANY, CollectionFeature.ALLOWS_NULL_QUERIES).createTestSuite());
suite.addTest(SetTestSuiteBuilder.using(new TestCellSetGenerator() {
@Override
RowSortedTable<String, Integer, Character> createTable() {
return Tables.unmodifiableRowSortedTable(TreeBasedTable.<String, Integer, Character>create());
}
@Override
public Set<Cell<String, Integer, Character>> create(Object... elements) {
RowSortedTable<String, Integer, Character> table = TreeBasedTable.create();
for (Object element : elements) {
@SuppressWarnings("unchecked") Cell<String, Integer, Character> cell = (Cell<String, Integer, Character>) element;
table.put(cell.getRowKey(), cell.getColumnKey(), cell.getValue());
}
return Tables.unmodifiableRowSortedTable(table).cellSet();
}
}).named("unmodifiableRowSortedTable[TreeBasedTable].cellSet").withFeatures(CollectionSize.ANY, CollectionFeature.ALLOWS_NULL_QUERIES).createTestSuite());
suite.addTest(SetTestSuiteBuilder.using(new TestStringSetGenerator() {
@Override
protected Set<String> create(String[] elements) {
Iterable<String> rowKeys = ImmutableSet.copyOf(elements);
Iterable<Integer> columnKeys = ImmutableList.of(1, 2, 3);
Table<String, Integer, Character> table = ArrayTable.create(rowKeys, columnKeys);
populateForRowKeySet(table, elements);
return table.column(1).keySet();
}
}).named("ArrayTable.column.keySet").withFeatures(CollectionSize.ONE, CollectionSize.SEVERAL, CollectionFeature.KNOWN_ORDER, CollectionFeature.ALLOWS_NULL_QUERIES).createTestSuite());
suite.addTest(SetTestSuiteBuilder.using(new TestStringSetGenerator() {
@Override
protected Set<String> create(String[] elements) {
Table<String, Integer, Character> table = HashBasedTable.create();
populateForRowKeySet(table, elements);
return table.column(1).keySet();
}
}).named("HashBasedTable.column.keySet").withFeatures(COLLECTION_FEATURES_REMOVE).suppressing(getIteratorUnknownOrderRemoveSupportedMethod()).createTestSuite());
suite.addTest(SetTestSuiteBuilder.using(new TestStringSetGenerator() {
@Override
protected Set<String> create(String[] elements) {
Table<String, Integer, Character> table = TreeBasedTable.create();
populateForRowKeySet(table, elements);
return table.column(1).keySet();
}
@Override
public List<String> order(List<String> insertionOrder) {
Collections.sort(insertionOrder);
return insertionOrder;
}
}).named("TreeBasedTable.column.keySet").withFeatures(COLLECTION_FEATURES_REMOVE_ORDER).suppressing(getIteratorKnownOrderRemoveSupportedMethod()).createTestSuite());
suite.addTest(SetTestSuiteBuilder.using(new TestStringSetGenerator() {
@Override
protected Set<String> create(String[] elements) {
Table<String, Integer, Character> table = HashBasedTable.create();
populateForRowKeySet(table, elements);
return Tables.transformValues(table, Functions.toStringFunction()).column(1).keySet();
}
}).named("TransformValues.column.keySet").withFeatures(COLLECTION_FEATURES_REMOVE).suppressing(getIteratorUnknownOrderRemoveSupportedMethod()).createTestSuite());
suite.addTest(SetTestSuiteBuilder.using(new TestStringSetGenerator() {
@Override
protected Set<String> create(String[] elements) {
Table<String, Integer, Character> table = HashBasedTable.create();
populateForRowKeySet(table, elements);
return Tables.unmodifiableTable(table).column(1).keySet();
}
}).named("unmodifiableTable[HashBasedTable].column.keySet").withFeatures(COLLECTION_FEATURES).suppressing(getIteratorUnknownOrderRemoveSupportedMethod()).createTestSuite());
suite.addTest(SetTestSuiteBuilder.using(new TestStringSetGenerator() {
@Override
protected Set<String> create(String[] elements) {
RowSortedTable<String, Integer, Character> table = TreeBasedTable.create();
populateForRowKeySet(table, elements);
return Tables.unmodifiableRowSortedTable(table).column(1).keySet();
}
@Override
public List<String> order(List<String> insertionOrder) {
Collections.sort(insertionOrder);
return insertionOrder;
}
}).named("unmodifiableRowSortedTable[TreeBasedTable].column.keySet").withFeatures(COLLECTION_FEATURES_ORDER).suppressing(getIteratorKnownOrderRemoveSupportedMethod()).createTestSuite());
return suite;
}
use of com.google.common.collect.testing.TestStringCollectionGenerator in project guava by hceylan.
the class ForwardingCollectionTest method suite.
public static Test suite() {
TestSuite suite = new TestSuite();
suite.addTestSuite(ForwardingCollectionTest.class);
suite.addTest(CollectionTestSuiteBuilder.using(new TestStringCollectionGenerator() {
@Override
protected Collection<String> create(String[] elements) {
return new StandardImplForwardingCollection<String>(Lists.newLinkedList(asList(elements)));
}
}).named("ForwardingCollection[LinkedList] with standard implementations").withFeatures(CollectionSize.ANY, CollectionFeature.ALLOWS_NULL_VALUES, CollectionFeature.GENERAL_PURPOSE).createTestSuite());
suite.addTest(CollectionTestSuiteBuilder.using(new TestStringCollectionGenerator() {
@Override
protected Collection<String> create(String[] elements) {
return new StandardImplForwardingCollection<String>(MinimalCollection.of(elements));
}
}).named("ForwardingCollection[MinimalCollection] with standard" + " implementations").withFeatures(CollectionSize.ANY, CollectionFeature.ALLOWS_NULL_VALUES).createTestSuite());
return suite;
}
Aggregations