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 5a95e9f commit ced4673
Show file tree
Hide file tree
Showing 52 changed files with 505 additions and 129 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,39 +37,53 @@ a copy of this software and associated documentation files (the
import java.math.BigInteger;
import java.util.List;

public class RangedBigDecimalNoMinWithLesserSpecifiedPrecisionPropertyParameterTest
public class
RangedBigDecimalNoMinWithLesserSpecifiedPrecisionPropertyParameterTest
extends BasicGeneratorPropertyParameterTest {

@InRange(max = "987654321987654321.09876")
@Precision(scale = 3)
public static final BigDecimal TYPE_BEARER = null;

private final BigDecimal max = new BigDecimal("987654321987654321.09876");
private final BigDecimal max =
new BigDecimal("987654321987654321.09876");
private final BigInteger maxBigInt = max.movePointRight(5).toBigInteger();

@Override protected void primeSourceOfRandomness() {
when(randomForParameterGenerator.nextBigInteger(
maxBigInt.subtract(maxBigInt.subtract(TEN.movePointRight(5).toBigInteger())).bitLength()))
maxBigInt.subtract(
maxBigInt.subtract(TEN.movePointRight(5).toBigInteger()))
.bitLength()))
.thenReturn(new BigInteger("6"));
when(randomForParameterGenerator.nextBigInteger(
maxBigInt.subtract(maxBigInt.subtract(TEN.pow(2).movePointRight(5).toBigInteger())).bitLength()))
maxBigInt.subtract(
maxBigInt.subtract(TEN.pow(2).movePointRight(5).toBigInteger()))
.bitLength()))
.thenReturn(new BigInteger("35"));
when(distro.sampleWithMean(1, randomForParameterGenerator)).thenReturn(0);
when(distro.sampleWithMean(2, randomForParameterGenerator)).thenReturn(1);
when(distro.sampleWithMean(1, randomForParameterGenerator))
.thenReturn(0);
when(distro.sampleWithMean(2, randomForParameterGenerator))
.thenReturn(1);
}

@Override protected int trials() {
return 2;
}

@Override protected List<?> randomValues() {
return asList(new BigDecimal("987654321987654311.09882"), new BigDecimal("987654321987654221.09911"));
return asList(
new BigDecimal("987654321987654311.09882"),
new BigDecimal("987654321987654221.09911"));
}

@Override public void verifyInteractionWithRandomness() {
verify(randomForParameterGenerator).nextBigInteger(
maxBigInt.subtract(maxBigInt.subtract(TEN.movePointRight(5).toBigInteger())).bitLength());
maxBigInt.subtract(
maxBigInt.subtract(TEN.movePointRight(5).toBigInteger()))
.bitLength());
verify(randomForParameterGenerator).nextBigInteger(
maxBigInt.subtract(maxBigInt.subtract(TEN.pow(2).movePointRight(5).toBigInteger())).bitLength());
maxBigInt.subtract(
maxBigInt.subtract(TEN.pow(2).movePointRight(5).toBigInteger()))
.bitLength());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,22 @@ a copy of this software and associated documentation files (the
public class RangedBigDecimalPropertyParameterTest
extends BasicGeneratorPropertyParameterTest {

@InRange(min = "-12345678123456781234567812345.678", max = "9876543219876543.21")
@InRange(
min = "-12345678123456781234567812345.678",
max = "9876543219876543.21")
public static final BigDecimal TYPE_BEARER = null;

private final BigDecimal min = new BigDecimal("-12345678123456781234567812345.678");
private final BigDecimal min =
new BigDecimal("-12345678123456781234567812345.678");
private final BigDecimal max = new BigDecimal("9876543219876543.21");
private int numberOfBits;

@Override protected void primeSourceOfRandomness() {
numberOfBits = max.movePointRight(3).subtract(min.movePointRight(3)).toBigInteger().bitLength();
numberOfBits =
max.movePointRight(3)
.subtract(min.movePointRight(3))
.toBigInteger()
.bitLength();
when(randomForParameterGenerator.nextBigInteger(numberOfBits))
.thenReturn(new BigInteger("2").pow(numberOfBits).subtract(ONE))
.thenReturn(ONE)
Expand All @@ -72,6 +79,7 @@ public class RangedBigDecimalPropertyParameterTest
}

@Override public void verifyInteractionWithRandomness() {
verify(randomForParameterGenerator, times(5)).nextBigInteger(numberOfBits);
verify(randomForParameterGenerator, times(5))
.nextBigInteger(numberOfBits);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,23 @@ a copy of this software and associated documentation files (the
public class RangedBigDecimalWithGreaterSpecifiedPrecisionPropertyParameterTest
extends BasicGeneratorPropertyParameterTest {

@InRange(min = "-12345678123456781234567812345.678", max = "9876543219876543.21")
@InRange(
min = "-12345678123456781234567812345.678",
max = "9876543219876543.21")
@Precision(scale = 6)
public static final BigDecimal TYPE_BEARER = null;

private final BigDecimal min = new BigDecimal("-12345678123456781234567812345.678");
private final BigDecimal min =
new BigDecimal("-12345678123456781234567812345.678");
private final BigDecimal max = new BigDecimal("9876543219876543.21");
private int numberOfBits;

@Override protected void primeSourceOfRandomness() {
numberOfBits = max.movePointRight(6).subtract(min.movePointRight(6)).toBigInteger().bitLength();
numberOfBits =
max.movePointRight(6)
.subtract(min.movePointRight(6))
.toBigInteger()
.bitLength();
when(randomForParameterGenerator.nextBigInteger(numberOfBits))
.thenReturn(new BigInteger("2").pow(numberOfBits).subtract(ONE))
.thenReturn(ONE)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,16 +43,23 @@ a copy of this software and associated documentation files (the
public class RangedBigDecimalWithLesserSpecifiedPrecisionPropertyParameterTest
extends BasicGeneratorPropertyParameterTest {

@InRange(min = "-12345678123456781234567812345.678", max = "9876543219876543.21")
@InRange(
min = "-12345678123456781234567812345.678",
max = "9876543219876543.21")
@Precision(scale = 2)
public static final BigDecimal TYPE_BEARER = null;

private final BigDecimal min = new BigDecimal("-12345678123456781234567812345.678");
private final BigDecimal min =
new BigDecimal("-12345678123456781234567812345.678");
private final BigDecimal max = new BigDecimal("9876543219876543.21");
private int numberOfBits;

@Override protected void primeSourceOfRandomness() {
numberOfBits = max.movePointRight(3).subtract(min.movePointRight(3)).toBigInteger().bitLength();
numberOfBits =
max.movePointRight(3)
.subtract(min.movePointRight(3))
.toBigInteger()
.bitLength();
when(randomForParameterGenerator.nextBigInteger(numberOfBits))
.thenReturn(new BigInteger("2").pow(numberOfBits).subtract(ONE))
.thenReturn(ONE)
Expand All @@ -74,6 +81,7 @@ public class RangedBigDecimalWithLesserSpecifiedPrecisionPropertyParameterTest
}

@Override public void verifyInteractionWithRandomness() {
verify(randomForParameterGenerator, times(5)).nextBigInteger(numberOfBits);
verify(randomForParameterGenerator, times(5))
.nextBigInteger(numberOfBits);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,24 +44,32 @@ public class RangedBigIntegerNoMaxPropertyParameterTest
private final BigInteger min = new BigInteger("-987654321987654321");

@Override protected void primeSourceOfRandomness() {
when(randomForParameterGenerator.nextBigInteger(min.add(TEN).subtract(min).bitLength()))
when(randomForParameterGenerator.nextBigInteger(
min.add(TEN).subtract(min).bitLength()))
.thenReturn(new BigInteger("6"));
when(randomForParameterGenerator.nextBigInteger(min.add(TEN.pow(2)).subtract(min).bitLength()))
when(randomForParameterGenerator.nextBigInteger(
min.add(TEN.pow(2)).subtract(min).bitLength()))
.thenReturn(new BigInteger("35"));
when(distro.sampleWithMean(1, randomForParameterGenerator)).thenReturn(0);
when(distro.sampleWithMean(2, randomForParameterGenerator)).thenReturn(1);
when(distro.sampleWithMean(1, randomForParameterGenerator))
.thenReturn(0);
when(distro.sampleWithMean(2, randomForParameterGenerator))
.thenReturn(1);
}

@Override protected int trials() {
return 2;
}

@Override protected List<?> randomValues() {
return asList(new BigInteger("-987654321987654315"), new BigInteger("-987654321987654286"));
return asList(
new BigInteger("-987654321987654315"),
new BigInteger("-987654321987654286"));
}

@Override public void verifyInteractionWithRandomness() {
verify(randomForParameterGenerator).nextBigInteger(min.add(TEN).subtract(min).bitLength());
verify(randomForParameterGenerator).nextBigInteger(min.add(TEN.pow(2)).subtract(min).bitLength());
verify(randomForParameterGenerator)
.nextBigInteger(min.add(TEN).subtract(min).bitLength());
verify(randomForParameterGenerator)
.nextBigInteger(min.add(TEN.pow(2)).subtract(min).bitLength());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,24 +44,32 @@ public class RangedBigIntegerNoMinPropertyParameterTest
private final BigInteger max = new BigInteger("987654321987654321");

@Override protected void primeSourceOfRandomness() {
when(randomForParameterGenerator.nextBigInteger(max.subtract(max.subtract(TEN)).bitLength()))
when(randomForParameterGenerator.nextBigInteger(
max.subtract(max.subtract(TEN)).bitLength()))
.thenReturn(new BigInteger("6"));
when(randomForParameterGenerator.nextBigInteger(max.subtract(max.subtract(TEN.pow(2))).bitLength()))
when(randomForParameterGenerator.nextBigInteger(
max.subtract(max.subtract(TEN.pow(2))).bitLength()))
.thenReturn(new BigInteger("35"));
when(distro.sampleWithMean(1, randomForParameterGenerator)).thenReturn(0);
when(distro.sampleWithMean(2, randomForParameterGenerator)).thenReturn(1);
when(distro.sampleWithMean(1, randomForParameterGenerator))
.thenReturn(0);
when(distro.sampleWithMean(2, randomForParameterGenerator))
.thenReturn(1);
}

@Override protected int trials() {
return 2;
}

@Override protected List<?> randomValues() {
return asList(new BigInteger("987654321987654317"), new BigInteger("987654321987654256"));
return asList(
new BigInteger("987654321987654317"),
new BigInteger("987654321987654256"));
}

@Override public void verifyInteractionWithRandomness() {
verify(randomForParameterGenerator).nextBigInteger(max.subtract(max.subtract(TEN)).bitLength());
verify(randomForParameterGenerator).nextBigInteger(max.subtract(max.subtract(TEN.pow(2))).bitLength());
verify(randomForParameterGenerator)
.nextBigInteger(max.subtract(max.subtract(TEN)).bitLength());
verify(randomForParameterGenerator)
.nextBigInteger(max.subtract(max.subtract(TEN.pow(2))).bitLength());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,15 @@ a copy of this software and associated documentation files (the
public class RangedBigIntegerPropertyParameterTest
extends BasicGeneratorPropertyParameterTest {

@InRange(min = "-12345678123456781234567812345678", max = "987654321987654321")
@InRange(
min = "-12345678123456781234567812345678",
max = "987654321987654321")
public static final BigInteger TYPE_BEARER = null;

private final BigInteger min = new BigInteger("-12345678123456781234567812345678");
private final BigInteger max = new BigInteger("987654321987654321");
private final BigInteger min =
new BigInteger("-12345678123456781234567812345678");
private final BigInteger max =
new BigInteger("987654321987654321");

@Override protected void primeSourceOfRandomness() {
int numberOfBits = max.subtract(min).bitLength();
Expand All @@ -62,10 +66,15 @@ public class RangedBigIntegerPropertyParameterTest
}

@Override protected List<?> randomValues() {
return asList(min.add(ONE), min.add(TEN), min.add(ZERO), min.add(new BigInteger("234234234234")));
return asList(
min.add(ONE),
min.add(TEN),
min.add(ZERO),
min.add(new BigInteger("234234234234")));
}

@Override public void verifyInteractionWithRandomness() {
verify(randomForParameterGenerator, times(5)).nextBigInteger(max.subtract(min).bitLength());
verify(randomForParameterGenerator, times(5))
.nextBigInteger(max.subtract(min).bitLength());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,17 @@ a copy of this software and associated documentation files (the
import java.util.ArrayList;
import java.util.List;

public class CharsetPropertyParameterTest extends BasicGeneratorPropertyParameterTest {
public class CharsetPropertyParameterTest
extends BasicGeneratorPropertyParameterTest {

public static final Charset TYPE_BEARER = null;

private static final List<String> CHARSET_NAMES =
new ArrayList<>(Charset.availableCharsets().keySet());

@Override protected void primeSourceOfRandomness() {
when(randomForParameterGenerator.choose(Charset.availableCharsets().keySet()))
when(randomForParameterGenerator.choose(
Charset.availableCharsets().keySet()))
.thenReturn(CHARSET_NAMES.get(2))
.thenReturn(CHARSET_NAMES.get(0))
.thenReturn(CHARSET_NAMES.get(1));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,20 @@ a copy of this software and associated documentation files (the
import static java.util.Arrays.*;
import static org.mockito.Mockito.*;

public class BitSetPropertyParameterTest extends BasicGeneratorPropertyParameterTest {
public class BitSetPropertyParameterTest
extends BasicGeneratorPropertyParameterTest {

public static final BitSet TYPE_BEARER = null;

@Override protected void primeSourceOfRandomness() {
when(Generating.booleans(randomForParameterGenerator))
.thenReturn(true).thenReturn(false).thenReturn(true);
when(distro.sampleWithMean(1, randomForParameterGenerator)).thenReturn(0);
when(distro.sampleWithMean(2, randomForParameterGenerator)).thenReturn(1);
when(distro.sampleWithMean(3, randomForParameterGenerator)).thenReturn(2);
when(distro.sampleWithMean(1, randomForParameterGenerator))
.thenReturn(0);
when(distro.sampleWithMean(2, randomForParameterGenerator))
.thenReturn(1);
when(distro.sampleWithMean(3, randomForParameterGenerator))
.thenReturn(2);
}

@Override protected int trials() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,23 +35,39 @@ a copy of this software and associated documentation files (the
import static java.util.Arrays.*;
import static org.mockito.Mockito.*;

public class DatePropertyParameterTest extends BasicGeneratorPropertyParameterTest {
public class DatePropertyParameterTest
extends BasicGeneratorPropertyParameterTest {

public static final Date TYPE_BEARER = null;

@Override protected void primeSourceOfRandomness() {
when(Generating.longs(randomForParameterGenerator, Integer.MIN_VALUE, Long.MAX_VALUE))
.thenReturn(0L).thenReturn(60000L).thenReturn(100000000L).thenReturn(300000000000L);
when(Generating.longs(
randomForParameterGenerator,
Integer.MIN_VALUE,
Long.MAX_VALUE))
.thenReturn(0L)
.thenReturn(60000L)
.thenReturn(100000000L)
.thenReturn(300000000000L);
}

@Override protected int trials() {
return 4;
}

@Override protected List<?> randomValues() {
return asList(new Date(0), new Date(60000), new Date(100000000), new Date(300000000000L));
return asList(
new Date(0),
new Date(60000),
new Date(100000000),
new Date(300000000000L));
}

@Override public void verifyInteractionWithRandomness() {
verifyLongs(randomForParameterGenerator, times(4), Integer.MIN_VALUE, Long.MAX_VALUE);
verifyLongs(
randomForParameterGenerator,
times(4),
Integer.MIN_VALUE,
Long.MAX_VALUE);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,15 @@ public class ListOfExtendsShortPropertyParameterTest

@Override protected void primeSourceOfRandomness() {
when(Generating.shorts(randomForParameterGenerator))
.thenReturn((short) -1).thenReturn((short) -2).thenReturn((short) -3);
when(distro.sampleWithMean(1, randomForParameterGenerator)).thenReturn(0);
when(distro.sampleWithMean(2, randomForParameterGenerator)).thenReturn(1);
when(distro.sampleWithMean(3, randomForParameterGenerator)).thenReturn(2);
.thenReturn((short) -1)
.thenReturn((short) -2)
.thenReturn((short) -3);
when(distro.sampleWithMean(1, randomForParameterGenerator))
.thenReturn(0);
when(distro.sampleWithMean(2, randomForParameterGenerator))
.thenReturn(1);
when(distro.sampleWithMean(3, randomForParameterGenerator))
.thenReturn(2);
}

@Override protected int trials() {
Expand Down

0 comments on commit ced4673

Please sign in to comment.