Search in sources :

Example 26 with ValueRange

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

the class TestDateTimeValueRange method test_checkValidValueInvalid_long_long.

@Test(expectedExceptions = DateTimeException.class)
public void test_checkValidValueInvalid_long_long() {
    ValueRange test = ValueRange.of(1, 28, Integer.MAX_VALUE + 1L);
    test.checkValidIntValue(Integer.MAX_VALUE + 2L, (ChronoField) null);
}
Also used : ValueRange(java.time.temporal.ValueRange) AbstractTest(test.java.time.AbstractTest) Test(org.testng.annotations.Test)

Example 27 with ValueRange

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

the class TCKValueRangeSerialization method test_serialization.

//-----------------------------------------------------------------------
// Serialization
//-----------------------------------------------------------------------
public void test_serialization() throws Exception {
    ValueRange range = ValueRange.of(1, 2, 3, 4);
    assertSerializable(range);
}
Also used : ValueRange(java.time.temporal.ValueRange)

Example 28 with ValueRange

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

the class TestUmmAlQuraChronology method test_hijrahDateLimits.

// Check the date limits
@Test
public void test_hijrahDateLimits() {
    HijrahChronology chrono = HijrahChronology.INSTANCE;
    ValueRange yearRange = chrono.range(YEAR);
    ValueRange monthRange = chrono.range(MONTH_OF_YEAR);
    ValueRange dayRange = chrono.range(DAY_OF_MONTH);
    HijrahDate xx = chrono.date(1434, 1, 1);
    HijrahDate minDate = chrono.date((int) yearRange.getLargestMinimum(), (int) monthRange.getMinimum(), (int) dayRange.getMinimum());
    try {
        HijrahDate before = minDate.minus(1, ChronoUnit.DAYS);
        fail("Exception did not occur, minDate: " + minDate + ".minus(1, DAYS) = " + before);
    } catch (DateTimeException ex) {
    // ignore, this exception was expected
    }
    HijrahDate maxDate = chrono.date((int) yearRange.getSmallestMaximum(), (int) monthRange.getMaximum(), 1);
    int monthLen = maxDate.lengthOfMonth();
    maxDate = maxDate.with(DAY_OF_MONTH, monthLen);
    try {
        HijrahDate after = maxDate.plus(1, ChronoUnit.DAYS);
        fail("Exception did not occur, maxDate: " + maxDate + ".plus(1, DAYS) = " + after);
    } catch (DateTimeException ex) {
    // ignore, this exception was expected
    }
}
Also used : ValueRange(java.time.temporal.ValueRange) HijrahDate(java.time.chrono.HijrahDate) DateTimeException(java.time.DateTimeException) 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