Skip to content

Commit

Permalink
tidying
Browse files Browse the repository at this point in the history
  • Loading branch information
pholser committed Nov 21, 2020
1 parent ced4673 commit ad8d5eb
Show file tree
Hide file tree
Showing 9 changed files with 52 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,14 @@ public FunctionGenerator() {
}

@SuppressWarnings("unchecked")
@Override public Function<F, T> generate(SourceOfRandomness random, GenerationStatus status) {
return makeLambda(Function.class, componentGenerators().get(1), status);
@Override public Function<F, T> generate(
SourceOfRandomness random,
GenerationStatus status) {

return makeLambda(
Function.class,
componentGenerators().get(1),
status);
}

@Override public int numberOfNeededComponents() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ a copy of this software and associated documentation files (the
/**
* Produces values of type {@link Optional}.
*/
@SuppressWarnings("ALL")
@SuppressWarnings("Guava")
public class OptionalGenerator extends ComponentizedGenerator<Optional> {
public OptionalGenerator() {
super(Optional.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,13 @@ public PredicateGenerator() {
super(Predicate.class);
}

@Override
public void provide(Generators provided) {
@Override public void provide(Generators provided) {
super.provide(provided);

generator = gen().type(boolean.class);
}

@SuppressWarnings("unchecked")
@SuppressWarnings("unchecked,Guava")
@Override public Predicate<T> generate(
SourceOfRandomness random,
GenerationStatus status) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,15 @@ public SupplierGenerator() {
super(Supplier.class);
}

@SuppressWarnings("unchecked")
@Override public Supplier<T> generate(SourceOfRandomness random, GenerationStatus status) {
return makeLambda(Supplier.class, componentGenerators().get(0), status);
@SuppressWarnings("unchecked,Guava")
@Override public Supplier<T> generate(
SourceOfRandomness random,
GenerationStatus status) {

return makeLambda(
Supplier.class,
componentGenerators().get(0),
status);
}

@Override public int numberOfNeededComponents() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ a copy of this software and associated documentation files (the
import java.util.List;
import java.util.Random;

public class FunctionOfStringToIntPropertyParameterTest extends CorePropertyParameterTest {
public class FunctionOfStringToIntPropertyParameterTest
extends CorePropertyParameterTest {

@SuppressWarnings("Guava")
public static final Function<String, Integer> TYPE_BEARER = null;

Expand All @@ -64,16 +66,23 @@ public class FunctionOfStringToIntPropertyParameterTest extends CorePropertyPara
}

@SuppressWarnings("Guava")
@Override protected void verifyEquivalenceOfPropertyParameter(int index, Object expected, Object actual)
@Override protected void verifyEquivalenceOfPropertyParameter(
int index,
Object expected,
Object actual)
throws Exception {

@SuppressWarnings("unchecked")
Function<String, Integer> f = (Function<String, Integer>) actual;

String argument = "foobar";

SourceOfRandomness source = new SourceOfRandomness(new Random());
source.setSeed(Objects.hashCode(argument));
Integer value = (Integer) repository.generatorFor(typeOf(getClass(), "integer")).generate(source, null);
Integer value =
(Integer)
repository.generatorFor(typeOf(getClass(), "integer"))
.generate(source, null);

for (int i = 0; i < 10000; ++i)
assertEquals(value, f.apply(argument));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,16 +63,22 @@ public static class FooToZilch {
}

@Test public void superShortToInteger() throws Exception {
assertThat(testResult(SuperShortToExtendsInteger.class), isSuccessful());
assertEquals(defaultPropertyTrialCount(), SuperShortToExtendsInteger.iterations);
assertThat(
testResult(SuperShortToExtendsInteger.class),
isSuccessful());
assertEquals(
defaultPropertyTrialCount(),
SuperShortToExtendsInteger.iterations);
}

@SuppressWarnings("Guava")
@RunWith(JUnitQuickcheck.class)
public static class SuperShortToExtendsInteger {
static int iterations;

@Property public void shouldHold(Function<? super Foo, ? extends Zilch> f) {
@Property public void shouldHold(
Function<? super Foo, ? extends Zilch> f) {

++iterations;

Foo foo = new Foo(2);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,10 @@ public class OptionalPropertyParameterTest {
public static class OptionalString {
@SuppressWarnings("Guava")
@Property public void works(
Optional<@From(Encoded.class) @InCharset("US-ASCII") String> optional) {
Optional<
@From(Encoded.class)
@InCharset("US-ASCII")
String> optional) {

assumeTrue(optional.isPresent());
assertTrue(optional.get().codePoints().allMatch(i -> i < 128));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ public class PredicatePropertyParameterTest {

@RunWith(JUnitQuickcheck.class)
public static class DefiniteArgType {
@Property public void x(@SuppressWarnings("Guava") Predicate<String> p) {
@Property public void x(
@SuppressWarnings("Guava") Predicate<String> p) {

p.apply("abc");
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,9 @@ public static class SupplyingInts {

@RunWith(JUnitQuickcheck.class)
public static class SupplyingUnresolvedLists<T> {
@Property public void holds(Supplier<List<T>> source) {
@Property public void holds(
@SuppressWarnings("Guava") Supplier<List<T>> source) {

for (T each : source.get()) {
// ensure types are ok
}
Expand All @@ -70,7 +72,7 @@ public static class SupplyingUnresolvedLists<T> {
@RunWith(JUnitQuickcheck.class)
public static class SupplyingUpperBounded {
@Property public <T extends Integer> void holds(
Supplier<? extends T[]> source) {
@SuppressWarnings("Guava") Supplier<? extends T[]> source) {

T[] items = source.get();
assumeThat(items.length, greaterThan(0));
Expand Down

0 comments on commit ad8d5eb

Please sign in to comment.