[cvs] / jsr166 / src / test / tck / TimeUnitTest.java Repository:
ViewVC logotype

Diff of /jsr166/src/test/tck/TimeUnitTest.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.4, Sat Sep 20 18:20:08 2003 UTC revision 1.5, Thu Sep 25 11:02:42 2003 UTC
# Line 20  Line 20 
20      }      }
21    
22      /**      /**
23       *       * convert correctly converts sample values across the four units
24       */       */
25      public void testConvert() {      public void testConvert() {
26          for (long t = 0; t < 10; ++t) {          for (long t = 0; t < 10; ++t) {
# Line 76  Line 76 
76      }      }
77    
78      /**      /**
79       *       * toNanos correctly converts sample values in different units to
80         * nanoseconds
81       */       */
82      public void testToNanos() {      public void testToNanos() {
83          for (long t = 0; t < 10; ++t) {          for (long t = 0; t < 10; ++t) {
# Line 93  Line 94 
94      }      }
95    
96      /**      /**
97       *       * toMicros correctly converts sample values in different units to
98         * microseconds
99       */       */
100      public void testToMicros() {      public void testToMicros() {
101          for (long t = 0; t < 10; ++t) {          for (long t = 0; t < 10; ++t) {
# Line 110  Line 112 
112      }      }
113    
114      /**      /**
115       *       * toMillis correctly converts sample values in different units to
116         * milliseconds
117       */       */
118      public void testToMillis() {      public void testToMillis() {
119          for (long t = 0; t < 10; ++t) {          for (long t = 0; t < 10; ++t) {
# Line 127  Line 130 
130      }      }
131    
132      /**      /**
133       *       * toSeconds correctly converts sample values in different units to
134         * seconds
135       */       */
136      public void testToSeconds() {      public void testToSeconds() {
137          for (long t = 0; t < 10; ++t) {          for (long t = 0; t < 10; ++t) {
# Line 145  Line 149 
149    
150    
151      /**      /**
152       *       * convert saturates positive too-large values to Long.MAX_VALUE
153         * and negative to LONG.MIN_VALUE
154       */       */
155      public void testConvertSaturate() {      public void testConvertSaturate() {
156          assertEquals(Long.MAX_VALUE,          assertEquals(Long.MAX_VALUE,
# Line 154  Line 159 
159          assertEquals(Long.MIN_VALUE,          assertEquals(Long.MIN_VALUE,
160                       TimeUnit.NANOSECONDS.convert(-Long.MAX_VALUE / 4,                       TimeUnit.NANOSECONDS.convert(-Long.MAX_VALUE / 4,
161                                                    TimeUnit.SECONDS));                                                    TimeUnit.SECONDS));
   
162      }      }
163    
164      /**      /**
165       *       * toNanos saturates positive too-large values to Long.MAX_VALUE
166         * and negative to LONG.MIN_VALUE
167       */       */
168      public void testToNanosSaturate() {      public void testToNanosSaturate() {
169              assertEquals(Long.MAX_VALUE,              assertEquals(Long.MAX_VALUE,
170                           TimeUnit.MILLISECONDS.toNanos(Long.MAX_VALUE / 2));                           TimeUnit.MILLISECONDS.toNanos(Long.MAX_VALUE / 2));
171              assertEquals(Long.MIN_VALUE,              assertEquals(Long.MIN_VALUE,
172                           TimeUnit.MILLISECONDS.toNanos(-Long.MAX_VALUE / 3));                           TimeUnit.MILLISECONDS.toNanos(-Long.MAX_VALUE / 3));
   
173      }      }
174    
175    
176      /**      /**
177       *       * toString returns string containing commn name of unit
178       */       */
179      public void testToString() {      public void testToString() {
180          String s = TimeUnit.SECONDS.toString();          String s = TimeUnit.SECONDS.toString();
# Line 182  Line 186 
186       *  Timed wait without holding lock throws       *  Timed wait without holding lock throws
187       *  IllegalMonitorStateException       *  IllegalMonitorStateException
188       */       */
     /**  
      *  
      */  
189      public void testTimedWait_IllegalMonitorException() {      public void testTimedWait_IllegalMonitorException() {
190          //created a new thread with anonymous runnable          //created a new thread with anonymous runnable
191    
# Line 215  Line 216 
216      }      }
217    
218      /**      /**
219       *   timedWait will throw InterruptedException.       * timedWait throws InterruptedException when interrupted
      *  Thread t waits on timedWait while the main thread interrupts it.  
      *  Note:  This does not throw IllegalMonitorException since timeWait  
      *         is synchronized on o  
      */  
     /**  
      *  
220       */       */
221      public void testTimedWait() {      public void testTimedWait() {
222          Thread t = new Thread(new Runnable() {          Thread t = new Thread(new Runnable() {
# Line 253  Line 248 
248    
249    
250      /**      /**
251       *   timedJoin will throw InterruptedException.       * timedJoin throws InterruptedException when interrupted
      *  Thread t waits on timedJoin while the main thread interrupts it.  
      */  
     /**  
      *  
252       */       */
253      public void testTimedJoin() {      public void testTimedJoin() {
254          Thread t = new Thread(new Runnable() {          Thread t = new Thread(new Runnable() {
# Line 289  Line 280 
280      }      }
281    
282      /**      /**
283       *   timedSleep will throw InterruptedException.       *  timedSleep throws InterruptedException when interrupted
      *  Thread t waits on timedSleep while the main thread interrupts it.  
      */  
     /**  
      *  
284       */       */
285      public void testTimedSleep() {      public void testTimedSleep() {
286          //created a new thread with anonymous runnable          //created a new thread with anonymous runnable
# Line 319  Line 306 
306      }      }
307    
308      /**      /**
309       *       * a deserialized serialized unit is equal
310       */       */
311      public void testSerialization() {      public void testSerialization() {
312          TimeUnit q = TimeUnit.MILLISECONDS;          TimeUnit q = TimeUnit.MILLISECONDS;

Legend:
Removed from v.1.4  
changed lines
  Added in v.1.5

Doug Lea
ViewVC Help
Powered by ViewVC 1.0.8