1 /* 2 * Copyright (C) 2017 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 package libcore.java.time; 17 18 import org.junit.Test; 19 import java.time.Instant; 20 import java.time.temporal.ChronoUnit; 21 import java.time.temporal.TemporalUnit; 22 23 import static org.junit.Assert.assertEquals; 24 25 /** 26 * Additional tests for {@link Instant}. 27 * 28 * @see tck.java.time.TCKInstant 29 * @see test.java.time.TestInstant 30 */ 31 public class InstantTest { 32 33 @Test 34 public void test_isSupported_TemporalUnit() { 35 assertEquals(false, Instant.EPOCH.isSupported((TemporalUnit) null)); 36 assertEquals(true, Instant.EPOCH.isSupported(ChronoUnit.NANOS)); 37 assertEquals(true, Instant.EPOCH.isSupported(ChronoUnit.MICROS)); 38 assertEquals(true, Instant.EPOCH.isSupported(ChronoUnit.MILLIS)); 39 assertEquals(true, Instant.EPOCH.isSupported(ChronoUnit.SECONDS)); 40 assertEquals(true, Instant.EPOCH.isSupported(ChronoUnit.MINUTES)); 41 assertEquals(true, Instant.EPOCH.isSupported(ChronoUnit.HOURS)); 42 assertEquals(true, Instant.EPOCH.isSupported(ChronoUnit.HALF_DAYS)); 43 assertEquals(true, Instant.EPOCH.isSupported(ChronoUnit.DAYS)); 44 assertEquals(false, Instant.EPOCH.isSupported(ChronoUnit.WEEKS)); 45 assertEquals(false, Instant.EPOCH.isSupported(ChronoUnit.MONTHS)); 46 assertEquals(false, Instant.EPOCH.isSupported(ChronoUnit.YEARS)); 47 assertEquals(false, Instant.EPOCH.isSupported(ChronoUnit.DECADES)); 48 assertEquals(false, Instant.EPOCH.isSupported(ChronoUnit.CENTURIES)); 49 assertEquals(false, Instant.EPOCH.isSupported(ChronoUnit.MILLENNIA)); 50 assertEquals(false, Instant.EPOCH.isSupported(ChronoUnit.ERAS)); 51 assertEquals(false, Instant.EPOCH.isSupported(ChronoUnit.FOREVER)); 52 } 53 } 54