本文整理汇总了Java中com.pholser.junit.quickcheck.generator.Generator类的典型用法代码示例。如果您正苦于以下问题:Java Generator类的具体用法?Java Generator怎么用?Java Generator使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Generator类属于com.pholser.junit.quickcheck.generator包,在下文中一共展示了Generator类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: registerGenerator
import com.pholser.junit.quickcheck.generator.Generator; //导入依赖的package包/类
public static void registerGenerator(Class<?> aClass, Generator<?> generator) {
CLASS_GENERATORS.put(aClass, generator);
}
示例2: findGenerator
import com.pholser.junit.quickcheck.generator.Generator; //导入依赖的package包/类
public static Optional<Generator<?>> findGenerator(Class<?> aClass) {
return Optional.ofNullable(CLASS_GENERATORS.get(aClass));
}
示例3: setUp
import com.pholser.junit.quickcheck.generator.Generator; //导入依赖的package包/类
@Setup(Level.Trial)
public void setUp() throws Exception {
final Generator<JmhValue> itemGenerator;
final AbstractSetGenerator<? extends Set.Immutable> collectionGenerator;
final SourceOfRandomness random0 = new SourceOfRandomness(new Random(13));
final GenerationStatus status0 = freshGenerationStatus.apply(random0);
try {
itemGenerator = new JmhSleepingIntegerGenerator();
collectionGenerator = generatorDescriptor.generatorClass().newInstance();
collectionGenerator.configure(CalculateFootprintsHeterogeneous.size(size, size));
collectionGenerator.addComponentGenerators(Arrays.asList(itemGenerator));
testSetCommon = collectionGenerator.generate(random0, status0);
SourceOfRandomness random = freshRandom.get();
GenerationStatus status = freshGenerationStatus.apply(random);
testSet1 = collectionGenerator.generate(random, status).__insertAll(testSetCommon);
testSet2 = collectionGenerator.generate(random, status).__insertAll(testSetCommon);
random = freshRandom.get();
status = freshGenerationStatus.apply(random);
testSet1Duplicate = collectionGenerator.generate(random, status).__insertAll(testSetCommon);
testSet2Duplicate = collectionGenerator.generate(random, status).__insertAll(testSetCommon);
// assert testSet1.size() == size;
// assert testSet2.size() == size;
} catch (InstantiationException | IllegalAccessException e) {
throw new RuntimeException(e);
}
//
// final Set<JmhValue> elements = testSet1.stream().map(Triple::_0)
// .collect(CapsuleCollectors.toSet());
//
// /*
// * select random integers that are contained in the data set
// */
// for (int i = 0; i < CACHED_NUMBERS_SIZE; i++) {
// if (i >= size) {
// cachedNumbers[i] = cachedNumbers[i % size];
// } else {
// cachedNumbers[i] = random.choose(elements);
// }
// }
//
// // assert (contained)
// assert Stream.of(cachedNumbers)
// .allMatch(sample -> testSet1.contains(Triple.of(sample, sample, sample)));
//
// /*
// * generate random integers that are not yet contained in the data set
// */
// for (int i = 0; i < CACHED_NUMBERS_SIZE; i++) {
// boolean found = false;
// while (!found) {
// final JmhValue candidate = itemGenerator.generate(random, status);
//
// if (!elements.contains(candidate)) {
// cachedNumbersNotContained[i] = candidate;
// found = true;
// }
// }
// }
//
// // assert (contained)
// assert Stream.of(cachedNumbersNotContained)
// .noneMatch(sample -> testSet1.contains(Triple.of(sample, sample, sample)));
//
// VALUE_EXISTING = cachedNumbers[0];
// VALUE_NOT_EXISTING = cachedNumbersNotContained[0];
// VALUE_EXISTING = cachedNumbers[0];
VALUE_NOT_EXISTING = itemGenerator.generate(random0, status0);
}