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

Comparing jsr166/src/test/tck/TimeUnitTest.java (file contents):
Revision 1.4 by dl, Sat Sep 20 18:20:08 2003 UTC vs.
Revision 1.8 by dl, Tue Jan 13 12:59:29 2004 UTC

# Line 1 | Line 1
1   /*
2 < * Written by members of JCP JSR-166 Expert Group and released to the
3 < * public domain. Use, modify, and redistribute this code in any way
4 < * without acknowledgement. Other contributors include Andrew Wright,
5 < * Jeffrey Hayes, Pat Fischer, Mike Judd.
2 > * Written by Doug Lea with assistance from members of JCP JSR-166
3 > * Expert Group and released to the public domain, as explained at
4 > * http://creativecommons.org/licenses/publicdomain
5 > * Other contributors include Andrew Wright, Jeffrey Hayes,
6 > * Pat Fisher, Mike Judd.
7   */
8  
9  
# Line 20 | Line 21 | public class TimeUnitTest extends JSR166
21      }
22  
23      /**
24 <     *
24 >     * convert correctly converts sample values across the four units
25       */
26      public void testConvert() {
27          for (long t = 0; t < 10; ++t) {
# Line 76 | Line 77 | public class TimeUnitTest extends JSR166
77      }
78  
79      /**
80 <     *
80 >     * toNanos correctly converts sample values in different units to
81 >     * nanoseconds
82       */
83      public void testToNanos() {
84          for (long t = 0; t < 10; ++t) {
# Line 93 | Line 95 | public class TimeUnitTest extends JSR166
95      }
96  
97      /**
98 <     *
98 >     * toMicros correctly converts sample values in different units to
99 >     * microseconds
100       */
101      public void testToMicros() {
102          for (long t = 0; t < 10; ++t) {
# Line 110 | Line 113 | public class TimeUnitTest extends JSR166
113      }
114  
115      /**
116 <     *
116 >     * toMillis correctly converts sample values in different units to
117 >     * milliseconds
118       */
119      public void testToMillis() {
120          for (long t = 0; t < 10; ++t) {
# Line 127 | Line 131 | public class TimeUnitTest extends JSR166
131      }
132  
133      /**
134 <     *
134 >     * toSeconds correctly converts sample values in different units to
135 >     * seconds
136       */
137      public void testToSeconds() {
138          for (long t = 0; t < 10; ++t) {
# Line 145 | Line 150 | public class TimeUnitTest extends JSR166
150  
151  
152      /**
153 <     *
153 >     * convert saturates positive too-large values to Long.MAX_VALUE
154 >     * and negative to LONG.MIN_VALUE
155       */
156      public void testConvertSaturate() {
157          assertEquals(Long.MAX_VALUE,
# Line 154 | Line 160 | public class TimeUnitTest extends JSR166
160          assertEquals(Long.MIN_VALUE,
161                       TimeUnit.NANOSECONDS.convert(-Long.MAX_VALUE / 4,
162                                                    TimeUnit.SECONDS));
157
163      }
164  
165      /**
166 <     *
166 >     * toNanos saturates positive too-large values to Long.MAX_VALUE
167 >     * and negative to LONG.MIN_VALUE
168       */
169      public void testToNanosSaturate() {
170              assertEquals(Long.MAX_VALUE,
171                           TimeUnit.MILLISECONDS.toNanos(Long.MAX_VALUE / 2));
172              assertEquals(Long.MIN_VALUE,
173                           TimeUnit.MILLISECONDS.toNanos(-Long.MAX_VALUE / 3));
168            
174      }
175  
176  
177      /**
178 <     *
178 >     * toString returns string containing common name of unit
179       */
180      public void testToString() {
181          String s = TimeUnit.SECONDS.toString();
182 <        assertTrue(s.indexOf("econd") >= 0);
182 >        assertTrue(s.indexOf("ECOND") >= 0);
183      }
184  
185      
# Line 182 | Line 187 | public class TimeUnitTest extends JSR166
187       *  Timed wait without holding lock throws
188       *  IllegalMonitorStateException
189       */
185    /**
186     *
187     */
190      public void testTimedWait_IllegalMonitorException() {
191          //created a new thread with anonymous runnable
192  
# Line 215 | Line 217 | public class TimeUnitTest extends JSR166
217      }
218      
219      /**
220 <     *   timedWait will throw InterruptedException.
219 <     *  Thread t waits on timedWait while the main thread interrupts it.
220 <     *  Note:  This does not throw IllegalMonitorException since timeWait
221 <     *         is synchronized on o
222 <     */
223 <    /**
224 <     *
220 >     * timedWait throws InterruptedException when interrupted
221       */
222      public void testTimedWait() {
223          Thread t = new Thread(new Runnable() {
# Line 253 | Line 249 | public class TimeUnitTest extends JSR166
249      
250      
251      /**
252 <     *   timedJoin will throw InterruptedException.
257 <     *  Thread t waits on timedJoin while the main thread interrupts it.
258 <     */
259 <    /**
260 <     *
252 >     * timedJoin throws InterruptedException when interrupted
253       */
254      public void testTimedJoin() {
255          Thread t = new Thread(new Runnable() {
# Line 289 | Line 281 | public class TimeUnitTest extends JSR166
281      }
282      
283      /**
284 <     *   timedSleep will throw InterruptedException.
293 <     *  Thread t waits on timedSleep while the main thread interrupts it.
294 <     */
295 <    /**
296 <     *
284 >     *  timedSleep throws InterruptedException when interrupted
285       */
286      public void testTimedSleep() {
287          //created a new thread with anonymous runnable
# Line 319 | Line 307 | public class TimeUnitTest extends JSR166
307      }
308  
309      /**
310 <     *
310 >     * a deserialized serialized unit is equal
311       */
312      public void testSerialization() {
313          TimeUnit q = TimeUnit.MILLISECONDS;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines