Example #1
0
 /** Two objects that are equal are required to return the same hashCode. */
 @Test
 public void testHashcode() {
   Millisecond m1 = new Millisecond(599, 23, 45, 7, 9, 10, 2007);
   Millisecond m2 = new Millisecond(599, 23, 45, 7, 9, 10, 2007);
   assertTrue(m1.equals(m2));
   int hash1 = m1.hashCode();
   int hash2 = m2.hashCode();
   assertEquals(hash1, hash2);
 }
Example #2
0
 /** Tests the equals method. */
 @Test
 public void testEquals() {
   Day day1 = new Day(29, MonthConstants.MARCH, 2002);
   Hour hour1 = new Hour(15, day1);
   Minute minute1 = new Minute(15, hour1);
   Second second1 = new Second(34, minute1);
   Millisecond milli1 = new Millisecond(999, second1);
   Day day2 = new Day(29, MonthConstants.MARCH, 2002);
   Hour hour2 = new Hour(15, day2);
   Minute minute2 = new Minute(15, hour2);
   Second second2 = new Second(34, minute2);
   Millisecond milli2 = new Millisecond(999, second2);
   assertTrue(milli1.equals(milli2));
 }
Example #3
0
 /**
  * Check that a {@link Millisecond} instance is equal to itself.
  *
  * <p>SourceForge Bug ID: 558850.
  */
 @Test
 public void testEqualsSelf() {
   Millisecond millisecond = new Millisecond();
   assertTrue(millisecond.equals(millisecond));
 }