Search in sources :

Example 1 with TestStringSortedMapGenerator

use of com.google.common.collect.testing.TestStringSortedMapGenerator in project guava by google.

the class ForwardingNavigableMapTest method suite.

public static Test suite() {
    TestSuite suite = new TestSuite();
    suite.addTestSuite(ForwardingNavigableMapTest.class);
    suite.addTest(NavigableMapTestSuiteBuilder.using(new TestStringSortedMapGenerator() {

        @Override
        protected SortedMap<String, String> create(Entry<String, String>[] entries) {
            NavigableMap<String, String> map = new SafeTreeMap<>();
            for (Entry<String, String> entry : entries) {
                map.put(entry.getKey(), entry.getValue());
            }
            return new StandardImplForwardingNavigableMap<>(map);
        }
    }).named("ForwardingNavigableMap[SafeTreeMap] with no comparator and standard " + "implementations").withFeatures(CollectionSize.ANY, CollectionFeature.KNOWN_ORDER, MapFeature.ALLOWS_NULL_VALUES, CollectionFeature.SUPPORTS_ITERATOR_REMOVE, MapFeature.GENERAL_PURPOSE).suppressing(MapEntrySetTester.getSetValueMethod(), MapEntrySetTester.getSetValueWithNullValuesAbsentMethod(), MapEntrySetTester.getSetValueWithNullValuesPresentMethod()).createTestSuite());
    // TODO(lowasser): add forwarding-to-ImmutableSortedMap test
    return suite;
}
Also used : TestSuite(junit.framework.TestSuite) SafeTreeMap(com.google.common.collect.testing.SafeTreeMap) TestStringSortedMapGenerator(com.google.common.collect.testing.TestStringSortedMapGenerator)

Example 2 with TestStringSortedMapGenerator

use of com.google.common.collect.testing.TestStringSortedMapGenerator in project guava by google.

the class MapsCollectionTest method transformSortedMapSuite.

static TestSuite transformSortedMapSuite() {
    TestSuite suite = new TestSuite("TransformSortedMap");
    suite.addTest(SortedMapTestSuiteBuilder.using(new TestStringSortedMapGenerator() {

        @Override
        protected SortedMap<String, String> create(Entry<String, String>[] entries) {
            SortedMap<String, String> map = new NonNavigableSortedMap();
            for (Entry<String, String> entry : entries) {
                map.put(entry.getKey(), encode(entry.getValue()));
            }
            return Maps.transformValues(map, DECODE_FUNCTION);
        }
    }).named("Maps.transformValues[SortedMap, Function]").withFeatures(CollectionSize.ANY, CollectionFeature.KNOWN_ORDER, MapFeature.SUPPORTS_REMOVE, CollectionFeature.SUPPORTS_ITERATOR_REMOVE).createTestSuite());
    suite.addTest(SortedMapTestSuiteBuilder.using(new TestStringSortedMapGenerator() {

        @Override
        protected SortedMap<String, String> create(Entry<String, String>[] entries) {
            SortedMap<String, String> map = new NonNavigableSortedMap();
            for (Entry<String, String> entry : entries) {
                map.put(entry.getKey(), encode(entry.getValue()));
            }
            return Maps.transformEntries(map, DECODE_ENTRY_TRANSFORMER);
        }
    }).named("Maps.transformEntries[SortedMap, EntryTransformer]").withFeatures(CollectionSize.ANY, CollectionFeature.KNOWN_ORDER, MapFeature.SUPPORTS_REMOVE, CollectionFeature.SUPPORTS_ITERATOR_REMOVE).createTestSuite());
    return suite;
}
Also used : Helpers.mapEntry(com.google.common.collect.testing.Helpers.mapEntry) Entry(java.util.Map.Entry) TestSuite(junit.framework.TestSuite) SortedMap(java.util.SortedMap) TestStringSortedMapGenerator(com.google.common.collect.testing.TestStringSortedMapGenerator)

Example 3 with TestStringSortedMapGenerator

use of com.google.common.collect.testing.TestStringSortedMapGenerator in project guava by google.

the class MapsCollectionTest method filterSortedMapSuite.

static TestSuite filterSortedMapSuite() {
    TestSuite suite = new TestSuite("FilterSortedMap");
    suite.addTest(SortedMapTestSuiteBuilder.using(new TestStringSortedMapGenerator() {

        @Override
        protected SortedMap<String, String> create(Entry<String, String>[] entries) {
            SortedMap<String, String> map = new NonNavigableSortedMap();
            putEntries(map, entries);
            map.putAll(ENTRIES_TO_FILTER);
            return Maps.filterKeys(map, FILTER_KEYS);
        }
    }).named("Maps.filterKeys[SortedMap, Predicate]").withFeatures(MapFeature.ALLOWS_NULL_VALUES, MapFeature.GENERAL_PURPOSE, CollectionSize.ANY).createTestSuite());
    suite.addTest(SortedMapTestSuiteBuilder.using(new TestStringSortedMapGenerator() {

        @Override
        protected SortedMap<String, String> create(Entry<String, String>[] entries) {
            SortedMap<String, String> map = new NonNavigableSortedMap();
            putEntries(map, entries);
            map.putAll(ENTRIES_TO_FILTER);
            return Maps.filterValues(map, FILTER_VALUES);
        }
    }).named("Maps.filterValues[SortedMap, Predicate]").withFeatures(MapFeature.ALLOWS_NULL_VALUES, MapFeature.GENERAL_PURPOSE, CollectionSize.ANY).createTestSuite());
    suite.addTest(SortedMapTestSuiteBuilder.using(new TestStringSortedMapGenerator() {

        @Override
        protected SortedMap<String, String> create(Entry<String, String>[] entries) {
            SortedMap<String, String> map = new NonNavigableSortedMap();
            putEntries(map, entries);
            map.putAll(ENTRIES_TO_FILTER);
            return Maps.filterEntries(map, FILTER_ENTRIES);
        }
    }).named("Maps.filterEntries[SortedMap, Predicate]").withFeatures(MapFeature.ALLOWS_NULL_VALUES, MapFeature.GENERAL_PURPOSE, CollectionSize.ANY).createTestSuite());
    return suite;
}
Also used : Helpers.mapEntry(com.google.common.collect.testing.Helpers.mapEntry) Entry(java.util.Map.Entry) TestSuite(junit.framework.TestSuite) SortedMap(java.util.SortedMap) TestStringSortedMapGenerator(com.google.common.collect.testing.TestStringSortedMapGenerator)

Example 4 with TestStringSortedMapGenerator

use of com.google.common.collect.testing.TestStringSortedMapGenerator in project guava by google.

the class TreeBasedTableTest method suite.

// suite
@GwtIncompatible
public static Test suite() {
    TestSuite suite = new TestSuite();
    suite.addTestSuite(TreeBasedTableTest.class);
    suite.addTestSuite(TreeRowTest.class);
    suite.addTest(SortedMapTestSuiteBuilder.using(new TestStringSortedMapGenerator() {

        @Override
        protected SortedMap<String, String> create(Entry<String, String>[] entries) {
            TreeBasedTable<String, String, String> table = TreeBasedTable.create();
            table.put("a", "b", "c");
            table.put("c", "b", "a");
            table.put("a", "a", "d");
            for (Entry<String, String> entry : entries) {
                table.put("b", entry.getKey(), entry.getValue());
            }
            return table.row("b");
        }
    }).withFeatures(MapFeature.GENERAL_PURPOSE, CollectionFeature.SUPPORTS_ITERATOR_REMOVE, CollectionSize.ANY).named("RowMapTestSuite").createTestSuite());
    return suite;
}
Also used : Entry(java.util.Map.Entry) TestSuite(junit.framework.TestSuite) SortedMap(java.util.SortedMap) TestStringSortedMapGenerator(com.google.common.collect.testing.TestStringSortedMapGenerator) GwtIncompatible(com.google.common.annotations.GwtIncompatible)

Example 5 with TestStringSortedMapGenerator

use of com.google.common.collect.testing.TestStringSortedMapGenerator in project guava by google.

the class MapsCollectionTest method filterNavigableMapSuite.

static TestSuite filterNavigableMapSuite() {
    TestSuite suite = new TestSuite("FilterNavigableMap");
    suite.addTest(NavigableMapTestSuiteBuilder.using(new TestStringSortedMapGenerator() {

        @Override
        protected NavigableMap<String, String> create(Entry<String, String>[] entries) {
            NavigableMap<String, String> map = new SafeTreeMap<>();
            putEntries(map, entries);
            map.put("banana", "toast");
            map.put("eggplant", "spam");
            return Maps.filterKeys(map, FILTER_KEYS);
        }
    }).named("Maps.filterKeys[NavigableMap, Predicate]").withFeatures(MapFeature.ALLOWS_NULL_VALUES, MapFeature.GENERAL_PURPOSE, CollectionSize.ANY).createTestSuite());
    suite.addTest(NavigableMapTestSuiteBuilder.using(new TestStringSortedMapGenerator() {

        @Override
        protected NavigableMap<String, String> create(Entry<String, String>[] entries) {
            NavigableMap<String, String> map = new SafeTreeMap<>();
            putEntries(map, entries);
            map.put("banana", "toast");
            map.put("eggplant", "spam");
            return Maps.filterValues(map, FILTER_VALUES);
        }
    }).named("Maps.filterValues[NavigableMap, Predicate]").withFeatures(MapFeature.ALLOWS_NULL_VALUES, MapFeature.GENERAL_PURPOSE, CollectionSize.ANY).createTestSuite());
    suite.addTest(NavigableMapTestSuiteBuilder.using(new TestStringSortedMapGenerator() {

        @Override
        protected NavigableMap<String, String> create(Entry<String, String>[] entries) {
            NavigableMap<String, String> map = new SafeTreeMap<>();
            putEntries(map, entries);
            map.put("banana", "toast");
            map.put("eggplant", "spam");
            return Maps.filterEntries(map, FILTER_ENTRIES);
        }
    }).named("Maps.filterEntries[NavigableMap, Predicate]").withFeatures(MapFeature.ALLOWS_NULL_VALUES, MapFeature.GENERAL_PURPOSE, CollectionSize.ANY).createTestSuite());
    return suite;
}
Also used : Helpers.mapEntry(com.google.common.collect.testing.Helpers.mapEntry) Entry(java.util.Map.Entry) TestSuite(junit.framework.TestSuite) NavigableMap(java.util.NavigableMap) TestStringSortedMapGenerator(com.google.common.collect.testing.TestStringSortedMapGenerator)

Aggregations

TestStringSortedMapGenerator (com.google.common.collect.testing.TestStringSortedMapGenerator)9 TestSuite (junit.framework.TestSuite)9 Entry (java.util.Map.Entry)8 SortedMap (java.util.SortedMap)6 Helpers.mapEntry (com.google.common.collect.testing.Helpers.mapEntry)5 NavigableMap (java.util.NavigableMap)4 SafeTreeMap (com.google.common.collect.testing.SafeTreeMap)2 GwtIncompatible (com.google.common.annotations.GwtIncompatible)1 Function (com.google.common.base.Function)1 SynchronizedNavigableMap (com.google.common.collect.Synchronized.SynchronizedNavigableMap)1 SynchronizedSortedMap (com.google.common.collect.Synchronized.SynchronizedSortedMap)1 SampleElements (com.google.common.collect.testing.SampleElements)1 SortedMapTestSuiteBuilder (com.google.common.collect.testing.SortedMapTestSuiteBuilder)1 TestStringBiMapGenerator (com.google.common.collect.testing.google.TestStringBiMapGenerator)1 Comparator (java.util.Comparator)1 Map (java.util.Map)1 NavigableSet (java.util.NavigableSet)1 Set (java.util.Set)1 SortedSet (java.util.SortedSet)1