本文整理汇总了Java中com.pholser.junit.quickcheck.generator.Size类的典型用法代码示例。如果您正苦于以下问题:Java Size类的具体用法?Java Size怎么用?Java Size使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Size类属于com.pholser.junit.quickcheck.generator包,在下文中一共展示了Size类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: stepwiseContainsAfterInsert
import com.pholser.junit.quickcheck.generator.Size; //导入依赖的package包/类
/**
* Inserted tuple by tuple, starting from an empty multimap. Keeps track of all so far inserted
* tuples and checks after each insertion if all inserted tuples are contained (quadratic
* operation).
*/
@Property(trials = DEFAULT_TRIALS)
public void stepwiseContainsAfterInsert(@Size(min = 0, max = 0) final CT emptyCollection,
@Size(min = 1, max = MAX_SIZE) final java.util.HashSet<Map.Entry<K, V>> inputValues) {
final HashSet<Map.Entry<K, V>> insertedValues = new HashSet<>(inputValues.size());
CT testCollection = emptyCollection;
for (Map.Entry<K, V> newValueTuple : inputValues) {
final CT tmpCollection =
(CT) testCollection.__insert(newValueTuple.getKey(), newValueTuple.getValue());
insertedValues.add(newValueTuple);
boolean containsInsertedValues = insertedValues.stream()
.allMatch(tuple -> tmpCollection.containsEntry(tuple.getKey(), tuple.getValue()));
assertTrue("All so far inserted values must be contained.", containsInsertedValues);
// String.format("%s.insert(%s)", testSet, newValue);
testCollection = tmpCollection;
}
}
示例2: containsAfterInsert
import com.pholser.junit.quickcheck.generator.Size; //导入依赖的package包/类
@Property(trials = DEFAULT_TRIALS)
public void containsAfterInsert(@Size(min = 0, max = 0) final CT emptyCollection,
@Size(min = 1, max = MAX_SIZE) final java.util.HashSet<Map.Entry<K, V>> inputValues) {
CT testCollection = emptyCollection;
for (Map.Entry<K, V> newValueTuple : inputValues) {
final CT tmpCollection =
(CT) testCollection.__insert(newValueTuple.getKey(), newValueTuple.getValue());
testCollection = tmpCollection;
}
final CT finalCollection = testCollection;
boolean containsInsertedValues = inputValues.stream()
.allMatch(tuple -> finalCollection.containsEntry(tuple.getKey(), tuple.getValue()));
assertTrue("Must contain all inserted values.", containsInsertedValues);
}
示例3: entryIteratorAfterInsert
import com.pholser.junit.quickcheck.generator.Size; //导入依赖的package包/类
@Property(trials = DEFAULT_TRIALS)
public void entryIteratorAfterInsert(@Size(min = 0, max = 0) final CT emptyCollection,
@Size(min = 1, max = MAX_SIZE) final java.util.HashSet<Map.Entry<K, V>> inputValues) {
CT testCollection = emptyCollection;
for (Map.Entry<K, V> newValueTuple : inputValues) {
final CT tmpCollection =
(CT) testCollection.__insert(newValueTuple.getKey(), newValueTuple.getValue());
testCollection = tmpCollection;
}
final CT finalCollection = testCollection;
final Spliterator<Map.Entry> entrySpliterator = Spliterators
.spliterator(finalCollection.entryIterator(), finalCollection.size(), Spliterator.DISTINCT);
final Stream<Map.Entry> entryStream = StreamSupport.stream(entrySpliterator, false);
boolean containsInsertedValues = entryStream.allMatch(inputValues::contains);
assertTrue("Must contain all inserted values.", containsInsertedValues);
}
示例4: stepwiseCheckSizeAfterInsertAll
import com.pholser.junit.quickcheck.generator.Size; //导入依赖的package包/类
/**
* Inserted element by element, starting from an empty set. Keeps track of all so far inserted
* values and checks after each insertion if all inserted elements are contained (quadratic
* operation).
*/
@Property(trials = DEFAULT_TRIALS)
public void stepwiseCheckSizeAfterInsertAll(@Size(min = 0, max = 0) final CT emptySet,
@Size(min = 1, max = MAX_SIZE) final java.util.HashSet<T> inputValues) {
int expectedSize = 0;
int expectedHashCode = 0;
final Set.Transient<T> builder = emptySet.asTransient();
for (T newValue : inputValues) {
builder.__insert(newValue);
expectedSize += 1;
expectedHashCode += newValue.hashCode();
assertEquals(expectedSize, builder.size());
assertEquals(expectedHashCode, builder.hashCode());
}
CT testSet = (CT) builder.freeze();
}
示例5: stepwiseContainsAfterInsert
import com.pholser.junit.quickcheck.generator.Size; //导入依赖的package包/类
/**
* Inserted element by element, starting from an empty set. Keeps track of all so far inserted
* values and checks after each insertion if all inserted elements are contained (quadratic
* operation).
*/
@Property(trials = DEFAULT_TRIALS)
public void stepwiseContainsAfterInsert(@Size(min = 0, max = 0) final CT emptySet,
@Size(min = 1, max = MAX_SIZE) final java.util.HashSet<T> inputValues) {
final HashSet<T> insertedValues = new HashSet<>(inputValues.size());
CT testSet = emptySet;
for (T newValue : inputValues) {
final CT tmpSet = (CT) testSet.__insert(newValue);
insertedValues.add(newValue);
boolean containsInsertedValues =
insertedValues.stream().allMatch(tmpSet::contains);
assertTrue("All so far inserted values must be contained.", containsInsertedValues);
// String.format("%s.insert(%s)", testSet, newValue);
testSet = tmpSet;
}
}
示例6: intersect
import com.pholser.junit.quickcheck.generator.Size; //导入依赖的package包/类
@Property(trials = LESS_TRIALS)
public void intersect(
@Size(min = 0, max = MAX_SIZE) final CT inputOne,
@Size(min = 0, max = MAX_SIZE) final CT inputTwo,
@Size(min = 0, max = MAX_SIZE) final CT inputShared) {
CT oneWithoutShared = (CT) inputOne.__removeAll(inputShared).__removeAll(inputTwo);
CT twoWithoutShared = (CT) inputTwo.__removeAll(inputShared).__removeAll(inputOne);
// CT intersectedWithoutShared = (CT) oneWithoutShared.intersect(twoWithoutShared);
CT oneWithShared = (CT) inputOne.__insertAll(inputShared);
CT twoWithShared = (CT) inputTwo.__insertAll(inputShared);
CT intersectedWithShared = (CT) oneWithShared.intersect(twoWithShared);
// CT intersectedMinusShared = (CT) intersectedWithShared.__removeAll(inputShared);
// CT sharedMinusIntersected = (CT) inputShared.__removeAll(intersectedWithShared);
assertTrue(inputShared.size() <= intersectedWithShared.size());
assertTrue(inputShared.stream().allMatch(intersectedWithShared::contains));
assertTrue(intersectedWithShared.stream().noneMatch(oneWithoutShared::contains));
assertTrue(intersectedWithShared.stream().noneMatch(twoWithoutShared::contains));
}
示例7: intersectIdentityMostlyReference
import com.pholser.junit.quickcheck.generator.Size; //导入依赖的package包/类
@Property(trials = LESS_TRIALS)
public void intersectIdentityMostlyReference(
@Size(min = 0, max = MAX_SIZE) final CT input, T key) {
final CT inputCopy;
if (input.contains(key)) {
inputCopy = (CT) input.__remove(key).__insert(key);
} else {
inputCopy = (CT) input.__insert(key).__remove(key);
}
CT intersectionL = (CT) input.intersect(inputCopy);
CT intersectionR = (CT) inputCopy.intersect(input);
assertEquals(input, intersectionL);
assertEquals(input, intersectionR);
}
示例8: unionIdentityMostlyReference
import com.pholser.junit.quickcheck.generator.Size; //导入依赖的package包/类
@Property(trials = LESS_TRIALS)
public void unionIdentityMostlyReference(@Size(min = 0, max = 0) final CT emptySet,
@Size(min = 0, max = MAX_SIZE) final CT input, T key) {
final CT inputCopy;
if (input.contains(key)) {
inputCopy = (CT) input.__remove(key).__insert(key);
} else {
inputCopy = (CT) input.__insert(key).__remove(key);
}
CT unionL = (CT) input.union(inputCopy);
CT unionR = (CT) inputCopy.union(input);
assertEquals(input, unionL);
assertEquals(input, unionR);
}
示例9: subtractIdentityMostlyReference
import com.pholser.junit.quickcheck.generator.Size; //导入依赖的package包/类
@Property(trials = LESS_TRIALS)
public void subtractIdentityMostlyReference(@Size(min = 0, max = 0) final CT emptySet,
@Size(min = 0, max = MAX_SIZE) final CT input, T key) {
final CT inputCopy;
if (input.contains(key)) {
inputCopy = (CT) input.__remove(key).__insert(key);
} else {
inputCopy = (CT) input.__insert(key).__remove(key);
}
CT subtractionL = (CT) input.subtract(inputCopy);
CT subtractionR = (CT) inputCopy.subtract(input);
assertEquals(emptySet, subtractionL);
assertEquals(emptySet, subtractionR);
}
示例10: subtract
import com.pholser.junit.quickcheck.generator.Size; //导入依赖的package包/类
@Property(trials = LESS_TRIALS)
public void subtract(
@Size(min = 0, max = MAX_SIZE) final CT inputOne,
@Size(min = 0, max = MAX_SIZE) final CT inputTwo,
@Size(min = 0, max = MAX_SIZE) final CT inputShared) {
CT oneWithoutShared = (CT) inputOne.__removeAll(inputShared).__removeAll(inputTwo);
CT twoWithoutShared = (CT) inputTwo.__removeAll(inputShared).__removeAll(inputOne);
// CT subtractedWithoutShared = (CT) oneWithoutShared.subtracted(twoWithoutShared);
CT oneWithShared = (CT) inputOne.__insertAll(inputShared);
CT twoWithShared = (CT) inputTwo.__insertAll(inputShared);
CT subtractedWithShared = (CT) oneWithShared.subtract(twoWithShared);
// CT intersectedMinusShared = (CT) intersectedWithShared.__removeAll(inputShared);
// CT sharedMinusIntersected = (CT) inputShared.__removeAll(intersectedWithShared);
// assertTrue(inputShared.size() <= intersectedWithShared.size());
assertTrue(inputShared.stream().noneMatch(subtractedWithShared::contains));
assertTrue(subtractedWithShared.stream().allMatch(oneWithoutShared::contains));
assertTrue(subtractedWithShared.stream().noneMatch(twoWithoutShared::contains));
}
示例11: size
import com.pholser.junit.quickcheck.generator.Size; //导入依赖的package包/类
public final static Size size(int min, int max) {
return new Size() {
@Override
public int min() {
return min;
}
@Override
public int max() {
return max;
}
@Override
public Class<? extends Annotation> annotationType() {
return Size.class;
}
};
}
示例12: varPatternIsAMorphism_From_VarPropertiesWithUnion_To_PatternsWithConjunction
import com.pholser.junit.quickcheck.generator.Size; //导入依赖的package包/类
@Property
public void varPatternIsAMorphism_From_VarPropertiesWithUnion_To_PatternsWithConjunction(
@Open GraknTx tx,
Var var, @Size(max=10) Set<VarProperty> a, @Size(max=10) Set<VarProperty> b
) {
assertEquivalent(tx,
varPattern(var, Sets.union(a, b)),
(varPattern(var, a)).and(varPattern(var, b))
);
}
示例13: aDefineQueryWithoutASubOrPlaysOrRelatesProperty_CannotBeInserted
import com.pholser.junit.quickcheck.generator.Size; //导入依赖的package包/类
@Ignore("Currently no error message is returned when trying to insert an empty set of propoerties. I am not entirely sure this is correct")
@Property
public void aDefineQueryWithoutASubOrPlaysOrRelatesProperty_CannotBeInserted(@Open GraknTx tx, @Size(max=5) Set<VarProperty> properties){
boolean containsSub = properties.stream().anyMatch(SubProperty.class::isInstance);
boolean containsPlays = properties.stream().anyMatch(PlaysProperty.class::isInstance);
boolean containsRelates = properties.stream().anyMatch(RelatesProperty.class::isInstance);
assumeFalse(containsSub || containsPlays || containsRelates);
VarPatternAdmin pattern = Patterns.varPattern(Graql.var("x"), properties);
exception.expect(GraqlQueryException.class);
tx.graql().define(pattern).execute();
}
示例14: anInsertQueryWithoutAnIsaProperty_CannotBeInserted
import com.pholser.junit.quickcheck.generator.Size; //导入依赖的package包/类
@Ignore("Currently no error message is returned when trying to insert an empty set of propoerties. I am not entirely sure this is correct")
@Property
public void anInsertQueryWithoutAnIsaProperty_CannotBeInserted(@Open GraknTx tx, @Size(max=5) Set<VarProperty> properties){
boolean containsIsa = properties.stream().anyMatch(IsaProperty.class::isInstance);
assumeFalse(containsIsa);
VarPatternAdmin pattern = Patterns.varPattern(Graql.var("x"), properties);
exception.expect(GraqlQueryException.class);
tx.graql().insert(pattern).execute();
}
示例15: mapEqualsOtherMap
import com.pholser.junit.quickcheck.generator.Size; //导入依赖的package包/类
@Property(trials = DEFAULT_TRIALS)
public void mapEqualsOtherMap(@Size(min = 0, max = 0) final CT emptyCollection,
final SetMultimap.Immutable<K, V> thatMap) {
final SetMultimap.Transient builder = emptyCollection.asTransient();
thatMap.entryIterator()
.forEachRemaining(tuple -> builder.__insert(tuple.getKey(), tuple.getValue()));
final CT thisMap = (CT) builder.freeze();
assertEquals(thisMap, thatMap);
assertEquals(thatMap, thisMap);
}