Example usage for com.google.common.collect.testing SetTestSuiteBuilder using

List of usage examples for com.google.common.collect.testing SetTestSuiteBuilder using

Introduction

In this page you can find the example usage for com.google.common.collect.testing SetTestSuiteBuilder using.

Prototype

public static <E> SetTestSuiteBuilder<E> using(TestSetGenerator<E> generator) 

Source Link

Usage

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

public static TestSuite suite() {

    TestStringSetGenerator generator = new TestStringSetGenerator() {

        @Override/*from w  w  w .  j a v  a 2s  .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//w w  w  .  j  a v a  2  s .co 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;
}