Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failures in Guava's MapTestSuiteBuilder suite #48

Open
ben-manes opened this issue Apr 29, 2017 · 0 comments
Open

Failures in Guava's MapTestSuiteBuilder suite #48

ben-manes opened this issue Apr 29, 2017 · 0 comments

Comments

@ben-manes
Copy link

ben-manes commented Apr 29, 2017

It appears that there are some small coverage mistakes that break the Map contract. Guava's testlib provides a nice way to perform a deep validation in a pluggable manner. In the following configuration there are 7 errors and 40 failures (many are duplicates at different population counts).

For example, testPutAll_nullKeyUnsupported fails due to putAll delegating to putInternal which does not perform a null key check. Instead it could delegate to any of the put(...) methods which includes it.

public final class ExpiringMapTest {

  public static Test suite() throws Exception {
    TestSuite suite = new TestSuite();
    suite.addTest(ExpiringMapTest.suite("ExpiringMap", () -> {
      return ExpiringMap.builder().build();
    }));
    return suite;
  }
  
  private static Test suite(String name, Supplier<Map<String, String>> supplier) {
    return MapTestSuiteBuilder
        .using(new TestStringMapGenerator() {
          @Override protected Map<String, String> create(Entry<String, String>[] entries) {
            Map<String, String> map = supplier.get();
            for (Entry<String, String> entry : entries) {
              map.put(entry.getKey(), entry.getValue());
            }
            return map;
          }
        })
        .named(name)
        .withFeatures(
            MapFeature.GENERAL_PURPOSE,
            MapFeature.ALLOWS_NULL_ENTRY_QUERIES,
            MapFeature.ALLOWS_NULL_VALUES,
            CollectionFeature.SUPPORTS_ITERATOR_REMOVE,
            CollectionSize.ANY)
        .createTestSuite();
  }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant