Example usage for com.google.common.collect.testing.features CollectionFeature GENERAL_PURPOSE

List of usage examples for com.google.common.collect.testing.features CollectionFeature GENERAL_PURPOSE

Introduction

In this page you can find the example usage for com.google.common.collect.testing.features CollectionFeature GENERAL_PURPOSE.

Prototype

CollectionFeature GENERAL_PURPOSE

To view the source code for com.google.common.collect.testing.features CollectionFeature GENERAL_PURPOSE.

Click Source Link

Document

Features supported by general-purpose collections - everything but #RESTRICTS_ELEMENTS .

Usage

From source file:org.java0.collection.ArraySetSuite.java

public static TestSuite suite() {

    TestStringSetGenerator generator = new TestStringSetGenerator() {

        @Override/*from   w  ww. j a  v  a2s . com*/
        protected Set<String> create(String[] elements) {
            Set<String> set = new ArraySet<String>();
            set.addAll(Arrays.asList(elements));
            return set;
        }

    };

    TestSuite suite = SetTestSuiteBuilder.using(generator).named("ArraySetTest")
            .withFeatures(SetFeature.GENERAL_PURPOSE, CollectionFeature.SUPPORTS_ADD,
                    CollectionFeature.SUPPORTS_REMOVE, CollectionFeature.SUPPORTS_ITERATOR_REMOVE,
                    CollectionFeature.GENERAL_PURPOSE, CollectionSize.ANY)
            .createTestSuite();

    return suite;
}

From source file:org.java0.collection.HashRowSetSuite.java

public static TestSuite suite() {

    TestSetGenerator<Tuple> generator = new TestSetGenerator<Tuple>() {

        @Override//from w w w  . j  a  v a 2  s  .  c  o  m
        public SampleElements<Tuple> samples() {
            return new SampleElements<Tuple>(new FourTuple<>("hello", 1, true, "world"),
                    new FourTuple<>("hello1", 1, true, "world"), new FourTuple<>("hello2", 1, true, "world"),
                    new FourTuple<>("hello", 1, true, "world1"), new FourTuple<>("hello", 1, true, "world2"));
        }

        @Override
        public Tuple[] createArray(int length) {
            return new Tuple[length];
        }

        @Override
        public Iterable<Tuple> order(List<Tuple> insertionOrder) {
            return insertionOrder;
        }

        @SuppressWarnings({ "unchecked", "rawtypes" })
        @Override
        public Set<Tuple> create(Object... elements) {
            Set<Tuple> set = new HashRowSet();
            set.addAll((Collection) Arrays.asList(elements));
            return set;
        }

    };

    TestSuite suite = SetTestSuiteBuilder.using(generator).named("HashRowSetSuite")
            .withFeatures(SetFeature.GENERAL_PURPOSE, CollectionFeature.SUPPORTS_ADD,
                    CollectionFeature.SUPPORTS_REMOVE, CollectionFeature.SUPPORTS_ITERATOR_REMOVE,
                    CollectionFeature.GENERAL_PURPOSE, CollectionSize.ANY)
            .createTestSuite();

    return suite;
}