Search in sources :

Example 6 with TestStringMapGenerator

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

the class TreeBasedTableTest method suite.

public static Test suite() {
    TestSuite suite = new TestSuite();
    suite.addTestSuite(TreeBasedTableTest.class);
    suite.addTestSuite(TreeRowTest.class);
    suite.addTest(MapTestSuiteBuilder.using(new TestStringMapGenerator() {

        @Override
        protected Map<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, CollectionSize.ANY).named("RowMapTestSuite").createTestSuite());
    return suite;
}
Also used : Entry(java.util.Map.Entry) TestSuite(junit.framework.TestSuite) TestStringMapGenerator(com.google.common.collect.testing.TestStringMapGenerator) Map(java.util.Map) SortedMap(java.util.SortedMap)

Example 7 with TestStringMapGenerator

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

the class ForwardingNavigableMapTest method suite.

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

        @Override
        protected Map<String, String> create(Entry<String, String>[] entries) {
            NavigableMap<String, String> map = new SafeTreeMap<String, String>();
            for (Entry<String, String> entry : entries) {
                map.put(entry.getKey(), entry.getValue());
            }
            return new StandardImplForwardingNavigableMap<String, String>(map);
        }

        @Override
        public Iterable<Entry<String, String>> order(List<Entry<String, String>> insertionOrder) {
            return sort(insertionOrder);
        }
    }).named("ForwardingNavigableMap[SafeTreeMap] with no comparator and standard " + "implementations").withFeatures(CollectionSize.ANY, CollectionFeature.KNOWN_ORDER, MapFeature.ALLOWS_NULL_VALUES, MapFeature.GENERAL_PURPOSE).createTestSuite());
    // TODO(user): add forwarding-to-ImmutableSortedMap test
    return suite;
}
Also used : Maps.immutableEntry(com.google.common.collect.Maps.immutableEntry) Entry(java.util.Map.Entry) TestSuite(junit.framework.TestSuite) NavigableMap(java.util.NavigableMap) TestStringMapGenerator(com.google.common.collect.testing.TestStringMapGenerator) NavigableMap(java.util.NavigableMap) SafeTreeMap(com.google.common.collect.testing.SafeTreeMap) Map(java.util.Map) SortedMap(java.util.SortedMap)

Example 8 with TestStringMapGenerator

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

the class ForwardingMapTest method suite.

public static Test suite() {
    TestSuite suite = new TestSuite();
    suite.addTestSuite(ForwardingMapTest.class);
    suite.addTest(MapTestSuiteBuilder.using(new TestStringMapGenerator() {

        @Override
        protected Map<String, String> create(Entry<String, String>[] entries) {
            Map<String, String> map = Maps.newLinkedHashMap();
            for (Entry<String, String> entry : entries) {
                map.put(entry.getKey(), entry.getValue());
            }
            return new StandardImplForwardingMap<String, String>(map);
        }
    }).named("ForwardingMap[LinkedHashMap] with standard implementations").withFeatures(CollectionSize.ANY, MapFeature.ALLOWS_NULL_VALUES, MapFeature.ALLOWS_NULL_KEYS, MapFeature.ALLOWS_ANY_NULL_QUERIES, MapFeature.GENERAL_PURPOSE, CollectionFeature.SUPPORTS_ITERATOR_REMOVE, CollectionFeature.KNOWN_ORDER).createTestSuite());
    suite.addTest(MapTestSuiteBuilder.using(new TestStringMapGenerator() {

        @Override
        protected Map<String, String> create(Entry<String, String>[] entries) {
            ImmutableMap.Builder<String, String> builder = ImmutableMap.builder();
            for (Entry<String, String> entry : entries) {
                builder.put(entry.getKey(), entry.getValue());
            }
            return new StandardImplForwardingMap<String, String>(builder.build());
        }
    }).named("ForwardingMap[ImmutableMap] with standard implementations").withFeatures(CollectionSize.ANY, MapFeature.REJECTS_DUPLICATES_AT_CREATION, MapFeature.ALLOWS_ANY_NULL_QUERIES, CollectionFeature.KNOWN_ORDER).createTestSuite());
    return suite;
}
Also used : Entry(java.util.Map.Entry) TestSuite(junit.framework.TestSuite) MapTestSuiteBuilder(com.google.common.collect.testing.MapTestSuiteBuilder) TestStringMapGenerator(com.google.common.collect.testing.TestStringMapGenerator) Map(java.util.Map)

Aggregations

TestStringMapGenerator (com.google.common.collect.testing.TestStringMapGenerator)8 Map (java.util.Map)8 Entry (java.util.Map.Entry)8 TestSuite (junit.framework.TestSuite)8 SafeTreeMap (com.google.common.collect.testing.SafeTreeMap)5 SortedMap (java.util.SortedMap)5 MapTestSuiteBuilder (com.google.common.collect.testing.MapTestSuiteBuilder)3 NavigableMap (java.util.NavigableMap)3 Helpers.mapEntry (com.google.common.collect.testing.Helpers.mapEntry)2 Maps.immutableEntry (com.google.common.collect.Maps.immutableEntry)1 TestStringBiMapGenerator (com.google.common.collect.testing.google.TestStringBiMapGenerator)1 HashMap (java.util.HashMap)1