本文整理了Java中com.pholser.junit.quickcheck.generator.Generator.doShrink()
方法的一些代码示例,展示了Generator.doShrink()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Generator.doShrink()
方法的具体详情如下:
包路径:com.pholser.junit.quickcheck.generator.Generator
类名称:Generator
方法名:doShrink
[英]Gives some objects that are "smaller" than a given "larger" object.
Unless overridden, a generator will produce an empty list of "smaller" values.
[中]给出一些比给定的“较大”对象“小”的对象。
除非重写,否则生成器将生成“较小”值的空列表。
代码示例来源:origin: pholser/junit-quickcheck
@Override
public List<T> doShrink(SourceOfRandomness random, T larger) {
return delegate.doShrink(random, larger);
}
代码示例来源:origin: pholser/junit-quickcheck
/**
* {@inheritDoc}
*
* <p>Generators first ensure that they {@linkplain #canShrink(Object) can
* participate} in shrinking the given value, and if so, they
* {@linkplain #doShrink(SourceOfRandomness, Object) produce shrinks}.</p>
*/
@Override public final List<T> shrink(SourceOfRandomness random, Object larger) {
if (!canShrink(larger)) {
throw new IllegalStateException(
getClass() + " not capable of shrinking " + larger);
}
return doShrink(random, narrow(larger));
}
代码示例来源:origin: pholser/junit-quickcheck
@Test public void shrinkingChoosesAComponentCapableOfShrinkingTheValue() {
stub(first.canShrink(7)).toReturn(true);
stub(second.canShrink(7)).toReturn(false);
stub(third.canShrink(7)).toReturn(true);
when(first.types()).thenReturn(singletonList(Integer.class));
when(first.doShrink(random, 7)).thenReturn(asList(3, 6));
when(random.nextInt(9)).thenReturn(1);
assertEquals(asList(3, 6), composite.shrink(random, 7));
verify(first, atLeastOnce()).doShrink(random, 7);
}
}
代码示例来源:origin: com.pholser/junit-quickcheck-core
/**
* {@inheritDoc}
*
* <p>Generators first ensure that they {@linkplain #canShrink(Object) can
* participate} in shrinking the given value, and if so, they
* {@linkplain #doShrink(SourceOfRandomness, Object) produce shrinks}.</p>
*/
@Override public final List<T> shrink(SourceOfRandomness random, Object larger) {
if (!canShrink(larger)) {
throw new IllegalStateException(
getClass() + " not capable of shrinking " + larger);
}
return doShrink(random, narrow(larger));
}
内容来源于网络,如有侵权,请联系作者删除!