Skip to content

Commit

Permalink
"null" is allowed as seed.
Browse files Browse the repository at this point in the history
  • Loading branch information
Gilles committed Aug 30, 2016
1 parent 3e8eb56 commit bc86f3f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,9 @@ Class<?>[] getArgs() {
* for this RNG type.
*/
public <SEED> boolean isNativeSeed(SEED seed) {
return getSeed().equals(seed.getClass());
return seed == null ?
false :
getSeed().equals(seed.getClass());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ public void testAllSeedTypes() {
final int[] intArraySeed = new int[] { 0, 11, -22, 33, -44, 55, -66, 77, -88, 99 };
final long[] longArraySeed = new long[] { 11111L, -222222L, 3333333L, -44444444L };

final Object[] seeds = new Object[] { intSeed, longSeed, intArraySeed, longArraySeed };
final Object[] seeds = new Object[] { null, intSeed, longSeed, intArraySeed, longArraySeed };

int nonNativeSeedCount = 0;
int seedCount = 0;
Expand All @@ -263,8 +263,8 @@ public void testAllSeedTypes() {
RandomSource.create(originalSource, s, originalArgs);
}

Assert.assertEquals(4, seedCount);
Assert.assertEquals(3, nonNativeSeedCount);
Assert.assertEquals(5, seedCount);
Assert.assertEquals(4, nonNativeSeedCount);
}

@Test
Expand Down

0 comments on commit bc86f3f

Please sign in to comment.