public Test testsForPatriciaTrie() { return MapTestSuiteBuilder .using(new TestStringMapGenerator() { @Override protected Map<String, String> create( final Entry<String, String>[] entries) { return populate(new PatriciaTrie<String>(), entries); } }) .named("PatriciaTrie") .withFeatures( MapFeature.GENERAL_PURPOSE, MapFeature.ALLOWS_NULL_ENTRY_QUERIES, MapFeature.FAILS_FAST_ON_CONCURRENT_MODIFICATION, CollectionFeature.SUPPORTS_ITERATOR_REMOVE, // Assumes Insertion Order if you don't implement SortedMap // CollectionFeature.KNOWN_ORDER, CollectionFeature.SERIALIZABLE, CollectionSize.ANY) .suppressing(suppressForPatriciaTrie()) .createTestSuite(); }
public static TestSuite suite() throws Exception { return MapTestSuiteBuilder.using(new TestStringMapGenerator() { @Override protected Map<String, String> create(Map.Entry<String, String>[] entries) { ParetoHashMap m = new ParetoHashMap(); // for (Map.Entry<String, String> entry : entries) { if (entry == null) m.put(null, null); else m.put(entry.getKey(), entry.getValue()); } return m; } } ).named("ParetoHashMap" ).withFeatures(MapFeature.GENERAL_PURPOSE, CollectionSize.ANY, MapFeature.ALLOWS_NULL_VALUES, MapFeature.ALLOWS_NULL_KEYS ).createTestSuite(); }
public static Test suite() { MapTestSuiteBuilder<String, String> chmSuite = using(new CHMTestGenerator()); configureSuite(chmSuite); TestSuite chmTests = chmSuite.named("Guava tests of Chronicle Map").createTestSuite(); MapTestSuiteBuilder<String, String> backed = using(new BackedUpMapGenerator()); configureSuite(backed); TestSuite backedTests = backed .named("Guava tests tests of Chronicle Map, backed with HashMap") .createTestSuite(); TestSuite tests = new TestSuite(); tests.addTest(chmTests); // TODO //tests.addTest(backedTests); return tests; }
public Test testsForPauselessHashMap() { return MapTestSuiteBuilder .using(new TestStringMapGenerator() { @Override protected Map<String, String> create( Map.Entry<String, String>[] entries) { return toHashMap(entries); } }) .named("HashMap") .withFeatures( MapFeature.GENERAL_PURPOSE, MapFeature.ALLOWS_NULL_KEYS, MapFeature.ALLOWS_NULL_VALUES, MapFeature.ALLOWS_ANY_NULL_QUERIES, MapFeature.FAILS_FAST_ON_CONCURRENT_MODIFICATION, CollectionFeature.SUPPORTS_ITERATOR_REMOVE, CollectionFeature.SERIALIZABLE, CollectionSize.ANY) .suppressing(suppressForHashMap()) .createTestSuite(); }
@Override protected List<TestSuite> createDerivedSuites( FeatureSpecificTestSuiteBuilder< ?, ? extends OneSizeTestContainerGenerator<M, Map.Entry<K, V>>> parentBuilder) { // TODO: Once invariant support is added, supply invariants to each of the // derived suites, to check that mutations to the derived collections are // reflected in the underlying map. List<TestSuite> derivedSuites = super.createDerivedSuites(parentBuilder); if (parentBuilder.getFeatures().contains(CollectionFeature.SERIALIZABLE)) { derivedSuites.add( MultimapTestSuiteBuilder.using( new ReserializedMultimapGenerator<K, V, M>(parentBuilder.getSubjectGenerator())) .withFeatures(computeReserializedMultimapFeatures(parentBuilder.getFeatures())) .named(parentBuilder.getName() + " reserialized") .suppressing(parentBuilder.getSuppressedTests()) .createTestSuite()); } derivedSuites.add( MapTestSuiteBuilder.using(new AsMapGenerator<K, V, M>(parentBuilder.getSubjectGenerator())) .withFeatures(computeAsMapFeatures(parentBuilder.getFeatures())) .named(parentBuilder.getName() + ".asMap") .suppressing(parentBuilder.getSuppressedTests()) .createTestSuite()); derivedSuites.add(computeEntriesTestSuite(parentBuilder)); derivedSuites.add(computeMultimapGetTestSuite(parentBuilder)); derivedSuites.add(computeMultimapAsMapGetTestSuite(parentBuilder)); derivedSuites.add(computeKeysTestSuite(parentBuilder)); derivedSuites.add(computeValuesTestSuite(parentBuilder)); return derivedSuites; }
public static TestSuite suite() { return MapTestSuiteBuilder .using(new TestStringMapGenerator() { @Override protected Map<String, String> create(Map.Entry<String, String>[] entries) { MapBox<String, String> inner = new MapBox<String, String>(MapBoxTest.class, "map").init(); for (Map.Entry<String, String> entry : entries) { if (entry != null) { inner.put(entry.getKey(), entry.getValue()); } } MapBox<String, String> outer = new MapBox<String, String>( BoxFamily.getInstance(MapBoxTest.class, "map")); outer.set(inner); return outer; } }) .named("MapBox") .withFeatures( CollectionFeature.ALLOWS_NULL_QUERIES, CollectionFeature.DESCENDING_VIEW, CollectionFeature.FAILS_FAST_ON_CONCURRENT_MODIFICATION, CollectionFeature.SUBSET_VIEW, CollectionFeature.SUPPORTS_ITERATOR_REMOVE, CollectionFeature.SUPPORTS_REMOVE, CollectionSize.ANY, MapFeature.ALLOWS_ANY_NULL_QUERIES, MapFeature.ALLOWS_NULL_KEYS, MapFeature.ALLOWS_NULL_VALUES, MapFeature.FAILS_FAST_ON_CONCURRENT_MODIFICATION, MapFeature.GENERAL_PURPOSE, MapFeature.SUPPORTS_PUT, MapFeature.SUPPORTS_REMOVE ).createTestSuite(); }
public static TestSuite suite() { return MapTestSuiteBuilder .using(new TestStringMapGenerator() { @Override protected Map<String, String> create(Map.Entry<String, String>[] entries) { BoxesMap<String, String> map = new BoxesMap<String, String>().allowBoxlessKeys(); for (Map.Entry<String, String> entry : entries) { if (entry != null) { map.put(entry.getKey(), entry.getValue()); } } return map; } }) .named("BoxesMap") .withFeatures( CollectionFeature.ALLOWS_NULL_QUERIES, CollectionFeature.DESCENDING_VIEW, CollectionFeature.FAILS_FAST_ON_CONCURRENT_MODIFICATION, CollectionFeature.SUBSET_VIEW, CollectionFeature.SUPPORTS_ITERATOR_REMOVE, CollectionFeature.SUPPORTS_REMOVE, CollectionSize.ANY, MapFeature.ALLOWS_ANY_NULL_QUERIES, MapFeature.ALLOWS_NULL_KEYS, MapFeature.ALLOWS_NULL_VALUES, MapFeature.FAILS_FAST_ON_CONCURRENT_MODIFICATION, MapFeature.GENERAL_PURPOSE, MapFeature.SUPPORTS_PUT, MapFeature.SUPPORTS_REMOVE ).createTestSuite(); }
createDerivedSuites( FeatureSpecificTestSuiteBuilder<?, ? extends OneSizeTestContainerGenerator<BiMap<K, V>, Entry<K, V>>> parentBuilder) { List<TestSuite> derived = super.createDerivedSuites(parentBuilder); // TODO(cpovirk): consider using this approach (derived suites instead of extension) in // ListTestSuiteBuilder, etc.? derived.add(MapTestSuiteBuilder .using(new MapGenerator<K, V>(parentBuilder.getSubjectGenerator())) .withFeatures(parentBuilder.getFeatures()) .named(parentBuilder.getName() + " [Map]") .suppressing(parentBuilder.getSuppressedTests()) .suppressing(SetCreationTester.class.getMethods()) // BiMap.entrySet() duplicate-handling behavior is too confusing for SetCreationTester .createTestSuite()); /* * TODO(cpovirk): the Map tests duplicate most of this effort by using a * CollectionTestSuiteBuilder on values(). It would be nice to avoid that */ derived.add(SetTestSuiteBuilder .using(new BiMapValueSetGenerator<K, V>(parentBuilder.getSubjectGenerator())) .withFeatures(computeValuesSetFeatures(parentBuilder.getFeatures())) .named(parentBuilder.getName() + " values [Set]") .suppressing(parentBuilder.getSuppressedTests()) .suppressing(SetCreationTester.class.getMethods()) // BiMap.values() duplicate-handling behavior is too confusing for SetCreationTester .createTestSuite()); if (!parentBuilder.getFeatures().contains(NoRecurse.INVERSE)) { derived.add(BiMapTestSuiteBuilder .using(new InverseBiMapGenerator<K, V>(parentBuilder.getSubjectGenerator())) .withFeatures(computeInverseFeatures(parentBuilder.getFeatures())) .named(parentBuilder.getName() + " inverse") .suppressing(parentBuilder.getSuppressedTests()) .createTestSuite()); } return derived; }
@Override protected List<TestSuite> createDerivedSuites( FeatureSpecificTestSuiteBuilder< ?, ? extends OneSizeTestContainerGenerator<M, Map.Entry<K, V>>> parentBuilder) { // TODO: Once invariant support is added, supply invariants to each of the // derived suites, to check that mutations to the derived collections are // reflected in the underlying map. List<TestSuite> derivedSuites = super.createDerivedSuites(parentBuilder); if (parentBuilder.getFeatures().contains(CollectionFeature.SERIALIZABLE)) { derivedSuites.add(MultimapTestSuiteBuilder.using( new ReserializedMultimapGenerator<K, V, M>(parentBuilder.getSubjectGenerator())) .withFeatures(computeReserializedMultimapFeatures(parentBuilder.getFeatures())) .named(parentBuilder.getName() + " reserialized") .suppressing(parentBuilder.getSuppressedTests()) .createTestSuite()); } derivedSuites.add(MapTestSuiteBuilder.using( new AsMapGenerator<K, V, M>(parentBuilder.getSubjectGenerator())) .withFeatures(computeAsMapFeatures(parentBuilder.getFeatures())) .named(parentBuilder.getName() + ".asMap") .suppressing(parentBuilder.getSuppressedTests()) .createTestSuite()); derivedSuites.add(computeEntriesTestSuite(parentBuilder)); derivedSuites.add(computeMultimapGetTestSuite(parentBuilder)); derivedSuites.add(computeMultimapAsMapGetTestSuite(parentBuilder)); derivedSuites.add(computeKeysTestSuite(parentBuilder)); derivedSuites.add(computeValuesTestSuite(parentBuilder)); return derivedSuites; }
public static TestSuite suite() throws Exception { return MapTestSuiteBuilder.using(new TestStringMapGenerator() { @Override protected Map<String, String> create(Map.Entry<String, String>[] entries) { ParetoLinkedHashMap m = new ParetoLinkedHashMap(); // for (Map.Entry<String, String> entry : entries) { m.put(entry.getKey(), entry.getValue()); } return m; } }).named("ParetoHashMap") .withFeatures(MapFeature.GENERAL_PURPOSE, CollectionSize.ANY, MapFeature.ALLOWS_NULL_KEYS, MapFeature.GENERAL_PURPOSE, MapFeature.ALLOWS_NULL_VALUES) .createTestSuite(); }
@Override protected List<TestSuite> createDerivedSuites( FeatureSpecificTestSuiteBuilder<?, ? extends OneSizeTestContainerGenerator<M, Entry<K, V>>> parentBuilder) { // TODO: Once invariant support is added, supply invariants to each of the // derived suites, to check that mutations to the derived collections are // reflected in the underlying map. List<TestSuite> derivedSuites = super.createDerivedSuites(parentBuilder); if (parentBuilder.getFeatures().contains(CollectionFeature.SERIALIZABLE)) { derivedSuites.add( MultimapTestSuiteBuilder.using( new ReserializedMultimapGenerator<K, V, M>(parentBuilder.getSubjectGenerator())) .withFeatures(computeReserializedMultimapFeatures(parentBuilder.getFeatures())) .named(parentBuilder.getName() + " reserialized") .suppressing(parentBuilder.getSuppressedTests()) .createTestSuite()); } derivedSuites.add( MapTestSuiteBuilder.using(new AsMapGenerator<K, V, M>(parentBuilder.getSubjectGenerator())) .withFeatures(computeAsMapFeatures(parentBuilder.getFeatures())) .named(parentBuilder.getName() + ".asMap") .suppressing(parentBuilder.getSuppressedTests()) .createTestSuite()); derivedSuites.add(computeEntriesTestSuite(parentBuilder)); derivedSuites.add(computeMultimapGetTestSuite(parentBuilder)); derivedSuites.add(computeMultimapAsMapGetTestSuite(parentBuilder)); derivedSuites.add(computeKeysTestSuite(parentBuilder)); derivedSuites.add(computeValuesTestSuite(parentBuilder)); return derivedSuites; }
@Override protected List<TestSuite> createDerivedSuites( FeatureSpecificTestSuiteBuilder< ?, ? extends OneSizeTestContainerGenerator<BiMap<K, V>, Entry<K, V>>> parentBuilder) { List<TestSuite> derived = super.createDerivedSuites(parentBuilder); // TODO(cpovirk): consider using this approach (derived suites instead of extension) in // ListTestSuiteBuilder, etc.? derived.add( MapTestSuiteBuilder.using(new MapGenerator<K, V>(parentBuilder.getSubjectGenerator())) .withFeatures(parentBuilder.getFeatures()) .named(parentBuilder.getName() + " [Map]") .suppressing(parentBuilder.getSuppressedTests()) .suppressing(SetCreationTester.class.getMethods()) // BiMap.entrySet() duplicate-handling behavior is too confusing for SetCreationTester .createTestSuite()); /* * TODO(cpovirk): the Map tests duplicate most of this effort by using a * CollectionTestSuiteBuilder on values(). It would be nice to avoid that */ derived.add( SetTestSuiteBuilder.using( new BiMapValueSetGenerator<K, V>(parentBuilder.getSubjectGenerator())) .withFeatures(computeValuesSetFeatures(parentBuilder.getFeatures())) .named(parentBuilder.getName() + " values [Set]") .suppressing(parentBuilder.getSuppressedTests()) .suppressing(SetCreationTester.class.getMethods()) // BiMap.values() duplicate-handling behavior is too confusing for SetCreationTester .createTestSuite()); if (!parentBuilder.getFeatures().contains(NoRecurse.INVERSE)) { derived.add( BiMapTestSuiteBuilder.using( new InverseBiMapGenerator<K, V>(parentBuilder.getSubjectGenerator())) .withFeatures(computeInverseFeatures(parentBuilder.getFeatures())) .named(parentBuilder.getName() + " inverse") .suppressing(parentBuilder.getSuppressedTests()) .createTestSuite()); } return derived; }
private static Set<Feature<?>> computeCommonDerivedCollectionFeatures( Set<Feature<?>> mapFeatures) { return MapTestSuiteBuilder.computeCommonDerivedCollectionFeatures(mapFeatures); }
private static void configureSuite(MapTestSuiteBuilder<String, String> suite) { suite.withFeatures(GENERAL_PURPOSE) .withFeatures(CollectionSize.ANY) .withFeatures(CollectionFeature.REMOVE_OPERATIONS) .withFeatures(RESTRICTS_KEYS, RESTRICTS_VALUES); }