Search in sources :

Example 6 with ValueRange

use of java.time.temporal.ValueRange in project jdk8u_jdk by JetBrains.

the class TestDateTimeValueRange method test_of_longlong.

//-----------------------------------------------------------------------
// of(long,long)
//-----------------------------------------------------------------------
public void test_of_longlong() {
    ValueRange test = ValueRange.of(1, 12);
    assertEquals(test.getMinimum(), 1);
    assertEquals(test.getLargestMinimum(), 1);
    assertEquals(test.getSmallestMaximum(), 12);
    assertEquals(test.getMaximum(), 12);
    assertEquals(test.isFixed(), true);
    assertEquals(test.isIntValue(), true);
}
Also used : ValueRange(java.time.temporal.ValueRange)

Example 7 with ValueRange

use of java.time.temporal.ValueRange in project jdk8u_jdk by JetBrains.

the class TestDateTimeValueRange method test_isValidValue_long_long.

public void test_isValidValue_long_long() {
    ValueRange test = ValueRange.of(1, 28, Integer.MAX_VALUE + 1L);
    assertEquals(test.isValidIntValue(0), false);
    assertEquals(test.isValidIntValue(1), false);
    assertEquals(test.isValidIntValue(31), false);
    assertEquals(test.isValidIntValue(32), false);
}
Also used : ValueRange(java.time.temporal.ValueRange)

Example 8 with ValueRange

use of java.time.temporal.ValueRange in project jdk8u_jdk by JetBrains.

the class TestDateTimeValueRange method test_equals_null.

public void test_equals_null() {
    ValueRange a = ValueRange.of(1, 12);
    assertEquals(a.equals(null), false);
}
Also used : ValueRange(java.time.temporal.ValueRange)

Example 9 with ValueRange

use of java.time.temporal.ValueRange in project jdk8u_jdk by JetBrains.

the class TCKJapaneseChronology method test_getDayOfYear.

//-----------------------------------------------------------------------
// JapaneseChronology.dateYearDay, getDayOfYear
//-----------------------------------------------------------------------
@Test
public void test_getDayOfYear() {
    // Test all the Eras
    for (JapaneseEra era : JapaneseEra.values()) {
        // Until Era supports range(YEAR_OF_ERA)
        int firstYear = (era == JapaneseEra.MEIJI) ? 6 : 1;
        JapaneseDate hd1 = JapaneseChronology.INSTANCE.dateYearDay(era, firstYear, 1);
        ValueRange range = hd1.range(DAY_OF_YEAR);
        assertEquals(range.getMaximum(), hd1.lengthOfYear(), "lengthOfYear should match range.getMaximum()");
        for (int i = 1; i <= hd1.lengthOfYear(); i++) {
            JapaneseDate hd = JapaneseChronology.INSTANCE.dateYearDay(era, firstYear, i);
            int doy = hd.get(DAY_OF_YEAR);
            assertEquals(doy, i, "get(DAY_OF_YEAR) incorrect for " + i + ", of date: " + hd);
        }
    }
}
Also used : ValueRange(java.time.temporal.ValueRange) JapaneseDate(java.time.chrono.JapaneseDate) JapaneseEra(java.time.chrono.JapaneseEra) Test(org.testng.annotations.Test)

Example 10 with ValueRange

use of java.time.temporal.ValueRange in project jdk8u_jdk by JetBrains.

the class TestUmmAlQuraChronology method Test_UmmAlQuraChronoRange.

// UmmAlQura chronology ranges for year, month and days for the HijrahChronology
@Test
public void Test_UmmAlQuraChronoRange() {
    HijrahChronology chrono = HijrahChronology.INSTANCE;
    ValueRange year = chrono.range(YEAR);
    assertEquals(year.getMinimum(), 1300, "Minimum year");
    assertEquals(year.getLargestMinimum(), 1300, "Largest minimum year");
    assertEquals(year.getMaximum(), 1600, "Largest year");
    assertEquals(year.getSmallestMaximum(), 1600, "Smallest Maximum year");
    ValueRange month = chrono.range(MONTH_OF_YEAR);
    assertEquals(month.getMinimum(), 1, "Minimum month");
    assertEquals(month.getLargestMinimum(), 1, "Largest minimum month");
    assertEquals(month.getMaximum(), 12, "Largest month");
    assertEquals(month.getSmallestMaximum(), 12, "Smallest Maximum month");
    ValueRange day = chrono.range(DAY_OF_MONTH);
    assertEquals(day.getMinimum(), 1, "Minimum day");
    assertEquals(day.getLargestMinimum(), 1, "Largest minimum day");
    assertEquals(day.getMaximum(), 30, "Largest day");
    assertEquals(day.getSmallestMaximum(), 29, "Smallest Maximum day");
}
Also used : ValueRange(java.time.temporal.ValueRange) HijrahChronology(java.time.chrono.HijrahChronology) Test(org.testng.annotations.Test)

Aggregations

ValueRange (java.time.temporal.ValueRange)28 Test (org.testng.annotations.Test)14 AbstractTest (test.java.time.AbstractTest)6 LocalDate (java.time.LocalDate)3 HijrahChronology (java.time.chrono.HijrahChronology)3 TemporalField (java.time.temporal.TemporalField)3 WeekFields (java.time.temporal.WeekFields)3 AbstractTCKTest (tck.java.time.AbstractTCKTest)3 DateTimeException (java.time.DateTimeException)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 ObjectOutputStream (java.io.ObjectOutputStream)1 ChronoLocalDate (java.time.chrono.ChronoLocalDate)1 HijrahDate (java.time.chrono.HijrahDate)1 JapaneseDate (java.time.chrono.JapaneseDate)1 JapaneseEra (java.time.chrono.JapaneseEra)1