[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.14, Sat Nov 21 02:07:27 2009 UTC revision 1.20, Fri May 27 19:12:09 2011 UTC
# Line 1  Line 1 
1  /*  /*
2   * Written by Doug Lea with assistance from members of JCP JSR-166   * Written by Doug Lea with assistance from members of JCP JSR-166
3   * Expert Group and released to the public domain, as explained at   * Expert Group and released to the public domain, as explained at
4   * http://creativecommons.org/licenses/publicdomain   * http://creativecommons.org/publicdomain/zero/1.0/
5   * Other contributors include Andrew Wright, Jeffrey Hayes,   * Other contributors include Andrew Wright, Jeffrey Hayes,
6   * Pat Fisher, Mike Judd.   * Pat Fisher, Mike Judd.
7   */   */
8    
   
9  import junit.framework.*;  import junit.framework.*;
10  import java.util.concurrent.*;  import java.util.concurrent.*;
11  import java.io.*;  import java.io.*;
# Line 49  Line 48 
48                           TimeUnit.SECONDS.convert(1000000000L*t,                           TimeUnit.SECONDS.convert(1000000000L*t,
49                                                    TimeUnit.NANOSECONDS));                                                    TimeUnit.NANOSECONDS));
50    
   
51              assertEquals(1000L*t*60*60*24,              assertEquals(1000L*t*60*60*24,
52                           TimeUnit.MILLISECONDS.convert(t,                           TimeUnit.MILLISECONDS.convert(t,
53                                                    TimeUnit.DAYS));                                                    TimeUnit.DAYS));
# Line 279  Line 277 
277          }          }
278      }      }
279    
   
280      /**      /**
281       * convert saturates positive too-large values to Long.MAX_VALUE       * convert saturates positive too-large values to Long.MAX_VALUE
282       * and negative to LONG.MIN_VALUE       * and negative to LONG.MIN_VALUE
# Line 309  Line 306 
306          assertEquals(Long.MIN_VALUE,          assertEquals(Long.MIN_VALUE,
307                       TimeUnit.NANOSECONDS.convert(-Long.MAX_VALUE / 4,                       TimeUnit.NANOSECONDS.convert(-Long.MAX_VALUE / 4,
308                                                    TimeUnit.DAYS));                                                    TimeUnit.DAYS));
   
309      }      }
310    
311      /**      /**
# Line 323  Line 319 
319                       TimeUnit.MILLISECONDS.toNanos(-Long.MAX_VALUE / 3));                       TimeUnit.MILLISECONDS.toNanos(-Long.MAX_VALUE / 3));
320      }      }
321    
   
322      /**      /**
323       * toString returns string containing common name of unit       * toString returns name of unit
324       */       */
325      public void testToString() {      public void testToString() {
326          String s = TimeUnit.SECONDS.toString();          assertEquals("SECONDS", TimeUnit.SECONDS.toString());
         assertTrue(s.indexOf("ECOND") >= 0);  
327      }      }
328    
329        /**
330         * name returns name of unit
331         */
332        public void testName() {
333            assertEquals("SECONDS", TimeUnit.SECONDS.name());
334        }
335    
336      /**      /**
337       *  Timed wait without holding lock throws       *  Timed wait without holding lock throws
# Line 372  Line 372 
372          t.join();          t.join();
373      }      }
374    
   
375      /**      /**
376       * timedJoin throws InterruptedException when interrupted       * timedJoin throws InterruptedException when interrupted
377       */       */
# Line 385  Line 384 
384              public void realRun() throws InterruptedException {              public void realRun() throws InterruptedException {
385                  TimeUnit tu = TimeUnit.MILLISECONDS;                  TimeUnit tu = TimeUnit.MILLISECONDS;
386                  tu.timedJoin(s, MEDIUM_DELAY_MS);                  tu.timedJoin(s, MEDIUM_DELAY_MS);
387              }});;              }});
388          s.start();          s.start();
389          t.start();          t.start();
390          Thread.sleep(SHORT_DELAY_MS);          Thread.sleep(SHORT_DELAY_MS);

Legend:
Removed from v.1.14  
changed lines
  Added in v.1.20

Doug Lea
ViewVC Help
Powered by ViewVC 1.0.8