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

Comparing jsr166/src/test/tck/ThreadLocalRandomTest.java (file contents):
Revision 1.1 by dl, Fri Jul 31 23:02:50 2009 UTC vs.
Revision 1.3 by jsr166, Tue Aug 4 10:04:47 2009 UTC

# Line 11 | Line 11 | import java.util.*;
11   public class ThreadLocalRandomTest extends JSR166TestCase {
12  
13      public static void main(String[] args) {
14 <        junit.textui.TestRunner.run (suite());  
14 >        junit.textui.TestRunner.run (suite());
15      }
16      public static Test suite() {
17          return new TestSuite(ThreadLocalRandomTest.class);
# Line 19 | Line 19 | public class ThreadLocalRandomTest exten
19  
20      /**
21       * Testing coverage notes:
22 <     *
22 >     *
23       * We don't test randomness properties, but only that repeated
24       * calls, up to NCALLS tries, produce at least one different
25       * result.  For bounded versions, we sample various intervals
26       * across multiples of primes.
27       */
28  
29 <    //
29 >    //
30      static final int NCALLS = 10000;
31  
32      // max sampled int bound
# Line 41 | Line 41 | public class ThreadLocalRandomTest exten
41      public void testSetSeed() {
42          try {
43              ThreadLocalRandom.current().setSeed(17);
44 <        } catch(UnsupportedOperationException success) {
44 >            shouldThrow();
45 >        } catch (UnsupportedOperationException success) {
46          }
47      }
48  
# Line 119 | Line 120 | public class ThreadLocalRandomTest exten
120      public void testNextIntBoundedNeg() {
121          try {
122              int  f = ThreadLocalRandom.current().nextInt(-17);
123 <        } catch(IllegalArgumentException success) {
123 >            shouldThrow();
124 >        } catch (IllegalArgumentException success) {
125          }
126      }
127  
# Line 129 | Line 131 | public class ThreadLocalRandomTest exten
131      public void testNextIntBadBounds() {
132          try {
133              int  f = ThreadLocalRandom.current().nextInt(17, 2);
134 <        } catch(IllegalArgumentException success) {
134 >            shouldThrow();
135 >        } catch (IllegalArgumentException success) {
136          }
137      }
138  
# Line 145 | Line 148 | public class ThreadLocalRandomTest exten
148              assertTrue(0 <= f && f < bound);
149              int i = 0;
150              int j;
151 <            while (i < NCALLS &&
151 >            while (i < NCALLS &&
152                     (j = ThreadLocalRandom.current().nextInt(bound)) == f) {
153                  assertTrue(0 <= j && j < bound);
154                  ++i;
# Line 166 | Line 169 | public class ThreadLocalRandomTest exten
169                  assertTrue(least <= f && f < bound);
170                  int i = 0;
171                  int j;
172 <                while (i < NCALLS &&
172 >                while (i < NCALLS &&
173                         (j = ThreadLocalRandom.current().nextInt(least, bound)) == f) {
174                      assertTrue(least <= j && j < bound);
175                      ++i;
# Line 182 | Line 185 | public class ThreadLocalRandomTest exten
185      public void testNextLongBoundedNeg() {
186          try {
187              long  f = ThreadLocalRandom.current().nextLong(-17);
188 <        } catch(IllegalArgumentException success) {
188 >            shouldThrow();
189 >        } catch (IllegalArgumentException success) {
190          }
191      }
192  
# Line 192 | Line 196 | public class ThreadLocalRandomTest exten
196      public void testNextLongBadBounds() {
197          try {
198              long  f = ThreadLocalRandom.current().nextLong(17, 2);
199 <        } catch(IllegalArgumentException success) {
199 >            shouldThrow();
200 >        } catch (IllegalArgumentException success) {
201          }
202      }
203  
# Line 206 | Line 211 | public class ThreadLocalRandomTest exten
211              assertTrue(0 <= f && f < bound);
212              int i = 0;
213              long j;
214 <            while (i < NCALLS &&
214 >            while (i < NCALLS &&
215                     (j = ThreadLocalRandom.current().nextLong(bound)) == f) {
216                  assertTrue(0 <= j && j < bound);
217                  ++i;
# Line 226 | Line 231 | public class ThreadLocalRandomTest exten
231                  assertTrue(least <= f && f < bound);
232                  int i = 0;
233                  long j;
234 <                while (i < NCALLS &&
234 >                while (i < NCALLS &&
235                         (j = ThreadLocalRandom.current().nextLong(least, bound)) == f) {
236                      assertTrue(least <= j && j < bound);
237                      ++i;
# Line 248 | Line 253 | public class ThreadLocalRandomTest exten
253                  assertTrue(least <= f && f < bound);
254                  int i = 0;
255                  double j;
256 <                while (i < NCALLS &&
256 >                while (i < NCALLS &&
257                         (j = ThreadLocalRandom.current().nextDouble(least, bound)) == f) {
258                      assertTrue(least <= j && j < bound);
259                      ++i;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines