On Thu, Oct 12, 2017 at 5:32 PM, Paul Sandoz <paul.san...@oracle.com> wrote:
> > SplittableRandomTest.java > — > > 592 int n = sr.nextInt(20); > > nextInt(1, 20) ? so you get a byte array of 1 or more in length. > Yes, I see now there is no testing at all when n == 0. Empty array and null array are both worth testing, so: Index: SplittableRandomTest.java =================================================================== RCS file: /export/home/jsr166/jsr166/jsr166/src/test/tck/SplittableRandomTest.java,v retrieving revision 1.22 diff -u -r1.22 SplittableRandomTest.java --- SplittableRandomTest.java 3 Oct 2017 22:27:04 -0000 1.22 +++ SplittableRandomTest.java 13 Oct 2017 02:31:20 -0000 @@ -562,7 +562,7 @@ */ public void testNextBytes() { SplittableRandom sr = new SplittableRandom(); - int n = sr.nextInt(20); + int n = sr.nextInt(1, 20); byte[] bytes = new byte[n]; outer: for (int i = 0; i < n; i++) { @@ -577,4 +577,18 @@ } } + /** + * Filling an empty array with random bytes succeeds without effect. + */ + public void testNextBytes_emptyArray() { + new SplittableRandom().nextBytes(new byte[0]); + } + + public void testNextBytes_nullArray() { + try { + new SplittableRandom().nextBytes(null); + shouldThrow(); + } catch (NullPointerException success) {} + } + }