Duplicate :
|
|
Relates :
|
|
Relates :
|
This is what I found: 1. Seed is constant hence redundant to print on failure ./BigInteger/ModPow.java ./BigInteger/PrimitiveConversionTests.java 2. Seed is printed on failure ./BigDecimal/StringConstructor.java 3. Seed is not printed on failure 3.1 Uses parameterless Random() ./BigInteger/BigIntegerTest.java ./BigInteger/ModPow65537.java ./BigInteger/SymmetricRangeTests.java Fixing these tests to print the seed is not a problem as a construct such as private static int seed = new Random().nextInt(); private static Random rnd = new Random(seed); which is used in the StringConstructor test could be applied. The Random instance actually used is ‘rnd’ and while its seed itself is random it is known and may be printed. A slight change might actually be better: private static Random rnd; private static long seed; static { rnd = new Random(); seed = rnd.nextLong(); rnd.setSeed(seed); } 3.2 Uses parameterless SplittableRandom() ./BigInteger/PrimeTest.java Something similar to what is currently done in StringConstructor could be done here as well to fix the problem. SplittableRandom does not have a setSeed() method so the other approach is infeasible. Note that there is no way to retrieve from an instance of either class the seed that was used by the parameterless constructor.
|