ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/jsr166/jsr166/src/test/tck/SplittableRandomTest.java
(Generate patch)

Comparing jsr166/src/test/tck/SplittableRandomTest.java (file contents):
Revision 1.9 by jsr166, Tue Sep 24 06:35:35 2013 UTC vs.
Revision 1.13 by jsr166, Fri Sep 27 20:29:31 2013 UTC

# Line 39 | Line 39 | public class SplittableRandomTest extend
39      static final int NCALLS = 10000;
40  
41      // max sampled int bound
42 <    static final int MAX_INT_BOUND = (1 << 28);
42 >    static final int MAX_INT_BOUND = (1 << 26);
43  
44      // max sampled long bound
45 <    static final long MAX_LONG_BOUND = (1L << 42);
45 >    static final long MAX_LONG_BOUND = (1L << 40);
46  
47      // Number of replications for other checks
48      static final int REPS =
# Line 130 | Line 130 | public class SplittableRandomTest extend
130      /**
131       * nextInt(non-positive) throws IllegalArgumentException
132       */
133 <    public void testNextIntNonPositive() {
133 >    public void testNextIntBoundNonPositive() {
134          SplittableRandom sr = new SplittableRandom();
135          Runnable[] throwingActions = {
136              () -> sr.nextInt(-17),
# Line 145 | Line 145 | public class SplittableRandomTest extend
145       */
146      public void testNextIntBadBounds() {
147          SplittableRandom sr = new SplittableRandom();
148 <        try {
149 <            int f = sr.nextInt(17, 2);
150 <            shouldThrow();
151 <        } catch (IllegalArgumentException success) {}
148 >        Runnable[] throwingActions = {
149 >            () -> sr.nextInt(17, 2),
150 >            () -> sr.nextInt(-42, -42),
151 >            () -> sr.nextInt(Integer.MAX_VALUE, Integer.MIN_VALUE),
152 >        };
153 >        assertThrows(IllegalArgumentException.class, throwingActions);
154      }
155  
156      /**
# Line 197 | Line 199 | public class SplittableRandomTest extend
199      /**
200       * nextLong(non-positive) throws IllegalArgumentException
201       */
202 <    public void testNextLongNonPositive() {
202 >    public void testNextLongBoundNonPositive() {
203          SplittableRandom sr = new SplittableRandom();
204          Runnable[] throwingActions = {
205              () -> sr.nextLong(-17L),
# Line 212 | Line 214 | public class SplittableRandomTest extend
214       */
215      public void testNextLongBadBounds() {
216          SplittableRandom sr = new SplittableRandom();
217 <        try {
218 <            long f = sr.nextLong(17, 2);
219 <            shouldThrow();
220 <        } catch (IllegalArgumentException success) {}
217 >        Runnable[] throwingActions = {
218 >            () -> sr.nextLong(17L, 2L),
219 >            () -> sr.nextLong(-42L, -42L),
220 >            () -> sr.nextLong(Long.MAX_VALUE, Long.MIN_VALUE),
221 >        };
222 >        assertThrows(IllegalArgumentException.class, throwingActions);
223      }
224  
225      /**
# Line 263 | Line 267 | public class SplittableRandomTest extend
267      /**
268       * nextDouble(non-positive) throws IllegalArgumentException
269       */
270 <    public void testNextDoubleNonPositive() {
270 >    public void testNextDoubleBoundNonPositive() {
271          SplittableRandom sr = new SplittableRandom();
272          Runnable[] throwingActions = {
273              () -> sr.nextDouble(-17.0d),
# Line 276 | Line 280 | public class SplittableRandomTest extend
280      }
281  
282      /**
283 +     * nextDouble(! (least < bound)) throws IllegalArgumentException
284 +     */
285 +    public void testNextDoubleBadBounds() {
286 +        SplittableRandom sr = new SplittableRandom();
287 +        Runnable[] throwingActions = {
288 +            () -> sr.nextDouble(17.0d, 2.0d),
289 +            () -> sr.nextDouble(-42.0d, -42.0d),
290 +            () -> sr.nextDouble(Double.MAX_VALUE, Double.MIN_VALUE),
291 +            () -> sr.nextDouble(Double.NaN, 0.0d),
292 +            () -> sr.nextDouble(0.0d, Double.NaN),
293 +        };
294 +        assertThrows(IllegalArgumentException.class, throwingActions);
295 +    }
296 +
297 +    // TODO: Test infinite bounds!
298 +    //() -> sr.nextDouble(Double.NEGATIVE_INFINITY, 0.0d),
299 +    //() -> sr.nextDouble(0.0d, Double.POSITIVE_INFINITY),
300 +
301 +    /**
302       * nextDouble(least, bound) returns least <= value < bound;
303       * repeated calls produce at least two distinct results
304       */

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines