use of java.time.Period in project j2objc by google.
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 j2objc by google.
the class TCKPeriod method factory_parse.
@Test()
@UseDataProvider("data_factory_parseSuccess")
public void factory_parse(String text, Period expected) {
Period p = Period.parse(text);
assertEquals(p, expected);
}
use of java.time.Period in project j2objc by google.
the class TCKPeriod method factory_parse_minus.
@Test()
@UseDataProvider("data_factory_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 j2objc by google.
the class TCKPeriod method test_plusYears_overflowTooSmall.
@Test(expected = ArithmeticException.class)
public void test_plusYears_overflowTooSmall() {
Period test = Period.ofYears(Integer.MIN_VALUE);
test.plusYears(-1);
}
use of java.time.Period in project j2objc by google.
the class TCKPeriod method test_minusYears_overflowTooBig.
@Test(expected = ArithmeticException.class)
public void test_minusYears_overflowTooBig() {
Period test = Period.ofYears(Integer.MAX_VALUE);
test.minusYears(-1);
}
Aggregations