本文整理汇总了Java中com.pholser.junit.quickcheck.When类的典型用法代码示例。如果您正苦于以下问题:Java When类的具体用法?Java When怎么用?Java When使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
When类属于com.pholser.junit.quickcheck包,在下文中一共展示了When类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: primeFactorsForEvenNumbersShouldContain2
import com.pholser.junit.quickcheck.When; //导入依赖的package包/类
@Property(maxShrinkDepth = 100, maxShrinks = 1000)
public void primeFactorsForEvenNumbersShouldContain2(
@InRange(min = "2", max = "9999999999999") @When(seed = -6527596145222155897L) final Long i)
{
assumeThat(i % 2, is(0L));
assertThat(sut.factor(i)).contains(2L);
}
示例2: testSignedFromWithInvalid
import com.pholser.junit.quickcheck.When; //导入依赖的package包/类
@Property(trials = 30)
public void testSignedFromWithInvalid(@When(satisfies = "#_ < -128 || #_ > 127") int byteValue){
try {
RoxByte.signedFrom(byteValue);
fail(byteValue + " was expected to be too low to convert to unsigned byte");
}catch(InvalidDataTypeException e) {
assertNotNull(e);
}
}
示例3: testWithBitInvalidChoice
import com.pholser.junit.quickcheck.When; //导入依赖的package包/类
@Property(trials = 5)
public void testWithBitInvalidChoice(@When(satisfies = "#_ < 0 || #_ > 7") int bit){
final RoxByte myByte = RoxByte.ZERO;
try {
myByte.withBit(bit);
fail("There is no bit " + bit + ", this should throw an error");
}catch(ArrayIndexOutOfBoundsException e){
assertNotNull(e);
}
}
示例4: testWithoutBitInvalidChoice
import com.pholser.junit.quickcheck.When; //导入依赖的package包/类
@Property(trials = 5)
public void testWithoutBitInvalidChoice(@When(satisfies = "#_ < 0 || #_ > 7") int bit){
final RoxByte myByte = RoxByte.ZERO;
try {
myByte.withoutBit(bit);
fail("There is no bit " + bit + ", this should throw an error");
}catch(ArrayIndexOutOfBoundsException e){
assertNotNull(e);
}
}
示例5: testIsBitSetInvalidChoice
import com.pholser.junit.quickcheck.When; //导入依赖的package包/类
@Property(trials = 5)
public void testIsBitSetInvalidChoice(@When(satisfies = "#_ < 0 || #_ > 7") int bit){
final RoxByte myByte = RoxByte.ZERO;
try {
myByte.isBitSet(bit);
fail("There is no bit " + bit + ", this should throw an error");
}catch(ArrayIndexOutOfBoundsException e){
assertNotNull(e);
}
}
示例6: testInvalidImmediateADC
import com.pholser.junit.quickcheck.When; //导入依赖的package包/类
@Property (trials = 100)
public void testInvalidImmediateADC(@When(satisfies = "#_ < 0 || #_ > 255") int value){
Program program = new Program().with(LDA_I, value);
memory.setBlock(0, program.getProgramAsByteArray());
processor.step();
Registers registers = processor.getRegisters();
assertNotEquals(value, registers.getRegister(Registers.REG_ACCUMULATOR));
assertEquals(program.getLength(), registers.getPC());
}
示例7: testInvalidFlagPlaceValueToFlagID
import com.pholser.junit.quickcheck.When; //导入依赖的package包/类
@Property(trials = 10)
public void testInvalidFlagPlaceValueToFlagID(@When(satisfies = "#_ < 0 || #_ > 128") int placeValue){
try{
Registers.getFlagID(placeValue);
fail("Place value " + Integer.toHexString(placeValue) + " should be invalid.");
}catch(IllegalArgumentException e){
assertNotNull(e);
}
}
示例8: allowAtMostOneFailsWithCustomException
import com.pholser.junit.quickcheck.When; //导入依赖的package包/类
@Property
public void allowAtMostOneFailsWithCustomException(@When(satisfies = " #_.size() > 1") List<?> tooManyElements) {
expectedException.expect(IllegalStateException.class);
tooManyElements.stream().collect(allowAtMostOneOrElseThrow((first, excess) -> {
assertThat(first, is(tooManyElements.get(0)));
assertThat(excess, is(tooManyElements.get(1)));
return new IllegalStateException();
}));
}
示例9: friendlyClassNameIsJustTheSimpleName
import com.pholser.junit.quickcheck.When; //导入依赖的package包/类
@Property
public void friendlyClassNameIsJustTheSimpleName(@When(satisfies = "#_ != null") Object anyInstanceOfNonNestedClass) {
Class<?> anyNonNestedClass = anyInstanceOfNonNestedClass.getClass();
assumeThat(anyNonNestedClass.getEnclosingClass(), nullValue());
assertThat(friendlyName(anyNonNestedClass), is(anyNonNestedClass.getSimpleName()));
}
示例10: allowAtMostOneFails
import com.pholser.junit.quickcheck.When; //导入依赖的package包/类
@Property
public void allowAtMostOneFails(@When(satisfies = " #_.size() > 1") List<?> tooManyElements) {
expectedException.expect(ViewableAsOptional.TooManyElements.class);
tooManyElements.stream().parallel().collect(allowAtMostOne());
}