Java Code Examples for com.google.common.collect.testing.MapTestSuiteBuilder

The following are top voted examples for showing how to use com.google.common.collect.testing.MapTestSuiteBuilder. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: cidr-ip-trie   File: TestPatriciaTrieWithGuava.java   View source code 6 votes vote down vote up
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();
}
 
Example 2
Project: pareto4j   File: ParetoHashMapTestSuite.java   View source code 6 votes vote down vote up
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();
}
 
Example 3
Project: Chronicle-Map   File: GuavaTest.java   View source code 6 votes vote down vote up
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;
}
 
Example 4
Project: PauselessHashMap   File: PauselessHashMapGuavaTest.java   View source code 6 votes vote down vote up
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();
}
 
Example 5
Project: guava-mock   File: MultimapTestSuiteBuilder.java   View source code 5 votes vote down vote up
@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;
}
 
Example 6
Project: googles-monorepo-demo   File: MultimapTestSuiteBuilder.java   View source code 5 votes vote down vote up
@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;
}
 
Example 7
Project: boxes   File: MapBoxTest.java   View source code 5 votes vote down vote up
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();
}
 
Example 8
Project: boxes   File: BoxesMapTest.java   View source code 5 votes vote down vote up
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();
}
 
Example 9
Project: guava-libraries   File: BiMapTestSuiteBuilder.java   View source code 5 votes vote down vote up
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;
}
 
Example 10
Project: guava-libraries   File: MultimapTestSuiteBuilder.java   View source code 5 votes vote down vote up
@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;
}
 
Example 11
Project: pareto4j   File: ParetoLinkedHashMapTestSuite.java   View source code 5 votes vote down vote up
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();
}
 
Example 12
Project: guava   File: MultimapTestSuiteBuilder.java   View source code 5 votes vote down vote up
@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;
}
 
Example 13
Project: guava   File: MultimapTestSuiteBuilder.java   View source code 5 votes vote down vote up
@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;
}
 
Example 14
Project: guava-mock   File: BiMapTestSuiteBuilder.java   View source code 4 votes vote down vote up
@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;
}
 
Example 15
Project: guava-mock   File: BiMapTestSuiteBuilder.java   View source code 4 votes vote down vote up
private static Set<Feature<?>> computeCommonDerivedCollectionFeatures(
    Set<Feature<?>> mapFeatures) {
  return MapTestSuiteBuilder.computeCommonDerivedCollectionFeatures(mapFeatures);
}
 
Example 16
Project: googles-monorepo-demo   File: BiMapTestSuiteBuilder.java   View source code 4 votes vote down vote up
@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;
}
 
Example 17
Project: googles-monorepo-demo   File: BiMapTestSuiteBuilder.java   View source code 4 votes vote down vote up
private static Set<Feature<?>> computeCommonDerivedCollectionFeatures(
    Set<Feature<?>> mapFeatures) {
  return MapTestSuiteBuilder.computeCommonDerivedCollectionFeatures(mapFeatures);
}
 
Example 18
Project: guava-libraries   File: BiMapTestSuiteBuilder.java   View source code 4 votes vote down vote up
private static Set<Feature<?>> computeCommonDerivedCollectionFeatures(
    Set<Feature<?>> mapFeatures) {
  return MapTestSuiteBuilder.computeCommonDerivedCollectionFeatures(mapFeatures);
}
 
Example 19
Project: guava   File: BiMapTestSuiteBuilder.java   View source code 4 votes vote down vote up
@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;
}
 
Example 20
Project: guava   File: BiMapTestSuiteBuilder.java   View source code 4 votes vote down vote up
private static Set<Feature<?>> computeCommonDerivedCollectionFeatures(
    Set<Feature<?>> mapFeatures) {
  return MapTestSuiteBuilder.computeCommonDerivedCollectionFeatures(mapFeatures);
}
 
Example 21
Project: guava   File: BiMapTestSuiteBuilder.java   View source code 4 votes vote down vote up
@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;
}
 
Example 22
Project: guava   File: BiMapTestSuiteBuilder.java   View source code 4 votes vote down vote up
private static Set<Feature<?>> computeCommonDerivedCollectionFeatures(
    Set<Feature<?>> mapFeatures) {
  return MapTestSuiteBuilder.computeCommonDerivedCollectionFeatures(mapFeatures);
}
 
Example 23
Project: Chronicle-Map   File: GuavaTest.java   View source code 4 votes vote down vote up
private static void configureSuite(MapTestSuiteBuilder<String, String> suite) {
    suite.withFeatures(GENERAL_PURPOSE)
            .withFeatures(CollectionSize.ANY)
            .withFeatures(CollectionFeature.REMOVE_OPERATIONS)
            .withFeatures(RESTRICTS_KEYS, RESTRICTS_VALUES);
}