本文整理汇总了Java中com.pholser.junit.quickcheck.Property类的典型用法代码示例。如果您正苦于以下问题:Java Property类的具体用法?Java Property怎么用?Java Property使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Property类属于com.pholser.junit.quickcheck包,在下文中一共展示了Property类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testDbl
import com.pholser.junit.quickcheck.Property; //导入依赖的package包/类
@Property
public void testDbl(long mi, long mf, boolean signB, byte exp) {
final double sign = signB ? 1.0 : -1.0;
final int mfd = 1 + (int) Math.log10(mf);
final double d = ((double) mi + (double) mf / Math.pow(10.0, mfd)) * Math.pow(10.0, sign * exp);
testDblImpl(d);
if (Math.abs(d) > 1e-20) {
testDblImpl(1.0 / d);
}
if (mf >= 0) {
final String s = mi + "." + mf + "E" + exp;
testDblImpl(s);
}
}
示例2: satisfyAppliesPredicate
import com.pholser.junit.quickcheck.Property; //导入依赖的package包/类
@Property
public void satisfyAppliesPredicate(char c0) {
final char even;
final char odd;
if (c0 % 2 == 0) {
even = c0;
odd = (char)((even + 1) % 0xffff);
} else {
odd = c0;
even = (char)((odd + 1) % 0xffff);
}
final Input<Chr> input1 = Input.of(String.valueOf(even));
final Input<Chr> input2 = Input.of(String.valueOf(odd));
final Parser<Chr, Chr> parser =
Combinators.satisfy("even", Predicate.of((Chr c) -> c.charValue() % 2 == 0));
TestUtils.ParserCheck.parser(parser)
.withInput(input1)
.succeedsWithResult(Chr.valueOf(even), input1.next());
TestUtils.ParserCheck.parser(parser)
.withInput(input2)
.fails();
}
示例3: andWithMapAppliesF
import com.pholser.junit.quickcheck.Property; //导入依赖的package包/类
@Property
public void andWithMapAppliesF(char c1, char c2) {
// String.toCharArray returns a new array each time, so ensure we call it only once.
final char[] data = ("" + c1 + c2).toCharArray();
final Input<Chr> input = Input.of(data);
final Parser<Chr, Tuple2<Chr, Chr>> parser =
any(Chr.class)
.and(any())
.map(Tuple2::of);
final Input<Chr> expInp = Input.of(data).next().next();
TestUtils.ParserCheck.parser(parser)
.withInput(input)
.succeedsWithResult(Tuple2.of(Chr.valueOf(c1), Chr.valueOf(c2)), expInp);
}
示例4: testString
import com.pholser.junit.quickcheck.Property; //导入依赖的package包/类
@Property
public void testString(String s) {
assumeFalse(s.isEmpty());
final Parser<Chr, String> p = Text.string(s);
final Result<Chr, String> r = p.parse(Input.of(s));
assertEquals("string(" + s + ").parse(" + s + ")", s, r.getOrThrow());
}
示例5: failAlwaysFails
import com.pholser.junit.quickcheck.Property; //导入依赖的package包/类
@Property
public void failAlwaysFails(char c1) {
final Input<Chr> input = Input.of(String.valueOf(c1));
final Parser<Chr, Chr> parser = Combinators.fail();
TestUtils.ParserCheck.parser(parser)
.withInput(input)
.fails();
}
示例6: eofSucceedsOnEmptyInput
import com.pholser.junit.quickcheck.Property; //导入依赖的package包/类
@Property
public void eofSucceedsOnEmptyInput(char c1) {
final Input<Chr> input = Input.of("");
final Parser<Chr, Unit> parser = Combinators.eof();
TestUtils.ParserCheck.parser(parser)
.withInput(input)
.succeedsWithResult(Unit.UNIT, input);
}
示例7: eofFailsOnNonEmptyInput
import com.pholser.junit.quickcheck.Property; //导入依赖的package包/类
@Property
public void eofFailsOnNonEmptyInput(char c1) {
final Parser<Chr, Unit> parser = Combinators.eof();
TestUtils.ParserCheck.parser(parser)
.withInput(Input.of("" + c1))
.fails();
}
示例8: valueMatchesValue
import com.pholser.junit.quickcheck.Property; //导入依赖的package包/类
@Property
public void valueMatchesValue(char c1, char c2) {
final Input<Chr> input1 = Input.of(String.valueOf(c1));
final Input<Chr> input2 = Input.of(String.valueOf(c2));
final Parser<Chr, Chr> parser = Combinators.value(Chr.valueOf(c1));
TestUtils.ParserCheck.parser(parser)
.withInput(input1)
.succeedsWithResult(Chr.valueOf(c1), input1.next());
TestUtils.ParserCheck.parser(parser)
.withInput(input2)
.fails();
}
示例9: valueFailsOnNonEmptyInput
import com.pholser.junit.quickcheck.Property; //导入依赖的package包/类
@Property
public void valueFailsOnNonEmptyInput(char c1) {
final Parser<Chr, Chr> parser = Combinators.value(Chr.valueOf(c1));
TestUtils.ParserCheck.parser(parser)
.withInput(Input.of(""))
.fails();
}
示例10: satisfyFailsOnNonEmptyInput
import com.pholser.junit.quickcheck.Property; //导入依赖的package包/类
@Property
public void satisfyFailsOnNonEmptyInput() {
final Parser<Chr, Chr> parser =
Combinators.satisfy("even", Predicate.of((Chr c) -> c.charValue() % 2 == 0));
TestUtils.ParserCheck.parser(parser)
.withInput(Input.of(""))
.fails();
}
示例11: anyMatchesAnything
import com.pholser.junit.quickcheck.Property; //导入依赖的package包/类
@Property
public void anyMatchesAnything(char c1) {
final Input<Chr> input = Input.of(String.valueOf(c1));
final Parser<Chr, Chr> parser = Combinators.any();
TestUtils.ParserCheck.parser(parser)
.withInput(input)
.succeedsWithResult(Chr.valueOf(c1), input.next());
}
示例12: anyFailsOnNonEmptyInput
import com.pholser.junit.quickcheck.Property; //导入依赖的package包/类
@Property
public void anyFailsOnNonEmptyInput() {
final Parser<Chr, Chr> parser = Combinators.any();
TestUtils.ParserCheck.parser(parser)
.withInput(Input.of(""))
.fails();
}
示例13: pureConsumesNoInput
import com.pholser.junit.quickcheck.Property; //导入依赖的package包/类
@Property
public void pureConsumesNoInput(char c1) {
final Input<Chr> input = Input.of("");
final Parser<Chr, Chr> parser = Parser.pure(Chr.valueOf(c1));
TestUtils.ParserCheck.parser(parser)
.withInput(input)
.succeedsWithResult(Chr.valueOf(c1), input);
}
示例14: mapTransformsValue
import com.pholser.junit.quickcheck.Property; //导入依赖的package包/类
@Property
public void mapTransformsValue(char c1) {
final Input<Chr> input = Input.of(String.valueOf(c1));
final Parser<Chr, Chr> parser =
value(Chr.valueOf(c1))
.map(c -> Chr.valueOf(c.charValue() + 1));
TestUtils.ParserCheck.parser(parser)
.withInput(input)
.succeedsWithResult(Chr.valueOf(c1 + 1), input.next());
}
示例15: apAppliesF
import com.pholser.junit.quickcheck.Property; //导入依赖的package包/类
@Property
public void apAppliesF(char c1) {
final Input<Chr> input = Input.of(String.valueOf(c1));
final F<Chr, Chr> f = c -> Chr.valueOf(c.charValue() + 1);
final Parser<Chr, Chr> parser = ap(f, any());
TestUtils.ParserCheck.parser(parser)
.withInput(input)
.succeedsWithResult(Chr.valueOf(c1 + 1), input.next());
}