use of java.time.Period in project jdk8u_jdk by JetBrains.
the class TCKPeriod method test_normalized_min.
@Test(expectedExceptions = ArithmeticException.class)
public void test_normalized_min() {
Period base = Period.of(Integer.MIN_VALUE, -12, 0);
base.normalized();
}
use of java.time.Period in project jdk8u_jdk by JetBrains.
the class TCKPeriod method factory_parse.
@Test(dataProvider = "parseSuccess")
public void factory_parse(String text, Period expected) {
Period p = Period.parse(text);
assertEquals(p, expected);
}
use of java.time.Period in project jdk8u_jdk by JetBrains.
the class TCKPeriod method factory_parse_minus.
@Test(dataProvider = "parseSuccess")
public void factory_parse_minus(String text, Period expected) {
Period p = null;
try {
p = Period.parse("-" + text);
} catch (DateTimeParseException ex) {
assertEquals(expected.getYears() == Integer.MIN_VALUE || expected.getMonths() == Integer.MIN_VALUE || expected.getDays() == Integer.MIN_VALUE, true);
return;
}
// not inside try/catch or it breaks test
assertEquals(p, expected.negated());
}
use of java.time.Period in project jdk8u_jdk by JetBrains.
the class TestPeriod method test_hashCode.
//-----------------------------------------------------------------------
// hashCode()
//-----------------------------------------------------------------------
@Test
public void test_hashCode() {
Period test5 = Period.ofDays(5);
Period test6 = Period.ofDays(6);
Period test5M = Period.ofMonths(5);
Period test5Y = Period.ofYears(5);
assertEquals(test5.hashCode() == test5.hashCode(), true);
assertEquals(test5.hashCode() == test6.hashCode(), false);
assertEquals(test5.hashCode() == test5M.hashCode(), false);
assertEquals(test5.hashCode() == test5Y.hashCode(), false);
}
use of java.time.Period in project jdk8u_jdk by JetBrains.
the class TCKPeriod method test_plusYears_overflowTooSmall.
@Test(expectedExceptions = ArithmeticException.class)
public void test_plusYears_overflowTooSmall() {
Period test = Period.ofYears(Integer.MIN_VALUE);
test.plusYears(-1);
}
Aggregations