Java Code Examples for com.google.common.collect.testing.TestStringSetGenerator

The following are top voted examples for showing how to use com.google.common.collect.testing.TestStringSetGenerator. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: guava-mock   File: SynchronizedSetTest.java   Source Code and License 6 votes vote down vote up
public static Test suite() {
  return SetTestSuiteBuilder.using(
          new TestStringSetGenerator() {
            @Override
            protected Set<String> create(String[] elements) {
              TestSet<String> inner = new TestSet<String>(new HashSet<String>(), null);
              Set<String> outer = Synchronized.set(inner, null);
              inner.mutex = outer;
              Collections.addAll(outer, elements);
              return outer;
            }
          })
      .named("Synchronized.set")
      .withFeatures(
          CollectionFeature.GENERAL_PURPOSE,
          CollectionFeature.ALLOWS_NULL_VALUES,
          CollectionSize.ANY,
          CollectionFeature.SERIALIZABLE)
      .createTestSuite();
}
 
Example 2
Project: guava-mock   File: SetsTest.java   Source Code and License 6 votes vote down vote up
@GwtIncompatible // suite
private static Test testsForFilter() {
  return SetTestSuiteBuilder.using(new TestStringSetGenerator() {
        @Override public Set<String> create(String[] elements) {
          Set<String> unfiltered = Sets.newLinkedHashSet();
          unfiltered.add("yyy");
          Collections.addAll(unfiltered, elements);
          unfiltered.add("zzz");
          return Sets.filter(unfiltered, Collections2Test.NOT_YYY_ZZZ);
        }
      })
      .named("Sets.filter")
      .withFeatures(
          CollectionFeature.SUPPORTS_ADD,
          CollectionFeature.SUPPORTS_REMOVE,
          CollectionFeature.ALLOWS_NULL_VALUES,
          CollectionFeature.KNOWN_ORDER,
          CollectionSize.ANY)
      .createTestSuite();
}
 
Example 3
Project: guava-mock   File: SetsTest.java   Source Code and License 6 votes vote down vote up
@GwtIncompatible // suite
private static Test testsForFilterFiltered() {
  return SetTestSuiteBuilder.using(new TestStringSetGenerator() {
        @Override public Set<String> create(String[] elements) {
          Set<String> unfiltered = Sets.newLinkedHashSet();
          unfiltered.add("yyy");
          unfiltered.addAll(ImmutableList.copyOf(elements));
          unfiltered.add("zzz");
          unfiltered.add("abc");
          return Sets.filter(
              Sets.filter(unfiltered, Collections2Test.LENGTH_1),
              Collections2Test.NOT_YYY_ZZZ);
        }
      })
      .named("Sets.filter, filtered input")
      .withFeatures(
          CollectionFeature.SUPPORTS_ADD,
          CollectionFeature.SUPPORTS_REMOVE,
          CollectionFeature.KNOWN_ORDER,
          CollectionSize.ANY,
          CollectionFeature.ALLOWS_NULL_QUERIES)
      .createTestSuite();
}
 
Example 4
Project: googles-monorepo-demo   File: SynchronizedSetTest.java   Source Code and License 6 votes vote down vote up
public static Test suite() {
  return SetTestSuiteBuilder.using(
          new TestStringSetGenerator() {
            @Override
            protected Set<String> create(String[] elements) {
              TestSet<String> inner = new TestSet<String>(new HashSet<String>(), null);
              Set<String> outer = Synchronized.set(inner, null);
              inner.mutex = outer;
              Collections.addAll(outer, elements);
              return outer;
            }
          })
      .named("Synchronized.set")
      .withFeatures(
          CollectionFeature.GENERAL_PURPOSE,
          CollectionFeature.ALLOWS_NULL_VALUES,
          CollectionSize.ANY,
          CollectionFeature.SERIALIZABLE)
      .createTestSuite();
}
 
Example 5
Project: googles-monorepo-demo   File: SetsTest.java   Source Code and License 6 votes vote down vote up
@GwtIncompatible // suite
private static Test testsForFilter() {
  return SetTestSuiteBuilder.using(new TestStringSetGenerator() {
        @Override public Set<String> create(String[] elements) {
          Set<String> unfiltered = Sets.newLinkedHashSet();
          unfiltered.add("yyy");
          Collections.addAll(unfiltered, elements);
          unfiltered.add("zzz");
          return Sets.filter(unfiltered, Collections2Test.NOT_YYY_ZZZ);
        }
      })
      .named("Sets.filter")
      .withFeatures(
          CollectionFeature.SUPPORTS_ADD,
          CollectionFeature.SUPPORTS_REMOVE,
          CollectionFeature.ALLOWS_NULL_VALUES,
          CollectionFeature.KNOWN_ORDER,
          CollectionSize.ANY)
      .createTestSuite();
}
 
Example 6
Project: googles-monorepo-demo   File: SetsTest.java   Source Code and License 6 votes vote down vote up
@GwtIncompatible // suite
private static Test testsForFilterFiltered() {
  return SetTestSuiteBuilder.using(new TestStringSetGenerator() {
        @Override public Set<String> create(String[] elements) {
          Set<String> unfiltered = Sets.newLinkedHashSet();
          unfiltered.add("yyy");
          unfiltered.addAll(ImmutableList.copyOf(elements));
          unfiltered.add("zzz");
          unfiltered.add("abc");
          return Sets.filter(
              Sets.filter(unfiltered, Collections2Test.LENGTH_1),
              Collections2Test.NOT_YYY_ZZZ);
        }
      })
      .named("Sets.filter, filtered input")
      .withFeatures(
          CollectionFeature.SUPPORTS_ADD,
          CollectionFeature.SUPPORTS_REMOVE,
          CollectionFeature.KNOWN_ORDER,
          CollectionSize.ANY,
          CollectionFeature.ALLOWS_NULL_QUERIES)
      .createTestSuite();
}
 
Example 7
Project: guava-libraries   File: SynchronizedSetTest.java   Source Code and License 6 votes vote down vote up
public static Test suite() {
  return SetTestSuiteBuilder.using(new TestStringSetGenerator() {
        @Override
        protected Set<String> create(String[] elements) {
          TestSet<String> inner = new TestSet<String>(new HashSet<String>(), MUTEX);
          Set<String> outer = Synchronized.set(inner, inner.mutex);
          Collections.addAll(outer, elements);
          return outer;
        }
      })
      .named("Synchronized.set")
      .withFeatures(CollectionFeature.GENERAL_PURPOSE,
          CollectionFeature.ALLOWS_NULL_VALUES,
          CollectionSize.ANY,
          CollectionFeature.SERIALIZABLE)
      .createTestSuite();
}
 
Example 8
Project: guava-libraries   File: SetsTest.java   Source Code and License 6 votes vote down vote up
@GwtIncompatible("suite")
private static Test testsForFilter() {
  return SetTestSuiteBuilder.using(new TestStringSetGenerator() {
        @Override public Set<String> create(String[] elements) {
          Set<String> unfiltered = Sets.newLinkedHashSet();
          unfiltered.add("yyy");
          Collections.addAll(unfiltered, elements);
          unfiltered.add("zzz");
          return Sets.filter(unfiltered, Collections2Test.NOT_YYY_ZZZ);
        }
      })
      .named("Sets.filter")
      .withFeatures(
          CollectionFeature.SUPPORTS_ADD,
          CollectionFeature.SUPPORTS_REMOVE,
          CollectionFeature.ALLOWS_NULL_VALUES,
          CollectionFeature.KNOWN_ORDER,
          CollectionSize.ANY)
      .createTestSuite();
}
 
Example 9
Project: guava-libraries   File: SetsTest.java   Source Code and License 6 votes vote down vote up
@GwtIncompatible("suite")
private static Test testsForFilterFiltered() {
  return SetTestSuiteBuilder.using(new TestStringSetGenerator() {
        @Override public Set<String> create(String[] elements) {
          Set<String> unfiltered = Sets.newLinkedHashSet();
          unfiltered.add("yyy");
          unfiltered.addAll(ImmutableList.copyOf(elements));
          unfiltered.add("zzz");
          unfiltered.add("abc");
          return Sets.filter(
              Sets.filter(unfiltered, Collections2Test.LENGTH_1),
              Collections2Test.NOT_YYY_ZZZ);
        }
      })
      .named("Sets.filter, filtered input")
      .withFeatures(
          CollectionFeature.SUPPORTS_ADD,
          CollectionFeature.SUPPORTS_REMOVE,
          CollectionFeature.KNOWN_ORDER,
          CollectionSize.ANY,
          CollectionFeature.ALLOWS_NULL_QUERIES)
      .createTestSuite();
}
 
Example 10
Project: NetworkParser   File: GuavaTest.java   Source Code and License 6 votes vote down vote up
public Test testsForHashSet() {
	    return SetTestSuiteBuilder
	        .using(new TestStringSetGenerator() {
	            @SuppressWarnings("unchecked")
				@Override public Set<String> create(String[] elements) {
	              Set<String> list = new HashSet<String>();
	              list.addAll(MinimalCollection.of(elements));
	              return list;
	            }
	          })
	        .named("HashSet")
	        .withFeatures(
	            SetFeature.GENERAL_PURPOSE,
	            CollectionFeature.FAILS_FAST_ON_CONCURRENT_MODIFICATION,
	            CollectionSize.ANY)
	        .suppressing(suppressForHashSet())
	        .createTestSuite();
//        CollectionFeature.ALLOWS_NULL_VALUES,
//	    CollectionFeature.SERIALIZABLE,
	  }
 
Example 11
Project: NetworkParser   File: GuavaTest.java   Source Code and License 6 votes vote down vote up
public Test testsForSimpleList() {
	    return SetTestSuiteBuilder
	        .using(new TestStringSetGenerator() {
	            @SuppressWarnings("unchecked")
				@Override public Set<String> create(String[] elements) {
//	              return (Set<String>) new HashSet<String>();
	            	return (Set<String>) new SimpleSet<String>().withList(MinimalCollection.of(elements));
	            }
	          })
	        .named("SimpleList")
	        .withFeatures(
	            SetFeature.GENERAL_PURPOSE,
	            CollectionFeature.FAILS_FAST_ON_CONCURRENT_MODIFICATION,
	            CollectionSize.ANY)
	        .suppressing(suppressForHashSet())
	        .createTestSuite();
//        CollectionFeature.ALLOWS_NULL_VALUES,
//	    CollectionFeature.SERIALIZABLE,
	  }
 
Example 12
Project: pareto4j   File: ParetoHashSetTestSuite.java   Source Code and License 6 votes vote down vote up
public static TestSuite suite() throws Exception {
    return SetTestSuiteBuilder.using(new TestStringSetGenerator() {

        @Override
        protected Set<String> create(String[] elements) {
            ParetoHashSet s = new ParetoHashSet();
            for (String element : elements) {
                s.add(element);
            }
            return s;
        }
    })
            .named("ParetoHashSetTestSuite")
            .withFeatures(SetFeature.GENERAL_PURPOSE, CollectionSize.ANY, CollectionFeature.ALLOWS_NULL_VALUES,
                    CollectionFeature.ALLOWS_NULL_QUERIES, CollectionFeature.REMOVE_OPERATIONS,
                    CollectionFeature.SERIALIZABLE)
            .createTestSuite();
}
 
Example 13
Project: guava   File: SynchronizedSetTest.java   Source Code and License 6 votes vote down vote up
public static Test suite() {
  return SetTestSuiteBuilder.using(
          new TestStringSetGenerator() {
            @Override
            protected Set<String> create(String[] elements) {
              TestSet<String> inner = new TestSet<>(new HashSet<String>(), MUTEX);
              Set<String> outer = Synchronized.set(inner, inner.mutex);
              Collections.addAll(outer, elements);
              return outer;
            }
          })
      .named("Synchronized.set")
      .withFeatures(
          CollectionFeature.GENERAL_PURPOSE,
          CollectionFeature.ALLOWS_NULL_VALUES,
          CollectionSize.ANY,
          CollectionFeature.SERIALIZABLE)
      .createTestSuite();
}
 
Example 14
Project: guava   File: SetsTest.java   Source Code and License 6 votes vote down vote up
@GwtIncompatible // suite
private static Test testsForFilter() {
  return SetTestSuiteBuilder.using(
          new TestStringSetGenerator() {
            @Override
            public Set<String> create(String[] elements) {
              Set<String> unfiltered = Sets.newLinkedHashSet();
              unfiltered.add("yyy");
              Collections.addAll(unfiltered, elements);
              unfiltered.add("zzz");
              return Sets.filter(unfiltered, Collections2Test.NOT_YYY_ZZZ);
            }
          })
      .named("Sets.filter")
      .withFeatures(
          CollectionFeature.SUPPORTS_ADD,
          CollectionFeature.SUPPORTS_REMOVE,
          CollectionFeature.ALLOWS_NULL_VALUES,
          CollectionFeature.KNOWN_ORDER,
          CollectionSize.ANY)
      .createTestSuite();
}
 
Example 15
Project: guava   File: SetsTest.java   Source Code and License 6 votes vote down vote up
@GwtIncompatible // suite
private static Test testsForFilterFiltered() {
  return SetTestSuiteBuilder.using(
          new TestStringSetGenerator() {
            @Override
            public Set<String> create(String[] elements) {
              Set<String> unfiltered = Sets.newLinkedHashSet();
              unfiltered.add("yyy");
              unfiltered.addAll(ImmutableList.copyOf(elements));
              unfiltered.add("zzz");
              unfiltered.add("abc");
              return Sets.filter(
                  Sets.filter(unfiltered, Collections2Test.LENGTH_1),
                  Collections2Test.NOT_YYY_ZZZ);
            }
          })
      .named("Sets.filter, filtered input")
      .withFeatures(
          CollectionFeature.SUPPORTS_ADD,
          CollectionFeature.SUPPORTS_REMOVE,
          CollectionFeature.KNOWN_ORDER,
          CollectionSize.ANY,
          CollectionFeature.ALLOWS_NULL_QUERIES)
      .createTestSuite();
}
 
Example 16
Project: guava   File: SynchronizedSetTest.java   Source Code and License 6 votes vote down vote up
public static Test suite() {
  return SetTestSuiteBuilder.using(
          new TestStringSetGenerator() {
            @Override
            protected Set<String> create(String[] elements) {
              TestSet<String> inner = new TestSet<>(new HashSet<String>(), null);
              Set<String> outer = Synchronized.set(inner, null);
              inner.mutex = outer;
              Collections.addAll(outer, elements);
              return outer;
            }
          })
      .named("Synchronized.set")
      .withFeatures(
          CollectionFeature.GENERAL_PURPOSE,
          CollectionFeature.ALLOWS_NULL_VALUES,
          CollectionSize.ANY,
          CollectionFeature.SERIALIZABLE)
      .createTestSuite();
}
 
Example 17
Project: guava   File: SetsTest.java   Source Code and License 6 votes vote down vote up
@GwtIncompatible // suite
private static Test testsForFilter() {
  return SetTestSuiteBuilder.using(
          new TestStringSetGenerator() {
            @Override
            public Set<String> create(String[] elements) {
              Set<String> unfiltered = Sets.newLinkedHashSet();
              unfiltered.add("yyy");
              Collections.addAll(unfiltered, elements);
              unfiltered.add("zzz");
              return Sets.filter(unfiltered, Collections2Test.NOT_YYY_ZZZ);
            }
          })
      .named("Sets.filter")
      .withFeatures(
          CollectionFeature.SUPPORTS_ADD,
          CollectionFeature.SUPPORTS_REMOVE,
          CollectionFeature.ALLOWS_NULL_VALUES,
          CollectionFeature.KNOWN_ORDER,
          CollectionSize.ANY)
      .createTestSuite();
}
 
Example 18
Project: guava   File: SetsTest.java   Source Code and License 6 votes vote down vote up
@GwtIncompatible // suite
private static Test testsForFilterFiltered() {
  return SetTestSuiteBuilder.using(
          new TestStringSetGenerator() {
            @Override
            public Set<String> create(String[] elements) {
              Set<String> unfiltered = Sets.newLinkedHashSet();
              unfiltered.add("yyy");
              unfiltered.addAll(ImmutableList.copyOf(elements));
              unfiltered.add("zzz");
              unfiltered.add("abc");
              return Sets.filter(
                  Sets.filter(unfiltered, Collections2Test.LENGTH_1),
                  Collections2Test.NOT_YYY_ZZZ);
            }
          })
      .named("Sets.filter, filtered input")
      .withFeatures(
          CollectionFeature.SUPPORTS_ADD,
          CollectionFeature.SUPPORTS_REMOVE,
          CollectionFeature.KNOWN_ORDER,
          CollectionSize.ANY,
          CollectionFeature.ALLOWS_NULL_QUERIES)
      .createTestSuite();
}
 
Example 19
Project: boxes   File: SetBoxTest.java   Source Code and License 5 votes vote down vote up
public static TestSuite suite() {
    return SetTestSuiteBuilder
            .using(new TestStringSetGenerator() {

                @Override
                protected Set<String> create(String[] elements) {
                    SetBox<String> inner = new SetBox<String>(SetBoxTest.class, "list");
                    inner.set(new HashSet<String>(Arrays.asList(elements)));
                    SetBox<String> outer = new SetBox<String>(BoxFamily.getInstance(SetBoxTest.class, "list"));
                    outer.set(inner);
                    return outer;
                }


            })
            .named("ListBox")
            .withFeatures(
                    CollectionFeature.ALLOWS_NULL_QUERIES,
                    CollectionFeature.ALLOWS_NULL_VALUES,
                    CollectionFeature.DESCENDING_VIEW,
                    CollectionFeature.GENERAL_PURPOSE,
                    CollectionFeature.FAILS_FAST_ON_CONCURRENT_MODIFICATION,
                    CollectionFeature.SUBSET_VIEW,
                    CollectionFeature.SUPPORTS_ADD,
                    CollectionFeature.SUPPORTS_ITERATOR_REMOVE,
                    CollectionFeature.SUPPORTS_REMOVE,
                    CollectionSize.ANY,
                    SetFeature.GENERAL_PURPOSE
            ).createTestSuite();
}
 
Example 20
Project: cqengine   File: ConcurrentIndexedCollectionTest.java   Source Code and License 5 votes vote down vote up
private static TestStringSetGenerator onHeapIndexedCollectionGenerator() {
    return new TestStringSetGenerator() {
        @Override protected Set<String> create(String[] elements) {
            IndexedCollection<String> indexedCollection = new ConcurrentIndexedCollection<String>(OnHeapPersistence.onPrimaryKey(QueryFactory.selfAttribute(String.class)));
            indexedCollection.addAll(asList(elements));
            return indexedCollection;
        }
    };
}
 
Example 21
Project: cqengine   File: ConcurrentIndexedCollectionTest.java   Source Code and License 5 votes vote down vote up
private static TestStringSetGenerator offHeapIndexedCollectionGenerator() {
    return new TestStringSetGenerator() {
        @Override protected Set<String> create(String[] elements) {
            IndexedCollection<String> indexedCollection = new ConcurrentIndexedCollection<String>(OffHeapPersistence.onPrimaryKey(QueryFactory.selfAttribute(String.class)));
            indexedCollection.addAll(asList(elements));
            return indexedCollection;
        }
    };
}
 
Example 22
Project: cqengine   File: TransactionalIndexedCollectionTest.java   Source Code and License 5 votes vote down vote up
private static TestStringSetGenerator onHeapIndexedCollectionGenerator() {
    return new TestStringSetGenerator() {
        @Override protected Set<String> create(String[] elements) {
            IndexedCollection<String> indexedCollection = new TransactionalIndexedCollection<String>(String.class, OnHeapPersistence.onPrimaryKey(QueryFactory.selfAttribute(String.class)));
            indexedCollection.addAll(Arrays.asList(elements));
            return indexedCollection;
        }
    };
}
 
Example 23
Project: cqengine   File: TransactionalIndexedCollectionTest.java   Source Code and License 5 votes vote down vote up
private static TestStringSetGenerator offHeapIndexedCollectionGenerator() {
    return new TestStringSetGenerator() {
        @Override protected Set<String> create(String[] elements) {
            IndexedCollection<String> indexedCollection = new TransactionalIndexedCollection<String>(String.class, OffHeapPersistence.onPrimaryKey(QueryFactory.selfAttribute(String.class)));
            indexedCollection.addAll(Arrays.asList(elements));
            return indexedCollection;
        }
    };
}
 
Example 24
Project: cqengine   File: ObjectLockingIndexedCollectionTest.java   Source Code and License 5 votes vote down vote up
private static TestStringSetGenerator onHeapIndexedCollectionGenerator() {
    return new TestStringSetGenerator() {
        @Override protected Set<String> create(String[] elements) {
            IndexedCollection<String> indexedCollection = new ObjectLockingIndexedCollection<String>(OnHeapPersistence.onPrimaryKey(QueryFactory.selfAttribute(String.class)));
            indexedCollection.addAll(Arrays.asList(elements));
            return indexedCollection;
        }
    };
}
 
Example 25
Project: cqengine   File: ObjectLockingIndexedCollectionTest.java   Source Code and License 5 votes vote down vote up
private static TestStringSetGenerator offHeapIndexedCollectionGenerator() {
    return new TestStringSetGenerator() {
        @Override protected Set<String> create(String[] elements) {
            IndexedCollection<String> indexedCollection = new ObjectLockingIndexedCollection<String>(OffHeapPersistence.onPrimaryKey(QueryFactory.selfAttribute(String.class)));
            indexedCollection.addAll(Arrays.asList(elements));
            return indexedCollection;
        }
    };
}
 
Example 26
Project: pareto4j   File: ParetoLinkedHashSetTestSuite.java   Source Code and License 5 votes vote down vote up
public static TestSuite suite() throws Exception {
    return SetTestSuiteBuilder.using(new TestStringSetGenerator() {

        @Override
        protected Set<String> create(String[] elements) {
            ParetoLinkedHashSet s = new ParetoLinkedHashSet();
            for (String element : elements) {
                s.add(element);
            }
            return s;
        }
    }).named("ParetoHashSetTestSuite")
            .withFeatures(SetFeature.GENERAL_PURPOSE, CollectionSize.ANY, CollectionFeature.ALLOWS_NULL_VALUES)
            .createTestSuite();
}
 
Example 27
Project: JCTools   File: SingleWriterHashSetTest.java   Source Code and License 5 votes vote down vote up
public static Test suite() throws Exception {
    return SetTestSuiteBuilder.using(new TestStringSetGenerator() {
        @Override
        protected Set<String> create(String[] elements) {
            Set<String> set = new SingleWriterHashSet<>(elements.length);
            Collections.addAll(set, elements);
            return set;
        }
    }).withFeatures(
            SetFeature.GENERAL_PURPOSE,
            CollectionSize.ANY,
            CollectionFeature.NON_STANDARD_TOSTRING)
      .named(SingleWriterHashSet.class.getSimpleName())
      .createTestSuite();
}