当前位置: 首页>>代码示例>>Java>>正文


Java Generator类代码示例

本文整理汇总了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);
}
 
开发者ID:soundvibe,项目名称:pbt4j,代码行数:4,代码来源:Generators.java

示例2: findGenerator

import com.pholser.junit.quickcheck.generator.Generator; //导入依赖的package包/类
public static Optional<Generator<?>> findGenerator(Class<?> aClass) {
    return Optional.ofNullable(CLASS_GENERATORS.get(aClass));
}
 
开发者ID:soundvibe,项目名称:pbt4j,代码行数:4,代码来源:Generators.java

示例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);
  }
 
开发者ID:msteindorfer,项目名称:criterion,代码行数:80,代码来源:JmhCapsuleSetBenchmark.java


注:本文中的com.pholser.junit.quickcheck.generator.Generator类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。