Example usage for com.google.common.collect.testing SampleElements SampleElements

List of usage examples for com.google.common.collect.testing SampleElements SampleElements

Introduction

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

Prototype

public SampleElements(E e0, E e1, E e2, E e3, E e4) 

Source Link

Usage

From source file:net.openhft.koloboke.collect.CharSamples.java

private static List<SampleElements<? extends Character>> all() {
    // noinspection unchecked
    return (List) Arrays.asList(
            /* if char|int t */
            new SampleElements.Chars(),
            /* endif */
            /* if char t //
            new SampleElements<Character>('b', 'a', 'c', 'd', (char) 0)
            // elif !(char t) */// w w w  .jav a2 s.com
            new SampleElements<Character>(/* const t 0 */(char) 0/* endconst */,
                    /* const t min */Character.MIN_VALUE/* endconst*/,
                    /* const t max */Character.MAX_VALUE/* endconst*/, /* const t 1 */(char) 1/* endconst */,
                    /* const t -2 */(char) -2/* endconst */
            )
    /* endif */
    );
}

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

public static TestSuite suite() {

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

        @Override/* www.  j  a va2 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;
}

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

public static TestSuite suite() {

    TestMapGenerator<String, Set<String>> generator = new TestMapGenerator<String, Set<String>>() {

        @Override/* ww  w.  j av  a2s. c o m*/
        public SampleElements<Map.Entry<String, Set<String>>> samples() {
            return new SampleElements<Map.Entry<String, Set<String>>>(
                    Helpers.mapEntry("AAA",
                            (Set<String>) new HashSet<String>(Arrays.asList(new String[] { "111", "222" }))),
                    Helpers.mapEntry("BBB",
                            (Set<String>) new HashSet<String>(Arrays.asList(new String[] { "333", "444" }))),
                    Helpers.mapEntry("CCC",
                            (Set<String>) new HashSet<String>(Arrays.asList(new String[] { "555", "666" }))),
                    Helpers.mapEntry("DDD",
                            (Set<String>) new HashSet<String>(Arrays.asList(new String[] { "777", "888" }))),
                    Helpers.mapEntry("EEE",
                            (Set<String>) new HashSet<String>(Arrays.asList(new String[] { "999", "000" }))));
        }

        @Override
        public Map<String, Set<String>> create(Object... entries) {
            Map<String, Set<String>> map = new HashSetMap<String, String>();
            for (Object o : entries) {
                @SuppressWarnings("unchecked")
                Entry<String, Set<String>> entry = (Entry<String, Set<String>>) o;
                map.put(entry.getKey(), entry.getValue());
            }
            return map;

        }

        @Override
        @SuppressWarnings("unchecked")
        public final Entry<String, Set<String>>[] createArray(int length) {
            return new Entry[length];
        }

        @Override
        public final String[] createKeyArray(int length) {
            return new String[length];
        }

        @SuppressWarnings("unchecked")
        @Override
        public final HashSet<String>[] createValueArray(int length) {
            return new HashSet[length];
        }

        /** Returns the original element list, unchanged. */
        @Override
        public Iterable<Entry<String, Set<String>>> order(List<Entry<String, Set<String>>> insertionOrder) {
            return insertionOrder;
        }
    };

    TestSuite suite = MapTestSuiteBuilder.using(generator).named("HashSetMapSuite")
            .withFeatures(MapFeature.GENERAL_PURPOSE, MapFeature.FAILS_FAST_ON_CONCURRENT_MODIFICATION,
                    MapFeature.SUPPORTS_PUT, MapFeature.SUPPORTS_REMOVE, MapFeature.ALLOWS_NULL_KEYS,
                    MapFeature.ALLOWS_NULL_VALUES, CollectionFeature.SUPPORTS_ITERATOR_REMOVE,
                    CollectionSize.ANY)
            .createTestSuite();

    return suite;
}

From source file:com.mycompany.timeseries.TimeseriesTestGenerator.java

@Override
public SampleElements<Map.Entry<Long, Object>> samples() {
    return new SampleElements<>(makeEntry(3L), makeEntry(4L), makeEntry(5L), makeEntry(6L), makeEntry(7L));
}