@Override
  protected List<TestSuite> createDerivedSuites(
      FeatureSpecificTestSuiteBuilder<?, ? extends OneSizeTestContainerGenerator<Collection<E>, E>>
          parentBuilder) {
    List<TestSuite> derivedSuites =
        new ArrayList<TestSuite>(super.createDerivedSuites(parentBuilder));

    derivedSuites.add(createElementSetTestSuite(parentBuilder));

    if (!parentBuilder.getFeatures().contains(NoRecurse.NO_ENTRY_SET)) {
      derivedSuites.add(
          SetTestSuiteBuilder.using(new EntrySetGenerator<E>(parentBuilder.getSubjectGenerator()))
              .named(getName() + ".entrySet")
              .withFeatures(computeEntrySetFeatures(parentBuilder.getFeatures()))
              .suppressing(parentBuilder.getSuppressedTests())
              .createTestSuite());
    }

    if (parentBuilder.getFeatures().contains(CollectionFeature.SERIALIZABLE)) {
      derivedSuites.add(
          MultisetTestSuiteBuilder.using(
                  new ReserializedMultisetGenerator<E>(parentBuilder.getSubjectGenerator()))
              .named(getName() + " reserialized")
              .withFeatures(computeReserializedMultisetFeatures(parentBuilder.getFeatures()))
              .suppressing(parentBuilder.getSuppressedTests())
              .createTestSuite());
    }
    return derivedSuites;
  }
 TestSuite computeKeysTestSuite(
     FeatureSpecificTestSuiteBuilder<
             ?, ? extends OneSizeTestContainerGenerator<M, Map.Entry<K, V>>>
         parentBuilder) {
   return MultisetTestSuiteBuilder.using(
           new KeysGenerator<K, V, M>(parentBuilder.getSubjectGenerator()))
       .withFeatures(computeKeysFeatures(parentBuilder.getFeatures()))
       .named(parentBuilder.getName() + ".keys")
       .suppressing(parentBuilder.getSuppressedTests())
       .createTestSuite();
 }
Exemplo n.º 3
0
 @GwtIncompatible // suite
 public static Test suite() {
   TestSuite suite = new TestSuite();
   suite.addTest(
       MultisetTestSuiteBuilder.using(hashMultisetGenerator())
           .withFeatures(
               CollectionSize.ANY,
               CollectionFeature.FAILS_FAST_ON_CONCURRENT_MODIFICATION,
               CollectionFeature.ALLOWS_NULL_VALUES,
               CollectionFeature.SERIALIZABLE,
               CollectionFeature.GENERAL_PURPOSE,
               MultisetFeature.ENTRIES_ARE_VIEWS)
           .named("HashMultiset")
           .createTestSuite());
   suite.addTestSuite(HashMultisetTest.class);
   return suite;
 }
  @GwtIncompatible("suite") // TODO(cpovirk): add to collect/gwt/suites
  public static Test suite() {
    TestSuite suite = new TestSuite();
    suite.addTestSuite(ImmutableMultisetTest.class);

    suite.addTest(
        MultisetTestSuiteBuilder.using(
                new TestStringMultisetGenerator() {
                  @Override
                  protected Multiset<String> create(String[] elements) {
                    return ImmutableMultiset.copyOf(elements);
                  }
                })
            .named("ImmutableMultiset")
            .withFeatures(
                CollectionSize.ANY,
                CollectionFeature.SERIALIZABLE_INCLUDING_VIEWS,
                CollectionFeature.ALLOWS_NULL_QUERIES)
            .createTestSuite());

    suite.addTest(
        SetTestSuiteBuilder.using(
                new TestStringSetGenerator() {
                  @Override
                  protected Set<String> create(String[] elements) {
                    return ImmutableMultiset.copyOf(elements).elementSet();
                  }
                })
            .named("ImmutableMultiset, element set")
            .withFeatures(
                CollectionSize.ANY,
                CollectionFeature.SERIALIZABLE,
                CollectionFeature.ALLOWS_NULL_QUERIES)
            .createTestSuite());

    suite.addTest(
        ListTestSuiteBuilder.using(
                new TestStringListGenerator() {
                  @Override
                  protected List<String> create(String[] elements) {
                    return ImmutableMultiset.copyOf(elements).asList();
                  }

                  @Override
                  public List<String> order(List<String> insertionOrder) {
                    List<String> order = new ArrayList<String>();
                    for (String s : insertionOrder) {
                      int index = order.indexOf(s);
                      if (index == -1) {
                        order.add(s);
                      } else {
                        order.add(index, s);
                      }
                    }
                    return order;
                  }
                })
            .named("ImmutableMultiset.asList")
            .withFeatures(
                CollectionSize.ANY,
                CollectionFeature.SERIALIZABLE,
                CollectionFeature.ALLOWS_NULL_QUERIES)
            .createTestSuite());

    suite.addTest(
        ListTestSuiteBuilder.using(
                new TestStringListGenerator() {
                  @Override
                  protected List<String> create(String[] elements) {
                    Set<String> set = new HashSet<String>();
                    ImmutableMultiset.Builder<String> builder = ImmutableMultiset.builder();
                    for (String s : elements) {
                      checkArgument(set.add(s));
                      builder.addCopies(s, 2);
                    }
                    ImmutableSet<String> elementSet =
                        (ImmutableSet<String>) builder.build().elementSet();
                    return elementSet.asList();
                  }
                })
            .named("ImmutableMultiset.elementSet.asList")
            .withFeatures(
                CollectionSize.ANY,
                CollectionFeature.REJECTS_DUPLICATES_AT_CREATION,
                CollectionFeature.SERIALIZABLE,
                CollectionFeature.ALLOWS_NULL_QUERIES)
            .createTestSuite());

    return suite;
  }