public Test testsForAbstractSet() { return SetTestSuiteBuilder.using( new TestStringSetGenerator() { @Override protected Set<String> create(String[] elements) { final String[] deduped = dedupe(elements); return new AbstractSet<String>() { @Override public int size() { return deduped.length; } @Override public Iterator<String> iterator() { return MinimalCollection.of(deduped).iterator(); } }; } }) .named("AbstractSet") .withFeatures( CollectionFeature.NONE, CollectionFeature.ALLOWS_NULL_VALUES, CollectionFeature.KNOWN_ORDER, // in this case, anyway CollectionSize.ANY) .suppressing(suppressForAbstractSet()) .createTestSuite(); }
public Test testsForEmptySet() { return SetTestSuiteBuilder.using( new TestStringSetGenerator() { @Override public Set<String> create(String[] elements) { return Collections.emptySet(); } }) .named("emptySet") .withFeatures(CollectionFeature.SERIALIZABLE, CollectionSize.ZERO) .suppressing(suppressForEmptySet()) .createTestSuite(); }
public Test testsForBadlyCollidingHashSet() { return SetTestSuiteBuilder.using( new TestCollidingSetGenerator() { @Override public Set<Object> create(Object... elements) { return new HashSet<Object>(MinimalCollection.of(elements)); } }) .named("badly colliding HashSet") .withFeatures( SetFeature.GENERAL_PURPOSE, CollectionFeature.ALLOWS_NULL_VALUES, CollectionSize.SEVERAL) .suppressing(suppressForHashSet()) .createTestSuite(); }
public Test testsForSingletonSet() { return SetTestSuiteBuilder.using( new TestStringSetGenerator() { @Override public Set<String> create(String[] elements) { return Collections.singleton(elements[0]); } }) .named("singleton") .withFeatures( CollectionFeature.SERIALIZABLE, CollectionFeature.ALLOWS_NULL_VALUES, CollectionSize.ONE) .suppressing(suppressForSingletonSet()) .createTestSuite(); }
public Test testsForConcurrentSkipListSetNatural() { return SetTestSuiteBuilder.using( new TestStringSortedSetGenerator() { @Override public SortedSet<String> create(String[] elements) { return new ConcurrentSkipListSet<String>(MinimalCollection.of(elements)); } }) .named("ConcurrentSkipListSet, natural") .withFeatures( SetFeature.GENERAL_PURPOSE, CollectionFeature.SERIALIZABLE, CollectionFeature.KNOWN_ORDER, CollectionSize.ANY) .suppressing(suppressForConcurrentSkipListSetNatural()) .createTestSuite(); }
public Test testsForCopyOnWriteArraySet() { return SetTestSuiteBuilder.using( new TestStringSetGenerator() { @Override public Set<String> create(String[] elements) { return new CopyOnWriteArraySet<String>(MinimalCollection.of(elements)); } }) .named("CopyOnWriteArraySet") .withFeatures( SetFeature.GENERAL_PURPOSE, CollectionFeature.SERIALIZABLE, CollectionFeature.ALLOWS_NULL_VALUES, CollectionFeature.KNOWN_ORDER, CollectionSize.ANY) .suppressing(suppressForCopyOnWriteArraySet()) .createTestSuite(); }
public Test testsForTreeSetNatural() { return SetTestSuiteBuilder.using( new TestStringSortedSetGenerator() { @Override public SortedSet<String> create(String[] elements) { return new TreeSet<String>(MinimalCollection.of(elements)); } }) .named("TreeSet, natural") .withFeatures( SetFeature.GENERAL_PURPOSE, CollectionFeature.SERIALIZABLE, CollectionFeature.KNOWN_ORDER, CollectionFeature.FAILS_FAST_ON_CONCURRENT_MODIFICATION, CollectionSize.ANY) .suppressing(suppressForTreeSetNatural()) .createTestSuite(); }
public Test testsForHashSet() { return SetTestSuiteBuilder.using( new TestStringSetGenerator() { @Override public Set<String> create(String[] elements) { return new HashSet<String>(MinimalCollection.of(elements)); } }) .named("HashSet") .withFeatures( SetFeature.GENERAL_PURPOSE, CollectionFeature.SERIALIZABLE, CollectionFeature.ALLOWS_NULL_VALUES, CollectionFeature.FAILS_FAST_ON_CONCURRENT_MODIFICATION, CollectionSize.ANY) .suppressing(suppressForHashSet()) .createTestSuite(); }
public Test testsForUnmodifiableSet() { return SetTestSuiteBuilder.using( new TestStringSetGenerator() { @Override public Set<String> create(String[] elements) { Set<String> innerSet = new HashSet<String>(); Collections.addAll(innerSet, elements); return Collections.unmodifiableSet(innerSet); } }) .named("unmodifiableSet/HashSet") .withFeatures( CollectionFeature.NONE, CollectionFeature.SERIALIZABLE, CollectionFeature.ALLOWS_NULL_VALUES, CollectionSize.ANY) .suppressing(suppressForUnmodifiableSet()) .createTestSuite(); }
public Test testsForConcurrentSkipListSetWithComparator() { return SetTestSuiteBuilder.using( new TestStringSortedSetGenerator() { @Override public SortedSet<String> create(String[] elements) { SortedSet<String> set = new ConcurrentSkipListSet<String>(arbitraryNullFriendlyComparator()); Collections.addAll(set, elements); return set; } }) .named("ConcurrentSkipListSet, with comparator") .withFeatures( SetFeature.GENERAL_PURPOSE, CollectionFeature.SERIALIZABLE, CollectionFeature.KNOWN_ORDER, CollectionSize.ANY) .suppressing(suppressForConcurrentSkipListSetWithComparator()) .createTestSuite(); }
public Test testsForCheckedSet() { return SetTestSuiteBuilder.using( new TestStringSetGenerator() { @Override public Set<String> create(String[] elements) { Set<String> innerSet = new HashSet<String>(); Collections.addAll(innerSet, elements); return Collections.checkedSet(innerSet, String.class); } }) .named("checkedSet/HashSet") .withFeatures( SetFeature.GENERAL_PURPOSE, CollectionFeature.SERIALIZABLE, CollectionFeature.ALLOWS_NULL_VALUES, CollectionFeature.RESTRICTS_ELEMENTS, CollectionSize.ANY) .suppressing(suppressForCheckedSet()) .createTestSuite(); }
public Test testsForEnumSet() { return SetTestSuiteBuilder.using( new TestEnumSetGenerator() { @Override public Set<AnEnum> create(AnEnum[] elements) { return (elements.length == 0) ? EnumSet.noneOf(AnEnum.class) : EnumSet.copyOf(MinimalCollection.of(elements)); } }) .named("EnumSet") .withFeatures( SetFeature.GENERAL_PURPOSE, CollectionFeature.SERIALIZABLE, CollectionFeature.KNOWN_ORDER, CollectionFeature.RESTRICTS_ELEMENTS, CollectionSize.ANY) .suppressing(suppressForEnumSet()) .createTestSuite(); }
public Test testsForTreeSetWithComparator() { return SetTestSuiteBuilder.using( new TestStringSortedSetGenerator() { @Override public SortedSet<String> create(String[] elements) { SortedSet<String> set = new TreeSet<String>(arbitraryNullFriendlyComparator()); Collections.addAll(set, elements); return set; } }) .named("TreeSet, with comparator") .withFeatures( SetFeature.GENERAL_PURPOSE, CollectionFeature.SERIALIZABLE, CollectionFeature.ALLOWS_NULL_VALUES, CollectionFeature.KNOWN_ORDER, CollectionFeature.FAILS_FAST_ON_CONCURRENT_MODIFICATION, CollectionSize.ANY) .suppressing(suppressForTreeSetWithComparator()) .createTestSuite(); }