[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.25, Sat Apr 25 04:55:31 2015 UTC revision 1.26, Fri Jan 29 20:02:39 2016 UTC
# Line 14  Line 14 
14  import static java.util.concurrent.TimeUnit.NANOSECONDS;  import static java.util.concurrent.TimeUnit.NANOSECONDS;
15  import static java.util.concurrent.TimeUnit.SECONDS;  import static java.util.concurrent.TimeUnit.SECONDS;
16    
17    import java.time.temporal.ChronoUnit;
18  import java.util.concurrent.CountDownLatch;  import java.util.concurrent.CountDownLatch;
19  import java.util.concurrent.TimeUnit;  import java.util.concurrent.TimeUnit;
20    
# Line 433  Line 434 
434          assertSame(x, serialClone(x));          assertSame(x, serialClone(x));
435      }      }
436    
437        /**
438         * tests for toChronoUnit.
439         */
440        public void testToChronoUnit() throws Exception {
441            assertSame(ChronoUnit.NANOS,   NANOSECONDS.toChronoUnit());
442            assertSame(ChronoUnit.MICROS,  MICROSECONDS.toChronoUnit());
443            assertSame(ChronoUnit.MILLIS,  MILLISECONDS.toChronoUnit());
444            assertSame(ChronoUnit.SECONDS, SECONDS.toChronoUnit());
445            assertSame(ChronoUnit.MINUTES, MINUTES.toChronoUnit());
446            assertSame(ChronoUnit.HOURS,   HOURS.toChronoUnit());
447            assertSame(ChronoUnit.DAYS,    DAYS.toChronoUnit());
448    
449            // Every TimeUnit has a defined ChronoUnit equivalent
450            for (TimeUnit x : TimeUnit.values())
451                assertSame(x, TimeUnit.of(x.toChronoUnit()));
452        }
453    
454        /**
455         * tests for TimeUnit.of(ChronoUnit).
456         */
457        public void testTimeUnitOf() throws Exception {
458            assertSame(NANOSECONDS,  TimeUnit.of(ChronoUnit.NANOS));
459            assertSame(MICROSECONDS, TimeUnit.of(ChronoUnit.MICROS));
460            assertSame(MILLISECONDS, TimeUnit.of(ChronoUnit.MILLIS));
461            assertSame(SECONDS,      TimeUnit.of(ChronoUnit.SECONDS));
462            assertSame(MINUTES,      TimeUnit.of(ChronoUnit.MINUTES));
463            assertSame(HOURS,        TimeUnit.of(ChronoUnit.HOURS));
464            assertSame(DAYS,         TimeUnit.of(ChronoUnit.DAYS));
465    
466            assertThrows(NullPointerException.class,
467                         () -> TimeUnit.of((ChronoUnit)null));
468    
469            // ChronoUnits either round trip to their TimeUnit
470            // equivalents, or throw IllegalArgumentException.
471            for (ChronoUnit cu : ChronoUnit.values()) {
472                final TimeUnit tu;
473                try {
474                    tu = TimeUnit.of(cu);
475                } catch (IllegalArgumentException acceptable) {
476                    continue;
477                }
478                assertSame(cu, tu.toChronoUnit());
479            }
480        }
481    
482  }  }

Legend:
Removed from v.1.25  
changed lines
  Added in v.1.26

Doug Lea
ViewVC Help
Powered by ViewVC 1.0.8