com.pholser.junit.quickcheck.generator.Generator.addComponentGenerators()方法的使用及代码示例

x33g5p2x  于2022-01-20 转载在 其他  
字(4.0k)|赞(0)|评价(0)|浏览(182)

本文整理了Java中com.pholser.junit.quickcheck.generator.Generator.addComponentGenerators()方法的一些代码示例,展示了Generator.addComponentGenerators()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Generator.addComponentGenerators()方法的具体详情如下:
包路径:com.pholser.junit.quickcheck.generator.Generator
类名称:Generator
方法名:addComponentGenerators

Generator.addComponentGenerators介绍

[英]Adds component generators to this generator.

Some generators need component generators to create proper values. For example, list generators require a single component generator in order to generate elements that have the type of the list parameter's type argument.

This is intended for use only by junit-quickcheck itself, and not by creators of custom generators.
[中]将组件生成器添加到此生成器。
某些生成器需要组件生成器来创建正确的值。例如,列表生成器需要单个组件生成器才能生成具有列表参数的类型参数类型的元素。
这仅适用于junit quickcheck本身,而不适用于自定义生成器的创建者。

代码示例

代码示例来源:origin: pholser/junit-quickcheck

@Override
public void addComponentGenerators(List<Generator<?>> newComponents) {
  delegate.addComponentGenerators(newComponents);
}

代码示例来源:origin: pholser/junit-quickcheck

@SuppressWarnings("unchecked")
@Override public <T> Generator<T> type(Class<T> type, Class<?>... componentTypes) {
  Generator<T> generator =
    (Generator<T>) produceGenerator(new ParameterTypeContext(type));
  generator.addComponentGenerators(
    Arrays.stream(componentTypes).map(c -> type(c)).collect(toList()));
  return generator;
}

代码示例来源:origin: pholser/junit-quickcheck

@Override public final <T extends Generator<?>> T make(
  Class<T> genType,
  Generator<?>... components) {
  T generator = instantiate(genType);
  generator.provide(this);
  generator.configure(genType);
  generator.addComponentGenerators(asList(components));
  return generator;
}

代码示例来源:origin: pholser/junit-quickcheck

private void applyComponentGenerators(Generator<?> generator, List<Generator<?>> componentGenerators) {
  if (generator.hasComponents()) {
    if (componentGenerators.isEmpty()) {
      List<Generator<?>> substitutes = new ArrayList<>();
      Generator<?> zilch = generatorFor(
        new ParameterTypeContext(
          "Zilch",
          null,
          getClass().getName(),
          token(Zilch.class),
          emptyMap())
        .allowMixedTypes(true));
      for (int i = 0; i < generator.numberOfNeededComponents(); ++i)
        substitutes.add(zilch);
      generator.addComponentGenerators(substitutes);
    } else
      generator.addComponentGenerators(componentGenerators);
  }
}

代码示例来源:origin: pholser/junit-quickcheck

@Test public void addingComponentsDoesNothing() {
    generator.addComponentGenerators(Collections.<Generator<?>> emptyList());
  }
}

代码示例来源:origin: pholser/junit-quickcheck

@Test public void addingComponentsDoesNothing() {
  generator.addComponentGenerators(Collections.<Generator<?>> emptyList());
}

代码示例来源:origin: com.pholser/junit-quickcheck-core

@SuppressWarnings("unchecked")
@Override public <T> Generator<T> type(Class<T> type, Class<?>... componentTypes) {
  Generator<T> generator =
    (Generator<T>) produceGenerator(new ParameterTypeContext(type));
  generator.addComponentGenerators(
    Arrays.stream(componentTypes).map(c -> type(c)).collect(toList()));
  return generator;
}

代码示例来源:origin: com.pholser/junit-quickcheck-core

@Override public final <T extends Generator<?>> T make(
  Class<T> genType,
  Generator<?>... components) {
  T generator = instantiate(genType);
  generator.provide(this);
  generator.configure(genType);
  generator.addComponentGenerators(asList(components));
  return generator;
}

代码示例来源:origin: com.pholser/junit-quickcheck-core

private void applyComponentGenerators(Generator<?> generator, List<Generator<?>> componentGenerators) {
  if (generator.hasComponents()) {
    if (componentGenerators.isEmpty()) {
      List<Generator<?>> substitutes = new ArrayList<>();
      Generator<?> zilch = generatorFor(
        new ParameterTypeContext(
          "Zilch",
          null,
          getClass().getName(),
          token(Zilch.class),
          emptyMap())
        .allowMixedTypes(true));
      for (int i = 0; i < generator.numberOfNeededComponents(); ++i)
        substitutes.add(zilch);
      generator.addComponentGenerators(substitutes);
    } else
      generator.addComponentGenerators(componentGenerators);
  }
}

相关文章