Skip to content

Commit

Permalink
update testUintTypeSymmetry
Browse files Browse the repository at this point in the history
update gradle and maven test parallelism
  • Loading branch information
esaulpaugh committed Oct 9, 2019
1 parent 8c82b17 commit 9e3daa5
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 16 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ group 'com.esaulpaugh'
version '1.4.9-SNAPSHOT'

test {
maxParallelForks = (int) Runtime.runtime.availableProcessors().intdiv(2) ?: 1
maxParallelForks = (int) Runtime.runtime.availableProcessors() ?: 1
}

task javadocJar(type: Jar, dependsOn: javadoc) {
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@
<configuration>
<useSystemClassLoader>false</useSystemClassLoader>
<parallel>all</parallel>
<threadCount>2</threadCount>
<threadCount>8</threadCount>
</configuration>
</plugin>
<plugin>
Expand Down
34 changes: 20 additions & 14 deletions src/test/java/com/esaulpaugh/headlong/abi/UnsignedTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -102,21 +102,27 @@ public void testToSigned() {
@Test
public void testUintTypeSymmetry() {
Random r = new Random(MonteCarloTest.getSeed(System.nanoTime()));
Integers.UintType type = new Integers.UintType(64);
final long mask = (long) (Math.pow(2, 64) - 1.0d);
for (int j = 0; j < 1_000; j++) {
long x = pickRandom(r);
x &= mask;
Assertions.assertEquals(x, type.toSigned(type.toUnsigned(x)));
Assertions.assertEquals(x, type.toUnsigned(type.toSigned(x)));
BigInteger bigIntX = BigInteger.valueOf(x);
Assertions.assertEquals(bigIntX, type.toUnsigned(type.toSigned(bigIntX)));
for (int i = 1; i < 64; i++) {
Integers.UintType type = new Integers.UintType(i);
final long mask = (long) Math.pow(2, i - 1) - 1L;
for (int j = 0; j < 25; j++) {
long x = pickRandom(r);
x &= mask;
Assertions.assertEquals(x, type.toSigned(type.toUnsigned(x)));
Assertions.assertEquals(x, type.toUnsigned(type.toSigned(x)));
BigInteger bigIntX = BigInteger.valueOf(x);
Assertions.assertEquals(bigIntX, type.toUnsigned(type.toSigned(bigIntX)));
Assertions.assertEquals(bigIntX, type.toSigned(type.toUnsigned(bigIntX)));
}
}
for (int j = 0; j < 1_000; j++) {
BigInteger x = BigInteger.valueOf(pickRandom(r));
Assertions.assertEquals(x, type.toSigned(type.toUnsigned(x)));
x = x.abs();
Assertions.assertEquals(x, type.toUnsigned(type.toSigned(x)));
for (int i = 64; i <= 256; i++) {
Integers.UintType type = new Integers.UintType(i);
for (int j = 0; j < 25; j++) {
BigInteger x = BigInteger.valueOf(pickRandom(r));
Assertions.assertEquals(x, type.toSigned(type.toUnsigned(x)));
x = x.abs();
Assertions.assertEquals(x, type.toUnsigned(type.toSigned(x)));
}
}
}

Expand Down

0 comments on commit 9e3daa5

Please sign in to comment.