use of org.quicktheories.impl.Constraint in project cassandra by apache.
the class WarningsSnapshotTest method counter.
private static Gen<Counter> counter() {
Gen<Boolean> empty = SourceDSL.booleans().all();
Constraint maxValue = Constraint.between(1, Long.MAX_VALUE);
Gen<ImmutableSet<InetAddressAndPort>> instances = SourceDSL.arbitrary().pick(ImmutableSet.of(HOME), ImmutableSet.of(VACATION_HOME), ImmutableSet.of(HOME, VACATION_HOME));
Gen<Counter> gen = rs -> empty.generate(rs) ? Counter.empty() : new Counter(instances.generate(rs), rs.next(maxValue));
return gen.describedAs(Counter::toString);
}
use of org.quicktheories.impl.Constraint in project cassandra by apache.
the class Generators method charArray.
public static Gen<char[]> charArray(Gen<Integer> sizes, char[] domain) {
Constraint constraints = Constraint.between(0, domain.length - 1).withNoShrinkPoint();
Gen<char[]> gen = td -> {
int size = sizes.generate(td);
char[] is = new char[size];
for (int i = 0; i != size; i++) {
int idx = (int) td.next(constraints);
is[i] = domain[idx];
}
return is;
};
gen.describedAs(String::new);
return gen;
}
Aggregations