use of com.google.common.collect.testing.SafeTreeSet in project guava by google.
the class ForwardingNavigableSetTest method suite.
public static Test suite() {
TestSuite suite = new TestSuite();
suite.addTestSuite(ForwardingNavigableSetTest.class);
suite.addTest(SetTestSuiteBuilder.using(new TestStringSetGenerator() {
@Override
protected Set<String> create(String[] elements) {
return new StandardImplForwardingNavigableSet<>(new SafeTreeSet<String>(Arrays.asList(elements)));
}
@Override
public List<String> order(List<String> insertionOrder) {
return Lists.newArrayList(Sets.newTreeSet(insertionOrder));
}
}).named("ForwardingNavigableSet[SafeTreeSet] with standard implementations").withFeatures(CollectionSize.ANY, CollectionFeature.KNOWN_ORDER, CollectionFeature.GENERAL_PURPOSE).createTestSuite());
suite.addTest(SetTestSuiteBuilder.using(new TestStringSetGenerator() {
@Override
protected Set<String> create(String[] elements) {
SafeTreeSet<String> set = new SafeTreeSet<>(Ordering.natural().nullsFirst());
Collections.addAll(set, elements);
return new StandardImplForwardingNavigableSet<>(set);
}
@Override
public List<String> order(List<String> insertionOrder) {
return Lists.newArrayList(Sets.newTreeSet(insertionOrder));
}
}).named("ForwardingNavigableSet[SafeTreeSet[Ordering.natural.nullsFirst]]" + " with standard implementations").withFeatures(CollectionSize.ANY, CollectionFeature.KNOWN_ORDER, CollectionFeature.GENERAL_PURPOSE, CollectionFeature.ALLOWS_NULL_VALUES).createTestSuite());
return suite;
}
use of com.google.common.collect.testing.SafeTreeSet in project guava by google.
the class ForwardingSortedSetTest method suite.
public static Test suite() {
TestSuite suite = new TestSuite();
suite.addTestSuite(ForwardingSortedSetTest.class);
suite.addTest(SortedSetTestSuiteBuilder.using(new TestStringSortedSetGenerator() {
@Override
protected SortedSet<String> create(String[] elements) {
return new StandardImplForwardingSortedSet<>(new SafeTreeSet<String>(Arrays.asList(elements)));
}
@Override
public List<String> order(List<String> insertionOrder) {
return Lists.newArrayList(Sets.newTreeSet(insertionOrder));
}
}).named("ForwardingSortedSet[SafeTreeSet] with standard implementations").withFeatures(CollectionSize.ANY, CollectionFeature.KNOWN_ORDER, CollectionFeature.GENERAL_PURPOSE).createTestSuite());
return suite;
}
use of com.google.common.collect.testing.SafeTreeSet in project guava by google.
the class SetsTest method suite.
// suite
@GwtIncompatible
public static Test suite() {
TestSuite suite = new TestSuite();
suite.addTestSuite(SetsTest.class);
suite.addTest(SetTestSuiteBuilder.using(new TestStringSetGenerator() {
@Override
protected Set<String> create(String[] elements) {
return Sets.newConcurrentHashSet(Arrays.asList(elements));
}
}).named("Sets.newConcurrentHashSet").withFeatures(CollectionSize.ANY, SetFeature.GENERAL_PURPOSE).createTestSuite());
suite.addTest(SetTestSuiteBuilder.using(new TestStringSetGenerator() {
@Override
protected Set<String> create(String[] elements) {
int size = elements.length;
// Remove last element, if size > 1
Set<String> set1 = (size > 1) ? Sets.newHashSet(Arrays.asList(elements).subList(0, size - 1)) : Sets.newHashSet(elements);
// Remove first element, if size > 0
Set<String> set2 = (size > 0) ? Sets.newHashSet(Arrays.asList(elements).subList(1, size)) : Sets.<String>newHashSet();
return Sets.union(set1, set2);
}
}).named("Sets.union").withFeatures(CollectionSize.ANY, CollectionFeature.ALLOWS_NULL_VALUES).createTestSuite());
suite.addTest(SetTestSuiteBuilder.using(new TestStringSetGenerator() {
@Override
protected Set<String> create(String[] elements) {
Set<String> set1 = Sets.newHashSet(elements);
set1.add(samples().e3());
Set<String> set2 = Sets.newHashSet(elements);
set2.add(samples().e4());
return Sets.intersection(set1, set2);
}
}).named("Sets.intersection").withFeatures(CollectionSize.ANY, CollectionFeature.ALLOWS_NULL_VALUES).createTestSuite());
suite.addTest(SetTestSuiteBuilder.using(new TestStringSetGenerator() {
@Override
protected Set<String> create(String[] elements) {
Set<String> set1 = Sets.newHashSet(elements);
set1.add(samples().e3());
Set<String> set2 = Sets.newHashSet(samples().e3());
return Sets.difference(set1, set2);
}
}).named("Sets.difference").withFeatures(CollectionSize.ANY, CollectionFeature.ALLOWS_NULL_VALUES).createTestSuite());
suite.addTest(SetTestSuiteBuilder.using(new TestEnumSetGenerator() {
@Override
protected Set<AnEnum> create(AnEnum[] elements) {
AnEnum[] otherElements = new AnEnum[elements.length - 1];
System.arraycopy(elements, 1, otherElements, 0, otherElements.length);
return Sets.immutableEnumSet(elements[0], otherElements);
}
}).named("Sets.immutableEnumSet").withFeatures(CollectionSize.ONE, CollectionSize.SEVERAL, CollectionFeature.ALLOWS_NULL_QUERIES).createTestSuite());
suite.addTest(NavigableSetTestSuiteBuilder.using(new TestStringSetGenerator() {
@Override
protected Set<String> create(String[] elements) {
SafeTreeSet<String> set = new SafeTreeSet<>(Arrays.asList(elements));
return Sets.unmodifiableNavigableSet(set);
}
@Override
public List<String> order(List<String> insertionOrder) {
return Ordering.natural().sortedCopy(insertionOrder);
}
}).named("Sets.unmodifiableNavigableSet[TreeSet]").withFeatures(CollectionSize.ANY, CollectionFeature.KNOWN_ORDER, CollectionFeature.SERIALIZABLE).createTestSuite());
suite.addTest(testsForFilter());
suite.addTest(testsForFilterNoNulls());
suite.addTest(testsForFilterFiltered());
return suite;
}
use of com.google.common.collect.testing.SafeTreeSet in project guava by hceylan.
the class ForwardingNavigableSetTest method suite.
public static Test suite() {
TestSuite suite = new TestSuite();
suite.addTestSuite(ForwardingNavigableSetTest.class);
suite.addTest(SetTestSuiteBuilder.using(new TestStringSetGenerator() {
@Override
protected Set<String> create(String[] elements) {
return new StandardImplForwardingNavigableSet<String>(new SafeTreeSet<String>(Arrays.asList(elements)));
}
@Override
public List<String> order(List<String> insertionOrder) {
return Lists.newArrayList(Sets.newTreeSet(insertionOrder));
}
}).named("ForwardingNavigableSet[SafeTreeSet] with standard implementations").withFeatures(CollectionSize.ANY, CollectionFeature.KNOWN_ORDER, CollectionFeature.GENERAL_PURPOSE).createTestSuite());
suite.addTest(SetTestSuiteBuilder.using(new TestStringSetGenerator() {
@Override
protected Set<String> create(String[] elements) {
SafeTreeSet<String> set = new SafeTreeSet<String>(Ordering.natural().nullsFirst());
set.addAll(Arrays.asList(elements));
return new StandardImplForwardingNavigableSet<String>(set);
}
@Override
public List<String> order(List<String> insertionOrder) {
return Lists.newArrayList(Sets.newTreeSet(insertionOrder));
}
}).named("ForwardingNavigableSet[SafeTreeSet[Ordering.natural.nullsFirst]]" + " with standard implementations").withFeatures(CollectionSize.ANY, CollectionFeature.KNOWN_ORDER, CollectionFeature.GENERAL_PURPOSE, CollectionFeature.ALLOWS_NULL_VALUES).createTestSuite());
return suite;
}
use of com.google.common.collect.testing.SafeTreeSet in project guava by hceylan.
the class ForwardingSortedSetTest method suite.
public static Test suite() {
TestSuite suite = new TestSuite();
suite.addTestSuite(ForwardingSortedSetTest.class);
suite.addTest(SetTestSuiteBuilder.using(new TestStringSetGenerator() {
@Override
protected Set<String> create(String[] elements) {
return new StandardImplForwardingSortedSet<String>(new SafeTreeSet<String>(Arrays.asList(elements)));
}
@Override
public List<String> order(List<String> insertionOrder) {
return Lists.newArrayList(Sets.newTreeSet(insertionOrder));
}
}).named("ForwardingSortedSet[SafeTreeSet] with standard implementations").withFeatures(CollectionSize.ANY, CollectionFeature.KNOWN_ORDER, CollectionFeature.GENERAL_PURPOSE).createTestSuite());
return suite;
}
Aggregations