diff options
Diffstat (limited to 'guava-testlib/src/com/google/common/collect/testing/TestsForSetsInJavaUtil.java')
-rw-r--r-- | guava-testlib/src/com/google/common/collect/testing/TestsForSetsInJavaUtil.java | 82 |
1 files changed, 9 insertions, 73 deletions
diff --git a/guava-testlib/src/com/google/common/collect/testing/TestsForSetsInJavaUtil.java b/guava-testlib/src/com/google/common/collect/testing/TestsForSetsInJavaUtil.java index b6484ac..4b4b924 100644 --- a/guava-testlib/src/com/google/common/collect/testing/TestsForSetsInJavaUtil.java +++ b/guava-testlib/src/com/google/common/collect/testing/TestsForSetsInJavaUtil.java @@ -19,12 +19,10 @@ package com.google.common.collect.testing; import com.google.common.collect.testing.features.CollectionFeature; import com.google.common.collect.testing.features.CollectionSize; import com.google.common.collect.testing.features.SetFeature; -import com.google.common.collect.testing.testers.CollectionIteratorTester; import junit.framework.Test; import junit.framework.TestSuite; -import java.io.Serializable; import java.lang.reflect.Method; import java.util.AbstractSet; import java.util.Collection; @@ -37,7 +35,6 @@ import java.util.LinkedHashSet; import java.util.Set; import java.util.SortedSet; import java.util.TreeSet; -import java.util.concurrent.ConcurrentSkipListSet; import java.util.concurrent.CopyOnWriteArraySet; /** @@ -66,8 +63,6 @@ public class TestsForSetsInJavaUtil { suite.addTest(testsForCheckedSet()); suite.addTest(testsForAbstractSet()); suite.addTest(testsForBadlyCollidingHashSet()); - suite.addTest(testsForConcurrentSkipListSetNatural()); - suite.addTest(testsForConcurrentSkipListSetWithComparator()); return suite; } @@ -94,8 +89,7 @@ public class TestsForSetsInJavaUtil { return Collections.emptySet(); } protected Collection<Method> suppressForCopyOnWriteArraySet() { - return Collections.singleton(CollectionIteratorTester - .getIteratorKnownOrderRemoveSupportedMethod()); + return Collections.emptySet(); } protected Collection<Method> suppressForUnmodifiableSet() { return Collections.emptySet(); @@ -106,12 +100,6 @@ public class TestsForSetsInJavaUtil { protected Collection<Method> suppressForAbstractSet() { return Collections.emptySet(); } - protected Collection<Method> suppressForConcurrentSkipListSetNatural() { - return Collections.emptySet(); - } - protected Collection<Method> suppressForConcurrentSkipListSetWithComparator() { - return Collections.emptySet(); - } public Test testsForEmptySet() { return SetTestSuiteBuilder @@ -122,7 +110,7 @@ public class TestsForSetsInJavaUtil { }) .named("emptySet") .withFeatures( - CollectionFeature.SERIALIZABLE, + CollectionFeature.NONE, CollectionSize.ZERO) .suppressing(suppressForEmptySet()) .createTestSuite(); @@ -137,7 +125,7 @@ public class TestsForSetsInJavaUtil { }) .named("singleton") .withFeatures( - CollectionFeature.SERIALIZABLE, + CollectionFeature.NONE, CollectionFeature.ALLOWS_NULL_VALUES, CollectionSize.ONE) .suppressing(suppressForSingletonSet()) @@ -154,9 +142,7 @@ public class TestsForSetsInJavaUtil { .named("HashSet") .withFeatures( SetFeature.GENERAL_PURPOSE, - CollectionFeature.SERIALIZABLE, CollectionFeature.ALLOWS_NULL_VALUES, - CollectionFeature.FAILS_FAST_ON_CONCURRENT_MODIFICATION, CollectionSize.ANY) .suppressing(suppressForHashSet()) .createTestSuite(); @@ -172,10 +158,8 @@ public class TestsForSetsInJavaUtil { .named("LinkedHashSet") .withFeatures( SetFeature.GENERAL_PURPOSE, - CollectionFeature.SERIALIZABLE, CollectionFeature.ALLOWS_NULL_VALUES, CollectionFeature.KNOWN_ORDER, - CollectionFeature.FAILS_FAST_ON_CONCURRENT_MODIFICATION, CollectionSize.ANY) .suppressing(suppressForLinkedHashSet()) .createTestSuite(); @@ -193,7 +177,6 @@ public class TestsForSetsInJavaUtil { .named("EnumSet") .withFeatures( SetFeature.GENERAL_PURPOSE, - CollectionFeature.SERIALIZABLE, CollectionFeature.KNOWN_ORDER, CollectionFeature.RESTRICTS_ELEMENTS, CollectionSize.ANY) @@ -211,9 +194,7 @@ public class TestsForSetsInJavaUtil { .named("TreeSet, natural") .withFeatures( SetFeature.GENERAL_PURPOSE, - CollectionFeature.SERIALIZABLE, CollectionFeature.KNOWN_ORDER, - CollectionFeature.FAILS_FAST_ON_CONCURRENT_MODIFICATION, CollectionSize.ANY) .suppressing(suppressForTreeSetNatural()) .createTestSuite(); @@ -232,10 +213,8 @@ public class TestsForSetsInJavaUtil { .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(); @@ -252,7 +231,6 @@ public class TestsForSetsInJavaUtil { .named("CopyOnWriteArraySet") .withFeatures( SetFeature.GENERAL_PURPOSE, - CollectionFeature.SERIALIZABLE, CollectionFeature.ALLOWS_NULL_VALUES, CollectionFeature.KNOWN_ORDER, CollectionSize.ANY) @@ -272,7 +250,6 @@ public class TestsForSetsInJavaUtil { .named("unmodifiableSet/HashSet") .withFeatures( CollectionFeature.NONE, - CollectionFeature.SERIALIZABLE, CollectionFeature.ALLOWS_NULL_VALUES, CollectionSize.ANY) .suppressing(suppressForUnmodifiableSet()) @@ -291,7 +268,6 @@ public class TestsForSetsInJavaUtil { .named("checkedSet/HashSet") .withFeatures( SetFeature.GENERAL_PURPOSE, - CollectionFeature.SERIALIZABLE, CollectionFeature.ALLOWS_NULL_VALUES, CollectionFeature.RESTRICTS_ELEMENTS, CollectionSize.ANY) @@ -341,43 +317,6 @@ public class TestsForSetsInJavaUtil { .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 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(); - } - private static String[] dedupe(String[] elements) { Set<String> tmp = new LinkedHashSet<String>(); Collections.addAll(tmp, elements); @@ -385,14 +324,11 @@ public class TestsForSetsInJavaUtil { } static <T> Comparator<T> arbitraryNullFriendlyComparator() { - return new NullFriendlyComparator<T>(); - } - - private static final class NullFriendlyComparator<T> - implements Comparator<T>, Serializable { - @Override - public int compare(T left, T right) { - return String.valueOf(left).compareTo(String.valueOf(right)); - } + return new Comparator<T>() { + @Override + public int compare(T left, T right) { + return String.valueOf(left).compareTo(String.valueOf(right)); + } + }; } } |